webgl-benchmark
Version:
Benchmark WebGL performance using different JavaScript rendering/game engines, such as Pixi and Phaser.
26 lines (23 loc) • 787 B
JavaScript
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
((arr) => {
arr.forEach(function (item) {
// eslint-disable-next-line no-prototype-builtins
if (item.hasOwnProperty('append')) {
return;
}
Object.defineProperty(item, 'append', {
configurable: true,
enumerable: true,
writable: true,
value: function append() {
const argArr = Array.prototype.slice.call(arguments),
docFrag = document.createDocumentFragment();
argArr.forEach(function (argItem) {
const isNode = argItem instanceof Node;
docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
});
this.appendChild(docFrag);
}
});
});
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);