Skip to content

Commit aac7634

Browse files
committed
Revert "feat: auto cache inline prop literals to avoid child re-render"
This reverts commit 996eb00.
1 parent ec2c48c commit aac7634

File tree

6 files changed

+0
-83
lines changed

6 files changed

+0
-83
lines changed

flow/component.js

-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ declare interface Component {
6969
_staticTrees: ?Array<VNode>; // v-once cached trees
7070
_hasHookEvent: boolean;
7171
_provided: ?Object;
72-
_inlineComputed: ?{ [key: string]: Watcher }; // inline computed watchers for literal props
7372
// _virtualComponents?: { [key: string]: Component };
7473

7574
// private methods
@@ -131,8 +130,6 @@ declare interface Component {
131130
_k: (eventKeyCode: number, key: string, builtInAlias?: number | Array<number>, eventKeyName?: string) => ?boolean;
132131
// resolve scoped slots
133132
_u: (scopedSlots: ScopedSlotsData, res?: Object) => { [key: string]: Function };
134-
// create / return value from inline computed
135-
_a: (id: number, getter: Function) => any;
136133

137134
// SSR specific
138135
_ssrNode: Function;

src/compiler/parser/index.js

-15
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,16 @@ const argRE = /:(.*)$/
2929
export const bindRE = /^:|^v-bind:/
3030
const modifierRE = /\.[^.]+/g
3131

32-
const literalValueRE = /^(\{.*\}|\[.*\])$/
33-
3432
const decodeHTMLCached = cached(he.decode)
3533

3634
// configurable state
3735
export let warn: any
38-
let literalPropId
3936
let delimiters
4037
let transforms
4138
let preTransforms
4239
let postTransforms
4340
let platformIsPreTag
4441
let platformMustUseProp
45-
let platformIsReservedTag
4642
let platformGetTagNamespace
4743

4844
type Attr = { name: string; value: string };
@@ -70,11 +66,9 @@ export function parse (
7066
options: CompilerOptions
7167
): ASTElement | void {
7268
warn = options.warn || baseWarn
73-
literalPropId = 0
7469

7570
platformIsPreTag = options.isPreTag || no
7671
platformMustUseProp = options.mustUseProp || no
77-
platformIsReservedTag = options.isReservedTag || no
7872
platformGetTagNamespace = options.getTagNamespace || no
7973

8074
transforms = pluckModuleFunction(options.modules, 'transformNode')
@@ -544,15 +538,6 @@ function processAttrs (el) {
544538
)
545539
}
546540
}
547-
// optimize literal values in component props by wrapping them
548-
// in an inline watcher to avoid unnecessary re-renders
549-
if (
550-
!platformIsReservedTag(el.tag) &&
551-
el.tag !== 'slot' &&
552-
literalValueRE.test(value.trim())
553-
) {
554-
value = `_a(${literalPropId++},function(){return ${value}})`
555-
}
556541
if (isProp || (
557542
!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
558543
)) {

src/core/instance/render-helpers/create-inline-computed.js

-28
This file was deleted.

src/core/instance/render-helpers/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { bindObjectProps } from './bind-object-props'
1010
import { renderStatic, markOnce } from './render-static'
1111
import { bindObjectListeners } from './bind-object-listeners'
1212
import { resolveScopedSlots } from './resolve-slots'
13-
import { createInlineComputed } from './create-inline-computed'
1413

1514
export function installRenderHelpers (target: any) {
1615
target._o = markOnce
@@ -28,5 +27,4 @@ export function installRenderHelpers (target: any) {
2827
target._e = createEmptyVNode
2928
target._u = resolveScopedSlots
3029
target._g = bindObjectListeners
31-
target._a = createInlineComputed
3230
}

src/core/instance/state.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function proxy (target: Object, sourceKey: string, key: string) {
4747

4848
export function initState (vm: Component) {
4949
vm._watchers = []
50-
vm._inlineComputed = null
5150
const opts = vm.$options
5251
if (opts.props) initProps(vm, opts.props)
5352
if (opts.methods) initMethods(vm, opts.methods)

test/unit/features/options/props.spec.js

-34
Original file line numberDiff line numberDiff line change
@@ -512,38 +512,4 @@ describe('Options props', () => {
512512
expect(`"${attr}" is a reserved attribute`).toHaveBeenWarned()
513513
})
514514
})
515-
516-
it('should not trigger re-render on non-changed inline literals', done => {
517-
const updated = jasmine.createSpy('updated')
518-
const vm = new Vue({
519-
data: {
520-
n: 1,
521-
m: 1
522-
},
523-
template: `
524-
<div id="app">
525-
{{ n }} {{ m }} <foo :a="{ n: 1 }" :b="{ n: n }"/>
526-
</div>
527-
`,
528-
components: {
529-
foo: {
530-
props: ['a', 'b'],
531-
updated,
532-
template: `<div>{{ a.n }} {{ b.n }}</div>`
533-
}
534-
}
535-
}).$mount()
536-
537-
expect(vm.$el.textContent).toContain('1 1 1 1')
538-
vm.n++ // literals that actually contain changed reactive data should trigger update
539-
waitForUpdate(() => {
540-
expect(vm.$el.textContent).toContain('2 1 1 2')
541-
expect(updated.calls.count()).toBe(1)
542-
}).then(() => {
543-
vm.m++ // changing data that does not affect any literals should not trigger update
544-
}).then(() => {
545-
expect(vm.$el.textContent).toContain('2 2 1 2')
546-
expect(updated.calls.count()).toBe(1)
547-
}).then(done)
548-
})
549515
})

0 commit comments

Comments
 (0)