VNDB fork of mithril.js
Find a file
impinball 12b8f044f1 Convert tests to Mocha/Chai/Sinon and lint them.
Details:

1. All tests now live in `test`. All test dependencies that aren't from npm live
   in `test-deps`.

2. The QUnit tests are gone, as well as their dependencies. Half of them
   duplicated existing tests, and some of them depended on the real DOM to
   properly test.

3. All tests are now using Mocha to run the tests, Chai for assertions, and
   Sinon and Sinon Chai for testing some callbacks.

4. Tests are run through mocha-phantomjs. If you want to run just the tests,
   run `grunt mocha_phantomjs` or fire up a server in the root and open
   `http://localhost:<port>/test/index.html`, e.g. `python3 -m http.server`.

5. The linter I chose is ESLint. It is relatively easy to configure, but with a
   lot of flexibility. The rules I chose mostly were in tune to the style the
   project was already using. I'm not including a style guide in this commit,
   but one will likely come. You can check out the `.eslintrc` in the root and
   in `test/` for the two configs. The `.eslintignore` includes a TODO for
   `mithril.js` itself targeted at me, in the root.

Other info:

- As a drive-by fix, I fixed line endings on a few of the files.

- I also took care of a few other files and linted them as I went:

  - `Gruntfile.js`
  - `test/input-cursor.html` (was in `tests/`)
  - `test/svg.html` (was in `tests/`)
  - `docs/layout/tools/template-converter.html`
  - `docs/layout/tools/template-converter.js`

  I didn't test the template converter after linting it, because it needs
  further scrutiny to ensure it works with the latest version of Mithril. I
  know the API has changed a little, which is why I want to be sure.

- I simplified the `.travis.yml` file because none of the tests are run directly
  through Node anymore. They are always run in a browser of some kind.

Hopefully, this turned out all right...
2015-10-31 11:07:22 -04:00
deploy #518 fix package.json file for cdn.js 2015-03-30 14:54:20 -04:00
docs Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
test Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
test-deps Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
.editorconfig tweak editorconfig preferences 2015-04-22 21:00:11 -04:00
.eslintignore Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
.eslintrc Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
.gitattributes Avoid EOL diff horror by enforcing CRLF on commit 2015-04-26 12:53:35 +01:00
.gitignore #686 prevent redraw lock on error 2015-06-23 13:43:54 -04:00
.npmignore adds saucelabs integration to unit tests 2014-07-25 11:23:47 -04:00
.travis.yml Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
dragdrop.html m.module -> m.mount: fix sample code in HTML files 2015-08-28 09:07:08 -03:00
Gruntfile.js Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
guide.html m.module -> m.mount: fix sample code in HTML files 2015-08-28 09:07:08 -03:00
LICENSE Initial commit 2014-03-16 18:59:39 -07:00
mithril.closure-compiler-externs.js Update externs for Google Closure compiler 2015-08-04 16:57:13 +02:00
mithril.d.ts Typescript: Support for Parameterized Components 2015-09-30 16:44:45 -04:00
mithril.js Make m.route.param() return all params #737 2015-08-18 20:44:58 +02:00
mithril.min.js Merge remote-tracking branch 'upstream/next' into speed, unfix "fixed" version 2015-07-23 05:26:31 -04:00
mithril.min.js.map Merge remote-tracking branch 'upstream/next' into speed, unfix "fixed" version 2015-07-23 05:26:31 -04:00
modulator-test.html Remove trailing whitespace 2015-07-09 03:38:42 -04:00
mvc.html m.module -> m.mount: fix sample code in HTML files 2015-08-28 09:07:08 -03:00
onerror.html clean up 2015-04-13 08:29:03 -04:00
package.json Convert tests to Mocha/Chai/Sinon and lint them. 2015-10-31 11:07:22 -04:00
README.md Update README gzip size statement 2015-09-23 16:41:26 -04:00

JS.ORG Join the chat at https://gitter.im/lhorie/mithril.js Support and Consulting Services Build Status

Mithril

A Javascript Framework for Building Brilliant Applications

See the website for documentation

There's also a blog and a mailing list


What is Mithril?

Mithril is a client-side MVC framework - a tool to organize code in a way that is easy to think about and to maintain.

Light-weight

  • Only 7kb gzipped, no dependencies
  • Small API, small learning curve

Robust

  • Safe-by-default templates
  • Hierarchical MVC via components

Fast

  • Virtual DOM diffing and compilable templates
  • Intelligent auto-redrawing system

Sample code

//namespace
var app = {};

//model
app.PageList = function() {
	return m.request({method: "GET", url: "pages.json"});
};

//controller
app.controller = function() {
	var pages = app.PageList();
	return {
		pages: pages,
		rotate: function() {
			pages().push(pages().shift());
		}
	}
};

//view
app.view = function(ctrl) {
	return [
		ctrl.pages().map(function(page) {
			return m("a", {href: page.url}, page.title);
		}),
		m("button", {onclick: ctrl.rotate}, "Rotate links")
	];
};


//initialize
m.mount(document.getElementById("example"), app);

Learn more