// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`compile > bindings 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx, $props, $emit, $attrs, $slots) {
const n0 = t0()
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_renderEffect(() => _setText(x0, "count is " + _toDisplayString(_ctx.count) + "."))
return n0
}"
`;
exports[`compile > dynamic root nodes and interpolation 1`] = `
-"import { child as _child, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { txt as _txt, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<button> </button>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = t0()
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
n0.$evtclick = e => _ctx.handleClick(e)
_renderEffect(() => {
const _count = _ctx.count
`;
exports[`compile > execution order > basic 1`] = `
-"import { child as _child, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { txt as _txt, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = t0()
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_renderEffect(() => {
_setProp(n0, "id", _ctx.foo)
_setText(x0, _toDisplayString(_ctx.bar))
`;
exports[`compile > execution order > with v-once 1`] = `
-"import { child as _child, next as _next, nthChild as _nthChild, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, next as _next, nthChild as _nthChild, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div><span> </span> <br> </div>", true)
export function render(_ctx) {
const n0 = _child(n3)
const n1 = _next(n0)
const n2 = _nthChild(n3, 3)
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_setText(x0, _toDisplayString(_ctx.foo))
_renderEffect(() => {
_setText(n1, " " + _toDisplayString(_ctx.bar))
`;
exports[`compiler: expression > empty interpolation 4`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n1 = t0()
const n0 = _child(n1)
- const x1 = _child(n1, -1)
+ const x1 = _txt(n1)
_renderEffect(() => {
const _foo = _ctx.foo
_setText(n0, _toDisplayString(_foo))
`;
exports[`compiler: expression > update expression 1`] = `
-"import { child as _child, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, txt as _txt, setProp as _setProp, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n1 = t0()
const n0 = _child(n1)
- const x1 = _child(n1, -1)
+ const x1 = _txt(n1)
_renderEffect(() => {
const _String = String
const _foo = _ctx.foo
`;
exports[`compiler: children transform > children & sibling references 1`] = `
-"import { child as _child, next as _next, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, next as _next, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div><p> </p> <p> </p></div>", true)
export function render(_ctx) {
const n0 = _child(n3)
const n1 = _next(n0)
const n2 = _next(n1)
- const x0 = _child(n0, -1)
- const x2 = _child(n2, -1)
+ const x0 = _txt(n0)
+ const x2 = _txt(n2)
_renderEffect(() => {
_setText(x0, _toDisplayString(_ctx.first))
_setText(n1, " " + _toDisplayString(_ctx.second) + " " + _toDisplayString(_ctx.third) + " ")
`;
exports[`compiler: children transform > efficient find 1`] = `
-"import { child as _child, nthChild as _nthChild, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, nthChild as _nthChild, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div><div>x</div><div>x</div><div> </div></div>", true)
export function render(_ctx) {
const n1 = t0()
const n0 = _nthChild(n1, 2)
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_renderEffect(() => _setText(x0, _toDisplayString(_ctx.msg)))
return n1
}"
`;
exports[`compiler: children transform > efficient traversal 1`] = `
-"import { child as _child, next as _next, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { child as _child, next as _next, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div><div>x</div><div><span> </span></div><div><span> </span></div><div><span> </span></div></div>", true)
export function render(_ctx) {
const n1 = _child(p1)
const p2 = _next(p1)
const n2 = _child(p2)
- const x0 = _child(n0, -1)
- const x1 = _child(n1, -1)
- const x2 = _child(n2, -1)
+ const x0 = _txt(n0)
+ const x1 = _txt(n1)
+ const x2 = _txt(n2)
_renderEffect(() => {
const _msg = _ctx.msg
_setText(x0, _toDisplayString(_msg))
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`compiler: v-for > array de-structured value (with rest) 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.list), (_for_item0, _for_key0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value[0] + _for_item0.value.slice(1) + _for_key0.value)))
return n2
}, ([id, ...other], index) => (id))
`;
exports[`compiler: v-for > array de-structured value 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.list), (_for_item0, _for_key0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value[0] + _for_item0.value[1] + _for_key0.value)))
return n2
}, ([id, other], index) => (id))
`;
exports[`compiler: v-for > basic v-for 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, delegateEvents as _delegateEvents, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, delegateEvents as _delegateEvents, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
_delegateEvents("click")
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.items), (_for_item0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
n2.$evtclick = () => (_ctx.remove(_for_item0.value))
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value)))
return n2
`;
exports[`compiler: v-for > key only binding pattern 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<tr> </tr>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.rows), (_for_item0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_setText(x2, _toDisplayString(_for_item0.value.id + _for_item0.value.id))
return n2
}, (row) => (row.id))
`;
exports[`compiler: v-for > nested v-for 1`] = `
-"import { setInsertionState as _setInsertionState, child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { setInsertionState as _setInsertionState, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<span> </span>")
const t1 = _template("<div></div>", true)
_setInsertionState(n5)
const n2 = _createFor(() => (_for_item0.value), (_for_item1) => {
const n4 = t0()
- const x4 = _child(n4, -1)
+ const x4 = _txt(n4)
_renderEffect(() => _setText(x4, _toDisplayString(_for_item1.value+_for_item0.value)))
return n4
}, undefined, 1)
`;
exports[`compiler: v-for > object de-structured value (with rest) 1`] = `
-"import { getRestElement as _getRestElement, child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { getRestElement as _getRestElement, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.list), (_for_item0, _for_key0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value.id + _getRestElement(_for_item0.value, ["id"]) + _for_key0.value)))
return n2
}, ({ id, ...other }, index) => (id))
`;
exports[`compiler: v-for > object de-structured value 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<span> </span>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.items), (_for_item0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value.id) + _toDisplayString(_for_item0.value.value)))
return n2
}, ({ id, value }) => (id))
`;
exports[`compiler: v-for > object value, key and index 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.list), (_for_item0, _for_key0, _for_index0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_for_item0.value + _for_key0.value + _for_index0.value)))
return n2
}, (value, key, index) => (key))
`;
exports[`compiler: v-for > selector pattern 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, createFor as _createFor, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<tr> </tr>", true)
export function render(_ctx) {
let _selector0_0
const n0 = _createFor(() => (_ctx.rows), (_for_item0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_selector0_0(() => {
_setText(x2, _toDisplayString(_ctx.selected === _for_item0.value.id ? 'danger' : ''))
})
`;
exports[`compiler: v-for > v-for aliases w/ complex expressions 1`] = `
-"import { getDefaultValue as _getDefaultValue, child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
+"import { getDefaultValue as _getDefaultValue, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createFor as _createFor, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createFor(() => (_ctx.list), (_for_item0) => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_getDefaultValue(_for_item0.value.foo, _ctx.bar) + _ctx.bar + _ctx.baz + _getDefaultValue(_for_item0.value.baz[0], _ctx.quux) + _ctx.quux)))
return n2
})
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`compiler: v-if > basic v-if 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createIf as _createIf, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createIf as _createIf, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = _createIf(() => (_ctx.ok), () => {
const n2 = t0()
- const x2 = _child(n2, -1)
+ const x2 = _txt(n2)
_renderEffect(() => _setText(x2, _toDisplayString(_ctx.msg)))
return n2
})
`;
exports[`compiler: v-if > comment between branches 1`] = `
-"import { createIf as _createIf, child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { createIf as _createIf, txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div></div>")
const t1 = _template("<!--foo-->")
const t2 = _template("<p></p>")
return [n10, n11]
}))
const n13 = t5()
- const x13 = _child(n13, -1)
+ const x13 = _txt(n13)
_renderEffect(() => _setText(x13, _toDisplayString(_ctx.text)))
return [n0, n13]
}"
`;
exports[`compiler: v-if > template v-if 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createIf as _createIf, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, createIf as _createIf, template as _template } from 'vue';
const t0 = _template("<div></div>")
const t1 = _template("hello")
const t2 = _template("<p> </p>", true)
const n2 = t0()
const n3 = t1()
const n4 = t2()
- const x4 = _child(n4, -1)
+ const x4 = _txt(n4)
_renderEffect(() => _setText(x4, _toDisplayString(_ctx.msg)))
return [n2, n3, n4]
})
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`v-text > should convert v-text to setText 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx, $props, $emit, $attrs, $slots) {
const n0 = t0()
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_renderEffect(() => _setText(x0, _toDisplayString(_ctx.str)))
return n0
}"
`;
exports[`v-text > should raise error and ignore children when v-text is present 1`] = `
-"import { child as _child, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
+"import { txt as _txt, toDisplayString as _toDisplayString, setText as _setText, renderEffect as _renderEffect, template as _template } from 'vue';
const t0 = _template("<div> </div>", true)
export function render(_ctx) {
const n0 = t0()
- const x0 = _child(n0, -1)
+ const x0 = _txt(n0)
_renderEffect(() => _setText(x0, _toDisplayString(_ctx.test)))
return n0
}"
return [
NEWLINE,
- `const x${oper.parent} = ${context.helper('child')}(n${oper.parent}, -1)`,
+ `const x${oper.parent} = ${context.helper('txt')}(n${oper.parent})`,
]
}
}
/*! #__NO_SIDE_EFFECTS__ */
-export function _child(node: ParentNode): Node {
- return node.firstChild!
-}
+const _txt: typeof _child = _child
/**
* Hydration-specific version of `child`.
*/
/*! #__NO_SIDE_EFFECTS__ */
-export function __child(node: ParentNode, offset?: number): Node {
+const __txt: typeof __child = (node: ParentNode): Node => {
let n = node.firstChild!
- // when offset is -1, it means we need to get the text node of this element
// since SSR doesn't generate whitespace placeholder text nodes, if firstChild
// is null, manually insert a text node as the first child
- if (offset === -1 && !n) {
+ if (!n) {
node.textContent = ' '
return node.firstChild!
}
+ return n
+}
+
+/*! #__NO_SIDE_EFFECTS__ */
+export function _child(node: ParentNode): Node {
+ return node.firstChild!
+}
+
+/**
+ * Hydration-specific version of `child`.
+ */
+/*! #__NO_SIDE_EFFECTS__ */
+export function __child(node: ParentNode): Node {
+ let n = node.firstChild!
while (n && (isComment(n, '[') || isInsertionAnchor(n))) {
// skip block node
n = skipBlockNodes(n) as ChildNode
}
/*! #__NO_SIDE_EFFECTS__ */
-export const child: DelegatedFunction<typeof __child> = (node, offset) => {
- return child.impl(node, offset)
+export const txt: DelegatedFunction<typeof _txt> = node => {
+ return txt.impl(node)
+}
+txt.impl = _child
+
+/*! #__NO_SIDE_EFFECTS__ */
+export const child: DelegatedFunction<typeof _child> = node => {
+ return child.impl(node)
}
child.impl = _child
* Enables hydration-specific node lookup behavior.
*
* Temporarily switches the implementations of the exported
- * `child`, `next`, and `nthChild` functions to their hydration-specific
- * versions (`__child`, `__next`, `__nthChild`). This allows traversal
+ * `txt`, `child`, `next`, and `nthChild` functions to their hydration-specific
+ * versions (`__txt`, `__child`, `__next`, `__nthChild`). This allows traversal
* logic to correctly handle SSR comment anchors during hydration.
*/
export function enableHydrationNodeLookup(): void {
+ txt.impl = __txt
child.impl = __child
next.impl = __next
nthChild.impl = __nthChild
}
export function disableHydrationNodeLookup(): void {
+ txt.impl = _txt
child.impl = _child
next.impl = _next
nthChild.impl = _nthChild
export { renderEffect } from './renderEffect'
export { createSlot, forwardedSlotCreator } from './componentSlots'
export { template } from './dom/template'
-export { createTextNode, child, nthChild, next } from './dom/node'
+export { createTextNode, child, nthChild, next, txt } from './dom/node'
export {
setText,
setHtml,