是否有任何实现新自定义元素规范的环境? [英] Is there any environment that implements the new custom elements specification?

查看:101
本文介绍了是否有任何实现新自定义元素规范的环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去某个时候已经发布了新版本的自定义元素(不确定何时,因为我暂时没有直接使用该规范)。是否有任何polyfill或环境实现新的自定义元素规范?

A new version of the custom elements has been released at some point in the past (not sure when, as I haven't directly used the spec for awhile). Is there any polyfill or environment that implements the new custom elements specification?

我要问的原因是我将在星期五就Web组件规范和它进行讨论没有演示就很难做出谈话,但从我看到的所有浏览器和polyfill仍然实现旧的规范。看看网络存档我可以看到新的规范已经存在了至少几个月,所以我希望它至少可以在某个地方实现。

Reason I am asking is that I will be giving a talk on Friday about the web components specs and it will hardly do to give a talk without a demonstrations, but from what I can see all browsers and polyfills still implement the old spec. Looking at web archive I can see that the new spec has been around for at least a few months, so I would expect it to be implemented at least somewhere.

推荐答案

更新:现在它在Chrome v54 +和Opera v41 +中运行,无需标记。

Update: now it runs in Chrome v54+ and Opera v41+ with no flag needed.

否则你可以使用用于IE11 / Firefox / Chrome的 WebReflection 的polyfill。

Otherwise you can use a polyfill from WebReflection for IE11 / Firefox / Chrome.

介绍已更改的内容此处

自定义元素v1 规范自Chrome v53起可用。这是一个原生实现。

The Custom Elements v1 Specification is available since Chrome v53. It's a native implementation.

注意:你必须使用一个标志来运行它来激活该功能:

Note: You have to run it with a flag to activate the feature:

> chrome --enable-blink-features=CustomElementsV1

如果你想要你可以在你的快捷方式中添加标志。

You can add the flag in your shortcut if you want.

PS:我建议使用最后一个版本( Canary )因为实施正在定期更新。

PS: I recommend to use the last build (Canary) because the implementation is being updated on a regular basis.

运行示例:

class CEv1 extends HTMLElement 
{
  constructor () 
  {
    super()
    console.log( "created this=", this )			
  }
  
  connectedCallback ()
  {
    this.innerHTML = "Hello V1!"
  }
} 
customElements.define( "test-v1", CEv1 )

<test-v1>Feature not activated</test-v1>

这篇关于是否有任何实现新自定义元素规范的环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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