@@ -49,7 +49,7 @@ var PADDING = (function () {
49
49
50
50
var isValid = function ( v ) {
51
51
var type = parsers . valueType ( v ) ;
52
- return type === TYPES . LENGTH || type === TYPES . PERCENT ;
52
+ return type === TYPES . LENGTH || type === TYPES . PERCENT || type === TYPES . INTEGER ;
53
53
} ;
54
54
55
55
var parser = function ( v ) {
@@ -101,7 +101,7 @@ var MARGIN = (function () {
101
101
var isValid = function ( v ) {
102
102
if ( v . toLowerCase ( ) === "auto" ) return true ;
103
103
var type = parsers . valueType ( v ) ;
104
- return type === TYPES . LENGTH || type === TYPES . PERCENT ;
104
+ return type === TYPES . LENGTH || type === TYPES . PERCENT || type === TYPES . INTEGER ;
105
105
} ;
106
106
107
107
var parser = function ( v ) {
@@ -311,9 +311,14 @@ exports.patch = function (jsdom) {
311
311
nodeName : { get : function ( ) { return this . name } }
312
312
} ) ;
313
313
}
314
+
314
315
//
315
316
// Fix CSSStyleDeclaration properties that are broken (padding, margin, width)
316
317
//
318
+
319
+ //
320
+ // Check if padding resets paddingTop
321
+ //
317
322
div . style . paddingTop = "10px" ;
318
323
div . style . padding = "1px" ;
319
324
if ( div . style . paddingTop !== "1px" ) {
@@ -323,6 +328,21 @@ exports.patch = function (jsdom) {
323
328
margin : MARGIN . definition
324
329
} ) ;
325
330
}
331
+ //
332
+ // Check if pixels without "px" are OK
333
+ //
334
+ div . style . padding = "" ;
335
+ div . style . padding = "1px 2 3px 4" ;
336
+ if ( div . style . padding !== "1px 2 3px 4" ) {
337
+ var core = require ( "jsdom/lib/jsdom/level1/core" ) ;
338
+ Object . defineProperties ( core . CSSStyleDeclaration . prototype , {
339
+ padding : PADDING . definition ,
340
+ margin : MARGIN . definition
341
+ } ) ;
342
+ }
343
+ //
344
+ // Check if paddingTop sets padding
345
+ //
326
346
div . style . padding = "1px 2px 3px 4px" ;
327
347
div . style . paddingTop = "10px" ;
328
348
if ( div . style . padding !== "10px 2px 3px 4px" ) {
@@ -378,11 +398,17 @@ exports.patch = function (jsdom) {
378
398
}
379
399
} ) ;
380
400
}
401
+ //
402
+ // Check if width can be "auto"
403
+ //
381
404
div . style . width = "auto" ;
382
405
if ( div . style . width !== "auto" ) {
383
406
var core = require ( "jsdom/lib/jsdom/level1/core" ) ;
384
407
Object . defineProperties ( core . CSSStyleDeclaration . prototype , { width : WIDTH } ) ;
385
408
}
409
+ //
410
+ // Check if units of ex are allowed
411
+ //
386
412
div . style . marginTop = "3ex" ;
387
413
if ( div . style . marginTop !== "3ex" ) FixValueType ( ) ;
388
414
}
0 commit comments