@@ -24,9 +24,15 @@ var countAssertions = function(tests) {
24
24
var curTest = tests [ i ] ;
25
25
26
26
if ( curTest . styles ) {
27
- for ( var k in curTest . styles ) {
28
- counter += Object . prototype . hasOwnProperty . call ( curTest . styles , k ) ;
29
- }
27
+ $ . each ( curTest . styles , function ( ) {
28
+ counter ++ ;
29
+ } ) ;
30
+ }
31
+
32
+ if ( curTest . attributes ) {
33
+ $ . each ( curTest . attributes , function ( ) {
34
+ counter ++ ;
35
+ } ) ;
30
36
}
31
37
32
38
counter += ! ! curTest . selector ;
@@ -58,11 +64,16 @@ var scrollTests = function(offset, tests) {
58
64
var curTest = tests [ i ] ;
59
65
60
66
if ( curTest . styles ) {
61
- for ( var k in curTest . styles ) {
62
- if ( Object . prototype . hasOwnProperty . call ( curTest . styles , k ) ) {
63
- QUnit . numericCSSPropertyEquals ( curTest . element . css ( k ) , curTest . styles [ k ] , curTest . message || 'element\'s (#' + curTest . element [ 0 ] . id + ') "' + k + '" CSS property is correct' ) ;
64
- }
65
- }
67
+ $ . each ( curTest . styles , function ( k ) {
68
+ QUnit . numericCSSPropertyEquals ( curTest . element . css ( k ) , curTest . styles [ k ] , curTest . message || 'element\'s (#' + curTest . element [ 0 ] . id + ') "' + k + '" CSS property is correct' ) ;
69
+ } ) ;
70
+ }
71
+
72
+ if ( curTest . attributes ) {
73
+ $ . each ( curTest . attributes , function ( k , value ) {
74
+ console . log ( curTest . element . prop ( k ) ) ;
75
+ QUnit . numericCSSPropertyEquals ( curTest . element . attr ( k ) , curTest . attributes [ k ] , curTest . message || 'element\'s (#' + curTest . element [ 0 ] . id + ') "' + k + '" attribute is correct' ) ;
76
+ } ) ;
66
77
}
67
78
68
79
if ( curTest . selector ) {
@@ -86,7 +97,7 @@ s.refresh(newElement[0]);
86
97
module ( 'basic stuff' ) ;
87
98
88
99
test ( 'CSS classes present' , function ( ) {
89
- strictEqual ( $ ( '.skrollable' ) . length , 22 , 'All elements have the .skrollable class' ) ;
100
+ strictEqual ( $ ( '.skrollable' ) . length , 23 , 'All elements have the .skrollable class' ) ;
90
101
91
102
ok ( $ ( 'html' ) . is ( '.skrollr' ) , 'HTML element has skrollr class' ) ;
92
103
ok ( $ ( 'html' ) . is ( ':not(.no-skrollr)' ) , 'HTML element does not have no-skrollr class' ) ;
@@ -180,6 +191,13 @@ scrollTests(500, [
180
191
styles : {
181
192
zIndex : 'auto'
182
193
}
194
+ } ,
195
+ {
196
+ message : 'attribute interpolation' ,
197
+ element : $ ( '#attr' ) ,
198
+ attributes : {
199
+ title : '0'
200
+ }
183
201
}
184
202
] ) ;
185
203
@@ -254,6 +272,14 @@ scrollTests(0, [
254
272
styles : {
255
273
zIndex : '1'
256
274
}
275
+ } ,
276
+ {
277
+ message : 'attribute interpolation' ,
278
+ element : $ ( '#attr' ) ,
279
+ attributes : {
280
+ title : '500' ,
281
+ 'data-test' : 'skrollr'
282
+ }
257
283
}
258
284
] ) ;
259
285
@@ -330,6 +356,14 @@ scrollTests(250, [
330
356
styles : {
331
357
float : 'none'
332
358
}
359
+ } ,
360
+ {
361
+ message : 'attribute interpolation' ,
362
+ element : $ ( '#attr' ) ,
363
+ attributes : {
364
+ title : '250' ,
365
+ 'data-test' : 'skrollr'
366
+ }
333
367
}
334
368
] ) ;
335
369
@@ -350,6 +384,13 @@ scrollTests(600, [
350
384
styles : {
351
385
left : '500px'
352
386
}
387
+ } ,
388
+ {
389
+ message : 'attribute interpolation' ,
390
+ element : $ ( '#attr' ) ,
391
+ attributes : {
392
+ 'data-test' : 'skrollr-test'
393
+ }
353
394
}
354
395
] ) ;
355
396
0 commit comments