Creates an HTML element from a valid fragment of HTML.
var element = new Element.html('<div class="foo">content</div>');
The HTML fragment should contain only one single root element, any leading or trailing text nodes will be removed.
The HTML fragment is parsed as if it occurred within the context of a <body>
tag, this means that special elements such as <caption>
which must be parsed within the scope of a <table>
element will be dropped. Use createFragment to parse contextual HTML fragments.
Unless a validator is provided this will perform the default validation and remove all scriptable elements and attributes.
See also:
factory Element.html(String html, {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { var fragment = document.body.createFragment(html, validator: validator, treeSanitizer: treeSanitizer); return fragment.nodes.where((e) => e is Element).single; }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-html/Element/Element.html.html