Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-adding support for inline comments, this was lost in the change th…

…at rebuild the ruleset from scratch.
  • Loading branch information...
commit 594c6b09fdcc943aca3fbf2d2bb12a64d9ea8613 1 parent 3032889
@kgn kgn authored
Showing with 23 additions and 0 deletions.
  1. +6 −0 cssprefixer/engine.py
  2. +17 −0 tests.py
View
6 cssprefixer/engine.py
@@ -27,6 +27,9 @@ def magic(ruleset, debug, minify):
ruleset.style = cssutils.css.CSSStyleDeclaration()#clear out the styles that were there
rules = list()
for rule in children:
+ if not hasattr(rule, 'name'):#comments don't have name
+ rules.append(rule)
+ continue
rule.name = prefixRegex.sub('', rule.name)
if rule.name in ruleSet:
continue
@@ -36,6 +39,9 @@ def magic(ruleset, debug, minify):
rules.reverse()#now that we have unique rules flip the order back to what it was
ruleset.style.seq._readonly = False
for rule in rules:
+ if not hasattr(rule, 'name'):
+ ruleset.style.seq.append(rule, 'Comment')
+ continue
processor = None
if rule.name in tr_rules:
processor = tr_rules[rule.name](rule)
View
17 tests.py
@@ -161,6 +161,23 @@ def test_comment(self):
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block
}''')
+
+ def test_inline_comment(self):
+ #TODO: it would be nice if comments on the same line remained there, but this may not be possible because
+ #cssutils tears everything apart into objects and then we rebuild it.
+ self.assertEqual(cssprefixer.process('''article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
+ display: block;/* HTML5 display-role reset for older browsers */
+ }''', minify=False), '''article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
+ display: block;
+ /* HTML5 display-role reset for older browsers */
+ }''')
+ self.assertEqual(cssprefixer.process('''article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
+ /* HTML5 display-role reset for older browsers */
+ display: block;
+ }''', minify=False), '''article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
+ /* HTML5 display-role reset for older browsers */
+ display: block
+ }''')
class WebkitPrefixerTestCase(unittest.TestCase):
def test_common(self):
Please sign in to comment.
Something went wrong with that request. Please try again.