mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] [SCSS] Properly parse oddly-quoted import directives.
This commit is contained in:
parent
74c1372f6a
commit
f130017fcd
4 changed files with 18 additions and 2 deletions
|
@ -164,7 +164,7 @@ module Sass
|
|||
def import
|
||||
@expected = "string or url()"
|
||||
arg = tok(STRING) || tok!(URI)
|
||||
path = @scanner[1]
|
||||
path = @scanner[1] || @scanner[2] || @scanner[3]
|
||||
ss
|
||||
|
||||
media = str {media_type}.strip
|
||||
|
|
|
@ -30,7 +30,7 @@ module Sass
|
|||
NAME = /#{NMCHAR}+/
|
||||
NUM = /[0-9]+|[0-9]*.[0-9]+/
|
||||
STRING = /#{STRING1}|#{STRING2}/
|
||||
URL = /([!#%$&*-~]|#{NONASCII}|#{ESCAPE})*/
|
||||
URL = /((?:[!#%$&*-~]|#{NONASCII}|#{ESCAPE})*)/
|
||||
W = /[ \t\r\n\f]*/
|
||||
|
||||
# This is more liberal than the spec's definition,
|
||||
|
|
|
@ -413,6 +413,14 @@ SCSS
|
|||
SCSS
|
||||
end
|
||||
|
||||
def test_import_directive
|
||||
assert_parses '@import "foo.css";'
|
||||
assert_parses "@import 'foo.css';"
|
||||
assert_parses '@import url("foo.css");'
|
||||
assert_parses "@import url('foo.css');"
|
||||
assert_parses '@import url(foo.css);'
|
||||
end
|
||||
|
||||
def test_import_directive_with_media
|
||||
assert_parses '@import "foo.css" screen;'
|
||||
assert_parses '@import "foo.css" screen, print;'
|
||||
|
|
|
@ -171,6 +171,14 @@ CSS
|
|||
SCSS
|
||||
end
|
||||
|
||||
def test_css_import_directive
|
||||
assert_equal "@import url(foo.css);\n", render('@import "foo.css";')
|
||||
assert_equal "@import url(foo.css);\n", render("@import 'foo.css';")
|
||||
assert_equal "@import url(foo.css);\n", render('@import url("foo.css");')
|
||||
assert_equal "@import url(foo.css);\n", render("@import url('foo.css');")
|
||||
assert_equal "@import url(foo.css);\n", render('@import url(foo.css);')
|
||||
end
|
||||
|
||||
def test_block_comment_in_script
|
||||
assert_equal <<CSS, render(<<SCSS)
|
||||
foo {
|
||||
|
|
Loading…
Add table
Reference in a new issue