Dart,为什么使用innerHtml设置影子根内容工作,但appendHtml不? [英] Dart, why does using innerHtml to set shadow root content work but appendHtml doesn't?

查看:89
本文介绍了Dart,为什么使用innerHtml设置影子根内容工作,但appendHtml不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经这个Gist 显示问题,但本质上我发现使用 shadowRoot.innerHtml ='...'有效,但使用 shadowRoot.appendHtml('...') ,它会导致控制台警告删除不允许的元素< STYLE> ,这我不能解释。

I have made this Gist to show the issue but essentially I have found that using shadowRoot.innerHtml = '...' works but using shadowRoot.appendHtml('...') doesn't work, it causes the console warning Removing disallowed element <STYLE> which I can't explain. Anyone know if this is simple the way it is meant to be or is it specific to Dart?

推荐答案

删除不允许的元素表示您需要一个NodeValidator。

Removing disallowed element indicates that you need a NodeValidator.

shadowRoot.append(
    new document.body.createFragment('....'), 
    validator: new NodeValidationBuilder().allow(...);

这篇关于Dart,为什么使用innerHtml设置影子根内容工作,但appendHtml不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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