Skip to content

Commit 03b5feb

Browse files
committed
Add support for replacing with a list of nodes
1 parent c950b5b commit 03b5feb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function findAndReplace(tree, find, replace, options) {
6565
}
6666

6767
if (value) {
68-
nodes.push(value)
68+
nodes = [].concat(nodes, value)
6969
}
7070

7171
start = position + match[0].length

Diff for: readme.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ Partial matches are not supported.
8888
— Value to insert.
8989
When `string`, turned into a [`Text`][text] node.
9090
When `Function`, invoked with the results of calling `RegExp.exec` as
91-
arguments, in which case it can return a [`Node`][node], a `string` (which
92-
is wrapped in a [`Text`][text] node), or `false` to not replace
91+
arguments, in which case it can return a single or a list of [`Node`][node],
92+
a `string` (which is wrapped in a [`Text`][text] node), or `false` to not
93+
replace
9394
* `search` (`Object` or `Array`)
9495
— Perform multiple find-and-replaces.
9596
When `Array`, each entry is a tuple (`Array`) of a `find` (at `0`) and

0 commit comments

Comments
 (0)