飞镖排除了特定属性 Element.setInnerHtml()
Specific attributes are being excluded from darts Element.setInnerHtml()
我遇到了以下问题:
之前 mods 可能会点击 'duplicate',但事实并非如此。我搜索了问题,找到了 'solutions',应用了 'solutions' 但它们没有用。所以问题可能是“为什么我的 'solution' 不工作?”或者问题可以是 'What is the actual solution?'
负责的代码是
querySelector("#element").setInnerHtml(some_element.outerHtml, treeSanitizer: NodeTreeSanitizer.trusted);
我做错了什么?
我发现要对 Element 使用消毒剂。
Element element = new Element.html('<a data-tag="value">thing</a>'), treeSanitizer: NodeTreeSanitizer.trusted)
我最近没有回去仔细检查这是最好的方法,但我们最终构建了一个通用的 NodeValidator,我们与各种自定义属性保持同步。
NodeValidator get commonValidator => _commonValidator;
/// Create a NodeValidator which passes common values.
final NodeValidator _commonValidator = new NodeValidatorBuilder.common()
..allowHtml5()
..allowInlineStyles()
..allowNavigation(_policy)
..allowImages()
..allowTextElements()
..allowElement("a", attributes: [
"data-version",
"data-attribute-add"])
..allowElement("div", attributes: [
"data-sec"]);
foo.setInnerHtml(someOddHtml, validator: commonValidator);
我遇到了以下问题:
之前 mods 可能会点击 'duplicate',但事实并非如此。我搜索了问题,找到了 'solutions',应用了 'solutions' 但它们没有用。所以问题可能是“为什么我的 'solution' 不工作?”或者问题可以是 'What is the actual solution?'
负责的代码是
querySelector("#element").setInnerHtml(some_element.outerHtml, treeSanitizer: NodeTreeSanitizer.trusted);
我做错了什么?
我发现要对 Element 使用消毒剂。
Element element = new Element.html('<a data-tag="value">thing</a>'), treeSanitizer: NodeTreeSanitizer.trusted)
我最近没有回去仔细检查这是最好的方法,但我们最终构建了一个通用的 NodeValidator,我们与各种自定义属性保持同步。
NodeValidator get commonValidator => _commonValidator;
/// Create a NodeValidator which passes common values.
final NodeValidator _commonValidator = new NodeValidatorBuilder.common()
..allowHtml5()
..allowInlineStyles()
..allowNavigation(_policy)
..allowImages()
..allowTextElements()
..allowElement("a", attributes: [
"data-version",
"data-attribute-add"])
..allowElement("div", attributes: [
"data-sec"]);
foo.setInnerHtml(someOddHtml, validator: commonValidator);