Created
October 21, 2016 19:19
-
-
Save tuespetre/ed3f314bf0c8959fe560d14931b81624 to your computer and use it in GitHub Desktop.
Allows you to use templates for custom elements in IE11. Wrote this to be able to use webcomponents/shadycss
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
(function (document) { | |
if ('content' in document.createElement('template')) { | |
return; | |
} | |
Object.defineProperty(HTMLUnknownElement.prototype, 'content', { | |
enumerable: false, | |
configurable: true, | |
get: function() { | |
if (this.localName !== 'template') { | |
return; | |
} | |
if (!this._content) { | |
this._content = document.createDocumentFragment(); | |
for (var i = 0; i < this.childNodes.length; i++) { | |
this._content.appendChild(this.childNodes[i].cloneNode(true)); | |
} | |
} | |
return this._content; | |
} | |
}); | |
})(window.document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment