From c6ba9af6c32d7a66b9b108521b0fa355e93cf35a Mon Sep 17 00:00:00 2001 From: InScopeApps Date: Mon, 25 Apr 2011 23:21:48 -0700 Subject: [PATCH] Add support for appearance. Only strip the vender prefix if we have a replacement rule, this way we don't disrupt the output css for vender properties that aren't yet supported. --- cssprefixer/engine.py | 6 ++++-- cssprefixer/rules.py | 2 +- tests.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cssprefixer/engine.py b/cssprefixer/engine.py index 6c22aaf..3d7a40f 100644 --- a/cssprefixer/engine.py +++ b/cssprefixer/engine.py @@ -28,7 +28,9 @@ def magic(ruleset, debug, minify): if not hasattr(rule, 'name'):#comments don't have name rules.append(rule) continue - rule.name = prefixRegex.sub('', rule.name) + name = prefixRegex.sub('', rule.name) + if name in tr_rules: + rule.name = name if rule.cssText in ruleSet: continue ruleSet.add(rule.cssText) @@ -40,7 +42,7 @@ def magic(ruleset, debug, minify): ruleset.style.seq.append(rule, 'Comment') continue processor = None - try: + try:#try except so if anything goes wrong we don't lose the original property if rule.name in tr_rules: processor = tr_rules[rule.name](rule) [ruleset.style.seq.append(prop, 'Property') for prop in processor.get_prefixed_props() if prop] diff --git a/cssprefixer/rules.py b/cssprefixer/rules.py index 3457bd2..30bc261 100644 --- a/cssprefixer/rules.py +++ b/cssprefixer/rules.py @@ -275,6 +275,6 @@ def get_base_prop(self): 'transform-origin': FullReplacementRule, 'display': DisplayReplacementRule, - 'opacity': OpacityReplacementRule, + 'appearance': WebkitReplacementRule, } diff --git a/tests.py b/tests.py index 8f2f22a..0b8167b 100644 --- a/tests.py +++ b/tests.py @@ -26,10 +26,22 @@ def test_common_and_opera(self): self.assertEqual(cssprefixer.process('a{transform: rotate(10deg)}', minify=True), 'a{-webkit-transform:rotate(10deg);-moz-transform:rotate(10deg);-o-transform:rotate(10deg);transform:rotate(10deg)}') + def test_undefined(self): + #test prefixed styles that don't have a rule yet, we use a fake property + #for this test becuase we will never have a rule for this + self.assertEqual(cssprefixer.process('a{-webkit-faker: black}', minify=True), + 'a{-webkit-faker:black}') + def test_webkit(self): self.assertEqual(cssprefixer.process('a{background-clip: padding-box}', minify=True), 'a{-webkit-background-clip:padding-box;background-clip:padding-box}') + def test_appearance(self): + #test prefixed styles that don't have a rule yet, we use a fake property + #for this test becuase we will never have a rule for this + self.assertEqual(cssprefixer.process('a{-webkit-appearance: none;}', minify=True), + 'a{-webkit-appearance:none;appearance:none}') + def test_ie_and_opera(self): self.assertEqual(cssprefixer.process('a{text-overflow: ellipsis}', minify=True), 'a{-o-text-overflow:ellipsis;-ms-text-overflow:ellipsis;text-overflow:ellipsis}')