Why is it not recommended to use a polyfill for CSS3 selector support?
Asked Answered
U

1

13

I need to ensure IE7 and IE8 support.

I'm using a few CSS3 selectors like :last-child. I dropped in Selectivizr, and it appears to fix many problems in those browsers, leaving me just a handful to clean up with some fallback code.

But HTML5 Please recommends using only fallbacks, not polyfills, to address CSS3 selector support:

We strongly recommend you do not try to polyfill this, but if you do need one, you can use Selectivizr.

It would be good to know why they "strongly recommend" against polyfills here... Anyone have any ideas?

Unduly answered 23/7, 2012 at 12:5 Comment(1)
Polyfills are apparently buggy. The other day someone reported span:last-child:after not working in IE8, even with Selectivizr enabled - #11578139Jaunitajaunt
M
7

Using a fallback I think means you should be adding classes to the elements that you cannot select with modern selectors like adding .first to be used for :first-child, or .checked for :checked, and so on.

I can't think of any reason HTML5 Please recommends not to use polyfills so strongly, except for performance and independence from JavaScript. It's best to depend solely on CSS to style and draw.

But in my humble opinion, Selectivizr is a piece of magic that will teach IE6-8 to behave and ensure your HTML is clean from unnecessary classes and will shorten your development time.

Middleman answered 23/7, 2012 at 12:13 Comment(3)
I agree, I can see how Selectivizr will be worse performing than manual fallbacks like extra classnames... but it seems odd that HTML5Please would "strongly recommend" against it just on this basis. I'm worried there are other hidden dangers.Unduly
Apart from some issues where supported selectors end up not working, I haven't come across any serious issues with it.Culm
From what I understand, it's just dependence of JavaScript and page load time, as this answer says. I haven't heard any other major issues. You could wrap it in an IE if statement, too, if you're really worried.Bibber

© 2022 - 2024 — McMap. All rights reserved.