Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2013 00:21
Show Gist options
  • Save anonymous/7259330 to your computer and use it in GitHub Desktop.
Save anonymous/7259330 to your computer and use it in GitHub Desktop.
loadLinks: function(urls) {
// HTMLImports polyfill can load links out of documents,
// so make a document and put our links in it
var doc = document.createDocumentFragment();
urls.forEach(function(url) {
var link = doc.appendChild(document.createElement('link'));
link.rel = "import";
link.href = url;
});
// ask the polyfill to load the links, do custom parsing
// stuff when they are ready
HTMLImports.importer.load(doc, function() {
doc.querySelectorAll('link').array().forEach(
function(link) {
HTMLImports.parser.parse(link.content);
CustomElements.parser.parse(link.content);
}
);
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment