postcss-selector-parser
Advanced tools
Comparing version 7.0.0 to 7.1.0
@@ -257,3 +257,3 @@ # API Documentation | ||
### `node.replaceWith(node)` | ||
### `node.replaceWith(node[,...nodeN])` | ||
@@ -271,2 +271,4 @@ Replace a node with another. | ||
* `node`: The node to substitute the original with. | ||
... | ||
* `nodeN`: The node to substitute the original with. | ||
@@ -536,3 +538,3 @@ ### `node.remove()` | ||
### `container.insertBefore(old, new)` & `container.insertAfter(old, new)` | ||
### `container.insertBefore(old, new[, ...newNodes])` & `container.insertAfter(old, new[, ...newNodes])` | ||
@@ -539,0 +541,0 @@ Add a node before or after an existing node in a container: |
@@ -0,1 +1,5 @@ | ||
# 7.1.0 | ||
- feat: insert(Before|After) support multiple new node | ||
# 7.0.0 | ||
@@ -2,0 +6,0 @@ |
@@ -75,5 +75,10 @@ "use strict"; | ||
_proto.insertAfter = function insertAfter(oldNode, newNode) { | ||
var _this$nodes; | ||
newNode.parent = this; | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex + 1, 0, newNode); | ||
var resetNode = []; | ||
for (var i = 2; i < arguments.length; i++) { | ||
resetNode.push(arguments[i]); | ||
} | ||
(_this$nodes = this.nodes).splice.apply(_this$nodes, [oldIndex + 1, 0, newNode].concat(resetNode)); | ||
newNode.parent = this; | ||
@@ -84,3 +89,3 @@ var index; | ||
if (oldIndex < index) { | ||
this.indexes[id] = index + 1; | ||
this.indexes[id] = index + arguments.length - 1; | ||
} | ||
@@ -91,5 +96,10 @@ } | ||
_proto.insertBefore = function insertBefore(oldNode, newNode) { | ||
var _this$nodes2; | ||
newNode.parent = this; | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex, 0, newNode); | ||
var resetNode = []; | ||
for (var i = 2; i < arguments.length; i++) { | ||
resetNode.push(arguments[i]); | ||
} | ||
(_this$nodes2 = this.nodes).splice.apply(_this$nodes2, [oldIndex, 0, newNode].concat(resetNode)); | ||
newNode.parent = this; | ||
@@ -100,3 +110,3 @@ var index; | ||
if (index >= oldIndex) { | ||
this.indexes[id] = index + 1; | ||
this.indexes[id] = index + arguments.length - 1; | ||
} | ||
@@ -127,3 +137,3 @@ } | ||
* updated as selector nodes are mutated. | ||
* | ||
* | ||
* Note that this location is relative to the location of the first character | ||
@@ -130,0 +140,0 @@ * of the selector, and not the location of the selector in the overall document |
{ | ||
"name": "postcss-selector-parser", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "@babel/cli": "^7.11.6", |
@@ -89,3 +89,3 @@ // Type definitions for postcss-selector-parser 2.2.3 | ||
/** | ||
* Preserve whitespace when true. Default: false; | ||
* Preserve whitespace when true. Default: true; | ||
*/ | ||
@@ -95,3 +95,3 @@ lossless: boolean; | ||
* When true and a postcss.Rule is passed, set the result of | ||
* processing back onto the rule when done. Default: false. | ||
* processing back onto the rule when done. Default: true. | ||
*/ | ||
@@ -240,4 +240,4 @@ updateSelector: boolean; | ||
empty(): this; | ||
insertAfter(oldNode: Child, newNode: Child): this; | ||
insertBefore(oldNode: Child, newNode: Child): this; | ||
insertAfter(oldNode: Child, newNode: Child, ...restNode: Child[]): this; | ||
insertBefore(oldNode: Child, newNode: Child, ...restNode: Child[]): this; | ||
each(callback: (node: Child, index: number) => boolean | void): boolean | undefined; | ||
@@ -244,0 +244,0 @@ walk( |
187187
3639