Commit 5c214c1
authored
Use textContent, not wholeText, to process text nodes (#31)
The wholeText property [1] [2] contains the text of the current text
node together with any text nodes adjacent to it. Given that we’re
processing each text node separately, this doesn’t make sense and means
we’re potentially processing the same text multiple times – we should
just process textContent instead, which is the node’s own text.
I initially thought this bug wouldn’t be reproducible in practice
without manually constructing a DOM with two adjacent text nodes, but
then I realized a v-if with a false condition can easily produce such a
DOM naturally, hence the test case.
[1]: https://www.php.net/manual/en/class.domtext.php#domtext.props.wholetext
[2]: https://developer.mozilla.org/en-US/docs/Web/API/Text/wholeText1 parent 158a0ff commit 5c214c1
2 files changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
275 | 284 | | |
276 | 285 | | |
277 | 286 | | |
| |||
0 commit comments