Skip to content

Commit

Permalink
add checkScan
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Nov 18, 2014
1 parent 0284b2b commit f65cd71
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions avalon.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,17 @@
//http://www.w3.org/TR/html5/syntax.html#void-elements
var stopScan = oneObject("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,noscript,script,style,textarea".toUpperCase())

function checkScan(elem, callback, innerHTML) {
var id = setTimeout(function() {
var currHTML = elem.innerHTML
clearTimeout(id)
if (currHTML === innerHTML) {
callback()
} else {
checkScan(elem, callback, currHTML)
}
})
}

function scanTag(elem, vmodels, node) {
//扫描顺序 ms-skip(0) --> ms-important(1) --> ms-controller(2) --> ms-if(10) --> ms-repeat(100)
Expand Down Expand Up @@ -2010,11 +2021,10 @@
text = loaded.apply(target, [text].concat(vmodels))
}
if (rendered) {
avalon.scanCallback(function() {
checkScan(target, function() {
rendered.call(target)
})
}, NaN)
}
avalon.scan(target)
while (true) {
var node = data.startInclude.nextSibling
if (node && node !== data.endInclude) {
Expand Down Expand Up @@ -2213,13 +2223,12 @@
break
}
var callback = data.renderedCallback || noop, args = arguments
avalon.scanCallback(function() {
checkScan(function() {
callback.apply(parent, args)
if (parent.oldValue && parent.tagName === "SELECT" && method === "index") {//fix #503
avalon(parent).val(parent.oldValue.split(","))
}
})
avalon.scan(parent)
}, parent)
}
},
"html": function(val, elem, data) {
Expand Down Expand Up @@ -2919,11 +2928,10 @@
}
}
data.bound("change", updateVModel)
avalon.scanCallback(function() {
checkScan(element, function() {
registerSubscriber(data)
data.changed.call(element, evaluator(), data)
})
avalon.scan(element)
}, NaN)
}
duplexBinding.TEXTAREA = duplexBinding.INPUT
//========================= event binding ====================
Expand Down

0 comments on commit f65cd71

Please sign in to comment.