mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] [SCSS] Support comments in selectors.
This commit is contained in:
parent
55dd4a858c
commit
daa935b567
2 changed files with 23 additions and 1 deletions
|
@ -59,6 +59,11 @@ module Sass
|
|||
true
|
||||
end
|
||||
|
||||
def whitespace
|
||||
return unless tok(S) || tok(SINGLE_LINE_COMMENT) || tok(COMMENT)
|
||||
ss
|
||||
end
|
||||
|
||||
def process_comment(text, node)
|
||||
pre_str = @scanner.string[/(?:\A|\n)(.*)\/\*/, 1].gsub(/[^\s]/, ' ')
|
||||
node << Sass::Tree::CommentNode.new(pre_str + text, false)
|
||||
|
@ -336,7 +341,7 @@ module Sass
|
|||
end
|
||||
|
||||
def combinator
|
||||
tok(PLUS) || tok(GREATER) || tok(TILDE) || tok(S)
|
||||
tok(PLUS) || tok(GREATER) || tok(TILDE) || str?{whitespace}
|
||||
end
|
||||
|
||||
def simple_selector_sequence
|
||||
|
@ -555,6 +560,13 @@ MESSAGE
|
|||
@strs.pop
|
||||
end
|
||||
|
||||
def str?
|
||||
@strs.push ""
|
||||
yield && @strs.last
|
||||
ensure
|
||||
@strs.pop
|
||||
end
|
||||
|
||||
def node(node)
|
||||
node.line = @line
|
||||
node
|
||||
|
|
|
@ -147,6 +147,16 @@ CSS
|
|||
SCSS
|
||||
end
|
||||
|
||||
def test_selector_comments
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
.foo #bar:baz( bip) {
|
||||
a: b; }
|
||||
CSS
|
||||
.foo /* .a #foo */ #bar:baz(/* bang )*/ bip) {
|
||||
a: b; }
|
||||
SCSS
|
||||
end
|
||||
|
||||
def test_lonely_comments
|
||||
assert_parses <<SCSS
|
||||
/* Foo
|
||||
|
|
Loading…
Add table
Reference in a new issue