Merge branch 'next' into strict-mode
This commit is contained in:
commit
934e0ac55e
19 changed files with 316 additions and 537 deletions
1
docs/CNAME
Normal file
1
docs/CNAME
Normal file
|
|
@ -0,0 +1 @@
|
|||
mithril.js.org
|
||||
|
|
@ -5,13 +5,13 @@ var path = require("path")
|
|||
var marked = require("marked")
|
||||
var layout = fs.readFileSync("./docs/layout.html", "utf-8")
|
||||
var version = JSON.parse(fs.readFileSync("./package.json", "utf-8")).version
|
||||
try {fs.mkdirSync("../mithril")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/archive")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version)} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/archive/v" + version + "/lib/prism")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/lib")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("../mithril/lib/prism")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/archive")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/archive/v" + version)} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/archive/v" + version + "/lib")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/archive/v" + version + "/lib/prism")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/lib")} catch (e) {/* ignore */}
|
||||
try {fs.mkdirSync("./dist/lib/prism")} catch (e) {/* ignore */}
|
||||
|
||||
var guides = fs.readFileSync("docs/guides.md", "utf-8")
|
||||
var methods = fs.readFileSync("docs/methods.md", "utf-8")
|
||||
|
|
@ -57,12 +57,12 @@ function generate(pathname) {
|
|||
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
|
||||
return "<h" + n + ' id="' + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-") + '">' + text + "</h" + n + ">"
|
||||
})
|
||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
fs.writeFileSync("./dist/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||
}
|
||||
else if (!pathname.match(/lint|generate/)) {
|
||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
fs.writeFileSync("../mithril/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
fs.writeFileSync("./dist/archive/v" + version + "/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
fs.writeFileSync("./dist/" + pathname.replace(/^docs\//, ""), fs.readFileSync(pathname, "utf-8"), "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,8 +257,6 @@ In the example above, we defined a route `/edit/:id`. This creates a dynamic rou
|
|||
|
||||
It's possible to have multiple arguments in a route, for example `/edit/:projectID/:userID` would yield the properties `projectID` and `userID` on the component's vnode attributes object.
|
||||
|
||||
In addition to routing parameters, the `attrs` object also includes a `path` property that contains the current route path, and a `route` property that contains the matched routed.
|
||||
|
||||
#### Key parameter
|
||||
|
||||
When a user navigates from a parameterized route to the same route with a different parameter (e.g. going from `/page/1` to `/page/2` given a route `/page/:id`, the component would not be recreated from scratch since both routes resolve to the same component, and thus result in a virtual dom in-place diff. This has the side-effect of triggering the `onupdate` hook, rather than `oninit`/`oncreate`. However, it's relatively common for a developer to want to synchronize the recreation of the component to the route change event.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,14 @@ Streams are NOT bundled with Mithril's core distribution. To include the Streams
|
|||
var Stream = require("mithril/stream")
|
||||
```
|
||||
|
||||
You can also download the module directly if your environment does not support a bundling toolchain:
|
||||
|
||||
```markup
|
||||
<script src="https://unpkg.com/mithril-stream"></script>
|
||||
```
|
||||
|
||||
When loaded directly with a `<script>` tag (rather than required), the stream library will be exposed as `window.m.stream`. If `window.m` is already defined (e.g. because you also use the main Mithril script), it will attach itself to the existing object. Otherwise it creates a new `window.m`. If you want to use streams in conjunction with Mithril as raw script tags, you should include Mithril in your page before `mithril-stream`, because `mithril` will otherwise overwrite the `window.m` object defined by `mithril-stream`. This is not a concern when the libraries are consumed as CommonJS modules (using `require(...)`).
|
||||
|
||||
---
|
||||
|
||||
### Signature
|
||||
|
|
|
|||
|
|
@ -73,9 +73,11 @@ Property | Type | Description
|
|||
`text` | `(String|Number|Boolean)?` | This is used instead of `children` if a vnode contains a text node as its only child. This is done for performance reasons. Component vnodes never use the `text` property even if they have a text node as their only child.
|
||||
`dom` | `Element?` | Points to the element that corresponds to the vnode. This property is `undefined` in the `oninit` lifecycle method. In fragments and trusted HTML vnodes, `dom` points to the first element in the range.
|
||||
`domSize` | `Number?` | This is only set in fragment and trusted HTML vnodes, and it's `undefined` in all other vnode types. It defines the number of DOM elements that the vnode represents (starting from the element referenced by the `dom` property).
|
||||
`state` | `Object` | An object that is persisted between redraws. In component vnodes, `state` is a shallow clone of the component object.
|
||||
`state` | `Object`? | An object that is persisted between redraws. It is provided by the core engine when needed. In component vnodes, the `state` inherits prototypically from the component object/class.
|
||||
`events` | `Object?` | An object that is persisted between redraws and that stores event handlers so that they can be removed using the DOM API. The `events` property is `undefined` if there are no event handlers defined. This property is only used internally by Mithril, do not use it.
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
### Vnode types
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue