mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Only use built-in Object.assign when in strict mode.
This commit is contained in:
@@ -803,12 +803,19 @@
|
|||||||
//
|
//
|
||||||
// Use `Object.preventExtensions` on a plain object instead of simply using
|
// Use `Object.preventExtensions` on a plain object instead of simply using
|
||||||
// `Object('x')` because Chrome and IE fail to throw an error when attempting
|
// `Object('x')` because Chrome and IE fail to throw an error when attempting
|
||||||
// to assign values to readonly indexes of strings in strict mode.
|
// to assign values to readonly indexes of strings.
|
||||||
var object = { '1': 0 },
|
var func = preventExtensions && isNative(func = Object.assign) && func;
|
||||||
func = preventExtensions && isNative(func = Object.assign) && func;
|
try {
|
||||||
|
if (func) {
|
||||||
try { func(preventExtensions(object), 'xo'); } catch(e) {}
|
var object = preventExtensions({ '1': 0 });
|
||||||
return !object[1] && func;
|
object[0] = 1;
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
// Only attempt in strict mode.
|
||||||
|
try { func(object, 'xo'); } catch(e) {}
|
||||||
|
return !object[1] && func;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/* Native method references for those with the same name as other `lodash` methods. */
|
/* Native method references for those with the same name as other `lodash` methods. */
|
||||||
|
|||||||
Reference in New Issue
Block a user