@@ -266,26 +266,20 @@ o.spec("updateElement", function() {
266266 var spyCamelCase1 = o . spy ( )
267267 var spyCamelCase2 = o . spy ( )
268268
269- var f = $window . document . createElement
270- $window . document . createElement = function ( tag , is ) {
271- var el = f ( tag , is )
272-
273- var style = { }
274- Object . defineProperties ( style , {
275- setProperty : { value : spySetProperty } ,
276- removeProperty : { value : spyRemoveProperty } ,
277- /* eslint-disable accessor-pairs */
278- "background-color" : { set : spyDashed1 } ,
279- "-webkit-border-radius" : { set : spyDashed2 } ,
280- "--foo" : { set : spyDashed3 } ,
281- backgroundColor : { set : spyCamelCase1 } ,
282- color : { set : spyCamelCase2 }
283- /* eslint-enable accessor-pairs */
284- } )
285-
286- Object . defineProperty ( el , "style" , { value : style } )
287- return el
288- }
269+ render ( root , m ( "a" ) )
270+ var el = root . firstChild
271+
272+ el . style . setProperty = spySetProperty
273+ el . style . removeProperty = spyRemoveProperty
274+ Object . defineProperties ( el . style , {
275+ /* eslint-disable accessor-pairs */
276+ "background-color" : { set : spyDashed1 } ,
277+ "-webkit-border-radius" : { set : spyDashed2 } ,
278+ "--foo" : { set : spyDashed3 } ,
279+ backgroundColor : { set : spyCamelCase1 } ,
280+ color : { set : spyCamelCase2 }
281+ /* eslint-enable accessor-pairs */
282+ } )
289283
290284 // sets dashed properties
291285 render ( root , m ( "a" , {
@@ -295,6 +289,10 @@ o.spec("updateElement", function() {
295289 "--foo" : "bar"
296290 }
297291 } ) )
292+ o ( spySetProperty . callCount ) . equals ( 3 )
293+ o ( spySetProperty . calls [ 0 ] . args ) . deepEquals ( [ "background-color" , "red" ] )
294+ o ( spySetProperty . calls [ 1 ] . args ) . deepEquals ( [ "-webkit-border-radius" , "10px" ] )
295+ o ( spySetProperty . calls [ 2 ] . args ) . deepEquals ( [ "--foo" , "bar" ] )
298296
299297 // sets camelCase properties and removes dashed properties
300298 render ( root , m ( "a" , {
@@ -303,32 +301,30 @@ o.spec("updateElement", function() {
303301 color : "red" ,
304302 }
305303 } ) )
304+ o ( spyCamelCase1 . callCount ) . equals ( 1 )
305+ o ( spyCamelCase2 . callCount ) . equals ( 1 )
306+ o ( spyCamelCase1 . calls [ 0 ] . args ) . deepEquals ( [ "green" ] )
307+ o ( spyCamelCase2 . calls [ 0 ] . args ) . deepEquals ( [ "red" ] )
308+ o ( spyRemoveProperty . callCount ) . equals ( 3 )
309+ o ( spyRemoveProperty . calls [ 0 ] . args ) . deepEquals ( [ "background-color" ] )
310+ o ( spyRemoveProperty . calls [ 1 ] . args ) . deepEquals ( [ "-webkit-border-radius" ] )
311+ o ( spyRemoveProperty . calls [ 2 ] . args ) . deepEquals ( [ "--foo" ] )
306312
307313 // updates "color" and removes "backgroundColor"
308314 render ( root , m ( "a" , { style : { color : "blue" } } ) )
315+ o ( spyCamelCase1 . callCount ) . equals ( 2 ) // set and remove
316+ o ( spyCamelCase2 . callCount ) . equals ( 2 ) // set and update
317+ o ( spyCamelCase1 . calls [ 1 ] . args ) . deepEquals ( [ "" ] )
318+ o ( spyCamelCase2 . calls [ 1 ] . args ) . deepEquals ( [ "blue" ] )
309319
310- // setProperty (for dashed properties)
320+ // unchanged by camelCase properties
311321 o ( spySetProperty . callCount ) . equals ( 3 )
312- o ( spySetProperty . calls [ 0 ] . args ) . deepEquals ( [ "background-color" , "red" ] )
313- o ( spySetProperty . calls [ 1 ] . args ) . deepEquals ( [ "-webkit-border-radius" , "10px" ] )
314- o ( spySetProperty . calls [ 2 ] . args ) . deepEquals ( [ "--foo" , "bar" ] )
315-
316- // removeProperty (for dashed properties)
317322 o ( spyRemoveProperty . callCount ) . equals ( 3 )
318- o ( spyRemoveProperty . calls [ 0 ] . args ) . deepEquals ( [ "background-color" ] )
319- o ( spyRemoveProperty . calls [ 1 ] . args ) . deepEquals ( [ "-webkit-border-radius" ] )
320- o ( spyRemoveProperty . calls [ 2 ] . args ) . deepEquals ( [ "--foo" ] )
321323
322- // property setter (for camelCase properties)
324+ // never calls dashed property setter
323325 o ( spyDashed1 . callCount ) . equals ( 0 )
324326 o ( spyDashed2 . callCount ) . equals ( 0 )
325327 o ( spyDashed3 . callCount ) . equals ( 0 )
326- o ( spyCamelCase1 . callCount ) . equals ( 2 ) // set and remove
327- o ( spyCamelCase2 . callCount ) . equals ( 2 ) // set and update
328- o ( spyCamelCase1 . calls [ 0 ] . args ) . deepEquals ( [ "green" ] )
329- o ( spyCamelCase1 . calls [ 1 ] . args ) . deepEquals ( [ "" ] )
330- o ( spyCamelCase2 . calls [ 0 ] . args ) . deepEquals ( [ "red" ] )
331- o ( spyCamelCase2 . calls [ 1 ] . args ) . deepEquals ( [ "blue" ] )
332328 } )
333329 o ( "replaces el" , function ( ) {
334330 var vnode = m ( "a" )
0 commit comments