Skip to content

Commit

Permalink
added append polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
msenkpiel committed Apr 19, 2017
1 parent 65adbc5 commit ea2db14
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion static/js/cookienotice.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,29 @@ var CookieNotice = function(text, label, lifetime) {
window.onload = function() {
init();
};
};
};

// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
(function (arr) {
arr.forEach(function (item) {
if (item.hasOwnProperty('append')) {
return;
}
Object.defineProperty(item, 'append', {
configurable: true,
enumerable: true,
writable: true,
value: function append() {
var argArr = Array.prototype.slice.call(arguments),
docFrag = document.createDocumentFragment();

argArr.forEach(function (argItem) {
var isNode = argItem instanceof Node;
docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
});

this.appendChild(docFrag);
}
});
});
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);

0 comments on commit ea2db14

Please sign in to comment.