I have an html text like:
'<div class="a"><span>1</span><div>2</div></div>'
Is there a function in closure library to get such a string as input and return a DOM tree to insert in a document?
I have an html text like:
'<div class="a"><span>1</span><div>2</div></div>'
Is there a function in closure library to get such a string as input and return a DOM tree to insert in a document?
Closure Library provides the function
goog.dom.safeHtmlToNode(html)
to create a document fragment (Node
) from agoog.html.SafeHtml
object, which can be created usinggoog.html.sanitizer.HtmlSanitizer
as shown below.Example