block by jkutianski 7556191

A new attempt to add templating to d3.js

Full Screen

D3.js templating test based on my previous solution of John Berryman’s attempt.

The HTMLTemplateElement is currently supported in Chrome, Firefox and Opera (15+) for now. See Eric Bidelman HTMLTemplateElement tuturial

I change the idea of use HTMLTemplateElement.content because is only supported by 3 browsers . I’m using HTMLElement.innerHTML to read the template content and DOMParser() to inject the result into the DOM. To hide the content of <template> (HTMLUnknownElement) on other browsers (Safari, IE, etc) I add a CSS rule with display:none. On browsers that support HTMLTemplateElement the <script> isn’t fired when the browser parse the document, but is different on HTMLUnknownElements. If someone know how to break the script execution on HTMLUnknownElements please send me a tweet @baldpower

Fork me @ GITHUB

TODOs:

index.html

d3.selection.template.js