Last active
September 21, 2015 11:06
-
-
Save zoechi/cfa606c738e3f36662b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// not tested with binding expressions (port of http://stackoverflow.com/a/31320384/217408) | |
// probably needs bound values set to `template` | |
injectBoundHtml(highlightedValue, $['container']); | |
// TODO(zoechi) create feature request to get this into the `Polymer` class | |
get _polymerBase { | |
final JsObject _polymer = context['Polymer']; | |
return (o) { | |
return o is JsObject ? o : new JsObject.fromBrowserObject(o); | |
}(_polymer['Base']); | |
} | |
void injectBoundHtml(String html, HtmlElement element) { | |
TemplateElement template = document.createElement('template', 'dom-bind'); | |
var doc = template.content.ownerDocument; | |
DivElement div = doc.createElement('div'); | |
div.setInnerHtml(html, validator: _nodeValidator); | |
template.content.children.add(div); | |
element.children.clear(); | |
element.append(_polymerBase.callMethod('instanceTemplate', [template])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment