From b14ca82c2ead1dac7d50ff472d254d6d430c62ca Mon Sep 17 00:00:00 2001 From: Dmitri Zaitsev Date: Sat, 31 Dec 2016 03:32:57 +0000 Subject: [PATCH 01/14] Recommend 'budo' for the quickest start ever Fewer steps to get a complete app running in the browser with live reload. --- docs/installation.md | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 98e6a9ef..24135b10 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -12,7 +12,34 @@ If you're new to Javascript or just want a very simple setup to get your feet we ### NPM -#### Quick start +#### Quick start with Budo + +The [budo browserify development server](https://github.com/mattdesl/budo) +allows for the fastest way to have your pure JavaScript app (no HTML file needed) +running in the browser with the covenient live reload feature on any source changes. + +```bash +# 1) install +npm install mithril@rewrite --save +npm install budo -g + +# 2) add this line into the scripts section in package.json +# "scripts": { +# "start": "budo --live --open index.js" +# } + +# 3) create an `index.js` file + +# 4) run budo +npm start +``` + +The source file `index.js` will be compiled (bundled) and a browser window opens showing the result. +Any changes in the source files will instantly get recompiled and the +browser will refresh reflecting the changes. + + +#### Quick start with Webpack ```bash # 1) install @@ -26,8 +53,13 @@ npm install webpack --save # 3) create an `index.js` file -# 4) run bundler +# 4) create an `index.html` file loading `app.js` + +# 5) run bundler npm run build + +# 6) open `index.html` in the (default) browser +open index.html ``` #### Step by step @@ -43,7 +75,13 @@ npm init --yes # creates a file called package.json ``` -Then, run `npm install mithril@rewrite --save` to install Mithril. This will create a folder called `node_modules`, and a `mithril` folder inside of it. It will also add an entry under `dependencies` in the `package.json` file +Then, run + +```bash +npm install mithril@rewrite --save +``` + +to install Mithril. This will create a folder called `node_modules`, and a `mithril` folder inside of it. It will also add an entry under `dependencies` in the `package.json` file ```bash npm install mithril@rewrite --save From c71ebf18edf8e405941a84a6aa459f155cf4114d Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 31 Dec 2016 08:35:50 -0500 Subject: [PATCH 02/14] tweaks in docs --- docs/contributing.md | 2 +- docs/fragment.md | 17 ++++++++++ docs/framework-comparison.md | 4 +++ docs/guides.md | 3 +- docs/installation.md | 62 +++++++++++++++++++----------------- docs/style.css | 7 ++-- docs/testing.md | 4 --- 7 files changed, 61 insertions(+), 38 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index e2e65fd6..5b4770d3 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -4,7 +4,7 @@ ## How do I go about contributing ideas or new features? -Create an [issue thread on Github](https://github.com/lhorie/mithril.js/issues/new) to suggest your idea so the community can discuss it. And don't worry, we're nice :) +Create an [issue thread on Github](https://github.com/lhorie/mithril.js/issues/new) to suggest your idea so the community can discuss it. If the consensus is that it's a good idea, the fastest way to get it into a release is to send a pull request. Without a PR, the time to implement the feature will depend on the bandwidth of the development team and its list of priorities. diff --git a/docs/fragment.md b/docs/fragment.md index cd1ff53a..018dc4ab 100644 --- a/docs/fragment.md +++ b/docs/fragment.md @@ -10,6 +10,23 @@ Allows attaching lifecycle methods to a fragment [vnode](vnodes.md) +```javascript +var groupVisible = true +var log = function() { + console.log("group is now visible") +} + +m("ul", [ + m("li", "child 1"), + m("li", "child 2"), + groupVisible ? m.fragment({oninit: log}, [ + // a fragment containing two elements + m("li", "child 3"), + m("li", "child 4"), + ]) : null +]) +``` + --- ### Signature diff --git a/docs/framework-comparison.md b/docs/framework-comparison.md index 70debb38..029d0319 100644 --- a/docs/framework-comparison.md +++ b/docs/framework-comparison.md @@ -1,5 +1,9 @@ # Framework comparison +- [React](#react) +- [Angular](#angular) +- [Vue](#vue) + If you're reading this page, you probably have used other frameworks to build applications, and you want to know if Mithril would help you solve your problems more effectively. In this page, you will find common arguments about other frameworks and comments on where Mithril is similar or why it differs from them. diff --git a/docs/guides.md b/docs/guides.md index 4abbf045..a4333b58 100644 --- a/docs/guides.md +++ b/docs/guides.md @@ -1,7 +1,7 @@ - Tutorials - [Installation](installation.md) - [Introduction](introduction.md) - - [Tutorial](tutorial.md) + - [Tutorial](simple-application.md) - [Testing](testing.md) - [Examples](examples.md) - Key concepts @@ -14,4 +14,5 @@ - [Contributing](contributing.md) - [Credits](credits.md) - Misc + - [Framework comparison](framework-comparison.md) - [Change log/Migration](change-log.md) diff --git a/docs/installation.md b/docs/installation.md index 24135b10..7536cbce 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,5 +1,8 @@ # Installation +- [CDN](#cdn) +- [NPM](#npm) + ### CDN If you're new to Javascript or just want a very simple setup to get your feet wet, you can get Mithril from a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network): @@ -12,33 +15,6 @@ If you're new to Javascript or just want a very simple setup to get your feet we ### NPM -#### Quick start with Budo - -The [budo browserify development server](https://github.com/mattdesl/budo) -allows for the fastest way to have your pure JavaScript app (no HTML file needed) -running in the browser with the covenient live reload feature on any source changes. - -```bash -# 1) install -npm install mithril@rewrite --save -npm install budo -g - -# 2) add this line into the scripts section in package.json -# "scripts": { -# "start": "budo --live --open index.js" -# } - -# 3) create an `index.js` file - -# 4) run budo -npm start -``` - -The source file `index.js` will be compiled (bundled) and a browser window opens showing the result. -Any changes in the source files will instantly get recompiled and the -browser will refresh reflecting the changes. - - #### Quick start with Webpack ```bash @@ -62,6 +38,10 @@ npm run build open index.html ``` +The source file `index.js` will be compiled (bundled) and a browser window opens showing the result. +Any changes in the source files will instantly get recompiled and the +browser will refresh reflecting the changes. + #### Step by step For production-level projects, the recommended way of installing Mithril is to use NPM. @@ -166,9 +146,31 @@ m.mount(document.body, MyComponent) Note that in this example, we're using `m.mount`, which wires up the component to Mithril's autoredraw system. In most applications, you will want to use `m.mount` (or `m.route` if your application has multiple screens) instead of `m.render` to take advantage of the autoredraw system, rather than re-rendering manually every time a change occurs. -#### Alternate ways to use Mithril +--- -##### Mithril bundler +### Alternate ways to use Mithril + +#### Live reload development environment + +Live reload is a feature where code changes automatically trigger the page to reload. [Budo](https://github.com/mattdesl/budo) is one tool that enables live reloading. + +```bash +# 1) install +npm install mithril@rewrite --save +npm install budo -g + +# 2) add this line into the scripts section in package.json +# "scripts": { +# "start": "budo --live --open index.js" +# } + +# 3) create an `index.js` file + +# 4) run budo +npm start +``` + +#### Mithril bundler Mithril comes with a bundler tool of its own. It is sufficient for projects that have no other dependencies other than Mithril, but it's currently considered experimental for projects that require other NPM dependencies. It produces smaller bundles than webpack, but you should not use it in production yet. @@ -183,7 +185,7 @@ If you want to try it and give feedback, you can open `package.json` and change } ``` -##### Vanilla +#### Vanilla If you don't have the ability to run a bundler script due to company security policies, there's an options to not use a module system at all: diff --git a/docs/style.css b/docs/style.css index faef030c..d80b9bca 100644 --- a/docs/style.css +++ b/docs/style.css @@ -5,8 +5,11 @@ nav a {border-left:1px solid #ddd;padding:0 10px;} nav a:first-child {border:0;padding-left:0;} main {margin-bottom:100px;} main section {margin-left:270px;} -h1 {margin:0 0 15px;} -h5 {font-style:italic;} +h1 {font-size:24px;margin:0 0 15px;} +h2 {font-size:22px;margin:30px 0 15px;} +h3 {font-size:20px;margin:30px 0 15px;} +h4 {font-size:18px;margin:15px 0 15px;} +h5 {font-weight:bold;margin:15px 0 15px;} pre,code {background:#eee;font-family:monospace;} pre {border-left:3px solid #1e5799;overflow:auto;padding:10px 20px;} code {border:1px solid #ddd;display:inline-block;margin:0 0 1px;padding:3px;white-space:pre;} diff --git a/docs/testing.md b/docs/testing.md index 63f231cf..ad4aaba0 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -8,11 +8,7 @@ The easist way to setup the test runner is to create an NPM script for it. Open { "name": "my-project", "scripts": { - "build": "bundle index.js --output app.js --watch", "test": "ospec" - }, - "dependencies": { - "mithril": "^1.0.0-rc.5" } } ``` From afcf28ab199df5e137069c48de087e5c80bd77fa Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 31 Dec 2016 09:38:35 -0500 Subject: [PATCH 03/14] more documentation --- docs/guides.md | 2 ++ docs/introduction.md | 7 ++++--- docs/testing.md | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/docs/guides.md b/docs/guides.md index a4333b58..3b3c537c 100644 --- a/docs/guides.md +++ b/docs/guides.md @@ -11,6 +11,8 @@ - [Keys](keys.md) - Social - [Community chat](https://gitter.im/lhorie/mithril.js) + - [Wiki](https://github.com/lhorie/mithril.js/wiki) + - [Jobs](https://github.com/lhorie/mithril.js/wiki/JOBS) - [Contributing](contributing.md) - [Credits](credits.md) - Misc diff --git a/docs/introduction.md b/docs/introduction.md index 2e451a7d..9a59f3b8 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -12,15 +12,16 @@ ### What is Mithril? -Mithril is a client-side Javascript framework for building Single Page Applications. It's small and batteries-included. +Mithril is a client-side Javascript framework for building Single Page Applications. +It's small (< 8kb gzip) and batteries-included. If you are an experienced developer and want to know how Mithril compares to other frameworks, see the [framework comparison](framework-comparison.md) page. --- -### Getting started +Note: This introduction assumes you have basic level of Javacript knowledge. If you don't, there are many great resources to learn. [Speaking Javascript](http://speakingjs.com/es5/index.html) is a good e-book for absolute beginners. If you're already familiar with other programming languages, the [Eloquent Javascript](http://eloquentjavascript.net/) e-book might be more suitable for you. [Codecademy](https://www.codecademy.com/learn/javascript) is another good resource that emphasizes learning via interactivity. -This introduction assumes you know Javacript. If you don't, there are many great resources to learn. [Speaking Javascript](http://speakingjs.com/es5/index.html) is a good e-book for absolute beginners. If you're already familiar with other programming languages, the [Eloquent Javascript](http://eloquentjavascript.net/) e-book might be more suitable for you. [Codecademy](https://www.codecademy.com/learn/javascript) is another good resource that emphasizes learning via interactivity. +### Getting started The easiest way to try out Mithril is to include it from a CDN, and follow this tutorial. It'll cover the majority of the API surface but it'll only take 10 minutes. diff --git a/docs/testing.md b/docs/testing.md index ad4aaba0..b2615649 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -44,3 +44,42 @@ Writing tests upfront requires specifications to be frozen. Upfront tests are a Writing tests after the fact is a way to document the behavior of a system and avoid regressions. They are useful to ensure that obscure corner cases are not inadvertedly broken and that previously fixed bugs do not get re-introduced by unrelated changes. +--- + +### Unit testing + +Unit testing is the practice of isolating a part of an application (typically a single module), and asserting that, given some inputs, it produces the expected outputs. + +Testing a Mithril component is easy. Let's assume we have a simple component like this: + +```javascript +// MyComponent.js +var m = require("mithril") + +module.exports = { + view: function() { + return m("div", "Hello world") + } +} +``` + +We can then create a `tests/MyComponent.js` file and create a test for this component like this: + +``` +var MyComponent = require("MyComponent") + +o.spec("MyComponent", function() { + o("returns a div", function() { + var vnode = MyComponent.view() + + o(vnode.tag).equals("div") + o(vnode.children.length).equals(1) + o(vnode.children[0].tag).equals("#") + o(vnode.children[0].children).equals("Hello world") + }) +}) +``` + +Typically, you wouldn't test the structure of the vnode tree so granularly, and you would instead only test non-trivial, dynamic aspects of the view. A tool that can help making testing easier with deep vnode trees is [Mithril Query](https://github.com/StephanHoyer/mithril-query). + +Sometimes, you need to mock the dependencies of a module in order to test the module in isolation. [Mockery](https://github.com/mfncooper/mockery) is one tool that allows you to do that. From d7732d35608141554217834929acbe4f3c858e88 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 31 Dec 2016 09:41:30 -0500 Subject: [PATCH 04/14] syntax highlighting --- docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing.md b/docs/testing.md index b2615649..e42696af 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -65,7 +65,7 @@ module.exports = { We can then create a `tests/MyComponent.js` file and create a test for this component like this: -``` +```javascript var MyComponent = require("MyComponent") o.spec("MyComponent", function() { From b62663bdc15fa7cfbe594634d3509da46b85f5b1 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 31 Dec 2016 19:27:23 -0500 Subject: [PATCH 05/14] ensure properties in arrays are tested #1497 --- ospec/README.md | 2 +- ospec/ospec.js | 7 +++++-- ospec/package.json | 2 +- ospec/tests/test-ospec.js | 10 +++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ospec/README.md b/ospec/README.md index cd08c697..084d949d 100644 --- a/ospec/README.md +++ b/ospec/README.md @@ -4,7 +4,7 @@ Noiseless testing framework -Version: 1.2.1 +Version: 1.2.2 License: MIT ## About diff --git a/ospec/ospec.js b/ospec/ospec.js index f094dfe6..24495b87 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -143,8 +143,11 @@ module.exports = new function init() { return true } if (a.length === b.length && (a instanceof Array && b instanceof Array || aIsArgs && bIsArgs)) { - for (var i = 0; i < a.length; i++) { - if (!deepEqual(a[i], b[i])) return false + var aKeys = Object.getOwnPropertyNames(a), bKeys = Object.getOwnPropertyNames(b) + if (aKeys.length !== bKeys.length) return false + var larger = aKeys.length < bKeys.length ? bKeys : aKeys + for (var i = 0; i < larger.length; i++) { + if (!deepEqual(a[larger[i]], b[larger[i]])) return false } return true } diff --git a/ospec/package.json b/ospec/package.json index 940b7f5a..1127ad7f 100644 --- a/ospec/package.json +++ b/ospec/package.json @@ -1,6 +1,6 @@ { "name": "ospec", - "version": "1.2.1", + "version": "1.2.2", "description": "Noiseless testing framework", "main": "ospec.js", "directories": { diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index 3b1dd440..a1433d26 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -28,7 +28,7 @@ o.spec("ospec", function() { o.beforeEach(function() {b = 1}) o.afterEach(function() {b = 0}) - o("assertions", function() { + o.only("assertions", function() { var spy = o.spy() spy(a) @@ -36,6 +36,14 @@ o.spec("ospec", function() { o(a).notEquals(2) o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3}) o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}]) + + var monkeypatch1 = [1, 2] + monkeypatch1.field = 3 + var monkeypatch2 = [1, 2] + monkeypatch2.field = 4 + + o(monkeypatch1).notDeepEquals([1, 2]) + o(monkeypatch1).notDeepEquals(monkeypatch2) var values = ["a", "", 1, 0, true, false, null, undefined, Date(0), ["a"], [], function() {return arguments}.call(), new Uint8Array(), {a: 1}, {}] for (var i = 0; i < values.length; i++) { From fab51f583a2b44843a11cbdf0f498ebdb13eef00 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 31 Dec 2016 19:27:53 -0500 Subject: [PATCH 06/14] clean up docs --- docs/guides.md | 5 ++--- docs/introduction.md | 2 +- docs/methods.md | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/guides.md b/docs/guides.md index 3b3c537c..d2bd87da 100644 --- a/docs/guides.md +++ b/docs/guides.md @@ -11,9 +11,8 @@ - [Keys](keys.md) - Social - [Community chat](https://gitter.im/lhorie/mithril.js) - - [Wiki](https://github.com/lhorie/mithril.js/wiki) - - [Jobs](https://github.com/lhorie/mithril.js/wiki/JOBS) - - [Contributing](contributing.md) + - [Mithril Jobs](https://github.com/lhorie/mithril.js/wiki/JOBS) + - [How to contribute](contributing.md) - [Credits](credits.md) - Misc - [Framework comparison](framework-comparison.md) diff --git a/docs/introduction.md b/docs/introduction.md index 9a59f3b8..29c59a4e 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -13,7 +13,7 @@ ### What is Mithril? Mithril is a client-side Javascript framework for building Single Page Applications. -It's small (< 8kb gzip) and batteries-included. +It's small (< 8kb gzip), fast and batteries-included. If you are an experienced developer and want to know how Mithril compares to other frameworks, see the [framework comparison](framework-comparison.md) page. diff --git a/docs/methods.md b/docs/methods.md index 9b19b4cc..06809b50 100644 --- a/docs/methods.md +++ b/docs/methods.md @@ -16,5 +16,4 @@ - Optional - [Stream](stream.md) - Tooling - - [Bundler](bundler.md) - - [Ospec](ospec.md) + - [Ospec](https://github.com/lhorie/mithril.js/blob/rewrite/ospec) From af39796da3d27c92a90499c487348895f08f45d5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Sun, 1 Jan 2017 10:59:40 +0100 Subject: [PATCH 07/14] [ospec:tests] Add assertions for array deepEquals corner cases --- ospec/tests/test-ospec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index a1433d26..8896c4a0 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -37,6 +37,13 @@ o.spec("ospec", function() { o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3}) o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}]) + var sparse1 = [void 1, void 2, void 3] + delete sparse1[0] + var sparse2 = [void 1, void 2, void 3] + delete sparse2[1] + + o(sparse1).notDeepEquals(sparse2) + var monkeypatch1 = [1, 2] monkeypatch1.field = 3 var monkeypatch2 = [1, 2] @@ -45,6 +52,14 @@ o.spec("ospec", function() { o(monkeypatch1).notDeepEquals([1, 2]) o(monkeypatch1).notDeepEquals(monkeypatch2) + monkeypatch2.field = 3 + o(monkeypatch1).deepEquals(monkeypatch2) + + monkeypatch1.undef = undefined + monkeypatch2.UNDEF = undefined + + o(monkeypatch1).notDeepEquals(monkeypatch2) + var values = ["a", "", 1, 0, true, false, null, undefined, Date(0), ["a"], [], function() {return arguments}.call(), new Uint8Array(), {a: 1}, {}] for (var i = 0; i < values.length; i++) { for (var j = 0; j < values.length; j++) { From 02545a8a98eefd6d9867ec7bd0c006c1ee8cbe2b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Sun, 1 Jan 2017 15:08:46 +0100 Subject: [PATCH 08/14] [ospec] Fix array deepEquals corner cases --- ospec/ospec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ospec/ospec.js b/ospec/ospec.js index 24495b87..9db636b4 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -145,9 +145,8 @@ module.exports = new function init() { if (a.length === b.length && (a instanceof Array && b instanceof Array || aIsArgs && bIsArgs)) { var aKeys = Object.getOwnPropertyNames(a), bKeys = Object.getOwnPropertyNames(b) if (aKeys.length !== bKeys.length) return false - var larger = aKeys.length < bKeys.length ? bKeys : aKeys - for (var i = 0; i < larger.length; i++) { - if (!deepEqual(a[larger[i]], b[larger[i]])) return false + for (var i = 0; i < aKeys.length; i++) { + if (!b.hasOwnProperty(aKeys[i]) || !deepEqual(a[aKeys[i]], b[aKeys[i]])) return false } return true } From 027a2207799efd2ff41f7b83a82e16101d447507 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Sun, 1 Jan 2017 16:09:15 +0100 Subject: [PATCH 09/14] [ospec:tests] Add assertion for object with undefined properties vs none --- ospec/tests/test-ospec.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index 8896c4a0..b3878f7a 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -36,6 +36,13 @@ o.spec("ospec", function() { o(a).notEquals(2) o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3}) o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}]) + + var undef1 = {undef: void 0} + var undef2 = {UNDEF: void 0} + + o(undef1).notDeepEquals(undef2) + o(undef1).notDeepEquals({}) + o({}).notDeepEquals(undef1) var sparse1 = [void 1, void 2, void 3] delete sparse1[0] From df1e19b86cd00b3504796cab1c138230e7734e1b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Sun, 1 Jan 2017 16:13:11 +0100 Subject: [PATCH 10/14] [ospec] Fix for objects with undefined properties --- ospec/ospec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospec/ospec.js b/ospec/ospec.js index 9db636b4..56111b66 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -135,7 +135,7 @@ module.exports = new function init() { var aIsArgs = isArguments(a), bIsArgs = isArguments(b) if (a.constructor === Object && b.constructor === Object && !aIsArgs && !bIsArgs) { for (var i in a) { - if (!deepEqual(a[i], b[i])) return false + if ((!(i in b)) || !deepEqual(a[i], b[i])) return false } for (var i in b) { if (!(i in a)) return false From ba96c23b84e52f3c96fd717e28c8b816cb5a38a7 Mon Sep 17 00:00:00 2001 From: Hugo Freitas Date: Mon, 2 Jan 2017 17:30:49 -0300 Subject: [PATCH 11/14] Remove duplicated install --- docs/installation.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 7536cbce..2d20dd11 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -63,10 +63,6 @@ npm install mithril@rewrite --save to install Mithril. This will create a folder called `node_modules`, and a `mithril` folder inside of it. It will also add an entry under `dependencies` in the `package.json` file -```bash -npm install mithril@rewrite --save -``` - You are now ready to start using Mithril. The recommended way to structure code is to modularize it via CommonJS modules: ```javascript From 933266670d35ec5c4b683ec428272c231b6e022b Mon Sep 17 00:00:00 2001 From: bruce-one Date: Tue, 3 Jan 2017 10:49:30 +1100 Subject: [PATCH 12/14] Recommend usage of fragments --- docs/keys.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/keys.md b/docs/keys.md index 245e078b..9fd87814 100644 --- a/docs/keys.md +++ b/docs/keys.md @@ -132,9 +132,7 @@ users.map(function(u) { // PREFER users.map(function(u) { - return {tag: "[", key: u.id, children: [ - m("button", u.name) - ]} + return m.fragment({key: u.id}, m("button", u.name)) }) ``` From 7868d9700654df1ddf9839f208bd642f0caba4a3 Mon Sep 17 00:00:00 2001 From: Bryce Gibson Date: Tue, 3 Jan 2017 11:19:55 +1100 Subject: [PATCH 13/14] Remove o.only call to ensure other tests are run. --- ospec/tests/test-ospec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ospec/tests/test-ospec.js b/ospec/tests/test-ospec.js index b3878f7a..2bdd5556 100644 --- a/ospec/tests/test-ospec.js +++ b/ospec/tests/test-ospec.js @@ -8,7 +8,7 @@ new function(o) { o.spec("ospec", function() { o("skipped", function() { - o(1).equals(1) + o(true).equals(false) }) o.only(".only()", function() { o(2).equals(2) @@ -28,7 +28,7 @@ o.spec("ospec", function() { o.beforeEach(function() {b = 1}) o.afterEach(function() {b = 0}) - o.only("assertions", function() { + o("assertions", function() { var spy = o.spy() spy(a) From 33fb63a72ba585fdf51bdd319e4a9a68829b1bc1 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 3 Jan 2017 10:47:35 -0500 Subject: [PATCH 14/14] fix merge --- docs/installation.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 2d20dd11..6993c5d5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -38,10 +38,6 @@ npm run build open index.html ``` -The source file `index.js` will be compiled (bundled) and a browser window opens showing the result. -Any changes in the source files will instantly get recompiled and the -browser will refresh reflecting the changes. - #### Step by step For production-level projects, the recommended way of installing Mithril is to use NPM. @@ -166,6 +162,8 @@ npm install budo -g npm start ``` +The source file `index.js` will be compiled (bundled) and a browser window opens showing the result. Any changes in the source files will instantly get recompiled and the browser will refresh reflecting the changes. + #### Mithril bundler Mithril comes with a bundler tool of its own. It is sufficient for projects that have no other dependencies other than Mithril, but it's currently considered experimental for projects that require other NPM dependencies. It produces smaller bundles than webpack, but you should not use it in production yet.