lint docs

This commit is contained in:
Leo Horie 2016-08-17 09:09:45 -04:00
parent 7718ef4c81
commit 8c9cc0e1f4
4 changed files with 17 additions and 15 deletions

View file

@ -16,7 +16,6 @@ module.exports = function($window, renderer, pubsub) {
current.path = path, current.component = component current.path = path, current.component = component
renderer.render(root, payload.view(Vnode(component, null, args, undefined, undefined, undefined))) renderer.render(root, payload.view(Vnode(component, null, args, undefined, undefined, undefined)))
} }
if (typeof payload.onmatch !== "function") payload.onmatch = function() {resolve(current.component)}
if (path !== current.path) payload.onmatch(Vnode(payload, null, args, undefined, undefined, undefined), resolve) if (path !== current.path) payload.onmatch(Vnode(payload, null, args, undefined, undefined, undefined), resolve)
else resolve(current.component) else resolve(current.component)
} }

View file

@ -44,7 +44,10 @@ function ensureCodeIsRunnable(file, data) {
} }
try { try {
new Function("console,fetch", code).call(this, silentConsole, fetch) new Function("console,fetch,module,require", code).call(this, silentConsole, fetch, {exports: {}}, function(dep) {
if (dep.indexOf("./mycomponent") === 0) return {view: function() {}}
if (dep === "mithril") return m
})
} }
catch (e) {console.log(file + " - javascript code cannot run\n\n" + e.stack + "\n\n" + code + "\n\n---\n\n")} catch (e) {console.log(file + " - javascript code cannot run\n\n" + e.stack + "\n\n" + code + "\n\n---\n\n")}

View file

@ -59,10 +59,10 @@ m.jsonp({
And sometimes, you just want to take advantage of HTTP caching for GET requests for rarely-modified data: And sometimes, you just want to take advantage of HTTP caching for GET requests for rarely-modified data:
```javascript ```javascript
//this request is always called with the same querystring, and therefore it is cached // this request is always called with the same querystring, and therefore it is cached
m.jsonp({ m.jsonp({
url: "https://api.github.com/users/lhorie" url: "https://api.github.com/users/lhorie",
callbackName: "__callback" callbackName: "__callback",
}) })
.run(function(response) { .run(function(response) {
console.log(response.data.login) // logs "lhorie" console.log(response.data.login) // logs "lhorie"

View file

@ -109,13 +109,13 @@ The `view` method is called on every redraw for a matching route. It is similar
`vnode = routeResolve.view(vnode)` `vnode = routeResolve.view(vnode)`
Argument | Type | Required | Description Argument | Type | Description
------------------- | --------------- | -------- | ----------- ------------------- | --------------- | -----------
`vnode` | `Object` | | A [vnode](vnodes.md) whose attributes object contains routing parameters. If the routeResolver does not have a `resolve` method, the vnode's `tag` field defaults to a `div` `vnode` | `Object` | A [vnode](vnodes.md) whose attributes object contains routing parameters. If the routeResolver does not have a `resolve` method, the vnode's `tag` field defaults to a `div`
`vnode.attrs` | `Object` | | A [vnode](vnodes.md) whose attributes object contains routing parameters. If the routeResolver does not have a `resolve` method, the vnode defaults to a `div` `vnode.attrs` | `Object` | A [vnode](vnodes.md) whose attributes object contains routing parameters. If the routeResolver does not have a `resolve` method, the vnode defaults to a `div`
`vnode.attrs.path` | `String` | | The current router path, including interpolated routing parameter values, but without the prefix. Same value as `m.route.get()` `vnode.attrs.path` | `String` | The current router path, including interpolated routing parameter values, but without the prefix. Same value as `m.route.get()`
`vnode.attrs.route` | `String` | | The matched route `vnode.attrs.route` | `String` | The matched route
**returns** | `Vnode` | | Returns a vnode **returns** | `Vnode` | Returns a vnode
--- ---
@ -212,7 +212,7 @@ When navigating to routes, there's no need to explicitly specify the router pref
Sometimes we want to have a variable id or similar data appear in a route, but we don't want to explicitly specify a separate route for every possible id. In order to achieve that, Mithril supports parameterized routes: Sometimes we want to have a variable id or similar data appear in a route, but we don't want to explicitly specify a separate route for every possible id. In order to achieve that, Mithril supports parameterized routes:
``` ```javascript
var Edit = { var Edit = {
view: function(vnode) { view: function(vnode) {
return [ return [
@ -390,8 +390,8 @@ Fortunately, there are a number of tools that facilitate the task of bundling mo
```javascript ```javascript
m.route(document.body, "/", { m.route(document.body, "/", {
"/": { "/": {
resolve: function(use) { onmatch: function(use) {
//using Webpack async code splitting // using Webpack async code splitting
require(['./Home.js'], use) require(['./Home.js'], use)
}, },
}, },