mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Avoid circular dependency in createCallback and get Curl modularize tests working.
Former-commit-id: cf33217163f2c809fe8ddbb9debd7c95b002b8dc
This commit is contained in:
12
build.js
12
build.js
@@ -102,7 +102,7 @@
|
|||||||
'compose': [],
|
'compose': [],
|
||||||
'contains': ['basicEach', 'getIndexOf', 'isString'],
|
'contains': ['basicEach', 'getIndexOf', 'isString'],
|
||||||
'countBy': ['createCallback', 'forEach'],
|
'countBy': ['createCallback', 'forEach'],
|
||||||
'createCallback': ['identity', 'isEqual', 'keys'],
|
'createCallback': ['identity', 'keys'],
|
||||||
'debounce': ['isObject'],
|
'debounce': ['isObject'],
|
||||||
'defaults': ['createCallback', 'createIterator'],
|
'defaults': ['createCallback', 'createIterator'],
|
||||||
'defer': ['bind'],
|
'defer': ['bind'],
|
||||||
@@ -252,19 +252,19 @@
|
|||||||
var varDependencyMap = {
|
var varDependencyMap = {
|
||||||
'bind': ['reNative'],
|
'bind': ['reNative'],
|
||||||
'bindKey': ['indicatorObject'],
|
'bindKey': ['indicatorObject'],
|
||||||
'createCallback': ['indicatorObject'],
|
'createCallback': ['dependencyObject', 'indicatorObject'],
|
||||||
'createIterator': ['indicatorObject', 'iteratorObject', 'objectTypes'],
|
'createIterator': ['dependencyObject', 'indicatorObject', 'objectTypes'],
|
||||||
'createObject': ['reNative'],
|
'createObject': ['reNative'],
|
||||||
'defer': ['objectTypes', 'reNative'],
|
'defer': ['objectTypes', 'reNative'],
|
||||||
'escape': ['reUnescapedHtml'],
|
'escape': ['reUnescapedHtml'],
|
||||||
'escapeHtmlChar': ['htmlEscapes'],
|
'escapeHtmlChar': ['htmlEscapes'],
|
||||||
'htmlUnescapes': ['htmlEscapes'],
|
'htmlUnescapes': ['htmlEscapes'],
|
||||||
'isArray': ['reNative'],
|
'isArray': ['reNative'],
|
||||||
'isEqual': ['indicatorObject'],
|
'isEqual': ['dependencyObject', 'indicatorObject'],
|
||||||
'isObject': ['objectTypes'],
|
'isObject': ['objectTypes'],
|
||||||
'isPlainObject': ['reNative'],
|
'isPlainObject': ['reNative'],
|
||||||
'isRegExp': ['objectTypes'],
|
'isRegExp': ['objectTypes'],
|
||||||
'keys': ['iteratorObject', 'reNative'],
|
'keys': ['dependencyObject', 'reNative'],
|
||||||
'merge': ['indicatorObject'],
|
'merge': ['indicatorObject'],
|
||||||
'partialRight': ['indicatorObject'],
|
'partialRight': ['indicatorObject'],
|
||||||
'reEscapedHtml': ['htmlUnescapes'],
|
'reEscapedHtml': ['htmlUnescapes'],
|
||||||
@@ -3285,7 +3285,7 @@
|
|||||||
// replace `_.isEqual`
|
// replace `_.isEqual`
|
||||||
if (!isLodash('isEqual')) {
|
if (!isLodash('isEqual')) {
|
||||||
source = replaceFunction(source, 'isEqual', [
|
source = replaceFunction(source, 'isEqual', [
|
||||||
'function isEqual(a, b, stackA, stackB) {',
|
'var isEqual = dependencyObject.isEqual = function(a, b, stackA, stackB) {',
|
||||||
' if (a === b) {',
|
' if (a === b) {',
|
||||||
' return a !== 0 || (1 / a == 1 / b);',
|
' return a !== 0 || (1 / a == 1 / b);',
|
||||||
' }',
|
' }',
|
||||||
|
|||||||
@@ -338,8 +338,8 @@
|
|||||||
'value'
|
'value'
|
||||||
];
|
];
|
||||||
|
|
||||||
// minify `iteratorObject.keys`
|
// minify `dependencyObject` properties
|
||||||
source = source.replace(/\b(iteratorObject(?:\.|\['))keys\b/g, function(match, prelude) {
|
source = source.replace(/\b(dependencyObject(?:\.|\['))\w+/g, function(match, prelude) {
|
||||||
return prelude + minNames[iteratorOptions.length + props.length];
|
return prelude + minNames[iteratorOptions.length + props.length];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
14
lodash.js
14
lodash.js
@@ -21,8 +21,8 @@
|
|||||||
/** Used internally to indicate various things */
|
/** Used internally to indicate various things */
|
||||||
var indicatorObject = {};
|
var indicatorObject = {};
|
||||||
|
|
||||||
/** Used to avoid reference errors in `createIterator` */
|
/** Used to avoid reference errors and circular dependency errors */
|
||||||
var iteratorObject = {};
|
var dependencyObject = {};
|
||||||
|
|
||||||
/** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
|
/** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
|
||||||
var keyPrefix = +new Date + '';
|
var keyPrefix = +new Date + '';
|
||||||
@@ -1122,7 +1122,7 @@
|
|||||||
*/
|
*/
|
||||||
function createIterator() {
|
function createIterator() {
|
||||||
var data = getObject(),
|
var data = getObject(),
|
||||||
keys = iteratorObject.keys;
|
keys = dependencyObject.keys;
|
||||||
|
|
||||||
// data properties
|
// data properties
|
||||||
data.shadowedProps = shadowedProps;
|
data.shadowedProps = shadowedProps;
|
||||||
@@ -1335,7 +1335,7 @@
|
|||||||
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
||||||
* // => ['one', 'two', 'three'] (order is not guaranteed)
|
* // => ['one', 'two', 'three'] (order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
var keys = iteratorObject.keys = !nativeKeys ? shimKeys : function(object) {
|
var keys = dependencyObject.keys = !nativeKeys ? shimKeys : function(object) {
|
||||||
if (!isObject(object)) {
|
if (!isObject(object)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -1917,7 +1917,7 @@
|
|||||||
* });
|
* });
|
||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
function isEqual(a, b, callback, thisArg, stackA, stackB) {
|
var isEqual = dependencyObject.isEqual = function(a, b, callback, thisArg, stackA, stackB) {
|
||||||
// used to indicate that when comparing objects, `a` has at least the properties of `b`
|
// used to indicate that when comparing objects, `a` has at least the properties of `b`
|
||||||
var whereIndicator = callback === indicatorObject;
|
var whereIndicator = callback === indicatorObject;
|
||||||
if (typeof callback == 'function' && !whereIndicator) {
|
if (typeof callback == 'function' && !whereIndicator) {
|
||||||
@@ -2073,7 +2073,7 @@
|
|||||||
releaseArray(stackB);
|
releaseArray(stackB);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is, or can be coerced to, a finite number.
|
* Checks if `value` is, or can be coerced to, a finite number.
|
||||||
@@ -4767,7 +4767,7 @@
|
|||||||
var length = props.length,
|
var length = props.length,
|
||||||
result = false;
|
result = false;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
if (!(result = isEqual(object[props[length]], func[props[length]], indicatorObject))) {
|
if (!(result = dependencyObject.isEqual(object[props[length]], func[props[length]], indicatorObject))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,40 +49,48 @@
|
|||||||
if (window.curl) {
|
if (window.curl) {
|
||||||
var require = curl;
|
var require = curl;
|
||||||
}
|
}
|
||||||
if (window.require) {
|
(function() {
|
||||||
|
if (!window.require) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var isModularize = /modularize/.test(ui.urlParams.build);
|
||||||
|
|
||||||
|
var baseUrl = isModularize
|
||||||
|
? '../modularize/'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
var modulePath = isModularize
|
||||||
|
? 'lodash'
|
||||||
|
: ui.buildPath.replace(/\.js$/, '');
|
||||||
|
|
||||||
|
var testPath = (
|
||||||
|
(window.curl ? ui.loaderPath.replace(/[\w.-]+$/, 'curl/plugin/js!') : '') +
|
||||||
|
(isModularize ? '../test/' : '') +
|
||||||
|
'test.js'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(testPath)
|
||||||
QUnit.config.autostart = false;
|
QUnit.config.autostart = false;
|
||||||
|
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
require((function() {
|
require({
|
||||||
var reModularize = /modularize/;
|
'baseUrl': baseUrl,
|
||||||
|
'urlArgs': 't=' + (+new Date),
|
||||||
var baseUrl = reModularize.test(ui.urlParams.build)
|
'paths': {
|
||||||
? '../modularize/'
|
'lodash': modulePath,
|
||||||
: '';
|
'shimmed': './abc/../' + modulePath,
|
||||||
|
'underscore': './xyz/../' + modulePath
|
||||||
var modulePath = reModularize.test(ui.urlParams.build)
|
},
|
||||||
? 'lodash'
|
'aliases': [
|
||||||
: ui.buildPath.replace(/\.js$/, '');
|
['shimmed', 'lodash'],
|
||||||
|
['underscore', 'lodash']
|
||||||
return {
|
],
|
||||||
'baseUrl': baseUrl,
|
'shim': {
|
||||||
'urlArgs': 't=' + (+new Date),
|
'shimmed': {
|
||||||
'paths': {
|
'exports': '_'
|
||||||
'lodash': modulePath,
|
|
||||||
'shimmed': './abc/../' + modulePath,
|
|
||||||
'underscore': './xyz/../' + modulePath
|
|
||||||
},
|
|
||||||
'aliases': [
|
|
||||||
['shimmed', 'lodash'],
|
|
||||||
['underscore', 'lodash']
|
|
||||||
],
|
|
||||||
'shim': {
|
|
||||||
'shimmed': {
|
|
||||||
'exports': '_'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}()),
|
},
|
||||||
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||||
if (shimmed && shimmed.noConflict) {
|
if (shimmed && shimmed.noConflict) {
|
||||||
shimmedModule = shimmed.noConflict();
|
shimmedModule = shimmed.noConflict();
|
||||||
@@ -96,17 +104,11 @@
|
|||||||
lodashModule = lodash.noConflict();
|
lodashModule = lodash.noConflict();
|
||||||
lodashModule.moduleName = 'lodash';
|
lodashModule.moduleName = 'lodash';
|
||||||
}
|
}
|
||||||
|
|
||||||
var testPath = (window.curl
|
|
||||||
? ui.loaderPath.replace(/[\w.-]+$/, 'curl/plugin/js!')
|
|
||||||
: ''
|
|
||||||
) + 'test.js';
|
|
||||||
|
|
||||||
require([testPath], function() {
|
require([testPath], function() {
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}());
|
||||||
|
|
||||||
// set a more readable browser name
|
// set a more readable browser name
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user