mirror of https://github.com/vuejs/core.git
refactor(compiler-vapor): remove createTextNode argument
This commit is contained in:
parent
ccfadc1fb4
commit
f7642ab77c
|
|
@ -7,7 +7,7 @@ export function render(_ctx) {
|
|||
const t0 = _template("<div>count is <!>.</div>")
|
||||
const n0 = t0()
|
||||
const { 0: [n3, { 1: [n2],}],} = _children(n0)
|
||||
const n1 = _createTextNode(_ctx.count)
|
||||
const n1 = _createTextNode()
|
||||
_insert(n1, n3, n2)
|
||||
_renderEffect(() => {
|
||||
_setText(n1, _ctx.count)
|
||||
|
|
@ -139,7 +139,7 @@ export function render(_ctx) {
|
|||
const t0 = _template("<div></div><div><Comp></Comp></div>")
|
||||
const n0 = t0()
|
||||
const { 1: [n2],} = _children(n0)
|
||||
const n1 = _createTextNode(_ctx.bar)
|
||||
const n1 = _createTextNode()
|
||||
_append(n2, n1)
|
||||
_renderEffect(() => {
|
||||
_setText(n1, _ctx.bar)
|
||||
|
|
@ -158,7 +158,7 @@ export function render(_ctx) {
|
|||
const t0 = _template("<div :id=\\"foo\\"><Comp></Comp>{{ bar }}</div><div><Comp></Comp></div>")
|
||||
const n0 = t0()
|
||||
const { 1: [n2],} = _children(n0)
|
||||
const n1 = _createTextNode(_ctx.bar)
|
||||
const n1 = _createTextNode()
|
||||
_append(n2, n1)
|
||||
_renderEffect(() => {
|
||||
_setText(n1, _ctx.bar)
|
||||
|
|
@ -176,8 +176,8 @@ exports[`compile > dynamic root 1`] = `
|
|||
export function render(_ctx) {
|
||||
const t0 = _fragment()
|
||||
const n0 = t0()
|
||||
const n1 = _createTextNode(1)
|
||||
const n2 = _createTextNode(2)
|
||||
const n1 = _createTextNode()
|
||||
const n2 = _createTextNode()
|
||||
_append(n0, n1, n2)
|
||||
_renderEffect(() => {
|
||||
_setText(n1, 1)
|
||||
|
|
@ -196,9 +196,9 @@ export function render(_ctx) {
|
|||
const t0 = _template("<button>foo<!>foo</button>")
|
||||
const n0 = t0()
|
||||
const { 0: [n4, { 1: [n5],}],} = _children(n0)
|
||||
const n1 = _createTextNode(_ctx.count)
|
||||
const n2 = _createTextNode(_ctx.count)
|
||||
const n3 = _createTextNode(_ctx.count)
|
||||
const n1 = _createTextNode()
|
||||
const n2 = _createTextNode()
|
||||
const n3 = _createTextNode()
|
||||
_prepend(n4, n1)
|
||||
_insert(n2, n4, n5)
|
||||
_append(n4, n3)
|
||||
|
|
@ -217,7 +217,7 @@ exports[`compile > expression parsing > interpolation 1`] = `
|
|||
"(() => {
|
||||
const t0 = _fragment()
|
||||
const n0 = t0()
|
||||
const n1 = _createTextNode(a + b.value)
|
||||
const n1 = _createTextNode()
|
||||
_append(n0, n1)
|
||||
_renderEffect(() => {
|
||||
_setText(n1, a + b.value)
|
||||
|
|
@ -255,14 +255,14 @@ export function render(_ctx) {
|
|||
const t0 = _template("3<!>6<!>9")
|
||||
const n0 = t0()
|
||||
const { 1: [n9], 3: [n10],} = _children(n0)
|
||||
const n1 = _createTextNode(1)
|
||||
const n2 = _createTextNode(2)
|
||||
const n3 = _createTextNode(4)
|
||||
const n4 = _createTextNode(5)
|
||||
const n5 = _createTextNode(7)
|
||||
const n6 = _createTextNode(8)
|
||||
const n7 = _createTextNode('A')
|
||||
const n8 = _createTextNode('B')
|
||||
const n1 = _createTextNode()
|
||||
const n2 = _createTextNode()
|
||||
const n3 = _createTextNode()
|
||||
const n4 = _createTextNode()
|
||||
const n5 = _createTextNode()
|
||||
const n6 = _createTextNode()
|
||||
const n7 = _createTextNode()
|
||||
const n8 = _createTextNode()
|
||||
_prepend(n0, n1, n2)
|
||||
_insert([n3, n4], n0, n9)
|
||||
_insert([n5, n6], n0, n10)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export function render(_ctx) {
|
|||
const t0 = _template("<div> <span></span></div>")
|
||||
const n0 = t0()
|
||||
const { 0: [n3, { 1: [n2],}],} = _children(n0)
|
||||
const n1 = _createTextNode(_ctx.msg)
|
||||
const n1 = _createTextNode()
|
||||
_setText(n1, _ctx.msg)
|
||||
_setClass(n2, _ctx.clz)
|
||||
_prepend(n3, n1)
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ describe('compiler: v-once', () => {
|
|||
{
|
||||
id: 1,
|
||||
type: IRNodeTypes.CREATE_TEXT_NODE,
|
||||
value: {
|
||||
type: NodeTypes.SIMPLE_EXPRESSION,
|
||||
content: 'msg',
|
||||
isStatic: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
element: 1,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ export function genCreateTextNode(
|
|||
return [
|
||||
newline(),
|
||||
`const n${oper.id} = `,
|
||||
...call(vaporHelper('createTextNode'), genExpression(oper.value, context)),
|
||||
...call(vaporHelper('createTextNode')),
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ export interface SetModelValueIRNode extends BaseIRNode {
|
|||
export interface CreateTextNodeIRNode extends BaseIRNode {
|
||||
type: IRNodeTypes.CREATE_TEXT_NODE
|
||||
id: number
|
||||
value: IRExpression
|
||||
}
|
||||
|
||||
export interface InsertNodeIRNode extends BaseIRNode {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ export const transformInterpolation: NodeTransform = (node, ctx) => {
|
|||
type: IRNodeTypes.CREATE_TEXT_NODE,
|
||||
loc: node.loc,
|
||||
id,
|
||||
value: expr,
|
||||
})
|
||||
ctx.registerEffect(
|
||||
[expr],
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ export function children(nodes: ChildNode[]): Children {
|
|||
return result
|
||||
}
|
||||
|
||||
export function createTextNode(val: unknown): Text {
|
||||
export function createTextNode(val?: unknown): Text {
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
return document.createTextNode(toDisplayString(val))
|
||||
return document.createTextNode(val === undefined ? '' : toDisplayString(val))
|
||||
}
|
||||
|
||||
export function createComment(data: string): Comment {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export const createFor = (
|
|||
let oldBlocks: ForBlock[] = []
|
||||
let newBlocks: ForBlock[]
|
||||
let parent: ParentNode | undefined | null
|
||||
const parentAnchor = __DEV__ ? createComment('for') : createTextNode('')
|
||||
const parentAnchor = __DEV__ ? createComment('for') : createTextNode()
|
||||
const ref: Fragment = {
|
||||
nodes: oldBlocks,
|
||||
[fragmentKey]: true,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const createIf = (
|
|||
let parent: ParentNode | undefined | null
|
||||
let block: Block | undefined
|
||||
let scope: EffectScope | undefined
|
||||
const anchor = __DEV__ ? createComment('if') : createTextNode('')
|
||||
const anchor = __DEV__ ? createComment('if') : createTextNode()
|
||||
const fragment: Fragment = {
|
||||
nodes: [],
|
||||
anchor,
|
||||
|
|
|
|||
Loading…
Reference in New Issue