From 45afd4117ac23663f7037a34f4e4ac674126fdce Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Mon, 3 Apr 2017 23:52:18 +0200 Subject: [PATCH 01/13] Fix render tests for Browsers --- render/tests/index.html | 2 +- render/tests/test-onbeforeremove.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/render/tests/index.html b/render/tests/index.html index b978ae6f..eda51921 100644 --- a/render/tests/index.html +++ b/render/tests/index.html @@ -8,7 +8,7 @@ - + diff --git a/render/tests/test-onbeforeremove.js b/render/tests/test-onbeforeremove.js index 2e23215b..0e83d4a0 100644 --- a/render/tests/test-onbeforeremove.js +++ b/render/tests/test-onbeforeremove.js @@ -199,9 +199,8 @@ o.spec("onbeforeremove", function() { render(root, [{tag: component}]) render(root, []) + o(onremove.callCount).equals(0) callAsync(function(){ - o(onremove.callCount).equals(0) - callAsync(function() { o(onremove.callCount).equals(1) done() From 98e3cbdc696ee038a13f4cfc9240de0e9de52e24 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Tue, 4 Apr 2017 12:20:14 +0200 Subject: [PATCH 02/13] Revert attrs.class creation logic to what we had in v1.0.1. fix #1764 --- render/hyperscript.js | 4 +- render/tests/test-hyperscript.js | 102 +++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/render/hyperscript.js b/render/hyperscript.js index ece288fc..3d4b21e4 100644 --- a/render/hyperscript.js +++ b/render/hyperscript.js @@ -34,8 +34,8 @@ function execSelector(state, attrs, children) { } } - if (className != null) { - if (attrs.class != null) { + if (className !== undefined) { + if (attrs.class !== undefined) { attrs.class = undefined attrs.className = className } diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index cf0b3155..3ef03358 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -16,6 +16,108 @@ o.spec("hyperscript", function() { o(vnode.tag).equals("a") }) + o("v1.0.1 bug-for-bug regression suite", function(){ + o + console.log(m('a', { + class: null + }).attrs, { + class: undefined, + className: null + }) + o(m('a', { + class: null + }).attrs).deepEquals({ + class: undefined, + className: null + }) + o(m('a', { + class: undefined + }).attrs).deepEquals({ + class: undefined, + }) + o(m('a', { + class: false + }).attrs).deepEquals({ + class: undefined, + className: false + }) + o(m('a', { + class: true + }).attrs).deepEquals({ + class: undefined, + className: true + }) + console.log(m('a.x', { + class: null + }).attrs, { + class: undefined, + className: "x null" + }) + o(m('a.x', { + class: null + }).attrs).deepEquals({ + class: undefined, + className: "x null" + }) + o(m('a.x', { + class: undefined + }).attrs).deepEquals({ + class: undefined, + className: "x" + }) + o(m('a.x', { + class: false + }).attrs).deepEquals({ + class: undefined, + className: "x false" + }) + o(m('a.x', { + class: true + }).attrs).deepEquals({ + class: undefined, + className: "x true" + }) + o(m('a', { + className: null + }).attrs).deepEquals({ + className: null + }) + o(m('a', { + className: undefined + }).attrs).deepEquals({ + className: undefined + }) + o(m('a', { + className: false + }).attrs).deepEquals({ + className: false + }) + o(m('a', { + className: true + }).attrs).deepEquals({ + className: true + }) + o(m('a.x', { + className: null + }).attrs).deepEquals({ + className: "x" + }) + o(m('a.x', { + className: undefined + }).attrs).deepEquals({ + className: "x" + }) + o(m('a.x', { + className: false + }).attrs).deepEquals({ + className: "x" + }) + o(m('a.x', { + className: true + }).attrs).deepEquals({ + className: "x true" + }) + }) o("handles class in selector", function() { var vnode = m(".a") From 0b5f05f4ae1ffa15f71337fb62b9aaf49a34de9f Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Tue, 4 Apr 2017 10:28:10 +0000 Subject: [PATCH 03/13] Bundled output for commit d60e7ab30c8440efe9fa3f564a410f317d425e86 [skip ci] --- mithril.js | 4 ++-- mithril.min.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mithril.js b/mithril.js index bc3045c8..1c1495d4 100644 --- a/mithril.js +++ b/mithril.js @@ -42,8 +42,8 @@ function execSelector(state, attrs, children) { attrs[key] = state.attrs[key] } } - if (className != null) { - if (attrs.class != null) { + if (className !== undefined) { + if (attrs.class !== undefined) { attrs.class = undefined attrs.className = className } diff --git a/mithril.min.js b/mithril.min.js index 58d33dde..35332cf2 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,8 +1,8 @@ (function(){function B(b,d,f,g,e,n){return{tag:b,key:d,attrs:f,children:g,text:e,dom:n,domSize:void 0,state:void 0,_state:void 0,events:void 0,instance:void 0,skip:!1}}function C(b){var d=arguments[1],f=2,g;if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b){var e;if(!(e=M[b])){g="div";for(var n=[],k={};e=P.exec(b);){var q=e[1],m=e[2];""===q&&""!==m?g=m:"#"===q?k.id=m:"."===q? n.push(m):"["===e[3][0]&&((q=e[6])&&(q=q.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===e[4]?n.push(q):k[e[4]]=q||!0)}0 Date: Tue, 4 Apr 2017 12:35:34 +0200 Subject: [PATCH 04/13] Fix change log --- docs/change-log.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/change-log.md b/docs/change-log.md index 2d3b03fe..042b8008 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -13,7 +13,7 @@ #### Bug fixes - hyperscript: Allow `0` as the second argument to `m()` - [#1752](https://github.com/lhorie/mithril.js/issues/#1752) / [#1753](https://github.com/lhorie/mithril.js/pull/#1753) ([@StephanHoyer](https://github.com/StephanHoyer)) -- hyperscript: remove `attrs.class` after normalizing to `attrs.className` - [#1764](https://github.com/lhorie/mithril.js/issues/#1764) / [#1769](https://github.com/lhorie/mithril.js/pull/#1769) +- hyperscript: restore `attrs.class` handling to what it was in v1.0.1 - [#1764](https://github.com/lhorie/mithril.js/issues/#1764) / [#1769](https://github.com/lhorie/mithril.js/pull/#1769) - documentation improvements ([@JAForbes](https://github.com/JAForbes), [@smuemd](https://github.com/smuemd), [@hankeypancake](https://github.com/hankeypancake)) ### v1.1.0 From 5c616c0fbbfb4dc520162f056730397fcdfd457b Mon Sep 17 00:00:00 2001 From: ludbek Date: Wed, 5 Apr 2017 22:01:21 +0545 Subject: [PATCH 05/13] removed console.log --- render/tests/test-hyperscript.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index 3ef03358..641eea2e 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -17,13 +17,6 @@ o.spec("hyperscript", function() { o(vnode.tag).equals("a") }) o("v1.0.1 bug-for-bug regression suite", function(){ - o - console.log(m('a', { - class: null - }).attrs, { - class: undefined, - className: null - }) o(m('a', { class: null }).attrs).deepEquals({ @@ -47,12 +40,6 @@ o.spec("hyperscript", function() { class: undefined, className: true }) - console.log(m('a.x', { - class: null - }).attrs, { - class: undefined, - className: "x null" - }) o(m('a.x', { class: null }).attrs).deepEquals({ From 6d23e0913c53e9ab549a66efd1f73f2862877f10 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 6 Apr 2017 20:41:55 +0000 Subject: [PATCH 06/13] docs: try to improve releasing docs --- docs/releasing.md | 77 ++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/docs/releasing.md b/docs/releasing.md index 12ceb19b..7a9cbe3c 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,49 +1,56 @@ -# Releasing +# Mithril Release Processes -## Publishing to NPM +## Releasing a new Mithril version -Releasing new builds of mithril to NPM is mostly automated via `npm run release` +### Prepare the release -1. Update information in `docs/change-log.md` to match reality & the new version that will be released -2. `npm run release ` +1. Determine patch level of the change +2. Update information in `docs/change-log.md` to match reality & the new version that will be released -All further steps are automated and run as follows: +### Merge from `next` to `master` -3. New bundles are generated using updated version -4. Tests are run -5. Linting is run (but doesn't fail build) -6. Version number in package.json is incremented -7. `git add` called on bundle output -8. `package.json` and updated bundles are committed to git -9. previous commit is tagged using new version number -10. `git push --follow-tags` pushes up new version commit & tag to github -11. Travis sees new release, starts build -12. Travis generates new bundles before running tests -13. Travis runs tests -14. Travis lints files (but can't fail build) -15. If build fails, abort -16. Build succeeded, so travis will commit back any changes to the repo (but there won't be any) -17. Travis sees that this commit has a tag associated with it -18. Travis will use the encrypted npm creds in `.travis.yml` to publish a new version to npm +3. Switch to `master` and merge `next` on top of it -## Publishing a GitHub release +```bash +$ git co master +$ git merge next +``` -Happens automatically as part of the [Publishing to NPM](#publishing-to-npm) process described above. +4. Clean & update npm dependencies and ensure the tests are passing. -Does require a manual description to be added though, as the auto-generated one isn't very interesting. I suggest coming up with a fun title & then copying the `docs/change-log.md` entry for the build. +```bash +$ npm prune +$ npm i +$ npm test +``` -## Updating `docs/change-log.md` +### Publish the release -This is still a manual process, I'm sorry. +5. `npm run release `, see the docs for [`npm version`](https://docs.npmjs.com/cli/version) +6. Travis will push the new release to npm & create a GitHub release -## Updating docs (outside of a new version) +### Update the GitHub release + +7. The GitHub Release will require a manual description & title to be added. I suggest coming up with a fun title & then copying the `docs/change-log.md` entry for the build. + +## Updating mithril.js.org Fixes to documentation can land whenever, updates to the site are published via Travis. -1. `git co next` -2. `git pull lhorie next` -3. `git co master` -4. `git co next -- ./docs` -5. Ensure that no new features are added -6. `git push lhorie` -7. After the Travis build completes new docs should appear in ~3 minutes +```bash +# These steps assume that lhorie/mithril.js is a git remote named "lhorie" + +# Ensure your next branch is up to date +$ git co next +$ git pull lhorie next + +# Splat the docs folder from next onto master +$ git co master +$ git co next -- ./docs + +# Manually ensure that no new feature docs were added + +$ git push lhorie +``` + +After the Travis build completes the updated docs should appear on https://mithril.js.org in a few minutes. From 9a54b12702cde040a3dc445be17a3be33f2b3364 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 6 Apr 2017 21:01:52 +0000 Subject: [PATCH 07/13] docs: fix some links --- docs/change-log.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index 042b8008..9c493aa4 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -12,8 +12,8 @@ #### Bug fixes -- hyperscript: Allow `0` as the second argument to `m()` - [#1752](https://github.com/lhorie/mithril.js/issues/#1752) / [#1753](https://github.com/lhorie/mithril.js/pull/#1753) ([@StephanHoyer](https://github.com/StephanHoyer)) -- hyperscript: restore `attrs.class` handling to what it was in v1.0.1 - [#1764](https://github.com/lhorie/mithril.js/issues/#1764) / [#1769](https://github.com/lhorie/mithril.js/pull/#1769) +- hyperscript: Allow `0` as the second argument to `m()` - [#1752](https://github.com/lhorie/mithril.js/issues/1752) / [#1753](https://github.com/lhorie/mithril.js/pull/1753) ([@StephanHoyer](https://github.com/StephanHoyer)) +- hyperscript: restore `attrs.class` handling to what it was in v1.0.1 - [#1764](https://github.com/lhorie/mithril.js/issues/1764) / [#1769](https://github.com/lhorie/mithril.js/pull/1769) - documentation improvements ([@JAForbes](https://github.com/JAForbes), [@smuemd](https://github.com/smuemd), [@hankeypancake](https://github.com/hankeypancake)) ### v1.1.0 From 34d6a710a9c343797f0e004c4e2db8dd00ab8a74 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Fri, 7 Apr 2017 12:56:31 -0700 Subject: [PATCH 08/13] style: fix quotes (#1787) --- render/tests/test-hyperscript.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/render/tests/test-hyperscript.js b/render/tests/test-hyperscript.js index 641eea2e..4f6c4548 100644 --- a/render/tests/test-hyperscript.js +++ b/render/tests/test-hyperscript.js @@ -17,89 +17,89 @@ o.spec("hyperscript", function() { o(vnode.tag).equals("a") }) o("v1.0.1 bug-for-bug regression suite", function(){ - o(m('a', { + o(m("a", { class: null }).attrs).deepEquals({ class: undefined, className: null }) - o(m('a', { + o(m("a", { class: undefined }).attrs).deepEquals({ class: undefined, }) - o(m('a', { + o(m("a", { class: false }).attrs).deepEquals({ class: undefined, className: false }) - o(m('a', { + o(m("a", { class: true }).attrs).deepEquals({ class: undefined, className: true }) - o(m('a.x', { + o(m("a.x", { class: null }).attrs).deepEquals({ class: undefined, className: "x null" }) - o(m('a.x', { + o(m("a.x", { class: undefined }).attrs).deepEquals({ class: undefined, className: "x" }) - o(m('a.x', { + o(m("a.x", { class: false }).attrs).deepEquals({ class: undefined, className: "x false" }) - o(m('a.x', { + o(m("a.x", { class: true }).attrs).deepEquals({ class: undefined, className: "x true" }) - o(m('a', { + o(m("a", { className: null }).attrs).deepEquals({ className: null }) - o(m('a', { + o(m("a", { className: undefined }).attrs).deepEquals({ className: undefined }) - o(m('a', { + o(m("a", { className: false }).attrs).deepEquals({ className: false }) - o(m('a', { + o(m("a", { className: true }).attrs).deepEquals({ className: true }) - o(m('a.x', { + o(m("a.x", { className: null }).attrs).deepEquals({ className: "x" }) - o(m('a.x', { + o(m("a.x", { className: undefined }).attrs).deepEquals({ className: "x" }) - o(m('a.x', { + o(m("a.x", { className: false }).attrs).deepEquals({ className: "x" }) - o(m('a.x', { + o(m("a.x", { className: true }).attrs).deepEquals({ className: "x true" From 96fb9a5bbd8fe18c75cfbdd787013d9cf684a430 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Mon, 10 Apr 2017 23:31:44 -0700 Subject: [PATCH 09/13] docs: add examples for tutorial --- docs/index.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/index.md b/docs/index.md index 86aca2cc..504dd2b1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -85,6 +85,11 @@ m.render(root, "My first app") As you can see, you use the same code to both create and update HTML. Mithril automatically figures out the most efficient way of updating the text, rather than blindly recreating it from scratch. +#### Live Example + +

See the Pen Mithril Hello World by Pat Cavit (@tivac) on CodePen.

+ + --- ### DOM elements @@ -119,6 +124,11 @@ m("main", [ ]) ``` +#### Live Example + +

See the Pen Simple Mithril Example by Pat Cavit (@tivac) on CodePen.

+ + Note: If you prefer `` syntax, [it's possible to use it via a Babel plugin](jsx.md). ```jsx @@ -185,6 +195,11 @@ You can now update the label of the button by clicking the button. Since we used If you're wondering about performance, it turns out Mithril is very fast at rendering updates, because it only touches the parts of the DOM it absolutely needs to. So in our example above, when you click the button, the text in it is the only part of the DOM Mithril actually updates. +#### Live Example + +

See the Pen Mithril Component Example by Pat Cavit (@tivac) on CodePen.

+ + --- ### Routing @@ -218,6 +233,11 @@ The `"/splash"` right after `root` means that's the default route, i.e. if the h Also, as you would expect, clicking on the link on the splash page takes you to the click counter screen we created earlier. Notice that now your URL will point to `http://localhost/#!/hello`. You can navigate back and forth to the splash page using the browser's back and next button. +#### Live Example + +

See the Pen Mithril Routing Example by Pat Cavit (@tivac) on CodePen.

+ + --- ### XHR @@ -260,6 +280,11 @@ var Hello = { Clicking the button should now update the count. +#### Live Example + +

See the Pen Mithril XHR Example by Pat Cavit (@tivac) on CodePen.

+ + --- We covered how to create and update HTML, how to create components, routes for a Single Page Application, and interacted with a server via XHR. From 451cf00951ca268e9bedfbe733482d5f59971d61 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Mon, 10 Apr 2017 23:31:56 -0700 Subject: [PATCH 10/13] docs: add incrementing value to repeated anchors --- docs/generate.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/generate.js b/docs/generate.js index 52bc3e70..4bc76499 100644 --- a/docs/generate.js +++ b/docs/generate.js @@ -27,6 +27,7 @@ function generate(pathname) { if (pathname.match(/\.md$/)) { var outputFilename = pathname.replace(/\.md$/, ".html") var markdown = fs.readFileSync(pathname, "utf-8") + var anchors = {} var fixed = markdown .replace(/`((?:\S| -> |, )+)(\|)(\S+)`/gim, function(match, a, b, c) { // fix pipes in code tags return "" + (a + b + c).replace(/\|/g, "|") + "" @@ -53,6 +54,12 @@ function generate(pathname) { .replace(/(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors var anchor = text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-"); + if(anchor in anchors) { + anchor += ++anchors[anchor] + } else { + anchors[anchor] = 0; + } + return `${text}`; }) fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8") From 4cfd0c4070eaf97bc31bdf9435f3f1598a1f6e1a Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Mon, 10 Apr 2017 23:43:10 -0700 Subject: [PATCH 11/13] docs: load mithril on mithril.js.org For futzing around in the dev console --- docs/generate.js | 2 +- docs/index.md | 2 ++ docs/layout.html | 5 +++-- package.json | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/generate.js b/docs/generate.js index 52bc3e70..4a6e8b54 100644 --- a/docs/generate.js +++ b/docs/generate.js @@ -48,7 +48,7 @@ function generate(pathname) { var title = fixed.match(/^#([^\n\r]+)/i) || [] var html = layout .replace(/Mithril\.js<\/title>/, "<title>" + title[1] + " - Mithril.js") - .replace(/\[version\]/, version) // update version + .replace(/\[version\]/g, version) // update version .replace(/\[body\]/, markedHtml) .replace(/(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors var anchor = text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-"); diff --git a/docs/index.md b/docs/index.md index 86aca2cc..5a634a3e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -65,6 +65,8 @@ Let's create an HTML file to follow along: ``` +Mithril is also loaded onto this page already, so you can start poking at the `m` object in the developer console right away if you'd like! + --- ### Hello world diff --git a/docs/layout.html b/docs/layout.html index f5ce0231..02e07a0b 100644 --- a/docs/layout.html +++ b/docs/layout.html @@ -26,8 +26,9 @@ License: MIT. © Leo Horie. - - + + + + --- ### Hello world From b718ae6f32d87c421f85217f5f57b5a089d99588 Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Tue, 11 Apr 2017 08:28:58 +0000 Subject: [PATCH 13/13] Bundled output for commit d01e8d458e4c2ce91fcd61350276f0eb4f8ef0ab [skip ci] --- mithril.js | 2 +- mithril.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mithril.js b/mithril.js index 1c1495d4..1b1a7b0a 100644 --- a/mithril.js +++ b/mithril.js @@ -1220,7 +1220,7 @@ m.request = requestService.request m.jsonp = requestService.jsonp m.parseQueryString = parseQueryString m.buildQueryString = buildQueryString -m.version = "1.0.1" +m.version = "1.1.1" m.vnode = Vnode if (typeof module !== "undefined") module["exports"] = m else window.m = m diff --git a/mithril.min.js b/mithril.min.js index 35332cf2..1a5bb54a 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -40,4 +40,4 @@ d("hash");default:return d("pathname").slice(q.prefix.length)+d("search")+d("has e={},f=g(a,e,e),l=b.history.state;if(null!=l)for(var m in l)e[m]=l[m];for(var u in d)if(l=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(f)){f.replace(l,function(){for(var b=u.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,1,-2),f=0;f