Skip to content

Commit b4c511d

Browse files
committed
chore: fix unit tests
1 parent 54f5f9b commit b4c511d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/core/observer/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { isReadonly, isRef } from '../../v3'
1919

2020
const arrayKeys = Object.getOwnPropertyNames(arrayMethods)
2121

22+
const NO_INIITIAL_VALUE = {}
23+
2224
/**
2325
* In some cases we may want to disable observation inside a component's
2426
* update computation.
@@ -67,7 +69,7 @@ export class Observer {
6769
const keys = Object.keys(obj)
6870
for (let i = 0; i < keys.length; i++) {
6971
const key = keys[i]
70-
defineReactive(obj, key, obj[key], undefined, shallow)
72+
defineReactive(obj, key, NO_INIITIAL_VALUE, undefined, shallow)
7173
}
7274
}
7375

@@ -149,7 +151,10 @@ export function defineReactive(
149151
// cater for pre-defined getter/setters
150152
const getter = property && property.get
151153
const setter = property && property.set
152-
if ((!getter || setter) && arguments.length === 2) {
154+
if (
155+
(!getter || setter) &&
156+
(val === NO_INIITIAL_VALUE || arguments.length === 2)
157+
) {
153158
val = obj[key]
154159
}
155160

test/unit/features/directives/class.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Vue from 'vue'
2+
import { isFunction } from 'core/util'
23

34
function assertClass(assertions, done) {
45
const vm = new Vue({

test/unit/modules/compiler/codegen.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { parse } from 'compiler/parser/index'
22
import { optimize } from 'compiler/optimizer'
33
import { generate } from 'compiler/codegen'
4-
import { isObject, extend } from 'shared/util'
4+
import { isObject, isFunction, extend } from 'shared/util'
55
import { isReservedTag } from 'web/util/index'
66
import { baseOptions } from 'web/compiler/options'
77

0 commit comments

Comments
 (0)