postcss-selector-parser
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.selectors[0].rules[0].type, 'attribute'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'attribute'); | ||
}); | ||
@@ -14,5 +14,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.selectors[0].rules[1].attribute, 'class'); | ||
t.equal(tree.selectors[0].rules[2].attribute, 'name'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[1].attribute, 'class'); | ||
t.equal(tree.nodes[0].nodes[2].attribute, 'name'); | ||
}); | ||
@@ -22,5 +22,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'name'); | ||
t.equal(tree.selectors[0].rules[0].operator, '='); | ||
t.equal(tree.selectors[0].rules[0].value, 'james'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'name'); | ||
t.equal(tree.nodes[0].nodes[0].operator, '='); | ||
t.equal(tree.nodes[0].nodes[0].value, 'james'); | ||
}); | ||
@@ -30,5 +30,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'name'); | ||
t.equal(tree.selectors[0].rules[0].operator, '='); | ||
t.equal(tree.selectors[0].rules[0].value, '"james"'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'name'); | ||
t.equal(tree.nodes[0].nodes[0].operator, '='); | ||
t.equal(tree.nodes[0].nodes[0].value, '"james"'); | ||
}); | ||
@@ -38,6 +38,6 @@ | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[2].attribute, 'name'); | ||
t.equal(tree.selectors[0].rules[2].combinator, ' '); | ||
t.equal(tree.selectors[0].rules[2].rules[0].combinator, ' > '); | ||
t.equal(tree.selectors[0].rules[2].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[2].attribute, 'name'); | ||
t.equal(tree.nodes[0].nodes[3].value, ' '); | ||
t.equal(tree.nodes[0].nodes[5].value, '>'); | ||
t.equal(tree.nodes[0].nodes[6].value, 'h2'); | ||
}); | ||
@@ -47,6 +47,6 @@ | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' > '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.selectors[0].rules[0].rules[1].value, 'test'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[1].value, '>'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[3].value, 'test'); | ||
}); | ||
@@ -56,5 +56,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, '"james"'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' > '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[0].value, '"james"'); | ||
t.equal(tree.nodes[0].nodes[1].value, '>'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h1'); | ||
}); | ||
@@ -64,13 +64,13 @@ | ||
t.plan(11); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.selectors[0].rules[0].value, '"test.com"'); | ||
t.equal(tree.selectors[0].rules[1].attribute, 'rel'); | ||
t.equal(tree.selectors[0].rules[1].value, '"external"'); | ||
t.equal(tree.selectors[0].rules[2].attribute, 'id'); | ||
t.notOk(tree.selectors[0].rules[2].value, 'should not have a value'); | ||
t.equal(tree.selectors[0].rules[3].attribute, 'class'); | ||
t.equal(tree.selectors[0].rules[3].value, '"test"'); | ||
t.equal(tree.selectors[0].rules[3].combinator, ' > '); | ||
t.equal(tree.selectors[0].rules[3].rules[0].attribute, 'name'); | ||
t.notOk(tree.selectors[0].rules[3].rules[0].value, 'should not have a value'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].value, '"test.com"'); | ||
t.equal(tree.nodes[0].nodes[1].attribute, 'rel'); | ||
t.equal(tree.nodes[0].nodes[1].value, '"external"'); | ||
t.equal(tree.nodes[0].nodes[2].attribute, 'id'); | ||
t.notOk(tree.nodes[0].nodes[2].value, 'should not have a value'); | ||
t.equal(tree.nodes[0].nodes[3].attribute, 'class'); | ||
t.equal(tree.nodes[0].nodes[3].value, '"test"'); | ||
t.equal(tree.nodes[0].nodes[4].value, '>'); | ||
t.equal(tree.nodes[0].nodes[5].attribute, 'name'); | ||
t.notOk(tree.nodes[0].nodes[5].value, 'should not have a value'); | ||
}); | ||
@@ -80,6 +80,6 @@ | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[0].operator, '*='); | ||
t.equal(tree.selectors[1].rules[0].operator, '^='); | ||
t.equal(tree.selectors[2].rules[0].operator, '$='); | ||
t.equal(tree.selectors[3].rules[0].operator, '|='); | ||
t.equal(tree.nodes[0].nodes[0].operator, '*='); | ||
t.equal(tree.nodes[1].nodes[0].operator, '^='); | ||
t.equal(tree.nodes[2].nodes[0].operator, '$='); | ||
t.equal(tree.nodes[3].nodes[0].operator, '|='); | ||
}); | ||
@@ -89,5 +89,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[1].attribute, ' href '); | ||
t.equal(tree.selectors[0].rules[1].operator, '*='); | ||
t.equal(tree.selectors[0].rules[1].value, ' "test" '); | ||
t.equal(tree.nodes[0].nodes[1].attribute, ' href '); | ||
t.equal(tree.nodes[0].nodes[1].operator, '*='); | ||
t.equal(tree.nodes[0].nodes[1].value, ' "test" '); | ||
}); | ||
@@ -97,4 +97,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, '"test"'); | ||
t.equal(tree.selectors[0].rules[0].insensitive, true); | ||
t.equal(tree.nodes[0].nodes[0].value, '"test"'); | ||
t.equal(tree.nodes[0].nodes[0].insensitive, true); | ||
}); | ||
@@ -104,4 +104,14 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, 'TEsT'); | ||
t.equal(tree.selectors[0].rules[0].raw.insensitive, ' i '); | ||
t.equal(tree.nodes[0].nodes[0].value, 'TEsT'); | ||
t.equal(tree.nodes[0].nodes[0].raw.insensitive, ' i '); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' [href] , [class] ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.after, ' '); | ||
t.equal(tree.nodes[1].nodes[0].attribute, 'class'); | ||
t.equal(tree.nodes[1].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[0].spaces.after, ' '); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, 'one'); | ||
t.equal(tree.selectors[0].rules[0].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'one'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'class'); | ||
}); | ||
@@ -14,5 +14,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'one'); | ||
t.equal(tree.selectors[0].rules[1].value, 'two'); | ||
t.equal(tree.selectors[0].rules[2].value, 'three'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'one'); | ||
t.equal(tree.nodes[0].nodes[1].value, 'two'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'three'); | ||
}); | ||
@@ -22,4 +22,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'class'); | ||
}); | ||
@@ -29,4 +29,14 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].type, 'class'); | ||
t.equal(tree.selectors[0].rules[0].value, '\\31\\ 0'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[0].value, '\\31\\ 0'); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' .h1 , .h2 ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.after, ' '); | ||
t.equal(tree.nodes[1].nodes[0].value, 'h2'); | ||
t.equal(tree.nodes[1].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[0].spaces.after, ' '); | ||
}); |
@@ -5,14 +5,23 @@ 'use strict'; | ||
(0, _utilHelpers.test)('multiple combinating spaces', 'h1 h2', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].value, ' '); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
(0, _utilHelpers.test)('column combinator', '.selected||td', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'selected'); | ||
t.equal(tree.selectors[0].rules[0].combinator, '||'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'td'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'selected'); | ||
t.equal(tree.nodes[0].nodes[1].value, '||'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'td'); | ||
}); | ||
(0, _utilHelpers.test)('column combinator (2)', '.selected || td', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'selected'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' || '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'td'); | ||
t.plan(5); | ||
t.equal(tree.nodes[0].nodes[0].value, 'selected'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[1].value, '||'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.after, ' '); | ||
t.equal(tree.nodes[0].nodes[2].value, 'td'); | ||
}); | ||
@@ -22,13 +31,12 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].value, ' '); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
(0, _utilHelpers.test)('multiple descendant combinators', 'h1 h2 h3 h4', function (t, tree) { | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' ', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, ' ', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].rules[0].combinator, ' ', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].rules[0].rules[0].combinator, '', 'should not have a combinator on the last node'); | ||
t.plan(3); | ||
t.equal(tree.nodes[0].nodes[1].value, ' ', 'should have a combinator'); | ||
t.equal(tree.nodes[0].nodes[3].value, ' ', 'should have a combinator'); | ||
t.equal(tree.nodes[0].nodes[5].value, ' ', 'should have a combinator'); | ||
}); | ||
@@ -38,5 +46,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, '~'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].value, '~'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
@@ -46,20 +54,23 @@ | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' ~'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, ''); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[1].value, '~'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
(0, _utilHelpers.test)('adjacent sibling combinator (3)', 'h1~ h2', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, '~ '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.plan(4); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].value, '~'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.after, ' '); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
(0, _utilHelpers.test)('adjacent sibling combinator (4)', 'h1 ~ h2', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' ~ '); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.plan(5); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[1].value, '~'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.after, ' '); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
}); | ||
@@ -69,28 +80,25 @@ | ||
t.plan(5); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].combinator, '~'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].value, 'h2'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, '~'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].rules[0].value, 'h3'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[1].value, '~'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[3].value, '~'); | ||
t.equal(tree.nodes[0].nodes[4].value, 'h3'); | ||
}); | ||
(0, _utilHelpers.test)('multiple combinators', 'h1~h2>h3', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].combinator, '~', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, '>', 'should have a combinator'); | ||
t.notOk(tree.selectors[0].rules[0].rules[0].rules[0].combinator, 'should not have a combinator on the last node'); | ||
t.plan(2); | ||
t.equal(tree.nodes[0].nodes[1].value, '~', 'should have a combinator'); | ||
t.equal(tree.nodes[0].nodes[3].value, '>', 'should have a combinator'); | ||
}); | ||
(0, _utilHelpers.test)('multiple combinators with whitespaces', 'h1 + h2 > h3', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].combinator, ' + ', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, ' > ', 'should have a combinator'); | ||
t.notOk(tree.selectors[0].rules[0].rules[0].rules[0].combinator, 'should not have a combinator on the last node'); | ||
t.plan(2); | ||
t.equal(tree.nodes[0].nodes[1].value, '+', 'should have a combinator'); | ||
t.equal(tree.nodes[0].nodes[3].value, '>', 'should have a combinator'); | ||
}); | ||
(0, _utilHelpers.test)('multiple combinators with whitespaces', 'h1+ h2 >h3', function (t, tree) { | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].combinator, '+ ', 'should have a combinator'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].combinator, ' >', 'should have a combinator'); | ||
t.notOk(tree.selectors[0].rules[0].rules[0].rules[0].combinator, 'should not have a combinator on the last node'); | ||
t.plan(2); | ||
t.equal(tree.nodes[0].nodes[1].value, '+', 'should have a combinator'); | ||
t.equal(tree.nodes[0].nodes[3].value, '>', 'should have a combinator'); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, '/*test comment*/'); | ||
t.equal(tree.selectors[0].rules[1].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[0].value, '/*test comment*/'); | ||
t.equal(tree.nodes[0].nodes[1].value, 'h2'); | ||
}); | ||
@@ -14,8 +14,8 @@ | ||
t.plan(6); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag', 'should have a tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'comment', 'should have a comment'); | ||
t.equal(tree.selectors[0].rules[2].type, 'tag', 'should have a tag'); | ||
t.equal(tree.selectors[0].rules[3].type, 'comment', 'should have a comment'); | ||
t.equal(tree.selectors[0].rules[4].type, 'class', 'should have a class name'); | ||
t.equal(tree.selectors[0].rules[5].type, 'comment', 'should have a comment'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag', 'should have a tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'comment', 'should have a comment'); | ||
t.equal(tree.nodes[0].nodes[2].type, 'tag', 'should have a tag'); | ||
t.equal(tree.nodes[0].nodes[3].type, 'comment', 'should have a comment'); | ||
t.equal(tree.nodes[0].nodes[4].type, 'class', 'should have a class name'); | ||
t.equal(tree.nodes[0].nodes[5].type, 'comment', 'should have a comment'); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, 'one'); | ||
t.equal(tree.selectors[0].rules[0].type, 'id'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'one'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'id'); | ||
}); | ||
@@ -14,9 +14,9 @@ | ||
t.plan(6); | ||
t.equal(tree.selectors[0].rules[0].value, 'one'); | ||
t.equal(tree.selectors[0].rules[1].value, 'two'); | ||
t.equal(tree.selectors[0].rules[2].value, 'three'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'one'); | ||
t.equal(tree.nodes[0].nodes[1].value, 'two'); | ||
t.equal(tree.nodes[0].nodes[2].value, 'three'); | ||
t.equal(tree.selectors[0].rules[0].type, 'id'); | ||
t.equal(tree.selectors[0].rules[1].type, 'class'); | ||
t.equal(tree.selectors[0].rules[2].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'id'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[2].type, 'class'); | ||
}); | ||
@@ -26,4 +26,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'id'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'id'); | ||
}); | ||
@@ -33,5 +33,15 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'id'); | ||
t.equal(tree.selectors[0].rules[2].type, 'class'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'id'); | ||
t.equal(tree.nodes[0].nodes[2].type, 'class'); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' #h1 , #h2 ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.after, ' '); | ||
t.equal(tree.nodes[1].nodes[0].value, 'h2'); | ||
t.equal(tree.nodes[1].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[0].spaces.after, ' '); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, 'postcss'); | ||
t.equal(tree.selectors[0].rules[0].value, 'button'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, 'postcss'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'button'); | ||
}); | ||
@@ -14,4 +14,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, 'postcss'); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, 'postcss'); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
}); | ||
@@ -21,4 +21,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, '*'); | ||
t.equal(tree.selectors[0].rules[0].value, 'button'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, '*'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'button'); | ||
}); | ||
@@ -28,4 +28,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, 'postcss'); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, 'postcss'); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
}); | ||
@@ -35,4 +35,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, '*'); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, '*'); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
}); | ||
@@ -42,4 +42,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, true); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, true); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
}); | ||
@@ -49,4 +49,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, true); | ||
t.equal(tree.selectors[0].rules[0].value, 'button'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, true); | ||
t.equal(tree.nodes[0].nodes[0].value, 'button'); | ||
}); | ||
@@ -56,4 +56,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, 'postcss'); | ||
t.equal(tree.selectors[0].rules[0].value, 'test'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, 'postcss'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'test'); | ||
}); | ||
@@ -63,4 +63,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, 'postcss'); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, 'postcss'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
}); | ||
@@ -70,4 +70,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, '*'); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, '*'); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
}); | ||
@@ -77,4 +77,4 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].namespace, true); | ||
t.equal(tree.selectors[0].rules[0].attribute, 'href'); | ||
t.equal(tree.nodes[0].nodes[0].namespace, true); | ||
t.equal(tree.nodes[0].nodes[0].attribute, 'href'); | ||
}); |
@@ -7,5 +7,5 @@ 'use strict'; | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'pseudo'); | ||
t.equal(tree.selectors[0].rules[1].value, ':after'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'pseudo'); | ||
t.equal(tree.nodes[0].nodes[1].value, ':after'); | ||
}); | ||
@@ -15,5 +15,5 @@ | ||
t.plan(3); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.selectors[0].rules[1].type, 'pseudo'); | ||
t.equal(tree.selectors[0].rules[1].value, '::after'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'pseudo'); | ||
t.equal(tree.nodes[0].nodes[1].value, '::after'); | ||
}); | ||
@@ -23,6 +23,6 @@ | ||
t.plan(4); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.selectors[0].rules[1].value, ':target'); | ||
t.equal(tree.selectors[0].rules[2].value, '::before'); | ||
t.equal(tree.selectors[1].rules[1].value, ':after'); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[1].value, ':target'); | ||
t.equal(tree.nodes[0].nodes[2].value, '::before'); | ||
t.equal(tree.nodes[1].nodes[1].value, ':after'); | ||
}); | ||
@@ -32,4 +32,37 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[1].value, ':not'); | ||
t.equal(tree.selectors[0].rules[1].parameters.selectors[0].value, 'heading'); | ||
t.equal(tree.nodes[0].nodes[1].value, ':not'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading'); | ||
}); | ||
(0, _utilHelpers.test)('negation pseudo element (2)', 'h1:not(.heading, .title, .content)', function (t, tree) { | ||
t.plan(4); | ||
t.equal(tree.nodes[0].nodes[1].value, ':not'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[1].nodes[0].value, 'title'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[2].nodes[0].value, 'content'); | ||
}); | ||
(0, _utilHelpers.test)('negation pseudo element (3)', 'h1:not(.heading > .title) > h1', function (t, tree) { | ||
t.plan(5); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'heading'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[1].value, '>'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[2].value, 'title'); | ||
t.equal(tree.nodes[0].nodes[2].value, '>'); | ||
t.equal(tree.nodes[0].nodes[3].value, 'h1'); | ||
}); | ||
(0, _utilHelpers.test)('negation pseudo element (4)', 'h1:not(h2:not(h3))', function (t, tree) { | ||
t.plan(2); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[1].nodes[0].nodes[0].value, 'h3'); | ||
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[1].nodes[0].nodes[0].parent.type, 'selector'); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' h1:after , h2:after ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[1].value, ':after'); | ||
t.equal(tree.nodes[0].nodes[1].spaces.after, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[1].value, ':after'); | ||
t.equal(tree.nodes[1].nodes[1].spaces.after, ' '); | ||
}); |
@@ -7,4 +7,4 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[0].rules[0].type, 'tag'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'tag'); | ||
}); | ||
@@ -14,4 +14,14 @@ | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, 'h1'); | ||
t.equal(tree.selectors[1].rules[0].value, 'h2'); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[1].nodes[0].value, 'h2'); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' h1 , h2 ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].value, 'h1'); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.after, ' '); | ||
t.equal(tree.nodes[1].nodes[0].value, 'h2'); | ||
t.equal(tree.nodes[1].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[0].spaces.after, ' '); | ||
}); |
@@ -7,10 +7,21 @@ 'use strict'; | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].value, '*'); | ||
t.equal(tree.selectors[0].rules[0].type, 'universal'); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].type, 'universal'); | ||
}); | ||
(0, _utilHelpers.test)('lobotomized owl', '* + *', function (t, tree) { | ||
t.plan(2); | ||
t.equal(tree.selectors[0].rules[0].type, 'universal'); | ||
t.equal(tree.selectors[0].rules[0].rules[0].type, 'universal'); | ||
t.plan(3); | ||
t.equal(tree.nodes[0].nodes[0].type, 'universal'); | ||
t.equal(tree.nodes[0].nodes[1].type, 'combinator'); | ||
t.equal(tree.nodes[0].nodes[2].type, 'universal'); | ||
}); | ||
(0, _utilHelpers.test)('extraneous non-combinating whitespace', ' * , * ', function (t, tree) { | ||
t.plan(6); | ||
t.equal(tree.nodes[0].nodes[0].value, '*'); | ||
t.equal(tree.nodes[0].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[0].nodes[0].spaces.after, ' '); | ||
t.equal(tree.nodes[1].nodes[0].value, '*'); | ||
t.equal(tree.nodes[1].nodes[0].spaces.before, ' '); | ||
t.equal(tree.nodes[1].nodes[0].spaces.after, ' '); | ||
}); |
@@ -17,5 +17,5 @@ 'use strict'; | ||
var _selectorsSelectors = require('./selectors/selectors'); | ||
var _selectorsSelector = require('./selectors/selector'); | ||
var _selectorsSelectors2 = _interopRequireDefault(_selectorsSelectors); | ||
var _selectorsSelector2 = _interopRequireDefault(_selectorsSelector); | ||
@@ -50,2 +50,6 @@ var _selectorsClassName = require('./selectors/className'); | ||
var _selectorsCombinator = require('./selectors/combinator'); | ||
var _selectorsCombinator2 = _interopRequireDefault(_selectorsCombinator); | ||
var _sortAscending = require('./sortAscending'); | ||
@@ -79,3 +83,3 @@ | ||
var selectors = new _selectorsSelectors2['default'](); | ||
var selectors = new _selectorsSelector2['default'](); | ||
this.root.append(selectors); | ||
@@ -130,3 +134,3 @@ | ||
} | ||
this.current.append(attr); | ||
this.newNode(attr); | ||
this.position++; | ||
@@ -140,5 +144,11 @@ } | ||
} | ||
var combinator = ''; | ||
var combinator = new _selectorsCombinator2['default']({ value: '' }); | ||
while (this.position < this.tokens.length && this.currToken[0] === 'space' || this.currToken[0] === 'combinator') { | ||
combinator += this.currToken[1]; | ||
if (this.nextToken[0] === 'combinator') { | ||
combinator.spaces.before = this.currToken[1]; | ||
} else if (this.prevToken[0] === 'combinator') { | ||
combinator.spaces.after = this.currToken[1]; | ||
} else if (this.currToken[0] === 'space' || this.currToken[0] === 'combinator') { | ||
combinator.value = this.currToken[1]; | ||
} | ||
this.position++; | ||
@@ -149,8 +159,6 @@ if (this.position === this.tokens.length) { | ||
} | ||
var last = this.current.rules[this.current.rules.length - 1]; | ||
if (!last) { | ||
if (!this.current.last) { | ||
this.error('Unexpected left hand side combinator.'); | ||
} | ||
last.combinator = combinator; | ||
this.current = last; | ||
return this.newNode(combinator); | ||
} | ||
@@ -163,8 +171,3 @@ }, { | ||
} | ||
var selectors = new _selectorsSelectors2['default'](); | ||
if (!this.inParens) { | ||
while (!this.current.parent.selectors) { | ||
this.current = this.current.parent; | ||
} | ||
} | ||
var selectors = new _selectorsSelector2['default'](); | ||
this.current.parent.append(selectors); | ||
@@ -178,3 +181,3 @@ this.current = selectors; | ||
var comment = new _selectorsComment2['default']({ value: this.currToken[1] }); | ||
this.current.append(comment); | ||
this.newNode(comment); | ||
this.position++; | ||
@@ -211,5 +214,9 @@ } | ||
var pseudo = new _selectorsPseudo2['default']({ value: pseudoStr }); | ||
this.newNode(pseudo); | ||
if (this.currToken && this.currToken[0] === '(') { | ||
var selector = new _selectorsSelector2['default'](); | ||
var cache = this.current; | ||
pseudo.append(selector); | ||
this.current = selector; | ||
var balanced = 1; | ||
var inside = []; | ||
this.position++; | ||
@@ -220,5 +227,28 @@ while (this.position < this.tokens.length && balanced) { | ||
if (balanced) { | ||
inside.push(this.currToken); | ||
switch (this.currToken[0]) { | ||
case 'space': | ||
this.space(); | ||
break; | ||
case 'comment': | ||
this.comment(); | ||
break; | ||
case '[': | ||
this.attribute(); | ||
break; | ||
case 'word': | ||
this.word(); | ||
break; | ||
case ':': | ||
this.pseudo(); | ||
break; | ||
case ',': | ||
this.comma(); | ||
break; | ||
case 'combinator': | ||
this.combinator(); | ||
break; | ||
} | ||
} else { | ||
this.position++; | ||
} | ||
this.position++; | ||
} | ||
@@ -228,41 +258,4 @@ if (balanced) { | ||
} | ||
var cache = { | ||
current: this.current, | ||
tokens: this.tokens, | ||
position: this.position | ||
}; | ||
this.position = 0; | ||
this.tokens = inside; | ||
this.current = pseudo.parameters; | ||
while (this.position < this.tokens.length) { | ||
switch (this.currToken[0]) { | ||
case 'space': | ||
this.space(); | ||
break; | ||
case 'comment': | ||
this.comment(); | ||
break; | ||
case '[': | ||
this.attribute(); | ||
break; | ||
case 'word': | ||
this.word(); | ||
break; | ||
case ':': | ||
this.pseudo(); | ||
break; | ||
case ',': | ||
this.comma(); | ||
break; | ||
case 'combinator': | ||
this.combinator(); | ||
break; | ||
} | ||
this.position++; | ||
} | ||
this.current = cache.current; | ||
this.tokens = cache.tokens; | ||
this.position = cache.position; | ||
this.current = cache; | ||
} | ||
this.current.append(pseudo); | ||
} else { | ||
@@ -278,6 +271,6 @@ this.error('Unexpected "' + this.currToken[0] + '" found.'); | ||
if (this.position === 0 || this.prevToken[0] === ',') { | ||
this.current.spaces.before = token[1]; | ||
this.spaces = token[1]; | ||
this.position++; | ||
} else if (this.position === this.tokens.length - 1) { | ||
this.current.spaces.after = token[1]; | ||
} else if (this.position === this.tokens.length - 1 || this.nextToken[0] === ',') { | ||
this.current.last.spaces.after = token[1]; | ||
this.position++; | ||
@@ -296,7 +289,3 @@ } else { | ||
} | ||
var universal = new _selectorsUniversal2['default']({ value: this.currToken[1] }); | ||
if (namespace) { | ||
universal.namespace = namespace; | ||
} | ||
this.current.append(universal); | ||
this.newNode(new _selectorsUniversal2['default']({ value: this.currToken[1] }), namespace); | ||
this.position++; | ||
@@ -345,7 +334,3 @@ } | ||
} | ||
if (namespace) { | ||
node.namespace = namespace; | ||
} | ||
_this.current.append(node); | ||
_this.newNode(node, namespace); | ||
}); | ||
@@ -388,3 +373,3 @@ this.position++; | ||
}, { | ||
key: 'currToken', | ||
key: 'newNode', | ||
@@ -395,2 +380,14 @@ /** | ||
value: function newNode(node, namespace) { | ||
if (namespace) { | ||
node.namespace = namespace; | ||
} | ||
if (this.spaces) { | ||
node.spaces.before = this.spaces; | ||
this.spaces = ''; | ||
} | ||
return this.current.append(node); | ||
} | ||
}, { | ||
key: 'currToken', | ||
get: function () { | ||
@@ -397,0 +394,0 @@ return this.tokens[this.position]; |
@@ -17,7 +17,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _namespace = require('./namespace'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var Attribute = (function (_Selector) { | ||
var Attribute = (function (_Namespace) { | ||
function Attribute(opts) { | ||
@@ -27,6 +27,2 @@ _classCallCheck(this, Attribute); | ||
_get(Object.getPrototypeOf(Attribute.prototype), 'constructor', this).call(this, opts); | ||
this.insensitive = opts.insensitive; | ||
this.attribute = opts.attribute; | ||
this.operator = opts.operator; | ||
this.namespace = opts.namespace; | ||
this.type = 'attribute'; | ||
@@ -36,3 +32,3 @@ this.raw = {}; | ||
_inherits(Attribute, _Selector); | ||
_inherits(Attribute, _Namespace); | ||
@@ -42,4 +38,3 @@ _createClass(Attribute, [{ | ||
value: function toString() { | ||
var namespace = this.namespace ? (typeof this.namespace === 'string' ? this.namespace : '') + '|' : ''; | ||
var selector = [this.spaces.before, '[', namespace, this.attribute]; | ||
var selector = [this.spaces.before, '[', this.ns, this.attribute]; | ||
@@ -57,4 +52,3 @@ if (this.operator) { | ||
} | ||
selector.push(']' + this.combinator); | ||
selector.push(this.rules.map(String).join('')); | ||
selector.push(']'); | ||
return selector.concat(this.spaces.after).join(''); | ||
@@ -65,5 +59,5 @@ } | ||
return Attribute; | ||
})(_selector2['default']); | ||
})(_namespace2['default']); | ||
exports['default'] = Attribute; | ||
module.exports = exports['default']; |
@@ -17,7 +17,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _namespace = require('./namespace'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var ClassName = (function (_Selector) { | ||
var ClassName = (function (_Namespace) { | ||
function ClassName(opts) { | ||
@@ -30,3 +30,3 @@ _classCallCheck(this, ClassName); | ||
_inherits(ClassName, _Selector); | ||
_inherits(ClassName, _Namespace); | ||
@@ -36,4 +36,3 @@ _createClass(ClassName, [{ | ||
value: function toString() { | ||
var namespace = this.namespace ? (typeof this.namespace === 'string' ? this.namespace : '') + '|' : ''; | ||
return [this.spaces.before, namespace, String('.' + this.value), this.combinator, this.rules.map(String).join(''), this.spaces.after].join(''); | ||
return [this.spaces.before, this.ns, String('.' + this.value), this.spaces.after].join(''); | ||
} | ||
@@ -43,5 +42,5 @@ }]); | ||
return ClassName; | ||
})(_selector2['default']); | ||
})(_namespace2['default']); | ||
exports['default'] = ClassName; | ||
module.exports = exports['default']; |
@@ -15,7 +15,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _node = require('./node'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _node2 = _interopRequireDefault(_node); | ||
var Comment = (function (_Selector) { | ||
var Comment = (function (_Node) { | ||
function Comment(opts) { | ||
@@ -28,8 +28,8 @@ _classCallCheck(this, Comment); | ||
_inherits(Comment, _Selector); | ||
_inherits(Comment, _Node); | ||
return Comment; | ||
})(_selector2['default']); | ||
})(_node2['default']); | ||
exports['default'] = Comment; | ||
module.exports = exports['default']; |
@@ -17,7 +17,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _namespace = require('./namespace'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var ID = (function (_Selector) { | ||
var ID = (function (_Namespace) { | ||
function ID(opts) { | ||
@@ -30,3 +30,3 @@ _classCallCheck(this, ID); | ||
_inherits(ID, _Selector); | ||
_inherits(ID, _Namespace); | ||
@@ -36,4 +36,3 @@ _createClass(ID, [{ | ||
value: function toString() { | ||
var namespace = this.namespace ? (typeof this.namespace === 'string' ? this.namespace : '') + '|' : ''; | ||
return [this.spaces.before, namespace, String('#' + this.value), this.combinator, this.rules.map(String).join(''), this.spaces.after].join(''); | ||
return [this.spaces.before, this.ns, String('#' + this.value), this.spaces.after].join(''); | ||
} | ||
@@ -43,5 +42,5 @@ }]); | ||
return ID; | ||
})(_selector2['default']); | ||
})(_namespace2['default']); | ||
exports['default'] = ID; | ||
module.exports = exports['default']; |
@@ -17,11 +17,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _container = require('./container'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _container2 = _interopRequireDefault(_container); | ||
var _parentheses = require('./parentheses'); | ||
var _parentheses2 = _interopRequireDefault(_parentheses); | ||
var Pseudo = (function (_Selector) { | ||
var Pseudo = (function (_Container) { | ||
function Pseudo(opts) { | ||
@@ -31,7 +27,6 @@ _classCallCheck(this, Pseudo); | ||
_get(Object.getPrototypeOf(Pseudo.prototype), 'constructor', this).call(this, opts); | ||
this.parameters = new _parentheses2['default'](); | ||
this.type = 'pseudo'; | ||
} | ||
_inherits(Pseudo, _Selector); | ||
_inherits(Pseudo, _Container); | ||
@@ -41,3 +36,4 @@ _createClass(Pseudo, [{ | ||
value: function toString() { | ||
return [this.spaces.before, String(this.value), String(this.parameters), this.combinator, this.rules.map(String).join(''), this.spaces.after].join(''); | ||
var params = this.nodes.length ? '(' + this.nodes.map(String).join(',') + ')' : ''; | ||
return [this.spaces.before, String(this.value), params, this.spaces.after].join(''); | ||
} | ||
@@ -47,5 +43,5 @@ }]); | ||
return Pseudo; | ||
})(_selector2['default']); | ||
})(_container2['default']); | ||
exports['default'] = Pseudo; | ||
module.exports = exports['default']; |
@@ -9,30 +9,28 @@ 'use strict'; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var Root = (function () { | ||
function Root() { | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
var _container = require('./container'); | ||
var _container2 = _interopRequireDefault(_container); | ||
var Root = (function (_Container) { | ||
function Root(opts) { | ||
_classCallCheck(this, Root); | ||
_get(Object.getPrototypeOf(Root.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'root'; | ||
this.selectors = []; | ||
this.spaces = { before: '', after: '' }; | ||
} | ||
_inherits(Root, _Container); | ||
_createClass(Root, [{ | ||
key: 'append', | ||
value: function append(selector) { | ||
selector.parent = this; | ||
this.selectors.push(selector); | ||
return this; | ||
} | ||
}, { | ||
key: 'each', | ||
value: function each(callback) { | ||
this.selectors.forEach(callback); | ||
return this; | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
return [this.spaces.before, this.selectors.map(String).join(','), this.spaces.after].join(''); | ||
return [this.spaces.before, this.nodes.map(String).join(','), this.spaces.after].join(''); | ||
} | ||
@@ -42,5 +40,5 @@ }]); | ||
return Root; | ||
})(); | ||
})(_container2['default']); | ||
exports['default'] = Root; | ||
module.exports = exports['default']; |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
@@ -18,7 +16,7 @@ | ||
var _selectors = require('./selectors'); | ||
var _container = require('./container'); | ||
var _selectors2 = _interopRequireDefault(_selectors); | ||
var _container2 = _interopRequireDefault(_container); | ||
var Selector = (function (_Selectors) { | ||
var Selector = (function (_Container) { | ||
function Selector(opts) { | ||
@@ -29,20 +27,10 @@ _classCallCheck(this, Selector); | ||
this.type = 'selector'; | ||
this.value = opts.value; | ||
this.combinator = ''; | ||
} | ||
_inherits(Selector, _Selectors); | ||
_inherits(Selector, _Container); | ||
_createClass(Selector, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
var namespace = this.namespace ? (typeof this.namespace === 'string' ? this.namespace : '') + '|' : ''; | ||
return [this.spaces.before, namespace, String(this.value), this.combinator, this.rules.map(String).join(''), this.spaces.after].join(''); | ||
} | ||
}]); | ||
return Selector; | ||
})(_selectors2['default']); | ||
})(_container2['default']); | ||
exports['default'] = Selector; | ||
module.exports = exports['default']; |
@@ -15,7 +15,7 @@ 'use strict'; | ||
var _selector = require('./selector'); | ||
var _namespace = require('./namespace'); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var Tag = (function (_Selector) { | ||
var Tag = (function (_Namespace) { | ||
function Tag(opts) { | ||
@@ -28,8 +28,8 @@ _classCallCheck(this, Tag); | ||
_inherits(Tag, _Selector); | ||
_inherits(Tag, _Namespace); | ||
return Tag; | ||
})(_selector2['default']); | ||
})(_namespace2['default']); | ||
exports['default'] = Tag; | ||
module.exports = exports['default']; |
@@ -15,7 +15,7 @@ 'use strict'; | ||
var _tag = require('./tag'); | ||
var _namespace = require('./namespace'); | ||
var _tag2 = _interopRequireDefault(_tag); | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var Universal = (function (_Tag) { | ||
var Universal = (function (_Namespace) { | ||
function Universal(opts) { | ||
@@ -28,8 +28,8 @@ _classCallCheck(this, Universal); | ||
_inherits(Universal, _Tag); | ||
_inherits(Universal, _Namespace); | ||
return Universal; | ||
})(_tag2['default']); | ||
})(_namespace2['default']); | ||
exports['default'] = Universal; | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss-selector-parser", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "babel": "^5.4.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83451
35
1603