-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
预处理器支持CSS的@support的可能性 #24
Comments
先检查 |
@Justineo 是应该这样。本文只是列一个初步的结构。话说你知道有什么预处理器支持 |
理论上是可行的,不过实际操作会遇到一些问题。参考以下代码: var decl = 'margin: 0 0 0 0'
document.body.style.cssText = decl
console.log(document.body.style.cssText) // => 'margin: 0px;' 这样写着写着发现要在前端实现一套 CSS 属性解析器了。 如果需要 JS 参与的话,大多数人应该会选择 Modernizr 这样的方案吧。 不好意思,第一次读此文时没有看到这一句(道理类似):
|
IE9 才支持
|
所有在选择器里明确写出 更简单的办法是要求所有针对根的样式规则明确写出 |
@hax 好像没有耶,这个除了 CSS 以外还要引入 JS,预处理器一般都不会有这个吧。 @cssmagic 用我说的方法应该不需要处理 :root[data-cssrules-1] h1,
h1:root[data-cssrules-1] {
// ...
} 只是感觉丑陋了点...不然就是得限制只能用 |
@Justineo 嗯,我正是觉得现有的预处理器只能编译出css,是大大削弱了其能力啊,尤其是polyfill的能力。 |
在Shadow DOM里面的样式应该也有问题, |
@sapjax shadow dom 本来就不该处理啊。 |
@hax 额,难道我理解错了? 不过存在一种状况是:可能不支持@support和不支持shadow dom的浏览器有很大一部分是重合的,那么反而没有问题了。 |
@sapjax shadow dom本来就是要特殊语法的啊,比如 |
@hax 这样的样式因为意图是只作用于 |
@sapjax 我理解你的意思了。shadow dom的样式应该需要单独处理,比如把 |
@hax 嗯,但是问题是没有办法给:host对应的节点增加 |
@sapjax 嗯,scoped style跟本方法的假设是矛盾的。 不过如你所言,shadow dom的支持浏览器基本上是 |
所以这个想法是我之前说的提供 「浏览器运行时」 的 CSS 处理器?:ghost: |
@yisibl 这个并不是运行时的css processor,只是一个需要运行时配合的css processor 😹 |
@hax 😂 我差不多就是这个意思。 |
可编译为:
注意:
:root
应该可获得优化从而解决属性选择器慢的问题。:root
排除了所有不支持:root
的老浏览器如IE6,我们一般可假设所有需要@supports
的特性均是IE6不支持的。:root:root
以保持一致。The text was updated successfully, but these errors were encountered: