VNDB fork of mithril.js
m.route('path'), when called programmatically (not attached to an anchor
tag), did not update the url in the navigation bar. I tracked it to this
error, where it is searching for an elements attributes, sepecifically
the this.attrs.href, which did not exist when called programatically.
The error returning was "Cannot read property 'href' of undefined",
which linked back to line 618 in the mithril core file.
I added a simple check to see if this.attrs exists before calling in
.href. Fixed it like a charm. I tried to follow the current coding
style, but let me know if there is something amiss in my change.
I ran both grunt test and grunt testall and everything seemed to run
perfect.
|
||
|---|---|---|
| archive | ||
| deploy | ||
| docs | ||
| tests | ||
| .gitignore | ||
| .npmignore | ||
| .travis.yml | ||
| Gruntfile.js | ||
| LICENSE | ||
| mithril.closure-compiler-externs.js | ||
| mithril.d.ts | ||
| mithril.js | ||
| mithril.min.js | ||
| mithril.min.js.map | ||
| package.json | ||
| README.md | ||
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 5kb 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.module(document.getElementById("example"), app);