Skip to content

Commit 5013304

Browse files
authored
refactor: tidy up (#2036)
1 parent b08c1db commit 5013304

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/shared/validators.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function isVueComponent(c: any): boolean {
3333
return true
3434
}
3535

36-
if (c === null || typeof c !== 'object') {
36+
if (!isPlainObject(c)) {
3737
return false
3838
}
3939

@@ -63,7 +63,7 @@ export function componentNeedsCompiling(component: Component): boolean {
6363

6464
export function isRefSelector(refOptionsObject: any): boolean {
6565
if (
66-
typeof refOptionsObject !== 'object' ||
66+
!isPlainObject(refOptionsObject) ||
6767
Object.keys(refOptionsObject || {}).length !== 1
6868
) {
6969
return false
@@ -73,7 +73,7 @@ export function isRefSelector(refOptionsObject: any): boolean {
7373
}
7474

7575
export function isNameSelector(nameOptionsObject: any): boolean {
76-
if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
76+
if (!isPlainObject(nameOptionsObject)) {
7777
return false
7878
}
7979

@@ -89,7 +89,7 @@ export function isDynamicComponent(c: any) {
8989
}
9090

9191
export function isComponentOptions(c: any) {
92-
return c !== null && typeof c === 'object' && (c.template || c.render)
92+
return isPlainObject(c) && (c.template || c.render)
9393
}
9494

9595
export function isFunctionalComponent(c: any) {

packages/test-utils/src/wrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
warnDeprecated,
2020
isVueWrapper
2121
} from 'shared/util'
22+
import { isPlainObject } from 'shared/validators'
2223
import { isElementVisible } from 'shared/is-visible'
2324
import find from './find'
2425
import createWrapper from './create-wrapper'
@@ -719,8 +720,7 @@ export default class Wrapper implements BaseWrapper {
719720
Object.keys(data).forEach(key => {
720721
// Don't let people set entire objects, because reactivity won't work
721722
if (
722-
typeof data[key] === 'object' &&
723-
data[key] !== null &&
723+
isPlainObject(data[key]) &&
724724
// $FlowIgnore : Problem with possibly null this.vm
725725
data[key] === this.vm[key]
726726
) {

0 commit comments

Comments
 (0)