refactor: applyDirectives -> withDirectives
This commit is contained in:
parent
cba34453db
commit
e98a85f3cb
@ -15,7 +15,7 @@ import {
|
||||
CREATE_BLOCK,
|
||||
FRAGMENT,
|
||||
RENDER_SLOT,
|
||||
APPLY_DIRECTIVES
|
||||
WITH_DIRECTIVES
|
||||
} from '../src/runtimeHelpers'
|
||||
import { transformIf } from '../src/transforms/vIf'
|
||||
import { transformFor } from '../src/transforms/vFor'
|
||||
@ -314,7 +314,7 @@ describe('compiler: transform', () => {
|
||||
{
|
||||
type: NodeTypes.JS_CALL_EXPRESSION,
|
||||
// should wrap applyDirectives() around createBlock()
|
||||
callee: APPLY_DIRECTIVES,
|
||||
callee: WITH_DIRECTIVES,
|
||||
arguments: [
|
||||
{ callee: CREATE_BLOCK },
|
||||
{ type: NodeTypes.JS_ARRAY_EXPRESSION }
|
||||
|
@ -101,12 +101,12 @@ const _hoisted_1 = { id: \\"foo\\" }
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { createVNode: _createVNode, applyDirectives: _applyDirectives, resolveDirective: _resolveDirective, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { createVNode: _createVNode, withDirectives: _withDirectives, resolveDirective: _resolveDirective, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
const _directive_foo = _resolveDirective(\\"foo\\")
|
||||
|
||||
return (_openBlock(), _createBlock(\\"div\\", null, [
|
||||
_applyDirectives(_createVNode(\\"div\\", _hoisted_1, null, 32 /* NEED_PATCH */), [
|
||||
_withDirectives(_createVNode(\\"div\\", _hoisted_1, null, 32 /* NEED_PATCH */), [
|
||||
[_directive_foo]
|
||||
])
|
||||
]))
|
||||
|
@ -137,12 +137,12 @@ exports[`compiler: v-for codegen v-for on element with custom directive 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode, applyDirectives: _applyDirectives, resolveDirective: _resolveDirective } = _Vue
|
||||
const { renderList: _renderList, openBlock: _openBlock, createBlock: _createBlock, Fragment: _Fragment, createVNode: _createVNode, withDirectives: _withDirectives, resolveDirective: _resolveDirective } = _Vue
|
||||
|
||||
const _directive_foo = _resolveDirective(\\"foo\\")
|
||||
|
||||
return (_openBlock(), _createBlock(_Fragment, null, _renderList(list, (i) => {
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"div\\", null, null, 32 /* NEED_PATCH */), [
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"div\\", null, null, 32 /* NEED_PATCH */), [
|
||||
[_directive_foo]
|
||||
]))
|
||||
}), 128 /* UNKEYED_FRAGMENT */))
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
OPEN_BLOCK,
|
||||
CREATE_BLOCK,
|
||||
CREATE_VNODE,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
FRAGMENT,
|
||||
RENDER_LIST
|
||||
} from '../../src/runtimeHelpers'
|
||||
@ -304,7 +304,7 @@ describe('compiler: hoistStatic transform', () => {
|
||||
{
|
||||
type: NodeTypes.ELEMENT,
|
||||
codegenNode: {
|
||||
callee: APPLY_DIRECTIVES,
|
||||
callee: WITH_DIRECTIVES,
|
||||
arguments: [
|
||||
{
|
||||
callee: CREATE_VNODE,
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
CREATE_VNODE,
|
||||
MERGE_PROPS,
|
||||
RESOLVE_DIRECTIVE,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
TO_HANDLERS,
|
||||
helperNameMap,
|
||||
PORTAL,
|
||||
@ -368,7 +368,7 @@ describe('compiler: element transform', () => {
|
||||
expect(root.helpers).toContain(RESOLVE_DIRECTIVE)
|
||||
expect(root.directives).toContain(`foo`)
|
||||
|
||||
expect(node.callee).toBe(APPLY_DIRECTIVES)
|
||||
expect(node.callee).toBe(WITH_DIRECTIVES)
|
||||
expect(node.arguments).toMatchObject([
|
||||
{
|
||||
type: NodeTypes.JS_CALL_EXPRESSION,
|
||||
@ -438,7 +438,7 @@ describe('compiler: element transform', () => {
|
||||
expect(root.directives).toContain(`bar`)
|
||||
expect(root.directives).toContain(`baz`)
|
||||
|
||||
expect(node.callee).toBe(APPLY_DIRECTIVES)
|
||||
expect(node.callee).toBe(WITH_DIRECTIVES)
|
||||
expect(node.arguments).toMatchObject([
|
||||
{
|
||||
type: NodeTypes.JS_CALL_EXPRESSION
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
FRAGMENT,
|
||||
RENDER_LIST,
|
||||
RENDER_SLOT,
|
||||
APPLY_DIRECTIVES
|
||||
WITH_DIRECTIVES
|
||||
} from '../../src/runtimeHelpers'
|
||||
import { PatchFlags } from '@vue/runtime-dom'
|
||||
import { createObjectMatcher, genFlagText } from '../testUtils'
|
||||
@ -859,7 +859,7 @@ describe('compiler: v-for', () => {
|
||||
{ callee: OPEN_BLOCK },
|
||||
// should wrap applyDirectives() around createBlock()
|
||||
{
|
||||
callee: APPLY_DIRECTIVES,
|
||||
callee: WITH_DIRECTIVES,
|
||||
arguments: [
|
||||
{ callee: CREATE_BLOCK },
|
||||
{ type: NodeTypes.JS_ARRAY_EXPRESSION }
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
COMMENT,
|
||||
FRAGMENT,
|
||||
MERGE_PROPS,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
RENDER_SLOT
|
||||
} from '../../src/runtimeHelpers'
|
||||
import { createObjectMatcher } from '../testUtils'
|
||||
@ -513,7 +513,7 @@ describe('compiler: v-if', () => {
|
||||
} = parseWithIfTransform(`<div v-if="ok" v-foo />`)
|
||||
const branch1 = (codegenNode.expressions[1] as ConditionalExpression)
|
||||
.consequent as CallExpression
|
||||
expect(branch1.callee).toBe(APPLY_DIRECTIVES)
|
||||
expect(branch1.callee).toBe(WITH_DIRECTIVES)
|
||||
const realBranch = branch1.arguments[0] as CallExpression
|
||||
expect(realBranch.arguments[1]).toMatchObject(
|
||||
createObjectMatcher({ key: `[0]` })
|
||||
|
@ -2,7 +2,7 @@ import { isString } from '@vue/shared'
|
||||
import { ForParseResult } from './transforms/vFor'
|
||||
import {
|
||||
CREATE_VNODE,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
RENDER_SLOT,
|
||||
CREATE_SLOTS,
|
||||
RENDER_LIST,
|
||||
@ -393,7 +393,7 @@ export interface DynamicSlotFnProperty extends Property {
|
||||
// ])
|
||||
export interface CodegenNodeWithDirective<T extends CallExpression>
|
||||
extends CallExpression {
|
||||
callee: typeof APPLY_DIRECTIVES
|
||||
callee: typeof WITH_DIRECTIVES
|
||||
arguments: [T, DirectiveArguments]
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ type InferCodegenNodeType<T> = T extends
|
||||
| typeof CREATE_VNODE
|
||||
| typeof CREATE_BLOCK
|
||||
? PlainElementCodegenNode | PlainComponentCodegenNode
|
||||
: T extends typeof APPLY_DIRECTIVES
|
||||
: T extends typeof WITH_DIRECTIVES
|
||||
?
|
||||
| CodegenNodeWithDirective<PlainElementCodegenNode>
|
||||
| CodegenNodeWithDirective<PlainComponentCodegenNode>
|
||||
|
@ -11,7 +11,7 @@ export const RESOLVE_DYNAMIC_COMPONENT = Symbol(
|
||||
__DEV__ ? `resolveDynamicComponent` : ``
|
||||
)
|
||||
export const RESOLVE_DIRECTIVE = Symbol(__DEV__ ? `resolveDirective` : ``)
|
||||
export const APPLY_DIRECTIVES = Symbol(__DEV__ ? `applyDirectives` : ``)
|
||||
export const WITH_DIRECTIVES = Symbol(__DEV__ ? `withDirectives` : ``)
|
||||
export const RENDER_LIST = Symbol(__DEV__ ? `renderList` : ``)
|
||||
export const RENDER_SLOT = Symbol(__DEV__ ? `renderSlot` : ``)
|
||||
export const CREATE_SLOTS = Symbol(__DEV__ ? `createSlots` : ``)
|
||||
@ -35,7 +35,7 @@ export const helperNameMap: any = {
|
||||
[RESOLVE_COMPONENT]: `resolveComponent`,
|
||||
[RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
||||
[RESOLVE_DIRECTIVE]: `resolveDirective`,
|
||||
[APPLY_DIRECTIVES]: `applyDirectives`,
|
||||
[WITH_DIRECTIVES]: `withDirectives`,
|
||||
[RENDER_LIST]: `renderList`,
|
||||
[RENDER_SLOT]: `renderSlot`,
|
||||
[CREATE_SLOTS]: `createSlots`,
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
CREATE_VNODE,
|
||||
FRAGMENT,
|
||||
helperNameMap,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
CREATE_BLOCK
|
||||
} from './runtimeHelpers'
|
||||
import { isVSlot, createBlockExpression } from './utils'
|
||||
@ -243,7 +243,7 @@ function finalizeRoot(root: RootNode, context: TransformContext) {
|
||||
const codegenNode = child.codegenNode as
|
||||
| ElementCodegenNode
|
||||
| ComponentCodegenNode
|
||||
if (codegenNode.callee === APPLY_DIRECTIVES) {
|
||||
if (codegenNode.callee === WITH_DIRECTIVES) {
|
||||
codegenNode.arguments[0].callee = helper(CREATE_BLOCK)
|
||||
} else {
|
||||
codegenNode.callee = helper(CREATE_BLOCK)
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
ElementNode
|
||||
} from '../ast'
|
||||
import { TransformContext } from '../transform'
|
||||
import { APPLY_DIRECTIVES } from '../runtimeHelpers'
|
||||
import { WITH_DIRECTIVES } from '../runtimeHelpers'
|
||||
import { PatchFlags, isString, isSymbol } from '@vue/shared'
|
||||
import { isSlotOutlet, findProp } from '../utils'
|
||||
|
||||
@ -72,7 +72,7 @@ function walk(
|
||||
!hasDynamicKeyOrRef(child)
|
||||
) {
|
||||
let codegenNode = child.codegenNode as ElementCodegenNode
|
||||
if (codegenNode.callee === APPLY_DIRECTIVES) {
|
||||
if (codegenNode.callee === WITH_DIRECTIVES) {
|
||||
codegenNode = codegenNode.arguments[0]
|
||||
}
|
||||
const props = codegenNode.arguments[1]
|
||||
@ -99,7 +99,7 @@ function walk(
|
||||
|
||||
function getPatchFlag(node: PlainElementNode): number | undefined {
|
||||
let codegenNode = node.codegenNode as ElementCodegenNode
|
||||
if (codegenNode.callee === APPLY_DIRECTIVES) {
|
||||
if (codegenNode.callee === WITH_DIRECTIVES) {
|
||||
codegenNode = codegenNode.arguments[0]
|
||||
}
|
||||
const flag = codegenNode.arguments[3]
|
||||
|
@ -19,7 +19,7 @@ import { PatchFlags, PatchFlagNames, isSymbol } from '@vue/shared'
|
||||
import { createCompilerError, ErrorCodes } from '../errors'
|
||||
import {
|
||||
CREATE_VNODE,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
RESOLVE_DIRECTIVE,
|
||||
RESOLVE_COMPONENT,
|
||||
RESOLVE_DYNAMIC_COMPONENT,
|
||||
@ -177,7 +177,7 @@ export const transformElement: NodeTransform = (node, context) => {
|
||||
|
||||
if (runtimeDirectives && runtimeDirectives.length) {
|
||||
node.codegenNode = createCallExpression(
|
||||
context.helper(APPLY_DIRECTIVES),
|
||||
context.helper(WITH_DIRECTIVES),
|
||||
[
|
||||
vnode,
|
||||
createArrayExpression(
|
||||
|
@ -31,7 +31,7 @@ import {
|
||||
OPEN_BLOCK,
|
||||
CREATE_BLOCK,
|
||||
FRAGMENT,
|
||||
APPLY_DIRECTIVES
|
||||
WITH_DIRECTIVES
|
||||
} from '../runtimeHelpers'
|
||||
import { processExpression } from './transformExpression'
|
||||
import { PatchFlags, PatchFlagNames } from '@vue/shared'
|
||||
@ -151,7 +151,7 @@ export const transformFor = createStructuralDirectiveTransform(
|
||||
// Normal element v-for. Directly use the child's codegenNode
|
||||
// arguments, but replace createVNode() with createBlock()
|
||||
let codegenNode = node.codegenNode as ElementCodegenNode
|
||||
if (codegenNode.callee === APPLY_DIRECTIVES) {
|
||||
if (codegenNode.callee === WITH_DIRECTIVES) {
|
||||
codegenNode.arguments[0].callee = helper(CREATE_BLOCK)
|
||||
} else {
|
||||
codegenNode.callee = helper(CREATE_BLOCK)
|
||||
|
@ -32,7 +32,7 @@ import {
|
||||
CREATE_BLOCK,
|
||||
COMMENT,
|
||||
FRAGMENT,
|
||||
APPLY_DIRECTIVES,
|
||||
WITH_DIRECTIVES,
|
||||
CREATE_VNODE
|
||||
} from '../runtimeHelpers'
|
||||
import { injectProp } from '../utils'
|
||||
@ -196,7 +196,7 @@ function createChildrenCodegenNode(
|
||||
| SlotOutletCodegenNode
|
||||
let vnodeCall = childCodegen
|
||||
// Element with custom directives. Locate the actual createVNode() call.
|
||||
if (vnodeCall.callee === APPLY_DIRECTIVES) {
|
||||
if (vnodeCall.callee === WITH_DIRECTIVES) {
|
||||
vnodeCall = vnodeCall.arguments[0]
|
||||
}
|
||||
// Change createVNode to createBlock.
|
||||
|
@ -5,9 +5,9 @@ exports[`compiler: transform v-model modifiers .lazy 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -27,9 +27,9 @@ exports[`compiler: transform v-model modifiers .number 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -49,9 +49,9 @@ exports[`compiler: transform v-model modifiers .trim 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -71,9 +71,9 @@ exports[`compiler: transform v-model simple expression 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -88,9 +88,9 @@ exports[`compiler: transform v-model simple expression for input (checkbox) 1`]
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelCheckbox: _vModelCheckbox, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelCheckbox: _vModelCheckbox, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
type: \\"checkbox\\",
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
@ -106,11 +106,11 @@ exports[`compiler: transform v-model simple expression for input (dynamic type)
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelDynamic: _vModelDynamic, createVNode: _createVNode, applyDirectives: _applyDirectives, resolveDirective: _resolveDirective, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelDynamic: _vModelDynamic, createVNode: _createVNode, withDirectives: _withDirectives, resolveDirective: _resolveDirective, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
const _directive_bind = _resolveDirective(\\"bind\\")
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -126,9 +126,9 @@ exports[`compiler: transform v-model simple expression for input (radio) 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelRadio: _vModelRadio, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelRadio: _vModelRadio, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
type: \\"radio\\",
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
@ -144,9 +144,9 @@ exports[`compiler: transform v-model simple expression for input (text) 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"input\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"input\\", {
|
||||
type: \\"text\\",
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
@ -162,9 +162,9 @@ exports[`compiler: transform v-model simple expression for select 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelSelect: _vModelSelect, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelSelect: _vModelSelect, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"select\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"select\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
@ -179,9 +179,9 @@ exports[`compiler: transform v-model simple expression for textarea 1`] = `
|
||||
|
||||
return function render() {
|
||||
with (this) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, applyDirectives: _applyDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, createBlock: _createBlock, openBlock: _openBlock } = _Vue
|
||||
|
||||
return (_openBlock(), _applyDirectives(_createBlock(\\"textarea\\", {
|
||||
return (_openBlock(), _withDirectives(_createBlock(\\"textarea\\", {
|
||||
modelValue: model,
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]), [
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
inject,
|
||||
resolveComponent,
|
||||
resolveDirective,
|
||||
applyDirectives,
|
||||
withDirectives,
|
||||
Plugin,
|
||||
ref,
|
||||
getCurrentInstance
|
||||
@ -128,7 +128,7 @@ describe('api: createApp', () => {
|
||||
return () => {
|
||||
// resolve in render
|
||||
const BarBaz = resolveDirective('bar-baz')!
|
||||
return applyDirectives(h('div'), [[FooBar], [BarBaz]])
|
||||
return withDirectives(h('div'), [[FooBar], [BarBaz]])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {
|
||||
h,
|
||||
applyDirectives,
|
||||
withDirectives,
|
||||
ref,
|
||||
render,
|
||||
nodeOps,
|
||||
@ -107,7 +107,7 @@ describe('directives', () => {
|
||||
},
|
||||
render() {
|
||||
_prevVnode = _vnode
|
||||
_vnode = applyDirectives(h('div', count.value), [
|
||||
_vnode = withDirectives(h('div', count.value), [
|
||||
[
|
||||
{
|
||||
beforeMount,
|
||||
@ -174,7 +174,7 @@ describe('directives', () => {
|
||||
},
|
||||
render() {
|
||||
_prevVnode = _vnode
|
||||
_vnode = applyDirectives(h('div', count.value), [
|
||||
_vnode = withDirectives(h('div', count.value), [
|
||||
[
|
||||
fn,
|
||||
// value
|
||||
|
@ -11,8 +11,8 @@ return applyDirectives(h(comp), [
|
||||
])
|
||||
*/
|
||||
|
||||
import { VNode, cloneVNode } from './vnode'
|
||||
import { extend, isArray, isFunction, EMPTY_OBJ, makeMap } from '@vue/shared'
|
||||
import { VNode } from './vnode'
|
||||
import { isArray, isFunction, EMPTY_OBJ, makeMap } from '@vue/shared'
|
||||
import { warn } from './warning'
|
||||
import { ComponentInternalInstance } from './component'
|
||||
import { currentRenderingInstance } from './componentRenderUtils'
|
||||
@ -120,11 +120,10 @@ export type DirectiveArguments = Array<
|
||||
| [Directive, any, string, DirectiveModifiers]
|
||||
>
|
||||
|
||||
export function applyDirectives(vnode: VNode, directives: DirectiveArguments) {
|
||||
export function withDirectives(vnode: VNode, directives: DirectiveArguments) {
|
||||
const instance = currentRenderingInstance
|
||||
if (instance !== null) {
|
||||
vnode = cloneVNode(vnode)
|
||||
vnode.props = vnode.props != null ? extend({}, vnode.props) : {}
|
||||
vnode.props = vnode.props || {}
|
||||
for (let i = 0; i < directives.length; i++) {
|
||||
const [dir, value, arg, modifiers] = directives[i]
|
||||
applyDirective(vnode.props, instance, dir, value, arg, modifiers)
|
||||
|
@ -38,7 +38,7 @@ export {
|
||||
|
||||
// Internal, for compiler generated code
|
||||
// should sync with '@vue/compiler-core/src/runtimeConstants.ts'
|
||||
export { applyDirectives } from './directives'
|
||||
export { withDirectives } from './directives'
|
||||
export {
|
||||
resolveComponent,
|
||||
resolveDirective,
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
nextTick,
|
||||
createComponent,
|
||||
vModelDynamic,
|
||||
applyDirectives,
|
||||
withDirectives,
|
||||
VNode
|
||||
} from '@vue/runtime-dom'
|
||||
|
||||
@ -14,7 +14,7 @@ const triggerEvent = (type: string, el: Element) => {
|
||||
}
|
||||
|
||||
const withVModel = (node: VNode, arg: any, mods?: any) =>
|
||||
applyDirectives(node, [[vModelDynamic, arg, '', mods]])
|
||||
withDirectives(node, [[vModelDynamic, arg, '', mods]])
|
||||
|
||||
const setValue = function(this: any, value: any) {
|
||||
this.value = value
|
||||
|
Loading…
Reference in New Issue
Block a user