Skip to content

Commit 17a2f01

Browse files
Onno van der Zeecscott
authored andcommitted
1 parent 08d0b3c commit 17a2f01

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

src/css/ValidationTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ var ValidationTypes = {
177177
},
178178

179179
"<padding-width>": function(part){
180-
return this["<length>"](part) || this["<percentage>"](part);
180+
return part.value >= 0 && (this["<length>"](part) || this["<percentage>"](part));
181181
},
182182

183183
"<shape>": function(part){

tests/css/CSSParserTests.htm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,50 @@ <h1>CSS Parser Tests</h1>
17971797

17981798
},
17991799

1800+
testPaddingLeft1: function(){
1801+
var parser = new Parser({ strict: true});
1802+
parser.addListener("property", function(event){
1803+
assert.isNull(event.invalid);
1804+
});
1805+
var result = parser.parse(".foo { padding-left: 6px; }");
1806+
1807+
},
1808+
1809+
testPaddingLeft2: function(){
1810+
var parser = new Parser({ strict: true});
1811+
parser.addListener("property", function(event){
1812+
assert.isNull(event.invalid);
1813+
});
1814+
var result = parser.parse(".foo { padding-left: 3%; }");
1815+
},
1816+
1817+
testPaddingLeft3: function(){
1818+
var parser = new Parser({ strict: true});
1819+
parser.addListener("property", function(event){
1820+
assert.isNull(event.invalid);
1821+
});
1822+
var result = parser.parse(".foo { padding-left: inherit; }");
1823+
1824+
},
1825+
1826+
testInvalidPaddingLeft1: function(){
1827+
var parser = new Parser({ strict: true});
1828+
parser.addListener("property", function(event){
1829+
assert.isNotNull(event.invalid);
1830+
assert.areEqual("Expected length greater than 0, percentage greater than 0 or inherit but found '-10px'.", event.invalid.message);
1831+
});
1832+
var result = parser.parse(".foo { padding-left: -10px; }");
1833+
},
1834+
1835+
testInvalidPaddingLeft2: function(){
1836+
var parser = new Parser({ strict: true});
1837+
parser.addListener("property", function(event){
1838+
assert.isNotNull(event.invalid);
1839+
assert.areEqual("Expected length, percentage or inherit but found 'auto'.", event.invalid.message);
1840+
});
1841+
var result = parser.parse(".foo { padding-left: auto; }");
1842+
},
1843+
18001844
testBorderWidth1: function(){
18011845
var parser = new Parser({ strict: true});
18021846
parser.addListener("property", function(event){

tests/css/Validation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,22 @@
10541054
}
10551055
}));
10561056

1057+
suite.add(new ValidationTestCase({
1058+
property: "padding-left",
1059+
1060+
valid: [
1061+
"6px",
1062+
"3%",
1063+
"inherit"
1064+
],
1065+
1066+
invalid: {
1067+
"-10px" : "Expected (<padding-width> | inherit) but found '-10px'.",
1068+
"-3%" : "Expected (<padding-width> | inherit) but found '-3%'.",
1069+
"auto" : "Expected (<padding-width> | inherit) but found 'auto'."
1070+
}
1071+
}));
1072+
10571073
suite.add(new ValidationTestCase({
10581074
property: "will-change",
10591075

0 commit comments

Comments
 (0)