Skip to content

Commit

Permalink
Remove check for Symbol.toStringTag field mutations in baseGetTag (lo…
Browse files Browse the repository at this point in the history
  • Loading branch information
blikblum authored and jdalton committed Dec 11, 2018
1 parent 6cb1f71 commit c77650a
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions .internal/baseGetTag.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const objectProto = Object.prototype
const hasOwnProperty = objectProto.hasOwnProperty
const toString = objectProto.toString
const symToStringTag = Symbol.toStringTag
const toString = Object.prototype.toString

/**
* The base implementation of `getTag` without fallbacks for buggy environments.
Expand All @@ -14,26 +11,7 @@ function baseGetTag(value) {
if (value == null) {
return value === undefined ? '[object Undefined]' : '[object Null]'
}
if (!(symToStringTag in Object(value))) {
return toString.call(value)
}
const isOwn = hasOwnProperty.call(value, symToStringTag)
const tag = value[symToStringTag]
let unmasked = false
try {
value[symToStringTag] = undefined
unmasked = true
} catch (e) {}

const result = toString.call(value)
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag
} else {
delete value[symToStringTag]
}
}
return result
return toString.call(value)
}

export default baseGetTag

0 comments on commit c77650a

Please sign in to comment.