Skip to content

Commit c8946b7

Browse files
committed
Fixes #231
1 parent e1b9757 commit c8946b7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import Vue from 'vue';
22

33
const toString = (x: any) => Object.prototype.toString.call(x);
44

5-
export function isNative (Ctor: any): boolean {
6-
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
5+
export function isNative(Ctor: any): boolean {
6+
return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
77
}
88

99
export const hasSymbol =
10-
typeof Symbol !== 'undefined' && isNative(Symbol) &&
11-
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys)
10+
typeof Symbol !== 'undefined' &&
11+
isNative(Symbol) &&
12+
typeof Reflect !== 'undefined' &&
13+
isNative(Reflect.ownKeys);
1214

1315
export const noopFn: any = (_: any) => _;
1416

@@ -34,9 +36,8 @@ export function def(obj: Object, key: string, val: any, enumerable?: boolean) {
3436
});
3537
}
3638

37-
const hasOwnProperty = Object.prototype.hasOwnProperty;
3839
export function hasOwn(obj: Object | any[], key: string): boolean {
39-
return hasOwnProperty.call(obj, key);
40+
return obj !== null && Object.hasOwnProperty.call(obj, key);
4041
}
4142

4243
export function assert(condition: any, msg: string) {

test/setup.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ describe('setup', () => {
2020
expect(vm.a).toBe(1);
2121
});
2222

23+
it('should work with non reactive null', () => {
24+
const vm = new Vue({
25+
setup() {
26+
return {
27+
a: null,
28+
};
29+
},
30+
}).$mount();
31+
expect(vm.a).toBe(null);
32+
});
33+
2334
it('should be overrided by data option of plain object', () => {
2435
const vm = new Vue({
2536
setup() {

0 commit comments

Comments
 (0)