UNPKG

polyfill-service

Version:
23 lines (19 loc) 546 B
// http://dom.spec.whatwg.org/#mutation-method-macro function _mutation(nodes) { if (!nodes.length) { throw new Error('DOM Exception 8'); } else if (nodes.length === 1) { return typeof nodes[0] === 'string' ? document.createTextNode(nodes[0]) : nodes[0]; } else { var fragment = document.createDocumentFragment(), length = nodes.length, index = -1, node; while (++index < length) { node = nodes[index]; fragment.appendChild(typeof node === 'string' ? document.createTextNode(node) : node); } return fragment; } }