make sure element is child of correct parent if child is recycled but parent is not
This commit is contained in:
parent
1385fc6268
commit
49dffe7e0e
7 changed files with 32 additions and 5 deletions
|
|
@ -73,6 +73,7 @@ new function(window) {
|
||||||
setAttributes(node, data.attrs, cached.attrs)
|
setAttributes(node, data.attrs, cached.attrs)
|
||||||
cached.children = build(node, data.children, cached.children)
|
cached.children = build(node, data.children, cached.children)
|
||||||
cached.nodes.intact = true
|
cached.nodes.intact = true
|
||||||
|
parent.appendChild(node)
|
||||||
}
|
}
|
||||||
if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew)
|
if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew)
|
||||||
}
|
}
|
||||||
|
|
@ -621,6 +622,12 @@ function testMithril(mock) {
|
||||||
m.render(root, m("div", [undefined]))
|
m.render(root, m("div", [undefined]))
|
||||||
return root.childNodes[0].childNodes.length === 0
|
return root.childNodes[0].childNodes.length === 0
|
||||||
})
|
})
|
||||||
|
test(function() {
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
m.render(root, m("div.classname", [m("a", {href: "/first"})]))
|
||||||
|
m.render(root, m("div", [m("a", {href: "/second"})]))
|
||||||
|
return root.childNodes[0].childNodes.length == 1
|
||||||
|
})
|
||||||
|
|
||||||
//m.redraw
|
//m.redraw
|
||||||
test(function() {
|
test(function() {
|
||||||
|
|
|
||||||
2
archive/v0.1.2/mithril.min.js
vendored
2
archive/v0.1.2/mithril.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -44,10 +44,24 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col(9,9,12)">
|
<div class="col(9,9,12)">
|
||||||
<h2 id="tools">Tools</h2>
|
<h2 id="tools">Tools</h2>
|
||||||
<h3 id="html-to-mithril-template-converter">HTML to Mithril Template Converter</h3>
|
<h3 id="html-to-mithril-template-converter">HTML-to-Mithril Template Converter</h3>
|
||||||
<p>If you already have your HTML written and want to convert it into a Mithril template, use the tool below.</p>
|
<p>If you already have your HTML written and want to convert it into a Mithril template, you can use the tool below for one-off manual conversion.</p>
|
||||||
<p><a href="tools/template-converter.html">Template Converter</a></p>
|
<p><a href="tools/template-converter.html">Template Converter</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
|
<h3 id="automatic-html-to-mithril-template-converter">Automatic HTML-to-Mithril Template Converter</h3>
|
||||||
|
<p>There's a tool called <a href="https://github.com/insin/msx">MSX by Jonathan Buchanan</a> that allows you to write templates using HTML syntax, and then automatically compile them to Javascript when files change.</p>
|
||||||
|
<p>It is useful for teams where styling and functionality are done by different people, and for those who prefer to maintain templates in HTML syntax.</p>
|
||||||
|
<p>The tool allows you to write code like this:</p>
|
||||||
|
<pre><code class="lang-javascript">todo.view = function(ctrl) {
|
||||||
|
return <html>
|
||||||
|
<body>
|
||||||
|
<input onchange={m.withAttr("value", ctrl.description)} value={ctrl.description()}/>
|
||||||
|
<button onclick={ctrl.add.bind(ctrl, ctrl.description)}>Add</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
};</code></pre>
|
||||||
|
<p>Note, however, that since the code above is not valid Javascript, this syntax can only be used with a preprocessor build tool such as the provided <a href="http://gulpjs.com">Gulp.js</a> script.</p>
|
||||||
|
<hr>
|
||||||
<h3 id="mithril-template-compiler">Mithril Template Compiler</h3>
|
<h3 id="mithril-template-compiler">Mithril Template Compiler</h3>
|
||||||
<p>You can pre-compile Mithril templates to make them run faster. For more information see this page:</p>
|
<p>You can pre-compile Mithril templates to make them run faster. For more information see this page:</p>
|
||||||
<p><a href="compiling-templates.html">Compiling Templates</a></p>
|
<p><a href="compiling-templates.html">Compiling Templates</a></p>
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ new function(window) {
|
||||||
setAttributes(node, data.attrs, cached.attrs)
|
setAttributes(node, data.attrs, cached.attrs)
|
||||||
cached.children = build(node, data.children, cached.children)
|
cached.children = build(node, data.children, cached.children)
|
||||||
cached.nodes.intact = true
|
cached.nodes.intact = true
|
||||||
|
parent.appendChild(node)
|
||||||
}
|
}
|
||||||
if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew)
|
if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew)
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +181,6 @@ new function(window) {
|
||||||
var currentRoot, currentModule = {view: function() {}}, currentController = {}, now = 0, lastRedraw = 0, lastRedrawId = 0
|
var currentRoot, currentModule = {view: function() {}}, currentController = {}, now = 0, lastRedraw = 0, lastRedrawId = 0
|
||||||
m.module = function(root, module) {
|
m.module = function(root, module) {
|
||||||
m.startComputation()
|
m.startComputation()
|
||||||
cellCache = {}
|
|
||||||
currentRoot = root
|
currentRoot = root
|
||||||
currentModule = module
|
currentModule = module
|
||||||
currentController = new module.controller
|
currentController = new module.controller
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,12 @@ function testMithril(mock) {
|
||||||
m.render(root, m("div", [undefined]))
|
m.render(root, m("div", [undefined]))
|
||||||
return root.childNodes[0].childNodes.length === 0
|
return root.childNodes[0].childNodes.length === 0
|
||||||
})
|
})
|
||||||
|
test(function() {
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
m.render(root, m("div.classname", [m("a", {href: "/first"})]))
|
||||||
|
m.render(root, m("div", [m("a", {href: "/second"})]))
|
||||||
|
return root.childNodes[0].childNodes.length == 1
|
||||||
|
})
|
||||||
|
|
||||||
//m.redraw
|
//m.redraw
|
||||||
test(function() {
|
test(function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue