diff --git a/wp-includes/js/underscore.js b/wp-includes/js/underscore.js index 8219dc5085..b29332f945 100644 --- a/wp-includes/js/underscore.js +++ b/wp-includes/js/underscore.js @@ -1,6 +1,6 @@ -// Underscore.js 1.9.1 +// Underscore.js 1.8.3 // http://underscorejs.org -// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. (function() { @@ -8,32 +8,29 @@ // Baseline setup // -------------- - // Establish the root object, `window` (`self`) in the browser, `global` - // on the server, or `this` in some virtual machines. We use `self` - // instead of `window` for `WebWorker` support. - var root = typeof self == 'object' && self.self === self && self || - typeof global == 'object' && global.global === global && global || - this || - {}; + // Establish the root object, `window` in the browser, or `exports` on the server. + var root = this; // Save the previous value of the `_` variable. var previousUnderscore = root._; // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype; - var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; // Create quick reference variables for speed access to core prototypes. - var push = ArrayProto.push, - slice = ArrayProto.slice, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; + var + push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; // All **ECMAScript 5** native function implementations that we hope to use // are declared here. - var nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeCreate = Object.create; + var + nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind, + nativeCreate = Object.create; // Naked function reference for surrogate-prototype-swapping. var Ctor = function(){}; @@ -46,12 +43,10 @@ }; // Export the Underscore object for **Node.js**, with - // backwards-compatibility for their old module API. If we're in + // backwards-compatibility for the old `require()` API. If we're in // the browser, add `_` as a global object. - // (`nodeType` is checked to ensure that `module` - // and `exports` are not HTML elements.) - if (typeof exports != 'undefined' && !exports.nodeType) { - if (typeof module != 'undefined' && !module.nodeType && module.exports) { + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { exports = module.exports = _; } exports._ = _; @@ -60,7 +55,7 @@ } // Current version. - _.VERSION = '1.9.1'; + _.VERSION = '1.8.3'; // Internal function that returns an efficient (for current engines) version // of the passed-in callback, to be repeatedly applied in other Underscore @@ -71,7 +66,9 @@ case 1: return function(value) { return func.call(context, value); }; - // The 2-argument case is omitted because we’re not using it. + case 2: return function(value, other) { + return func.call(context, value, other); + }; case 3: return function(value, index, collection) { return func.call(context, value, index, collection); }; @@ -84,51 +81,34 @@ }; }; - var builtinIteratee; - - // An internal function to generate callbacks that can be applied to each - // element in a collection, returning the desired result — either `identity`, - // an arbitrary callback, a property matcher, or a property accessor. + // A mostly-internal function to generate callbacks that can be applied + // to each element in a collection, returning the desired result — either + // identity, an arbitrary callback, a property matcher, or a property accessor. var cb = function(value, context, argCount) { - if (_.iteratee !== builtinIteratee) return _.iteratee(value, context); if (value == null) return _.identity; if (_.isFunction(value)) return optimizeCb(value, context, argCount); - if (_.isObject(value) && !_.isArray(value)) return _.matcher(value); + if (_.isObject(value)) return _.matcher(value); return _.property(value); }; - - // External wrapper for our callback generator. Users may customize - // `_.iteratee` if they want additional predicate/iteratee shorthand styles. - // This abstraction hides the internal-only argCount argument. - _.iteratee = builtinIteratee = function(value, context) { + _.iteratee = function(value, context) { return cb(value, context, Infinity); }; - // Some functions take a variable number of arguments, or a few expected - // arguments at the beginning and then a variable number of values to operate - // on. This helper accumulates all remaining arguments past the function’s - // argument length (or an explicit `startIndex`), into an array that becomes - // the last argument. Similar to ES6’s "rest parameter". - var restArguments = function(func, startIndex) { - startIndex = startIndex == null ? func.length - 1 : +startIndex; - return function() { - var length = Math.max(arguments.length - startIndex, 0), - rest = Array(length), - index = 0; - for (; index < length; index++) { - rest[index] = arguments[index + startIndex]; + // An internal function for creating assigner functions. + var createAssigner = function(keysFunc, undefinedOnly) { + return function(obj) { + var length = arguments.length; + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; + } } - switch (startIndex) { - case 0: return func.call(this, rest); - case 1: return func.call(this, arguments[0], rest); - case 2: return func.call(this, arguments[0], arguments[1], rest); - } - var args = Array(startIndex + 1); - for (index = 0; index < startIndex; index++) { - args[index] = arguments[index]; - } - args[startIndex] = rest; - return func.apply(this, args); + return obj; }; }; @@ -142,31 +122,18 @@ return result; }; - var shallowProperty = function(key) { + var property = function(key) { return function(obj) { return obj == null ? void 0 : obj[key]; }; }; - var has = function(obj, path) { - return obj != null && hasOwnProperty.call(obj, path); - } - - var deepGet = function(obj, path) { - var length = path.length; - for (var i = 0; i < length; i++) { - if (obj == null) return void 0; - obj = obj[path[i]]; - } - return length ? obj : void 0; - }; - // Helper for collection methods to determine whether a collection - // should be iterated as an array or as an object. + // should be iterated as an array or as an object // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = shallowProperty('length'); + var getLength = property('length'); var isArrayLike = function(collection) { var length = getLength(collection); return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; @@ -208,29 +175,30 @@ }; // Create a reducing function iterating left or right. - var createReduce = function(dir) { - // Wrap code that reassigns argument variables in a separate function than - // the one that accesses `arguments.length` to avoid a perf hit. (#1991) - var reducer = function(obj, iteratee, memo, initial) { - var keys = !isArrayLike(obj) && _.keys(obj), - length = (keys || obj).length, - index = dir > 0 ? 0 : length - 1; - if (!initial) { - memo = obj[keys ? keys[index] : index]; - index += dir; - } + function createReduce(dir) { + // Optimized iterator function as using arguments.length + // in the main function will deoptimize the, see #1991. + function iterator(obj, iteratee, memo, keys, index, length) { for (; index >= 0 && index < length; index += dir) { var currentKey = keys ? keys[index] : index; memo = iteratee(memo, obj[currentKey], currentKey, obj); } return memo; - }; + } return function(obj, iteratee, memo, context) { - var initial = arguments.length >= 3; - return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + iteratee = optimizeCb(iteratee, context, 4); + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length, + index = dir > 0 ? 0 : length - 1; + // Determine the initial value if none is provided. + if (arguments.length < 3) { + memo = obj[keys ? keys[index] : index]; + index += dir; + } + return iterator(obj, iteratee, memo, keys, index, length); }; - }; + } // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. @@ -241,8 +209,12 @@ // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { - var keyFinder = isArrayLike(obj) ? _.findIndex : _.findKey; - var key = keyFinder(obj, predicate, context); + var key; + if (isArrayLike(obj)) { + key = _.findIndex(obj, predicate, context); + } else { + key = _.findKey(obj, predicate, context); + } if (key !== void 0 && key !== -1) return obj[key]; }; @@ -297,26 +269,14 @@ }; // Invoke a method (with arguments) on every item in a collection. - _.invoke = restArguments(function(obj, path, args) { - var contextPath, func; - if (_.isFunction(path)) { - func = path; - } else if (_.isArray(path)) { - contextPath = path.slice(0, -1); - path = path[path.length - 1]; - } - return _.map(obj, function(context) { - var method = func; - if (!method) { - if (contextPath && contextPath.length) { - context = deepGet(context, contextPath); - } - if (context == null) return void 0; - method = context[path]; - } - return method == null ? method : method.apply(context, args); + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + var func = isFunc ? method : value[method]; + return func == null ? func : func.apply(value, args); }); - }); + }; // Convenience version of a common use case of `map`: fetching a property. _.pluck = function(obj, key) { @@ -339,20 +299,20 @@ _.max = function(obj, iteratee, context) { var result = -Infinity, lastComputed = -Infinity, value, computed; - if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + if (iteratee == null && obj != null) { obj = isArrayLike(obj) ? obj : _.values(obj); for (var i = 0, length = obj.length; i < length; i++) { value = obj[i]; - if (value != null && value > result) { + if (value > result) { result = value; } } } else { iteratee = cb(iteratee, context); - _.each(obj, function(v, index, list) { - computed = iteratee(v, index, list); + _.each(obj, function(value, index, list) { + computed = iteratee(value, index, list); if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = v; + result = value; lastComputed = computed; } }); @@ -364,20 +324,20 @@ _.min = function(obj, iteratee, context) { var result = Infinity, lastComputed = Infinity, value, computed; - if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + if (iteratee == null && obj != null) { obj = isArrayLike(obj) ? obj : _.values(obj); for (var i = 0, length = obj.length; i < length; i++) { value = obj[i]; - if (value != null && value < result) { + if (value < result) { result = value; } } } else { iteratee = cb(iteratee, context); - _.each(obj, function(v, index, list) { - computed = iteratee(v, index, list); + _.each(obj, function(value, index, list) { + computed = iteratee(value, index, list); if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = v; + result = value; lastComputed = computed; } }); @@ -385,13 +345,21 @@ return result; }; - // Shuffle a collection. + // Shuffle a collection, using the modern version of the + // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). _.shuffle = function(obj) { - return _.sample(obj, Infinity); + var set = isArrayLike(obj) ? obj : _.values(obj); + var length = set.length; + var shuffled = Array(length); + for (var index = 0, rand; index < length; index++) { + rand = _.random(0, index); + if (rand !== index) shuffled[index] = shuffled[rand]; + shuffled[rand] = set[index]; + } + return shuffled; }; - // Sample **n** random values from a collection using the modern version of the - // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // Sample **n** random values from a collection. // If **n** is not specified, returns a single random element. // The internal `guard` argument allows it to work with `map`. _.sample = function(obj, n, guard) { @@ -399,28 +367,17 @@ if (!isArrayLike(obj)) obj = _.values(obj); return obj[_.random(obj.length - 1)]; } - var sample = isArrayLike(obj) ? _.clone(obj) : _.values(obj); - var length = getLength(sample); - n = Math.max(Math.min(n, length), 0); - var last = length - 1; - for (var index = 0; index < n; index++) { - var rand = _.random(index, last); - var temp = sample[index]; - sample[index] = sample[rand]; - sample[rand] = temp; - } - return sample.slice(0, n); + return _.shuffle(obj).slice(0, Math.max(0, n)); }; // Sort the object's values by a criterion produced by an iteratee. _.sortBy = function(obj, iteratee, context) { - var index = 0; iteratee = cb(iteratee, context); - return _.pluck(_.map(obj, function(value, key, list) { + return _.pluck(_.map(obj, function(value, index, list) { return { value: value, - index: index++, - criteria: iteratee(value, key, list) + index: index, + criteria: iteratee(value, index, list) }; }).sort(function(left, right) { var a = left.criteria; @@ -434,9 +391,9 @@ }; // An internal function used for aggregate "group by" operations. - var group = function(behavior, partition) { + var group = function(behavior) { return function(obj, iteratee, context) { - var result = partition ? [[], []] : {}; + var result = {}; iteratee = cb(iteratee, context); _.each(obj, function(value, index) { var key = iteratee(value, index, obj); @@ -449,7 +406,7 @@ // Groups the object's values by a criterion. Pass either a string attribute // to group by, or a function that returns the criterion. _.groupBy = group(function(result, value, key) { - if (has(result, key)) result[key].push(value); else result[key] = [value]; + if (_.has(result, key)) result[key].push(value); else result[key] = [value]; }); // Indexes the object's values by a criterion, similar to `groupBy`, but for @@ -462,18 +419,13 @@ // either a string attribute to count by, or a function that returns the // criterion. _.countBy = group(function(result, value, key) { - if (has(result, key)) result[key]++; else result[key] = 1; + if (_.has(result, key)) result[key]++; else result[key] = 1; }); - var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; // Safely create a real, live array from anything iterable. _.toArray = function(obj) { if (!obj) return []; if (_.isArray(obj)) return slice.call(obj); - if (_.isString(obj)) { - // Keep surrogate pair characters together - return obj.match(reStrSymbol); - } if (isArrayLike(obj)) return _.map(obj, _.identity); return _.values(obj); }; @@ -486,9 +438,14 @@ // Split a collection into two arrays: one whose elements all satisfy the given // predicate, and one whose elements all do not satisfy the predicate. - _.partition = group(function(result, value, pass) { - result[pass ? 0 : 1].push(value); - }, true); + _.partition = function(obj, predicate, context) { + predicate = cb(predicate, context); + var pass = [], fail = []; + _.each(obj, function(value, key, obj) { + (predicate(value, key, obj) ? pass : fail).push(value); + }); + return [pass, fail]; + }; // Array Functions // --------------- @@ -497,7 +454,7 @@ // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { - if (array == null || array.length < 1) return n == null ? void 0 : []; + if (array == null) return void 0; if (n == null || guard) return array[0]; return _.initial(array, array.length - n); }; @@ -512,7 +469,7 @@ // Get the last element of an array. Passing **n** will return the last N // values in the array. _.last = function(array, n, guard) { - if (array == null || array.length < 1) return n == null ? void 0 : []; + if (array == null) return void 0; if (n == null || guard) return array[array.length - 1]; return _.rest(array, Math.max(0, array.length - n)); }; @@ -526,23 +483,21 @@ // Trim out all falsy values from an array. _.compact = function(array) { - return _.filter(array, Boolean); + return _.filter(array, _.identity); }; // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, strict, output) { - output = output || []; - var idx = output.length; - for (var i = 0, length = getLength(input); i < length; i++) { + var flatten = function(input, shallow, strict, startIndex) { + var output = [], idx = 0; + for (var i = startIndex || 0, length = getLength(input); i < length; i++) { var value = input[i]; if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { - // Flatten current level of array or arguments object. - if (shallow) { - var j = 0, len = value.length; - while (j < len) output[idx++] = value[j++]; - } else { - flatten(value, shallow, strict, output); - idx = output.length; + //flatten current level of array or arguments object + if (!shallow) value = flatten(value, shallow, strict); + var j = 0, len = value.length; + output.length += len; + while (j < len) { + output[idx++] = value[j++]; } } else if (!strict) { output[idx++] = value; @@ -557,15 +512,12 @@ }; // Return a version of the array that does not contain the specified value(s). - _.without = restArguments(function(array, otherArrays) { - return _.difference(array, otherArrays); - }); + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; // Produce a duplicate-free version of the array. If the array has already // been sorted, you have the option of using a faster algorithm. - // The faster algorithm will not work with an iteratee if the iteratee - // is not a one-to-one function, so providing an iteratee will disable - // the faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iteratee, context) { if (!_.isBoolean(isSorted)) { @@ -579,7 +531,7 @@ for (var i = 0, length = getLength(array); i < length; i++) { var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted && !iteratee) { + if (isSorted) { if (!i || seen !== computed) result.push(value); seen = computed; } else if (iteratee) { @@ -596,9 +548,9 @@ // Produce an array that contains the union: each distinct element from all of // the passed-in arrays. - _.union = restArguments(function(arrays) { - return _.uniq(flatten(arrays, true, true)); - }); + _.union = function() { + return _.uniq(flatten(arguments, true, true)); + }; // Produce an array that contains every item shared between all the // passed-in arrays. @@ -608,8 +560,7 @@ for (var i = 0, length = getLength(array); i < length; i++) { var item = array[i]; if (_.contains(result, item)) continue; - var j; - for (j = 1; j < argsLength; j++) { + for (var j = 1; j < argsLength; j++) { if (!_.contains(arguments[j], item)) break; } if (j === argsLength) result.push(item); @@ -619,15 +570,21 @@ // Take the difference between one array and a number of other arrays. // Only the elements present in just the first array will remain. - _.difference = restArguments(function(array, rest) { - rest = flatten(rest, true, true); + _.difference = function(array) { + var rest = flatten(arguments, true, true, 1); return _.filter(array, function(value){ return !_.contains(rest, value); }); - }); + }; + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = function() { + return _.unzip(arguments); + }; // Complement of _.zip. Unzip accepts an array of arrays and groups - // each array's elements on shared indices. + // each array's elements on shared indices _.unzip = function(array) { var length = array && _.max(array, getLength).length || 0; var result = Array(length); @@ -638,13 +595,9 @@ return result; }; - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = restArguments(_.unzip); - // Converts lists into objects. Pass either a single array of `[key, value]` // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. Passing by pairs is the reverse of _.pairs. + // the corresponding values. _.object = function(list, values) { var result = {}; for (var i = 0, length = getLength(list); i < length; i++) { @@ -657,8 +610,8 @@ return result; }; - // Generator function to create the findIndex and findLastIndex functions. - var createPredicateIndexFinder = function(dir) { + // Generator function to create the findIndex and findLastIndex functions + function createPredicateIndexFinder(dir) { return function(array, predicate, context) { predicate = cb(predicate, context); var length = getLength(array); @@ -668,9 +621,9 @@ } return -1; }; - }; + } - // Returns the first index on an array-like that passes a predicate test. + // Returns the first index on an array-like that passes a predicate test _.findIndex = createPredicateIndexFinder(1); _.findLastIndex = createPredicateIndexFinder(-1); @@ -687,15 +640,15 @@ return low; }; - // Generator function to create the indexOf and lastIndexOf functions. - var createIndexFinder = function(dir, predicateFind, sortedIndex) { + // Generator function to create the indexOf and lastIndexOf functions + function createIndexFinder(dir, predicateFind, sortedIndex) { return function(array, item, idx) { var i = 0, length = getLength(array); if (typeof idx == 'number') { if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); + i = idx >= 0 ? idx : Math.max(idx + length, i); } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; } } else if (sortedIndex && idx && length) { idx = sortedIndex(array, item); @@ -710,7 +663,7 @@ } return -1; }; - }; + } // Return the position of the first occurrence of an item in an array, // or -1 if the item is not included in the array. @@ -727,9 +680,7 @@ stop = start || 0; start = 0; } - if (!step) { - step = stop < start ? -1 : 1; - } + step = step || 1; var length = Math.max(Math.ceil((stop - start) / step), 0); var range = Array(length); @@ -741,23 +692,11 @@ return range; }; - // Chunk a single array into multiple arrays, each containing `count` or fewer - // items. - _.chunk = function(array, count) { - if (count == null || count < 1) return []; - var result = []; - var i = 0, length = array.length; - while (i < length) { - result.push(slice.call(array, i, i += count)); - } - return result; - }; - // Function (ahem) Functions // ------------------ // Determines whether to execute a function as a constructor - // or a normal function with the provided arguments. + // or a normal function with the provided arguments var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); var self = baseCreate(sourceFunc.prototype); @@ -769,53 +708,52 @@ // Create a function bound to a given object (assigning `this`, and arguments, // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if // available. - _.bind = restArguments(function(func, context, args) { + _.bind = function(func, context) { + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); - var bound = restArguments(function(callArgs) { - return executeBound(func, bound, context, this, args.concat(callArgs)); - }); + var args = slice.call(arguments, 2); + var bound = function() { + return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); + }; return bound; - }); + }; // Partially apply a function by creating a version that has had some of its // arguments pre-filled, without changing its dynamic `this` context. _ acts - // as a placeholder by default, allowing any combination of arguments to be - // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. - _.partial = restArguments(function(func, boundArgs) { - var placeholder = _.partial.placeholder; + // as a placeholder, allowing any combination of arguments to be pre-filled. + _.partial = function(func) { + var boundArgs = slice.call(arguments, 1); var bound = function() { var position = 0, length = boundArgs.length; var args = Array(length); for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; } while (position < arguments.length) args.push(arguments[position++]); return executeBound(func, bound, this, this, args); }; return bound; - }); - - _.partial.placeholder = _; + }; // Bind a number of an object's methods to that object. Remaining arguments // are the method names to be bound. Useful for ensuring that all callbacks // defined on an object belong to it. - _.bindAll = restArguments(function(obj, keys) { - keys = flatten(keys, false, false); - var index = keys.length; - if (index < 1) throw new Error('bindAll must be passed function names'); - while (index--) { - var key = keys[index]; + _.bindAll = function(obj) { + var i, length = arguments.length, key; + if (length <= 1) throw new Error('bindAll must be passed function names'); + for (i = 1; i < length; i++) { + key = arguments[i]; obj[key] = _.bind(obj[key], obj); } - }); + return obj; + }; // Memoize an expensive function by storing its results. _.memoize = function(func, hasher) { var memoize = function(key) { var cache = memoize.cache; var address = '' + (hasher ? hasher.apply(this, arguments) : key); - if (!has(cache, address)) cache[address] = func.apply(this, arguments); + if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); return cache[address]; }; memoize.cache = {}; @@ -824,11 +762,12 @@ // Delays a function for the given number of milliseconds, and then calls // it with the arguments supplied. - _.delay = restArguments(function(func, wait, args) { - return setTimeout(function() { + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function(){ return func.apply(null, args); }, wait); - }); + }; // Defers a function, scheduling it to run after the current call stack has // cleared. @@ -840,18 +779,17 @@ // but if you'd like to disable the execution on the leading edge, pass // `{leading: false}`. To disable execution on the trailing edge, ditto. _.throttle = function(func, wait, options) { - var timeout, context, args, result; + var context, args, result; + var timeout = null; var previous = 0; if (!options) options = {}; - var later = function() { previous = options.leading === false ? 0 : _.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; - - var throttled = function() { + return function() { var now = _.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); @@ -870,14 +808,6 @@ } return result; }; - - throttled.cancel = function() { - clearTimeout(timeout); - previous = 0; - timeout = context = args = null; - }; - - return throttled; }; // Returns a function, that, as long as it continues to be invoked, will not @@ -885,32 +815,35 @@ // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. _.debounce = function(func, wait, immediate) { - var timeout, result; + var timeout, args, context, timestamp, result; - var later = function(context, args) { - timeout = null; - if (args) result = func.apply(context, args); + var later = function() { + var last = _.now() - timestamp; + + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + if (!timeout) context = args = null; + } + } }; - var debounced = restArguments(function(args) { - if (timeout) clearTimeout(timeout); - if (immediate) { - var callNow = !timeout; - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(this, args); - } else { - timeout = _.delay(later, wait, this, args); + return function() { + context = this; + args = arguments; + timestamp = _.now(); + var callNow = immediate && !timeout; + if (!timeout) timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + context = args = null; } return result; - }); - - debounced.cancel = function() { - clearTimeout(timeout); - timeout = null; }; - - return debounced; }; // Returns the first function passed as an argument to the second, @@ -965,24 +898,22 @@ // often you call it. Useful for lazy initialization. _.once = _.partial(_.before, 2); - _.restArguments = restArguments; - // Object Functions // ---------------- // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - var collectNonEnumProps = function(obj, keys) { + function collectNonEnumProps(obj, keys) { var nonEnumIdx = nonEnumerableProps.length; var constructor = obj.constructor; - var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; + var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; // Constructor is a special case. var prop = 'constructor'; - if (has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); + if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); while (nonEnumIdx--) { prop = nonEnumerableProps[nonEnumIdx]; @@ -990,15 +921,15 @@ keys.push(prop); } } - }; + } // Retrieve the names of an object's own properties. - // Delegates to **ECMAScript 5**'s native `Object.keys`. + // Delegates to **ECMAScript 5**'s native `Object.keys` _.keys = function(obj) { if (!_.isObject(obj)) return []; if (nativeKeys) return nativeKeys(obj); var keys = []; - for (var key in obj) if (has(obj, key)) keys.push(key); + for (var key in obj) if (_.has(obj, key)) keys.push(key); // Ahem, IE < 9. if (hasEnumBug) collectNonEnumProps(obj, keys); return keys; @@ -1025,22 +956,22 @@ return values; }; - // Returns the results of applying the iteratee to each element of the object. - // In contrast to _.map it returns an object. + // Returns the results of applying the iteratee to each element of the object + // In contrast to _.map it returns an object _.mapObject = function(obj, iteratee, context) { iteratee = cb(iteratee, context); - var keys = _.keys(obj), - length = keys.length, - results = {}; - for (var index = 0; index < length; index++) { - var currentKey = keys[index]; - results[currentKey] = iteratee(obj[currentKey], currentKey, obj); - } - return results; + var keys = _.keys(obj), + length = keys.length, + results = {}, + currentKey; + for (var index = 0; index < length; index++) { + currentKey = keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; }; // Convert an object into a list of `[key, value]` pairs. - // The opposite of _.object. _.pairs = function(obj) { var keys = _.keys(obj); var length = keys.length; @@ -1062,7 +993,7 @@ }; // Return a sorted list of the function names available on the object. - // Aliased as `methods`. + // Aliased as `methods` _.functions = _.methods = function(obj) { var names = []; for (var key in obj) { @@ -1071,33 +1002,14 @@ return names.sort(); }; - // An internal function for creating assigner functions. - var createAssigner = function(keysFunc, defaults) { - return function(obj) { - var length = arguments.length; - if (defaults) obj = Object(obj); - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], - keys = keysFunc(source), - l = keys.length; - for (var i = 0; i < l; i++) { - var key = keys[i]; - if (!defaults || obj[key] === void 0) obj[key] = source[key]; - } - } - return obj; - }; - }; - // Extend a given object with all the properties in passed-in object(s). _.extend = createAssigner(_.allKeys); - // Assigns a given object with all the own properties in the passed-in object(s). + // Assigns a given object with all the own properties in the passed-in object(s) // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) _.extendOwn = _.assign = createAssigner(_.keys); - // Returns the first key on an object that passes a predicate test. + // Returns the first key on an object that passes a predicate test _.findKey = function(obj, predicate, context) { predicate = cb(predicate, context); var keys = _.keys(obj), key; @@ -1107,21 +1019,16 @@ } }; - // Internal pick helper function to determine if `obj` has key `key`. - var keyInObj = function(value, key, obj) { - return key in obj; - }; - // Return a copy of the object only containing the whitelisted properties. - _.pick = restArguments(function(obj, keys) { - var result = {}, iteratee = keys[0]; + _.pick = function(object, oiteratee, context) { + var result = {}, obj = object, iteratee, keys; if (obj == null) return result; - if (_.isFunction(iteratee)) { - if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + if (_.isFunction(oiteratee)) { keys = _.allKeys(obj); + iteratee = optimizeCb(oiteratee, context); } else { - iteratee = keyInObj; - keys = flatten(keys, false, false); + keys = flatten(arguments, false, false, 1); + iteratee = function(value, key, obj) { return key in obj; }; obj = Object(obj); } for (var i = 0, length = keys.length; i < length; i++) { @@ -1130,22 +1037,20 @@ if (iteratee(value, key, obj)) result[key] = value; } return result; - }); + }; - // Return a copy of the object without the blacklisted properties. - _.omit = restArguments(function(obj, keys) { - var iteratee = keys[0], context; + // Return a copy of the object without the blacklisted properties. + _.omit = function(obj, iteratee, context) { if (_.isFunction(iteratee)) { iteratee = _.negate(iteratee); - if (keys.length > 1) context = keys[1]; } else { - keys = _.map(flatten(keys, false, false), String); + var keys = _.map(flatten(arguments, false, false, 1), String); iteratee = function(value, key) { return !_.contains(keys, key); }; } return _.pick(obj, iteratee, context); - }); + }; // Fill in a given object with default properties. _.defaults = createAssigner(_.allKeys, true); @@ -1187,23 +1092,12 @@ // Internal recursive comparison function for `isEqual`. - var eq, deepEq; - eq = function(a, b, aStack, bStack) { + var eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). if (a === b) return a !== 0 || 1 / a === 1 / b; - // `null` or `undefined` only equal to itself (strict comparison). - if (a == null || b == null) return false; - // `NaN`s are equivalent, but non-reflexive. - if (a !== a) return b !== b; - // Exhaust primitive checks - var type = typeof a; - if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; - return deepEq(a, b, aStack, bStack); - }; - - // Internal recursive comparison function for `isEqual`. - deepEq = function(a, b, aStack, bStack) { + // A strict comparison is necessary because `null == undefined`. + if (a == null || b == null) return a === b; // Unwrap any wrapped objects. if (a instanceof _) a = a._wrapped; if (b instanceof _) b = b._wrapped; @@ -1220,7 +1114,7 @@ return '' + a === '' + b; case '[object Number]': // `NaN`s are equivalent, but non-reflexive. - // Object(NaN) is equivalent to NaN. + // Object(NaN) is equivalent to NaN if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values. return +a === 0 ? 1 / +a === 1 / b : +a === +b; @@ -1230,8 +1124,6 @@ // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a === +b; - case '[object Symbol]': - return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); } var areArrays = className === '[object Array]'; @@ -1283,7 +1175,7 @@ while (length--) { // Deep compare each member key = keys[length]; - if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; } } // Remove the first object from the stack of traversed objects. @@ -1322,8 +1214,8 @@ return type === 'function' || type === 'object' && !!obj; }; - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet. - _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'], function(name) { + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. + _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) === '[object ' + name + ']'; }; @@ -1333,14 +1225,13 @@ // there isn't any inspectable "Arguments" type. if (!_.isArguments(arguments)) { _.isArguments = function(obj) { - return has(obj, 'callee'); + return _.has(obj, 'callee'); }; } // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, - // IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). - var nodelist = root.document && root.document.childNodes; - if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + // IE 11 (#1621), and in Safari 8 (#1929). + if (typeof /./ != 'function' && typeof Int8Array != 'object') { _.isFunction = function(obj) { return typeof obj == 'function' || false; }; @@ -1348,12 +1239,12 @@ // Is a given object a finite number? _.isFinite = function(obj) { - return !_.isSymbol(obj) && isFinite(obj) && !isNaN(parseFloat(obj)); + return isFinite(obj) && !isNaN(parseFloat(obj)); }; - // Is the given value `NaN`? + // Is the given value `NaN`? (NaN is the only number which does not equal itself). _.isNaN = function(obj) { - return _.isNumber(obj) && isNaN(obj); + return _.isNumber(obj) && obj !== +obj; }; // Is a given value a boolean? @@ -1373,19 +1264,8 @@ // Shortcut function for checking if an object has a given property directly // on itself (in other words, not on a prototype). - _.has = function(obj, path) { - if (!_.isArray(path)) { - return has(obj, path); - } - var length = path.length; - for (var i = 0; i < length; i++) { - var key = path[i]; - if (obj == null || !hasOwnProperty.call(obj, key)) { - return false; - } - obj = obj[key]; - } - return !!length; + _.has = function(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); }; // Utility Functions @@ -1412,24 +1292,12 @@ _.noop = function(){}; - // Creates a function that, when passed an object, will traverse that object’s - // properties down the given `path`, specified as an array of keys or indexes. - _.property = function(path) { - if (!_.isArray(path)) { - return shallowProperty(path); - } - return function(obj) { - return deepGet(obj, path); - }; - }; + _.property = property; // Generates a function for a given object that returns a given property. _.propertyOf = function(obj) { - if (obj == null) { - return function(){}; - } - return function(path) { - return !_.isArray(path) ? obj[path] : deepGet(obj, path); + return obj == null ? function(){} : function(key) { + return obj[key]; }; }; @@ -1464,7 +1332,7 @@ return new Date().getTime(); }; - // List of HTML entities for escaping. + // List of HTML entities for escaping. var escapeMap = { '&': '&', '<': '<', @@ -1480,7 +1348,7 @@ var escaper = function(match) { return map[match]; }; - // Regexes for identifying a key that needs to be escaped. + // Regexes for identifying a key that needs to be escaped var source = '(?:' + _.keys(map).join('|') + ')'; var testRegexp = RegExp(source); var replaceRegexp = RegExp(source, 'g'); @@ -1492,24 +1360,14 @@ _.escape = createEscaper(escapeMap); _.unescape = createEscaper(unescapeMap); - // Traverses the children of `obj` along `path`. If a child is a function, it - // is invoked with its parent as context. Returns the value of the final - // child, or `fallback` if any child is undefined. - _.result = function(obj, path, fallback) { - if (!_.isArray(path)) path = [path]; - var length = path.length; - if (!length) { - return _.isFunction(fallback) ? fallback.call(obj) : fallback; + // If the value of the named `property` is a function then invoke it with the + // `object` as context; otherwise, return it. + _.result = function(object, property, fallback) { + var value = object == null ? void 0 : object[property]; + if (value === void 0) { + value = fallback; } - for (var i = 0; i < length; i++) { - var prop = obj == null ? void 0 : obj[path[i]]; - if (prop === void 0) { - prop = fallback; - i = length; // Ensure we don't continue iterating. - } - obj = _.isFunction(prop) ? prop.call(obj) : prop; - } - return obj; + return _.isFunction(value) ? value.call(object) : value; }; // Generate a unique integer id (unique within the entire client session). @@ -1523,9 +1381,9 @@ // By default, Underscore uses ERB-style template delimiters, change the // following template settings to use alternative delimiters. _.templateSettings = { - evaluate: /<%([\s\S]+?)%>/g, - interpolate: /<%=([\s\S]+?)%>/g, - escape: /<%-([\s\S]+?)%>/g + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g }; // When customizing `templateSettings`, if you don't want to define an @@ -1536,15 +1394,15 @@ // Certain characters need to be escaped so that they can be put into a // string literal. var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', '\u2028': 'u2028', '\u2029': 'u2029' }; - var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + var escaper = /\\|'|\r|\n|\u2028|\u2029/g; var escapeChar = function(match) { return '\\' + escapes[match]; @@ -1569,7 +1427,7 @@ var index = 0; var source = "__p+='"; text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + source += text.slice(index, offset).replace(escaper, escapeChar); index = offset + match.length; if (escape) { @@ -1580,7 +1438,7 @@ source += "';\n" + evaluate + "\n__p+='"; } - // Adobe VMs need the match returned to produce the correct offset. + // Adobe VMs need the match returned to produce the correct offest. return match; }); source += "';\n"; @@ -1592,9 +1450,8 @@ "print=function(){__p+=__j.call(arguments,'');};\n" + source + 'return __p;\n'; - var render; try { - render = new Function(settings.variable || 'obj', '_', source); + var render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; @@ -1625,7 +1482,7 @@ // underscore functions. Wrapped objects may be chained. // Helper function to continue chaining intermediate results. - var chainResult = function(instance, obj) { + var result = function(instance, obj) { return instance._chain ? _(obj).chain() : obj; }; @@ -1636,10 +1493,9 @@ _.prototype[name] = function() { var args = [this._wrapped]; push.apply(args, arguments); - return chainResult(this, func.apply(_, args)); + return result(this, func.apply(_, args)); }; }); - return _; }; // Add all of the Underscore functions to the wrapper object. @@ -1652,7 +1508,7 @@ var obj = this._wrapped; method.apply(obj, arguments); if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; - return chainResult(this, obj); + return result(this, obj); }; }); @@ -1660,7 +1516,7 @@ _.each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { - return chainResult(this, method.apply(this._wrapped, arguments)); + return result(this, method.apply(this._wrapped, arguments)); }; }); @@ -1674,7 +1530,7 @@ _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; _.prototype.toString = function() { - return String(this._wrapped); + return '' + this._wrapped; }; // AMD registration happens at the end for compatibility with AMD loaders @@ -1684,9 +1540,9 @@ // popular enough to be bundled in a third party lib, but not be part of // an AMD load request. Those cases could generate an error when an // anonymous define() is called outside of a loader request. - if (typeof define == 'function' && define.amd) { + if (typeof define === 'function' && define.amd) { define('underscore', [], function() { return _; }); } -}()); +}.call(this)); diff --git a/wp-includes/js/underscore.min.js b/wp-includes/js/underscore.min.js index 2476bea87c..e2b52042eb 100644 --- a/wp-includes/js/underscore.min.js +++ b/wp-includes/js/underscore.min.js @@ -1 +1 @@ -!function(){var a="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this||{},b=a._,c=Array.prototype,d=Object.prototype,e="undefined"!=typeof Symbol?Symbol.prototype:null,f=c.push,g=c.slice,h=d.toString,i=d.hasOwnProperty,j=Array.isArray,k=Object.keys,l=Object.create,m=function(){},n=function(a){return a instanceof n?a:this instanceof n?void(this._wrapped=a):new n(a)};"undefined"==typeof exports||exports.nodeType?a._=n:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=n),exports._=n),n.VERSION="1.9.1";var o,p=function(a,b,c){if(void 0===b)return a;switch(null==c?3:c){case 1:return function(c){return a.call(b,c)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return function(){return a.apply(b,arguments)}},q=function(a,b,c){return n.iteratee!==o?n.iteratee(a,b):null==a?n.identity:n.isFunction(a)?p(a,b,c):n.isObject(a)&&!n.isArray(a)?n.matcher(a):n.property(a)};n.iteratee=o=function(a,b){return q(a,b,1/0)};var r=function(a,b){return b=null==b?a.length-1:+b,function(){for(var c=Math.max(arguments.length-b,0),d=Array(c),e=0;e=0&&b<=w};n.each=n.forEach=function(a,b,c){b=p(b,c);var d,e;if(y(a))for(d=0,e=a.length;d0?0:g-1;for(e||(d=b[f?f[h]:h],h+=a);h>=0&&h=3;return b(a,p(c,e,4),d,f)}};n.reduce=n.foldl=n.inject=z(1),n.reduceRight=n.foldr=z(-1),n.find=n.detect=function(a,b,c){var d=y(a)?n.findIndex:n.findKey,e=d(a,b,c);if(void 0!==e&&e!==-1)return a[e]},n.filter=n.select=function(a,b,c){var d=[];return b=q(b,c),n.each(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d},n.reject=function(a,b,c){return n.filter(a,n.negate(q(b)),c)},n.every=n.all=function(a,b,c){b=q(b,c);for(var d=!y(a)&&n.keys(a),e=(d||a).length,f=0;f=0},n.invoke=r(function(a,b,c){var d,e;return n.isFunction(b)?e=b:n.isArray(b)&&(d=b.slice(0,-1),b=b[b.length-1]),n.map(a,function(a){var f=e;if(!f){if(d&&d.length&&(a=v(a,d)),null==a)return;f=a[b]}return null==f?f:f.apply(a,c)})}),n.pluck=function(a,b){return n.map(a,n.property(b))},n.where=function(a,b){return n.filter(a,n.matcher(b))},n.findWhere=function(a,b){return n.find(a,n.matcher(b))},n.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b||"number"==typeof b&&"object"!=typeof a[0]&&null!=a){a=y(a)?a:n.values(a);for(var h=0,i=a.length;hf&&(f=d)}else b=q(b,c),n.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},n.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b||"number"==typeof b&&"object"!=typeof a[0]&&null!=a){a=y(a)?a:n.values(a);for(var h=0,i=a.length;hd||void 0===c)return 1;if(c0?0:e-1;f>=0&&f0?h=f>=0?f:Math.max(f+i,h):i=f>=0?Math.min(f+1,i):f+i+1;else if(c&&f&&i)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(g.call(d,h,i),n.isNaN),f>=0?f+h:-1;for(f=a>0?h:i-1;f>=0&&fb?(d&&(clearTimeout(d),d=null),h=j,g=a.apply(e,f),d||(e=f=null)):d||c.trailing===!1||(d=setTimeout(i,k)),g};return j.cancel=function(){clearTimeout(d),h=0,d=e=f=null},j},n.debounce=function(a,b,c){var d,e,f=function(b,c){d=null,c&&(e=a.apply(b,c))},g=r(function(g){if(d&&clearTimeout(d),c){var h=!d;d=setTimeout(f,b),h&&(e=a.apply(this,g))}else d=n.delay(f,b,this,g);return e});return g.cancel=function(){clearTimeout(d),d=null},g},n.wrap=function(a,b){return n.partial(b,a)},n.negate=function(a){return function(){return!a.apply(this,arguments)}},n.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},n.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},n.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},n.once=n.partial(n.before,2),n.restArguments=r;var G=!{toString:null}.propertyIsEnumerable("toString"),H=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],I=function(a,b){var c=H.length,e=a.constructor,f=n.isFunction(e)&&e.prototype||d,g="constructor";for(u(a,g)&&!n.contains(b,g)&&b.push(g);c--;)g=H[c],g in a&&a[g]!==f[g]&&!n.contains(b,g)&&b.push(g)};n.keys=function(a){if(!n.isObject(a))return[];if(k)return k(a);var b=[];for(var c in a)u(a,c)&&b.push(c);return G&&I(a,b),b},n.allKeys=function(a){if(!n.isObject(a))return[];var b=[];for(var c in a)b.push(c);return G&&I(a,b),b},n.values=function(a){for(var b=n.keys(a),c=b.length,d=Array(c),e=0;e1&&(d=p(d,b[1])),b=n.allKeys(a)):(d=K,b=C(b,!1,!1),a=Object(a));for(var e=0,f=b.length;e1&&(c=b[1])):(b=n.map(C(b,!1,!1),String),d=function(a,c){return!n.contains(b,c)}),n.pick(a,d,c)}),n.defaults=J(n.allKeys,!0),n.create=function(a,b){var c=s(a);return b&&n.extendOwn(c,b),c},n.clone=function(a){return n.isObject(a)?n.isArray(a)?a.slice():n.extend({},a):a},n.tap=function(a,b){return b(a),a},n.isMatch=function(a,b){var c=n.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;f":">",'"':""","'":"'","`":"`"},P=n.invert(O),Q=function(a){var b=function(b){return a[b]},c="(?:"+n.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};n.escape=Q(O),n.unescape=Q(P),n.result=function(a,b,c){n.isArray(b)||(b=[b]);var d=b.length;if(!d)return n.isFunction(c)?c.call(a):c;for(var e=0;e/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var S=/(.)^/,T={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},U=/\\|'|\r|\n|\u2028|\u2029/g,V=function(a){return"\\"+T[a]};n.template=function(a,b,c){!b&&c&&(b=c),b=n.defaults({},b,n.templateSettings);var d=RegExp([(b.escape||S).source,(b.interpolate||S).source,(b.evaluate||S).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(U,V),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";var g;try{g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,n)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},n.chain=function(a){var b=n(a);return b._chain=!0,b};var W=function(a,b){return a._chain?n(b).chain():b};n.mixin=function(a){return n.each(n.functions(a),function(b){var c=n[b]=a[b];n.prototype[b]=function(){var a=[this._wrapped];return f.apply(a,arguments),W(this,c.apply(n,a))}}),n},n.mixin(n),n.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=c[a];n.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],W(this,c)}}),n.each(["concat","join","slice"],function(a){var b=c[a];n.prototype[a]=function(){return W(this,b.apply(this._wrapped,arguments))}}),n.prototype.value=function(){return this._wrapped},n.prototype.valueOf=n.prototype.toJSON=n.prototype.value,n.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return n})}(); \ No newline at end of file +(function(){function a(a){function b(b,c,d,e,f,g){for(;f>=0&&f0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function b(a){return function(b,c,d){c=u(c,d);for(var e=z(b),f=a>0?0:e-1;f>=0&&f0?g=f>=0?f:Math.max(f+h,g):h=f>=0?Math.min(f+1,h):f+h+1;else if(c&&f&&h)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(k.call(d,g,h),s.isNaN),f>=0?f+g:-1;for(f=a>0?g:h-1;f>=0&&f=0&&b<=y};s.each=s.forEach=function(a,b,c){b=t(b,c);var d,e;if(A(a))for(d=0,e=a.length;d=0},s.invoke=function(a,b){var c=k.call(arguments,2),d=s.isFunction(b);return s.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},s.pluck=function(a,b){return s.map(a,s.property(b))},s.where=function(a,b){return s.filter(a,s.matcher(b))},s.findWhere=function(a,b){return s.find(a,s.matcher(b))},s.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=A(a)?a:s.values(a);for(var h=0,i=a.length;hf&&(f=d)}else b=u(b,c),s.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},s.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=A(a)?a:s.values(a);for(var h=0,i=a.length;hd||void 0===c)return 1;if(cb?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},s.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=s.now()-g;j=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=s.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},s.wrap=function(a,b){return s.partial(b,a)},s.negate=function(a){return function(){return!a.apply(this,arguments)}},s.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},s.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},s.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},s.once=s.partial(s.before,2);var E=!{toString:null}.propertyIsEnumerable("toString"),F=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];s.keys=function(a){if(!s.isObject(a))return[];if(o)return o(a);var b=[];for(var c in a)s.has(a,c)&&b.push(c);return E&&d(a,b),b},s.allKeys=function(a){if(!s.isObject(a))return[];var b=[];for(var c in a)b.push(c);return E&&d(a,b),b},s.values=function(a){for(var b=s.keys(a),c=b.length,d=Array(c),e=0;e":">",'"':""","'":"'","`":"`"},I=s.invert(H),J=function(a){var b=function(b){return a[b]},c="(?:"+s.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};s.escape=J(H),s.unescape=J(I),s.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),s.isFunction(d)?d.call(a):d};var K=0;s.uniqueId=function(a){var b=++K+"";return a?a+b:b},s.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var L=/(.)^/,M={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},N=/\\|'|\r|\n|\u2028|\u2029/g,O=function(a){return"\\"+M[a]};s.template=function(a,b,c){!b&&c&&(b=c),b=s.defaults({},b,s.templateSettings);var d=RegExp([(b.escape||L).source,(b.interpolate||L).source,(b.evaluate||L).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(N,O),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,s)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},s.chain=function(a){var b=s(a);return b._chain=!0,b};var P=function(a,b){return a._chain?s(b).chain():b};s.mixin=function(a){s.each(s.functions(a),function(b){var c=s[b]=a[b];s.prototype[b]=function(){var a=[this._wrapped];return j.apply(a,arguments),P(this,c.apply(s,a))}})},s.mixin(s),s.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=g[a];s.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],P(this,c)}}),s.each(["concat","join","slice"],function(a){var b=g[a];s.prototype[a]=function(){return P(this,b.apply(this._wrapped,arguments))}}),s.prototype.value=function(){return this._wrapped},s.prototype.valueOf=s.prototype.toJSON=s.prototype.value,s.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return s})}).call(this); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index eabc0eb539..4153980a25 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46092'; +$wp_version = '5.3-alpha-46093'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.