wip(ssr): adjust event hydration flag

This commit is contained in:
Evan You
2020-02-13 18:28:40 -05:00
parent 6b505dcd23
commit 9aaef60ad2
22 changed files with 190 additions and 138 deletions

View File

@@ -7,7 +7,7 @@ const { createVNode: _createVNode } = _Vue
const _hoisted_1 = {}
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { createVNode: _createVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return (_openBlock(), _createBlock(_Fragment, null, [

View File

@@ -4,7 +4,7 @@ exports[`compiler: transform v-model input w/ dynamic v-bind 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelDynamic: _vModelDynamic, mergeProps: _mergeProps, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", _mergeProps(obj, {
@@ -21,7 +21,7 @@ exports[`compiler: transform v-model input w/ dynamic v-bind 2`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
@@ -41,7 +41,7 @@ exports[`compiler: transform v-model modifiers .lazy 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -63,7 +63,7 @@ exports[`compiler: transform v-model modifiers .number 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -85,7 +85,7 @@ exports[`compiler: transform v-model modifiers .trim 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -107,7 +107,7 @@ exports[`compiler: transform v-model simple expression 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -124,7 +124,7 @@ exports[`compiler: transform v-model simple expression for input (checkbox) 1`]
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelCheckbox: _vModelCheckbox, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -142,7 +142,7 @@ exports[`compiler: transform v-model simple expression for input (dynamic type)
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelDynamic: _vModelDynamic, resolveDirective: _resolveDirective, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
const _directive_bind = _resolveDirective(\\"bind\\")
@@ -162,7 +162,7 @@ exports[`compiler: transform v-model simple expression for input (radio) 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelRadio: _vModelRadio, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -180,7 +180,7 @@ exports[`compiler: transform v-model simple expression for input (text) 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"input\\", {
@@ -198,7 +198,7 @@ exports[`compiler: transform v-model simple expression for select 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelSelect: _vModelSelect, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"select\\", {
@@ -215,7 +215,7 @@ exports[`compiler: transform v-model simple expression for textarea 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"textarea\\", {

View File

@@ -4,10 +4,10 @@ exports[`compiler: v-show transform simple expression 1`] = `
"const _Vue = Vue
return function render(_ctx, _cache) {
with (this) {
with (_ctx) {
const { vShow: _vShow, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, -1 /* NEED_PATCH */)), [
return _withDirectives((_openBlock(), _createBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [
[_vShow, a]
])
}

View File

@@ -11,7 +11,11 @@ import { transformOn } from '../../src/transforms/vOn'
import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../../src/runtimeHelpers'
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
import { transformExpression } from '../../../compiler-core/src/transforms/transformExpression'
import { createObjectMatcher } from '../../../compiler-core/__tests__/testUtils'
import {
createObjectMatcher,
genFlagText
} from '../../../compiler-core/__tests__/testUtils'
import { PatchFlags } from '@vue/shared'
function parseWithVOn(template: string, options: CompilerOptions = {}) {
const ast = parse(template)
@@ -157,8 +161,11 @@ describe('compiler-dom: transform v-on', () => {
cacheHandlers: true
})
expect(root.cached).toBe(1)
// should not treat cached handler as dynamicProp, so no flags
expect((root as any).children[0].codegenNode.patchFlag).toBeUndefined()
// should not treat cached handler as dynamicProp, so it should have no
// dynamicProps flags and only the hydration flag
expect((root as any).children[0].codegenNode.patchFlag).toBe(
genFlagText(PatchFlags.HYDRATE_EVENTS)
)
expect(prop.value).toMatchObject({
type: NodeTypes.JS_CACHE_EXPRESSION,
index: 1,