简体   繁体   English

为什么不建议使用polyfill来支持CSS3选择器?

[英]Why is it not recommended to use a polyfill for CSS3 selector support?

I need to ensure IE7 and IE8 support. 我需要确保IE7和IE8支持。

I'm using a few CSS3 selectors like :last-child . 我正在使用一些CSS3选择器,如: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. 我放弃了Selectivizr ,它似乎解决了这些浏览器中的许多问题,让我只需要少量清理一些后备代码。

But HTML5 Please recommends using only fallbacks, not polyfills, to address CSS3 selector support: 但是HTML5请建议使用回退而不是polyfill来解决CSS3选择器支持问题:

We strongly recommend you do not try to polyfill this, but if you do need one, you can use Selectivizr. 我们强烈建议您不要尝试将其填充,但如果您确实需要填充,则可以使用Selectivizr。

It would be good to know why they "strongly recommend" against polyfills here... Anyone have any ideas? 很高兴知道为什么他们“强烈推荐”这里的polyfill ...任何人都有任何想法?

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. 使用回退,我认为意味着你应该添加类,你不能像加了现代化的选择选择要素.first将用于:first-child ,或.checked:checked ,等等。

I can't think of any reason HTML5 Please recommends not to use polyfills so strongly, except for performance and independence from JavaScript. 我想不出任何原因HTML5请建议不要如此强烈地使用polyfill,除了性能和JavaScript的独立性。 It's best to depend solely on CSS to style and draw. 最好只依靠CSS来设计和绘制。

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. 但在我看来,Selectivizr是一个魔术,它将教会IE6-8的行为并确保您的HTML从不必要的类中清除,并缩短您的开发时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM