Permalink
Browse files

Implemented Namespaced Selectors

  • Loading branch information...
1 parent f015997 commit 4f41af4c12dd3cb14dc5f421c18919c55cb0fb7c @bmavity committed Sep 23, 2010
Showing with 23 additions and 19 deletions.
  1. +8 −8 src/cssSelector.ometa
  2. +15 −11 tests/test.js
View
16 src/cssSelector.ometa
@@ -72,15 +72,15 @@ 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 | 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 | '*') '|'
- | '|',
+ non_namespaced_selector = (HASH | class | attrib | negation | pseudo):sel -> { sel },
+ simple_selector_sequence = namespace_prefix:pre '*' non_namespaced_selector*:post -> { pre + '*' + post.join('') }
+ | namespace_prefix:pre element_name:ele non_namespaced_selector*:post -> { pre + ele + post.join('') }
+ | '*' non_namespaced_selector*:post -> { '*' + post.join('') }
+ | element_name:ele non_namespaced_selector*:post -> { ele + post.join('') }
+ | non_namespaced_selector+:sels -> { sels.join('') },
+ namespace_prefix = ('*' | IDENT):pre '|' -> { pre + '|' }
+ | '|' -> { '|' },
element_name = IDENT:i -> { i },
- universal = namespace_prefix '*'
- | '*',
class = '.' IDENT:i -> { '.' + i },
attrib = '[' S* possible_namespaced_attrib:att ']' -> { '[' + att + ']' },
View
26 tests/test.js
@@ -181,19 +181,23 @@ vows.describe('Negation Selectors').addBatch({
/*
- def test_moz_any_selector
- assert_selector_parses(':-moz-any(h1, h2, h3)')
- assert_selector_parses(':-moz-any(.foo)')
- assert_selector_parses(':-moz-any(foo bar, .baz > .bang)')
- end
+vows.describe('moz Any Selector').addBatch({
+ ':-moz-any(h1, h2, h3)': shouldParse(),
+ ':-moz-any(.foo)': shouldParse(),
+ ':-moz-any(foo bar, .baz > .bang)': shouldParse()
+}).run();
+*/
- def test_namespaced_selectors
- assert_selector_parses('foo|E')
- assert_selector_parses('*|E')
- assert_selector_parses('foo|*')
- assert_selector_parses('*|*')
- end
+vows.describe('Namespaced Selectors').addBatch({
+ 'foo|E': shouldParse(),
+ '*|E': shouldParse(),
+ 'foo|*': shouldParse(),
+ '*|*': shouldParse()
+}).run();
+
+
+/*
def test_namespaced_attribute_selectors
assert_selector_parses('[foo|bar=baz]')
assert_selector_parses('[*|bar=baz]')

0 comments on commit 4f41af4

Please sign in to comment.