Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Negation Selectors for selectors types that have been already i…

…mplemented
  • Loading branch information...
commit f015997d432d633f1fc913c26051031d642e2fe8 1 parent 572a14e
@bmavity authored
Showing with 28 additions and 24 deletions.
  1. +8 −5 src/cssSelector.ometa
  2. +20 −19 tests/test.js
View
13 src/cssSelector.ometa
@@ -53,7 +53,7 @@ ometa CssSelector <: Parser {
GREATER = w '>' -> { ' >' },
COMMA = w ',' -> { ' ,' },
TILDE = w '~' -> { ' ~' },
- NOT = ':' N O T '(',
+ NOT = ':' N O T '(' -> { ':not(' },
ATKEYWORD = '@' ident,
INVALID = invalid,
PERCENTAGE = num '%',
@@ -72,8 +72,8 @@ ometa CssSelector <: Parser {
| TILDE:t -> { t }
| S+ -> { ' ' },
combined_sequence = combinator:comb simple_selector_sequence:sel -> { comb + sel },
- simple_selector_sequence = (type_selector | universal):pre (HASH | class | attrib | pseudo | negation)*:post -> { pre + post.join('') }
- | (HASH | class | attrib | pseudo | negation)+:sels -> { sels.join('') },
+ simple_selector_sequence = (type_selector | universal):pre (HASH | class | attrib | negation | pseudo)*:post -> { pre + post.join('') }
+ | (HASH | class | attrib | negation | pseudo)+:sels -> { sels.join('') },
type_selector = namespace_prefix element_name
| element_name:ele -> { ele },
namespace_prefix = (IDENT | '*') '|'
@@ -99,8 +99,11 @@ ometa CssSelector <: Parser {
| expression_content:ec expression:e -> { ec + e }
| expression_content:ec S* -> { ec },
full_expression = (expression)+:ea -> { ea.join('') },
- negation = NOT S* negation_arg S* ')',
- negation_arg = type_selector | universal | HASH | class | attrib | pseudo
+ negation = NOT:n S* negation_arg:na S* ')' -> { n + na + ')' },
+
+ //negation_arg = (type_selector | universal | HASH | class | attrib | pseudo):na -> { na }
+ //Technically not allowed, but here for scss compatibility
+ negation_arg = (selectors_group):na -> { na }
}
CssSelector.initialize = function() {
View
39 tests/test.js
@@ -155,31 +155,32 @@ vows.describe('Nth Selectors').addBatch({
}).run();
-/*
- def test_negation_selectors
- assert_selector_parses(':not(foo|bar)')
- assert_selector_parses(':not(*|bar)')
+vows.describe('Negation Selectors').addBatch({
+ ':not(foo|bar)': shouldParse(),
+ ':not(*|bar)': shouldParse(),
- assert_selector_parses(':not(foo|*)')
- assert_selector_parses(':not(*|*)')
+ ':not(foo|*)': shouldParse(),
+ ':not(*|*)': shouldParse(),
- assert_selector_parses(':not(#blah)')
- assert_selector_parses(':not(.blah)')
+ ':not(#blah)': shouldParse(),
+ ':not(.blah)': shouldParse(),
- assert_selector_parses(':not([foo])')
- assert_selector_parses(':not([foo^="bar"])')
- assert_selector_parses(':not([baz|foo~="bar"])')
+ ':not([foo])': shouldParse(),
+ ':not([foo^="bar"])': shouldParse(),
+ ':not([baz|foo~="bar"])': shouldParse(),
- assert_selector_parses(':not(:hover)')
- assert_selector_parses(':not(:nth-child(2n + 3))')
+ ':not(:hover)': shouldParse(),
+ ':not(:nth-child(2n + 3))': shouldParse(),
- # Not technically allowed, but what the heck
- assert_selector_parses(':not(:not(#foo))')
- assert_selector_parses(':not(a#foo.bar)')
- assert_selector_parses(':not(#foo .bar > baz)')
- assert_selector_parses(':not(h1, h2, h3)')
- end
+ // Not technically allowed, but what the heck
+ ':not(:not(#foo))': shouldParse(),
+ ':not(a#foo.bar)': shouldParse(),
+ ':not(#foo .bar > baz)': shouldParse(),
+ ':not(h1, h2, h3)': shouldParse()
+}).run();
+
+/*
def test_moz_any_selector
assert_selector_parses(':-moz-any(h1, h2, h3)')
assert_selector_parses(':-moz-any(.foo)')
Please sign in to comment.
Something went wrong with that request. Please try again.