Last active
January 30, 2016 16:28
-
-
Save reosablo/f932dcbc0bb8b9293777 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
// Templates inside SVG won't work in polymer-1.0 without some monkeypatching. | |
(function() { | |
var templates = document.currentScript.parentElement.querySelector("template").content.querySelectorAll("svg template"); | |
Array.prototype.slice.call(templates).reverse().forEach(function(template) { | |
var new_template = template.ownerDocument.createElement("template"); | |
template.parentElement.replaceChild(new_template, template); | |
Array.prototype.forEach.call(template.attributes, function(attribute) { | |
new_template.setAttribute(attribute.name, attribute.value); | |
}); | |
for (var child; child = template.firstChild; new_template.content.appendChild(child)); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
querySelector("svg template")
elements should be processed descendants first (in reverse order) for nested<template>