keithclark / selectivizr

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8.
1.71k stars 247 forks source link

:before and :after cannot be used with :nth-child, :nth-of-type, etc #58

Open ianthedev opened 11 years ago

ianthedev commented 11 years ago

:before and :after cannot be used with CSS3 selectors such as :nth-child, :nth-of-type, first-of-type, :last-child, ...... etc.

For example, these aren't working:

div:nth-child(2):before {   }
div:last-child:after {   }
div:nth-of-type(3):after {   }
eloivaque commented 11 years ago

Isn't a solution, but if you use two tags, do works.

.field-item:last-child span:after

ianthedev commented 11 years ago

Thanks.

Actually it can be fixed by changing line 263 (or line 270 of v1.0.3b):

var domSelectorText = selectorText.replace(RE_LIBRARY_INCOMPATIBLE_PSEUDOS, EMPTY_STRING);

To

var domSelectorText = selectorText.replace(RE_LIBRARY_INCOMPATIBLE_PSEUDOS, EMPTY_STRING).replace(/:before|:after/, '');