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 47c2167 commit 07a2644
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,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,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 @@ -2650,11 +2661,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 @@ -2881,13 +2891,12 @@
}
var callback = data.renderedCallback || noop,
args = arguments
avalon.scanCallback(function() {
checkScan(parent, function() {
callback.apply(parent, args)
if (parent.oldValue && parent.tagName === "SELECT" && method === "index") { //fix #503
avalon(parent).val(parent.oldValue.split(","))
}
})
avalon.scan(parent)
}, NaN)
}
},
"html": function(val, elem, data) {
Expand Down Expand Up @@ -3655,12 +3664,11 @@
}
}
data.bound("change", updateVModel)
avalon.scanCallback(function() {
checkScan(element,function() {
//先等到select里的option元素被扫描后,才根据model设置selected属性
registerSubscriber(data)
data.changed.call(element, evaluator(), data)
})
avalon.scan(element)
}, NaN)
}
duplexBinding.TEXTAREA = duplexBinding.INPUT
//============================= event binding =======================
Expand Down

0 comments on commit 07a2644

Please sign in to comment.