Simplify draw routine
This commit is contained in:
parent
15c28066d7
commit
39b6f1e0fe
1 changed files with 9 additions and 34 deletions
|
|
@ -15,38 +15,19 @@ o.spec("attributes", function() {
|
||||||
|
|
||||||
o("when vnode is customElement, custom setAttribute called", function(){
|
o("when vnode is customElement, custom setAttribute called", function(){
|
||||||
|
|
||||||
var normalFirstDraw = [
|
var normal = [
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
{ tag: "input", attrs: { value: 'hello' } },
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
{ tag: "input", attrs: { value: 'hello' } },
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
{ tag: "input", attrs: { value: 'hello' } }
|
||||||
]
|
]
|
||||||
|
|
||||||
var normalSecondDraw = [
|
var custom = [
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
|
||||||
{ tag: "input", attrs: { wow: 'text' } },
|
|
||||||
]
|
|
||||||
|
|
||||||
var customFirstDraw = [
|
|
||||||
{ tag: "custom-element", attrs: { custom: 'x' } },
|
{ tag: "custom-element", attrs: { custom: 'x' } },
|
||||||
{ tag: "input", attrs: { is: 'something-special', custom: 'x' } },
|
{ tag: "input", attrs: { is: 'something-special', custom: 'x' } },
|
||||||
{ tag: "custom-element", attrs: { is: 'something-special', custom: 'x' } }
|
{ tag: "custom-element", attrs: { is: 'something-special', custom: 'x' } }
|
||||||
]
|
]
|
||||||
|
|
||||||
var customSecondDraw = [
|
var view = normal.concat(custom)
|
||||||
{ tag: "custom-element", attrs: { custom: 'y' } },
|
|
||||||
{ tag: "input", attrs: { is: 'something-special', custom: 'y' } },
|
|
||||||
{ tag: "custom-element", attrs: { is: 'something-special', custom: 'y' } }
|
|
||||||
]
|
|
||||||
|
|
||||||
var draws = [
|
|
||||||
normalFirstDraw, normalSecondDraw,
|
|
||||||
customFirstDraw, customSecondDraw
|
|
||||||
]
|
|
||||||
|
|
||||||
var customRedraws = 2
|
|
||||||
var customSetAttrCalls = customFirstDraw.length * customRedraws;
|
|
||||||
var innerHTMLCalls = normalFirstDraw.length
|
|
||||||
|
|
||||||
var f = $window.document.createElement
|
var f = $window.document.createElement
|
||||||
var spy
|
var spy
|
||||||
|
|
@ -61,15 +42,9 @@ o.spec("attributes", function() {
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
|
|
||||||
draws.forEach(
|
render(root, view)
|
||||||
function(view) {
|
|
||||||
render(root, view)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
o(spy.callCount).equals(
|
o(spy.callCount).equals( custom.length )
|
||||||
customSetAttrCalls + innerHTMLCalls
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue