Skip to content

Commit 5cf4593

Browse files
committed
fix(core): fix type check for Date prop
Now it checks a prop by `[object Date]` instead of `instanceof Date`
1 parent 515467a commit 5cf4593

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/core/util/props.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
toRawType,
99
hyphenate,
1010
capitalize,
11+
isDate,
1112
isPlainObject
1213
} from 'shared/util'
1314

@@ -166,6 +167,8 @@ function assertType (value: any, type: Function, vm: ?Component): {
166167
valid = isPlainObject(value)
167168
} else if (expectedType === 'Array') {
168169
valid = Array.isArray(value)
170+
} else if (expectedType === 'Date') {
171+
valid = isDate(value)
169172
} else {
170173
try {
171174
valid = value instanceof type

src/shared/util.js

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export function isRegExp (v: any): boolean {
6363
return _toString.call(v) === '[object RegExp]'
6464
}
6565

66+
export function isDate (v: any): boolean {
67+
return _toString.call(v) === '[object Date]'
68+
}
69+
6670
/**
6771
* Check if val is a valid array index.
6872
*/

0 commit comments

Comments
 (0)