/deep/和>>>的使用在角 2 [英] The use of /deep/ and >>> in Angular 2

查看:17
本文介绍了/deep/和>>>的使用在角 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读这个选择器,得到的答案相互矛盾.

在:做什么/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/>>> 都会产生错误,尽管它们都可以正常工作错误.

我的问题有两个:

  1. /deep/会留下来吗?我们是否有任何来源、引用或任何规范中的任何内容表明它将被采用?或者如果它已被正式弃用?

  2. 我们能否在不完全禁用语法检查的情况下抑制 Visual Studio Code 中的此错误?

解决方案

  1. <块引用>

    /deep/会留下来吗?我们是否有任何来源、引用或任何规范中的任何内容表明它将被采用?或者如果它已被正式弃用?

    /deep/ 语法已过时,最后一次出现在 css-scoping 在 2014 年,它的替代品 >>> 在大约半年前在 Chrome 45 中被弃用了.p>

    shadow-piercing 后代组合器的整个概念是 计划从 Shadow DOM 中完全删除.实现可以将其完全删除,也可以将其别名为常规后代组合器(这取决于将来如何实现 Shadow DOM 可能有意义,也可能没有意义).

  2. <块引用>

    我们能否在不完全禁用语法检查的情况下抑制 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:

As Joel H. points out in the comments, Chrome has since deprecated the /deep/ combinator, and it gives a syntax error in IE.

In: https://github.com/Microsoft/vscode/issues/7002

We see:

/deep/ no longer exists, so I don't think we should support it. >>> is the new version, which should probably be supported

However, in the Angular 2 docs: https://angular.io/docs/ts/latest/guide/component-styles.html

We see:

The /deep/ selector also has the alias >>>. We can use either of the two interchangeably.

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:

  1. 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?

  2. Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?

解决方案

  1. 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?

    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).

  2. Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?

    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/和&gt;&gt;&gt;的使用在角 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆