es5-lit-html
Version:
An ES5 transpiled version of lit-html
62 lines (51 loc) • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeNodes = exports.reparentNodes = exports.isCEPolyfill = void 0;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
/**
* True if the custom elements polyfill is in use.
*/
var isCEPolyfill = window.customElements !== undefined && window.customElements.polyfillWrapFlushCallback !== undefined;
/**
* Reparents nodes, starting from `start` (inclusive) to `end` (exclusive),
* into another container (could be the same container), before `before`. If
* `before` is null, it appends the nodes to the container.
*/
exports.isCEPolyfill = isCEPolyfill;
var reparentNodes = function reparentNodes(container, start) {
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var before = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
while (start !== end) {
var n = start.nextSibling;
container.insertBefore(start, before);
start = n;
}
};
/**
* Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from
* `container`.
*/
exports.reparentNodes = reparentNodes;
var removeNodes = function removeNodes(container, start) {
var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
while (start !== end) {
var n = start.nextSibling;
container.removeChild(start);
start = n;
}
};
exports.removeNodes = removeNodes;