mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Make deep _.clone copy array properties assigned by RegExp#exec.
Former-commit-id: b465457babfc04e8204048dfaeff6e5d37e5e43c
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -939,11 +939,14 @@
|
||||
|
||||
/**
|
||||
* Creates a clone of `value`. If `deep` is `true`, all nested objects will
|
||||
* also be cloned otherwise they will be assigned by reference. Functions and
|
||||
* also be cloned, otherwise they will be assigned by reference. Functions and
|
||||
* DOM nodes are **not** cloned. The enumerable properties of `arguments` objects
|
||||
* and objects created by constructors other than `Object` are cloned to plain
|
||||
* Object objects.
|
||||
*
|
||||
* Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm.
|
||||
* See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
@@ -1032,6 +1035,15 @@
|
||||
result[key] = clone(objValue, deep, null, stackA, stackB);
|
||||
});
|
||||
|
||||
// add array properties assigned by `RegExp#exec`
|
||||
if (isArr) {
|
||||
if (hasOwnProperty.call(value, 'index')) {
|
||||
result.index = value.index;
|
||||
}
|
||||
if (hasOwnProperty.call(value, 'input')) {
|
||||
result.input = value.input;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3643,7 +3655,7 @@
|
||||
/**
|
||||
* This function returns the first argument passed to it.
|
||||
*
|
||||
* Note: It is used throughout Lo-Dash as a default callback.
|
||||
* Note: This function is used throughout Lo-Dash as a default callback.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
Reference in New Issue
Block a user