我一直在阅读这个选择器,并得到相互矛盾的答案。
在:What do /deep/ and ::shadow mean in a CSS selector?
我们看到:
As Joel H. points out in the comments, Chrome has since deprecated the /deep/ combinator, and it gives a syntax error in IE.
在:https://github.com/Microsoft/vscode/issues/7002
我们看到:
/deep/ no longer exists, so I don't think we should support it. >>> is the new version, which should probably be supported
但是,在 Angular 2 文档中:https://angular.io/docs/ts/latest/guide/component-styles.html
我们看到:
The /deep/ selector also has the alias >>>. We can use either of the two interchangeably.
显然,相信 Angular 2 文档是明智的,但由于所有这些相互矛盾的信息,我有点犹豫。
事实上,在最新版本的 Microsoft Visual Studio Code 中,/deep/
和 >>>
都会产生错误,尽管它们都可以在存在错误的情况下工作。
我的问题有两个:
/deep/会留下来吗?我们是否有任何来源、引述或来自任何规范的任何内容表明它将被采用?或者如果它已被正式弃用?
我们能否在不完全禁用语法检查的情况下在 Visual Studio Code 中抑制此错误?
最佳答案
-
Is /deep/ here to stay? Do we have any source, a quote, or anything from any specification saying that it will be adopted? Or if it has officially been deprecated?
/deep/
语法已过时,最后一次出现在 css-scoping in 2014 ,它的替代品>>>
大约半年前在 Chrome 45 中被弃用。shadow-piercing 后代组合器的整个概念是 slated to be removed from the Shadow DOM entirely .实现可能会完全删除它或将其别名为常规后代组合器(这取决于 Shadow DOM 将来的实现方式可能有意义也可能没有意义)。
-
Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?
不幸的是没有。
出于兼容性目的,Angular 允许在模拟 View 中进行封装,但强烈建议作者继续使用
>>>
,因为/deep/
现在在技术上是无效的,因此在原生 View 封装中不受支持。
关于css - Angular 2中/deep/和>>>的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42134355/