Comparing version 0.0.20 to 0.0.21
@@ -288,2 +288,45 @@ 'use strict'; | ||
/** | ||
* Removes children from `firstRefChild` to `lastRefChild` with specified element. | ||
* | ||
* @param {Element} firstRefChild | ||
* @param {Element} lastRefChild | ||
*/ | ||
}, { | ||
key: 'removeChildren', | ||
value: function removeChildren(firstRefChild, lastRefChild) { | ||
if (!firstRefChild || firstRefChild._parentElement !== this) { | ||
throw new Error('Invalid first reference child'); | ||
} | ||
if (!lastRefChild || lastRefChild._parentElement !== this) { | ||
throw new Error('Invalid last reference child'); | ||
} | ||
var firstIndex = this._childElements.indexOf(firstRefChild); | ||
var lastIndex = this._childElements.indexOf(lastRefChild); | ||
if (firstIndex > lastIndex) { | ||
throw new Error('Invalid reference children order'); | ||
} | ||
var children = this._childElements.slice(0, firstIndex).concat(this._childElements.slice(lastIndex + 1)); | ||
var removedChildren = this._childElements.slice(firstIndex, lastIndex + 1); | ||
this._setChildren(children); | ||
var ownerProgram = this.ownerProgram; | ||
if (ownerProgram) { | ||
ownerProgram._removeElementsFromProgram(removedChildren); | ||
} | ||
for (var i = 0; i < removedChildren.length; i++) { | ||
var removedChild = removedChildren[i]; | ||
removedChild._parentElement = null; | ||
removedChild._previousSibling = null; | ||
removedChild._nextSibling = null; | ||
} | ||
} | ||
/** | ||
* Replaces child with specified element. | ||
@@ -290,0 +333,0 @@ * Accepts multiple replacement nodes using `Fragment`. |
{ | ||
"name": "cst", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "JavaScript CST Implementation", | ||
@@ -5,0 +5,0 @@ "author": "Marat Dulin", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
528351
8421