|
1 |
| -import { isComment, isEmptyText, locateEndAnchor } from './hydration' |
| 1 | +import { isComment, isNonHydrationNode, locateEndAnchor } from './hydration' |
2 | 2 | import {
|
3 | 3 | DYNAMIC_END_ANCHOR_LABEL,
|
4 | 4 | DYNAMIC_START_ANCHOR_LABEL,
|
5 |
| - isDynamicAnchor, |
6 | 5 | isVaporFragmentEndAnchor,
|
7 | 6 | } from '@vue/shared'
|
8 | 7 |
|
@@ -79,7 +78,19 @@ function _next(node: Node): Node {
|
79 | 78 |
|
80 | 79 | /*! #__NO_SIDE_EFFECTS__ */
|
81 | 80 | export function __next(node: Node): Node {
|
82 |
| - node = handleWrappedNode(node) |
| 81 | + // process dynamic node (<!--[[-->...<!--]]-->) as a single node |
| 82 | + if (isComment(node, DYNAMIC_START_ANCHOR_LABEL)) { |
| 83 | + node = locateEndAnchor( |
| 84 | + node, |
| 85 | + DYNAMIC_START_ANCHOR_LABEL, |
| 86 | + DYNAMIC_END_ANCHOR_LABEL, |
| 87 | + )! |
| 88 | + } |
| 89 | + |
| 90 | + // process fragment (<!--[-->...<!--]-->) as a single node |
| 91 | + else if (isComment(node, '[')) { |
| 92 | + node = locateEndAnchor(node)! |
| 93 | + } |
83 | 94 |
|
84 | 95 | let n = node.nextSibling!
|
85 | 96 | while (n && isNonHydrationNode(n)) {
|
@@ -142,47 +153,3 @@ export function disableHydrationNodeLookup(): void {
|
142 | 153 | next.impl = _next
|
143 | 154 | nthChild.impl = _nthChild
|
144 | 155 | }
|
145 |
| - |
146 |
| -function isNonHydrationNode(node: Node) { |
147 |
| - return ( |
148 |
| - // empty text nodes, no need to hydrate |
149 |
| - isEmptyText(node) || |
150 |
| - // dynamic node anchors (<!--[[-->, <!--]]-->) |
151 |
| - isDynamicAnchor(node) || |
152 |
| - // fragment end anchor (`<!--]-->`) |
153 |
| - isComment(node, ']') || |
154 |
| - // vapor fragment end anchors |
155 |
| - isVaporFragmentEndAnchor(node) |
156 |
| - ) |
157 |
| -} |
158 |
| - |
159 |
| -export function findVaporFragmentAnchor( |
160 |
| - node: Node, |
161 |
| - anchorLabel: string, |
162 |
| -): Comment | null { |
163 |
| - let n = node.nextSibling |
164 |
| - while (n) { |
165 |
| - if (isComment(n, anchorLabel)) return n |
166 |
| - n = n.nextSibling |
167 |
| - } |
168 |
| - |
169 |
| - return null |
170 |
| -} |
171 |
| - |
172 |
| -function handleWrappedNode(node: Node): Node { |
173 |
| - // process dynamic node (<!--[[-->...<!--]]-->) as a single one |
174 |
| - if (isComment(node, DYNAMIC_START_ANCHOR_LABEL)) { |
175 |
| - return locateEndAnchor( |
176 |
| - node, |
177 |
| - DYNAMIC_START_ANCHOR_LABEL, |
178 |
| - DYNAMIC_END_ANCHOR_LABEL, |
179 |
| - )! |
180 |
| - } |
181 |
| - |
182 |
| - // process fragment (<!--[-->...<!--]-->) as a single one |
183 |
| - else if (isComment(node, '[')) { |
184 |
| - return locateEndAnchor(node)! |
185 |
| - } |
186 |
| - |
187 |
| - return node |
188 |
| -} |
0 commit comments