Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
Add support for appearance.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kgn committed Apr 26, 2011
1 parent 52e1b55 commit c6ba9af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cssprefixer/engine.py
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion cssprefixer/rules.py
Expand Up @@ -275,6 +275,6 @@ def get_base_prop(self):
'transform-origin': FullReplacementRule,

'display': DisplayReplacementRule,

'opacity': OpacityReplacementRule,
'appearance': WebkitReplacementRule,
}
12 changes: 12 additions & 0 deletions tests.py
Expand Up @@ -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}')
Expand Down

0 comments on commit c6ba9af

Please sign in to comment.