refactor: applyDirectives -> withDirectives

This commit is contained in:
Evan You
2019-10-18 16:35:01 -04:00
parent cba34453db
commit e98a85f3cb
20 changed files with 63 additions and 64 deletions

View File

@@ -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 }

View File

@@ -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]
])
]))

View File

@@ -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 */))

View File

@@ -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,

View File

@@ -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

View File

@@ -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 }

View File

@@ -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]` })