diff --git a/.travis.yml b/.travis.yml index 4f72128..4de1ad4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,10 @@ script: - nosetests - mincss https://news.ycombinator.com +branches: + only: + - master + deploy: provider: pypi user: peterbe diff --git a/mincss/processor.py b/mincss/processor.py index 1c7cb11..6165819 100644 --- a/mincss/processor.py +++ b/mincss/processor.py @@ -33,6 +33,9 @@ RE_NESTS = re.compile('@(-|keyframes).*?({)', re.DOTALL | re.M) RE_CLASS_DEF = re.compile('\.([\w-]+)') RE_ID_DEF = re.compile('#([\w-]+)') +MOUSE_PSEUDO_CLASSES = re.compile( + ':(link|hover|active|focus|visited)$', re.M | re.I +) EXCEPTIONAL_SELECTORS = ( @@ -477,7 +480,9 @@ def _found(self, bodies, selector): return r def _selector_query_found(self, bodies, selector): - selector = selector.split(':')[0] + # If the select has something like :active or :hover + if MOUSE_PSEUDO_CLASSES.findall(selector) or '::' in selector: + selector = selector.split(':')[0] if '}' in selector: # XXX does this ever happen any more? diff --git a/tests/nth-child.html b/tests/nth-child.html new file mode 100644 index 0000000..6014e16 --- /dev/null +++ b/tests/nth-child.html @@ -0,0 +1,40 @@ + + +
+ +First one
+Second one
+Third one
+ Fourth one +Fifth one
+