mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Make _.runInContext not require a fully populated context object.
Former-commit-id: 11bf3cad2bfd3e922e7701eb7b0f48028f522ba6
This commit is contained in:
20
dist/lodash.underscore.js
vendored
20
dist/lodash.underscore.js
vendored
@@ -333,10 +333,8 @@
|
||||
: partialArgs;
|
||||
}
|
||||
if (this instanceof bound) {
|
||||
// ensure `new bound` is an instance of `bound` and `func`
|
||||
noop.prototype = func.prototype;
|
||||
thisBinding = new noop;
|
||||
noop.prototype = null;
|
||||
// ensure `new bound` is an instance of `func`
|
||||
thisBinding = createObject(func.prototype);
|
||||
|
||||
// mimic the constructor's `return` behavior
|
||||
// http://es5.github.com/#x13.2.2
|
||||
@@ -406,6 +404,20 @@
|
||||
return func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new object that inherits from the given `prototype` object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} prototype The prototype object.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function createObject(prototype) {
|
||||
noop.prototype = prototype;
|
||||
var result = new noop;
|
||||
noop.prototype = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function compiled to iterate `arguments` objects, arrays, objects, and
|
||||
* strings consistenly across environments, executing the `callback` for each
|
||||
|
||||
Reference in New Issue
Block a user