From a55d822f9abdb877213b8c4a6b9f337e6b1e2b38 Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 10 Apr 2015 21:24:32 -0700 Subject: [PATCH] Add more comments to `nativeAssign` definition. [ci skip] --- lodash.src.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 57deacf12..ac4680e6c 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -797,12 +797,17 @@ /** Used as `baseAssign`. */ var nativeAssign = (function() { + 'use strict'; + // Avoid `Object.assign` in Firefox 34-37 which have an early implementation + // with a now defunct try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344 + // for more details. + // + // Use `Object.preventExtensions` on a plain object instead of simply using + // `Object('x')` because Chrome and IE fail to throw an error when attempting + // to assign values to readonly indexes of strings in strict mode. var object = { '1': 0 }, func = preventExtensions && isNative(func = Object.assign) && func; - // Avoid `Object.assign` in Firefox 34-37 which have an early implementation - // with a slower try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344 - // for more details. try { func(preventExtensions(object), 'xo'); } catch(e) {} return !object[1] && func; }());