Simplify draw routine

This commit is contained in:
James 2016-12-18 22:21:53 +11:00
parent 15c28066d7
commit 39b6f1e0fe

View file

@ -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
)
}) })
}) })