Merge remote-tracking branch 'origin/rewrite' into rewrite
Conflicts: mithril.min.js
This commit is contained in:
commit
17161a05c5
10 changed files with 122 additions and 54 deletions
13
mithril.js
13
mithril.js
|
|
@ -72,6 +72,12 @@ function hyperscript(selector) {
|
|||
if (typeof selector === "string") return selectorCache[selector](attrs || {}, Vnode.normalizeChildren(children))
|
||||
return Vnode(selector, attrs && attrs.key, attrs || {}, Vnode.normalizeChildren(children), undefined, undefined)
|
||||
}
|
||||
hyperscript.trust = function(html) {
|
||||
return Vnode("<", undefined, undefined, html, undefined, undefined)
|
||||
}
|
||||
hyperscript.fragment = function(attrs, children) {
|
||||
return Vnode("[", attrs.key, attrs, Vnode.normalizeChildren(children), undefined, undefined)
|
||||
}
|
||||
var m = hyperscript
|
||||
var renderService = function($window) {
|
||||
var $doc = $window.document
|
||||
|
|
@ -160,6 +166,8 @@ var renderService = function($window) {
|
|||
initLifecycle(vnode.tag, vnode, hooks)
|
||||
vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
|
||||
if (vnode.instance != null) {
|
||||
if(vnode.instance === vnode)
|
||||
throw Error("A component view mustn't return the vnode that was supplied to it.")
|
||||
var element = createNode(vnode.instance, hooks, ns)
|
||||
vnode.dom = vnode.instance.dom
|
||||
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
|
||||
|
|
@ -178,7 +186,6 @@ var renderService = function($window) {
|
|||
else {
|
||||
var recycling = isRecyclable(old, vnodes)
|
||||
if (recycling) old = old.concat(old.pool)
|
||||
|
||||
if (old.length === vnodes.length && vnodes[0] != null && vnodes[0].key == null) {
|
||||
for (var i = 0; i < old.length; i++) {
|
||||
if (old[i] === vnodes[i] || old[i] == null && vnodes[i] == null) continue
|
||||
|
|
@ -569,7 +576,6 @@ var renderService = function($window) {
|
|||
function render(dom, vnodes) {
|
||||
var hooks = []
|
||||
var active = $doc.activeElement
|
||||
|
||||
// First time rendering into a node clears it out
|
||||
if (dom.vnodes == null) dom.textContent = ""
|
||||
if (!(vnodes instanceof Array)) vnodes = [vnodes]
|
||||
|
|
@ -1136,9 +1142,6 @@ m.mount = function(renderer, pubsub) {
|
|||
run()
|
||||
}
|
||||
}(renderService, redrawService)
|
||||
m.trust = function(html) {
|
||||
return Vnode("<", undefined, undefined, html, undefined, undefined)
|
||||
}
|
||||
m.withAttr = function(attrName, callback, context) {
|
||||
return function(e) {
|
||||
return callback.call(context || this, attrName in e.currentTarget ? e.currentTarget[attrName] : e.currentTarget.getAttribute(attrName))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue