Use Object.freeze in a backwards compatible way
This commit is contained in:
parent
7452fe0c0b
commit
8b79d0f94b
|
@ -541,7 +541,10 @@ function equal(a, b) {
|
|||
|
||||
function defineReadonlyProperty(obj, key, value) {
|
||||
var copy = deepCopy(value);
|
||||
Object.freeze(copy);
|
||||
// In ES6, freezing a literal is OK (it returns the same value), but in previous versions it's an exception.
|
||||
if (typeof copy == "object") {
|
||||
Object.freeze(copy);
|
||||
}
|
||||
Object.defineProperty(obj, key, {value: copy, configurable: true})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user