问题描述
我一直在阅读这个选择器,得到的答案相互矛盾.
在:做什么/deep/和::shadow 在 CSS 选择器中的意思?
我们看到了:
正如 Joel H. 在评论中指出的那样,Chrome 已经弃用/deep/组合器,它在 IE 中给出了语法错误.
在:https://github.com/Microsoft/vscode/issues/7002
我们看到了:
/deep/不再存在,所以我认为我们不应该支持它.>>> 是新版本,应该会支持
但是,在 Angular 2 文档中:https://angular.io/docs/ts/latest/guide/component-styles.html
我们看到了:
/deep/选择器也有别名 >>>.我们可以使用任何一个两个可以互换.
显然,相信 Angular 2 文档是明智的,但由于所有这些相互矛盾的信息,我有点犹豫.
事实上,在最新版本的 Microsoft Visual Studio Code 中,/deep/
和 >>>
都会产生错误,尽管它们都可以正常工作错误.
我的问题有两个:
/deep/会留下来吗?我们是否有任何来源、引用或任何规范中的任何内容表明它将被采用?或者如果它已被正式弃用?
我们能否在不完全禁用语法检查的情况下抑制 Visual Studio Code 中的此错误?
/deep/会留下来吗?我们是否有任何来源、引用或任何规范中的任何内容表明它将被采用?或者如果它已被正式弃用?
/deep/
语法已过时,最后一次出现在 css-scoping 在 2014 年,它的替代品>>>
在大约半年前在 Chrome 45 中被弃用了.p>shadow-piercing 后代组合器的整个概念是 计划从 Shadow DOM 中完全删除.实现可以将其完全删除,也可以将其别名为常规后代组合器(这取决于将来如何实现 Shadow DOM 可能有意义,也可能没有意义).
我们能否在不完全禁用语法检查的情况下抑制 Visual Studio Code 中的此错误?
很遗憾没有.
出于兼容性目的,Angular 允许在模拟视图中封装两者,但强烈建议作者继续使用
>>>
,因为/deep/
在技术上是现在无效,因此在原生视图封装中不受支持.
I've been reading up on this selector, and getting conflicting answers.
In: What do /deep/ and ::shadow mean in a CSS selector?
We see:
In: https://github.com/Microsoft/vscode/issues/7002
We see:
However, in the Angular 2 docs: https://angular.io/docs/ts/latest/guide/component-styles.html
We see:
Obviously it would be wise to trust the Angular 2 docs, but I'm a bit hesitant because of all this conflicting information.
In fact, in the latest version of Microsoft Visual Studio Code, BOTH /deep/
and >>>
create errors, though they both do work despite the errors.
My question is twofold:
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?
Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?
The
/deep/
syntax is obsolete, last seen in css-scoping in 2014, and its replacement>>>
was deprecated about half a year ago in Chrome 45.The entire concept of the shadow-piercing descendant combinator is slated to be removed from the Shadow DOM entirely. Implementations may either remove it altogether or alias it to the regular descendant combinator (which depending on how the Shadow DOM is implemented in the future may or may not make sense).
Unfortunately not.
Angular allows both in emulated view encapsulation for compatibility purposes, but authors are strongly encouraged to use
>>>
going forward, since/deep/
is technically invalid now, and therefore unsupported in native view encapsulation.
这篇关于/deep/和>>>的使用在角 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!