Drop m.version (#2466)

* Drop `m.version`

It's caused way too much grief over the years, and I've finally decided
it's worth pitching. For those who need it, it's easy to get, especially
if you use it through Node or a build system. And for those who are just
loading it globally, you have to explicitly specify the version anyways,
so you'd be just as golden if you followed it up with a simple inline
script that does `m.version = "the version you loaded"`.

Oh, and also, you shouldn't be coding specifically for version numbers,
either - it's a known anti-pattern. Instead, you should prefer feature
detection and just do the right thing.

* Update changelog [skip ci]
This commit is contained in:
Isiah Meadows 2019-07-10 14:04:44 -04:00 committed by GitHub
parent 02a91356c0
commit 904b63b2aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2 additions and 47 deletions

View file

@ -60,6 +60,7 @@
- redraw: `mithril/redraw` now just exposes the `m.redraw` callback ([#2458](https://github.com/MithrilJS/mithril.js/pull/2458) [@isiahmeadows](https://github.com/isiahmeadows))
- The `.schedule`, `.unschedule`, and `.render` properties of the former `redrawService` are all removed.
- If you want to know how to work around it, look at the call to `mount` in Mithril's source for `m.route`. That should help you in finding ways around the removed feature. (It doesn't take that much more code.)
- api: `m.version` has been removed. If you really need the version for whatever reason, just read the `version` field of `mithril/package.json` directly. ([#2466](https://github.com/MithrilJS/mithril.js/pull/2466) [@isiahmeadows](https://github.com/isiahmeadows))
#### News

View file

@ -12,7 +12,6 @@
- [m.trust](trust.md)
- [m.fragment](fragment.md)
- [m.redraw](redraw.md)
- [m.version](version.md)
- [Promise](promise.md)
- Optional
- [Stream](stream.md)

View file

@ -1,27 +0,0 @@
# version
- [Signature](#signature)
- [How it works](#how-it-works)
---
### Signature
`m.version`
Argument | Type | Required | Description
----------- | -------------------- | -------- | ---
**returns** | String | | Returns the version number
---
### How it works
The `m.version` property is a string containing the [semver](http://semver.org/) value for the current release.
Semver (or Semantic Versioning) specifies that a version number must follow the syntax "0.0.0", where the first number is the MAJOR number, the second is the MINOR number and the third is the PATCH number.
- The MAJOR number changes when there are backwards-incompatible API changes,
- The MINOR number changes when functionality is added in a backwards-compatible manner, and
- The PATCH number changes when there are backwards-compatible bug fixes

View file

@ -18,7 +18,6 @@ m.parseQueryString = require("./querystring/parse")
m.buildQueryString = require("./querystring/build")
m.parsePathname = require("./pathname/parse")
m.buildPathname = require("./pathname/build")
m.version = "2.0.0-rc.7"
m.vnode = require("./render/vnode")
m.PromisePolyfill = require("./promise/polyfill")

View file

@ -22,7 +22,7 @@
"cover": "istanbul cover --print both ospec/bin/ospec",
"release": "npm version -m 'v%s'",
"preversion": "npm run test",
"version": "node scripts/update-version && npm run build && git add index.js mithril.js mithril.min.js",
"version": "npm run build && git add index.js mithril.js mithril.min.js",
"postversion": "git push --follow-tags"
},
"devDependencies": {

View file

@ -1,10 +0,0 @@
"use strict"
const fs = require("fs")
const version = require("../package.json").version
const index = require.resolve("../index")
fs.writeFile(index,
fs.readFile(index, "utf-8")
.replace(/(version\s*=\s*)(['"]).*?\2/, `$1$2${version}$2`)
)

View file

@ -24,13 +24,6 @@ o.spec("api", function() {
o(vnode.tag).equals("div")
})
})
o.spec("m.version", function() {
o("works", function() {
o(typeof m.version).equals("string")
o(m.version.indexOf(".") > -1).equals(true)
o((/\d/).test(m.version)).equals(true)
})
})
o.spec("m.trust", function() {
o("works", function() {
var vnode = m.trust("<br>")