lint docs
This commit is contained in:
parent
7718ef4c81
commit
8c9cc0e1f4
4 changed files with 17 additions and 15 deletions
|
|
@ -16,7 +16,6 @@ module.exports = function($window, renderer, pubsub) {
|
|||
current.path = path, current.component = component
|
||||
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)
|
||||
else resolve(current.component)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,10 @@ function ensureCodeIsRunnable(file, data) {
|
|||
}
|
||||
|
||||
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")}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ m.jsonp({
|
|||
And sometimes, you just want to take advantage of HTTP caching for GET requests for rarely-modified data:
|
||||
|
||||
```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({
|
||||
url: "https://api.github.com/users/lhorie"
|
||||
callbackName: "__callback"
|
||||
url: "https://api.github.com/users/lhorie",
|
||||
callbackName: "__callback",
|
||||
})
|
||||
.run(function(response) {
|
||||
console.log(response.data.login) // logs "lhorie"
|
||||
|
|
|
|||
|
|
@ -109,13 +109,13 @@ The `view` method is called on every redraw for a matching route. It is similar
|
|||
|
||||
`vnode = routeResolve.view(vnode)`
|
||||
|
||||
Argument | Type | Required | 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.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.route` | `String` | | The matched route
|
||||
**returns** | `Vnode` | | Returns a vnode
|
||||
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.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.route` | `String` | The matched route
|
||||
**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:
|
||||
|
||||
```
|
||||
```javascript
|
||||
var Edit = {
|
||||
view: function(vnode) {
|
||||
return [
|
||||
|
|
@ -390,8 +390,8 @@ Fortunately, there are a number of tools that facilitate the task of bundling mo
|
|||
```javascript
|
||||
m.route(document.body, "/", {
|
||||
"/": {
|
||||
resolve: function(use) {
|
||||
//using Webpack async code splitting
|
||||
onmatch: function(use) {
|
||||
// using Webpack async code splitting
|
||||
require(['./Home.js'], use)
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue