-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support selector separator newline in nested selectors
Fixes #666
- Loading branch information
1 parent
0ff2940
commit 4cbe64a
Showing
7 changed files
with
125 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,42 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea | |
// | ||
t('#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity = 90);\n}', '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity=90);\n}'); | ||
|
||
// Selector Separator - (separator = " ", separator1 = " ") | ||
opts.selector_separator_newline = false; | ||
opts.selector_separator = " "; | ||
t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}'); | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}'); | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}'); | ||
t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}'); | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}'); | ||
|
||
// Selector Separator - (separator = " ", separator1 = " ") | ||
opts.selector_separator_newline = false; | ||
opts.selector_separator = " "; | ||
t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}'); | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}'); | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}'); | ||
t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}'); | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}'); | ||
|
||
// Selector Separator - (separator = "\n", separator1 = "\n\t") | ||
opts.selector_separator_newline = true; | ||
opts.selector_separator = " "; | ||
t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}'); | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}'); | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}'); | ||
t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}'); | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}'); | ||
|
||
// Selector Separator - (separator = "\n", separator1 = "\n\t") | ||
opts.selector_separator_newline = true; | ||
opts.selector_separator = " "; | ||
t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}'); | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}'); | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}'); | ||
t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}'); | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}'); | ||
|
||
// Newline Between Rules - (separator = "\n") | ||
opts.newline_between_rules = true; | ||
t('.div {}\n.span {}', '.div {}\n\n.span {}'); | ||
|
@@ -244,9 +280,6 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea | |
t("a:first-child{color:red;div:first-child{color:black;}}", | ||
"a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
t("a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}", | ||
"a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
// handle SASS/LESS parent reference | ||
t("div{&:first-letter {text-transform: uppercase;}}", | ||
"div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); | ||
|
@@ -269,11 +302,6 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea | |
opts.indent_char = ' '; | ||
opts.selector_separator_newline = false; | ||
|
||
t("#bla, #foo{color:green}", "#bla, #foo {\n color: green\n}"); | ||
t("@media print {.tab{}}", "@media print {\n .tab {}\n}"); | ||
t("@media print {.tab,.bat{}}", "@media print {\n .tab, .bat {}\n}"); | ||
t("#bla, #foo{color:black}", "#bla, #foo {\n color: black\n}"); | ||
|
||
// pseudo-classes and pseudo-elements | ||
t("#foo:hover {\n background-image: url([email protected])\n}"); | ||
t("#foo *:hover {\n color: purple\n}"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,42 @@ def testGenerated(self): | |
# | ||
t('#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity = 90);\n}', '#cboxOverlay {\n\tbackground: url(images/overlay.png) repeat 0 0;\n\topacity: 0.9;\n\tfilter: alpha(opacity=90);\n}') | ||
|
||
# Selector Separator - (separator = " ", separator1 = " ") | ||
self.options.selector_separator_newline = false | ||
self.options.selector_separator = " " | ||
t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}') | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}') | ||
t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}') | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}') | ||
|
||
# Selector Separator - (separator = " ", separator1 = " ") | ||
self.options.selector_separator_newline = false | ||
self.options.selector_separator = " " | ||
t('#bla, #foo{color:green}', '#bla, #foo {\n\tcolor: green\n}') | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab, .bat {}\n}') | ||
t('#bla, #foo{color:black}', '#bla, #foo {\n\tcolor: black\n}') | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child, a:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}') | ||
|
||
# Selector Separator - (separator = "\n", separator1 = "\n\t") | ||
self.options.selector_separator_newline = true | ||
self.options.selector_separator = " " | ||
t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}') | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}') | ||
t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}') | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}') | ||
|
||
# Selector Separator - (separator = "\n", separator1 = "\n\t") | ||
self.options.selector_separator_newline = true | ||
self.options.selector_separator = " " | ||
t('#bla, #foo{color:green}', '#bla,\n#foo {\n\tcolor: green\n}') | ||
t('@media print {.tab{}}', '@media print {\n\t.tab {}\n}') | ||
t('@media print {.tab,.bat{}}', '@media print {\n\t.tab,\n\t.bat {}\n}') | ||
t('#bla, #foo{color:black}', '#bla,\n#foo {\n\tcolor: black\n}') | ||
t('a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', 'a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child,\n\tdiv:hover {\n\t\tcolor: black;\n\t}\n}') | ||
|
||
# Newline Between Rules - (separator = "\n") | ||
self.options.newline_between_rules = true | ||
t('.div {}\n.span {}', '.div {}\n\n.span {}') | ||
|
@@ -211,11 +247,6 @@ def testOptions(self): | |
self.options.selector_separator_newline = False | ||
t = self.decodesto | ||
|
||
t("#bla, #foo{color:green}", "#bla, #foo {\n color: green\n}") | ||
t("@media print {.tab{}}", "@media print {\n .tab {}\n}") | ||
t("@media print {.tab,.bat{}}", "@media print {\n .tab, .bat {}\n}") | ||
t("#bla, #foo{color:black}", "#bla, #foo {\n color: black\n}") | ||
|
||
# pseudo-classes and pseudo-elements | ||
t("#foo:hover {\n background-image: url([email protected])\n}") | ||
t("#foo *:hover {\n color: purple\n}") | ||
|
@@ -264,9 +295,6 @@ def testLessCss(self): | |
t("a:first-child{color:red;div:first-child{color:black;}}", | ||
"a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
t("a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}", | ||
"a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
# handle SASS/LESS parent reference | ||
t("div{&:first-letter {text-transform: uppercase;}}", | ||
"div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,9 +163,6 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea | |
t("a:first-child{color:red;div:first-child{color:black;}}", | ||
"a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
t("a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}", | ||
"a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
// handle SASS/LESS parent reference | ||
t("div{&:first-letter {text-transform: uppercase;}}", | ||
"div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); | ||
|
@@ -188,11 +185,6 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea | |
opts.indent_char = ' '; | ||
opts.selector_separator_newline = false; | ||
|
||
t("#bla, #foo{color:green}", "#bla, #foo {\n color: green\n}"); | ||
t("@media print {.tab{}}", "@media print {\n .tab {}\n}"); | ||
t("@media print {.tab,.bat{}}", "@media print {\n .tab, .bat {}\n}"); | ||
t("#bla, #foo{color:black}", "#bla, #foo {\n color: black\n}"); | ||
|
||
// pseudo-classes and pseudo-elements | ||
t("#foo:hover {\n background-image: url([email protected])\n}"); | ||
t("#foo *:hover {\n color: purple\n}"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,11 +130,6 @@ class CSSBeautifierTest(unittest.TestCase): | |
self.options.selector_separator_newline = False | ||
t = self.decodesto | ||
|
||
t("#bla, #foo{color:green}", "#bla, #foo {\n color: green\n}") | ||
t("@media print {.tab{}}", "@media print {\n .tab {}\n}") | ||
t("@media print {.tab,.bat{}}", "@media print {\n .tab, .bat {}\n}") | ||
t("#bla, #foo{color:black}", "#bla, #foo {\n color: black\n}") | ||
|
||
# pseudo-classes and pseudo-elements | ||
t("#foo:hover {\n background-image: url([email protected])\n}") | ||
t("#foo *:hover {\n color: purple\n}") | ||
|
@@ -183,9 +178,6 @@ class CSSBeautifierTest(unittest.TestCase): | |
t("a:first-child{color:red;div:first-child{color:black;}}", | ||
"a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
t("a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}", | ||
"a:first-child,\na:first-child {\n\tcolor: red;\n\tdiv:first-child, div:hover {\n\t\tcolor: black;\n\t}\n}"); | ||
|
||
# handle SASS/LESS parent reference | ||
t("div{&:first-letter {text-transform: uppercase;}}", | ||
"div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); | ||
|