Skip to content

Commit f2f3dc0

Browse files
committed
Updated parser (fixes #261, fixes #259, fixes #242)
1 parent 9c91c47 commit f2f3dc0

2 files changed

Lines changed: 43 additions & 6 deletions

File tree

lib/parserlib.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
24+
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
931931
THE SOFTWARE.
932932
933933
*/
934-
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
934+
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
935935
(function(){
936936
var EventTarget = parserlib.util.EventTarget,
937937
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2640,7 +2640,8 @@ Parser.prototype = function(){
26402640
expr = null,
26412641
prio = null,
26422642
error = null,
2643-
invalid = null;
2643+
invalid = null,
2644+
propertyName= "";
26442645

26452646
property = this._property();
26462647
if (property !== null){
@@ -2657,8 +2658,20 @@ Parser.prototype = function(){
26572658

26582659
prio = this._prio();
26592660

2661+
/*
2662+
* If hacks should be allowed, then only check the root
2663+
* property. If hacks should not be allowed, treat
2664+
* _property or *property as invalid properties.
2665+
*/
2666+
propertyName = property.toString();
2667+
if (this.options.starHack && property.hack == "*" ||
2668+
this.options.underscoreHack && property.hack == "_") {
2669+
2670+
propertyName = property.text;
2671+
}
2672+
26602673
try {
2661-
this._validateProperty(property, expr);
2674+
this._validateProperty(propertyName, expr);
26622675
} catch (ex) {
26632676
invalid = ex;
26642677
}
@@ -3499,6 +3512,7 @@ var Properties = {
34993512
"background-repeat" : { multi: "<repeat-style>" },
35003513
"background-size" : { multi: "<bg-size>", comma: true },
35013514
"baseline-shift" : "baseline | sub | super | <percentage> | <length>",
3515+
"behavior" : 1,
35023516
"binding" : 1,
35033517
"bleed" : "<length>",
35043518
"bookmark-label" : "<content> | <attr> | <string>",
@@ -3845,6 +3859,7 @@ var Properties = {
38453859
"text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
38463860
"text-outline" : 1,
38473861
"text-overflow" : 1,
3862+
"text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
38483863
"text-shadow" : 1,
38493864
"text-transform" : "capitalize | uppercase | lowercase | none | inherit",
38503865
"text-wrap" : "normal | none | avoid",
@@ -5924,7 +5939,7 @@ var ValidationTypes = {
59245939
i, len, found = false;
59255940

59265941
for (i=0,len=args.length; i < len && !found; i++){
5927-
if (text == args[i]){
5942+
if (text == args[i].toLowerCase()){
59285943
found = true;
59295944
}
59305945
}
@@ -6016,7 +6031,7 @@ var ValidationTypes = {
60166031
},
60176032

60186033
"<gradient>": function(part) {
6019-
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
6034+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
60206035
},
60216036

60226037
"<box>": function(part){
@@ -6108,6 +6123,18 @@ var ValidationTypes = {
61086123
part,
61096124
i, len;
61106125

6126+
/*
6127+
<position> = [
6128+
[ left | center | right | top | bottom | <percentage> | <length> ]
6129+
|
6130+
[ left | center | right | <percentage> | <length> ]
6131+
[ top | center | bottom | <percentage> | <length> ]
6132+
|
6133+
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
6134+
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
6135+
]
6136+
6137+
*/
61116138

61126139
if (ValidationTypes.isAny(expression, "top | bottom")) {
61136140
result = true;

tests/rules/known-properties.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
Assert.areEqual(0, result.messages.length);
2020
},
2121

22+
"Using a known property with the star hack should not result in a warning": function(){
23+
var result = CSSLint.verify("h1 { *color: red;}", { "known-properties": 1 });
24+
Assert.areEqual(0, result.messages.length);
25+
},
26+
27+
"Using a known property with the underscore hack should not result in a warning": function(){
28+
var result = CSSLint.verify("h1 { _color: red;}", { "known-properties": 1 });
29+
Assert.areEqual(0, result.messages.length);
30+
},
31+
2232
"Using a vendor-prefix property should not result in a warning": function(){
2333
var result = CSSLint.verify("h2 { -moz-border-radius: 5px; }", { "known-properties": 1 });
2434
Assert.areEqual(0, result.messages.length);

0 commit comments

Comments
 (0)