Skip to content

Commit b97beb8

Browse files
leshakosskossnocorp
authored andcommitted
Replace instanceof with safe alternative
1 parent 525e0fb commit b97beb8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/locale/_lib/buildMatchFn/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function buildMatchFn (args) {
1515
var parsePatterns = (width && args.parsePatterns[width]) || args.parsePatterns[args.defaultParseWidth]
1616

1717
var value
18-
if (parsePatterns instanceof Array) {
18+
if (Object.prototype.toString.call(parsePatterns) === '[object Array]') {
1919
value = parsePatterns.findIndex(function (pattern) {
2020
return pattern.test(string)
2121
})

src/toDate/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export default function toDate (argument, dirtyOptions) {
101101
if (argument instanceof Date) {
102102
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
103103
return new Date(argument.getTime())
104-
} else if (typeof argument === 'number' || argument instanceof Number) {
104+
} else if (typeof argument === 'number' || Object.prototype.toString.call(argument) === '[object Number]') {
105105
return new Date(argument)
106-
} else if (!(typeof argument === 'string' || argument instanceof String)) {
106+
} else if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
107107
return new Date(NaN)
108108
}
109109

0 commit comments

Comments
 (0)