mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 18:31:22 +00:00
43835 lines
3.4 MiB
43835 lines
3.4 MiB
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
// shim for using process in browser
|
|
|
|
var process = module.exports = {};
|
|
|
|
process.nextTick = (function () {
|
|
var canSetImmediate = typeof window !== 'undefined'
|
|
&& window.setImmediate;
|
|
var canMutationObserver = typeof window !== 'undefined'
|
|
&& window.MutationObserver;
|
|
var canPost = typeof window !== 'undefined'
|
|
&& window.postMessage && window.addEventListener
|
|
;
|
|
|
|
if (canSetImmediate) {
|
|
return function (f) { return window.setImmediate(f) };
|
|
}
|
|
|
|
var queue = [];
|
|
|
|
if (canMutationObserver) {
|
|
var hiddenDiv = document.createElement("div");
|
|
var observer = new MutationObserver(function () {
|
|
var queueList = queue.slice();
|
|
queue.length = 0;
|
|
queueList.forEach(function (fn) {
|
|
fn();
|
|
});
|
|
});
|
|
|
|
observer.observe(hiddenDiv, { attributes: true });
|
|
|
|
return function nextTick(fn) {
|
|
if (!queue.length) {
|
|
hiddenDiv.setAttribute('yes', 'no');
|
|
}
|
|
queue.push(fn);
|
|
};
|
|
}
|
|
|
|
if (canPost) {
|
|
window.addEventListener('message', function (ev) {
|
|
var source = ev.source;
|
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
ev.stopPropagation();
|
|
if (queue.length > 0) {
|
|
var fn = queue.shift();
|
|
fn();
|
|
}
|
|
}
|
|
}, true);
|
|
|
|
return function nextTick(fn) {
|
|
queue.push(fn);
|
|
window.postMessage('process-tick', '*');
|
|
};
|
|
}
|
|
|
|
return function nextTick(fn) {
|
|
setTimeout(fn, 0);
|
|
};
|
|
})();
|
|
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
|
|
function noop() {}
|
|
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
};
|
|
|
|
// TODO(shtylman)
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
|
|
},{}],2:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule Dispatcher
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require('./invariant');
|
|
|
|
var _lastID = 1;
|
|
var _prefix = 'ID_';
|
|
|
|
/**
|
|
* Dispatcher is used to broadcast payloads to registered callbacks. This is
|
|
* different from generic pub-sub systems in two ways:
|
|
*
|
|
* 1) Callbacks are not subscribed to particular events. Every payload is
|
|
* dispatched to every registered callback.
|
|
* 2) Callbacks can be deferred in whole or part until other callbacks have
|
|
* been executed.
|
|
*
|
|
* For example, consider this hypothetical flight destination form, which
|
|
* selects a default city when a country is selected:
|
|
*
|
|
* var flightDispatcher = new Dispatcher();
|
|
*
|
|
* // Keeps track of which country is selected
|
|
* var CountryStore = {country: null};
|
|
*
|
|
* // Keeps track of which city is selected
|
|
* var CityStore = {city: null};
|
|
*
|
|
* // Keeps track of the base flight price of the selected city
|
|
* var FlightPriceStore = {price: null}
|
|
*
|
|
* When a user changes the selected city, we dispatch the payload:
|
|
*
|
|
* flightDispatcher.dispatch({
|
|
* actionType: 'city-update',
|
|
* selectedCity: 'paris'
|
|
* });
|
|
*
|
|
* This payload is digested by `CityStore`:
|
|
*
|
|
* flightDispatcher.register(function(payload) {
|
|
* if (payload.actionType === 'city-update') {
|
|
* CityStore.city = payload.selectedCity;
|
|
* }
|
|
* });
|
|
*
|
|
* When the user selects a country, we dispatch the payload:
|
|
*
|
|
* flightDispatcher.dispatch({
|
|
* actionType: 'country-update',
|
|
* selectedCountry: 'australia'
|
|
* });
|
|
*
|
|
* This payload is digested by both stores:
|
|
*
|
|
* CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
|
|
* if (payload.actionType === 'country-update') {
|
|
* CountryStore.country = payload.selectedCountry;
|
|
* }
|
|
* });
|
|
*
|
|
* When the callback to update `CountryStore` is registered, we save a reference
|
|
* to the returned token. Using this token with `waitFor()`, we can guarantee
|
|
* that `CountryStore` is updated before the callback that updates `CityStore`
|
|
* needs to query its data.
|
|
*
|
|
* CityStore.dispatchToken = flightDispatcher.register(function(payload) {
|
|
* if (payload.actionType === 'country-update') {
|
|
* // `CountryStore.country` may not be updated.
|
|
* flightDispatcher.waitFor([CountryStore.dispatchToken]);
|
|
* // `CountryStore.country` is now guaranteed to be updated.
|
|
*
|
|
* // Select the default city for the new country
|
|
* CityStore.city = getDefaultCityForCountry(CountryStore.country);
|
|
* }
|
|
* });
|
|
*
|
|
* The usage of `waitFor()` can be chained, for example:
|
|
*
|
|
* FlightPriceStore.dispatchToken =
|
|
* flightDispatcher.register(function(payload) {
|
|
* switch (payload.actionType) {
|
|
* case 'country-update':
|
|
* flightDispatcher.waitFor([CityStore.dispatchToken]);
|
|
* FlightPriceStore.price =
|
|
* getFlightPriceStore(CountryStore.country, CityStore.city);
|
|
* break;
|
|
*
|
|
* case 'city-update':
|
|
* FlightPriceStore.price =
|
|
* FlightPriceStore(CountryStore.country, CityStore.city);
|
|
* break;
|
|
* }
|
|
* });
|
|
*
|
|
* The `country-update` payload will be guaranteed to invoke the stores'
|
|
* registered callbacks in order: `CountryStore`, `CityStore`, then
|
|
* `FlightPriceStore`.
|
|
*/
|
|
|
|
function Dispatcher() {
|
|
this.$Dispatcher_callbacks = {};
|
|
this.$Dispatcher_isPending = {};
|
|
this.$Dispatcher_isHandled = {};
|
|
this.$Dispatcher_isDispatching = false;
|
|
this.$Dispatcher_pendingPayload = null;
|
|
}
|
|
|
|
/**
|
|
* Registers a callback to be invoked with every dispatched payload. Returns
|
|
* a token that can be used with `waitFor()`.
|
|
*
|
|
* @param {function} callback
|
|
* @return {string}
|
|
*/
|
|
Dispatcher.prototype.register=function(callback) {
|
|
var id = _prefix + _lastID++;
|
|
this.$Dispatcher_callbacks[id] = callback;
|
|
return id;
|
|
};
|
|
|
|
/**
|
|
* Removes a callback based on its token.
|
|
*
|
|
* @param {string} id
|
|
*/
|
|
Dispatcher.prototype.unregister=function(id) {
|
|
invariant(
|
|
this.$Dispatcher_callbacks[id],
|
|
'Dispatcher.unregister(...): `%s` does not map to a registered callback.',
|
|
id
|
|
);
|
|
delete this.$Dispatcher_callbacks[id];
|
|
};
|
|
|
|
/**
|
|
* Waits for the callbacks specified to be invoked before continuing execution
|
|
* of the current callback. This method should only be used by a callback in
|
|
* response to a dispatched payload.
|
|
*
|
|
* @param {array<string>} ids
|
|
*/
|
|
Dispatcher.prototype.waitFor=function(ids) {
|
|
invariant(
|
|
this.$Dispatcher_isDispatching,
|
|
'Dispatcher.waitFor(...): Must be invoked while dispatching.'
|
|
);
|
|
for (var ii = 0; ii < ids.length; ii++) {
|
|
var id = ids[ii];
|
|
if (this.$Dispatcher_isPending[id]) {
|
|
invariant(
|
|
this.$Dispatcher_isHandled[id],
|
|
'Dispatcher.waitFor(...): Circular dependency detected while ' +
|
|
'waiting for `%s`.',
|
|
id
|
|
);
|
|
continue;
|
|
}
|
|
invariant(
|
|
this.$Dispatcher_callbacks[id],
|
|
'Dispatcher.waitFor(...): `%s` does not map to a registered callback.',
|
|
id
|
|
);
|
|
this.$Dispatcher_invokeCallback(id);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Dispatches a payload to all registered callbacks.
|
|
*
|
|
* @param {object} payload
|
|
*/
|
|
Dispatcher.prototype.dispatch=function(payload) {
|
|
invariant(
|
|
!this.$Dispatcher_isDispatching,
|
|
'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.'
|
|
);
|
|
this.$Dispatcher_startDispatching(payload);
|
|
try {
|
|
for (var id in this.$Dispatcher_callbacks) {
|
|
if (this.$Dispatcher_isPending[id]) {
|
|
continue;
|
|
}
|
|
this.$Dispatcher_invokeCallback(id);
|
|
}
|
|
} finally {
|
|
this.$Dispatcher_stopDispatching();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Is this Dispatcher currently dispatching.
|
|
*
|
|
* @return {boolean}
|
|
*/
|
|
Dispatcher.prototype.isDispatching=function() {
|
|
return this.$Dispatcher_isDispatching;
|
|
};
|
|
|
|
/**
|
|
* Call the callback stored with the given id. Also do some internal
|
|
* bookkeeping.
|
|
*
|
|
* @param {string} id
|
|
* @internal
|
|
*/
|
|
Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) {
|
|
this.$Dispatcher_isPending[id] = true;
|
|
this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload);
|
|
this.$Dispatcher_isHandled[id] = true;
|
|
};
|
|
|
|
/**
|
|
* Set up bookkeeping needed when dispatching.
|
|
*
|
|
* @param {object} payload
|
|
* @internal
|
|
*/
|
|
Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) {
|
|
for (var id in this.$Dispatcher_callbacks) {
|
|
this.$Dispatcher_isPending[id] = false;
|
|
this.$Dispatcher_isHandled[id] = false;
|
|
}
|
|
this.$Dispatcher_pendingPayload = payload;
|
|
this.$Dispatcher_isDispatching = true;
|
|
};
|
|
|
|
/**
|
|
* Clear bookkeeping used for dispatching.
|
|
*
|
|
* @internal
|
|
*/
|
|
Dispatcher.prototype.$Dispatcher_stopDispatching=function() {
|
|
this.$Dispatcher_pendingPayload = null;
|
|
this.$Dispatcher_isDispatching = false;
|
|
};
|
|
|
|
|
|
module.exports = Dispatcher;
|
|
|
|
},{"./invariant":3}],3:[function(require,module,exports){
|
|
/**
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule invariant
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Use invariant() to assert state which your program assumes to be true.
|
|
*
|
|
* Provide sprintf-style format (only %s is supported) and arguments
|
|
* to provide information about what broke and what you were
|
|
* expecting.
|
|
*
|
|
* The invariant message will be stripped in production, but the invariant
|
|
* will remain to ensure logic does not differ in production.
|
|
*/
|
|
|
|
var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
if (false) {
|
|
if (format === undefined) {
|
|
throw new Error('invariant requires an error message argument');
|
|
}
|
|
}
|
|
|
|
if (!condition) {
|
|
var error;
|
|
if (format === undefined) {
|
|
error = new Error(
|
|
'Minified exception occurred; use the non-minified dev environment ' +
|
|
'for the full error message and additional helpful warnings.'
|
|
);
|
|
} else {
|
|
var args = [a, b, c, d, e, f];
|
|
var argIndex = 0;
|
|
error = new Error(
|
|
'Invariant Violation: ' +
|
|
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
);
|
|
}
|
|
|
|
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
module.exports = invariant;
|
|
|
|
},{}],4:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/**
|
|
* Represents a cancellation caused by navigating away
|
|
* before the previous transition has fully resolved.
|
|
*/
|
|
function Cancellation() {}
|
|
|
|
module.exports = Cancellation;
|
|
},{}],5:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var warning = require("react/lib/warning");
|
|
var invariant = require("react/lib/invariant");
|
|
|
|
function checkPropTypes(componentName, propTypes, props) {
|
|
for (var propName in propTypes) {
|
|
if (propTypes.hasOwnProperty(propName)) {
|
|
var error = propTypes[propName](props, propName, componentName);
|
|
|
|
if (error instanceof Error) warning(false, error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
var Configuration = {
|
|
|
|
statics: {
|
|
|
|
validateProps: function validateProps(props) {
|
|
checkPropTypes(this.displayName, this.propTypes, props);
|
|
}
|
|
|
|
},
|
|
|
|
render: function render() {
|
|
invariant(false, "%s elements are for router configuration only and should not be rendered", this.constructor.displayName);
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = Configuration;
|
|
},{"react/lib/invariant":182,"react/lib/warning":202}],6:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var invariant = require("react/lib/invariant");
|
|
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM;
|
|
|
|
var History = {
|
|
|
|
/**
|
|
* The current number of entries in the history.
|
|
*
|
|
* Note: This property is read-only.
|
|
*/
|
|
length: 1,
|
|
|
|
/**
|
|
* Sends the browser back one entry in the history.
|
|
*/
|
|
back: function back() {
|
|
invariant(canUseDOM, "Cannot use History.back without a DOM");
|
|
|
|
// Do this first so that History.length will
|
|
// be accurate in location change listeners.
|
|
History.length -= 1;
|
|
|
|
window.history.back();
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = History;
|
|
},{"react/lib/ExecutionEnvironment":64,"react/lib/invariant":182}],7:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
|
|
|
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
|
|
|
/* jshint -W084 */
|
|
var PathUtils = require("./PathUtils");
|
|
|
|
function deepSearch(route, pathname, query) {
|
|
// Check the subtree first to find the most deeply-nested match.
|
|
var childRoutes = route.childRoutes;
|
|
if (childRoutes) {
|
|
var match, childRoute;
|
|
for (var i = 0, len = childRoutes.length; i < len; ++i) {
|
|
childRoute = childRoutes[i];
|
|
|
|
if (childRoute.isDefault || childRoute.isNotFound) continue; // Check these in order later.
|
|
|
|
if (match = deepSearch(childRoute, pathname, query)) {
|
|
// A route in the subtree matched! Add this route and we're done.
|
|
match.routes.unshift(route);
|
|
return match;
|
|
}
|
|
}
|
|
}
|
|
|
|
// No child routes matched; try the default route.
|
|
var defaultRoute = route.defaultRoute;
|
|
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname))) {
|
|
return new Match(pathname, params, query, [route, defaultRoute]);
|
|
} // Does the "not found" route match?
|
|
var notFoundRoute = route.notFoundRoute;
|
|
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname))) {
|
|
return new Match(pathname, params, query, [route, notFoundRoute]);
|
|
} // Last attempt: check this route.
|
|
var params = PathUtils.extractParams(route.path, pathname);
|
|
if (params) {
|
|
return new Match(pathname, params, query, [route]);
|
|
}return null;
|
|
}
|
|
|
|
var Match = (function () {
|
|
function Match(pathname, params, query, routes) {
|
|
_classCallCheck(this, Match);
|
|
|
|
this.pathname = pathname;
|
|
this.params = params;
|
|
this.query = query;
|
|
this.routes = routes;
|
|
}
|
|
|
|
_prototypeProperties(Match, {
|
|
findMatch: {
|
|
|
|
/**
|
|
* Attempts to match depth-first a route in the given route's
|
|
* subtree against the given path and returns the match if it
|
|
* succeeds, null if no match can be made.
|
|
*/
|
|
|
|
value: function findMatch(routes, path) {
|
|
var pathname = PathUtils.withoutQuery(path);
|
|
var query = PathUtils.extractQuery(path);
|
|
var match = null;
|
|
|
|
for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query);
|
|
|
|
return match;
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
});
|
|
|
|
return Match;
|
|
})();
|
|
|
|
module.exports = Match;
|
|
},{"./PathUtils":10}],8:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var PropTypes = require("./PropTypes");
|
|
|
|
/**
|
|
* A mixin for components that modify the URL.
|
|
*
|
|
* Example:
|
|
*
|
|
* var MyLink = React.createClass({
|
|
* mixins: [ Router.Navigation ],
|
|
* handleClick: function (event) {
|
|
* event.preventDefault();
|
|
* this.transitionTo('aRoute', { the: 'params' }, { the: 'query' });
|
|
* },
|
|
* render: function () {
|
|
* return (
|
|
* <a onClick={this.handleClick}>Click me!</a>
|
|
* );
|
|
* }
|
|
* });
|
|
*/
|
|
var Navigation = {
|
|
|
|
contextTypes: {
|
|
makePath: PropTypes.func.isRequired,
|
|
makeHref: PropTypes.func.isRequired,
|
|
transitionTo: PropTypes.func.isRequired,
|
|
replaceWith: PropTypes.func.isRequired,
|
|
goBack: PropTypes.func.isRequired
|
|
},
|
|
|
|
/**
|
|
* Returns an absolute URL path created from the given route
|
|
* name, URL parameters, and query values.
|
|
*/
|
|
makePath: function makePath(to, params, query) {
|
|
return this.context.makePath(to, params, query);
|
|
},
|
|
|
|
/**
|
|
* Returns a string that may safely be used as the href of a
|
|
* link to the route with the given name.
|
|
*/
|
|
makeHref: function makeHref(to, params, query) {
|
|
return this.context.makeHref(to, params, query);
|
|
},
|
|
|
|
/**
|
|
* Transitions to the URL specified in the arguments by pushing
|
|
* a new URL onto the history stack.
|
|
*/
|
|
transitionTo: function transitionTo(to, params, query) {
|
|
this.context.transitionTo(to, params, query);
|
|
},
|
|
|
|
/**
|
|
* Transitions to the URL specified in the arguments by replacing
|
|
* the current URL in the history stack.
|
|
*/
|
|
replaceWith: function replaceWith(to, params, query) {
|
|
this.context.replaceWith(to, params, query);
|
|
},
|
|
|
|
/**
|
|
* Transitions to the previous URL.
|
|
*/
|
|
goBack: function goBack() {
|
|
return this.context.goBack();
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = Navigation;
|
|
},{"./PropTypes":11}],9:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var PropTypes = require("./PropTypes");
|
|
|
|
/**
|
|
* Provides the router with context for Router.Navigation.
|
|
*/
|
|
var NavigationContext = {
|
|
|
|
childContextTypes: {
|
|
makePath: PropTypes.func.isRequired,
|
|
makeHref: PropTypes.func.isRequired,
|
|
transitionTo: PropTypes.func.isRequired,
|
|
replaceWith: PropTypes.func.isRequired,
|
|
goBack: PropTypes.func.isRequired
|
|
},
|
|
|
|
getChildContext: function getChildContext() {
|
|
return {
|
|
makePath: this.constructor.makePath.bind(this.constructor),
|
|
makeHref: this.constructor.makeHref.bind(this.constructor),
|
|
transitionTo: this.constructor.transitionTo.bind(this.constructor),
|
|
replaceWith: this.constructor.replaceWith.bind(this.constructor),
|
|
goBack: this.constructor.goBack.bind(this.constructor)
|
|
};
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = NavigationContext;
|
|
},{"./PropTypes":11}],10:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var invariant = require("react/lib/invariant");
|
|
var merge = require("qs/lib/utils").merge;
|
|
var qs = require("qs");
|
|
|
|
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
|
|
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
|
|
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
|
|
var queryMatcher = /\?(.+)/;
|
|
|
|
var _compiledPatterns = {};
|
|
|
|
function compilePattern(pattern) {
|
|
if (!(pattern in _compiledPatterns)) {
|
|
var paramNames = [];
|
|
var source = pattern.replace(paramCompileMatcher, function (match, paramName) {
|
|
if (paramName) {
|
|
paramNames.push(paramName);
|
|
return "([^/?#]+)";
|
|
} else if (match === "*") {
|
|
paramNames.push("splat");
|
|
return "(.*?)";
|
|
} else {
|
|
return "\\" + match;
|
|
}
|
|
});
|
|
|
|
_compiledPatterns[pattern] = {
|
|
matcher: new RegExp("^" + source + "$", "i"),
|
|
paramNames: paramNames
|
|
};
|
|
}
|
|
|
|
return _compiledPatterns[pattern];
|
|
}
|
|
|
|
var PathUtils = {
|
|
|
|
/**
|
|
* Returns true if the given path is absolute.
|
|
*/
|
|
isAbsolute: function isAbsolute(path) {
|
|
return path.charAt(0) === "/";
|
|
},
|
|
|
|
/**
|
|
* Joins two URL paths together.
|
|
*/
|
|
join: function join(a, b) {
|
|
return a.replace(/\/*$/, "/") + b;
|
|
},
|
|
|
|
/**
|
|
* Returns an array of the names of all parameters in the given pattern.
|
|
*/
|
|
extractParamNames: function extractParamNames(pattern) {
|
|
return compilePattern(pattern).paramNames;
|
|
},
|
|
|
|
/**
|
|
* Extracts the portions of the given URL path that match the given pattern
|
|
* and returns an object of param name => value pairs. Returns null if the
|
|
* pattern does not match the given path.
|
|
*/
|
|
extractParams: function extractParams(pattern, path) {
|
|
var _compilePattern = compilePattern(pattern);
|
|
|
|
var matcher = _compilePattern.matcher;
|
|
var paramNames = _compilePattern.paramNames;
|
|
|
|
var match = path.match(matcher);
|
|
|
|
if (!match) {
|
|
return null;
|
|
}var params = {};
|
|
|
|
paramNames.forEach(function (paramName, index) {
|
|
params[paramName] = match[index + 1];
|
|
});
|
|
|
|
return params;
|
|
},
|
|
|
|
/**
|
|
* Returns a version of the given route path with params interpolated. Throws
|
|
* if there is a dynamic segment of the route path for which there is no param.
|
|
*/
|
|
injectParams: function injectParams(pattern, params) {
|
|
params = params || {};
|
|
|
|
var splatIndex = 0;
|
|
|
|
return pattern.replace(paramInjectMatcher, function (match, paramName) {
|
|
paramName = paramName || "splat";
|
|
|
|
// If param is optional don't check for existence
|
|
if (paramName.slice(-1) === "?") {
|
|
paramName = paramName.slice(0, -1);
|
|
|
|
if (params[paramName] == null) return "";
|
|
} else {
|
|
invariant(params[paramName] != null, "Missing \"%s\" parameter for path \"%s\"", paramName, pattern);
|
|
}
|
|
|
|
var segment;
|
|
if (paramName === "splat" && Array.isArray(params[paramName])) {
|
|
segment = params[paramName][splatIndex++];
|
|
|
|
invariant(segment != null, "Missing splat # %s for path \"%s\"", splatIndex, pattern);
|
|
} else {
|
|
segment = params[paramName];
|
|
}
|
|
|
|
return segment;
|
|
}).replace(paramInjectTrailingSlashMatcher, "/");
|
|
},
|
|
|
|
/**
|
|
* Returns an object that is the result of parsing any query string contained
|
|
* in the given path, null if the path contains no query string.
|
|
*/
|
|
extractQuery: function extractQuery(path) {
|
|
var match = path.match(queryMatcher);
|
|
return match && qs.parse(match[1]);
|
|
},
|
|
|
|
/**
|
|
* Returns a version of the given path without the query string.
|
|
*/
|
|
withoutQuery: function withoutQuery(path) {
|
|
return path.replace(queryMatcher, "");
|
|
},
|
|
|
|
/**
|
|
* Returns a version of the given path with the parameters in the given
|
|
* query merged into the query string.
|
|
*/
|
|
withQuery: function withQuery(path, query) {
|
|
var existingQuery = PathUtils.extractQuery(path);
|
|
|
|
if (existingQuery) query = query ? merge(existingQuery, query) : existingQuery;
|
|
|
|
var queryString = qs.stringify(query, { indices: false });
|
|
|
|
if (queryString) {
|
|
return PathUtils.withoutQuery(path) + "?" + queryString;
|
|
}return path;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = PathUtils;
|
|
},{"qs":38,"qs/lib/utils":42,"react/lib/invariant":182}],11:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var assign = require("react/lib/Object.assign");
|
|
var ReactPropTypes = require("react").PropTypes;
|
|
|
|
var PropTypes = assign({
|
|
|
|
/**
|
|
* Requires that the value of a prop be falsy.
|
|
*/
|
|
falsy: function falsy(props, propName, componentName) {
|
|
if (props[propName]) {
|
|
return new Error("<" + componentName + "> may not have a \"" + propName + "\" prop");
|
|
}
|
|
}
|
|
|
|
}, ReactPropTypes);
|
|
|
|
module.exports = PropTypes;
|
|
},{"react":"react","react/lib/Object.assign":70}],12:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/**
|
|
* Encapsulates a redirect to the given route.
|
|
*/
|
|
function Redirect(to, params, query) {
|
|
this.to = to;
|
|
this.params = params;
|
|
this.query = query;
|
|
}
|
|
|
|
module.exports = Redirect;
|
|
},{}],13:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
|
|
|
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
|
|
|
var assign = require("react/lib/Object.assign");
|
|
var invariant = require("react/lib/invariant");
|
|
var warning = require("react/lib/warning");
|
|
var PathUtils = require("./PathUtils");
|
|
|
|
var _currentRoute;
|
|
|
|
var Route = (function () {
|
|
function Route(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
|
|
_classCallCheck(this, Route);
|
|
|
|
this.name = name;
|
|
this.path = path;
|
|
this.paramNames = PathUtils.extractParamNames(this.path);
|
|
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
|
|
this.isDefault = !!isDefault;
|
|
this.isNotFound = !!isNotFound;
|
|
this.onEnter = onEnter;
|
|
this.onLeave = onLeave;
|
|
this.handler = handler;
|
|
}
|
|
|
|
_prototypeProperties(Route, {
|
|
createRoute: {
|
|
|
|
/**
|
|
* Creates and returns a new route. Options may be a URL pathname string
|
|
* with placeholders for named params or an object with any of the following
|
|
* properties:
|
|
*
|
|
* - name The name of the route. This is used to lookup a
|
|
* route relative to its parent route and should be
|
|
* unique among all child routes of the same parent
|
|
* - path A URL pathname string with optional placeholders
|
|
* that specify the names of params to extract from
|
|
* the URL when the path matches. Defaults to `/${name}`
|
|
* when there is a name given, or the path of the parent
|
|
* route, or /
|
|
* - ignoreScrollBehavior True to make this route (and all descendants) ignore
|
|
* the scroll behavior of the router
|
|
* - isDefault True to make this route the default route among all
|
|
* its siblings
|
|
* - isNotFound True to make this route the "not found" route among
|
|
* all its siblings
|
|
* - onEnter A transition hook that will be called when the
|
|
* router is going to enter this route
|
|
* - onLeave A transition hook that will be called when the
|
|
* router is going to leave this route
|
|
* - handler A React component that will be rendered when
|
|
* this route is active
|
|
* - parentRoute The parent route to use for this route. This option
|
|
* is automatically supplied when creating routes inside
|
|
* the callback to another invocation of createRoute. You
|
|
* only ever need to use this when declaring routes
|
|
* independently of one another to manually piece together
|
|
* the route hierarchy
|
|
*
|
|
* The callback may be used to structure your route hierarchy. Any call to
|
|
* createRoute, createDefaultRoute, createNotFoundRoute, or createRedirect
|
|
* inside the callback automatically uses this route as its parent.
|
|
*/
|
|
|
|
value: function createRoute(options, callback) {
|
|
options = options || {};
|
|
|
|
if (typeof options === "string") options = { path: options };
|
|
|
|
var parentRoute = _currentRoute;
|
|
|
|
if (parentRoute) {
|
|
warning(options.parentRoute == null || options.parentRoute === parentRoute, "You should not use parentRoute with createRoute inside another route's child callback; it is ignored");
|
|
} else {
|
|
parentRoute = options.parentRoute;
|
|
}
|
|
|
|
var name = options.name;
|
|
var path = options.path || name;
|
|
|
|
if (path && !(options.isDefault || options.isNotFound)) {
|
|
if (PathUtils.isAbsolute(path)) {
|
|
if (parentRoute) {
|
|
invariant(parentRoute.paramNames.length === 0, "You cannot nest path \"%s\" inside \"%s\"; the parent requires URL parameters", path, parentRoute.path);
|
|
}
|
|
} else if (parentRoute) {
|
|
// Relative paths extend their parent.
|
|
path = PathUtils.join(parentRoute.path, path);
|
|
} else {
|
|
path = "/" + path;
|
|
}
|
|
} else {
|
|
path = parentRoute ? parentRoute.path : "/";
|
|
}
|
|
|
|
if (options.isNotFound && !/\*$/.test(path)) path += "*"; // Auto-append * to the path of not found routes.
|
|
|
|
var route = new Route(name, path, options.ignoreScrollBehavior, options.isDefault, options.isNotFound, options.onEnter, options.onLeave, options.handler);
|
|
|
|
if (parentRoute) {
|
|
if (route.isDefault) {
|
|
invariant(parentRoute.defaultRoute == null, "%s may not have more than one default route", parentRoute);
|
|
|
|
parentRoute.defaultRoute = route;
|
|
} else if (route.isNotFound) {
|
|
invariant(parentRoute.notFoundRoute == null, "%s may not have more than one not found route", parentRoute);
|
|
|
|
parentRoute.notFoundRoute = route;
|
|
}
|
|
|
|
parentRoute.appendChild(route);
|
|
}
|
|
|
|
// Any routes created in the callback
|
|
// use this route as their parent.
|
|
if (typeof callback === "function") {
|
|
var currentRoute = _currentRoute;
|
|
_currentRoute = route;
|
|
callback.call(route, route);
|
|
_currentRoute = currentRoute;
|
|
}
|
|
|
|
return route;
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
},
|
|
createDefaultRoute: {
|
|
|
|
/**
|
|
* Creates and returns a route that is rendered when its parent matches
|
|
* the current URL.
|
|
*/
|
|
|
|
value: function createDefaultRoute(options) {
|
|
return Route.createRoute(assign({}, options, { isDefault: true }));
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
},
|
|
createNotFoundRoute: {
|
|
|
|
/**
|
|
* Creates and returns a route that is rendered when its parent matches
|
|
* the current URL but none of its siblings do.
|
|
*/
|
|
|
|
value: function createNotFoundRoute(options) {
|
|
return Route.createRoute(assign({}, options, { isNotFound: true }));
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
},
|
|
createRedirect: {
|
|
|
|
/**
|
|
* Creates and returns a route that automatically redirects the transition
|
|
* to another route. In addition to the normal options to createRoute, this
|
|
* function accepts the following options:
|
|
*
|
|
* - from An alias for the `path` option. Defaults to *
|
|
* - to The path/route/route name to redirect to
|
|
* - params The params to use in the redirect URL. Defaults
|
|
* to using the current params
|
|
* - query The query to use in the redirect URL. Defaults
|
|
* to using the current query
|
|
*/
|
|
|
|
value: function createRedirect(options) {
|
|
return Route.createRoute(assign({}, options, {
|
|
path: options.path || options.from || "*",
|
|
onEnter: function onEnter(transition, params, query) {
|
|
transition.redirect(options.to, options.params || params, options.query || query);
|
|
}
|
|
}));
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
}, {
|
|
appendChild: {
|
|
|
|
/**
|
|
* Appends the given route to this route's child routes.
|
|
*/
|
|
|
|
value: function appendChild(route) {
|
|
invariant(route instanceof Route, "route.appendChild must use a valid Route");
|
|
|
|
if (!this.childRoutes) this.childRoutes = [];
|
|
|
|
this.childRoutes.push(route);
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
},
|
|
toString: {
|
|
value: function toString() {
|
|
var string = "<Route";
|
|
|
|
if (this.name) string += " name=\"" + this.name + "\"";
|
|
|
|
string += " path=\"" + this.path + "\">";
|
|
|
|
return string;
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
});
|
|
|
|
return Route;
|
|
})();
|
|
|
|
module.exports = Route;
|
|
},{"./PathUtils":10,"react/lib/Object.assign":70,"react/lib/invariant":182,"react/lib/warning":202}],14:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var assign = require("react/lib/Object.assign");
|
|
var PropTypes = require("./PropTypes");
|
|
|
|
var REF_NAME = "__routeHandler__";
|
|
|
|
var RouteHandlerMixin = {
|
|
|
|
contextTypes: {
|
|
getRouteAtDepth: PropTypes.func.isRequired,
|
|
setRouteComponentAtDepth: PropTypes.func.isRequired,
|
|
routeHandlers: PropTypes.array.isRequired
|
|
},
|
|
|
|
childContextTypes: {
|
|
routeHandlers: PropTypes.array.isRequired
|
|
},
|
|
|
|
getChildContext: function getChildContext() {
|
|
return {
|
|
routeHandlers: this.context.routeHandlers.concat([this])
|
|
};
|
|
},
|
|
|
|
componentDidMount: function componentDidMount() {
|
|
this._updateRouteComponent(this.refs[REF_NAME]);
|
|
},
|
|
|
|
componentDidUpdate: function componentDidUpdate() {
|
|
this._updateRouteComponent(this.refs[REF_NAME]);
|
|
},
|
|
|
|
componentWillUnmount: function componentWillUnmount() {
|
|
this._updateRouteComponent(null);
|
|
},
|
|
|
|
_updateRouteComponent: function _updateRouteComponent(component) {
|
|
this.context.setRouteComponentAtDepth(this.getRouteDepth(), component);
|
|
},
|
|
|
|
getRouteDepth: function getRouteDepth() {
|
|
return this.context.routeHandlers.length;
|
|
},
|
|
|
|
createChildRouteHandler: function createChildRouteHandler(props) {
|
|
var route = this.context.getRouteAtDepth(this.getRouteDepth());
|
|
return route ? React.createElement(route.handler, assign({}, props || this.props, { ref: REF_NAME })) : null;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = RouteHandlerMixin;
|
|
},{"./PropTypes":11,"react":"react","react/lib/Object.assign":70}],15:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var invariant = require("react/lib/invariant");
|
|
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM;
|
|
var getWindowScrollPosition = require("./getWindowScrollPosition");
|
|
|
|
function shouldUpdateScroll(state, prevState) {
|
|
if (!prevState) {
|
|
return true;
|
|
} // Don't update scroll position when only the query has changed.
|
|
if (state.pathname === prevState.pathname) {
|
|
return false;
|
|
}var routes = state.routes;
|
|
var prevRoutes = prevState.routes;
|
|
|
|
var sharedAncestorRoutes = routes.filter(function (route) {
|
|
return prevRoutes.indexOf(route) !== -1;
|
|
});
|
|
|
|
return !sharedAncestorRoutes.some(function (route) {
|
|
return route.ignoreScrollBehavior;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Provides the router with the ability to manage window scroll position
|
|
* according to its scroll behavior.
|
|
*/
|
|
var ScrollHistory = {
|
|
|
|
statics: {
|
|
|
|
/**
|
|
* Records curent scroll position as the last known position for the given URL path.
|
|
*/
|
|
recordScrollPosition: function recordScrollPosition(path) {
|
|
if (!this.scrollHistory) this.scrollHistory = {};
|
|
|
|
this.scrollHistory[path] = getWindowScrollPosition();
|
|
},
|
|
|
|
/**
|
|
* Returns the last known scroll position for the given URL path.
|
|
*/
|
|
getScrollPosition: function getScrollPosition(path) {
|
|
if (!this.scrollHistory) this.scrollHistory = {};
|
|
|
|
return this.scrollHistory[path] || null;
|
|
}
|
|
|
|
},
|
|
|
|
componentWillMount: function componentWillMount() {
|
|
invariant(this.constructor.getScrollBehavior() == null || canUseDOM, "Cannot use scroll behavior without a DOM");
|
|
},
|
|
|
|
componentDidMount: function componentDidMount() {
|
|
this._updateScroll();
|
|
},
|
|
|
|
componentDidUpdate: function componentDidUpdate(prevProps, prevState) {
|
|
this._updateScroll(prevState);
|
|
},
|
|
|
|
_updateScroll: function _updateScroll(prevState) {
|
|
if (!shouldUpdateScroll(this.state, prevState)) {
|
|
return;
|
|
}var scrollBehavior = this.constructor.getScrollBehavior();
|
|
|
|
if (scrollBehavior) scrollBehavior.updateScrollPosition(this.constructor.getScrollPosition(this.state.path), this.state.action);
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ScrollHistory;
|
|
},{"./getWindowScrollPosition":30,"react/lib/ExecutionEnvironment":64,"react/lib/invariant":182}],16:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var PropTypes = require("./PropTypes");
|
|
|
|
/**
|
|
* A mixin for components that need to know the path, routes, URL
|
|
* params and query that are currently active.
|
|
*
|
|
* Example:
|
|
*
|
|
* var AboutLink = React.createClass({
|
|
* mixins: [ Router.State ],
|
|
* render: function () {
|
|
* var className = this.props.className;
|
|
*
|
|
* if (this.isActive('about'))
|
|
* className += ' is-active';
|
|
*
|
|
* return React.DOM.a({ className: className }, this.props.children);
|
|
* }
|
|
* });
|
|
*/
|
|
var State = {
|
|
|
|
contextTypes: {
|
|
getCurrentPath: PropTypes.func.isRequired,
|
|
getCurrentRoutes: PropTypes.func.isRequired,
|
|
getCurrentPathname: PropTypes.func.isRequired,
|
|
getCurrentParams: PropTypes.func.isRequired,
|
|
getCurrentQuery: PropTypes.func.isRequired,
|
|
isActive: PropTypes.func.isRequired
|
|
},
|
|
|
|
/**
|
|
* Returns the current URL path.
|
|
*/
|
|
getPath: function getPath() {
|
|
return this.context.getCurrentPath();
|
|
},
|
|
|
|
/**
|
|
* Returns an array of the routes that are currently active.
|
|
*/
|
|
getRoutes: function getRoutes() {
|
|
return this.context.getCurrentRoutes();
|
|
},
|
|
|
|
/**
|
|
* Returns the current URL path without the query string.
|
|
*/
|
|
getPathname: function getPathname() {
|
|
return this.context.getCurrentPathname();
|
|
},
|
|
|
|
/**
|
|
* Returns an object of the URL params that are currently active.
|
|
*/
|
|
getParams: function getParams() {
|
|
return this.context.getCurrentParams();
|
|
},
|
|
|
|
/**
|
|
* Returns an object of the query params that are currently active.
|
|
*/
|
|
getQuery: function getQuery() {
|
|
return this.context.getCurrentQuery();
|
|
},
|
|
|
|
/**
|
|
* A helper method to determine if a given route, params, and query
|
|
* are active.
|
|
*/
|
|
isActive: function isActive(to, params, query) {
|
|
return this.context.isActive(to, params, query);
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = State;
|
|
},{"./PropTypes":11}],17:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var assign = require("react/lib/Object.assign");
|
|
var PropTypes = require("./PropTypes");
|
|
var PathUtils = require("./PathUtils");
|
|
|
|
function routeIsActive(activeRoutes, routeName) {
|
|
return activeRoutes.some(function (route) {
|
|
return route.name === routeName;
|
|
});
|
|
}
|
|
|
|
function paramsAreActive(activeParams, params) {
|
|
for (var property in params) if (String(activeParams[property]) !== String(params[property])) {
|
|
return false;
|
|
}return true;
|
|
}
|
|
|
|
function queryIsActive(activeQuery, query) {
|
|
for (var property in query) if (String(activeQuery[property]) !== String(query[property])) {
|
|
return false;
|
|
}return true;
|
|
}
|
|
|
|
/**
|
|
* Provides the router with context for Router.State.
|
|
*/
|
|
var StateContext = {
|
|
|
|
/**
|
|
* Returns the current URL path + query string.
|
|
*/
|
|
getCurrentPath: function getCurrentPath() {
|
|
return this.state.path;
|
|
},
|
|
|
|
/**
|
|
* Returns a read-only array of the currently active routes.
|
|
*/
|
|
getCurrentRoutes: function getCurrentRoutes() {
|
|
return this.state.routes.slice(0);
|
|
},
|
|
|
|
/**
|
|
* Returns the current URL path without the query string.
|
|
*/
|
|
getCurrentPathname: function getCurrentPathname() {
|
|
return this.state.pathname;
|
|
},
|
|
|
|
/**
|
|
* Returns a read-only object of the currently active URL parameters.
|
|
*/
|
|
getCurrentParams: function getCurrentParams() {
|
|
return assign({}, this.state.params);
|
|
},
|
|
|
|
/**
|
|
* Returns a read-only object of the currently active query parameters.
|
|
*/
|
|
getCurrentQuery: function getCurrentQuery() {
|
|
return assign({}, this.state.query);
|
|
},
|
|
|
|
/**
|
|
* Returns true if the given route, params, and query are active.
|
|
*/
|
|
isActive: function isActive(to, params, query) {
|
|
if (PathUtils.isAbsolute(to)) {
|
|
return to === this.state.path;
|
|
}return routeIsActive(this.state.routes, to) && paramsAreActive(this.state.params, params) && (query == null || queryIsActive(this.state.query, query));
|
|
},
|
|
|
|
childContextTypes: {
|
|
getCurrentPath: PropTypes.func.isRequired,
|
|
getCurrentRoutes: PropTypes.func.isRequired,
|
|
getCurrentPathname: PropTypes.func.isRequired,
|
|
getCurrentParams: PropTypes.func.isRequired,
|
|
getCurrentQuery: PropTypes.func.isRequired,
|
|
isActive: PropTypes.func.isRequired
|
|
},
|
|
|
|
getChildContext: function getChildContext() {
|
|
return {
|
|
getCurrentPath: this.getCurrentPath,
|
|
getCurrentRoutes: this.getCurrentRoutes,
|
|
getCurrentPathname: this.getCurrentPathname,
|
|
getCurrentParams: this.getCurrentParams,
|
|
getCurrentQuery: this.getCurrentQuery,
|
|
isActive: this.isActive
|
|
};
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = StateContext;
|
|
},{"./PathUtils":10,"./PropTypes":11,"react/lib/Object.assign":70}],18:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/* jshint -W058 */
|
|
|
|
var Cancellation = require("./Cancellation");
|
|
var Redirect = require("./Redirect");
|
|
|
|
/**
|
|
* Encapsulates a transition to a given path.
|
|
*
|
|
* The willTransitionTo and willTransitionFrom handlers receive
|
|
* an instance of this class as their first argument.
|
|
*/
|
|
function Transition(path, retry) {
|
|
this.path = path;
|
|
this.abortReason = null;
|
|
// TODO: Change this to router.retryTransition(transition)
|
|
this.retry = retry.bind(this);
|
|
}
|
|
|
|
Transition.prototype.abort = function (reason) {
|
|
if (this.abortReason == null) this.abortReason = reason || "ABORT";
|
|
};
|
|
|
|
Transition.prototype.redirect = function (to, params, query) {
|
|
this.abort(new Redirect(to, params, query));
|
|
};
|
|
|
|
Transition.prototype.cancel = function () {
|
|
this.abort(new Cancellation());
|
|
};
|
|
|
|
Transition.from = function (transition, routes, components, callback) {
|
|
routes.reduce(function (callback, route, index) {
|
|
return function (error) {
|
|
if (error || transition.abortReason) {
|
|
callback(error);
|
|
} else if (route.onLeave) {
|
|
try {
|
|
route.onLeave(transition, components[index], callback);
|
|
|
|
// If there is no callback in the argument list, call it automatically.
|
|
if (route.onLeave.length < 3) callback();
|
|
} catch (e) {
|
|
callback(e);
|
|
}
|
|
} else {
|
|
callback();
|
|
}
|
|
};
|
|
}, callback)();
|
|
};
|
|
|
|
Transition.to = function (transition, routes, params, query, callback) {
|
|
routes.reduceRight(function (callback, route) {
|
|
return function (error) {
|
|
if (error || transition.abortReason) {
|
|
callback(error);
|
|
} else if (route.onEnter) {
|
|
try {
|
|
route.onEnter(transition, params, query, callback);
|
|
|
|
// If there is no callback in the argument list, call it automatically.
|
|
if (route.onEnter.length < 4) callback();
|
|
} catch (e) {
|
|
callback(e);
|
|
}
|
|
} else {
|
|
callback();
|
|
}
|
|
};
|
|
}, callback)();
|
|
};
|
|
|
|
module.exports = Transition;
|
|
},{"./Cancellation":4,"./Redirect":12}],19:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/**
|
|
* Actions that modify the URL.
|
|
*/
|
|
var LocationActions = {
|
|
|
|
/**
|
|
* Indicates a new location is being pushed to the history stack.
|
|
*/
|
|
PUSH: "push",
|
|
|
|
/**
|
|
* Indicates the current location should be replaced.
|
|
*/
|
|
REPLACE: "replace",
|
|
|
|
/**
|
|
* Indicates the most recent entry should be removed from the history stack.
|
|
*/
|
|
POP: "pop"
|
|
|
|
};
|
|
|
|
module.exports = LocationActions;
|
|
},{}],20:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var LocationActions = require("../actions/LocationActions");
|
|
|
|
/**
|
|
* A scroll behavior that attempts to imitate the default behavior
|
|
* of modern browsers.
|
|
*/
|
|
var ImitateBrowserBehavior = {
|
|
|
|
updateScrollPosition: function updateScrollPosition(position, actionType) {
|
|
switch (actionType) {
|
|
case LocationActions.PUSH:
|
|
case LocationActions.REPLACE:
|
|
window.scrollTo(0, 0);
|
|
break;
|
|
case LocationActions.POP:
|
|
if (position) {
|
|
window.scrollTo(position.x, position.y);
|
|
} else {
|
|
window.scrollTo(0, 0);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ImitateBrowserBehavior;
|
|
},{"../actions/LocationActions":19}],21:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/**
|
|
* A scroll behavior that always scrolls to the top of the page
|
|
* after a transition.
|
|
*/
|
|
var ScrollToTopBehavior = {
|
|
|
|
updateScrollPosition: function updateScrollPosition() {
|
|
window.scrollTo(0, 0);
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ScrollToTopBehavior;
|
|
},{}],22:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var Configuration = require("../Configuration");
|
|
var PropTypes = require("../PropTypes");
|
|
|
|
/**
|
|
* A <DefaultRoute> component is a special kind of <Route> that
|
|
* renders when its parent matches but none of its siblings do.
|
|
* Only one such route may be used at any given level in the
|
|
* route hierarchy.
|
|
*/
|
|
var DefaultRoute = React.createClass({
|
|
|
|
displayName: "DefaultRoute",
|
|
|
|
mixins: [Configuration],
|
|
|
|
propTypes: {
|
|
name: PropTypes.string,
|
|
path: PropTypes.falsy,
|
|
children: PropTypes.falsy,
|
|
handler: PropTypes.func.isRequired
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = DefaultRoute;
|
|
},{"../Configuration":5,"../PropTypes":11,"react":"react"}],23:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var classSet = require("react/lib/cx");
|
|
var assign = require("react/lib/Object.assign");
|
|
var Navigation = require("../Navigation");
|
|
var State = require("../State");
|
|
var PropTypes = require("../PropTypes");
|
|
var Route = require("../Route");
|
|
|
|
function isLeftClickEvent(event) {
|
|
return event.button === 0;
|
|
}
|
|
|
|
function isModifiedEvent(event) {
|
|
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
}
|
|
|
|
/**
|
|
* <Link> components are used to create an <a> element that links to a route.
|
|
* When that route is active, the link gets an "active" class name (or the
|
|
* value of its `activeClassName` prop).
|
|
*
|
|
* For example, assuming you have the following route:
|
|
*
|
|
* <Route name="showPost" path="/posts/:postID" handler={Post}/>
|
|
*
|
|
* You could use the following component to link to that route:
|
|
*
|
|
* <Link to="showPost" params={{ postID: "123" }} />
|
|
*
|
|
* In addition to params, links may pass along query string parameters
|
|
* using the `query` prop.
|
|
*
|
|
* <Link to="showPost" params={{ postID: "123" }} query={{ show:true }}/>
|
|
*/
|
|
var Link = React.createClass({
|
|
|
|
displayName: "Link",
|
|
|
|
mixins: [Navigation, State],
|
|
|
|
propTypes: {
|
|
activeClassName: PropTypes.string.isRequired,
|
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Route)]),
|
|
params: PropTypes.object,
|
|
query: PropTypes.object,
|
|
activeStyle: PropTypes.object,
|
|
onClick: PropTypes.func
|
|
},
|
|
|
|
getDefaultProps: function getDefaultProps() {
|
|
return {
|
|
activeClassName: "active"
|
|
};
|
|
},
|
|
|
|
handleClick: function handleClick(event) {
|
|
var allowTransition = true;
|
|
var clickResult;
|
|
|
|
if (this.props.onClick) clickResult = this.props.onClick(event);
|
|
|
|
if (isModifiedEvent(event) || !isLeftClickEvent(event)) {
|
|
return;
|
|
}if (clickResult === false || event.defaultPrevented === true) allowTransition = false;
|
|
|
|
event.preventDefault();
|
|
|
|
if (allowTransition) this.transitionTo(this.props.to, this.props.params, this.props.query);
|
|
},
|
|
|
|
/**
|
|
* Returns the value of the "href" attribute to use on the DOM element.
|
|
*/
|
|
getHref: function getHref() {
|
|
return this.makeHref(this.props.to, this.props.params, this.props.query);
|
|
},
|
|
|
|
/**
|
|
* Returns the value of the "class" attribute to use on the DOM element, which contains
|
|
* the value of the activeClassName property when this <Link> is active.
|
|
*/
|
|
getClassName: function getClassName() {
|
|
var classNames = {};
|
|
|
|
if (this.props.className) classNames[this.props.className] = true;
|
|
|
|
if (this.getActiveState()) classNames[this.props.activeClassName] = true;
|
|
|
|
return classSet(classNames);
|
|
},
|
|
|
|
getActiveState: function getActiveState() {
|
|
return this.isActive(this.props.to, this.props.params, this.props.query);
|
|
},
|
|
|
|
render: function render() {
|
|
var props = assign({}, this.props, {
|
|
href: this.getHref(),
|
|
className: this.getClassName(),
|
|
onClick: this.handleClick
|
|
});
|
|
|
|
if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle;
|
|
|
|
return React.DOM.a(props, this.props.children);
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = Link;
|
|
},{"../Navigation":8,"../PropTypes":11,"../Route":13,"../State":16,"react":"react","react/lib/Object.assign":70,"react/lib/cx":160}],24:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var Configuration = require("../Configuration");
|
|
var PropTypes = require("../PropTypes");
|
|
|
|
/**
|
|
* A <NotFoundRoute> is a special kind of <Route> that
|
|
* renders when the beginning of its parent's path matches
|
|
* but none of its siblings do, including any <DefaultRoute>.
|
|
* Only one such route may be used at any given level in the
|
|
* route hierarchy.
|
|
*/
|
|
var NotFoundRoute = React.createClass({
|
|
|
|
displayName: "NotFoundRoute",
|
|
|
|
mixins: [Configuration],
|
|
|
|
propTypes: {
|
|
name: PropTypes.string,
|
|
path: PropTypes.falsy,
|
|
children: PropTypes.falsy,
|
|
handler: PropTypes.func.isRequired
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = NotFoundRoute;
|
|
},{"../Configuration":5,"../PropTypes":11,"react":"react"}],25:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var Configuration = require("../Configuration");
|
|
var PropTypes = require("../PropTypes");
|
|
|
|
/**
|
|
* A <Redirect> component is a special kind of <Route> that always
|
|
* redirects to another route when it matches.
|
|
*/
|
|
var Redirect = React.createClass({
|
|
|
|
displayName: "Redirect",
|
|
|
|
mixins: [Configuration],
|
|
|
|
propTypes: {
|
|
path: PropTypes.string,
|
|
from: PropTypes.string, // Alias for path.
|
|
to: PropTypes.string,
|
|
handler: PropTypes.falsy
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = Redirect;
|
|
},{"../Configuration":5,"../PropTypes":11,"react":"react"}],26:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var Configuration = require("../Configuration");
|
|
var PropTypes = require("../PropTypes");
|
|
var RouteHandler = require("./RouteHandler");
|
|
/**
|
|
* <Route> components specify components that are rendered to the page when the
|
|
* URL matches a given pattern.
|
|
*
|
|
* Routes are arranged in a nested tree structure. When a new URL is requested,
|
|
* the tree is searched depth-first to find a route whose path matches the URL.
|
|
* When one is found, all routes in the tree that lead to it are considered
|
|
* "active" and their components are rendered into the DOM, nested in the same
|
|
* order as they are in the tree.
|
|
*
|
|
* The preferred way to configure a router is using JSX. The XML-like syntax is
|
|
* a great way to visualize how routes are laid out in an application.
|
|
*
|
|
* var routes = [
|
|
* <Route handler={App}>
|
|
* <Route name="login" handler={Login}/>
|
|
* <Route name="logout" handler={Logout}/>
|
|
* <Route name="about" handler={About}/>
|
|
* </Route>
|
|
* ];
|
|
*
|
|
* Router.run(routes, function (Handler) {
|
|
* React.render(<Handler/>, document.body);
|
|
* });
|
|
*
|
|
* Handlers for Route components that contain children can render their active
|
|
* child route using a <RouteHandler> element.
|
|
*
|
|
* var App = React.createClass({
|
|
* render: function () {
|
|
* return (
|
|
* <div class="application">
|
|
* <RouteHandler/>
|
|
* </div>
|
|
* );
|
|
* }
|
|
* });
|
|
*
|
|
* If no handler is provided for the route, it will render a matched child route.
|
|
*/
|
|
var Route = React.createClass({
|
|
|
|
displayName: "Route",
|
|
|
|
mixins: [Configuration],
|
|
|
|
propTypes: {
|
|
name: PropTypes.string,
|
|
path: PropTypes.string,
|
|
handler: PropTypes.func,
|
|
ignoreScrollBehavior: PropTypes.bool
|
|
},
|
|
|
|
getDefaultProps: function getDefaultProps() {
|
|
return {
|
|
handler: RouteHandler
|
|
};
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = Route;
|
|
},{"../Configuration":5,"../PropTypes":11,"./RouteHandler":27,"react":"react"}],27:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
var RouteHandlerMixin = require("../RouteHandlerMixin");
|
|
|
|
/**
|
|
* A <RouteHandler> component renders the active child route handler
|
|
* when routes are nested.
|
|
*/
|
|
var RouteHandler = React.createClass({
|
|
|
|
displayName: "RouteHandler",
|
|
|
|
mixins: [RouteHandlerMixin],
|
|
|
|
render: function render() {
|
|
return this.createChildRouteHandler();
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = RouteHandler;
|
|
},{"../RouteHandlerMixin":14,"react":"react"}],28:[function(require,module,exports){
|
|
(function (process){
|
|
"use strict";
|
|
|
|
/* jshint -W058 */
|
|
var React = require("react");
|
|
var warning = require("react/lib/warning");
|
|
var invariant = require("react/lib/invariant");
|
|
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM;
|
|
var LocationActions = require("./actions/LocationActions");
|
|
var ImitateBrowserBehavior = require("./behaviors/ImitateBrowserBehavior");
|
|
var HashLocation = require("./locations/HashLocation");
|
|
var HistoryLocation = require("./locations/HistoryLocation");
|
|
var RefreshLocation = require("./locations/RefreshLocation");
|
|
var StaticLocation = require("./locations/StaticLocation");
|
|
var NavigationContext = require("./NavigationContext");
|
|
var ScrollHistory = require("./ScrollHistory");
|
|
var StateContext = require("./StateContext");
|
|
var createRoutesFromReactChildren = require("./createRoutesFromReactChildren");
|
|
var isReactChildren = require("./isReactChildren");
|
|
var Transition = require("./Transition");
|
|
var PropTypes = require("./PropTypes");
|
|
var Redirect = require("./Redirect");
|
|
var History = require("./History");
|
|
var Cancellation = require("./Cancellation");
|
|
var Match = require("./Match");
|
|
var Route = require("./Route");
|
|
var supportsHistory = require("./supportsHistory");
|
|
var PathUtils = require("./PathUtils");
|
|
|
|
/**
|
|
* The default location for new routers.
|
|
*/
|
|
var DEFAULT_LOCATION = canUseDOM ? HashLocation : "/";
|
|
|
|
/**
|
|
* The default scroll behavior for new routers.
|
|
*/
|
|
var DEFAULT_SCROLL_BEHAVIOR = canUseDOM ? ImitateBrowserBehavior : null;
|
|
|
|
function hasProperties(object, properties) {
|
|
for (var propertyName in properties) if (properties.hasOwnProperty(propertyName) && object[propertyName] !== properties[propertyName]) {
|
|
return false;
|
|
}return true;
|
|
}
|
|
|
|
function hasMatch(routes, route, prevParams, nextParams, prevQuery, nextQuery) {
|
|
return routes.some(function (r) {
|
|
if (r !== route) return false;
|
|
|
|
var paramNames = route.paramNames;
|
|
var paramName;
|
|
|
|
// Ensure that all params the route cares about did not change.
|
|
for (var i = 0, len = paramNames.length; i < len; ++i) {
|
|
paramName = paramNames[i];
|
|
|
|
if (nextParams[paramName] !== prevParams[paramName]) return false;
|
|
}
|
|
|
|
// Ensure the query hasn't changed.
|
|
return hasProperties(prevQuery, nextQuery) && hasProperties(nextQuery, prevQuery);
|
|
});
|
|
}
|
|
|
|
function addRoutesToNamedRoutes(routes, namedRoutes) {
|
|
var route;
|
|
for (var i = 0, len = routes.length; i < len; ++i) {
|
|
route = routes[i];
|
|
|
|
if (route.name) {
|
|
invariant(namedRoutes[route.name] == null, "You may not have more than one route named \"%s\"", route.name);
|
|
|
|
namedRoutes[route.name] = route;
|
|
}
|
|
|
|
if (route.childRoutes) addRoutesToNamedRoutes(route.childRoutes, namedRoutes);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates and returns a new router using the given options. A router
|
|
* is a ReactComponent class that knows how to react to changes in the
|
|
* URL and keep the contents of the page in sync.
|
|
*
|
|
* Options may be any of the following:
|
|
*
|
|
* - routes (required) The route config
|
|
* - location The location to use. Defaults to HashLocation when
|
|
* the DOM is available, "/" otherwise
|
|
* - scrollBehavior The scroll behavior to use. Defaults to ImitateBrowserBehavior
|
|
* when the DOM is available, null otherwise
|
|
* - onError A function that is used to handle errors
|
|
* - onAbort A function that is used to handle aborted transitions
|
|
*
|
|
* When rendering in a server-side environment, the location should simply
|
|
* be the URL path that was used in the request, including the query string.
|
|
*/
|
|
function createRouter(options) {
|
|
options = options || {};
|
|
|
|
if (isReactChildren(options)) options = { routes: options };
|
|
|
|
var mountedComponents = [];
|
|
var location = options.location || DEFAULT_LOCATION;
|
|
var scrollBehavior = options.scrollBehavior || DEFAULT_SCROLL_BEHAVIOR;
|
|
var state = {};
|
|
var nextState = {};
|
|
var pendingTransition = null;
|
|
var dispatchHandler = null;
|
|
|
|
if (typeof location === "string") location = new StaticLocation(location);
|
|
|
|
if (location instanceof StaticLocation) {
|
|
warning(!canUseDOM || process.env.NODE_ENV === "test", "You should not use a static location in a DOM environment because " + "the router will not be kept in sync with the current URL");
|
|
} else {
|
|
invariant(canUseDOM || location.needsDOM === false, "You cannot use %s without a DOM", location);
|
|
}
|
|
|
|
// Automatically fall back to full page refreshes in
|
|
// browsers that don't support the HTML history API.
|
|
if (location === HistoryLocation && !supportsHistory()) location = RefreshLocation;
|
|
|
|
var Router = React.createClass({
|
|
|
|
displayName: "Router",
|
|
|
|
statics: {
|
|
|
|
isRunning: false,
|
|
|
|
cancelPendingTransition: function cancelPendingTransition() {
|
|
if (pendingTransition) {
|
|
pendingTransition.cancel();
|
|
pendingTransition = null;
|
|
}
|
|
},
|
|
|
|
clearAllRoutes: function clearAllRoutes() {
|
|
this.cancelPendingTransition();
|
|
this.namedRoutes = {};
|
|
this.routes = [];
|
|
},
|
|
|
|
/**
|
|
* Adds routes to this router from the given children object (see ReactChildren).
|
|
*/
|
|
addRoutes: function addRoutes(routes) {
|
|
if (isReactChildren(routes)) routes = createRoutesFromReactChildren(routes);
|
|
|
|
addRoutesToNamedRoutes(routes, this.namedRoutes);
|
|
|
|
this.routes.push.apply(this.routes, routes);
|
|
},
|
|
|
|
/**
|
|
* Replaces routes of this router from the given children object (see ReactChildren).
|
|
*/
|
|
replaceRoutes: function replaceRoutes(routes) {
|
|
this.clearAllRoutes();
|
|
this.addRoutes(routes);
|
|
this.refresh();
|
|
},
|
|
|
|
/**
|
|
* Performs a match of the given path against this router and returns an object
|
|
* with the { routes, params, pathname, query } that match. Returns null if no
|
|
* match can be made.
|
|
*/
|
|
match: function match(path) {
|
|
return Match.findMatch(this.routes, path);
|
|
},
|
|
|
|
/**
|
|
* Returns an absolute URL path created from the given route
|
|
* name, URL parameters, and query.
|
|
*/
|
|
makePath: function makePath(to, params, query) {
|
|
var path;
|
|
if (PathUtils.isAbsolute(to)) {
|
|
path = to;
|
|
} else {
|
|
var route = to instanceof Route ? to : this.namedRoutes[to];
|
|
|
|
invariant(route instanceof Route, "Cannot find a route named \"%s\"", to);
|
|
|
|
path = route.path;
|
|
}
|
|
|
|
return PathUtils.withQuery(PathUtils.injectParams(path, params), query);
|
|
},
|
|
|
|
/**
|
|
* Returns a string that may safely be used as the href of a link
|
|
* to the route with the given name, URL parameters, and query.
|
|
*/
|
|
makeHref: function makeHref(to, params, query) {
|
|
var path = this.makePath(to, params, query);
|
|
return location === HashLocation ? "#" + path : path;
|
|
},
|
|
|
|
/**
|
|
* Transitions to the URL specified in the arguments by pushing
|
|
* a new URL onto the history stack.
|
|
*/
|
|
transitionTo: function transitionTo(to, params, query) {
|
|
var path = this.makePath(to, params, query);
|
|
|
|
if (pendingTransition) {
|
|
// Replace so pending location does not stay in history.
|
|
location.replace(path);
|
|
} else {
|
|
location.push(path);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Transitions to the URL specified in the arguments by replacing
|
|
* the current URL in the history stack.
|
|
*/
|
|
replaceWith: function replaceWith(to, params, query) {
|
|
location.replace(this.makePath(to, params, query));
|
|
},
|
|
|
|
/**
|
|
* Transitions to the previous URL if one is available. Returns true if the
|
|
* router was able to go back, false otherwise.
|
|
*
|
|
* Note: The router only tracks history entries in your application, not the
|
|
* current browser session, so you can safely call this function without guarding
|
|
* against sending the user back to some other site. However, when using
|
|
* RefreshLocation (which is the fallback for HistoryLocation in browsers that
|
|
* don't support HTML5 history) this method will *always* send the client back
|
|
* because we cannot reliably track history length.
|
|
*/
|
|
goBack: function goBack() {
|
|
if (History.length > 1 || location === RefreshLocation) {
|
|
location.pop();
|
|
return true;
|
|
}
|
|
|
|
warning(false, "goBack() was ignored because there is no router history");
|
|
|
|
return false;
|
|
},
|
|
|
|
handleAbort: options.onAbort || function (abortReason) {
|
|
if (location instanceof StaticLocation) throw new Error("Unhandled aborted transition! Reason: " + abortReason);
|
|
|
|
if (abortReason instanceof Cancellation) {
|
|
return;
|
|
} else if (abortReason instanceof Redirect) {
|
|
location.replace(this.makePath(abortReason.to, abortReason.params, abortReason.query));
|
|
} else {
|
|
location.pop();
|
|
}
|
|
},
|
|
|
|
handleError: options.onError || function (error) {
|
|
// Throw so we don't silently swallow async errors.
|
|
throw error; // This error probably originated in a transition hook.
|
|
},
|
|
|
|
handleLocationChange: function handleLocationChange(change) {
|
|
this.dispatch(change.path, change.type);
|
|
},
|
|
|
|
/**
|
|
* Performs a transition to the given path and calls callback(error, abortReason)
|
|
* when the transition is finished. If both arguments are null the router's state
|
|
* was updated. Otherwise the transition did not complete.
|
|
*
|
|
* In a transition, a router first determines which routes are involved by beginning
|
|
* with the current route, up the route tree to the first parent route that is shared
|
|
* with the destination route, and back down the tree to the destination route. The
|
|
* willTransitionFrom hook is invoked on all route handlers we're transitioning away
|
|
* from, in reverse nesting order. Likewise, the willTransitionTo hook is invoked on
|
|
* all route handlers we're transitioning to.
|
|
*
|
|
* Both willTransitionFrom and willTransitionTo hooks may either abort or redirect the
|
|
* transition. To resolve asynchronously, they may use the callback argument. If no
|
|
* hooks wait, the transition is fully synchronous.
|
|
*/
|
|
dispatch: function dispatch(path, action) {
|
|
this.cancelPendingTransition();
|
|
|
|
var prevPath = state.path;
|
|
var isRefreshing = action == null;
|
|
|
|
if (prevPath === path && !isRefreshing) {
|
|
return;
|
|
} // Nothing to do!
|
|
|
|
// Record the scroll position as early as possible to
|
|
// get it before browsers try update it automatically.
|
|
if (prevPath && action === LocationActions.PUSH) this.recordScrollPosition(prevPath);
|
|
|
|
var match = this.match(path);
|
|
|
|
warning(match != null, "No route matches path \"%s\". Make sure you have <Route path=\"%s\"> somewhere in your routes", path, path);
|
|
|
|
if (match == null) match = {};
|
|
|
|
var prevRoutes = state.routes || [];
|
|
var prevParams = state.params || {};
|
|
var prevQuery = state.query || {};
|
|
|
|
var nextRoutes = match.routes || [];
|
|
var nextParams = match.params || {};
|
|
var nextQuery = match.query || {};
|
|
|
|
var fromRoutes, toRoutes;
|
|
if (prevRoutes.length) {
|
|
fromRoutes = prevRoutes.filter(function (route) {
|
|
return !hasMatch(nextRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
|
});
|
|
|
|
toRoutes = nextRoutes.filter(function (route) {
|
|
return !hasMatch(prevRoutes, route, prevParams, nextParams, prevQuery, nextQuery);
|
|
});
|
|
} else {
|
|
fromRoutes = [];
|
|
toRoutes = nextRoutes;
|
|
}
|
|
|
|
var transition = new Transition(path, this.replaceWith.bind(this, path));
|
|
pendingTransition = transition;
|
|
|
|
var fromComponents = mountedComponents.slice(prevRoutes.length - fromRoutes.length);
|
|
|
|
Transition.from(transition, fromRoutes, fromComponents, function (error) {
|
|
if (error || transition.abortReason) return dispatchHandler.call(Router, error, transition); // No need to continue.
|
|
|
|
Transition.to(transition, toRoutes, nextParams, nextQuery, function (error) {
|
|
dispatchHandler.call(Router, error, transition, {
|
|
path: path,
|
|
action: action,
|
|
pathname: match.pathname,
|
|
routes: nextRoutes,
|
|
params: nextParams,
|
|
query: nextQuery
|
|
});
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Starts this router and calls callback(router, state) when the route changes.
|
|
*
|
|
* If the router's location is static (i.e. a URL path in a server environment)
|
|
* the callback is called only once. Otherwise, the location should be one of the
|
|
* Router.*Location objects (e.g. Router.HashLocation or Router.HistoryLocation).
|
|
*/
|
|
run: function run(callback) {
|
|
invariant(!this.isRunning, "Router is already running");
|
|
|
|
dispatchHandler = function (error, transition, newState) {
|
|
if (error) Router.handleError(error);
|
|
|
|
if (pendingTransition !== transition) return;
|
|
|
|
pendingTransition = null;
|
|
|
|
if (transition.abortReason) {
|
|
Router.handleAbort(transition.abortReason);
|
|
} else {
|
|
callback.call(this, this, nextState = newState);
|
|
}
|
|
};
|
|
|
|
if (!(location instanceof StaticLocation)) {
|
|
if (location.addChangeListener) location.addChangeListener(Router.handleLocationChange);
|
|
|
|
this.isRunning = true;
|
|
}
|
|
|
|
// Bootstrap using the current path.
|
|
this.refresh();
|
|
},
|
|
|
|
refresh: function refresh() {
|
|
Router.dispatch(location.getCurrentPath(), null);
|
|
},
|
|
|
|
stop: function stop() {
|
|
this.cancelPendingTransition();
|
|
|
|
if (location.removeChangeListener) location.removeChangeListener(Router.handleLocationChange);
|
|
|
|
this.isRunning = false;
|
|
},
|
|
|
|
getScrollBehavior: function getScrollBehavior() {
|
|
return scrollBehavior;
|
|
}
|
|
|
|
},
|
|
|
|
mixins: [NavigationContext, StateContext, ScrollHistory],
|
|
|
|
propTypes: {
|
|
children: PropTypes.falsy
|
|
},
|
|
|
|
childContextTypes: {
|
|
getRouteAtDepth: React.PropTypes.func.isRequired,
|
|
setRouteComponentAtDepth: React.PropTypes.func.isRequired,
|
|
routeHandlers: React.PropTypes.array.isRequired
|
|
},
|
|
|
|
getChildContext: function getChildContext() {
|
|
return {
|
|
getRouteAtDepth: this.getRouteAtDepth,
|
|
setRouteComponentAtDepth: this.setRouteComponentAtDepth,
|
|
routeHandlers: [this]
|
|
};
|
|
},
|
|
|
|
getInitialState: function getInitialState() {
|
|
return state = nextState;
|
|
},
|
|
|
|
componentWillReceiveProps: function componentWillReceiveProps() {
|
|
this.setState(state = nextState);
|
|
},
|
|
|
|
componentWillUnmount: function componentWillUnmount() {
|
|
Router.stop();
|
|
},
|
|
|
|
getLocation: function getLocation() {
|
|
return location;
|
|
},
|
|
|
|
getRouteAtDepth: function getRouteAtDepth(depth) {
|
|
var routes = this.state.routes;
|
|
return routes && routes[depth];
|
|
},
|
|
|
|
setRouteComponentAtDepth: function setRouteComponentAtDepth(depth, component) {
|
|
mountedComponents[depth] = component;
|
|
},
|
|
|
|
render: function render() {
|
|
var route = this.getRouteAtDepth(0);
|
|
return route ? React.createElement(route.handler, this.props) : null;
|
|
}
|
|
|
|
});
|
|
|
|
Router.clearAllRoutes();
|
|
|
|
if (options.routes) Router.addRoutes(options.routes);
|
|
|
|
return Router;
|
|
}
|
|
|
|
module.exports = createRouter;
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Cancellation":4,"./History":6,"./Match":7,"./NavigationContext":9,"./PathUtils":10,"./PropTypes":11,"./Redirect":12,"./Route":13,"./ScrollHistory":15,"./StateContext":17,"./Transition":18,"./actions/LocationActions":19,"./behaviors/ImitateBrowserBehavior":20,"./createRoutesFromReactChildren":29,"./isReactChildren":31,"./locations/HashLocation":32,"./locations/HistoryLocation":33,"./locations/RefreshLocation":34,"./locations/StaticLocation":35,"./supportsHistory":37,"_process":1,"react":"react","react/lib/ExecutionEnvironment":64,"react/lib/invariant":182,"react/lib/warning":202}],29:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
/* jshint -W084 */
|
|
|
|
var React = require("react");
|
|
var assign = require("react/lib/Object.assign");
|
|
var warning = require("react/lib/warning");
|
|
var DefaultRouteType = require("./components/DefaultRoute").type;
|
|
var NotFoundRouteType = require("./components/NotFoundRoute").type;
|
|
var RedirectType = require("./components/Redirect").type;
|
|
var Route = require("./Route");
|
|
|
|
function checkPropTypes(componentName, propTypes, props) {
|
|
componentName = componentName || "UnknownComponent";
|
|
|
|
for (var propName in propTypes) {
|
|
if (propTypes.hasOwnProperty(propName)) {
|
|
var error = propTypes[propName](props, propName, componentName);
|
|
|
|
if (error instanceof Error) warning(false, error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
function createRouteOptions(props) {
|
|
var options = assign({}, props);
|
|
var handler = options.handler;
|
|
|
|
if (handler) {
|
|
options.onEnter = handler.willTransitionTo;
|
|
options.onLeave = handler.willTransitionFrom;
|
|
}
|
|
|
|
return options;
|
|
}
|
|
|
|
function createRouteFromReactElement(element) {
|
|
if (!React.isValidElement(element)) {
|
|
return;
|
|
}var type = element.type;
|
|
var props = element.props;
|
|
|
|
if (type.propTypes) checkPropTypes(type.displayName, type.propTypes, props);
|
|
|
|
if (type === DefaultRouteType) {
|
|
return Route.createDefaultRoute(createRouteOptions(props));
|
|
}if (type === NotFoundRouteType) {
|
|
return Route.createNotFoundRoute(createRouteOptions(props));
|
|
}if (type === RedirectType) {
|
|
return Route.createRedirect(createRouteOptions(props));
|
|
}return Route.createRoute(createRouteOptions(props), function () {
|
|
if (props.children) createRoutesFromReactChildren(props.children);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Creates and returns an array of routes created from the given
|
|
* ReactChildren, all of which should be one of <Route>, <DefaultRoute>,
|
|
* <NotFoundRoute>, or <Redirect>, e.g.:
|
|
*
|
|
* var { createRoutesFromReactChildren, Route, Redirect } = require('react-router');
|
|
*
|
|
* var routes = createRoutesFromReactChildren(
|
|
* <Route path="/" handler={App}>
|
|
* <Route name="user" path="/user/:userId" handler={User}>
|
|
* <Route name="task" path="tasks/:taskId" handler={Task}/>
|
|
* <Redirect from="todos/:taskId" to="task"/>
|
|
* </Route>
|
|
* </Route>
|
|
* );
|
|
*/
|
|
function createRoutesFromReactChildren(children) {
|
|
var routes = [];
|
|
|
|
React.Children.forEach(children, function (child) {
|
|
if (child = createRouteFromReactElement(child)) routes.push(child);
|
|
});
|
|
|
|
return routes;
|
|
}
|
|
|
|
module.exports = createRoutesFromReactChildren;
|
|
},{"./Route":13,"./components/DefaultRoute":22,"./components/NotFoundRoute":24,"./components/Redirect":25,"react":"react","react/lib/Object.assign":70,"react/lib/warning":202}],30:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var invariant = require("react/lib/invariant");
|
|
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM;
|
|
|
|
/**
|
|
* Returns the current scroll position of the window as { x, y }.
|
|
*/
|
|
function getWindowScrollPosition() {
|
|
invariant(canUseDOM, "Cannot get current scroll position without a DOM");
|
|
|
|
return {
|
|
x: window.pageXOffset || document.documentElement.scrollLeft,
|
|
y: window.pageYOffset || document.documentElement.scrollTop
|
|
};
|
|
}
|
|
|
|
module.exports = getWindowScrollPosition;
|
|
},{"react/lib/ExecutionEnvironment":64,"react/lib/invariant":182}],31:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var React = require("react");
|
|
|
|
function isValidChild(object) {
|
|
return object == null || React.isValidElement(object);
|
|
}
|
|
|
|
function isReactChildren(object) {
|
|
return isValidChild(object) || Array.isArray(object) && object.every(isValidChild);
|
|
}
|
|
|
|
module.exports = isReactChildren;
|
|
},{"react":"react"}],32:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var LocationActions = require("../actions/LocationActions");
|
|
var History = require("../History");
|
|
|
|
/**
|
|
* Returns the current URL path from the `hash` portion of the URL, including
|
|
* query string.
|
|
*/
|
|
function getHashPath() {
|
|
return decodeURI(
|
|
// We can't use window.location.hash here because it's not
|
|
// consistent across browsers - Firefox will pre-decode it!
|
|
window.location.href.split("#")[1] || "");
|
|
}
|
|
|
|
var _actionType;
|
|
|
|
function ensureSlash() {
|
|
var path = getHashPath();
|
|
|
|
if (path.charAt(0) === "/") {
|
|
return true;
|
|
}HashLocation.replace("/" + path);
|
|
|
|
return false;
|
|
}
|
|
|
|
var _changeListeners = [];
|
|
|
|
function notifyChange(type) {
|
|
if (type === LocationActions.PUSH) History.length += 1;
|
|
|
|
var change = {
|
|
path: getHashPath(),
|
|
type: type
|
|
};
|
|
|
|
_changeListeners.forEach(function (listener) {
|
|
listener(change);
|
|
});
|
|
}
|
|
|
|
var _isListening = false;
|
|
|
|
function onHashChange() {
|
|
if (ensureSlash()) {
|
|
// If we don't have an _actionType then all we know is the hash
|
|
// changed. It was probably caused by the user clicking the Back
|
|
// button, but may have also been the Forward button or manual
|
|
// manipulation. So just guess 'pop'.
|
|
notifyChange(_actionType || LocationActions.POP);
|
|
_actionType = null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A Location that uses `window.location.hash`.
|
|
*/
|
|
var HashLocation = {
|
|
|
|
addChangeListener: function addChangeListener(listener) {
|
|
_changeListeners.push(listener);
|
|
|
|
// Do this BEFORE listening for hashchange.
|
|
ensureSlash();
|
|
|
|
if (!_isListening) {
|
|
if (window.addEventListener) {
|
|
window.addEventListener("hashchange", onHashChange, false);
|
|
} else {
|
|
window.attachEvent("onhashchange", onHashChange);
|
|
}
|
|
|
|
_isListening = true;
|
|
}
|
|
},
|
|
|
|
removeChangeListener: function removeChangeListener(listener) {
|
|
_changeListeners = _changeListeners.filter(function (l) {
|
|
return l !== listener;
|
|
});
|
|
|
|
if (_changeListeners.length === 0) {
|
|
if (window.removeEventListener) {
|
|
window.removeEventListener("hashchange", onHashChange, false);
|
|
} else {
|
|
window.removeEvent("onhashchange", onHashChange);
|
|
}
|
|
|
|
_isListening = false;
|
|
}
|
|
},
|
|
|
|
push: function push(path) {
|
|
_actionType = LocationActions.PUSH;
|
|
window.location.hash = path;
|
|
},
|
|
|
|
replace: function replace(path) {
|
|
_actionType = LocationActions.REPLACE;
|
|
window.location.replace(window.location.pathname + window.location.search + "#" + path);
|
|
},
|
|
|
|
pop: function pop() {
|
|
_actionType = LocationActions.POP;
|
|
History.back();
|
|
},
|
|
|
|
getCurrentPath: getHashPath,
|
|
|
|
toString: function toString() {
|
|
return "<HashLocation>";
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = HashLocation;
|
|
},{"../History":6,"../actions/LocationActions":19}],33:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var LocationActions = require("../actions/LocationActions");
|
|
var History = require("../History");
|
|
|
|
/**
|
|
* Returns the current URL path from `window.location`, including query string.
|
|
*/
|
|
function getWindowPath() {
|
|
return decodeURI(window.location.pathname + window.location.search);
|
|
}
|
|
|
|
var _changeListeners = [];
|
|
|
|
function notifyChange(type) {
|
|
var change = {
|
|
path: getWindowPath(),
|
|
type: type
|
|
};
|
|
|
|
_changeListeners.forEach(function (listener) {
|
|
listener(change);
|
|
});
|
|
}
|
|
|
|
var _isListening = false;
|
|
|
|
function onPopState(event) {
|
|
if (event.state === undefined) {
|
|
return;
|
|
} // Ignore extraneous popstate events in WebKit.
|
|
|
|
notifyChange(LocationActions.POP);
|
|
}
|
|
|
|
/**
|
|
* A Location that uses HTML5 history.
|
|
*/
|
|
var HistoryLocation = {
|
|
|
|
addChangeListener: function addChangeListener(listener) {
|
|
_changeListeners.push(listener);
|
|
|
|
if (!_isListening) {
|
|
if (window.addEventListener) {
|
|
window.addEventListener("popstate", onPopState, false);
|
|
} else {
|
|
window.attachEvent("onpopstate", onPopState);
|
|
}
|
|
|
|
_isListening = true;
|
|
}
|
|
},
|
|
|
|
removeChangeListener: function removeChangeListener(listener) {
|
|
_changeListeners = _changeListeners.filter(function (l) {
|
|
return l !== listener;
|
|
});
|
|
|
|
if (_changeListeners.length === 0) {
|
|
if (window.addEventListener) {
|
|
window.removeEventListener("popstate", onPopState, false);
|
|
} else {
|
|
window.removeEvent("onpopstate", onPopState);
|
|
}
|
|
|
|
_isListening = false;
|
|
}
|
|
},
|
|
|
|
push: function push(path) {
|
|
window.history.pushState({ path: path }, "", path);
|
|
History.length += 1;
|
|
notifyChange(LocationActions.PUSH);
|
|
},
|
|
|
|
replace: function replace(path) {
|
|
window.history.replaceState({ path: path }, "", path);
|
|
notifyChange(LocationActions.REPLACE);
|
|
},
|
|
|
|
pop: History.back,
|
|
|
|
getCurrentPath: getWindowPath,
|
|
|
|
toString: function toString() {
|
|
return "<HistoryLocation>";
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = HistoryLocation;
|
|
},{"../History":6,"../actions/LocationActions":19}],34:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var HistoryLocation = require("./HistoryLocation");
|
|
var History = require("../History");
|
|
|
|
/**
|
|
* A Location that uses full page refreshes. This is used as
|
|
* the fallback for HistoryLocation in browsers that do not
|
|
* support the HTML5 history API.
|
|
*/
|
|
var RefreshLocation = {
|
|
|
|
push: function push(path) {
|
|
window.location = path;
|
|
},
|
|
|
|
replace: function replace(path) {
|
|
window.location.replace(path);
|
|
},
|
|
|
|
pop: History.back,
|
|
|
|
getCurrentPath: HistoryLocation.getCurrentPath,
|
|
|
|
toString: function toString() {
|
|
return "<RefreshLocation>";
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = RefreshLocation;
|
|
},{"../History":6,"./HistoryLocation":33}],35:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
|
|
|
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
|
|
|
var invariant = require("react/lib/invariant");
|
|
|
|
function throwCannotModify() {
|
|
invariant(false, "You cannot modify a static location");
|
|
}
|
|
|
|
/**
|
|
* A location that only ever contains a single path. Useful in
|
|
* stateless environments like servers where there is no path history,
|
|
* only the path that was used in the request.
|
|
*/
|
|
|
|
var StaticLocation = (function () {
|
|
function StaticLocation(path) {
|
|
_classCallCheck(this, StaticLocation);
|
|
|
|
this.path = path;
|
|
}
|
|
|
|
_prototypeProperties(StaticLocation, null, {
|
|
getCurrentPath: {
|
|
value: function getCurrentPath() {
|
|
return this.path;
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
},
|
|
toString: {
|
|
value: function toString() {
|
|
return "<StaticLocation path=\"" + this.path + "\">";
|
|
},
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
});
|
|
|
|
return StaticLocation;
|
|
})();
|
|
|
|
// TODO: Include these in the above class definition
|
|
// once we can use ES7 property initializers.
|
|
StaticLocation.prototype.push = throwCannotModify;
|
|
StaticLocation.prototype.replace = throwCannotModify;
|
|
StaticLocation.prototype.pop = throwCannotModify;
|
|
|
|
module.exports = StaticLocation;
|
|
},{"react/lib/invariant":182}],36:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var createRouter = require("./createRouter");
|
|
|
|
/**
|
|
* A high-level convenience method that creates, configures, and
|
|
* runs a router in one shot. The method signature is:
|
|
*
|
|
* Router.run(routes[, location ], callback);
|
|
*
|
|
* Using `window.location.hash` to manage the URL, you could do:
|
|
*
|
|
* Router.run(routes, function (Handler) {
|
|
* React.render(<Handler/>, document.body);
|
|
* });
|
|
*
|
|
* Using HTML5 history and a custom "cursor" prop:
|
|
*
|
|
* Router.run(routes, Router.HistoryLocation, function (Handler) {
|
|
* React.render(<Handler cursor={cursor}/>, document.body);
|
|
* });
|
|
*
|
|
* Returns the newly created router.
|
|
*
|
|
* Note: If you need to specify further options for your router such
|
|
* as error/abort handling or custom scroll behavior, use Router.create
|
|
* instead.
|
|
*
|
|
* var router = Router.create(options);
|
|
* router.run(function (Handler) {
|
|
* // ...
|
|
* });
|
|
*/
|
|
function runRouter(routes, location, callback) {
|
|
if (typeof location === "function") {
|
|
callback = location;
|
|
location = null;
|
|
}
|
|
|
|
var router = createRouter({
|
|
routes: routes,
|
|
location: location
|
|
});
|
|
|
|
router.run(callback);
|
|
|
|
return router;
|
|
}
|
|
|
|
module.exports = runRouter;
|
|
},{"./createRouter":28}],37:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function supportsHistory() {
|
|
/*! taken from modernizr
|
|
* https://github.com/Modernizr/Modernizr/blob/master/LICENSE
|
|
* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
|
|
* changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586
|
|
*/
|
|
var ua = navigator.userAgent;
|
|
if ((ua.indexOf("Android 2.") !== -1 || ua.indexOf("Android 4.0") !== -1) && ua.indexOf("Mobile Safari") !== -1 && ua.indexOf("Chrome") === -1 && ua.indexOf("Windows Phone") === -1) {
|
|
return false;
|
|
}
|
|
return window.history && "pushState" in window.history;
|
|
}
|
|
|
|
module.exports = supportsHistory;
|
|
},{}],38:[function(require,module,exports){
|
|
module.exports = require('./lib/');
|
|
|
|
},{"./lib/":39}],39:[function(require,module,exports){
|
|
// Load modules
|
|
|
|
var Stringify = require('./stringify');
|
|
var Parse = require('./parse');
|
|
|
|
|
|
// Declare internals
|
|
|
|
var internals = {};
|
|
|
|
|
|
module.exports = {
|
|
stringify: Stringify,
|
|
parse: Parse
|
|
};
|
|
|
|
},{"./parse":40,"./stringify":41}],40:[function(require,module,exports){
|
|
// Load modules
|
|
|
|
var Utils = require('./utils');
|
|
|
|
|
|
// Declare internals
|
|
|
|
var internals = {
|
|
delimiter: '&',
|
|
depth: 5,
|
|
arrayLimit: 20,
|
|
parameterLimit: 1000
|
|
};
|
|
|
|
|
|
internals.parseValues = function (str, options) {
|
|
|
|
var obj = {};
|
|
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
|
|
|
|
for (var i = 0, il = parts.length; i < il; ++i) {
|
|
var part = parts[i];
|
|
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
|
|
|
if (pos === -1) {
|
|
obj[Utils.decode(part)] = '';
|
|
}
|
|
else {
|
|
var key = Utils.decode(part.slice(0, pos));
|
|
var val = Utils.decode(part.slice(pos + 1));
|
|
|
|
if (!obj.hasOwnProperty(key)) {
|
|
obj[key] = val;
|
|
}
|
|
else {
|
|
obj[key] = [].concat(obj[key]).concat(val);
|
|
}
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
|
|
internals.parseObject = function (chain, val, options) {
|
|
|
|
if (!chain.length) {
|
|
return val;
|
|
}
|
|
|
|
var root = chain.shift();
|
|
|
|
var obj = {};
|
|
if (root === '[]') {
|
|
obj = [];
|
|
obj = obj.concat(internals.parseObject(chain, val, options));
|
|
}
|
|
else {
|
|
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
|
|
var index = parseInt(cleanRoot, 10);
|
|
var indexString = '' + index;
|
|
if (!isNaN(index) &&
|
|
root !== cleanRoot &&
|
|
indexString === cleanRoot &&
|
|
index >= 0 &&
|
|
index <= options.arrayLimit) {
|
|
|
|
obj = [];
|
|
obj[index] = internals.parseObject(chain, val, options);
|
|
}
|
|
else {
|
|
obj[cleanRoot] = internals.parseObject(chain, val, options);
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
|
|
internals.parseKeys = function (key, val, options) {
|
|
|
|
if (!key) {
|
|
return;
|
|
}
|
|
|
|
// The regex chunks
|
|
|
|
var parent = /^([^\[\]]*)/;
|
|
var child = /(\[[^\[\]]*\])/g;
|
|
|
|
// Get the parent
|
|
|
|
var segment = parent.exec(key);
|
|
|
|
// Don't allow them to overwrite object prototype properties
|
|
|
|
if (Object.prototype.hasOwnProperty(segment[1])) {
|
|
return;
|
|
}
|
|
|
|
// Stash the parent if it exists
|
|
|
|
var keys = [];
|
|
if (segment[1]) {
|
|
keys.push(segment[1]);
|
|
}
|
|
|
|
// Loop through children appending to the array until we hit depth
|
|
|
|
var i = 0;
|
|
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
|
|
|
++i;
|
|
if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
|
|
keys.push(segment[1]);
|
|
}
|
|
}
|
|
|
|
// If there's a remainder, just add whatever is left
|
|
|
|
if (segment) {
|
|
keys.push('[' + key.slice(segment.index) + ']');
|
|
}
|
|
|
|
return internals.parseObject(keys, val, options);
|
|
};
|
|
|
|
|
|
module.exports = function (str, options) {
|
|
|
|
if (str === '' ||
|
|
str === null ||
|
|
typeof str === 'undefined') {
|
|
|
|
return {};
|
|
}
|
|
|
|
options = options || {};
|
|
options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
|
|
options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
|
|
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
|
|
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
|
|
|
|
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
|
|
var obj = {};
|
|
|
|
// Iterate over the keys and setup the new object
|
|
|
|
var keys = Object.keys(tempObj);
|
|
for (var i = 0, il = keys.length; i < il; ++i) {
|
|
var key = keys[i];
|
|
var newObj = internals.parseKeys(key, tempObj[key], options);
|
|
obj = Utils.merge(obj, newObj);
|
|
}
|
|
|
|
return Utils.compact(obj);
|
|
};
|
|
|
|
},{"./utils":42}],41:[function(require,module,exports){
|
|
// Load modules
|
|
|
|
var Utils = require('./utils');
|
|
|
|
|
|
// Declare internals
|
|
|
|
var internals = {
|
|
delimiter: '&',
|
|
indices: true
|
|
};
|
|
|
|
|
|
internals.stringify = function (obj, prefix, options) {
|
|
|
|
if (Utils.isBuffer(obj)) {
|
|
obj = obj.toString();
|
|
}
|
|
else if (obj instanceof Date) {
|
|
obj = obj.toISOString();
|
|
}
|
|
else if (obj === null) {
|
|
obj = '';
|
|
}
|
|
|
|
if (typeof obj === 'string' ||
|
|
typeof obj === 'number' ||
|
|
typeof obj === 'boolean') {
|
|
|
|
return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)];
|
|
}
|
|
|
|
var values = [];
|
|
|
|
if (typeof obj === 'undefined') {
|
|
return values;
|
|
}
|
|
|
|
var objKeys = Object.keys(obj);
|
|
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
|
var key = objKeys[i];
|
|
if (!options.indices &&
|
|
Array.isArray(obj)) {
|
|
|
|
values = values.concat(internals.stringify(obj[key], prefix, options));
|
|
}
|
|
else {
|
|
values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', options));
|
|
}
|
|
}
|
|
|
|
return values;
|
|
};
|
|
|
|
|
|
module.exports = function (obj, options) {
|
|
|
|
options = options || {};
|
|
var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
|
|
options.indices = typeof options.indices === 'boolean' ? options.indices : internals.indices;
|
|
|
|
var keys = [];
|
|
|
|
if (typeof obj !== 'object' ||
|
|
obj === null) {
|
|
|
|
return '';
|
|
}
|
|
|
|
var objKeys = Object.keys(obj);
|
|
for (var i = 0, il = objKeys.length; i < il; ++i) {
|
|
var key = objKeys[i];
|
|
keys = keys.concat(internals.stringify(obj[key], key, options));
|
|
}
|
|
|
|
return keys.join(delimiter);
|
|
};
|
|
|
|
},{"./utils":42}],42:[function(require,module,exports){
|
|
// Load modules
|
|
|
|
|
|
// Declare internals
|
|
|
|
var internals = {};
|
|
|
|
|
|
exports.arrayToObject = function (source) {
|
|
|
|
var obj = {};
|
|
for (var i = 0, il = source.length; i < il; ++i) {
|
|
if (typeof source[i] !== 'undefined') {
|
|
|
|
obj[i] = source[i];
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
|
|
exports.merge = function (target, source) {
|
|
|
|
if (!source) {
|
|
return target;
|
|
}
|
|
|
|
if (typeof source !== 'object') {
|
|
if (Array.isArray(target)) {
|
|
target.push(source);
|
|
}
|
|
else {
|
|
target[source] = true;
|
|
}
|
|
|
|
return target;
|
|
}
|
|
|
|
if (typeof target !== 'object') {
|
|
target = [target].concat(source);
|
|
return target;
|
|
}
|
|
|
|
if (Array.isArray(target) &&
|
|
!Array.isArray(source)) {
|
|
|
|
target = exports.arrayToObject(target);
|
|
}
|
|
|
|
var keys = Object.keys(source);
|
|
for (var k = 0, kl = keys.length; k < kl; ++k) {
|
|
var key = keys[k];
|
|
var value = source[key];
|
|
|
|
if (!target[key]) {
|
|
target[key] = value;
|
|
}
|
|
else {
|
|
target[key] = exports.merge(target[key], value);
|
|
}
|
|
}
|
|
|
|
return target;
|
|
};
|
|
|
|
|
|
exports.decode = function (str) {
|
|
|
|
try {
|
|
return decodeURIComponent(str.replace(/\+/g, ' '));
|
|
} catch (e) {
|
|
return str;
|
|
}
|
|
};
|
|
|
|
|
|
exports.compact = function (obj, refs) {
|
|
|
|
if (typeof obj !== 'object' ||
|
|
obj === null) {
|
|
|
|
return obj;
|
|
}
|
|
|
|
refs = refs || [];
|
|
var lookup = refs.indexOf(obj);
|
|
if (lookup !== -1) {
|
|
return refs[lookup];
|
|
}
|
|
|
|
refs.push(obj);
|
|
|
|
if (Array.isArray(obj)) {
|
|
var compacted = [];
|
|
|
|
for (var i = 0, il = obj.length; i < il; ++i) {
|
|
if (typeof obj[i] !== 'undefined') {
|
|
compacted.push(obj[i]);
|
|
}
|
|
}
|
|
|
|
return compacted;
|
|
}
|
|
|
|
var keys = Object.keys(obj);
|
|
for (i = 0, il = keys.length; i < il; ++i) {
|
|
var key = keys[i];
|
|
obj[key] = exports.compact(obj[key], refs);
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
|
|
exports.isRegExp = function (obj) {
|
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
};
|
|
|
|
|
|
exports.isBuffer = function (obj) {
|
|
|
|
if (obj === null ||
|
|
typeof obj === 'undefined') {
|
|
|
|
return false;
|
|
}
|
|
|
|
return !!(obj.constructor &&
|
|
obj.constructor.isBuffer &&
|
|
obj.constructor.isBuffer(obj));
|
|
};
|
|
|
|
},{}],43:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule AutoFocusMixin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var focusNode = require("./focusNode");
|
|
|
|
var AutoFocusMixin = {
|
|
componentDidMount: function() {
|
|
if (this.props.autoFocus) {
|
|
focusNode(this.getDOMNode());
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = AutoFocusMixin;
|
|
|
|
},{"./focusNode":167}],44:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013 Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule BeforeInputEventPlugin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
var SyntheticInputEvent = require("./SyntheticInputEvent");
|
|
|
|
var keyOf = require("./keyOf");
|
|
|
|
var canUseTextInputEvent = (
|
|
ExecutionEnvironment.canUseDOM &&
|
|
'TextEvent' in window &&
|
|
!('documentMode' in document || isPresto())
|
|
);
|
|
|
|
/**
|
|
* Opera <= 12 includes TextEvent in window, but does not fire
|
|
* text input events. Rely on keypress instead.
|
|
*/
|
|
function isPresto() {
|
|
var opera = window.opera;
|
|
return (
|
|
typeof opera === 'object' &&
|
|
typeof opera.version === 'function' &&
|
|
parseInt(opera.version(), 10) <= 12
|
|
);
|
|
}
|
|
|
|
var SPACEBAR_CODE = 32;
|
|
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
// Events and their corresponding property names.
|
|
var eventTypes = {
|
|
beforeInput: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onBeforeInput: null}),
|
|
captured: keyOf({onBeforeInputCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topCompositionEnd,
|
|
topLevelTypes.topKeyPress,
|
|
topLevelTypes.topTextInput,
|
|
topLevelTypes.topPaste
|
|
]
|
|
}
|
|
};
|
|
|
|
// Track characters inserted via keypress and composition events.
|
|
var fallbackChars = null;
|
|
|
|
// Track whether we've ever handled a keypress on the space key.
|
|
var hasSpaceKeypress = false;
|
|
|
|
/**
|
|
* Return whether a native keypress event is assumed to be a command.
|
|
* This is required because Firefox fires `keypress` events for key commands
|
|
* (cut, copy, select-all, etc.) even though no character is inserted.
|
|
*/
|
|
function isKeypressCommand(nativeEvent) {
|
|
return (
|
|
(nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
|
|
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
|
|
!(nativeEvent.ctrlKey && nativeEvent.altKey)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Create an `onBeforeInput` event to match
|
|
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
|
|
*
|
|
* This event plugin is based on the native `textInput` event
|
|
* available in Chrome, Safari, Opera, and IE. This event fires after
|
|
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
|
|
*
|
|
* `beforeInput` is spec'd but not implemented in any browsers, and
|
|
* the `input` event does not provide any useful information about what has
|
|
* actually been added, contrary to the spec. Thus, `textInput` is the best
|
|
* available event to identify the characters that have actually been inserted
|
|
* into the target node.
|
|
*/
|
|
var BeforeInputEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
|
|
var chars;
|
|
|
|
if (canUseTextInputEvent) {
|
|
switch (topLevelType) {
|
|
case topLevelTypes.topKeyPress:
|
|
/**
|
|
* If native `textInput` events are available, our goal is to make
|
|
* use of them. However, there is a special case: the spacebar key.
|
|
* In Webkit, preventing default on a spacebar `textInput` event
|
|
* cancels character insertion, but it *also* causes the browser
|
|
* to fall back to its default spacebar behavior of scrolling the
|
|
* page.
|
|
*
|
|
* Tracking at:
|
|
* https://code.google.com/p/chromium/issues/detail?id=355103
|
|
*
|
|
* To avoid this issue, use the keypress event as if no `textInput`
|
|
* event is available.
|
|
*/
|
|
var which = nativeEvent.which;
|
|
if (which !== SPACEBAR_CODE) {
|
|
return;
|
|
}
|
|
|
|
hasSpaceKeypress = true;
|
|
chars = SPACEBAR_CHAR;
|
|
break;
|
|
|
|
case topLevelTypes.topTextInput:
|
|
// Record the characters to be added to the DOM.
|
|
chars = nativeEvent.data;
|
|
|
|
// If it's a spacebar character, assume that we have already handled
|
|
// it at the keypress level and bail immediately. Android Chrome
|
|
// doesn't give us keycodes, so we need to blacklist it.
|
|
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
|
return;
|
|
}
|
|
|
|
// Otherwise, carry on.
|
|
break;
|
|
|
|
default:
|
|
// For other native event types, do nothing.
|
|
return;
|
|
}
|
|
} else {
|
|
switch (topLevelType) {
|
|
case topLevelTypes.topPaste:
|
|
// If a paste event occurs after a keypress, throw out the input
|
|
// chars. Paste events should not lead to BeforeInput events.
|
|
fallbackChars = null;
|
|
break;
|
|
case topLevelTypes.topKeyPress:
|
|
/**
|
|
* As of v27, Firefox may fire keypress events even when no character
|
|
* will be inserted. A few possibilities:
|
|
*
|
|
* - `which` is `0`. Arrow keys, Esc key, etc.
|
|
*
|
|
* - `which` is the pressed key code, but no char is available.
|
|
* Ex: 'AltGr + d` in Polish. There is no modified character for
|
|
* this key combination and no character is inserted into the
|
|
* document, but FF fires the keypress for char code `100` anyway.
|
|
* No `input` event will occur.
|
|
*
|
|
* - `which` is the pressed key code, but a command combination is
|
|
* being used. Ex: `Cmd+C`. No character is inserted, and no
|
|
* `input` event will occur.
|
|
*/
|
|
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
|
|
fallbackChars = String.fromCharCode(nativeEvent.which);
|
|
}
|
|
break;
|
|
case topLevelTypes.topCompositionEnd:
|
|
fallbackChars = nativeEvent.data;
|
|
break;
|
|
}
|
|
|
|
// If no changes have occurred to the fallback string, no relevant
|
|
// event has fired and we're done.
|
|
if (fallbackChars === null) {
|
|
return;
|
|
}
|
|
|
|
chars = fallbackChars;
|
|
}
|
|
|
|
// If no characters are being inserted, no BeforeInput event should
|
|
// be fired.
|
|
if (!chars) {
|
|
return;
|
|
}
|
|
|
|
var event = SyntheticInputEvent.getPooled(
|
|
eventTypes.beforeInput,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
|
|
event.data = chars;
|
|
fallbackChars = null;
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
return event;
|
|
}
|
|
};
|
|
|
|
module.exports = BeforeInputEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./EventPropagators":63,"./ExecutionEnvironment":64,"./SyntheticInputEvent":143,"./keyOf":189}],45:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule CSSCore
|
|
* @typechecks
|
|
*/
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* The CSSCore module specifies the API (and implements most of the methods)
|
|
* that should be used when dealing with the display of elements (via their
|
|
* CSS classes and visibility on screen. It is an API focused on mutating the
|
|
* display and not reading it as no logical state should be encoded in the
|
|
* display of elements.
|
|
*/
|
|
|
|
var CSSCore = {
|
|
|
|
/**
|
|
* Adds the class passed in to the element if it doesn't already have it.
|
|
*
|
|
* @param {DOMElement} element the element to set the class on
|
|
* @param {string} className the CSS className
|
|
* @return {DOMElement} the element passed in
|
|
*/
|
|
addClass: function(element, className) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!/\s/.test(className),
|
|
'CSSCore.addClass takes only a single class name. "%s" contains ' +
|
|
'multiple classes.', className
|
|
) : invariant(!/\s/.test(className)));
|
|
|
|
if (className) {
|
|
if (element.classList) {
|
|
element.classList.add(className);
|
|
} else if (!CSSCore.hasClass(element, className)) {
|
|
element.className = element.className + ' ' + className;
|
|
}
|
|
}
|
|
return element;
|
|
},
|
|
|
|
/**
|
|
* Removes the class passed in from the element
|
|
*
|
|
* @param {DOMElement} element the element to set the class on
|
|
* @param {string} className the CSS className
|
|
* @return {DOMElement} the element passed in
|
|
*/
|
|
removeClass: function(element, className) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!/\s/.test(className),
|
|
'CSSCore.removeClass takes only a single class name. "%s" contains ' +
|
|
'multiple classes.', className
|
|
) : invariant(!/\s/.test(className)));
|
|
|
|
if (className) {
|
|
if (element.classList) {
|
|
element.classList.remove(className);
|
|
} else if (CSSCore.hasClass(element, className)) {
|
|
element.className = element.className
|
|
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
|
|
.replace(/\s+/g, ' ') // multiple spaces to one
|
|
.replace(/^\s*|\s*$/g, ''); // trim the ends
|
|
}
|
|
}
|
|
return element;
|
|
},
|
|
|
|
/**
|
|
* Helper to add or remove a class from an element based on a condition.
|
|
*
|
|
* @param {DOMElement} element the element to set the class on
|
|
* @param {string} className the CSS className
|
|
* @param {*} bool condition to whether to add or remove the class
|
|
* @return {DOMElement} the element passed in
|
|
*/
|
|
conditionClass: function(element, className, bool) {
|
|
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
|
|
},
|
|
|
|
/**
|
|
* Tests whether the element has the class specified.
|
|
*
|
|
* @param {DOMNode|DOMWindow} element the element to set the class on
|
|
* @param {string} className the CSS className
|
|
* @return {boolean} true if the element has the class, false if not
|
|
*/
|
|
hasClass: function(element, className) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!/\s/.test(className),
|
|
'CSS.hasClass takes only a single class name.'
|
|
) : invariant(!/\s/.test(className)));
|
|
if (element.classList) {
|
|
return !!className && element.classList.contains(className);
|
|
}
|
|
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = CSSCore;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],46:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule CSSProperty
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* CSS properties which accept numbers but are not in units of "px".
|
|
*/
|
|
var isUnitlessNumber = {
|
|
columnCount: true,
|
|
flex: true,
|
|
flexGrow: true,
|
|
flexShrink: true,
|
|
fontWeight: true,
|
|
lineClamp: true,
|
|
lineHeight: true,
|
|
opacity: true,
|
|
order: true,
|
|
orphans: true,
|
|
widows: true,
|
|
zIndex: true,
|
|
zoom: true,
|
|
|
|
// SVG-related properties
|
|
fillOpacity: true,
|
|
strokeOpacity: true
|
|
};
|
|
|
|
/**
|
|
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
* @param {string} key style name, eg: transitionDuration
|
|
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
* WebkitTransitionDuration
|
|
*/
|
|
function prefixKey(prefix, key) {
|
|
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
}
|
|
|
|
/**
|
|
* Support style names that may come passed in prefixed by adding permutations
|
|
* of vendor prefixes.
|
|
*/
|
|
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
|
|
|
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
// infinite loop, because it iterates over the newly added props too.
|
|
Object.keys(isUnitlessNumber).forEach(function(prop) {
|
|
prefixes.forEach(function(prefix) {
|
|
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
});
|
|
});
|
|
|
|
/**
|
|
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
|
* doesn't like doing that with shorthand properties so for the properties that
|
|
* IE8 breaks on, which are listed here, we instead unset each of the
|
|
* individual properties. See http://bugs.jquery.com/ticket/12385.
|
|
* The 4-value 'clock' properties like margin, padding, border-width seem to
|
|
* behave without any problems. Curiously, list-style works too without any
|
|
* special prodding.
|
|
*/
|
|
var shorthandPropertyExpansions = {
|
|
background: {
|
|
backgroundImage: true,
|
|
backgroundPosition: true,
|
|
backgroundRepeat: true,
|
|
backgroundColor: true
|
|
},
|
|
border: {
|
|
borderWidth: true,
|
|
borderStyle: true,
|
|
borderColor: true
|
|
},
|
|
borderBottom: {
|
|
borderBottomWidth: true,
|
|
borderBottomStyle: true,
|
|
borderBottomColor: true
|
|
},
|
|
borderLeft: {
|
|
borderLeftWidth: true,
|
|
borderLeftStyle: true,
|
|
borderLeftColor: true
|
|
},
|
|
borderRight: {
|
|
borderRightWidth: true,
|
|
borderRightStyle: true,
|
|
borderRightColor: true
|
|
},
|
|
borderTop: {
|
|
borderTopWidth: true,
|
|
borderTopStyle: true,
|
|
borderTopColor: true
|
|
},
|
|
font: {
|
|
fontStyle: true,
|
|
fontVariant: true,
|
|
fontWeight: true,
|
|
fontSize: true,
|
|
lineHeight: true,
|
|
fontFamily: true
|
|
}
|
|
};
|
|
|
|
var CSSProperty = {
|
|
isUnitlessNumber: isUnitlessNumber,
|
|
shorthandPropertyExpansions: shorthandPropertyExpansions
|
|
};
|
|
|
|
module.exports = CSSProperty;
|
|
|
|
},{}],47:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule CSSPropertyOperations
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var CSSProperty = require("./CSSProperty");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var camelizeStyleName = require("./camelizeStyleName");
|
|
var dangerousStyleValue = require("./dangerousStyleValue");
|
|
var hyphenateStyleName = require("./hyphenateStyleName");
|
|
var memoizeStringOnly = require("./memoizeStringOnly");
|
|
var warning = require("./warning");
|
|
|
|
var processStyleName = memoizeStringOnly(function(styleName) {
|
|
return hyphenateStyleName(styleName);
|
|
});
|
|
|
|
var styleFloatAccessor = 'cssFloat';
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
// IE8 only supports accessing cssFloat (standard) as styleFloat
|
|
if (document.documentElement.style.cssFloat === undefined) {
|
|
styleFloatAccessor = 'styleFloat';
|
|
}
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var warnedStyleNames = {};
|
|
|
|
var warnHyphenatedStyleName = function(name) {
|
|
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
return;
|
|
}
|
|
|
|
warnedStyleNames[name] = true;
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'Unsupported style property ' + name + '. Did you mean ' +
|
|
camelizeStyleName(name) + '?'
|
|
) : null);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Operations for dealing with CSS properties.
|
|
*/
|
|
var CSSPropertyOperations = {
|
|
|
|
/**
|
|
* Serializes a mapping of style properties for use as inline styles:
|
|
*
|
|
* > createMarkupForStyles({width: '200px', height: 0})
|
|
* "width:200px;height:0;"
|
|
*
|
|
* Undefined values are ignored so that declarative programming is easier.
|
|
* The result should be HTML-escaped before insertion into the DOM.
|
|
*
|
|
* @param {object} styles
|
|
* @return {?string}
|
|
*/
|
|
createMarkupForStyles: function(styles) {
|
|
var serialized = '';
|
|
for (var styleName in styles) {
|
|
if (!styles.hasOwnProperty(styleName)) {
|
|
continue;
|
|
}
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (styleName.indexOf('-') > -1) {
|
|
warnHyphenatedStyleName(styleName);
|
|
}
|
|
}
|
|
var styleValue = styles[styleName];
|
|
if (styleValue != null) {
|
|
serialized += processStyleName(styleName) + ':';
|
|
serialized += dangerousStyleValue(styleName, styleValue) + ';';
|
|
}
|
|
}
|
|
return serialized || null;
|
|
},
|
|
|
|
/**
|
|
* Sets the value for multiple styles on a node. If a value is specified as
|
|
* '' (empty string), the corresponding style property will be unset.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @param {object} styles
|
|
*/
|
|
setValueForStyles: function(node, styles) {
|
|
var style = node.style;
|
|
for (var styleName in styles) {
|
|
if (!styles.hasOwnProperty(styleName)) {
|
|
continue;
|
|
}
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (styleName.indexOf('-') > -1) {
|
|
warnHyphenatedStyleName(styleName);
|
|
}
|
|
}
|
|
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
|
|
if (styleName === 'float') {
|
|
styleName = styleFloatAccessor;
|
|
}
|
|
if (styleValue) {
|
|
style[styleName] = styleValue;
|
|
} else {
|
|
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
|
|
if (expansion) {
|
|
// Shorthand property that IE8 won't like unsetting, so unset each
|
|
// component to placate it
|
|
for (var individualStyleName in expansion) {
|
|
style[individualStyleName] = '';
|
|
}
|
|
} else {
|
|
style[styleName] = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = CSSPropertyOperations;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./CSSProperty":46,"./ExecutionEnvironment":64,"./camelizeStyleName":154,"./dangerousStyleValue":161,"./hyphenateStyleName":180,"./memoizeStringOnly":191,"./warning":202,"_process":1}],48:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule CallbackQueue
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var PooledClass = require("./PooledClass");
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* A specialized pseudo-event module to help keep track of components waiting to
|
|
* be notified when their DOM representations are available for use.
|
|
*
|
|
* This implements `PooledClass`, so you should never need to instantiate this.
|
|
* Instead, use `CallbackQueue.getPooled()`.
|
|
*
|
|
* @class ReactMountReady
|
|
* @implements PooledClass
|
|
* @internal
|
|
*/
|
|
function CallbackQueue() {
|
|
this._callbacks = null;
|
|
this._contexts = null;
|
|
}
|
|
|
|
assign(CallbackQueue.prototype, {
|
|
|
|
/**
|
|
* Enqueues a callback to be invoked when `notifyAll` is invoked.
|
|
*
|
|
* @param {function} callback Invoked when `notifyAll` is invoked.
|
|
* @param {?object} context Context to call `callback` with.
|
|
* @internal
|
|
*/
|
|
enqueue: function(callback, context) {
|
|
this._callbacks = this._callbacks || [];
|
|
this._contexts = this._contexts || [];
|
|
this._callbacks.push(callback);
|
|
this._contexts.push(context);
|
|
},
|
|
|
|
/**
|
|
* Invokes all enqueued callbacks and clears the queue. This is invoked after
|
|
* the DOM representation of a component has been created or updated.
|
|
*
|
|
* @internal
|
|
*/
|
|
notifyAll: function() {
|
|
var callbacks = this._callbacks;
|
|
var contexts = this._contexts;
|
|
if (callbacks) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
callbacks.length === contexts.length,
|
|
"Mismatched list of contexts in callback queue"
|
|
) : invariant(callbacks.length === contexts.length));
|
|
this._callbacks = null;
|
|
this._contexts = null;
|
|
for (var i = 0, l = callbacks.length; i < l; i++) {
|
|
callbacks[i].call(contexts[i]);
|
|
}
|
|
callbacks.length = 0;
|
|
contexts.length = 0;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Resets the internal queue.
|
|
*
|
|
* @internal
|
|
*/
|
|
reset: function() {
|
|
this._callbacks = null;
|
|
this._contexts = null;
|
|
},
|
|
|
|
/**
|
|
* `PooledClass` looks for this.
|
|
*/
|
|
destructor: function() {
|
|
this.reset();
|
|
}
|
|
|
|
});
|
|
|
|
PooledClass.addPoolingTo(CallbackQueue);
|
|
|
|
module.exports = CallbackQueue;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./PooledClass":71,"./invariant":182,"_process":1}],49:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ChangeEventPlugin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
var isEventSupported = require("./isEventSupported");
|
|
var isTextInputElement = require("./isTextInputElement");
|
|
var keyOf = require("./keyOf");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
var eventTypes = {
|
|
change: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onChange: null}),
|
|
captured: keyOf({onChangeCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topBlur,
|
|
topLevelTypes.topChange,
|
|
topLevelTypes.topClick,
|
|
topLevelTypes.topFocus,
|
|
topLevelTypes.topInput,
|
|
topLevelTypes.topKeyDown,
|
|
topLevelTypes.topKeyUp,
|
|
topLevelTypes.topSelectionChange
|
|
]
|
|
}
|
|
};
|
|
|
|
/**
|
|
* For IE shims
|
|
*/
|
|
var activeElement = null;
|
|
var activeElementID = null;
|
|
var activeElementValue = null;
|
|
var activeElementValueProp = null;
|
|
|
|
/**
|
|
* SECTION: handle `change` event
|
|
*/
|
|
function shouldUseChangeEvent(elem) {
|
|
return (
|
|
elem.nodeName === 'SELECT' ||
|
|
(elem.nodeName === 'INPUT' && elem.type === 'file')
|
|
);
|
|
}
|
|
|
|
var doesChangeEventBubble = false;
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
// See `handleChange` comment below
|
|
doesChangeEventBubble = isEventSupported('change') && (
|
|
!('documentMode' in document) || document.documentMode > 8
|
|
);
|
|
}
|
|
|
|
function manualDispatchChangeEvent(nativeEvent) {
|
|
var event = SyntheticEvent.getPooled(
|
|
eventTypes.change,
|
|
activeElementID,
|
|
nativeEvent
|
|
);
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
|
|
// If change and propertychange bubbled, we'd just bind to it like all the
|
|
// other events and have it go through ReactBrowserEventEmitter. Since it
|
|
// doesn't, we manually listen for the events and so we have to enqueue and
|
|
// process the abstract event manually.
|
|
//
|
|
// Batching is necessary here in order to ensure that all event handlers run
|
|
// before the next rerender (including event handlers attached to ancestor
|
|
// elements instead of directly on the input). Without this, controlled
|
|
// components don't work properly in conjunction with event bubbling because
|
|
// the component is rerendered and the value reverted before all the event
|
|
// handlers can run. See https://github.com/facebook/react/issues/708.
|
|
ReactUpdates.batchedUpdates(runEventInBatch, event);
|
|
}
|
|
|
|
function runEventInBatch(event) {
|
|
EventPluginHub.enqueueEvents(event);
|
|
EventPluginHub.processEventQueue();
|
|
}
|
|
|
|
function startWatchingForChangeEventIE8(target, targetID) {
|
|
activeElement = target;
|
|
activeElementID = targetID;
|
|
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
|
|
}
|
|
|
|
function stopWatchingForChangeEventIE8() {
|
|
if (!activeElement) {
|
|
return;
|
|
}
|
|
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
|
|
activeElement = null;
|
|
activeElementID = null;
|
|
}
|
|
|
|
function getTargetIDForChangeEvent(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topChange) {
|
|
return topLevelTargetID;
|
|
}
|
|
}
|
|
function handleEventsForChangeEventIE8(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topFocus) {
|
|
// stopWatching() should be a noop here but we call it just in case we
|
|
// missed a blur event somehow.
|
|
stopWatchingForChangeEventIE8();
|
|
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
|
|
} else if (topLevelType === topLevelTypes.topBlur) {
|
|
stopWatchingForChangeEventIE8();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* SECTION: handle `input` event
|
|
*/
|
|
var isInputEventSupported = false;
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
// IE9 claims to support the input event but fails to trigger it when
|
|
// deleting text, so we ignore its input events
|
|
isInputEventSupported = isEventSupported('input') && (
|
|
!('documentMode' in document) || document.documentMode > 9
|
|
);
|
|
}
|
|
|
|
/**
|
|
* (For old IE.) Replacement getter/setter for the `value` property that gets
|
|
* set on the active element.
|
|
*/
|
|
var newValueProp = {
|
|
get: function() {
|
|
return activeElementValueProp.get.call(this);
|
|
},
|
|
set: function(val) {
|
|
// Cast to a string so we can do equality checks.
|
|
activeElementValue = '' + val;
|
|
activeElementValueProp.set.call(this, val);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* (For old IE.) Starts tracking propertychange events on the passed-in element
|
|
* and override the value property so that we can distinguish user events from
|
|
* value changes in JS.
|
|
*/
|
|
function startWatchingForValueChange(target, targetID) {
|
|
activeElement = target;
|
|
activeElementID = targetID;
|
|
activeElementValue = target.value;
|
|
activeElementValueProp = Object.getOwnPropertyDescriptor(
|
|
target.constructor.prototype,
|
|
'value'
|
|
);
|
|
|
|
Object.defineProperty(activeElement, 'value', newValueProp);
|
|
activeElement.attachEvent('onpropertychange', handlePropertyChange);
|
|
}
|
|
|
|
/**
|
|
* (For old IE.) Removes the event listeners from the currently-tracked element,
|
|
* if any exists.
|
|
*/
|
|
function stopWatchingForValueChange() {
|
|
if (!activeElement) {
|
|
return;
|
|
}
|
|
|
|
// delete restores the original property definition
|
|
delete activeElement.value;
|
|
activeElement.detachEvent('onpropertychange', handlePropertyChange);
|
|
|
|
activeElement = null;
|
|
activeElementID = null;
|
|
activeElementValue = null;
|
|
activeElementValueProp = null;
|
|
}
|
|
|
|
/**
|
|
* (For old IE.) Handles a propertychange event, sending a `change` event if
|
|
* the value of the active element has changed.
|
|
*/
|
|
function handlePropertyChange(nativeEvent) {
|
|
if (nativeEvent.propertyName !== 'value') {
|
|
return;
|
|
}
|
|
var value = nativeEvent.srcElement.value;
|
|
if (value === activeElementValue) {
|
|
return;
|
|
}
|
|
activeElementValue = value;
|
|
|
|
manualDispatchChangeEvent(nativeEvent);
|
|
}
|
|
|
|
/**
|
|
* If a `change` event should be fired, returns the target's ID.
|
|
*/
|
|
function getTargetIDForInputEvent(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topInput) {
|
|
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
|
|
// what we want so fall through here and trigger an abstract event
|
|
return topLevelTargetID;
|
|
}
|
|
}
|
|
|
|
// For IE8 and IE9.
|
|
function handleEventsForInputEventIE(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topFocus) {
|
|
// In IE8, we can capture almost all .value changes by adding a
|
|
// propertychange handler and looking for events with propertyName
|
|
// equal to 'value'
|
|
// In IE9, propertychange fires for most input events but is buggy and
|
|
// doesn't fire when text is deleted, but conveniently, selectionchange
|
|
// appears to fire in all of the remaining cases so we catch those and
|
|
// forward the event if the value has changed
|
|
// In either case, we don't want to call the event handler if the value
|
|
// is changed from JS so we redefine a setter for `.value` that updates
|
|
// our activeElementValue variable, allowing us to ignore those changes
|
|
//
|
|
// stopWatching() should be a noop here but we call it just in case we
|
|
// missed a blur event somehow.
|
|
stopWatchingForValueChange();
|
|
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
|
|
} else if (topLevelType === topLevelTypes.topBlur) {
|
|
stopWatchingForValueChange();
|
|
}
|
|
}
|
|
|
|
// For IE8 and IE9.
|
|
function getTargetIDForInputEventIE(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topSelectionChange ||
|
|
topLevelType === topLevelTypes.topKeyUp ||
|
|
topLevelType === topLevelTypes.topKeyDown) {
|
|
// On the selectionchange event, the target is just document which isn't
|
|
// helpful for us so just check activeElement instead.
|
|
//
|
|
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
|
|
// propertychange on the first input event after setting `value` from a
|
|
// script and fires only keydown, keypress, keyup. Catching keyup usually
|
|
// gets it and catching keydown lets us fire an event for the first
|
|
// keystroke if user does a key repeat (it'll be a little delayed: right
|
|
// before the second keystroke). Other input methods (e.g., paste) seem to
|
|
// fire selectionchange normally.
|
|
if (activeElement && activeElement.value !== activeElementValue) {
|
|
activeElementValue = activeElement.value;
|
|
return activeElementID;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* SECTION: handle `click` event
|
|
*/
|
|
function shouldUseClickEvent(elem) {
|
|
// Use the `click` event to detect changes to checkbox and radio inputs.
|
|
// This approach works across all browsers, whereas `change` does not fire
|
|
// until `blur` in IE8.
|
|
return (
|
|
elem.nodeName === 'INPUT' &&
|
|
(elem.type === 'checkbox' || elem.type === 'radio')
|
|
);
|
|
}
|
|
|
|
function getTargetIDForClickEvent(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID) {
|
|
if (topLevelType === topLevelTypes.topClick) {
|
|
return topLevelTargetID;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This plugin creates an `onChange` event that normalizes change events
|
|
* across form elements. This event fires at a time when it's possible to
|
|
* change the element's value without seeing a flicker.
|
|
*
|
|
* Supported elements are:
|
|
* - input (see `isTextInputElement`)
|
|
* - textarea
|
|
* - select
|
|
*/
|
|
var ChangeEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
|
|
var getTargetIDFunc, handleEventFunc;
|
|
if (shouldUseChangeEvent(topLevelTarget)) {
|
|
if (doesChangeEventBubble) {
|
|
getTargetIDFunc = getTargetIDForChangeEvent;
|
|
} else {
|
|
handleEventFunc = handleEventsForChangeEventIE8;
|
|
}
|
|
} else if (isTextInputElement(topLevelTarget)) {
|
|
if (isInputEventSupported) {
|
|
getTargetIDFunc = getTargetIDForInputEvent;
|
|
} else {
|
|
getTargetIDFunc = getTargetIDForInputEventIE;
|
|
handleEventFunc = handleEventsForInputEventIE;
|
|
}
|
|
} else if (shouldUseClickEvent(topLevelTarget)) {
|
|
getTargetIDFunc = getTargetIDForClickEvent;
|
|
}
|
|
|
|
if (getTargetIDFunc) {
|
|
var targetID = getTargetIDFunc(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID
|
|
);
|
|
if (targetID) {
|
|
var event = SyntheticEvent.getPooled(
|
|
eventTypes.change,
|
|
targetID,
|
|
nativeEvent
|
|
);
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
return event;
|
|
}
|
|
}
|
|
|
|
if (handleEventFunc) {
|
|
handleEventFunc(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID
|
|
);
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ChangeEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./EventPluginHub":60,"./EventPropagators":63,"./ExecutionEnvironment":64,"./ReactUpdates":132,"./SyntheticEvent":141,"./isEventSupported":183,"./isTextInputElement":185,"./keyOf":189}],50:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ClientReactRootIndex
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var nextReactRootIndex = 0;
|
|
|
|
var ClientReactRootIndex = {
|
|
createReactRootIndex: function() {
|
|
return nextReactRootIndex++;
|
|
}
|
|
};
|
|
|
|
module.exports = ClientReactRootIndex;
|
|
|
|
},{}],51:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule CompositionEventPlugin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
var ReactInputSelection = require("./ReactInputSelection");
|
|
var SyntheticCompositionEvent = require("./SyntheticCompositionEvent");
|
|
|
|
var getTextContentAccessor = require("./getTextContentAccessor");
|
|
var keyOf = require("./keyOf");
|
|
|
|
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
|
|
var START_KEYCODE = 229;
|
|
|
|
var useCompositionEvent = (
|
|
ExecutionEnvironment.canUseDOM &&
|
|
'CompositionEvent' in window
|
|
);
|
|
|
|
// In IE9+, we have access to composition events, but the data supplied
|
|
// by the native compositionend event may be incorrect. In Korean, for example,
|
|
// the compositionend event contains only one character regardless of
|
|
// how many characters have been composed since compositionstart.
|
|
// We therefore use the fallback data while still using the native
|
|
// events as triggers.
|
|
var useFallbackData = (
|
|
!useCompositionEvent ||
|
|
(
|
|
'documentMode' in document &&
|
|
document.documentMode > 8 &&
|
|
document.documentMode <= 11
|
|
)
|
|
);
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
var currentComposition = null;
|
|
|
|
// Events and their corresponding property names.
|
|
var eventTypes = {
|
|
compositionEnd: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onCompositionEnd: null}),
|
|
captured: keyOf({onCompositionEndCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topBlur,
|
|
topLevelTypes.topCompositionEnd,
|
|
topLevelTypes.topKeyDown,
|
|
topLevelTypes.topKeyPress,
|
|
topLevelTypes.topKeyUp,
|
|
topLevelTypes.topMouseDown
|
|
]
|
|
},
|
|
compositionStart: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onCompositionStart: null}),
|
|
captured: keyOf({onCompositionStartCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topBlur,
|
|
topLevelTypes.topCompositionStart,
|
|
topLevelTypes.topKeyDown,
|
|
topLevelTypes.topKeyPress,
|
|
topLevelTypes.topKeyUp,
|
|
topLevelTypes.topMouseDown
|
|
]
|
|
},
|
|
compositionUpdate: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onCompositionUpdate: null}),
|
|
captured: keyOf({onCompositionUpdateCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topBlur,
|
|
topLevelTypes.topCompositionUpdate,
|
|
topLevelTypes.topKeyDown,
|
|
topLevelTypes.topKeyPress,
|
|
topLevelTypes.topKeyUp,
|
|
topLevelTypes.topMouseDown
|
|
]
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Translate native top level events into event types.
|
|
*
|
|
* @param {string} topLevelType
|
|
* @return {object}
|
|
*/
|
|
function getCompositionEventType(topLevelType) {
|
|
switch (topLevelType) {
|
|
case topLevelTypes.topCompositionStart:
|
|
return eventTypes.compositionStart;
|
|
case topLevelTypes.topCompositionEnd:
|
|
return eventTypes.compositionEnd;
|
|
case topLevelTypes.topCompositionUpdate:
|
|
return eventTypes.compositionUpdate;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Does our fallback best-guess model think this event signifies that
|
|
* composition has begun?
|
|
*
|
|
* @param {string} topLevelType
|
|
* @param {object} nativeEvent
|
|
* @return {boolean}
|
|
*/
|
|
function isFallbackStart(topLevelType, nativeEvent) {
|
|
return (
|
|
topLevelType === topLevelTypes.topKeyDown &&
|
|
nativeEvent.keyCode === START_KEYCODE
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Does our fallback mode think that this event is the end of composition?
|
|
*
|
|
* @param {string} topLevelType
|
|
* @param {object} nativeEvent
|
|
* @return {boolean}
|
|
*/
|
|
function isFallbackEnd(topLevelType, nativeEvent) {
|
|
switch (topLevelType) {
|
|
case topLevelTypes.topKeyUp:
|
|
// Command keys insert or clear IME input.
|
|
return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
|
|
case topLevelTypes.topKeyDown:
|
|
// Expect IME keyCode on each keydown. If we get any other
|
|
// code we must have exited earlier.
|
|
return (nativeEvent.keyCode !== START_KEYCODE);
|
|
case topLevelTypes.topKeyPress:
|
|
case topLevelTypes.topMouseDown:
|
|
case topLevelTypes.topBlur:
|
|
// Events are not possible without cancelling IME.
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper class stores information about selection and document state
|
|
* so we can figure out what changed at a later date.
|
|
*
|
|
* @param {DOMEventTarget} root
|
|
*/
|
|
function FallbackCompositionState(root) {
|
|
this.root = root;
|
|
this.startSelection = ReactInputSelection.getSelection(root);
|
|
this.startValue = this.getText();
|
|
}
|
|
|
|
/**
|
|
* Get current text of input.
|
|
*
|
|
* @return {string}
|
|
*/
|
|
FallbackCompositionState.prototype.getText = function() {
|
|
return this.root.value || this.root[getTextContentAccessor()];
|
|
};
|
|
|
|
/**
|
|
* Text that has changed since the start of composition.
|
|
*
|
|
* @return {string}
|
|
*/
|
|
FallbackCompositionState.prototype.getData = function() {
|
|
var endValue = this.getText();
|
|
var prefixLength = this.startSelection.start;
|
|
var suffixLength = this.startValue.length - this.startSelection.end;
|
|
|
|
return endValue.substr(
|
|
prefixLength,
|
|
endValue.length - suffixLength - prefixLength
|
|
);
|
|
};
|
|
|
|
/**
|
|
* This plugin creates `onCompositionStart`, `onCompositionUpdate` and
|
|
* `onCompositionEnd` events on inputs, textareas and contentEditable
|
|
* nodes.
|
|
*/
|
|
var CompositionEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
|
|
var eventType;
|
|
var data;
|
|
|
|
if (useCompositionEvent) {
|
|
eventType = getCompositionEventType(topLevelType);
|
|
} else if (!currentComposition) {
|
|
if (isFallbackStart(topLevelType, nativeEvent)) {
|
|
eventType = eventTypes.compositionStart;
|
|
}
|
|
} else if (isFallbackEnd(topLevelType, nativeEvent)) {
|
|
eventType = eventTypes.compositionEnd;
|
|
}
|
|
|
|
if (useFallbackData) {
|
|
// The current composition is stored statically and must not be
|
|
// overwritten while composition continues.
|
|
if (!currentComposition && eventType === eventTypes.compositionStart) {
|
|
currentComposition = new FallbackCompositionState(topLevelTarget);
|
|
} else if (eventType === eventTypes.compositionEnd) {
|
|
if (currentComposition) {
|
|
data = currentComposition.getData();
|
|
currentComposition = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (eventType) {
|
|
var event = SyntheticCompositionEvent.getPooled(
|
|
eventType,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
if (data) {
|
|
// Inject data generated from fallback path into the synthetic event.
|
|
// This matches the property of native CompositionEventInterface.
|
|
event.data = data;
|
|
}
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
return event;
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = CompositionEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./EventPropagators":63,"./ExecutionEnvironment":64,"./ReactInputSelection":106,"./SyntheticCompositionEvent":139,"./getTextContentAccessor":177,"./keyOf":189}],52:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule DOMChildrenOperations
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var Danger = require("./Danger");
|
|
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
|
|
|
|
var getTextContentAccessor = require("./getTextContentAccessor");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* The DOM property to use when setting text content.
|
|
*
|
|
* @type {string}
|
|
* @private
|
|
*/
|
|
var textContentAccessor = getTextContentAccessor();
|
|
|
|
/**
|
|
* Inserts `childNode` as a child of `parentNode` at the `index`.
|
|
*
|
|
* @param {DOMElement} parentNode Parent node in which to insert.
|
|
* @param {DOMElement} childNode Child node to insert.
|
|
* @param {number} index Index at which to insert the child.
|
|
* @internal
|
|
*/
|
|
function insertChildAt(parentNode, childNode, index) {
|
|
// By exploiting arrays returning `undefined` for an undefined index, we can
|
|
// rely exclusively on `insertBefore(node, null)` instead of also using
|
|
// `appendChild(node)`. However, using `undefined` is not allowed by all
|
|
// browsers so we must replace it with `null`.
|
|
parentNode.insertBefore(
|
|
childNode,
|
|
parentNode.childNodes[index] || null
|
|
);
|
|
}
|
|
|
|
var updateTextContent;
|
|
if (textContentAccessor === 'textContent') {
|
|
/**
|
|
* Sets the text content of `node` to `text`.
|
|
*
|
|
* @param {DOMElement} node Node to change
|
|
* @param {string} text New text content
|
|
*/
|
|
updateTextContent = function(node, text) {
|
|
node.textContent = text;
|
|
};
|
|
} else {
|
|
/**
|
|
* Sets the text content of `node` to `text`.
|
|
*
|
|
* @param {DOMElement} node Node to change
|
|
* @param {string} text New text content
|
|
*/
|
|
updateTextContent = function(node, text) {
|
|
// In order to preserve newlines correctly, we can't use .innerText to set
|
|
// the contents (see #1080), so we empty the element then append a text node
|
|
while (node.firstChild) {
|
|
node.removeChild(node.firstChild);
|
|
}
|
|
if (text) {
|
|
var doc = node.ownerDocument || document;
|
|
node.appendChild(doc.createTextNode(text));
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Operations for updating with DOM children.
|
|
*/
|
|
var DOMChildrenOperations = {
|
|
|
|
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
|
|
|
updateTextContent: updateTextContent,
|
|
|
|
/**
|
|
* Updates a component's children by processing a series of updates. The
|
|
* update configurations are each expected to have a `parentNode` property.
|
|
*
|
|
* @param {array<object>} updates List of update configurations.
|
|
* @param {array<string>} markupList List of markup strings.
|
|
* @internal
|
|
*/
|
|
processUpdates: function(updates, markupList) {
|
|
var update;
|
|
// Mapping from parent IDs to initial child orderings.
|
|
var initialChildren = null;
|
|
// List of children that will be moved or removed.
|
|
var updatedChildren = null;
|
|
|
|
for (var i = 0; update = updates[i]; i++) {
|
|
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
|
|
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
|
var updatedIndex = update.fromIndex;
|
|
var updatedChild = update.parentNode.childNodes[updatedIndex];
|
|
var parentID = update.parentID;
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
updatedChild,
|
|
'processUpdates(): Unable to find child %s of element. This ' +
|
|
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
|
|
'browser), usually due to forgetting a <tbody> when using tables, ' +
|
|
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements '+
|
|
'in an <svg> parent. Try inspecting the child nodes of the element ' +
|
|
'with React ID `%s`.',
|
|
updatedIndex,
|
|
parentID
|
|
) : invariant(updatedChild));
|
|
|
|
initialChildren = initialChildren || {};
|
|
initialChildren[parentID] = initialChildren[parentID] || [];
|
|
initialChildren[parentID][updatedIndex] = updatedChild;
|
|
|
|
updatedChildren = updatedChildren || [];
|
|
updatedChildren.push(updatedChild);
|
|
}
|
|
}
|
|
|
|
var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
|
|
|
|
// Remove updated children first so that `toIndex` is consistent.
|
|
if (updatedChildren) {
|
|
for (var j = 0; j < updatedChildren.length; j++) {
|
|
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
|
|
}
|
|
}
|
|
|
|
for (var k = 0; update = updates[k]; k++) {
|
|
switch (update.type) {
|
|
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
|
insertChildAt(
|
|
update.parentNode,
|
|
renderedMarkup[update.markupIndex],
|
|
update.toIndex
|
|
);
|
|
break;
|
|
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
|
insertChildAt(
|
|
update.parentNode,
|
|
initialChildren[update.parentID][update.fromIndex],
|
|
update.toIndex
|
|
);
|
|
break;
|
|
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
|
updateTextContent(
|
|
update.parentNode,
|
|
update.textContent
|
|
);
|
|
break;
|
|
case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
|
// Already removed by the for-loop above.
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = DOMChildrenOperations;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Danger":55,"./ReactMultiChildUpdateTypes":113,"./getTextContentAccessor":177,"./invariant":182,"_process":1}],53:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule DOMProperty
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
/*jslint bitwise: true */
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
function checkMask(value, bitmask) {
|
|
return (value & bitmask) === bitmask;
|
|
}
|
|
|
|
var DOMPropertyInjection = {
|
|
/**
|
|
* Mapping from normalized, camelcased property names to a configuration that
|
|
* specifies how the associated DOM property should be accessed or rendered.
|
|
*/
|
|
MUST_USE_ATTRIBUTE: 0x1,
|
|
MUST_USE_PROPERTY: 0x2,
|
|
HAS_SIDE_EFFECTS: 0x4,
|
|
HAS_BOOLEAN_VALUE: 0x8,
|
|
HAS_NUMERIC_VALUE: 0x10,
|
|
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
|
|
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
|
|
|
|
/**
|
|
* Inject some specialized knowledge about the DOM. This takes a config object
|
|
* with the following properties:
|
|
*
|
|
* isCustomAttribute: function that given an attribute name will return true
|
|
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
|
|
* attributes where it's impossible to enumerate all of the possible
|
|
* attribute names,
|
|
*
|
|
* Properties: object mapping DOM property name to one of the
|
|
* DOMPropertyInjection constants or null. If your attribute isn't in here,
|
|
* it won't get written to the DOM.
|
|
*
|
|
* DOMAttributeNames: object mapping React attribute name to the DOM
|
|
* attribute name. Attribute names not specified use the **lowercase**
|
|
* normalized name.
|
|
*
|
|
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
|
|
* Property names not specified use the normalized name.
|
|
*
|
|
* DOMMutationMethods: Properties that require special mutation methods. If
|
|
* `value` is undefined, the mutation method should unset the property.
|
|
*
|
|
* @param {object} domPropertyConfig the config as described above.
|
|
*/
|
|
injectDOMPropertyConfig: function(domPropertyConfig) {
|
|
var Properties = domPropertyConfig.Properties || {};
|
|
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
|
|
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
|
|
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
|
|
|
|
if (domPropertyConfig.isCustomAttribute) {
|
|
DOMProperty._isCustomAttributeFunctions.push(
|
|
domPropertyConfig.isCustomAttribute
|
|
);
|
|
}
|
|
|
|
for (var propName in Properties) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!DOMProperty.isStandardName.hasOwnProperty(propName),
|
|
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
|
|
'\'%s\' which has already been injected. You may be accidentally ' +
|
|
'injecting the same DOM property config twice, or you may be ' +
|
|
'injecting two configs that have conflicting property names.',
|
|
propName
|
|
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
|
|
|
|
DOMProperty.isStandardName[propName] = true;
|
|
|
|
var lowerCased = propName.toLowerCase();
|
|
DOMProperty.getPossibleStandardName[lowerCased] = propName;
|
|
|
|
if (DOMAttributeNames.hasOwnProperty(propName)) {
|
|
var attributeName = DOMAttributeNames[propName];
|
|
DOMProperty.getPossibleStandardName[attributeName] = propName;
|
|
DOMProperty.getAttributeName[propName] = attributeName;
|
|
} else {
|
|
DOMProperty.getAttributeName[propName] = lowerCased;
|
|
}
|
|
|
|
DOMProperty.getPropertyName[propName] =
|
|
DOMPropertyNames.hasOwnProperty(propName) ?
|
|
DOMPropertyNames[propName] :
|
|
propName;
|
|
|
|
if (DOMMutationMethods.hasOwnProperty(propName)) {
|
|
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
|
|
} else {
|
|
DOMProperty.getMutationMethod[propName] = null;
|
|
}
|
|
|
|
var propConfig = Properties[propName];
|
|
DOMProperty.mustUseAttribute[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
|
|
DOMProperty.mustUseProperty[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
|
|
DOMProperty.hasSideEffects[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
|
|
DOMProperty.hasBooleanValue[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
|
|
DOMProperty.hasNumericValue[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
|
|
DOMProperty.hasPositiveNumericValue[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
|
|
DOMProperty.hasOverloadedBooleanValue[propName] =
|
|
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!DOMProperty.mustUseAttribute[propName] ||
|
|
!DOMProperty.mustUseProperty[propName],
|
|
'DOMProperty: Cannot require using both attribute and property: %s',
|
|
propName
|
|
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
|
|
!DOMProperty.mustUseProperty[propName]));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
DOMProperty.mustUseProperty[propName] ||
|
|
!DOMProperty.hasSideEffects[propName],
|
|
'DOMProperty: Properties that have side effects must use property: %s',
|
|
propName
|
|
) : invariant(DOMProperty.mustUseProperty[propName] ||
|
|
!DOMProperty.hasSideEffects[propName]));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!!DOMProperty.hasBooleanValue[propName] +
|
|
!!DOMProperty.hasNumericValue[propName] +
|
|
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
|
|
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
|
|
'numeric value, but not a combination: %s',
|
|
propName
|
|
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
|
|
!!DOMProperty.hasNumericValue[propName] +
|
|
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
|
|
}
|
|
}
|
|
};
|
|
var defaultValueCache = {};
|
|
|
|
/**
|
|
* DOMProperty exports lookup objects that can be used like functions:
|
|
*
|
|
* > DOMProperty.isValid['id']
|
|
* true
|
|
* > DOMProperty.isValid['foobar']
|
|
* undefined
|
|
*
|
|
* Although this may be confusing, it performs better in general.
|
|
*
|
|
* @see http://jsperf.com/key-exists
|
|
* @see http://jsperf.com/key-missing
|
|
*/
|
|
var DOMProperty = {
|
|
|
|
ID_ATTRIBUTE_NAME: 'data-reactid',
|
|
|
|
/**
|
|
* Checks whether a property name is a standard property.
|
|
* @type {Object}
|
|
*/
|
|
isStandardName: {},
|
|
|
|
/**
|
|
* Mapping from lowercase property names to the properly cased version, used
|
|
* to warn in the case of missing properties.
|
|
* @type {Object}
|
|
*/
|
|
getPossibleStandardName: {},
|
|
|
|
/**
|
|
* Mapping from normalized names to attribute names that differ. Attribute
|
|
* names are used when rendering markup or with `*Attribute()`.
|
|
* @type {Object}
|
|
*/
|
|
getAttributeName: {},
|
|
|
|
/**
|
|
* Mapping from normalized names to properties on DOM node instances.
|
|
* (This includes properties that mutate due to external factors.)
|
|
* @type {Object}
|
|
*/
|
|
getPropertyName: {},
|
|
|
|
/**
|
|
* Mapping from normalized names to mutation methods. This will only exist if
|
|
* mutation cannot be set simply by the property or `setAttribute()`.
|
|
* @type {Object}
|
|
*/
|
|
getMutationMethod: {},
|
|
|
|
/**
|
|
* Whether the property must be accessed and mutated as an object property.
|
|
* @type {Object}
|
|
*/
|
|
mustUseAttribute: {},
|
|
|
|
/**
|
|
* Whether the property must be accessed and mutated using `*Attribute()`.
|
|
* (This includes anything that fails `<propName> in <element>`.)
|
|
* @type {Object}
|
|
*/
|
|
mustUseProperty: {},
|
|
|
|
/**
|
|
* Whether or not setting a value causes side effects such as triggering
|
|
* resources to be loaded or text selection changes. We must ensure that
|
|
* the value is only set if it has changed.
|
|
* @type {Object}
|
|
*/
|
|
hasSideEffects: {},
|
|
|
|
/**
|
|
* Whether the property should be removed when set to a falsey value.
|
|
* @type {Object}
|
|
*/
|
|
hasBooleanValue: {},
|
|
|
|
/**
|
|
* Whether the property must be numeric or parse as a
|
|
* numeric and should be removed when set to a falsey value.
|
|
* @type {Object}
|
|
*/
|
|
hasNumericValue: {},
|
|
|
|
/**
|
|
* Whether the property must be positive numeric or parse as a positive
|
|
* numeric and should be removed when set to a falsey value.
|
|
* @type {Object}
|
|
*/
|
|
hasPositiveNumericValue: {},
|
|
|
|
/**
|
|
* Whether the property can be used as a flag as well as with a value. Removed
|
|
* when strictly equal to false; present without a value when strictly equal
|
|
* to true; present with a value otherwise.
|
|
* @type {Object}
|
|
*/
|
|
hasOverloadedBooleanValue: {},
|
|
|
|
/**
|
|
* All of the isCustomAttribute() functions that have been injected.
|
|
*/
|
|
_isCustomAttributeFunctions: [],
|
|
|
|
/**
|
|
* Checks whether a property name is a custom attribute.
|
|
* @method
|
|
*/
|
|
isCustomAttribute: function(attributeName) {
|
|
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
|
|
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
|
|
if (isCustomAttributeFn(attributeName)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
|
|
/**
|
|
* Returns the default property value for a DOM property (i.e., not an
|
|
* attribute). Most default values are '' or false, but not all. Worse yet,
|
|
* some (in particular, `type`) vary depending on the type of element.
|
|
*
|
|
* TODO: Is it better to grab all the possible properties when creating an
|
|
* element to avoid having to create the same element twice?
|
|
*/
|
|
getDefaultValueForProperty: function(nodeName, prop) {
|
|
var nodeDefaults = defaultValueCache[nodeName];
|
|
var testElement;
|
|
if (!nodeDefaults) {
|
|
defaultValueCache[nodeName] = nodeDefaults = {};
|
|
}
|
|
if (!(prop in nodeDefaults)) {
|
|
testElement = document.createElement(nodeName);
|
|
nodeDefaults[prop] = testElement[prop];
|
|
}
|
|
return nodeDefaults[prop];
|
|
},
|
|
|
|
injection: DOMPropertyInjection
|
|
};
|
|
|
|
module.exports = DOMProperty;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],54:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule DOMPropertyOperations
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
|
|
var escapeTextForBrowser = require("./escapeTextForBrowser");
|
|
var memoizeStringOnly = require("./memoizeStringOnly");
|
|
var warning = require("./warning");
|
|
|
|
function shouldIgnoreValue(name, value) {
|
|
return value == null ||
|
|
(DOMProperty.hasBooleanValue[name] && !value) ||
|
|
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
|
|
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
|
|
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
|
|
}
|
|
|
|
var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
|
|
return escapeTextForBrowser(name) + '="';
|
|
});
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var reactProps = {
|
|
children: true,
|
|
dangerouslySetInnerHTML: true,
|
|
key: true,
|
|
ref: true
|
|
};
|
|
var warnedProperties = {};
|
|
|
|
var warnUnknownProperty = function(name) {
|
|
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
|
|
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
return;
|
|
}
|
|
|
|
warnedProperties[name] = true;
|
|
var lowerCasedName = name.toLowerCase();
|
|
|
|
// data-* attributes should be lowercase; suggest the lowercase version
|
|
var standardName = (
|
|
DOMProperty.isCustomAttribute(lowerCasedName) ?
|
|
lowerCasedName :
|
|
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
|
|
DOMProperty.getPossibleStandardName[lowerCasedName] :
|
|
null
|
|
);
|
|
|
|
// For now, only warn when we have a suggested correction. This prevents
|
|
// logging too much when using transferPropsTo.
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
standardName == null,
|
|
'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
|
|
) : null);
|
|
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Operations for dealing with DOM properties.
|
|
*/
|
|
var DOMPropertyOperations = {
|
|
|
|
/**
|
|
* Creates markup for the ID property.
|
|
*
|
|
* @param {string} id Unescaped ID.
|
|
* @return {string} Markup string.
|
|
*/
|
|
createMarkupForID: function(id) {
|
|
return processAttributeNameAndPrefix(DOMProperty.ID_ATTRIBUTE_NAME) +
|
|
escapeTextForBrowser(id) + '"';
|
|
},
|
|
|
|
/**
|
|
* Creates markup for a property.
|
|
*
|
|
* @param {string} name
|
|
* @param {*} value
|
|
* @return {?string} Markup string, or null if the property was invalid.
|
|
*/
|
|
createMarkupForProperty: function(name, value) {
|
|
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
DOMProperty.isStandardName[name]) {
|
|
if (shouldIgnoreValue(name, value)) {
|
|
return '';
|
|
}
|
|
var attributeName = DOMProperty.getAttributeName[name];
|
|
if (DOMProperty.hasBooleanValue[name] ||
|
|
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
|
|
return escapeTextForBrowser(attributeName);
|
|
}
|
|
return processAttributeNameAndPrefix(attributeName) +
|
|
escapeTextForBrowser(value) + '"';
|
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
if (value == null) {
|
|
return '';
|
|
}
|
|
return processAttributeNameAndPrefix(name) +
|
|
escapeTextForBrowser(value) + '"';
|
|
} else if ("production" !== process.env.NODE_ENV) {
|
|
warnUnknownProperty(name);
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/**
|
|
* Sets the value for a property on a node.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @param {string} name
|
|
* @param {*} value
|
|
*/
|
|
setValueForProperty: function(node, name, value) {
|
|
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
DOMProperty.isStandardName[name]) {
|
|
var mutationMethod = DOMProperty.getMutationMethod[name];
|
|
if (mutationMethod) {
|
|
mutationMethod(node, value);
|
|
} else if (shouldIgnoreValue(name, value)) {
|
|
this.deleteValueForProperty(node, name);
|
|
} else if (DOMProperty.mustUseAttribute[name]) {
|
|
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
|
// ('' + value) makes it output the correct toString()-value.
|
|
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
|
|
} else {
|
|
var propName = DOMProperty.getPropertyName[name];
|
|
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
|
// property type before comparing; only `value` does and is string.
|
|
if (!DOMProperty.hasSideEffects[name] ||
|
|
('' + node[propName]) !== ('' + value)) {
|
|
// Contrary to `setAttribute`, object properties are properly
|
|
// `toString`ed by IE8/9.
|
|
node[propName] = value;
|
|
}
|
|
}
|
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
if (value == null) {
|
|
node.removeAttribute(name);
|
|
} else {
|
|
node.setAttribute(name, '' + value);
|
|
}
|
|
} else if ("production" !== process.env.NODE_ENV) {
|
|
warnUnknownProperty(name);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Deletes the value for a property on a node.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @param {string} name
|
|
*/
|
|
deleteValueForProperty: function(node, name) {
|
|
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
DOMProperty.isStandardName[name]) {
|
|
var mutationMethod = DOMProperty.getMutationMethod[name];
|
|
if (mutationMethod) {
|
|
mutationMethod(node, undefined);
|
|
} else if (DOMProperty.mustUseAttribute[name]) {
|
|
node.removeAttribute(DOMProperty.getAttributeName[name]);
|
|
} else {
|
|
var propName = DOMProperty.getPropertyName[name];
|
|
var defaultValue = DOMProperty.getDefaultValueForProperty(
|
|
node.nodeName,
|
|
propName
|
|
);
|
|
if (!DOMProperty.hasSideEffects[name] ||
|
|
('' + node[propName]) !== defaultValue) {
|
|
node[propName] = defaultValue;
|
|
}
|
|
}
|
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
node.removeAttribute(name);
|
|
} else if ("production" !== process.env.NODE_ENV) {
|
|
warnUnknownProperty(name);
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = DOMPropertyOperations;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./DOMProperty":53,"./escapeTextForBrowser":165,"./memoizeStringOnly":191,"./warning":202,"_process":1}],55:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule Danger
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
/*jslint evil: true, sub: true */
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var createNodesFromMarkup = require("./createNodesFromMarkup");
|
|
var emptyFunction = require("./emptyFunction");
|
|
var getMarkupWrap = require("./getMarkupWrap");
|
|
var invariant = require("./invariant");
|
|
|
|
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
|
|
var RESULT_INDEX_ATTR = 'data-danger-index';
|
|
|
|
/**
|
|
* Extracts the `nodeName` from a string of markup.
|
|
*
|
|
* NOTE: Extracting the `nodeName` does not require a regular expression match
|
|
* because we make assumptions about React-generated markup (i.e. there are no
|
|
* spaces surrounding the opening tag and there is at least one attribute).
|
|
*
|
|
* @param {string} markup String of markup.
|
|
* @return {string} Node name of the supplied markup.
|
|
* @see http://jsperf.com/extract-nodename
|
|
*/
|
|
function getNodeName(markup) {
|
|
return markup.substring(1, markup.indexOf(' '));
|
|
}
|
|
|
|
var Danger = {
|
|
|
|
/**
|
|
* Renders markup into an array of nodes. The markup is expected to render
|
|
* into a list of root nodes. Also, the length of `resultList` and
|
|
* `markupList` should be the same.
|
|
*
|
|
* @param {array<string>} markupList List of markup strings to render.
|
|
* @return {array<DOMElement>} List of rendered nodes.
|
|
* @internal
|
|
*/
|
|
dangerouslyRenderMarkup: function(markupList) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ExecutionEnvironment.canUseDOM,
|
|
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
|
|
'thread. Make sure `window` and `document` are available globally ' +
|
|
'before requiring React when unit testing or use ' +
|
|
'React.renderToString for server rendering.'
|
|
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
var nodeName;
|
|
var markupByNodeName = {};
|
|
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
|
|
for (var i = 0; i < markupList.length; i++) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
markupList[i],
|
|
'dangerouslyRenderMarkup(...): Missing markup.'
|
|
) : invariant(markupList[i]));
|
|
nodeName = getNodeName(markupList[i]);
|
|
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
|
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
|
markupByNodeName[nodeName][i] = markupList[i];
|
|
}
|
|
var resultList = [];
|
|
var resultListAssignmentCount = 0;
|
|
for (nodeName in markupByNodeName) {
|
|
if (!markupByNodeName.hasOwnProperty(nodeName)) {
|
|
continue;
|
|
}
|
|
var markupListByNodeName = markupByNodeName[nodeName];
|
|
|
|
// This for-in loop skips the holes of the sparse array. The order of
|
|
// iteration should follow the order of assignment, which happens to match
|
|
// numerical index order, but we don't rely on that.
|
|
for (var resultIndex in markupListByNodeName) {
|
|
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
|
|
var markup = markupListByNodeName[resultIndex];
|
|
|
|
// Push the requested markup with an additional RESULT_INDEX_ATTR
|
|
// attribute. If the markup does not start with a < character, it
|
|
// will be discarded below (with an appropriate console.error).
|
|
markupListByNodeName[resultIndex] = markup.replace(
|
|
OPEN_TAG_NAME_EXP,
|
|
// This index will be parsed back out below.
|
|
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
|
|
);
|
|
}
|
|
}
|
|
|
|
// Render each group of markup with similar wrapping `nodeName`.
|
|
var renderNodes = createNodesFromMarkup(
|
|
markupListByNodeName.join(''),
|
|
emptyFunction // Do nothing special with <script> tags.
|
|
);
|
|
|
|
for (i = 0; i < renderNodes.length; ++i) {
|
|
var renderNode = renderNodes[i];
|
|
if (renderNode.hasAttribute &&
|
|
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
|
|
|
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
|
renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!resultList.hasOwnProperty(resultIndex),
|
|
'Danger: Assigning to an already-occupied result index.'
|
|
) : invariant(!resultList.hasOwnProperty(resultIndex)));
|
|
|
|
resultList[resultIndex] = renderNode;
|
|
|
|
// This should match resultList.length and markupList.length when
|
|
// we're done.
|
|
resultListAssignmentCount += 1;
|
|
|
|
} else if ("production" !== process.env.NODE_ENV) {
|
|
console.error(
|
|
"Danger: Discarding unexpected node:",
|
|
renderNode
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Although resultList was populated out of order, it should now be a dense
|
|
// array.
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
resultListAssignmentCount === resultList.length,
|
|
'Danger: Did not assign to every index of resultList.'
|
|
) : invariant(resultListAssignmentCount === resultList.length));
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
resultList.length === markupList.length,
|
|
'Danger: Expected markup to render %s nodes, but rendered %s.',
|
|
markupList.length,
|
|
resultList.length
|
|
) : invariant(resultList.length === markupList.length));
|
|
|
|
return resultList;
|
|
},
|
|
|
|
/**
|
|
* Replaces a node with a string of markup at its current position within its
|
|
* parent. The markup must render into a single root node.
|
|
*
|
|
* @param {DOMElement} oldChild Child node to replace.
|
|
* @param {string} markup Markup to render in place of the child node.
|
|
* @internal
|
|
*/
|
|
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ExecutionEnvironment.canUseDOM,
|
|
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
|
|
'worker thread. Make sure `window` and `document` are available ' +
|
|
'globally before requiring React when unit testing or use ' +
|
|
'React.renderToString for server rendering.'
|
|
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
oldChild.tagName.toLowerCase() !== 'html',
|
|
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
|
|
'<html> node. This is because browser quirks make this unreliable ' +
|
|
'and/or slow. If you want to render to the root you must use ' +
|
|
'server rendering. See renderComponentToString().'
|
|
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
|
|
|
|
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = Danger;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ExecutionEnvironment":64,"./createNodesFromMarkup":159,"./emptyFunction":163,"./getMarkupWrap":174,"./invariant":182,"_process":1}],56:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule DefaultEventPluginOrder
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var keyOf = require("./keyOf");
|
|
|
|
/**
|
|
* Module that is injectable into `EventPluginHub`, that specifies a
|
|
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
|
|
* plugins, without having to package every one of them. This is better than
|
|
* having plugins be ordered in the same order that they are injected because
|
|
* that ordering would be influenced by the packaging order.
|
|
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
|
|
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
|
|
*/
|
|
var DefaultEventPluginOrder = [
|
|
keyOf({ResponderEventPlugin: null}),
|
|
keyOf({SimpleEventPlugin: null}),
|
|
keyOf({TapEventPlugin: null}),
|
|
keyOf({EnterLeaveEventPlugin: null}),
|
|
keyOf({ChangeEventPlugin: null}),
|
|
keyOf({SelectEventPlugin: null}),
|
|
keyOf({CompositionEventPlugin: null}),
|
|
keyOf({BeforeInputEventPlugin: null}),
|
|
keyOf({AnalyticsEventPlugin: null}),
|
|
keyOf({MobileSafariClickEventPlugin: null})
|
|
];
|
|
|
|
module.exports = DefaultEventPluginOrder;
|
|
|
|
},{"./keyOf":189}],57:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EnterLeaveEventPlugin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
|
|
|
var ReactMount = require("./ReactMount");
|
|
var keyOf = require("./keyOf");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
|
|
|
var eventTypes = {
|
|
mouseEnter: {
|
|
registrationName: keyOf({onMouseEnter: null}),
|
|
dependencies: [
|
|
topLevelTypes.topMouseOut,
|
|
topLevelTypes.topMouseOver
|
|
]
|
|
},
|
|
mouseLeave: {
|
|
registrationName: keyOf({onMouseLeave: null}),
|
|
dependencies: [
|
|
topLevelTypes.topMouseOut,
|
|
topLevelTypes.topMouseOver
|
|
]
|
|
}
|
|
};
|
|
|
|
var extractedEvents = [null, null];
|
|
|
|
var EnterLeaveEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* For almost every interaction we care about, there will be both a top-level
|
|
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
|
|
* we do not extract duplicate events. However, moving the mouse into the
|
|
* browser from outside will not fire a `mouseout` event. In this case, we use
|
|
* the `mouseover` top-level event.
|
|
*
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
if (topLevelType === topLevelTypes.topMouseOver &&
|
|
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
|
return null;
|
|
}
|
|
if (topLevelType !== topLevelTypes.topMouseOut &&
|
|
topLevelType !== topLevelTypes.topMouseOver) {
|
|
// Must not be a mouse in or mouse out - ignoring.
|
|
return null;
|
|
}
|
|
|
|
var win;
|
|
if (topLevelTarget.window === topLevelTarget) {
|
|
// `topLevelTarget` is probably a window object.
|
|
win = topLevelTarget;
|
|
} else {
|
|
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
|
var doc = topLevelTarget.ownerDocument;
|
|
if (doc) {
|
|
win = doc.defaultView || doc.parentWindow;
|
|
} else {
|
|
win = window;
|
|
}
|
|
}
|
|
|
|
var from, to;
|
|
if (topLevelType === topLevelTypes.topMouseOut) {
|
|
from = topLevelTarget;
|
|
to =
|
|
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
|
|
win;
|
|
} else {
|
|
from = win;
|
|
to = topLevelTarget;
|
|
}
|
|
|
|
if (from === to) {
|
|
// Nothing pertains to our managed components.
|
|
return null;
|
|
}
|
|
|
|
var fromID = from ? ReactMount.getID(from) : '';
|
|
var toID = to ? ReactMount.getID(to) : '';
|
|
|
|
var leave = SyntheticMouseEvent.getPooled(
|
|
eventTypes.mouseLeave,
|
|
fromID,
|
|
nativeEvent
|
|
);
|
|
leave.type = 'mouseleave';
|
|
leave.target = from;
|
|
leave.relatedTarget = to;
|
|
|
|
var enter = SyntheticMouseEvent.getPooled(
|
|
eventTypes.mouseEnter,
|
|
toID,
|
|
nativeEvent
|
|
);
|
|
enter.type = 'mouseenter';
|
|
enter.target = to;
|
|
enter.relatedTarget = from;
|
|
|
|
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
|
|
|
|
extractedEvents[0] = leave;
|
|
extractedEvents[1] = enter;
|
|
|
|
return extractedEvents;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = EnterLeaveEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./EventPropagators":63,"./ReactMount":111,"./SyntheticMouseEvent":145,"./keyOf":189}],58:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EventConstants
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var keyMirror = require("./keyMirror");
|
|
|
|
var PropagationPhases = keyMirror({bubbled: null, captured: null});
|
|
|
|
/**
|
|
* Types of raw signals from the browser caught at the top level.
|
|
*/
|
|
var topLevelTypes = keyMirror({
|
|
topBlur: null,
|
|
topChange: null,
|
|
topClick: null,
|
|
topCompositionEnd: null,
|
|
topCompositionStart: null,
|
|
topCompositionUpdate: null,
|
|
topContextMenu: null,
|
|
topCopy: null,
|
|
topCut: null,
|
|
topDoubleClick: null,
|
|
topDrag: null,
|
|
topDragEnd: null,
|
|
topDragEnter: null,
|
|
topDragExit: null,
|
|
topDragLeave: null,
|
|
topDragOver: null,
|
|
topDragStart: null,
|
|
topDrop: null,
|
|
topError: null,
|
|
topFocus: null,
|
|
topInput: null,
|
|
topKeyDown: null,
|
|
topKeyPress: null,
|
|
topKeyUp: null,
|
|
topLoad: null,
|
|
topMouseDown: null,
|
|
topMouseMove: null,
|
|
topMouseOut: null,
|
|
topMouseOver: null,
|
|
topMouseUp: null,
|
|
topPaste: null,
|
|
topReset: null,
|
|
topScroll: null,
|
|
topSelectionChange: null,
|
|
topSubmit: null,
|
|
topTextInput: null,
|
|
topTouchCancel: null,
|
|
topTouchEnd: null,
|
|
topTouchMove: null,
|
|
topTouchStart: null,
|
|
topWheel: null
|
|
});
|
|
|
|
var EventConstants = {
|
|
topLevelTypes: topLevelTypes,
|
|
PropagationPhases: PropagationPhases
|
|
};
|
|
|
|
module.exports = EventConstants;
|
|
|
|
},{"./keyMirror":188}],59:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014 Facebook, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* @providesModule EventListener
|
|
* @typechecks
|
|
*/
|
|
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
/**
|
|
* Upstream version of event listener. Does not take into account specific
|
|
* nature of platform.
|
|
*/
|
|
var EventListener = {
|
|
/**
|
|
* Listen to DOM events during the bubble phase.
|
|
*
|
|
* @param {DOMEventTarget} target DOM element to register listener on.
|
|
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
|
|
* @param {function} callback Callback function.
|
|
* @return {object} Object with a `remove` method.
|
|
*/
|
|
listen: function(target, eventType, callback) {
|
|
if (target.addEventListener) {
|
|
target.addEventListener(eventType, callback, false);
|
|
return {
|
|
remove: function() {
|
|
target.removeEventListener(eventType, callback, false);
|
|
}
|
|
};
|
|
} else if (target.attachEvent) {
|
|
target.attachEvent('on' + eventType, callback);
|
|
return {
|
|
remove: function() {
|
|
target.detachEvent('on' + eventType, callback);
|
|
}
|
|
};
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Listen to DOM events during the capture phase.
|
|
*
|
|
* @param {DOMEventTarget} target DOM element to register listener on.
|
|
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
|
|
* @param {function} callback Callback function.
|
|
* @return {object} Object with a `remove` method.
|
|
*/
|
|
capture: function(target, eventType, callback) {
|
|
if (!target.addEventListener) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
console.error(
|
|
'Attempted to listen to events during the capture phase on a ' +
|
|
'browser that does not support the capture phase. Your application ' +
|
|
'will not receive some events.'
|
|
);
|
|
}
|
|
return {
|
|
remove: emptyFunction
|
|
};
|
|
} else {
|
|
target.addEventListener(eventType, callback, true);
|
|
return {
|
|
remove: function() {
|
|
target.removeEventListener(eventType, callback, true);
|
|
}
|
|
};
|
|
}
|
|
},
|
|
|
|
registerDefault: function() {}
|
|
};
|
|
|
|
module.exports = EventListener;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./emptyFunction":163,"_process":1}],60:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EventPluginHub
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventPluginRegistry = require("./EventPluginRegistry");
|
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
|
|
var accumulateInto = require("./accumulateInto");
|
|
var forEachAccumulated = require("./forEachAccumulated");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Internal store for event listeners
|
|
*/
|
|
var listenerBank = {};
|
|
|
|
/**
|
|
* Internal queue of events that have accumulated their dispatches and are
|
|
* waiting to have their dispatches executed.
|
|
*/
|
|
var eventQueue = null;
|
|
|
|
/**
|
|
* Dispatches an event and releases it back into the pool, unless persistent.
|
|
*
|
|
* @param {?object} event Synthetic event to be dispatched.
|
|
* @private
|
|
*/
|
|
var executeDispatchesAndRelease = function(event) {
|
|
if (event) {
|
|
var executeDispatch = EventPluginUtils.executeDispatch;
|
|
// Plugins can provide custom behavior when dispatching events.
|
|
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
|
|
if (PluginModule && PluginModule.executeDispatch) {
|
|
executeDispatch = PluginModule.executeDispatch;
|
|
}
|
|
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
|
|
|
|
if (!event.isPersistent()) {
|
|
event.constructor.release(event);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
* hierarchy given ids of the logical DOM elements involved.
|
|
*/
|
|
var InstanceHandle = null;
|
|
|
|
function validateInstanceHandle() {
|
|
var invalid = !InstanceHandle||
|
|
!InstanceHandle.traverseTwoPhase ||
|
|
!InstanceHandle.traverseEnterLeave;
|
|
if (invalid) {
|
|
throw new Error('InstanceHandle not injected before use!');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This is a unified interface for event plugins to be installed and configured.
|
|
*
|
|
* Event plugins can implement the following properties:
|
|
*
|
|
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
|
|
* Required. When a top-level event is fired, this method is expected to
|
|
* extract synthetic events that will in turn be queued and dispatched.
|
|
*
|
|
* `eventTypes` {object}
|
|
* Optional, plugins that fire events must publish a mapping of registration
|
|
* names that are used to register listeners. Values of this mapping must
|
|
* be objects that contain `registrationName` or `phasedRegistrationNames`.
|
|
*
|
|
* `executeDispatch` {function(object, function, string)}
|
|
* Optional, allows plugins to override how an event gets dispatched. By
|
|
* default, the listener is simply invoked.
|
|
*
|
|
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
|
|
*
|
|
* @public
|
|
*/
|
|
var EventPluginHub = {
|
|
|
|
/**
|
|
* Methods for injecting dependencies.
|
|
*/
|
|
injection: {
|
|
|
|
/**
|
|
* @param {object} InjectedMount
|
|
* @public
|
|
*/
|
|
injectMount: EventPluginUtils.injection.injectMount,
|
|
|
|
/**
|
|
* @param {object} InjectedInstanceHandle
|
|
* @public
|
|
*/
|
|
injectInstanceHandle: function(InjectedInstanceHandle) {
|
|
InstanceHandle = InjectedInstanceHandle;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateInstanceHandle();
|
|
}
|
|
},
|
|
|
|
getInstanceHandle: function() {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateInstanceHandle();
|
|
}
|
|
return InstanceHandle;
|
|
},
|
|
|
|
/**
|
|
* @param {array} InjectedEventPluginOrder
|
|
* @public
|
|
*/
|
|
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
|
|
|
|
/**
|
|
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
|
|
*/
|
|
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
|
|
|
|
},
|
|
|
|
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
|
|
|
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
|
|
|
/**
|
|
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
|
*
|
|
* @param {string} id ID of the DOM element.
|
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
* @param {?function} listener The callback to store.
|
|
*/
|
|
putListener: function(id, registrationName, listener) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!listener || typeof listener === 'function',
|
|
'Expected %s listener to be a function, instead got type %s',
|
|
registrationName, typeof listener
|
|
) : invariant(!listener || typeof listener === 'function'));
|
|
|
|
var bankForRegistrationName =
|
|
listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
|
bankForRegistrationName[id] = listener;
|
|
},
|
|
|
|
/**
|
|
* @param {string} id ID of the DOM element.
|
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
* @return {?function} The stored callback.
|
|
*/
|
|
getListener: function(id, registrationName) {
|
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
return bankForRegistrationName && bankForRegistrationName[id];
|
|
},
|
|
|
|
/**
|
|
* Deletes a listener from the registration bank.
|
|
*
|
|
* @param {string} id ID of the DOM element.
|
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
*/
|
|
deleteListener: function(id, registrationName) {
|
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
if (bankForRegistrationName) {
|
|
delete bankForRegistrationName[id];
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Deletes all listeners for the DOM element with the supplied ID.
|
|
*
|
|
* @param {string} id ID of the DOM element.
|
|
*/
|
|
deleteAllListeners: function(id) {
|
|
for (var registrationName in listenerBank) {
|
|
delete listenerBank[registrationName][id];
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Allows registered plugins an opportunity to extract events from top-level
|
|
* native browser events.
|
|
*
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @internal
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
var events;
|
|
var plugins = EventPluginRegistry.plugins;
|
|
for (var i = 0, l = plugins.length; i < l; i++) {
|
|
// Not every plugin in the ordering may be loaded at runtime.
|
|
var possiblePlugin = plugins[i];
|
|
if (possiblePlugin) {
|
|
var extractedEvents = possiblePlugin.extractEvents(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
if (extractedEvents) {
|
|
events = accumulateInto(events, extractedEvents);
|
|
}
|
|
}
|
|
}
|
|
return events;
|
|
},
|
|
|
|
/**
|
|
* Enqueues a synthetic event that should be dispatched when
|
|
* `processEventQueue` is invoked.
|
|
*
|
|
* @param {*} events An accumulation of synthetic events.
|
|
* @internal
|
|
*/
|
|
enqueueEvents: function(events) {
|
|
if (events) {
|
|
eventQueue = accumulateInto(eventQueue, events);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Dispatches all synthetic events on the event queue.
|
|
*
|
|
* @internal
|
|
*/
|
|
processEventQueue: function() {
|
|
// Set `eventQueue` to null before processing it so that we can tell if more
|
|
// events get enqueued while processing.
|
|
var processingEventQueue = eventQueue;
|
|
eventQueue = null;
|
|
forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!eventQueue,
|
|
'processEventQueue(): Additional events were enqueued while processing ' +
|
|
'an event queue. Support for this has not yet been implemented.'
|
|
) : invariant(!eventQueue));
|
|
},
|
|
|
|
/**
|
|
* These are needed for tests only. Do not use!
|
|
*/
|
|
__purge: function() {
|
|
listenerBank = {};
|
|
},
|
|
|
|
__getListenerBank: function() {
|
|
return listenerBank;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = EventPluginHub;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./EventPluginRegistry":61,"./EventPluginUtils":62,"./accumulateInto":151,"./forEachAccumulated":168,"./invariant":182,"_process":1}],61:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EventPluginRegistry
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Injectable ordering of event plugins.
|
|
*/
|
|
var EventPluginOrder = null;
|
|
|
|
/**
|
|
* Injectable mapping from names to event plugin modules.
|
|
*/
|
|
var namesToPlugins = {};
|
|
|
|
/**
|
|
* Recomputes the plugin list using the injected plugins and plugin ordering.
|
|
*
|
|
* @private
|
|
*/
|
|
function recomputePluginOrdering() {
|
|
if (!EventPluginOrder) {
|
|
// Wait until an `EventPluginOrder` is injected.
|
|
return;
|
|
}
|
|
for (var pluginName in namesToPlugins) {
|
|
var PluginModule = namesToPlugins[pluginName];
|
|
var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
pluginIndex > -1,
|
|
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
|
|
'the plugin ordering, `%s`.',
|
|
pluginName
|
|
) : invariant(pluginIndex > -1));
|
|
if (EventPluginRegistry.plugins[pluginIndex]) {
|
|
continue;
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
PluginModule.extractEvents,
|
|
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
|
|
'method, but `%s` does not.',
|
|
pluginName
|
|
) : invariant(PluginModule.extractEvents));
|
|
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
|
var publishedEvents = PluginModule.eventTypes;
|
|
for (var eventName in publishedEvents) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
publishEventForPlugin(
|
|
publishedEvents[eventName],
|
|
PluginModule,
|
|
eventName
|
|
),
|
|
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
|
|
eventName,
|
|
pluginName
|
|
) : invariant(publishEventForPlugin(
|
|
publishedEvents[eventName],
|
|
PluginModule,
|
|
eventName
|
|
)));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Publishes an event so that it can be dispatched by the supplied plugin.
|
|
*
|
|
* @param {object} dispatchConfig Dispatch configuration for the event.
|
|
* @param {object} PluginModule Plugin publishing the event.
|
|
* @return {boolean} True if the event was successfully published.
|
|
* @private
|
|
*/
|
|
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
|
|
'EventPluginHub: More than one plugin attempted to publish the same ' +
|
|
'event name, `%s`.',
|
|
eventName
|
|
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
|
|
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
|
|
|
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
|
if (phasedRegistrationNames) {
|
|
for (var phaseName in phasedRegistrationNames) {
|
|
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
|
|
var phasedRegistrationName = phasedRegistrationNames[phaseName];
|
|
publishRegistrationName(
|
|
phasedRegistrationName,
|
|
PluginModule,
|
|
eventName
|
|
);
|
|
}
|
|
}
|
|
return true;
|
|
} else if (dispatchConfig.registrationName) {
|
|
publishRegistrationName(
|
|
dispatchConfig.registrationName,
|
|
PluginModule,
|
|
eventName
|
|
);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Publishes a registration name that is used to identify dispatched events and
|
|
* can be used with `EventPluginHub.putListener` to register listeners.
|
|
*
|
|
* @param {string} registrationName Registration name to add.
|
|
* @param {object} PluginModule Plugin publishing the event.
|
|
* @private
|
|
*/
|
|
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!EventPluginRegistry.registrationNameModules[registrationName],
|
|
'EventPluginHub: More than one plugin attempted to publish the same ' +
|
|
'registration name, `%s`.',
|
|
registrationName
|
|
) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
|
|
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
|
EventPluginRegistry.registrationNameDependencies[registrationName] =
|
|
PluginModule.eventTypes[eventName].dependencies;
|
|
}
|
|
|
|
/**
|
|
* Registers plugins so that they can extract and dispatch events.
|
|
*
|
|
* @see {EventPluginHub}
|
|
*/
|
|
var EventPluginRegistry = {
|
|
|
|
/**
|
|
* Ordered list of injected plugins.
|
|
*/
|
|
plugins: [],
|
|
|
|
/**
|
|
* Mapping from event name to dispatch config
|
|
*/
|
|
eventNameDispatchConfigs: {},
|
|
|
|
/**
|
|
* Mapping from registration name to plugin module
|
|
*/
|
|
registrationNameModules: {},
|
|
|
|
/**
|
|
* Mapping from registration name to event name
|
|
*/
|
|
registrationNameDependencies: {},
|
|
|
|
/**
|
|
* Injects an ordering of plugins (by plugin name). This allows the ordering
|
|
* to be decoupled from injection of the actual plugins so that ordering is
|
|
* always deterministic regardless of packaging, on-the-fly injection, etc.
|
|
*
|
|
* @param {array} InjectedEventPluginOrder
|
|
* @internal
|
|
* @see {EventPluginHub.injection.injectEventPluginOrder}
|
|
*/
|
|
injectEventPluginOrder: function(InjectedEventPluginOrder) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!EventPluginOrder,
|
|
'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
|
|
'once. You are likely trying to load more than one copy of React.'
|
|
) : invariant(!EventPluginOrder));
|
|
// Clone the ordering so it cannot be dynamically mutated.
|
|
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
|
recomputePluginOrdering();
|
|
},
|
|
|
|
/**
|
|
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
|
|
* in the ordering injected by `injectEventPluginOrder`.
|
|
*
|
|
* Plugins can be injected as part of page initialization or on-the-fly.
|
|
*
|
|
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
|
|
* @internal
|
|
* @see {EventPluginHub.injection.injectEventPluginsByName}
|
|
*/
|
|
injectEventPluginsByName: function(injectedNamesToPlugins) {
|
|
var isOrderingDirty = false;
|
|
for (var pluginName in injectedNamesToPlugins) {
|
|
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
|
|
continue;
|
|
}
|
|
var PluginModule = injectedNamesToPlugins[pluginName];
|
|
if (!namesToPlugins.hasOwnProperty(pluginName) ||
|
|
namesToPlugins[pluginName] !== PluginModule) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!namesToPlugins[pluginName],
|
|
'EventPluginRegistry: Cannot inject two different event plugins ' +
|
|
'using the same name, `%s`.',
|
|
pluginName
|
|
) : invariant(!namesToPlugins[pluginName]));
|
|
namesToPlugins[pluginName] = PluginModule;
|
|
isOrderingDirty = true;
|
|
}
|
|
}
|
|
if (isOrderingDirty) {
|
|
recomputePluginOrdering();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Looks up the plugin for the supplied event.
|
|
*
|
|
* @param {object} event A synthetic event.
|
|
* @return {?object} The plugin that created the supplied event.
|
|
* @internal
|
|
*/
|
|
getPluginModuleForEvent: function(event) {
|
|
var dispatchConfig = event.dispatchConfig;
|
|
if (dispatchConfig.registrationName) {
|
|
return EventPluginRegistry.registrationNameModules[
|
|
dispatchConfig.registrationName
|
|
] || null;
|
|
}
|
|
for (var phase in dispatchConfig.phasedRegistrationNames) {
|
|
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
|
|
continue;
|
|
}
|
|
var PluginModule = EventPluginRegistry.registrationNameModules[
|
|
dispatchConfig.phasedRegistrationNames[phase]
|
|
];
|
|
if (PluginModule) {
|
|
return PluginModule;
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/**
|
|
* Exposed for unit testing.
|
|
* @private
|
|
*/
|
|
_resetEventPlugins: function() {
|
|
EventPluginOrder = null;
|
|
for (var pluginName in namesToPlugins) {
|
|
if (namesToPlugins.hasOwnProperty(pluginName)) {
|
|
delete namesToPlugins[pluginName];
|
|
}
|
|
}
|
|
EventPluginRegistry.plugins.length = 0;
|
|
|
|
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
|
|
for (var eventName in eventNameDispatchConfigs) {
|
|
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
|
|
delete eventNameDispatchConfigs[eventName];
|
|
}
|
|
}
|
|
|
|
var registrationNameModules = EventPluginRegistry.registrationNameModules;
|
|
for (var registrationName in registrationNameModules) {
|
|
if (registrationNameModules.hasOwnProperty(registrationName)) {
|
|
delete registrationNameModules[registrationName];
|
|
}
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = EventPluginRegistry;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],62:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EventPluginUtils
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Injected dependencies:
|
|
*/
|
|
|
|
/**
|
|
* - `Mount`: [required] Module that can convert between React dom IDs and
|
|
* actual node references.
|
|
*/
|
|
var injection = {
|
|
Mount: null,
|
|
injectMount: function(InjectedMount) {
|
|
injection.Mount = InjectedMount;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
InjectedMount && InjectedMount.getNode,
|
|
'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
|
|
'is missing getNode.'
|
|
) : invariant(InjectedMount && InjectedMount.getNode));
|
|
}
|
|
}
|
|
};
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
function isEndish(topLevelType) {
|
|
return topLevelType === topLevelTypes.topMouseUp ||
|
|
topLevelType === topLevelTypes.topTouchEnd ||
|
|
topLevelType === topLevelTypes.topTouchCancel;
|
|
}
|
|
|
|
function isMoveish(topLevelType) {
|
|
return topLevelType === topLevelTypes.topMouseMove ||
|
|
topLevelType === topLevelTypes.topTouchMove;
|
|
}
|
|
function isStartish(topLevelType) {
|
|
return topLevelType === topLevelTypes.topMouseDown ||
|
|
topLevelType === topLevelTypes.topTouchStart;
|
|
}
|
|
|
|
|
|
var validateEventDispatches;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateEventDispatches = function(event) {
|
|
var dispatchListeners = event._dispatchListeners;
|
|
var dispatchIDs = event._dispatchIDs;
|
|
|
|
var listenersIsArr = Array.isArray(dispatchListeners);
|
|
var idsIsArr = Array.isArray(dispatchIDs);
|
|
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
|
|
var listenersLen = listenersIsArr ?
|
|
dispatchListeners.length :
|
|
dispatchListeners ? 1 : 0;
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
idsIsArr === listenersIsArr && IDsLen === listenersLen,
|
|
'EventPluginUtils: Invalid `event`.'
|
|
) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Invokes `cb(event, listener, id)`. Avoids using call if no scope is
|
|
* provided. The `(listener,id)` pair effectively forms the "dispatch" but are
|
|
* kept separate to conserve memory.
|
|
*/
|
|
function forEachEventDispatch(event, cb) {
|
|
var dispatchListeners = event._dispatchListeners;
|
|
var dispatchIDs = event._dispatchIDs;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateEventDispatches(event);
|
|
}
|
|
if (Array.isArray(dispatchListeners)) {
|
|
for (var i = 0; i < dispatchListeners.length; i++) {
|
|
if (event.isPropagationStopped()) {
|
|
break;
|
|
}
|
|
// Listeners and IDs are two parallel arrays that are always in sync.
|
|
cb(event, dispatchListeners[i], dispatchIDs[i]);
|
|
}
|
|
} else if (dispatchListeners) {
|
|
cb(event, dispatchListeners, dispatchIDs);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Default implementation of PluginModule.executeDispatch().
|
|
* @param {SyntheticEvent} SyntheticEvent to handle
|
|
* @param {function} Application-level callback
|
|
* @param {string} domID DOM id to pass to the callback.
|
|
*/
|
|
function executeDispatch(event, listener, domID) {
|
|
event.currentTarget = injection.Mount.getNode(domID);
|
|
var returnValue = listener(event, domID);
|
|
event.currentTarget = null;
|
|
return returnValue;
|
|
}
|
|
|
|
/**
|
|
* Standard/simple iteration through an event's collected dispatches.
|
|
*/
|
|
function executeDispatchesInOrder(event, executeDispatch) {
|
|
forEachEventDispatch(event, executeDispatch);
|
|
event._dispatchListeners = null;
|
|
event._dispatchIDs = null;
|
|
}
|
|
|
|
/**
|
|
* Standard/simple iteration through an event's collected dispatches, but stops
|
|
* at the first dispatch execution returning true, and returns that id.
|
|
*
|
|
* @return id of the first dispatch execution who's listener returns true, or
|
|
* null if no listener returned true.
|
|
*/
|
|
function executeDispatchesInOrderStopAtTrueImpl(event) {
|
|
var dispatchListeners = event._dispatchListeners;
|
|
var dispatchIDs = event._dispatchIDs;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateEventDispatches(event);
|
|
}
|
|
if (Array.isArray(dispatchListeners)) {
|
|
for (var i = 0; i < dispatchListeners.length; i++) {
|
|
if (event.isPropagationStopped()) {
|
|
break;
|
|
}
|
|
// Listeners and IDs are two parallel arrays that are always in sync.
|
|
if (dispatchListeners[i](event, dispatchIDs[i])) {
|
|
return dispatchIDs[i];
|
|
}
|
|
}
|
|
} else if (dispatchListeners) {
|
|
if (dispatchListeners(event, dispatchIDs)) {
|
|
return dispatchIDs;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @see executeDispatchesInOrderStopAtTrueImpl
|
|
*/
|
|
function executeDispatchesInOrderStopAtTrue(event) {
|
|
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
|
event._dispatchIDs = null;
|
|
event._dispatchListeners = null;
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Execution of a "direct" dispatch - there must be at most one dispatch
|
|
* accumulated on the event or it is considered an error. It doesn't really make
|
|
* sense for an event with multiple dispatches (bubbled) to keep track of the
|
|
* return values at each dispatch execution, but it does tend to make sense when
|
|
* dealing with "direct" dispatches.
|
|
*
|
|
* @return The return value of executing the single dispatch.
|
|
*/
|
|
function executeDirectDispatch(event) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
validateEventDispatches(event);
|
|
}
|
|
var dispatchListener = event._dispatchListeners;
|
|
var dispatchID = event._dispatchIDs;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!Array.isArray(dispatchListener),
|
|
'executeDirectDispatch(...): Invalid `event`.'
|
|
) : invariant(!Array.isArray(dispatchListener)));
|
|
var res = dispatchListener ?
|
|
dispatchListener(event, dispatchID) :
|
|
null;
|
|
event._dispatchListeners = null;
|
|
event._dispatchIDs = null;
|
|
return res;
|
|
}
|
|
|
|
/**
|
|
* @param {SyntheticEvent} event
|
|
* @return {bool} True iff number of dispatches accumulated is greater than 0.
|
|
*/
|
|
function hasDispatches(event) {
|
|
return !!event._dispatchListeners;
|
|
}
|
|
|
|
/**
|
|
* General utilities that are useful in creating custom Event Plugins.
|
|
*/
|
|
var EventPluginUtils = {
|
|
isEndish: isEndish,
|
|
isMoveish: isMoveish,
|
|
isStartish: isStartish,
|
|
|
|
executeDirectDispatch: executeDirectDispatch,
|
|
executeDispatch: executeDispatch,
|
|
executeDispatchesInOrder: executeDispatchesInOrder,
|
|
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
|
|
hasDispatches: hasDispatches,
|
|
injection: injection,
|
|
useTouchEvents: false
|
|
};
|
|
|
|
module.exports = EventPluginUtils;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./EventConstants":58,"./invariant":182,"_process":1}],63:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule EventPropagators
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
|
|
var accumulateInto = require("./accumulateInto");
|
|
var forEachAccumulated = require("./forEachAccumulated");
|
|
|
|
var PropagationPhases = EventConstants.PropagationPhases;
|
|
var getListener = EventPluginHub.getListener;
|
|
|
|
/**
|
|
* Some event types have a notion of different registration names for different
|
|
* "phases" of propagation. This finds listeners by a given phase.
|
|
*/
|
|
function listenerAtPhase(id, event, propagationPhase) {
|
|
var registrationName =
|
|
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
|
return getListener(id, registrationName);
|
|
}
|
|
|
|
/**
|
|
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
|
|
* here, allows us to not have to bind or create functions for each event.
|
|
* Mutating the event's members allows us to not have to create a wrapping
|
|
* "dispatch" object that pairs the event with the listener.
|
|
*/
|
|
function accumulateDirectionalDispatches(domID, upwards, event) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (!domID) {
|
|
throw new Error('Dispatching id must not be null');
|
|
}
|
|
}
|
|
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
|
var listener = listenerAtPhase(domID, event, phase);
|
|
if (listener) {
|
|
event._dispatchListeners =
|
|
accumulateInto(event._dispatchListeners, listener);
|
|
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Collect dispatches (must be entirely collected before dispatching - see unit
|
|
* tests). Lazily allocate the array to conserve memory. We must loop through
|
|
* each event and perform the traversal for each one. We can not perform a
|
|
* single traversal for the entire collection of events because each event may
|
|
* have a different target.
|
|
*/
|
|
function accumulateTwoPhaseDispatchesSingle(event) {
|
|
if (event && event.dispatchConfig.phasedRegistrationNames) {
|
|
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
|
|
event.dispatchMarker,
|
|
accumulateDirectionalDispatches,
|
|
event
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Accumulates without regard to direction, does not look for phased
|
|
* registration names. Same as `accumulateDirectDispatchesSingle` but without
|
|
* requiring that the `dispatchMarker` be the same as the dispatched ID.
|
|
*/
|
|
function accumulateDispatches(id, ignoredDirection, event) {
|
|
if (event && event.dispatchConfig.registrationName) {
|
|
var registrationName = event.dispatchConfig.registrationName;
|
|
var listener = getListener(id, registrationName);
|
|
if (listener) {
|
|
event._dispatchListeners =
|
|
accumulateInto(event._dispatchListeners, listener);
|
|
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Accumulates dispatches on an `SyntheticEvent`, but only for the
|
|
* `dispatchMarker`.
|
|
* @param {SyntheticEvent} event
|
|
*/
|
|
function accumulateDirectDispatchesSingle(event) {
|
|
if (event && event.dispatchConfig.registrationName) {
|
|
accumulateDispatches(event.dispatchMarker, null, event);
|
|
}
|
|
}
|
|
|
|
function accumulateTwoPhaseDispatches(events) {
|
|
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
|
}
|
|
|
|
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
|
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
|
|
fromID,
|
|
toID,
|
|
accumulateDispatches,
|
|
leave,
|
|
enter
|
|
);
|
|
}
|
|
|
|
|
|
function accumulateDirectDispatches(events) {
|
|
forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* A small set of propagation patterns, each of which will accept a small amount
|
|
* of information, and generate a set of "dispatch ready event objects" - which
|
|
* are sets of events that have already been annotated with a set of dispatched
|
|
* listener functions/ids. The API is designed this way to discourage these
|
|
* propagation strategies from actually executing the dispatches, since we
|
|
* always want to collect the entire set of dispatches before executing event a
|
|
* single one.
|
|
*
|
|
* @constructor EventPropagators
|
|
*/
|
|
var EventPropagators = {
|
|
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
|
|
accumulateDirectDispatches: accumulateDirectDispatches,
|
|
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
|
};
|
|
|
|
module.exports = EventPropagators;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./EventConstants":58,"./EventPluginHub":60,"./accumulateInto":151,"./forEachAccumulated":168,"_process":1}],64:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ExecutionEnvironment
|
|
*/
|
|
|
|
/*jslint evil: true */
|
|
|
|
"use strict";
|
|
|
|
var canUseDOM = !!(
|
|
typeof window !== 'undefined' &&
|
|
window.document &&
|
|
window.document.createElement
|
|
);
|
|
|
|
/**
|
|
* Simple, lightweight module assisting with the detection and context of
|
|
* Worker. Helps avoid circular dependencies and allows code to reason about
|
|
* whether or not they are in a Worker, even if they never include the main
|
|
* `ReactWorker` dependency.
|
|
*/
|
|
var ExecutionEnvironment = {
|
|
|
|
canUseDOM: canUseDOM,
|
|
|
|
canUseWorkers: typeof Worker !== 'undefined',
|
|
|
|
canUseEventListeners:
|
|
canUseDOM && !!(window.addEventListener || window.attachEvent),
|
|
|
|
canUseViewport: canUseDOM && !!window.screen,
|
|
|
|
isInWorker: !canUseDOM // For now, this is true - might change in the future.
|
|
|
|
};
|
|
|
|
module.exports = ExecutionEnvironment;
|
|
|
|
},{}],65:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule HTMLDOMPropertyConfig
|
|
*/
|
|
|
|
/*jslint bitwise: true*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
|
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
|
|
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
|
|
var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
|
|
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
|
|
var HAS_POSITIVE_NUMERIC_VALUE =
|
|
DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
|
|
var HAS_OVERLOADED_BOOLEAN_VALUE =
|
|
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
|
|
|
|
var hasSVG;
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
var implementation = document.implementation;
|
|
hasSVG = (
|
|
implementation &&
|
|
implementation.hasFeature &&
|
|
implementation.hasFeature(
|
|
'http://www.w3.org/TR/SVG11/feature#BasicStructure',
|
|
'1.1'
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
var HTMLDOMPropertyConfig = {
|
|
isCustomAttribute: RegExp.prototype.test.bind(
|
|
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
|
|
),
|
|
Properties: {
|
|
/**
|
|
* Standard Properties
|
|
*/
|
|
accept: null,
|
|
acceptCharset: null,
|
|
accessKey: null,
|
|
action: null,
|
|
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
|
allowTransparency: MUST_USE_ATTRIBUTE,
|
|
alt: null,
|
|
async: HAS_BOOLEAN_VALUE,
|
|
autoComplete: null,
|
|
// autoFocus is polyfilled/normalized by AutoFocusMixin
|
|
// autoFocus: HAS_BOOLEAN_VALUE,
|
|
autoPlay: HAS_BOOLEAN_VALUE,
|
|
cellPadding: null,
|
|
cellSpacing: null,
|
|
charSet: MUST_USE_ATTRIBUTE,
|
|
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
classID: MUST_USE_ATTRIBUTE,
|
|
// To set className on SVG elements, it's necessary to use .setAttribute;
|
|
// this works on HTML elements too in all browsers except IE8. Conveniently,
|
|
// IE8 doesn't support SVG and so we can simply use the attribute in
|
|
// browsers that support SVG and the property in browsers that don't,
|
|
// regardless of whether the element is HTML or SVG.
|
|
className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
|
|
cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
|
colSpan: null,
|
|
content: null,
|
|
contentEditable: null,
|
|
contextMenu: MUST_USE_ATTRIBUTE,
|
|
controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
coords: null,
|
|
crossOrigin: null,
|
|
data: null, // For `<object />` acts as `src`.
|
|
dateTime: MUST_USE_ATTRIBUTE,
|
|
defer: HAS_BOOLEAN_VALUE,
|
|
dir: null,
|
|
disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
|
download: HAS_OVERLOADED_BOOLEAN_VALUE,
|
|
draggable: null,
|
|
encType: null,
|
|
form: MUST_USE_ATTRIBUTE,
|
|
formAction: MUST_USE_ATTRIBUTE,
|
|
formEncType: MUST_USE_ATTRIBUTE,
|
|
formMethod: MUST_USE_ATTRIBUTE,
|
|
formNoValidate: HAS_BOOLEAN_VALUE,
|
|
formTarget: MUST_USE_ATTRIBUTE,
|
|
frameBorder: MUST_USE_ATTRIBUTE,
|
|
height: MUST_USE_ATTRIBUTE,
|
|
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
|
href: null,
|
|
hrefLang: null,
|
|
htmlFor: null,
|
|
httpEquiv: null,
|
|
icon: null,
|
|
id: MUST_USE_PROPERTY,
|
|
label: null,
|
|
lang: null,
|
|
list: MUST_USE_ATTRIBUTE,
|
|
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
manifest: MUST_USE_ATTRIBUTE,
|
|
marginHeight: null,
|
|
marginWidth: null,
|
|
max: null,
|
|
maxLength: MUST_USE_ATTRIBUTE,
|
|
media: MUST_USE_ATTRIBUTE,
|
|
mediaGroup: null,
|
|
method: null,
|
|
min: null,
|
|
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
name: null,
|
|
noValidate: HAS_BOOLEAN_VALUE,
|
|
open: null,
|
|
pattern: null,
|
|
placeholder: null,
|
|
poster: null,
|
|
preload: null,
|
|
radioGroup: null,
|
|
readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
rel: null,
|
|
required: HAS_BOOLEAN_VALUE,
|
|
role: MUST_USE_ATTRIBUTE,
|
|
rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
|
rowSpan: null,
|
|
sandbox: null,
|
|
scope: null,
|
|
scrolling: null,
|
|
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
|
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
|
shape: null,
|
|
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
|
sizes: MUST_USE_ATTRIBUTE,
|
|
span: HAS_POSITIVE_NUMERIC_VALUE,
|
|
spellCheck: null,
|
|
src: null,
|
|
srcDoc: MUST_USE_PROPERTY,
|
|
srcSet: MUST_USE_ATTRIBUTE,
|
|
start: HAS_NUMERIC_VALUE,
|
|
step: null,
|
|
style: null,
|
|
tabIndex: null,
|
|
target: null,
|
|
title: null,
|
|
type: null,
|
|
useMap: null,
|
|
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
|
|
width: MUST_USE_ATTRIBUTE,
|
|
wmode: MUST_USE_ATTRIBUTE,
|
|
|
|
/**
|
|
* Non-standard Properties
|
|
*/
|
|
autoCapitalize: null, // Supported in Mobile Safari for keyboard hints
|
|
autoCorrect: null, // Supported in Mobile Safari for keyboard hints
|
|
itemProp: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
|
|
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, // Microdata: http://schema.org/docs/gs.html
|
|
itemType: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
|
|
property: null // Supports OG in meta tags
|
|
},
|
|
DOMAttributeNames: {
|
|
acceptCharset: 'accept-charset',
|
|
className: 'class',
|
|
htmlFor: 'for',
|
|
httpEquiv: 'http-equiv'
|
|
},
|
|
DOMPropertyNames: {
|
|
autoCapitalize: 'autocapitalize',
|
|
autoComplete: 'autocomplete',
|
|
autoCorrect: 'autocorrect',
|
|
autoFocus: 'autofocus',
|
|
autoPlay: 'autoplay',
|
|
encType: 'enctype',
|
|
hrefLang: 'hreflang',
|
|
radioGroup: 'radiogroup',
|
|
spellCheck: 'spellcheck',
|
|
srcDoc: 'srcdoc',
|
|
srcSet: 'srcset'
|
|
}
|
|
};
|
|
|
|
module.exports = HTMLDOMPropertyConfig;
|
|
|
|
},{"./DOMProperty":53,"./ExecutionEnvironment":64}],66:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule LinkedStateMixin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactLink = require("./ReactLink");
|
|
var ReactStateSetters = require("./ReactStateSetters");
|
|
|
|
/**
|
|
* A simple mixin around ReactLink.forState().
|
|
*/
|
|
var LinkedStateMixin = {
|
|
/**
|
|
* Create a ReactLink that's linked to part of this component's state. The
|
|
* ReactLink will have the current value of this.state[key] and will call
|
|
* setState() when a change is requested.
|
|
*
|
|
* @param {string} key state key to update. Note: you may want to use keyOf()
|
|
* if you're using Google Closure Compiler advanced mode.
|
|
* @return {ReactLink} ReactLink instance linking to the state.
|
|
*/
|
|
linkState: function(key) {
|
|
return new ReactLink(
|
|
this.state[key],
|
|
ReactStateSetters.createStateKeySetter(this, key)
|
|
);
|
|
}
|
|
};
|
|
|
|
module.exports = LinkedStateMixin;
|
|
|
|
},{"./ReactLink":109,"./ReactStateSetters":126}],67:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule LinkedValueUtils
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactPropTypes = require("./ReactPropTypes");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
var hasReadOnlyValue = {
|
|
'button': true,
|
|
'checkbox': true,
|
|
'image': true,
|
|
'hidden': true,
|
|
'radio': true,
|
|
'reset': true,
|
|
'submit': true
|
|
};
|
|
|
|
function _assertSingleLink(input) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
input.props.checkedLink == null || input.props.valueLink == null,
|
|
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
|
|
'checkedLink, you probably don\'t want to use valueLink and vice versa.'
|
|
) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
|
|
}
|
|
function _assertValueLink(input) {
|
|
_assertSingleLink(input);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
input.props.value == null && input.props.onChange == null,
|
|
'Cannot provide a valueLink and a value or onChange event. If you want ' +
|
|
'to use value or onChange, you probably don\'t want to use valueLink.'
|
|
) : invariant(input.props.value == null && input.props.onChange == null));
|
|
}
|
|
|
|
function _assertCheckedLink(input) {
|
|
_assertSingleLink(input);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
input.props.checked == null && input.props.onChange == null,
|
|
'Cannot provide a checkedLink and a checked property or onChange event. ' +
|
|
'If you want to use checked or onChange, you probably don\'t want to ' +
|
|
'use checkedLink'
|
|
) : invariant(input.props.checked == null && input.props.onChange == null));
|
|
}
|
|
|
|
/**
|
|
* @param {SyntheticEvent} e change event to handle
|
|
*/
|
|
function _handleLinkedValueChange(e) {
|
|
/*jshint validthis:true */
|
|
this.props.valueLink.requestChange(e.target.value);
|
|
}
|
|
|
|
/**
|
|
* @param {SyntheticEvent} e change event to handle
|
|
*/
|
|
function _handleLinkedCheckChange(e) {
|
|
/*jshint validthis:true */
|
|
this.props.checkedLink.requestChange(e.target.checked);
|
|
}
|
|
|
|
/**
|
|
* Provide a linked `value` attribute for controlled forms. You should not use
|
|
* this outside of the ReactDOM controlled form components.
|
|
*/
|
|
var LinkedValueUtils = {
|
|
Mixin: {
|
|
propTypes: {
|
|
value: function(props, propName, componentName) {
|
|
if (!props[propName] ||
|
|
hasReadOnlyValue[props.type] ||
|
|
props.onChange ||
|
|
props.readOnly ||
|
|
props.disabled) {
|
|
return;
|
|
}
|
|
return new Error(
|
|
'You provided a `value` prop to a form field without an ' +
|
|
'`onChange` handler. This will render a read-only field. If ' +
|
|
'the field should be mutable use `defaultValue`. Otherwise, ' +
|
|
'set either `onChange` or `readOnly`.'
|
|
);
|
|
},
|
|
checked: function(props, propName, componentName) {
|
|
if (!props[propName] ||
|
|
props.onChange ||
|
|
props.readOnly ||
|
|
props.disabled) {
|
|
return;
|
|
}
|
|
return new Error(
|
|
'You provided a `checked` prop to a form field without an ' +
|
|
'`onChange` handler. This will render a read-only field. If ' +
|
|
'the field should be mutable use `defaultChecked`. Otherwise, ' +
|
|
'set either `onChange` or `readOnly`.'
|
|
);
|
|
},
|
|
onChange: ReactPropTypes.func
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {ReactComponent} input Form component
|
|
* @return {*} current value of the input either from value prop or link.
|
|
*/
|
|
getValue: function(input) {
|
|
if (input.props.valueLink) {
|
|
_assertValueLink(input);
|
|
return input.props.valueLink.value;
|
|
}
|
|
return input.props.value;
|
|
},
|
|
|
|
/**
|
|
* @param {ReactComponent} input Form component
|
|
* @return {*} current checked status of the input either from checked prop
|
|
* or link.
|
|
*/
|
|
getChecked: function(input) {
|
|
if (input.props.checkedLink) {
|
|
_assertCheckedLink(input);
|
|
return input.props.checkedLink.value;
|
|
}
|
|
return input.props.checked;
|
|
},
|
|
|
|
/**
|
|
* @param {ReactComponent} input Form component
|
|
* @return {function} change callback either from onChange prop or link.
|
|
*/
|
|
getOnChange: function(input) {
|
|
if (input.props.valueLink) {
|
|
_assertValueLink(input);
|
|
return _handleLinkedValueChange;
|
|
} else if (input.props.checkedLink) {
|
|
_assertCheckedLink(input);
|
|
return _handleLinkedCheckChange;
|
|
}
|
|
return input.props.onChange;
|
|
}
|
|
};
|
|
|
|
module.exports = LinkedValueUtils;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactPropTypes":120,"./invariant":182,"_process":1}],68:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule LocalEventTrapMixin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
|
|
var accumulateInto = require("./accumulateInto");
|
|
var forEachAccumulated = require("./forEachAccumulated");
|
|
var invariant = require("./invariant");
|
|
|
|
function remove(event) {
|
|
event.remove();
|
|
}
|
|
|
|
var LocalEventTrapMixin = {
|
|
trapBubbledEvent:function(topLevelType, handlerBaseName) {
|
|
("production" !== process.env.NODE_ENV ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
|
|
var listener = ReactBrowserEventEmitter.trapBubbledEvent(
|
|
topLevelType,
|
|
handlerBaseName,
|
|
this.getDOMNode()
|
|
);
|
|
this._localEventListeners =
|
|
accumulateInto(this._localEventListeners, listener);
|
|
},
|
|
|
|
// trapCapturedEvent would look nearly identical. We don't implement that
|
|
// method because it isn't currently needed.
|
|
|
|
componentWillUnmount:function() {
|
|
if (this._localEventListeners) {
|
|
forEachAccumulated(this._localEventListeners, remove);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = LocalEventTrapMixin;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactBrowserEventEmitter":74,"./accumulateInto":151,"./forEachAccumulated":168,"./invariant":182,"_process":1}],69:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule MobileSafariClickEventPlugin
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
/**
|
|
* Mobile Safari does not fire properly bubble click events on non-interactive
|
|
* elements, which means delegated click listeners do not fire. The workaround
|
|
* for this bug involves attaching an empty click listener on the target node.
|
|
*
|
|
* This particular plugin works around the bug by attaching an empty click
|
|
* listener on `touchstart` (which does fire on every element).
|
|
*/
|
|
var MobileSafariClickEventPlugin = {
|
|
|
|
eventTypes: null,
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
if (topLevelType === topLevelTypes.topTouchStart) {
|
|
var target = nativeEvent.target;
|
|
if (target && !target.onclick) {
|
|
target.onclick = emptyFunction;
|
|
}
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = MobileSafariClickEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./emptyFunction":163}],70:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule Object.assign
|
|
*/
|
|
|
|
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
|
|
|
|
function assign(target, sources) {
|
|
if (target == null) {
|
|
throw new TypeError('Object.assign target cannot be null or undefined');
|
|
}
|
|
|
|
var to = Object(target);
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
|
var nextSource = arguments[nextIndex];
|
|
if (nextSource == null) {
|
|
continue;
|
|
}
|
|
|
|
var from = Object(nextSource);
|
|
|
|
// We don't currently support accessors nor proxies. Therefore this
|
|
// copy cannot throw. If we ever supported this then we must handle
|
|
// exceptions and side-effects. We don't support symbols so they won't
|
|
// be transferred.
|
|
|
|
for (var key in from) {
|
|
if (hasOwnProperty.call(from, key)) {
|
|
to[key] = from[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
return to;
|
|
};
|
|
|
|
module.exports = assign;
|
|
|
|
},{}],71:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule PooledClass
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Static poolers. Several custom versions for each potential number of
|
|
* arguments. A completely generic pooler is easy to implement, but would
|
|
* require accessing the `arguments` object. In each of these, `this` refers to
|
|
* the Class itself, not an instance. If any others are needed, simply add them
|
|
* here, or in their own files.
|
|
*/
|
|
var oneArgumentPooler = function(copyFieldsFrom) {
|
|
var Klass = this;
|
|
if (Klass.instancePool.length) {
|
|
var instance = Klass.instancePool.pop();
|
|
Klass.call(instance, copyFieldsFrom);
|
|
return instance;
|
|
} else {
|
|
return new Klass(copyFieldsFrom);
|
|
}
|
|
};
|
|
|
|
var twoArgumentPooler = function(a1, a2) {
|
|
var Klass = this;
|
|
if (Klass.instancePool.length) {
|
|
var instance = Klass.instancePool.pop();
|
|
Klass.call(instance, a1, a2);
|
|
return instance;
|
|
} else {
|
|
return new Klass(a1, a2);
|
|
}
|
|
};
|
|
|
|
var threeArgumentPooler = function(a1, a2, a3) {
|
|
var Klass = this;
|
|
if (Klass.instancePool.length) {
|
|
var instance = Klass.instancePool.pop();
|
|
Klass.call(instance, a1, a2, a3);
|
|
return instance;
|
|
} else {
|
|
return new Klass(a1, a2, a3);
|
|
}
|
|
};
|
|
|
|
var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
|
|
var Klass = this;
|
|
if (Klass.instancePool.length) {
|
|
var instance = Klass.instancePool.pop();
|
|
Klass.call(instance, a1, a2, a3, a4, a5);
|
|
return instance;
|
|
} else {
|
|
return new Klass(a1, a2, a3, a4, a5);
|
|
}
|
|
};
|
|
|
|
var standardReleaser = function(instance) {
|
|
var Klass = this;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
instance instanceof Klass,
|
|
'Trying to release an instance into a pool of a different type.'
|
|
) : invariant(instance instanceof Klass));
|
|
if (instance.destructor) {
|
|
instance.destructor();
|
|
}
|
|
if (Klass.instancePool.length < Klass.poolSize) {
|
|
Klass.instancePool.push(instance);
|
|
}
|
|
};
|
|
|
|
var DEFAULT_POOL_SIZE = 10;
|
|
var DEFAULT_POOLER = oneArgumentPooler;
|
|
|
|
/**
|
|
* Augments `CopyConstructor` to be a poolable class, augmenting only the class
|
|
* itself (statically) not adding any prototypical fields. Any CopyConstructor
|
|
* you give this may have a `poolSize` property, and will look for a
|
|
* prototypical `destructor` on instances (optional).
|
|
*
|
|
* @param {Function} CopyConstructor Constructor that can be used to reset.
|
|
* @param {Function} pooler Customizable pooler.
|
|
*/
|
|
var addPoolingTo = function(CopyConstructor, pooler) {
|
|
var NewKlass = CopyConstructor;
|
|
NewKlass.instancePool = [];
|
|
NewKlass.getPooled = pooler || DEFAULT_POOLER;
|
|
if (!NewKlass.poolSize) {
|
|
NewKlass.poolSize = DEFAULT_POOL_SIZE;
|
|
}
|
|
NewKlass.release = standardReleaser;
|
|
return NewKlass;
|
|
};
|
|
|
|
var PooledClass = {
|
|
addPoolingTo: addPoolingTo,
|
|
oneArgumentPooler: oneArgumentPooler,
|
|
twoArgumentPooler: twoArgumentPooler,
|
|
threeArgumentPooler: threeArgumentPooler,
|
|
fiveArgumentPooler: fiveArgumentPooler
|
|
};
|
|
|
|
module.exports = PooledClass;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],72:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule React
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
var ReactChildren = require("./ReactChildren");
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactContext = require("./ReactContext");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
var ReactDOM = require("./ReactDOM");
|
|
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
var ReactDefaultInjection = require("./ReactDefaultInjection");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
var ReactPerf = require("./ReactPerf");
|
|
var ReactPropTypes = require("./ReactPropTypes");
|
|
var ReactServerRendering = require("./ReactServerRendering");
|
|
var ReactTextComponent = require("./ReactTextComponent");
|
|
|
|
var assign = require("./Object.assign");
|
|
var deprecated = require("./deprecated");
|
|
var onlyChild = require("./onlyChild");
|
|
|
|
ReactDefaultInjection.inject();
|
|
|
|
var createElement = ReactElement.createElement;
|
|
var createFactory = ReactElement.createFactory;
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
createElement = ReactElementValidator.createElement;
|
|
createFactory = ReactElementValidator.createFactory;
|
|
}
|
|
|
|
// TODO: Drop legacy elements once classes no longer export these factories
|
|
createElement = ReactLegacyElement.wrapCreateElement(
|
|
createElement
|
|
);
|
|
createFactory = ReactLegacyElement.wrapCreateFactory(
|
|
createFactory
|
|
);
|
|
|
|
var render = ReactPerf.measure('React', 'render', ReactMount.render);
|
|
|
|
var React = {
|
|
Children: {
|
|
map: ReactChildren.map,
|
|
forEach: ReactChildren.forEach,
|
|
count: ReactChildren.count,
|
|
only: onlyChild
|
|
},
|
|
DOM: ReactDOM,
|
|
PropTypes: ReactPropTypes,
|
|
initializeTouchEvents: function(shouldUseTouch) {
|
|
EventPluginUtils.useTouchEvents = shouldUseTouch;
|
|
},
|
|
createClass: ReactCompositeComponent.createClass,
|
|
createElement: createElement,
|
|
createFactory: createFactory,
|
|
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
|
|
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
|
|
render: render,
|
|
renderToString: ReactServerRendering.renderToString,
|
|
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
|
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
|
isValidClass: ReactLegacyElement.isValidClass,
|
|
isValidElement: ReactElement.isValidElement,
|
|
withContext: ReactContext.withContext,
|
|
|
|
// Hook for JSX spread, don't use this for anything else.
|
|
__spread: assign,
|
|
|
|
// Deprecations (remove for 0.13)
|
|
renderComponent: deprecated(
|
|
'React',
|
|
'renderComponent',
|
|
'render',
|
|
this,
|
|
render
|
|
),
|
|
renderComponentToString: deprecated(
|
|
'React',
|
|
'renderComponentToString',
|
|
'renderToString',
|
|
this,
|
|
ReactServerRendering.renderToString
|
|
),
|
|
renderComponentToStaticMarkup: deprecated(
|
|
'React',
|
|
'renderComponentToStaticMarkup',
|
|
'renderToStaticMarkup',
|
|
this,
|
|
ReactServerRendering.renderToStaticMarkup
|
|
),
|
|
isValidComponent: deprecated(
|
|
'React',
|
|
'isValidComponent',
|
|
'isValidElement',
|
|
this,
|
|
ReactElement.isValidElement
|
|
)
|
|
};
|
|
|
|
// Inject the runtime into a devtools global hook regardless of browser.
|
|
// Allows for debugging when the hook is injected on the page.
|
|
if (
|
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
|
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
|
|
Component: ReactComponent,
|
|
CurrentOwner: ReactCurrentOwner,
|
|
DOMComponent: ReactDOMComponent,
|
|
DOMPropertyOperations: DOMPropertyOperations,
|
|
InstanceHandles: ReactInstanceHandles,
|
|
Mount: ReactMount,
|
|
MultiChild: ReactMultiChild,
|
|
TextComponent: ReactTextComponent
|
|
});
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
|
|
|
|
// If we're in Chrome, look for the devtools marker and provide a download
|
|
// link if not installed.
|
|
if (navigator.userAgent.indexOf('Chrome') > -1) {
|
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
|
console.debug(
|
|
'Download the React DevTools for a better development experience: ' +
|
|
'http://fb.me/react-devtools'
|
|
);
|
|
}
|
|
}
|
|
|
|
var expectedFeatures = [
|
|
// shims
|
|
Array.isArray,
|
|
Array.prototype.every,
|
|
Array.prototype.forEach,
|
|
Array.prototype.indexOf,
|
|
Array.prototype.map,
|
|
Date.now,
|
|
Function.prototype.bind,
|
|
Object.keys,
|
|
String.prototype.split,
|
|
String.prototype.trim,
|
|
|
|
// shams
|
|
Object.create,
|
|
Object.freeze
|
|
];
|
|
|
|
for (var i = 0; i < expectedFeatures.length; i++) {
|
|
if (!expectedFeatures[i]) {
|
|
console.error(
|
|
'One or more ES5 shim/shams expected by React are not available: ' +
|
|
'http://fb.me/react-warning-polyfills'
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Version exists only in the open-source version of React, not in Facebook's
|
|
// internal version.
|
|
React.version = '0.12.2';
|
|
|
|
module.exports = React;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./DOMPropertyOperations":54,"./EventPluginUtils":62,"./ExecutionEnvironment":64,"./Object.assign":70,"./ReactChildren":77,"./ReactComponent":78,"./ReactCompositeComponent":81,"./ReactContext":82,"./ReactCurrentOwner":83,"./ReactDOM":84,"./ReactDOMComponent":86,"./ReactDefaultInjection":96,"./ReactElement":99,"./ReactElementValidator":100,"./ReactInstanceHandles":107,"./ReactLegacyElement":108,"./ReactMount":111,"./ReactMultiChild":112,"./ReactPerf":116,"./ReactPropTypes":120,"./ReactServerRendering":124,"./ReactTextComponent":128,"./deprecated":162,"./onlyChild":193,"_process":1}],73:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactBrowserComponentMixin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
var ReactMount = require("./ReactMount");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
var ReactBrowserComponentMixin = {
|
|
/**
|
|
* Returns the DOM node rendered by this component.
|
|
*
|
|
* @return {DOMElement} The root node of this component.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
getDOMNode: function() {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isMounted(),
|
|
'getDOMNode(): A component must be mounted to have a DOM node.'
|
|
) : invariant(this.isMounted()));
|
|
if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
|
|
return null;
|
|
}
|
|
return ReactMount.getNode(this._rootNodeID);
|
|
}
|
|
};
|
|
|
|
module.exports = ReactBrowserComponentMixin;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactEmptyComponent":101,"./ReactMount":111,"./invariant":182,"_process":1}],74:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactBrowserEventEmitter
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
var EventPluginRegistry = require("./EventPluginRegistry");
|
|
var ReactEventEmitterMixin = require("./ReactEventEmitterMixin");
|
|
var ViewportMetrics = require("./ViewportMetrics");
|
|
|
|
var assign = require("./Object.assign");
|
|
var isEventSupported = require("./isEventSupported");
|
|
|
|
/**
|
|
* Summary of `ReactBrowserEventEmitter` event handling:
|
|
*
|
|
* - Top-level delegation is used to trap most native browser events. This
|
|
* may only occur in the main thread and is the responsibility of
|
|
* ReactEventListener, which is injected and can therefore support pluggable
|
|
* event sources. This is the only work that occurs in the main thread.
|
|
*
|
|
* - We normalize and de-duplicate events to account for browser quirks. This
|
|
* may be done in the worker thread.
|
|
*
|
|
* - Forward these native events (with the associated top-level type used to
|
|
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
|
|
* to extract any synthetic events.
|
|
*
|
|
* - The `EventPluginHub` will then process each event by annotating them with
|
|
* "dispatches", a sequence of listeners and IDs that care about that event.
|
|
*
|
|
* - The `EventPluginHub` then dispatches the events.
|
|
*
|
|
* Overview of React and the event system:
|
|
*
|
|
* +------------+ .
|
|
* | DOM | .
|
|
* +------------+ .
|
|
* | .
|
|
* v .
|
|
* +------------+ .
|
|
* | ReactEvent | .
|
|
* | Listener | .
|
|
* +------------+ . +-----------+
|
|
* | . +--------+|SimpleEvent|
|
|
* | . | |Plugin |
|
|
* +-----|------+ . v +-----------+
|
|
* | | | . +--------------+ +------------+
|
|
* | +-----------.--->|EventPluginHub| | Event |
|
|
* | | . | | +-----------+ | Propagators|
|
|
* | ReactEvent | . | | |TapEvent | |------------|
|
|
* | Emitter | . | |<---+|Plugin | |other plugin|
|
|
* | | . | | +-----------+ | utilities |
|
|
* | +-----------.--->| | +------------+
|
|
* | | | . +--------------+
|
|
* +-----|------+ . ^ +-----------+
|
|
* | . | |Enter/Leave|
|
|
* + . +-------+|Plugin |
|
|
* +-------------+ . +-----------+
|
|
* | application | .
|
|
* |-------------| .
|
|
* | | .
|
|
* | | .
|
|
* +-------------+ .
|
|
* .
|
|
* React Core . General Purpose Event Plugin System
|
|
*/
|
|
|
|
var alreadyListeningTo = {};
|
|
var isMonitoringScrollValue = false;
|
|
var reactTopListenersCounter = 0;
|
|
|
|
// For events like 'submit' which don't consistently bubble (which we trap at a
|
|
// lower node than `document`), binding at `document` would cause duplicate
|
|
// events so we don't include them here
|
|
var topEventMapping = {
|
|
topBlur: 'blur',
|
|
topChange: 'change',
|
|
topClick: 'click',
|
|
topCompositionEnd: 'compositionend',
|
|
topCompositionStart: 'compositionstart',
|
|
topCompositionUpdate: 'compositionupdate',
|
|
topContextMenu: 'contextmenu',
|
|
topCopy: 'copy',
|
|
topCut: 'cut',
|
|
topDoubleClick: 'dblclick',
|
|
topDrag: 'drag',
|
|
topDragEnd: 'dragend',
|
|
topDragEnter: 'dragenter',
|
|
topDragExit: 'dragexit',
|
|
topDragLeave: 'dragleave',
|
|
topDragOver: 'dragover',
|
|
topDragStart: 'dragstart',
|
|
topDrop: 'drop',
|
|
topFocus: 'focus',
|
|
topInput: 'input',
|
|
topKeyDown: 'keydown',
|
|
topKeyPress: 'keypress',
|
|
topKeyUp: 'keyup',
|
|
topMouseDown: 'mousedown',
|
|
topMouseMove: 'mousemove',
|
|
topMouseOut: 'mouseout',
|
|
topMouseOver: 'mouseover',
|
|
topMouseUp: 'mouseup',
|
|
topPaste: 'paste',
|
|
topScroll: 'scroll',
|
|
topSelectionChange: 'selectionchange',
|
|
topTextInput: 'textInput',
|
|
topTouchCancel: 'touchcancel',
|
|
topTouchEnd: 'touchend',
|
|
topTouchMove: 'touchmove',
|
|
topTouchStart: 'touchstart',
|
|
topWheel: 'wheel'
|
|
};
|
|
|
|
/**
|
|
* To ensure no conflicts with other potential React instances on the page
|
|
*/
|
|
var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2);
|
|
|
|
function getListeningForDocument(mountAt) {
|
|
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
|
|
// directly.
|
|
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
|
|
mountAt[topListenersIDKey] = reactTopListenersCounter++;
|
|
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
|
|
}
|
|
return alreadyListeningTo[mountAt[topListenersIDKey]];
|
|
}
|
|
|
|
/**
|
|
* `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
|
|
* example:
|
|
*
|
|
* ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
|
|
*
|
|
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
|
|
*
|
|
* @internal
|
|
*/
|
|
var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
|
|
|
/**
|
|
* Injectable event backend
|
|
*/
|
|
ReactEventListener: null,
|
|
|
|
injection: {
|
|
/**
|
|
* @param {object} ReactEventListener
|
|
*/
|
|
injectReactEventListener: function(ReactEventListener) {
|
|
ReactEventListener.setHandleTopLevel(
|
|
ReactBrowserEventEmitter.handleTopLevel
|
|
);
|
|
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Sets whether or not any created callbacks should be enabled.
|
|
*
|
|
* @param {boolean} enabled True if callbacks should be enabled.
|
|
*/
|
|
setEnabled: function(enabled) {
|
|
if (ReactBrowserEventEmitter.ReactEventListener) {
|
|
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @return {boolean} True if callbacks are enabled.
|
|
*/
|
|
isEnabled: function() {
|
|
return !!(
|
|
ReactBrowserEventEmitter.ReactEventListener &&
|
|
ReactBrowserEventEmitter.ReactEventListener.isEnabled()
|
|
);
|
|
},
|
|
|
|
/**
|
|
* We listen for bubbled touch events on the document object.
|
|
*
|
|
* Firefox v8.01 (and possibly others) exhibited strange behavior when
|
|
* mounting `onmousemove` events at some node that was not the document
|
|
* element. The symptoms were that if your mouse is not moving over something
|
|
* contained within that mount point (for example on the background) the
|
|
* top-level listeners for `onmousemove` won't be called. However, if you
|
|
* register the `mousemove` on the document object, then it will of course
|
|
* catch all `mousemove`s. This along with iOS quirks, justifies restricting
|
|
* top-level listeners to the document object only, at least for these
|
|
* movement types of events and possibly all events.
|
|
*
|
|
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
|
|
*
|
|
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
|
|
* they bubble to document.
|
|
*
|
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
* @param {object} contentDocumentHandle Document which owns the container
|
|
*/
|
|
listenTo: function(registrationName, contentDocumentHandle) {
|
|
var mountAt = contentDocumentHandle;
|
|
var isListening = getListeningForDocument(mountAt);
|
|
var dependencies = EventPluginRegistry.
|
|
registrationNameDependencies[registrationName];
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
for (var i = 0, l = dependencies.length; i < l; i++) {
|
|
var dependency = dependencies[i];
|
|
if (!(
|
|
isListening.hasOwnProperty(dependency) &&
|
|
isListening[dependency]
|
|
)) {
|
|
if (dependency === topLevelTypes.topWheel) {
|
|
if (isEventSupported('wheel')) {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topWheel,
|
|
'wheel',
|
|
mountAt
|
|
);
|
|
} else if (isEventSupported('mousewheel')) {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topWheel,
|
|
'mousewheel',
|
|
mountAt
|
|
);
|
|
} else {
|
|
// Firefox needs to capture a different mouse scroll event.
|
|
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topWheel,
|
|
'DOMMouseScroll',
|
|
mountAt
|
|
);
|
|
}
|
|
} else if (dependency === topLevelTypes.topScroll) {
|
|
|
|
if (isEventSupported('scroll', true)) {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
topLevelTypes.topScroll,
|
|
'scroll',
|
|
mountAt
|
|
);
|
|
} else {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topScroll,
|
|
'scroll',
|
|
ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
|
|
);
|
|
}
|
|
} else if (dependency === topLevelTypes.topFocus ||
|
|
dependency === topLevelTypes.topBlur) {
|
|
|
|
if (isEventSupported('focus', true)) {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
topLevelTypes.topFocus,
|
|
'focus',
|
|
mountAt
|
|
);
|
|
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
topLevelTypes.topBlur,
|
|
'blur',
|
|
mountAt
|
|
);
|
|
} else if (isEventSupported('focusin')) {
|
|
// IE has `focusin` and `focusout` events which bubble.
|
|
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topFocus,
|
|
'focusin',
|
|
mountAt
|
|
);
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelTypes.topBlur,
|
|
'focusout',
|
|
mountAt
|
|
);
|
|
}
|
|
|
|
// to make sure blur and focus event listeners are only attached once
|
|
isListening[topLevelTypes.topBlur] = true;
|
|
isListening[topLevelTypes.topFocus] = true;
|
|
} else if (topEventMapping.hasOwnProperty(dependency)) {
|
|
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
dependency,
|
|
topEventMapping[dependency],
|
|
mountAt
|
|
);
|
|
}
|
|
|
|
isListening[dependency] = true;
|
|
}
|
|
}
|
|
},
|
|
|
|
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
|
|
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
topLevelType,
|
|
handlerBaseName,
|
|
handle
|
|
);
|
|
},
|
|
|
|
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
|
|
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
topLevelType,
|
|
handlerBaseName,
|
|
handle
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Listens to window scroll and resize events. We cache scroll values so that
|
|
* application code can access them without triggering reflows.
|
|
*
|
|
* NOTE: Scroll events do not bubble.
|
|
*
|
|
* @see http://www.quirksmode.org/dom/events/scroll.html
|
|
*/
|
|
ensureScrollValueMonitoring: function(){
|
|
if (!isMonitoringScrollValue) {
|
|
var refresh = ViewportMetrics.refreshScrollValues;
|
|
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
|
|
isMonitoringScrollValue = true;
|
|
}
|
|
},
|
|
|
|
eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
|
|
|
|
registrationNameModules: EventPluginHub.registrationNameModules,
|
|
|
|
putListener: EventPluginHub.putListener,
|
|
|
|
getListener: EventPluginHub.getListener,
|
|
|
|
deleteListener: EventPluginHub.deleteListener,
|
|
|
|
deleteAllListeners: EventPluginHub.deleteAllListeners
|
|
|
|
});
|
|
|
|
module.exports = ReactBrowserEventEmitter;
|
|
|
|
},{"./EventConstants":58,"./EventPluginHub":60,"./EventPluginRegistry":61,"./Object.assign":70,"./ReactEventEmitterMixin":103,"./ViewportMetrics":150,"./isEventSupported":183}],75:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @typechecks
|
|
* @providesModule ReactCSSTransitionGroup
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var React = require("./React");
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
var ReactTransitionGroup = React.createFactory(
|
|
require("./ReactTransitionGroup")
|
|
);
|
|
var ReactCSSTransitionGroupChild = React.createFactory(
|
|
require("./ReactCSSTransitionGroupChild")
|
|
);
|
|
|
|
var ReactCSSTransitionGroup = React.createClass({
|
|
displayName: 'ReactCSSTransitionGroup',
|
|
|
|
propTypes: {
|
|
transitionName: React.PropTypes.string.isRequired,
|
|
transitionEnter: React.PropTypes.bool,
|
|
transitionLeave: React.PropTypes.bool
|
|
},
|
|
|
|
getDefaultProps: function() {
|
|
return {
|
|
transitionEnter: true,
|
|
transitionLeave: true
|
|
};
|
|
},
|
|
|
|
_wrapChild: function(child) {
|
|
// We need to provide this childFactory so that
|
|
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
|
|
// leave while it is leaving.
|
|
return ReactCSSTransitionGroupChild(
|
|
{
|
|
name: this.props.transitionName,
|
|
enter: this.props.transitionEnter,
|
|
leave: this.props.transitionLeave
|
|
},
|
|
child
|
|
);
|
|
},
|
|
|
|
render: function() {
|
|
return (
|
|
ReactTransitionGroup(
|
|
assign({}, this.props, {childFactory: this._wrapChild})
|
|
)
|
|
);
|
|
}
|
|
});
|
|
|
|
module.exports = ReactCSSTransitionGroup;
|
|
|
|
},{"./Object.assign":70,"./React":72,"./ReactCSSTransitionGroupChild":76,"./ReactTransitionGroup":131}],76:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @typechecks
|
|
* @providesModule ReactCSSTransitionGroupChild
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var React = require("./React");
|
|
|
|
var CSSCore = require("./CSSCore");
|
|
var ReactTransitionEvents = require("./ReactTransitionEvents");
|
|
|
|
var onlyChild = require("./onlyChild");
|
|
|
|
// We don't remove the element from the DOM until we receive an animationend or
|
|
// transitionend event. If the user screws up and forgets to add an animation
|
|
// their node will be stuck in the DOM forever, so we detect if an animation
|
|
// does not start and if it doesn't, we just call the end listener immediately.
|
|
var TICK = 17;
|
|
var NO_EVENT_TIMEOUT = 5000;
|
|
|
|
var noEventListener = null;
|
|
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
noEventListener = function() {
|
|
console.warn(
|
|
'transition(): tried to perform an animation without ' +
|
|
'an animationend or transitionend event after timeout (' +
|
|
NO_EVENT_TIMEOUT + 'ms). You should either disable this ' +
|
|
'transition in JS or add a CSS animation/transition.'
|
|
);
|
|
};
|
|
}
|
|
|
|
var ReactCSSTransitionGroupChild = React.createClass({
|
|
displayName: 'ReactCSSTransitionGroupChild',
|
|
|
|
transition: function(animationType, finishCallback) {
|
|
var node = this.getDOMNode();
|
|
var className = this.props.name + '-' + animationType;
|
|
var activeClassName = className + '-active';
|
|
var noEventTimeout = null;
|
|
|
|
var endListener = function(e) {
|
|
if (e && e.target !== node) {
|
|
return;
|
|
}
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
clearTimeout(noEventTimeout);
|
|
}
|
|
|
|
CSSCore.removeClass(node, className);
|
|
CSSCore.removeClass(node, activeClassName);
|
|
|
|
ReactTransitionEvents.removeEndEventListener(node, endListener);
|
|
|
|
// Usually this optional callback is used for informing an owner of
|
|
// a leave animation and telling it to remove the child.
|
|
finishCallback && finishCallback();
|
|
};
|
|
|
|
ReactTransitionEvents.addEndEventListener(node, endListener);
|
|
|
|
CSSCore.addClass(node, className);
|
|
|
|
// Need to do this to actually trigger a transition.
|
|
this.queueClass(activeClassName);
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
noEventTimeout = setTimeout(noEventListener, NO_EVENT_TIMEOUT);
|
|
}
|
|
},
|
|
|
|
queueClass: function(className) {
|
|
this.classNameQueue.push(className);
|
|
|
|
if (!this.timeout) {
|
|
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
|
|
}
|
|
},
|
|
|
|
flushClassNameQueue: function() {
|
|
if (this.isMounted()) {
|
|
this.classNameQueue.forEach(
|
|
CSSCore.addClass.bind(CSSCore, this.getDOMNode())
|
|
);
|
|
}
|
|
this.classNameQueue.length = 0;
|
|
this.timeout = null;
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
this.classNameQueue = [];
|
|
},
|
|
|
|
componentWillUnmount: function() {
|
|
if (this.timeout) {
|
|
clearTimeout(this.timeout);
|
|
}
|
|
},
|
|
|
|
componentWillEnter: function(done) {
|
|
if (this.props.enter) {
|
|
this.transition('enter', done);
|
|
} else {
|
|
done();
|
|
}
|
|
},
|
|
|
|
componentWillLeave: function(done) {
|
|
if (this.props.leave) {
|
|
this.transition('leave', done);
|
|
} else {
|
|
done();
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
return onlyChild(this.props.children);
|
|
}
|
|
});
|
|
|
|
module.exports = ReactCSSTransitionGroupChild;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./CSSCore":45,"./React":72,"./ReactTransitionEvents":130,"./onlyChild":193,"_process":1}],77:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactChildren
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var PooledClass = require("./PooledClass");
|
|
|
|
var traverseAllChildren = require("./traverseAllChildren");
|
|
var warning = require("./warning");
|
|
|
|
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
|
var threeArgumentPooler = PooledClass.threeArgumentPooler;
|
|
|
|
/**
|
|
* PooledClass representing the bookkeeping associated with performing a child
|
|
* traversal. Allows avoiding binding callbacks.
|
|
*
|
|
* @constructor ForEachBookKeeping
|
|
* @param {!function} forEachFunction Function to perform traversal with.
|
|
* @param {?*} forEachContext Context to perform context with.
|
|
*/
|
|
function ForEachBookKeeping(forEachFunction, forEachContext) {
|
|
this.forEachFunction = forEachFunction;
|
|
this.forEachContext = forEachContext;
|
|
}
|
|
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
|
|
|
function forEachSingleChild(traverseContext, child, name, i) {
|
|
var forEachBookKeeping = traverseContext;
|
|
forEachBookKeeping.forEachFunction.call(
|
|
forEachBookKeeping.forEachContext, child, i);
|
|
}
|
|
|
|
/**
|
|
* Iterates through children that are typically specified as `props.children`.
|
|
*
|
|
* The provided forEachFunc(child, index) will be called for each
|
|
* leaf child.
|
|
*
|
|
* @param {?*} children Children tree container.
|
|
* @param {function(*, int)} forEachFunc.
|
|
* @param {*} forEachContext Context for forEachContext.
|
|
*/
|
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
if (children == null) {
|
|
return children;
|
|
}
|
|
|
|
var traverseContext =
|
|
ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
|
ForEachBookKeeping.release(traverseContext);
|
|
}
|
|
|
|
/**
|
|
* PooledClass representing the bookkeeping associated with performing a child
|
|
* mapping. Allows avoiding binding callbacks.
|
|
*
|
|
* @constructor MapBookKeeping
|
|
* @param {!*} mapResult Object containing the ordered map of results.
|
|
* @param {!function} mapFunction Function to perform mapping with.
|
|
* @param {?*} mapContext Context to perform mapping with.
|
|
*/
|
|
function MapBookKeeping(mapResult, mapFunction, mapContext) {
|
|
this.mapResult = mapResult;
|
|
this.mapFunction = mapFunction;
|
|
this.mapContext = mapContext;
|
|
}
|
|
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
|
|
|
|
function mapSingleChildIntoContext(traverseContext, child, name, i) {
|
|
var mapBookKeeping = traverseContext;
|
|
var mapResult = mapBookKeeping.mapResult;
|
|
|
|
var keyUnique = !mapResult.hasOwnProperty(name);
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
keyUnique,
|
|
'ReactChildren.map(...): Encountered two children with the same key, ' +
|
|
'`%s`. Child keys must be unique; when two children share a key, only ' +
|
|
'the first child will be used.',
|
|
name
|
|
) : null);
|
|
|
|
if (keyUnique) {
|
|
var mappedChild =
|
|
mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
|
|
mapResult[name] = mappedChild;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Maps children that are typically specified as `props.children`.
|
|
*
|
|
* The provided mapFunction(child, key, index) will be called for each
|
|
* leaf child.
|
|
*
|
|
* TODO: This may likely break any calls to `ReactChildren.map` that were
|
|
* previously relying on the fact that we guarded against null children.
|
|
*
|
|
* @param {?*} children Children tree container.
|
|
* @param {function(*, int)} mapFunction.
|
|
* @param {*} mapContext Context for mapFunction.
|
|
* @return {object} Object containing the ordered map of results.
|
|
*/
|
|
function mapChildren(children, func, context) {
|
|
if (children == null) {
|
|
return children;
|
|
}
|
|
|
|
var mapResult = {};
|
|
var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
|
|
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
MapBookKeeping.release(traverseContext);
|
|
return mapResult;
|
|
}
|
|
|
|
function forEachSingleChildDummy(traverseContext, child, name, i) {
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Count the number of children that are typically specified as
|
|
* `props.children`.
|
|
*
|
|
* @param {?*} children Children tree container.
|
|
* @return {number} The number of children.
|
|
*/
|
|
function countChildren(children, context) {
|
|
return traverseAllChildren(children, forEachSingleChildDummy, null);
|
|
}
|
|
|
|
var ReactChildren = {
|
|
forEach: forEachChildren,
|
|
map: mapChildren,
|
|
count: countChildren
|
|
};
|
|
|
|
module.exports = ReactChildren;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./PooledClass":71,"./traverseAllChildren":200,"./warning":202,"_process":1}],78:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactComponent
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactOwner = require("./ReactOwner");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
var keyMirror = require("./keyMirror");
|
|
|
|
/**
|
|
* Every React component is in one of these life cycles.
|
|
*/
|
|
var ComponentLifeCycle = keyMirror({
|
|
/**
|
|
* Mounted components have a DOM node representation and are capable of
|
|
* receiving new props.
|
|
*/
|
|
MOUNTED: null,
|
|
/**
|
|
* Unmounted components are inactive and cannot receive new props.
|
|
*/
|
|
UNMOUNTED: null
|
|
});
|
|
|
|
var injected = false;
|
|
|
|
/**
|
|
* Optionally injectable environment dependent cleanup hook. (server vs.
|
|
* browser etc). Example: A browser system caches DOM nodes based on component
|
|
* ID and must remove that cache entry when this instance is unmounted.
|
|
*
|
|
* @private
|
|
*/
|
|
var unmountIDFromEnvironment = null;
|
|
|
|
/**
|
|
* The "image" of a component tree, is the platform specific (typically
|
|
* serialized) data that represents a tree of lower level UI building blocks.
|
|
* On the web, this "image" is HTML markup which describes a construction of
|
|
* low level `div` and `span` nodes. Other platforms may have different
|
|
* encoding of this "image". This must be injected.
|
|
*
|
|
* @private
|
|
*/
|
|
var mountImageIntoNode = null;
|
|
|
|
/**
|
|
* Components are the basic units of composition in React.
|
|
*
|
|
* Every component accepts a set of keyed input parameters known as "props" that
|
|
* are initialized by the constructor. Once a component is mounted, the props
|
|
* can be mutated using `setProps` or `replaceProps`.
|
|
*
|
|
* Every component is capable of the following operations:
|
|
*
|
|
* `mountComponent`
|
|
* Initializes the component, renders markup, and registers event listeners.
|
|
*
|
|
* `receiveComponent`
|
|
* Updates the rendered DOM nodes to match the given component.
|
|
*
|
|
* `unmountComponent`
|
|
* Releases any resources allocated by this component.
|
|
*
|
|
* Components can also be "owned" by other components. Being owned by another
|
|
* component means being constructed by that component. This is different from
|
|
* being the child of a component, which means having a DOM representation that
|
|
* is a child of the DOM representation of that component.
|
|
*
|
|
* @class ReactComponent
|
|
*/
|
|
var ReactComponent = {
|
|
|
|
injection: {
|
|
injectEnvironment: function(ReactComponentEnvironment) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!injected,
|
|
'ReactComponent: injectEnvironment() can only be called once.'
|
|
) : invariant(!injected));
|
|
mountImageIntoNode = ReactComponentEnvironment.mountImageIntoNode;
|
|
unmountIDFromEnvironment =
|
|
ReactComponentEnvironment.unmountIDFromEnvironment;
|
|
ReactComponent.BackendIDOperations =
|
|
ReactComponentEnvironment.BackendIDOperations;
|
|
injected = true;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
LifeCycle: ComponentLifeCycle,
|
|
|
|
/**
|
|
* Injected module that provides ability to mutate individual properties.
|
|
* Injected into the base class because many different subclasses need access
|
|
* to this.
|
|
*
|
|
* @internal
|
|
*/
|
|
BackendIDOperations: null,
|
|
|
|
/**
|
|
* Base functionality for every ReactComponent constructor. Mixed into the
|
|
* `ReactComponent` prototype, but exposed statically for easy access.
|
|
*
|
|
* @lends {ReactComponent.prototype}
|
|
*/
|
|
Mixin: {
|
|
|
|
/**
|
|
* Checks whether or not this component is mounted.
|
|
*
|
|
* @return {boolean} True if mounted, false otherwise.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
isMounted: function() {
|
|
return this._lifeCycleState === ComponentLifeCycle.MOUNTED;
|
|
},
|
|
|
|
/**
|
|
* Sets a subset of the props.
|
|
*
|
|
* @param {object} partialProps Subset of the next props.
|
|
* @param {?function} callback Called after props are updated.
|
|
* @final
|
|
* @public
|
|
*/
|
|
setProps: function(partialProps, callback) {
|
|
// Merge with the pending element if it exists, otherwise with existing
|
|
// element props.
|
|
var element = this._pendingElement || this._currentElement;
|
|
this.replaceProps(
|
|
assign({}, element.props, partialProps),
|
|
callback
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Replaces all of the props.
|
|
*
|
|
* @param {object} props New props.
|
|
* @param {?function} callback Called after props are updated.
|
|
* @final
|
|
* @public
|
|
*/
|
|
replaceProps: function(props, callback) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isMounted(),
|
|
'replaceProps(...): Can only update a mounted component.'
|
|
) : invariant(this.isMounted()));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this._mountDepth === 0,
|
|
'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
|
|
'component with a parent. This is an anti-pattern since props will ' +
|
|
'get reactively updated when rendered. Instead, change the owner\'s ' +
|
|
'`render` method to pass the correct value as props to the component ' +
|
|
'where it is created.'
|
|
) : invariant(this._mountDepth === 0));
|
|
// This is a deoptimized path. We optimize for always having a element.
|
|
// This creates an extra internal element.
|
|
this._pendingElement = ReactElement.cloneAndReplaceProps(
|
|
this._pendingElement || this._currentElement,
|
|
props
|
|
);
|
|
ReactUpdates.enqueueUpdate(this, callback);
|
|
},
|
|
|
|
/**
|
|
* Schedule a partial update to the props. Only used for internal testing.
|
|
*
|
|
* @param {object} partialProps Subset of the next props.
|
|
* @param {?function} callback Called after props are updated.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
_setPropsInternal: function(partialProps, callback) {
|
|
// This is a deoptimized path. We optimize for always having a element.
|
|
// This creates an extra internal element.
|
|
var element = this._pendingElement || this._currentElement;
|
|
this._pendingElement = ReactElement.cloneAndReplaceProps(
|
|
element,
|
|
assign({}, element.props, partialProps)
|
|
);
|
|
ReactUpdates.enqueueUpdate(this, callback);
|
|
},
|
|
|
|
/**
|
|
* Base constructor for all React components.
|
|
*
|
|
* Subclasses that override this method should make sure to invoke
|
|
* `ReactComponent.Mixin.construct.call(this, ...)`.
|
|
*
|
|
* @param {ReactElement} element
|
|
* @internal
|
|
*/
|
|
construct: function(element) {
|
|
// This is the public exposed props object after it has been processed
|
|
// with default props. The element's props represents the true internal
|
|
// state of the props.
|
|
this.props = element.props;
|
|
// Record the component responsible for creating this component.
|
|
// This is accessible through the element but we maintain an extra
|
|
// field for compatibility with devtools and as a way to make an
|
|
// incremental update. TODO: Consider deprecating this field.
|
|
this._owner = element._owner;
|
|
|
|
// All components start unmounted.
|
|
this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
|
|
|
|
// See ReactUpdates.
|
|
this._pendingCallbacks = null;
|
|
|
|
// We keep the old element and a reference to the pending element
|
|
// to track updates.
|
|
this._currentElement = element;
|
|
this._pendingElement = null;
|
|
},
|
|
|
|
/**
|
|
* Initializes the component, renders markup, and registers event listeners.
|
|
*
|
|
* NOTE: This does not insert any nodes into the DOM.
|
|
*
|
|
* Subclasses that override this method should make sure to invoke
|
|
* `ReactComponent.Mixin.mountComponent.call(this, ...)`.
|
|
*
|
|
* @param {string} rootID DOM ID of the root node.
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @param {number} mountDepth number of components in the owner hierarchy.
|
|
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
* @internal
|
|
*/
|
|
mountComponent: function(rootID, transaction, mountDepth) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!this.isMounted(),
|
|
'mountComponent(%s, ...): Can only mount an unmounted component. ' +
|
|
'Make sure to avoid storing components between renders or reusing a ' +
|
|
'single component instance in multiple places.',
|
|
rootID
|
|
) : invariant(!this.isMounted()));
|
|
var ref = this._currentElement.ref;
|
|
if (ref != null) {
|
|
var owner = this._currentElement._owner;
|
|
ReactOwner.addComponentAsRefTo(this, ref, owner);
|
|
}
|
|
this._rootNodeID = rootID;
|
|
this._lifeCycleState = ComponentLifeCycle.MOUNTED;
|
|
this._mountDepth = mountDepth;
|
|
// Effectively: return '';
|
|
},
|
|
|
|
/**
|
|
* Releases any resources allocated by `mountComponent`.
|
|
*
|
|
* NOTE: This does not remove any nodes from the DOM.
|
|
*
|
|
* Subclasses that override this method should make sure to invoke
|
|
* `ReactComponent.Mixin.unmountComponent.call(this)`.
|
|
*
|
|
* @internal
|
|
*/
|
|
unmountComponent: function() {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isMounted(),
|
|
'unmountComponent(): Can only unmount a mounted component.'
|
|
) : invariant(this.isMounted()));
|
|
var ref = this._currentElement.ref;
|
|
if (ref != null) {
|
|
ReactOwner.removeComponentAsRefFrom(this, ref, this._owner);
|
|
}
|
|
unmountIDFromEnvironment(this._rootNodeID);
|
|
this._rootNodeID = null;
|
|
this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
|
|
},
|
|
|
|
/**
|
|
* Given a new instance of this component, updates the rendered DOM nodes
|
|
* as if that instance was rendered instead.
|
|
*
|
|
* Subclasses that override this method should make sure to invoke
|
|
* `ReactComponent.Mixin.receiveComponent.call(this, ...)`.
|
|
*
|
|
* @param {object} nextComponent Next set of properties.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
*/
|
|
receiveComponent: function(nextElement, transaction) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isMounted(),
|
|
'receiveComponent(...): Can only update a mounted component.'
|
|
) : invariant(this.isMounted()));
|
|
this._pendingElement = nextElement;
|
|
this.performUpdateIfNecessary(transaction);
|
|
},
|
|
|
|
/**
|
|
* If `_pendingElement` is set, update the component.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
*/
|
|
performUpdateIfNecessary: function(transaction) {
|
|
if (this._pendingElement == null) {
|
|
return;
|
|
}
|
|
var prevElement = this._currentElement;
|
|
var nextElement = this._pendingElement;
|
|
this._currentElement = nextElement;
|
|
this.props = nextElement.props;
|
|
this._owner = nextElement._owner;
|
|
this._pendingElement = null;
|
|
this.updateComponent(transaction, prevElement);
|
|
},
|
|
|
|
/**
|
|
* Updates the component's currently mounted representation.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @param {object} prevElement
|
|
* @internal
|
|
*/
|
|
updateComponent: function(transaction, prevElement) {
|
|
var nextElement = this._currentElement;
|
|
|
|
// If either the owner or a `ref` has changed, make sure the newest owner
|
|
// has stored a reference to `this`, and the previous owner (if different)
|
|
// has forgotten the reference to `this`. We use the element instead
|
|
// of the public this.props because the post processing cannot determine
|
|
// a ref. The ref conceptually lives on the element.
|
|
|
|
// TODO: Should this even be possible? The owner cannot change because
|
|
// it's forbidden by shouldUpdateReactComponent. The ref can change
|
|
// if you swap the keys of but not the refs. Reconsider where this check
|
|
// is made. It probably belongs where the key checking and
|
|
// instantiateReactComponent is done.
|
|
|
|
if (nextElement._owner !== prevElement._owner ||
|
|
nextElement.ref !== prevElement.ref) {
|
|
if (prevElement.ref != null) {
|
|
ReactOwner.removeComponentAsRefFrom(
|
|
this, prevElement.ref, prevElement._owner
|
|
);
|
|
}
|
|
// Correct, even if the owner is the same, and only the ref has changed.
|
|
if (nextElement.ref != null) {
|
|
ReactOwner.addComponentAsRefTo(
|
|
this,
|
|
nextElement.ref,
|
|
nextElement._owner
|
|
);
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Mounts this component and inserts it into the DOM.
|
|
*
|
|
* @param {string} rootID DOM ID of the root node.
|
|
* @param {DOMElement} container DOM element to mount into.
|
|
* @param {boolean} shouldReuseMarkup If true, do not insert markup
|
|
* @final
|
|
* @internal
|
|
* @see {ReactMount.render}
|
|
*/
|
|
mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
|
|
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
|
|
transaction.perform(
|
|
this._mountComponentIntoNode,
|
|
this,
|
|
rootID,
|
|
container,
|
|
transaction,
|
|
shouldReuseMarkup
|
|
);
|
|
ReactUpdates.ReactReconcileTransaction.release(transaction);
|
|
},
|
|
|
|
/**
|
|
* @param {string} rootID DOM ID of the root node.
|
|
* @param {DOMElement} container DOM element to mount into.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @param {boolean} shouldReuseMarkup If true, do not insert markup
|
|
* @final
|
|
* @private
|
|
*/
|
|
_mountComponentIntoNode: function(
|
|
rootID,
|
|
container,
|
|
transaction,
|
|
shouldReuseMarkup) {
|
|
var markup = this.mountComponent(rootID, transaction, 0);
|
|
mountImageIntoNode(markup, container, shouldReuseMarkup);
|
|
},
|
|
|
|
/**
|
|
* Checks if this component is owned by the supplied `owner` component.
|
|
*
|
|
* @param {ReactComponent} owner Component to check.
|
|
* @return {boolean} True if `owners` owns this component.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
isOwnedBy: function(owner) {
|
|
return this._owner === owner;
|
|
},
|
|
|
|
/**
|
|
* Gets another component, that shares the same owner as this one, by ref.
|
|
*
|
|
* @param {string} ref of a sibling Component.
|
|
* @return {?ReactComponent} the actual sibling Component.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
getSiblingByRef: function(ref) {
|
|
var owner = this._owner;
|
|
if (!owner || !owner.refs) {
|
|
return null;
|
|
}
|
|
return owner.refs[ref];
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = ReactComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./ReactElement":99,"./ReactOwner":115,"./ReactUpdates":132,"./invariant":182,"./keyMirror":188,"_process":1}],79:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactComponentBrowserEnvironment
|
|
*/
|
|
|
|
/*jslint evil: true */
|
|
|
|
"use strict";
|
|
|
|
var ReactDOMIDOperations = require("./ReactDOMIDOperations");
|
|
var ReactMarkupChecksum = require("./ReactMarkupChecksum");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactPerf = require("./ReactPerf");
|
|
var ReactReconcileTransaction = require("./ReactReconcileTransaction");
|
|
|
|
var getReactRootElementInContainer = require("./getReactRootElementInContainer");
|
|
var invariant = require("./invariant");
|
|
var setInnerHTML = require("./setInnerHTML");
|
|
|
|
|
|
var ELEMENT_NODE_TYPE = 1;
|
|
var DOC_NODE_TYPE = 9;
|
|
|
|
|
|
/**
|
|
* Abstracts away all functionality of `ReactComponent` requires knowledge of
|
|
* the browser context.
|
|
*/
|
|
var ReactComponentBrowserEnvironment = {
|
|
ReactReconcileTransaction: ReactReconcileTransaction,
|
|
|
|
BackendIDOperations: ReactDOMIDOperations,
|
|
|
|
/**
|
|
* If a particular environment requires that some resources be cleaned up,
|
|
* specify this in the injected Mixin. In the DOM, we would likely want to
|
|
* purge any cached node ID lookups.
|
|
*
|
|
* @private
|
|
*/
|
|
unmountIDFromEnvironment: function(rootNodeID) {
|
|
ReactMount.purgeID(rootNodeID);
|
|
},
|
|
|
|
/**
|
|
* @param {string} markup Markup string to place into the DOM Element.
|
|
* @param {DOMElement} container DOM Element to insert markup into.
|
|
* @param {boolean} shouldReuseMarkup Should reuse the existing markup in the
|
|
* container if possible.
|
|
*/
|
|
mountImageIntoNode: ReactPerf.measure(
|
|
'ReactComponentBrowserEnvironment',
|
|
'mountImageIntoNode',
|
|
function(markup, container, shouldReuseMarkup) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
container && (
|
|
container.nodeType === ELEMENT_NODE_TYPE ||
|
|
container.nodeType === DOC_NODE_TYPE
|
|
),
|
|
'mountComponentIntoNode(...): Target container is not valid.'
|
|
) : invariant(container && (
|
|
container.nodeType === ELEMENT_NODE_TYPE ||
|
|
container.nodeType === DOC_NODE_TYPE
|
|
)));
|
|
|
|
if (shouldReuseMarkup) {
|
|
if (ReactMarkupChecksum.canReuseMarkup(
|
|
markup,
|
|
getReactRootElementInContainer(container))) {
|
|
return;
|
|
} else {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
container.nodeType !== DOC_NODE_TYPE,
|
|
'You\'re trying to render a component to the document using ' +
|
|
'server rendering but the checksum was invalid. This usually ' +
|
|
'means you rendered a different component type or props on ' +
|
|
'the client from the one on the server, or your render() ' +
|
|
'methods are impure. React cannot handle this case due to ' +
|
|
'cross-browser quirks by rendering at the document root. You ' +
|
|
'should look for environment dependent code in your components ' +
|
|
'and ensure the props are the same client and server side.'
|
|
) : invariant(container.nodeType !== DOC_NODE_TYPE));
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
console.warn(
|
|
'React attempted to use reuse markup in a container but the ' +
|
|
'checksum was invalid. This generally means that you are ' +
|
|
'using server rendering and the markup generated on the ' +
|
|
'server was not what the client was expecting. React injected ' +
|
|
'new markup to compensate which works but you have lost many ' +
|
|
'of the benefits of server rendering. Instead, figure out ' +
|
|
'why the markup being generated is different on the client ' +
|
|
'or server.'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
container.nodeType !== DOC_NODE_TYPE,
|
|
'You\'re trying to render a component to the document but ' +
|
|
'you didn\'t use server rendering. We can\'t do this ' +
|
|
'without using server rendering due to cross-browser quirks. ' +
|
|
'See renderComponentToString() for server rendering.'
|
|
) : invariant(container.nodeType !== DOC_NODE_TYPE));
|
|
|
|
setInnerHTML(container, markup);
|
|
}
|
|
)
|
|
};
|
|
|
|
module.exports = ReactComponentBrowserEnvironment;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactDOMIDOperations":88,"./ReactMarkupChecksum":110,"./ReactMount":111,"./ReactPerf":116,"./ReactReconcileTransaction":122,"./getReactRootElementInContainer":176,"./invariant":182,"./setInnerHTML":196,"_process":1}],80:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactComponentWithPureRenderMixin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var shallowEqual = require("./shallowEqual");
|
|
|
|
/**
|
|
* If your React component's render function is "pure", e.g. it will render the
|
|
* same result given the same props and state, provide this Mixin for a
|
|
* considerable performance boost.
|
|
*
|
|
* Most React components have pure render functions.
|
|
*
|
|
* Example:
|
|
*
|
|
* var ReactComponentWithPureRenderMixin =
|
|
* require('ReactComponentWithPureRenderMixin');
|
|
* React.createClass({
|
|
* mixins: [ReactComponentWithPureRenderMixin],
|
|
*
|
|
* render: function() {
|
|
* return <div className={this.props.className}>foo</div>;
|
|
* }
|
|
* });
|
|
*
|
|
* Note: This only checks shallow equality for props and state. If these contain
|
|
* complex data structures this mixin may have false-negatives for deeper
|
|
* differences. Only mixin to components which have simple props and state, or
|
|
* use `forceUpdate()` when you know deep data structures have changed.
|
|
*/
|
|
var ReactComponentWithPureRenderMixin = {
|
|
shouldComponentUpdate: function(nextProps, nextState) {
|
|
return !shallowEqual(this.props, nextProps) ||
|
|
!shallowEqual(this.state, nextState);
|
|
}
|
|
};
|
|
|
|
module.exports = ReactComponentWithPureRenderMixin;
|
|
|
|
},{"./shallowEqual":197}],81:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactCompositeComponent
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactContext = require("./ReactContext");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
var ReactErrorUtils = require("./ReactErrorUtils");
|
|
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
var ReactOwner = require("./ReactOwner");
|
|
var ReactPerf = require("./ReactPerf");
|
|
var ReactPropTransferer = require("./ReactPropTransferer");
|
|
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
|
|
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
var invariant = require("./invariant");
|
|
var keyMirror = require("./keyMirror");
|
|
var keyOf = require("./keyOf");
|
|
var monitorCodeUse = require("./monitorCodeUse");
|
|
var mapObject = require("./mapObject");
|
|
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
var warning = require("./warning");
|
|
|
|
var MIXINS_KEY = keyOf({mixins: null});
|
|
|
|
/**
|
|
* Policies that describe methods in `ReactCompositeComponentInterface`.
|
|
*/
|
|
var SpecPolicy = keyMirror({
|
|
/**
|
|
* These methods may be defined only once by the class specification or mixin.
|
|
*/
|
|
DEFINE_ONCE: null,
|
|
/**
|
|
* These methods may be defined by both the class specification and mixins.
|
|
* Subsequent definitions will be chained. These methods must return void.
|
|
*/
|
|
DEFINE_MANY: null,
|
|
/**
|
|
* These methods are overriding the base ReactCompositeComponent class.
|
|
*/
|
|
OVERRIDE_BASE: null,
|
|
/**
|
|
* These methods are similar to DEFINE_MANY, except we assume they return
|
|
* objects. We try to merge the keys of the return values of all the mixed in
|
|
* functions. If there is a key conflict we throw.
|
|
*/
|
|
DEFINE_MANY_MERGED: null
|
|
});
|
|
|
|
|
|
var injectedMixins = [];
|
|
|
|
/**
|
|
* Composite components are higher-level components that compose other composite
|
|
* or native components.
|
|
*
|
|
* To create a new type of `ReactCompositeComponent`, pass a specification of
|
|
* your new class to `React.createClass`. The only requirement of your class
|
|
* specification is that you implement a `render` method.
|
|
*
|
|
* var MyComponent = React.createClass({
|
|
* render: function() {
|
|
* return <div>Hello World</div>;
|
|
* }
|
|
* });
|
|
*
|
|
* The class specification supports a specific protocol of methods that have
|
|
* special meaning (e.g. `render`). See `ReactCompositeComponentInterface` for
|
|
* more the comprehensive protocol. Any other properties and methods in the
|
|
* class specification will available on the prototype.
|
|
*
|
|
* @interface ReactCompositeComponentInterface
|
|
* @internal
|
|
*/
|
|
var ReactCompositeComponentInterface = {
|
|
|
|
/**
|
|
* An array of Mixin objects to include when defining your component.
|
|
*
|
|
* @type {array}
|
|
* @optional
|
|
*/
|
|
mixins: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* An object containing properties and methods that should be defined on
|
|
* the component's constructor instead of its prototype (static methods).
|
|
*
|
|
* @type {object}
|
|
* @optional
|
|
*/
|
|
statics: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Definition of prop types for this component.
|
|
*
|
|
* @type {object}
|
|
* @optional
|
|
*/
|
|
propTypes: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Definition of context types for this component.
|
|
*
|
|
* @type {object}
|
|
* @optional
|
|
*/
|
|
contextTypes: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Definition of context types this component sets for its children.
|
|
*
|
|
* @type {object}
|
|
* @optional
|
|
*/
|
|
childContextTypes: SpecPolicy.DEFINE_MANY,
|
|
|
|
// ==== Definition methods ====
|
|
|
|
/**
|
|
* Invoked when the component is mounted. Values in the mapping will be set on
|
|
* `this.props` if that prop is not specified (i.e. using an `in` check).
|
|
*
|
|
* This method is invoked before `getInitialState` and therefore cannot rely
|
|
* on `this.state` or use `this.setState`.
|
|
*
|
|
* @return {object}
|
|
* @optional
|
|
*/
|
|
getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
|
|
|
|
/**
|
|
* Invoked once before the component is mounted. The return value will be used
|
|
* as the initial value of `this.state`.
|
|
*
|
|
* getInitialState: function() {
|
|
* return {
|
|
* isOn: false,
|
|
* fooBaz: new BazFoo()
|
|
* }
|
|
* }
|
|
*
|
|
* @return {object}
|
|
* @optional
|
|
*/
|
|
getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
|
|
|
|
/**
|
|
* @return {object}
|
|
* @optional
|
|
*/
|
|
getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
|
|
|
|
/**
|
|
* Uses props from `this.props` and state from `this.state` to render the
|
|
* structure of the component.
|
|
*
|
|
* No guarantees are made about when or how often this method is invoked, so
|
|
* it must not have side effects.
|
|
*
|
|
* render: function() {
|
|
* var name = this.props.name;
|
|
* return <div>Hello, {name}!</div>;
|
|
* }
|
|
*
|
|
* @return {ReactComponent}
|
|
* @nosideeffects
|
|
* @required
|
|
*/
|
|
render: SpecPolicy.DEFINE_ONCE,
|
|
|
|
|
|
|
|
// ==== Delegate methods ====
|
|
|
|
/**
|
|
* Invoked when the component is initially created and about to be mounted.
|
|
* This may have side effects, but any external subscriptions or data created
|
|
* by this method must be cleaned up in `componentWillUnmount`.
|
|
*
|
|
* @optional
|
|
*/
|
|
componentWillMount: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Invoked when the component has been mounted and has a DOM representation.
|
|
* However, there is no guarantee that the DOM node is in the document.
|
|
*
|
|
* Use this as an opportunity to operate on the DOM when the component has
|
|
* been mounted (initialized and rendered) for the first time.
|
|
*
|
|
* @param {DOMElement} rootNode DOM element representing the component.
|
|
* @optional
|
|
*/
|
|
componentDidMount: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Invoked before the component receives new props.
|
|
*
|
|
* Use this as an opportunity to react to a prop transition by updating the
|
|
* state using `this.setState`. Current props are accessed via `this.props`.
|
|
*
|
|
* componentWillReceiveProps: function(nextProps, nextContext) {
|
|
* this.setState({
|
|
* likesIncreasing: nextProps.likeCount > this.props.likeCount
|
|
* });
|
|
* }
|
|
*
|
|
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
|
|
* transition may cause a state change, but the opposite is not true. If you
|
|
* need it, you are probably looking for `componentWillUpdate`.
|
|
*
|
|
* @param {object} nextProps
|
|
* @optional
|
|
*/
|
|
componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Invoked while deciding if the component should be updated as a result of
|
|
* receiving new props, state and/or context.
|
|
*
|
|
* Use this as an opportunity to `return false` when you're certain that the
|
|
* transition to the new props/state/context will not require a component
|
|
* update.
|
|
*
|
|
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
|
|
* return !equal(nextProps, this.props) ||
|
|
* !equal(nextState, this.state) ||
|
|
* !equal(nextContext, this.context);
|
|
* }
|
|
*
|
|
* @param {object} nextProps
|
|
* @param {?object} nextState
|
|
* @param {?object} nextContext
|
|
* @return {boolean} True if the component should update.
|
|
* @optional
|
|
*/
|
|
shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
|
|
|
|
/**
|
|
* Invoked when the component is about to update due to a transition from
|
|
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
|
|
* and `nextContext`.
|
|
*
|
|
* Use this as an opportunity to perform preparation before an update occurs.
|
|
*
|
|
* NOTE: You **cannot** use `this.setState()` in this method.
|
|
*
|
|
* @param {object} nextProps
|
|
* @param {?object} nextState
|
|
* @param {?object} nextContext
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @optional
|
|
*/
|
|
componentWillUpdate: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Invoked when the component's DOM representation has been updated.
|
|
*
|
|
* Use this as an opportunity to operate on the DOM when the component has
|
|
* been updated.
|
|
*
|
|
* @param {object} prevProps
|
|
* @param {?object} prevState
|
|
* @param {?object} prevContext
|
|
* @param {DOMElement} rootNode DOM element representing the component.
|
|
* @optional
|
|
*/
|
|
componentDidUpdate: SpecPolicy.DEFINE_MANY,
|
|
|
|
/**
|
|
* Invoked when the component is about to be removed from its parent and have
|
|
* its DOM representation destroyed.
|
|
*
|
|
* Use this as an opportunity to deallocate any external resources.
|
|
*
|
|
* NOTE: There is no `componentDidUnmount` since your component will have been
|
|
* destroyed by that point.
|
|
*
|
|
* @optional
|
|
*/
|
|
componentWillUnmount: SpecPolicy.DEFINE_MANY,
|
|
|
|
|
|
|
|
// ==== Advanced methods ====
|
|
|
|
/**
|
|
* Updates the component's currently mounted DOM representation.
|
|
*
|
|
* By default, this implements React's rendering and reconciliation algorithm.
|
|
* Sophisticated clients may wish to override this.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
* @overridable
|
|
*/
|
|
updateComponent: SpecPolicy.OVERRIDE_BASE
|
|
|
|
};
|
|
|
|
/**
|
|
* Mapping from class specification keys to special processing functions.
|
|
*
|
|
* Although these are declared like instance properties in the specification
|
|
* when defining classes using `React.createClass`, they are actually static
|
|
* and are accessible on the constructor instead of the prototype. Despite
|
|
* being static, they must be defined outside of the "statics" key under
|
|
* which all other static methods are defined.
|
|
*/
|
|
var RESERVED_SPEC_KEYS = {
|
|
displayName: function(Constructor, displayName) {
|
|
Constructor.displayName = displayName;
|
|
},
|
|
mixins: function(Constructor, mixins) {
|
|
if (mixins) {
|
|
for (var i = 0; i < mixins.length; i++) {
|
|
mixSpecIntoComponent(Constructor, mixins[i]);
|
|
}
|
|
}
|
|
},
|
|
childContextTypes: function(Constructor, childContextTypes) {
|
|
validateTypeDef(
|
|
Constructor,
|
|
childContextTypes,
|
|
ReactPropTypeLocations.childContext
|
|
);
|
|
Constructor.childContextTypes = assign(
|
|
{},
|
|
Constructor.childContextTypes,
|
|
childContextTypes
|
|
);
|
|
},
|
|
contextTypes: function(Constructor, contextTypes) {
|
|
validateTypeDef(
|
|
Constructor,
|
|
contextTypes,
|
|
ReactPropTypeLocations.context
|
|
);
|
|
Constructor.contextTypes = assign(
|
|
{},
|
|
Constructor.contextTypes,
|
|
contextTypes
|
|
);
|
|
},
|
|
/**
|
|
* Special case getDefaultProps which should move into statics but requires
|
|
* automatic merging.
|
|
*/
|
|
getDefaultProps: function(Constructor, getDefaultProps) {
|
|
if (Constructor.getDefaultProps) {
|
|
Constructor.getDefaultProps = createMergedResultFunction(
|
|
Constructor.getDefaultProps,
|
|
getDefaultProps
|
|
);
|
|
} else {
|
|
Constructor.getDefaultProps = getDefaultProps;
|
|
}
|
|
},
|
|
propTypes: function(Constructor, propTypes) {
|
|
validateTypeDef(
|
|
Constructor,
|
|
propTypes,
|
|
ReactPropTypeLocations.prop
|
|
);
|
|
Constructor.propTypes = assign(
|
|
{},
|
|
Constructor.propTypes,
|
|
propTypes
|
|
);
|
|
},
|
|
statics: function(Constructor, statics) {
|
|
mixStaticSpecIntoComponent(Constructor, statics);
|
|
}
|
|
};
|
|
|
|
function getDeclarationErrorAddendum(component) {
|
|
var owner = component._owner || null;
|
|
if (owner && owner.constructor && owner.constructor.displayName) {
|
|
return ' Check the render method of `' + owner.constructor.displayName +
|
|
'`.';
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function validateTypeDef(Constructor, typeDef, location) {
|
|
for (var propName in typeDef) {
|
|
if (typeDef.hasOwnProperty(propName)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof typeDef[propName] == 'function',
|
|
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
|
|
'React.PropTypes.',
|
|
Constructor.displayName || 'ReactCompositeComponent',
|
|
ReactPropTypeLocationNames[location],
|
|
propName
|
|
) : invariant(typeof typeDef[propName] == 'function'));
|
|
}
|
|
}
|
|
}
|
|
|
|
function validateMethodOverride(proto, name) {
|
|
var specPolicy = ReactCompositeComponentInterface.hasOwnProperty(name) ?
|
|
ReactCompositeComponentInterface[name] :
|
|
null;
|
|
|
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
if (ReactCompositeComponentMixin.hasOwnProperty(name)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
specPolicy === SpecPolicy.OVERRIDE_BASE,
|
|
'ReactCompositeComponentInterface: You are attempting to override ' +
|
|
'`%s` from your class specification. Ensure that your method names ' +
|
|
'do not overlap with React methods.',
|
|
name
|
|
) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
|
|
}
|
|
|
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
if (proto.hasOwnProperty(name)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
specPolicy === SpecPolicy.DEFINE_MANY ||
|
|
specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
|
|
'ReactCompositeComponentInterface: You are attempting to define ' +
|
|
'`%s` on your component more than once. This conflict may be due ' +
|
|
'to a mixin.',
|
|
name
|
|
) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
|
|
specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
|
|
}
|
|
}
|
|
|
|
function validateLifeCycleOnReplaceState(instance) {
|
|
var compositeLifeCycleState = instance._compositeLifeCycleState;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
instance.isMounted() ||
|
|
compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
|
|
'replaceState(...): Can only update a mounted or mounting component.'
|
|
) : invariant(instance.isMounted() ||
|
|
compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactCurrentOwner.current == null,
|
|
'replaceState(...): Cannot update during an existing state transition ' +
|
|
'(such as within `render`). Render methods should be a pure function ' +
|
|
'of props and state.'
|
|
) : invariant(ReactCurrentOwner.current == null));
|
|
("production" !== process.env.NODE_ENV ? invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
|
|
'replaceState(...): Cannot update while unmounting component. This ' +
|
|
'usually means you called setState() on an unmounted component.'
|
|
) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
|
|
}
|
|
|
|
/**
|
|
* Mixin helper which handles policy validation and reserved
|
|
* specification keys when building `ReactCompositeComponent` classses.
|
|
*/
|
|
function mixSpecIntoComponent(Constructor, spec) {
|
|
if (!spec) {
|
|
return;
|
|
}
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!ReactLegacyElement.isValidFactory(spec),
|
|
'ReactCompositeComponent: You\'re attempting to ' +
|
|
'use a component class as a mixin. Instead, just use a regular object.'
|
|
) : invariant(!ReactLegacyElement.isValidFactory(spec)));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!ReactElement.isValidElement(spec),
|
|
'ReactCompositeComponent: You\'re attempting to ' +
|
|
'use a component as a mixin. Instead, just use a regular object.'
|
|
) : invariant(!ReactElement.isValidElement(spec)));
|
|
|
|
var proto = Constructor.prototype;
|
|
|
|
// By handling mixins before any other properties, we ensure the same
|
|
// chaining order is applied to methods with DEFINE_MANY policy, whether
|
|
// mixins are listed before or after these methods in the spec.
|
|
if (spec.hasOwnProperty(MIXINS_KEY)) {
|
|
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
|
|
}
|
|
|
|
for (var name in spec) {
|
|
if (!spec.hasOwnProperty(name)) {
|
|
continue;
|
|
}
|
|
|
|
if (name === MIXINS_KEY) {
|
|
// We have already handled mixins in a special case above
|
|
continue;
|
|
}
|
|
|
|
var property = spec[name];
|
|
validateMethodOverride(proto, name);
|
|
|
|
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
|
|
RESERVED_SPEC_KEYS[name](Constructor, property);
|
|
} else {
|
|
// Setup methods on prototype:
|
|
// The following member methods should not be automatically bound:
|
|
// 1. Expected ReactCompositeComponent methods (in the "interface").
|
|
// 2. Overridden methods (that were mixed in).
|
|
var isCompositeComponentMethod =
|
|
ReactCompositeComponentInterface.hasOwnProperty(name);
|
|
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
var markedDontBind = property && property.__reactDontBind;
|
|
var isFunction = typeof property === 'function';
|
|
var shouldAutoBind =
|
|
isFunction &&
|
|
!isCompositeComponentMethod &&
|
|
!isAlreadyDefined &&
|
|
!markedDontBind;
|
|
|
|
if (shouldAutoBind) {
|
|
if (!proto.__reactAutoBindMap) {
|
|
proto.__reactAutoBindMap = {};
|
|
}
|
|
proto.__reactAutoBindMap[name] = property;
|
|
proto[name] = property;
|
|
} else {
|
|
if (isAlreadyDefined) {
|
|
var specPolicy = ReactCompositeComponentInterface[name];
|
|
|
|
// These cases should already be caught by validateMethodOverride
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
isCompositeComponentMethod && (
|
|
specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
|
|
specPolicy === SpecPolicy.DEFINE_MANY
|
|
),
|
|
'ReactCompositeComponent: Unexpected spec policy %s for key %s ' +
|
|
'when mixing in component specs.',
|
|
specPolicy,
|
|
name
|
|
) : invariant(isCompositeComponentMethod && (
|
|
specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
|
|
specPolicy === SpecPolicy.DEFINE_MANY
|
|
)));
|
|
|
|
// For methods which are defined more than once, call the existing
|
|
// methods before calling the new property, merging if appropriate.
|
|
if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
|
|
proto[name] = createMergedResultFunction(proto[name], property);
|
|
} else if (specPolicy === SpecPolicy.DEFINE_MANY) {
|
|
proto[name] = createChainedFunction(proto[name], property);
|
|
}
|
|
} else {
|
|
proto[name] = property;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// Add verbose displayName to the function, which helps when looking
|
|
// at profiling tools.
|
|
if (typeof property === 'function' && spec.displayName) {
|
|
proto[name].displayName = spec.displayName + '_' + name;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
if (!statics) {
|
|
return;
|
|
}
|
|
for (var name in statics) {
|
|
var property = statics[name];
|
|
if (!statics.hasOwnProperty(name)) {
|
|
continue;
|
|
}
|
|
|
|
var isReserved = name in RESERVED_SPEC_KEYS;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!isReserved,
|
|
'ReactCompositeComponent: You are attempting to define a reserved ' +
|
|
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
|
|
'as an instance property instead; it will still be accessible on the ' +
|
|
'constructor.',
|
|
name
|
|
) : invariant(!isReserved));
|
|
|
|
var isInherited = name in Constructor;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!isInherited,
|
|
'ReactCompositeComponent: You are attempting to define ' +
|
|
'`%s` on your component more than once. This conflict may be ' +
|
|
'due to a mixin.',
|
|
name
|
|
) : invariant(!isInherited));
|
|
Constructor[name] = property;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Merge two objects, but throw if both contain the same key.
|
|
*
|
|
* @param {object} one The first object, which is mutated.
|
|
* @param {object} two The second object
|
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
*/
|
|
function mergeObjectsWithNoDuplicateKeys(one, two) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
one && two && typeof one === 'object' && typeof two === 'object',
|
|
'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects'
|
|
) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
|
|
|
|
mapObject(two, function(value, key) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
one[key] === undefined,
|
|
'mergeObjectsWithNoDuplicateKeys(): ' +
|
|
'Tried to merge two objects with the same key: `%s`. This conflict ' +
|
|
'may be due to a mixin; in particular, this may be caused by two ' +
|
|
'getInitialState() or getDefaultProps() methods returning objects ' +
|
|
'with clashing keys.',
|
|
key
|
|
) : invariant(one[key] === undefined));
|
|
one[key] = value;
|
|
});
|
|
return one;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes two functions and merges their return values.
|
|
*
|
|
* @param {function} one Function to invoke first.
|
|
* @param {function} two Function to invoke second.
|
|
* @return {function} Function that invokes the two argument functions.
|
|
* @private
|
|
*/
|
|
function createMergedResultFunction(one, two) {
|
|
return function mergedResult() {
|
|
var a = one.apply(this, arguments);
|
|
var b = two.apply(this, arguments);
|
|
if (a == null) {
|
|
return b;
|
|
} else if (b == null) {
|
|
return a;
|
|
}
|
|
return mergeObjectsWithNoDuplicateKeys(a, b);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes two functions and ignores their return vales.
|
|
*
|
|
* @param {function} one Function to invoke first.
|
|
* @param {function} two Function to invoke second.
|
|
* @return {function} Function that invokes the two argument functions.
|
|
* @private
|
|
*/
|
|
function createChainedFunction(one, two) {
|
|
return function chainedFunction() {
|
|
one.apply(this, arguments);
|
|
two.apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* `ReactCompositeComponent` maintains an auxiliary life cycle state in
|
|
* `this._compositeLifeCycleState` (which can be null).
|
|
*
|
|
* This is different from the life cycle state maintained by `ReactComponent` in
|
|
* `this._lifeCycleState`. The following diagram shows how the states overlap in
|
|
* time. There are times when the CompositeLifeCycle is null - at those times it
|
|
* is only meaningful to look at ComponentLifeCycle alone.
|
|
*
|
|
* Top Row: ReactComponent.ComponentLifeCycle
|
|
* Low Row: ReactComponent.CompositeLifeCycle
|
|
*
|
|
* +-------+---------------------------------+--------+
|
|
* | UN | MOUNTED | UN |
|
|
* |MOUNTED| | MOUNTED|
|
|
* +-------+---------------------------------+--------+
|
|
* | ^--------+ +-------+ +--------^ |
|
|
* | | | | | | | |
|
|
* | 0--|MOUNTING|-0-|RECEIVE|-0-| UN |--->0 |
|
|
* | | | |PROPS | |MOUNTING| |
|
|
* | | | | | | | |
|
|
* | | | | | | | |
|
|
* | +--------+ +-------+ +--------+ |
|
|
* | | | |
|
|
* +-------+---------------------------------+--------+
|
|
*/
|
|
var CompositeLifeCycle = keyMirror({
|
|
/**
|
|
* Components in the process of being mounted respond to state changes
|
|
* differently.
|
|
*/
|
|
MOUNTING: null,
|
|
/**
|
|
* Components in the process of being unmounted are guarded against state
|
|
* changes.
|
|
*/
|
|
UNMOUNTING: null,
|
|
/**
|
|
* Components that are mounted and receiving new props respond to state
|
|
* changes differently.
|
|
*/
|
|
RECEIVING_PROPS: null
|
|
});
|
|
|
|
/**
|
|
* @lends {ReactCompositeComponent.prototype}
|
|
*/
|
|
var ReactCompositeComponentMixin = {
|
|
|
|
/**
|
|
* Base constructor for all composite component.
|
|
*
|
|
* @param {ReactElement} element
|
|
* @final
|
|
* @internal
|
|
*/
|
|
construct: function(element) {
|
|
// Children can be either an array or more than one argument
|
|
ReactComponent.Mixin.construct.apply(this, arguments);
|
|
ReactOwner.Mixin.construct.apply(this, arguments);
|
|
|
|
this.state = null;
|
|
this._pendingState = null;
|
|
|
|
// This is the public post-processed context. The real context and pending
|
|
// context lives on the element.
|
|
this.context = null;
|
|
|
|
this._compositeLifeCycleState = null;
|
|
},
|
|
|
|
/**
|
|
* Checks whether or not this composite component is mounted.
|
|
* @return {boolean} True if mounted, false otherwise.
|
|
* @protected
|
|
* @final
|
|
*/
|
|
isMounted: function() {
|
|
return ReactComponent.Mixin.isMounted.call(this) &&
|
|
this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING;
|
|
},
|
|
|
|
/**
|
|
* Initializes the component, renders markup, and registers event listeners.
|
|
*
|
|
* @param {string} rootID DOM ID of the root node.
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @param {number} mountDepth number of components in the owner hierarchy
|
|
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
mountComponent: ReactPerf.measure(
|
|
'ReactCompositeComponent',
|
|
'mountComponent',
|
|
function(rootID, transaction, mountDepth) {
|
|
ReactComponent.Mixin.mountComponent.call(
|
|
this,
|
|
rootID,
|
|
transaction,
|
|
mountDepth
|
|
);
|
|
this._compositeLifeCycleState = CompositeLifeCycle.MOUNTING;
|
|
|
|
if (this.__reactAutoBindMap) {
|
|
this._bindAutoBindMethods();
|
|
}
|
|
|
|
this.context = this._processContext(this._currentElement._context);
|
|
this.props = this._processProps(this.props);
|
|
|
|
this.state = this.getInitialState ? this.getInitialState() : null;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof this.state === 'object' && !Array.isArray(this.state),
|
|
'%s.getInitialState(): must return an object or null',
|
|
this.constructor.displayName || 'ReactCompositeComponent'
|
|
) : invariant(typeof this.state === 'object' && !Array.isArray(this.state)));
|
|
|
|
this._pendingState = null;
|
|
this._pendingForceUpdate = false;
|
|
|
|
if (this.componentWillMount) {
|
|
this.componentWillMount();
|
|
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
// `this._pendingState` without triggering a re-render.
|
|
if (this._pendingState) {
|
|
this.state = this._pendingState;
|
|
this._pendingState = null;
|
|
}
|
|
}
|
|
|
|
this._renderedComponent = instantiateReactComponent(
|
|
this._renderValidatedComponent(),
|
|
this._currentElement.type // The wrapping type
|
|
);
|
|
|
|
// Done with mounting, `setState` will now trigger UI changes.
|
|
this._compositeLifeCycleState = null;
|
|
var markup = this._renderedComponent.mountComponent(
|
|
rootID,
|
|
transaction,
|
|
mountDepth + 1
|
|
);
|
|
if (this.componentDidMount) {
|
|
transaction.getReactMountReady().enqueue(this.componentDidMount, this);
|
|
}
|
|
return markup;
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Releases any resources allocated by `mountComponent`.
|
|
*
|
|
* @final
|
|
* @internal
|
|
*/
|
|
unmountComponent: function() {
|
|
this._compositeLifeCycleState = CompositeLifeCycle.UNMOUNTING;
|
|
if (this.componentWillUnmount) {
|
|
this.componentWillUnmount();
|
|
}
|
|
this._compositeLifeCycleState = null;
|
|
|
|
this._renderedComponent.unmountComponent();
|
|
this._renderedComponent = null;
|
|
|
|
ReactComponent.Mixin.unmountComponent.call(this);
|
|
|
|
// Some existing components rely on this.props even after they've been
|
|
// destroyed (in event handlers).
|
|
// TODO: this.props = null;
|
|
// TODO: this.state = null;
|
|
},
|
|
|
|
/**
|
|
* Sets a subset of the state. Always use this or `replaceState` to mutate
|
|
* state. You should treat `this.state` as immutable.
|
|
*
|
|
* There is no guarantee that `this.state` will be immediately updated, so
|
|
* accessing `this.state` after calling this method may return the old value.
|
|
*
|
|
* There is no guarantee that calls to `setState` will run synchronously,
|
|
* as they may eventually be batched together. You can provide an optional
|
|
* callback that will be executed when the call to setState is actually
|
|
* completed.
|
|
*
|
|
* @param {object} partialState Next partial state to be merged with state.
|
|
* @param {?function} callback Called after state is updated.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
setState: function(partialState, callback) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof partialState === 'object' || partialState == null,
|
|
'setState(...): takes an object of state variables to update.'
|
|
) : invariant(typeof partialState === 'object' || partialState == null));
|
|
if ("production" !== process.env.NODE_ENV){
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
partialState != null,
|
|
'setState(...): You passed an undefined or null state object; ' +
|
|
'instead, use forceUpdate().'
|
|
) : null);
|
|
}
|
|
// Merge with `_pendingState` if it exists, otherwise with existing state.
|
|
this.replaceState(
|
|
assign({}, this._pendingState || this.state, partialState),
|
|
callback
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Replaces all of the state. Always use this or `setState` to mutate state.
|
|
* You should treat `this.state` as immutable.
|
|
*
|
|
* There is no guarantee that `this.state` will be immediately updated, so
|
|
* accessing `this.state` after calling this method may return the old value.
|
|
*
|
|
* @param {object} completeState Next state.
|
|
* @param {?function} callback Called after state is updated.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
replaceState: function(completeState, callback) {
|
|
validateLifeCycleOnReplaceState(this);
|
|
this._pendingState = completeState;
|
|
if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) {
|
|
// If we're in a componentWillMount handler, don't enqueue a rerender
|
|
// because ReactUpdates assumes we're in a browser context (which is wrong
|
|
// for server rendering) and we're about to do a render anyway.
|
|
// TODO: The callback here is ignored when setState is called from
|
|
// componentWillMount. Either fix it or disallow doing so completely in
|
|
// favor of getInitialState.
|
|
ReactUpdates.enqueueUpdate(this, callback);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Filters the context object to only contain keys specified in
|
|
* `contextTypes`, and asserts that they are valid.
|
|
*
|
|
* @param {object} context
|
|
* @return {?object}
|
|
* @private
|
|
*/
|
|
_processContext: function(context) {
|
|
var maskedContext = null;
|
|
var contextTypes = this.constructor.contextTypes;
|
|
if (contextTypes) {
|
|
maskedContext = {};
|
|
for (var contextName in contextTypes) {
|
|
maskedContext[contextName] = context[contextName];
|
|
}
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
this._checkPropTypes(
|
|
contextTypes,
|
|
maskedContext,
|
|
ReactPropTypeLocations.context
|
|
);
|
|
}
|
|
}
|
|
return maskedContext;
|
|
},
|
|
|
|
/**
|
|
* @param {object} currentContext
|
|
* @return {object}
|
|
* @private
|
|
*/
|
|
_processChildContext: function(currentContext) {
|
|
var childContext = this.getChildContext && this.getChildContext();
|
|
var displayName = this.constructor.displayName || 'ReactCompositeComponent';
|
|
if (childContext) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof this.constructor.childContextTypes === 'object',
|
|
'%s.getChildContext(): childContextTypes must be defined in order to ' +
|
|
'use getChildContext().',
|
|
displayName
|
|
) : invariant(typeof this.constructor.childContextTypes === 'object'));
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
this._checkPropTypes(
|
|
this.constructor.childContextTypes,
|
|
childContext,
|
|
ReactPropTypeLocations.childContext
|
|
);
|
|
}
|
|
for (var name in childContext) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
name in this.constructor.childContextTypes,
|
|
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
|
displayName,
|
|
name
|
|
) : invariant(name in this.constructor.childContextTypes));
|
|
}
|
|
return assign({}, currentContext, childContext);
|
|
}
|
|
return currentContext;
|
|
},
|
|
|
|
/**
|
|
* Processes props by setting default values for unspecified props and
|
|
* asserting that the props are valid. Does not mutate its argument; returns
|
|
* a new props object with defaults merged in.
|
|
*
|
|
* @param {object} newProps
|
|
* @return {object}
|
|
* @private
|
|
*/
|
|
_processProps: function(newProps) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var propTypes = this.constructor.propTypes;
|
|
if (propTypes) {
|
|
this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
|
|
}
|
|
}
|
|
return newProps;
|
|
},
|
|
|
|
/**
|
|
* Assert that the props are valid
|
|
*
|
|
* @param {object} propTypes Map of prop name to a ReactPropType
|
|
* @param {object} props
|
|
* @param {string} location e.g. "prop", "context", "child context"
|
|
* @private
|
|
*/
|
|
_checkPropTypes: function(propTypes, props, location) {
|
|
// TODO: Stop validating prop types here and only use the element
|
|
// validation.
|
|
var componentName = this.constructor.displayName;
|
|
for (var propName in propTypes) {
|
|
if (propTypes.hasOwnProperty(propName)) {
|
|
var error =
|
|
propTypes[propName](props, propName, componentName, location);
|
|
if (error instanceof Error) {
|
|
// We may want to extend this logic for similar errors in
|
|
// renderComponent calls, so I'm abstracting it away into
|
|
// a function to minimize refactoring in the future
|
|
var addendum = getDeclarationErrorAddendum(this);
|
|
("production" !== process.env.NODE_ENV ? warning(false, error.message + addendum) : null);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* If any of `_pendingElement`, `_pendingState`, or `_pendingForceUpdate`
|
|
* is set, update the component.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
*/
|
|
performUpdateIfNecessary: function(transaction) {
|
|
var compositeLifeCycleState = this._compositeLifeCycleState;
|
|
// Do not trigger a state transition if we are in the middle of mounting or
|
|
// receiving props because both of those will already be doing this.
|
|
if (compositeLifeCycleState === CompositeLifeCycle.MOUNTING ||
|
|
compositeLifeCycleState === CompositeLifeCycle.RECEIVING_PROPS) {
|
|
return;
|
|
}
|
|
|
|
if (this._pendingElement == null &&
|
|
this._pendingState == null &&
|
|
!this._pendingForceUpdate) {
|
|
return;
|
|
}
|
|
|
|
var nextContext = this.context;
|
|
var nextProps = this.props;
|
|
var nextElement = this._currentElement;
|
|
if (this._pendingElement != null) {
|
|
nextElement = this._pendingElement;
|
|
nextContext = this._processContext(nextElement._context);
|
|
nextProps = this._processProps(nextElement.props);
|
|
this._pendingElement = null;
|
|
|
|
this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
|
|
if (this.componentWillReceiveProps) {
|
|
this.componentWillReceiveProps(nextProps, nextContext);
|
|
}
|
|
}
|
|
|
|
this._compositeLifeCycleState = null;
|
|
|
|
var nextState = this._pendingState || this.state;
|
|
this._pendingState = null;
|
|
|
|
var shouldUpdate =
|
|
this._pendingForceUpdate ||
|
|
!this.shouldComponentUpdate ||
|
|
this.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (typeof shouldUpdate === "undefined") {
|
|
console.warn(
|
|
(this.constructor.displayName || 'ReactCompositeComponent') +
|
|
'.shouldComponentUpdate(): Returned undefined instead of a ' +
|
|
'boolean value. Make sure to return true or false.'
|
|
);
|
|
}
|
|
}
|
|
|
|
if (shouldUpdate) {
|
|
this._pendingForceUpdate = false;
|
|
// Will set `this.props`, `this.state` and `this.context`.
|
|
this._performComponentUpdate(
|
|
nextElement,
|
|
nextProps,
|
|
nextState,
|
|
nextContext,
|
|
transaction
|
|
);
|
|
} else {
|
|
// If it's determined that a component should not update, we still want
|
|
// to set props and state.
|
|
this._currentElement = nextElement;
|
|
this.props = nextProps;
|
|
this.state = nextState;
|
|
this.context = nextContext;
|
|
|
|
// Owner cannot change because shouldUpdateReactComponent doesn't allow
|
|
// it. TODO: Remove this._owner completely.
|
|
this._owner = nextElement._owner;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Merges new props and state, notifies delegate methods of update and
|
|
* performs update.
|
|
*
|
|
* @param {ReactElement} nextElement Next element
|
|
* @param {object} nextProps Next public object to set as properties.
|
|
* @param {?object} nextState Next object to set as state.
|
|
* @param {?object} nextContext Next public object to set as context.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @private
|
|
*/
|
|
_performComponentUpdate: function(
|
|
nextElement,
|
|
nextProps,
|
|
nextState,
|
|
nextContext,
|
|
transaction
|
|
) {
|
|
var prevElement = this._currentElement;
|
|
var prevProps = this.props;
|
|
var prevState = this.state;
|
|
var prevContext = this.context;
|
|
|
|
if (this.componentWillUpdate) {
|
|
this.componentWillUpdate(nextProps, nextState, nextContext);
|
|
}
|
|
|
|
this._currentElement = nextElement;
|
|
this.props = nextProps;
|
|
this.state = nextState;
|
|
this.context = nextContext;
|
|
|
|
// Owner cannot change because shouldUpdateReactComponent doesn't allow
|
|
// it. TODO: Remove this._owner completely.
|
|
this._owner = nextElement._owner;
|
|
|
|
this.updateComponent(
|
|
transaction,
|
|
prevElement
|
|
);
|
|
|
|
if (this.componentDidUpdate) {
|
|
transaction.getReactMountReady().enqueue(
|
|
this.componentDidUpdate.bind(this, prevProps, prevState, prevContext),
|
|
this
|
|
);
|
|
}
|
|
},
|
|
|
|
receiveComponent: function(nextElement, transaction) {
|
|
if (nextElement === this._currentElement &&
|
|
nextElement._owner != null) {
|
|
// Since elements are immutable after the owner is rendered,
|
|
// we can do a cheap identity compare here to determine if this is a
|
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
// change should trigger an update of the owner which would recreate
|
|
// the element. We explicitly check for the existence of an owner since
|
|
// it's possible for a element created outside a composite to be
|
|
// deeply mutated and reused.
|
|
return;
|
|
}
|
|
|
|
ReactComponent.Mixin.receiveComponent.call(
|
|
this,
|
|
nextElement,
|
|
transaction
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Updates the component's currently mounted DOM representation.
|
|
*
|
|
* By default, this implements React's rendering and reconciliation algorithm.
|
|
* Sophisticated clients may wish to override this.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @param {ReactElement} prevElement
|
|
* @internal
|
|
* @overridable
|
|
*/
|
|
updateComponent: ReactPerf.measure(
|
|
'ReactCompositeComponent',
|
|
'updateComponent',
|
|
function(transaction, prevParentElement) {
|
|
ReactComponent.Mixin.updateComponent.call(
|
|
this,
|
|
transaction,
|
|
prevParentElement
|
|
);
|
|
|
|
var prevComponentInstance = this._renderedComponent;
|
|
var prevElement = prevComponentInstance._currentElement;
|
|
var nextElement = this._renderValidatedComponent();
|
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
prevComponentInstance.receiveComponent(nextElement, transaction);
|
|
} else {
|
|
// These two IDs are actually the same! But nothing should rely on that.
|
|
var thisID = this._rootNodeID;
|
|
var prevComponentID = prevComponentInstance._rootNodeID;
|
|
prevComponentInstance.unmountComponent();
|
|
this._renderedComponent = instantiateReactComponent(
|
|
nextElement,
|
|
this._currentElement.type
|
|
);
|
|
var nextMarkup = this._renderedComponent.mountComponent(
|
|
thisID,
|
|
transaction,
|
|
this._mountDepth + 1
|
|
);
|
|
ReactComponent.BackendIDOperations.dangerouslyReplaceNodeWithMarkupByID(
|
|
prevComponentID,
|
|
nextMarkup
|
|
);
|
|
}
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Forces an update. This should only be invoked when it is known with
|
|
* certainty that we are **not** in a DOM transaction.
|
|
*
|
|
* You may want to call this when you know that some deeper aspect of the
|
|
* component's state has changed but `setState` was not called.
|
|
*
|
|
* This will not invoke `shouldUpdateComponent`, but it will invoke
|
|
* `componentWillUpdate` and `componentDidUpdate`.
|
|
*
|
|
* @param {?function} callback Called after update is complete.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
forceUpdate: function(callback) {
|
|
var compositeLifeCycleState = this._compositeLifeCycleState;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isMounted() ||
|
|
compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
|
|
'forceUpdate(...): Can only force an update on mounted or mounting ' +
|
|
'components.'
|
|
) : invariant(this.isMounted() ||
|
|
compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
|
|
ReactCurrentOwner.current == null,
|
|
'forceUpdate(...): Cannot force an update while unmounting component ' +
|
|
'or within a `render` function.'
|
|
) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
|
|
ReactCurrentOwner.current == null));
|
|
this._pendingForceUpdate = true;
|
|
ReactUpdates.enqueueUpdate(this, callback);
|
|
},
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
_renderValidatedComponent: ReactPerf.measure(
|
|
'ReactCompositeComponent',
|
|
'_renderValidatedComponent',
|
|
function() {
|
|
var renderedComponent;
|
|
var previousContext = ReactContext.current;
|
|
ReactContext.current = this._processChildContext(
|
|
this._currentElement._context
|
|
);
|
|
ReactCurrentOwner.current = this;
|
|
try {
|
|
renderedComponent = this.render();
|
|
if (renderedComponent === null || renderedComponent === false) {
|
|
renderedComponent = ReactEmptyComponent.getEmptyComponent();
|
|
ReactEmptyComponent.registerNullComponentID(this._rootNodeID);
|
|
} else {
|
|
ReactEmptyComponent.deregisterNullComponentID(this._rootNodeID);
|
|
}
|
|
} finally {
|
|
ReactContext.current = previousContext;
|
|
ReactCurrentOwner.current = null;
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactElement.isValidElement(renderedComponent),
|
|
'%s.render(): A valid ReactComponent must be returned. You may have ' +
|
|
'returned undefined, an array or some other invalid object.',
|
|
this.constructor.displayName || 'ReactCompositeComponent'
|
|
) : invariant(ReactElement.isValidElement(renderedComponent)));
|
|
return renderedComponent;
|
|
}
|
|
),
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
_bindAutoBindMethods: function() {
|
|
for (var autoBindKey in this.__reactAutoBindMap) {
|
|
if (!this.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
|
|
continue;
|
|
}
|
|
var method = this.__reactAutoBindMap[autoBindKey];
|
|
this[autoBindKey] = this._bindAutoBindMethod(ReactErrorUtils.guard(
|
|
method,
|
|
this.constructor.displayName + '.' + autoBindKey
|
|
));
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Binds a method to the component.
|
|
*
|
|
* @param {function} method Method to be bound.
|
|
* @private
|
|
*/
|
|
_bindAutoBindMethod: function(method) {
|
|
var component = this;
|
|
var boundMethod = method.bind(component);
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
boundMethod.__reactBoundContext = component;
|
|
boundMethod.__reactBoundMethod = method;
|
|
boundMethod.__reactBoundArguments = null;
|
|
var componentName = component.constructor.displayName;
|
|
var _bind = boundMethod.bind;
|
|
boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
|
// User is trying to bind() an autobound method; we effectively will
|
|
// ignore the value of "this" that the user is trying to use, so
|
|
// let's warn.
|
|
if (newThis !== component && newThis !== null) {
|
|
monitorCodeUse('react_bind_warning', { component: componentName });
|
|
console.warn(
|
|
'bind(): React component methods may only be bound to the ' +
|
|
'component instance. See ' + componentName
|
|
);
|
|
} else if (!args.length) {
|
|
monitorCodeUse('react_bind_warning', { component: componentName });
|
|
console.warn(
|
|
'bind(): You are binding a component method to the component. ' +
|
|
'React does this for you automatically in a high-performance ' +
|
|
'way, so you can safely remove this call. See ' + componentName
|
|
);
|
|
return boundMethod;
|
|
}
|
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
reboundMethod.__reactBoundContext = component;
|
|
reboundMethod.__reactBoundMethod = method;
|
|
reboundMethod.__reactBoundArguments = args;
|
|
return reboundMethod;
|
|
};
|
|
}
|
|
return boundMethod;
|
|
}
|
|
};
|
|
|
|
var ReactCompositeComponentBase = function() {};
|
|
assign(
|
|
ReactCompositeComponentBase.prototype,
|
|
ReactComponent.Mixin,
|
|
ReactOwner.Mixin,
|
|
ReactPropTransferer.Mixin,
|
|
ReactCompositeComponentMixin
|
|
);
|
|
|
|
/**
|
|
* Module for creating composite components.
|
|
*
|
|
* @class ReactCompositeComponent
|
|
* @extends ReactComponent
|
|
* @extends ReactOwner
|
|
* @extends ReactPropTransferer
|
|
*/
|
|
var ReactCompositeComponent = {
|
|
|
|
LifeCycle: CompositeLifeCycle,
|
|
|
|
Base: ReactCompositeComponentBase,
|
|
|
|
/**
|
|
* Creates a composite component class given a class specification.
|
|
*
|
|
* @param {object} spec Class specification (which must define `render`).
|
|
* @return {function} Component constructor function.
|
|
* @public
|
|
*/
|
|
createClass: function(spec) {
|
|
var Constructor = function(props) {
|
|
// This constructor is overridden by mocks. The argument is used
|
|
// by mocks to assert on what gets mounted. This will later be used
|
|
// by the stand-alone class implementation.
|
|
};
|
|
Constructor.prototype = new ReactCompositeComponentBase();
|
|
Constructor.prototype.constructor = Constructor;
|
|
|
|
injectedMixins.forEach(
|
|
mixSpecIntoComponent.bind(null, Constructor)
|
|
);
|
|
|
|
mixSpecIntoComponent(Constructor, spec);
|
|
|
|
// Initialize the defaultProps property after all mixins have been merged
|
|
if (Constructor.getDefaultProps) {
|
|
Constructor.defaultProps = Constructor.getDefaultProps();
|
|
}
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Constructor.prototype.render,
|
|
'createClass(...): Class specification must implement a `render` method.'
|
|
) : invariant(Constructor.prototype.render));
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (Constructor.prototype.componentShouldUpdate) {
|
|
monitorCodeUse(
|
|
'react_component_should_update_warning',
|
|
{ component: spec.displayName }
|
|
);
|
|
console.warn(
|
|
(spec.displayName || 'A component') + ' has a method called ' +
|
|
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
|
'The name is phrased as a question because the function is ' +
|
|
'expected to return a value.'
|
|
);
|
|
}
|
|
}
|
|
|
|
// Reduce time spent doing lookups by setting these on the prototype.
|
|
for (var methodName in ReactCompositeComponentInterface) {
|
|
if (!Constructor.prototype[methodName]) {
|
|
Constructor.prototype[methodName] = null;
|
|
}
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
return ReactLegacyElement.wrapFactory(
|
|
ReactElementValidator.createFactory(Constructor)
|
|
);
|
|
}
|
|
return ReactLegacyElement.wrapFactory(
|
|
ReactElement.createFactory(Constructor)
|
|
);
|
|
},
|
|
|
|
injection: {
|
|
injectMixin: function(mixin) {
|
|
injectedMixins.push(mixin);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = ReactCompositeComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./ReactComponent":78,"./ReactContext":82,"./ReactCurrentOwner":83,"./ReactElement":99,"./ReactElementValidator":100,"./ReactEmptyComponent":101,"./ReactErrorUtils":102,"./ReactLegacyElement":108,"./ReactOwner":115,"./ReactPerf":116,"./ReactPropTransferer":117,"./ReactPropTypeLocationNames":118,"./ReactPropTypeLocations":119,"./ReactUpdates":132,"./instantiateReactComponent":181,"./invariant":182,"./keyMirror":188,"./keyOf":189,"./mapObject":190,"./monitorCodeUse":192,"./shouldUpdateReactComponent":198,"./warning":202,"_process":1}],82:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactContext
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
/**
|
|
* Keeps track of the current context.
|
|
*
|
|
* The context is automatically passed down the component ownership hierarchy
|
|
* and is accessible via `this.context` on ReactCompositeComponents.
|
|
*/
|
|
var ReactContext = {
|
|
|
|
/**
|
|
* @internal
|
|
* @type {object}
|
|
*/
|
|
current: {},
|
|
|
|
/**
|
|
* Temporarily extends the current context while executing scopedCallback.
|
|
*
|
|
* A typical use case might look like
|
|
*
|
|
* render: function() {
|
|
* var children = ReactContext.withContext({foo: 'foo'}, () => (
|
|
*
|
|
* ));
|
|
* return <div>{children}</div>;
|
|
* }
|
|
*
|
|
* @param {object} newContext New context to merge into the existing context
|
|
* @param {function} scopedCallback Callback to run with the new context
|
|
* @return {ReactComponent|array<ReactComponent>}
|
|
*/
|
|
withContext: function(newContext, scopedCallback) {
|
|
var result;
|
|
var previousContext = ReactContext.current;
|
|
ReactContext.current = assign({}, previousContext, newContext);
|
|
try {
|
|
result = scopedCallback();
|
|
} finally {
|
|
ReactContext.current = previousContext;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ReactContext;
|
|
|
|
},{"./Object.assign":70}],83:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactCurrentOwner
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Keeps track of the current owner.
|
|
*
|
|
* The current owner is the component who should own any components that are
|
|
* currently being constructed.
|
|
*
|
|
* The depth indicate how many composite components are above this render level.
|
|
*/
|
|
var ReactCurrentOwner = {
|
|
|
|
/**
|
|
* @internal
|
|
* @type {ReactComponent}
|
|
*/
|
|
current: null
|
|
|
|
};
|
|
|
|
module.exports = ReactCurrentOwner;
|
|
|
|
},{}],84:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOM
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
|
|
var mapObject = require("./mapObject");
|
|
|
|
/**
|
|
* Create a factory that creates HTML tag elements.
|
|
*
|
|
* @param {string} tag Tag name (e.g. `div`).
|
|
* @private
|
|
*/
|
|
function createDOMFactory(tag) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
return ReactLegacyElement.markNonLegacyFactory(
|
|
ReactElementValidator.createFactory(tag)
|
|
);
|
|
}
|
|
return ReactLegacyElement.markNonLegacyFactory(
|
|
ReactElement.createFactory(tag)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
|
|
* This is also accessible via `React.DOM`.
|
|
*
|
|
* @public
|
|
*/
|
|
var ReactDOM = mapObject({
|
|
a: 'a',
|
|
abbr: 'abbr',
|
|
address: 'address',
|
|
area: 'area',
|
|
article: 'article',
|
|
aside: 'aside',
|
|
audio: 'audio',
|
|
b: 'b',
|
|
base: 'base',
|
|
bdi: 'bdi',
|
|
bdo: 'bdo',
|
|
big: 'big',
|
|
blockquote: 'blockquote',
|
|
body: 'body',
|
|
br: 'br',
|
|
button: 'button',
|
|
canvas: 'canvas',
|
|
caption: 'caption',
|
|
cite: 'cite',
|
|
code: 'code',
|
|
col: 'col',
|
|
colgroup: 'colgroup',
|
|
data: 'data',
|
|
datalist: 'datalist',
|
|
dd: 'dd',
|
|
del: 'del',
|
|
details: 'details',
|
|
dfn: 'dfn',
|
|
dialog: 'dialog',
|
|
div: 'div',
|
|
dl: 'dl',
|
|
dt: 'dt',
|
|
em: 'em',
|
|
embed: 'embed',
|
|
fieldset: 'fieldset',
|
|
figcaption: 'figcaption',
|
|
figure: 'figure',
|
|
footer: 'footer',
|
|
form: 'form',
|
|
h1: 'h1',
|
|
h2: 'h2',
|
|
h3: 'h3',
|
|
h4: 'h4',
|
|
h5: 'h5',
|
|
h6: 'h6',
|
|
head: 'head',
|
|
header: 'header',
|
|
hr: 'hr',
|
|
html: 'html',
|
|
i: 'i',
|
|
iframe: 'iframe',
|
|
img: 'img',
|
|
input: 'input',
|
|
ins: 'ins',
|
|
kbd: 'kbd',
|
|
keygen: 'keygen',
|
|
label: 'label',
|
|
legend: 'legend',
|
|
li: 'li',
|
|
link: 'link',
|
|
main: 'main',
|
|
map: 'map',
|
|
mark: 'mark',
|
|
menu: 'menu',
|
|
menuitem: 'menuitem',
|
|
meta: 'meta',
|
|
meter: 'meter',
|
|
nav: 'nav',
|
|
noscript: 'noscript',
|
|
object: 'object',
|
|
ol: 'ol',
|
|
optgroup: 'optgroup',
|
|
option: 'option',
|
|
output: 'output',
|
|
p: 'p',
|
|
param: 'param',
|
|
picture: 'picture',
|
|
pre: 'pre',
|
|
progress: 'progress',
|
|
q: 'q',
|
|
rp: 'rp',
|
|
rt: 'rt',
|
|
ruby: 'ruby',
|
|
s: 's',
|
|
samp: 'samp',
|
|
script: 'script',
|
|
section: 'section',
|
|
select: 'select',
|
|
small: 'small',
|
|
source: 'source',
|
|
span: 'span',
|
|
strong: 'strong',
|
|
style: 'style',
|
|
sub: 'sub',
|
|
summary: 'summary',
|
|
sup: 'sup',
|
|
table: 'table',
|
|
tbody: 'tbody',
|
|
td: 'td',
|
|
textarea: 'textarea',
|
|
tfoot: 'tfoot',
|
|
th: 'th',
|
|
thead: 'thead',
|
|
time: 'time',
|
|
title: 'title',
|
|
tr: 'tr',
|
|
track: 'track',
|
|
u: 'u',
|
|
ul: 'ul',
|
|
'var': 'var',
|
|
video: 'video',
|
|
wbr: 'wbr',
|
|
|
|
// SVG
|
|
circle: 'circle',
|
|
defs: 'defs',
|
|
ellipse: 'ellipse',
|
|
g: 'g',
|
|
line: 'line',
|
|
linearGradient: 'linearGradient',
|
|
mask: 'mask',
|
|
path: 'path',
|
|
pattern: 'pattern',
|
|
polygon: 'polygon',
|
|
polyline: 'polyline',
|
|
radialGradient: 'radialGradient',
|
|
rect: 'rect',
|
|
stop: 'stop',
|
|
svg: 'svg',
|
|
text: 'text',
|
|
tspan: 'tspan'
|
|
|
|
}, createDOMFactory);
|
|
|
|
module.exports = ReactDOM;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./ReactElementValidator":100,"./ReactLegacyElement":108,"./mapObject":190,"_process":1}],85:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMButton
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
|
|
var keyMirror = require("./keyMirror");
|
|
|
|
// Store a reference to the <button> `ReactDOMComponent`. TODO: use string
|
|
var button = ReactElement.createFactory(ReactDOM.button.type);
|
|
|
|
var mouseListenerNames = keyMirror({
|
|
onClick: true,
|
|
onDoubleClick: true,
|
|
onMouseDown: true,
|
|
onMouseMove: true,
|
|
onMouseUp: true,
|
|
onClickCapture: true,
|
|
onDoubleClickCapture: true,
|
|
onMouseDownCapture: true,
|
|
onMouseMoveCapture: true,
|
|
onMouseUpCapture: true
|
|
});
|
|
|
|
/**
|
|
* Implements a <button> native component that does not receive mouse events
|
|
* when `disabled` is set.
|
|
*/
|
|
var ReactDOMButton = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMButton',
|
|
|
|
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
|
|
|
|
render: function() {
|
|
var props = {};
|
|
|
|
// Copy the props; except the mouse listeners if we're disabled
|
|
for (var key in this.props) {
|
|
if (this.props.hasOwnProperty(key) &&
|
|
(!this.props.disabled || !mouseListenerNames[key])) {
|
|
props[key] = this.props[key];
|
|
}
|
|
}
|
|
|
|
return button(props, this.props.children);
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = ReactDOMButton;
|
|
|
|
},{"./AutoFocusMixin":43,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99,"./keyMirror":188}],86:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMComponent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
var DOMProperty = require("./DOMProperty");
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactMultiChild = require("./ReactMultiChild");
|
|
var ReactPerf = require("./ReactPerf");
|
|
|
|
var assign = require("./Object.assign");
|
|
var escapeTextForBrowser = require("./escapeTextForBrowser");
|
|
var invariant = require("./invariant");
|
|
var isEventSupported = require("./isEventSupported");
|
|
var keyOf = require("./keyOf");
|
|
var monitorCodeUse = require("./monitorCodeUse");
|
|
|
|
var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
|
var listenTo = ReactBrowserEventEmitter.listenTo;
|
|
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
|
|
|
|
// For quickly matching children type, to test if can be treated as content.
|
|
var CONTENT_TYPES = {'string': true, 'number': true};
|
|
|
|
var STYLE = keyOf({style: null});
|
|
|
|
var ELEMENT_NODE_TYPE = 1;
|
|
|
|
/**
|
|
* @param {?object} props
|
|
*/
|
|
function assertValidProps(props) {
|
|
if (!props) {
|
|
return;
|
|
}
|
|
// Note the use of `==` which checks for null or undefined.
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
props.children == null || props.dangerouslySetInnerHTML == null,
|
|
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
|
|
) : invariant(props.children == null || props.dangerouslySetInnerHTML == null));
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (props.contentEditable && props.children != null) {
|
|
console.warn(
|
|
'A component is `contentEditable` and contains `children` managed by ' +
|
|
'React. It is now your responsibility to guarantee that none of those '+
|
|
'nodes are unexpectedly modified or duplicated. This is probably not ' +
|
|
'intentional.'
|
|
);
|
|
}
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
props.style == null || typeof props.style === 'object',
|
|
'The `style` prop expects a mapping from style properties to values, ' +
|
|
'not a string.'
|
|
) : invariant(props.style == null || typeof props.style === 'object'));
|
|
}
|
|
|
|
function putListener(id, registrationName, listener, transaction) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
|
// bubble.
|
|
if (registrationName === 'onScroll' &&
|
|
!isEventSupported('scroll', true)) {
|
|
monitorCodeUse('react_no_scroll_event');
|
|
console.warn('This browser doesn\'t support the `onScroll` event');
|
|
}
|
|
}
|
|
var container = ReactMount.findReactContainerForID(id);
|
|
if (container) {
|
|
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
|
|
container.ownerDocument :
|
|
container;
|
|
listenTo(registrationName, doc);
|
|
}
|
|
transaction.getPutListenerQueue().enqueuePutListener(
|
|
id,
|
|
registrationName,
|
|
listener
|
|
);
|
|
}
|
|
|
|
// For HTML, certain tags should omit their close tag. We keep a whitelist for
|
|
// those special cased tags.
|
|
|
|
var omittedCloseTags = {
|
|
'area': true,
|
|
'base': true,
|
|
'br': true,
|
|
'col': true,
|
|
'embed': true,
|
|
'hr': true,
|
|
'img': true,
|
|
'input': true,
|
|
'keygen': true,
|
|
'link': true,
|
|
'meta': true,
|
|
'param': true,
|
|
'source': true,
|
|
'track': true,
|
|
'wbr': true
|
|
// NOTE: menuitem's close tag should be omitted, but that causes problems.
|
|
};
|
|
|
|
// We accept any tag to be rendered but since this gets injected into abitrary
|
|
// HTML, we want to make sure that it's a safe tag.
|
|
// http://www.w3.org/TR/REC-xml/#NT-Name
|
|
|
|
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
|
|
var validatedTagCache = {};
|
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
|
|
function validateDangerousTag(tag) {
|
|
if (!hasOwnProperty.call(validatedTagCache, tag)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
|
|
validatedTagCache[tag] = true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates a new React class that is idempotent and capable of containing other
|
|
* React components. It accepts event listeners and DOM properties that are
|
|
* valid according to `DOMProperty`.
|
|
*
|
|
* - Event listeners: `onClick`, `onMouseDown`, etc.
|
|
* - DOM properties: `className`, `name`, `title`, etc.
|
|
*
|
|
* The `style` property functions differently from the DOM API. It accepts an
|
|
* object mapping of style properties to values.
|
|
*
|
|
* @constructor ReactDOMComponent
|
|
* @extends ReactComponent
|
|
* @extends ReactMultiChild
|
|
*/
|
|
function ReactDOMComponent(tag) {
|
|
validateDangerousTag(tag);
|
|
this._tag = tag;
|
|
this.tagName = tag.toUpperCase();
|
|
}
|
|
|
|
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
|
|
|
ReactDOMComponent.Mixin = {
|
|
|
|
/**
|
|
* Generates root tag markup then recurses. This method has side effects and
|
|
* is not idempotent.
|
|
*
|
|
* @internal
|
|
* @param {string} rootID The root DOM ID for this node.
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @param {number} mountDepth number of components in the owner hierarchy
|
|
* @return {string} The computed markup.
|
|
*/
|
|
mountComponent: ReactPerf.measure(
|
|
'ReactDOMComponent',
|
|
'mountComponent',
|
|
function(rootID, transaction, mountDepth) {
|
|
ReactComponent.Mixin.mountComponent.call(
|
|
this,
|
|
rootID,
|
|
transaction,
|
|
mountDepth
|
|
);
|
|
assertValidProps(this.props);
|
|
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
|
return (
|
|
this._createOpenTagMarkupAndPutListeners(transaction) +
|
|
this._createContentMarkup(transaction) +
|
|
closeTag
|
|
);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Creates markup for the open tag and all attributes.
|
|
*
|
|
* This method has side effects because events get registered.
|
|
*
|
|
* Iterating over object properties is faster than iterating over arrays.
|
|
* @see http://jsperf.com/obj-vs-arr-iteration
|
|
*
|
|
* @private
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @return {string} Markup of opening tag.
|
|
*/
|
|
_createOpenTagMarkupAndPutListeners: function(transaction) {
|
|
var props = this.props;
|
|
var ret = '<' + this._tag;
|
|
|
|
for (var propKey in props) {
|
|
if (!props.hasOwnProperty(propKey)) {
|
|
continue;
|
|
}
|
|
var propValue = props[propKey];
|
|
if (propValue == null) {
|
|
continue;
|
|
}
|
|
if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
putListener(this._rootNodeID, propKey, propValue, transaction);
|
|
} else {
|
|
if (propKey === STYLE) {
|
|
if (propValue) {
|
|
propValue = props.style = assign({}, props.style);
|
|
}
|
|
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
|
}
|
|
var markup =
|
|
DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
|
|
if (markup) {
|
|
ret += ' ' + markup;
|
|
}
|
|
}
|
|
}
|
|
|
|
// For static pages, no need to put React ID and checksum. Saves lots of
|
|
// bytes.
|
|
if (transaction.renderToStaticMarkup) {
|
|
return ret + '>';
|
|
}
|
|
|
|
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
|
|
return ret + ' ' + markupForID + '>';
|
|
},
|
|
|
|
/**
|
|
* Creates markup for the content between the tags.
|
|
*
|
|
* @private
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @return {string} Content markup.
|
|
*/
|
|
_createContentMarkup: function(transaction) {
|
|
// Intentional use of != to avoid catching zero/false.
|
|
var innerHTML = this.props.dangerouslySetInnerHTML;
|
|
if (innerHTML != null) {
|
|
if (innerHTML.__html != null) {
|
|
return innerHTML.__html;
|
|
}
|
|
} else {
|
|
var contentToUse =
|
|
CONTENT_TYPES[typeof this.props.children] ? this.props.children : null;
|
|
var childrenToUse = contentToUse != null ? null : this.props.children;
|
|
if (contentToUse != null) {
|
|
return escapeTextForBrowser(contentToUse);
|
|
} else if (childrenToUse != null) {
|
|
var mountImages = this.mountChildren(
|
|
childrenToUse,
|
|
transaction
|
|
);
|
|
return mountImages.join('');
|
|
}
|
|
}
|
|
return '';
|
|
},
|
|
|
|
receiveComponent: function(nextElement, transaction) {
|
|
if (nextElement === this._currentElement &&
|
|
nextElement._owner != null) {
|
|
// Since elements are immutable after the owner is rendered,
|
|
// we can do a cheap identity compare here to determine if this is a
|
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
// change should trigger an update of the owner which would recreate
|
|
// the element. We explicitly check for the existence of an owner since
|
|
// it's possible for a element created outside a composite to be
|
|
// deeply mutated and reused.
|
|
return;
|
|
}
|
|
|
|
ReactComponent.Mixin.receiveComponent.call(
|
|
this,
|
|
nextElement,
|
|
transaction
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Updates a native DOM component after it has already been allocated and
|
|
* attached to the DOM. Reconciles the root DOM node, then recurses.
|
|
*
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @param {ReactElement} prevElement
|
|
* @internal
|
|
* @overridable
|
|
*/
|
|
updateComponent: ReactPerf.measure(
|
|
'ReactDOMComponent',
|
|
'updateComponent',
|
|
function(transaction, prevElement) {
|
|
assertValidProps(this._currentElement.props);
|
|
ReactComponent.Mixin.updateComponent.call(
|
|
this,
|
|
transaction,
|
|
prevElement
|
|
);
|
|
this._updateDOMProperties(prevElement.props, transaction);
|
|
this._updateDOMChildren(prevElement.props, transaction);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Reconciles the properties by detecting differences in property values and
|
|
* updating the DOM as necessary. This function is probably the single most
|
|
* critical path for performance optimization.
|
|
*
|
|
* TODO: Benchmark whether checking for changed values in memory actually
|
|
* improves performance (especially statically positioned elements).
|
|
* TODO: Benchmark the effects of putting this at the top since 99% of props
|
|
* do not change for a given reconciliation.
|
|
* TODO: Benchmark areas that can be improved with caching.
|
|
*
|
|
* @private
|
|
* @param {object} lastProps
|
|
* @param {ReactReconcileTransaction} transaction
|
|
*/
|
|
_updateDOMProperties: function(lastProps, transaction) {
|
|
var nextProps = this.props;
|
|
var propKey;
|
|
var styleName;
|
|
var styleUpdates;
|
|
for (propKey in lastProps) {
|
|
if (nextProps.hasOwnProperty(propKey) ||
|
|
!lastProps.hasOwnProperty(propKey)) {
|
|
continue;
|
|
}
|
|
if (propKey === STYLE) {
|
|
var lastStyle = lastProps[propKey];
|
|
for (styleName in lastStyle) {
|
|
if (lastStyle.hasOwnProperty(styleName)) {
|
|
styleUpdates = styleUpdates || {};
|
|
styleUpdates[styleName] = '';
|
|
}
|
|
}
|
|
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
deleteListener(this._rootNodeID, propKey);
|
|
} else if (
|
|
DOMProperty.isStandardName[propKey] ||
|
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
ReactComponent.BackendIDOperations.deletePropertyByID(
|
|
this._rootNodeID,
|
|
propKey
|
|
);
|
|
}
|
|
}
|
|
for (propKey in nextProps) {
|
|
var nextProp = nextProps[propKey];
|
|
var lastProp = lastProps[propKey];
|
|
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
|
continue;
|
|
}
|
|
if (propKey === STYLE) {
|
|
if (nextProp) {
|
|
nextProp = nextProps.style = assign({}, nextProp);
|
|
}
|
|
if (lastProp) {
|
|
// Unset styles on `lastProp` but not on `nextProp`.
|
|
for (styleName in lastProp) {
|
|
if (lastProp.hasOwnProperty(styleName) &&
|
|
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
|
styleUpdates = styleUpdates || {};
|
|
styleUpdates[styleName] = '';
|
|
}
|
|
}
|
|
// Update styles that changed since `lastProp`.
|
|
for (styleName in nextProp) {
|
|
if (nextProp.hasOwnProperty(styleName) &&
|
|
lastProp[styleName] !== nextProp[styleName]) {
|
|
styleUpdates = styleUpdates || {};
|
|
styleUpdates[styleName] = nextProp[styleName];
|
|
}
|
|
}
|
|
} else {
|
|
// Relies on `updateStylesByID` not mutating `styleUpdates`.
|
|
styleUpdates = nextProp;
|
|
}
|
|
} else if (registrationNameModules.hasOwnProperty(propKey)) {
|
|
putListener(this._rootNodeID, propKey, nextProp, transaction);
|
|
} else if (
|
|
DOMProperty.isStandardName[propKey] ||
|
|
DOMProperty.isCustomAttribute(propKey)) {
|
|
ReactComponent.BackendIDOperations.updatePropertyByID(
|
|
this._rootNodeID,
|
|
propKey,
|
|
nextProp
|
|
);
|
|
}
|
|
}
|
|
if (styleUpdates) {
|
|
ReactComponent.BackendIDOperations.updateStylesByID(
|
|
this._rootNodeID,
|
|
styleUpdates
|
|
);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Reconciles the children with the various properties that affect the
|
|
* children content.
|
|
*
|
|
* @param {object} lastProps
|
|
* @param {ReactReconcileTransaction} transaction
|
|
*/
|
|
_updateDOMChildren: function(lastProps, transaction) {
|
|
var nextProps = this.props;
|
|
|
|
var lastContent =
|
|
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
|
|
var nextContent =
|
|
CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
|
|
|
|
var lastHtml =
|
|
lastProps.dangerouslySetInnerHTML &&
|
|
lastProps.dangerouslySetInnerHTML.__html;
|
|
var nextHtml =
|
|
nextProps.dangerouslySetInnerHTML &&
|
|
nextProps.dangerouslySetInnerHTML.__html;
|
|
|
|
// Note the use of `!=` which checks for null or undefined.
|
|
var lastChildren = lastContent != null ? null : lastProps.children;
|
|
var nextChildren = nextContent != null ? null : nextProps.children;
|
|
|
|
// If we're switching from children to content/html or vice versa, remove
|
|
// the old content
|
|
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
|
|
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
|
|
if (lastChildren != null && nextChildren == null) {
|
|
this.updateChildren(null, transaction);
|
|
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
|
|
this.updateTextContent('');
|
|
}
|
|
|
|
if (nextContent != null) {
|
|
if (lastContent !== nextContent) {
|
|
this.updateTextContent('' + nextContent);
|
|
}
|
|
} else if (nextHtml != null) {
|
|
if (lastHtml !== nextHtml) {
|
|
ReactComponent.BackendIDOperations.updateInnerHTMLByID(
|
|
this._rootNodeID,
|
|
nextHtml
|
|
);
|
|
}
|
|
} else if (nextChildren != null) {
|
|
this.updateChildren(nextChildren, transaction);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Destroys all event registrations for this instance. Does not remove from
|
|
* the DOM. That must be done by the parent.
|
|
*
|
|
* @internal
|
|
*/
|
|
unmountComponent: function() {
|
|
this.unmountChildren();
|
|
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
|
ReactComponent.Mixin.unmountComponent.call(this);
|
|
}
|
|
|
|
};
|
|
|
|
assign(
|
|
ReactDOMComponent.prototype,
|
|
ReactComponent.Mixin,
|
|
ReactDOMComponent.Mixin,
|
|
ReactMultiChild.Mixin,
|
|
ReactBrowserComponentMixin
|
|
);
|
|
|
|
module.exports = ReactDOMComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./CSSPropertyOperations":47,"./DOMProperty":53,"./DOMPropertyOperations":54,"./Object.assign":70,"./ReactBrowserComponentMixin":73,"./ReactBrowserEventEmitter":74,"./ReactComponent":78,"./ReactMount":111,"./ReactMultiChild":112,"./ReactPerf":116,"./escapeTextForBrowser":165,"./invariant":182,"./isEventSupported":183,"./keyOf":189,"./monitorCodeUse":192,"_process":1}],87:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMForm
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
|
|
// Store a reference to the <form> `ReactDOMComponent`. TODO: use string
|
|
var form = ReactElement.createFactory(ReactDOM.form.type);
|
|
|
|
/**
|
|
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
|
|
* to capture it on the <form> element itself. There are lots of hacks we could
|
|
* do to accomplish this, but the most reliable is to make <form> a
|
|
* composite component and use `componentDidMount` to attach the event handlers.
|
|
*/
|
|
var ReactDOMForm = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMForm',
|
|
|
|
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
|
|
render: function() {
|
|
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
|
|
// `jshint` fails to parse JSX so in order for linting to work in the open
|
|
// source repo, we need to just use `ReactDOM.form`.
|
|
return form(this.props);
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
|
|
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
|
|
}
|
|
});
|
|
|
|
module.exports = ReactDOMForm;
|
|
|
|
},{"./EventConstants":58,"./LocalEventTrapMixin":68,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99}],88:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMIDOperations
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
/*jslint evil: true */
|
|
|
|
"use strict";
|
|
|
|
var CSSPropertyOperations = require("./CSSPropertyOperations");
|
|
var DOMChildrenOperations = require("./DOMChildrenOperations");
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactPerf = require("./ReactPerf");
|
|
|
|
var invariant = require("./invariant");
|
|
var setInnerHTML = require("./setInnerHTML");
|
|
|
|
/**
|
|
* Errors for properties that should not be updated with `updatePropertyById()`.
|
|
*
|
|
* @type {object}
|
|
* @private
|
|
*/
|
|
var INVALID_PROPERTY_ERRORS = {
|
|
dangerouslySetInnerHTML:
|
|
'`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
|
|
style: '`style` must be set using `updateStylesByID()`.'
|
|
};
|
|
|
|
/**
|
|
* Operations used to process updates to DOM nodes. This is made injectable via
|
|
* `ReactComponent.BackendIDOperations`.
|
|
*/
|
|
var ReactDOMIDOperations = {
|
|
|
|
/**
|
|
* Updates a DOM node with new property values. This should only be used to
|
|
* update DOM properties in `DOMProperty`.
|
|
*
|
|
* @param {string} id ID of the node to update.
|
|
* @param {string} name A valid property name, see `DOMProperty`.
|
|
* @param {*} value New value of the property.
|
|
* @internal
|
|
*/
|
|
updatePropertyByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'updatePropertyByID',
|
|
function(id, name, value) {
|
|
var node = ReactMount.getNode(id);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
'updatePropertyByID(...): %s',
|
|
INVALID_PROPERTY_ERRORS[name]
|
|
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
|
|
// If we're updating to null or undefined, we should remove the property
|
|
// from the DOM node instead of inadvertantly setting to a string. This
|
|
// brings us in line with the same behavior we have on initial render.
|
|
if (value != null) {
|
|
DOMPropertyOperations.setValueForProperty(node, name, value);
|
|
} else {
|
|
DOMPropertyOperations.deleteValueForProperty(node, name);
|
|
}
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Updates a DOM node to remove a property. This should only be used to remove
|
|
* DOM properties in `DOMProperty`.
|
|
*
|
|
* @param {string} id ID of the node to update.
|
|
* @param {string} name A property name to remove, see `DOMProperty`.
|
|
* @internal
|
|
*/
|
|
deletePropertyByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'deletePropertyByID',
|
|
function(id, name, value) {
|
|
var node = ReactMount.getNode(id);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
|
'updatePropertyByID(...): %s',
|
|
INVALID_PROPERTY_ERRORS[name]
|
|
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
|
DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Updates a DOM node with new style values. If a value is specified as '',
|
|
* the corresponding style property will be unset.
|
|
*
|
|
* @param {string} id ID of the node to update.
|
|
* @param {object} styles Mapping from styles to values.
|
|
* @internal
|
|
*/
|
|
updateStylesByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'updateStylesByID',
|
|
function(id, styles) {
|
|
var node = ReactMount.getNode(id);
|
|
CSSPropertyOperations.setValueForStyles(node, styles);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Updates a DOM node's innerHTML.
|
|
*
|
|
* @param {string} id ID of the node to update.
|
|
* @param {string} html An HTML string.
|
|
* @internal
|
|
*/
|
|
updateInnerHTMLByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'updateInnerHTMLByID',
|
|
function(id, html) {
|
|
var node = ReactMount.getNode(id);
|
|
setInnerHTML(node, html);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Updates a DOM node's text content set by `props.content`.
|
|
*
|
|
* @param {string} id ID of the node to update.
|
|
* @param {string} content Text content.
|
|
* @internal
|
|
*/
|
|
updateTextContentByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'updateTextContentByID',
|
|
function(id, content) {
|
|
var node = ReactMount.getNode(id);
|
|
DOMChildrenOperations.updateTextContent(node, content);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Replaces a DOM node that exists in the document with markup.
|
|
*
|
|
* @param {string} id ID of child to be replaced.
|
|
* @param {string} markup Dangerous markup to inject in place of child.
|
|
* @internal
|
|
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
|
|
*/
|
|
dangerouslyReplaceNodeWithMarkupByID: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'dangerouslyReplaceNodeWithMarkupByID',
|
|
function(id, markup) {
|
|
var node = ReactMount.getNode(id);
|
|
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Updates a component's children by processing a series of updates.
|
|
*
|
|
* @param {array<object>} updates List of update configurations.
|
|
* @param {array<string>} markup List of markup strings.
|
|
* @internal
|
|
*/
|
|
dangerouslyProcessChildrenUpdates: ReactPerf.measure(
|
|
'ReactDOMIDOperations',
|
|
'dangerouslyProcessChildrenUpdates',
|
|
function(updates, markup) {
|
|
for (var i = 0; i < updates.length; i++) {
|
|
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
|
}
|
|
DOMChildrenOperations.processUpdates(updates, markup);
|
|
}
|
|
)
|
|
};
|
|
|
|
module.exports = ReactDOMIDOperations;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./CSSPropertyOperations":47,"./DOMChildrenOperations":52,"./DOMPropertyOperations":54,"./ReactMount":111,"./ReactPerf":116,"./invariant":182,"./setInnerHTML":196,"_process":1}],89:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMImg
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
|
|
// Store a reference to the <img> `ReactDOMComponent`. TODO: use string
|
|
var img = ReactElement.createFactory(ReactDOM.img.type);
|
|
|
|
/**
|
|
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
|
|
* capture it on the <img> element itself. There are lots of hacks we could do
|
|
* to accomplish this, but the most reliable is to make <img> a composite
|
|
* component and use `componentDidMount` to attach the event handlers.
|
|
*/
|
|
var ReactDOMImg = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMImg',
|
|
tagName: 'IMG',
|
|
|
|
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
|
|
|
render: function() {
|
|
return img(this.props);
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
|
|
this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
|
|
}
|
|
});
|
|
|
|
module.exports = ReactDOMImg;
|
|
|
|
},{"./EventConstants":58,"./LocalEventTrapMixin":68,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99}],90:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMInput
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
|
|
// Store a reference to the <input> `ReactDOMComponent`. TODO: use string
|
|
var input = ReactElement.createFactory(ReactDOM.input.type);
|
|
|
|
var instancesByReactID = {};
|
|
|
|
function forceUpdateIfMounted() {
|
|
/*jshint validthis:true */
|
|
if (this.isMounted()) {
|
|
this.forceUpdate();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements an <input> native component that allows setting these optional
|
|
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
|
|
*
|
|
* If `checked` or `value` are not supplied (or null/undefined), user actions
|
|
* that affect the checked state or value will trigger updates to the element.
|
|
*
|
|
* If they are supplied (and not null/undefined), the rendered element will not
|
|
* trigger updates to the element. Instead, the props must change in order for
|
|
* the rendered element to be updated.
|
|
*
|
|
* The rendered element will be initialized as unchecked (or `defaultChecked`)
|
|
* with an empty value (or `defaultValue`).
|
|
*
|
|
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
|
|
*/
|
|
var ReactDOMInput = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMInput',
|
|
|
|
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
|
|
getInitialState: function() {
|
|
var defaultValue = this.props.defaultValue;
|
|
return {
|
|
initialChecked: this.props.defaultChecked || false,
|
|
initialValue: defaultValue != null ? defaultValue : null
|
|
};
|
|
},
|
|
|
|
render: function() {
|
|
// Clone `this.props` so we don't mutate the input.
|
|
var props = assign({}, this.props);
|
|
|
|
props.defaultChecked = null;
|
|
props.defaultValue = null;
|
|
|
|
var value = LinkedValueUtils.getValue(this);
|
|
props.value = value != null ? value : this.state.initialValue;
|
|
|
|
var checked = LinkedValueUtils.getChecked(this);
|
|
props.checked = checked != null ? checked : this.state.initialChecked;
|
|
|
|
props.onChange = this._handleChange;
|
|
|
|
return input(props, this.props.children);
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
var id = ReactMount.getID(this.getDOMNode());
|
|
instancesByReactID[id] = this;
|
|
},
|
|
|
|
componentWillUnmount: function() {
|
|
var rootNode = this.getDOMNode();
|
|
var id = ReactMount.getID(rootNode);
|
|
delete instancesByReactID[id];
|
|
},
|
|
|
|
componentDidUpdate: function(prevProps, prevState, prevContext) {
|
|
var rootNode = this.getDOMNode();
|
|
if (this.props.checked != null) {
|
|
DOMPropertyOperations.setValueForProperty(
|
|
rootNode,
|
|
'checked',
|
|
this.props.checked || false
|
|
);
|
|
}
|
|
|
|
var value = LinkedValueUtils.getValue(this);
|
|
if (value != null) {
|
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
|
|
}
|
|
},
|
|
|
|
_handleChange: function(event) {
|
|
var returnValue;
|
|
var onChange = LinkedValueUtils.getOnChange(this);
|
|
if (onChange) {
|
|
returnValue = onChange.call(this, event);
|
|
}
|
|
// Here we use asap to wait until all updates have propagated, which
|
|
// is important when using controlled components within layers:
|
|
// https://github.com/facebook/react/issues/1698
|
|
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
|
|
var name = this.props.name;
|
|
if (this.props.type === 'radio' && name != null) {
|
|
var rootNode = this.getDOMNode();
|
|
var queryRoot = rootNode;
|
|
|
|
while (queryRoot.parentNode) {
|
|
queryRoot = queryRoot.parentNode;
|
|
}
|
|
|
|
// If `rootNode.form` was non-null, then we could try `form.elements`,
|
|
// but that sometimes behaves strangely in IE8. We could also try using
|
|
// `form.getElementsByName`, but that will only return direct children
|
|
// and won't include inputs that use the HTML5 `form=` attribute. Since
|
|
// the input might not even be in a form, let's just use the global
|
|
// `querySelectorAll` to ensure we don't miss anything.
|
|
var group = queryRoot.querySelectorAll(
|
|
'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
|
|
|
|
for (var i = 0, groupLen = group.length; i < groupLen; i++) {
|
|
var otherNode = group[i];
|
|
if (otherNode === rootNode ||
|
|
otherNode.form !== rootNode.form) {
|
|
continue;
|
|
}
|
|
var otherID = ReactMount.getID(otherNode);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
otherID,
|
|
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
|
|
'same `name` is not supported.'
|
|
) : invariant(otherID));
|
|
var otherInstance = instancesByReactID[otherID];
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
otherInstance,
|
|
'ReactDOMInput: Unknown radio button ID %s.',
|
|
otherID
|
|
) : invariant(otherInstance));
|
|
// If this is a controlled radio button group, forcing the input that
|
|
// was previously checked to update will cause it to be come re-checked
|
|
// as appropriate.
|
|
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
|
|
}
|
|
}
|
|
|
|
return returnValue;
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = ReactDOMInput;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./AutoFocusMixin":43,"./DOMPropertyOperations":54,"./LinkedValueUtils":67,"./Object.assign":70,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99,"./ReactMount":111,"./ReactUpdates":132,"./invariant":182,"_process":1}],91:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMOption
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
|
|
var warning = require("./warning");
|
|
|
|
// Store a reference to the <option> `ReactDOMComponent`. TODO: use string
|
|
var option = ReactElement.createFactory(ReactDOM.option.type);
|
|
|
|
/**
|
|
* Implements an <option> native component that warns when `selected` is set.
|
|
*/
|
|
var ReactDOMOption = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMOption',
|
|
|
|
mixins: [ReactBrowserComponentMixin],
|
|
|
|
componentWillMount: function() {
|
|
// TODO (yungsters): Remove support for `selected` in <option>.
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
this.props.selected == null,
|
|
'Use the `defaultValue` or `value` props on <select> instead of ' +
|
|
'setting `selected` on <option>.'
|
|
) : null);
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
return option(this.props, this.props.children);
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = ReactDOMOption;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99,"./warning":202,"_process":1}],92:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMSelect
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
// Store a reference to the <select> `ReactDOMComponent`. TODO: use string
|
|
var select = ReactElement.createFactory(ReactDOM.select.type);
|
|
|
|
function updateWithPendingValueIfMounted() {
|
|
/*jshint validthis:true */
|
|
if (this.isMounted()) {
|
|
this.setState({value: this._pendingValue});
|
|
this._pendingValue = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Validation function for `value` and `defaultValue`.
|
|
* @private
|
|
*/
|
|
function selectValueType(props, propName, componentName) {
|
|
if (props[propName] == null) {
|
|
return;
|
|
}
|
|
if (props.multiple) {
|
|
if (!Array.isArray(props[propName])) {
|
|
return new Error(
|
|
("The `" + propName + "` prop supplied to <select> must be an array if ") +
|
|
("`multiple` is true.")
|
|
);
|
|
}
|
|
} else {
|
|
if (Array.isArray(props[propName])) {
|
|
return new Error(
|
|
("The `" + propName + "` prop supplied to <select> must be a scalar ") +
|
|
("value if `multiple` is false.")
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* If `value` is supplied, updates <option> elements on mount and update.
|
|
* @param {ReactComponent} component Instance of ReactDOMSelect
|
|
* @param {?*} propValue For uncontrolled components, null/undefined. For
|
|
* controlled components, a string (or with `multiple`, a list of strings).
|
|
* @private
|
|
*/
|
|
function updateOptions(component, propValue) {
|
|
var multiple = component.props.multiple;
|
|
var value = propValue != null ? propValue : component.state.value;
|
|
var options = component.getDOMNode().options;
|
|
var selectedValue, i, l;
|
|
if (multiple) {
|
|
selectedValue = {};
|
|
for (i = 0, l = value.length; i < l; ++i) {
|
|
selectedValue['' + value[i]] = true;
|
|
}
|
|
} else {
|
|
selectedValue = '' + value;
|
|
}
|
|
for (i = 0, l = options.length; i < l; i++) {
|
|
var selected = multiple ?
|
|
selectedValue.hasOwnProperty(options[i].value) :
|
|
options[i].value === selectedValue;
|
|
|
|
if (selected !== options[i].selected) {
|
|
options[i].selected = selected;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements a <select> native component that allows optionally setting the
|
|
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
|
|
* string. If `multiple` is true, the prop must be an array of strings.
|
|
*
|
|
* If `value` is not supplied (or null/undefined), user actions that change the
|
|
* selected option will trigger updates to the rendered options.
|
|
*
|
|
* If it is supplied (and not null/undefined), the rendered options will not
|
|
* update in response to user actions. Instead, the `value` prop must change in
|
|
* order for the rendered options to update.
|
|
*
|
|
* If `defaultValue` is provided, any options with the supplied values will be
|
|
* selected.
|
|
*/
|
|
var ReactDOMSelect = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMSelect',
|
|
|
|
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
|
|
propTypes: {
|
|
defaultValue: selectValueType,
|
|
value: selectValueType
|
|
},
|
|
|
|
getInitialState: function() {
|
|
return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
this._pendingValue = null;
|
|
},
|
|
|
|
componentWillReceiveProps: function(nextProps) {
|
|
if (!this.props.multiple && nextProps.multiple) {
|
|
this.setState({value: [this.state.value]});
|
|
} else if (this.props.multiple && !nextProps.multiple) {
|
|
this.setState({value: this.state.value[0]});
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
// Clone `this.props` so we don't mutate the input.
|
|
var props = assign({}, this.props);
|
|
|
|
props.onChange = this._handleChange;
|
|
props.value = null;
|
|
|
|
return select(props, this.props.children);
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
updateOptions(this, LinkedValueUtils.getValue(this));
|
|
},
|
|
|
|
componentDidUpdate: function(prevProps) {
|
|
var value = LinkedValueUtils.getValue(this);
|
|
var prevMultiple = !!prevProps.multiple;
|
|
var multiple = !!this.props.multiple;
|
|
if (value != null || prevMultiple !== multiple) {
|
|
updateOptions(this, value);
|
|
}
|
|
},
|
|
|
|
_handleChange: function(event) {
|
|
var returnValue;
|
|
var onChange = LinkedValueUtils.getOnChange(this);
|
|
if (onChange) {
|
|
returnValue = onChange.call(this, event);
|
|
}
|
|
|
|
var selectedValue;
|
|
if (this.props.multiple) {
|
|
selectedValue = [];
|
|
var options = event.target.options;
|
|
for (var i = 0, l = options.length; i < l; i++) {
|
|
if (options[i].selected) {
|
|
selectedValue.push(options[i].value);
|
|
}
|
|
}
|
|
} else {
|
|
selectedValue = event.target.value;
|
|
}
|
|
|
|
this._pendingValue = selectedValue;
|
|
ReactUpdates.asap(updateWithPendingValueIfMounted, this);
|
|
return returnValue;
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = ReactDOMSelect;
|
|
|
|
},{"./AutoFocusMixin":43,"./LinkedValueUtils":67,"./Object.assign":70,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99,"./ReactUpdates":132}],93:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMSelection
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var getNodeForCharacterOffset = require("./getNodeForCharacterOffset");
|
|
var getTextContentAccessor = require("./getTextContentAccessor");
|
|
|
|
/**
|
|
* While `isCollapsed` is available on the Selection object and `collapsed`
|
|
* is available on the Range object, IE11 sometimes gets them wrong.
|
|
* If the anchor/focus nodes and offsets are the same, the range is collapsed.
|
|
*/
|
|
function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
|
|
return anchorNode === focusNode && anchorOffset === focusOffset;
|
|
}
|
|
|
|
/**
|
|
* Get the appropriate anchor and focus node/offset pairs for IE.
|
|
*
|
|
* The catch here is that IE's selection API doesn't provide information
|
|
* about whether the selection is forward or backward, so we have to
|
|
* behave as though it's always forward.
|
|
*
|
|
* IE text differs from modern selection in that it behaves as though
|
|
* block elements end with a new line. This means character offsets will
|
|
* differ between the two APIs.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @return {object}
|
|
*/
|
|
function getIEOffsets(node) {
|
|
var selection = document.selection;
|
|
var selectedRange = selection.createRange();
|
|
var selectedLength = selectedRange.text.length;
|
|
|
|
// Duplicate selection so we can move range without breaking user selection.
|
|
var fromStart = selectedRange.duplicate();
|
|
fromStart.moveToElementText(node);
|
|
fromStart.setEndPoint('EndToStart', selectedRange);
|
|
|
|
var startOffset = fromStart.text.length;
|
|
var endOffset = startOffset + selectedLength;
|
|
|
|
return {
|
|
start: startOffset,
|
|
end: endOffset
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param {DOMElement} node
|
|
* @return {?object}
|
|
*/
|
|
function getModernOffsets(node) {
|
|
var selection = window.getSelection && window.getSelection();
|
|
|
|
if (!selection || selection.rangeCount === 0) {
|
|
return null;
|
|
}
|
|
|
|
var anchorNode = selection.anchorNode;
|
|
var anchorOffset = selection.anchorOffset;
|
|
var focusNode = selection.focusNode;
|
|
var focusOffset = selection.focusOffset;
|
|
|
|
var currentRange = selection.getRangeAt(0);
|
|
|
|
// If the node and offset values are the same, the selection is collapsed.
|
|
// `Selection.isCollapsed` is available natively, but IE sometimes gets
|
|
// this value wrong.
|
|
var isSelectionCollapsed = isCollapsed(
|
|
selection.anchorNode,
|
|
selection.anchorOffset,
|
|
selection.focusNode,
|
|
selection.focusOffset
|
|
);
|
|
|
|
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
|
|
|
|
var tempRange = currentRange.cloneRange();
|
|
tempRange.selectNodeContents(node);
|
|
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
|
|
|
|
var isTempRangeCollapsed = isCollapsed(
|
|
tempRange.startContainer,
|
|
tempRange.startOffset,
|
|
tempRange.endContainer,
|
|
tempRange.endOffset
|
|
);
|
|
|
|
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
|
|
var end = start + rangeLength;
|
|
|
|
// Detect whether the selection is backward.
|
|
var detectionRange = document.createRange();
|
|
detectionRange.setStart(anchorNode, anchorOffset);
|
|
detectionRange.setEnd(focusNode, focusOffset);
|
|
var isBackward = detectionRange.collapsed;
|
|
|
|
return {
|
|
start: isBackward ? end : start,
|
|
end: isBackward ? start : end
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param {DOMElement|DOMTextNode} node
|
|
* @param {object} offsets
|
|
*/
|
|
function setIEOffsets(node, offsets) {
|
|
var range = document.selection.createRange().duplicate();
|
|
var start, end;
|
|
|
|
if (typeof offsets.end === 'undefined') {
|
|
start = offsets.start;
|
|
end = start;
|
|
} else if (offsets.start > offsets.end) {
|
|
start = offsets.end;
|
|
end = offsets.start;
|
|
} else {
|
|
start = offsets.start;
|
|
end = offsets.end;
|
|
}
|
|
|
|
range.moveToElementText(node);
|
|
range.moveStart('character', start);
|
|
range.setEndPoint('EndToStart', range);
|
|
range.moveEnd('character', end - start);
|
|
range.select();
|
|
}
|
|
|
|
/**
|
|
* In modern non-IE browsers, we can support both forward and backward
|
|
* selections.
|
|
*
|
|
* Note: IE10+ supports the Selection object, but it does not support
|
|
* the `extend` method, which means that even in modern IE, it's not possible
|
|
* to programatically create a backward selection. Thus, for all IE
|
|
* versions, we use the old IE API to create our selections.
|
|
*
|
|
* @param {DOMElement|DOMTextNode} node
|
|
* @param {object} offsets
|
|
*/
|
|
function setModernOffsets(node, offsets) {
|
|
if (!window.getSelection) {
|
|
return;
|
|
}
|
|
|
|
var selection = window.getSelection();
|
|
var length = node[getTextContentAccessor()].length;
|
|
var start = Math.min(offsets.start, length);
|
|
var end = typeof offsets.end === 'undefined' ?
|
|
start : Math.min(offsets.end, length);
|
|
|
|
// IE 11 uses modern selection, but doesn't support the extend method.
|
|
// Flip backward selections, so we can set with a single range.
|
|
if (!selection.extend && start > end) {
|
|
var temp = end;
|
|
end = start;
|
|
start = temp;
|
|
}
|
|
|
|
var startMarker = getNodeForCharacterOffset(node, start);
|
|
var endMarker = getNodeForCharacterOffset(node, end);
|
|
|
|
if (startMarker && endMarker) {
|
|
var range = document.createRange();
|
|
range.setStart(startMarker.node, startMarker.offset);
|
|
selection.removeAllRanges();
|
|
|
|
if (start > end) {
|
|
selection.addRange(range);
|
|
selection.extend(endMarker.node, endMarker.offset);
|
|
} else {
|
|
range.setEnd(endMarker.node, endMarker.offset);
|
|
selection.addRange(range);
|
|
}
|
|
}
|
|
}
|
|
|
|
var useIEOffsets = ExecutionEnvironment.canUseDOM && document.selection;
|
|
|
|
var ReactDOMSelection = {
|
|
/**
|
|
* @param {DOMElement} node
|
|
*/
|
|
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
|
|
|
|
/**
|
|
* @param {DOMElement|DOMTextNode} node
|
|
* @param {object} offsets
|
|
*/
|
|
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
|
|
};
|
|
|
|
module.exports = ReactDOMSelection;
|
|
|
|
},{"./ExecutionEnvironment":64,"./getNodeForCharacterOffset":175,"./getTextContentAccessor":177}],94:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDOMTextarea
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var AutoFocusMixin = require("./AutoFocusMixin");
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var LinkedValueUtils = require("./LinkedValueUtils");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactDOM = require("./ReactDOM");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
|
|
var warning = require("./warning");
|
|
|
|
// Store a reference to the <textarea> `ReactDOMComponent`. TODO: use string
|
|
var textarea = ReactElement.createFactory(ReactDOM.textarea.type);
|
|
|
|
function forceUpdateIfMounted() {
|
|
/*jshint validthis:true */
|
|
if (this.isMounted()) {
|
|
this.forceUpdate();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements a <textarea> native component that allows setting `value`, and
|
|
* `defaultValue`. This differs from the traditional DOM API because value is
|
|
* usually set as PCDATA children.
|
|
*
|
|
* If `value` is not supplied (or null/undefined), user actions that affect the
|
|
* value will trigger updates to the element.
|
|
*
|
|
* If `value` is supplied (and not null/undefined), the rendered element will
|
|
* not trigger updates to the element. Instead, the `value` prop must change in
|
|
* order for the rendered element to be updated.
|
|
*
|
|
* The rendered element will be initialized with an empty value, the prop
|
|
* `defaultValue` if specified, or the children content (deprecated).
|
|
*/
|
|
var ReactDOMTextarea = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactDOMTextarea',
|
|
|
|
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
|
|
|
getInitialState: function() {
|
|
var defaultValue = this.props.defaultValue;
|
|
// TODO (yungsters): Remove support for children content in <textarea>.
|
|
var children = this.props.children;
|
|
if (children != null) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'Use the `defaultValue` or `value` props instead of setting ' +
|
|
'children on <textarea>.'
|
|
) : null);
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
defaultValue == null,
|
|
'If you supply `defaultValue` on a <textarea>, do not pass children.'
|
|
) : invariant(defaultValue == null));
|
|
if (Array.isArray(children)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
children.length <= 1,
|
|
'<textarea> can only have at most one child.'
|
|
) : invariant(children.length <= 1));
|
|
children = children[0];
|
|
}
|
|
|
|
defaultValue = '' + children;
|
|
}
|
|
if (defaultValue == null) {
|
|
defaultValue = '';
|
|
}
|
|
var value = LinkedValueUtils.getValue(this);
|
|
return {
|
|
// We save the initial value so that `ReactDOMComponent` doesn't update
|
|
// `textContent` (unnecessary since we update value).
|
|
// The initial value can be a boolean or object so that's why it's
|
|
// forced to be a string.
|
|
initialValue: '' + (value != null ? value : defaultValue)
|
|
};
|
|
},
|
|
|
|
render: function() {
|
|
// Clone `this.props` so we don't mutate the input.
|
|
var props = assign({}, this.props);
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
props.dangerouslySetInnerHTML == null,
|
|
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
|
|
) : invariant(props.dangerouslySetInnerHTML == null));
|
|
|
|
props.defaultValue = null;
|
|
props.value = null;
|
|
props.onChange = this._handleChange;
|
|
|
|
// Always set children to the same thing. In IE9, the selection range will
|
|
// get reset if `textContent` is mutated.
|
|
return textarea(props, this.state.initialValue);
|
|
},
|
|
|
|
componentDidUpdate: function(prevProps, prevState, prevContext) {
|
|
var value = LinkedValueUtils.getValue(this);
|
|
if (value != null) {
|
|
var rootNode = this.getDOMNode();
|
|
// Cast `value` to a string to ensure the value is set correctly. While
|
|
// browsers typically do this as necessary, jsdom doesn't.
|
|
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
|
|
}
|
|
},
|
|
|
|
_handleChange: function(event) {
|
|
var returnValue;
|
|
var onChange = LinkedValueUtils.getOnChange(this);
|
|
if (onChange) {
|
|
returnValue = onChange.call(this, event);
|
|
}
|
|
ReactUpdates.asap(forceUpdateIfMounted, this);
|
|
return returnValue;
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = ReactDOMTextarea;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./AutoFocusMixin":43,"./DOMPropertyOperations":54,"./LinkedValueUtils":67,"./Object.assign":70,"./ReactBrowserComponentMixin":73,"./ReactCompositeComponent":81,"./ReactDOM":84,"./ReactElement":99,"./ReactUpdates":132,"./invariant":182,"./warning":202,"_process":1}],95:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDefaultBatchingStrategy
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
var Transaction = require("./Transaction");
|
|
|
|
var assign = require("./Object.assign");
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
var RESET_BATCHED_UPDATES = {
|
|
initialize: emptyFunction,
|
|
close: function() {
|
|
ReactDefaultBatchingStrategy.isBatchingUpdates = false;
|
|
}
|
|
};
|
|
|
|
var FLUSH_BATCHED_UPDATES = {
|
|
initialize: emptyFunction,
|
|
close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
|
|
};
|
|
|
|
var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
|
|
|
|
function ReactDefaultBatchingStrategyTransaction() {
|
|
this.reinitializeTransaction();
|
|
}
|
|
|
|
assign(
|
|
ReactDefaultBatchingStrategyTransaction.prototype,
|
|
Transaction.Mixin,
|
|
{
|
|
getTransactionWrappers: function() {
|
|
return TRANSACTION_WRAPPERS;
|
|
}
|
|
}
|
|
);
|
|
|
|
var transaction = new ReactDefaultBatchingStrategyTransaction();
|
|
|
|
var ReactDefaultBatchingStrategy = {
|
|
isBatchingUpdates: false,
|
|
|
|
/**
|
|
* Call the provided function in a context within which calls to `setState`
|
|
* and friends are batched such that components aren't updated unnecessarily.
|
|
*/
|
|
batchedUpdates: function(callback, a, b) {
|
|
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
|
|
|
|
ReactDefaultBatchingStrategy.isBatchingUpdates = true;
|
|
|
|
// The code is written this way to avoid extra allocations
|
|
if (alreadyBatchingUpdates) {
|
|
callback(a, b);
|
|
} else {
|
|
transaction.perform(callback, null, a, b);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = ReactDefaultBatchingStrategy;
|
|
|
|
},{"./Object.assign":70,"./ReactUpdates":132,"./Transaction":149,"./emptyFunction":163}],96:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDefaultInjection
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var BeforeInputEventPlugin = require("./BeforeInputEventPlugin");
|
|
var ChangeEventPlugin = require("./ChangeEventPlugin");
|
|
var ClientReactRootIndex = require("./ClientReactRootIndex");
|
|
var CompositionEventPlugin = require("./CompositionEventPlugin");
|
|
var DefaultEventPluginOrder = require("./DefaultEventPluginOrder");
|
|
var EnterLeaveEventPlugin = require("./EnterLeaveEventPlugin");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
var HTMLDOMPropertyConfig = require("./HTMLDOMPropertyConfig");
|
|
var MobileSafariClickEventPlugin = require("./MobileSafariClickEventPlugin");
|
|
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
|
|
var ReactComponentBrowserEnvironment =
|
|
require("./ReactComponentBrowserEnvironment");
|
|
var ReactDefaultBatchingStrategy = require("./ReactDefaultBatchingStrategy");
|
|
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
var ReactDOMButton = require("./ReactDOMButton");
|
|
var ReactDOMForm = require("./ReactDOMForm");
|
|
var ReactDOMImg = require("./ReactDOMImg");
|
|
var ReactDOMInput = require("./ReactDOMInput");
|
|
var ReactDOMOption = require("./ReactDOMOption");
|
|
var ReactDOMSelect = require("./ReactDOMSelect");
|
|
var ReactDOMTextarea = require("./ReactDOMTextarea");
|
|
var ReactEventListener = require("./ReactEventListener");
|
|
var ReactInjection = require("./ReactInjection");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
var ReactMount = require("./ReactMount");
|
|
var SelectEventPlugin = require("./SelectEventPlugin");
|
|
var ServerReactRootIndex = require("./ServerReactRootIndex");
|
|
var SimpleEventPlugin = require("./SimpleEventPlugin");
|
|
var SVGDOMPropertyConfig = require("./SVGDOMPropertyConfig");
|
|
|
|
var createFullPageComponent = require("./createFullPageComponent");
|
|
|
|
function inject() {
|
|
ReactInjection.EventEmitter.injectReactEventListener(
|
|
ReactEventListener
|
|
);
|
|
|
|
/**
|
|
* Inject modules for resolving DOM hierarchy and plugin ordering.
|
|
*/
|
|
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
|
|
ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
|
|
ReactInjection.EventPluginHub.injectMount(ReactMount);
|
|
|
|
/**
|
|
* Some important event plugins included by default (without having to require
|
|
* them).
|
|
*/
|
|
ReactInjection.EventPluginHub.injectEventPluginsByName({
|
|
SimpleEventPlugin: SimpleEventPlugin,
|
|
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
|
|
ChangeEventPlugin: ChangeEventPlugin,
|
|
CompositionEventPlugin: CompositionEventPlugin,
|
|
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
|
|
SelectEventPlugin: SelectEventPlugin,
|
|
BeforeInputEventPlugin: BeforeInputEventPlugin
|
|
});
|
|
|
|
ReactInjection.NativeComponent.injectGenericComponentClass(
|
|
ReactDOMComponent
|
|
);
|
|
|
|
ReactInjection.NativeComponent.injectComponentClasses({
|
|
'button': ReactDOMButton,
|
|
'form': ReactDOMForm,
|
|
'img': ReactDOMImg,
|
|
'input': ReactDOMInput,
|
|
'option': ReactDOMOption,
|
|
'select': ReactDOMSelect,
|
|
'textarea': ReactDOMTextarea,
|
|
|
|
'html': createFullPageComponent('html'),
|
|
'head': createFullPageComponent('head'),
|
|
'body': createFullPageComponent('body')
|
|
});
|
|
|
|
// This needs to happen after createFullPageComponent() otherwise the mixin
|
|
// gets double injected.
|
|
ReactInjection.CompositeComponent.injectMixin(ReactBrowserComponentMixin);
|
|
|
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
|
|
|
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
|
|
|
|
ReactInjection.Updates.injectReconcileTransaction(
|
|
ReactComponentBrowserEnvironment.ReactReconcileTransaction
|
|
);
|
|
ReactInjection.Updates.injectBatchingStrategy(
|
|
ReactDefaultBatchingStrategy
|
|
);
|
|
|
|
ReactInjection.RootIndex.injectCreateReactRootIndex(
|
|
ExecutionEnvironment.canUseDOM ?
|
|
ClientReactRootIndex.createReactRootIndex :
|
|
ServerReactRootIndex.createReactRootIndex
|
|
);
|
|
|
|
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
|
|
if ((/[?&]react_perf\b/).test(url)) {
|
|
var ReactDefaultPerf = require("./ReactDefaultPerf");
|
|
ReactDefaultPerf.start();
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
inject: inject
|
|
};
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./BeforeInputEventPlugin":44,"./ChangeEventPlugin":49,"./ClientReactRootIndex":50,"./CompositionEventPlugin":51,"./DefaultEventPluginOrder":56,"./EnterLeaveEventPlugin":57,"./ExecutionEnvironment":64,"./HTMLDOMPropertyConfig":65,"./MobileSafariClickEventPlugin":69,"./ReactBrowserComponentMixin":73,"./ReactComponentBrowserEnvironment":79,"./ReactDOMButton":85,"./ReactDOMComponent":86,"./ReactDOMForm":87,"./ReactDOMImg":89,"./ReactDOMInput":90,"./ReactDOMOption":91,"./ReactDOMSelect":92,"./ReactDOMTextarea":94,"./ReactDefaultBatchingStrategy":95,"./ReactDefaultPerf":97,"./ReactEventListener":104,"./ReactInjection":105,"./ReactInstanceHandles":107,"./ReactMount":111,"./SVGDOMPropertyConfig":134,"./SelectEventPlugin":135,"./ServerReactRootIndex":136,"./SimpleEventPlugin":137,"./createFullPageComponent":158,"_process":1}],97:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDefaultPerf
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
var ReactDefaultPerfAnalysis = require("./ReactDefaultPerfAnalysis");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactPerf = require("./ReactPerf");
|
|
|
|
var performanceNow = require("./performanceNow");
|
|
|
|
function roundFloat(val) {
|
|
return Math.floor(val * 100) / 100;
|
|
}
|
|
|
|
function addValue(obj, key, val) {
|
|
obj[key] = (obj[key] || 0) + val;
|
|
}
|
|
|
|
var ReactDefaultPerf = {
|
|
_allMeasurements: [], // last item in the list is the current one
|
|
_mountStack: [0],
|
|
_injected: false,
|
|
|
|
start: function() {
|
|
if (!ReactDefaultPerf._injected) {
|
|
ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
|
|
}
|
|
|
|
ReactDefaultPerf._allMeasurements.length = 0;
|
|
ReactPerf.enableMeasure = true;
|
|
},
|
|
|
|
stop: function() {
|
|
ReactPerf.enableMeasure = false;
|
|
},
|
|
|
|
getLastMeasurements: function() {
|
|
return ReactDefaultPerf._allMeasurements;
|
|
},
|
|
|
|
printExclusive: function(measurements) {
|
|
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
|
|
console.table(summary.map(function(item) {
|
|
return {
|
|
'Component class name': item.componentName,
|
|
'Total inclusive time (ms)': roundFloat(item.inclusive),
|
|
'Exclusive mount time (ms)': roundFloat(item.exclusive),
|
|
'Exclusive render time (ms)': roundFloat(item.render),
|
|
'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
|
|
'Render time per instance (ms)': roundFloat(item.render / item.count),
|
|
'Instances': item.count
|
|
};
|
|
}));
|
|
// TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
|
|
// number.
|
|
},
|
|
|
|
printInclusive: function(measurements) {
|
|
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
|
|
console.table(summary.map(function(item) {
|
|
return {
|
|
'Owner > component': item.componentName,
|
|
'Inclusive time (ms)': roundFloat(item.time),
|
|
'Instances': item.count
|
|
};
|
|
}));
|
|
console.log(
|
|
'Total time:',
|
|
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
|
);
|
|
},
|
|
|
|
getMeasurementsSummaryMap: function(measurements) {
|
|
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
|
|
measurements,
|
|
true
|
|
);
|
|
return summary.map(function(item) {
|
|
return {
|
|
'Owner > component': item.componentName,
|
|
'Wasted time (ms)': item.time,
|
|
'Instances': item.count
|
|
};
|
|
});
|
|
},
|
|
|
|
printWasted: function(measurements) {
|
|
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
|
|
console.log(
|
|
'Total time:',
|
|
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
|
);
|
|
},
|
|
|
|
printDOM: function(measurements) {
|
|
measurements = measurements || ReactDefaultPerf._allMeasurements;
|
|
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
|
|
console.table(summary.map(function(item) {
|
|
var result = {};
|
|
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
|
|
result['type'] = item.type;
|
|
result['args'] = JSON.stringify(item.args);
|
|
return result;
|
|
}));
|
|
console.log(
|
|
'Total time:',
|
|
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
|
);
|
|
},
|
|
|
|
_recordWrite: function(id, fnName, totalTime, args) {
|
|
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
|
|
var writes =
|
|
ReactDefaultPerf
|
|
._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
|
|
.writes;
|
|
writes[id] = writes[id] || [];
|
|
writes[id].push({
|
|
type: fnName,
|
|
time: totalTime,
|
|
args: args
|
|
});
|
|
},
|
|
|
|
measure: function(moduleName, fnName, func) {
|
|
return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
|
var totalTime;
|
|
var rv;
|
|
var start;
|
|
|
|
if (fnName === '_renderNewRootComponent' ||
|
|
fnName === 'flushBatchedUpdates') {
|
|
// A "measurement" is a set of metrics recorded for each flush. We want
|
|
// to group the metrics for a given flush together so we can look at the
|
|
// components that rendered and the DOM operations that actually
|
|
// happened to determine the amount of "wasted work" performed.
|
|
ReactDefaultPerf._allMeasurements.push({
|
|
exclusive: {},
|
|
inclusive: {},
|
|
render: {},
|
|
counts: {},
|
|
writes: {},
|
|
displayNames: {},
|
|
totalTime: 0
|
|
});
|
|
start = performanceNow();
|
|
rv = func.apply(this, args);
|
|
ReactDefaultPerf._allMeasurements[
|
|
ReactDefaultPerf._allMeasurements.length - 1
|
|
].totalTime = performanceNow() - start;
|
|
return rv;
|
|
} else if (moduleName === 'ReactDOMIDOperations' ||
|
|
moduleName === 'ReactComponentBrowserEnvironment') {
|
|
start = performanceNow();
|
|
rv = func.apply(this, args);
|
|
totalTime = performanceNow() - start;
|
|
|
|
if (fnName === 'mountImageIntoNode') {
|
|
var mountID = ReactMount.getID(args[1]);
|
|
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
|
|
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
|
|
// special format
|
|
args[0].forEach(function(update) {
|
|
var writeArgs = {};
|
|
if (update.fromIndex !== null) {
|
|
writeArgs.fromIndex = update.fromIndex;
|
|
}
|
|
if (update.toIndex !== null) {
|
|
writeArgs.toIndex = update.toIndex;
|
|
}
|
|
if (update.textContent !== null) {
|
|
writeArgs.textContent = update.textContent;
|
|
}
|
|
if (update.markupIndex !== null) {
|
|
writeArgs.markup = args[1][update.markupIndex];
|
|
}
|
|
ReactDefaultPerf._recordWrite(
|
|
update.parentID,
|
|
update.type,
|
|
totalTime,
|
|
writeArgs
|
|
);
|
|
});
|
|
} else {
|
|
// basic format
|
|
ReactDefaultPerf._recordWrite(
|
|
args[0],
|
|
fnName,
|
|
totalTime,
|
|
Array.prototype.slice.call(args, 1)
|
|
);
|
|
}
|
|
return rv;
|
|
} else if (moduleName === 'ReactCompositeComponent' && (
|
|
fnName === 'mountComponent' ||
|
|
fnName === 'updateComponent' || // TODO: receiveComponent()?
|
|
fnName === '_renderValidatedComponent')) {
|
|
|
|
var rootNodeID = fnName === 'mountComponent' ?
|
|
args[0] :
|
|
this._rootNodeID;
|
|
var isRender = fnName === '_renderValidatedComponent';
|
|
var isMount = fnName === 'mountComponent';
|
|
|
|
var mountStack = ReactDefaultPerf._mountStack;
|
|
var entry = ReactDefaultPerf._allMeasurements[
|
|
ReactDefaultPerf._allMeasurements.length - 1
|
|
];
|
|
|
|
if (isRender) {
|
|
addValue(entry.counts, rootNodeID, 1);
|
|
} else if (isMount) {
|
|
mountStack.push(0);
|
|
}
|
|
|
|
start = performanceNow();
|
|
rv = func.apply(this, args);
|
|
totalTime = performanceNow() - start;
|
|
|
|
if (isRender) {
|
|
addValue(entry.render, rootNodeID, totalTime);
|
|
} else if (isMount) {
|
|
var subMountTime = mountStack.pop();
|
|
mountStack[mountStack.length - 1] += totalTime;
|
|
addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
|
|
addValue(entry.inclusive, rootNodeID, totalTime);
|
|
} else {
|
|
addValue(entry.inclusive, rootNodeID, totalTime);
|
|
}
|
|
|
|
entry.displayNames[rootNodeID] = {
|
|
current: this.constructor.displayName,
|
|
owner: this._owner ? this._owner.constructor.displayName : '<root>'
|
|
};
|
|
|
|
return rv;
|
|
} else {
|
|
return func.apply(this, args);
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
module.exports = ReactDefaultPerf;
|
|
|
|
},{"./DOMProperty":53,"./ReactDefaultPerfAnalysis":98,"./ReactMount":111,"./ReactPerf":116,"./performanceNow":195}],98:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactDefaultPerfAnalysis
|
|
*/
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
// Don't try to save users less than 1.2ms (a number I made up)
|
|
var DONT_CARE_THRESHOLD = 1.2;
|
|
var DOM_OPERATION_TYPES = {
|
|
'mountImageIntoNode': 'set innerHTML',
|
|
INSERT_MARKUP: 'set innerHTML',
|
|
MOVE_EXISTING: 'move',
|
|
REMOVE_NODE: 'remove',
|
|
TEXT_CONTENT: 'set textContent',
|
|
'updatePropertyByID': 'update attribute',
|
|
'deletePropertyByID': 'delete attribute',
|
|
'updateStylesByID': 'update styles',
|
|
'updateInnerHTMLByID': 'set innerHTML',
|
|
'dangerouslyReplaceNodeWithMarkupByID': 'replace'
|
|
};
|
|
|
|
function getTotalTime(measurements) {
|
|
// TODO: return number of DOM ops? could be misleading.
|
|
// TODO: measure dropped frames after reconcile?
|
|
// TODO: log total time of each reconcile and the top-level component
|
|
// class that triggered it.
|
|
var totalTime = 0;
|
|
for (var i = 0; i < measurements.length; i++) {
|
|
var measurement = measurements[i];
|
|
totalTime += measurement.totalTime;
|
|
}
|
|
return totalTime;
|
|
}
|
|
|
|
function getDOMSummary(measurements) {
|
|
var items = [];
|
|
for (var i = 0; i < measurements.length; i++) {
|
|
var measurement = measurements[i];
|
|
var id;
|
|
|
|
for (id in measurement.writes) {
|
|
measurement.writes[id].forEach(function(write) {
|
|
items.push({
|
|
id: id,
|
|
type: DOM_OPERATION_TYPES[write.type] || write.type,
|
|
args: write.args
|
|
});
|
|
});
|
|
}
|
|
}
|
|
return items;
|
|
}
|
|
|
|
function getExclusiveSummary(measurements) {
|
|
var candidates = {};
|
|
var displayName;
|
|
|
|
for (var i = 0; i < measurements.length; i++) {
|
|
var measurement = measurements[i];
|
|
var allIDs = assign(
|
|
{},
|
|
measurement.exclusive,
|
|
measurement.inclusive
|
|
);
|
|
|
|
for (var id in allIDs) {
|
|
displayName = measurement.displayNames[id].current;
|
|
|
|
candidates[displayName] = candidates[displayName] || {
|
|
componentName: displayName,
|
|
inclusive: 0,
|
|
exclusive: 0,
|
|
render: 0,
|
|
count: 0
|
|
};
|
|
if (measurement.render[id]) {
|
|
candidates[displayName].render += measurement.render[id];
|
|
}
|
|
if (measurement.exclusive[id]) {
|
|
candidates[displayName].exclusive += measurement.exclusive[id];
|
|
}
|
|
if (measurement.inclusive[id]) {
|
|
candidates[displayName].inclusive += measurement.inclusive[id];
|
|
}
|
|
if (measurement.counts[id]) {
|
|
candidates[displayName].count += measurement.counts[id];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Now make a sorted array with the results.
|
|
var arr = [];
|
|
for (displayName in candidates) {
|
|
if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
|
|
arr.push(candidates[displayName]);
|
|
}
|
|
}
|
|
|
|
arr.sort(function(a, b) {
|
|
return b.exclusive - a.exclusive;
|
|
});
|
|
|
|
return arr;
|
|
}
|
|
|
|
function getInclusiveSummary(measurements, onlyClean) {
|
|
var candidates = {};
|
|
var inclusiveKey;
|
|
|
|
for (var i = 0; i < measurements.length; i++) {
|
|
var measurement = measurements[i];
|
|
var allIDs = assign(
|
|
{},
|
|
measurement.exclusive,
|
|
measurement.inclusive
|
|
);
|
|
var cleanComponents;
|
|
|
|
if (onlyClean) {
|
|
cleanComponents = getUnchangedComponents(measurement);
|
|
}
|
|
|
|
for (var id in allIDs) {
|
|
if (onlyClean && !cleanComponents[id]) {
|
|
continue;
|
|
}
|
|
|
|
var displayName = measurement.displayNames[id];
|
|
|
|
// Inclusive time is not useful for many components without knowing where
|
|
// they are instantiated. So we aggregate inclusive time with both the
|
|
// owner and current displayName as the key.
|
|
inclusiveKey = displayName.owner + ' > ' + displayName.current;
|
|
|
|
candidates[inclusiveKey] = candidates[inclusiveKey] || {
|
|
componentName: inclusiveKey,
|
|
time: 0,
|
|
count: 0
|
|
};
|
|
|
|
if (measurement.inclusive[id]) {
|
|
candidates[inclusiveKey].time += measurement.inclusive[id];
|
|
}
|
|
if (measurement.counts[id]) {
|
|
candidates[inclusiveKey].count += measurement.counts[id];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Now make a sorted array with the results.
|
|
var arr = [];
|
|
for (inclusiveKey in candidates) {
|
|
if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
|
|
arr.push(candidates[inclusiveKey]);
|
|
}
|
|
}
|
|
|
|
arr.sort(function(a, b) {
|
|
return b.time - a.time;
|
|
});
|
|
|
|
return arr;
|
|
}
|
|
|
|
function getUnchangedComponents(measurement) {
|
|
// For a given reconcile, look at which components did not actually
|
|
// render anything to the DOM and return a mapping of their ID to
|
|
// the amount of time it took to render the entire subtree.
|
|
var cleanComponents = {};
|
|
var dirtyLeafIDs = Object.keys(measurement.writes);
|
|
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
|
|
|
|
for (var id in allIDs) {
|
|
var isDirty = false;
|
|
// For each component that rendered, see if a component that triggered
|
|
// a DOM op is in its subtree.
|
|
for (var i = 0; i < dirtyLeafIDs.length; i++) {
|
|
if (dirtyLeafIDs[i].indexOf(id) === 0) {
|
|
isDirty = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!isDirty && measurement.counts[id] > 0) {
|
|
cleanComponents[id] = true;
|
|
}
|
|
}
|
|
return cleanComponents;
|
|
}
|
|
|
|
var ReactDefaultPerfAnalysis = {
|
|
getExclusiveSummary: getExclusiveSummary,
|
|
getInclusiveSummary: getInclusiveSummary,
|
|
getDOMSummary: getDOMSummary,
|
|
getTotalTime: getTotalTime
|
|
};
|
|
|
|
module.exports = ReactDefaultPerfAnalysis;
|
|
|
|
},{"./Object.assign":70}],99:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactElement
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactContext = require("./ReactContext");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
|
|
var warning = require("./warning");
|
|
|
|
var RESERVED_PROPS = {
|
|
key: true,
|
|
ref: true
|
|
};
|
|
|
|
/**
|
|
* Warn for mutations.
|
|
*
|
|
* @internal
|
|
* @param {object} object
|
|
* @param {string} key
|
|
*/
|
|
function defineWarningProperty(object, key) {
|
|
Object.defineProperty(object, key, {
|
|
|
|
configurable: false,
|
|
enumerable: true,
|
|
|
|
get: function() {
|
|
if (!this._store) {
|
|
return null;
|
|
}
|
|
return this._store[key];
|
|
},
|
|
|
|
set: function(value) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'Don\'t set the ' + key + ' property of the component. ' +
|
|
'Mutate the existing props object instead.'
|
|
) : null);
|
|
this._store[key] = value;
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
/**
|
|
* This is updated to true if the membrane is successfully created.
|
|
*/
|
|
var useMutationMembrane = false;
|
|
|
|
/**
|
|
* Warn for mutations.
|
|
*
|
|
* @internal
|
|
* @param {object} element
|
|
*/
|
|
function defineMutationMembrane(prototype) {
|
|
try {
|
|
var pseudoFrozenProperties = {
|
|
props: true
|
|
};
|
|
for (var key in pseudoFrozenProperties) {
|
|
defineWarningProperty(prototype, key);
|
|
}
|
|
useMutationMembrane = true;
|
|
} catch (x) {
|
|
// IE will fail on defineProperty
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Base constructor for all React elements. This is only used to make this
|
|
* work with a dynamic instanceof check. Nothing should live on this prototype.
|
|
*
|
|
* @param {*} type
|
|
* @param {string|object} ref
|
|
* @param {*} key
|
|
* @param {*} props
|
|
* @internal
|
|
*/
|
|
var ReactElement = function(type, key, ref, owner, context, props) {
|
|
// Built-in properties that belong on the element
|
|
this.type = type;
|
|
this.key = key;
|
|
this.ref = ref;
|
|
|
|
// Record the component responsible for creating this element.
|
|
this._owner = owner;
|
|
|
|
// TODO: Deprecate withContext, and then the context becomes accessible
|
|
// through the owner.
|
|
this._context = context;
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// The validation flag and props are currently mutative. We put them on
|
|
// an external backing store so that we can freeze the whole object.
|
|
// This can be replaced with a WeakMap once they are implemented in
|
|
// commonly used development environments.
|
|
this._store = { validated: false, props: props };
|
|
|
|
// We're not allowed to set props directly on the object so we early
|
|
// return and rely on the prototype membrane to forward to the backing
|
|
// store.
|
|
if (useMutationMembrane) {
|
|
Object.freeze(this);
|
|
return;
|
|
}
|
|
}
|
|
|
|
this.props = props;
|
|
};
|
|
|
|
// We intentionally don't expose the function on the constructor property.
|
|
// ReactElement should be indistinguishable from a plain object.
|
|
ReactElement.prototype = {
|
|
_isReactElement: true
|
|
};
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
defineMutationMembrane(ReactElement.prototype);
|
|
}
|
|
|
|
ReactElement.createElement = function(type, config, children) {
|
|
var propName;
|
|
|
|
// Reserved names are extracted
|
|
var props = {};
|
|
|
|
var key = null;
|
|
var ref = null;
|
|
|
|
if (config != null) {
|
|
ref = config.ref === undefined ? null : config.ref;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
config.key !== null,
|
|
'createElement(...): Encountered component with a `key` of null. In ' +
|
|
'a future version, this will be treated as equivalent to the string ' +
|
|
'\'null\'; instead, provide an explicit key or use undefined.'
|
|
) : null);
|
|
}
|
|
// TODO: Change this back to `config.key === undefined`
|
|
key = config.key == null ? null : '' + config.key;
|
|
// Remaining properties are added to a new props object
|
|
for (propName in config) {
|
|
if (config.hasOwnProperty(propName) &&
|
|
!RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
props[propName] = config[propName];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Children can be more than one argument, and those are transferred onto
|
|
// the newly allocated props object.
|
|
var childrenLength = arguments.length - 2;
|
|
if (childrenLength === 1) {
|
|
props.children = children;
|
|
} else if (childrenLength > 1) {
|
|
var childArray = Array(childrenLength);
|
|
for (var i = 0; i < childrenLength; i++) {
|
|
childArray[i] = arguments[i + 2];
|
|
}
|
|
props.children = childArray;
|
|
}
|
|
|
|
// Resolve default props
|
|
if (type && type.defaultProps) {
|
|
var defaultProps = type.defaultProps;
|
|
for (propName in defaultProps) {
|
|
if (typeof props[propName] === 'undefined') {
|
|
props[propName] = defaultProps[propName];
|
|
}
|
|
}
|
|
}
|
|
|
|
return new ReactElement(
|
|
type,
|
|
key,
|
|
ref,
|
|
ReactCurrentOwner.current,
|
|
ReactContext.current,
|
|
props
|
|
);
|
|
};
|
|
|
|
ReactElement.createFactory = function(type) {
|
|
var factory = ReactElement.createElement.bind(null, type);
|
|
// Expose the type on the factory and the prototype so that it can be
|
|
// easily accessed on elements. E.g. <Foo />.type === Foo.type.
|
|
// This should not be named `constructor` since this may not be the function
|
|
// that created the element, and it may not even be a constructor.
|
|
factory.type = type;
|
|
return factory;
|
|
};
|
|
|
|
ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
|
|
var newElement = new ReactElement(
|
|
oldElement.type,
|
|
oldElement.key,
|
|
oldElement.ref,
|
|
oldElement._owner,
|
|
oldElement._context,
|
|
newProps
|
|
);
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// If the key on the original is valid, then the clone is valid
|
|
newElement._store.validated = oldElement._store.validated;
|
|
}
|
|
return newElement;
|
|
};
|
|
|
|
/**
|
|
* @param {?object} object
|
|
* @return {boolean} True if `object` is a valid component.
|
|
* @final
|
|
*/
|
|
ReactElement.isValidElement = function(object) {
|
|
// ReactTestUtils is often used outside of beforeEach where as React is
|
|
// within it. This leads to two different instances of React on the same
|
|
// page. To identify a element from a different React instance we use
|
|
// a flag instead of an instanceof check.
|
|
var isElement = !!(object && object._isReactElement);
|
|
// if (isElement && !(object instanceof ReactElement)) {
|
|
// This is an indicator that you're using multiple versions of React at the
|
|
// same time. This will screw with ownership and stuff. Fix it, please.
|
|
// TODO: We could possibly warn here.
|
|
// }
|
|
return isElement;
|
|
};
|
|
|
|
module.exports = ReactElement;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactContext":82,"./ReactCurrentOwner":83,"./warning":202,"_process":1}],100:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactElementValidator
|
|
*/
|
|
|
|
/**
|
|
* ReactElementValidator provides a wrapper around a element factory
|
|
* which validates the props passed to the element. This is intended to be
|
|
* used only in DEV and could be replaced by a static type checker for languages
|
|
* that support it.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
|
|
var monitorCodeUse = require("./monitorCodeUse");
|
|
var warning = require("./warning");
|
|
|
|
/**
|
|
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
* object keys are not valid. This allows us to keep track of children between
|
|
* updates.
|
|
*/
|
|
var ownerHasKeyUseWarning = {
|
|
'react_key_warning': {},
|
|
'react_numeric_key_warning': {}
|
|
};
|
|
var ownerHasMonitoredObjectMap = {};
|
|
|
|
var loggedTypeFailures = {};
|
|
|
|
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
|
|
/**
|
|
* Gets the current owner's displayName for use in warnings.
|
|
*
|
|
* @internal
|
|
* @return {?string} Display name or undefined
|
|
*/
|
|
function getCurrentOwnerDisplayName() {
|
|
var current = ReactCurrentOwner.current;
|
|
return current && current.constructor.displayName || undefined;
|
|
}
|
|
|
|
/**
|
|
* Warn if the component doesn't have an explicit key assigned to it.
|
|
* This component is in an array. The array could grow and shrink or be
|
|
* reordered. All children that haven't already been validated are required to
|
|
* have a "key" property assigned to it.
|
|
*
|
|
* @internal
|
|
* @param {ReactComponent} component Component that requires a key.
|
|
* @param {*} parentType component's parent's type.
|
|
*/
|
|
function validateExplicitKey(component, parentType) {
|
|
if (component._store.validated || component.key != null) {
|
|
return;
|
|
}
|
|
component._store.validated = true;
|
|
|
|
warnAndMonitorForKeyUse(
|
|
'react_key_warning',
|
|
'Each child in an array should have a unique "key" prop.',
|
|
component,
|
|
parentType
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Warn if the key is being defined as an object property but has an incorrect
|
|
* value.
|
|
*
|
|
* @internal
|
|
* @param {string} name Property name of the key.
|
|
* @param {ReactComponent} component Component that requires a key.
|
|
* @param {*} parentType component's parent's type.
|
|
*/
|
|
function validatePropertyKey(name, component, parentType) {
|
|
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
return;
|
|
}
|
|
warnAndMonitorForKeyUse(
|
|
'react_numeric_key_warning',
|
|
'Child objects should have non-numeric keys so ordering is preserved.',
|
|
component,
|
|
parentType
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Shared warning and monitoring code for the key warnings.
|
|
*
|
|
* @internal
|
|
* @param {string} warningID The id used when logging.
|
|
* @param {string} message The base warning that gets output.
|
|
* @param {ReactComponent} component Component that requires a key.
|
|
* @param {*} parentType component's parent's type.
|
|
*/
|
|
function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
|
|
var ownerName = getCurrentOwnerDisplayName();
|
|
var parentName = parentType.displayName;
|
|
|
|
var useName = ownerName || parentName;
|
|
var memoizer = ownerHasKeyUseWarning[warningID];
|
|
if (memoizer.hasOwnProperty(useName)) {
|
|
return;
|
|
}
|
|
memoizer[useName] = true;
|
|
|
|
message += ownerName ?
|
|
(" Check the render method of " + ownerName + ".") :
|
|
(" Check the renderComponent call using <" + parentName + ">.");
|
|
|
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
// property, it may be the creator of the child that's responsible for
|
|
// assigning it a key.
|
|
var childOwnerName = null;
|
|
if (component._owner && component._owner !== ReactCurrentOwner.current) {
|
|
// Name of the component that originally created this child.
|
|
childOwnerName = component._owner.constructor.displayName;
|
|
|
|
message += (" It was passed a child from " + childOwnerName + ".");
|
|
}
|
|
|
|
message += ' See http://fb.me/react-warning-keys for more information.';
|
|
monitorCodeUse(warningID, {
|
|
component: useName,
|
|
componentOwner: childOwnerName
|
|
});
|
|
console.warn(message);
|
|
}
|
|
|
|
/**
|
|
* Log that we're using an object map. We're considering deprecating this
|
|
* feature and replace it with proper Map and ImmutableMap data structures.
|
|
*
|
|
* @internal
|
|
*/
|
|
function monitorUseOfObjectMap() {
|
|
var currentName = getCurrentOwnerDisplayName() || '';
|
|
if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) {
|
|
return;
|
|
}
|
|
ownerHasMonitoredObjectMap[currentName] = true;
|
|
monitorCodeUse('react_object_map_children');
|
|
}
|
|
|
|
/**
|
|
* Ensure that every component either is passed in a static location, in an
|
|
* array with an explicit keys property defined, or in an object literal
|
|
* with valid key property.
|
|
*
|
|
* @internal
|
|
* @param {*} component Statically passed child of any type.
|
|
* @param {*} parentType component's parent's type.
|
|
* @return {boolean}
|
|
*/
|
|
function validateChildKeys(component, parentType) {
|
|
if (Array.isArray(component)) {
|
|
for (var i = 0; i < component.length; i++) {
|
|
var child = component[i];
|
|
if (ReactElement.isValidElement(child)) {
|
|
validateExplicitKey(child, parentType);
|
|
}
|
|
}
|
|
} else if (ReactElement.isValidElement(component)) {
|
|
// This component was passed in a valid location.
|
|
component._store.validated = true;
|
|
} else if (component && typeof component === 'object') {
|
|
monitorUseOfObjectMap();
|
|
for (var name in component) {
|
|
validatePropertyKey(name, component[name], parentType);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Assert that the props are valid
|
|
*
|
|
* @param {string} componentName Name of the component for error messages.
|
|
* @param {object} propTypes Map of prop name to a ReactPropType
|
|
* @param {object} props
|
|
* @param {string} location e.g. "prop", "context", "child context"
|
|
* @private
|
|
*/
|
|
function checkPropTypes(componentName, propTypes, props, location) {
|
|
for (var propName in propTypes) {
|
|
if (propTypes.hasOwnProperty(propName)) {
|
|
var error;
|
|
// Prop type validation may throw. In case they do, we don't want to
|
|
// fail the render phase where it didn't fail before. So we log it.
|
|
// After these have been cleaned up, we'll let them throw.
|
|
try {
|
|
error = propTypes[propName](props, propName, componentName, location);
|
|
} catch (ex) {
|
|
error = ex;
|
|
}
|
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
// Only monitor this failure once because there tends to be a lot of the
|
|
// same error.
|
|
loggedTypeFailures[error.message] = true;
|
|
// This will soon use the warning module
|
|
monitorCodeUse(
|
|
'react_failed_descriptor_type_check',
|
|
{ message: error.message }
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var ReactElementValidator = {
|
|
|
|
createElement: function(type, props, children) {
|
|
// We warn in this case but don't throw. We expect the element creation to
|
|
// succeed and there will likely be errors in render.
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
type != null,
|
|
'React.createElement: type should not be null or undefined. It should ' +
|
|
'be a string (for DOM elements) or a ReactClass (for composite ' +
|
|
'components).'
|
|
) : null);
|
|
|
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
|
|
// The result can be nullish if a mock or a custom function is used.
|
|
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
if (element == null) {
|
|
return element;
|
|
}
|
|
|
|
for (var i = 2; i < arguments.length; i++) {
|
|
validateChildKeys(arguments[i], type);
|
|
}
|
|
|
|
if (type) {
|
|
var name = type.displayName;
|
|
if (type.propTypes) {
|
|
checkPropTypes(
|
|
name,
|
|
type.propTypes,
|
|
element.props,
|
|
ReactPropTypeLocations.prop
|
|
);
|
|
}
|
|
if (type.contextTypes) {
|
|
checkPropTypes(
|
|
name,
|
|
type.contextTypes,
|
|
element._context,
|
|
ReactPropTypeLocations.context
|
|
);
|
|
}
|
|
}
|
|
return element;
|
|
},
|
|
|
|
createFactory: function(type) {
|
|
var validatedFactory = ReactElementValidator.createElement.bind(
|
|
null,
|
|
type
|
|
);
|
|
validatedFactory.type = type;
|
|
return validatedFactory;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ReactElementValidator;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactCurrentOwner":83,"./ReactElement":99,"./ReactPropTypeLocations":119,"./monitorCodeUse":192,"./warning":202,"_process":1}],101:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactEmptyComponent
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
var component;
|
|
// This registry keeps track of the React IDs of the components that rendered to
|
|
// `null` (in reality a placeholder such as `noscript`)
|
|
var nullComponentIdsRegistry = {};
|
|
|
|
var ReactEmptyComponentInjection = {
|
|
injectEmptyComponent: function(emptyComponent) {
|
|
component = ReactElement.createFactory(emptyComponent);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @return {ReactComponent} component The injected empty component.
|
|
*/
|
|
function getEmptyComponent() {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
component,
|
|
'Trying to return null from a render, but no null placeholder component ' +
|
|
'was injected.'
|
|
) : invariant(component));
|
|
return component();
|
|
}
|
|
|
|
/**
|
|
* Mark the component as having rendered to null.
|
|
* @param {string} id Component's `_rootNodeID`.
|
|
*/
|
|
function registerNullComponentID(id) {
|
|
nullComponentIdsRegistry[id] = true;
|
|
}
|
|
|
|
/**
|
|
* Unmark the component as having rendered to null: it renders to something now.
|
|
* @param {string} id Component's `_rootNodeID`.
|
|
*/
|
|
function deregisterNullComponentID(id) {
|
|
delete nullComponentIdsRegistry[id];
|
|
}
|
|
|
|
/**
|
|
* @param {string} id Component's `_rootNodeID`.
|
|
* @return {boolean} True if the component is rendered to null.
|
|
*/
|
|
function isNullComponentID(id) {
|
|
return nullComponentIdsRegistry[id];
|
|
}
|
|
|
|
var ReactEmptyComponent = {
|
|
deregisterNullComponentID: deregisterNullComponentID,
|
|
getEmptyComponent: getEmptyComponent,
|
|
injection: ReactEmptyComponentInjection,
|
|
isNullComponentID: isNullComponentID,
|
|
registerNullComponentID: registerNullComponentID
|
|
};
|
|
|
|
module.exports = ReactEmptyComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./invariant":182,"_process":1}],102:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactErrorUtils
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactErrorUtils = {
|
|
/**
|
|
* Creates a guarded version of a function. This is supposed to make debugging
|
|
* of event handlers easier. To aid debugging with the browser's debugger,
|
|
* this currently simply returns the original function.
|
|
*
|
|
* @param {function} func Function to be executed
|
|
* @param {string} name The name of the guard
|
|
* @return {function}
|
|
*/
|
|
guard: function(func, name) {
|
|
return func;
|
|
}
|
|
};
|
|
|
|
module.exports = ReactErrorUtils;
|
|
|
|
},{}],103:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactEventEmitterMixin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
|
|
function runEventQueueInBatch(events) {
|
|
EventPluginHub.enqueueEvents(events);
|
|
EventPluginHub.processEventQueue();
|
|
}
|
|
|
|
var ReactEventEmitterMixin = {
|
|
|
|
/**
|
|
* Streams a fired top-level event to `EventPluginHub` where plugins have the
|
|
* opportunity to create `ReactEvent`s to be dispatched.
|
|
*
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {object} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native environment event.
|
|
*/
|
|
handleTopLevel: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
var events = EventPluginHub.extractEvents(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
|
|
runEventQueueInBatch(events);
|
|
}
|
|
};
|
|
|
|
module.exports = ReactEventEmitterMixin;
|
|
|
|
},{"./EventPluginHub":60}],104:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactEventListener
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventListener = require("./EventListener");
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
var PooledClass = require("./PooledClass");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var assign = require("./Object.assign");
|
|
var getEventTarget = require("./getEventTarget");
|
|
var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
|
|
|
|
/**
|
|
* Finds the parent React component of `node`.
|
|
*
|
|
* @param {*} node
|
|
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
|
|
* is not nested.
|
|
*/
|
|
function findParent(node) {
|
|
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
|
|
// traversal, but caching is difficult to do correctly without using a
|
|
// mutation observer to listen for all DOM changes.
|
|
var nodeID = ReactMount.getID(node);
|
|
var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
|
|
var container = ReactMount.findReactContainerForID(rootID);
|
|
var parent = ReactMount.getFirstReactDOM(container);
|
|
return parent;
|
|
}
|
|
|
|
// Used to store ancestor hierarchy in top level callback
|
|
function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
|
|
this.topLevelType = topLevelType;
|
|
this.nativeEvent = nativeEvent;
|
|
this.ancestors = [];
|
|
}
|
|
assign(TopLevelCallbackBookKeeping.prototype, {
|
|
destructor: function() {
|
|
this.topLevelType = null;
|
|
this.nativeEvent = null;
|
|
this.ancestors.length = 0;
|
|
}
|
|
});
|
|
PooledClass.addPoolingTo(
|
|
TopLevelCallbackBookKeeping,
|
|
PooledClass.twoArgumentPooler
|
|
);
|
|
|
|
function handleTopLevelImpl(bookKeeping) {
|
|
var topLevelTarget = ReactMount.getFirstReactDOM(
|
|
getEventTarget(bookKeeping.nativeEvent)
|
|
) || window;
|
|
|
|
// Loop through the hierarchy, in case there's any nested components.
|
|
// It's important that we build the array of ancestors before calling any
|
|
// event handlers, because event handlers can modify the DOM, leading to
|
|
// inconsistencies with ReactMount's node cache. See #1105.
|
|
var ancestor = topLevelTarget;
|
|
while (ancestor) {
|
|
bookKeeping.ancestors.push(ancestor);
|
|
ancestor = findParent(ancestor);
|
|
}
|
|
|
|
for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
|
|
topLevelTarget = bookKeeping.ancestors[i];
|
|
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
|
|
ReactEventListener._handleTopLevel(
|
|
bookKeeping.topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
bookKeeping.nativeEvent
|
|
);
|
|
}
|
|
}
|
|
|
|
function scrollValueMonitor(cb) {
|
|
var scrollPosition = getUnboundedScrollPosition(window);
|
|
cb(scrollPosition);
|
|
}
|
|
|
|
var ReactEventListener = {
|
|
_enabled: true,
|
|
_handleTopLevel: null,
|
|
|
|
WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
|
|
|
|
setHandleTopLevel: function(handleTopLevel) {
|
|
ReactEventListener._handleTopLevel = handleTopLevel;
|
|
},
|
|
|
|
setEnabled: function(enabled) {
|
|
ReactEventListener._enabled = !!enabled;
|
|
},
|
|
|
|
isEnabled: function() {
|
|
return ReactEventListener._enabled;
|
|
},
|
|
|
|
|
|
/**
|
|
* Traps top-level events by using event bubbling.
|
|
*
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
* @param {object} handle Element on which to attach listener.
|
|
* @return {object} An object with a remove function which will forcefully
|
|
* remove the listener.
|
|
* @internal
|
|
*/
|
|
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
|
|
var element = handle;
|
|
if (!element) {
|
|
return;
|
|
}
|
|
return EventListener.listen(
|
|
element,
|
|
handlerBaseName,
|
|
ReactEventListener.dispatchEvent.bind(null, topLevelType)
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Traps a top-level event by using event capturing.
|
|
*
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
* @param {object} handle Element on which to attach listener.
|
|
* @return {object} An object with a remove function which will forcefully
|
|
* remove the listener.
|
|
* @internal
|
|
*/
|
|
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
|
|
var element = handle;
|
|
if (!element) {
|
|
return;
|
|
}
|
|
return EventListener.capture(
|
|
element,
|
|
handlerBaseName,
|
|
ReactEventListener.dispatchEvent.bind(null, topLevelType)
|
|
);
|
|
},
|
|
|
|
monitorScrollValue: function(refresh) {
|
|
var callback = scrollValueMonitor.bind(null, refresh);
|
|
EventListener.listen(window, 'scroll', callback);
|
|
EventListener.listen(window, 'resize', callback);
|
|
},
|
|
|
|
dispatchEvent: function(topLevelType, nativeEvent) {
|
|
if (!ReactEventListener._enabled) {
|
|
return;
|
|
}
|
|
|
|
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
|
|
topLevelType,
|
|
nativeEvent
|
|
);
|
|
try {
|
|
// Event queue being processed in the same cycle allows
|
|
// `preventDefault`.
|
|
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
|
|
} finally {
|
|
TopLevelCallbackBookKeeping.release(bookKeeping);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = ReactEventListener;
|
|
|
|
},{"./EventListener":59,"./ExecutionEnvironment":64,"./Object.assign":70,"./PooledClass":71,"./ReactInstanceHandles":107,"./ReactMount":111,"./ReactUpdates":132,"./getEventTarget":173,"./getUnboundedScrollPosition":178}],105:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactInjection
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
var ReactPerf = require("./ReactPerf");
|
|
var ReactRootIndex = require("./ReactRootIndex");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var ReactInjection = {
|
|
Component: ReactComponent.injection,
|
|
CompositeComponent: ReactCompositeComponent.injection,
|
|
DOMProperty: DOMProperty.injection,
|
|
EmptyComponent: ReactEmptyComponent.injection,
|
|
EventPluginHub: EventPluginHub.injection,
|
|
EventEmitter: ReactBrowserEventEmitter.injection,
|
|
NativeComponent: ReactNativeComponent.injection,
|
|
Perf: ReactPerf.injection,
|
|
RootIndex: ReactRootIndex.injection,
|
|
Updates: ReactUpdates.injection
|
|
};
|
|
|
|
module.exports = ReactInjection;
|
|
|
|
},{"./DOMProperty":53,"./EventPluginHub":60,"./ReactBrowserEventEmitter":74,"./ReactComponent":78,"./ReactCompositeComponent":81,"./ReactEmptyComponent":101,"./ReactNativeComponent":114,"./ReactPerf":116,"./ReactRootIndex":123,"./ReactUpdates":132}],106:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactInputSelection
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactDOMSelection = require("./ReactDOMSelection");
|
|
|
|
var containsNode = require("./containsNode");
|
|
var focusNode = require("./focusNode");
|
|
var getActiveElement = require("./getActiveElement");
|
|
|
|
function isInDocument(node) {
|
|
return containsNode(document.documentElement, node);
|
|
}
|
|
|
|
/**
|
|
* @ReactInputSelection: React input selection module. Based on Selection.js,
|
|
* but modified to be suitable for react and has a couple of bug fixes (doesn't
|
|
* assume buttons have range selections allowed).
|
|
* Input selection module for React.
|
|
*/
|
|
var ReactInputSelection = {
|
|
|
|
hasSelectionCapabilities: function(elem) {
|
|
return elem && (
|
|
(elem.nodeName === 'INPUT' && elem.type === 'text') ||
|
|
elem.nodeName === 'TEXTAREA' ||
|
|
elem.contentEditable === 'true'
|
|
);
|
|
},
|
|
|
|
getSelectionInformation: function() {
|
|
var focusedElem = getActiveElement();
|
|
return {
|
|
focusedElem: focusedElem,
|
|
selectionRange:
|
|
ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
|
|
ReactInputSelection.getSelection(focusedElem) :
|
|
null
|
|
};
|
|
},
|
|
|
|
/**
|
|
* @restoreSelection: If any selection information was potentially lost,
|
|
* restore it. This is useful when performing operations that could remove dom
|
|
* nodes and place them back in, resulting in focus being lost.
|
|
*/
|
|
restoreSelection: function(priorSelectionInformation) {
|
|
var curFocusedElem = getActiveElement();
|
|
var priorFocusedElem = priorSelectionInformation.focusedElem;
|
|
var priorSelectionRange = priorSelectionInformation.selectionRange;
|
|
if (curFocusedElem !== priorFocusedElem &&
|
|
isInDocument(priorFocusedElem)) {
|
|
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
|
|
ReactInputSelection.setSelection(
|
|
priorFocusedElem,
|
|
priorSelectionRange
|
|
);
|
|
}
|
|
focusNode(priorFocusedElem);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @getSelection: Gets the selection bounds of a focused textarea, input or
|
|
* contentEditable node.
|
|
* -@input: Look up selection bounds of this input
|
|
* -@return {start: selectionStart, end: selectionEnd}
|
|
*/
|
|
getSelection: function(input) {
|
|
var selection;
|
|
|
|
if ('selectionStart' in input) {
|
|
// Modern browser with input or textarea.
|
|
selection = {
|
|
start: input.selectionStart,
|
|
end: input.selectionEnd
|
|
};
|
|
} else if (document.selection && input.nodeName === 'INPUT') {
|
|
// IE8 input.
|
|
var range = document.selection.createRange();
|
|
// There can only be one selection per document in IE, so it must
|
|
// be in our element.
|
|
if (range.parentElement() === input) {
|
|
selection = {
|
|
start: -range.moveStart('character', -input.value.length),
|
|
end: -range.moveEnd('character', -input.value.length)
|
|
};
|
|
}
|
|
} else {
|
|
// Content editable or old IE textarea.
|
|
selection = ReactDOMSelection.getOffsets(input);
|
|
}
|
|
|
|
return selection || {start: 0, end: 0};
|
|
},
|
|
|
|
/**
|
|
* @setSelection: Sets the selection bounds of a textarea or input and focuses
|
|
* the input.
|
|
* -@input Set selection bounds of this input or textarea
|
|
* -@offsets Object of same form that is returned from get*
|
|
*/
|
|
setSelection: function(input, offsets) {
|
|
var start = offsets.start;
|
|
var end = offsets.end;
|
|
if (typeof end === 'undefined') {
|
|
end = start;
|
|
}
|
|
|
|
if ('selectionStart' in input) {
|
|
input.selectionStart = start;
|
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
} else if (document.selection && input.nodeName === 'INPUT') {
|
|
var range = input.createTextRange();
|
|
range.collapse(true);
|
|
range.moveStart('character', start);
|
|
range.moveEnd('character', end - start);
|
|
range.select();
|
|
} else {
|
|
ReactDOMSelection.setOffsets(input, offsets);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = ReactInputSelection;
|
|
|
|
},{"./ReactDOMSelection":93,"./containsNode":156,"./focusNode":167,"./getActiveElement":169}],107:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactInstanceHandles
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactRootIndex = require("./ReactRootIndex");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
var SEPARATOR = '.';
|
|
var SEPARATOR_LENGTH = SEPARATOR.length;
|
|
|
|
/**
|
|
* Maximum depth of traversals before we consider the possibility of a bad ID.
|
|
*/
|
|
var MAX_TREE_DEPTH = 100;
|
|
|
|
/**
|
|
* Creates a DOM ID prefix to use when mounting React components.
|
|
*
|
|
* @param {number} index A unique integer
|
|
* @return {string} React root ID.
|
|
* @internal
|
|
*/
|
|
function getReactRootIDString(index) {
|
|
return SEPARATOR + index.toString(36);
|
|
}
|
|
|
|
/**
|
|
* Checks if a character in the supplied ID is a separator or the end.
|
|
*
|
|
* @param {string} id A React DOM ID.
|
|
* @param {number} index Index of the character to check.
|
|
* @return {boolean} True if the character is a separator or end of the ID.
|
|
* @private
|
|
*/
|
|
function isBoundary(id, index) {
|
|
return id.charAt(index) === SEPARATOR || index === id.length;
|
|
}
|
|
|
|
/**
|
|
* Checks if the supplied string is a valid React DOM ID.
|
|
*
|
|
* @param {string} id A React DOM ID, maybe.
|
|
* @return {boolean} True if the string is a valid React DOM ID.
|
|
* @private
|
|
*/
|
|
function isValidID(id) {
|
|
return id === '' || (
|
|
id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Checks if the first ID is an ancestor of or equal to the second ID.
|
|
*
|
|
* @param {string} ancestorID
|
|
* @param {string} descendantID
|
|
* @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
|
|
* @internal
|
|
*/
|
|
function isAncestorIDOf(ancestorID, descendantID) {
|
|
return (
|
|
descendantID.indexOf(ancestorID) === 0 &&
|
|
isBoundary(descendantID, ancestorID.length)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Gets the parent ID of the supplied React DOM ID, `id`.
|
|
*
|
|
* @param {string} id ID of a component.
|
|
* @return {string} ID of the parent, or an empty string.
|
|
* @private
|
|
*/
|
|
function getParentID(id) {
|
|
return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
|
|
}
|
|
|
|
/**
|
|
* Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
|
|
* supplied `destinationID`. If they are equal, the ID is returned.
|
|
*
|
|
* @param {string} ancestorID ID of an ancestor node of `destinationID`.
|
|
* @param {string} destinationID ID of the destination node.
|
|
* @return {string} Next ID on the path from `ancestorID` to `destinationID`.
|
|
* @private
|
|
*/
|
|
function getNextDescendantID(ancestorID, destinationID) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
isValidID(ancestorID) && isValidID(destinationID),
|
|
'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
|
|
ancestorID,
|
|
destinationID
|
|
) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
isAncestorIDOf(ancestorID, destinationID),
|
|
'getNextDescendantID(...): React has made an invalid assumption about ' +
|
|
'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
|
|
ancestorID,
|
|
destinationID
|
|
) : invariant(isAncestorIDOf(ancestorID, destinationID)));
|
|
if (ancestorID === destinationID) {
|
|
return ancestorID;
|
|
}
|
|
// Skip over the ancestor and the immediate separator. Traverse until we hit
|
|
// another separator or we reach the end of `destinationID`.
|
|
var start = ancestorID.length + SEPARATOR_LENGTH;
|
|
for (var i = start; i < destinationID.length; i++) {
|
|
if (isBoundary(destinationID, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return destinationID.substr(0, i);
|
|
}
|
|
|
|
/**
|
|
* Gets the nearest common ancestor ID of two IDs.
|
|
*
|
|
* Using this ID scheme, the nearest common ancestor ID is the longest common
|
|
* prefix of the two IDs that immediately preceded a "marker" in both strings.
|
|
*
|
|
* @param {string} oneID
|
|
* @param {string} twoID
|
|
* @return {string} Nearest common ancestor ID, or the empty string if none.
|
|
* @private
|
|
*/
|
|
function getFirstCommonAncestorID(oneID, twoID) {
|
|
var minLength = Math.min(oneID.length, twoID.length);
|
|
if (minLength === 0) {
|
|
return '';
|
|
}
|
|
var lastCommonMarkerIndex = 0;
|
|
// Use `<=` to traverse until the "EOL" of the shorter string.
|
|
for (var i = 0; i <= minLength; i++) {
|
|
if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
|
|
lastCommonMarkerIndex = i;
|
|
} else if (oneID.charAt(i) !== twoID.charAt(i)) {
|
|
break;
|
|
}
|
|
}
|
|
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
isValidID(longestCommonID),
|
|
'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
|
|
oneID,
|
|
twoID,
|
|
longestCommonID
|
|
) : invariant(isValidID(longestCommonID)));
|
|
return longestCommonID;
|
|
}
|
|
|
|
/**
|
|
* Traverses the parent path between two IDs (either up or down). The IDs must
|
|
* not be the same, and there must exist a parent path between them. If the
|
|
* callback returns `false`, traversal is stopped.
|
|
*
|
|
* @param {?string} start ID at which to start traversal.
|
|
* @param {?string} stop ID at which to end traversal.
|
|
* @param {function} cb Callback to invoke each ID with.
|
|
* @param {?boolean} skipFirst Whether or not to skip the first node.
|
|
* @param {?boolean} skipLast Whether or not to skip the last node.
|
|
* @private
|
|
*/
|
|
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
|
start = start || '';
|
|
stop = stop || '';
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
start !== stop,
|
|
'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
|
|
start
|
|
) : invariant(start !== stop));
|
|
var traverseUp = isAncestorIDOf(stop, start);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
traverseUp || isAncestorIDOf(start, stop),
|
|
'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
|
|
'not have a parent path.',
|
|
start,
|
|
stop
|
|
) : invariant(traverseUp || isAncestorIDOf(start, stop)));
|
|
// Traverse from `start` to `stop` one depth at a time.
|
|
var depth = 0;
|
|
var traverse = traverseUp ? getParentID : getNextDescendantID;
|
|
for (var id = start; /* until break */; id = traverse(id, stop)) {
|
|
var ret;
|
|
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
|
|
ret = cb(id, traverseUp, arg);
|
|
}
|
|
if (ret === false || id === stop) {
|
|
// Only break //after// visiting `stop`.
|
|
break;
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
depth++ < MAX_TREE_DEPTH,
|
|
'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
|
|
'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
|
|
start, stop
|
|
) : invariant(depth++ < MAX_TREE_DEPTH));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Manages the IDs assigned to DOM representations of React components. This
|
|
* uses a specific scheme in order to traverse the DOM efficiently (e.g. in
|
|
* order to simulate events).
|
|
*
|
|
* @internal
|
|
*/
|
|
var ReactInstanceHandles = {
|
|
|
|
/**
|
|
* Constructs a React root ID
|
|
* @return {string} A React root ID.
|
|
*/
|
|
createReactRootID: function() {
|
|
return getReactRootIDString(ReactRootIndex.createReactRootIndex());
|
|
},
|
|
|
|
/**
|
|
* Constructs a React ID by joining a root ID with a name.
|
|
*
|
|
* @param {string} rootID Root ID of a parent component.
|
|
* @param {string} name A component's name (as flattened children).
|
|
* @return {string} A React ID.
|
|
* @internal
|
|
*/
|
|
createReactID: function(rootID, name) {
|
|
return rootID + name;
|
|
},
|
|
|
|
/**
|
|
* Gets the DOM ID of the React component that is the root of the tree that
|
|
* contains the React component with the supplied DOM ID.
|
|
*
|
|
* @param {string} id DOM ID of a React component.
|
|
* @return {?string} DOM ID of the React component that is the root.
|
|
* @internal
|
|
*/
|
|
getReactRootIDFromNodeID: function(id) {
|
|
if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
|
|
var index = id.indexOf(SEPARATOR, 1);
|
|
return index > -1 ? id.substr(0, index) : id;
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/**
|
|
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
|
|
* should would receive a `mouseEnter` or `mouseLeave` event.
|
|
*
|
|
* NOTE: Does not invoke the callback on the nearest common ancestor because
|
|
* nothing "entered" or "left" that element.
|
|
*
|
|
* @param {string} leaveID ID being left.
|
|
* @param {string} enterID ID being entered.
|
|
* @param {function} cb Callback to invoke on each entered/left ID.
|
|
* @param {*} upArg Argument to invoke the callback with on left IDs.
|
|
* @param {*} downArg Argument to invoke the callback with on entered IDs.
|
|
* @internal
|
|
*/
|
|
traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
|
|
var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
|
|
if (ancestorID !== leaveID) {
|
|
traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
|
|
}
|
|
if (ancestorID !== enterID) {
|
|
traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
|
|
*
|
|
* NOTE: This traversal happens on IDs without touching the DOM.
|
|
*
|
|
* @param {string} targetID ID of the target node.
|
|
* @param {function} cb Callback to invoke.
|
|
* @param {*} arg Argument to invoke the callback with.
|
|
* @internal
|
|
*/
|
|
traverseTwoPhase: function(targetID, cb, arg) {
|
|
if (targetID) {
|
|
traverseParentPath('', targetID, cb, arg, true, false);
|
|
traverseParentPath(targetID, '', cb, arg, false, true);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
|
|
* example, passing `.0.$row-0.1` would result in `cb` getting called
|
|
* with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
|
|
*
|
|
* NOTE: This traversal happens on IDs without touching the DOM.
|
|
*
|
|
* @param {string} targetID ID of the target node.
|
|
* @param {function} cb Callback to invoke.
|
|
* @param {*} arg Argument to invoke the callback with.
|
|
* @internal
|
|
*/
|
|
traverseAncestors: function(targetID, cb, arg) {
|
|
traverseParentPath('', targetID, cb, arg, true, false);
|
|
},
|
|
|
|
/**
|
|
* Exposed for unit testing.
|
|
* @private
|
|
*/
|
|
_getFirstCommonAncestorID: getFirstCommonAncestorID,
|
|
|
|
/**
|
|
* Exposed for unit testing.
|
|
* @private
|
|
*/
|
|
_getNextDescendantID: getNextDescendantID,
|
|
|
|
isAncestorIDOf: isAncestorIDOf,
|
|
|
|
SEPARATOR: SEPARATOR
|
|
|
|
};
|
|
|
|
module.exports = ReactInstanceHandles;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactRootIndex":123,"./invariant":182,"_process":1}],108:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactLegacyElement
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
|
|
var invariant = require("./invariant");
|
|
var monitorCodeUse = require("./monitorCodeUse");
|
|
var warning = require("./warning");
|
|
|
|
var legacyFactoryLogs = {};
|
|
function warnForLegacyFactoryCall() {
|
|
if (!ReactLegacyElementFactory._isLegacyCallWarningEnabled) {
|
|
return;
|
|
}
|
|
var owner = ReactCurrentOwner.current;
|
|
var name = owner && owner.constructor ? owner.constructor.displayName : '';
|
|
if (!name) {
|
|
name = 'Something';
|
|
}
|
|
if (legacyFactoryLogs.hasOwnProperty(name)) {
|
|
return;
|
|
}
|
|
legacyFactoryLogs[name] = true;
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
name + ' is calling a React component directly. ' +
|
|
'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
|
|
) : null);
|
|
monitorCodeUse('react_legacy_factory_call', { version: 3, name: name });
|
|
}
|
|
|
|
function warnForPlainFunctionType(type) {
|
|
var isReactClass =
|
|
type.prototype &&
|
|
typeof type.prototype.mountComponent === 'function' &&
|
|
typeof type.prototype.receiveComponent === 'function';
|
|
if (isReactClass) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'Did not expect to get a React class here. Use `Component` instead ' +
|
|
'of `Component.type` or `this.constructor`.'
|
|
) : null);
|
|
} else {
|
|
if (!type._reactWarnedForThisType) {
|
|
try {
|
|
type._reactWarnedForThisType = true;
|
|
} catch (x) {
|
|
// just incase this is a frozen object or some special object
|
|
}
|
|
monitorCodeUse(
|
|
'react_non_component_in_jsx',
|
|
{ version: 3, name: type.name }
|
|
);
|
|
}
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'This JSX uses a plain function. Only React components are ' +
|
|
'valid in React\'s JSX transform.'
|
|
) : null);
|
|
}
|
|
}
|
|
|
|
function warnForNonLegacyFactory(type) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'Do not pass React.DOM.' + type.type + ' to JSX or createFactory. ' +
|
|
'Use the string "' + type.type + '" instead.'
|
|
) : null);
|
|
}
|
|
|
|
/**
|
|
* Transfer static properties from the source to the target. Functions are
|
|
* rebound to have this reflect the original source.
|
|
*/
|
|
function proxyStaticMethods(target, source) {
|
|
if (typeof source !== 'function') {
|
|
return;
|
|
}
|
|
for (var key in source) {
|
|
if (source.hasOwnProperty(key)) {
|
|
var value = source[key];
|
|
if (typeof value === 'function') {
|
|
var bound = value.bind(source);
|
|
// Copy any properties defined on the function, such as `isRequired` on
|
|
// a PropTypes validator.
|
|
for (var k in value) {
|
|
if (value.hasOwnProperty(k)) {
|
|
bound[k] = value[k];
|
|
}
|
|
}
|
|
target[key] = bound;
|
|
} else {
|
|
target[key] = value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// We use an object instead of a boolean because booleans are ignored by our
|
|
// mocking libraries when these factories gets mocked.
|
|
var LEGACY_MARKER = {};
|
|
var NON_LEGACY_MARKER = {};
|
|
|
|
var ReactLegacyElementFactory = {};
|
|
|
|
ReactLegacyElementFactory.wrapCreateFactory = function(createFactory) {
|
|
var legacyCreateFactory = function(type) {
|
|
if (typeof type !== 'function') {
|
|
// Non-function types cannot be legacy factories
|
|
return createFactory(type);
|
|
}
|
|
|
|
if (type.isReactNonLegacyFactory) {
|
|
// This is probably a factory created by ReactDOM we unwrap it to get to
|
|
// the underlying string type. It shouldn't have been passed here so we
|
|
// warn.
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warnForNonLegacyFactory(type);
|
|
}
|
|
return createFactory(type.type);
|
|
}
|
|
|
|
if (type.isReactLegacyFactory) {
|
|
// This is probably a legacy factory created by ReactCompositeComponent.
|
|
// We unwrap it to get to the underlying class.
|
|
return createFactory(type.type);
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warnForPlainFunctionType(type);
|
|
}
|
|
|
|
// Unless it's a legacy factory, then this is probably a plain function,
|
|
// that is expecting to be invoked by JSX. We can just return it as is.
|
|
return type;
|
|
};
|
|
return legacyCreateFactory;
|
|
};
|
|
|
|
ReactLegacyElementFactory.wrapCreateElement = function(createElement) {
|
|
var legacyCreateElement = function(type, props, children) {
|
|
if (typeof type !== 'function') {
|
|
// Non-function types cannot be legacy factories
|
|
return createElement.apply(this, arguments);
|
|
}
|
|
|
|
var args;
|
|
|
|
if (type.isReactNonLegacyFactory) {
|
|
// This is probably a factory created by ReactDOM we unwrap it to get to
|
|
// the underlying string type. It shouldn't have been passed here so we
|
|
// warn.
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warnForNonLegacyFactory(type);
|
|
}
|
|
args = Array.prototype.slice.call(arguments, 0);
|
|
args[0] = type.type;
|
|
return createElement.apply(this, args);
|
|
}
|
|
|
|
if (type.isReactLegacyFactory) {
|
|
// This is probably a legacy factory created by ReactCompositeComponent.
|
|
// We unwrap it to get to the underlying class.
|
|
if (type._isMockFunction) {
|
|
// If this is a mock function, people will expect it to be called. We
|
|
// will actually call the original mock factory function instead. This
|
|
// future proofs unit testing that assume that these are classes.
|
|
type.type._mockedReactClassConstructor = type;
|
|
}
|
|
args = Array.prototype.slice.call(arguments, 0);
|
|
args[0] = type.type;
|
|
return createElement.apply(this, args);
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warnForPlainFunctionType(type);
|
|
}
|
|
|
|
// This is being called with a plain function we should invoke it
|
|
// immediately as if this was used with legacy JSX.
|
|
return type.apply(null, Array.prototype.slice.call(arguments, 1));
|
|
};
|
|
return legacyCreateElement;
|
|
};
|
|
|
|
ReactLegacyElementFactory.wrapFactory = function(factory) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof factory === 'function',
|
|
'This is suppose to accept a element factory'
|
|
) : invariant(typeof factory === 'function'));
|
|
var legacyElementFactory = function(config, children) {
|
|
// This factory should not be called when JSX is used. Use JSX instead.
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warnForLegacyFactoryCall();
|
|
}
|
|
return factory.apply(this, arguments);
|
|
};
|
|
proxyStaticMethods(legacyElementFactory, factory.type);
|
|
legacyElementFactory.isReactLegacyFactory = LEGACY_MARKER;
|
|
legacyElementFactory.type = factory.type;
|
|
return legacyElementFactory;
|
|
};
|
|
|
|
// This is used to mark a factory that will remain. E.g. we're allowed to call
|
|
// it as a function. However, you're not suppose to pass it to createElement
|
|
// or createFactory, so it will warn you if you do.
|
|
ReactLegacyElementFactory.markNonLegacyFactory = function(factory) {
|
|
factory.isReactNonLegacyFactory = NON_LEGACY_MARKER;
|
|
return factory;
|
|
};
|
|
|
|
// Checks if a factory function is actually a legacy factory pretending to
|
|
// be a class.
|
|
ReactLegacyElementFactory.isValidFactory = function(factory) {
|
|
// TODO: This will be removed and moved into a class validator or something.
|
|
return typeof factory === 'function' &&
|
|
factory.isReactLegacyFactory === LEGACY_MARKER;
|
|
};
|
|
|
|
ReactLegacyElementFactory.isValidClass = function(factory) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'isValidClass is deprecated and will be removed in a future release. ' +
|
|
'Use a more specific validator instead.'
|
|
) : null);
|
|
}
|
|
return ReactLegacyElementFactory.isValidFactory(factory);
|
|
};
|
|
|
|
ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
|
|
|
|
module.exports = ReactLegacyElementFactory;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactCurrentOwner":83,"./invariant":182,"./monitorCodeUse":192,"./warning":202,"_process":1}],109:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactLink
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* ReactLink encapsulates a common pattern in which a component wants to modify
|
|
* a prop received from its parent. ReactLink allows the parent to pass down a
|
|
* value coupled with a callback that, when invoked, expresses an intent to
|
|
* modify that value. For example:
|
|
*
|
|
* React.createClass({
|
|
* getInitialState: function() {
|
|
* return {value: ''};
|
|
* },
|
|
* render: function() {
|
|
* var valueLink = new ReactLink(this.state.value, this._handleValueChange);
|
|
* return <input valueLink={valueLink} />;
|
|
* },
|
|
* this._handleValueChange: function(newValue) {
|
|
* this.setState({value: newValue});
|
|
* }
|
|
* });
|
|
*
|
|
* We have provided some sugary mixins to make the creation and
|
|
* consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
|
|
*/
|
|
|
|
var React = require("./React");
|
|
|
|
/**
|
|
* @param {*} value current value of the link
|
|
* @param {function} requestChange callback to request a change
|
|
*/
|
|
function ReactLink(value, requestChange) {
|
|
this.value = value;
|
|
this.requestChange = requestChange;
|
|
}
|
|
|
|
/**
|
|
* Creates a PropType that enforces the ReactLink API and optionally checks the
|
|
* type of the value being passed inside the link. Example:
|
|
*
|
|
* MyComponent.propTypes = {
|
|
* tabIndexLink: ReactLink.PropTypes.link(React.PropTypes.number)
|
|
* }
|
|
*/
|
|
function createLinkTypeChecker(linkType) {
|
|
var shapes = {
|
|
value: typeof linkType === 'undefined' ?
|
|
React.PropTypes.any.isRequired :
|
|
linkType.isRequired,
|
|
requestChange: React.PropTypes.func.isRequired
|
|
};
|
|
return React.PropTypes.shape(shapes);
|
|
}
|
|
|
|
ReactLink.PropTypes = {
|
|
link: createLinkTypeChecker
|
|
};
|
|
|
|
module.exports = ReactLink;
|
|
|
|
},{"./React":72}],110:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactMarkupChecksum
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var adler32 = require("./adler32");
|
|
|
|
var ReactMarkupChecksum = {
|
|
CHECKSUM_ATTR_NAME: 'data-react-checksum',
|
|
|
|
/**
|
|
* @param {string} markup Markup string
|
|
* @return {string} Markup string with checksum attribute attached
|
|
*/
|
|
addChecksumToMarkup: function(markup) {
|
|
var checksum = adler32(markup);
|
|
return markup.replace(
|
|
'>',
|
|
' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
|
|
);
|
|
},
|
|
|
|
/**
|
|
* @param {string} markup to use
|
|
* @param {DOMElement} element root React element
|
|
* @returns {boolean} whether or not the markup is the same
|
|
*/
|
|
canReuseMarkup: function(markup, element) {
|
|
var existingChecksum = element.getAttribute(
|
|
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
|
|
);
|
|
existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
|
|
var markupChecksum = adler32(markup);
|
|
return markupChecksum === existingChecksum;
|
|
}
|
|
};
|
|
|
|
module.exports = ReactMarkupChecksum;
|
|
|
|
},{"./adler32":152}],111:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactMount
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
var ReactPerf = require("./ReactPerf");
|
|
|
|
var containsNode = require("./containsNode");
|
|
var deprecated = require("./deprecated");
|
|
var getReactRootElementInContainer = require("./getReactRootElementInContainer");
|
|
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
var invariant = require("./invariant");
|
|
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
var warning = require("./warning");
|
|
|
|
var createElement = ReactLegacyElement.wrapCreateElement(
|
|
ReactElement.createElement
|
|
);
|
|
|
|
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
|
|
|
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
|
|
var nodeCache = {};
|
|
|
|
var ELEMENT_NODE_TYPE = 1;
|
|
var DOC_NODE_TYPE = 9;
|
|
|
|
/** Mapping from reactRootID to React component instance. */
|
|
var instancesByReactRootID = {};
|
|
|
|
/** Mapping from reactRootID to `container` nodes. */
|
|
var containersByReactRootID = {};
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
/** __DEV__-only mapping from reactRootID to root elements. */
|
|
var rootElementsByReactRootID = {};
|
|
}
|
|
|
|
// Used to store breadth-first search state in findComponentRoot.
|
|
var findComponentRootReusableArray = [];
|
|
|
|
/**
|
|
* @param {DOMElement} container DOM element that may contain a React component.
|
|
* @return {?string} A "reactRoot" ID, if a React component is rendered.
|
|
*/
|
|
function getReactRootID(container) {
|
|
var rootElement = getReactRootElementInContainer(container);
|
|
return rootElement && ReactMount.getID(rootElement);
|
|
}
|
|
|
|
/**
|
|
* Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
|
|
* element can return its control whose name or ID equals ATTR_NAME. All
|
|
* DOM nodes support `getAttributeNode` but this can also get called on
|
|
* other objects so just return '' if we're given something other than a
|
|
* DOM node (such as window).
|
|
*
|
|
* @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
|
|
* @return {string} ID of the supplied `domNode`.
|
|
*/
|
|
function getID(node) {
|
|
var id = internalGetID(node);
|
|
if (id) {
|
|
if (nodeCache.hasOwnProperty(id)) {
|
|
var cached = nodeCache[id];
|
|
if (cached !== node) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!isValid(cached, id),
|
|
'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
|
|
ATTR_NAME, id
|
|
) : invariant(!isValid(cached, id)));
|
|
|
|
nodeCache[id] = node;
|
|
}
|
|
} else {
|
|
nodeCache[id] = node;
|
|
}
|
|
}
|
|
|
|
return id;
|
|
}
|
|
|
|
function internalGetID(node) {
|
|
// If node is something like a window, document, or text node, none of
|
|
// which support attributes or a .getAttribute method, gracefully return
|
|
// the empty string, as if the attribute were missing.
|
|
return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
|
|
}
|
|
|
|
/**
|
|
* Sets the React-specific ID of the given node.
|
|
*
|
|
* @param {DOMElement} node The DOM node whose ID will be set.
|
|
* @param {string} id The value of the ID attribute.
|
|
*/
|
|
function setID(node, id) {
|
|
var oldID = internalGetID(node);
|
|
if (oldID !== id) {
|
|
delete nodeCache[oldID];
|
|
}
|
|
node.setAttribute(ATTR_NAME, id);
|
|
nodeCache[id] = node;
|
|
}
|
|
|
|
/**
|
|
* Finds the node with the supplied React-generated DOM ID.
|
|
*
|
|
* @param {string} id A React-generated DOM ID.
|
|
* @return {DOMElement} DOM node with the suppled `id`.
|
|
* @internal
|
|
*/
|
|
function getNode(id) {
|
|
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
|
|
nodeCache[id] = ReactMount.findReactNodeByID(id);
|
|
}
|
|
return nodeCache[id];
|
|
}
|
|
|
|
/**
|
|
* A node is "valid" if it is contained by a currently mounted container.
|
|
*
|
|
* This means that the node does not have to be contained by a document in
|
|
* order to be considered valid.
|
|
*
|
|
* @param {?DOMElement} node The candidate DOM node.
|
|
* @param {string} id The expected ID of the node.
|
|
* @return {boolean} Whether the node is contained by a mounted container.
|
|
*/
|
|
function isValid(node, id) {
|
|
if (node) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
internalGetID(node) === id,
|
|
'ReactMount: Unexpected modification of `%s`',
|
|
ATTR_NAME
|
|
) : invariant(internalGetID(node) === id));
|
|
|
|
var container = ReactMount.findReactContainerForID(id);
|
|
if (container && containsNode(container, node)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Causes the cache to forget about one React-specific ID.
|
|
*
|
|
* @param {string} id The ID to forget.
|
|
*/
|
|
function purgeID(id) {
|
|
delete nodeCache[id];
|
|
}
|
|
|
|
var deepestNodeSoFar = null;
|
|
function findDeepestCachedAncestorImpl(ancestorID) {
|
|
var ancestor = nodeCache[ancestorID];
|
|
if (ancestor && isValid(ancestor, ancestorID)) {
|
|
deepestNodeSoFar = ancestor;
|
|
} else {
|
|
// This node isn't populated in the cache, so presumably none of its
|
|
// descendants are. Break out of the loop.
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return the deepest cached node whose ID is a prefix of `targetID`.
|
|
*/
|
|
function findDeepestCachedAncestor(targetID) {
|
|
deepestNodeSoFar = null;
|
|
ReactInstanceHandles.traverseAncestors(
|
|
targetID,
|
|
findDeepestCachedAncestorImpl
|
|
);
|
|
|
|
var foundNode = deepestNodeSoFar;
|
|
deepestNodeSoFar = null;
|
|
return foundNode;
|
|
}
|
|
|
|
/**
|
|
* Mounting is the process of initializing a React component by creatings its
|
|
* representative DOM elements and inserting them into a supplied `container`.
|
|
* Any prior content inside `container` is destroyed in the process.
|
|
*
|
|
* ReactMount.render(
|
|
* component,
|
|
* document.getElementById('container')
|
|
* );
|
|
*
|
|
* <div id="container"> <-- Supplied `container`.
|
|
* <div data-reactid=".3"> <-- Rendered reactRoot of React
|
|
* // ... component.
|
|
* </div>
|
|
* </div>
|
|
*
|
|
* Inside of `container`, the first element rendered is the "reactRoot".
|
|
*/
|
|
var ReactMount = {
|
|
/** Exposed for debugging purposes **/
|
|
_instancesByReactRootID: instancesByReactRootID,
|
|
|
|
/**
|
|
* This is a hook provided to support rendering React components while
|
|
* ensuring that the apparent scroll position of its `container` does not
|
|
* change.
|
|
*
|
|
* @param {DOMElement} container The `container` being rendered into.
|
|
* @param {function} renderCallback This must be called once to do the render.
|
|
*/
|
|
scrollMonitor: function(container, renderCallback) {
|
|
renderCallback();
|
|
},
|
|
|
|
/**
|
|
* Take a component that's already mounted into the DOM and replace its props
|
|
* @param {ReactComponent} prevComponent component instance already in the DOM
|
|
* @param {ReactComponent} nextComponent component instance to render
|
|
* @param {DOMElement} container container to render into
|
|
* @param {?function} callback function triggered on completion
|
|
*/
|
|
_updateRootComponent: function(
|
|
prevComponent,
|
|
nextComponent,
|
|
container,
|
|
callback) {
|
|
var nextProps = nextComponent.props;
|
|
ReactMount.scrollMonitor(container, function() {
|
|
prevComponent.replaceProps(nextProps, callback);
|
|
});
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// Record the root element in case it later gets transplanted.
|
|
rootElementsByReactRootID[getReactRootID(container)] =
|
|
getReactRootElementInContainer(container);
|
|
}
|
|
|
|
return prevComponent;
|
|
},
|
|
|
|
/**
|
|
* Register a component into the instance map and starts scroll value
|
|
* monitoring
|
|
* @param {ReactComponent} nextComponent component instance to render
|
|
* @param {DOMElement} container container to render into
|
|
* @return {string} reactRoot ID prefix
|
|
*/
|
|
_registerComponent: function(nextComponent, container) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
container && (
|
|
container.nodeType === ELEMENT_NODE_TYPE ||
|
|
container.nodeType === DOC_NODE_TYPE
|
|
),
|
|
'_registerComponent(...): Target container is not a DOM element.'
|
|
) : invariant(container && (
|
|
container.nodeType === ELEMENT_NODE_TYPE ||
|
|
container.nodeType === DOC_NODE_TYPE
|
|
)));
|
|
|
|
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
|
|
|
|
var reactRootID = ReactMount.registerContainer(container);
|
|
instancesByReactRootID[reactRootID] = nextComponent;
|
|
return reactRootID;
|
|
},
|
|
|
|
/**
|
|
* Render a new component into the DOM.
|
|
* @param {ReactComponent} nextComponent component instance to render
|
|
* @param {DOMElement} container container to render into
|
|
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion
|
|
* @return {ReactComponent} nextComponent
|
|
*/
|
|
_renderNewRootComponent: ReactPerf.measure(
|
|
'ReactMount',
|
|
'_renderNewRootComponent',
|
|
function(
|
|
nextComponent,
|
|
container,
|
|
shouldReuseMarkup) {
|
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
// verify that that's the case.
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
ReactCurrentOwner.current == null,
|
|
'_renderNewRootComponent(): Render methods should be a pure function ' +
|
|
'of props and state; triggering nested component updates from ' +
|
|
'render is not allowed. If necessary, trigger nested updates in ' +
|
|
'componentDidUpdate.'
|
|
) : null);
|
|
|
|
var componentInstance = instantiateReactComponent(nextComponent, null);
|
|
var reactRootID = ReactMount._registerComponent(
|
|
componentInstance,
|
|
container
|
|
);
|
|
componentInstance.mountComponentIntoNode(
|
|
reactRootID,
|
|
container,
|
|
shouldReuseMarkup
|
|
);
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
// Record the root element in case it later gets transplanted.
|
|
rootElementsByReactRootID[reactRootID] =
|
|
getReactRootElementInContainer(container);
|
|
}
|
|
|
|
return componentInstance;
|
|
}
|
|
),
|
|
|
|
/**
|
|
* Renders a React component into the DOM in the supplied `container`.
|
|
*
|
|
* If the React component was previously rendered into `container`, this will
|
|
* perform an update on it and only mutate the DOM as necessary to reflect the
|
|
* latest React component.
|
|
*
|
|
* @param {ReactElement} nextElement Component element to render.
|
|
* @param {DOMElement} container DOM element to render into.
|
|
* @param {?function} callback function triggered on completion
|
|
* @return {ReactComponent} Component instance rendered in `container`.
|
|
*/
|
|
render: function(nextElement, container, callback) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactElement.isValidElement(nextElement),
|
|
'renderComponent(): Invalid component element.%s',
|
|
(
|
|
typeof nextElement === 'string' ?
|
|
' Instead of passing an element string, make sure to instantiate ' +
|
|
'it by passing it to React.createElement.' :
|
|
ReactLegacyElement.isValidFactory(nextElement) ?
|
|
' Instead of passing a component class, make sure to instantiate ' +
|
|
'it by passing it to React.createElement.' :
|
|
// Check if it quacks like a element
|
|
typeof nextElement.props !== "undefined" ?
|
|
' This may be caused by unintentionally loading two independent ' +
|
|
'copies of React.' :
|
|
''
|
|
)
|
|
) : invariant(ReactElement.isValidElement(nextElement)));
|
|
|
|
var prevComponent = instancesByReactRootID[getReactRootID(container)];
|
|
|
|
if (prevComponent) {
|
|
var prevElement = prevComponent._currentElement;
|
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
return ReactMount._updateRootComponent(
|
|
prevComponent,
|
|
nextElement,
|
|
container,
|
|
callback
|
|
);
|
|
} else {
|
|
ReactMount.unmountComponentAtNode(container);
|
|
}
|
|
}
|
|
|
|
var reactRootElement = getReactRootElementInContainer(container);
|
|
var containerHasReactMarkup =
|
|
reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
|
|
|
|
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
|
|
|
|
var component = ReactMount._renderNewRootComponent(
|
|
nextElement,
|
|
container,
|
|
shouldReuseMarkup
|
|
);
|
|
callback && callback.call(component);
|
|
return component;
|
|
},
|
|
|
|
/**
|
|
* Constructs a component instance of `constructor` with `initialProps` and
|
|
* renders it into the supplied `container`.
|
|
*
|
|
* @param {function} constructor React component constructor.
|
|
* @param {?object} props Initial props of the component instance.
|
|
* @param {DOMElement} container DOM element to render into.
|
|
* @return {ReactComponent} Component instance rendered in `container`.
|
|
*/
|
|
constructAndRenderComponent: function(constructor, props, container) {
|
|
var element = createElement(constructor, props);
|
|
return ReactMount.render(element, container);
|
|
},
|
|
|
|
/**
|
|
* Constructs a component instance of `constructor` with `initialProps` and
|
|
* renders it into a container node identified by supplied `id`.
|
|
*
|
|
* @param {function} componentConstructor React component constructor
|
|
* @param {?object} props Initial props of the component instance.
|
|
* @param {string} id ID of the DOM element to render into.
|
|
* @return {ReactComponent} Component instance rendered in the container node.
|
|
*/
|
|
constructAndRenderComponentByID: function(constructor, props, id) {
|
|
var domNode = document.getElementById(id);
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
domNode,
|
|
'Tried to get element with id of "%s" but it is not present on the page.',
|
|
id
|
|
) : invariant(domNode));
|
|
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
|
|
},
|
|
|
|
/**
|
|
* Registers a container node into which React components will be rendered.
|
|
* This also creates the "reactRoot" ID that will be assigned to the element
|
|
* rendered within.
|
|
*
|
|
* @param {DOMElement} container DOM element to register as a container.
|
|
* @return {string} The "reactRoot" ID of elements rendered within.
|
|
*/
|
|
registerContainer: function(container) {
|
|
var reactRootID = getReactRootID(container);
|
|
if (reactRootID) {
|
|
// If one exists, make sure it is a valid "reactRoot" ID.
|
|
reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
|
|
}
|
|
if (!reactRootID) {
|
|
// No valid "reactRoot" ID found, create one.
|
|
reactRootID = ReactInstanceHandles.createReactRootID();
|
|
}
|
|
containersByReactRootID[reactRootID] = container;
|
|
return reactRootID;
|
|
},
|
|
|
|
/**
|
|
* Unmounts and destroys the React component rendered in the `container`.
|
|
*
|
|
* @param {DOMElement} container DOM element containing a React component.
|
|
* @return {boolean} True if a component was found in and unmounted from
|
|
* `container`
|
|
*/
|
|
unmountComponentAtNode: function(container) {
|
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
// verify that that's the case. (Strictly speaking, unmounting won't cause a
|
|
// render but we still don't expect to be in a render call here.)
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
ReactCurrentOwner.current == null,
|
|
'unmountComponentAtNode(): Render methods should be a pure function of ' +
|
|
'props and state; triggering nested component updates from render is ' +
|
|
'not allowed. If necessary, trigger nested updates in ' +
|
|
'componentDidUpdate.'
|
|
) : null);
|
|
|
|
var reactRootID = getReactRootID(container);
|
|
var component = instancesByReactRootID[reactRootID];
|
|
if (!component) {
|
|
return false;
|
|
}
|
|
ReactMount.unmountComponentFromNode(component, container);
|
|
delete instancesByReactRootID[reactRootID];
|
|
delete containersByReactRootID[reactRootID];
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
delete rootElementsByReactRootID[reactRootID];
|
|
}
|
|
return true;
|
|
},
|
|
|
|
/**
|
|
* Unmounts a component and removes it from the DOM.
|
|
*
|
|
* @param {ReactComponent} instance React component instance.
|
|
* @param {DOMElement} container DOM element to unmount from.
|
|
* @final
|
|
* @internal
|
|
* @see {ReactMount.unmountComponentAtNode}
|
|
*/
|
|
unmountComponentFromNode: function(instance, container) {
|
|
instance.unmountComponent();
|
|
|
|
if (container.nodeType === DOC_NODE_TYPE) {
|
|
container = container.documentElement;
|
|
}
|
|
|
|
// http://jsperf.com/emptying-a-node
|
|
while (container.lastChild) {
|
|
container.removeChild(container.lastChild);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Finds the container DOM element that contains React component to which the
|
|
* supplied DOM `id` belongs.
|
|
*
|
|
* @param {string} id The ID of an element rendered by a React component.
|
|
* @return {?DOMElement} DOM element that contains the `id`.
|
|
*/
|
|
findReactContainerForID: function(id) {
|
|
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
|
|
var container = containersByReactRootID[reactRootID];
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var rootElement = rootElementsByReactRootID[reactRootID];
|
|
if (rootElement && rootElement.parentNode !== container) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
// Call internalGetID here because getID calls isValid which calls
|
|
// findReactContainerForID (this function).
|
|
internalGetID(rootElement) === reactRootID,
|
|
'ReactMount: Root element ID differed from reactRootID.'
|
|
) : invariant(// Call internalGetID here because getID calls isValid which calls
|
|
// findReactContainerForID (this function).
|
|
internalGetID(rootElement) === reactRootID));
|
|
|
|
var containerChild = container.firstChild;
|
|
if (containerChild &&
|
|
reactRootID === internalGetID(containerChild)) {
|
|
// If the container has a new child with the same ID as the old
|
|
// root element, then rootElementsByReactRootID[reactRootID] is
|
|
// just stale and needs to be updated. The case that deserves a
|
|
// warning is when the container is empty.
|
|
rootElementsByReactRootID[reactRootID] = containerChild;
|
|
} else {
|
|
console.warn(
|
|
'ReactMount: Root element has been removed from its original ' +
|
|
'container. New container:', rootElement.parentNode
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
return container;
|
|
},
|
|
|
|
/**
|
|
* Finds an element rendered by React with the supplied ID.
|
|
*
|
|
* @param {string} id ID of a DOM node in the React component.
|
|
* @return {DOMElement} Root DOM node of the React component.
|
|
*/
|
|
findReactNodeByID: function(id) {
|
|
var reactRoot = ReactMount.findReactContainerForID(id);
|
|
return ReactMount.findComponentRoot(reactRoot, id);
|
|
},
|
|
|
|
/**
|
|
* True if the supplied `node` is rendered by React.
|
|
*
|
|
* @param {*} node DOM Element to check.
|
|
* @return {boolean} True if the DOM Element appears to be rendered by React.
|
|
* @internal
|
|
*/
|
|
isRenderedByReact: function(node) {
|
|
if (node.nodeType !== 1) {
|
|
// Not a DOMElement, therefore not a React component
|
|
return false;
|
|
}
|
|
var id = ReactMount.getID(node);
|
|
return id ? id.charAt(0) === SEPARATOR : false;
|
|
},
|
|
|
|
/**
|
|
* Traverses up the ancestors of the supplied node to find a node that is a
|
|
* DOM representation of a React component.
|
|
*
|
|
* @param {*} node
|
|
* @return {?DOMEventTarget}
|
|
* @internal
|
|
*/
|
|
getFirstReactDOM: function(node) {
|
|
var current = node;
|
|
while (current && current.parentNode !== current) {
|
|
if (ReactMount.isRenderedByReact(current)) {
|
|
return current;
|
|
}
|
|
current = current.parentNode;
|
|
}
|
|
return null;
|
|
},
|
|
|
|
/**
|
|
* Finds a node with the supplied `targetID` inside of the supplied
|
|
* `ancestorNode`. Exploits the ID naming scheme to perform the search
|
|
* quickly.
|
|
*
|
|
* @param {DOMEventTarget} ancestorNode Search from this root.
|
|
* @pararm {string} targetID ID of the DOM representation of the component.
|
|
* @return {DOMEventTarget} DOM node with the supplied `targetID`.
|
|
* @internal
|
|
*/
|
|
findComponentRoot: function(ancestorNode, targetID) {
|
|
var firstChildren = findComponentRootReusableArray;
|
|
var childIndex = 0;
|
|
|
|
var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
|
|
|
|
firstChildren[0] = deepestAncestor.firstChild;
|
|
firstChildren.length = 1;
|
|
|
|
while (childIndex < firstChildren.length) {
|
|
var child = firstChildren[childIndex++];
|
|
var targetChild;
|
|
|
|
while (child) {
|
|
var childID = ReactMount.getID(child);
|
|
if (childID) {
|
|
// Even if we find the node we're looking for, we finish looping
|
|
// through its siblings to ensure they're cached so that we don't have
|
|
// to revisit this node again. Otherwise, we make n^2 calls to getID
|
|
// when visiting the many children of a single node in order.
|
|
|
|
if (targetID === childID) {
|
|
targetChild = child;
|
|
} else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
|
|
// If we find a child whose ID is an ancestor of the given ID,
|
|
// then we can be sure that we only want to search the subtree
|
|
// rooted at this child, so we can throw out the rest of the
|
|
// search state.
|
|
firstChildren.length = childIndex = 0;
|
|
firstChildren.push(child.firstChild);
|
|
}
|
|
|
|
} else {
|
|
// If this child had no ID, then there's a chance that it was
|
|
// injected automatically by the browser, as when a `<table>`
|
|
// element sprouts an extra `<tbody>` child as a side effect of
|
|
// `.innerHTML` parsing. Optimistically continue down this
|
|
// branch, but not before examining the other siblings.
|
|
firstChildren.push(child.firstChild);
|
|
}
|
|
|
|
child = child.nextSibling;
|
|
}
|
|
|
|
if (targetChild) {
|
|
// Emptying firstChildren/findComponentRootReusableArray is
|
|
// not necessary for correctness, but it helps the GC reclaim
|
|
// any nodes that were left at the end of the search.
|
|
firstChildren.length = 0;
|
|
|
|
return targetChild;
|
|
}
|
|
}
|
|
|
|
firstChildren.length = 0;
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
false,
|
|
'findComponentRoot(..., %s): Unable to find element. This probably ' +
|
|
'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
|
|
'usually due to forgetting a <tbody> when using tables, nesting tags ' +
|
|
'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
|
|
'parent. ' +
|
|
'Try inspecting the child nodes of the element with React ID `%s`.',
|
|
targetID,
|
|
ReactMount.getID(ancestorNode)
|
|
) : invariant(false));
|
|
},
|
|
|
|
|
|
/**
|
|
* React ID utilities.
|
|
*/
|
|
|
|
getReactRootID: getReactRootID,
|
|
|
|
getID: getID,
|
|
|
|
setID: setID,
|
|
|
|
getNode: getNode,
|
|
|
|
purgeID: purgeID
|
|
};
|
|
|
|
// Deprecations (remove for 0.13)
|
|
ReactMount.renderComponent = deprecated(
|
|
'ReactMount',
|
|
'renderComponent',
|
|
'render',
|
|
this,
|
|
ReactMount.render
|
|
);
|
|
|
|
module.exports = ReactMount;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./DOMProperty":53,"./ReactBrowserEventEmitter":74,"./ReactCurrentOwner":83,"./ReactElement":99,"./ReactInstanceHandles":107,"./ReactLegacyElement":108,"./ReactPerf":116,"./containsNode":156,"./deprecated":162,"./getReactRootElementInContainer":176,"./instantiateReactComponent":181,"./invariant":182,"./shouldUpdateReactComponent":198,"./warning":202,"_process":1}],112:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactMultiChild
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
|
|
|
|
var flattenChildren = require("./flattenChildren");
|
|
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
|
|
/**
|
|
* Updating children of a component may trigger recursive updates. The depth is
|
|
* used to batch recursive updates to render markup more efficiently.
|
|
*
|
|
* @type {number}
|
|
* @private
|
|
*/
|
|
var updateDepth = 0;
|
|
|
|
/**
|
|
* Queue of update configuration objects.
|
|
*
|
|
* Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
|
|
*
|
|
* @type {array<object>}
|
|
* @private
|
|
*/
|
|
var updateQueue = [];
|
|
|
|
/**
|
|
* Queue of markup to be rendered.
|
|
*
|
|
* @type {array<string>}
|
|
* @private
|
|
*/
|
|
var markupQueue = [];
|
|
|
|
/**
|
|
* Enqueues markup to be rendered and inserted at a supplied index.
|
|
*
|
|
* @param {string} parentID ID of the parent component.
|
|
* @param {string} markup Markup that renders into an element.
|
|
* @param {number} toIndex Destination index.
|
|
* @private
|
|
*/
|
|
function enqueueMarkup(parentID, markup, toIndex) {
|
|
// NOTE: Null values reduce hidden classes.
|
|
updateQueue.push({
|
|
parentID: parentID,
|
|
parentNode: null,
|
|
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
|
|
markupIndex: markupQueue.push(markup) - 1,
|
|
textContent: null,
|
|
fromIndex: null,
|
|
toIndex: toIndex
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Enqueues moving an existing element to another index.
|
|
*
|
|
* @param {string} parentID ID of the parent component.
|
|
* @param {number} fromIndex Source index of the existing element.
|
|
* @param {number} toIndex Destination index of the element.
|
|
* @private
|
|
*/
|
|
function enqueueMove(parentID, fromIndex, toIndex) {
|
|
// NOTE: Null values reduce hidden classes.
|
|
updateQueue.push({
|
|
parentID: parentID,
|
|
parentNode: null,
|
|
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
|
|
markupIndex: null,
|
|
textContent: null,
|
|
fromIndex: fromIndex,
|
|
toIndex: toIndex
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Enqueues removing an element at an index.
|
|
*
|
|
* @param {string} parentID ID of the parent component.
|
|
* @param {number} fromIndex Index of the element to remove.
|
|
* @private
|
|
*/
|
|
function enqueueRemove(parentID, fromIndex) {
|
|
// NOTE: Null values reduce hidden classes.
|
|
updateQueue.push({
|
|
parentID: parentID,
|
|
parentNode: null,
|
|
type: ReactMultiChildUpdateTypes.REMOVE_NODE,
|
|
markupIndex: null,
|
|
textContent: null,
|
|
fromIndex: fromIndex,
|
|
toIndex: null
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Enqueues setting the text content.
|
|
*
|
|
* @param {string} parentID ID of the parent component.
|
|
* @param {string} textContent Text content to set.
|
|
* @private
|
|
*/
|
|
function enqueueTextContent(parentID, textContent) {
|
|
// NOTE: Null values reduce hidden classes.
|
|
updateQueue.push({
|
|
parentID: parentID,
|
|
parentNode: null,
|
|
type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
|
|
markupIndex: null,
|
|
textContent: textContent,
|
|
fromIndex: null,
|
|
toIndex: null
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Processes any enqueued updates.
|
|
*
|
|
* @private
|
|
*/
|
|
function processQueue() {
|
|
if (updateQueue.length) {
|
|
ReactComponent.BackendIDOperations.dangerouslyProcessChildrenUpdates(
|
|
updateQueue,
|
|
markupQueue
|
|
);
|
|
clearQueue();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clears any enqueued updates.
|
|
*
|
|
* @private
|
|
*/
|
|
function clearQueue() {
|
|
updateQueue.length = 0;
|
|
markupQueue.length = 0;
|
|
}
|
|
|
|
/**
|
|
* ReactMultiChild are capable of reconciling multiple children.
|
|
*
|
|
* @class ReactMultiChild
|
|
* @internal
|
|
*/
|
|
var ReactMultiChild = {
|
|
|
|
/**
|
|
* Provides common functionality for components that must reconcile multiple
|
|
* children. This is used by `ReactDOMComponent` to mount, update, and
|
|
* unmount child components.
|
|
*
|
|
* @lends {ReactMultiChild.prototype}
|
|
*/
|
|
Mixin: {
|
|
|
|
/**
|
|
* Generates a "mount image" for each of the supplied children. In the case
|
|
* of `ReactDOMComponent`, a mount image is a string of markup.
|
|
*
|
|
* @param {?object} nestedChildren Nested child maps.
|
|
* @return {array} An array of mounted representations.
|
|
* @internal
|
|
*/
|
|
mountChildren: function(nestedChildren, transaction) {
|
|
var children = flattenChildren(nestedChildren);
|
|
var mountImages = [];
|
|
var index = 0;
|
|
this._renderedChildren = children;
|
|
for (var name in children) {
|
|
var child = children[name];
|
|
if (children.hasOwnProperty(name)) {
|
|
// The rendered children must be turned into instances as they're
|
|
// mounted.
|
|
var childInstance = instantiateReactComponent(child, null);
|
|
children[name] = childInstance;
|
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
var rootID = this._rootNodeID + name;
|
|
var mountImage = childInstance.mountComponent(
|
|
rootID,
|
|
transaction,
|
|
this._mountDepth + 1
|
|
);
|
|
childInstance._mountIndex = index;
|
|
mountImages.push(mountImage);
|
|
index++;
|
|
}
|
|
}
|
|
return mountImages;
|
|
},
|
|
|
|
/**
|
|
* Replaces any rendered children with a text content string.
|
|
*
|
|
* @param {string} nextContent String of content.
|
|
* @internal
|
|
*/
|
|
updateTextContent: function(nextContent) {
|
|
updateDepth++;
|
|
var errorThrown = true;
|
|
try {
|
|
var prevChildren = this._renderedChildren;
|
|
// Remove any rendered children.
|
|
for (var name in prevChildren) {
|
|
if (prevChildren.hasOwnProperty(name)) {
|
|
this._unmountChildByName(prevChildren[name], name);
|
|
}
|
|
}
|
|
// Set new text content.
|
|
this.setTextContent(nextContent);
|
|
errorThrown = false;
|
|
} finally {
|
|
updateDepth--;
|
|
if (!updateDepth) {
|
|
errorThrown ? clearQueue() : processQueue();
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Updates the rendered children with new children.
|
|
*
|
|
* @param {?object} nextNestedChildren Nested child maps.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
*/
|
|
updateChildren: function(nextNestedChildren, transaction) {
|
|
updateDepth++;
|
|
var errorThrown = true;
|
|
try {
|
|
this._updateChildren(nextNestedChildren, transaction);
|
|
errorThrown = false;
|
|
} finally {
|
|
updateDepth--;
|
|
if (!updateDepth) {
|
|
errorThrown ? clearQueue() : processQueue();
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Improve performance by isolating this hot code path from the try/catch
|
|
* block in `updateChildren`.
|
|
*
|
|
* @param {?object} nextNestedChildren Nested child maps.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @final
|
|
* @protected
|
|
*/
|
|
_updateChildren: function(nextNestedChildren, transaction) {
|
|
var nextChildren = flattenChildren(nextNestedChildren);
|
|
var prevChildren = this._renderedChildren;
|
|
if (!nextChildren && !prevChildren) {
|
|
return;
|
|
}
|
|
var name;
|
|
// `nextIndex` will increment for each child in `nextChildren`, but
|
|
// `lastIndex` will be the last index visited in `prevChildren`.
|
|
var lastIndex = 0;
|
|
var nextIndex = 0;
|
|
for (name in nextChildren) {
|
|
if (!nextChildren.hasOwnProperty(name)) {
|
|
continue;
|
|
}
|
|
var prevChild = prevChildren && prevChildren[name];
|
|
var prevElement = prevChild && prevChild._currentElement;
|
|
var nextElement = nextChildren[name];
|
|
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
prevChild.receiveComponent(nextElement, transaction);
|
|
prevChild._mountIndex = nextIndex;
|
|
} else {
|
|
if (prevChild) {
|
|
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
|
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
this._unmountChildByName(prevChild, name);
|
|
}
|
|
// The child must be instantiated before it's mounted.
|
|
var nextChildInstance = instantiateReactComponent(
|
|
nextElement,
|
|
null
|
|
);
|
|
this._mountChildByNameAtIndex(
|
|
nextChildInstance, name, nextIndex, transaction
|
|
);
|
|
}
|
|
nextIndex++;
|
|
}
|
|
// Remove children that are no longer present.
|
|
for (name in prevChildren) {
|
|
if (prevChildren.hasOwnProperty(name) &&
|
|
!(nextChildren && nextChildren[name])) {
|
|
this._unmountChildByName(prevChildren[name], name);
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Unmounts all rendered children. This should be used to clean up children
|
|
* when this component is unmounted.
|
|
*
|
|
* @internal
|
|
*/
|
|
unmountChildren: function() {
|
|
var renderedChildren = this._renderedChildren;
|
|
for (var name in renderedChildren) {
|
|
var renderedChild = renderedChildren[name];
|
|
// TODO: When is this not true?
|
|
if (renderedChild.unmountComponent) {
|
|
renderedChild.unmountComponent();
|
|
}
|
|
}
|
|
this._renderedChildren = null;
|
|
},
|
|
|
|
/**
|
|
* Moves a child component to the supplied index.
|
|
*
|
|
* @param {ReactComponent} child Component to move.
|
|
* @param {number} toIndex Destination index of the element.
|
|
* @param {number} lastIndex Last index visited of the siblings of `child`.
|
|
* @protected
|
|
*/
|
|
moveChild: function(child, toIndex, lastIndex) {
|
|
// If the index of `child` is less than `lastIndex`, then it needs to
|
|
// be moved. Otherwise, we do not need to move it because a child will be
|
|
// inserted or moved before `child`.
|
|
if (child._mountIndex < lastIndex) {
|
|
enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Creates a child component.
|
|
*
|
|
* @param {ReactComponent} child Component to create.
|
|
* @param {string} mountImage Markup to insert.
|
|
* @protected
|
|
*/
|
|
createChild: function(child, mountImage) {
|
|
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
|
|
},
|
|
|
|
/**
|
|
* Removes a child component.
|
|
*
|
|
* @param {ReactComponent} child Child to remove.
|
|
* @protected
|
|
*/
|
|
removeChild: function(child) {
|
|
enqueueRemove(this._rootNodeID, child._mountIndex);
|
|
},
|
|
|
|
/**
|
|
* Sets this text content string.
|
|
*
|
|
* @param {string} textContent Text content to set.
|
|
* @protected
|
|
*/
|
|
setTextContent: function(textContent) {
|
|
enqueueTextContent(this._rootNodeID, textContent);
|
|
},
|
|
|
|
/**
|
|
* Mounts a child with the supplied name.
|
|
*
|
|
* NOTE: This is part of `updateChildren` and is here for readability.
|
|
*
|
|
* @param {ReactComponent} child Component to mount.
|
|
* @param {string} name Name of the child.
|
|
* @param {number} index Index at which to insert the child.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @private
|
|
*/
|
|
_mountChildByNameAtIndex: function(child, name, index, transaction) {
|
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
var rootID = this._rootNodeID + name;
|
|
var mountImage = child.mountComponent(
|
|
rootID,
|
|
transaction,
|
|
this._mountDepth + 1
|
|
);
|
|
child._mountIndex = index;
|
|
this.createChild(child, mountImage);
|
|
this._renderedChildren = this._renderedChildren || {};
|
|
this._renderedChildren[name] = child;
|
|
},
|
|
|
|
/**
|
|
* Unmounts a rendered child by name.
|
|
*
|
|
* NOTE: This is part of `updateChildren` and is here for readability.
|
|
*
|
|
* @param {ReactComponent} child Component to unmount.
|
|
* @param {string} name Name of the child in `this._renderedChildren`.
|
|
* @private
|
|
*/
|
|
_unmountChildByName: function(child, name) {
|
|
this.removeChild(child);
|
|
child._mountIndex = null;
|
|
child.unmountComponent();
|
|
delete this._renderedChildren[name];
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ReactMultiChild;
|
|
|
|
},{"./ReactComponent":78,"./ReactMultiChildUpdateTypes":113,"./flattenChildren":166,"./instantiateReactComponent":181,"./shouldUpdateReactComponent":198}],113:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactMultiChildUpdateTypes
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var keyMirror = require("./keyMirror");
|
|
|
|
/**
|
|
* When a component's children are updated, a series of update configuration
|
|
* objects are created in order to batch and serialize the required changes.
|
|
*
|
|
* Enumerates all the possible types of update configurations.
|
|
*
|
|
* @internal
|
|
*/
|
|
var ReactMultiChildUpdateTypes = keyMirror({
|
|
INSERT_MARKUP: null,
|
|
MOVE_EXISTING: null,
|
|
REMOVE_NODE: null,
|
|
TEXT_CONTENT: null
|
|
});
|
|
|
|
module.exports = ReactMultiChildUpdateTypes;
|
|
|
|
},{"./keyMirror":188}],114:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactNativeComponent
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
|
|
var genericComponentClass = null;
|
|
// This registry keeps track of wrapper classes around native tags
|
|
var tagToComponentClass = {};
|
|
|
|
var ReactNativeComponentInjection = {
|
|
// This accepts a class that receives the tag string. This is a catch all
|
|
// that can render any kind of tag.
|
|
injectGenericComponentClass: function(componentClass) {
|
|
genericComponentClass = componentClass;
|
|
},
|
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
// tag. That particular tag will use this class instead of the generic one.
|
|
injectComponentClasses: function(componentClasses) {
|
|
assign(tagToComponentClass, componentClasses);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Create an internal class for a specific tag.
|
|
*
|
|
* @param {string} tag The tag for which to create an internal instance.
|
|
* @param {any} props The props passed to the instance constructor.
|
|
* @return {ReactComponent} component The injected empty component.
|
|
*/
|
|
function createInstanceForTag(tag, props, parentType) {
|
|
var componentClass = tagToComponentClass[tag];
|
|
if (componentClass == null) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
genericComponentClass,
|
|
'There is no registered component for the tag %s',
|
|
tag
|
|
) : invariant(genericComponentClass));
|
|
return new genericComponentClass(tag, props);
|
|
}
|
|
if (parentType === tag) {
|
|
// Avoid recursion
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
genericComponentClass,
|
|
'There is no registered component for the tag %s',
|
|
tag
|
|
) : invariant(genericComponentClass));
|
|
return new genericComponentClass(tag, props);
|
|
}
|
|
// Unwrap legacy factories
|
|
return new componentClass.type(props);
|
|
}
|
|
|
|
var ReactNativeComponent = {
|
|
createInstanceForTag: createInstanceForTag,
|
|
injection: ReactNativeComponentInjection
|
|
};
|
|
|
|
module.exports = ReactNativeComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./invariant":182,"_process":1}],115:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactOwner
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var emptyObject = require("./emptyObject");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* ReactOwners are capable of storing references to owned components.
|
|
*
|
|
* All components are capable of //being// referenced by owner components, but
|
|
* only ReactOwner components are capable of //referencing// owned components.
|
|
* The named reference is known as a "ref".
|
|
*
|
|
* Refs are available when mounted and updated during reconciliation.
|
|
*
|
|
* var MyComponent = React.createClass({
|
|
* render: function() {
|
|
* return (
|
|
* <div onClick={this.handleClick}>
|
|
* <CustomComponent ref="custom" />
|
|
* </div>
|
|
* );
|
|
* },
|
|
* handleClick: function() {
|
|
* this.refs.custom.handleClick();
|
|
* },
|
|
* componentDidMount: function() {
|
|
* this.refs.custom.initialize();
|
|
* }
|
|
* });
|
|
*
|
|
* Refs should rarely be used. When refs are used, they should only be done to
|
|
* control data that is not handled by React's data flow.
|
|
*
|
|
* @class ReactOwner
|
|
*/
|
|
var ReactOwner = {
|
|
|
|
/**
|
|
* @param {?object} object
|
|
* @return {boolean} True if `object` is a valid owner.
|
|
* @final
|
|
*/
|
|
isValidOwner: function(object) {
|
|
return !!(
|
|
object &&
|
|
typeof object.attachRef === 'function' &&
|
|
typeof object.detachRef === 'function'
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Adds a component by ref to an owner component.
|
|
*
|
|
* @param {ReactComponent} component Component to reference.
|
|
* @param {string} ref Name by which to refer to the component.
|
|
* @param {ReactOwner} owner Component on which to record the ref.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
addComponentAsRefTo: function(component, ref, owner) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactOwner.isValidOwner(owner),
|
|
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
|
|
'usually means that you\'re trying to add a ref to a component that ' +
|
|
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
'component\'s `render` method). Try rendering this component inside of ' +
|
|
'a new top-level component which will hold the ref.'
|
|
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
owner.attachRef(ref, component);
|
|
},
|
|
|
|
/**
|
|
* Removes a component by ref from an owner component.
|
|
*
|
|
* @param {ReactComponent} component Component to dereference.
|
|
* @param {string} ref Name of the ref to remove.
|
|
* @param {ReactOwner} owner Component on which the ref is recorded.
|
|
* @final
|
|
* @internal
|
|
*/
|
|
removeComponentAsRefFrom: function(component, ref, owner) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactOwner.isValidOwner(owner),
|
|
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
|
|
'usually means that you\'re trying to remove a ref to a component that ' +
|
|
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
'component\'s `render` method). Try rendering this component inside of ' +
|
|
'a new top-level component which will hold the ref.'
|
|
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
// Check that `component` is still the current ref because we do not want to
|
|
// detach the ref if another component stole it.
|
|
if (owner.refs[ref] === component) {
|
|
owner.detachRef(ref);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* A ReactComponent must mix this in to have refs.
|
|
*
|
|
* @lends {ReactOwner.prototype}
|
|
*/
|
|
Mixin: {
|
|
|
|
construct: function() {
|
|
this.refs = emptyObject;
|
|
},
|
|
|
|
/**
|
|
* Lazily allocates the refs object and stores `component` as `ref`.
|
|
*
|
|
* @param {string} ref Reference name.
|
|
* @param {component} component Component to store as `ref`.
|
|
* @final
|
|
* @private
|
|
*/
|
|
attachRef: function(ref, component) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
component.isOwnedBy(this),
|
|
'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
|
|
ref
|
|
) : invariant(component.isOwnedBy(this)));
|
|
var refs = this.refs === emptyObject ? (this.refs = {}) : this.refs;
|
|
refs[ref] = component;
|
|
},
|
|
|
|
/**
|
|
* Detaches a reference name.
|
|
*
|
|
* @param {string} ref Name to dereference.
|
|
* @final
|
|
* @private
|
|
*/
|
|
detachRef: function(ref) {
|
|
delete this.refs[ref];
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ReactOwner;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./emptyObject":164,"./invariant":182,"_process":1}],116:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPerf
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* ReactPerf is a general AOP system designed to measure performance. This
|
|
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
|
|
*/
|
|
var ReactPerf = {
|
|
/**
|
|
* Boolean to enable/disable measurement. Set to false by default to prevent
|
|
* accidental logging and perf loss.
|
|
*/
|
|
enableMeasure: false,
|
|
|
|
/**
|
|
* Holds onto the measure function in use. By default, don't measure
|
|
* anything, but we'll override this if we inject a measure function.
|
|
*/
|
|
storedMeasure: _noMeasure,
|
|
|
|
/**
|
|
* Use this to wrap methods you want to measure. Zero overhead in production.
|
|
*
|
|
* @param {string} objName
|
|
* @param {string} fnName
|
|
* @param {function} func
|
|
* @return {function}
|
|
*/
|
|
measure: function(objName, fnName, func) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var measuredFunc = null;
|
|
var wrapper = function() {
|
|
if (ReactPerf.enableMeasure) {
|
|
if (!measuredFunc) {
|
|
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
|
|
}
|
|
return measuredFunc.apply(this, arguments);
|
|
}
|
|
return func.apply(this, arguments);
|
|
};
|
|
wrapper.displayName = objName + '_' + fnName;
|
|
return wrapper;
|
|
}
|
|
return func;
|
|
},
|
|
|
|
injection: {
|
|
/**
|
|
* @param {function} measure
|
|
*/
|
|
injectMeasure: function(measure) {
|
|
ReactPerf.storedMeasure = measure;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Simply passes through the measured function, without measuring it.
|
|
*
|
|
* @param {string} objName
|
|
* @param {string} fnName
|
|
* @param {function} func
|
|
* @return {function}
|
|
*/
|
|
function _noMeasure(objName, fnName, func) {
|
|
return func;
|
|
}
|
|
|
|
module.exports = ReactPerf;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"_process":1}],117:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPropTransferer
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var assign = require("./Object.assign");
|
|
var emptyFunction = require("./emptyFunction");
|
|
var invariant = require("./invariant");
|
|
var joinClasses = require("./joinClasses");
|
|
var warning = require("./warning");
|
|
|
|
var didWarn = false;
|
|
|
|
/**
|
|
* Creates a transfer strategy that will merge prop values using the supplied
|
|
* `mergeStrategy`. If a prop was previously unset, this just sets it.
|
|
*
|
|
* @param {function} mergeStrategy
|
|
* @return {function}
|
|
*/
|
|
function createTransferStrategy(mergeStrategy) {
|
|
return function(props, key, value) {
|
|
if (!props.hasOwnProperty(key)) {
|
|
props[key] = value;
|
|
} else {
|
|
props[key] = mergeStrategy(props[key], value);
|
|
}
|
|
};
|
|
}
|
|
|
|
var transferStrategyMerge = createTransferStrategy(function(a, b) {
|
|
// `merge` overrides the first object's (`props[key]` above) keys using the
|
|
// second object's (`value`) keys. An object's style's existing `propA` would
|
|
// get overridden. Flip the order here.
|
|
return assign({}, b, a);
|
|
});
|
|
|
|
/**
|
|
* Transfer strategies dictate how props are transferred by `transferPropsTo`.
|
|
* NOTE: if you add any more exceptions to this list you should be sure to
|
|
* update `cloneWithProps()` accordingly.
|
|
*/
|
|
var TransferStrategies = {
|
|
/**
|
|
* Never transfer `children`.
|
|
*/
|
|
children: emptyFunction,
|
|
/**
|
|
* Transfer the `className` prop by merging them.
|
|
*/
|
|
className: createTransferStrategy(joinClasses),
|
|
/**
|
|
* Transfer the `style` prop (which is an object) by merging them.
|
|
*/
|
|
style: transferStrategyMerge
|
|
};
|
|
|
|
/**
|
|
* Mutates the first argument by transferring the properties from the second
|
|
* argument.
|
|
*
|
|
* @param {object} props
|
|
* @param {object} newProps
|
|
* @return {object}
|
|
*/
|
|
function transferInto(props, newProps) {
|
|
for (var thisKey in newProps) {
|
|
if (!newProps.hasOwnProperty(thisKey)) {
|
|
continue;
|
|
}
|
|
|
|
var transferStrategy = TransferStrategies[thisKey];
|
|
|
|
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
|
|
transferStrategy(props, thisKey, newProps[thisKey]);
|
|
} else if (!props.hasOwnProperty(thisKey)) {
|
|
props[thisKey] = newProps[thisKey];
|
|
}
|
|
}
|
|
return props;
|
|
}
|
|
|
|
/**
|
|
* ReactPropTransferer are capable of transferring props to another component
|
|
* using a `transferPropsTo` method.
|
|
*
|
|
* @class ReactPropTransferer
|
|
*/
|
|
var ReactPropTransferer = {
|
|
|
|
TransferStrategies: TransferStrategies,
|
|
|
|
/**
|
|
* Merge two props objects using TransferStrategies.
|
|
*
|
|
* @param {object} oldProps original props (they take precedence)
|
|
* @param {object} newProps new props to merge in
|
|
* @return {object} a new object containing both sets of props merged.
|
|
*/
|
|
mergeProps: function(oldProps, newProps) {
|
|
return transferInto(assign({}, oldProps), newProps);
|
|
},
|
|
|
|
/**
|
|
* @lends {ReactPropTransferer.prototype}
|
|
*/
|
|
Mixin: {
|
|
|
|
/**
|
|
* Transfer props from this component to a target component.
|
|
*
|
|
* Props that do not have an explicit transfer strategy will be transferred
|
|
* only if the target component does not already have the prop set.
|
|
*
|
|
* This is usually used to pass down props to a returned root component.
|
|
*
|
|
* @param {ReactElement} element Component receiving the properties.
|
|
* @return {ReactElement} The supplied `component`.
|
|
* @final
|
|
* @protected
|
|
*/
|
|
transferPropsTo: function(element) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
element._owner === this,
|
|
'%s: You can\'t call transferPropsTo() on a component that you ' +
|
|
'don\'t own, %s. This usually means you are calling ' +
|
|
'transferPropsTo() on a component passed in as props or children.',
|
|
this.constructor.displayName,
|
|
typeof element.type === 'string' ?
|
|
element.type :
|
|
element.type.displayName
|
|
) : invariant(element._owner === this));
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (!didWarn) {
|
|
didWarn = true;
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
false,
|
|
'transferPropsTo is deprecated. ' +
|
|
'See http://fb.me/react-transferpropsto for more information.'
|
|
) : null);
|
|
}
|
|
}
|
|
|
|
// Because elements are immutable we have to merge into the existing
|
|
// props object rather than clone it.
|
|
transferInto(element.props, this.props);
|
|
|
|
return element;
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
module.exports = ReactPropTransferer;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./emptyFunction":163,"./invariant":182,"./joinClasses":187,"./warning":202,"_process":1}],118:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPropTypeLocationNames
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactPropTypeLocationNames = {};
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
ReactPropTypeLocationNames = {
|
|
prop: 'prop',
|
|
context: 'context',
|
|
childContext: 'child context'
|
|
};
|
|
}
|
|
|
|
module.exports = ReactPropTypeLocationNames;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"_process":1}],119:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPropTypeLocations
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var keyMirror = require("./keyMirror");
|
|
|
|
var ReactPropTypeLocations = keyMirror({
|
|
prop: null,
|
|
context: null,
|
|
childContext: null
|
|
});
|
|
|
|
module.exports = ReactPropTypeLocations;
|
|
|
|
},{"./keyMirror":188}],120:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPropTypes
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
|
|
|
|
var deprecated = require("./deprecated");
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
/**
|
|
* Collection of methods that allow declaration and validation of props that are
|
|
* supplied to React components. Example usage:
|
|
*
|
|
* var Props = require('ReactPropTypes');
|
|
* var MyArticle = React.createClass({
|
|
* propTypes: {
|
|
* // An optional string prop named "description".
|
|
* description: Props.string,
|
|
*
|
|
* // A required enum prop named "category".
|
|
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
*
|
|
* // A prop named "dialog" that requires an instance of Dialog.
|
|
* dialog: Props.instanceOf(Dialog).isRequired
|
|
* },
|
|
* render: function() { ... }
|
|
* });
|
|
*
|
|
* A more formal specification of how these methods are used:
|
|
*
|
|
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
*
|
|
* Each and every declaration produces a function with the same signature. This
|
|
* allows the creation of custom validation functions. For example:
|
|
*
|
|
* var MyLink = React.createClass({
|
|
* propTypes: {
|
|
* // An optional string or URI prop named "href".
|
|
* href: function(props, propName, componentName) {
|
|
* var propValue = props[propName];
|
|
* if (propValue != null && typeof propValue !== 'string' &&
|
|
* !(propValue instanceof URI)) {
|
|
* return new Error(
|
|
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
* componentName
|
|
* );
|
|
* }
|
|
* }
|
|
* },
|
|
* render: function() {...}
|
|
* });
|
|
*
|
|
* @internal
|
|
*/
|
|
|
|
var ANONYMOUS = '<<anonymous>>';
|
|
|
|
var elementTypeChecker = createElementTypeChecker();
|
|
var nodeTypeChecker = createNodeChecker();
|
|
|
|
var ReactPropTypes = {
|
|
array: createPrimitiveTypeChecker('array'),
|
|
bool: createPrimitiveTypeChecker('boolean'),
|
|
func: createPrimitiveTypeChecker('function'),
|
|
number: createPrimitiveTypeChecker('number'),
|
|
object: createPrimitiveTypeChecker('object'),
|
|
string: createPrimitiveTypeChecker('string'),
|
|
|
|
any: createAnyTypeChecker(),
|
|
arrayOf: createArrayOfTypeChecker,
|
|
element: elementTypeChecker,
|
|
instanceOf: createInstanceTypeChecker,
|
|
node: nodeTypeChecker,
|
|
objectOf: createObjectOfTypeChecker,
|
|
oneOf: createEnumTypeChecker,
|
|
oneOfType: createUnionTypeChecker,
|
|
shape: createShapeTypeChecker,
|
|
|
|
component: deprecated(
|
|
'React.PropTypes',
|
|
'component',
|
|
'element',
|
|
this,
|
|
elementTypeChecker
|
|
),
|
|
renderable: deprecated(
|
|
'React.PropTypes',
|
|
'renderable',
|
|
'node',
|
|
this,
|
|
nodeTypeChecker
|
|
)
|
|
};
|
|
|
|
function createChainableTypeChecker(validate) {
|
|
function checkType(isRequired, props, propName, componentName, location) {
|
|
componentName = componentName || ANONYMOUS;
|
|
if (props[propName] == null) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
if (isRequired) {
|
|
return new Error(
|
|
("Required " + locationName + " `" + propName + "` was not specified in ")+
|
|
("`" + componentName + "`.")
|
|
);
|
|
}
|
|
} else {
|
|
return validate(props, propName, componentName, location);
|
|
}
|
|
}
|
|
|
|
var chainedCheckType = checkType.bind(null, false);
|
|
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
|
|
return chainedCheckType;
|
|
}
|
|
|
|
function createPrimitiveTypeChecker(expectedType) {
|
|
function validate(props, propName, componentName, location) {
|
|
var propValue = props[propName];
|
|
var propType = getPropType(propValue);
|
|
if (propType !== expectedType) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
// check, but we can offer a more precise error message here rather than
|
|
// 'of type `object`'.
|
|
var preciseType = getPreciseType(propValue);
|
|
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
|
|
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
|
|
);
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createAnyTypeChecker() {
|
|
return createChainableTypeChecker(emptyFunction.thatReturns());
|
|
}
|
|
|
|
function createArrayOfTypeChecker(typeChecker) {
|
|
function validate(props, propName, componentName, location) {
|
|
var propValue = props[propName];
|
|
if (!Array.isArray(propValue)) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
var propType = getPropType(propValue);
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
|
|
);
|
|
}
|
|
for (var i = 0; i < propValue.length; i++) {
|
|
var error = typeChecker(propValue, i, componentName, location);
|
|
if (error instanceof Error) {
|
|
return error;
|
|
}
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createElementTypeChecker() {
|
|
function validate(props, propName, componentName, location) {
|
|
if (!ReactElement.isValidElement(props[propName])) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
("`" + componentName + "`, expected a ReactElement.")
|
|
);
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createInstanceTypeChecker(expectedClass) {
|
|
function validate(props, propName, componentName, location) {
|
|
if (!(props[propName] instanceof expectedClass)) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
|
|
);
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createEnumTypeChecker(expectedValues) {
|
|
function validate(props, propName, componentName, location) {
|
|
var propValue = props[propName];
|
|
for (var i = 0; i < expectedValues.length; i++) {
|
|
if (propValue === expectedValues[i]) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
var valuesString = JSON.stringify(expectedValues);
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
|
|
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
|
|
);
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createObjectOfTypeChecker(typeChecker) {
|
|
function validate(props, propName, componentName, location) {
|
|
var propValue = props[propName];
|
|
var propType = getPropType(propValue);
|
|
if (propType !== 'object') {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
|
|
);
|
|
}
|
|
for (var key in propValue) {
|
|
if (propValue.hasOwnProperty(key)) {
|
|
var error = typeChecker(propValue, key, componentName, location);
|
|
if (error instanceof Error) {
|
|
return error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
function validate(props, propName, componentName, location) {
|
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
var checker = arrayOfTypeCheckers[i];
|
|
if (checker(props, propName, componentName, location) == null) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
("`" + componentName + "`.")
|
|
);
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createNodeChecker() {
|
|
function validate(props, propName, componentName, location) {
|
|
if (!isNode(props[propName])) {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
("`" + componentName + "`, expected a ReactNode.")
|
|
);
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate);
|
|
}
|
|
|
|
function createShapeTypeChecker(shapeTypes) {
|
|
function validate(props, propName, componentName, location) {
|
|
var propValue = props[propName];
|
|
var propType = getPropType(propValue);
|
|
if (propType !== 'object') {
|
|
var locationName = ReactPropTypeLocationNames[location];
|
|
return new Error(
|
|
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
|
|
("supplied to `" + componentName + "`, expected `object`.")
|
|
);
|
|
}
|
|
for (var key in shapeTypes) {
|
|
var checker = shapeTypes[key];
|
|
if (!checker) {
|
|
continue;
|
|
}
|
|
var error = checker(propValue, key, componentName, location);
|
|
if (error) {
|
|
return error;
|
|
}
|
|
}
|
|
}
|
|
return createChainableTypeChecker(validate, 'expected `object`');
|
|
}
|
|
|
|
function isNode(propValue) {
|
|
switch(typeof propValue) {
|
|
case 'number':
|
|
case 'string':
|
|
return true;
|
|
case 'boolean':
|
|
return !propValue;
|
|
case 'object':
|
|
if (Array.isArray(propValue)) {
|
|
return propValue.every(isNode);
|
|
}
|
|
if (ReactElement.isValidElement(propValue)) {
|
|
return true;
|
|
}
|
|
for (var k in propValue) {
|
|
if (!isNode(propValue[k])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
function getPropType(propValue) {
|
|
var propType = typeof propValue;
|
|
if (Array.isArray(propValue)) {
|
|
return 'array';
|
|
}
|
|
if (propValue instanceof RegExp) {
|
|
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
// passes PropTypes.object.
|
|
return 'object';
|
|
}
|
|
return propType;
|
|
}
|
|
|
|
// This handles more types than `getPropType`. Only used for error messages.
|
|
// See `createPrimitiveTypeChecker`.
|
|
function getPreciseType(propValue) {
|
|
var propType = getPropType(propValue);
|
|
if (propType === 'object') {
|
|
if (propValue instanceof Date) {
|
|
return 'date';
|
|
} else if (propValue instanceof RegExp) {
|
|
return 'regexp';
|
|
}
|
|
}
|
|
return propType;
|
|
}
|
|
|
|
module.exports = ReactPropTypes;
|
|
|
|
},{"./ReactElement":99,"./ReactPropTypeLocationNames":118,"./deprecated":162,"./emptyFunction":163}],121:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactPutListenerQueue
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var PooledClass = require("./PooledClass");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
function ReactPutListenerQueue() {
|
|
this.listenersToPut = [];
|
|
}
|
|
|
|
assign(ReactPutListenerQueue.prototype, {
|
|
enqueuePutListener: function(rootNodeID, propKey, propValue) {
|
|
this.listenersToPut.push({
|
|
rootNodeID: rootNodeID,
|
|
propKey: propKey,
|
|
propValue: propValue
|
|
});
|
|
},
|
|
|
|
putListeners: function() {
|
|
for (var i = 0; i < this.listenersToPut.length; i++) {
|
|
var listenerToPut = this.listenersToPut[i];
|
|
ReactBrowserEventEmitter.putListener(
|
|
listenerToPut.rootNodeID,
|
|
listenerToPut.propKey,
|
|
listenerToPut.propValue
|
|
);
|
|
}
|
|
},
|
|
|
|
reset: function() {
|
|
this.listenersToPut.length = 0;
|
|
},
|
|
|
|
destructor: function() {
|
|
this.reset();
|
|
}
|
|
});
|
|
|
|
PooledClass.addPoolingTo(ReactPutListenerQueue);
|
|
|
|
module.exports = ReactPutListenerQueue;
|
|
|
|
},{"./Object.assign":70,"./PooledClass":71,"./ReactBrowserEventEmitter":74}],122:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactReconcileTransaction
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var CallbackQueue = require("./CallbackQueue");
|
|
var PooledClass = require("./PooledClass");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
var ReactInputSelection = require("./ReactInputSelection");
|
|
var ReactPutListenerQueue = require("./ReactPutListenerQueue");
|
|
var Transaction = require("./Transaction");
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
/**
|
|
* Ensures that, when possible, the selection range (currently selected text
|
|
* input) is not disturbed by performing the transaction.
|
|
*/
|
|
var SELECTION_RESTORATION = {
|
|
/**
|
|
* @return {Selection} Selection information.
|
|
*/
|
|
initialize: ReactInputSelection.getSelectionInformation,
|
|
/**
|
|
* @param {Selection} sel Selection information returned from `initialize`.
|
|
*/
|
|
close: ReactInputSelection.restoreSelection
|
|
};
|
|
|
|
/**
|
|
* Suppresses events (blur/focus) that could be inadvertently dispatched due to
|
|
* high level DOM manipulations (like temporarily removing a text input from the
|
|
* DOM).
|
|
*/
|
|
var EVENT_SUPPRESSION = {
|
|
/**
|
|
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
|
|
* the reconciliation.
|
|
*/
|
|
initialize: function() {
|
|
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
|
|
ReactBrowserEventEmitter.setEnabled(false);
|
|
return currentlyEnabled;
|
|
},
|
|
|
|
/**
|
|
* @param {boolean} previouslyEnabled Enabled status of
|
|
* `ReactBrowserEventEmitter` before the reconciliation occured. `close`
|
|
* restores the previous value.
|
|
*/
|
|
close: function(previouslyEnabled) {
|
|
ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Provides a queue for collecting `componentDidMount` and
|
|
* `componentDidUpdate` callbacks during the the transaction.
|
|
*/
|
|
var ON_DOM_READY_QUEUEING = {
|
|
/**
|
|
* Initializes the internal `onDOMReady` queue.
|
|
*/
|
|
initialize: function() {
|
|
this.reactMountReady.reset();
|
|
},
|
|
|
|
/**
|
|
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
|
|
*/
|
|
close: function() {
|
|
this.reactMountReady.notifyAll();
|
|
}
|
|
};
|
|
|
|
var PUT_LISTENER_QUEUEING = {
|
|
initialize: function() {
|
|
this.putListenerQueue.reset();
|
|
},
|
|
|
|
close: function() {
|
|
this.putListenerQueue.putListeners();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
* being member methods, but with an implied ordering while being isolated from
|
|
* each other.
|
|
*/
|
|
var TRANSACTION_WRAPPERS = [
|
|
PUT_LISTENER_QUEUEING,
|
|
SELECTION_RESTORATION,
|
|
EVENT_SUPPRESSION,
|
|
ON_DOM_READY_QUEUEING
|
|
];
|
|
|
|
/**
|
|
* Currently:
|
|
* - The order that these are listed in the transaction is critical:
|
|
* - Suppresses events.
|
|
* - Restores selection range.
|
|
*
|
|
* Future:
|
|
* - Restore document/overflow scroll positions that were unintentionally
|
|
* modified via DOM insertions above the top viewport boundary.
|
|
* - Implement/integrate with customized constraint based layout system and keep
|
|
* track of which dimensions must be remeasured.
|
|
*
|
|
* @class ReactReconcileTransaction
|
|
*/
|
|
function ReactReconcileTransaction() {
|
|
this.reinitializeTransaction();
|
|
// Only server-side rendering really needs this option (see
|
|
// `ReactServerRendering`), but server-side uses
|
|
// `ReactServerRenderingTransaction` instead. This option is here so that it's
|
|
// accessible and defaults to false when `ReactDOMComponent` and
|
|
// `ReactTextComponent` checks it in `mountComponent`.`
|
|
this.renderToStaticMarkup = false;
|
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
this.putListenerQueue = ReactPutListenerQueue.getPooled();
|
|
}
|
|
|
|
var Mixin = {
|
|
/**
|
|
* @see Transaction
|
|
* @abstract
|
|
* @final
|
|
* @return {array<object>} List of operation wrap proceedures.
|
|
* TODO: convert to array<TransactionWrapper>
|
|
*/
|
|
getTransactionWrappers: function() {
|
|
return TRANSACTION_WRAPPERS;
|
|
},
|
|
|
|
/**
|
|
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
*/
|
|
getReactMountReady: function() {
|
|
return this.reactMountReady;
|
|
},
|
|
|
|
getPutListenerQueue: function() {
|
|
return this.putListenerQueue;
|
|
},
|
|
|
|
/**
|
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
* instance to be resused.
|
|
*/
|
|
destructor: function() {
|
|
CallbackQueue.release(this.reactMountReady);
|
|
this.reactMountReady = null;
|
|
|
|
ReactPutListenerQueue.release(this.putListenerQueue);
|
|
this.putListenerQueue = null;
|
|
}
|
|
};
|
|
|
|
|
|
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
|
|
|
PooledClass.addPoolingTo(ReactReconcileTransaction);
|
|
|
|
module.exports = ReactReconcileTransaction;
|
|
|
|
},{"./CallbackQueue":48,"./Object.assign":70,"./PooledClass":71,"./ReactBrowserEventEmitter":74,"./ReactInputSelection":106,"./ReactPutListenerQueue":121,"./Transaction":149}],123:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactRootIndex
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactRootIndexInjection = {
|
|
/**
|
|
* @param {function} _createReactRootIndex
|
|
*/
|
|
injectCreateReactRootIndex: function(_createReactRootIndex) {
|
|
ReactRootIndex.createReactRootIndex = _createReactRootIndex;
|
|
}
|
|
};
|
|
|
|
var ReactRootIndex = {
|
|
createReactRootIndex: null,
|
|
injection: ReactRootIndexInjection
|
|
};
|
|
|
|
module.exports = ReactRootIndex;
|
|
|
|
},{}],124:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @typechecks static-only
|
|
* @providesModule ReactServerRendering
|
|
*/
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
var ReactMarkupChecksum = require("./ReactMarkupChecksum");
|
|
var ReactServerRenderingTransaction =
|
|
require("./ReactServerRenderingTransaction");
|
|
|
|
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* @param {ReactElement} element
|
|
* @return {string} the HTML markup
|
|
*/
|
|
function renderToString(element) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactElement.isValidElement(element),
|
|
'renderToString(): You must pass a valid ReactElement.'
|
|
) : invariant(ReactElement.isValidElement(element)));
|
|
|
|
var transaction;
|
|
try {
|
|
var id = ReactInstanceHandles.createReactRootID();
|
|
transaction = ReactServerRenderingTransaction.getPooled(false);
|
|
|
|
return transaction.perform(function() {
|
|
var componentInstance = instantiateReactComponent(element, null);
|
|
var markup = componentInstance.mountComponent(id, transaction, 0);
|
|
return ReactMarkupChecksum.addChecksumToMarkup(markup);
|
|
}, null);
|
|
} finally {
|
|
ReactServerRenderingTransaction.release(transaction);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {ReactElement} element
|
|
* @return {string} the HTML markup, without the extra React ID and checksum
|
|
* (for generating static pages)
|
|
*/
|
|
function renderToStaticMarkup(element) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactElement.isValidElement(element),
|
|
'renderToStaticMarkup(): You must pass a valid ReactElement.'
|
|
) : invariant(ReactElement.isValidElement(element)));
|
|
|
|
var transaction;
|
|
try {
|
|
var id = ReactInstanceHandles.createReactRootID();
|
|
transaction = ReactServerRenderingTransaction.getPooled(true);
|
|
|
|
return transaction.perform(function() {
|
|
var componentInstance = instantiateReactComponent(element, null);
|
|
return componentInstance.mountComponent(id, transaction, 0);
|
|
}, null);
|
|
} finally {
|
|
ReactServerRenderingTransaction.release(transaction);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
renderToString: renderToString,
|
|
renderToStaticMarkup: renderToStaticMarkup
|
|
};
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./ReactInstanceHandles":107,"./ReactMarkupChecksum":110,"./ReactServerRenderingTransaction":125,"./instantiateReactComponent":181,"./invariant":182,"_process":1}],125:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactServerRenderingTransaction
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var PooledClass = require("./PooledClass");
|
|
var CallbackQueue = require("./CallbackQueue");
|
|
var ReactPutListenerQueue = require("./ReactPutListenerQueue");
|
|
var Transaction = require("./Transaction");
|
|
|
|
var assign = require("./Object.assign");
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
/**
|
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
|
|
* during the performing of the transaction.
|
|
*/
|
|
var ON_DOM_READY_QUEUEING = {
|
|
/**
|
|
* Initializes the internal `onDOMReady` queue.
|
|
*/
|
|
initialize: function() {
|
|
this.reactMountReady.reset();
|
|
},
|
|
|
|
close: emptyFunction
|
|
};
|
|
|
|
var PUT_LISTENER_QUEUEING = {
|
|
initialize: function() {
|
|
this.putListenerQueue.reset();
|
|
},
|
|
|
|
close: emptyFunction
|
|
};
|
|
|
|
/**
|
|
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
* being member methods, but with an implied ordering while being isolated from
|
|
* each other.
|
|
*/
|
|
var TRANSACTION_WRAPPERS = [
|
|
PUT_LISTENER_QUEUEING,
|
|
ON_DOM_READY_QUEUEING
|
|
];
|
|
|
|
/**
|
|
* @class ReactServerRenderingTransaction
|
|
* @param {boolean} renderToStaticMarkup
|
|
*/
|
|
function ReactServerRenderingTransaction(renderToStaticMarkup) {
|
|
this.reinitializeTransaction();
|
|
this.renderToStaticMarkup = renderToStaticMarkup;
|
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
this.putListenerQueue = ReactPutListenerQueue.getPooled();
|
|
}
|
|
|
|
var Mixin = {
|
|
/**
|
|
* @see Transaction
|
|
* @abstract
|
|
* @final
|
|
* @return {array} Empty list of operation wrap proceedures.
|
|
*/
|
|
getTransactionWrappers: function() {
|
|
return TRANSACTION_WRAPPERS;
|
|
},
|
|
|
|
/**
|
|
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
*/
|
|
getReactMountReady: function() {
|
|
return this.reactMountReady;
|
|
},
|
|
|
|
getPutListenerQueue: function() {
|
|
return this.putListenerQueue;
|
|
},
|
|
|
|
/**
|
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
* instance to be resused.
|
|
*/
|
|
destructor: function() {
|
|
CallbackQueue.release(this.reactMountReady);
|
|
this.reactMountReady = null;
|
|
|
|
ReactPutListenerQueue.release(this.putListenerQueue);
|
|
this.putListenerQueue = null;
|
|
}
|
|
};
|
|
|
|
|
|
assign(
|
|
ReactServerRenderingTransaction.prototype,
|
|
Transaction.Mixin,
|
|
Mixin
|
|
);
|
|
|
|
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
|
|
|
|
module.exports = ReactServerRenderingTransaction;
|
|
|
|
},{"./CallbackQueue":48,"./Object.assign":70,"./PooledClass":71,"./ReactPutListenerQueue":121,"./Transaction":149,"./emptyFunction":163}],126:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactStateSetters
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactStateSetters = {
|
|
/**
|
|
* Returns a function that calls the provided function, and uses the result
|
|
* of that to set the component's state.
|
|
*
|
|
* @param {ReactCompositeComponent} component
|
|
* @param {function} funcReturningState Returned callback uses this to
|
|
* determine how to update state.
|
|
* @return {function} callback that when invoked uses funcReturningState to
|
|
* determined the object literal to setState.
|
|
*/
|
|
createStateSetter: function(component, funcReturningState) {
|
|
return function(a, b, c, d, e, f) {
|
|
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
|
|
if (partialState) {
|
|
component.setState(partialState);
|
|
}
|
|
};
|
|
},
|
|
|
|
/**
|
|
* Returns a single-argument callback that can be used to update a single
|
|
* key in the component's state.
|
|
*
|
|
* Note: this is memoized function, which makes it inexpensive to call.
|
|
*
|
|
* @param {ReactCompositeComponent} component
|
|
* @param {string} key The key in the state that you should update.
|
|
* @return {function} callback of 1 argument which calls setState() with
|
|
* the provided keyName and callback argument.
|
|
*/
|
|
createStateKeySetter: function(component, key) {
|
|
// Memoize the setters.
|
|
var cache = component.__keySetters || (component.__keySetters = {});
|
|
return cache[key] || (cache[key] = createStateKeySetter(component, key));
|
|
}
|
|
};
|
|
|
|
function createStateKeySetter(component, key) {
|
|
// Partial state is allocated outside of the function closure so it can be
|
|
// reused with every call, avoiding memory allocation when this function
|
|
// is called.
|
|
var partialState = {};
|
|
return function stateKeySetter(value) {
|
|
partialState[key] = value;
|
|
component.setState(partialState);
|
|
};
|
|
}
|
|
|
|
ReactStateSetters.Mixin = {
|
|
/**
|
|
* Returns a function that calls the provided function, and uses the result
|
|
* of that to set the component's state.
|
|
*
|
|
* For example, these statements are equivalent:
|
|
*
|
|
* this.setState({x: 1});
|
|
* this.createStateSetter(function(xValue) {
|
|
* return {x: xValue};
|
|
* })(1);
|
|
*
|
|
* @param {function} funcReturningState Returned callback uses this to
|
|
* determine how to update state.
|
|
* @return {function} callback that when invoked uses funcReturningState to
|
|
* determined the object literal to setState.
|
|
*/
|
|
createStateSetter: function(funcReturningState) {
|
|
return ReactStateSetters.createStateSetter(this, funcReturningState);
|
|
},
|
|
|
|
/**
|
|
* Returns a single-argument callback that can be used to update a single
|
|
* key in the component's state.
|
|
*
|
|
* For example, these statements are equivalent:
|
|
*
|
|
* this.setState({x: 1});
|
|
* this.createStateKeySetter('x')(1);
|
|
*
|
|
* Note: this is memoized function, which makes it inexpensive to call.
|
|
*
|
|
* @param {string} key The key in the state that you should update.
|
|
* @return {function} callback of 1 argument which calls setState() with
|
|
* the provided keyName and callback argument.
|
|
*/
|
|
createStateKeySetter: function(key) {
|
|
return ReactStateSetters.createStateKeySetter(this, key);
|
|
}
|
|
};
|
|
|
|
module.exports = ReactStateSetters;
|
|
|
|
},{}],127:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactTestUtils
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPluginHub = require("./EventPluginHub");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var React = require("./React");
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
var ReactMount = require("./ReactMount");
|
|
var ReactTextComponent = require("./ReactTextComponent");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
var assign = require("./Object.assign");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
function Event(suffix) {}
|
|
|
|
/**
|
|
* @class ReactTestUtils
|
|
*/
|
|
|
|
/**
|
|
* Todo: Support the entire DOM.scry query syntax. For now, these simple
|
|
* utilities will suffice for testing purposes.
|
|
* @lends ReactTestUtils
|
|
*/
|
|
var ReactTestUtils = {
|
|
renderIntoDocument: function(instance) {
|
|
var div = document.createElement('div');
|
|
// None of our tests actually require attaching the container to the
|
|
// DOM, and doing so creates a mess that we rely on test isolation to
|
|
// clean up, so we're going to stop honoring the name of this method
|
|
// (and probably rename it eventually) if no problems arise.
|
|
// document.documentElement.appendChild(div);
|
|
return React.render(instance, div);
|
|
},
|
|
|
|
isElement: function(element) {
|
|
return ReactElement.isValidElement(element);
|
|
},
|
|
|
|
isElementOfType: function(inst, convenienceConstructor) {
|
|
return (
|
|
ReactElement.isValidElement(inst) &&
|
|
inst.type === convenienceConstructor.type
|
|
);
|
|
},
|
|
|
|
isDOMComponent: function(inst) {
|
|
return !!(inst && inst.mountComponent && inst.tagName);
|
|
},
|
|
|
|
isDOMComponentElement: function(inst) {
|
|
return !!(inst &&
|
|
ReactElement.isValidElement(inst) &&
|
|
!!inst.tagName);
|
|
},
|
|
|
|
isCompositeComponent: function(inst) {
|
|
return typeof inst.render === 'function' &&
|
|
typeof inst.setState === 'function';
|
|
},
|
|
|
|
isCompositeComponentWithType: function(inst, type) {
|
|
return !!(ReactTestUtils.isCompositeComponent(inst) &&
|
|
(inst.constructor === type.type));
|
|
},
|
|
|
|
isCompositeComponentElement: function(inst) {
|
|
if (!ReactElement.isValidElement(inst)) {
|
|
return false;
|
|
}
|
|
// We check the prototype of the type that will get mounted, not the
|
|
// instance itself. This is a future proof way of duck typing.
|
|
var prototype = inst.type.prototype;
|
|
return (
|
|
typeof prototype.render === 'function' &&
|
|
typeof prototype.setState === 'function'
|
|
);
|
|
},
|
|
|
|
isCompositeComponentElementWithType: function(inst, type) {
|
|
return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
|
|
(inst.constructor === type));
|
|
},
|
|
|
|
isTextComponent: function(inst) {
|
|
return inst instanceof ReactTextComponent.type;
|
|
},
|
|
|
|
findAllInRenderedTree: function(inst, test) {
|
|
if (!inst) {
|
|
return [];
|
|
}
|
|
var ret = test(inst) ? [inst] : [];
|
|
if (ReactTestUtils.isDOMComponent(inst)) {
|
|
var renderedChildren = inst._renderedChildren;
|
|
var key;
|
|
for (key in renderedChildren) {
|
|
if (!renderedChildren.hasOwnProperty(key)) {
|
|
continue;
|
|
}
|
|
ret = ret.concat(
|
|
ReactTestUtils.findAllInRenderedTree(renderedChildren[key], test)
|
|
);
|
|
}
|
|
} else if (ReactTestUtils.isCompositeComponent(inst)) {
|
|
ret = ret.concat(
|
|
ReactTestUtils.findAllInRenderedTree(inst._renderedComponent, test)
|
|
);
|
|
}
|
|
return ret;
|
|
},
|
|
|
|
/**
|
|
* Finds all instance of components in the rendered tree that are DOM
|
|
* components with the class name matching `className`.
|
|
* @return an array of all the matches.
|
|
*/
|
|
scryRenderedDOMComponentsWithClass: function(root, className) {
|
|
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
|
|
var instClassName = inst.props.className;
|
|
return ReactTestUtils.isDOMComponent(inst) && (
|
|
instClassName &&
|
|
(' ' + instClassName + ' ').indexOf(' ' + className + ' ') !== -1
|
|
);
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Like scryRenderedDOMComponentsWithClass but expects there to be one result,
|
|
* and returns that one result, or throws exception if there is any other
|
|
* number of matches besides one.
|
|
* @return {!ReactDOMComponent} The one match.
|
|
*/
|
|
findRenderedDOMComponentWithClass: function(root, className) {
|
|
var all =
|
|
ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
|
|
if (all.length !== 1) {
|
|
throw new Error('Did not find exactly one match for class:' + className);
|
|
}
|
|
return all[0];
|
|
},
|
|
|
|
|
|
/**
|
|
* Finds all instance of components in the rendered tree that are DOM
|
|
* components with the tag name matching `tagName`.
|
|
* @return an array of all the matches.
|
|
*/
|
|
scryRenderedDOMComponentsWithTag: function(root, tagName) {
|
|
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
|
|
return ReactTestUtils.isDOMComponent(inst) &&
|
|
inst.tagName === tagName.toUpperCase();
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Like scryRenderedDOMComponentsWithTag but expects there to be one result,
|
|
* and returns that one result, or throws exception if there is any other
|
|
* number of matches besides one.
|
|
* @return {!ReactDOMComponent} The one match.
|
|
*/
|
|
findRenderedDOMComponentWithTag: function(root, tagName) {
|
|
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
|
|
if (all.length !== 1) {
|
|
throw new Error('Did not find exactly one match for tag:' + tagName);
|
|
}
|
|
return all[0];
|
|
},
|
|
|
|
|
|
/**
|
|
* Finds all instances of components with type equal to `componentType`.
|
|
* @return an array of all the matches.
|
|
*/
|
|
scryRenderedComponentsWithType: function(root, componentType) {
|
|
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
|
|
return ReactTestUtils.isCompositeComponentWithType(
|
|
inst,
|
|
componentType
|
|
);
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Same as `scryRenderedComponentsWithType` but expects there to be one result
|
|
* and returns that one result, or throws exception if there is any other
|
|
* number of matches besides one.
|
|
* @return {!ReactComponent} The one match.
|
|
*/
|
|
findRenderedComponentWithType: function(root, componentType) {
|
|
var all = ReactTestUtils.scryRenderedComponentsWithType(
|
|
root,
|
|
componentType
|
|
);
|
|
if (all.length !== 1) {
|
|
throw new Error(
|
|
'Did not find exactly one match for componentType:' + componentType
|
|
);
|
|
}
|
|
return all[0];
|
|
},
|
|
|
|
/**
|
|
* Pass a mocked component module to this method to augment it with
|
|
* useful methods that allow it to be used as a dummy React component.
|
|
* Instead of rendering as usual, the component will become a simple
|
|
* <div> containing any provided children.
|
|
*
|
|
* @param {object} module the mock function object exported from a
|
|
* module that defines the component to be mocked
|
|
* @param {?string} mockTagName optional dummy root tag name to return
|
|
* from render method (overrides
|
|
* module.mockTagName if provided)
|
|
* @return {object} the ReactTestUtils object (for chaining)
|
|
*/
|
|
mockComponent: function(module, mockTagName) {
|
|
mockTagName = mockTagName || module.mockTagName || "div";
|
|
|
|
var ConvenienceConstructor = React.createClass({displayName: "ConvenienceConstructor",
|
|
render: function() {
|
|
return React.createElement(
|
|
mockTagName,
|
|
null,
|
|
this.props.children
|
|
);
|
|
}
|
|
});
|
|
|
|
module.mockImplementation(ConvenienceConstructor);
|
|
|
|
module.type = ConvenienceConstructor.type;
|
|
module.isReactLegacyFactory = true;
|
|
|
|
return this;
|
|
},
|
|
|
|
/**
|
|
* Simulates a top level event being dispatched from a raw event that occured
|
|
* on an `Element` node.
|
|
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`
|
|
* @param {!Element} node The dom to simulate an event occurring on.
|
|
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
|
*/
|
|
simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) {
|
|
fakeNativeEvent.target = node;
|
|
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(
|
|
topLevelType,
|
|
fakeNativeEvent
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Simulates a top level event being dispatched from a raw event that occured
|
|
* on the `ReactDOMComponent` `comp`.
|
|
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`.
|
|
* @param comp {!ReactDOMComponent}
|
|
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
|
*/
|
|
simulateNativeEventOnDOMComponent: function(
|
|
topLevelType,
|
|
comp,
|
|
fakeNativeEvent) {
|
|
ReactTestUtils.simulateNativeEventOnNode(
|
|
topLevelType,
|
|
comp.getDOMNode(),
|
|
fakeNativeEvent
|
|
);
|
|
},
|
|
|
|
nativeTouchData: function(x, y) {
|
|
return {
|
|
touches: [
|
|
{pageX: x, pageY: y}
|
|
]
|
|
};
|
|
},
|
|
|
|
Simulate: null,
|
|
SimulateNative: {}
|
|
};
|
|
|
|
/**
|
|
* Exports:
|
|
*
|
|
* - `ReactTestUtils.Simulate.click(Element/ReactDOMComponent)`
|
|
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactDOMComponent)`
|
|
* - `ReactTestUtils.Simulate.change(Element/ReactDOMComponent)`
|
|
* - ... (All keys from event plugin `eventTypes` objects)
|
|
*/
|
|
function makeSimulator(eventType) {
|
|
return function(domComponentOrNode, eventData) {
|
|
var node;
|
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
node = domComponentOrNode.getDOMNode();
|
|
} else if (domComponentOrNode.tagName) {
|
|
node = domComponentOrNode;
|
|
}
|
|
|
|
var fakeNativeEvent = new Event();
|
|
fakeNativeEvent.target = node;
|
|
// We don't use SyntheticEvent.getPooled in order to not have to worry about
|
|
// properly destroying any properties assigned from `eventData` upon release
|
|
var event = new SyntheticEvent(
|
|
ReactBrowserEventEmitter.eventNameDispatchConfigs[eventType],
|
|
ReactMount.getID(node),
|
|
fakeNativeEvent
|
|
);
|
|
assign(event, eventData);
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
|
|
ReactUpdates.batchedUpdates(function() {
|
|
EventPluginHub.enqueueEvents(event);
|
|
EventPluginHub.processEventQueue();
|
|
});
|
|
};
|
|
}
|
|
|
|
function buildSimulators() {
|
|
ReactTestUtils.Simulate = {};
|
|
|
|
var eventType;
|
|
for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
|
|
/**
|
|
* @param {!Element || ReactDOMComponent} domComponentOrNode
|
|
* @param {?object} eventData Fake event data to use in SyntheticEvent.
|
|
*/
|
|
ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
|
|
}
|
|
}
|
|
|
|
// Rebuild ReactTestUtils.Simulate whenever event plugins are injected
|
|
var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
|
|
EventPluginHub.injection.injectEventPluginOrder = function() {
|
|
oldInjectEventPluginOrder.apply(this, arguments);
|
|
buildSimulators();
|
|
};
|
|
var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
|
|
EventPluginHub.injection.injectEventPluginsByName = function() {
|
|
oldInjectEventPlugins.apply(this, arguments);
|
|
buildSimulators();
|
|
};
|
|
|
|
buildSimulators();
|
|
|
|
/**
|
|
* Exports:
|
|
*
|
|
* - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
|
|
* - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
|
|
* - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
|
|
* - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
|
|
* - ... (All keys from `EventConstants.topLevelTypes`)
|
|
*
|
|
* Note: Top level event types are a subset of the entire set of handler types
|
|
* (which include a broader set of "synthetic" events). For example, onDragDone
|
|
* is a synthetic event. Except when testing an event plugin or React's event
|
|
* handling code specifically, you probably want to use ReactTestUtils.Simulate
|
|
* to dispatch synthetic events.
|
|
*/
|
|
|
|
function makeNativeSimulator(eventType) {
|
|
return function(domComponentOrNode, nativeEventData) {
|
|
var fakeNativeEvent = new Event(eventType);
|
|
assign(fakeNativeEvent, nativeEventData);
|
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
ReactTestUtils.simulateNativeEventOnDOMComponent(
|
|
eventType,
|
|
domComponentOrNode,
|
|
fakeNativeEvent
|
|
);
|
|
} else if (!!domComponentOrNode.tagName) {
|
|
// Will allow on actual dom nodes.
|
|
ReactTestUtils.simulateNativeEventOnNode(
|
|
eventType,
|
|
domComponentOrNode,
|
|
fakeNativeEvent
|
|
);
|
|
}
|
|
};
|
|
}
|
|
|
|
var eventType;
|
|
for (eventType in topLevelTypes) {
|
|
// Event type is stored as 'topClick' - we transform that to 'click'
|
|
var convenienceName = eventType.indexOf('top') === 0 ?
|
|
eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
|
|
/**
|
|
* @param {!Element || ReactDOMComponent} domComponentOrNode
|
|
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
|
*/
|
|
ReactTestUtils.SimulateNative[convenienceName] =
|
|
makeNativeSimulator(eventType);
|
|
}
|
|
|
|
module.exports = ReactTestUtils;
|
|
|
|
},{"./EventConstants":58,"./EventPluginHub":60,"./EventPropagators":63,"./Object.assign":70,"./React":72,"./ReactBrowserEventEmitter":74,"./ReactElement":99,"./ReactMount":111,"./ReactTextComponent":128,"./ReactUpdates":132,"./SyntheticEvent":141}],128:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactTextComponent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
var ReactComponent = require("./ReactComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
|
|
var assign = require("./Object.assign");
|
|
var escapeTextForBrowser = require("./escapeTextForBrowser");
|
|
|
|
/**
|
|
* Text nodes violate a couple assumptions that React makes about components:
|
|
*
|
|
* - When mounting text into the DOM, adjacent text nodes are merged.
|
|
* - Text nodes cannot be assigned a React root ID.
|
|
*
|
|
* This component is used to wrap strings in elements so that they can undergo
|
|
* the same reconciliation that is applied to elements.
|
|
*
|
|
* TODO: Investigate representing React components in the DOM with text nodes.
|
|
*
|
|
* @class ReactTextComponent
|
|
* @extends ReactComponent
|
|
* @internal
|
|
*/
|
|
var ReactTextComponent = function(props) {
|
|
// This constructor and it's argument is currently used by mocks.
|
|
};
|
|
|
|
assign(ReactTextComponent.prototype, ReactComponent.Mixin, {
|
|
|
|
/**
|
|
* Creates the markup for this text node. This node is not intended to have
|
|
* any features besides containing text content.
|
|
*
|
|
* @param {string} rootID DOM ID of the root node.
|
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
* @param {number} mountDepth number of components in the owner hierarchy
|
|
* @return {string} Markup for this text node.
|
|
* @internal
|
|
*/
|
|
mountComponent: function(rootID, transaction, mountDepth) {
|
|
ReactComponent.Mixin.mountComponent.call(
|
|
this,
|
|
rootID,
|
|
transaction,
|
|
mountDepth
|
|
);
|
|
|
|
var escapedText = escapeTextForBrowser(this.props);
|
|
|
|
if (transaction.renderToStaticMarkup) {
|
|
// Normally we'd wrap this in a `span` for the reasons stated above, but
|
|
// since this is a situation where React won't take over (static pages),
|
|
// we can simply return the text as it is.
|
|
return escapedText;
|
|
}
|
|
|
|
return (
|
|
'<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
|
|
escapedText +
|
|
'</span>'
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Updates this component by updating the text content.
|
|
*
|
|
* @param {object} nextComponent Contains the next text content.
|
|
* @param {ReactReconcileTransaction} transaction
|
|
* @internal
|
|
*/
|
|
receiveComponent: function(nextComponent, transaction) {
|
|
var nextProps = nextComponent.props;
|
|
if (nextProps !== this.props) {
|
|
this.props = nextProps;
|
|
ReactComponent.BackendIDOperations.updateTextContentByID(
|
|
this._rootNodeID,
|
|
nextProps
|
|
);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
var ReactTextComponentFactory = function(text) {
|
|
// Bypass validation and configuration
|
|
return new ReactElement(ReactTextComponent, null, null, null, null, text);
|
|
};
|
|
|
|
ReactTextComponentFactory.type = ReactTextComponent;
|
|
|
|
module.exports = ReactTextComponentFactory;
|
|
|
|
},{"./DOMPropertyOperations":54,"./Object.assign":70,"./ReactComponent":78,"./ReactElement":99,"./escapeTextForBrowser":165}],129:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @typechecks static-only
|
|
* @providesModule ReactTransitionChildMapping
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactChildren = require("./ReactChildren");
|
|
|
|
var ReactTransitionChildMapping = {
|
|
/**
|
|
* Given `this.props.children`, return an object mapping key to child. Just
|
|
* simple syntactic sugar around ReactChildren.map().
|
|
*
|
|
* @param {*} children `this.props.children`
|
|
* @return {object} Mapping of key to child
|
|
*/
|
|
getChildMapping: function(children) {
|
|
return ReactChildren.map(children, function(child) {
|
|
return child;
|
|
});
|
|
},
|
|
|
|
/**
|
|
* When you're adding or removing children some may be added or removed in the
|
|
* same render pass. We want to show *both* since we want to simultaneously
|
|
* animate elements in and out. This function takes a previous set of keys
|
|
* and a new set of keys and merges them with its best guess of the correct
|
|
* ordering. In the future we may expose some of the utilities in
|
|
* ReactMultiChild to make this easy, but for now React itself does not
|
|
* directly have this concept of the union of prevChildren and nextChildren
|
|
* so we implement it here.
|
|
*
|
|
* @param {object} prev prev children as returned from
|
|
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
* @param {object} next next children as returned from
|
|
* `ReactTransitionChildMapping.getChildMapping()`.
|
|
* @return {object} a key set that contains all keys in `prev` and all keys
|
|
* in `next` in a reasonable order.
|
|
*/
|
|
mergeChildMappings: function(prev, next) {
|
|
prev = prev || {};
|
|
next = next || {};
|
|
|
|
function getValueForKey(key) {
|
|
if (next.hasOwnProperty(key)) {
|
|
return next[key];
|
|
} else {
|
|
return prev[key];
|
|
}
|
|
}
|
|
|
|
// For each key of `next`, the list of keys to insert before that key in
|
|
// the combined list
|
|
var nextKeysPending = {};
|
|
|
|
var pendingKeys = [];
|
|
for (var prevKey in prev) {
|
|
if (next.hasOwnProperty(prevKey)) {
|
|
if (pendingKeys.length) {
|
|
nextKeysPending[prevKey] = pendingKeys;
|
|
pendingKeys = [];
|
|
}
|
|
} else {
|
|
pendingKeys.push(prevKey);
|
|
}
|
|
}
|
|
|
|
var i;
|
|
var childMapping = {};
|
|
for (var nextKey in next) {
|
|
if (nextKeysPending.hasOwnProperty(nextKey)) {
|
|
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
|
|
var pendingNextKey = nextKeysPending[nextKey][i];
|
|
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
|
|
pendingNextKey
|
|
);
|
|
}
|
|
}
|
|
childMapping[nextKey] = getValueForKey(nextKey);
|
|
}
|
|
|
|
// Finally, add the keys which didn't appear before any key in `next`
|
|
for (i = 0; i < pendingKeys.length; i++) {
|
|
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
|
|
}
|
|
|
|
return childMapping;
|
|
}
|
|
};
|
|
|
|
module.exports = ReactTransitionChildMapping;
|
|
|
|
},{"./ReactChildren":77}],130:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactTransitionEvents
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
/**
|
|
* EVENT_NAME_MAP is used to determine which event fired when a
|
|
* transition/animation ends, based on the style property used to
|
|
* define that event.
|
|
*/
|
|
var EVENT_NAME_MAP = {
|
|
transitionend: {
|
|
'transition': 'transitionend',
|
|
'WebkitTransition': 'webkitTransitionEnd',
|
|
'MozTransition': 'mozTransitionEnd',
|
|
'OTransition': 'oTransitionEnd',
|
|
'msTransition': 'MSTransitionEnd'
|
|
},
|
|
|
|
animationend: {
|
|
'animation': 'animationend',
|
|
'WebkitAnimation': 'webkitAnimationEnd',
|
|
'MozAnimation': 'mozAnimationEnd',
|
|
'OAnimation': 'oAnimationEnd',
|
|
'msAnimation': 'MSAnimationEnd'
|
|
}
|
|
};
|
|
|
|
var endEvents = [];
|
|
|
|
function detectEvents() {
|
|
var testEl = document.createElement('div');
|
|
var style = testEl.style;
|
|
|
|
// On some platforms, in particular some releases of Android 4.x,
|
|
// the un-prefixed "animation" and "transition" properties are defined on the
|
|
// style object but the events that fire will still be prefixed, so we need
|
|
// to check if the un-prefixed events are useable, and if not remove them
|
|
// from the map
|
|
if (!('AnimationEvent' in window)) {
|
|
delete EVENT_NAME_MAP.animationend.animation;
|
|
}
|
|
|
|
if (!('TransitionEvent' in window)) {
|
|
delete EVENT_NAME_MAP.transitionend.transition;
|
|
}
|
|
|
|
for (var baseEventName in EVENT_NAME_MAP) {
|
|
var baseEvents = EVENT_NAME_MAP[baseEventName];
|
|
for (var styleName in baseEvents) {
|
|
if (styleName in style) {
|
|
endEvents.push(baseEvents[styleName]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
detectEvents();
|
|
}
|
|
|
|
// We use the raw {add|remove}EventListener() call because EventListener
|
|
// does not know how to remove event listeners and we really should
|
|
// clean up. Also, these events are not triggered in older browsers
|
|
// so we should be A-OK here.
|
|
|
|
function addEventListener(node, eventName, eventListener) {
|
|
node.addEventListener(eventName, eventListener, false);
|
|
}
|
|
|
|
function removeEventListener(node, eventName, eventListener) {
|
|
node.removeEventListener(eventName, eventListener, false);
|
|
}
|
|
|
|
var ReactTransitionEvents = {
|
|
addEndEventListener: function(node, eventListener) {
|
|
if (endEvents.length === 0) {
|
|
// If CSS transitions are not supported, trigger an "end animation"
|
|
// event immediately.
|
|
window.setTimeout(eventListener, 0);
|
|
return;
|
|
}
|
|
endEvents.forEach(function(endEvent) {
|
|
addEventListener(node, endEvent, eventListener);
|
|
});
|
|
},
|
|
|
|
removeEndEventListener: function(node, eventListener) {
|
|
if (endEvents.length === 0) {
|
|
return;
|
|
}
|
|
endEvents.forEach(function(endEvent) {
|
|
removeEventListener(node, endEvent, eventListener);
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = ReactTransitionEvents;
|
|
|
|
},{"./ExecutionEnvironment":64}],131:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactTransitionGroup
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var React = require("./React");
|
|
var ReactTransitionChildMapping = require("./ReactTransitionChildMapping");
|
|
|
|
var assign = require("./Object.assign");
|
|
var cloneWithProps = require("./cloneWithProps");
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
var ReactTransitionGroup = React.createClass({
|
|
displayName: 'ReactTransitionGroup',
|
|
|
|
propTypes: {
|
|
component: React.PropTypes.any,
|
|
childFactory: React.PropTypes.func
|
|
},
|
|
|
|
getDefaultProps: function() {
|
|
return {
|
|
component: 'span',
|
|
childFactory: emptyFunction.thatReturnsArgument
|
|
};
|
|
},
|
|
|
|
getInitialState: function() {
|
|
return {
|
|
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
|
|
};
|
|
},
|
|
|
|
componentWillReceiveProps: function(nextProps) {
|
|
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
nextProps.children
|
|
);
|
|
var prevChildMapping = this.state.children;
|
|
|
|
this.setState({
|
|
children: ReactTransitionChildMapping.mergeChildMappings(
|
|
prevChildMapping,
|
|
nextChildMapping
|
|
)
|
|
});
|
|
|
|
var key;
|
|
|
|
for (key in nextChildMapping) {
|
|
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
|
|
if (nextChildMapping[key] && !hasPrev &&
|
|
!this.currentlyTransitioningKeys[key]) {
|
|
this.keysToEnter.push(key);
|
|
}
|
|
}
|
|
|
|
for (key in prevChildMapping) {
|
|
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
|
|
if (prevChildMapping[key] && !hasNext &&
|
|
!this.currentlyTransitioningKeys[key]) {
|
|
this.keysToLeave.push(key);
|
|
}
|
|
}
|
|
|
|
// If we want to someday check for reordering, we could do it here.
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
this.currentlyTransitioningKeys = {};
|
|
this.keysToEnter = [];
|
|
this.keysToLeave = [];
|
|
},
|
|
|
|
componentDidUpdate: function() {
|
|
var keysToEnter = this.keysToEnter;
|
|
this.keysToEnter = [];
|
|
keysToEnter.forEach(this.performEnter);
|
|
|
|
var keysToLeave = this.keysToLeave;
|
|
this.keysToLeave = [];
|
|
keysToLeave.forEach(this.performLeave);
|
|
},
|
|
|
|
performEnter: function(key) {
|
|
this.currentlyTransitioningKeys[key] = true;
|
|
|
|
var component = this.refs[key];
|
|
|
|
if (component.componentWillEnter) {
|
|
component.componentWillEnter(
|
|
this._handleDoneEntering.bind(this, key)
|
|
);
|
|
} else {
|
|
this._handleDoneEntering(key);
|
|
}
|
|
},
|
|
|
|
_handleDoneEntering: function(key) {
|
|
var component = this.refs[key];
|
|
if (component.componentDidEnter) {
|
|
component.componentDidEnter();
|
|
}
|
|
|
|
delete this.currentlyTransitioningKeys[key];
|
|
|
|
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
this.props.children
|
|
);
|
|
|
|
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
|
|
// This was removed before it had fully entered. Remove it.
|
|
this.performLeave(key);
|
|
}
|
|
},
|
|
|
|
performLeave: function(key) {
|
|
this.currentlyTransitioningKeys[key] = true;
|
|
|
|
var component = this.refs[key];
|
|
if (component.componentWillLeave) {
|
|
component.componentWillLeave(this._handleDoneLeaving.bind(this, key));
|
|
} else {
|
|
// Note that this is somewhat dangerous b/c it calls setState()
|
|
// again, effectively mutating the component before all the work
|
|
// is done.
|
|
this._handleDoneLeaving(key);
|
|
}
|
|
},
|
|
|
|
_handleDoneLeaving: function(key) {
|
|
var component = this.refs[key];
|
|
|
|
if (component.componentDidLeave) {
|
|
component.componentDidLeave();
|
|
}
|
|
|
|
delete this.currentlyTransitioningKeys[key];
|
|
|
|
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
this.props.children
|
|
);
|
|
|
|
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
|
|
// This entered again before it fully left. Add it again.
|
|
this.performEnter(key);
|
|
} else {
|
|
var newChildren = assign({}, this.state.children);
|
|
delete newChildren[key];
|
|
this.setState({children: newChildren});
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
// TODO: we could get rid of the need for the wrapper node
|
|
// by cloning a single child
|
|
var childrenToRender = {};
|
|
for (var key in this.state.children) {
|
|
var child = this.state.children[key];
|
|
if (child) {
|
|
// You may need to apply reactive updates to a child as it is leaving.
|
|
// The normal React way to do it won't work since the child will have
|
|
// already been removed. In case you need this behavior you can provide
|
|
// a childFactory function to wrap every child, even the ones that are
|
|
// leaving.
|
|
childrenToRender[key] = cloneWithProps(
|
|
this.props.childFactory(child),
|
|
{ref: key}
|
|
);
|
|
}
|
|
}
|
|
return React.createElement(
|
|
this.props.component,
|
|
this.props,
|
|
childrenToRender
|
|
);
|
|
}
|
|
});
|
|
|
|
module.exports = ReactTransitionGroup;
|
|
|
|
},{"./Object.assign":70,"./React":72,"./ReactTransitionChildMapping":129,"./cloneWithProps":155,"./emptyFunction":163}],132:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactUpdates
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var CallbackQueue = require("./CallbackQueue");
|
|
var PooledClass = require("./PooledClass");
|
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
var ReactPerf = require("./ReactPerf");
|
|
var Transaction = require("./Transaction");
|
|
|
|
var assign = require("./Object.assign");
|
|
var invariant = require("./invariant");
|
|
var warning = require("./warning");
|
|
|
|
var dirtyComponents = [];
|
|
var asapCallbackQueue = CallbackQueue.getPooled();
|
|
var asapEnqueued = false;
|
|
|
|
var batchingStrategy = null;
|
|
|
|
function ensureInjected() {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactUpdates.ReactReconcileTransaction && batchingStrategy,
|
|
'ReactUpdates: must inject a reconcile transaction class and batching ' +
|
|
'strategy'
|
|
) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
|
|
}
|
|
|
|
var NESTED_UPDATES = {
|
|
initialize: function() {
|
|
this.dirtyComponentsLength = dirtyComponents.length;
|
|
},
|
|
close: function() {
|
|
if (this.dirtyComponentsLength !== dirtyComponents.length) {
|
|
// Additional updates were enqueued by componentDidUpdate handlers or
|
|
// similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
|
|
// these new updates so that if A's componentDidUpdate calls setState on
|
|
// B, B will update before the callback A's updater provided when calling
|
|
// setState.
|
|
dirtyComponents.splice(0, this.dirtyComponentsLength);
|
|
flushBatchedUpdates();
|
|
} else {
|
|
dirtyComponents.length = 0;
|
|
}
|
|
}
|
|
};
|
|
|
|
var UPDATE_QUEUEING = {
|
|
initialize: function() {
|
|
this.callbackQueue.reset();
|
|
},
|
|
close: function() {
|
|
this.callbackQueue.notifyAll();
|
|
}
|
|
};
|
|
|
|
var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
|
|
|
|
function ReactUpdatesFlushTransaction() {
|
|
this.reinitializeTransaction();
|
|
this.dirtyComponentsLength = null;
|
|
this.callbackQueue = CallbackQueue.getPooled();
|
|
this.reconcileTransaction =
|
|
ReactUpdates.ReactReconcileTransaction.getPooled();
|
|
}
|
|
|
|
assign(
|
|
ReactUpdatesFlushTransaction.prototype,
|
|
Transaction.Mixin, {
|
|
getTransactionWrappers: function() {
|
|
return TRANSACTION_WRAPPERS;
|
|
},
|
|
|
|
destructor: function() {
|
|
this.dirtyComponentsLength = null;
|
|
CallbackQueue.release(this.callbackQueue);
|
|
this.callbackQueue = null;
|
|
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
|
|
this.reconcileTransaction = null;
|
|
},
|
|
|
|
perform: function(method, scope, a) {
|
|
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
|
|
// with this transaction's wrappers around it.
|
|
return Transaction.Mixin.perform.call(
|
|
this,
|
|
this.reconcileTransaction.perform,
|
|
this.reconcileTransaction,
|
|
method,
|
|
scope,
|
|
a
|
|
);
|
|
}
|
|
});
|
|
|
|
PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
|
|
|
|
function batchedUpdates(callback, a, b) {
|
|
ensureInjected();
|
|
batchingStrategy.batchedUpdates(callback, a, b);
|
|
}
|
|
|
|
/**
|
|
* Array comparator for ReactComponents by owner depth
|
|
*
|
|
* @param {ReactComponent} c1 first component you're comparing
|
|
* @param {ReactComponent} c2 second component you're comparing
|
|
* @return {number} Return value usable by Array.prototype.sort().
|
|
*/
|
|
function mountDepthComparator(c1, c2) {
|
|
return c1._mountDepth - c2._mountDepth;
|
|
}
|
|
|
|
function runBatchedUpdates(transaction) {
|
|
var len = transaction.dirtyComponentsLength;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
len === dirtyComponents.length,
|
|
'Expected flush transaction\'s stored dirty-components length (%s) to ' +
|
|
'match dirty-components array length (%s).',
|
|
len,
|
|
dirtyComponents.length
|
|
) : invariant(len === dirtyComponents.length));
|
|
|
|
// Since reconciling a component higher in the owner hierarchy usually (not
|
|
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
|
|
// them before their children by sorting the array.
|
|
dirtyComponents.sort(mountDepthComparator);
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
// If a component is unmounted before pending changes apply, ignore them
|
|
// TODO: Queue unmounts in the same list to avoid this happening at all
|
|
var component = dirtyComponents[i];
|
|
if (component.isMounted()) {
|
|
// If performUpdateIfNecessary happens to enqueue any new updates, we
|
|
// shouldn't execute the callbacks until the next render happens, so
|
|
// stash the callbacks first
|
|
var callbacks = component._pendingCallbacks;
|
|
component._pendingCallbacks = null;
|
|
component.performUpdateIfNecessary(transaction.reconcileTransaction);
|
|
|
|
if (callbacks) {
|
|
for (var j = 0; j < callbacks.length; j++) {
|
|
transaction.callbackQueue.enqueue(
|
|
callbacks[j],
|
|
component
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var flushBatchedUpdates = ReactPerf.measure(
|
|
'ReactUpdates',
|
|
'flushBatchedUpdates',
|
|
function() {
|
|
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
|
|
// array and perform any updates enqueued by mount-ready handlers (i.e.,
|
|
// componentDidUpdate) but we need to check here too in order to catch
|
|
// updates enqueued by setState callbacks and asap calls.
|
|
while (dirtyComponents.length || asapEnqueued) {
|
|
if (dirtyComponents.length) {
|
|
var transaction = ReactUpdatesFlushTransaction.getPooled();
|
|
transaction.perform(runBatchedUpdates, null, transaction);
|
|
ReactUpdatesFlushTransaction.release(transaction);
|
|
}
|
|
|
|
if (asapEnqueued) {
|
|
asapEnqueued = false;
|
|
var queue = asapCallbackQueue;
|
|
asapCallbackQueue = CallbackQueue.getPooled();
|
|
queue.notifyAll();
|
|
CallbackQueue.release(queue);
|
|
}
|
|
}
|
|
}
|
|
);
|
|
|
|
/**
|
|
* Mark a component as needing a rerender, adding an optional callback to a
|
|
* list of functions which will be executed once the rerender occurs.
|
|
*/
|
|
function enqueueUpdate(component, callback) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!callback || typeof callback === "function",
|
|
'enqueueUpdate(...): You called `setProps`, `replaceProps`, ' +
|
|
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
|
|
'isn\'t callable.'
|
|
) : invariant(!callback || typeof callback === "function"));
|
|
ensureInjected();
|
|
|
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
// verify that that's the case. (This is called by each top-level update
|
|
// function, like setProps, setState, forceUpdate, etc.; creation and
|
|
// destruction of top-level components is guarded in ReactMount.)
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
ReactCurrentOwner.current == null,
|
|
'enqueueUpdate(): Render methods should be a pure function of props ' +
|
|
'and state; triggering nested component updates from render is not ' +
|
|
'allowed. If necessary, trigger nested updates in ' +
|
|
'componentDidUpdate.'
|
|
) : null);
|
|
|
|
if (!batchingStrategy.isBatchingUpdates) {
|
|
batchingStrategy.batchedUpdates(enqueueUpdate, component, callback);
|
|
return;
|
|
}
|
|
|
|
dirtyComponents.push(component);
|
|
|
|
if (callback) {
|
|
if (component._pendingCallbacks) {
|
|
component._pendingCallbacks.push(callback);
|
|
} else {
|
|
component._pendingCallbacks = [callback];
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Enqueue a callback to be run at the end of the current batching cycle. Throws
|
|
* if no updates are currently being performed.
|
|
*/
|
|
function asap(callback, context) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
batchingStrategy.isBatchingUpdates,
|
|
'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
|
|
'updates are not being batched.'
|
|
) : invariant(batchingStrategy.isBatchingUpdates));
|
|
asapCallbackQueue.enqueue(callback, context);
|
|
asapEnqueued = true;
|
|
}
|
|
|
|
var ReactUpdatesInjection = {
|
|
injectReconcileTransaction: function(ReconcileTransaction) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReconcileTransaction,
|
|
'ReactUpdates: must provide a reconcile transaction class'
|
|
) : invariant(ReconcileTransaction));
|
|
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
|
|
},
|
|
|
|
injectBatchingStrategy: function(_batchingStrategy) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
_batchingStrategy,
|
|
'ReactUpdates: must provide a batching strategy'
|
|
) : invariant(_batchingStrategy));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof _batchingStrategy.batchedUpdates === 'function',
|
|
'ReactUpdates: must provide a batchedUpdates() function'
|
|
) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof _batchingStrategy.isBatchingUpdates === 'boolean',
|
|
'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
|
|
) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
|
|
batchingStrategy = _batchingStrategy;
|
|
}
|
|
};
|
|
|
|
var ReactUpdates = {
|
|
/**
|
|
* React references `ReactReconcileTransaction` using this property in order
|
|
* to allow dependency injection.
|
|
*
|
|
* @internal
|
|
*/
|
|
ReactReconcileTransaction: null,
|
|
|
|
batchedUpdates: batchedUpdates,
|
|
enqueueUpdate: enqueueUpdate,
|
|
flushBatchedUpdates: flushBatchedUpdates,
|
|
injection: ReactUpdatesInjection,
|
|
asap: asap
|
|
};
|
|
|
|
module.exports = ReactUpdates;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./CallbackQueue":48,"./Object.assign":70,"./PooledClass":71,"./ReactCurrentOwner":83,"./ReactPerf":116,"./Transaction":149,"./invariant":182,"./warning":202,"_process":1}],133:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ReactWithAddons
|
|
*/
|
|
|
|
/**
|
|
* This module exists purely in the open source project, and is meant as a way
|
|
* to create a separate standalone build of React. This build has "addons", or
|
|
* functionality we've built and think might be useful but doesn't have a good
|
|
* place to live inside React core.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var LinkedStateMixin = require("./LinkedStateMixin");
|
|
var React = require("./React");
|
|
var ReactComponentWithPureRenderMixin =
|
|
require("./ReactComponentWithPureRenderMixin");
|
|
var ReactCSSTransitionGroup = require("./ReactCSSTransitionGroup");
|
|
var ReactTransitionGroup = require("./ReactTransitionGroup");
|
|
var ReactUpdates = require("./ReactUpdates");
|
|
|
|
var cx = require("./cx");
|
|
var cloneWithProps = require("./cloneWithProps");
|
|
var update = require("./update");
|
|
|
|
React.addons = {
|
|
CSSTransitionGroup: ReactCSSTransitionGroup,
|
|
LinkedStateMixin: LinkedStateMixin,
|
|
PureRenderMixin: ReactComponentWithPureRenderMixin,
|
|
TransitionGroup: ReactTransitionGroup,
|
|
|
|
batchedUpdates: ReactUpdates.batchedUpdates,
|
|
classSet: cx,
|
|
cloneWithProps: cloneWithProps,
|
|
update: update
|
|
};
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
React.addons.Perf = require("./ReactDefaultPerf");
|
|
React.addons.TestUtils = require("./ReactTestUtils");
|
|
}
|
|
|
|
module.exports = React;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./LinkedStateMixin":66,"./React":72,"./ReactCSSTransitionGroup":75,"./ReactComponentWithPureRenderMixin":80,"./ReactDefaultPerf":97,"./ReactTestUtils":127,"./ReactTransitionGroup":131,"./ReactUpdates":132,"./cloneWithProps":155,"./cx":160,"./update":201,"_process":1}],134:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SVGDOMPropertyConfig
|
|
*/
|
|
|
|
/*jslint bitwise: true*/
|
|
|
|
"use strict";
|
|
|
|
var DOMProperty = require("./DOMProperty");
|
|
|
|
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
|
|
|
var SVGDOMPropertyConfig = {
|
|
Properties: {
|
|
cx: MUST_USE_ATTRIBUTE,
|
|
cy: MUST_USE_ATTRIBUTE,
|
|
d: MUST_USE_ATTRIBUTE,
|
|
dx: MUST_USE_ATTRIBUTE,
|
|
dy: MUST_USE_ATTRIBUTE,
|
|
fill: MUST_USE_ATTRIBUTE,
|
|
fillOpacity: MUST_USE_ATTRIBUTE,
|
|
fontFamily: MUST_USE_ATTRIBUTE,
|
|
fontSize: MUST_USE_ATTRIBUTE,
|
|
fx: MUST_USE_ATTRIBUTE,
|
|
fy: MUST_USE_ATTRIBUTE,
|
|
gradientTransform: MUST_USE_ATTRIBUTE,
|
|
gradientUnits: MUST_USE_ATTRIBUTE,
|
|
markerEnd: MUST_USE_ATTRIBUTE,
|
|
markerMid: MUST_USE_ATTRIBUTE,
|
|
markerStart: MUST_USE_ATTRIBUTE,
|
|
offset: MUST_USE_ATTRIBUTE,
|
|
opacity: MUST_USE_ATTRIBUTE,
|
|
patternContentUnits: MUST_USE_ATTRIBUTE,
|
|
patternUnits: MUST_USE_ATTRIBUTE,
|
|
points: MUST_USE_ATTRIBUTE,
|
|
preserveAspectRatio: MUST_USE_ATTRIBUTE,
|
|
r: MUST_USE_ATTRIBUTE,
|
|
rx: MUST_USE_ATTRIBUTE,
|
|
ry: MUST_USE_ATTRIBUTE,
|
|
spreadMethod: MUST_USE_ATTRIBUTE,
|
|
stopColor: MUST_USE_ATTRIBUTE,
|
|
stopOpacity: MUST_USE_ATTRIBUTE,
|
|
stroke: MUST_USE_ATTRIBUTE,
|
|
strokeDasharray: MUST_USE_ATTRIBUTE,
|
|
strokeLinecap: MUST_USE_ATTRIBUTE,
|
|
strokeOpacity: MUST_USE_ATTRIBUTE,
|
|
strokeWidth: MUST_USE_ATTRIBUTE,
|
|
textAnchor: MUST_USE_ATTRIBUTE,
|
|
transform: MUST_USE_ATTRIBUTE,
|
|
version: MUST_USE_ATTRIBUTE,
|
|
viewBox: MUST_USE_ATTRIBUTE,
|
|
x1: MUST_USE_ATTRIBUTE,
|
|
x2: MUST_USE_ATTRIBUTE,
|
|
x: MUST_USE_ATTRIBUTE,
|
|
y1: MUST_USE_ATTRIBUTE,
|
|
y2: MUST_USE_ATTRIBUTE,
|
|
y: MUST_USE_ATTRIBUTE
|
|
},
|
|
DOMAttributeNames: {
|
|
fillOpacity: 'fill-opacity',
|
|
fontFamily: 'font-family',
|
|
fontSize: 'font-size',
|
|
gradientTransform: 'gradientTransform',
|
|
gradientUnits: 'gradientUnits',
|
|
markerEnd: 'marker-end',
|
|
markerMid: 'marker-mid',
|
|
markerStart: 'marker-start',
|
|
patternContentUnits: 'patternContentUnits',
|
|
patternUnits: 'patternUnits',
|
|
preserveAspectRatio: 'preserveAspectRatio',
|
|
spreadMethod: 'spreadMethod',
|
|
stopColor: 'stop-color',
|
|
stopOpacity: 'stop-opacity',
|
|
strokeDasharray: 'stroke-dasharray',
|
|
strokeLinecap: 'stroke-linecap',
|
|
strokeOpacity: 'stroke-opacity',
|
|
strokeWidth: 'stroke-width',
|
|
textAnchor: 'text-anchor',
|
|
viewBox: 'viewBox'
|
|
}
|
|
};
|
|
|
|
module.exports = SVGDOMPropertyConfig;
|
|
|
|
},{"./DOMProperty":53}],135:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SelectEventPlugin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var ReactInputSelection = require("./ReactInputSelection");
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
var getActiveElement = require("./getActiveElement");
|
|
var isTextInputElement = require("./isTextInputElement");
|
|
var keyOf = require("./keyOf");
|
|
var shallowEqual = require("./shallowEqual");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
var eventTypes = {
|
|
select: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onSelect: null}),
|
|
captured: keyOf({onSelectCapture: null})
|
|
},
|
|
dependencies: [
|
|
topLevelTypes.topBlur,
|
|
topLevelTypes.topContextMenu,
|
|
topLevelTypes.topFocus,
|
|
topLevelTypes.topKeyDown,
|
|
topLevelTypes.topMouseDown,
|
|
topLevelTypes.topMouseUp,
|
|
topLevelTypes.topSelectionChange
|
|
]
|
|
}
|
|
};
|
|
|
|
var activeElement = null;
|
|
var activeElementID = null;
|
|
var lastSelection = null;
|
|
var mouseDown = false;
|
|
|
|
/**
|
|
* Get an object which is a unique representation of the current selection.
|
|
*
|
|
* The return value will not be consistent across nodes or browsers, but
|
|
* two identical selections on the same node will return identical objects.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @param {object}
|
|
*/
|
|
function getSelection(node) {
|
|
if ('selectionStart' in node &&
|
|
ReactInputSelection.hasSelectionCapabilities(node)) {
|
|
return {
|
|
start: node.selectionStart,
|
|
end: node.selectionEnd
|
|
};
|
|
} else if (window.getSelection) {
|
|
var selection = window.getSelection();
|
|
return {
|
|
anchorNode: selection.anchorNode,
|
|
anchorOffset: selection.anchorOffset,
|
|
focusNode: selection.focusNode,
|
|
focusOffset: selection.focusOffset
|
|
};
|
|
} else if (document.selection) {
|
|
var range = document.selection.createRange();
|
|
return {
|
|
parentElement: range.parentElement(),
|
|
text: range.text,
|
|
top: range.boundingTop,
|
|
left: range.boundingLeft
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Poll selection to see whether it's changed.
|
|
*
|
|
* @param {object} nativeEvent
|
|
* @return {?SyntheticEvent}
|
|
*/
|
|
function constructSelectEvent(nativeEvent) {
|
|
// Ensure we have the right element, and that the user is not dragging a
|
|
// selection (this matches native `select` event behavior). In HTML5, select
|
|
// fires only on input and textarea thus if there's no focused element we
|
|
// won't dispatch.
|
|
if (mouseDown ||
|
|
activeElement == null ||
|
|
activeElement != getActiveElement()) {
|
|
return;
|
|
}
|
|
|
|
// Only fire when selection has actually changed.
|
|
var currentSelection = getSelection(activeElement);
|
|
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
|
lastSelection = currentSelection;
|
|
|
|
var syntheticEvent = SyntheticEvent.getPooled(
|
|
eventTypes.select,
|
|
activeElementID,
|
|
nativeEvent
|
|
);
|
|
|
|
syntheticEvent.type = 'select';
|
|
syntheticEvent.target = activeElement;
|
|
|
|
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
|
|
|
|
return syntheticEvent;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This plugin creates an `onSelect` event that normalizes select events
|
|
* across form elements.
|
|
*
|
|
* Supported elements are:
|
|
* - input (see `isTextInputElement`)
|
|
* - textarea
|
|
* - contentEditable
|
|
*
|
|
* This differs from native browser implementations in the following ways:
|
|
* - Fires on contentEditable fields as well as inputs.
|
|
* - Fires for collapsed selection.
|
|
* - Fires after user input.
|
|
*/
|
|
var SelectEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
|
|
switch (topLevelType) {
|
|
// Track the input node that has focus.
|
|
case topLevelTypes.topFocus:
|
|
if (isTextInputElement(topLevelTarget) ||
|
|
topLevelTarget.contentEditable === 'true') {
|
|
activeElement = topLevelTarget;
|
|
activeElementID = topLevelTargetID;
|
|
lastSelection = null;
|
|
}
|
|
break;
|
|
case topLevelTypes.topBlur:
|
|
activeElement = null;
|
|
activeElementID = null;
|
|
lastSelection = null;
|
|
break;
|
|
|
|
// Don't fire the event while the user is dragging. This matches the
|
|
// semantics of the native select event.
|
|
case topLevelTypes.topMouseDown:
|
|
mouseDown = true;
|
|
break;
|
|
case topLevelTypes.topContextMenu:
|
|
case topLevelTypes.topMouseUp:
|
|
mouseDown = false;
|
|
return constructSelectEvent(nativeEvent);
|
|
|
|
// Chrome and IE fire non-standard event when selection is changed (and
|
|
// sometimes when it hasn't).
|
|
// Firefox doesn't support selectionchange, so check selection status
|
|
// after each key entry. The selection changes after keydown and before
|
|
// keyup, but we check on keydown as well in the case of holding down a
|
|
// key, when multiple keydown events are fired but only one keyup is.
|
|
case topLevelTypes.topSelectionChange:
|
|
case topLevelTypes.topKeyDown:
|
|
case topLevelTypes.topKeyUp:
|
|
return constructSelectEvent(nativeEvent);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = SelectEventPlugin;
|
|
|
|
},{"./EventConstants":58,"./EventPropagators":63,"./ReactInputSelection":106,"./SyntheticEvent":141,"./getActiveElement":169,"./isTextInputElement":185,"./keyOf":189,"./shallowEqual":197}],136:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ServerReactRootIndex
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Size of the reactRoot ID space. We generate random numbers for React root
|
|
* IDs and if there's a collision the events and DOM update system will
|
|
* get confused. In the future we need a way to generate GUIDs but for
|
|
* now this will work on a smaller scale.
|
|
*/
|
|
var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
|
|
|
|
var ServerReactRootIndex = {
|
|
createReactRootIndex: function() {
|
|
return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
|
|
}
|
|
};
|
|
|
|
module.exports = ServerReactRootIndex;
|
|
|
|
},{}],137:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SimpleEventPlugin
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var EventConstants = require("./EventConstants");
|
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
var EventPropagators = require("./EventPropagators");
|
|
var SyntheticClipboardEvent = require("./SyntheticClipboardEvent");
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
var SyntheticFocusEvent = require("./SyntheticFocusEvent");
|
|
var SyntheticKeyboardEvent = require("./SyntheticKeyboardEvent");
|
|
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
|
var SyntheticDragEvent = require("./SyntheticDragEvent");
|
|
var SyntheticTouchEvent = require("./SyntheticTouchEvent");
|
|
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
var SyntheticWheelEvent = require("./SyntheticWheelEvent");
|
|
|
|
var getEventCharCode = require("./getEventCharCode");
|
|
|
|
var invariant = require("./invariant");
|
|
var keyOf = require("./keyOf");
|
|
var warning = require("./warning");
|
|
|
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
|
|
var eventTypes = {
|
|
blur: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onBlur: true}),
|
|
captured: keyOf({onBlurCapture: true})
|
|
}
|
|
},
|
|
click: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onClick: true}),
|
|
captured: keyOf({onClickCapture: true})
|
|
}
|
|
},
|
|
contextMenu: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onContextMenu: true}),
|
|
captured: keyOf({onContextMenuCapture: true})
|
|
}
|
|
},
|
|
copy: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onCopy: true}),
|
|
captured: keyOf({onCopyCapture: true})
|
|
}
|
|
},
|
|
cut: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onCut: true}),
|
|
captured: keyOf({onCutCapture: true})
|
|
}
|
|
},
|
|
doubleClick: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDoubleClick: true}),
|
|
captured: keyOf({onDoubleClickCapture: true})
|
|
}
|
|
},
|
|
drag: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDrag: true}),
|
|
captured: keyOf({onDragCapture: true})
|
|
}
|
|
},
|
|
dragEnd: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragEnd: true}),
|
|
captured: keyOf({onDragEndCapture: true})
|
|
}
|
|
},
|
|
dragEnter: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragEnter: true}),
|
|
captured: keyOf({onDragEnterCapture: true})
|
|
}
|
|
},
|
|
dragExit: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragExit: true}),
|
|
captured: keyOf({onDragExitCapture: true})
|
|
}
|
|
},
|
|
dragLeave: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragLeave: true}),
|
|
captured: keyOf({onDragLeaveCapture: true})
|
|
}
|
|
},
|
|
dragOver: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragOver: true}),
|
|
captured: keyOf({onDragOverCapture: true})
|
|
}
|
|
},
|
|
dragStart: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDragStart: true}),
|
|
captured: keyOf({onDragStartCapture: true})
|
|
}
|
|
},
|
|
drop: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onDrop: true}),
|
|
captured: keyOf({onDropCapture: true})
|
|
}
|
|
},
|
|
focus: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onFocus: true}),
|
|
captured: keyOf({onFocusCapture: true})
|
|
}
|
|
},
|
|
input: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onInput: true}),
|
|
captured: keyOf({onInputCapture: true})
|
|
}
|
|
},
|
|
keyDown: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onKeyDown: true}),
|
|
captured: keyOf({onKeyDownCapture: true})
|
|
}
|
|
},
|
|
keyPress: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onKeyPress: true}),
|
|
captured: keyOf({onKeyPressCapture: true})
|
|
}
|
|
},
|
|
keyUp: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onKeyUp: true}),
|
|
captured: keyOf({onKeyUpCapture: true})
|
|
}
|
|
},
|
|
load: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onLoad: true}),
|
|
captured: keyOf({onLoadCapture: true})
|
|
}
|
|
},
|
|
error: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onError: true}),
|
|
captured: keyOf({onErrorCapture: true})
|
|
}
|
|
},
|
|
// Note: We do not allow listening to mouseOver events. Instead, use the
|
|
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
|
|
mouseDown: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onMouseDown: true}),
|
|
captured: keyOf({onMouseDownCapture: true})
|
|
}
|
|
},
|
|
mouseMove: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onMouseMove: true}),
|
|
captured: keyOf({onMouseMoveCapture: true})
|
|
}
|
|
},
|
|
mouseOut: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onMouseOut: true}),
|
|
captured: keyOf({onMouseOutCapture: true})
|
|
}
|
|
},
|
|
mouseOver: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onMouseOver: true}),
|
|
captured: keyOf({onMouseOverCapture: true})
|
|
}
|
|
},
|
|
mouseUp: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onMouseUp: true}),
|
|
captured: keyOf({onMouseUpCapture: true})
|
|
}
|
|
},
|
|
paste: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onPaste: true}),
|
|
captured: keyOf({onPasteCapture: true})
|
|
}
|
|
},
|
|
reset: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onReset: true}),
|
|
captured: keyOf({onResetCapture: true})
|
|
}
|
|
},
|
|
scroll: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onScroll: true}),
|
|
captured: keyOf({onScrollCapture: true})
|
|
}
|
|
},
|
|
submit: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onSubmit: true}),
|
|
captured: keyOf({onSubmitCapture: true})
|
|
}
|
|
},
|
|
touchCancel: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onTouchCancel: true}),
|
|
captured: keyOf({onTouchCancelCapture: true})
|
|
}
|
|
},
|
|
touchEnd: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onTouchEnd: true}),
|
|
captured: keyOf({onTouchEndCapture: true})
|
|
}
|
|
},
|
|
touchMove: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onTouchMove: true}),
|
|
captured: keyOf({onTouchMoveCapture: true})
|
|
}
|
|
},
|
|
touchStart: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onTouchStart: true}),
|
|
captured: keyOf({onTouchStartCapture: true})
|
|
}
|
|
},
|
|
wheel: {
|
|
phasedRegistrationNames: {
|
|
bubbled: keyOf({onWheel: true}),
|
|
captured: keyOf({onWheelCapture: true})
|
|
}
|
|
}
|
|
};
|
|
|
|
var topLevelEventsToDispatchConfig = {
|
|
topBlur: eventTypes.blur,
|
|
topClick: eventTypes.click,
|
|
topContextMenu: eventTypes.contextMenu,
|
|
topCopy: eventTypes.copy,
|
|
topCut: eventTypes.cut,
|
|
topDoubleClick: eventTypes.doubleClick,
|
|
topDrag: eventTypes.drag,
|
|
topDragEnd: eventTypes.dragEnd,
|
|
topDragEnter: eventTypes.dragEnter,
|
|
topDragExit: eventTypes.dragExit,
|
|
topDragLeave: eventTypes.dragLeave,
|
|
topDragOver: eventTypes.dragOver,
|
|
topDragStart: eventTypes.dragStart,
|
|
topDrop: eventTypes.drop,
|
|
topError: eventTypes.error,
|
|
topFocus: eventTypes.focus,
|
|
topInput: eventTypes.input,
|
|
topKeyDown: eventTypes.keyDown,
|
|
topKeyPress: eventTypes.keyPress,
|
|
topKeyUp: eventTypes.keyUp,
|
|
topLoad: eventTypes.load,
|
|
topMouseDown: eventTypes.mouseDown,
|
|
topMouseMove: eventTypes.mouseMove,
|
|
topMouseOut: eventTypes.mouseOut,
|
|
topMouseOver: eventTypes.mouseOver,
|
|
topMouseUp: eventTypes.mouseUp,
|
|
topPaste: eventTypes.paste,
|
|
topReset: eventTypes.reset,
|
|
topScroll: eventTypes.scroll,
|
|
topSubmit: eventTypes.submit,
|
|
topTouchCancel: eventTypes.touchCancel,
|
|
topTouchEnd: eventTypes.touchEnd,
|
|
topTouchMove: eventTypes.touchMove,
|
|
topTouchStart: eventTypes.touchStart,
|
|
topWheel: eventTypes.wheel
|
|
};
|
|
|
|
for (var topLevelType in topLevelEventsToDispatchConfig) {
|
|
topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType];
|
|
}
|
|
|
|
var SimpleEventPlugin = {
|
|
|
|
eventTypes: eventTypes,
|
|
|
|
/**
|
|
* Same as the default implementation, except cancels the event when return
|
|
* value is false. This behavior will be disabled in a future release.
|
|
*
|
|
* @param {object} Event to be dispatched.
|
|
* @param {function} Application-level callback.
|
|
* @param {string} domID DOM ID to pass to the callback.
|
|
*/
|
|
executeDispatch: function(event, listener, domID) {
|
|
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
|
|
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
typeof returnValue !== 'boolean',
|
|
'Returning `false` from an event handler is deprecated and will be ' +
|
|
'ignored in a future release. Instead, manually call ' +
|
|
'e.stopPropagation() or e.preventDefault(), as appropriate.'
|
|
) : null);
|
|
|
|
if (returnValue === false) {
|
|
event.stopPropagation();
|
|
event.preventDefault();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {*} An accumulation of synthetic events.
|
|
* @see {EventPluginHub.extractEvents}
|
|
*/
|
|
extractEvents: function(
|
|
topLevelType,
|
|
topLevelTarget,
|
|
topLevelTargetID,
|
|
nativeEvent) {
|
|
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
|
|
if (!dispatchConfig) {
|
|
return null;
|
|
}
|
|
var EventConstructor;
|
|
switch (topLevelType) {
|
|
case topLevelTypes.topInput:
|
|
case topLevelTypes.topLoad:
|
|
case topLevelTypes.topError:
|
|
case topLevelTypes.topReset:
|
|
case topLevelTypes.topSubmit:
|
|
// HTML Events
|
|
// @see http://www.w3.org/TR/html5/index.html#events-0
|
|
EventConstructor = SyntheticEvent;
|
|
break;
|
|
case topLevelTypes.topKeyPress:
|
|
// FireFox creates a keypress event for function keys too. This removes
|
|
// the unwanted keypress events. Enter is however both printable and
|
|
// non-printable. One would expect Tab to be as well (but it isn't).
|
|
if (getEventCharCode(nativeEvent) === 0) {
|
|
return null;
|
|
}
|
|
/* falls through */
|
|
case topLevelTypes.topKeyDown:
|
|
case topLevelTypes.topKeyUp:
|
|
EventConstructor = SyntheticKeyboardEvent;
|
|
break;
|
|
case topLevelTypes.topBlur:
|
|
case topLevelTypes.topFocus:
|
|
EventConstructor = SyntheticFocusEvent;
|
|
break;
|
|
case topLevelTypes.topClick:
|
|
// Firefox creates a click event on right mouse clicks. This removes the
|
|
// unwanted click events.
|
|
if (nativeEvent.button === 2) {
|
|
return null;
|
|
}
|
|
/* falls through */
|
|
case topLevelTypes.topContextMenu:
|
|
case topLevelTypes.topDoubleClick:
|
|
case topLevelTypes.topMouseDown:
|
|
case topLevelTypes.topMouseMove:
|
|
case topLevelTypes.topMouseOut:
|
|
case topLevelTypes.topMouseOver:
|
|
case topLevelTypes.topMouseUp:
|
|
EventConstructor = SyntheticMouseEvent;
|
|
break;
|
|
case topLevelTypes.topDrag:
|
|
case topLevelTypes.topDragEnd:
|
|
case topLevelTypes.topDragEnter:
|
|
case topLevelTypes.topDragExit:
|
|
case topLevelTypes.topDragLeave:
|
|
case topLevelTypes.topDragOver:
|
|
case topLevelTypes.topDragStart:
|
|
case topLevelTypes.topDrop:
|
|
EventConstructor = SyntheticDragEvent;
|
|
break;
|
|
case topLevelTypes.topTouchCancel:
|
|
case topLevelTypes.topTouchEnd:
|
|
case topLevelTypes.topTouchMove:
|
|
case topLevelTypes.topTouchStart:
|
|
EventConstructor = SyntheticTouchEvent;
|
|
break;
|
|
case topLevelTypes.topScroll:
|
|
EventConstructor = SyntheticUIEvent;
|
|
break;
|
|
case topLevelTypes.topWheel:
|
|
EventConstructor = SyntheticWheelEvent;
|
|
break;
|
|
case topLevelTypes.topCopy:
|
|
case topLevelTypes.topCut:
|
|
case topLevelTypes.topPaste:
|
|
EventConstructor = SyntheticClipboardEvent;
|
|
break;
|
|
}
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
EventConstructor,
|
|
'SimpleEventPlugin: Unhandled event type, `%s`.',
|
|
topLevelType
|
|
) : invariant(EventConstructor));
|
|
var event = EventConstructor.getPooled(
|
|
dispatchConfig,
|
|
topLevelTargetID,
|
|
nativeEvent
|
|
);
|
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
return event;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = SimpleEventPlugin;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./EventConstants":58,"./EventPluginUtils":62,"./EventPropagators":63,"./SyntheticClipboardEvent":138,"./SyntheticDragEvent":140,"./SyntheticEvent":141,"./SyntheticFocusEvent":142,"./SyntheticKeyboardEvent":144,"./SyntheticMouseEvent":145,"./SyntheticTouchEvent":146,"./SyntheticUIEvent":147,"./SyntheticWheelEvent":148,"./getEventCharCode":170,"./invariant":182,"./keyOf":189,"./warning":202,"_process":1}],138:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticClipboardEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
/**
|
|
* @interface Event
|
|
* @see http://www.w3.org/TR/clipboard-apis/
|
|
*/
|
|
var ClipboardEventInterface = {
|
|
clipboardData: function(event) {
|
|
return (
|
|
'clipboardData' in event ?
|
|
event.clipboardData :
|
|
window.clipboardData
|
|
);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
|
|
|
|
module.exports = SyntheticClipboardEvent;
|
|
|
|
|
|
},{"./SyntheticEvent":141}],139:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticCompositionEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
/**
|
|
* @interface Event
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
|
|
*/
|
|
var CompositionEventInterface = {
|
|
data: null
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticCompositionEvent(
|
|
dispatchConfig,
|
|
dispatchMarker,
|
|
nativeEvent) {
|
|
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticEvent.augmentClass(
|
|
SyntheticCompositionEvent,
|
|
CompositionEventInterface
|
|
);
|
|
|
|
module.exports = SyntheticCompositionEvent;
|
|
|
|
|
|
},{"./SyntheticEvent":141}],140:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticDragEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
|
|
|
/**
|
|
* @interface DragEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var DragEventInterface = {
|
|
dataTransfer: null
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
|
|
|
|
module.exports = SyntheticDragEvent;
|
|
|
|
},{"./SyntheticMouseEvent":145}],141:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var PooledClass = require("./PooledClass");
|
|
|
|
var assign = require("./Object.assign");
|
|
var emptyFunction = require("./emptyFunction");
|
|
var getEventTarget = require("./getEventTarget");
|
|
|
|
/**
|
|
* @interface Event
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var EventInterface = {
|
|
type: null,
|
|
target: getEventTarget,
|
|
// currentTarget is set when dispatching; no use in copying it here
|
|
currentTarget: emptyFunction.thatReturnsNull,
|
|
eventPhase: null,
|
|
bubbles: null,
|
|
cancelable: null,
|
|
timeStamp: function(event) {
|
|
return event.timeStamp || Date.now();
|
|
},
|
|
defaultPrevented: null,
|
|
isTrusted: null
|
|
};
|
|
|
|
/**
|
|
* Synthetic events are dispatched by event plugins, typically in response to a
|
|
* top-level event delegation handler.
|
|
*
|
|
* These systems should generally use pooling to reduce the frequency of garbage
|
|
* collection. The system should check `isPersistent` to determine whether the
|
|
* event should be released into the pool after being dispatched. Users that
|
|
* need a persisted event should invoke `persist`.
|
|
*
|
|
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
|
|
* normalizing browser quirks. Subclasses do not necessarily have to implement a
|
|
* DOM interface; custom application-specific events can also subclass this.
|
|
*
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
*/
|
|
function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
this.dispatchConfig = dispatchConfig;
|
|
this.dispatchMarker = dispatchMarker;
|
|
this.nativeEvent = nativeEvent;
|
|
|
|
var Interface = this.constructor.Interface;
|
|
for (var propName in Interface) {
|
|
if (!Interface.hasOwnProperty(propName)) {
|
|
continue;
|
|
}
|
|
var normalize = Interface[propName];
|
|
if (normalize) {
|
|
this[propName] = normalize(nativeEvent);
|
|
} else {
|
|
this[propName] = nativeEvent[propName];
|
|
}
|
|
}
|
|
|
|
var defaultPrevented = nativeEvent.defaultPrevented != null ?
|
|
nativeEvent.defaultPrevented :
|
|
nativeEvent.returnValue === false;
|
|
if (defaultPrevented) {
|
|
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
|
|
} else {
|
|
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
|
|
}
|
|
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
|
|
}
|
|
|
|
assign(SyntheticEvent.prototype, {
|
|
|
|
preventDefault: function() {
|
|
this.defaultPrevented = true;
|
|
var event = this.nativeEvent;
|
|
event.preventDefault ? event.preventDefault() : event.returnValue = false;
|
|
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
|
|
},
|
|
|
|
stopPropagation: function() {
|
|
var event = this.nativeEvent;
|
|
event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
|
|
this.isPropagationStopped = emptyFunction.thatReturnsTrue;
|
|
},
|
|
|
|
/**
|
|
* We release all dispatched `SyntheticEvent`s after each event loop, adding
|
|
* them back into the pool. This allows a way to hold onto a reference that
|
|
* won't be added back into the pool.
|
|
*/
|
|
persist: function() {
|
|
this.isPersistent = emptyFunction.thatReturnsTrue;
|
|
},
|
|
|
|
/**
|
|
* Checks if this event should be released back into the pool.
|
|
*
|
|
* @return {boolean} True if this should not be released, false otherwise.
|
|
*/
|
|
isPersistent: emptyFunction.thatReturnsFalse,
|
|
|
|
/**
|
|
* `PooledClass` looks for `destructor` on each instance it releases.
|
|
*/
|
|
destructor: function() {
|
|
var Interface = this.constructor.Interface;
|
|
for (var propName in Interface) {
|
|
this[propName] = null;
|
|
}
|
|
this.dispatchConfig = null;
|
|
this.dispatchMarker = null;
|
|
this.nativeEvent = null;
|
|
}
|
|
|
|
});
|
|
|
|
SyntheticEvent.Interface = EventInterface;
|
|
|
|
/**
|
|
* Helper to reduce boilerplate when creating subclasses.
|
|
*
|
|
* @param {function} Class
|
|
* @param {?object} Interface
|
|
*/
|
|
SyntheticEvent.augmentClass = function(Class, Interface) {
|
|
var Super = this;
|
|
|
|
var prototype = Object.create(Super.prototype);
|
|
assign(prototype, Class.prototype);
|
|
Class.prototype = prototype;
|
|
Class.prototype.constructor = Class;
|
|
|
|
Class.Interface = assign({}, Super.Interface, Interface);
|
|
Class.augmentClass = Super.augmentClass;
|
|
|
|
PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
|
|
};
|
|
|
|
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
|
|
|
|
module.exports = SyntheticEvent;
|
|
|
|
},{"./Object.assign":70,"./PooledClass":71,"./emptyFunction":163,"./getEventTarget":173}],142:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticFocusEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
|
|
/**
|
|
* @interface FocusEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var FocusEventInterface = {
|
|
relatedTarget: null
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
|
|
|
|
module.exports = SyntheticFocusEvent;
|
|
|
|
},{"./SyntheticUIEvent":147}],143:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013 Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticInputEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
/**
|
|
* @interface Event
|
|
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
|
|
* /#events-inputevents
|
|
*/
|
|
var InputEventInterface = {
|
|
data: null
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticInputEvent(
|
|
dispatchConfig,
|
|
dispatchMarker,
|
|
nativeEvent) {
|
|
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticEvent.augmentClass(
|
|
SyntheticInputEvent,
|
|
InputEventInterface
|
|
);
|
|
|
|
module.exports = SyntheticInputEvent;
|
|
|
|
|
|
},{"./SyntheticEvent":141}],144:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticKeyboardEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
|
|
var getEventCharCode = require("./getEventCharCode");
|
|
var getEventKey = require("./getEventKey");
|
|
var getEventModifierState = require("./getEventModifierState");
|
|
|
|
/**
|
|
* @interface KeyboardEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var KeyboardEventInterface = {
|
|
key: getEventKey,
|
|
location: null,
|
|
ctrlKey: null,
|
|
shiftKey: null,
|
|
altKey: null,
|
|
metaKey: null,
|
|
repeat: null,
|
|
locale: null,
|
|
getModifierState: getEventModifierState,
|
|
// Legacy Interface
|
|
charCode: function(event) {
|
|
// `charCode` is the result of a KeyPress event and represents the value of
|
|
// the actual printable character.
|
|
|
|
// KeyPress is deprecated, but its replacement is not yet final and not
|
|
// implemented in any major browser. Only KeyPress has charCode.
|
|
if (event.type === 'keypress') {
|
|
return getEventCharCode(event);
|
|
}
|
|
return 0;
|
|
},
|
|
keyCode: function(event) {
|
|
// `keyCode` is the result of a KeyDown/Up event and represents the value of
|
|
// physical keyboard key.
|
|
|
|
// The actual meaning of the value depends on the users' keyboard layout
|
|
// which cannot be detected. Assuming that it is a US keyboard layout
|
|
// provides a surprisingly accurate mapping for US and European users.
|
|
// Due to this, it is left to the user to implement at this time.
|
|
if (event.type === 'keydown' || event.type === 'keyup') {
|
|
return event.keyCode;
|
|
}
|
|
return 0;
|
|
},
|
|
which: function(event) {
|
|
// `which` is an alias for either `keyCode` or `charCode` depending on the
|
|
// type of the event.
|
|
if (event.type === 'keypress') {
|
|
return getEventCharCode(event);
|
|
}
|
|
if (event.type === 'keydown' || event.type === 'keyup') {
|
|
return event.keyCode;
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
|
|
|
|
module.exports = SyntheticKeyboardEvent;
|
|
|
|
},{"./SyntheticUIEvent":147,"./getEventCharCode":170,"./getEventKey":171,"./getEventModifierState":172}],145:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticMouseEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
var ViewportMetrics = require("./ViewportMetrics");
|
|
|
|
var getEventModifierState = require("./getEventModifierState");
|
|
|
|
/**
|
|
* @interface MouseEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var MouseEventInterface = {
|
|
screenX: null,
|
|
screenY: null,
|
|
clientX: null,
|
|
clientY: null,
|
|
ctrlKey: null,
|
|
shiftKey: null,
|
|
altKey: null,
|
|
metaKey: null,
|
|
getModifierState: getEventModifierState,
|
|
button: function(event) {
|
|
// Webkit, Firefox, IE9+
|
|
// which: 1 2 3
|
|
// button: 0 1 2 (standard)
|
|
var button = event.button;
|
|
if ('which' in event) {
|
|
return button;
|
|
}
|
|
// IE<9
|
|
// which: undefined
|
|
// button: 0 0 0
|
|
// button: 1 4 2 (onmouseup)
|
|
return button === 2 ? 2 : button === 4 ? 1 : 0;
|
|
},
|
|
buttons: null,
|
|
relatedTarget: function(event) {
|
|
return event.relatedTarget || (
|
|
event.fromElement === event.srcElement ?
|
|
event.toElement :
|
|
event.fromElement
|
|
);
|
|
},
|
|
// "Proprietary" Interface.
|
|
pageX: function(event) {
|
|
return 'pageX' in event ?
|
|
event.pageX :
|
|
event.clientX + ViewportMetrics.currentScrollLeft;
|
|
},
|
|
pageY: function(event) {
|
|
return 'pageY' in event ?
|
|
event.pageY :
|
|
event.clientY + ViewportMetrics.currentScrollTop;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
|
|
|
|
module.exports = SyntheticMouseEvent;
|
|
|
|
},{"./SyntheticUIEvent":147,"./ViewportMetrics":150,"./getEventModifierState":172}],146:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticTouchEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
|
|
var getEventModifierState = require("./getEventModifierState");
|
|
|
|
/**
|
|
* @interface TouchEvent
|
|
* @see http://www.w3.org/TR/touch-events/
|
|
*/
|
|
var TouchEventInterface = {
|
|
touches: null,
|
|
targetTouches: null,
|
|
changedTouches: null,
|
|
altKey: null,
|
|
metaKey: null,
|
|
ctrlKey: null,
|
|
shiftKey: null,
|
|
getModifierState: getEventModifierState
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticUIEvent}
|
|
*/
|
|
function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
|
|
|
|
module.exports = SyntheticTouchEvent;
|
|
|
|
},{"./SyntheticUIEvent":147,"./getEventModifierState":172}],147:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticUIEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticEvent = require("./SyntheticEvent");
|
|
|
|
var getEventTarget = require("./getEventTarget");
|
|
|
|
/**
|
|
* @interface UIEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var UIEventInterface = {
|
|
view: function(event) {
|
|
if (event.view) {
|
|
return event.view;
|
|
}
|
|
|
|
var target = getEventTarget(event);
|
|
if (target != null && target.window === target) {
|
|
// target is a window object
|
|
return target;
|
|
}
|
|
|
|
var doc = target.ownerDocument;
|
|
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
|
if (doc) {
|
|
return doc.defaultView || doc.parentWindow;
|
|
} else {
|
|
return window;
|
|
}
|
|
},
|
|
detail: function(event) {
|
|
return event.detail || 0;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticEvent}
|
|
*/
|
|
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
|
|
|
|
module.exports = SyntheticUIEvent;
|
|
|
|
},{"./SyntheticEvent":141,"./getEventTarget":173}],148:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule SyntheticWheelEvent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
|
|
|
/**
|
|
* @interface WheelEvent
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
*/
|
|
var WheelEventInterface = {
|
|
deltaX: function(event) {
|
|
return (
|
|
'deltaX' in event ? event.deltaX :
|
|
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
|
|
'wheelDeltaX' in event ? -event.wheelDeltaX : 0
|
|
);
|
|
},
|
|
deltaY: function(event) {
|
|
return (
|
|
'deltaY' in event ? event.deltaY :
|
|
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
|
|
'wheelDeltaY' in event ? -event.wheelDeltaY :
|
|
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
|
|
'wheelDelta' in event ? -event.wheelDelta : 0
|
|
);
|
|
},
|
|
deltaZ: null,
|
|
|
|
// Browsers without "deltaMode" is reporting in raw wheel delta where one
|
|
// notch on the scroll is always +/- 120, roughly equivalent to pixels.
|
|
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
|
|
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
|
|
deltaMode: null
|
|
};
|
|
|
|
/**
|
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
* @param {string} dispatchMarker Marker identifying the event target.
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @extends {SyntheticMouseEvent}
|
|
*/
|
|
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
|
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
|
}
|
|
|
|
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
|
|
|
|
module.exports = SyntheticWheelEvent;
|
|
|
|
},{"./SyntheticMouseEvent":145}],149:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule Transaction
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* `Transaction` creates a black box that is able to wrap any method such that
|
|
* certain invariants are maintained before and after the method is invoked
|
|
* (Even if an exception is thrown while invoking the wrapped method). Whoever
|
|
* instantiates a transaction can provide enforcers of the invariants at
|
|
* creation time. The `Transaction` class itself will supply one additional
|
|
* automatic invariant for you - the invariant that any transaction instance
|
|
* should not be run while it is already being run. You would typically create a
|
|
* single instance of a `Transaction` for reuse multiple times, that potentially
|
|
* is used to wrap several different methods. Wrappers are extremely simple -
|
|
* they only require implementing two methods.
|
|
*
|
|
* <pre>
|
|
* wrappers (injected at creation time)
|
|
* + +
|
|
* | |
|
|
* +-----------------|--------|--------------+
|
|
* | v | |
|
|
* | +---------------+ | |
|
|
* | +--| wrapper1 |---|----+ |
|
|
* | | +---------------+ v | |
|
|
* | | +-------------+ | |
|
|
* | | +----| wrapper2 |--------+ |
|
|
* | | | +-------------+ | | |
|
|
* | | | | | |
|
|
* | v v v v | wrapper
|
|
* | +---+ +---+ +---------+ +---+ +---+ | invariants
|
|
* perform(anyMethod) | | | | | | | | | | | | maintained
|
|
* +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
|
|
* | | | | | | | | | | | |
|
|
* | | | | | | | | | | | |
|
|
* | | | | | | | | | | | |
|
|
* | +---+ +---+ +---------+ +---+ +---+ |
|
|
* | initialize close |
|
|
* +-----------------------------------------+
|
|
* </pre>
|
|
*
|
|
* Use cases:
|
|
* - Preserving the input selection ranges before/after reconciliation.
|
|
* Restoring selection even in the event of an unexpected error.
|
|
* - Deactivating events while rearranging the DOM, preventing blurs/focuses,
|
|
* while guaranteeing that afterwards, the event system is reactivated.
|
|
* - Flushing a queue of collected DOM mutations to the main UI thread after a
|
|
* reconciliation takes place in a worker thread.
|
|
* - Invoking any collected `componentDidUpdate` callbacks after rendering new
|
|
* content.
|
|
* - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
|
|
* to preserve the `scrollTop` (an automatic scroll aware DOM).
|
|
* - (Future use case): Layout calculations before and after DOM upates.
|
|
*
|
|
* Transactional plugin API:
|
|
* - A module that has an `initialize` method that returns any precomputation.
|
|
* - and a `close` method that accepts the precomputation. `close` is invoked
|
|
* when the wrapped process is completed, or has failed.
|
|
*
|
|
* @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
|
|
* that implement `initialize` and `close`.
|
|
* @return {Transaction} Single transaction for reuse in thread.
|
|
*
|
|
* @class Transaction
|
|
*/
|
|
var Mixin = {
|
|
/**
|
|
* Sets up this instance so that it is prepared for collecting metrics. Does
|
|
* so such that this setup method may be used on an instance that is already
|
|
* initialized, in a way that does not consume additional memory upon reuse.
|
|
* That can be useful if you decide to make your subclass of this mixin a
|
|
* "PooledClass".
|
|
*/
|
|
reinitializeTransaction: function() {
|
|
this.transactionWrappers = this.getTransactionWrappers();
|
|
if (!this.wrapperInitData) {
|
|
this.wrapperInitData = [];
|
|
} else {
|
|
this.wrapperInitData.length = 0;
|
|
}
|
|
this._isInTransaction = false;
|
|
},
|
|
|
|
_isInTransaction: false,
|
|
|
|
/**
|
|
* @abstract
|
|
* @return {Array<TransactionWrapper>} Array of transaction wrappers.
|
|
*/
|
|
getTransactionWrappers: null,
|
|
|
|
isInTransaction: function() {
|
|
return !!this._isInTransaction;
|
|
},
|
|
|
|
/**
|
|
* Executes the function within a safety window. Use this for the top level
|
|
* methods that result in large amounts of computation/mutations that would
|
|
* need to be safety checked.
|
|
*
|
|
* @param {function} method Member of scope to call.
|
|
* @param {Object} scope Scope to invoke from.
|
|
* @param {Object?=} args... Arguments to pass to the method (optional).
|
|
* Helps prevent need to bind in many cases.
|
|
* @return Return value from `method`.
|
|
*/
|
|
perform: function(method, scope, a, b, c, d, e, f) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!this.isInTransaction(),
|
|
'Transaction.perform(...): Cannot initialize a transaction when there ' +
|
|
'is already an outstanding transaction.'
|
|
) : invariant(!this.isInTransaction()));
|
|
var errorThrown;
|
|
var ret;
|
|
try {
|
|
this._isInTransaction = true;
|
|
// Catching errors makes debugging more difficult, so we start with
|
|
// errorThrown set to true before setting it to false after calling
|
|
// close -- if it's still set to true in the finally block, it means
|
|
// one of these calls threw.
|
|
errorThrown = true;
|
|
this.initializeAll(0);
|
|
ret = method.call(scope, a, b, c, d, e, f);
|
|
errorThrown = false;
|
|
} finally {
|
|
try {
|
|
if (errorThrown) {
|
|
// If `method` throws, prefer to show that stack trace over any thrown
|
|
// by invoking `closeAll`.
|
|
try {
|
|
this.closeAll(0);
|
|
} catch (err) {
|
|
}
|
|
} else {
|
|
// Since `method` didn't throw, we don't want to silence the exception
|
|
// here.
|
|
this.closeAll(0);
|
|
}
|
|
} finally {
|
|
this._isInTransaction = false;
|
|
}
|
|
}
|
|
return ret;
|
|
},
|
|
|
|
initializeAll: function(startIndex) {
|
|
var transactionWrappers = this.transactionWrappers;
|
|
for (var i = startIndex; i < transactionWrappers.length; i++) {
|
|
var wrapper = transactionWrappers[i];
|
|
try {
|
|
// Catching errors makes debugging more difficult, so we start with the
|
|
// OBSERVED_ERROR state before overwriting it with the real return value
|
|
// of initialize -- if it's still set to OBSERVED_ERROR in the finally
|
|
// block, it means wrapper.initialize threw.
|
|
this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
|
|
this.wrapperInitData[i] = wrapper.initialize ?
|
|
wrapper.initialize.call(this) :
|
|
null;
|
|
} finally {
|
|
if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
|
|
// The initializer for wrapper i threw an error; initialize the
|
|
// remaining wrappers but silence any exceptions from them to ensure
|
|
// that the first error is the one to bubble up.
|
|
try {
|
|
this.initializeAll(i + 1);
|
|
} catch (err) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Invokes each of `this.transactionWrappers.close[i]` functions, passing into
|
|
* them the respective return values of `this.transactionWrappers.init[i]`
|
|
* (`close`rs that correspond to initializers that failed will not be
|
|
* invoked).
|
|
*/
|
|
closeAll: function(startIndex) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
this.isInTransaction(),
|
|
'Transaction.closeAll(): Cannot close transaction when none are open.'
|
|
) : invariant(this.isInTransaction()));
|
|
var transactionWrappers = this.transactionWrappers;
|
|
for (var i = startIndex; i < transactionWrappers.length; i++) {
|
|
var wrapper = transactionWrappers[i];
|
|
var initData = this.wrapperInitData[i];
|
|
var errorThrown;
|
|
try {
|
|
// Catching errors makes debugging more difficult, so we start with
|
|
// errorThrown set to true before setting it to false after calling
|
|
// close -- if it's still set to true in the finally block, it means
|
|
// wrapper.close threw.
|
|
errorThrown = true;
|
|
if (initData !== Transaction.OBSERVED_ERROR) {
|
|
wrapper.close && wrapper.close.call(this, initData);
|
|
}
|
|
errorThrown = false;
|
|
} finally {
|
|
if (errorThrown) {
|
|
// The closer for wrapper i threw an error; close the remaining
|
|
// wrappers but silence any exceptions from them to ensure that the
|
|
// first error is the one to bubble up.
|
|
try {
|
|
this.closeAll(i + 1);
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.wrapperInitData.length = 0;
|
|
}
|
|
};
|
|
|
|
var Transaction = {
|
|
|
|
Mixin: Mixin,
|
|
|
|
/**
|
|
* Token to look for to determine if an error occured.
|
|
*/
|
|
OBSERVED_ERROR: {}
|
|
|
|
};
|
|
|
|
module.exports = Transaction;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],150:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule ViewportMetrics
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
|
|
|
|
var ViewportMetrics = {
|
|
|
|
currentScrollLeft: 0,
|
|
|
|
currentScrollTop: 0,
|
|
|
|
refreshScrollValues: function() {
|
|
var scrollPosition = getUnboundedScrollPosition(window);
|
|
ViewportMetrics.currentScrollLeft = scrollPosition.x;
|
|
ViewportMetrics.currentScrollTop = scrollPosition.y;
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = ViewportMetrics;
|
|
|
|
},{"./getUnboundedScrollPosition":178}],151:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule accumulateInto
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
*
|
|
* Accumulates items that must not be null or undefined into the first one. This
|
|
* is used to conserve memory by avoiding array allocations, and thus sacrifices
|
|
* API cleanness. Since `current` can be null before being passed in and not
|
|
* null after this function, make sure to assign it back to `current`:
|
|
*
|
|
* `a = accumulateInto(a, b);`
|
|
*
|
|
* This API should be sparingly used. Try `accumulate` for something cleaner.
|
|
*
|
|
* @return {*|array<*>} An accumulation of items.
|
|
*/
|
|
|
|
function accumulateInto(current, next) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
next != null,
|
|
'accumulateInto(...): Accumulated items must not be null or undefined.'
|
|
) : invariant(next != null));
|
|
if (current == null) {
|
|
return next;
|
|
}
|
|
|
|
// Both are not empty. Warning: Never call x.concat(y) when you are not
|
|
// certain that x is an Array (x could be a string with concat method).
|
|
var currentIsArray = Array.isArray(current);
|
|
var nextIsArray = Array.isArray(next);
|
|
|
|
if (currentIsArray && nextIsArray) {
|
|
current.push.apply(current, next);
|
|
return current;
|
|
}
|
|
|
|
if (currentIsArray) {
|
|
current.push(next);
|
|
return current;
|
|
}
|
|
|
|
if (nextIsArray) {
|
|
// A bit too dangerous to mutate `next`.
|
|
return [current].concat(next);
|
|
}
|
|
|
|
return [current, next];
|
|
}
|
|
|
|
module.exports = accumulateInto;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],152:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule adler32
|
|
*/
|
|
|
|
/* jslint bitwise:true */
|
|
|
|
"use strict";
|
|
|
|
var MOD = 65521;
|
|
|
|
// This is a clean-room implementation of adler32 designed for detecting
|
|
// if markup is not what we expect it to be. It does not need to be
|
|
// cryptographically strong, only reasonably good at detecting if markup
|
|
// generated on the server is different than that on the client.
|
|
function adler32(data) {
|
|
var a = 1;
|
|
var b = 0;
|
|
for (var i = 0; i < data.length; i++) {
|
|
a = (a + data.charCodeAt(i)) % MOD;
|
|
b = (b + a) % MOD;
|
|
}
|
|
return a | (b << 16);
|
|
}
|
|
|
|
module.exports = adler32;
|
|
|
|
},{}],153:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule camelize
|
|
* @typechecks
|
|
*/
|
|
|
|
var _hyphenPattern = /-(.)/g;
|
|
|
|
/**
|
|
* Camelcases a hyphenated string, for example:
|
|
*
|
|
* > camelize('background-color')
|
|
* < "backgroundColor"
|
|
*
|
|
* @param {string} string
|
|
* @return {string}
|
|
*/
|
|
function camelize(string) {
|
|
return string.replace(_hyphenPattern, function(_, character) {
|
|
return character.toUpperCase();
|
|
});
|
|
}
|
|
|
|
module.exports = camelize;
|
|
|
|
},{}],154:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule camelizeStyleName
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var camelize = require("./camelize");
|
|
|
|
var msPattern = /^-ms-/;
|
|
|
|
/**
|
|
* Camelcases a hyphenated CSS property name, for example:
|
|
*
|
|
* > camelizeStyleName('background-color')
|
|
* < "backgroundColor"
|
|
* > camelizeStyleName('-moz-transition')
|
|
* < "MozTransition"
|
|
* > camelizeStyleName('-ms-transition')
|
|
* < "msTransition"
|
|
*
|
|
* As Andi Smith suggests
|
|
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
|
|
* is converted to lowercase `ms`.
|
|
*
|
|
* @param {string} string
|
|
* @return {string}
|
|
*/
|
|
function camelizeStyleName(string) {
|
|
return camelize(string.replace(msPattern, 'ms-'));
|
|
}
|
|
|
|
module.exports = camelizeStyleName;
|
|
|
|
},{"./camelize":153}],155:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @typechecks
|
|
* @providesModule cloneWithProps
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactPropTransferer = require("./ReactPropTransferer");
|
|
|
|
var keyOf = require("./keyOf");
|
|
var warning = require("./warning");
|
|
|
|
var CHILDREN_PROP = keyOf({children: null});
|
|
|
|
/**
|
|
* Sometimes you want to change the props of a child passed to you. Usually
|
|
* this is to add a CSS class.
|
|
*
|
|
* @param {object} child child component you'd like to clone
|
|
* @param {object} props props you'd like to modify. They will be merged
|
|
* as if you used `transferPropsTo()`.
|
|
* @return {object} a clone of child with props merged in.
|
|
*/
|
|
function cloneWithProps(child, props) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
!child.ref,
|
|
'You are calling cloneWithProps() on a child with a ref. This is ' +
|
|
'dangerous because you\'re creating a new child which will not be ' +
|
|
'added as a ref to its parent.'
|
|
) : null);
|
|
}
|
|
|
|
var newProps = ReactPropTransferer.mergeProps(props, child.props);
|
|
|
|
// Use `child.props.children` if it is provided.
|
|
if (!newProps.hasOwnProperty(CHILDREN_PROP) &&
|
|
child.props.hasOwnProperty(CHILDREN_PROP)) {
|
|
newProps.children = child.props.children;
|
|
}
|
|
|
|
// The current API doesn't retain _owner and _context, which is why this
|
|
// doesn't use ReactElement.cloneAndReplaceProps.
|
|
return ReactElement.createElement(child.type, newProps);
|
|
}
|
|
|
|
module.exports = cloneWithProps;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./ReactPropTransferer":117,"./keyOf":189,"./warning":202,"_process":1}],156:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule containsNode
|
|
* @typechecks
|
|
*/
|
|
|
|
var isTextNode = require("./isTextNode");
|
|
|
|
/*jslint bitwise:true */
|
|
|
|
/**
|
|
* Checks if a given DOM node contains or is another DOM node.
|
|
*
|
|
* @param {?DOMNode} outerNode Outer DOM node.
|
|
* @param {?DOMNode} innerNode Inner DOM node.
|
|
* @return {boolean} True if `outerNode` contains or is `innerNode`.
|
|
*/
|
|
function containsNode(outerNode, innerNode) {
|
|
if (!outerNode || !innerNode) {
|
|
return false;
|
|
} else if (outerNode === innerNode) {
|
|
return true;
|
|
} else if (isTextNode(outerNode)) {
|
|
return false;
|
|
} else if (isTextNode(innerNode)) {
|
|
return containsNode(outerNode, innerNode.parentNode);
|
|
} else if (outerNode.contains) {
|
|
return outerNode.contains(innerNode);
|
|
} else if (outerNode.compareDocumentPosition) {
|
|
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
module.exports = containsNode;
|
|
|
|
},{"./isTextNode":186}],157:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule createArrayFrom
|
|
* @typechecks
|
|
*/
|
|
|
|
var toArray = require("./toArray");
|
|
|
|
/**
|
|
* Perform a heuristic test to determine if an object is "array-like".
|
|
*
|
|
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
|
|
* Joshu replied: "Mu."
|
|
*
|
|
* This function determines if its argument has "array nature": it returns
|
|
* true if the argument is an actual array, an `arguments' object, or an
|
|
* HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
|
|
*
|
|
* It will return false for other array-like objects like Filelist.
|
|
*
|
|
* @param {*} obj
|
|
* @return {boolean}
|
|
*/
|
|
function hasArrayNature(obj) {
|
|
return (
|
|
// not null/false
|
|
!!obj &&
|
|
// arrays are objects, NodeLists are functions in Safari
|
|
(typeof obj == 'object' || typeof obj == 'function') &&
|
|
// quacks like an array
|
|
('length' in obj) &&
|
|
// not window
|
|
!('setInterval' in obj) &&
|
|
// no DOM node should be considered an array-like
|
|
// a 'select' element has 'length' and 'item' properties on IE8
|
|
(typeof obj.nodeType != 'number') &&
|
|
(
|
|
// a real array
|
|
(// HTMLCollection/NodeList
|
|
(Array.isArray(obj) ||
|
|
// arguments
|
|
('callee' in obj) || 'item' in obj))
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Ensure that the argument is an array by wrapping it in an array if it is not.
|
|
* Creates a copy of the argument if it is already an array.
|
|
*
|
|
* This is mostly useful idiomatically:
|
|
*
|
|
* var createArrayFrom = require('createArrayFrom');
|
|
*
|
|
* function takesOneOrMoreThings(things) {
|
|
* things = createArrayFrom(things);
|
|
* ...
|
|
* }
|
|
*
|
|
* This allows you to treat `things' as an array, but accept scalars in the API.
|
|
*
|
|
* If you need to convert an array-like object, like `arguments`, into an array
|
|
* use toArray instead.
|
|
*
|
|
* @param {*} obj
|
|
* @return {array}
|
|
*/
|
|
function createArrayFrom(obj) {
|
|
if (!hasArrayNature(obj)) {
|
|
return [obj];
|
|
} else if (Array.isArray(obj)) {
|
|
return obj.slice();
|
|
} else {
|
|
return toArray(obj);
|
|
}
|
|
}
|
|
|
|
module.exports = createArrayFrom;
|
|
|
|
},{"./toArray":199}],158:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule createFullPageComponent
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
// Defeat circular references by requiring this directly.
|
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
var ReactElement = require("./ReactElement");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Create a component that will throw an exception when unmounted.
|
|
*
|
|
* Components like <html> <head> and <body> can't be removed or added
|
|
* easily in a cross-browser way, however it's valuable to be able to
|
|
* take advantage of React's reconciliation for styling and <title>
|
|
* management. So we just document it and throw in dangerous cases.
|
|
*
|
|
* @param {string} tag The tag to wrap
|
|
* @return {function} convenience constructor of new component
|
|
*/
|
|
function createFullPageComponent(tag) {
|
|
var elementFactory = ReactElement.createFactory(tag);
|
|
|
|
var FullPageComponent = ReactCompositeComponent.createClass({
|
|
displayName: 'ReactFullPageComponent' + tag,
|
|
|
|
componentWillUnmount: function() {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
false,
|
|
'%s tried to unmount. Because of cross-browser quirks it is ' +
|
|
'impossible to unmount some top-level components (eg <html>, <head>, ' +
|
|
'and <body>) reliably and efficiently. To fix this, have a single ' +
|
|
'top-level component that never unmounts render these elements.',
|
|
this.constructor.displayName
|
|
) : invariant(false));
|
|
},
|
|
|
|
render: function() {
|
|
return elementFactory(this.props);
|
|
}
|
|
});
|
|
|
|
return FullPageComponent;
|
|
}
|
|
|
|
module.exports = createFullPageComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactCompositeComponent":81,"./ReactElement":99,"./invariant":182,"_process":1}],159:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule createNodesFromMarkup
|
|
* @typechecks
|
|
*/
|
|
|
|
/*jslint evil: true, sub: true */
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var createArrayFrom = require("./createArrayFrom");
|
|
var getMarkupWrap = require("./getMarkupWrap");
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Dummy container used to render all markup.
|
|
*/
|
|
var dummyNode =
|
|
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
|
|
|
/**
|
|
* Pattern used by `getNodeName`.
|
|
*/
|
|
var nodeNamePattern = /^\s*<(\w+)/;
|
|
|
|
/**
|
|
* Extracts the `nodeName` of the first element in a string of markup.
|
|
*
|
|
* @param {string} markup String of markup.
|
|
* @return {?string} Node name of the supplied markup.
|
|
*/
|
|
function getNodeName(markup) {
|
|
var nodeNameMatch = markup.match(nodeNamePattern);
|
|
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
|
|
}
|
|
|
|
/**
|
|
* Creates an array containing the nodes rendered from the supplied markup. The
|
|
* optionally supplied `handleScript` function will be invoked once for each
|
|
* <script> element that is rendered. If no `handleScript` function is supplied,
|
|
* an exception is thrown if any <script> elements are rendered.
|
|
*
|
|
* @param {string} markup A string of valid HTML markup.
|
|
* @param {?function} handleScript Invoked once for each rendered <script>.
|
|
* @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
|
|
*/
|
|
function createNodesFromMarkup(markup, handleScript) {
|
|
var node = dummyNode;
|
|
("production" !== process.env.NODE_ENV ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
|
|
var nodeName = getNodeName(markup);
|
|
|
|
var wrap = nodeName && getMarkupWrap(nodeName);
|
|
if (wrap) {
|
|
node.innerHTML = wrap[1] + markup + wrap[2];
|
|
|
|
var wrapDepth = wrap[0];
|
|
while (wrapDepth--) {
|
|
node = node.lastChild;
|
|
}
|
|
} else {
|
|
node.innerHTML = markup;
|
|
}
|
|
|
|
var scripts = node.getElementsByTagName('script');
|
|
if (scripts.length) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
handleScript,
|
|
'createNodesFromMarkup(...): Unexpected <script> element rendered.'
|
|
) : invariant(handleScript));
|
|
createArrayFrom(scripts).forEach(handleScript);
|
|
}
|
|
|
|
var nodes = createArrayFrom(node.childNodes);
|
|
while (node.lastChild) {
|
|
node.removeChild(node.lastChild);
|
|
}
|
|
return nodes;
|
|
}
|
|
|
|
module.exports = createNodesFromMarkup;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ExecutionEnvironment":64,"./createArrayFrom":157,"./getMarkupWrap":174,"./invariant":182,"_process":1}],160:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule cx
|
|
*/
|
|
|
|
/**
|
|
* This function is used to mark string literals representing CSS class names
|
|
* so that they can be transformed statically. This allows for modularization
|
|
* and minification of CSS class names.
|
|
*
|
|
* In static_upstream, this function is actually implemented, but it should
|
|
* eventually be replaced with something more descriptive, and the transform
|
|
* that is used in the main stack should be ported for use elsewhere.
|
|
*
|
|
* @param string|object className to modularize, or an object of key/values.
|
|
* In the object case, the values are conditions that
|
|
* determine if the className keys should be included.
|
|
* @param [string ...] Variable list of classNames in the string case.
|
|
* @return string Renderable space-separated CSS className.
|
|
*/
|
|
function cx(classNames) {
|
|
if (typeof classNames == 'object') {
|
|
return Object.keys(classNames).filter(function(className) {
|
|
return classNames[className];
|
|
}).join(' ');
|
|
} else {
|
|
return Array.prototype.join.call(arguments, ' ');
|
|
}
|
|
}
|
|
|
|
module.exports = cx;
|
|
|
|
},{}],161:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule dangerousStyleValue
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var CSSProperty = require("./CSSProperty");
|
|
|
|
var isUnitlessNumber = CSSProperty.isUnitlessNumber;
|
|
|
|
/**
|
|
* Convert a value into the proper css writable value. The style name `name`
|
|
* should be logical (no hyphens), as specified
|
|
* in `CSSProperty.isUnitlessNumber`.
|
|
*
|
|
* @param {string} name CSS property name such as `topMargin`.
|
|
* @param {*} value CSS property value such as `10px`.
|
|
* @return {string} Normalized style value with dimensions applied.
|
|
*/
|
|
function dangerousStyleValue(name, value) {
|
|
// Note that we've removed escapeTextForBrowser() calls here since the
|
|
// whole string will be escaped when the attribute is injected into
|
|
// the markup. If you provide unsafe user data here they can inject
|
|
// arbitrary CSS which may be problematic (I couldn't repro this):
|
|
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
|
|
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
|
|
// This is not an XSS hole but instead a potential CSS injection issue
|
|
// which has lead to a greater discussion about how we're going to
|
|
// trust URLs moving forward. See #2115901
|
|
|
|
var isEmpty = value == null || typeof value === 'boolean' || value === '';
|
|
if (isEmpty) {
|
|
return '';
|
|
}
|
|
|
|
var isNonNumeric = isNaN(value);
|
|
if (isNonNumeric || value === 0 ||
|
|
isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
|
|
return '' + value; // cast to string
|
|
}
|
|
|
|
if (typeof value === 'string') {
|
|
value = value.trim();
|
|
}
|
|
return value + 'px';
|
|
}
|
|
|
|
module.exports = dangerousStyleValue;
|
|
|
|
},{"./CSSProperty":46}],162:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule deprecated
|
|
*/
|
|
|
|
var assign = require("./Object.assign");
|
|
var warning = require("./warning");
|
|
|
|
/**
|
|
* This will log a single deprecation notice per function and forward the call
|
|
* on to the new API.
|
|
*
|
|
* @param {string} namespace The namespace of the call, eg 'React'
|
|
* @param {string} oldName The old function name, eg 'renderComponent'
|
|
* @param {string} newName The new function name, eg 'render'
|
|
* @param {*} ctx The context this forwarded call should run in
|
|
* @param {function} fn The function to forward on to
|
|
* @return {*} Will be the value as returned from `fn`
|
|
*/
|
|
function deprecated(namespace, oldName, newName, ctx, fn) {
|
|
var warned = false;
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
var newFn = function() {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
warned,
|
|
(namespace + "." + oldName + " will be deprecated in a future version. ") +
|
|
("Use " + namespace + "." + newName + " instead.")
|
|
) : null);
|
|
warned = true;
|
|
return fn.apply(ctx, arguments);
|
|
};
|
|
newFn.displayName = (namespace + "_" + oldName);
|
|
// We need to make sure all properties of the original fn are copied over.
|
|
// In particular, this is needed to support PropTypes
|
|
return assign(newFn, fn);
|
|
}
|
|
|
|
return fn;
|
|
}
|
|
|
|
module.exports = deprecated;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./warning":202,"_process":1}],163:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule emptyFunction
|
|
*/
|
|
|
|
function makeEmptyFunction(arg) {
|
|
return function() {
|
|
return arg;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* This function accepts and discards inputs; it has no side effects. This is
|
|
* primarily useful idiomatically for overridable function endpoints which
|
|
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
*/
|
|
function emptyFunction() {}
|
|
|
|
emptyFunction.thatReturns = makeEmptyFunction;
|
|
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
emptyFunction.thatReturnsThis = function() { return this; };
|
|
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
|
|
|
|
module.exports = emptyFunction;
|
|
|
|
},{}],164:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule emptyObject
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var emptyObject = {};
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
Object.freeze(emptyObject);
|
|
}
|
|
|
|
module.exports = emptyObject;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"_process":1}],165:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule escapeTextForBrowser
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ESCAPE_LOOKUP = {
|
|
"&": "&",
|
|
">": ">",
|
|
"<": "<",
|
|
"\"": """,
|
|
"'": "'"
|
|
};
|
|
|
|
var ESCAPE_REGEX = /[&><"']/g;
|
|
|
|
function escaper(match) {
|
|
return ESCAPE_LOOKUP[match];
|
|
}
|
|
|
|
/**
|
|
* Escapes text to prevent scripting attacks.
|
|
*
|
|
* @param {*} text Text value to escape.
|
|
* @return {string} An escaped string.
|
|
*/
|
|
function escapeTextForBrowser(text) {
|
|
return ('' + text).replace(ESCAPE_REGEX, escaper);
|
|
}
|
|
|
|
module.exports = escapeTextForBrowser;
|
|
|
|
},{}],166:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule flattenChildren
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactTextComponent = require("./ReactTextComponent");
|
|
|
|
var traverseAllChildren = require("./traverseAllChildren");
|
|
var warning = require("./warning");
|
|
|
|
/**
|
|
* @param {function} traverseContext Context passed through traversal.
|
|
* @param {?ReactComponent} child React child component.
|
|
* @param {!string} name String name of key path to child.
|
|
*/
|
|
function flattenSingleChildIntoContext(traverseContext, child, name) {
|
|
// We found a component instance.
|
|
var result = traverseContext;
|
|
var keyUnique = !result.hasOwnProperty(name);
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
keyUnique,
|
|
'flattenChildren(...): Encountered two children with the same key, ' +
|
|
'`%s`. Child keys must be unique; when two children share a key, only ' +
|
|
'the first child will be used.',
|
|
name
|
|
) : null);
|
|
if (keyUnique && child != null) {
|
|
var type = typeof child;
|
|
var normalizedValue;
|
|
|
|
if (type === 'string') {
|
|
normalizedValue = ReactTextComponent(child);
|
|
} else if (type === 'number') {
|
|
normalizedValue = ReactTextComponent('' + child);
|
|
} else {
|
|
normalizedValue = child;
|
|
}
|
|
|
|
result[name] = normalizedValue;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Flattens children that are typically specified as `props.children`. Any null
|
|
* children will not be included in the resulting object.
|
|
* @return {!object} flattened children keyed by name.
|
|
*/
|
|
function flattenChildren(children) {
|
|
if (children == null) {
|
|
return children;
|
|
}
|
|
var result = {};
|
|
traverseAllChildren(children, flattenSingleChildIntoContext, result);
|
|
return result;
|
|
}
|
|
|
|
module.exports = flattenChildren;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactTextComponent":128,"./traverseAllChildren":200,"./warning":202,"_process":1}],167:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule focusNode
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @param {DOMElement} node input/textarea to focus
|
|
*/
|
|
function focusNode(node) {
|
|
// IE8 can throw "Can't move focus to the control because it is invisible,
|
|
// not enabled, or of a type that does not accept the focus." for all kinds of
|
|
// reasons that are too expensive and fragile to test.
|
|
try {
|
|
node.focus();
|
|
} catch(e) {
|
|
}
|
|
}
|
|
|
|
module.exports = focusNode;
|
|
|
|
},{}],168:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule forEachAccumulated
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @param {array} an "accumulation" of items which is either an Array or
|
|
* a single item. Useful when paired with the `accumulate` module. This is a
|
|
* simple utility that allows us to reason about a collection of items, but
|
|
* handling the case when there is exactly one item (and we do not need to
|
|
* allocate an array).
|
|
*/
|
|
var forEachAccumulated = function(arr, cb, scope) {
|
|
if (Array.isArray(arr)) {
|
|
arr.forEach(cb, scope);
|
|
} else if (arr) {
|
|
cb.call(scope, arr);
|
|
}
|
|
};
|
|
|
|
module.exports = forEachAccumulated;
|
|
|
|
},{}],169:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getActiveElement
|
|
* @typechecks
|
|
*/
|
|
|
|
/**
|
|
* Same as document.activeElement but wraps in a try-catch block. In IE it is
|
|
* not safe to call document.activeElement if there is nothing focused.
|
|
*
|
|
* The activeElement will be null only if the document body is not yet defined.
|
|
*/
|
|
function getActiveElement() /*?DOMElement*/ {
|
|
try {
|
|
return document.activeElement || document.body;
|
|
} catch (e) {
|
|
return document.body;
|
|
}
|
|
}
|
|
|
|
module.exports = getActiveElement;
|
|
|
|
},{}],170:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getEventCharCode
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* `charCode` represents the actual "character code" and is safe to use with
|
|
* `String.fromCharCode`. As such, only keys that correspond to printable
|
|
* characters produce a valid `charCode`, the only exception to this is Enter.
|
|
* The Tab-key is considered non-printable and does not have a `charCode`,
|
|
* presumably because it does not produce a tab-character in browsers.
|
|
*
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {string} Normalized `charCode` property.
|
|
*/
|
|
function getEventCharCode(nativeEvent) {
|
|
var charCode;
|
|
var keyCode = nativeEvent.keyCode;
|
|
|
|
if ('charCode' in nativeEvent) {
|
|
charCode = nativeEvent.charCode;
|
|
|
|
// FF does not set `charCode` for the Enter-key, check against `keyCode`.
|
|
if (charCode === 0 && keyCode === 13) {
|
|
charCode = 13;
|
|
}
|
|
} else {
|
|
// IE8 does not implement `charCode`, but `keyCode` has the correct value.
|
|
charCode = keyCode;
|
|
}
|
|
|
|
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
|
|
// Must not discard the (non-)printable Enter-key.
|
|
if (charCode >= 32 || charCode === 13) {
|
|
return charCode;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
module.exports = getEventCharCode;
|
|
|
|
},{}],171:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getEventKey
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var getEventCharCode = require("./getEventCharCode");
|
|
|
|
/**
|
|
* Normalization of deprecated HTML5 `key` values
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
*/
|
|
var normalizeKey = {
|
|
'Esc': 'Escape',
|
|
'Spacebar': ' ',
|
|
'Left': 'ArrowLeft',
|
|
'Up': 'ArrowUp',
|
|
'Right': 'ArrowRight',
|
|
'Down': 'ArrowDown',
|
|
'Del': 'Delete',
|
|
'Win': 'OS',
|
|
'Menu': 'ContextMenu',
|
|
'Apps': 'ContextMenu',
|
|
'Scroll': 'ScrollLock',
|
|
'MozPrintableKey': 'Unidentified'
|
|
};
|
|
|
|
/**
|
|
* Translation from legacy `keyCode` to HTML5 `key`
|
|
* Only special keys supported, all others depend on keyboard layout or browser
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
|
*/
|
|
var translateToKey = {
|
|
8: 'Backspace',
|
|
9: 'Tab',
|
|
12: 'Clear',
|
|
13: 'Enter',
|
|
16: 'Shift',
|
|
17: 'Control',
|
|
18: 'Alt',
|
|
19: 'Pause',
|
|
20: 'CapsLock',
|
|
27: 'Escape',
|
|
32: ' ',
|
|
33: 'PageUp',
|
|
34: 'PageDown',
|
|
35: 'End',
|
|
36: 'Home',
|
|
37: 'ArrowLeft',
|
|
38: 'ArrowUp',
|
|
39: 'ArrowRight',
|
|
40: 'ArrowDown',
|
|
45: 'Insert',
|
|
46: 'Delete',
|
|
112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
|
|
118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
|
|
144: 'NumLock',
|
|
145: 'ScrollLock',
|
|
224: 'Meta'
|
|
};
|
|
|
|
/**
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {string} Normalized `key` property.
|
|
*/
|
|
function getEventKey(nativeEvent) {
|
|
if (nativeEvent.key) {
|
|
// Normalize inconsistent values reported by browsers due to
|
|
// implementations of a working draft specification.
|
|
|
|
// FireFox implements `key` but returns `MozPrintableKey` for all
|
|
// printable characters (normalized to `Unidentified`), ignore it.
|
|
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
|
|
if (key !== 'Unidentified') {
|
|
return key;
|
|
}
|
|
}
|
|
|
|
// Browser does not implement `key`, polyfill as much of it as we can.
|
|
if (nativeEvent.type === 'keypress') {
|
|
var charCode = getEventCharCode(nativeEvent);
|
|
|
|
// The enter-key is technically both printable and non-printable and can
|
|
// thus be captured by `keypress`, no other non-printable key should.
|
|
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
|
|
}
|
|
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
|
|
// While user keyboard layout determines the actual meaning of each
|
|
// `keyCode` value, almost all function keys have a universal value.
|
|
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
|
|
}
|
|
return '';
|
|
}
|
|
|
|
module.exports = getEventKey;
|
|
|
|
},{"./getEventCharCode":170}],172:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013 Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getEventModifierState
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Translation from modifier key to the associated property in the event.
|
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
|
|
*/
|
|
|
|
var modifierKeyToProp = {
|
|
'Alt': 'altKey',
|
|
'Control': 'ctrlKey',
|
|
'Meta': 'metaKey',
|
|
'Shift': 'shiftKey'
|
|
};
|
|
|
|
// IE8 does not implement getModifierState so we simply map it to the only
|
|
// modifier keys exposed by the event itself, does not support Lock-keys.
|
|
// Currently, all major browsers except Chrome seems to support Lock-keys.
|
|
function modifierStateGetter(keyArg) {
|
|
/*jshint validthis:true */
|
|
var syntheticEvent = this;
|
|
var nativeEvent = syntheticEvent.nativeEvent;
|
|
if (nativeEvent.getModifierState) {
|
|
return nativeEvent.getModifierState(keyArg);
|
|
}
|
|
var keyProp = modifierKeyToProp[keyArg];
|
|
return keyProp ? !!nativeEvent[keyProp] : false;
|
|
}
|
|
|
|
function getEventModifierState(nativeEvent) {
|
|
return modifierStateGetter;
|
|
}
|
|
|
|
module.exports = getEventModifierState;
|
|
|
|
},{}],173:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getEventTarget
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Gets the target node from a native browser event by accounting for
|
|
* inconsistencies in browser DOM APIs.
|
|
*
|
|
* @param {object} nativeEvent Native browser event.
|
|
* @return {DOMEventTarget} Target node.
|
|
*/
|
|
function getEventTarget(nativeEvent) {
|
|
var target = nativeEvent.target || nativeEvent.srcElement || window;
|
|
// Safari may fire events on text nodes (Node.TEXT_NODE is 3).
|
|
// @see http://www.quirksmode.org/js/events_properties.html
|
|
return target.nodeType === 3 ? target.parentNode : target;
|
|
}
|
|
|
|
module.exports = getEventTarget;
|
|
|
|
},{}],174:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getMarkupWrap
|
|
*/
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Dummy container used to detect which wraps are necessary.
|
|
*/
|
|
var dummyNode =
|
|
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
|
|
|
/**
|
|
* Some browsers cannot use `innerHTML` to render certain elements standalone,
|
|
* so we wrap them, render the wrapped nodes, then extract the desired node.
|
|
*
|
|
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
|
|
*/
|
|
var shouldWrap = {
|
|
// Force wrapping for SVG elements because if they get created inside a <div>,
|
|
// they will be initialized in the wrong namespace (and will not display).
|
|
'circle': true,
|
|
'defs': true,
|
|
'ellipse': true,
|
|
'g': true,
|
|
'line': true,
|
|
'linearGradient': true,
|
|
'path': true,
|
|
'polygon': true,
|
|
'polyline': true,
|
|
'radialGradient': true,
|
|
'rect': true,
|
|
'stop': true,
|
|
'text': true
|
|
};
|
|
|
|
var selectWrap = [1, '<select multiple="true">', '</select>'];
|
|
var tableWrap = [1, '<table>', '</table>'];
|
|
var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
|
|
|
|
var svgWrap = [1, '<svg>', '</svg>'];
|
|
|
|
var markupWrap = {
|
|
'*': [1, '?<div>', '</div>'],
|
|
|
|
'area': [1, '<map>', '</map>'],
|
|
'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
|
|
'legend': [1, '<fieldset>', '</fieldset>'],
|
|
'param': [1, '<object>', '</object>'],
|
|
'tr': [2, '<table><tbody>', '</tbody></table>'],
|
|
|
|
'optgroup': selectWrap,
|
|
'option': selectWrap,
|
|
|
|
'caption': tableWrap,
|
|
'colgroup': tableWrap,
|
|
'tbody': tableWrap,
|
|
'tfoot': tableWrap,
|
|
'thead': tableWrap,
|
|
|
|
'td': trWrap,
|
|
'th': trWrap,
|
|
|
|
'circle': svgWrap,
|
|
'defs': svgWrap,
|
|
'ellipse': svgWrap,
|
|
'g': svgWrap,
|
|
'line': svgWrap,
|
|
'linearGradient': svgWrap,
|
|
'path': svgWrap,
|
|
'polygon': svgWrap,
|
|
'polyline': svgWrap,
|
|
'radialGradient': svgWrap,
|
|
'rect': svgWrap,
|
|
'stop': svgWrap,
|
|
'text': svgWrap
|
|
};
|
|
|
|
/**
|
|
* Gets the markup wrap configuration for the supplied `nodeName`.
|
|
*
|
|
* NOTE: This lazily detects which wraps are necessary for the current browser.
|
|
*
|
|
* @param {string} nodeName Lowercase `nodeName`.
|
|
* @return {?array} Markup wrap configuration, if applicable.
|
|
*/
|
|
function getMarkupWrap(nodeName) {
|
|
("production" !== process.env.NODE_ENV ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
|
|
if (!markupWrap.hasOwnProperty(nodeName)) {
|
|
nodeName = '*';
|
|
}
|
|
if (!shouldWrap.hasOwnProperty(nodeName)) {
|
|
if (nodeName === '*') {
|
|
dummyNode.innerHTML = '<link />';
|
|
} else {
|
|
dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
|
|
}
|
|
shouldWrap[nodeName] = !dummyNode.firstChild;
|
|
}
|
|
return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
|
|
}
|
|
|
|
|
|
module.exports = getMarkupWrap;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ExecutionEnvironment":64,"./invariant":182,"_process":1}],175:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getNodeForCharacterOffset
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Given any node return the first leaf node without children.
|
|
*
|
|
* @param {DOMElement|DOMTextNode} node
|
|
* @return {DOMElement|DOMTextNode}
|
|
*/
|
|
function getLeafNode(node) {
|
|
while (node && node.firstChild) {
|
|
node = node.firstChild;
|
|
}
|
|
return node;
|
|
}
|
|
|
|
/**
|
|
* Get the next sibling within a container. This will walk up the
|
|
* DOM if a node's siblings have been exhausted.
|
|
*
|
|
* @param {DOMElement|DOMTextNode} node
|
|
* @return {?DOMElement|DOMTextNode}
|
|
*/
|
|
function getSiblingNode(node) {
|
|
while (node) {
|
|
if (node.nextSibling) {
|
|
return node.nextSibling;
|
|
}
|
|
node = node.parentNode;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get object describing the nodes which contain characters at offset.
|
|
*
|
|
* @param {DOMElement|DOMTextNode} root
|
|
* @param {number} offset
|
|
* @return {?object}
|
|
*/
|
|
function getNodeForCharacterOffset(root, offset) {
|
|
var node = getLeafNode(root);
|
|
var nodeStart = 0;
|
|
var nodeEnd = 0;
|
|
|
|
while (node) {
|
|
if (node.nodeType == 3) {
|
|
nodeEnd = nodeStart + node.textContent.length;
|
|
|
|
if (nodeStart <= offset && nodeEnd >= offset) {
|
|
return {
|
|
node: node,
|
|
offset: offset - nodeStart
|
|
};
|
|
}
|
|
|
|
nodeStart = nodeEnd;
|
|
}
|
|
|
|
node = getLeafNode(getSiblingNode(node));
|
|
}
|
|
}
|
|
|
|
module.exports = getNodeForCharacterOffset;
|
|
|
|
},{}],176:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getReactRootElementInContainer
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var DOC_NODE_TYPE = 9;
|
|
|
|
/**
|
|
* @param {DOMElement|DOMDocument} container DOM element that may contain
|
|
* a React component
|
|
* @return {?*} DOM element that may have the reactRoot ID, or null.
|
|
*/
|
|
function getReactRootElementInContainer(container) {
|
|
if (!container) {
|
|
return null;
|
|
}
|
|
|
|
if (container.nodeType === DOC_NODE_TYPE) {
|
|
return container.documentElement;
|
|
} else {
|
|
return container.firstChild;
|
|
}
|
|
}
|
|
|
|
module.exports = getReactRootElementInContainer;
|
|
|
|
},{}],177:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getTextContentAccessor
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var contentKey = null;
|
|
|
|
/**
|
|
* Gets the key used to access text content on a DOM node.
|
|
*
|
|
* @return {?string} Key used to access text content.
|
|
* @internal
|
|
*/
|
|
function getTextContentAccessor() {
|
|
if (!contentKey && ExecutionEnvironment.canUseDOM) {
|
|
// Prefer textContent to innerText because many browsers support both but
|
|
// SVG <text> elements don't support innerText even when <div> does.
|
|
contentKey = 'textContent' in document.documentElement ?
|
|
'textContent' :
|
|
'innerText';
|
|
}
|
|
return contentKey;
|
|
}
|
|
|
|
module.exports = getTextContentAccessor;
|
|
|
|
},{"./ExecutionEnvironment":64}],178:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule getUnboundedScrollPosition
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Gets the scroll position of the supplied element or window.
|
|
*
|
|
* The return values are unbounded, unlike `getScrollPosition`. This means they
|
|
* may be negative or exceed the element boundaries (which is possible using
|
|
* inertial scrolling).
|
|
*
|
|
* @param {DOMWindow|DOMElement} scrollable
|
|
* @return {object} Map with `x` and `y` keys.
|
|
*/
|
|
function getUnboundedScrollPosition(scrollable) {
|
|
if (scrollable === window) {
|
|
return {
|
|
x: window.pageXOffset || document.documentElement.scrollLeft,
|
|
y: window.pageYOffset || document.documentElement.scrollTop
|
|
};
|
|
}
|
|
return {
|
|
x: scrollable.scrollLeft,
|
|
y: scrollable.scrollTop
|
|
};
|
|
}
|
|
|
|
module.exports = getUnboundedScrollPosition;
|
|
|
|
},{}],179:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule hyphenate
|
|
* @typechecks
|
|
*/
|
|
|
|
var _uppercasePattern = /([A-Z])/g;
|
|
|
|
/**
|
|
* Hyphenates a camelcased string, for example:
|
|
*
|
|
* > hyphenate('backgroundColor')
|
|
* < "background-color"
|
|
*
|
|
* For CSS style names, use `hyphenateStyleName` instead which works properly
|
|
* with all vendor prefixes, including `ms`.
|
|
*
|
|
* @param {string} string
|
|
* @return {string}
|
|
*/
|
|
function hyphenate(string) {
|
|
return string.replace(_uppercasePattern, '-$1').toLowerCase();
|
|
}
|
|
|
|
module.exports = hyphenate;
|
|
|
|
},{}],180:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule hyphenateStyleName
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var hyphenate = require("./hyphenate");
|
|
|
|
var msPattern = /^ms-/;
|
|
|
|
/**
|
|
* Hyphenates a camelcased CSS property name, for example:
|
|
*
|
|
* > hyphenateStyleName('backgroundColor')
|
|
* < "background-color"
|
|
* > hyphenateStyleName('MozTransition')
|
|
* < "-moz-transition"
|
|
* > hyphenateStyleName('msTransition')
|
|
* < "-ms-transition"
|
|
*
|
|
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
|
* is converted to `-ms-`.
|
|
*
|
|
* @param {string} string
|
|
* @return {string}
|
|
*/
|
|
function hyphenateStyleName(string) {
|
|
return hyphenate(string).replace(msPattern, '-ms-');
|
|
}
|
|
|
|
module.exports = hyphenateStyleName;
|
|
|
|
},{"./hyphenate":179}],181:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule instantiateReactComponent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var warning = require("./warning");
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactLegacyElement = require("./ReactLegacyElement");
|
|
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
|
|
/**
|
|
* Given an `element` create an instance that will actually be mounted.
|
|
*
|
|
* @param {object} element
|
|
* @param {*} parentCompositeType The composite type that resolved this.
|
|
* @return {object} A new instance of the element's constructor.
|
|
* @protected
|
|
*/
|
|
function instantiateReactComponent(element, parentCompositeType) {
|
|
var instance;
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
element && (typeof element.type === 'function' ||
|
|
typeof element.type === 'string'),
|
|
'Only functions or strings can be mounted as React components.'
|
|
) : null);
|
|
|
|
// Resolve mock instances
|
|
if (element.type._mockedReactClassConstructor) {
|
|
// If this is a mocked class, we treat the legacy factory as if it was the
|
|
// class constructor for future proofing unit tests. Because this might
|
|
// be mocked as a legacy factory, we ignore any warnings triggerd by
|
|
// this temporary hack.
|
|
ReactLegacyElement._isLegacyCallWarningEnabled = false;
|
|
try {
|
|
instance = new element.type._mockedReactClassConstructor(
|
|
element.props
|
|
);
|
|
} finally {
|
|
ReactLegacyElement._isLegacyCallWarningEnabled = true;
|
|
}
|
|
|
|
// If the mock implementation was a legacy factory, then it returns a
|
|
// element. We need to turn this into a real component instance.
|
|
if (ReactElement.isValidElement(instance)) {
|
|
instance = new instance.type(instance.props);
|
|
}
|
|
|
|
var render = instance.render;
|
|
if (!render) {
|
|
// For auto-mocked factories, the prototype isn't shimmed and therefore
|
|
// there is no render function on the instance. We replace the whole
|
|
// component with an empty component instance instead.
|
|
element = ReactEmptyComponent.getEmptyComponent();
|
|
} else {
|
|
if (render._isMockFunction && !render._getMockImplementation()) {
|
|
// Auto-mocked components may have a prototype with a mocked render
|
|
// function. For those, we'll need to mock the result of the render
|
|
// since we consider undefined to be invalid results from render.
|
|
render.mockImplementation(
|
|
ReactEmptyComponent.getEmptyComponent
|
|
);
|
|
}
|
|
instance.construct(element);
|
|
return instance;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Special case string values
|
|
if (typeof element.type === 'string') {
|
|
instance = ReactNativeComponent.createInstanceForTag(
|
|
element.type,
|
|
element.props,
|
|
parentCompositeType
|
|
);
|
|
} else {
|
|
// Normal case for non-mocks and non-strings
|
|
instance = new element.type(element.props);
|
|
}
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
("production" !== process.env.NODE_ENV ? warning(
|
|
typeof instance.construct === 'function' &&
|
|
typeof instance.mountComponent === 'function' &&
|
|
typeof instance.receiveComponent === 'function',
|
|
'Only React Components can be mounted.'
|
|
) : null);
|
|
}
|
|
|
|
// This actually sets up the internal instance. This will become decoupled
|
|
// from the public instance in a future diff.
|
|
instance.construct(element);
|
|
|
|
return instance;
|
|
}
|
|
|
|
module.exports = instantiateReactComponent;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./ReactEmptyComponent":101,"./ReactLegacyElement":108,"./ReactNativeComponent":114,"./warning":202,"_process":1}],182:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule invariant
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Use invariant() to assert state which your program assumes to be true.
|
|
*
|
|
* Provide sprintf-style format (only %s is supported) and arguments
|
|
* to provide information about what broke and what you were
|
|
* expecting.
|
|
*
|
|
* The invariant message will be stripped in production, but the invariant
|
|
* will remain to ensure logic does not differ in production.
|
|
*/
|
|
|
|
var invariant = function(condition, format, a, b, c, d, e, f) {
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
if (format === undefined) {
|
|
throw new Error('invariant requires an error message argument');
|
|
}
|
|
}
|
|
|
|
if (!condition) {
|
|
var error;
|
|
if (format === undefined) {
|
|
error = new Error(
|
|
'Minified exception occurred; use the non-minified dev environment ' +
|
|
'for the full error message and additional helpful warnings.'
|
|
);
|
|
} else {
|
|
var args = [a, b, c, d, e, f];
|
|
var argIndex = 0;
|
|
error = new Error(
|
|
'Invariant Violation: ' +
|
|
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
);
|
|
}
|
|
|
|
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
throw error;
|
|
}
|
|
};
|
|
|
|
module.exports = invariant;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"_process":1}],183:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule isEventSupported
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var useHasFeature;
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
useHasFeature =
|
|
document.implementation &&
|
|
document.implementation.hasFeature &&
|
|
// always returns true in newer browsers as per the standard.
|
|
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
document.implementation.hasFeature('', '') !== true;
|
|
}
|
|
|
|
/**
|
|
* Checks if an event is supported in the current execution environment.
|
|
*
|
|
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
* `reset`, `load`, `error`, and `select`.
|
|
*
|
|
* Borrows from Modernizr.
|
|
*
|
|
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
* @param {?boolean} capture Check if the capture phase is supported.
|
|
* @return {boolean} True if the event is supported.
|
|
* @internal
|
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
*/
|
|
function isEventSupported(eventNameSuffix, capture) {
|
|
if (!ExecutionEnvironment.canUseDOM ||
|
|
capture && !('addEventListener' in document)) {
|
|
return false;
|
|
}
|
|
|
|
var eventName = 'on' + eventNameSuffix;
|
|
var isSupported = eventName in document;
|
|
|
|
if (!isSupported) {
|
|
var element = document.createElement('div');
|
|
element.setAttribute(eventName, 'return;');
|
|
isSupported = typeof element[eventName] === 'function';
|
|
}
|
|
|
|
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
|
|
// This is the only way to test support for the `wheel` event in IE9+.
|
|
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
|
}
|
|
|
|
return isSupported;
|
|
}
|
|
|
|
module.exports = isEventSupported;
|
|
|
|
},{"./ExecutionEnvironment":64}],184:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule isNode
|
|
* @typechecks
|
|
*/
|
|
|
|
/**
|
|
* @param {*} object The object to check.
|
|
* @return {boolean} Whether or not the object is a DOM node.
|
|
*/
|
|
function isNode(object) {
|
|
return !!(object && (
|
|
typeof Node === 'function' ? object instanceof Node :
|
|
typeof object === 'object' &&
|
|
typeof object.nodeType === 'number' &&
|
|
typeof object.nodeName === 'string'
|
|
));
|
|
}
|
|
|
|
module.exports = isNode;
|
|
|
|
},{}],185:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule isTextInputElement
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
|
|
*/
|
|
var supportedInputTypes = {
|
|
'color': true,
|
|
'date': true,
|
|
'datetime': true,
|
|
'datetime-local': true,
|
|
'email': true,
|
|
'month': true,
|
|
'number': true,
|
|
'password': true,
|
|
'range': true,
|
|
'search': true,
|
|
'tel': true,
|
|
'text': true,
|
|
'time': true,
|
|
'url': true,
|
|
'week': true
|
|
};
|
|
|
|
function isTextInputElement(elem) {
|
|
return elem && (
|
|
(elem.nodeName === 'INPUT' && supportedInputTypes[elem.type]) ||
|
|
elem.nodeName === 'TEXTAREA'
|
|
);
|
|
}
|
|
|
|
module.exports = isTextInputElement;
|
|
|
|
},{}],186:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule isTextNode
|
|
* @typechecks
|
|
*/
|
|
|
|
var isNode = require("./isNode");
|
|
|
|
/**
|
|
* @param {*} object The object to check.
|
|
* @return {boolean} Whether or not the object is a DOM text node.
|
|
*/
|
|
function isTextNode(object) {
|
|
return isNode(object) && object.nodeType == 3;
|
|
}
|
|
|
|
module.exports = isTextNode;
|
|
|
|
},{"./isNode":184}],187:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule joinClasses
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Combines multiple className strings into one.
|
|
* http://jsperf.com/joinclasses-args-vs-array
|
|
*
|
|
* @param {...?string} classes
|
|
* @return {string}
|
|
*/
|
|
function joinClasses(className/*, ... */) {
|
|
if (!className) {
|
|
className = '';
|
|
}
|
|
var nextClass;
|
|
var argLength = arguments.length;
|
|
if (argLength > 1) {
|
|
for (var ii = 1; ii < argLength; ii++) {
|
|
nextClass = arguments[ii];
|
|
if (nextClass) {
|
|
className = (className ? className + ' ' : '') + nextClass;
|
|
}
|
|
}
|
|
}
|
|
return className;
|
|
}
|
|
|
|
module.exports = joinClasses;
|
|
|
|
},{}],188:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule keyMirror
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Constructs an enumeration with keys equal to their value.
|
|
*
|
|
* For example:
|
|
*
|
|
* var COLORS = keyMirror({blue: null, red: null});
|
|
* var myColor = COLORS.blue;
|
|
* var isColorValid = !!COLORS[myColor];
|
|
*
|
|
* The last line could not be performed if the values of the generated enum were
|
|
* not equal to their keys.
|
|
*
|
|
* Input: {key1: val1, key2: val2}
|
|
* Output: {key1: key1, key2: key2}
|
|
*
|
|
* @param {object} obj
|
|
* @return {object}
|
|
*/
|
|
var keyMirror = function(obj) {
|
|
var ret = {};
|
|
var key;
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
obj instanceof Object && !Array.isArray(obj),
|
|
'keyMirror(...): Argument must be an object.'
|
|
) : invariant(obj instanceof Object && !Array.isArray(obj)));
|
|
for (key in obj) {
|
|
if (!obj.hasOwnProperty(key)) {
|
|
continue;
|
|
}
|
|
ret[key] = key;
|
|
}
|
|
return ret;
|
|
};
|
|
|
|
module.exports = keyMirror;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],189:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule keyOf
|
|
*/
|
|
|
|
/**
|
|
* Allows extraction of a minified key. Let's the build system minify keys
|
|
* without loosing the ability to dynamically use key strings as values
|
|
* themselves. Pass in an object with a single key/val pair and it will return
|
|
* you the string key of that single record. Suppose you want to grab the
|
|
* value for a key 'className' inside of an object. Key/val minification may
|
|
* have aliased that key to be 'xa12'. keyOf({className: null}) will return
|
|
* 'xa12' in that case. Resolve keys you want to use once at startup time, then
|
|
* reuse those resolutions.
|
|
*/
|
|
var keyOf = function(oneKeyObj) {
|
|
var key;
|
|
for (key in oneKeyObj) {
|
|
if (!oneKeyObj.hasOwnProperty(key)) {
|
|
continue;
|
|
}
|
|
return key;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
module.exports = keyOf;
|
|
|
|
},{}],190:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule mapObject
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
/**
|
|
* Executes the provided `callback` once for each enumerable own property in the
|
|
* object and constructs a new object from the results. The `callback` is
|
|
* invoked with three arguments:
|
|
*
|
|
* - the property value
|
|
* - the property name
|
|
* - the object being traversed
|
|
*
|
|
* Properties that are added after the call to `mapObject` will not be visited
|
|
* by `callback`. If the values of existing properties are changed, the value
|
|
* passed to `callback` will be the value at the time `mapObject` visits them.
|
|
* Properties that are deleted before being visited are not visited.
|
|
*
|
|
* @grep function objectMap()
|
|
* @grep function objMap()
|
|
*
|
|
* @param {?object} object
|
|
* @param {function} callback
|
|
* @param {*} context
|
|
* @return {?object}
|
|
*/
|
|
function mapObject(object, callback, context) {
|
|
if (!object) {
|
|
return null;
|
|
}
|
|
var result = {};
|
|
for (var name in object) {
|
|
if (hasOwnProperty.call(object, name)) {
|
|
result[name] = callback.call(context, object[name], name, object);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
module.exports = mapObject;
|
|
|
|
},{}],191:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule memoizeStringOnly
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Memoizes the return value of a function that accepts one string argument.
|
|
*
|
|
* @param {function} callback
|
|
* @return {function}
|
|
*/
|
|
function memoizeStringOnly(callback) {
|
|
var cache = {};
|
|
return function(string) {
|
|
if (cache.hasOwnProperty(string)) {
|
|
return cache[string];
|
|
} else {
|
|
return cache[string] = callback.call(this, string);
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = memoizeStringOnly;
|
|
|
|
},{}],192:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule monitorCodeUse
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Provides open-source compatible instrumentation for monitoring certain API
|
|
* uses before we're ready to issue a warning or refactor. It accepts an event
|
|
* name which may only contain the characters [a-z0-9_] and an optional data
|
|
* object with further information.
|
|
*/
|
|
|
|
function monitorCodeUse(eventName, data) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
eventName && !/[^a-z0-9_]/.test(eventName),
|
|
'You must provide an eventName using only the characters [a-z0-9_]'
|
|
) : invariant(eventName && !/[^a-z0-9_]/.test(eventName)));
|
|
}
|
|
|
|
module.exports = monitorCodeUse;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],193:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule onlyChild
|
|
*/
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Returns the first child in a collection of children and verifies that there
|
|
* is only one child in the collection. The current implementation of this
|
|
* function assumes that a single child gets passed without a wrapper, but the
|
|
* purpose of this helper function is to abstract away the particular structure
|
|
* of children.
|
|
*
|
|
* @param {?object} children Child collection structure.
|
|
* @return {ReactComponent} The first and only `ReactComponent` contained in the
|
|
* structure.
|
|
*/
|
|
function onlyChild(children) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
ReactElement.isValidElement(children),
|
|
'onlyChild must be passed a children with exactly one child.'
|
|
) : invariant(ReactElement.isValidElement(children)));
|
|
return children;
|
|
}
|
|
|
|
module.exports = onlyChild;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./invariant":182,"_process":1}],194:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule performance
|
|
* @typechecks
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var performance;
|
|
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
performance =
|
|
window.performance ||
|
|
window.msPerformance ||
|
|
window.webkitPerformance;
|
|
}
|
|
|
|
module.exports = performance || {};
|
|
|
|
},{"./ExecutionEnvironment":64}],195:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule performanceNow
|
|
* @typechecks
|
|
*/
|
|
|
|
var performance = require("./performance");
|
|
|
|
/**
|
|
* Detect if we can use `window.performance.now()` and gracefully fallback to
|
|
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
|
|
* because of Facebook's testing infrastructure.
|
|
*/
|
|
if (!performance || !performance.now) {
|
|
performance = Date;
|
|
}
|
|
|
|
var performanceNow = performance.now.bind(performance);
|
|
|
|
module.exports = performanceNow;
|
|
|
|
},{"./performance":194}],196:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule setInnerHTML
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
|
|
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
|
|
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
|
|
/**
|
|
* Set the innerHTML property of a node, ensuring that whitespace is preserved
|
|
* even in IE8.
|
|
*
|
|
* @param {DOMElement} node
|
|
* @param {string} html
|
|
* @internal
|
|
*/
|
|
var setInnerHTML = function(node, html) {
|
|
node.innerHTML = html;
|
|
};
|
|
|
|
if (ExecutionEnvironment.canUseDOM) {
|
|
// IE8: When updating a just created node with innerHTML only leading
|
|
// whitespace is removed. When updating an existing node with innerHTML
|
|
// whitespace in root TextNodes is also collapsed.
|
|
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
|
|
|
|
// Feature detection; only IE8 is known to behave improperly like this.
|
|
var testElement = document.createElement('div');
|
|
testElement.innerHTML = ' ';
|
|
if (testElement.innerHTML === '') {
|
|
setInnerHTML = function(node, html) {
|
|
// Magic theory: IE8 supposedly differentiates between added and updated
|
|
// nodes when processing innerHTML, innerHTML on updated nodes suffers
|
|
// from worse whitespace behavior. Re-adding a node like this triggers
|
|
// the initial and more favorable whitespace behavior.
|
|
// TODO: What to do on a detached node?
|
|
if (node.parentNode) {
|
|
node.parentNode.replaceChild(node, node);
|
|
}
|
|
|
|
// We also implement a workaround for non-visible tags disappearing into
|
|
// thin air on IE8, this only happens if there is no visible text
|
|
// in-front of the non-visible tags. Piggyback on the whitespace fix
|
|
// and simply check if any non-visible tags appear in the source.
|
|
if (WHITESPACE_TEST.test(html) ||
|
|
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
|
// Recover leading whitespace by temporarily prepending any character.
|
|
// \uFEFF has the potential advantage of being zero-width/invisible.
|
|
node.innerHTML = '\uFEFF' + html;
|
|
|
|
// deleteData leaves an empty `TextNode` which offsets the index of all
|
|
// children. Definitely want to avoid this.
|
|
var textNode = node.firstChild;
|
|
if (textNode.data.length === 1) {
|
|
node.removeChild(textNode);
|
|
} else {
|
|
textNode.deleteData(0, 1);
|
|
}
|
|
} else {
|
|
node.innerHTML = html;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = setInnerHTML;
|
|
|
|
},{"./ExecutionEnvironment":64}],197:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule shallowEqual
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Performs equality by iterating through keys on an object and returning
|
|
* false when any key has values which are not strictly equal between
|
|
* objA and objB. Returns true when the values of all keys are strictly equal.
|
|
*
|
|
* @return {boolean}
|
|
*/
|
|
function shallowEqual(objA, objB) {
|
|
if (objA === objB) {
|
|
return true;
|
|
}
|
|
var key;
|
|
// Test for A's keys different from B.
|
|
for (key in objA) {
|
|
if (objA.hasOwnProperty(key) &&
|
|
(!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
|
|
return false;
|
|
}
|
|
}
|
|
// Test for B's keys missing from A.
|
|
for (key in objB) {
|
|
if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
module.exports = shallowEqual;
|
|
|
|
},{}],198:[function(require,module,exports){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule shouldUpdateReactComponent
|
|
* @typechecks static-only
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Given a `prevElement` and `nextElement`, determines if the existing
|
|
* instance should be updated as opposed to being destroyed or replaced by a new
|
|
* instance. Both arguments are elements. This ensures that this logic can
|
|
* operate on stateless trees without any backing instance.
|
|
*
|
|
* @param {?object} prevElement
|
|
* @param {?object} nextElement
|
|
* @return {boolean} True if the existing instance should be updated.
|
|
* @protected
|
|
*/
|
|
function shouldUpdateReactComponent(prevElement, nextElement) {
|
|
if (prevElement && nextElement &&
|
|
prevElement.type === nextElement.type &&
|
|
prevElement.key === nextElement.key &&
|
|
prevElement._owner === nextElement._owner) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
module.exports = shouldUpdateReactComponent;
|
|
|
|
},{}],199:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule toArray
|
|
* @typechecks
|
|
*/
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
/**
|
|
* Convert array-like objects to arrays.
|
|
*
|
|
* This API assumes the caller knows the contents of the data type. For less
|
|
* well defined inputs use createArrayFrom.
|
|
*
|
|
* @param {object|function|filelist} obj
|
|
* @return {array}
|
|
*/
|
|
function toArray(obj) {
|
|
var length = obj.length;
|
|
|
|
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
|
|
// old versions of Safari).
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!Array.isArray(obj) &&
|
|
(typeof obj === 'object' || typeof obj === 'function'),
|
|
'toArray: Array-like object expected'
|
|
) : invariant(!Array.isArray(obj) &&
|
|
(typeof obj === 'object' || typeof obj === 'function')));
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof length === 'number',
|
|
'toArray: Object needs a length property'
|
|
) : invariant(typeof length === 'number'));
|
|
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
length === 0 ||
|
|
(length - 1) in obj,
|
|
'toArray: Object should have keys for indices'
|
|
) : invariant(length === 0 ||
|
|
(length - 1) in obj));
|
|
|
|
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
|
|
// without method will throw during the slice call and skip straight to the
|
|
// fallback.
|
|
if (obj.hasOwnProperty) {
|
|
try {
|
|
return Array.prototype.slice.call(obj);
|
|
} catch (e) {
|
|
// IE < 9 does not support Array#slice on collections objects
|
|
}
|
|
}
|
|
|
|
// Fall back to copying key by key. This assumes all keys have a value,
|
|
// so will not preserve sparsely populated inputs.
|
|
var ret = Array(length);
|
|
for (var ii = 0; ii < length; ii++) {
|
|
ret[ii] = obj[ii];
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
module.exports = toArray;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./invariant":182,"_process":1}],200:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule traverseAllChildren
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var ReactElement = require("./ReactElement");
|
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
|
|
var invariant = require("./invariant");
|
|
|
|
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
|
var SUBSEPARATOR = ':';
|
|
|
|
/**
|
|
* TODO: Test that:
|
|
* 1. `mapChildren` transforms strings and numbers into `ReactTextComponent`.
|
|
* 2. it('should fail when supplied duplicate key', function() {
|
|
* 3. That a single child and an array with one item have the same key pattern.
|
|
* });
|
|
*/
|
|
|
|
var userProvidedKeyEscaperLookup = {
|
|
'=': '=0',
|
|
'.': '=1',
|
|
':': '=2'
|
|
};
|
|
|
|
var userProvidedKeyEscapeRegex = /[=.:]/g;
|
|
|
|
function userProvidedKeyEscaper(match) {
|
|
return userProvidedKeyEscaperLookup[match];
|
|
}
|
|
|
|
/**
|
|
* Generate a key string that identifies a component within a set.
|
|
*
|
|
* @param {*} component A component that could contain a manual key.
|
|
* @param {number} index Index that is used if a manual key is not provided.
|
|
* @return {string}
|
|
*/
|
|
function getComponentKey(component, index) {
|
|
if (component && component.key != null) {
|
|
// Explicit key
|
|
return wrapUserProvidedKey(component.key);
|
|
}
|
|
// Implicit key determined by the index in the set
|
|
return index.toString(36);
|
|
}
|
|
|
|
/**
|
|
* Escape a component key so that it is safe to use in a reactid.
|
|
*
|
|
* @param {*} key Component key to be escaped.
|
|
* @return {string} An escaped string.
|
|
*/
|
|
function escapeUserProvidedKey(text) {
|
|
return ('' + text).replace(
|
|
userProvidedKeyEscapeRegex,
|
|
userProvidedKeyEscaper
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Wrap a `key` value explicitly provided by the user to distinguish it from
|
|
* implicitly-generated keys generated by a component's index in its parent.
|
|
*
|
|
* @param {string} key Value of a user-provided `key` attribute
|
|
* @return {string}
|
|
*/
|
|
function wrapUserProvidedKey(key) {
|
|
return '$' + escapeUserProvidedKey(key);
|
|
}
|
|
|
|
/**
|
|
* @param {?*} children Children tree container.
|
|
* @param {!string} nameSoFar Name of the key path so far.
|
|
* @param {!number} indexSoFar Number of children encountered until this point.
|
|
* @param {!function} callback Callback to invoke with each child found.
|
|
* @param {?*} traverseContext Used to pass information throughout the traversal
|
|
* process.
|
|
* @return {!number} The number of children in this subtree.
|
|
*/
|
|
var traverseAllChildrenImpl =
|
|
function(children, nameSoFar, indexSoFar, callback, traverseContext) {
|
|
var nextName, nextIndex;
|
|
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
if (Array.isArray(children)) {
|
|
for (var i = 0; i < children.length; i++) {
|
|
var child = children[i];
|
|
nextName = (
|
|
nameSoFar +
|
|
(nameSoFar ? SUBSEPARATOR : SEPARATOR) +
|
|
getComponentKey(child, i)
|
|
);
|
|
nextIndex = indexSoFar + subtreeCount;
|
|
subtreeCount += traverseAllChildrenImpl(
|
|
child,
|
|
nextName,
|
|
nextIndex,
|
|
callback,
|
|
traverseContext
|
|
);
|
|
}
|
|
} else {
|
|
var type = typeof children;
|
|
var isOnlyChild = nameSoFar === '';
|
|
// If it's the only child, treat the name as if it was wrapped in an array
|
|
// so that it's consistent if the number of children grows
|
|
var storageName =
|
|
isOnlyChild ? SEPARATOR + getComponentKey(children, 0) : nameSoFar;
|
|
if (children == null || type === 'boolean') {
|
|
// All of the above are perceived as null.
|
|
callback(traverseContext, null, storageName, indexSoFar);
|
|
subtreeCount = 1;
|
|
} else if (type === 'string' || type === 'number' ||
|
|
ReactElement.isValidElement(children)) {
|
|
callback(traverseContext, children, storageName, indexSoFar);
|
|
subtreeCount = 1;
|
|
} else if (type === 'object') {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
!children || children.nodeType !== 1,
|
|
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
|
|
'elements are not valid children of React components.'
|
|
) : invariant(!children || children.nodeType !== 1));
|
|
for (var key in children) {
|
|
if (children.hasOwnProperty(key)) {
|
|
nextName = (
|
|
nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
|
|
wrapUserProvidedKey(key) + SUBSEPARATOR +
|
|
getComponentKey(children[key], 0)
|
|
);
|
|
nextIndex = indexSoFar + subtreeCount;
|
|
subtreeCount += traverseAllChildrenImpl(
|
|
children[key],
|
|
nextName,
|
|
nextIndex,
|
|
callback,
|
|
traverseContext
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return subtreeCount;
|
|
};
|
|
|
|
/**
|
|
* Traverses children that are typically specified as `props.children`, but
|
|
* might also be specified through attributes:
|
|
*
|
|
* - `traverseAllChildren(this.props.children, ...)`
|
|
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
|
|
*
|
|
* The `traverseContext` is an optional argument that is passed through the
|
|
* entire traversal. It can be used to store accumulations or anything else that
|
|
* the callback might find relevant.
|
|
*
|
|
* @param {?*} children Children tree object.
|
|
* @param {!function} callback To invoke upon traversing each child.
|
|
* @param {?*} traverseContext Context for traversal.
|
|
* @return {!number} The number of children in this subtree.
|
|
*/
|
|
function traverseAllChildren(children, callback, traverseContext) {
|
|
if (children == null) {
|
|
return 0;
|
|
}
|
|
|
|
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
|
}
|
|
|
|
module.exports = traverseAllChildren;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./ReactElement":99,"./ReactInstanceHandles":107,"./invariant":182,"_process":1}],201:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2013-2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule update
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var assign = require("./Object.assign");
|
|
var keyOf = require("./keyOf");
|
|
var invariant = require("./invariant");
|
|
|
|
function shallowCopy(x) {
|
|
if (Array.isArray(x)) {
|
|
return x.concat();
|
|
} else if (x && typeof x === 'object') {
|
|
return assign(new x.constructor(), x);
|
|
} else {
|
|
return x;
|
|
}
|
|
}
|
|
|
|
var COMMAND_PUSH = keyOf({$push: null});
|
|
var COMMAND_UNSHIFT = keyOf({$unshift: null});
|
|
var COMMAND_SPLICE = keyOf({$splice: null});
|
|
var COMMAND_SET = keyOf({$set: null});
|
|
var COMMAND_MERGE = keyOf({$merge: null});
|
|
var COMMAND_APPLY = keyOf({$apply: null});
|
|
|
|
var ALL_COMMANDS_LIST = [
|
|
COMMAND_PUSH,
|
|
COMMAND_UNSHIFT,
|
|
COMMAND_SPLICE,
|
|
COMMAND_SET,
|
|
COMMAND_MERGE,
|
|
COMMAND_APPLY
|
|
];
|
|
|
|
var ALL_COMMANDS_SET = {};
|
|
|
|
ALL_COMMANDS_LIST.forEach(function(command) {
|
|
ALL_COMMANDS_SET[command] = true;
|
|
});
|
|
|
|
function invariantArrayCase(value, spec, command) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Array.isArray(value),
|
|
'update(): expected target of %s to be an array; got %s.',
|
|
command,
|
|
value
|
|
) : invariant(Array.isArray(value)));
|
|
var specValue = spec[command];
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Array.isArray(specValue),
|
|
'update(): expected spec of %s to be an array; got %s. ' +
|
|
'Did you forget to wrap your parameter in an array?',
|
|
command,
|
|
specValue
|
|
) : invariant(Array.isArray(specValue)));
|
|
}
|
|
|
|
function update(value, spec) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof spec === 'object',
|
|
'update(): You provided a key path to update() that did not contain one ' +
|
|
'of %s. Did you forget to include {%s: ...}?',
|
|
ALL_COMMANDS_LIST.join(', '),
|
|
COMMAND_SET
|
|
) : invariant(typeof spec === 'object'));
|
|
|
|
if (spec.hasOwnProperty(COMMAND_SET)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Object.keys(spec).length === 1,
|
|
'Cannot have more than one key in an object with %s',
|
|
COMMAND_SET
|
|
) : invariant(Object.keys(spec).length === 1));
|
|
|
|
return spec[COMMAND_SET];
|
|
}
|
|
|
|
var nextValue = shallowCopy(value);
|
|
|
|
if (spec.hasOwnProperty(COMMAND_MERGE)) {
|
|
var mergeObj = spec[COMMAND_MERGE];
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
mergeObj && typeof mergeObj === 'object',
|
|
'update(): %s expects a spec of type \'object\'; got %s',
|
|
COMMAND_MERGE,
|
|
mergeObj
|
|
) : invariant(mergeObj && typeof mergeObj === 'object'));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
nextValue && typeof nextValue === 'object',
|
|
'update(): %s expects a target of type \'object\'; got %s',
|
|
COMMAND_MERGE,
|
|
nextValue
|
|
) : invariant(nextValue && typeof nextValue === 'object'));
|
|
assign(nextValue, spec[COMMAND_MERGE]);
|
|
}
|
|
|
|
if (spec.hasOwnProperty(COMMAND_PUSH)) {
|
|
invariantArrayCase(value, spec, COMMAND_PUSH);
|
|
spec[COMMAND_PUSH].forEach(function(item) {
|
|
nextValue.push(item);
|
|
});
|
|
}
|
|
|
|
if (spec.hasOwnProperty(COMMAND_UNSHIFT)) {
|
|
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
|
|
spec[COMMAND_UNSHIFT].forEach(function(item) {
|
|
nextValue.unshift(item);
|
|
});
|
|
}
|
|
|
|
if (spec.hasOwnProperty(COMMAND_SPLICE)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Array.isArray(value),
|
|
'Expected %s target to be an array; got %s',
|
|
COMMAND_SPLICE,
|
|
value
|
|
) : invariant(Array.isArray(value)));
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Array.isArray(spec[COMMAND_SPLICE]),
|
|
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
|
'Did you forget to wrap your parameters in an array?',
|
|
COMMAND_SPLICE,
|
|
spec[COMMAND_SPLICE]
|
|
) : invariant(Array.isArray(spec[COMMAND_SPLICE])));
|
|
spec[COMMAND_SPLICE].forEach(function(args) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
Array.isArray(args),
|
|
'update(): expected spec of %s to be an array of arrays; got %s. ' +
|
|
'Did you forget to wrap your parameters in an array?',
|
|
COMMAND_SPLICE,
|
|
spec[COMMAND_SPLICE]
|
|
) : invariant(Array.isArray(args)));
|
|
nextValue.splice.apply(nextValue, args);
|
|
});
|
|
}
|
|
|
|
if (spec.hasOwnProperty(COMMAND_APPLY)) {
|
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
typeof spec[COMMAND_APPLY] === 'function',
|
|
'update(): expected spec of %s to be a function; got %s.',
|
|
COMMAND_APPLY,
|
|
spec[COMMAND_APPLY]
|
|
) : invariant(typeof spec[COMMAND_APPLY] === 'function'));
|
|
nextValue = spec[COMMAND_APPLY](nextValue);
|
|
}
|
|
|
|
for (var k in spec) {
|
|
if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) {
|
|
nextValue[k] = update(value[k], spec[k]);
|
|
}
|
|
}
|
|
|
|
return nextValue;
|
|
}
|
|
|
|
module.exports = update;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./Object.assign":70,"./invariant":182,"./keyOf":189,"_process":1}],202:[function(require,module,exports){
|
|
(function (process){
|
|
/**
|
|
* Copyright 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule warning
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
var emptyFunction = require("./emptyFunction");
|
|
|
|
/**
|
|
* Similar to invariant but only logs a warning if the condition is not met.
|
|
* This can be used to log issues in development environments in critical
|
|
* paths. Removing the logging code for production environments will keep the
|
|
* same logic and follow the same code paths.
|
|
*/
|
|
|
|
var warning = emptyFunction;
|
|
|
|
if ("production" !== process.env.NODE_ENV) {
|
|
warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
|
if (format === undefined) {
|
|
throw new Error(
|
|
'`warning(condition, format, ...args)` requires a warning ' +
|
|
'message argument'
|
|
);
|
|
}
|
|
|
|
if (!condition) {
|
|
var argIndex = 0;
|
|
console.warn('Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}));
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = warning;
|
|
|
|
}).call(this,require('_process'))
|
|
|
|
},{"./emptyFunction":163,"_process":1}],"flux":[function(require,module,exports){
|
|
/**
|
|
* Copyright (c) 2014, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
module.exports.Dispatcher = require('./lib/Dispatcher')
|
|
|
|
},{"./lib/Dispatcher":2}],"jquery":[function(require,module,exports){
|
|
/*!
|
|
* jQuery JavaScript Library v2.1.3
|
|
* http://jquery.com/
|
|
*
|
|
* Includes Sizzle.js
|
|
* http://sizzlejs.com/
|
|
*
|
|
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
|
|
* Released under the MIT license
|
|
* http://jquery.org/license
|
|
*
|
|
* Date: 2014-12-18T15:11Z
|
|
*/
|
|
|
|
(function( global, factory ) {
|
|
|
|
if ( typeof module === "object" && typeof module.exports === "object" ) {
|
|
// For CommonJS and CommonJS-like environments where a proper `window`
|
|
// is present, execute the factory and get jQuery.
|
|
// For environments that do not have a `window` with a `document`
|
|
// (such as Node.js), expose a factory as module.exports.
|
|
// This accentuates the need for the creation of a real `window`.
|
|
// e.g. var jQuery = require("jquery")(window);
|
|
// See ticket #14549 for more info.
|
|
module.exports = global.document ?
|
|
factory( global, true ) :
|
|
function( w ) {
|
|
if ( !w.document ) {
|
|
throw new Error( "jQuery requires a window with a document" );
|
|
}
|
|
return factory( w );
|
|
};
|
|
} else {
|
|
factory( global );
|
|
}
|
|
|
|
// Pass this if window is not defined yet
|
|
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
|
|
|
|
// Support: Firefox 18+
|
|
// Can't be in strict mode, several libs including ASP.NET trace
|
|
// the stack via arguments.caller.callee and Firefox dies if
|
|
// you try to trace through "use strict" call chains. (#13335)
|
|
//
|
|
|
|
var arr = [];
|
|
|
|
var slice = arr.slice;
|
|
|
|
var concat = arr.concat;
|
|
|
|
var push = arr.push;
|
|
|
|
var indexOf = arr.indexOf;
|
|
|
|
var class2type = {};
|
|
|
|
var toString = class2type.toString;
|
|
|
|
var hasOwn = class2type.hasOwnProperty;
|
|
|
|
var support = {};
|
|
|
|
|
|
|
|
var
|
|
// Use the correct document accordingly with window argument (sandbox)
|
|
document = window.document,
|
|
|
|
version = "2.1.3",
|
|
|
|
// Define a local copy of jQuery
|
|
jQuery = function( selector, context ) {
|
|
// The jQuery object is actually just the init constructor 'enhanced'
|
|
// Need init if jQuery is called (just allow error to be thrown if not included)
|
|
return new jQuery.fn.init( selector, context );
|
|
},
|
|
|
|
// Support: Android<4.1
|
|
// Make sure we trim BOM and NBSP
|
|
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
|
|
// Matches dashed string for camelizing
|
|
rmsPrefix = /^-ms-/,
|
|
rdashAlpha = /-([\da-z])/gi,
|
|
|
|
// Used by jQuery.camelCase as callback to replace()
|
|
fcamelCase = function( all, letter ) {
|
|
return letter.toUpperCase();
|
|
};
|
|
|
|
jQuery.fn = jQuery.prototype = {
|
|
// The current version of jQuery being used
|
|
jquery: version,
|
|
|
|
constructor: jQuery,
|
|
|
|
// Start with an empty selector
|
|
selector: "",
|
|
|
|
// The default length of a jQuery object is 0
|
|
length: 0,
|
|
|
|
toArray: function() {
|
|
return slice.call( this );
|
|
},
|
|
|
|
// Get the Nth element in the matched element set OR
|
|
// Get the whole matched element set as a clean array
|
|
get: function( num ) {
|
|
return num != null ?
|
|
|
|
// Return just the one element from the set
|
|
( num < 0 ? this[ num + this.length ] : this[ num ] ) :
|
|
|
|
// Return all the elements in a clean array
|
|
slice.call( this );
|
|
},
|
|
|
|
// Take an array of elements and push it onto the stack
|
|
// (returning the new matched element set)
|
|
pushStack: function( elems ) {
|
|
|
|
// Build a new jQuery matched element set
|
|
var ret = jQuery.merge( this.constructor(), elems );
|
|
|
|
// Add the old object onto the stack (as a reference)
|
|
ret.prevObject = this;
|
|
ret.context = this.context;
|
|
|
|
// Return the newly-formed element set
|
|
return ret;
|
|
},
|
|
|
|
// Execute a callback for every element in the matched set.
|
|
// (You can seed the arguments with an array of args, but this is
|
|
// only used internally.)
|
|
each: function( callback, args ) {
|
|
return jQuery.each( this, callback, args );
|
|
},
|
|
|
|
map: function( callback ) {
|
|
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
|
return callback.call( elem, i, elem );
|
|
}));
|
|
},
|
|
|
|
slice: function() {
|
|
return this.pushStack( slice.apply( this, arguments ) );
|
|
},
|
|
|
|
first: function() {
|
|
return this.eq( 0 );
|
|
},
|
|
|
|
last: function() {
|
|
return this.eq( -1 );
|
|
},
|
|
|
|
eq: function( i ) {
|
|
var len = this.length,
|
|
j = +i + ( i < 0 ? len : 0 );
|
|
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
|
|
},
|
|
|
|
end: function() {
|
|
return this.prevObject || this.constructor(null);
|
|
},
|
|
|
|
// For internal use only.
|
|
// Behaves like an Array's method, not like a jQuery method.
|
|
push: push,
|
|
sort: arr.sort,
|
|
splice: arr.splice
|
|
};
|
|
|
|
jQuery.extend = jQuery.fn.extend = function() {
|
|
var options, name, src, copy, copyIsArray, clone,
|
|
target = arguments[0] || {},
|
|
i = 1,
|
|
length = arguments.length,
|
|
deep = false;
|
|
|
|
// Handle a deep copy situation
|
|
if ( typeof target === "boolean" ) {
|
|
deep = target;
|
|
|
|
// Skip the boolean and the target
|
|
target = arguments[ i ] || {};
|
|
i++;
|
|
}
|
|
|
|
// Handle case when target is a string or something (possible in deep copy)
|
|
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
|
target = {};
|
|
}
|
|
|
|
// Extend jQuery itself if only one argument is passed
|
|
if ( i === length ) {
|
|
target = this;
|
|
i--;
|
|
}
|
|
|
|
for ( ; i < length; i++ ) {
|
|
// Only deal with non-null/undefined values
|
|
if ( (options = arguments[ i ]) != null ) {
|
|
// Extend the base object
|
|
for ( name in options ) {
|
|
src = target[ name ];
|
|
copy = options[ name ];
|
|
|
|
// Prevent never-ending loop
|
|
if ( target === copy ) {
|
|
continue;
|
|
}
|
|
|
|
// Recurse if we're merging plain objects or arrays
|
|
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
|
if ( copyIsArray ) {
|
|
copyIsArray = false;
|
|
clone = src && jQuery.isArray(src) ? src : [];
|
|
|
|
} else {
|
|
clone = src && jQuery.isPlainObject(src) ? src : {};
|
|
}
|
|
|
|
// Never move original objects, clone them
|
|
target[ name ] = jQuery.extend( deep, clone, copy );
|
|
|
|
// Don't bring in undefined values
|
|
} else if ( copy !== undefined ) {
|
|
target[ name ] = copy;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Return the modified object
|
|
return target;
|
|
};
|
|
|
|
jQuery.extend({
|
|
// Unique for each copy of jQuery on the page
|
|
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
|
|
|
|
// Assume jQuery is ready without the ready module
|
|
isReady: true,
|
|
|
|
error: function( msg ) {
|
|
throw new Error( msg );
|
|
},
|
|
|
|
noop: function() {},
|
|
|
|
isFunction: function( obj ) {
|
|
return jQuery.type(obj) === "function";
|
|
},
|
|
|
|
isArray: Array.isArray,
|
|
|
|
isWindow: function( obj ) {
|
|
return obj != null && obj === obj.window;
|
|
},
|
|
|
|
isNumeric: function( obj ) {
|
|
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
|
|
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
|
|
// subtraction forces infinities to NaN
|
|
// adding 1 corrects loss of precision from parseFloat (#15100)
|
|
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
|
|
},
|
|
|
|
isPlainObject: function( obj ) {
|
|
// Not plain objects:
|
|
// - Any object or value whose internal [[Class]] property is not "[object Object]"
|
|
// - DOM nodes
|
|
// - window
|
|
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
|
return false;
|
|
}
|
|
|
|
if ( obj.constructor &&
|
|
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
|
|
return false;
|
|
}
|
|
|
|
// If the function hasn't returned already, we're confident that
|
|
// |obj| is a plain object, created by {} or constructed with new Object
|
|
return true;
|
|
},
|
|
|
|
isEmptyObject: function( obj ) {
|
|
var name;
|
|
for ( name in obj ) {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
type: function( obj ) {
|
|
if ( obj == null ) {
|
|
return obj + "";
|
|
}
|
|
// Support: Android<4.0, iOS<6 (functionish RegExp)
|
|
return typeof obj === "object" || typeof obj === "function" ?
|
|
class2type[ toString.call(obj) ] || "object" :
|
|
typeof obj;
|
|
},
|
|
|
|
// Evaluates a script in a global context
|
|
globalEval: function( code ) {
|
|
var script,
|
|
indirect = eval;
|
|
|
|
code = jQuery.trim( code );
|
|
|
|
if ( code ) {
|
|
// If the code includes a valid, prologue position
|
|
// strict mode pragma, execute code by injecting a
|
|
// script tag into the document.
|
|
if ( code.indexOf("use strict") === 1 ) {
|
|
script = document.createElement("script");
|
|
script.text = code;
|
|
document.head.appendChild( script ).parentNode.removeChild( script );
|
|
} else {
|
|
// Otherwise, avoid the DOM node creation, insertion
|
|
// and removal by using an indirect global eval
|
|
indirect( code );
|
|
}
|
|
}
|
|
},
|
|
|
|
// Convert dashed to camelCase; used by the css and data modules
|
|
// Support: IE9-11+
|
|
// Microsoft forgot to hump their vendor prefix (#9572)
|
|
camelCase: function( string ) {
|
|
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
|
},
|
|
|
|
nodeName: function( elem, name ) {
|
|
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
|
},
|
|
|
|
// args is for internal usage only
|
|
each: function( obj, callback, args ) {
|
|
var value,
|
|
i = 0,
|
|
length = obj.length,
|
|
isArray = isArraylike( obj );
|
|
|
|
if ( args ) {
|
|
if ( isArray ) {
|
|
for ( ; i < length; i++ ) {
|
|
value = callback.apply( obj[ i ], args );
|
|
|
|
if ( value === false ) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
for ( i in obj ) {
|
|
value = callback.apply( obj[ i ], args );
|
|
|
|
if ( value === false ) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// A special, fast, case for the most common use of each
|
|
} else {
|
|
if ( isArray ) {
|
|
for ( ; i < length; i++ ) {
|
|
value = callback.call( obj[ i ], i, obj[ i ] );
|
|
|
|
if ( value === false ) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
for ( i in obj ) {
|
|
value = callback.call( obj[ i ], i, obj[ i ] );
|
|
|
|
if ( value === false ) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
},
|
|
|
|
// Support: Android<4.1
|
|
trim: function( text ) {
|
|
return text == null ?
|
|
"" :
|
|
( text + "" ).replace( rtrim, "" );
|
|
},
|
|
|
|
// results is for internal usage only
|
|
makeArray: function( arr, results ) {
|
|
var ret = results || [];
|
|
|
|
if ( arr != null ) {
|
|
if ( isArraylike( Object(arr) ) ) {
|
|
jQuery.merge( ret,
|
|
typeof arr === "string" ?
|
|
[ arr ] : arr
|
|
);
|
|
} else {
|
|
push.call( ret, arr );
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
},
|
|
|
|
inArray: function( elem, arr, i ) {
|
|
return arr == null ? -1 : indexOf.call( arr, elem, i );
|
|
},
|
|
|
|
merge: function( first, second ) {
|
|
var len = +second.length,
|
|
j = 0,
|
|
i = first.length;
|
|
|
|
for ( ; j < len; j++ ) {
|
|
first[ i++ ] = second[ j ];
|
|
}
|
|
|
|
first.length = i;
|
|
|
|
return first;
|
|
},
|
|
|
|
grep: function( elems, callback, invert ) {
|
|
var callbackInverse,
|
|
matches = [],
|
|
i = 0,
|
|
length = elems.length,
|
|
callbackExpect = !invert;
|
|
|
|
// Go through the array, only saving the items
|
|
// that pass the validator function
|
|
for ( ; i < length; i++ ) {
|
|
callbackInverse = !callback( elems[ i ], i );
|
|
if ( callbackInverse !== callbackExpect ) {
|
|
matches.push( elems[ i ] );
|
|
}
|
|
}
|
|
|
|
return matches;
|
|
},
|
|
|
|
// arg is for internal usage only
|
|
map: function( elems, callback, arg ) {
|
|
var value,
|
|
i = 0,
|
|
length = elems.length,
|
|
isArray = isArraylike( elems ),
|
|
ret = [];
|
|
|
|
// Go through the array, translating each of the items to their new values
|
|
if ( isArray ) {
|
|
for ( ; i < length; i++ ) {
|
|
value = callback( elems[ i ], i, arg );
|
|
|
|
if ( value != null ) {
|
|
ret.push( value );
|
|
}
|
|
}
|
|
|
|
// Go through every key on the object,
|
|
} else {
|
|
for ( i in elems ) {
|
|
value = callback( elems[ i ], i, arg );
|
|
|
|
if ( value != null ) {
|
|
ret.push( value );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Flatten any nested arrays
|
|
return concat.apply( [], ret );
|
|
},
|
|
|
|
// A global GUID counter for objects
|
|
guid: 1,
|
|
|
|
// Bind a function to a context, optionally partially applying any
|
|
// arguments.
|
|
proxy: function( fn, context ) {
|
|
var tmp, args, proxy;
|
|
|
|
if ( typeof context === "string" ) {
|
|
tmp = fn[ context ];
|
|
context = fn;
|
|
fn = tmp;
|
|
}
|
|
|
|
// Quick check to determine if target is callable, in the spec
|
|
// this throws a TypeError, but we will just return undefined.
|
|
if ( !jQuery.isFunction( fn ) ) {
|
|
return undefined;
|
|
}
|
|
|
|
// Simulated bind
|
|
args = slice.call( arguments, 2 );
|
|
proxy = function() {
|
|
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
|
|
};
|
|
|
|
// Set the guid of unique handler to the same of original handler, so it can be removed
|
|
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
|
|
|
|
return proxy;
|
|
},
|
|
|
|
now: Date.now,
|
|
|
|
// jQuery.support is not used in Core but other projects attach their
|
|
// properties to it so it needs to exist.
|
|
support: support
|
|
});
|
|
|
|
// Populate the class2type map
|
|
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
|
|
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
|
});
|
|
|
|
function isArraylike( obj ) {
|
|
var length = obj.length,
|
|
type = jQuery.type( obj );
|
|
|
|
if ( type === "function" || jQuery.isWindow( obj ) ) {
|
|
return false;
|
|
}
|
|
|
|
if ( obj.nodeType === 1 && length ) {
|
|
return true;
|
|
}
|
|
|
|
return type === "array" || length === 0 ||
|
|
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
|
|
}
|
|
var Sizzle =
|
|
/*!
|
|
* Sizzle CSS Selector Engine v2.2.0-pre
|
|
* http://sizzlejs.com/
|
|
*
|
|
* Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
|
|
* Released under the MIT license
|
|
* http://jquery.org/license
|
|
*
|
|
* Date: 2014-12-16
|
|
*/
|
|
(function( window ) {
|
|
|
|
var i,
|
|
support,
|
|
Expr,
|
|
getText,
|
|
isXML,
|
|
tokenize,
|
|
compile,
|
|
select,
|
|
outermostContext,
|
|
sortInput,
|
|
hasDuplicate,
|
|
|
|
// Local document vars
|
|
setDocument,
|
|
document,
|
|
docElem,
|
|
documentIsHTML,
|
|
rbuggyQSA,
|
|
rbuggyMatches,
|
|
matches,
|
|
contains,
|
|
|
|
// Instance-specific data
|
|
expando = "sizzle" + 1 * new Date(),
|
|
preferredDoc = window.document,
|
|
dirruns = 0,
|
|
done = 0,
|
|
classCache = createCache(),
|
|
tokenCache = createCache(),
|
|
compilerCache = createCache(),
|
|
sortOrder = function( a, b ) {
|
|
if ( a === b ) {
|
|
hasDuplicate = true;
|
|
}
|
|
return 0;
|
|
},
|
|
|
|
// General-purpose constants
|
|
MAX_NEGATIVE = 1 << 31,
|
|
|
|
// Instance methods
|
|
hasOwn = ({}).hasOwnProperty,
|
|
arr = [],
|
|
pop = arr.pop,
|
|
push_native = arr.push,
|
|
push = arr.push,
|
|
slice = arr.slice,
|
|
// Use a stripped-down indexOf as it's faster than native
|
|
// http://jsperf.com/thor-indexof-vs-for/5
|
|
indexOf = function( list, elem ) {
|
|
var i = 0,
|
|
len = list.length;
|
|
for ( ; i < len; i++ ) {
|
|
if ( list[i] === elem ) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
},
|
|
|
|
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
|
|
|
|
// Regular expressions
|
|
|
|
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
|
|
whitespace = "[\\x20\\t\\r\\n\\f]",
|
|
// http://www.w3.org/TR/css3-syntax/#characters
|
|
characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
|
|
|
|
// Loosely modeled on CSS identifier characters
|
|
// An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
|
|
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
|
|
identifier = characterEncoding.replace( "w", "w#" ),
|
|
|
|
// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
|
|
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
|
|
// Operator (capture 2)
|
|
"*([*^$|!~]?=)" + whitespace +
|
|
// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
|
|
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
|
|
"*\\]",
|
|
|
|
pseudos = ":(" + characterEncoding + ")(?:\\((" +
|
|
// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
|
|
// 1. quoted (capture 3; capture 4 or capture 5)
|
|
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
|
|
// 2. simple (capture 6)
|
|
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
|
|
// 3. anything else (capture 2)
|
|
".*" +
|
|
")\\)|)",
|
|
|
|
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
|
|
rwhitespace = new RegExp( whitespace + "+", "g" ),
|
|
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
|
|
|
|
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
|
|
rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
|
|
|
|
rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
|
|
|
|
rpseudo = new RegExp( pseudos ),
|
|
ridentifier = new RegExp( "^" + identifier + "$" ),
|
|
|
|
matchExpr = {
|
|
"ID": new RegExp( "^#(" + characterEncoding + ")" ),
|
|
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
|
|
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
|
|
"ATTR": new RegExp( "^" + attributes ),
|
|
"PSEUDO": new RegExp( "^" + pseudos ),
|
|
"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
|
|
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
|
|
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
|
|
"bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
|
|
// For use in libraries implementing .is()
|
|
// We use this for POS matching in `select`
|
|
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
|
|
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
|
|
},
|
|
|
|
rinputs = /^(?:input|select|textarea|button)$/i,
|
|
rheader = /^h\d$/i,
|
|
|
|
rnative = /^[^{]+\{\s*\[native \w/,
|
|
|
|
// Easily-parseable/retrievable ID or TAG or CLASS selectors
|
|
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
|
|
|
|
rsibling = /[+~]/,
|
|
rescape = /'|\\/g,
|
|
|
|
// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
|
|
runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
|
|
funescape = function( _, escaped, escapedWhitespace ) {
|
|
var high = "0x" + escaped - 0x10000;
|
|
// NaN means non-codepoint
|
|
// Support: Firefox<24
|
|
// Workaround erroneous numeric interpretation of +"0x"
|
|
return high !== high || escapedWhitespace ?
|
|
escaped :
|
|
high < 0 ?
|
|
// BMP codepoint
|
|
String.fromCharCode( high + 0x10000 ) :
|
|
// Supplemental Plane codepoint (surrogate pair)
|
|
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
|
|
},
|
|
|
|
// Used for iframes
|
|
// See setDocument()
|
|
// Removing the function wrapper causes a "Permission Denied"
|
|
// error in IE
|
|
unloadHandler = function() {
|
|
setDocument();
|
|
};
|
|
|
|
// Optimize for push.apply( _, NodeList )
|
|
try {
|
|
push.apply(
|
|
(arr = slice.call( preferredDoc.childNodes )),
|
|
preferredDoc.childNodes
|
|
);
|
|
// Support: Android<4.0
|
|
// Detect silently failing push.apply
|
|
arr[ preferredDoc.childNodes.length ].nodeType;
|
|
} catch ( e ) {
|
|
push = { apply: arr.length ?
|
|
|
|
// Leverage slice if possible
|
|
function( target, els ) {
|
|
push_native.apply( target, slice.call(els) );
|
|
} :
|
|
|
|
// Support: IE<9
|
|
// Otherwise append directly
|
|
function( target, els ) {
|
|
var j = target.length,
|
|
i = 0;
|
|
// Can't trust NodeList.length
|
|
while ( (target[j++] = els[i++]) ) {}
|
|
target.length = j - 1;
|
|
}
|
|
};
|
|
}
|
|
|
|
function Sizzle( selector, context, results, seed ) {
|
|
var match, elem, m, nodeType,
|
|
// QSA vars
|
|
i, groups, old, nid, newContext, newSelector;
|
|
|
|
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
|
|
setDocument( context );
|
|
}
|
|
|
|
context = context || document;
|
|
results = results || [];
|
|
nodeType = context.nodeType;
|
|
|
|
if ( typeof selector !== "string" || !selector ||
|
|
nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
|
|
|
|
return results;
|
|
}
|
|
|
|
if ( !seed && documentIsHTML ) {
|
|
|
|
// Try to shortcut find operations when possible (e.g., not under DocumentFragment)
|
|
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
|
|
// Speed-up: Sizzle("#ID")
|
|
if ( (m = match[1]) ) {
|
|
if ( nodeType === 9 ) {
|
|
elem = context.getElementById( m );
|
|
// Check parentNode to catch when Blackberry 4.6 returns
|
|
// nodes that are no longer in the document (jQuery #6963)
|
|
if ( elem && elem.parentNode ) {
|
|
// Handle the case where IE, Opera, and Webkit return items
|
|
// by name instead of ID
|
|
if ( elem.id === m ) {
|
|
results.push( elem );
|
|
return results;
|
|
}
|
|
} else {
|
|
return results;
|
|
}
|
|
} else {
|
|
// Context is not a document
|
|
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
|
|
contains( context, elem ) && elem.id === m ) {
|
|
results.push( elem );
|
|
return results;
|
|
}
|
|
}
|
|
|
|
// Speed-up: Sizzle("TAG")
|
|
} else if ( match[2] ) {
|
|
push.apply( results, context.getElementsByTagName( selector ) );
|
|
return results;
|
|
|
|
// Speed-up: Sizzle(".CLASS")
|
|
} else if ( (m = match[3]) && support.getElementsByClassName ) {
|
|
push.apply( results, context.getElementsByClassName( m ) );
|
|
return results;
|
|
}
|
|
}
|
|
|
|
// QSA path
|
|
if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
|
|
nid = old = expando;
|
|
newContext = context;
|
|
newSelector = nodeType !== 1 && selector;
|
|
|
|
// qSA works strangely on Element-rooted queries
|
|
// We can work around this by specifying an extra ID on the root
|
|
// and working up from there (Thanks to Andrew Dupont for the technique)
|
|
// IE 8 doesn't work on object elements
|
|
if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
|
groups = tokenize( selector );
|
|
|
|
if ( (old = context.getAttribute("id")) ) {
|
|
nid = old.replace( rescape, "\\$&" );
|
|
} else {
|
|
context.setAttribute( "id", nid );
|
|
}
|
|
nid = "[id='" + nid + "'] ";
|
|
|
|
i = groups.length;
|
|
while ( i-- ) {
|
|
groups[i] = nid + toSelector( groups[i] );
|
|
}
|
|
newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
|
|
newSelector = groups.join(",");
|
|
}
|
|
|
|
if ( newSelector ) {
|
|
try {
|
|
push.apply( results,
|
|
newContext.querySelectorAll( newSelector )
|
|
);
|
|
return results;
|
|
} catch(qsaError) {
|
|
} finally {
|
|
if ( !old ) {
|
|
context.removeAttribute("id");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// All others
|
|
return select( selector.replace( rtrim, "$1" ), context, results, seed );
|
|
}
|
|
|
|
/**
|
|
* Create key-value caches of limited size
|
|
* @returns {Function(string, Object)} Returns the Object data after storing it on itself with
|
|
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
|
|
* deleting the oldest entry
|
|
*/
|
|
function createCache() {
|
|
var keys = [];
|
|
|
|
function cache( key, value ) {
|
|
// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
|
|
if ( keys.push( key + " " ) > Expr.cacheLength ) {
|
|
// Only keep the most recent entries
|
|
delete cache[ keys.shift() ];
|
|
}
|
|
return (cache[ key + " " ] = value);
|
|
}
|
|
return cache;
|
|
}
|
|
|
|
/**
|
|
* Mark a function for special use by Sizzle
|
|
* @param {Function} fn The function to mark
|
|
*/
|
|
function markFunction( fn ) {
|
|
fn[ expando ] = true;
|
|
return fn;
|
|
}
|
|
|
|
/**
|
|
* Support testing using an element
|
|
* @param {Function} fn Passed the created div and expects a boolean result
|
|
*/
|
|
function assert( fn ) {
|
|
var div = document.createElement("div");
|
|
|
|
try {
|
|
return !!fn( div );
|
|
} catch (e) {
|
|
return false;
|
|
} finally {
|
|
// Remove from its parent by default
|
|
if ( div.parentNode ) {
|
|
div.parentNode.removeChild( div );
|
|
}
|
|
// release memory in IE
|
|
div = null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds the same handler for all of the specified attrs
|
|
* @param {String} attrs Pipe-separated list of attributes
|
|
* @param {Function} handler The method that will be applied
|
|
*/
|
|
function addHandle( attrs, handler ) {
|
|
var arr = attrs.split("|"),
|
|
i = attrs.length;
|
|
|
|
while ( i-- ) {
|
|
Expr.attrHandle[ arr[i] ] = handler;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks document order of two siblings
|
|
* @param {Element} a
|
|
* @param {Element} b
|
|
* @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
|
|
*/
|
|
function siblingCheck( a, b ) {
|
|
var cur = b && a,
|
|
diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
|
|
( ~b.sourceIndex || MAX_NEGATIVE ) -
|
|
( ~a.sourceIndex || MAX_NEGATIVE );
|
|
|
|
// Use IE sourceIndex if available on both nodes
|
|
if ( diff ) {
|
|
return diff;
|
|
}
|
|
|
|
// Check if b follows a
|
|
if ( cur ) {
|
|
while ( (cur = cur.nextSibling) ) {
|
|
if ( cur === b ) {
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
|
|
return a ? 1 : -1;
|
|
}
|
|
|
|
/**
|
|
* Returns a function to use in pseudos for input types
|
|
* @param {String} type
|
|
*/
|
|
function createInputPseudo( type ) {
|
|
return function( elem ) {
|
|
var name = elem.nodeName.toLowerCase();
|
|
return name === "input" && elem.type === type;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Returns a function to use in pseudos for buttons
|
|
* @param {String} type
|
|
*/
|
|
function createButtonPseudo( type ) {
|
|
return function( elem ) {
|
|
var name = elem.nodeName.toLowerCase();
|
|
return (name === "input" || name === "button") && elem.type === type;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Returns a function to use in pseudos for positionals
|
|
* @param {Function} fn
|
|
*/
|
|
function createPositionalPseudo( fn ) {
|
|
return markFunction(function( argument ) {
|
|
argument = +argument;
|
|
return markFunction(function( seed, matches ) {
|
|
var j,
|
|
matchIndexes = fn( [], seed.length, argument ),
|
|
i = matchIndexes.length;
|
|
|
|
// Match elements found at the specified indexes
|
|
while ( i-- ) {
|
|
if ( seed[ (j = matchIndexes[i]) ] ) {
|
|
seed[j] = !(matches[j] = seed[j]);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Checks a node for validity as a Sizzle context
|
|
* @param {Element|Object=} context
|
|
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
|
|
*/
|
|
function testContext( context ) {
|
|
return context && typeof context.getElementsByTagName !== "undefined" && context;
|
|
}
|
|
|
|
// Expose support vars for convenience
|
|
support = Sizzle.support = {};
|
|
|
|
/**
|
|
* Detects XML nodes
|
|
* @param {Element|Object} elem An element or a document
|
|
* @returns {Boolean} True iff elem is a non-HTML XML node
|
|
*/
|
|
isXML = Sizzle.isXML = function( elem ) {
|
|
// documentElement is verified for cases where it doesn't yet exist
|
|
// (such as loading iframes in IE - #4833)
|
|
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
|
|
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
|
};
|
|
|
|
/**
|
|
* Sets document-related variables once based on the current document
|
|
* @param {Element|Object} [doc] An element or document object to use to set the document
|
|
* @returns {Object} Returns the current document
|
|
*/
|
|
setDocument = Sizzle.setDocument = function( node ) {
|
|
var hasCompare, parent,
|
|
doc = node ? node.ownerDocument || node : preferredDoc;
|
|
|
|
// If no document and documentElement is available, return
|
|
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
|
|
return document;
|
|
}
|
|
|
|
// Set our document
|
|
document = doc;
|
|
docElem = doc.documentElement;
|
|
parent = doc.defaultView;
|
|
|
|
// Support: IE>8
|
|
// If iframe document is assigned to "document" variable and if iframe has been reloaded,
|
|
// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
|
|
// IE6-8 do not support the defaultView property so parent will be undefined
|
|
if ( parent && parent !== parent.top ) {
|
|
// IE11 does not have attachEvent, so all must suffer
|
|
if ( parent.addEventListener ) {
|
|
parent.addEventListener( "unload", unloadHandler, false );
|
|
} else if ( parent.attachEvent ) {
|
|
parent.attachEvent( "onunload", unloadHandler );
|
|
}
|
|
}
|
|
|
|
/* Support tests
|
|
---------------------------------------------------------------------- */
|
|
documentIsHTML = !isXML( doc );
|
|
|
|
/* Attributes
|
|
---------------------------------------------------------------------- */
|
|
|
|
// Support: IE<8
|
|
// Verify that getAttribute really returns attributes and not properties
|
|
// (excepting IE8 booleans)
|
|
support.attributes = assert(function( div ) {
|
|
div.className = "i";
|
|
return !div.getAttribute("className");
|
|
});
|
|
|
|
/* getElement(s)By*
|
|
---------------------------------------------------------------------- */
|
|
|
|
// Check if getElementsByTagName("*") returns only elements
|
|
support.getElementsByTagName = assert(function( div ) {
|
|
div.appendChild( doc.createComment("") );
|
|
return !div.getElementsByTagName("*").length;
|
|
});
|
|
|
|
// Support: IE<9
|
|
support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
|
|
|
|
// Support: IE<10
|
|
// Check if getElementById returns elements by name
|
|
// The broken getElementById methods don't pick up programatically-set names,
|
|
// so use a roundabout getElementsByName test
|
|
support.getById = assert(function( div ) {
|
|
docElem.appendChild( div ).id = expando;
|
|
return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
|
|
});
|
|
|
|
// ID find and filter
|
|
if ( support.getById ) {
|
|
Expr.find["ID"] = function( id, context ) {
|
|
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
|
|
var m = context.getElementById( id );
|
|
// Check parentNode to catch when Blackberry 4.6 returns
|
|
// nodes that are no longer in the document #6963
|
|
return m && m.parentNode ? [ m ] : [];
|
|
}
|
|
};
|
|
Expr.filter["ID"] = function( id ) {
|
|
var attrId = id.replace( runescape, funescape );
|
|
return function( elem ) {
|
|
return elem.getAttribute("id") === attrId;
|
|
};
|
|
};
|
|
} else {
|
|
// Support: IE6/7
|
|
// getElementById is not reliable as a find shortcut
|
|
delete Expr.find["ID"];
|
|
|
|
Expr.filter["ID"] = function( id ) {
|
|
var attrId = id.replace( runescape, funescape );
|
|
return function( elem ) {
|
|
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
|
return node && node.value === attrId;
|
|
};
|
|
};
|
|
}
|
|
|
|
// Tag
|
|
Expr.find["TAG"] = support.getElementsByTagName ?
|
|
function( tag, context ) {
|
|
if ( typeof context.getElementsByTagName !== "undefined" ) {
|
|
return context.getElementsByTagName( tag );
|
|
|
|
// DocumentFragment nodes don't have gEBTN
|
|
} else if ( support.qsa ) {
|
|
return context.querySelectorAll( tag );
|
|
}
|
|
} :
|
|
|
|
function( tag, context ) {
|
|
var elem,
|
|
tmp = [],
|
|
i = 0,
|
|
// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
|
|
results = context.getElementsByTagName( tag );
|
|
|
|
// Filter out possible comments
|
|
if ( tag === "*" ) {
|
|
while ( (elem = results[i++]) ) {
|
|
if ( elem.nodeType === 1 ) {
|
|
tmp.push( elem );
|
|
}
|
|
}
|
|
|
|
return tmp;
|
|
}
|
|
return results;
|
|
};
|
|
|
|
// Class
|
|
Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
|
|
if ( documentIsHTML ) {
|
|
return context.getElementsByClassName( className );
|
|
}
|
|
};
|
|
|
|
/* QSA/matchesSelector
|
|
---------------------------------------------------------------------- */
|
|
|
|
// QSA and matchesSelector support
|
|
|
|
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
|
|
rbuggyMatches = [];
|
|
|
|
// qSa(:focus) reports false when true (Chrome 21)
|
|
// We allow this because of a bug in IE8/9 that throws an error
|
|
// whenever `document.activeElement` is accessed on an iframe
|
|
// So, we allow :focus to pass through QSA all the time to avoid the IE error
|
|
// See http://bugs.jquery.com/ticket/13378
|
|
rbuggyQSA = [];
|
|
|
|
if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
|
|
// Build QSA regex
|
|
// Regex strategy adopted from Diego Perini
|
|
assert(function( div ) {
|
|
// Select is set to empty string on purpose
|
|
// This is to test IE's treatment of not explicitly
|
|
// setting a boolean content attribute,
|
|
// since its presence should be enough
|
|
// http://bugs.jquery.com/ticket/12359
|
|
docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
|
|
"<select id='" + expando + "-\f]' msallowcapture=''>" +
|
|
"<option selected=''></option></select>";
|
|
|
|
// Support: IE8, Opera 11-12.16
|
|
// Nothing should be selected when empty strings follow ^= or $= or *=
|
|
// The test attribute must be unknown in Opera but "safe" for WinRT
|
|
// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
|
|
if ( div.querySelectorAll("[msallowcapture^='']").length ) {
|
|
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
|
|
}
|
|
|
|
// Support: IE8
|
|
// Boolean attributes and "value" are not treated correctly
|
|
if ( !div.querySelectorAll("[selected]").length ) {
|
|
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
|
|
}
|
|
|
|
// Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
|
|
if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
|
|
rbuggyQSA.push("~=");
|
|
}
|
|
|
|
// Webkit/Opera - :checked should return selected option elements
|
|
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
// IE8 throws error here and will not see later tests
|
|
if ( !div.querySelectorAll(":checked").length ) {
|
|
rbuggyQSA.push(":checked");
|
|
}
|
|
|
|
// Support: Safari 8+, iOS 8+
|
|
// https://bugs.webkit.org/show_bug.cgi?id=136851
|
|
// In-page `selector#id sibing-combinator selector` fails
|
|
if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
|
|
rbuggyQSA.push(".#.+[+~]");
|
|
}
|
|
});
|
|
|
|
assert(function( div ) {
|
|
// Support: Windows 8 Native Apps
|
|
// The type and name attributes are restricted during .innerHTML assignment
|
|
var input = doc.createElement("input");
|
|
input.setAttribute( "type", "hidden" );
|
|
div.appendChild( input ).setAttribute( "name", "D" );
|
|
|
|
// Support: IE8
|
|
// Enforce case-sensitivity of name attribute
|
|
if ( div.querySelectorAll("[name=d]").length ) {
|
|
rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
|
|
}
|
|
|
|
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
|
|
// IE8 throws error here and will not see later tests
|
|
if ( !div.querySelectorAll(":enabled").length ) {
|
|
rbuggyQSA.push( ":enabled", ":disabled" );
|
|
}
|
|
|
|
// Opera 10-11 does not throw on post-comma invalid pseudos
|
|
div.querySelectorAll("*,:x");
|
|
rbuggyQSA.push(",.*:");
|
|
});
|
|
}
|
|
|
|
if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
|
|
docElem.webkitMatchesSelector ||
|
|
docElem.mozMatchesSelector ||
|
|
docElem.oMatchesSelector ||
|
|
docElem.msMatchesSelector) )) ) {
|
|
|
|
assert(function( div ) {
|
|
// Check to see if it's possible to do matchesSelector
|
|
// on a disconnected node (IE 9)
|
|
support.disconnectedMatch = matches.call( div, "div" );
|
|
|
|
// This should fail with an exception
|
|
// Gecko does not error, returns false instead
|
|
matches.call( div, "[s!='']:x" );
|
|
rbuggyMatches.push( "!=", pseudos );
|
|
});
|
|
}
|
|
|
|
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
|
|
rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
|
|
|
|
/* Contains
|
|
---------------------------------------------------------------------- */
|
|
hasCompare = rnative.test( docElem.compareDocumentPosition );
|
|
|
|
// Element contains another
|
|
// Purposefully does not implement inclusive descendent
|
|
// As in, an element does not contain itself
|
|
contains = hasCompare || rnative.test( docElem.contains ) ?
|
|
function( a, b ) {
|
|
var adown = a.nodeType === 9 ? a.documentElement : a,
|
|
bup = b && b.parentNode;
|
|
return a === bup || !!( bup && bup.nodeType === 1 && (
|
|
adown.contains ?
|
|
adown.contains( bup ) :
|
|
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
|
|
));
|
|
} :
|
|
function( a, b ) {
|
|
if ( b ) {
|
|
while ( (b = b.parentNode) ) {
|
|
if ( b === a ) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/* Sorting
|
|
---------------------------------------------------------------------- */
|
|
|
|
// Document order sorting
|
|
sortOrder = hasCompare ?
|
|
function( a, b ) {
|
|
|
|
// Flag for duplicate removal
|
|
if ( a === b ) {
|
|
hasDuplicate = true;
|
|
return 0;
|
|
}
|
|
|
|
// Sort on method existence if only one input has compareDocumentPosition
|
|
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
|
|
if ( compare ) {
|
|
return compare;
|
|
}
|
|
|
|
// Calculate position if both inputs belong to the same document
|
|
compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
|
|
a.compareDocumentPosition( b ) :
|
|
|
|
// Otherwise we know they are disconnected
|
|
1;
|
|
|
|
// Disconnected nodes
|
|
if ( compare & 1 ||
|
|
(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
|
|
|
|
// Choose the first element that is related to our preferred document
|
|
if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
|
|
return -1;
|
|
}
|
|
if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
|
|
return 1;
|
|
}
|
|
|
|
// Maintain original order
|
|
return sortInput ?
|
|
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
|
|
0;
|
|
}
|
|
|
|
return compare & 4 ? -1 : 1;
|
|
} :
|
|
function( a, b ) {
|
|
// Exit early if the nodes are identical
|
|
if ( a === b ) {
|
|
hasDuplicate = true;
|
|
return 0;
|
|
}
|
|
|
|
var cur,
|
|
i = 0,
|
|
aup = a.parentNode,
|
|
bup = b.parentNode,
|
|
ap = [ a ],
|
|
bp = [ b ];
|
|
|
|
// Parentless nodes are either documents or disconnected
|
|
if ( !aup || !bup ) {
|
|
return a === doc ? -1 :
|
|
b === doc ? 1 :
|
|
aup ? -1 :
|
|
bup ? 1 :
|
|
sortInput ?
|
|
( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
|
|
0;
|
|
|
|
// If the nodes are siblings, we can do a quick check
|
|
} else if ( aup === bup ) {
|
|
return siblingCheck( a, b );
|
|
}
|
|
|
|
// Otherwise we need full lists of their ancestors for comparison
|
|
cur = a;
|
|
while ( (cur = cur.parentNode) ) {
|
|
ap.unshift( cur );
|
|
}
|
|
cur = b;
|
|
while ( (cur = cur.parentNode) ) {
|
|
bp.unshift( cur );
|
|
}
|
|
|
|
// Walk down the tree looking for a discrepancy
|
|
while ( ap[i] === bp[i] ) {
|
|
i++;
|
|
}
|
|
|
|
return i ?
|
|
// Do a sibling check if the nodes have a common ancestor
|
|
siblingCheck( ap[i], bp[i] ) :
|
|
|
|
// Otherwise nodes in our document sort first
|
|
ap[i] === preferredDoc ? -1 :
|
|
bp[i] === preferredDoc ? 1 :
|
|
0;
|
|
};
|
|
|
|
return doc;
|
|
};
|
|
|
|
Sizzle.matches = function( expr, elements ) {
|
|
return Sizzle( expr, null, null, elements );
|
|
};
|
|
|
|
Sizzle.matchesSelector = function( elem, expr ) {
|
|
// Set document vars if needed
|
|
if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
setDocument( elem );
|
|
}
|
|
|
|
// Make sure that attribute selectors are quoted
|
|
expr = expr.replace( rattributeQuotes, "='$1']" );
|
|
|
|
if ( support.matchesSelector && documentIsHTML &&
|
|
( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
|
|
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
|
|
|
|
try {
|
|
var ret = matches.call( elem, expr );
|
|
|
|
// IE 9's matchesSelector returns false on disconnected nodes
|
|
if ( ret || support.disconnectedMatch ||
|
|
// As well, disconnected nodes are said to be in a document
|
|
// fragment in IE 9
|
|
elem.document && elem.document.nodeType !== 11 ) {
|
|
return ret;
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
|
|
return Sizzle( expr, document, null, [ elem ] ).length > 0;
|
|
};
|
|
|
|
Sizzle.contains = function( context, elem ) {
|
|
// Set document vars if needed
|
|
if ( ( context.ownerDocument || context ) !== document ) {
|
|
setDocument( context );
|
|
}
|
|
return contains( context, elem );
|
|
};
|
|
|
|
Sizzle.attr = function( elem, name ) {
|
|
// Set document vars if needed
|
|
if ( ( elem.ownerDocument || elem ) !== document ) {
|
|
setDocument( elem );
|
|
}
|
|
|
|
var fn = Expr.attrHandle[ name.toLowerCase() ],
|
|
// Don't get fooled by Object.prototype properties (jQuery #13807)
|
|
val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
|
|
fn( elem, name, !documentIsHTML ) :
|
|
undefined;
|
|
|
|
return val !== undefined ?
|
|
val :
|
|
support.attributes || !documentIsHTML ?
|
|
elem.getAttribute( name ) :
|
|
(val = elem.getAttributeNode(name)) && val.specified ?
|
|
val.value :
|
|
null;
|
|
};
|
|
|
|
Sizzle.error = function( msg ) {
|
|
throw new Error( "Syntax error, unrecognized expression: " + msg );
|
|
};
|
|
|
|
/**
|
|
* Document sorting and removing duplicates
|
|
* @param {ArrayLike} results
|
|
*/
|
|
Sizzle.uniqueSort = function( results ) {
|
|
var elem,
|
|
duplicates = [],
|
|
j = 0,
|
|
i = 0;
|
|
|
|
// Unless we *know* we can detect duplicates, assume their presence
|
|
hasDuplicate = !support.detectDuplicates;
|
|
sortInput = !support.sortStable && results.slice( 0 );
|
|
results.sort( sortOrder );
|
|
|
|
if ( hasDuplicate ) {
|
|
while ( (elem = results[i++]) ) {
|
|
if ( elem === results[ i ] ) {
|
|
j = duplicates.push( i );
|
|
}
|
|
}
|
|
while ( j-- ) {
|
|
results.splice( duplicates[ j ], 1 );
|
|
}
|
|
}
|
|
|
|
// Clear input after sorting to release objects
|
|
// See https://github.com/jquery/sizzle/pull/225
|
|
sortInput = null;
|
|
|
|
return results;
|
|
};
|
|
|
|
/**
|
|
* Utility function for retrieving the text value of an array of DOM nodes
|
|
* @param {Array|Element} elem
|
|
*/
|
|
getText = Sizzle.getText = function( elem ) {
|
|
var node,
|
|
ret = "",
|
|
i = 0,
|
|
nodeType = elem.nodeType;
|
|
|
|
if ( !nodeType ) {
|
|
// If no nodeType, this is expected to be an array
|
|
while ( (node = elem[i++]) ) {
|
|
// Do not traverse comment nodes
|
|
ret += getText( node );
|
|
}
|
|
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
|
|
// Use textContent for elements
|
|
// innerText usage removed for consistency of new lines (jQuery #11153)
|
|
if ( typeof elem.textContent === "string" ) {
|
|
return elem.textContent;
|
|
} else {
|
|
// Traverse its children
|
|
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
ret += getText( elem );
|
|
}
|
|
}
|
|
} else if ( nodeType === 3 || nodeType === 4 ) {
|
|
return elem.nodeValue;
|
|
}
|
|
// Do not include comment or processing instruction nodes
|
|
|
|
return ret;
|
|
};
|
|
|
|
Expr = Sizzle.selectors = {
|
|
|
|
// Can be adjusted by the user
|
|
cacheLength: 50,
|
|
|
|
createPseudo: markFunction,
|
|
|
|
match: matchExpr,
|
|
|
|
attrHandle: {},
|
|
|
|
find: {},
|
|
|
|
relative: {
|
|
">": { dir: "parentNode", first: true },
|
|
" ": { dir: "parentNode" },
|
|
"+": { dir: "previousSibling", first: true },
|
|
"~": { dir: "previousSibling" }
|
|
},
|
|
|
|
preFilter: {
|
|
"ATTR": function( match ) {
|
|
match[1] = match[1].replace( runescape, funescape );
|
|
|
|
// Move the given value to match[3] whether quoted or unquoted
|
|
match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
|
|
|
|
if ( match[2] === "~=" ) {
|
|
match[3] = " " + match[3] + " ";
|
|
}
|
|
|
|
return match.slice( 0, 4 );
|
|
},
|
|
|
|
"CHILD": function( match ) {
|
|
/* matches from matchExpr["CHILD"]
|
|
1 type (only|nth|...)
|
|
2 what (child|of-type)
|
|
3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
|
|
4 xn-component of xn+y argument ([+-]?\d*n|)
|
|
5 sign of xn-component
|
|
6 x of xn-component
|
|
7 sign of y-component
|
|
8 y of y-component
|
|
*/
|
|
match[1] = match[1].toLowerCase();
|
|
|
|
if ( match[1].slice( 0, 3 ) === "nth" ) {
|
|
// nth-* requires argument
|
|
if ( !match[3] ) {
|
|
Sizzle.error( match[0] );
|
|
}
|
|
|
|
// numeric x and y parameters for Expr.filter.CHILD
|
|
// remember that false/true cast respectively to 0/1
|
|
match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
|
|
match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
|
|
|
|
// other types prohibit arguments
|
|
} else if ( match[3] ) {
|
|
Sizzle.error( match[0] );
|
|
}
|
|
|
|
return match;
|
|
},
|
|
|
|
"PSEUDO": function( match ) {
|
|
var excess,
|
|
unquoted = !match[6] && match[2];
|
|
|
|
if ( matchExpr["CHILD"].test( match[0] ) ) {
|
|
return null;
|
|
}
|
|
|
|
// Accept quoted arguments as-is
|
|
if ( match[3] ) {
|
|
match[2] = match[4] || match[5] || "";
|
|
|
|
// Strip excess characters from unquoted arguments
|
|
} else if ( unquoted && rpseudo.test( unquoted ) &&
|
|
// Get excess from tokenize (recursively)
|
|
(excess = tokenize( unquoted, true )) &&
|
|
// advance to the next closing parenthesis
|
|
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
|
|
|
|
// excess is a negative index
|
|
match[0] = match[0].slice( 0, excess );
|
|
match[2] = unquoted.slice( 0, excess );
|
|
}
|
|
|
|
// Return only captures needed by the pseudo filter method (type and argument)
|
|
return match.slice( 0, 3 );
|
|
}
|
|
},
|
|
|
|
filter: {
|
|
|
|
"TAG": function( nodeNameSelector ) {
|
|
var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
|
|
return nodeNameSelector === "*" ?
|
|
function() { return true; } :
|
|
function( elem ) {
|
|
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
|
|
};
|
|
},
|
|
|
|
"CLASS": function( className ) {
|
|
var pattern = classCache[ className + " " ];
|
|
|
|
return pattern ||
|
|
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
|
|
classCache( className, function( elem ) {
|
|
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
|
|
});
|
|
},
|
|
|
|
"ATTR": function( name, operator, check ) {
|
|
return function( elem ) {
|
|
var result = Sizzle.attr( elem, name );
|
|
|
|
if ( result == null ) {
|
|
return operator === "!=";
|
|
}
|
|
if ( !operator ) {
|
|
return true;
|
|
}
|
|
|
|
result += "";
|
|
|
|
return operator === "=" ? result === check :
|
|
operator === "!=" ? result !== check :
|
|
operator === "^=" ? check && result.indexOf( check ) === 0 :
|
|
operator === "*=" ? check && result.indexOf( check ) > -1 :
|
|
operator === "$=" ? check && result.slice( -check.length ) === check :
|
|
operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
|
|
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
|
|
false;
|
|
};
|
|
},
|
|
|
|
"CHILD": function( type, what, argument, first, last ) {
|
|
var simple = type.slice( 0, 3 ) !== "nth",
|
|
forward = type.slice( -4 ) !== "last",
|
|
ofType = what === "of-type";
|
|
|
|
return first === 1 && last === 0 ?
|
|
|
|
// Shortcut for :nth-*(n)
|
|
function( elem ) {
|
|
return !!elem.parentNode;
|
|
} :
|
|
|
|
function( elem, context, xml ) {
|
|
var cache, outerCache, node, diff, nodeIndex, start,
|
|
dir = simple !== forward ? "nextSibling" : "previousSibling",
|
|
parent = elem.parentNode,
|
|
name = ofType && elem.nodeName.toLowerCase(),
|
|
useCache = !xml && !ofType;
|
|
|
|
if ( parent ) {
|
|
|
|
// :(first|last|only)-(child|of-type)
|
|
if ( simple ) {
|
|
while ( dir ) {
|
|
node = elem;
|
|
while ( (node = node[ dir ]) ) {
|
|
if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
|
|
return false;
|
|
}
|
|
}
|
|
// Reverse direction for :only-* (if we haven't yet done so)
|
|
start = dir = type === "only" && !start && "nextSibling";
|
|
}
|
|
return true;
|
|
}
|
|
|
|
start = [ forward ? parent.firstChild : parent.lastChild ];
|
|
|
|
// non-xml :nth-child(...) stores cache data on `parent`
|
|
if ( forward && useCache ) {
|
|
// Seek `elem` from a previously-cached index
|
|
outerCache = parent[ expando ] || (parent[ expando ] = {});
|
|
cache = outerCache[ type ] || [];
|
|
nodeIndex = cache[0] === dirruns && cache[1];
|
|
diff = cache[0] === dirruns && cache[2];
|
|
node = nodeIndex && parent.childNodes[ nodeIndex ];
|
|
|
|
while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
|
|
// Fallback to seeking `elem` from the start
|
|
(diff = nodeIndex = 0) || start.pop()) ) {
|
|
|
|
// When found, cache indexes on `parent` and break
|
|
if ( node.nodeType === 1 && ++diff && node === elem ) {
|
|
outerCache[ type ] = [ dirruns, nodeIndex, diff ];
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Use previously-cached element index if available
|
|
} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
|
|
diff = cache[1];
|
|
|
|
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
|
|
} else {
|
|
// Use the same loop as above to seek `elem` from the start
|
|
while ( (node = ++nodeIndex && node && node[ dir ] ||
|
|
(diff = nodeIndex = 0) || start.pop()) ) {
|
|
|
|
if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
|
|
// Cache the index of each encountered element
|
|
if ( useCache ) {
|
|
(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
|
|
}
|
|
|
|
if ( node === elem ) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Incorporate the offset, then check against cycle size
|
|
diff -= last;
|
|
return diff === first || ( diff % first === 0 && diff / first >= 0 );
|
|
}
|
|
};
|
|
},
|
|
|
|
"PSEUDO": function( pseudo, argument ) {
|
|
// pseudo-class names are case-insensitive
|
|
// http://www.w3.org/TR/selectors/#pseudo-classes
|
|
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
|
|
// Remember that setFilters inherits from pseudos
|
|
var args,
|
|
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
|
|
Sizzle.error( "unsupported pseudo: " + pseudo );
|
|
|
|
// The user may use createPseudo to indicate that
|
|
// arguments are needed to create the filter function
|
|
// just as Sizzle does
|
|
if ( fn[ expando ] ) {
|
|
return fn( argument );
|
|
}
|
|
|
|
// But maintain support for old signatures
|
|
if ( fn.length > 1 ) {
|
|
args = [ pseudo, pseudo, "", argument ];
|
|
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
|
|
markFunction(function( seed, matches ) {
|
|
var idx,
|
|
matched = fn( seed, argument ),
|
|
i = matched.length;
|
|
while ( i-- ) {
|
|
idx = indexOf( seed, matched[i] );
|
|
seed[ idx ] = !( matches[ idx ] = matched[i] );
|
|
}
|
|
}) :
|
|
function( elem ) {
|
|
return fn( elem, 0, args );
|
|
};
|
|
}
|
|
|
|
return fn;
|
|
}
|
|
},
|
|
|
|
pseudos: {
|
|
// Potentially complex pseudos
|
|
"not": markFunction(function( selector ) {
|
|
// Trim the selector passed to compile
|
|
// to avoid treating leading and trailing
|
|
// spaces as combinators
|
|
var input = [],
|
|
results = [],
|
|
matcher = compile( selector.replace( rtrim, "$1" ) );
|
|
|
|
return matcher[ expando ] ?
|
|
markFunction(function( seed, matches, context, xml ) {
|
|
var elem,
|
|
unmatched = matcher( seed, null, xml, [] ),
|
|
i = seed.length;
|
|
|
|
// Match elements unmatched by `matcher`
|
|
while ( i-- ) {
|
|
if ( (elem = unmatched[i]) ) {
|
|
seed[i] = !(matches[i] = elem);
|
|
}
|
|
}
|
|
}) :
|
|
function( elem, context, xml ) {
|
|
input[0] = elem;
|
|
matcher( input, null, xml, results );
|
|
// Don't keep the element (issue #299)
|
|
input[0] = null;
|
|
return !results.pop();
|
|
};
|
|
}),
|
|
|
|
"has": markFunction(function( selector ) {
|
|
return function( elem ) {
|
|
return Sizzle( selector, elem ).length > 0;
|
|
};
|
|
}),
|
|
|
|
"contains": markFunction(function( text ) {
|
|
text = text.replace( runescape, funescape );
|
|
return function( elem ) {
|
|
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
|
|
};
|
|
}),
|
|
|
|
// "Whether an element is represented by a :lang() selector
|
|
// is based solely on the element's language value
|
|
// being equal to the identifier C,
|
|
// or beginning with the identifier C immediately followed by "-".
|
|
// The matching of C against the element's language value is performed case-insensitively.
|
|
// The identifier C does not have to be a valid language name."
|
|
// http://www.w3.org/TR/selectors/#lang-pseudo
|
|
"lang": markFunction( function( lang ) {
|
|
// lang value must be a valid identifier
|
|
if ( !ridentifier.test(lang || "") ) {
|
|
Sizzle.error( "unsupported lang: " + lang );
|
|
}
|
|
lang = lang.replace( runescape, funescape ).toLowerCase();
|
|
return function( elem ) {
|
|
var elemLang;
|
|
do {
|
|
if ( (elemLang = documentIsHTML ?
|
|
elem.lang :
|
|
elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
|
|
|
|
elemLang = elemLang.toLowerCase();
|
|
return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
|
|
}
|
|
} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
|
|
return false;
|
|
};
|
|
}),
|
|
|
|
// Miscellaneous
|
|
"target": function( elem ) {
|
|
var hash = window.location && window.location.hash;
|
|
return hash && hash.slice( 1 ) === elem.id;
|
|
},
|
|
|
|
"root": function( elem ) {
|
|
return elem === docElem;
|
|
},
|
|
|
|
"focus": function( elem ) {
|
|
return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
|
|
},
|
|
|
|
// Boolean properties
|
|
"enabled": function( elem ) {
|
|
return elem.disabled === false;
|
|
},
|
|
|
|
"disabled": function( elem ) {
|
|
return elem.disabled === true;
|
|
},
|
|
|
|
"checked": function( elem ) {
|
|
// In CSS3, :checked should return both checked and selected elements
|
|
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
|
|
var nodeName = elem.nodeName.toLowerCase();
|
|
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
|
|
},
|
|
|
|
"selected": function( elem ) {
|
|
// Accessing this property makes selected-by-default
|
|
// options in Safari work properly
|
|
if ( elem.parentNode ) {
|
|
elem.parentNode.selectedIndex;
|
|
}
|
|
|
|
return elem.selected === true;
|
|
},
|
|
|
|
// Contents
|
|
"empty": function( elem ) {
|
|
// http://www.w3.org/TR/selectors/#empty-pseudo
|
|
// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
|
|
// but not by others (comment: 8; processing instruction: 7; etc.)
|
|
// nodeType < 6 works because attributes (2) do not appear as children
|
|
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
|
if ( elem.nodeType < 6 ) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
|
|
"parent": function( elem ) {
|
|
return !Expr.pseudos["empty"]( elem );
|
|
},
|
|
|
|
// Element/input types
|
|
"header": function( elem ) {
|
|
return rheader.test( elem.nodeName );
|
|
},
|
|
|
|
"input": function( elem ) {
|
|
return rinputs.test( elem.nodeName );
|
|
},
|
|
|
|
"button": function( elem ) {
|
|
var name = elem.nodeName.toLowerCase();
|
|
return name === "input" && elem.type === "button" || name === "button";
|
|
},
|
|
|
|
"text": function( elem ) {
|
|
var attr;
|
|
return elem.nodeName.toLowerCase() === "input" &&
|
|
elem.type === "text" &&
|
|
|
|
// Support: IE<8
|
|
// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
|
|
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
|
|
},
|
|
|
|
// Position-in-collection
|
|
"first": createPositionalPseudo(function() {
|
|
return [ 0 ];
|
|
}),
|
|
|
|
"last": createPositionalPseudo(function( matchIndexes, length ) {
|
|
return [ length - 1 ];
|
|
}),
|
|
|
|
"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
return [ argument < 0 ? argument + length : argument ];
|
|
}),
|
|
|
|
"even": createPositionalPseudo(function( matchIndexes, length ) {
|
|
var i = 0;
|
|
for ( ; i < length; i += 2 ) {
|
|
matchIndexes.push( i );
|
|
}
|
|
return matchIndexes;
|
|
}),
|
|
|
|
"odd": createPositionalPseudo(function( matchIndexes, length ) {
|
|
var i = 1;
|
|
for ( ; i < length; i += 2 ) {
|
|
matchIndexes.push( i );
|
|
}
|
|
return matchIndexes;
|
|
}),
|
|
|
|
"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
var i = argument < 0 ? argument + length : argument;
|
|
for ( ; --i >= 0; ) {
|
|
matchIndexes.push( i );
|
|
}
|
|
return matchIndexes;
|
|
}),
|
|
|
|
"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
|
|
var i = argument < 0 ? argument + length : argument;
|
|
for ( ; ++i < length; ) {
|
|
matchIndexes.push( i );
|
|
}
|
|
return matchIndexes;
|
|
})
|
|
}
|
|
};
|
|
|
|
Expr.pseudos["nth"] = Expr.pseudos["eq"];
|
|
|
|
// Add button/input type pseudos
|
|
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
|
|
Expr.pseudos[ i ] = createInputPseudo( i );
|
|
}
|
|
for ( i in { submit: true, reset: true } ) {
|
|
Expr.pseudos[ i ] = createButtonPseudo( i );
|
|
}
|
|
|
|
// Easy API for creating new setFilters
|
|
function setFilters() {}
|
|
setFilters.prototype = Expr.filters = Expr.pseudos;
|
|
Expr.setFilters = new setFilters();
|
|
|
|
tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
|
|
var matched, match, tokens, type,
|
|
soFar, groups, preFilters,
|
|
cached = tokenCache[ selector + " " ];
|
|
|
|
if ( cached ) {
|
|
return parseOnly ? 0 : cached.slice( 0 );
|
|
}
|
|
|
|
soFar = selector;
|
|
groups = [];
|
|
preFilters = Expr.preFilter;
|
|
|
|
while ( soFar ) {
|
|
|
|
// Comma and first run
|
|
if ( !matched || (match = rcomma.exec( soFar )) ) {
|
|
if ( match ) {
|
|
// Don't consume trailing commas as valid
|
|
soFar = soFar.slice( match[0].length ) || soFar;
|
|
}
|
|
groups.push( (tokens = []) );
|
|
}
|
|
|
|
matched = false;
|
|
|
|
// Combinators
|
|
if ( (match = rcombinators.exec( soFar )) ) {
|
|
matched = match.shift();
|
|
tokens.push({
|
|
value: matched,
|
|
// Cast descendant combinators to space
|
|
type: match[0].replace( rtrim, " " )
|
|
});
|
|
soFar = soFar.slice( matched.length );
|
|
}
|
|
|
|
// Filters
|
|
for ( type in Expr.filter ) {
|
|
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
|
|
(match = preFilters[ type ]( match ))) ) {
|
|
matched = match.shift();
|
|
tokens.push({
|
|
value: matched,
|
|
type: type,
|
|
matches: match
|
|
});
|
|
soFar = soFar.slice( matched.length );
|
|
}
|
|
}
|
|
|
|
if ( !matched ) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Return the length of the invalid excess
|
|
// if we're just parsing
|
|
// Otherwise, throw an error or return tokens
|
|
return parseOnly ?
|
|
soFar.length :
|
|
soFar ?
|
|
Sizzle.error( selector ) :
|
|
// Cache the tokens
|
|
tokenCache( selector, groups ).slice( 0 );
|
|
};
|
|
|
|
function toSelector( tokens ) {
|
|
var i = 0,
|
|
len = tokens.length,
|
|
selector = "";
|
|
for ( ; i < len; i++ ) {
|
|
selector += tokens[i].value;
|
|
}
|
|
return selector;
|
|
}
|
|
|
|
function addCombinator( matcher, combinator, base ) {
|
|
var dir = combinator.dir,
|
|
checkNonElements = base && dir === "parentNode",
|
|
doneName = done++;
|
|
|
|
return combinator.first ?
|
|
// Check against closest ancestor/preceding element
|
|
function( elem, context, xml ) {
|
|
while ( (elem = elem[ dir ]) ) {
|
|
if ( elem.nodeType === 1 || checkNonElements ) {
|
|
return matcher( elem, context, xml );
|
|
}
|
|
}
|
|
} :
|
|
|
|
// Check against all ancestor/preceding elements
|
|
function( elem, context, xml ) {
|
|
var oldCache, outerCache,
|
|
newCache = [ dirruns, doneName ];
|
|
|
|
// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
|
|
if ( xml ) {
|
|
while ( (elem = elem[ dir ]) ) {
|
|
if ( elem.nodeType === 1 || checkNonElements ) {
|
|
if ( matcher( elem, context, xml ) ) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
while ( (elem = elem[ dir ]) ) {
|
|
if ( elem.nodeType === 1 || checkNonElements ) {
|
|
outerCache = elem[ expando ] || (elem[ expando ] = {});
|
|
if ( (oldCache = outerCache[ dir ]) &&
|
|
oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
|
|
|
|
// Assign to newCache so results back-propagate to previous elements
|
|
return (newCache[ 2 ] = oldCache[ 2 ]);
|
|
} else {
|
|
// Reuse newcache so results back-propagate to previous elements
|
|
outerCache[ dir ] = newCache;
|
|
|
|
// A match means we're done; a fail means we have to keep checking
|
|
if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
function elementMatcher( matchers ) {
|
|
return matchers.length > 1 ?
|
|
function( elem, context, xml ) {
|
|
var i = matchers.length;
|
|
while ( i-- ) {
|
|
if ( !matchers[i]( elem, context, xml ) ) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
} :
|
|
matchers[0];
|
|
}
|
|
|
|
function multipleContexts( selector, contexts, results ) {
|
|
var i = 0,
|
|
len = contexts.length;
|
|
for ( ; i < len; i++ ) {
|
|
Sizzle( selector, contexts[i], results );
|
|
}
|
|
return results;
|
|
}
|
|
|
|
function condense( unmatched, map, filter, context, xml ) {
|
|
var elem,
|
|
newUnmatched = [],
|
|
i = 0,
|
|
len = unmatched.length,
|
|
mapped = map != null;
|
|
|
|
for ( ; i < len; i++ ) {
|
|
if ( (elem = unmatched[i]) ) {
|
|
if ( !filter || filter( elem, context, xml ) ) {
|
|
newUnmatched.push( elem );
|
|
if ( mapped ) {
|
|
map.push( i );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return newUnmatched;
|
|
}
|
|
|
|
function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
|
|
if ( postFilter && !postFilter[ expando ] ) {
|
|
postFilter = setMatcher( postFilter );
|
|
}
|
|
if ( postFinder && !postFinder[ expando ] ) {
|
|
postFinder = setMatcher( postFinder, postSelector );
|
|
}
|
|
return markFunction(function( seed, results, context, xml ) {
|
|
var temp, i, elem,
|
|
preMap = [],
|
|
postMap = [],
|
|
preexisting = results.length,
|
|
|
|
// Get initial elements from seed or context
|
|
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
|
|
|
|
// Prefilter to get matcher input, preserving a map for seed-results synchronization
|
|
matcherIn = preFilter && ( seed || !selector ) ?
|
|
condense( elems, preMap, preFilter, context, xml ) :
|
|
elems,
|
|
|
|
matcherOut = matcher ?
|
|
// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
|
|
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
|
|
|
|
// ...intermediate processing is necessary
|
|
[] :
|
|
|
|
// ...otherwise use results directly
|
|
results :
|
|
matcherIn;
|
|
|
|
// Find primary matches
|
|
if ( matcher ) {
|
|
matcher( matcherIn, matcherOut, context, xml );
|
|
}
|
|
|
|
// Apply postFilter
|
|
if ( postFilter ) {
|
|
temp = condense( matcherOut, postMap );
|
|
postFilter( temp, [], context, xml );
|
|
|
|
// Un-match failing elements by moving them back to matcherIn
|
|
i = temp.length;
|
|
while ( i-- ) {
|
|
if ( (elem = temp[i]) ) {
|
|
matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( seed ) {
|
|
if ( postFinder || preFilter ) {
|
|
if ( postFinder ) {
|
|
// Get the final matcherOut by condensing this intermediate into postFinder contexts
|
|
temp = [];
|
|
i = matcherOut.length;
|
|
while ( i-- ) {
|
|
if ( (elem = matcherOut[i]) ) {
|
|
// Restore matcherIn since elem is not yet a final match
|
|
temp.push( (matcherIn[i] = elem) );
|
|
}
|
|
}
|
|
postFinder( null, (matcherOut = []), temp, xml );
|
|
}
|
|
|
|
// Move matched elements from seed to results to keep them synchronized
|
|
i = matcherOut.length;
|
|
while ( i-- ) {
|
|
if ( (elem = matcherOut[i]) &&
|
|
(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
|
|
|
|
seed[temp] = !(results[temp] = elem);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add elements to results, through postFinder if defined
|
|
} else {
|
|
matcherOut = condense(
|
|
matcherOut === results ?
|
|
matcherOut.splice( preexisting, matcherOut.length ) :
|
|
matcherOut
|
|
);
|
|
if ( postFinder ) {
|
|
postFinder( null, results, matcherOut, xml );
|
|
} else {
|
|
push.apply( results, matcherOut );
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function matcherFromTokens( tokens ) {
|
|
var checkContext, matcher, j,
|
|
len = tokens.length,
|
|
leadingRelative = Expr.relative[ tokens[0].type ],
|
|
implicitRelative = leadingRelative || Expr.relative[" "],
|
|
i = leadingRelative ? 1 : 0,
|
|
|
|
// The foundational matcher ensures that elements are reachable from top-level context(s)
|
|
matchContext = addCombinator( function( elem ) {
|
|
return elem === checkContext;
|
|
}, implicitRelative, true ),
|
|
matchAnyContext = addCombinator( function( elem ) {
|
|
return indexOf( checkContext, elem ) > -1;
|
|
}, implicitRelative, true ),
|
|
matchers = [ function( elem, context, xml ) {
|
|
var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
|
|
(checkContext = context).nodeType ?
|
|
matchContext( elem, context, xml ) :
|
|
matchAnyContext( elem, context, xml ) );
|
|
// Avoid hanging onto element (issue #299)
|
|
checkContext = null;
|
|
return ret;
|
|
} ];
|
|
|
|
for ( ; i < len; i++ ) {
|
|
if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
|
|
matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
|
|
} else {
|
|
matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
|
|
|
|
// Return special upon seeing a positional matcher
|
|
if ( matcher[ expando ] ) {
|
|
// Find the next relative operator (if any) for proper handling
|
|
j = ++i;
|
|
for ( ; j < len; j++ ) {
|
|
if ( Expr.relative[ tokens[j].type ] ) {
|
|
break;
|
|
}
|
|
}
|
|
return setMatcher(
|
|
i > 1 && elementMatcher( matchers ),
|
|
i > 1 && toSelector(
|
|
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
|
|
tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
|
|
).replace( rtrim, "$1" ),
|
|
matcher,
|
|
i < j && matcherFromTokens( tokens.slice( i, j ) ),
|
|
j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
|
|
j < len && toSelector( tokens )
|
|
);
|
|
}
|
|
matchers.push( matcher );
|
|
}
|
|
}
|
|
|
|
return elementMatcher( matchers );
|
|
}
|
|
|
|
function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
|
|
var bySet = setMatchers.length > 0,
|
|
byElement = elementMatchers.length > 0,
|
|
superMatcher = function( seed, context, xml, results, outermost ) {
|
|
var elem, j, matcher,
|
|
matchedCount = 0,
|
|
i = "0",
|
|
unmatched = seed && [],
|
|
setMatched = [],
|
|
contextBackup = outermostContext,
|
|
// We must always have either seed elements or outermost context
|
|
elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
|
|
// Use integer dirruns iff this is the outermost matcher
|
|
dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
|
|
len = elems.length;
|
|
|
|
if ( outermost ) {
|
|
outermostContext = context !== document && context;
|
|
}
|
|
|
|
// Add elements passing elementMatchers directly to results
|
|
// Keep `i` a string if there are no elements so `matchedCount` will be "00" below
|
|
// Support: IE<9, Safari
|
|
// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
|
|
for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
|
|
if ( byElement && elem ) {
|
|
j = 0;
|
|
while ( (matcher = elementMatchers[j++]) ) {
|
|
if ( matcher( elem, context, xml ) ) {
|
|
results.push( elem );
|
|
break;
|
|
}
|
|
}
|
|
if ( outermost ) {
|
|
dirruns = dirrunsUnique;
|
|
}
|
|
}
|
|
|
|
// Track unmatched elements for set filters
|
|
if ( bySet ) {
|
|
// They will have gone through all possible matchers
|
|
if ( (elem = !matcher && elem) ) {
|
|
matchedCount--;
|
|
}
|
|
|
|
// Lengthen the array for every element, matched or not
|
|
if ( seed ) {
|
|
unmatched.push( elem );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Apply set filters to unmatched elements
|
|
matchedCount += i;
|
|
if ( bySet && i !== matchedCount ) {
|
|
j = 0;
|
|
while ( (matcher = setMatchers[j++]) ) {
|
|
matcher( unmatched, setMatched, context, xml );
|
|
}
|
|
|
|
if ( seed ) {
|
|
// Reintegrate element matches to eliminate the need for sorting
|
|
if ( matchedCount > 0 ) {
|
|
while ( i-- ) {
|
|
if ( !(unmatched[i] || setMatched[i]) ) {
|
|
setMatched[i] = pop.call( results );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Discard index placeholder values to get only actual matches
|
|
setMatched = condense( setMatched );
|
|
}
|
|
|
|
// Add matches to results
|
|
push.apply( results, setMatched );
|
|
|
|
// Seedless set matches succeeding multiple successful matchers stipulate sorting
|
|
if ( outermost && !seed && setMatched.length > 0 &&
|
|
( matchedCount + setMatchers.length ) > 1 ) {
|
|
|
|
Sizzle.uniqueSort( results );
|
|
}
|
|
}
|
|
|
|
// Override manipulation of globals by nested matchers
|
|
if ( outermost ) {
|
|
dirruns = dirrunsUnique;
|
|
outermostContext = contextBackup;
|
|
}
|
|
|
|
return unmatched;
|
|
};
|
|
|
|
return bySet ?
|
|
markFunction( superMatcher ) :
|
|
superMatcher;
|
|
}
|
|
|
|
compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
|
|
var i,
|
|
setMatchers = [],
|
|
elementMatchers = [],
|
|
cached = compilerCache[ selector + " " ];
|
|
|
|
if ( !cached ) {
|
|
// Generate a function of recursive functions that can be used to check each element
|
|
if ( !match ) {
|
|
match = tokenize( selector );
|
|
}
|
|
i = match.length;
|
|
while ( i-- ) {
|
|
cached = matcherFromTokens( match[i] );
|
|
if ( cached[ expando ] ) {
|
|
setMatchers.push( cached );
|
|
} else {
|
|
elementMatchers.push( cached );
|
|
}
|
|
}
|
|
|
|
// Cache the compiled function
|
|
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
|
|
|
|
// Save selector and tokenization
|
|
cached.selector = selector;
|
|
}
|
|
return cached;
|
|
};
|
|
|
|
/**
|
|
* A low-level selection function that works with Sizzle's compiled
|
|
* selector functions
|
|
* @param {String|Function} selector A selector or a pre-compiled
|
|
* selector function built with Sizzle.compile
|
|
* @param {Element} context
|
|
* @param {Array} [results]
|
|
* @param {Array} [seed] A set of elements to match against
|
|
*/
|
|
select = Sizzle.select = function( selector, context, results, seed ) {
|
|
var i, tokens, token, type, find,
|
|
compiled = typeof selector === "function" && selector,
|
|
match = !seed && tokenize( (selector = compiled.selector || selector) );
|
|
|
|
results = results || [];
|
|
|
|
// Try to minimize operations if there is no seed and only one group
|
|
if ( match.length === 1 ) {
|
|
|
|
// Take a shortcut and set the context if the root selector is an ID
|
|
tokens = match[0] = match[0].slice( 0 );
|
|
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
|
|
support.getById && context.nodeType === 9 && documentIsHTML &&
|
|
Expr.relative[ tokens[1].type ] ) {
|
|
|
|
context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
|
|
if ( !context ) {
|
|
return results;
|
|
|
|
// Precompiled matchers will still verify ancestry, so step up a level
|
|
} else if ( compiled ) {
|
|
context = context.parentNode;
|
|
}
|
|
|
|
selector = selector.slice( tokens.shift().value.length );
|
|
}
|
|
|
|
// Fetch a seed set for right-to-left matching
|
|
i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
|
|
while ( i-- ) {
|
|
token = tokens[i];
|
|
|
|
// Abort if we hit a combinator
|
|
if ( Expr.relative[ (type = token.type) ] ) {
|
|
break;
|
|
}
|
|
if ( (find = Expr.find[ type ]) ) {
|
|
// Search, expanding context for leading sibling combinators
|
|
if ( (seed = find(
|
|
token.matches[0].replace( runescape, funescape ),
|
|
rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
|
|
)) ) {
|
|
|
|
// If seed is empty or no tokens remain, we can return early
|
|
tokens.splice( i, 1 );
|
|
selector = seed.length && toSelector( tokens );
|
|
if ( !selector ) {
|
|
push.apply( results, seed );
|
|
return results;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Compile and execute a filtering function if one is not provided
|
|
// Provide `match` to avoid retokenization if we modified the selector above
|
|
( compiled || compile( selector, match ) )(
|
|
seed,
|
|
context,
|
|
!documentIsHTML,
|
|
results,
|
|
rsibling.test( selector ) && testContext( context.parentNode ) || context
|
|
);
|
|
return results;
|
|
};
|
|
|
|
// One-time assignments
|
|
|
|
// Sort stability
|
|
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
|
|
|
|
// Support: Chrome 14-35+
|
|
// Always assume duplicates if they aren't passed to the comparison function
|
|
support.detectDuplicates = !!hasDuplicate;
|
|
|
|
// Initialize against the default document
|
|
setDocument();
|
|
|
|
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
|
|
// Detached nodes confoundingly follow *each other*
|
|
support.sortDetached = assert(function( div1 ) {
|
|
// Should return 1, but returns 4 (following)
|
|
return div1.compareDocumentPosition( document.createElement("div") ) & 1;
|
|
});
|
|
|
|
// Support: IE<8
|
|
// Prevent attribute/property "interpolation"
|
|
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
|
if ( !assert(function( div ) {
|
|
div.innerHTML = "<a href='#'></a>";
|
|
return div.firstChild.getAttribute("href") === "#" ;
|
|
}) ) {
|
|
addHandle( "type|href|height|width", function( elem, name, isXML ) {
|
|
if ( !isXML ) {
|
|
return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
|
|
}
|
|
});
|
|
}
|
|
|
|
// Support: IE<9
|
|
// Use defaultValue in place of getAttribute("value")
|
|
if ( !support.attributes || !assert(function( div ) {
|
|
div.innerHTML = "<input/>";
|
|
div.firstChild.setAttribute( "value", "" );
|
|
return div.firstChild.getAttribute( "value" ) === "";
|
|
}) ) {
|
|
addHandle( "value", function( elem, name, isXML ) {
|
|
if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
|
|
return elem.defaultValue;
|
|
}
|
|
});
|
|
}
|
|
|
|
// Support: IE<9
|
|
// Use getAttributeNode to fetch booleans when getAttribute lies
|
|
if ( !assert(function( div ) {
|
|
return div.getAttribute("disabled") == null;
|
|
}) ) {
|
|
addHandle( booleans, function( elem, name, isXML ) {
|
|
var val;
|
|
if ( !isXML ) {
|
|
return elem[ name ] === true ? name.toLowerCase() :
|
|
(val = elem.getAttributeNode( name )) && val.specified ?
|
|
val.value :
|
|
null;
|
|
}
|
|
});
|
|
}
|
|
|
|
return Sizzle;
|
|
|
|
})( window );
|
|
|
|
|
|
|
|
jQuery.find = Sizzle;
|
|
jQuery.expr = Sizzle.selectors;
|
|
jQuery.expr[":"] = jQuery.expr.pseudos;
|
|
jQuery.unique = Sizzle.uniqueSort;
|
|
jQuery.text = Sizzle.getText;
|
|
jQuery.isXMLDoc = Sizzle.isXML;
|
|
jQuery.contains = Sizzle.contains;
|
|
|
|
|
|
|
|
var rneedsContext = jQuery.expr.match.needsContext;
|
|
|
|
var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
|
|
|
|
|
|
|
|
var risSimple = /^.[^:#\[\.,]*$/;
|
|
|
|
// Implement the identical functionality for filter and not
|
|
function winnow( elements, qualifier, not ) {
|
|
if ( jQuery.isFunction( qualifier ) ) {
|
|
return jQuery.grep( elements, function( elem, i ) {
|
|
/* jshint -W018 */
|
|
return !!qualifier.call( elem, i, elem ) !== not;
|
|
});
|
|
|
|
}
|
|
|
|
if ( qualifier.nodeType ) {
|
|
return jQuery.grep( elements, function( elem ) {
|
|
return ( elem === qualifier ) !== not;
|
|
});
|
|
|
|
}
|
|
|
|
if ( typeof qualifier === "string" ) {
|
|
if ( risSimple.test( qualifier ) ) {
|
|
return jQuery.filter( qualifier, elements, not );
|
|
}
|
|
|
|
qualifier = jQuery.filter( qualifier, elements );
|
|
}
|
|
|
|
return jQuery.grep( elements, function( elem ) {
|
|
return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
|
|
});
|
|
}
|
|
|
|
jQuery.filter = function( expr, elems, not ) {
|
|
var elem = elems[ 0 ];
|
|
|
|
if ( not ) {
|
|
expr = ":not(" + expr + ")";
|
|
}
|
|
|
|
return elems.length === 1 && elem.nodeType === 1 ?
|
|
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
|
|
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
|
|
return elem.nodeType === 1;
|
|
}));
|
|
};
|
|
|
|
jQuery.fn.extend({
|
|
find: function( selector ) {
|
|
var i,
|
|
len = this.length,
|
|
ret = [],
|
|
self = this;
|
|
|
|
if ( typeof selector !== "string" ) {
|
|
return this.pushStack( jQuery( selector ).filter(function() {
|
|
for ( i = 0; i < len; i++ ) {
|
|
if ( jQuery.contains( self[ i ], this ) ) {
|
|
return true;
|
|
}
|
|
}
|
|
}) );
|
|
}
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
jQuery.find( selector, self[ i ], ret );
|
|
}
|
|
|
|
// Needed because $( selector, context ) becomes $( context ).find( selector )
|
|
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
|
|
ret.selector = this.selector ? this.selector + " " + selector : selector;
|
|
return ret;
|
|
},
|
|
filter: function( selector ) {
|
|
return this.pushStack( winnow(this, selector || [], false) );
|
|
},
|
|
not: function( selector ) {
|
|
return this.pushStack( winnow(this, selector || [], true) );
|
|
},
|
|
is: function( selector ) {
|
|
return !!winnow(
|
|
this,
|
|
|
|
// If this is a positional/relative selector, check membership in the returned set
|
|
// so $("p:first").is("p:last") won't return true for a doc with two "p".
|
|
typeof selector === "string" && rneedsContext.test( selector ) ?
|
|
jQuery( selector ) :
|
|
selector || [],
|
|
false
|
|
).length;
|
|
}
|
|
});
|
|
|
|
|
|
// Initialize a jQuery object
|
|
|
|
|
|
// A central reference to the root jQuery(document)
|
|
var rootjQuery,
|
|
|
|
// A simple way to check for HTML strings
|
|
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
|
// Strict HTML recognition (#11290: must start with <)
|
|
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
|
|
|
|
init = jQuery.fn.init = function( selector, context ) {
|
|
var match, elem;
|
|
|
|
// HANDLE: $(""), $(null), $(undefined), $(false)
|
|
if ( !selector ) {
|
|
return this;
|
|
}
|
|
|
|
// Handle HTML strings
|
|
if ( typeof selector === "string" ) {
|
|
if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
|
|
// Assume that strings that start and end with <> are HTML and skip the regex check
|
|
match = [ null, selector, null ];
|
|
|
|
} else {
|
|
match = rquickExpr.exec( selector );
|
|
}
|
|
|
|
// Match html or make sure no context is specified for #id
|
|
if ( match && (match[1] || !context) ) {
|
|
|
|
// HANDLE: $(html) -> $(array)
|
|
if ( match[1] ) {
|
|
context = context instanceof jQuery ? context[0] : context;
|
|
|
|
// Option to run scripts is true for back-compat
|
|
// Intentionally let the error be thrown if parseHTML is not present
|
|
jQuery.merge( this, jQuery.parseHTML(
|
|
match[1],
|
|
context && context.nodeType ? context.ownerDocument || context : document,
|
|
true
|
|
) );
|
|
|
|
// HANDLE: $(html, props)
|
|
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
|
|
for ( match in context ) {
|
|
// Properties of context are called as methods if possible
|
|
if ( jQuery.isFunction( this[ match ] ) ) {
|
|
this[ match ]( context[ match ] );
|
|
|
|
// ...and otherwise set as attributes
|
|
} else {
|
|
this.attr( match, context[ match ] );
|
|
}
|
|
}
|
|
}
|
|
|
|
return this;
|
|
|
|
// HANDLE: $(#id)
|
|
} else {
|
|
elem = document.getElementById( match[2] );
|
|
|
|
// Support: Blackberry 4.6
|
|
// gEBID returns nodes no longer in the document (#6963)
|
|
if ( elem && elem.parentNode ) {
|
|
// Inject the element directly into the jQuery object
|
|
this.length = 1;
|
|
this[0] = elem;
|
|
}
|
|
|
|
this.context = document;
|
|
this.selector = selector;
|
|
return this;
|
|
}
|
|
|
|
// HANDLE: $(expr, $(...))
|
|
} else if ( !context || context.jquery ) {
|
|
return ( context || rootjQuery ).find( selector );
|
|
|
|
// HANDLE: $(expr, context)
|
|
// (which is just equivalent to: $(context).find(expr)
|
|
} else {
|
|
return this.constructor( context ).find( selector );
|
|
}
|
|
|
|
// HANDLE: $(DOMElement)
|
|
} else if ( selector.nodeType ) {
|
|
this.context = this[0] = selector;
|
|
this.length = 1;
|
|
return this;
|
|
|
|
// HANDLE: $(function)
|
|
// Shortcut for document ready
|
|
} else if ( jQuery.isFunction( selector ) ) {
|
|
return typeof rootjQuery.ready !== "undefined" ?
|
|
rootjQuery.ready( selector ) :
|
|
// Execute immediately if ready is not present
|
|
selector( jQuery );
|
|
}
|
|
|
|
if ( selector.selector !== undefined ) {
|
|
this.selector = selector.selector;
|
|
this.context = selector.context;
|
|
}
|
|
|
|
return jQuery.makeArray( selector, this );
|
|
};
|
|
|
|
// Give the init function the jQuery prototype for later instantiation
|
|
init.prototype = jQuery.fn;
|
|
|
|
// Initialize central reference
|
|
rootjQuery = jQuery( document );
|
|
|
|
|
|
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
|
// Methods guaranteed to produce a unique set when starting from a unique set
|
|
guaranteedUnique = {
|
|
children: true,
|
|
contents: true,
|
|
next: true,
|
|
prev: true
|
|
};
|
|
|
|
jQuery.extend({
|
|
dir: function( elem, dir, until ) {
|
|
var matched = [],
|
|
truncate = until !== undefined;
|
|
|
|
while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
|
|
if ( elem.nodeType === 1 ) {
|
|
if ( truncate && jQuery( elem ).is( until ) ) {
|
|
break;
|
|
}
|
|
matched.push( elem );
|
|
}
|
|
}
|
|
return matched;
|
|
},
|
|
|
|
sibling: function( n, elem ) {
|
|
var matched = [];
|
|
|
|
for ( ; n; n = n.nextSibling ) {
|
|
if ( n.nodeType === 1 && n !== elem ) {
|
|
matched.push( n );
|
|
}
|
|
}
|
|
|
|
return matched;
|
|
}
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
has: function( target ) {
|
|
var targets = jQuery( target, this ),
|
|
l = targets.length;
|
|
|
|
return this.filter(function() {
|
|
var i = 0;
|
|
for ( ; i < l; i++ ) {
|
|
if ( jQuery.contains( this, targets[i] ) ) {
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
closest: function( selectors, context ) {
|
|
var cur,
|
|
i = 0,
|
|
l = this.length,
|
|
matched = [],
|
|
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
|
|
jQuery( selectors, context || this.context ) :
|
|
0;
|
|
|
|
for ( ; i < l; i++ ) {
|
|
for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
|
|
// Always skip document fragments
|
|
if ( cur.nodeType < 11 && (pos ?
|
|
pos.index(cur) > -1 :
|
|
|
|
// Don't pass non-elements to Sizzle
|
|
cur.nodeType === 1 &&
|
|
jQuery.find.matchesSelector(cur, selectors)) ) {
|
|
|
|
matched.push( cur );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
|
|
},
|
|
|
|
// Determine the position of an element within the set
|
|
index: function( elem ) {
|
|
|
|
// No argument, return index in parent
|
|
if ( !elem ) {
|
|
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
|
|
}
|
|
|
|
// Index in selector
|
|
if ( typeof elem === "string" ) {
|
|
return indexOf.call( jQuery( elem ), this[ 0 ] );
|
|
}
|
|
|
|
// Locate the position of the desired element
|
|
return indexOf.call( this,
|
|
|
|
// If it receives a jQuery object, the first element is used
|
|
elem.jquery ? elem[ 0 ] : elem
|
|
);
|
|
},
|
|
|
|
add: function( selector, context ) {
|
|
return this.pushStack(
|
|
jQuery.unique(
|
|
jQuery.merge( this.get(), jQuery( selector, context ) )
|
|
)
|
|
);
|
|
},
|
|
|
|
addBack: function( selector ) {
|
|
return this.add( selector == null ?
|
|
this.prevObject : this.prevObject.filter(selector)
|
|
);
|
|
}
|
|
});
|
|
|
|
function sibling( cur, dir ) {
|
|
while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
|
|
return cur;
|
|
}
|
|
|
|
jQuery.each({
|
|
parent: function( elem ) {
|
|
var parent = elem.parentNode;
|
|
return parent && parent.nodeType !== 11 ? parent : null;
|
|
},
|
|
parents: function( elem ) {
|
|
return jQuery.dir( elem, "parentNode" );
|
|
},
|
|
parentsUntil: function( elem, i, until ) {
|
|
return jQuery.dir( elem, "parentNode", until );
|
|
},
|
|
next: function( elem ) {
|
|
return sibling( elem, "nextSibling" );
|
|
},
|
|
prev: function( elem ) {
|
|
return sibling( elem, "previousSibling" );
|
|
},
|
|
nextAll: function( elem ) {
|
|
return jQuery.dir( elem, "nextSibling" );
|
|
},
|
|
prevAll: function( elem ) {
|
|
return jQuery.dir( elem, "previousSibling" );
|
|
},
|
|
nextUntil: function( elem, i, until ) {
|
|
return jQuery.dir( elem, "nextSibling", until );
|
|
},
|
|
prevUntil: function( elem, i, until ) {
|
|
return jQuery.dir( elem, "previousSibling", until );
|
|
},
|
|
siblings: function( elem ) {
|
|
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
|
|
},
|
|
children: function( elem ) {
|
|
return jQuery.sibling( elem.firstChild );
|
|
},
|
|
contents: function( elem ) {
|
|
return elem.contentDocument || jQuery.merge( [], elem.childNodes );
|
|
}
|
|
}, function( name, fn ) {
|
|
jQuery.fn[ name ] = function( until, selector ) {
|
|
var matched = jQuery.map( this, fn, until );
|
|
|
|
if ( name.slice( -5 ) !== "Until" ) {
|
|
selector = until;
|
|
}
|
|
|
|
if ( selector && typeof selector === "string" ) {
|
|
matched = jQuery.filter( selector, matched );
|
|
}
|
|
|
|
if ( this.length > 1 ) {
|
|
// Remove duplicates
|
|
if ( !guaranteedUnique[ name ] ) {
|
|
jQuery.unique( matched );
|
|
}
|
|
|
|
// Reverse order for parents* and prev-derivatives
|
|
if ( rparentsprev.test( name ) ) {
|
|
matched.reverse();
|
|
}
|
|
}
|
|
|
|
return this.pushStack( matched );
|
|
};
|
|
});
|
|
var rnotwhite = (/\S+/g);
|
|
|
|
|
|
|
|
// String to Object options format cache
|
|
var optionsCache = {};
|
|
|
|
// Convert String-formatted options into Object-formatted ones and store in cache
|
|
function createOptions( options ) {
|
|
var object = optionsCache[ options ] = {};
|
|
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
|
|
object[ flag ] = true;
|
|
});
|
|
return object;
|
|
}
|
|
|
|
/*
|
|
* Create a callback list using the following parameters:
|
|
*
|
|
* options: an optional list of space-separated options that will change how
|
|
* the callback list behaves or a more traditional option object
|
|
*
|
|
* By default a callback list will act like an event callback list and can be
|
|
* "fired" multiple times.
|
|
*
|
|
* Possible options:
|
|
*
|
|
* once: will ensure the callback list can only be fired once (like a Deferred)
|
|
*
|
|
* memory: will keep track of previous values and will call any callback added
|
|
* after the list has been fired right away with the latest "memorized"
|
|
* values (like a Deferred)
|
|
*
|
|
* unique: will ensure a callback can only be added once (no duplicate in the list)
|
|
*
|
|
* stopOnFalse: interrupt callings when a callback returns false
|
|
*
|
|
*/
|
|
jQuery.Callbacks = function( options ) {
|
|
|
|
// Convert options from String-formatted to Object-formatted if needed
|
|
// (we check in cache first)
|
|
options = typeof options === "string" ?
|
|
( optionsCache[ options ] || createOptions( options ) ) :
|
|
jQuery.extend( {}, options );
|
|
|
|
var // Last fire value (for non-forgettable lists)
|
|
memory,
|
|
// Flag to know if list was already fired
|
|
fired,
|
|
// Flag to know if list is currently firing
|
|
firing,
|
|
// First callback to fire (used internally by add and fireWith)
|
|
firingStart,
|
|
// End of the loop when firing
|
|
firingLength,
|
|
// Index of currently firing callback (modified by remove if needed)
|
|
firingIndex,
|
|
// Actual callback list
|
|
list = [],
|
|
// Stack of fire calls for repeatable lists
|
|
stack = !options.once && [],
|
|
// Fire callbacks
|
|
fire = function( data ) {
|
|
memory = options.memory && data;
|
|
fired = true;
|
|
firingIndex = firingStart || 0;
|
|
firingStart = 0;
|
|
firingLength = list.length;
|
|
firing = true;
|
|
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
|
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
|
memory = false; // To prevent further calls using add
|
|
break;
|
|
}
|
|
}
|
|
firing = false;
|
|
if ( list ) {
|
|
if ( stack ) {
|
|
if ( stack.length ) {
|
|
fire( stack.shift() );
|
|
}
|
|
} else if ( memory ) {
|
|
list = [];
|
|
} else {
|
|
self.disable();
|
|
}
|
|
}
|
|
},
|
|
// Actual Callbacks object
|
|
self = {
|
|
// Add a callback or a collection of callbacks to the list
|
|
add: function() {
|
|
if ( list ) {
|
|
// First, we save the current length
|
|
var start = list.length;
|
|
(function add( args ) {
|
|
jQuery.each( args, function( _, arg ) {
|
|
var type = jQuery.type( arg );
|
|
if ( type === "function" ) {
|
|
if ( !options.unique || !self.has( arg ) ) {
|
|
list.push( arg );
|
|
}
|
|
} else if ( arg && arg.length && type !== "string" ) {
|
|
// Inspect recursively
|
|
add( arg );
|
|
}
|
|
});
|
|
})( arguments );
|
|
// Do we need to add the callbacks to the
|
|
// current firing batch?
|
|
if ( firing ) {
|
|
firingLength = list.length;
|
|
// With memory, if we're not firing then
|
|
// we should call right away
|
|
} else if ( memory ) {
|
|
firingStart = start;
|
|
fire( memory );
|
|
}
|
|
}
|
|
return this;
|
|
},
|
|
// Remove a callback from the list
|
|
remove: function() {
|
|
if ( list ) {
|
|
jQuery.each( arguments, function( _, arg ) {
|
|
var index;
|
|
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
|
|
list.splice( index, 1 );
|
|
// Handle firing indexes
|
|
if ( firing ) {
|
|
if ( index <= firingLength ) {
|
|
firingLength--;
|
|
}
|
|
if ( index <= firingIndex ) {
|
|
firingIndex--;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return this;
|
|
},
|
|
// Check if a given callback is in the list.
|
|
// If no argument is given, return whether or not list has callbacks attached.
|
|
has: function( fn ) {
|
|
return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
|
|
},
|
|
// Remove all callbacks from the list
|
|
empty: function() {
|
|
list = [];
|
|
firingLength = 0;
|
|
return this;
|
|
},
|
|
// Have the list do nothing anymore
|
|
disable: function() {
|
|
list = stack = memory = undefined;
|
|
return this;
|
|
},
|
|
// Is it disabled?
|
|
disabled: function() {
|
|
return !list;
|
|
},
|
|
// Lock the list in its current state
|
|
lock: function() {
|
|
stack = undefined;
|
|
if ( !memory ) {
|
|
self.disable();
|
|
}
|
|
return this;
|
|
},
|
|
// Is it locked?
|
|
locked: function() {
|
|
return !stack;
|
|
},
|
|
// Call all callbacks with the given context and arguments
|
|
fireWith: function( context, args ) {
|
|
if ( list && ( !fired || stack ) ) {
|
|
args = args || [];
|
|
args = [ context, args.slice ? args.slice() : args ];
|
|
if ( firing ) {
|
|
stack.push( args );
|
|
} else {
|
|
fire( args );
|
|
}
|
|
}
|
|
return this;
|
|
},
|
|
// Call all the callbacks with the given arguments
|
|
fire: function() {
|
|
self.fireWith( this, arguments );
|
|
return this;
|
|
},
|
|
// To know if the callbacks have already been called at least once
|
|
fired: function() {
|
|
return !!fired;
|
|
}
|
|
};
|
|
|
|
return self;
|
|
};
|
|
|
|
|
|
jQuery.extend({
|
|
|
|
Deferred: function( func ) {
|
|
var tuples = [
|
|
// action, add listener, listener list, final state
|
|
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
|
|
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
|
|
[ "notify", "progress", jQuery.Callbacks("memory") ]
|
|
],
|
|
state = "pending",
|
|
promise = {
|
|
state: function() {
|
|
return state;
|
|
},
|
|
always: function() {
|
|
deferred.done( arguments ).fail( arguments );
|
|
return this;
|
|
},
|
|
then: function( /* fnDone, fnFail, fnProgress */ ) {
|
|
var fns = arguments;
|
|
return jQuery.Deferred(function( newDefer ) {
|
|
jQuery.each( tuples, function( i, tuple ) {
|
|
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
|
|
// deferred[ done | fail | progress ] for forwarding actions to newDefer
|
|
deferred[ tuple[1] ](function() {
|
|
var returned = fn && fn.apply( this, arguments );
|
|
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
|
returned.promise()
|
|
.done( newDefer.resolve )
|
|
.fail( newDefer.reject )
|
|
.progress( newDefer.notify );
|
|
} else {
|
|
newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
|
|
}
|
|
});
|
|
});
|
|
fns = null;
|
|
}).promise();
|
|
},
|
|
// Get a promise for this deferred
|
|
// If obj is provided, the promise aspect is added to the object
|
|
promise: function( obj ) {
|
|
return obj != null ? jQuery.extend( obj, promise ) : promise;
|
|
}
|
|
},
|
|
deferred = {};
|
|
|
|
// Keep pipe for back-compat
|
|
promise.pipe = promise.then;
|
|
|
|
// Add list-specific methods
|
|
jQuery.each( tuples, function( i, tuple ) {
|
|
var list = tuple[ 2 ],
|
|
stateString = tuple[ 3 ];
|
|
|
|
// promise[ done | fail | progress ] = list.add
|
|
promise[ tuple[1] ] = list.add;
|
|
|
|
// Handle state
|
|
if ( stateString ) {
|
|
list.add(function() {
|
|
// state = [ resolved | rejected ]
|
|
state = stateString;
|
|
|
|
// [ reject_list | resolve_list ].disable; progress_list.lock
|
|
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
|
|
}
|
|
|
|
// deferred[ resolve | reject | notify ]
|
|
deferred[ tuple[0] ] = function() {
|
|
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
|
|
return this;
|
|
};
|
|
deferred[ tuple[0] + "With" ] = list.fireWith;
|
|
});
|
|
|
|
// Make the deferred a promise
|
|
promise.promise( deferred );
|
|
|
|
// Call given func if any
|
|
if ( func ) {
|
|
func.call( deferred, deferred );
|
|
}
|
|
|
|
// All done!
|
|
return deferred;
|
|
},
|
|
|
|
// Deferred helper
|
|
when: function( subordinate /* , ..., subordinateN */ ) {
|
|
var i = 0,
|
|
resolveValues = slice.call( arguments ),
|
|
length = resolveValues.length,
|
|
|
|
// the count of uncompleted subordinates
|
|
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
|
|
|
// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
|
|
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
|
|
|
// Update function for both resolve and progress values
|
|
updateFunc = function( i, contexts, values ) {
|
|
return function( value ) {
|
|
contexts[ i ] = this;
|
|
values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
|
|
if ( values === progressValues ) {
|
|
deferred.notifyWith( contexts, values );
|
|
} else if ( !( --remaining ) ) {
|
|
deferred.resolveWith( contexts, values );
|
|
}
|
|
};
|
|
},
|
|
|
|
progressValues, progressContexts, resolveContexts;
|
|
|
|
// Add listeners to Deferred subordinates; treat others as resolved
|
|
if ( length > 1 ) {
|
|
progressValues = new Array( length );
|
|
progressContexts = new Array( length );
|
|
resolveContexts = new Array( length );
|
|
for ( ; i < length; i++ ) {
|
|
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
|
|
resolveValues[ i ].promise()
|
|
.done( updateFunc( i, resolveContexts, resolveValues ) )
|
|
.fail( deferred.reject )
|
|
.progress( updateFunc( i, progressContexts, progressValues ) );
|
|
} else {
|
|
--remaining;
|
|
}
|
|
}
|
|
}
|
|
|
|
// If we're not waiting on anything, resolve the master
|
|
if ( !remaining ) {
|
|
deferred.resolveWith( resolveContexts, resolveValues );
|
|
}
|
|
|
|
return deferred.promise();
|
|
}
|
|
});
|
|
|
|
|
|
// The deferred used on DOM ready
|
|
var readyList;
|
|
|
|
jQuery.fn.ready = function( fn ) {
|
|
// Add the callback
|
|
jQuery.ready.promise().done( fn );
|
|
|
|
return this;
|
|
};
|
|
|
|
jQuery.extend({
|
|
// Is the DOM ready to be used? Set to true once it occurs.
|
|
isReady: false,
|
|
|
|
// A counter to track how many items to wait for before
|
|
// the ready event fires. See #6781
|
|
readyWait: 1,
|
|
|
|
// Hold (or release) the ready event
|
|
holdReady: function( hold ) {
|
|
if ( hold ) {
|
|
jQuery.readyWait++;
|
|
} else {
|
|
jQuery.ready( true );
|
|
}
|
|
},
|
|
|
|
// Handle when the DOM is ready
|
|
ready: function( wait ) {
|
|
|
|
// Abort if there are pending holds or we're already ready
|
|
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
|
|
return;
|
|
}
|
|
|
|
// Remember that the DOM is ready
|
|
jQuery.isReady = true;
|
|
|
|
// If a normal DOM Ready event fired, decrement, and wait if need be
|
|
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
|
return;
|
|
}
|
|
|
|
// If there are functions bound, to execute
|
|
readyList.resolveWith( document, [ jQuery ] );
|
|
|
|
// Trigger any bound ready events
|
|
if ( jQuery.fn.triggerHandler ) {
|
|
jQuery( document ).triggerHandler( "ready" );
|
|
jQuery( document ).off( "ready" );
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* The ready event handler and self cleanup method
|
|
*/
|
|
function completed() {
|
|
document.removeEventListener( "DOMContentLoaded", completed, false );
|
|
window.removeEventListener( "load", completed, false );
|
|
jQuery.ready();
|
|
}
|
|
|
|
jQuery.ready.promise = function( obj ) {
|
|
if ( !readyList ) {
|
|
|
|
readyList = jQuery.Deferred();
|
|
|
|
// Catch cases where $(document).ready() is called after the browser event has already occurred.
|
|
// We once tried to use readyState "interactive" here, but it caused issues like the one
|
|
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
|
if ( document.readyState === "complete" ) {
|
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
|
setTimeout( jQuery.ready );
|
|
|
|
} else {
|
|
|
|
// Use the handy event callback
|
|
document.addEventListener( "DOMContentLoaded", completed, false );
|
|
|
|
// A fallback to window.onload, that will always work
|
|
window.addEventListener( "load", completed, false );
|
|
}
|
|
}
|
|
return readyList.promise( obj );
|
|
};
|
|
|
|
// Kick off the DOM ready check even if the user does not
|
|
jQuery.ready.promise();
|
|
|
|
|
|
|
|
|
|
// Multifunctional method to get and set values of a collection
|
|
// The value/s can optionally be executed if it's a function
|
|
var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
|
var i = 0,
|
|
len = elems.length,
|
|
bulk = key == null;
|
|
|
|
// Sets many values
|
|
if ( jQuery.type( key ) === "object" ) {
|
|
chainable = true;
|
|
for ( i in key ) {
|
|
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
|
|
}
|
|
|
|
// Sets one value
|
|
} else if ( value !== undefined ) {
|
|
chainable = true;
|
|
|
|
if ( !jQuery.isFunction( value ) ) {
|
|
raw = true;
|
|
}
|
|
|
|
if ( bulk ) {
|
|
// Bulk operations run against the entire set
|
|
if ( raw ) {
|
|
fn.call( elems, value );
|
|
fn = null;
|
|
|
|
// ...except when executing function values
|
|
} else {
|
|
bulk = fn;
|
|
fn = function( elem, key, value ) {
|
|
return bulk.call( jQuery( elem ), value );
|
|
};
|
|
}
|
|
}
|
|
|
|
if ( fn ) {
|
|
for ( ; i < len; i++ ) {
|
|
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
return chainable ?
|
|
elems :
|
|
|
|
// Gets
|
|
bulk ?
|
|
fn.call( elems ) :
|
|
len ? fn( elems[0], key ) : emptyGet;
|
|
};
|
|
|
|
|
|
/**
|
|
* Determines whether an object can have data
|
|
*/
|
|
jQuery.acceptData = function( owner ) {
|
|
// Accepts only:
|
|
// - Node
|
|
// - Node.ELEMENT_NODE
|
|
// - Node.DOCUMENT_NODE
|
|
// - Object
|
|
// - Any
|
|
/* jshint -W018 */
|
|
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
|
|
};
|
|
|
|
|
|
function Data() {
|
|
// Support: Android<4,
|
|
// Old WebKit does not have Object.preventExtensions/freeze method,
|
|
// return new empty object instead with no [[set]] accessor
|
|
Object.defineProperty( this.cache = {}, 0, {
|
|
get: function() {
|
|
return {};
|
|
}
|
|
});
|
|
|
|
this.expando = jQuery.expando + Data.uid++;
|
|
}
|
|
|
|
Data.uid = 1;
|
|
Data.accepts = jQuery.acceptData;
|
|
|
|
Data.prototype = {
|
|
key: function( owner ) {
|
|
// We can accept data for non-element nodes in modern browsers,
|
|
// but we should not, see #8335.
|
|
// Always return the key for a frozen object.
|
|
if ( !Data.accepts( owner ) ) {
|
|
return 0;
|
|
}
|
|
|
|
var descriptor = {},
|
|
// Check if the owner object already has a cache key
|
|
unlock = owner[ this.expando ];
|
|
|
|
// If not, create one
|
|
if ( !unlock ) {
|
|
unlock = Data.uid++;
|
|
|
|
// Secure it in a non-enumerable, non-writable property
|
|
try {
|
|
descriptor[ this.expando ] = { value: unlock };
|
|
Object.defineProperties( owner, descriptor );
|
|
|
|
// Support: Android<4
|
|
// Fallback to a less secure definition
|
|
} catch ( e ) {
|
|
descriptor[ this.expando ] = unlock;
|
|
jQuery.extend( owner, descriptor );
|
|
}
|
|
}
|
|
|
|
// Ensure the cache object
|
|
if ( !this.cache[ unlock ] ) {
|
|
this.cache[ unlock ] = {};
|
|
}
|
|
|
|
return unlock;
|
|
},
|
|
set: function( owner, data, value ) {
|
|
var prop,
|
|
// There may be an unlock assigned to this node,
|
|
// if there is no entry for this "owner", create one inline
|
|
// and set the unlock as though an owner entry had always existed
|
|
unlock = this.key( owner ),
|
|
cache = this.cache[ unlock ];
|
|
|
|
// Handle: [ owner, key, value ] args
|
|
if ( typeof data === "string" ) {
|
|
cache[ data ] = value;
|
|
|
|
// Handle: [ owner, { properties } ] args
|
|
} else {
|
|
// Fresh assignments by object are shallow copied
|
|
if ( jQuery.isEmptyObject( cache ) ) {
|
|
jQuery.extend( this.cache[ unlock ], data );
|
|
// Otherwise, copy the properties one-by-one to the cache object
|
|
} else {
|
|
for ( prop in data ) {
|
|
cache[ prop ] = data[ prop ];
|
|
}
|
|
}
|
|
}
|
|
return cache;
|
|
},
|
|
get: function( owner, key ) {
|
|
// Either a valid cache is found, or will be created.
|
|
// New caches will be created and the unlock returned,
|
|
// allowing direct access to the newly created
|
|
// empty data object. A valid owner object must be provided.
|
|
var cache = this.cache[ this.key( owner ) ];
|
|
|
|
return key === undefined ?
|
|
cache : cache[ key ];
|
|
},
|
|
access: function( owner, key, value ) {
|
|
var stored;
|
|
// In cases where either:
|
|
//
|
|
// 1. No key was specified
|
|
// 2. A string key was specified, but no value provided
|
|
//
|
|
// Take the "read" path and allow the get method to determine
|
|
// which value to return, respectively either:
|
|
//
|
|
// 1. The entire cache object
|
|
// 2. The data stored at the key
|
|
//
|
|
if ( key === undefined ||
|
|
((key && typeof key === "string") && value === undefined) ) {
|
|
|
|
stored = this.get( owner, key );
|
|
|
|
return stored !== undefined ?
|
|
stored : this.get( owner, jQuery.camelCase(key) );
|
|
}
|
|
|
|
// [*]When the key is not a string, or both a key and value
|
|
// are specified, set or extend (existing objects) with either:
|
|
//
|
|
// 1. An object of properties
|
|
// 2. A key and value
|
|
//
|
|
this.set( owner, key, value );
|
|
|
|
// Since the "set" path can have two possible entry points
|
|
// return the expected data based on which path was taken[*]
|
|
return value !== undefined ? value : key;
|
|
},
|
|
remove: function( owner, key ) {
|
|
var i, name, camel,
|
|
unlock = this.key( owner ),
|
|
cache = this.cache[ unlock ];
|
|
|
|
if ( key === undefined ) {
|
|
this.cache[ unlock ] = {};
|
|
|
|
} else {
|
|
// Support array or space separated string of keys
|
|
if ( jQuery.isArray( key ) ) {
|
|
// If "name" is an array of keys...
|
|
// When data is initially created, via ("key", "val") signature,
|
|
// keys will be converted to camelCase.
|
|
// Since there is no way to tell _how_ a key was added, remove
|
|
// both plain key and camelCase key. #12786
|
|
// This will only penalize the array argument path.
|
|
name = key.concat( key.map( jQuery.camelCase ) );
|
|
} else {
|
|
camel = jQuery.camelCase( key );
|
|
// Try the string as a key before any manipulation
|
|
if ( key in cache ) {
|
|
name = [ key, camel ];
|
|
} else {
|
|
// If a key with the spaces exists, use it.
|
|
// Otherwise, create an array by matching non-whitespace
|
|
name = camel;
|
|
name = name in cache ?
|
|
[ name ] : ( name.match( rnotwhite ) || [] );
|
|
}
|
|
}
|
|
|
|
i = name.length;
|
|
while ( i-- ) {
|
|
delete cache[ name[ i ] ];
|
|
}
|
|
}
|
|
},
|
|
hasData: function( owner ) {
|
|
return !jQuery.isEmptyObject(
|
|
this.cache[ owner[ this.expando ] ] || {}
|
|
);
|
|
},
|
|
discard: function( owner ) {
|
|
if ( owner[ this.expando ] ) {
|
|
delete this.cache[ owner[ this.expando ] ];
|
|
}
|
|
}
|
|
};
|
|
var data_priv = new Data();
|
|
|
|
var data_user = new Data();
|
|
|
|
|
|
|
|
// Implementation Summary
|
|
//
|
|
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
|
|
// 2. Improve the module's maintainability by reducing the storage
|
|
// paths to a single mechanism.
|
|
// 3. Use the same single mechanism to support "private" and "user" data.
|
|
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
|
|
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
|
|
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
|
|
|
|
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
|
|
rmultiDash = /([A-Z])/g;
|
|
|
|
function dataAttr( elem, key, data ) {
|
|
var name;
|
|
|
|
// If nothing was found internally, try to fetch any
|
|
// data from the HTML5 data-* attribute
|
|
if ( data === undefined && elem.nodeType === 1 ) {
|
|
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
|
data = elem.getAttribute( name );
|
|
|
|
if ( typeof data === "string" ) {
|
|
try {
|
|
data = data === "true" ? true :
|
|
data === "false" ? false :
|
|
data === "null" ? null :
|
|
// Only convert to a number if it doesn't change the string
|
|
+data + "" === data ? +data :
|
|
rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
|
data;
|
|
} catch( e ) {}
|
|
|
|
// Make sure we set the data so it isn't changed later
|
|
data_user.set( elem, key, data );
|
|
} else {
|
|
data = undefined;
|
|
}
|
|
}
|
|
return data;
|
|
}
|
|
|
|
jQuery.extend({
|
|
hasData: function( elem ) {
|
|
return data_user.hasData( elem ) || data_priv.hasData( elem );
|
|
},
|
|
|
|
data: function( elem, name, data ) {
|
|
return data_user.access( elem, name, data );
|
|
},
|
|
|
|
removeData: function( elem, name ) {
|
|
data_user.remove( elem, name );
|
|
},
|
|
|
|
// TODO: Now that all calls to _data and _removeData have been replaced
|
|
// with direct calls to data_priv methods, these can be deprecated.
|
|
_data: function( elem, name, data ) {
|
|
return data_priv.access( elem, name, data );
|
|
},
|
|
|
|
_removeData: function( elem, name ) {
|
|
data_priv.remove( elem, name );
|
|
}
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
data: function( key, value ) {
|
|
var i, name, data,
|
|
elem = this[ 0 ],
|
|
attrs = elem && elem.attributes;
|
|
|
|
// Gets all values
|
|
if ( key === undefined ) {
|
|
if ( this.length ) {
|
|
data = data_user.get( elem );
|
|
|
|
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
|
|
i = attrs.length;
|
|
while ( i-- ) {
|
|
|
|
// Support: IE11+
|
|
// The attrs elements can be null (#14894)
|
|
if ( attrs[ i ] ) {
|
|
name = attrs[ i ].name;
|
|
if ( name.indexOf( "data-" ) === 0 ) {
|
|
name = jQuery.camelCase( name.slice(5) );
|
|
dataAttr( elem, name, data[ name ] );
|
|
}
|
|
}
|
|
}
|
|
data_priv.set( elem, "hasDataAttrs", true );
|
|
}
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
// Sets multiple values
|
|
if ( typeof key === "object" ) {
|
|
return this.each(function() {
|
|
data_user.set( this, key );
|
|
});
|
|
}
|
|
|
|
return access( this, function( value ) {
|
|
var data,
|
|
camelKey = jQuery.camelCase( key );
|
|
|
|
// The calling jQuery object (element matches) is not empty
|
|
// (and therefore has an element appears at this[ 0 ]) and the
|
|
// `value` parameter was not undefined. An empty jQuery object
|
|
// will result in `undefined` for elem = this[ 0 ] which will
|
|
// throw an exception if an attempt to read a data cache is made.
|
|
if ( elem && value === undefined ) {
|
|
// Attempt to get data from the cache
|
|
// with the key as-is
|
|
data = data_user.get( elem, key );
|
|
if ( data !== undefined ) {
|
|
return data;
|
|
}
|
|
|
|
// Attempt to get data from the cache
|
|
// with the key camelized
|
|
data = data_user.get( elem, camelKey );
|
|
if ( data !== undefined ) {
|
|
return data;
|
|
}
|
|
|
|
// Attempt to "discover" the data in
|
|
// HTML5 custom data-* attrs
|
|
data = dataAttr( elem, camelKey, undefined );
|
|
if ( data !== undefined ) {
|
|
return data;
|
|
}
|
|
|
|
// We tried really hard, but the data doesn't exist.
|
|
return;
|
|
}
|
|
|
|
// Set the data...
|
|
this.each(function() {
|
|
// First, attempt to store a copy or reference of any
|
|
// data that might've been store with a camelCased key.
|
|
var data = data_user.get( this, camelKey );
|
|
|
|
// For HTML5 data-* attribute interop, we have to
|
|
// store property names with dashes in a camelCase form.
|
|
// This might not apply to all properties...*
|
|
data_user.set( this, camelKey, value );
|
|
|
|
// *... In the case of properties that might _actually_
|
|
// have dashes, we need to also store a copy of that
|
|
// unchanged property.
|
|
if ( key.indexOf("-") !== -1 && data !== undefined ) {
|
|
data_user.set( this, key, value );
|
|
}
|
|
});
|
|
}, null, value, arguments.length > 1, null, true );
|
|
},
|
|
|
|
removeData: function( key ) {
|
|
return this.each(function() {
|
|
data_user.remove( this, key );
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
jQuery.extend({
|
|
queue: function( elem, type, data ) {
|
|
var queue;
|
|
|
|
if ( elem ) {
|
|
type = ( type || "fx" ) + "queue";
|
|
queue = data_priv.get( elem, type );
|
|
|
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
|
if ( data ) {
|
|
if ( !queue || jQuery.isArray( data ) ) {
|
|
queue = data_priv.access( elem, type, jQuery.makeArray(data) );
|
|
} else {
|
|
queue.push( data );
|
|
}
|
|
}
|
|
return queue || [];
|
|
}
|
|
},
|
|
|
|
dequeue: function( elem, type ) {
|
|
type = type || "fx";
|
|
|
|
var queue = jQuery.queue( elem, type ),
|
|
startLength = queue.length,
|
|
fn = queue.shift(),
|
|
hooks = jQuery._queueHooks( elem, type ),
|
|
next = function() {
|
|
jQuery.dequeue( elem, type );
|
|
};
|
|
|
|
// If the fx queue is dequeued, always remove the progress sentinel
|
|
if ( fn === "inprogress" ) {
|
|
fn = queue.shift();
|
|
startLength--;
|
|
}
|
|
|
|
if ( fn ) {
|
|
|
|
// Add a progress sentinel to prevent the fx queue from being
|
|
// automatically dequeued
|
|
if ( type === "fx" ) {
|
|
queue.unshift( "inprogress" );
|
|
}
|
|
|
|
// Clear up the last queue stop function
|
|
delete hooks.stop;
|
|
fn.call( elem, next, hooks );
|
|
}
|
|
|
|
if ( !startLength && hooks ) {
|
|
hooks.empty.fire();
|
|
}
|
|
},
|
|
|
|
// Not public - generate a queueHooks object, or return the current one
|
|
_queueHooks: function( elem, type ) {
|
|
var key = type + "queueHooks";
|
|
return data_priv.get( elem, key ) || data_priv.access( elem, key, {
|
|
empty: jQuery.Callbacks("once memory").add(function() {
|
|
data_priv.remove( elem, [ type + "queue", key ] );
|
|
})
|
|
});
|
|
}
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
queue: function( type, data ) {
|
|
var setter = 2;
|
|
|
|
if ( typeof type !== "string" ) {
|
|
data = type;
|
|
type = "fx";
|
|
setter--;
|
|
}
|
|
|
|
if ( arguments.length < setter ) {
|
|
return jQuery.queue( this[0], type );
|
|
}
|
|
|
|
return data === undefined ?
|
|
this :
|
|
this.each(function() {
|
|
var queue = jQuery.queue( this, type, data );
|
|
|
|
// Ensure a hooks for this queue
|
|
jQuery._queueHooks( this, type );
|
|
|
|
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
|
jQuery.dequeue( this, type );
|
|
}
|
|
});
|
|
},
|
|
dequeue: function( type ) {
|
|
return this.each(function() {
|
|
jQuery.dequeue( this, type );
|
|
});
|
|
},
|
|
clearQueue: function( type ) {
|
|
return this.queue( type || "fx", [] );
|
|
},
|
|
// Get a promise resolved when queues of a certain type
|
|
// are emptied (fx is the type by default)
|
|
promise: function( type, obj ) {
|
|
var tmp,
|
|
count = 1,
|
|
defer = jQuery.Deferred(),
|
|
elements = this,
|
|
i = this.length,
|
|
resolve = function() {
|
|
if ( !( --count ) ) {
|
|
defer.resolveWith( elements, [ elements ] );
|
|
}
|
|
};
|
|
|
|
if ( typeof type !== "string" ) {
|
|
obj = type;
|
|
type = undefined;
|
|
}
|
|
type = type || "fx";
|
|
|
|
while ( i-- ) {
|
|
tmp = data_priv.get( elements[ i ], type + "queueHooks" );
|
|
if ( tmp && tmp.empty ) {
|
|
count++;
|
|
tmp.empty.add( resolve );
|
|
}
|
|
}
|
|
resolve();
|
|
return defer.promise( obj );
|
|
}
|
|
});
|
|
var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
|
|
|
|
var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
|
|
|
|
var isHidden = function( elem, el ) {
|
|
// isHidden might be called from jQuery#filter function;
|
|
// in that case, element will be second argument
|
|
elem = el || elem;
|
|
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
|
};
|
|
|
|
var rcheckableType = (/^(?:checkbox|radio)$/i);
|
|
|
|
|
|
|
|
(function() {
|
|
var fragment = document.createDocumentFragment(),
|
|
div = fragment.appendChild( document.createElement( "div" ) ),
|
|
input = document.createElement( "input" );
|
|
|
|
// Support: Safari<=5.1
|
|
// Check state lost if the name is set (#11217)
|
|
// Support: Windows Web Apps (WWA)
|
|
// `name` and `type` must use .setAttribute for WWA (#14901)
|
|
input.setAttribute( "type", "radio" );
|
|
input.setAttribute( "checked", "checked" );
|
|
input.setAttribute( "name", "t" );
|
|
|
|
div.appendChild( input );
|
|
|
|
// Support: Safari<=5.1, Android<4.2
|
|
// Older WebKit doesn't clone checked state correctly in fragments
|
|
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
|
|
|
// Support: IE<=11+
|
|
// Make sure textarea (and checkbox) defaultValue is properly cloned
|
|
div.innerHTML = "<textarea>x</textarea>";
|
|
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
|
|
})();
|
|
var strundefined = typeof undefined;
|
|
|
|
|
|
|
|
support.focusinBubbles = "onfocusin" in window;
|
|
|
|
|
|
var
|
|
rkeyEvent = /^key/,
|
|
rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
|
|
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
|
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
|
|
|
|
function returnTrue() {
|
|
return true;
|
|
}
|
|
|
|
function returnFalse() {
|
|
return false;
|
|
}
|
|
|
|
function safeActiveElement() {
|
|
try {
|
|
return document.activeElement;
|
|
} catch ( err ) { }
|
|
}
|
|
|
|
/*
|
|
* Helper functions for managing events -- not part of the public interface.
|
|
* Props to Dean Edwards' addEvent library for many of the ideas.
|
|
*/
|
|
jQuery.event = {
|
|
|
|
global: {},
|
|
|
|
add: function( elem, types, handler, data, selector ) {
|
|
|
|
var handleObjIn, eventHandle, tmp,
|
|
events, t, handleObj,
|
|
special, handlers, type, namespaces, origType,
|
|
elemData = data_priv.get( elem );
|
|
|
|
// Don't attach events to noData or text/comment nodes (but allow plain objects)
|
|
if ( !elemData ) {
|
|
return;
|
|
}
|
|
|
|
// Caller can pass in an object of custom data in lieu of the handler
|
|
if ( handler.handler ) {
|
|
handleObjIn = handler;
|
|
handler = handleObjIn.handler;
|
|
selector = handleObjIn.selector;
|
|
}
|
|
|
|
// Make sure that the handler has a unique ID, used to find/remove it later
|
|
if ( !handler.guid ) {
|
|
handler.guid = jQuery.guid++;
|
|
}
|
|
|
|
// Init the element's event structure and main handler, if this is the first
|
|
if ( !(events = elemData.events) ) {
|
|
events = elemData.events = {};
|
|
}
|
|
if ( !(eventHandle = elemData.handle) ) {
|
|
eventHandle = elemData.handle = function( e ) {
|
|
// Discard the second event of a jQuery.event.trigger() and
|
|
// when an event is called after a page has unloaded
|
|
return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
|
|
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
|
|
};
|
|
}
|
|
|
|
// Handle multiple events separated by a space
|
|
types = ( types || "" ).match( rnotwhite ) || [ "" ];
|
|
t = types.length;
|
|
while ( t-- ) {
|
|
tmp = rtypenamespace.exec( types[t] ) || [];
|
|
type = origType = tmp[1];
|
|
namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
|
|
// There *must* be a type, no attaching namespace-only handlers
|
|
if ( !type ) {
|
|
continue;
|
|
}
|
|
|
|
// If event changes its type, use the special event handlers for the changed type
|
|
special = jQuery.event.special[ type ] || {};
|
|
|
|
// If selector defined, determine special event api type, otherwise given type
|
|
type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
|
|
// Update special based on newly reset type
|
|
special = jQuery.event.special[ type ] || {};
|
|
|
|
// handleObj is passed to all event handlers
|
|
handleObj = jQuery.extend({
|
|
type: type,
|
|
origType: origType,
|
|
data: data,
|
|
handler: handler,
|
|
guid: handler.guid,
|
|
selector: selector,
|
|
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
|
|
namespace: namespaces.join(".")
|
|
}, handleObjIn );
|
|
|
|
// Init the event handler queue if we're the first
|
|
if ( !(handlers = events[ type ]) ) {
|
|
handlers = events[ type ] = [];
|
|
handlers.delegateCount = 0;
|
|
|
|
// Only use addEventListener if the special events handler returns false
|
|
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
|
if ( elem.addEventListener ) {
|
|
elem.addEventListener( type, eventHandle, false );
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( special.add ) {
|
|
special.add.call( elem, handleObj );
|
|
|
|
if ( !handleObj.handler.guid ) {
|
|
handleObj.handler.guid = handler.guid;
|
|
}
|
|
}
|
|
|
|
// Add to the element's handler list, delegates in front
|
|
if ( selector ) {
|
|
handlers.splice( handlers.delegateCount++, 0, handleObj );
|
|
} else {
|
|
handlers.push( handleObj );
|
|
}
|
|
|
|
// Keep track of which events have ever been used, for event optimization
|
|
jQuery.event.global[ type ] = true;
|
|
}
|
|
|
|
},
|
|
|
|
// Detach an event or set of events from an element
|
|
remove: function( elem, types, handler, selector, mappedTypes ) {
|
|
|
|
var j, origCount, tmp,
|
|
events, t, handleObj,
|
|
special, handlers, type, namespaces, origType,
|
|
elemData = data_priv.hasData( elem ) && data_priv.get( elem );
|
|
|
|
if ( !elemData || !(events = elemData.events) ) {
|
|
return;
|
|
}
|
|
|
|
// Once for each type.namespace in types; type may be omitted
|
|
types = ( types || "" ).match( rnotwhite ) || [ "" ];
|
|
t = types.length;
|
|
while ( t-- ) {
|
|
tmp = rtypenamespace.exec( types[t] ) || [];
|
|
type = origType = tmp[1];
|
|
namespaces = ( tmp[2] || "" ).split( "." ).sort();
|
|
|
|
// Unbind all events (on this namespace, if provided) for the element
|
|
if ( !type ) {
|
|
for ( type in events ) {
|
|
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
|
}
|
|
continue;
|
|
}
|
|
|
|
special = jQuery.event.special[ type ] || {};
|
|
type = ( selector ? special.delegateType : special.bindType ) || type;
|
|
handlers = events[ type ] || [];
|
|
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
|
|
|
// Remove matching events
|
|
origCount = j = handlers.length;
|
|
while ( j-- ) {
|
|
handleObj = handlers[ j ];
|
|
|
|
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
|
( !handler || handler.guid === handleObj.guid ) &&
|
|
( !tmp || tmp.test( handleObj.namespace ) ) &&
|
|
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
|
handlers.splice( j, 1 );
|
|
|
|
if ( handleObj.selector ) {
|
|
handlers.delegateCount--;
|
|
}
|
|
if ( special.remove ) {
|
|
special.remove.call( elem, handleObj );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Remove generic event handler if we removed something and no more handlers exist
|
|
// (avoids potential for endless recursion during removal of special event handlers)
|
|
if ( origCount && !handlers.length ) {
|
|
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
|
jQuery.removeEvent( elem, type, elemData.handle );
|
|
}
|
|
|
|
delete events[ type ];
|
|
}
|
|
}
|
|
|
|
// Remove the expando if it's no longer used
|
|
if ( jQuery.isEmptyObject( events ) ) {
|
|
delete elemData.handle;
|
|
data_priv.remove( elem, "events" );
|
|
}
|
|
},
|
|
|
|
trigger: function( event, data, elem, onlyHandlers ) {
|
|
|
|
var i, cur, tmp, bubbleType, ontype, handle, special,
|
|
eventPath = [ elem || document ],
|
|
type = hasOwn.call( event, "type" ) ? event.type : event,
|
|
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
|
|
|
|
cur = tmp = elem = elem || document;
|
|
|
|
// Don't do events on text and comment nodes
|
|
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
|
|
return;
|
|
}
|
|
|
|
// focus/blur morphs to focusin/out; ensure we're not firing them right now
|
|
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
|
return;
|
|
}
|
|
|
|
if ( type.indexOf(".") >= 0 ) {
|
|
// Namespaced trigger; create a regexp to match event type in handle()
|
|
namespaces = type.split(".");
|
|
type = namespaces.shift();
|
|
namespaces.sort();
|
|
}
|
|
ontype = type.indexOf(":") < 0 && "on" + type;
|
|
|
|
// Caller can pass in a jQuery.Event object, Object, or just an event type string
|
|
event = event[ jQuery.expando ] ?
|
|
event :
|
|
new jQuery.Event( type, typeof event === "object" && event );
|
|
|
|
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
|
event.isTrigger = onlyHandlers ? 2 : 3;
|
|
event.namespace = namespaces.join(".");
|
|
event.namespace_re = event.namespace ?
|
|
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
|
null;
|
|
|
|
// Clean up the event in case it is being reused
|
|
event.result = undefined;
|
|
if ( !event.target ) {
|
|
event.target = elem;
|
|
}
|
|
|
|
// Clone any incoming data and prepend the event, creating the handler arg list
|
|
data = data == null ?
|
|
[ event ] :
|
|
jQuery.makeArray( data, [ event ] );
|
|
|
|
// Allow special events to draw outside the lines
|
|
special = jQuery.event.special[ type ] || {};
|
|
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
|
|
return;
|
|
}
|
|
|
|
// Determine event propagation path in advance, per W3C events spec (#9951)
|
|
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
|
|
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
|
|
|
bubbleType = special.delegateType || type;
|
|
if ( !rfocusMorph.test( bubbleType + type ) ) {
|
|
cur = cur.parentNode;
|
|
}
|
|
for ( ; cur; cur = cur.parentNode ) {
|
|
eventPath.push( cur );
|
|
tmp = cur;
|
|
}
|
|
|
|
// Only add window if we got to document (e.g., not plain obj or detached DOM)
|
|
if ( tmp === (elem.ownerDocument || document) ) {
|
|
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
|
|
}
|
|
}
|
|
|
|
// Fire handlers on the event path
|
|
i = 0;
|
|
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
|
|
|
|
event.type = i > 1 ?
|
|
bubbleType :
|
|
special.bindType || type;
|
|
|
|
// jQuery handler
|
|
handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
|
|
if ( handle ) {
|
|
handle.apply( cur, data );
|
|
}
|
|
|
|
// Native handler
|
|
handle = ontype && cur[ ontype ];
|
|
if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
|
|
event.result = handle.apply( cur, data );
|
|
if ( event.result === false ) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
}
|
|
event.type = type;
|
|
|
|
// If nobody prevented the default action, do it now
|
|
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
|
|
|
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
|
jQuery.acceptData( elem ) ) {
|
|
|
|
// Call a native DOM method on the target with the same name name as the event.
|
|
// Don't do default actions on window, that's where global variables be (#6170)
|
|
if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
|
|
|
|
// Don't re-trigger an onFOO event when we call its FOO() method
|
|
tmp = elem[ ontype ];
|
|
|
|
if ( tmp ) {
|
|
elem[ ontype ] = null;
|
|
}
|
|
|
|
// Prevent re-triggering of the same event, since we already bubbled it above
|
|
jQuery.event.triggered = type;
|
|
elem[ type ]();
|
|
jQuery.event.triggered = undefined;
|
|
|
|
if ( tmp ) {
|
|
elem[ ontype ] = tmp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return event.result;
|
|
},
|
|
|
|
dispatch: function( event ) {
|
|
|
|
// Make a writable jQuery.Event from the native event object
|
|
event = jQuery.event.fix( event );
|
|
|
|
var i, j, ret, matched, handleObj,
|
|
handlerQueue = [],
|
|
args = slice.call( arguments ),
|
|
handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
|
|
special = jQuery.event.special[ event.type ] || {};
|
|
|
|
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
|
args[0] = event;
|
|
event.delegateTarget = this;
|
|
|
|
// Call the preDispatch hook for the mapped type, and let it bail if desired
|
|
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
|
|
return;
|
|
}
|
|
|
|
// Determine handlers
|
|
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
|
|
|
|
// Run delegates first; they may want to stop propagation beneath us
|
|
i = 0;
|
|
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
|
|
event.currentTarget = matched.elem;
|
|
|
|
j = 0;
|
|
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
|
|
|
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
|
|
// a subset or equal to those in the bound event (both can have no namespace).
|
|
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
|
|
|
event.handleObj = handleObj;
|
|
event.data = handleObj.data;
|
|
|
|
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
|
.apply( matched.elem, args );
|
|
|
|
if ( ret !== undefined ) {
|
|
if ( (event.result = ret) === false ) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Call the postDispatch hook for the mapped type
|
|
if ( special.postDispatch ) {
|
|
special.postDispatch.call( this, event );
|
|
}
|
|
|
|
return event.result;
|
|
},
|
|
|
|
handlers: function( event, handlers ) {
|
|
var i, matches, sel, handleObj,
|
|
handlerQueue = [],
|
|
delegateCount = handlers.delegateCount,
|
|
cur = event.target;
|
|
|
|
// Find delegate handlers
|
|
// Black-hole SVG <use> instance trees (#13180)
|
|
// Avoid non-left-click bubbling in Firefox (#3861)
|
|
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
|
|
|
|
for ( ; cur !== this; cur = cur.parentNode || this ) {
|
|
|
|
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
|
|
if ( cur.disabled !== true || event.type !== "click" ) {
|
|
matches = [];
|
|
for ( i = 0; i < delegateCount; i++ ) {
|
|
handleObj = handlers[ i ];
|
|
|
|
// Don't conflict with Object.prototype properties (#13203)
|
|
sel = handleObj.selector + " ";
|
|
|
|
if ( matches[ sel ] === undefined ) {
|
|
matches[ sel ] = handleObj.needsContext ?
|
|
jQuery( sel, this ).index( cur ) >= 0 :
|
|
jQuery.find( sel, this, null, [ cur ] ).length;
|
|
}
|
|
if ( matches[ sel ] ) {
|
|
matches.push( handleObj );
|
|
}
|
|
}
|
|
if ( matches.length ) {
|
|
handlerQueue.push({ elem: cur, handlers: matches });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add the remaining (directly-bound) handlers
|
|
if ( delegateCount < handlers.length ) {
|
|
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
|
|
}
|
|
|
|
return handlerQueue;
|
|
},
|
|
|
|
// Includes some event props shared by KeyEvent and MouseEvent
|
|
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
|
|
|
fixHooks: {},
|
|
|
|
keyHooks: {
|
|
props: "char charCode key keyCode".split(" "),
|
|
filter: function( event, original ) {
|
|
|
|
// Add which for key events
|
|
if ( event.which == null ) {
|
|
event.which = original.charCode != null ? original.charCode : original.keyCode;
|
|
}
|
|
|
|
return event;
|
|
}
|
|
},
|
|
|
|
mouseHooks: {
|
|
props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
|
filter: function( event, original ) {
|
|
var eventDoc, doc, body,
|
|
button = original.button;
|
|
|
|
// Calculate pageX/Y if missing and clientX/Y available
|
|
if ( event.pageX == null && original.clientX != null ) {
|
|
eventDoc = event.target.ownerDocument || document;
|
|
doc = eventDoc.documentElement;
|
|
body = eventDoc.body;
|
|
|
|
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
|
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
|
}
|
|
|
|
// Add which for click: 1 === left; 2 === middle; 3 === right
|
|
// Note: button is not normalized, so don't use it
|
|
if ( !event.which && button !== undefined ) {
|
|
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
|
}
|
|
|
|
return event;
|
|
}
|
|
},
|
|
|
|
fix: function( event ) {
|
|
if ( event[ jQuery.expando ] ) {
|
|
return event;
|
|
}
|
|
|
|
// Create a writable copy of the event object and normalize some properties
|
|
var i, prop, copy,
|
|
type = event.type,
|
|
originalEvent = event,
|
|
fixHook = this.fixHooks[ type ];
|
|
|
|
if ( !fixHook ) {
|
|
this.fixHooks[ type ] = fixHook =
|
|
rmouseEvent.test( type ) ? this.mouseHooks :
|
|
rkeyEvent.test( type ) ? this.keyHooks :
|
|
{};
|
|
}
|
|
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
|
|
|
event = new jQuery.Event( originalEvent );
|
|
|
|
i = copy.length;
|
|
while ( i-- ) {
|
|
prop = copy[ i ];
|
|
event[ prop ] = originalEvent[ prop ];
|
|
}
|
|
|
|
// Support: Cordova 2.5 (WebKit) (#13255)
|
|
// All events should have a target; Cordova deviceready doesn't
|
|
if ( !event.target ) {
|
|
event.target = document;
|
|
}
|
|
|
|
// Support: Safari 6.0+, Chrome<28
|
|
// Target should not be a text node (#504, #13143)
|
|
if ( event.target.nodeType === 3 ) {
|
|
event.target = event.target.parentNode;
|
|
}
|
|
|
|
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
|
|
},
|
|
|
|
special: {
|
|
load: {
|
|
// Prevent triggered image.load events from bubbling to window.load
|
|
noBubble: true
|
|
},
|
|
focus: {
|
|
// Fire native event if possible so blur/focus sequence is correct
|
|
trigger: function() {
|
|
if ( this !== safeActiveElement() && this.focus ) {
|
|
this.focus();
|
|
return false;
|
|
}
|
|
},
|
|
delegateType: "focusin"
|
|
},
|
|
blur: {
|
|
trigger: function() {
|
|
if ( this === safeActiveElement() && this.blur ) {
|
|
this.blur();
|
|
return false;
|
|
}
|
|
},
|
|
delegateType: "focusout"
|
|
},
|
|
click: {
|
|
// For checkbox, fire native event so checked state will be right
|
|
trigger: function() {
|
|
if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
|
|
this.click();
|
|
return false;
|
|
}
|
|
},
|
|
|
|
// For cross-browser consistency, don't fire native .click() on links
|
|
_default: function( event ) {
|
|
return jQuery.nodeName( event.target, "a" );
|
|
}
|
|
},
|
|
|
|
beforeunload: {
|
|
postDispatch: function( event ) {
|
|
|
|
// Support: Firefox 20+
|
|
// Firefox doesn't alert if the returnValue field is not set.
|
|
if ( event.result !== undefined && event.originalEvent ) {
|
|
event.originalEvent.returnValue = event.result;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
simulate: function( type, elem, event, bubble ) {
|
|
// Piggyback on a donor event to simulate a different one.
|
|
// Fake originalEvent to avoid donor's stopPropagation, but if the
|
|
// simulated event prevents default then we do the same on the donor.
|
|
var e = jQuery.extend(
|
|
new jQuery.Event(),
|
|
event,
|
|
{
|
|
type: type,
|
|
isSimulated: true,
|
|
originalEvent: {}
|
|
}
|
|
);
|
|
if ( bubble ) {
|
|
jQuery.event.trigger( e, null, elem );
|
|
} else {
|
|
jQuery.event.dispatch.call( elem, e );
|
|
}
|
|
if ( e.isDefaultPrevented() ) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
};
|
|
|
|
jQuery.removeEvent = function( elem, type, handle ) {
|
|
if ( elem.removeEventListener ) {
|
|
elem.removeEventListener( type, handle, false );
|
|
}
|
|
};
|
|
|
|
jQuery.Event = function( src, props ) {
|
|
// Allow instantiation without the 'new' keyword
|
|
if ( !(this instanceof jQuery.Event) ) {
|
|
return new jQuery.Event( src, props );
|
|
}
|
|
|
|
// Event object
|
|
if ( src && src.type ) {
|
|
this.originalEvent = src;
|
|
this.type = src.type;
|
|
|
|
// Events bubbling up the document may have been marked as prevented
|
|
// by a handler lower down the tree; reflect the correct value.
|
|
this.isDefaultPrevented = src.defaultPrevented ||
|
|
src.defaultPrevented === undefined &&
|
|
// Support: Android<4.0
|
|
src.returnValue === false ?
|
|
returnTrue :
|
|
returnFalse;
|
|
|
|
// Event type
|
|
} else {
|
|
this.type = src;
|
|
}
|
|
|
|
// Put explicitly provided properties onto the event object
|
|
if ( props ) {
|
|
jQuery.extend( this, props );
|
|
}
|
|
|
|
// Create a timestamp if incoming event doesn't have one
|
|
this.timeStamp = src && src.timeStamp || jQuery.now();
|
|
|
|
// Mark it as fixed
|
|
this[ jQuery.expando ] = true;
|
|
};
|
|
|
|
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
|
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
|
jQuery.Event.prototype = {
|
|
isDefaultPrevented: returnFalse,
|
|
isPropagationStopped: returnFalse,
|
|
isImmediatePropagationStopped: returnFalse,
|
|
|
|
preventDefault: function() {
|
|
var e = this.originalEvent;
|
|
|
|
this.isDefaultPrevented = returnTrue;
|
|
|
|
if ( e && e.preventDefault ) {
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
stopPropagation: function() {
|
|
var e = this.originalEvent;
|
|
|
|
this.isPropagationStopped = returnTrue;
|
|
|
|
if ( e && e.stopPropagation ) {
|
|
e.stopPropagation();
|
|
}
|
|
},
|
|
stopImmediatePropagation: function() {
|
|
var e = this.originalEvent;
|
|
|
|
this.isImmediatePropagationStopped = returnTrue;
|
|
|
|
if ( e && e.stopImmediatePropagation ) {
|
|
e.stopImmediatePropagation();
|
|
}
|
|
|
|
this.stopPropagation();
|
|
}
|
|
};
|
|
|
|
// Create mouseenter/leave events using mouseover/out and event-time checks
|
|
// Support: Chrome 15+
|
|
jQuery.each({
|
|
mouseenter: "mouseover",
|
|
mouseleave: "mouseout",
|
|
pointerenter: "pointerover",
|
|
pointerleave: "pointerout"
|
|
}, function( orig, fix ) {
|
|
jQuery.event.special[ orig ] = {
|
|
delegateType: fix,
|
|
bindType: fix,
|
|
|
|
handle: function( event ) {
|
|
var ret,
|
|
target = this,
|
|
related = event.relatedTarget,
|
|
handleObj = event.handleObj;
|
|
|
|
// For mousenter/leave call the handler if related is outside the target.
|
|
// NB: No relatedTarget if the mouse left/entered the browser window
|
|
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
|
event.type = handleObj.origType;
|
|
ret = handleObj.handler.apply( this, arguments );
|
|
event.type = fix;
|
|
}
|
|
return ret;
|
|
}
|
|
};
|
|
});
|
|
|
|
// Support: Firefox, Chrome, Safari
|
|
// Create "bubbling" focus and blur events
|
|
if ( !support.focusinBubbles ) {
|
|
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
|
|
|
// Attach a single capturing handler on the document while someone wants focusin/focusout
|
|
var handler = function( event ) {
|
|
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
|
};
|
|
|
|
jQuery.event.special[ fix ] = {
|
|
setup: function() {
|
|
var doc = this.ownerDocument || this,
|
|
attaches = data_priv.access( doc, fix );
|
|
|
|
if ( !attaches ) {
|
|
doc.addEventListener( orig, handler, true );
|
|
}
|
|
data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
|
|
},
|
|
teardown: function() {
|
|
var doc = this.ownerDocument || this,
|
|
attaches = data_priv.access( doc, fix ) - 1;
|
|
|
|
if ( !attaches ) {
|
|
doc.removeEventListener( orig, handler, true );
|
|
data_priv.remove( doc, fix );
|
|
|
|
} else {
|
|
data_priv.access( doc, fix, attaches );
|
|
}
|
|
}
|
|
};
|
|
});
|
|
}
|
|
|
|
jQuery.fn.extend({
|
|
|
|
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
|
var origFn, type;
|
|
|
|
// Types can be a map of types/handlers
|
|
if ( typeof types === "object" ) {
|
|
// ( types-Object, selector, data )
|
|
if ( typeof selector !== "string" ) {
|
|
// ( types-Object, data )
|
|
data = data || selector;
|
|
selector = undefined;
|
|
}
|
|
for ( type in types ) {
|
|
this.on( type, selector, data, types[ type ], one );
|
|
}
|
|
return this;
|
|
}
|
|
|
|
if ( data == null && fn == null ) {
|
|
// ( types, fn )
|
|
fn = selector;
|
|
data = selector = undefined;
|
|
} else if ( fn == null ) {
|
|
if ( typeof selector === "string" ) {
|
|
// ( types, selector, fn )
|
|
fn = data;
|
|
data = undefined;
|
|
} else {
|
|
// ( types, data, fn )
|
|
fn = data;
|
|
data = selector;
|
|
selector = undefined;
|
|
}
|
|
}
|
|
if ( fn === false ) {
|
|
fn = returnFalse;
|
|
} else if ( !fn ) {
|
|
return this;
|
|
}
|
|
|
|
if ( one === 1 ) {
|
|
origFn = fn;
|
|
fn = function( event ) {
|
|
// Can use an empty set, since event contains the info
|
|
jQuery().off( event );
|
|
return origFn.apply( this, arguments );
|
|
};
|
|
// Use same guid so caller can remove using origFn
|
|
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
|
}
|
|
return this.each( function() {
|
|
jQuery.event.add( this, types, fn, data, selector );
|
|
});
|
|
},
|
|
one: function( types, selector, data, fn ) {
|
|
return this.on( types, selector, data, fn, 1 );
|
|
},
|
|
off: function( types, selector, fn ) {
|
|
var handleObj, type;
|
|
if ( types && types.preventDefault && types.handleObj ) {
|
|
// ( event ) dispatched jQuery.Event
|
|
handleObj = types.handleObj;
|
|
jQuery( types.delegateTarget ).off(
|
|
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
|
handleObj.selector,
|
|
handleObj.handler
|
|
);
|
|
return this;
|
|
}
|
|
if ( typeof types === "object" ) {
|
|
// ( types-object [, selector] )
|
|
for ( type in types ) {
|
|
this.off( type, selector, types[ type ] );
|
|
}
|
|
return this;
|
|
}
|
|
if ( selector === false || typeof selector === "function" ) {
|
|
// ( types [, fn] )
|
|
fn = selector;
|
|
selector = undefined;
|
|
}
|
|
if ( fn === false ) {
|
|
fn = returnFalse;
|
|
}
|
|
return this.each(function() {
|
|
jQuery.event.remove( this, types, fn, selector );
|
|
});
|
|
},
|
|
|
|
trigger: function( type, data ) {
|
|
return this.each(function() {
|
|
jQuery.event.trigger( type, data, this );
|
|
});
|
|
},
|
|
triggerHandler: function( type, data ) {
|
|
var elem = this[0];
|
|
if ( elem ) {
|
|
return jQuery.event.trigger( type, data, elem, true );
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
var
|
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
|
rtagName = /<([\w:]+)/,
|
|
rhtml = /<|&#?\w+;/,
|
|
rnoInnerhtml = /<(?:script|style|link)/i,
|
|
// checked="checked" or checked
|
|
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
|
rscriptType = /^$|\/(?:java|ecma)script/i,
|
|
rscriptTypeMasked = /^true\/(.*)/,
|
|
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
|
|
|
// We have to close these tags to support XHTML (#13200)
|
|
wrapMap = {
|
|
|
|
// Support: IE9
|
|
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
|
|
thead: [ 1, "<table>", "</table>" ],
|
|
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
|
|
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
|
|
_default: [ 0, "", "" ]
|
|
};
|
|
|
|
// Support: IE9
|
|
wrapMap.optgroup = wrapMap.option;
|
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
// Support: 1.x compatibility
|
|
// Manipulating tables requires a tbody
|
|
function manipulationTarget( elem, content ) {
|
|
return jQuery.nodeName( elem, "table" ) &&
|
|
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
|
|
|
|
elem.getElementsByTagName("tbody")[0] ||
|
|
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
|
elem;
|
|
}
|
|
|
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
function disableScript( elem ) {
|
|
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
|
|
return elem;
|
|
}
|
|
function restoreScript( elem ) {
|
|
var match = rscriptTypeMasked.exec( elem.type );
|
|
|
|
if ( match ) {
|
|
elem.type = match[ 1 ];
|
|
} else {
|
|
elem.removeAttribute("type");
|
|
}
|
|
|
|
return elem;
|
|
}
|
|
|
|
// Mark scripts as having already been evaluated
|
|
function setGlobalEval( elems, refElements ) {
|
|
var i = 0,
|
|
l = elems.length;
|
|
|
|
for ( ; i < l; i++ ) {
|
|
data_priv.set(
|
|
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
|
|
);
|
|
}
|
|
}
|
|
|
|
function cloneCopyEvent( src, dest ) {
|
|
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
|
|
|
|
if ( dest.nodeType !== 1 ) {
|
|
return;
|
|
}
|
|
|
|
// 1. Copy private data: events, handlers, etc.
|
|
if ( data_priv.hasData( src ) ) {
|
|
pdataOld = data_priv.access( src );
|
|
pdataCur = data_priv.set( dest, pdataOld );
|
|
events = pdataOld.events;
|
|
|
|
if ( events ) {
|
|
delete pdataCur.handle;
|
|
pdataCur.events = {};
|
|
|
|
for ( type in events ) {
|
|
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
jQuery.event.add( dest, type, events[ type ][ i ] );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 2. Copy user data
|
|
if ( data_user.hasData( src ) ) {
|
|
udataOld = data_user.access( src );
|
|
udataCur = jQuery.extend( {}, udataOld );
|
|
|
|
data_user.set( dest, udataCur );
|
|
}
|
|
}
|
|
|
|
function getAll( context, tag ) {
|
|
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
|
|
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
|
|
[];
|
|
|
|
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
jQuery.merge( [ context ], ret ) :
|
|
ret;
|
|
}
|
|
|
|
// Fix IE bugs, see support tests
|
|
function fixInput( src, dest ) {
|
|
var nodeName = dest.nodeName.toLowerCase();
|
|
|
|
// Fails to persist the checked state of a cloned checkbox or radio button.
|
|
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
|
|
dest.checked = src.checked;
|
|
|
|
// Fails to return the selected option to the default selected state when cloning options
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
dest.defaultValue = src.defaultValue;
|
|
}
|
|
}
|
|
|
|
jQuery.extend({
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
|
var i, l, srcElements, destElements,
|
|
clone = elem.cloneNode( true ),
|
|
inPage = jQuery.contains( elem.ownerDocument, elem );
|
|
|
|
// Fix IE cloning issues
|
|
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
|
|
!jQuery.isXMLDoc( elem ) ) {
|
|
|
|
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
|
destElements = getAll( clone );
|
|
srcElements = getAll( elem );
|
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
|
fixInput( srcElements[ i ], destElements[ i ] );
|
|
}
|
|
}
|
|
|
|
// Copy the events from the original to the clone
|
|
if ( dataAndEvents ) {
|
|
if ( deepDataAndEvents ) {
|
|
srcElements = srcElements || getAll( elem );
|
|
destElements = destElements || getAll( clone );
|
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
|
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
|
|
}
|
|
} else {
|
|
cloneCopyEvent( elem, clone );
|
|
}
|
|
}
|
|
|
|
// Preserve script evaluation history
|
|
destElements = getAll( clone, "script" );
|
|
if ( destElements.length > 0 ) {
|
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
}
|
|
|
|
// Return the cloned set
|
|
return clone;
|
|
},
|
|
|
|
buildFragment: function( elems, context, scripts, selection ) {
|
|
var elem, tmp, tag, wrap, contains, j,
|
|
fragment = context.createDocumentFragment(),
|
|
nodes = [],
|
|
i = 0,
|
|
l = elems.length;
|
|
|
|
for ( ; i < l; i++ ) {
|
|
elem = elems[ i ];
|
|
|
|
if ( elem || elem === 0 ) {
|
|
|
|
// Add nodes directly
|
|
if ( jQuery.type( elem ) === "object" ) {
|
|
// Support: QtWebKit, PhantomJS
|
|
// push.apply(_, arraylike) throws on ancient WebKit
|
|
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
|
|
|
// Convert non-html into a text node
|
|
} else if ( !rhtml.test( elem ) ) {
|
|
nodes.push( context.createTextNode( elem ) );
|
|
|
|
// Convert html into DOM nodes
|
|
} else {
|
|
tmp = tmp || fragment.appendChild( context.createElement("div") );
|
|
|
|
// Deserialize a standard representation
|
|
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
|
|
wrap = wrapMap[ tag ] || wrapMap._default;
|
|
tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
|
|
|
|
// Descend through wrappers to the right content
|
|
j = wrap[ 0 ];
|
|
while ( j-- ) {
|
|
tmp = tmp.lastChild;
|
|
}
|
|
|
|
// Support: QtWebKit, PhantomJS
|
|
// push.apply(_, arraylike) throws on ancient WebKit
|
|
jQuery.merge( nodes, tmp.childNodes );
|
|
|
|
// Remember the top-level container
|
|
tmp = fragment.firstChild;
|
|
|
|
// Ensure the created nodes are orphaned (#12392)
|
|
tmp.textContent = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
// Remove wrapper from fragment
|
|
fragment.textContent = "";
|
|
|
|
i = 0;
|
|
while ( (elem = nodes[ i++ ]) ) {
|
|
|
|
// #4087 - If origin and destination elements are the same, and this is
|
|
// that element, do not do anything
|
|
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
|
|
continue;
|
|
}
|
|
|
|
contains = jQuery.contains( elem.ownerDocument, elem );
|
|
|
|
// Append to fragment
|
|
tmp = getAll( fragment.appendChild( elem ), "script" );
|
|
|
|
// Preserve script evaluation history
|
|
if ( contains ) {
|
|
setGlobalEval( tmp );
|
|
}
|
|
|
|
// Capture executables
|
|
if ( scripts ) {
|
|
j = 0;
|
|
while ( (elem = tmp[ j++ ]) ) {
|
|
if ( rscriptType.test( elem.type || "" ) ) {
|
|
scripts.push( elem );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return fragment;
|
|
},
|
|
|
|
cleanData: function( elems ) {
|
|
var data, elem, type, key,
|
|
special = jQuery.event.special,
|
|
i = 0;
|
|
|
|
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
|
|
if ( jQuery.acceptData( elem ) ) {
|
|
key = elem[ data_priv.expando ];
|
|
|
|
if ( key && (data = data_priv.cache[ key ]) ) {
|
|
if ( data.events ) {
|
|
for ( type in data.events ) {
|
|
if ( special[ type ] ) {
|
|
jQuery.event.remove( elem, type );
|
|
|
|
// This is a shortcut to avoid jQuery.event.remove's overhead
|
|
} else {
|
|
jQuery.removeEvent( elem, type, data.handle );
|
|
}
|
|
}
|
|
}
|
|
if ( data_priv.cache[ key ] ) {
|
|
// Discard any remaining `private` data
|
|
delete data_priv.cache[ key ];
|
|
}
|
|
}
|
|
}
|
|
// Discard any remaining `user` data
|
|
delete data_user.cache[ elem[ data_user.expando ] ];
|
|
}
|
|
}
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
text: function( value ) {
|
|
return access( this, function( value ) {
|
|
return value === undefined ?
|
|
jQuery.text( this ) :
|
|
this.empty().each(function() {
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
this.textContent = value;
|
|
}
|
|
});
|
|
}, null, value, arguments.length );
|
|
},
|
|
|
|
append: function() {
|
|
return this.domManip( arguments, function( elem ) {
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
var target = manipulationTarget( this, elem );
|
|
target.appendChild( elem );
|
|
}
|
|
});
|
|
},
|
|
|
|
prepend: function() {
|
|
return this.domManip( arguments, function( elem ) {
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
var target = manipulationTarget( this, elem );
|
|
target.insertBefore( elem, target.firstChild );
|
|
}
|
|
});
|
|
},
|
|
|
|
before: function() {
|
|
return this.domManip( arguments, function( elem ) {
|
|
if ( this.parentNode ) {
|
|
this.parentNode.insertBefore( elem, this );
|
|
}
|
|
});
|
|
},
|
|
|
|
after: function() {
|
|
return this.domManip( arguments, function( elem ) {
|
|
if ( this.parentNode ) {
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
|
}
|
|
});
|
|
},
|
|
|
|
remove: function( selector, keepData /* Internal Use Only */ ) {
|
|
var elem,
|
|
elems = selector ? jQuery.filter( selector, this ) : this,
|
|
i = 0;
|
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
if ( !keepData && elem.nodeType === 1 ) {
|
|
jQuery.cleanData( getAll( elem ) );
|
|
}
|
|
|
|
if ( elem.parentNode ) {
|
|
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
setGlobalEval( getAll( elem, "script" ) );
|
|
}
|
|
elem.parentNode.removeChild( elem );
|
|
}
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
empty: function() {
|
|
var elem,
|
|
i = 0;
|
|
|
|
for ( ; (elem = this[i]) != null; i++ ) {
|
|
if ( elem.nodeType === 1 ) {
|
|
|
|
// Prevent memory leaks
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
|
|
// Remove any remaining nodes
|
|
elem.textContent = "";
|
|
}
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
|
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
|
|
|
return this.map(function() {
|
|
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
|
});
|
|
},
|
|
|
|
html: function( value ) {
|
|
return access( this, function( value ) {
|
|
var elem = this[ 0 ] || {},
|
|
i = 0,
|
|
l = this.length;
|
|
|
|
if ( value === undefined && elem.nodeType === 1 ) {
|
|
return elem.innerHTML;
|
|
}
|
|
|
|
// See if we can take a shortcut and just use innerHTML
|
|
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
|
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
|
|
|
|
value = value.replace( rxhtmlTag, "<$1></$2>" );
|
|
|
|
try {
|
|
for ( ; i < l; i++ ) {
|
|
elem = this[ i ] || {};
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
if ( elem.nodeType === 1 ) {
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
elem.innerHTML = value;
|
|
}
|
|
}
|
|
|
|
elem = 0;
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
|
} catch( e ) {}
|
|
}
|
|
|
|
if ( elem ) {
|
|
this.empty().append( value );
|
|
}
|
|
}, null, value, arguments.length );
|
|
},
|
|
|
|
replaceWith: function() {
|
|
var arg = arguments[ 0 ];
|
|
|
|
// Make the changes, replacing each context element with the new content
|
|
this.domManip( arguments, function( elem ) {
|
|
arg = this.parentNode;
|
|
|
|
jQuery.cleanData( getAll( this ) );
|
|
|
|
if ( arg ) {
|
|
arg.replaceChild( elem, this );
|
|
}
|
|
});
|
|
|
|
// Force removal if there was no new content (e.g., from empty arguments)
|
|
return arg && (arg.length || arg.nodeType) ? this : this.remove();
|
|
},
|
|
|
|
detach: function( selector ) {
|
|
return this.remove( selector, true );
|
|
},
|
|
|
|
domManip: function( args, callback ) {
|
|
|
|
// Flatten any nested arrays
|
|
args = concat.apply( [], args );
|
|
|
|
var fragment, first, scripts, hasScripts, node, doc,
|
|
i = 0,
|
|
l = this.length,
|
|
set = this,
|
|
iNoClone = l - 1,
|
|
value = args[ 0 ],
|
|
isFunction = jQuery.isFunction( value );
|
|
|
|
// We can't cloneNode fragments that contain checked, in WebKit
|
|
if ( isFunction ||
|
|
( l > 1 && typeof value === "string" &&
|
|
!support.checkClone && rchecked.test( value ) ) ) {
|
|
return this.each(function( index ) {
|
|
var self = set.eq( index );
|
|
if ( isFunction ) {
|
|
args[ 0 ] = value.call( this, index, self.html() );
|
|
}
|
|
self.domManip( args, callback );
|
|
});
|
|
}
|
|
|
|
if ( l ) {
|
|
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
|
|
first = fragment.firstChild;
|
|
|
|
if ( fragment.childNodes.length === 1 ) {
|
|
fragment = first;
|
|
}
|
|
|
|
if ( first ) {
|
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
hasScripts = scripts.length;
|
|
|
|
// Use the original fragment for the last item instead of the first because it can end up
|
|
// being emptied incorrectly in certain situations (#8070).
|
|
for ( ; i < l; i++ ) {
|
|
node = fragment;
|
|
|
|
if ( i !== iNoClone ) {
|
|
node = jQuery.clone( node, true, true );
|
|
|
|
// Keep references to cloned scripts for later restoration
|
|
if ( hasScripts ) {
|
|
// Support: QtWebKit
|
|
// jQuery.merge because push.apply(_, arraylike) throws
|
|
jQuery.merge( scripts, getAll( node, "script" ) );
|
|
}
|
|
}
|
|
|
|
callback.call( this[ i ], node, i );
|
|
}
|
|
|
|
if ( hasScripts ) {
|
|
doc = scripts[ scripts.length - 1 ].ownerDocument;
|
|
|
|
// Reenable scripts
|
|
jQuery.map( scripts, restoreScript );
|
|
|
|
// Evaluate executable scripts on first document insertion
|
|
for ( i = 0; i < hasScripts; i++ ) {
|
|
node = scripts[ i ];
|
|
if ( rscriptType.test( node.type || "" ) &&
|
|
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
|
|
|
if ( node.src ) {
|
|
// Optional AJAX dependency, but won't run scripts if not present
|
|
if ( jQuery._evalUrl ) {
|
|
jQuery._evalUrl( node.src );
|
|
}
|
|
} else {
|
|
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return this;
|
|
}
|
|
});
|
|
|
|
jQuery.each({
|
|
appendTo: "append",
|
|
prependTo: "prepend",
|
|
insertBefore: "before",
|
|
insertAfter: "after",
|
|
replaceAll: "replaceWith"
|
|
}, function( name, original ) {
|
|
jQuery.fn[ name ] = function( selector ) {
|
|
var elems,
|
|
ret = [],
|
|
insert = jQuery( selector ),
|
|
last = insert.length - 1,
|
|
i = 0;
|
|
|
|
for ( ; i <= last; i++ ) {
|
|
elems = i === last ? this : this.clone( true );
|
|
jQuery( insert[ i ] )[ original ]( elems );
|
|
|
|
// Support: QtWebKit
|
|
// .get() because push.apply(_, arraylike) throws
|
|
push.apply( ret, elems.get() );
|
|
}
|
|
|
|
return this.pushStack( ret );
|
|
};
|
|
});
|
|
|
|
|
|
var iframe,
|
|
elemdisplay = {};
|
|
|
|
/**
|
|
* Retrieve the actual display of a element
|
|
* @param {String} name nodeName of the element
|
|
* @param {Object} doc Document object
|
|
*/
|
|
// Called only from within defaultDisplay
|
|
function actualDisplay( name, doc ) {
|
|
var style,
|
|
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
|
|
|
// getDefaultComputedStyle might be reliably used only on attached element
|
|
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
|
|
|
|
// Use of this method is a temporary fix (more like optimization) until something better comes along,
|
|
// since it was removed from specification and supported only in FF
|
|
style.display : jQuery.css( elem[ 0 ], "display" );
|
|
|
|
// We don't have any data stored on the element,
|
|
// so use "detach" method as fast way to get rid of the element
|
|
elem.detach();
|
|
|
|
return display;
|
|
}
|
|
|
|
/**
|
|
* Try to determine the default display value of an element
|
|
* @param {String} nodeName
|
|
*/
|
|
function defaultDisplay( nodeName ) {
|
|
var doc = document,
|
|
display = elemdisplay[ nodeName ];
|
|
|
|
if ( !display ) {
|
|
display = actualDisplay( nodeName, doc );
|
|
|
|
// If the simple way fails, read from inside an iframe
|
|
if ( display === "none" || !display ) {
|
|
|
|
// Use the already-created iframe if possible
|
|
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
|
|
|
|
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
|
doc = iframe[ 0 ].contentDocument;
|
|
|
|
// Support: IE
|
|
doc.write();
|
|
doc.close();
|
|
|
|
display = actualDisplay( nodeName, doc );
|
|
iframe.detach();
|
|
}
|
|
|
|
// Store the correct default display
|
|
elemdisplay[ nodeName ] = display;
|
|
}
|
|
|
|
return display;
|
|
}
|
|
var rmargin = (/^margin/);
|
|
|
|
var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
|
|
|
|
var getStyles = function( elem ) {
|
|
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
|
|
// IE throws on elements created in popups
|
|
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
|
|
if ( elem.ownerDocument.defaultView.opener ) {
|
|
return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
|
|
}
|
|
|
|
return window.getComputedStyle( elem, null );
|
|
};
|
|
|
|
|
|
|
|
function curCSS( elem, name, computed ) {
|
|
var width, minWidth, maxWidth, ret,
|
|
style = elem.style;
|
|
|
|
computed = computed || getStyles( elem );
|
|
|
|
// Support: IE9
|
|
// getPropertyValue is only needed for .css('filter') (#12537)
|
|
if ( computed ) {
|
|
ret = computed.getPropertyValue( name ) || computed[ name ];
|
|
}
|
|
|
|
if ( computed ) {
|
|
|
|
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
ret = jQuery.style( elem, name );
|
|
}
|
|
|
|
// Support: iOS < 6
|
|
// A tribute to the "awesome hack by Dean Edwards"
|
|
// iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
|
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
|
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
|
|
|
// Remember the original values
|
|
width = style.width;
|
|
minWidth = style.minWidth;
|
|
maxWidth = style.maxWidth;
|
|
|
|
// Put in the new values to get a computed value out
|
|
style.minWidth = style.maxWidth = style.width = ret;
|
|
ret = computed.width;
|
|
|
|
// Revert the changed values
|
|
style.width = width;
|
|
style.minWidth = minWidth;
|
|
style.maxWidth = maxWidth;
|
|
}
|
|
}
|
|
|
|
return ret !== undefined ?
|
|
// Support: IE
|
|
// IE returns zIndex value as an integer.
|
|
ret + "" :
|
|
ret;
|
|
}
|
|
|
|
|
|
function addGetHookIf( conditionFn, hookFn ) {
|
|
// Define the hook, we'll check on the first run if it's really needed.
|
|
return {
|
|
get: function() {
|
|
if ( conditionFn() ) {
|
|
// Hook not needed (or it's not possible to use it due
|
|
// to missing dependency), remove it.
|
|
delete this.get;
|
|
return;
|
|
}
|
|
|
|
// Hook needed; redefine it so that the support test is not executed again.
|
|
return (this.get = hookFn).apply( this, arguments );
|
|
}
|
|
};
|
|
}
|
|
|
|
|
|
(function() {
|
|
var pixelPositionVal, boxSizingReliableVal,
|
|
docElem = document.documentElement,
|
|
container = document.createElement( "div" ),
|
|
div = document.createElement( "div" );
|
|
|
|
if ( !div.style ) {
|
|
return;
|
|
}
|
|
|
|
// Support: IE9-11+
|
|
// Style of cloned element affects source element cloned (#8908)
|
|
div.style.backgroundClip = "content-box";
|
|
div.cloneNode( true ).style.backgroundClip = "";
|
|
support.clearCloneStyle = div.style.backgroundClip === "content-box";
|
|
|
|
container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
|
|
"position:absolute";
|
|
container.appendChild( div );
|
|
|
|
// Executing both pixelPosition & boxSizingReliable tests require only one layout
|
|
// so they're executed at the same time to save the second computation.
|
|
function computePixelPositionAndBoxSizingReliable() {
|
|
div.style.cssText =
|
|
// Support: Firefox<29, Android 2.3
|
|
// Vendor-prefix box-sizing
|
|
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
|
|
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
|
|
"border:1px;padding:1px;width:4px;position:absolute";
|
|
div.innerHTML = "";
|
|
docElem.appendChild( container );
|
|
|
|
var divStyle = window.getComputedStyle( div, null );
|
|
pixelPositionVal = divStyle.top !== "1%";
|
|
boxSizingReliableVal = divStyle.width === "4px";
|
|
|
|
docElem.removeChild( container );
|
|
}
|
|
|
|
// Support: node.js jsdom
|
|
// Don't assume that getComputedStyle is a property of the global object
|
|
if ( window.getComputedStyle ) {
|
|
jQuery.extend( support, {
|
|
pixelPosition: function() {
|
|
|
|
// This test is executed only once but we still do memoizing
|
|
// since we can use the boxSizingReliable pre-computing.
|
|
// No need to check if the test was already performed, though.
|
|
computePixelPositionAndBoxSizingReliable();
|
|
return pixelPositionVal;
|
|
},
|
|
boxSizingReliable: function() {
|
|
if ( boxSizingReliableVal == null ) {
|
|
computePixelPositionAndBoxSizingReliable();
|
|
}
|
|
return boxSizingReliableVal;
|
|
},
|
|
reliableMarginRight: function() {
|
|
|
|
// Support: Android 2.3
|
|
// Check if div with explicit width and no margin-right incorrectly
|
|
// gets computed margin-right based on width of container. (#3333)
|
|
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
// This support function is only executed once so no memoizing is needed.
|
|
var ret,
|
|
marginDiv = div.appendChild( document.createElement( "div" ) );
|
|
|
|
// Reset CSS: box-sizing; display; margin; border; padding
|
|
marginDiv.style.cssText = div.style.cssText =
|
|
// Support: Firefox<29, Android 2.3
|
|
// Vendor-prefix box-sizing
|
|
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
|
|
"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
|
|
marginDiv.style.marginRight = marginDiv.style.width = "0";
|
|
div.style.width = "1px";
|
|
docElem.appendChild( container );
|
|
|
|
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
|
|
|
|
docElem.removeChild( container );
|
|
div.removeChild( marginDiv );
|
|
|
|
return ret;
|
|
}
|
|
});
|
|
}
|
|
})();
|
|
|
|
|
|
// A method for quickly swapping in/out CSS properties to get correct calculations.
|
|
jQuery.swap = function( elem, options, callback, args ) {
|
|
var ret, name,
|
|
old = {};
|
|
|
|
// Remember the old values, and insert the new ones
|
|
for ( name in options ) {
|
|
old[ name ] = elem.style[ name ];
|
|
elem.style[ name ] = options[ name ];
|
|
}
|
|
|
|
ret = callback.apply( elem, args || [] );
|
|
|
|
// Revert the old values
|
|
for ( name in options ) {
|
|
elem.style[ name ] = old[ name ];
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
var
|
|
// Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
|
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
|
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
|
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
|
|
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
|
|
|
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
|
cssNormalTransform = {
|
|
letterSpacing: "0",
|
|
fontWeight: "400"
|
|
},
|
|
|
|
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
|
|
|
|
// Return a css property mapped to a potentially vendor prefixed property
|
|
function vendorPropName( style, name ) {
|
|
|
|
// Shortcut for names that are not vendor prefixed
|
|
if ( name in style ) {
|
|
return name;
|
|
}
|
|
|
|
// Check for vendor prefixed names
|
|
var capName = name[0].toUpperCase() + name.slice(1),
|
|
origName = name,
|
|
i = cssPrefixes.length;
|
|
|
|
while ( i-- ) {
|
|
name = cssPrefixes[ i ] + capName;
|
|
if ( name in style ) {
|
|
return name;
|
|
}
|
|
}
|
|
|
|
return origName;
|
|
}
|
|
|
|
function setPositiveNumber( elem, value, subtract ) {
|
|
var matches = rnumsplit.exec( value );
|
|
return matches ?
|
|
// Guard against undefined "subtract", e.g., when used as in cssHooks
|
|
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
|
value;
|
|
}
|
|
|
|
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
|
var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
|
// If we already have the right measurement, avoid augmentation
|
|
4 :
|
|
// Otherwise initialize for horizontal or vertical properties
|
|
name === "width" ? 1 : 0,
|
|
|
|
val = 0;
|
|
|
|
for ( ; i < 4; i += 2 ) {
|
|
// Both box models exclude margin, so add it if we want it
|
|
if ( extra === "margin" ) {
|
|
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
|
}
|
|
|
|
if ( isBorderBox ) {
|
|
// border-box includes padding, so remove it if we want content
|
|
if ( extra === "content" ) {
|
|
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
}
|
|
|
|
// At this point, extra isn't border nor margin, so remove border
|
|
if ( extra !== "margin" ) {
|
|
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
}
|
|
} else {
|
|
// At this point, extra isn't content, so add padding
|
|
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
|
|
|
// At this point, extra isn't content nor padding, so add border
|
|
if ( extra !== "padding" ) {
|
|
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
|
}
|
|
}
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
function getWidthOrHeight( elem, name, extra ) {
|
|
|
|
// Start with offset property, which is equivalent to the border-box value
|
|
var valueIsBorderBox = true,
|
|
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
|
styles = getStyles( elem ),
|
|
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
|
|
|
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
|
|
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
|
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
|
if ( val <= 0 || val == null ) {
|
|
// Fall back to computed then uncomputed css if necessary
|
|
val = curCSS( elem, name, styles );
|
|
if ( val < 0 || val == null ) {
|
|
val = elem.style[ name ];
|
|
}
|
|
|
|
// Computed unit is not pixels. Stop here and return.
|
|
if ( rnumnonpx.test(val) ) {
|
|
return val;
|
|
}
|
|
|
|
// Check for style in case a browser which returns unreliable values
|
|
// for getComputedStyle silently falls back to the reliable elem.style
|
|
valueIsBorderBox = isBorderBox &&
|
|
( support.boxSizingReliable() || val === elem.style[ name ] );
|
|
|
|
// Normalize "", auto, and prepare for extra
|
|
val = parseFloat( val ) || 0;
|
|
}
|
|
|
|
// Use the active box-sizing model to add/subtract irrelevant styles
|
|
return ( val +
|
|
augmentWidthOrHeight(
|
|
elem,
|
|
name,
|
|
extra || ( isBorderBox ? "border" : "content" ),
|
|
valueIsBorderBox,
|
|
styles
|
|
)
|
|
) + "px";
|
|
}
|
|
|
|
function showHide( elements, show ) {
|
|
var display, elem, hidden,
|
|
values = [],
|
|
index = 0,
|
|
length = elements.length;
|
|
|
|
for ( ; index < length; index++ ) {
|
|
elem = elements[ index ];
|
|
if ( !elem.style ) {
|
|
continue;
|
|
}
|
|
|
|
values[ index ] = data_priv.get( elem, "olddisplay" );
|
|
display = elem.style.display;
|
|
if ( show ) {
|
|
// Reset the inline display of this element to learn if it is
|
|
// being hidden by cascaded rules or not
|
|
if ( !values[ index ] && display === "none" ) {
|
|
elem.style.display = "";
|
|
}
|
|
|
|
// Set elements which have been overridden with display: none
|
|
// in a stylesheet to whatever the default browser style is
|
|
// for such an element
|
|
if ( elem.style.display === "" && isHidden( elem ) ) {
|
|
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
|
|
}
|
|
} else {
|
|
hidden = isHidden( elem );
|
|
|
|
if ( display !== "none" || !hidden ) {
|
|
data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Set the display of most of the elements in a second loop
|
|
// to avoid the constant reflow
|
|
for ( index = 0; index < length; index++ ) {
|
|
elem = elements[ index ];
|
|
if ( !elem.style ) {
|
|
continue;
|
|
}
|
|
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
|
|
elem.style.display = show ? values[ index ] || "" : "none";
|
|
}
|
|
}
|
|
|
|
return elements;
|
|
}
|
|
|
|
jQuery.extend({
|
|
|
|
// Add in style property hooks for overriding the default
|
|
// behavior of getting and setting a style property
|
|
cssHooks: {
|
|
opacity: {
|
|
get: function( elem, computed ) {
|
|
if ( computed ) {
|
|
|
|
// We should always get a number back from opacity
|
|
var ret = curCSS( elem, "opacity" );
|
|
return ret === "" ? "1" : ret;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
// Don't automatically add "px" to these possibly-unitless properties
|
|
cssNumber: {
|
|
"columnCount": true,
|
|
"fillOpacity": true,
|
|
"flexGrow": true,
|
|
"flexShrink": true,
|
|
"fontWeight": true,
|
|
"lineHeight": true,
|
|
"opacity": true,
|
|
"order": true,
|
|
"orphans": true,
|
|
"widows": true,
|
|
"zIndex": true,
|
|
"zoom": true
|
|
},
|
|
|
|
// Add in properties whose names you wish to fix before
|
|
// setting or getting the value
|
|
cssProps: {
|
|
"float": "cssFloat"
|
|
},
|
|
|
|
// Get and set the style property on a DOM Node
|
|
style: function( elem, name, value, extra ) {
|
|
|
|
// Don't set styles on text and comment nodes
|
|
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
|
return;
|
|
}
|
|
|
|
// Make sure that we're working with the right name
|
|
var ret, type, hooks,
|
|
origName = jQuery.camelCase( name ),
|
|
style = elem.style;
|
|
|
|
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
|
|
|
// Gets hook for the prefixed version, then unprefixed version
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
|
|
// Check if we're setting a value
|
|
if ( value !== undefined ) {
|
|
type = typeof value;
|
|
|
|
// Convert "+=" or "-=" to relative numbers (#7345)
|
|
if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
|
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
|
|
// Fixes bug #9237
|
|
type = "number";
|
|
}
|
|
|
|
// Make sure that null and NaN values aren't set (#7116)
|
|
if ( value == null || value !== value ) {
|
|
return;
|
|
}
|
|
|
|
// If a number, add 'px' to the (except for certain CSS properties)
|
|
if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
|
value += "px";
|
|
}
|
|
|
|
// Support: IE9-11+
|
|
// background-* props affect original clone's values
|
|
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
|
|
style[ name ] = "inherit";
|
|
}
|
|
|
|
// If a hook was provided, use that value, otherwise just set the specified value
|
|
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
|
style[ name ] = value;
|
|
}
|
|
|
|
} else {
|
|
// If a hook was provided get the non-computed value from there
|
|
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
|
return ret;
|
|
}
|
|
|
|
// Otherwise just get the value from the style object
|
|
return style[ name ];
|
|
}
|
|
},
|
|
|
|
css: function( elem, name, extra, styles ) {
|
|
var val, num, hooks,
|
|
origName = jQuery.camelCase( name );
|
|
|
|
// Make sure that we're working with the right name
|
|
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
|
|
|
// Try prefixed name followed by the unprefixed name
|
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
|
|
|
// If a hook was provided get the computed value from there
|
|
if ( hooks && "get" in hooks ) {
|
|
val = hooks.get( elem, true, extra );
|
|
}
|
|
|
|
// Otherwise, if a way to get the computed value exists, use that
|
|
if ( val === undefined ) {
|
|
val = curCSS( elem, name, styles );
|
|
}
|
|
|
|
// Convert "normal" to computed value
|
|
if ( val === "normal" && name in cssNormalTransform ) {
|
|
val = cssNormalTransform[ name ];
|
|
}
|
|
|
|
// Make numeric if forced or a qualifier was provided and val looks numeric
|
|
if ( extra === "" || extra ) {
|
|
num = parseFloat( val );
|
|
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
|
|
}
|
|
return val;
|
|
}
|
|
});
|
|
|
|
jQuery.each([ "height", "width" ], function( i, name ) {
|
|
jQuery.cssHooks[ name ] = {
|
|
get: function( elem, computed, extra ) {
|
|
if ( computed ) {
|
|
|
|
// Certain elements can have dimension info if we invisibly show them
|
|
// but it must have a current display style that would benefit
|
|
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
|
|
jQuery.swap( elem, cssShow, function() {
|
|
return getWidthOrHeight( elem, name, extra );
|
|
}) :
|
|
getWidthOrHeight( elem, name, extra );
|
|
}
|
|
},
|
|
|
|
set: function( elem, value, extra ) {
|
|
var styles = extra && getStyles( elem );
|
|
return setPositiveNumber( elem, value, extra ?
|
|
augmentWidthOrHeight(
|
|
elem,
|
|
name,
|
|
extra,
|
|
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
styles
|
|
) : 0
|
|
);
|
|
}
|
|
};
|
|
});
|
|
|
|
// Support: Android 2.3
|
|
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
|
|
function( elem, computed ) {
|
|
if ( computed ) {
|
|
return jQuery.swap( elem, { "display": "inline-block" },
|
|
curCSS, [ elem, "marginRight" ] );
|
|
}
|
|
}
|
|
);
|
|
|
|
// These hooks are used by animate to expand properties
|
|
jQuery.each({
|
|
margin: "",
|
|
padding: "",
|
|
border: "Width"
|
|
}, function( prefix, suffix ) {
|
|
jQuery.cssHooks[ prefix + suffix ] = {
|
|
expand: function( value ) {
|
|
var i = 0,
|
|
expanded = {},
|
|
|
|
// Assumes a single number if not a string
|
|
parts = typeof value === "string" ? value.split(" ") : [ value ];
|
|
|
|
for ( ; i < 4; i++ ) {
|
|
expanded[ prefix + cssExpand[ i ] + suffix ] =
|
|
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
|
|
}
|
|
|
|
return expanded;
|
|
}
|
|
};
|
|
|
|
if ( !rmargin.test( prefix ) ) {
|
|
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
|
|
}
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
css: function( name, value ) {
|
|
return access( this, function( elem, name, value ) {
|
|
var styles, len,
|
|
map = {},
|
|
i = 0;
|
|
|
|
if ( jQuery.isArray( name ) ) {
|
|
styles = getStyles( elem );
|
|
len = name.length;
|
|
|
|
for ( ; i < len; i++ ) {
|
|
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
|
|
}
|
|
|
|
return map;
|
|
}
|
|
|
|
return value !== undefined ?
|
|
jQuery.style( elem, name, value ) :
|
|
jQuery.css( elem, name );
|
|
}, name, value, arguments.length > 1 );
|
|
},
|
|
show: function() {
|
|
return showHide( this, true );
|
|
},
|
|
hide: function() {
|
|
return showHide( this );
|
|
},
|
|
toggle: function( state ) {
|
|
if ( typeof state === "boolean" ) {
|
|
return state ? this.show() : this.hide();
|
|
}
|
|
|
|
return this.each(function() {
|
|
if ( isHidden( this ) ) {
|
|
jQuery( this ).show();
|
|
} else {
|
|
jQuery( this ).hide();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
function Tween( elem, options, prop, end, easing ) {
|
|
return new Tween.prototype.init( elem, options, prop, end, easing );
|
|
}
|
|
jQuery.Tween = Tween;
|
|
|
|
Tween.prototype = {
|
|
constructor: Tween,
|
|
init: function( elem, options, prop, end, easing, unit ) {
|
|
this.elem = elem;
|
|
this.prop = prop;
|
|
this.easing = easing || "swing";
|
|
this.options = options;
|
|
this.start = this.now = this.cur();
|
|
this.end = end;
|
|
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
|
|
},
|
|
cur: function() {
|
|
var hooks = Tween.propHooks[ this.prop ];
|
|
|
|
return hooks && hooks.get ?
|
|
hooks.get( this ) :
|
|
Tween.propHooks._default.get( this );
|
|
},
|
|
run: function( percent ) {
|
|
var eased,
|
|
hooks = Tween.propHooks[ this.prop ];
|
|
|
|
if ( this.options.duration ) {
|
|
this.pos = eased = jQuery.easing[ this.easing ](
|
|
percent, this.options.duration * percent, 0, 1, this.options.duration
|
|
);
|
|
} else {
|
|
this.pos = eased = percent;
|
|
}
|
|
this.now = ( this.end - this.start ) * eased + this.start;
|
|
|
|
if ( this.options.step ) {
|
|
this.options.step.call( this.elem, this.now, this );
|
|
}
|
|
|
|
if ( hooks && hooks.set ) {
|
|
hooks.set( this );
|
|
} else {
|
|
Tween.propHooks._default.set( this );
|
|
}
|
|
return this;
|
|
}
|
|
};
|
|
|
|
Tween.prototype.init.prototype = Tween.prototype;
|
|
|
|
Tween.propHooks = {
|
|
_default: {
|
|
get: function( tween ) {
|
|
var result;
|
|
|
|
if ( tween.elem[ tween.prop ] != null &&
|
|
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
|
|
return tween.elem[ tween.prop ];
|
|
}
|
|
|
|
// Passing an empty string as a 3rd parameter to .css will automatically
|
|
// attempt a parseFloat and fallback to a string if the parse fails.
|
|
// Simple values such as "10px" are parsed to Float;
|
|
// complex values such as "rotate(1rad)" are returned as-is.
|
|
result = jQuery.css( tween.elem, tween.prop, "" );
|
|
// Empty strings, null, undefined and "auto" are converted to 0.
|
|
return !result || result === "auto" ? 0 : result;
|
|
},
|
|
set: function( tween ) {
|
|
// Use step hook for back compat.
|
|
// Use cssHook if its there.
|
|
// Use .style if available and use plain properties where available.
|
|
if ( jQuery.fx.step[ tween.prop ] ) {
|
|
jQuery.fx.step[ tween.prop ]( tween );
|
|
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
|
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
|
} else {
|
|
tween.elem[ tween.prop ] = tween.now;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// Support: IE9
|
|
// Panic based approach to setting things on disconnected nodes
|
|
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
|
|
set: function( tween ) {
|
|
if ( tween.elem.nodeType && tween.elem.parentNode ) {
|
|
tween.elem[ tween.prop ] = tween.now;
|
|
}
|
|
}
|
|
};
|
|
|
|
jQuery.easing = {
|
|
linear: function( p ) {
|
|
return p;
|
|
},
|
|
swing: function( p ) {
|
|
return 0.5 - Math.cos( p * Math.PI ) / 2;
|
|
}
|
|
};
|
|
|
|
jQuery.fx = Tween.prototype.init;
|
|
|
|
// Back Compat <1.8 extension point
|
|
jQuery.fx.step = {};
|
|
|
|
|
|
|
|
|
|
var
|
|
fxNow, timerId,
|
|
rfxtypes = /^(?:toggle|show|hide)$/,
|
|
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
|
|
rrun = /queueHooks$/,
|
|
animationPrefilters = [ defaultPrefilter ],
|
|
tweeners = {
|
|
"*": [ function( prop, value ) {
|
|
var tween = this.createTween( prop, value ),
|
|
target = tween.cur(),
|
|
parts = rfxnum.exec( value ),
|
|
unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
|
|
|
// Starting value computation is required for potential unit mismatches
|
|
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
|
|
rfxnum.exec( jQuery.css( tween.elem, prop ) ),
|
|
scale = 1,
|
|
maxIterations = 20;
|
|
|
|
if ( start && start[ 3 ] !== unit ) {
|
|
// Trust units reported by jQuery.css
|
|
unit = unit || start[ 3 ];
|
|
|
|
// Make sure we update the tween properties later on
|
|
parts = parts || [];
|
|
|
|
// Iteratively approximate from a nonzero starting point
|
|
start = +target || 1;
|
|
|
|
do {
|
|
// If previous iteration zeroed out, double until we get *something*.
|
|
// Use string for doubling so we don't accidentally see scale as unchanged below
|
|
scale = scale || ".5";
|
|
|
|
// Adjust and apply
|
|
start = start / scale;
|
|
jQuery.style( tween.elem, prop, start + unit );
|
|
|
|
// Update scale, tolerating zero or NaN from tween.cur(),
|
|
// break the loop if scale is unchanged or perfect, or if we've just had enough
|
|
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
|
}
|
|
|
|
// Update tween properties
|
|
if ( parts ) {
|
|
start = tween.start = +start || +target || 0;
|
|
tween.unit = unit;
|
|
// If a +=/-= token was provided, we're doing a relative animation
|
|
tween.end = parts[ 1 ] ?
|
|
start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
|
|
+parts[ 2 ];
|
|
}
|
|
|
|
return tween;
|
|
} ]
|
|
};
|
|
|
|
// Animations created synchronously will run synchronously
|
|
function createFxNow() {
|
|
setTimeout(function() {
|
|
fxNow = undefined;
|
|
});
|
|
return ( fxNow = jQuery.now() );
|
|
}
|
|
|
|
// Generate parameters to create a standard animation
|
|
function genFx( type, includeWidth ) {
|
|
var which,
|
|
i = 0,
|
|
attrs = { height: type };
|
|
|
|
// If we include width, step value is 1 to do all cssExpand values,
|
|
// otherwise step value is 2 to skip over Left and Right
|
|
includeWidth = includeWidth ? 1 : 0;
|
|
for ( ; i < 4 ; i += 2 - includeWidth ) {
|
|
which = cssExpand[ i ];
|
|
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
|
|
}
|
|
|
|
if ( includeWidth ) {
|
|
attrs.opacity = attrs.width = type;
|
|
}
|
|
|
|
return attrs;
|
|
}
|
|
|
|
function createTween( value, prop, animation ) {
|
|
var tween,
|
|
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
|
|
index = 0,
|
|
length = collection.length;
|
|
for ( ; index < length; index++ ) {
|
|
if ( (tween = collection[ index ].call( animation, prop, value )) ) {
|
|
|
|
// We're done with this property
|
|
return tween;
|
|
}
|
|
}
|
|
}
|
|
|
|
function defaultPrefilter( elem, props, opts ) {
|
|
/* jshint validthis: true */
|
|
var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
|
|
anim = this,
|
|
orig = {},
|
|
style = elem.style,
|
|
hidden = elem.nodeType && isHidden( elem ),
|
|
dataShow = data_priv.get( elem, "fxshow" );
|
|
|
|
// Handle queue: false promises
|
|
if ( !opts.queue ) {
|
|
hooks = jQuery._queueHooks( elem, "fx" );
|
|
if ( hooks.unqueued == null ) {
|
|
hooks.unqueued = 0;
|
|
oldfire = hooks.empty.fire;
|
|
hooks.empty.fire = function() {
|
|
if ( !hooks.unqueued ) {
|
|
oldfire();
|
|
}
|
|
};
|
|
}
|
|
hooks.unqueued++;
|
|
|
|
anim.always(function() {
|
|
// Ensure the complete handler is called before this completes
|
|
anim.always(function() {
|
|
hooks.unqueued--;
|
|
if ( !jQuery.queue( elem, "fx" ).length ) {
|
|
hooks.empty.fire();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// Height/width overflow pass
|
|
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
|
|
// Make sure that nothing sneaks out
|
|
// Record all 3 overflow attributes because IE9-10 do not
|
|
// change the overflow attribute when overflowX and
|
|
// overflowY are set to the same value
|
|
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
|
|
|
|
// Set display property to inline-block for height/width
|
|
// animations on inline elements that are having width/height animated
|
|
display = jQuery.css( elem, "display" );
|
|
|
|
// Test default display if display is currently "none"
|
|
checkDisplay = display === "none" ?
|
|
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
|
|
|
|
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
|
|
style.display = "inline-block";
|
|
}
|
|
}
|
|
|
|
if ( opts.overflow ) {
|
|
style.overflow = "hidden";
|
|
anim.always(function() {
|
|
style.overflow = opts.overflow[ 0 ];
|
|
style.overflowX = opts.overflow[ 1 ];
|
|
style.overflowY = opts.overflow[ 2 ];
|
|
});
|
|
}
|
|
|
|
// show/hide pass
|
|
for ( prop in props ) {
|
|
value = props[ prop ];
|
|
if ( rfxtypes.exec( value ) ) {
|
|
delete props[ prop ];
|
|
toggle = toggle || value === "toggle";
|
|
if ( value === ( hidden ? "hide" : "show" ) ) {
|
|
|
|
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
|
|
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
|
|
hidden = true;
|
|
} else {
|
|
continue;
|
|
}
|
|
}
|
|
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
|
|
|
|
// Any non-fx value stops us from restoring the original display value
|
|
} else {
|
|
display = undefined;
|
|
}
|
|
}
|
|
|
|
if ( !jQuery.isEmptyObject( orig ) ) {
|
|
if ( dataShow ) {
|
|
if ( "hidden" in dataShow ) {
|
|
hidden = dataShow.hidden;
|
|
}
|
|
} else {
|
|
dataShow = data_priv.access( elem, "fxshow", {} );
|
|
}
|
|
|
|
// Store state if its toggle - enables .stop().toggle() to "reverse"
|
|
if ( toggle ) {
|
|
dataShow.hidden = !hidden;
|
|
}
|
|
if ( hidden ) {
|
|
jQuery( elem ).show();
|
|
} else {
|
|
anim.done(function() {
|
|
jQuery( elem ).hide();
|
|
});
|
|
}
|
|
anim.done(function() {
|
|
var prop;
|
|
|
|
data_priv.remove( elem, "fxshow" );
|
|
for ( prop in orig ) {
|
|
jQuery.style( elem, prop, orig[ prop ] );
|
|
}
|
|
});
|
|
for ( prop in orig ) {
|
|
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
|
|
|
|
if ( !( prop in dataShow ) ) {
|
|
dataShow[ prop ] = tween.start;
|
|
if ( hidden ) {
|
|
tween.end = tween.start;
|
|
tween.start = prop === "width" || prop === "height" ? 1 : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
// If this is a noop like .hide().hide(), restore an overwritten display value
|
|
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
|
|
style.display = display;
|
|
}
|
|
}
|
|
|
|
function propFilter( props, specialEasing ) {
|
|
var index, name, easing, value, hooks;
|
|
|
|
// camelCase, specialEasing and expand cssHook pass
|
|
for ( index in props ) {
|
|
name = jQuery.camelCase( index );
|
|
easing = specialEasing[ name ];
|
|
value = props[ index ];
|
|
if ( jQuery.isArray( value ) ) {
|
|
easing = value[ 1 ];
|
|
value = props[ index ] = value[ 0 ];
|
|
}
|
|
|
|
if ( index !== name ) {
|
|
props[ name ] = value;
|
|
delete props[ index ];
|
|
}
|
|
|
|
hooks = jQuery.cssHooks[ name ];
|
|
if ( hooks && "expand" in hooks ) {
|
|
value = hooks.expand( value );
|
|
delete props[ name ];
|
|
|
|
// Not quite $.extend, this won't overwrite existing keys.
|
|
// Reusing 'index' because we have the correct "name"
|
|
for ( index in value ) {
|
|
if ( !( index in props ) ) {
|
|
props[ index ] = value[ index ];
|
|
specialEasing[ index ] = easing;
|
|
}
|
|
}
|
|
} else {
|
|
specialEasing[ name ] = easing;
|
|
}
|
|
}
|
|
}
|
|
|
|
function Animation( elem, properties, options ) {
|
|
var result,
|
|
stopped,
|
|
index = 0,
|
|
length = animationPrefilters.length,
|
|
deferred = jQuery.Deferred().always( function() {
|
|
// Don't match elem in the :animated selector
|
|
delete tick.elem;
|
|
}),
|
|
tick = function() {
|
|
if ( stopped ) {
|
|
return false;
|
|
}
|
|
var currentTime = fxNow || createFxNow(),
|
|
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
|
// Support: Android 2.3
|
|
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
|
|
temp = remaining / animation.duration || 0,
|
|
percent = 1 - temp,
|
|
index = 0,
|
|
length = animation.tweens.length;
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
animation.tweens[ index ].run( percent );
|
|
}
|
|
|
|
deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
|
|
|
if ( percent < 1 && length ) {
|
|
return remaining;
|
|
} else {
|
|
deferred.resolveWith( elem, [ animation ] );
|
|
return false;
|
|
}
|
|
},
|
|
animation = deferred.promise({
|
|
elem: elem,
|
|
props: jQuery.extend( {}, properties ),
|
|
opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
|
originalProperties: properties,
|
|
originalOptions: options,
|
|
startTime: fxNow || createFxNow(),
|
|
duration: options.duration,
|
|
tweens: [],
|
|
createTween: function( prop, end ) {
|
|
var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
|
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
|
animation.tweens.push( tween );
|
|
return tween;
|
|
},
|
|
stop: function( gotoEnd ) {
|
|
var index = 0,
|
|
// If we are going to the end, we want to run all the tweens
|
|
// otherwise we skip this part
|
|
length = gotoEnd ? animation.tweens.length : 0;
|
|
if ( stopped ) {
|
|
return this;
|
|
}
|
|
stopped = true;
|
|
for ( ; index < length ; index++ ) {
|
|
animation.tweens[ index ].run( 1 );
|
|
}
|
|
|
|
// Resolve when we played the last frame; otherwise, reject
|
|
if ( gotoEnd ) {
|
|
deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
|
} else {
|
|
deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
|
}
|
|
return this;
|
|
}
|
|
}),
|
|
props = animation.props;
|
|
|
|
propFilter( props, animation.opts.specialEasing );
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
|
if ( result ) {
|
|
return result;
|
|
}
|
|
}
|
|
|
|
jQuery.map( props, createTween, animation );
|
|
|
|
if ( jQuery.isFunction( animation.opts.start ) ) {
|
|
animation.opts.start.call( elem, animation );
|
|
}
|
|
|
|
jQuery.fx.timer(
|
|
jQuery.extend( tick, {
|
|
elem: elem,
|
|
anim: animation,
|
|
queue: animation.opts.queue
|
|
})
|
|
);
|
|
|
|
// attach callbacks from options
|
|
return animation.progress( animation.opts.progress )
|
|
.done( animation.opts.done, animation.opts.complete )
|
|
.fail( animation.opts.fail )
|
|
.always( animation.opts.always );
|
|
}
|
|
|
|
jQuery.Animation = jQuery.extend( Animation, {
|
|
|
|
tweener: function( props, callback ) {
|
|
if ( jQuery.isFunction( props ) ) {
|
|
callback = props;
|
|
props = [ "*" ];
|
|
} else {
|
|
props = props.split(" ");
|
|
}
|
|
|
|
var prop,
|
|
index = 0,
|
|
length = props.length;
|
|
|
|
for ( ; index < length ; index++ ) {
|
|
prop = props[ index ];
|
|
tweeners[ prop ] = tweeners[ prop ] || [];
|
|
tweeners[ prop ].unshift( callback );
|
|
}
|
|
},
|
|
|
|
prefilter: function( callback, prepend ) {
|
|
if ( prepend ) {
|
|
animationPrefilters.unshift( callback );
|
|
} else {
|
|
animationPrefilters.push( callback );
|
|
}
|
|
}
|
|
});
|
|
|
|
jQuery.speed = function( speed, easing, fn ) {
|
|
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
|
complete: fn || !fn && easing ||
|
|
jQuery.isFunction( speed ) && speed,
|
|
duration: speed,
|
|
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
|
};
|
|
|
|
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
|
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
|
|
|
// Normalize opt.queue - true/undefined/null -> "fx"
|
|
if ( opt.queue == null || opt.queue === true ) {
|
|
opt.queue = "fx";
|
|
}
|
|
|
|
// Queueing
|
|
opt.old = opt.complete;
|
|
|
|
opt.complete = function() {
|
|
if ( jQuery.isFunction( opt.old ) ) {
|
|
opt.old.call( this );
|
|
}
|
|
|
|
if ( opt.queue ) {
|
|
jQuery.dequeue( this, opt.queue );
|
|
}
|
|
};
|
|
|
|
return opt;
|
|
};
|
|
|
|
jQuery.fn.extend({
|
|
fadeTo: function( speed, to, easing, callback ) {
|
|
|
|
// Show any hidden elements after setting opacity to 0
|
|
return this.filter( isHidden ).css( "opacity", 0 ).show()
|
|
|
|
// Animate to the value specified
|
|
.end().animate({ opacity: to }, speed, easing, callback );
|
|
},
|
|
animate: function( prop, speed, easing, callback ) {
|
|
var empty = jQuery.isEmptyObject( prop ),
|
|
optall = jQuery.speed( speed, easing, callback ),
|
|
doAnimation = function() {
|
|
// Operate on a copy of prop so per-property easing won't be lost
|
|
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
|
|
|
// Empty animations, or finishing resolves immediately
|
|
if ( empty || data_priv.get( this, "finish" ) ) {
|
|
anim.stop( true );
|
|
}
|
|
};
|
|
doAnimation.finish = doAnimation;
|
|
|
|
return empty || optall.queue === false ?
|
|
this.each( doAnimation ) :
|
|
this.queue( optall.queue, doAnimation );
|
|
},
|
|
stop: function( type, clearQueue, gotoEnd ) {
|
|
var stopQueue = function( hooks ) {
|
|
var stop = hooks.stop;
|
|
delete hooks.stop;
|
|
stop( gotoEnd );
|
|
};
|
|
|
|
if ( typeof type !== "string" ) {
|
|
gotoEnd = clearQueue;
|
|
clearQueue = type;
|
|
type = undefined;
|
|
}
|
|
if ( clearQueue && type !== false ) {
|
|
this.queue( type || "fx", [] );
|
|
}
|
|
|
|
return this.each(function() {
|
|
var dequeue = true,
|
|
index = type != null && type + "queueHooks",
|
|
timers = jQuery.timers,
|
|
data = data_priv.get( this );
|
|
|
|
if ( index ) {
|
|
if ( data[ index ] && data[ index ].stop ) {
|
|
stopQueue( data[ index ] );
|
|
}
|
|
} else {
|
|
for ( index in data ) {
|
|
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
|
|
stopQueue( data[ index ] );
|
|
}
|
|
}
|
|
}
|
|
|
|
for ( index = timers.length; index--; ) {
|
|
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
|
timers[ index ].anim.stop( gotoEnd );
|
|
dequeue = false;
|
|
timers.splice( index, 1 );
|
|
}
|
|
}
|
|
|
|
// Start the next in the queue if the last step wasn't forced.
|
|
// Timers currently will call their complete callbacks, which
|
|
// will dequeue but only if they were gotoEnd.
|
|
if ( dequeue || !gotoEnd ) {
|
|
jQuery.dequeue( this, type );
|
|
}
|
|
});
|
|
},
|
|
finish: function( type ) {
|
|
if ( type !== false ) {
|
|
type = type || "fx";
|
|
}
|
|
return this.each(function() {
|
|
var index,
|
|
data = data_priv.get( this ),
|
|
queue = data[ type + "queue" ],
|
|
hooks = data[ type + "queueHooks" ],
|
|
timers = jQuery.timers,
|
|
length = queue ? queue.length : 0;
|
|
|
|
// Enable finishing flag on private data
|
|
data.finish = true;
|
|
|
|
// Empty the queue first
|
|
jQuery.queue( this, type, [] );
|
|
|
|
if ( hooks && hooks.stop ) {
|
|
hooks.stop.call( this, true );
|
|
}
|
|
|
|
// Look for any active animations, and finish them
|
|
for ( index = timers.length; index--; ) {
|
|
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
|
|
timers[ index ].anim.stop( true );
|
|
timers.splice( index, 1 );
|
|
}
|
|
}
|
|
|
|
// Look for any animations in the old queue and finish them
|
|
for ( index = 0; index < length; index++ ) {
|
|
if ( queue[ index ] && queue[ index ].finish ) {
|
|
queue[ index ].finish.call( this );
|
|
}
|
|
}
|
|
|
|
// Turn off finishing flag
|
|
delete data.finish;
|
|
});
|
|
}
|
|
});
|
|
|
|
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
|
var cssFn = jQuery.fn[ name ];
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
return speed == null || typeof speed === "boolean" ?
|
|
cssFn.apply( this, arguments ) :
|
|
this.animate( genFx( name, true ), speed, easing, callback );
|
|
};
|
|
});
|
|
|
|
// Generate shortcuts for custom animations
|
|
jQuery.each({
|
|
slideDown: genFx("show"),
|
|
slideUp: genFx("hide"),
|
|
slideToggle: genFx("toggle"),
|
|
fadeIn: { opacity: "show" },
|
|
fadeOut: { opacity: "hide" },
|
|
fadeToggle: { opacity: "toggle" }
|
|
}, function( name, props ) {
|
|
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
return this.animate( props, speed, easing, callback );
|
|
};
|
|
});
|
|
|
|
jQuery.timers = [];
|
|
jQuery.fx.tick = function() {
|
|
var timer,
|
|
i = 0,
|
|
timers = jQuery.timers;
|
|
|
|
fxNow = jQuery.now();
|
|
|
|
for ( ; i < timers.length; i++ ) {
|
|
timer = timers[ i ];
|
|
// Checks the timer has not already been removed
|
|
if ( !timer() && timers[ i ] === timer ) {
|
|
timers.splice( i--, 1 );
|
|
}
|
|
}
|
|
|
|
if ( !timers.length ) {
|
|
jQuery.fx.stop();
|
|
}
|
|
fxNow = undefined;
|
|
};
|
|
|
|
jQuery.fx.timer = function( timer ) {
|
|
jQuery.timers.push( timer );
|
|
if ( timer() ) {
|
|
jQuery.fx.start();
|
|
} else {
|
|
jQuery.timers.pop();
|
|
}
|
|
};
|
|
|
|
jQuery.fx.interval = 13;
|
|
|
|
jQuery.fx.start = function() {
|
|
if ( !timerId ) {
|
|
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
|
}
|
|
};
|
|
|
|
jQuery.fx.stop = function() {
|
|
clearInterval( timerId );
|
|
timerId = null;
|
|
};
|
|
|
|
jQuery.fx.speeds = {
|
|
slow: 600,
|
|
fast: 200,
|
|
// Default speed
|
|
_default: 400
|
|
};
|
|
|
|
|
|
// Based off of the plugin by Clint Helfers, with permission.
|
|
// http://blindsignals.com/index.php/2009/07/jquery-delay/
|
|
jQuery.fn.delay = function( time, type ) {
|
|
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
|
|
type = type || "fx";
|
|
|
|
return this.queue( type, function( next, hooks ) {
|
|
var timeout = setTimeout( next, time );
|
|
hooks.stop = function() {
|
|
clearTimeout( timeout );
|
|
};
|
|
});
|
|
};
|
|
|
|
|
|
(function() {
|
|
var input = document.createElement( "input" ),
|
|
select = document.createElement( "select" ),
|
|
opt = select.appendChild( document.createElement( "option" ) );
|
|
|
|
input.type = "checkbox";
|
|
|
|
// Support: iOS<=5.1, Android<=4.2+
|
|
// Default value for a checkbox should be "on"
|
|
support.checkOn = input.value !== "";
|
|
|
|
// Support: IE<=11+
|
|
// Must access selectedIndex to make default options select
|
|
support.optSelected = opt.selected;
|
|
|
|
// Support: Android<=2.3
|
|
// Options inside disabled selects are incorrectly marked as disabled
|
|
select.disabled = true;
|
|
support.optDisabled = !opt.disabled;
|
|
|
|
// Support: IE<=11+
|
|
// An input loses its value after becoming a radio
|
|
input = document.createElement( "input" );
|
|
input.value = "t";
|
|
input.type = "radio";
|
|
support.radioValue = input.value === "t";
|
|
})();
|
|
|
|
|
|
var nodeHook, boolHook,
|
|
attrHandle = jQuery.expr.attrHandle;
|
|
|
|
jQuery.fn.extend({
|
|
attr: function( name, value ) {
|
|
return access( this, jQuery.attr, name, value, arguments.length > 1 );
|
|
},
|
|
|
|
removeAttr: function( name ) {
|
|
return this.each(function() {
|
|
jQuery.removeAttr( this, name );
|
|
});
|
|
}
|
|
});
|
|
|
|
jQuery.extend({
|
|
attr: function( elem, name, value ) {
|
|
var hooks, ret,
|
|
nType = elem.nodeType;
|
|
|
|
// don't get/set attributes on text, comment and attribute nodes
|
|
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
return;
|
|
}
|
|
|
|
// Fallback to prop when attributes are not supported
|
|
if ( typeof elem.getAttribute === strundefined ) {
|
|
return jQuery.prop( elem, name, value );
|
|
}
|
|
|
|
// All attributes are lowercase
|
|
// Grab necessary hook if one is defined
|
|
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
|
|
name = name.toLowerCase();
|
|
hooks = jQuery.attrHooks[ name ] ||
|
|
( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
|
|
}
|
|
|
|
if ( value !== undefined ) {
|
|
|
|
if ( value === null ) {
|
|
jQuery.removeAttr( elem, name );
|
|
|
|
} else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
|
return ret;
|
|
|
|
} else {
|
|
elem.setAttribute( name, value + "" );
|
|
return value;
|
|
}
|
|
|
|
} else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
|
return ret;
|
|
|
|
} else {
|
|
ret = jQuery.find.attr( elem, name );
|
|
|
|
// Non-existent attributes return null, we normalize to undefined
|
|
return ret == null ?
|
|
undefined :
|
|
ret;
|
|
}
|
|
},
|
|
|
|
removeAttr: function( elem, value ) {
|
|
var name, propName,
|
|
i = 0,
|
|
attrNames = value && value.match( rnotwhite );
|
|
|
|
if ( attrNames && elem.nodeType === 1 ) {
|
|
while ( (name = attrNames[i++]) ) {
|
|
propName = jQuery.propFix[ name ] || name;
|
|
|
|
// Boolean attributes get special treatment (#10870)
|
|
if ( jQuery.expr.match.bool.test( name ) ) {
|
|
// Set corresponding property to false
|
|
elem[ propName ] = false;
|
|
}
|
|
|
|
elem.removeAttribute( name );
|
|
}
|
|
}
|
|
},
|
|
|
|
attrHooks: {
|
|
type: {
|
|
set: function( elem, value ) {
|
|
if ( !support.radioValue && value === "radio" &&
|
|
jQuery.nodeName( elem, "input" ) ) {
|
|
var val = elem.value;
|
|
elem.setAttribute( "type", value );
|
|
if ( val ) {
|
|
elem.value = val;
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// Hooks for boolean attributes
|
|
boolHook = {
|
|
set: function( elem, value, name ) {
|
|
if ( value === false ) {
|
|
// Remove boolean attributes when set to false
|
|
jQuery.removeAttr( elem, name );
|
|
} else {
|
|
elem.setAttribute( name, name );
|
|
}
|
|
return name;
|
|
}
|
|
};
|
|
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
|
|
var getter = attrHandle[ name ] || jQuery.find.attr;
|
|
|
|
attrHandle[ name ] = function( elem, name, isXML ) {
|
|
var ret, handle;
|
|
if ( !isXML ) {
|
|
// Avoid an infinite loop by temporarily removing this function from the getter
|
|
handle = attrHandle[ name ];
|
|
attrHandle[ name ] = ret;
|
|
ret = getter( elem, name, isXML ) != null ?
|
|
name.toLowerCase() :
|
|
null;
|
|
attrHandle[ name ] = handle;
|
|
}
|
|
return ret;
|
|
};
|
|
});
|
|
|
|
|
|
|
|
|
|
var rfocusable = /^(?:input|select|textarea|button)$/i;
|
|
|
|
jQuery.fn.extend({
|
|
prop: function( name, value ) {
|
|
return access( this, jQuery.prop, name, value, arguments.length > 1 );
|
|
},
|
|
|
|
removeProp: function( name ) {
|
|
return this.each(function() {
|
|
delete this[ jQuery.propFix[ name ] || name ];
|
|
});
|
|
}
|
|
});
|
|
|
|
jQuery.extend({
|
|
propFix: {
|
|
"for": "htmlFor",
|
|
"class": "className"
|
|
},
|
|
|
|
prop: function( elem, name, value ) {
|
|
var ret, hooks, notxml,
|
|
nType = elem.nodeType;
|
|
|
|
// Don't get/set properties on text, comment and attribute nodes
|
|
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
|
return;
|
|
}
|
|
|
|
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
|
|
|
if ( notxml ) {
|
|
// Fix name and attach hooks
|
|
name = jQuery.propFix[ name ] || name;
|
|
hooks = jQuery.propHooks[ name ];
|
|
}
|
|
|
|
if ( value !== undefined ) {
|
|
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
|
|
ret :
|
|
( elem[ name ] = value );
|
|
|
|
} else {
|
|
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
|
|
ret :
|
|
elem[ name ];
|
|
}
|
|
},
|
|
|
|
propHooks: {
|
|
tabIndex: {
|
|
get: function( elem ) {
|
|
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
|
|
elem.tabIndex :
|
|
-1;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
if ( !support.optSelected ) {
|
|
jQuery.propHooks.selected = {
|
|
get: function( elem ) {
|
|
var parent = elem.parentNode;
|
|
if ( parent && parent.parentNode ) {
|
|
parent.parentNode.selectedIndex;
|
|
}
|
|
return null;
|
|
}
|
|
};
|
|
}
|
|
|
|
jQuery.each([
|
|
"tabIndex",
|
|
"readOnly",
|
|
"maxLength",
|
|
"cellSpacing",
|
|
"cellPadding",
|
|
"rowSpan",
|
|
"colSpan",
|
|
"useMap",
|
|
"frameBorder",
|
|
"contentEditable"
|
|
], function() {
|
|
jQuery.propFix[ this.toLowerCase() ] = this;
|
|
});
|
|
|
|
|
|
|
|
|
|
var rclass = /[\t\r\n\f]/g;
|
|
|
|
jQuery.fn.extend({
|
|
addClass: function( value ) {
|
|
var classes, elem, cur, clazz, j, finalValue,
|
|
proceed = typeof value === "string" && value,
|
|
i = 0,
|
|
len = this.length;
|
|
|
|
if ( jQuery.isFunction( value ) ) {
|
|
return this.each(function( j ) {
|
|
jQuery( this ).addClass( value.call( this, j, this.className ) );
|
|
});
|
|
}
|
|
|
|
if ( proceed ) {
|
|
// The disjunction here is for better compressibility (see removeClass)
|
|
classes = ( value || "" ).match( rnotwhite ) || [];
|
|
|
|
for ( ; i < len; i++ ) {
|
|
elem = this[ i ];
|
|
cur = elem.nodeType === 1 && ( elem.className ?
|
|
( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
" "
|
|
);
|
|
|
|
if ( cur ) {
|
|
j = 0;
|
|
while ( (clazz = classes[j++]) ) {
|
|
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
|
|
cur += clazz + " ";
|
|
}
|
|
}
|
|
|
|
// only assign if different to avoid unneeded rendering.
|
|
finalValue = jQuery.trim( cur );
|
|
if ( elem.className !== finalValue ) {
|
|
elem.className = finalValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
removeClass: function( value ) {
|
|
var classes, elem, cur, clazz, j, finalValue,
|
|
proceed = arguments.length === 0 || typeof value === "string" && value,
|
|
i = 0,
|
|
len = this.length;
|
|
|
|
if ( jQuery.isFunction( value ) ) {
|
|
return this.each(function( j ) {
|
|
jQuery( this ).removeClass( value.call( this, j, this.className ) );
|
|
});
|
|
}
|
|
if ( proceed ) {
|
|
classes = ( value || "" ).match( rnotwhite ) || [];
|
|
|
|
for ( ; i < len; i++ ) {
|
|
elem = this[ i ];
|
|
// This expression is here for better compressibility (see addClass)
|
|
cur = elem.nodeType === 1 && ( elem.className ?
|
|
( " " + elem.className + " " ).replace( rclass, " " ) :
|
|
""
|
|
);
|
|
|
|
if ( cur ) {
|
|
j = 0;
|
|
while ( (clazz = classes[j++]) ) {
|
|
// Remove *all* instances
|
|
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
|
|
cur = cur.replace( " " + clazz + " ", " " );
|
|
}
|
|
}
|
|
|
|
// Only assign if different to avoid unneeded rendering.
|
|
finalValue = value ? jQuery.trim( cur ) : "";
|
|
if ( elem.className !== finalValue ) {
|
|
elem.className = finalValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
toggleClass: function( value, stateVal ) {
|
|
var type = typeof value;
|
|
|
|
if ( typeof stateVal === "boolean" && type === "string" ) {
|
|
return stateVal ? this.addClass( value ) : this.removeClass( value );
|
|
}
|
|
|
|
if ( jQuery.isFunction( value ) ) {
|
|
return this.each(function( i ) {
|
|
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
|
});
|
|
}
|
|
|
|
return this.each(function() {
|
|
if ( type === "string" ) {
|
|
// Toggle individual class names
|
|
var className,
|
|
i = 0,
|
|
self = jQuery( this ),
|
|
classNames = value.match( rnotwhite ) || [];
|
|
|
|
while ( (className = classNames[ i++ ]) ) {
|
|
// Check each className given, space separated list
|
|
if ( self.hasClass( className ) ) {
|
|
self.removeClass( className );
|
|
} else {
|
|
self.addClass( className );
|
|
}
|
|
}
|
|
|
|
// Toggle whole class name
|
|
} else if ( type === strundefined || type === "boolean" ) {
|
|
if ( this.className ) {
|
|
// store className if set
|
|
data_priv.set( this, "__className__", this.className );
|
|
}
|
|
|
|
// If the element has a class name or if we're passed `false`,
|
|
// then remove the whole classname (if there was one, the above saved it).
|
|
// Otherwise bring back whatever was previously saved (if anything),
|
|
// falling back to the empty string if nothing was stored.
|
|
this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
|
|
}
|
|
});
|
|
},
|
|
|
|
hasClass: function( selector ) {
|
|
var className = " " + selector + " ",
|
|
i = 0,
|
|
l = this.length;
|
|
for ( ; i < l; i++ ) {
|
|
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
var rreturn = /\r/g;
|
|
|
|
jQuery.fn.extend({
|
|
val: function( value ) {
|
|
var hooks, ret, isFunction,
|
|
elem = this[0];
|
|
|
|
if ( !arguments.length ) {
|
|
if ( elem ) {
|
|
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
|
|
|
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
|
return ret;
|
|
}
|
|
|
|
ret = elem.value;
|
|
|
|
return typeof ret === "string" ?
|
|
// Handle most common string cases
|
|
ret.replace(rreturn, "") :
|
|
// Handle cases where value is null/undef or number
|
|
ret == null ? "" : ret;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
isFunction = jQuery.isFunction( value );
|
|
|
|
return this.each(function( i ) {
|
|
var val;
|
|
|
|
if ( this.nodeType !== 1 ) {
|
|
return;
|
|
}
|
|
|
|
if ( isFunction ) {
|
|
val = value.call( this, i, jQuery( this ).val() );
|
|
} else {
|
|
val = value;
|
|
}
|
|
|
|
// Treat null/undefined as ""; convert numbers to string
|
|
if ( val == null ) {
|
|
val = "";
|
|
|
|
} else if ( typeof val === "number" ) {
|
|
val += "";
|
|
|
|
} else if ( jQuery.isArray( val ) ) {
|
|
val = jQuery.map( val, function( value ) {
|
|
return value == null ? "" : value + "";
|
|
});
|
|
}
|
|
|
|
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
|
|
|
|
// If set returns undefined, fall back to normal setting
|
|
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
|
this.value = val;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
jQuery.extend({
|
|
valHooks: {
|
|
option: {
|
|
get: function( elem ) {
|
|
var val = jQuery.find.attr( elem, "value" );
|
|
return val != null ?
|
|
val :
|
|
// Support: IE10-11+
|
|
// option.text throws exceptions (#14686, #14858)
|
|
jQuery.trim( jQuery.text( elem ) );
|
|
}
|
|
},
|
|
select: {
|
|
get: function( elem ) {
|
|
var value, option,
|
|
options = elem.options,
|
|
index = elem.selectedIndex,
|
|
one = elem.type === "select-one" || index < 0,
|
|
values = one ? null : [],
|
|
max = one ? index + 1 : options.length,
|
|
i = index < 0 ?
|
|
max :
|
|
one ? index : 0;
|
|
|
|
// Loop through all the selected options
|
|
for ( ; i < max; i++ ) {
|
|
option = options[ i ];
|
|
|
|
// IE6-9 doesn't update selected after form reset (#2551)
|
|
if ( ( option.selected || i === index ) &&
|
|
// Don't return options that are disabled or in a disabled optgroup
|
|
( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
|
|
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
|
|
|
// Get the specific value for the option
|
|
value = jQuery( option ).val();
|
|
|
|
// We don't need an array for one selects
|
|
if ( one ) {
|
|
return value;
|
|
}
|
|
|
|
// Multi-Selects return an array
|
|
values.push( value );
|
|
}
|
|
}
|
|
|
|
return values;
|
|
},
|
|
|
|
set: function( elem, value ) {
|
|
var optionSet, option,
|
|
options = elem.options,
|
|
values = jQuery.makeArray( value ),
|
|
i = options.length;
|
|
|
|
while ( i-- ) {
|
|
option = options[ i ];
|
|
if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
|
|
optionSet = true;
|
|
}
|
|
}
|
|
|
|
// Force browsers to behave consistently when non-matching value is set
|
|
if ( !optionSet ) {
|
|
elem.selectedIndex = -1;
|
|
}
|
|
return values;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// Radios and checkboxes getter/setter
|
|
jQuery.each([ "radio", "checkbox" ], function() {
|
|
jQuery.valHooks[ this ] = {
|
|
set: function( elem, value ) {
|
|
if ( jQuery.isArray( value ) ) {
|
|
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
|
}
|
|
}
|
|
};
|
|
if ( !support.checkOn ) {
|
|
jQuery.valHooks[ this ].get = function( elem ) {
|
|
return elem.getAttribute("value") === null ? "on" : elem.value;
|
|
};
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
// Return jQuery for attributes-only inclusion
|
|
|
|
|
|
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
|
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
|
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
|
|
|
// Handle event binding
|
|
jQuery.fn[ name ] = function( data, fn ) {
|
|
return arguments.length > 0 ?
|
|
this.on( name, null, data, fn ) :
|
|
this.trigger( name );
|
|
};
|
|
});
|
|
|
|
jQuery.fn.extend({
|
|
hover: function( fnOver, fnOut ) {
|
|
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
|
},
|
|
|
|
bind: function( types, data, fn ) {
|
|
return this.on( types, null, data, fn );
|
|
},
|
|
unbind: function( types, fn ) {
|
|
return this.off( types, null, fn );
|
|
},
|
|
|
|
delegate: function( selector, types, data, fn ) {
|
|
return this.on( types, selector, data, fn );
|
|
},
|
|
undelegate: function( selector, types, fn ) {
|
|
// ( namespace ) or ( selector, types [, fn] )
|
|
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
|
|
}
|
|
});
|
|
|
|
|
|
var nonce = jQuery.now();
|
|
|
|
var rquery = (/\?/);
|
|
|
|
|
|
|
|
// Support: Android 2.3
|
|
// Workaround failure to string-cast null input
|
|
jQuery.parseJSON = function( data ) {
|
|
return JSON.parse( data + "" );
|
|
};
|
|
|
|
|
|
// Cross-browser xml parsing
|
|
jQuery.parseXML = function( data ) {
|
|
var xml, tmp;
|
|
if ( !data || typeof data !== "string" ) {
|
|
return null;
|
|
}
|
|
|
|
// Support: IE9
|
|
try {
|
|
tmp = new DOMParser();
|
|
xml = tmp.parseFromString( data, "text/xml" );
|
|
} catch ( e ) {
|
|
xml = undefined;
|
|
}
|
|
|
|
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
|
|
jQuery.error( "Invalid XML: " + data );
|
|
}
|
|
return xml;
|
|
};
|
|
|
|
|
|
var
|
|
rhash = /#.*$/,
|
|
rts = /([?&])_=[^&]*/,
|
|
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
|
|
// #7653, #8125, #8152: local protocol detection
|
|
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
|
rnoContent = /^(?:GET|HEAD)$/,
|
|
rprotocol = /^\/\//,
|
|
rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
|
|
|
|
/* Prefilters
|
|
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
|
* 2) These are called:
|
|
* - BEFORE asking for a transport
|
|
* - AFTER param serialization (s.data is a string if s.processData is true)
|
|
* 3) key is the dataType
|
|
* 4) the catchall symbol "*" can be used
|
|
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
|
*/
|
|
prefilters = {},
|
|
|
|
/* Transports bindings
|
|
* 1) key is the dataType
|
|
* 2) the catchall symbol "*" can be used
|
|
* 3) selection will start with transport dataType and THEN go to "*" if needed
|
|
*/
|
|
transports = {},
|
|
|
|
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
|
allTypes = "*/".concat( "*" ),
|
|
|
|
// Document location
|
|
ajaxLocation = window.location.href,
|
|
|
|
// Segment location into parts
|
|
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
|
|
|
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
|
function addToPrefiltersOrTransports( structure ) {
|
|
|
|
// dataTypeExpression is optional and defaults to "*"
|
|
return function( dataTypeExpression, func ) {
|
|
|
|
if ( typeof dataTypeExpression !== "string" ) {
|
|
func = dataTypeExpression;
|
|
dataTypeExpression = "*";
|
|
}
|
|
|
|
var dataType,
|
|
i = 0,
|
|
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
|
|
|
|
if ( jQuery.isFunction( func ) ) {
|
|
// For each dataType in the dataTypeExpression
|
|
while ( (dataType = dataTypes[i++]) ) {
|
|
// Prepend if requested
|
|
if ( dataType[0] === "+" ) {
|
|
dataType = dataType.slice( 1 ) || "*";
|
|
(structure[ dataType ] = structure[ dataType ] || []).unshift( func );
|
|
|
|
// Otherwise append
|
|
} else {
|
|
(structure[ dataType ] = structure[ dataType ] || []).push( func );
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// Base inspection function for prefilters and transports
|
|
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
|
|
|
|
var inspected = {},
|
|
seekingTransport = ( structure === transports );
|
|
|
|
function inspect( dataType ) {
|
|
var selected;
|
|
inspected[ dataType ] = true;
|
|
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
|
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
|
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
|
options.dataTypes.unshift( dataTypeOrTransport );
|
|
inspect( dataTypeOrTransport );
|
|
return false;
|
|
} else if ( seekingTransport ) {
|
|
return !( selected = dataTypeOrTransport );
|
|
}
|
|
});
|
|
return selected;
|
|
}
|
|
|
|
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
|
|
}
|
|
|
|
// A special extend for ajax options
|
|
// that takes "flat" options (not to be deep extended)
|
|
// Fixes #9887
|
|
function ajaxExtend( target, src ) {
|
|
var key, deep,
|
|
flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
|
|
|
for ( key in src ) {
|
|
if ( src[ key ] !== undefined ) {
|
|
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
|
|
}
|
|
}
|
|
if ( deep ) {
|
|
jQuery.extend( true, target, deep );
|
|
}
|
|
|
|
return target;
|
|
}
|
|
|
|
/* Handles responses to an ajax request:
|
|
* - finds the right dataType (mediates between content-type and expected dataType)
|
|
* - returns the corresponding response
|
|
*/
|
|
function ajaxHandleResponses( s, jqXHR, responses ) {
|
|
|
|
var ct, type, finalDataType, firstDataType,
|
|
contents = s.contents,
|
|
dataTypes = s.dataTypes;
|
|
|
|
// Remove auto dataType and get content-type in the process
|
|
while ( dataTypes[ 0 ] === "*" ) {
|
|
dataTypes.shift();
|
|
if ( ct === undefined ) {
|
|
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
|
|
}
|
|
}
|
|
|
|
// Check if we're dealing with a known content-type
|
|
if ( ct ) {
|
|
for ( type in contents ) {
|
|
if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
|
dataTypes.unshift( type );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Check to see if we have a response for the expected dataType
|
|
if ( dataTypes[ 0 ] in responses ) {
|
|
finalDataType = dataTypes[ 0 ];
|
|
} else {
|
|
// Try convertible dataTypes
|
|
for ( type in responses ) {
|
|
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
|
finalDataType = type;
|
|
break;
|
|
}
|
|
if ( !firstDataType ) {
|
|
firstDataType = type;
|
|
}
|
|
}
|
|
// Or just use first one
|
|
finalDataType = finalDataType || firstDataType;
|
|
}
|
|
|
|
// If we found a dataType
|
|
// We add the dataType to the list if needed
|
|
// and return the corresponding response
|
|
if ( finalDataType ) {
|
|
if ( finalDataType !== dataTypes[ 0 ] ) {
|
|
dataTypes.unshift( finalDataType );
|
|
}
|
|
return responses[ finalDataType ];
|
|
}
|
|
}
|
|
|
|
/* Chain conversions given the request and the original response
|
|
* Also sets the responseXXX fields on the jqXHR instance
|
|
*/
|
|
function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
|
var conv2, current, conv, tmp, prev,
|
|
converters = {},
|
|
// Work with a copy of dataTypes in case we need to modify it for conversion
|
|
dataTypes = s.dataTypes.slice();
|
|
|
|
// Create converters map with lowercased keys
|
|
if ( dataTypes[ 1 ] ) {
|
|
for ( conv in s.converters ) {
|
|
converters[ conv.toLowerCase() ] = s.converters[ conv ];
|
|
}
|
|
}
|
|
|
|
current = dataTypes.shift();
|
|
|
|
// Convert to each sequential dataType
|
|
while ( current ) {
|
|
|
|
if ( s.responseFields[ current ] ) {
|
|
jqXHR[ s.responseFields[ current ] ] = response;
|
|
}
|
|
|
|
// Apply the dataFilter if provided
|
|
if ( !prev && isSuccess && s.dataFilter ) {
|
|
response = s.dataFilter( response, s.dataType );
|
|
}
|
|
|
|
prev = current;
|
|
current = dataTypes.shift();
|
|
|
|
if ( current ) {
|
|
|
|
// There's only work to do if current dataType is non-auto
|
|
if ( current === "*" ) {
|
|
|
|
current = prev;
|
|
|
|
// Convert response if prev dataType is non-auto and differs from current
|
|
} else if ( prev !== "*" && prev !== current ) {
|
|
|
|
// Seek a direct converter
|
|
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
|
|
|
|
// If none found, seek a pair
|
|
if ( !conv ) {
|
|
for ( conv2 in converters ) {
|
|
|
|
// If conv2 outputs current
|
|
tmp = conv2.split( " " );
|
|
if ( tmp[ 1 ] === current ) {
|
|
|
|
// If prev can be converted to accepted input
|
|
conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
|
converters[ "* " + tmp[ 0 ] ];
|
|
if ( conv ) {
|
|
// Condense equivalence converters
|
|
if ( conv === true ) {
|
|
conv = converters[ conv2 ];
|
|
|
|
// Otherwise, insert the intermediate dataType
|
|
} else if ( converters[ conv2 ] !== true ) {
|
|
current = tmp[ 0 ];
|
|
dataTypes.unshift( tmp[ 1 ] );
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Apply converter (if not an equivalence)
|
|
if ( conv !== true ) {
|
|
|
|
// Unless errors are allowed to bubble, catch and return them
|
|
if ( conv && s[ "throws" ] ) {
|
|
response = conv( response );
|
|
} else {
|
|
try {
|
|
response = conv( response );
|
|
} catch ( e ) {
|
|
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return { state: "success", data: response };
|
|
}
|
|
|
|
jQuery.extend({
|
|
|
|
// Counter for holding the number of active queries
|
|
active: 0,
|
|
|
|
// Last-Modified header cache for next request
|
|
lastModified: {},
|
|
etag: {},
|
|
|
|
ajaxSettings: {
|
|
url: ajaxLocation,
|
|
type: "GET",
|
|
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
|
global: true,
|
|
processData: true,
|
|
async: true,
|
|
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
|
/*
|
|
timeout: 0,
|
|
data: null,
|
|
dataType: null,
|
|
username: null,
|
|
password: null,
|
|
cache: null,
|
|
throws: false,
|
|
traditional: false,
|
|
headers: {},
|
|
*/
|
|
|
|
accepts: {
|
|
"*": allTypes,
|
|
text: "text/plain",
|
|
html: "text/html",
|
|
xml: "application/xml, text/xml",
|
|
json: "application/json, text/javascript"
|
|
},
|
|
|
|
contents: {
|
|
xml: /xml/,
|
|
html: /html/,
|
|
json: /json/
|
|
},
|
|
|
|
responseFields: {
|
|
xml: "responseXML",
|
|
text: "responseText",
|
|
json: "responseJSON"
|
|
},
|
|
|
|
// Data converters
|
|
// Keys separate source (or catchall "*") and destination types with a single space
|
|
converters: {
|
|
|
|
// Convert anything to text
|
|
"* text": String,
|
|
|
|
// Text to html (true = no transformation)
|
|
"text html": true,
|
|
|
|
// Evaluate text as a json expression
|
|
"text json": jQuery.parseJSON,
|
|
|
|
// Parse text as xml
|
|
"text xml": jQuery.parseXML
|
|
},
|
|
|
|
// For options that shouldn't be deep extended:
|
|
// you can add your own custom options here if
|
|
// and when you create one that shouldn't be
|
|
// deep extended (see ajaxExtend)
|
|
flatOptions: {
|
|
url: true,
|
|
context: true
|
|
}
|
|
},
|
|
|
|
// Creates a full fledged settings object into target
|
|
// with both ajaxSettings and settings fields.
|
|
// If target is omitted, writes into ajaxSettings.
|
|
ajaxSetup: function( target, settings ) {
|
|
return settings ?
|
|
|
|
// Building a settings object
|
|
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
|
|
|
|
// Extending ajaxSettings
|
|
ajaxExtend( jQuery.ajaxSettings, target );
|
|
},
|
|
|
|
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
|
ajaxTransport: addToPrefiltersOrTransports( transports ),
|
|
|
|
// Main method
|
|
ajax: function( url, options ) {
|
|
|
|
// If url is an object, simulate pre-1.5 signature
|
|
if ( typeof url === "object" ) {
|
|
options = url;
|
|
url = undefined;
|
|
}
|
|
|
|
// Force options to be an object
|
|
options = options || {};
|
|
|
|
var transport,
|
|
// URL without anti-cache param
|
|
cacheURL,
|
|
// Response headers
|
|
responseHeadersString,
|
|
responseHeaders,
|
|
// timeout handle
|
|
timeoutTimer,
|
|
// Cross-domain detection vars
|
|
parts,
|
|
// To know if global events are to be dispatched
|
|
fireGlobals,
|
|
// Loop variable
|
|
i,
|
|
// Create the final options object
|
|
s = jQuery.ajaxSetup( {}, options ),
|
|
// Callbacks context
|
|
callbackContext = s.context || s,
|
|
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
|
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
|
jQuery( callbackContext ) :
|
|
jQuery.event,
|
|
// Deferreds
|
|
deferred = jQuery.Deferred(),
|
|
completeDeferred = jQuery.Callbacks("once memory"),
|
|
// Status-dependent callbacks
|
|
statusCode = s.statusCode || {},
|
|
// Headers (they are sent all at once)
|
|
requestHeaders = {},
|
|
requestHeadersNames = {},
|
|
// The jqXHR state
|
|
state = 0,
|
|
// Default abort message
|
|
strAbort = "canceled",
|
|
// Fake xhr
|
|
jqXHR = {
|
|
readyState: 0,
|
|
|
|
// Builds headers hashtable if needed
|
|
getResponseHeader: function( key ) {
|
|
var match;
|
|
if ( state === 2 ) {
|
|
if ( !responseHeaders ) {
|
|
responseHeaders = {};
|
|
while ( (match = rheaders.exec( responseHeadersString )) ) {
|
|
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
|
}
|
|
}
|
|
match = responseHeaders[ key.toLowerCase() ];
|
|
}
|
|
return match == null ? null : match;
|
|
},
|
|
|
|
// Raw string
|
|
getAllResponseHeaders: function() {
|
|
return state === 2 ? responseHeadersString : null;
|
|
},
|
|
|
|
// Caches the header
|
|
setRequestHeader: function( name, value ) {
|
|
var lname = name.toLowerCase();
|
|
if ( !state ) {
|
|
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
|
requestHeaders[ name ] = value;
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// Overrides response content-type header
|
|
overrideMimeType: function( type ) {
|
|
if ( !state ) {
|
|
s.mimeType = type;
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// Status-dependent callbacks
|
|
statusCode: function( map ) {
|
|
var code;
|
|
if ( map ) {
|
|
if ( state < 2 ) {
|
|
for ( code in map ) {
|
|
// Lazy-add the new callback in a way that preserves old ones
|
|
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
|
}
|
|
} else {
|
|
// Execute the appropriate callbacks
|
|
jqXHR.always( map[ jqXHR.status ] );
|
|
}
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// Cancel the request
|
|
abort: function( statusText ) {
|
|
var finalText = statusText || strAbort;
|
|
if ( transport ) {
|
|
transport.abort( finalText );
|
|
}
|
|
done( 0, finalText );
|
|
return this;
|
|
}
|
|
};
|
|
|
|
// Attach deferreds
|
|
deferred.promise( jqXHR ).complete = completeDeferred.add;
|
|
jqXHR.success = jqXHR.done;
|
|
jqXHR.error = jqXHR.fail;
|
|
|
|
// Remove hash character (#7531: and string promotion)
|
|
// Add protocol if not provided (prefilters might expect it)
|
|
// Handle falsy url in the settings object (#10093: consistency with old signature)
|
|
// We also use the url parameter if available
|
|
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
|
|
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
|
|
|
// Alias method option to type as per ticket #12004
|
|
s.type = options.method || options.type || s.method || s.type;
|
|
|
|
// Extract dataTypes list
|
|
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
|
|
|
|
// A cross-domain request is in order when we have a protocol:host:port mismatch
|
|
if ( s.crossDomain == null ) {
|
|
parts = rurl.exec( s.url.toLowerCase() );
|
|
s.crossDomain = !!( parts &&
|
|
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
|
|
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
|
|
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
|
|
);
|
|
}
|
|
|
|
// Convert data if not already a string
|
|
if ( s.data && s.processData && typeof s.data !== "string" ) {
|
|
s.data = jQuery.param( s.data, s.traditional );
|
|
}
|
|
|
|
// Apply prefilters
|
|
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
|
|
|
// If request was aborted inside a prefilter, stop there
|
|
if ( state === 2 ) {
|
|
return jqXHR;
|
|
}
|
|
|
|
// We can fire global events as of now if asked to
|
|
// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
|
|
fireGlobals = jQuery.event && s.global;
|
|
|
|
// Watch for a new set of requests
|
|
if ( fireGlobals && jQuery.active++ === 0 ) {
|
|
jQuery.event.trigger("ajaxStart");
|
|
}
|
|
|
|
// Uppercase the type
|
|
s.type = s.type.toUpperCase();
|
|
|
|
// Determine if request has content
|
|
s.hasContent = !rnoContent.test( s.type );
|
|
|
|
// Save the URL in case we're toying with the If-Modified-Since
|
|
// and/or If-None-Match header later on
|
|
cacheURL = s.url;
|
|
|
|
// More options handling for requests with no content
|
|
if ( !s.hasContent ) {
|
|
|
|
// If data is available, append data to url
|
|
if ( s.data ) {
|
|
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
|
// #9682: remove data so that it's not used in an eventual retry
|
|
delete s.data;
|
|
}
|
|
|
|
// Add anti-cache in url if needed
|
|
if ( s.cache === false ) {
|
|
s.url = rts.test( cacheURL ) ?
|
|
|
|
// If there is already a '_' parameter, set its value
|
|
cacheURL.replace( rts, "$1_=" + nonce++ ) :
|
|
|
|
// Otherwise add one to the end
|
|
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
|
|
}
|
|
}
|
|
|
|
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
if ( s.ifModified ) {
|
|
if ( jQuery.lastModified[ cacheURL ] ) {
|
|
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
|
|
}
|
|
if ( jQuery.etag[ cacheURL ] ) {
|
|
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
|
|
}
|
|
}
|
|
|
|
// Set the correct header, if data is being sent
|
|
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
|
jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
|
}
|
|
|
|
// Set the Accepts header for the server, depending on the dataType
|
|
jqXHR.setRequestHeader(
|
|
"Accept",
|
|
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
|
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
|
s.accepts[ "*" ]
|
|
);
|
|
|
|
// Check for headers option
|
|
for ( i in s.headers ) {
|
|
jqXHR.setRequestHeader( i, s.headers[ i ] );
|
|
}
|
|
|
|
// Allow custom headers/mimetypes and early abort
|
|
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
|
// Abort if not done already and return
|
|
return jqXHR.abort();
|
|
}
|
|
|
|
// Aborting is no longer a cancellation
|
|
strAbort = "abort";
|
|
|
|
// Install callbacks on deferreds
|
|
for ( i in { success: 1, error: 1, complete: 1 } ) {
|
|
jqXHR[ i ]( s[ i ] );
|
|
}
|
|
|
|
// Get transport
|
|
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
|
|
|
// If no transport, we auto-abort
|
|
if ( !transport ) {
|
|
done( -1, "No Transport" );
|
|
} else {
|
|
jqXHR.readyState = 1;
|
|
|
|
// Send global event
|
|
if ( fireGlobals ) {
|
|
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
|
}
|
|
// Timeout
|
|
if ( s.async && s.timeout > 0 ) {
|
|
timeoutTimer = setTimeout(function() {
|
|
jqXHR.abort("timeout");
|
|
}, s.timeout );
|
|
}
|
|
|
|
try {
|
|
state = 1;
|
|
transport.send( requestHeaders, done );
|
|
} catch ( e ) {
|
|
// Propagate exception as error if not done
|
|
if ( state < 2 ) {
|
|
done( -1, e );
|
|
// Simply rethrow otherwise
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Callback for when everything is done
|
|
function done( status, nativeStatusText, responses, headers ) {
|
|
var isSuccess, success, error, response, modified,
|
|
statusText = nativeStatusText;
|
|
|
|
// Called once
|
|
if ( state === 2 ) {
|
|
return;
|
|
}
|
|
|
|
// State is "done" now
|
|
state = 2;
|
|
|
|
// Clear timeout if it exists
|
|
if ( timeoutTimer ) {
|
|
clearTimeout( timeoutTimer );
|
|
}
|
|
|
|
// Dereference transport for early garbage collection
|
|
// (no matter how long the jqXHR object will be used)
|
|
transport = undefined;
|
|
|
|
// Cache response headers
|
|
responseHeadersString = headers || "";
|
|
|
|
// Set readyState
|
|
jqXHR.readyState = status > 0 ? 4 : 0;
|
|
|
|
// Determine if successful
|
|
isSuccess = status >= 200 && status < 300 || status === 304;
|
|
|
|
// Get response data
|
|
if ( responses ) {
|
|
response = ajaxHandleResponses( s, jqXHR, responses );
|
|
}
|
|
|
|
// Convert no matter what (that way responseXXX fields are always set)
|
|
response = ajaxConvert( s, response, jqXHR, isSuccess );
|
|
|
|
// If successful, handle type chaining
|
|
if ( isSuccess ) {
|
|
|
|
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
|
if ( s.ifModified ) {
|
|
modified = jqXHR.getResponseHeader("Last-Modified");
|
|
if ( modified ) {
|
|
jQuery.lastModified[ cacheURL ] = modified;
|
|
}
|
|
modified = jqXHR.getResponseHeader("etag");
|
|
if ( modified ) {
|
|
jQuery.etag[ cacheURL ] = modified;
|
|
}
|
|
}
|
|
|
|
// if no content
|
|
if ( status === 204 || s.type === "HEAD" ) {
|
|
statusText = "nocontent";
|
|
|
|
// if not modified
|
|
} else if ( status === 304 ) {
|
|
statusText = "notmodified";
|
|
|
|
// If we have data, let's convert it
|
|
} else {
|
|
statusText = response.state;
|
|
success = response.data;
|
|
error = response.error;
|
|
isSuccess = !error;
|
|
}
|
|
} else {
|
|
// Extract error from statusText and normalize for non-aborts
|
|
error = statusText;
|
|
if ( status || !statusText ) {
|
|
statusText = "error";
|
|
if ( status < 0 ) {
|
|
status = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Set data for the fake xhr object
|
|
jqXHR.status = status;
|
|
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
|
|
|
|
// Success/Error
|
|
if ( isSuccess ) {
|
|
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
|
} else {
|
|
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
|
}
|
|
|
|
// Status-dependent callbacks
|
|
jqXHR.statusCode( statusCode );
|
|
statusCode = undefined;
|
|
|
|
if ( fireGlobals ) {
|
|
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
|
|
[ jqXHR, s, isSuccess ? success : error ] );
|
|
}
|
|
|
|
// Complete
|
|
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
|
|
|
if ( fireGlobals ) {
|
|
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
|
// Handle the global AJAX counter
|
|
if ( !( --jQuery.active ) ) {
|
|
jQuery.event.trigger("ajaxStop");
|
|
}
|
|
}
|
|
}
|
|
|
|
return jqXHR;
|
|
},
|
|
|
|
getJSON: function( url, data, callback ) {
|
|
return jQuery.get( url, data, callback, "json" );
|
|
},
|
|
|
|
getScript: function( url, callback ) {
|
|
return jQuery.get( url, undefined, callback, "script" );
|
|
}
|
|
});
|
|
|
|
jQuery.each( [ "get", "post" ], function( i, method ) {
|
|
jQuery[ method ] = function( url, data, callback, type ) {
|
|
// Shift arguments if data argument was omitted
|
|
if ( jQuery.isFunction( data ) ) {
|
|
type = type || callback;
|
|
callback = data;
|
|
data = undefined;
|
|
}
|
|
|
|
return jQuery.ajax({
|
|
url: url,
|
|
type: method,
|
|
dataType: type,
|
|
data: data,
|
|
success: callback
|
|
});
|
|
};
|
|
});
|
|
|
|
|
|
jQuery._evalUrl = function( url ) {
|
|
return jQuery.ajax({
|
|
url: url,
|
|
type: "GET",
|
|
dataType: "script",
|
|
async: false,
|
|
global: false,
|
|
"throws": true
|
|
});
|
|
};
|
|
|
|
|
|
jQuery.fn.extend({
|
|
wrapAll: function( html ) {
|
|
var wrap;
|
|
|
|
if ( jQuery.isFunction( html ) ) {
|
|
return this.each(function( i ) {
|
|
jQuery( this ).wrapAll( html.call(this, i) );
|
|
});
|
|
}
|
|
|
|
if ( this[ 0 ] ) {
|
|
|
|
// The elements to wrap the target around
|
|
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
|
|
|
|
if ( this[ 0 ].parentNode ) {
|
|
wrap.insertBefore( this[ 0 ] );
|
|
}
|
|
|
|
wrap.map(function() {
|
|
var elem = this;
|
|
|
|
while ( elem.firstElementChild ) {
|
|
elem = elem.firstElementChild;
|
|
}
|
|
|
|
return elem;
|
|
}).append( this );
|
|
}
|
|
|
|
return this;
|
|
},
|
|
|
|
wrapInner: function( html ) {
|
|
if ( jQuery.isFunction( html ) ) {
|
|
return this.each(function( i ) {
|
|
jQuery( this ).wrapInner( html.call(this, i) );
|
|
});
|
|
}
|
|
|
|
return this.each(function() {
|
|
var self = jQuery( this ),
|
|
contents = self.contents();
|
|
|
|
if ( contents.length ) {
|
|
contents.wrapAll( html );
|
|
|
|
} else {
|
|
self.append( html );
|
|
}
|
|
});
|
|
},
|
|
|
|
wrap: function( html ) {
|
|
var isFunction = jQuery.isFunction( html );
|
|
|
|
return this.each(function( i ) {
|
|
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
|
|
});
|
|
},
|
|
|
|
unwrap: function() {
|
|
return this.parent().each(function() {
|
|
if ( !jQuery.nodeName( this, "body" ) ) {
|
|
jQuery( this ).replaceWith( this.childNodes );
|
|
}
|
|
}).end();
|
|
}
|
|
});
|
|
|
|
|
|
jQuery.expr.filters.hidden = function( elem ) {
|
|
// Support: Opera <= 12.12
|
|
// Opera reports offsetWidths and offsetHeights less than zero on some elements
|
|
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
|
|
};
|
|
jQuery.expr.filters.visible = function( elem ) {
|
|
return !jQuery.expr.filters.hidden( elem );
|
|
};
|
|
|
|
|
|
|
|
|
|
var r20 = /%20/g,
|
|
rbracket = /\[\]$/,
|
|
rCRLF = /\r?\n/g,
|
|
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
|
|
rsubmittable = /^(?:input|select|textarea|keygen)/i;
|
|
|
|
function buildParams( prefix, obj, traditional, add ) {
|
|
var name;
|
|
|
|
if ( jQuery.isArray( obj ) ) {
|
|
// Serialize array item.
|
|
jQuery.each( obj, function( i, v ) {
|
|
if ( traditional || rbracket.test( prefix ) ) {
|
|
// Treat each array item as a scalar.
|
|
add( prefix, v );
|
|
|
|
} else {
|
|
// Item is non-scalar (array or object), encode its numeric index.
|
|
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
|
|
}
|
|
});
|
|
|
|
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
|
|
// Serialize object item.
|
|
for ( name in obj ) {
|
|
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
|
}
|
|
|
|
} else {
|
|
// Serialize scalar item.
|
|
add( prefix, obj );
|
|
}
|
|
}
|
|
|
|
// Serialize an array of form elements or a set of
|
|
// key/values into a query string
|
|
jQuery.param = function( a, traditional ) {
|
|
var prefix,
|
|
s = [],
|
|
add = function( key, value ) {
|
|
// If value is a function, invoke it and return its value
|
|
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
|
|
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
|
|
};
|
|
|
|
// Set traditional to true for jQuery <= 1.3.2 behavior.
|
|
if ( traditional === undefined ) {
|
|
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
|
|
}
|
|
|
|
// If an array was passed in, assume that it is an array of form elements.
|
|
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
|
// Serialize the form elements
|
|
jQuery.each( a, function() {
|
|
add( this.name, this.value );
|
|
});
|
|
|
|
} else {
|
|
// If traditional, encode the "old" way (the way 1.3.2 or older
|
|
// did it), otherwise encode params recursively.
|
|
for ( prefix in a ) {
|
|
buildParams( prefix, a[ prefix ], traditional, add );
|
|
}
|
|
}
|
|
|
|
// Return the resulting serialization
|
|
return s.join( "&" ).replace( r20, "+" );
|
|
};
|
|
|
|
jQuery.fn.extend({
|
|
serialize: function() {
|
|
return jQuery.param( this.serializeArray() );
|
|
},
|
|
serializeArray: function() {
|
|
return this.map(function() {
|
|
// Can add propHook for "elements" to filter or add form elements
|
|
var elements = jQuery.prop( this, "elements" );
|
|
return elements ? jQuery.makeArray( elements ) : this;
|
|
})
|
|
.filter(function() {
|
|
var type = this.type;
|
|
|
|
// Use .is( ":disabled" ) so that fieldset[disabled] works
|
|
return this.name && !jQuery( this ).is( ":disabled" ) &&
|
|
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
|
( this.checked || !rcheckableType.test( type ) );
|
|
})
|
|
.map(function( i, elem ) {
|
|
var val = jQuery( this ).val();
|
|
|
|
return val == null ?
|
|
null :
|
|
jQuery.isArray( val ) ?
|
|
jQuery.map( val, function( val ) {
|
|
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
}) :
|
|
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
|
}).get();
|
|
}
|
|
});
|
|
|
|
|
|
jQuery.ajaxSettings.xhr = function() {
|
|
try {
|
|
return new XMLHttpRequest();
|
|
} catch( e ) {}
|
|
};
|
|
|
|
var xhrId = 0,
|
|
xhrCallbacks = {},
|
|
xhrSuccessStatus = {
|
|
// file protocol always yields status code 0, assume 200
|
|
0: 200,
|
|
// Support: IE9
|
|
// #1450: sometimes IE returns 1223 when it should be 204
|
|
1223: 204
|
|
},
|
|
xhrSupported = jQuery.ajaxSettings.xhr();
|
|
|
|
// Support: IE9
|
|
// Open requests must be manually aborted on unload (#5280)
|
|
// See https://support.microsoft.com/kb/2856746 for more info
|
|
if ( window.attachEvent ) {
|
|
window.attachEvent( "onunload", function() {
|
|
for ( var key in xhrCallbacks ) {
|
|
xhrCallbacks[ key ]();
|
|
}
|
|
});
|
|
}
|
|
|
|
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
|
|
support.ajax = xhrSupported = !!xhrSupported;
|
|
|
|
jQuery.ajaxTransport(function( options ) {
|
|
var callback;
|
|
|
|
// Cross domain only allowed if supported through XMLHttpRequest
|
|
if ( support.cors || xhrSupported && !options.crossDomain ) {
|
|
return {
|
|
send: function( headers, complete ) {
|
|
var i,
|
|
xhr = options.xhr(),
|
|
id = ++xhrId;
|
|
|
|
xhr.open( options.type, options.url, options.async, options.username, options.password );
|
|
|
|
// Apply custom fields if provided
|
|
if ( options.xhrFields ) {
|
|
for ( i in options.xhrFields ) {
|
|
xhr[ i ] = options.xhrFields[ i ];
|
|
}
|
|
}
|
|
|
|
// Override mime type if needed
|
|
if ( options.mimeType && xhr.overrideMimeType ) {
|
|
xhr.overrideMimeType( options.mimeType );
|
|
}
|
|
|
|
// X-Requested-With header
|
|
// For cross-domain requests, seeing as conditions for a preflight are
|
|
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
|
// (it can always be set on a per-request basis or even using ajaxSetup)
|
|
// For same-domain requests, won't change header if already provided.
|
|
if ( !options.crossDomain && !headers["X-Requested-With"] ) {
|
|
headers["X-Requested-With"] = "XMLHttpRequest";
|
|
}
|
|
|
|
// Set headers
|
|
for ( i in headers ) {
|
|
xhr.setRequestHeader( i, headers[ i ] );
|
|
}
|
|
|
|
// Callback
|
|
callback = function( type ) {
|
|
return function() {
|
|
if ( callback ) {
|
|
delete xhrCallbacks[ id ];
|
|
callback = xhr.onload = xhr.onerror = null;
|
|
|
|
if ( type === "abort" ) {
|
|
xhr.abort();
|
|
} else if ( type === "error" ) {
|
|
complete(
|
|
// file: protocol always yields status 0; see #8605, #14207
|
|
xhr.status,
|
|
xhr.statusText
|
|
);
|
|
} else {
|
|
complete(
|
|
xhrSuccessStatus[ xhr.status ] || xhr.status,
|
|
xhr.statusText,
|
|
// Support: IE9
|
|
// Accessing binary-data responseText throws an exception
|
|
// (#11426)
|
|
typeof xhr.responseText === "string" ? {
|
|
text: xhr.responseText
|
|
} : undefined,
|
|
xhr.getAllResponseHeaders()
|
|
);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
// Listen to events
|
|
xhr.onload = callback();
|
|
xhr.onerror = callback("error");
|
|
|
|
// Create the abort callback
|
|
callback = xhrCallbacks[ id ] = callback("abort");
|
|
|
|
try {
|
|
// Do send the request (this may raise an exception)
|
|
xhr.send( options.hasContent && options.data || null );
|
|
} catch ( e ) {
|
|
// #14683: Only rethrow if this hasn't been notified as an error yet
|
|
if ( callback ) {
|
|
throw e;
|
|
}
|
|
}
|
|
},
|
|
|
|
abort: function() {
|
|
if ( callback ) {
|
|
callback();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
// Install script dataType
|
|
jQuery.ajaxSetup({
|
|
accepts: {
|
|
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
|
},
|
|
contents: {
|
|
script: /(?:java|ecma)script/
|
|
},
|
|
converters: {
|
|
"text script": function( text ) {
|
|
jQuery.globalEval( text );
|
|
return text;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Handle cache's special case and crossDomain
|
|
jQuery.ajaxPrefilter( "script", function( s ) {
|
|
if ( s.cache === undefined ) {
|
|
s.cache = false;
|
|
}
|
|
if ( s.crossDomain ) {
|
|
s.type = "GET";
|
|
}
|
|
});
|
|
|
|
// Bind script tag hack transport
|
|
jQuery.ajaxTransport( "script", function( s ) {
|
|
// This transport only deals with cross domain requests
|
|
if ( s.crossDomain ) {
|
|
var script, callback;
|
|
return {
|
|
send: function( _, complete ) {
|
|
script = jQuery("<script>").prop({
|
|
async: true,
|
|
charset: s.scriptCharset,
|
|
src: s.url
|
|
}).on(
|
|
"load error",
|
|
callback = function( evt ) {
|
|
script.remove();
|
|
callback = null;
|
|
if ( evt ) {
|
|
complete( evt.type === "error" ? 404 : 200, evt.type );
|
|
}
|
|
}
|
|
);
|
|
document.head.appendChild( script[ 0 ] );
|
|
},
|
|
abort: function() {
|
|
if ( callback ) {
|
|
callback();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
var oldCallbacks = [],
|
|
rjsonp = /(=)\?(?=&|$)|\?\?/;
|
|
|
|
// Default jsonp settings
|
|
jQuery.ajaxSetup({
|
|
jsonp: "callback",
|
|
jsonpCallback: function() {
|
|
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
|
|
this[ callback ] = true;
|
|
return callback;
|
|
}
|
|
});
|
|
|
|
// Detect, normalize options and install callbacks for jsonp requests
|
|
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|
|
|
var callbackName, overwritten, responseContainer,
|
|
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
|
"url" :
|
|
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
|
);
|
|
|
|
// Handle iff the expected data type is "jsonp" or we have a parameter to set
|
|
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
|
|
|
|
// Get callback name, remembering preexisting value associated with it
|
|
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
|
|
s.jsonpCallback() :
|
|
s.jsonpCallback;
|
|
|
|
// Insert callback into url or form data
|
|
if ( jsonProp ) {
|
|
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
|
|
} else if ( s.jsonp !== false ) {
|
|
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
|
}
|
|
|
|
// Use data converter to retrieve json after script execution
|
|
s.converters["script json"] = function() {
|
|
if ( !responseContainer ) {
|
|
jQuery.error( callbackName + " was not called" );
|
|
}
|
|
return responseContainer[ 0 ];
|
|
};
|
|
|
|
// force json dataType
|
|
s.dataTypes[ 0 ] = "json";
|
|
|
|
// Install callback
|
|
overwritten = window[ callbackName ];
|
|
window[ callbackName ] = function() {
|
|
responseContainer = arguments;
|
|
};
|
|
|
|
// Clean-up function (fires after converters)
|
|
jqXHR.always(function() {
|
|
// Restore preexisting value
|
|
window[ callbackName ] = overwritten;
|
|
|
|
// Save back as free
|
|
if ( s[ callbackName ] ) {
|
|
// make sure that re-using the options doesn't screw things around
|
|
s.jsonpCallback = originalSettings.jsonpCallback;
|
|
|
|
// save the callback name for future use
|
|
oldCallbacks.push( callbackName );
|
|
}
|
|
|
|
// Call if it was a function and we have a response
|
|
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
|
|
overwritten( responseContainer[ 0 ] );
|
|
}
|
|
|
|
responseContainer = overwritten = undefined;
|
|
});
|
|
|
|
// Delegate to script
|
|
return "script";
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
// data: string of html
|
|
// context (optional): If specified, the fragment will be created in this context, defaults to document
|
|
// keepScripts (optional): If true, will include scripts passed in the html string
|
|
jQuery.parseHTML = function( data, context, keepScripts ) {
|
|
if ( !data || typeof data !== "string" ) {
|
|
return null;
|
|
}
|
|
if ( typeof context === "boolean" ) {
|
|
keepScripts = context;
|
|
context = false;
|
|
}
|
|
context = context || document;
|
|
|
|
var parsed = rsingleTag.exec( data ),
|
|
scripts = !keepScripts && [];
|
|
|
|
// Single tag
|
|
if ( parsed ) {
|
|
return [ context.createElement( parsed[1] ) ];
|
|
}
|
|
|
|
parsed = jQuery.buildFragment( [ data ], context, scripts );
|
|
|
|
if ( scripts && scripts.length ) {
|
|
jQuery( scripts ).remove();
|
|
}
|
|
|
|
return jQuery.merge( [], parsed.childNodes );
|
|
};
|
|
|
|
|
|
// Keep a copy of the old load method
|
|
var _load = jQuery.fn.load;
|
|
|
|
/**
|
|
* Load a url into a page
|
|
*/
|
|
jQuery.fn.load = function( url, params, callback ) {
|
|
if ( typeof url !== "string" && _load ) {
|
|
return _load.apply( this, arguments );
|
|
}
|
|
|
|
var selector, type, response,
|
|
self = this,
|
|
off = url.indexOf(" ");
|
|
|
|
if ( off >= 0 ) {
|
|
selector = jQuery.trim( url.slice( off ) );
|
|
url = url.slice( 0, off );
|
|
}
|
|
|
|
// If it's a function
|
|
if ( jQuery.isFunction( params ) ) {
|
|
|
|
// We assume that it's the callback
|
|
callback = params;
|
|
params = undefined;
|
|
|
|
// Otherwise, build a param string
|
|
} else if ( params && typeof params === "object" ) {
|
|
type = "POST";
|
|
}
|
|
|
|
// If we have elements to modify, make the request
|
|
if ( self.length > 0 ) {
|
|
jQuery.ajax({
|
|
url: url,
|
|
|
|
// if "type" variable is undefined, then "GET" method will be used
|
|
type: type,
|
|
dataType: "html",
|
|
data: params
|
|
}).done(function( responseText ) {
|
|
|
|
// Save response for use in complete callback
|
|
response = arguments;
|
|
|
|
self.html( selector ?
|
|
|
|
// If a selector was specified, locate the right elements in a dummy div
|
|
// Exclude scripts to avoid IE 'Permission Denied' errors
|
|
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
|
|
|
// Otherwise use the full result
|
|
responseText );
|
|
|
|
}).complete( callback && function( jqXHR, status ) {
|
|
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
|
});
|
|
}
|
|
|
|
return this;
|
|
};
|
|
|
|
|
|
|
|
|
|
// Attach a bunch of functions for handling common AJAX events
|
|
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
|
|
jQuery.fn[ type ] = function( fn ) {
|
|
return this.on( type, fn );
|
|
};
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery.expr.filters.animated = function( elem ) {
|
|
return jQuery.grep(jQuery.timers, function( fn ) {
|
|
return elem === fn.elem;
|
|
}).length;
|
|
};
|
|
|
|
|
|
|
|
|
|
var docElem = window.document.documentElement;
|
|
|
|
/**
|
|
* Gets a window from an element
|
|
*/
|
|
function getWindow( elem ) {
|
|
return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
|
|
}
|
|
|
|
jQuery.offset = {
|
|
setOffset: function( elem, options, i ) {
|
|
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
|
|
position = jQuery.css( elem, "position" ),
|
|
curElem = jQuery( elem ),
|
|
props = {};
|
|
|
|
// Set position first, in-case top/left are set even on static elem
|
|
if ( position === "static" ) {
|
|
elem.style.position = "relative";
|
|
}
|
|
|
|
curOffset = curElem.offset();
|
|
curCSSTop = jQuery.css( elem, "top" );
|
|
curCSSLeft = jQuery.css( elem, "left" );
|
|
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
|
|
( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
|
|
|
|
// Need to be able to calculate position if either
|
|
// top or left is auto and position is either absolute or fixed
|
|
if ( calculatePosition ) {
|
|
curPosition = curElem.position();
|
|
curTop = curPosition.top;
|
|
curLeft = curPosition.left;
|
|
|
|
} else {
|
|
curTop = parseFloat( curCSSTop ) || 0;
|
|
curLeft = parseFloat( curCSSLeft ) || 0;
|
|
}
|
|
|
|
if ( jQuery.isFunction( options ) ) {
|
|
options = options.call( elem, i, curOffset );
|
|
}
|
|
|
|
if ( options.top != null ) {
|
|
props.top = ( options.top - curOffset.top ) + curTop;
|
|
}
|
|
if ( options.left != null ) {
|
|
props.left = ( options.left - curOffset.left ) + curLeft;
|
|
}
|
|
|
|
if ( "using" in options ) {
|
|
options.using.call( elem, props );
|
|
|
|
} else {
|
|
curElem.css( props );
|
|
}
|
|
}
|
|
};
|
|
|
|
jQuery.fn.extend({
|
|
offset: function( options ) {
|
|
if ( arguments.length ) {
|
|
return options === undefined ?
|
|
this :
|
|
this.each(function( i ) {
|
|
jQuery.offset.setOffset( this, options, i );
|
|
});
|
|
}
|
|
|
|
var docElem, win,
|
|
elem = this[ 0 ],
|
|
box = { top: 0, left: 0 },
|
|
doc = elem && elem.ownerDocument;
|
|
|
|
if ( !doc ) {
|
|
return;
|
|
}
|
|
|
|
docElem = doc.documentElement;
|
|
|
|
// Make sure it's not a disconnected DOM node
|
|
if ( !jQuery.contains( docElem, elem ) ) {
|
|
return box;
|
|
}
|
|
|
|
// Support: BlackBerry 5, iOS 3 (original iPhone)
|
|
// If we don't have gBCR, just use 0,0 rather than error
|
|
if ( typeof elem.getBoundingClientRect !== strundefined ) {
|
|
box = elem.getBoundingClientRect();
|
|
}
|
|
win = getWindow( doc );
|
|
return {
|
|
top: box.top + win.pageYOffset - docElem.clientTop,
|
|
left: box.left + win.pageXOffset - docElem.clientLeft
|
|
};
|
|
},
|
|
|
|
position: function() {
|
|
if ( !this[ 0 ] ) {
|
|
return;
|
|
}
|
|
|
|
var offsetParent, offset,
|
|
elem = this[ 0 ],
|
|
parentOffset = { top: 0, left: 0 };
|
|
|
|
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
|
|
if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
|
// Assume getBoundingClientRect is there when computed position is fixed
|
|
offset = elem.getBoundingClientRect();
|
|
|
|
} else {
|
|
// Get *real* offsetParent
|
|
offsetParent = this.offsetParent();
|
|
|
|
// Get correct offsets
|
|
offset = this.offset();
|
|
if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
|
|
parentOffset = offsetParent.offset();
|
|
}
|
|
|
|
// Add offsetParent borders
|
|
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
|
|
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
|
|
}
|
|
|
|
// Subtract parent offsets and element margins
|
|
return {
|
|
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
|
|
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
|
|
};
|
|
},
|
|
|
|
offsetParent: function() {
|
|
return this.map(function() {
|
|
var offsetParent = this.offsetParent || docElem;
|
|
|
|
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
|
|
offsetParent = offsetParent.offsetParent;
|
|
}
|
|
|
|
return offsetParent || docElem;
|
|
});
|
|
}
|
|
});
|
|
|
|
// Create scrollLeft and scrollTop methods
|
|
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
|
|
var top = "pageYOffset" === prop;
|
|
|
|
jQuery.fn[ method ] = function( val ) {
|
|
return access( this, function( elem, method, val ) {
|
|
var win = getWindow( elem );
|
|
|
|
if ( val === undefined ) {
|
|
return win ? win[ prop ] : elem[ method ];
|
|
}
|
|
|
|
if ( win ) {
|
|
win.scrollTo(
|
|
!top ? val : window.pageXOffset,
|
|
top ? val : window.pageYOffset
|
|
);
|
|
|
|
} else {
|
|
elem[ method ] = val;
|
|
}
|
|
}, method, val, arguments.length, null );
|
|
};
|
|
});
|
|
|
|
// Support: Safari<7+, Chrome<37+
|
|
// Add the top/left cssHooks using jQuery.fn.position
|
|
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
|
// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280
|
|
// getComputedStyle returns percent when specified for top/left/bottom/right;
|
|
// rather than make the css module depend on the offset module, just check for it here
|
|
jQuery.each( [ "top", "left" ], function( i, prop ) {
|
|
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
|
|
function( elem, computed ) {
|
|
if ( computed ) {
|
|
computed = curCSS( elem, prop );
|
|
// If curCSS returns percentage, fallback to offset
|
|
return rnumnonpx.test( computed ) ?
|
|
jQuery( elem ).position()[ prop ] + "px" :
|
|
computed;
|
|
}
|
|
}
|
|
);
|
|
});
|
|
|
|
|
|
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
|
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
|
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
|
// Margin is only for outerHeight, outerWidth
|
|
jQuery.fn[ funcName ] = function( margin, value ) {
|
|
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
|
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
|
|
|
|
return access( this, function( elem, type, value ) {
|
|
var doc;
|
|
|
|
if ( jQuery.isWindow( elem ) ) {
|
|
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
|
|
// isn't a whole lot we can do. See pull request at this URL for discussion:
|
|
// https://github.com/jquery/jquery/pull/764
|
|
return elem.document.documentElement[ "client" + name ];
|
|
}
|
|
|
|
// Get document width or height
|
|
if ( elem.nodeType === 9 ) {
|
|
doc = elem.documentElement;
|
|
|
|
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
|
|
// whichever is greatest
|
|
return Math.max(
|
|
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
|
|
elem.body[ "offset" + name ], doc[ "offset" + name ],
|
|
doc[ "client" + name ]
|
|
);
|
|
}
|
|
|
|
return value === undefined ?
|
|
// Get width or height on the element, requesting but not forcing parseFloat
|
|
jQuery.css( elem, type, extra ) :
|
|
|
|
// Set width or height on the element
|
|
jQuery.style( elem, type, value, extra );
|
|
}, type, chainable ? margin : undefined, chainable, null );
|
|
};
|
|
});
|
|
});
|
|
|
|
|
|
// The number of elements contained in the matched element set
|
|
jQuery.fn.size = function() {
|
|
return this.length;
|
|
};
|
|
|
|
jQuery.fn.andSelf = jQuery.fn.addBack;
|
|
|
|
|
|
|
|
|
|
// Register as a named AMD module, since jQuery can be concatenated with other
|
|
// files that may use define, but not via a proper concatenation script that
|
|
// understands anonymous AMD modules. A named AMD is safest and most robust
|
|
// way to register. Lowercase jquery is used because AMD module names are
|
|
// derived from file names, and jQuery is normally delivered in a lowercase
|
|
// file name. Do this after creating the global so that if an AMD module wants
|
|
// to call noConflict to hide this version of jQuery, it will work.
|
|
|
|
// Note that for maximum portability, libraries that are not jQuery should
|
|
// declare themselves as anonymous modules, and avoid setting a global if an
|
|
// AMD loader is present. jQuery is a special case. For more information, see
|
|
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
define( "jquery", [], function() {
|
|
return jQuery;
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
var
|
|
// Map over jQuery in case of overwrite
|
|
_jQuery = window.jQuery,
|
|
|
|
// Map over the $ in case of overwrite
|
|
_$ = window.$;
|
|
|
|
jQuery.noConflict = function( deep ) {
|
|
if ( window.$ === jQuery ) {
|
|
window.$ = _$;
|
|
}
|
|
|
|
if ( deep && window.jQuery === jQuery ) {
|
|
window.jQuery = _jQuery;
|
|
}
|
|
|
|
return jQuery;
|
|
};
|
|
|
|
// Expose jQuery and $ identifiers, even in AMD
|
|
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
|
|
// and CommonJS for browser emulators (#13566)
|
|
if ( typeof noGlobal === strundefined ) {
|
|
window.jQuery = window.$ = jQuery;
|
|
}
|
|
|
|
|
|
|
|
|
|
return jQuery;
|
|
|
|
}));
|
|
|
|
},{}],"lodash":[function(require,module,exports){
|
|
(function (global){
|
|
/**
|
|
* @license
|
|
* lodash 3.3.1 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern -d -o ./index.js`
|
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
;(function() {
|
|
|
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
|
var undefined;
|
|
|
|
/** Used as the semantic version number. */
|
|
var VERSION = '3.3.1';
|
|
|
|
/** Used to compose bitmasks for wrapper metadata. */
|
|
var BIND_FLAG = 1,
|
|
BIND_KEY_FLAG = 2,
|
|
CURRY_BOUND_FLAG = 4,
|
|
CURRY_FLAG = 8,
|
|
CURRY_RIGHT_FLAG = 16,
|
|
PARTIAL_FLAG = 32,
|
|
PARTIAL_RIGHT_FLAG = 64,
|
|
REARG_FLAG = 128,
|
|
ARY_FLAG = 256;
|
|
|
|
/** Used as default options for `_.trunc`. */
|
|
var DEFAULT_TRUNC_LENGTH = 30,
|
|
DEFAULT_TRUNC_OMISSION = '...';
|
|
|
|
/** Used to detect when a function becomes hot. */
|
|
var HOT_COUNT = 150,
|
|
HOT_SPAN = 16;
|
|
|
|
/** Used to indicate the type of lazy iteratees. */
|
|
var LAZY_FILTER_FLAG = 0,
|
|
LAZY_MAP_FLAG = 1,
|
|
LAZY_WHILE_FLAG = 2;
|
|
|
|
/** Used as the `TypeError` message for "Functions" methods. */
|
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
|
|
/** Used as the internal argument placeholder. */
|
|
var PLACEHOLDER = '__lodash_placeholder__';
|
|
|
|
/** `Object#toString` result references. */
|
|
var argsTag = '[object Arguments]',
|
|
arrayTag = '[object Array]',
|
|
boolTag = '[object Boolean]',
|
|
dateTag = '[object Date]',
|
|
errorTag = '[object Error]',
|
|
funcTag = '[object Function]',
|
|
mapTag = '[object Map]',
|
|
numberTag = '[object Number]',
|
|
objectTag = '[object Object]',
|
|
regexpTag = '[object RegExp]',
|
|
setTag = '[object Set]',
|
|
stringTag = '[object String]',
|
|
weakMapTag = '[object WeakMap]';
|
|
|
|
var arrayBufferTag = '[object ArrayBuffer]',
|
|
float32Tag = '[object Float32Array]',
|
|
float64Tag = '[object Float64Array]',
|
|
int8Tag = '[object Int8Array]',
|
|
int16Tag = '[object Int16Array]',
|
|
int32Tag = '[object Int32Array]',
|
|
uint8Tag = '[object Uint8Array]',
|
|
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
uint16Tag = '[object Uint16Array]',
|
|
uint32Tag = '[object Uint32Array]';
|
|
|
|
/** Used to match empty string literals in compiled template source. */
|
|
var reEmptyStringLeading = /\b__p \+= '';/g,
|
|
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
|
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
|
|
|
/** Used to match HTML entities and HTML characters. */
|
|
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
|
|
reUnescapedHtml = /[&<>"'`]/g,
|
|
reHasEscapedHtml = RegExp(reEscapedHtml.source),
|
|
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
|
|
/** Used to match template delimiters. */
|
|
var reEscape = /<%-([\s\S]+?)%>/g,
|
|
reEvaluate = /<%([\s\S]+?)%>/g,
|
|
reInterpolate = /<%=([\s\S]+?)%>/g;
|
|
|
|
/**
|
|
* Used to match ES template delimiters.
|
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components)
|
|
* for more details.
|
|
*/
|
|
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
|
|
|
/** Used to match `RegExp` flags from their coerced string values. */
|
|
var reFlags = /\w*$/;
|
|
|
|
/** Used to detect named functions. */
|
|
var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
|
|
|
/** Used to detect hexadecimal string values. */
|
|
var reHexPrefix = /^0[xX]/;
|
|
|
|
/** Used to detect host constructors (Safari > 5). */
|
|
var reHostCtor = /^\[object .+?Constructor\]$/;
|
|
|
|
/** Used to match latin-1 supplementary letters (excluding mathematical operators). */
|
|
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
|
|
|
|
/** Used to ensure capturing order of template delimiters. */
|
|
var reNoMatch = /($^)/;
|
|
|
|
/**
|
|
* Used to match `RegExp` special characters.
|
|
* See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special)
|
|
* for more details.
|
|
*/
|
|
var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
|
|
reHasRegExpChars = RegExp(reRegExpChars.source);
|
|
|
|
/** Used to detect functions containing a `this` reference. */
|
|
var reThis = /\bthis\b/;
|
|
|
|
/** Used to match unescaped characters in compiled string literals. */
|
|
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
|
|
|
/** Used to match words to create compound words. */
|
|
var reWords = (function() {
|
|
var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]',
|
|
lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';
|
|
|
|
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
|
|
}());
|
|
|
|
/** Used to detect and test for whitespace. */
|
|
var whitespace = (
|
|
// Basic whitespace characters.
|
|
' \t\x0b\f\xa0\ufeff' +
|
|
|
|
// Line terminators.
|
|
'\n\r\u2028\u2029' +
|
|
|
|
// Unicode category "Zs" space separators.
|
|
'\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'
|
|
);
|
|
|
|
/** Used to assign default `context` object properties. */
|
|
var contextProps = [
|
|
'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',
|
|
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',
|
|
'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document',
|
|
'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
|
|
'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
|
|
'window', 'WinRTError'
|
|
];
|
|
|
|
/** Used to make template sourceURLs easier to identify. */
|
|
var templateCounter = -1;
|
|
|
|
/** Used to identify `toStringTag` values of typed arrays. */
|
|
var typedArrayTags = {};
|
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
typedArrayTags[uint32Tag] = true;
|
|
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
typedArrayTags[dateTag] = typedArrayTags[errorTag] =
|
|
typedArrayTags[funcTag] = typedArrayTags[mapTag] =
|
|
typedArrayTags[numberTag] = typedArrayTags[objectTag] =
|
|
typedArrayTags[regexpTag] = typedArrayTags[setTag] =
|
|
typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
|
|
|
/** Used to identify `toStringTag` values supported by `_.clone`. */
|
|
var cloneableTags = {};
|
|
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
|
cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
|
|
cloneableTags[dateTag] = cloneableTags[float32Tag] =
|
|
cloneableTags[float64Tag] = cloneableTags[int8Tag] =
|
|
cloneableTags[int16Tag] = cloneableTags[int32Tag] =
|
|
cloneableTags[numberTag] = cloneableTags[objectTag] =
|
|
cloneableTags[regexpTag] = cloneableTags[stringTag] =
|
|
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
|
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
|
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
|
cloneableTags[mapTag] = cloneableTags[setTag] =
|
|
cloneableTags[weakMapTag] = false;
|
|
|
|
/** Used as an internal `_.debounce` options object by `_.throttle`. */
|
|
var debounceOptions = {
|
|
'leading': false,
|
|
'maxWait': 0,
|
|
'trailing': false
|
|
};
|
|
|
|
/** Used to map latin-1 supplementary letters to basic latin letters. */
|
|
var deburredLetters = {
|
|
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
|
|
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
|
|
'\xc7': 'C', '\xe7': 'c',
|
|
'\xd0': 'D', '\xf0': 'd',
|
|
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
|
|
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
|
|
'\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
|
|
'\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
|
|
'\xd1': 'N', '\xf1': 'n',
|
|
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
|
|
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
|
|
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
|
|
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
|
|
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
|
|
'\xc6': 'Ae', '\xe6': 'ae',
|
|
'\xde': 'Th', '\xfe': 'th',
|
|
'\xdf': 'ss'
|
|
};
|
|
|
|
/** Used to map characters to HTML entities. */
|
|
var htmlEscapes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": ''',
|
|
'`': '`'
|
|
};
|
|
|
|
/** Used to map HTML entities to characters. */
|
|
var htmlUnescapes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
''': "'",
|
|
'`': '`'
|
|
};
|
|
|
|
/** Used to determine if values are of the language type `Object`. */
|
|
var objectTypes = {
|
|
'function': true,
|
|
'object': true
|
|
};
|
|
|
|
/** Used to escape characters for inclusion in compiled string literals. */
|
|
var stringEscapes = {
|
|
'\\': '\\',
|
|
"'": "'",
|
|
'\n': 'n',
|
|
'\r': 'r',
|
|
'\u2028': 'u2028',
|
|
'\u2029': 'u2029'
|
|
};
|
|
|
|
/**
|
|
* Used as a reference to the global object.
|
|
*
|
|
* The `this` value is used if it is the global object to avoid Greasemonkey's
|
|
* restricted `window` object, otherwise the `window` object is used.
|
|
*/
|
|
var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this;
|
|
|
|
/** Detect free variable `exports`. */
|
|
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
|
|
|
/** Detect free variable `module`. */
|
|
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
|
|
|
/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
|
|
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
|
|
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
|
|
root = freeGlobal;
|
|
}
|
|
|
|
/** Detect the popular CommonJS extension `module.exports`. */
|
|
var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The base implementation of `compareAscending` which compares values and
|
|
* sorts them in ascending order without guaranteeing a stable sort.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to compare to `other`.
|
|
* @param {*} other The value to compare to `value`.
|
|
* @returns {number} Returns the sort order indicator for `value`.
|
|
*/
|
|
function baseCompareAscending(value, other) {
|
|
if (value !== other) {
|
|
var valIsReflexive = value === value,
|
|
othIsReflexive = other === other;
|
|
|
|
if (value > other || !valIsReflexive || (typeof value == 'undefined' && othIsReflexive)) {
|
|
return 1;
|
|
}
|
|
if (value < other || !othIsReflexive || (typeof other == 'undefined' && valIsReflexive)) {
|
|
return -1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.indexOf` without support for binary searches.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {number} [fromIndex=0] The index to search from.
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
*/
|
|
function baseIndexOf(array, value, fromIndex) {
|
|
if (value !== value) {
|
|
return indexOfNaN(array, fromIndex);
|
|
}
|
|
var index = (fromIndex || 0) - 1,
|
|
length = array.length;
|
|
|
|
while (++index < length) {
|
|
if (array[index] === value) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.isFunction` without support for environments
|
|
* with incorrect `typeof` results.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
*/
|
|
function baseIsFunction(value) {
|
|
// Avoid a Chakra JIT bug in compatibility modes of IE 11.
|
|
// See https://github.com/jashkenas/underscore/issues/1621 for more details.
|
|
return typeof value == 'function' || false;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer`
|
|
* to define the sort order of `array` and replaces criteria objects with their
|
|
* corresponding values.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to sort.
|
|
* @param {Function} comparer The function to define sort order.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function baseSortBy(array, comparer) {
|
|
var length = array.length;
|
|
|
|
array.sort(comparer);
|
|
while (length--) {
|
|
array[length] = array[length].value;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* Converts `value` to a string if it is not one. An empty string is returned
|
|
* for `null` or `undefined` values.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to process.
|
|
* @returns {string} Returns the string.
|
|
*/
|
|
function baseToString(value) {
|
|
if (typeof value == 'string') {
|
|
return value;
|
|
}
|
|
return value == null ? '' : (value + '');
|
|
}
|
|
|
|
/**
|
|
* Used by `_.max` and `_.min` as the default callback for string values.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @returns {number} Returns the code unit of the first character of the string.
|
|
*/
|
|
function charAtCallback(string) {
|
|
return string.charCodeAt(0);
|
|
}
|
|
|
|
/**
|
|
* Used by `_.trim` and `_.trimLeft` to get the index of the first character
|
|
* of `string` that is not found in `chars`.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @param {string} chars The characters to find.
|
|
* @returns {number} Returns the index of the first character not found in `chars`.
|
|
*/
|
|
function charsLeftIndex(string, chars) {
|
|
var index = -1,
|
|
length = string.length;
|
|
|
|
while (++index < length && chars.indexOf(string.charAt(index)) > -1) {}
|
|
return index;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.trim` and `_.trimRight` to get the index of the last character
|
|
* of `string` that is not found in `chars`.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @param {string} chars The characters to find.
|
|
* @returns {number} Returns the index of the last character not found in `chars`.
|
|
*/
|
|
function charsRightIndex(string, chars) {
|
|
var index = string.length;
|
|
|
|
while (index-- && chars.indexOf(string.charAt(index)) > -1) {}
|
|
return index;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.sortBy` to compare transformed elements of a collection and stable
|
|
* sort them in ascending order.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to compare to `other`.
|
|
* @param {Object} other The object to compare to `object`.
|
|
* @returns {number} Returns the sort order indicator for `object`.
|
|
*/
|
|
function compareAscending(object, other) {
|
|
return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
|
|
}
|
|
|
|
/**
|
|
* Used by `_.sortByAll` to compare multiple properties of each element
|
|
* in a collection and stable sort them in ascending order.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to compare to `other`.
|
|
* @param {Object} other The object to compare to `object`.
|
|
* @returns {number} Returns the sort order indicator for `object`.
|
|
*/
|
|
function compareMultipleAscending(object, other) {
|
|
var index = -1,
|
|
objCriteria = object.criteria,
|
|
othCriteria = other.criteria,
|
|
length = objCriteria.length;
|
|
|
|
while (++index < length) {
|
|
var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
}
|
|
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
|
// that causes it, under certain circumstances, to provide the same value for
|
|
// `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
|
|
// for more details.
|
|
//
|
|
// This also ensures a stable sort in V8 and other engines.
|
|
// See https://code.google.com/p/v8/issues/detail?id=90 for more details.
|
|
return object.index - other.index;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
|
|
*
|
|
* @private
|
|
* @param {string} letter The matched letter to deburr.
|
|
* @returns {string} Returns the deburred letter.
|
|
*/
|
|
function deburrLetter(letter) {
|
|
return deburredLetters[letter];
|
|
}
|
|
|
|
/**
|
|
* Used by `_.escape` to convert characters to HTML entities.
|
|
*
|
|
* @private
|
|
* @param {string} chr The matched character to escape.
|
|
* @returns {string} Returns the escaped character.
|
|
*/
|
|
function escapeHtmlChar(chr) {
|
|
return htmlEscapes[chr];
|
|
}
|
|
|
|
/**
|
|
* Used by `_.template` to escape characters for inclusion in compiled
|
|
* string literals.
|
|
*
|
|
* @private
|
|
* @param {string} chr The matched character to escape.
|
|
* @returns {string} Returns the escaped character.
|
|
*/
|
|
function escapeStringChar(chr) {
|
|
return '\\' + stringEscapes[chr];
|
|
}
|
|
|
|
/**
|
|
* Gets the index at which the first occurrence of `NaN` is found in `array`.
|
|
* If `fromRight` is provided elements of `array` are iterated from right to left.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to search.
|
|
* @param {number} [fromIndex] The index to search from.
|
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
* @returns {number} Returns the index of the matched `NaN`, else `-1`.
|
|
*/
|
|
function indexOfNaN(array, fromIndex, fromRight) {
|
|
var length = array.length,
|
|
index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1);
|
|
|
|
while ((fromRight ? index-- : ++index < length)) {
|
|
var other = array[index];
|
|
if (other !== other) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is object-like.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
*/
|
|
function isObjectLike(value) {
|
|
return (value && typeof value == 'object') || false;
|
|
}
|
|
|
|
/**
|
|
* Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a
|
|
* character code is whitespace.
|
|
*
|
|
* @private
|
|
* @param {number} charCode The character code to inspect.
|
|
* @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.
|
|
*/
|
|
function isSpace(charCode) {
|
|
return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||
|
|
(charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));
|
|
}
|
|
|
|
/**
|
|
* Replaces all `placeholder` elements in `array` with an internal placeholder
|
|
* and returns an array of their indexes.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to modify.
|
|
* @param {*} placeholder The placeholder to replace.
|
|
* @returns {Array} Returns the new array of placeholder indexes.
|
|
*/
|
|
function replaceHolders(array, placeholder) {
|
|
var index = -1,
|
|
length = array.length,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
if (array[index] === placeholder) {
|
|
array[index] = PLACEHOLDER;
|
|
result[++resIndex] = index;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* An implementation of `_.uniq` optimized for sorted arrays without support
|
|
* for callback shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to inspect.
|
|
* @param {Function} [iteratee] The function invoked per iteration.
|
|
* @returns {Array} Returns the new duplicate-value-free array.
|
|
*/
|
|
function sortedUniq(array, iteratee) {
|
|
var seen,
|
|
index = -1,
|
|
length = array.length,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index],
|
|
computed = iteratee ? iteratee(value, index, array) : value;
|
|
|
|
if (!index || seen !== computed) {
|
|
seen = computed;
|
|
result[++resIndex] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
|
|
* character of `string`.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @returns {number} Returns the index of the first non-whitespace character.
|
|
*/
|
|
function trimmedLeftIndex(string) {
|
|
var index = -1,
|
|
length = string.length;
|
|
|
|
while (++index < length && isSpace(string.charCodeAt(index))) {}
|
|
return index;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace
|
|
* character of `string`.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @returns {number} Returns the index of the last non-whitespace character.
|
|
*/
|
|
function trimmedRightIndex(string) {
|
|
var index = string.length;
|
|
|
|
while (index-- && isSpace(string.charCodeAt(index))) {}
|
|
return index;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.unescape` to convert HTML entities to characters.
|
|
*
|
|
* @private
|
|
* @param {string} chr The matched character to unescape.
|
|
* @returns {string} Returns the unescaped character.
|
|
*/
|
|
function unescapeHtmlChar(chr) {
|
|
return htmlUnescapes[chr];
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Create a new pristine `lodash` function using the given `context` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {Object} [context=root] The context object.
|
|
* @returns {Function} Returns a new `lodash` function.
|
|
* @example
|
|
*
|
|
* _.mixin({ 'add': function(a, b) { return a + b; } });
|
|
*
|
|
* var lodash = _.runInContext();
|
|
* lodash.mixin({ 'sub': function(a, b) { return a - b; } });
|
|
*
|
|
* _.isFunction(_.add);
|
|
* // => true
|
|
* _.isFunction(_.sub);
|
|
* // => false
|
|
*
|
|
* lodash.isFunction(lodash.add);
|
|
* // => false
|
|
* lodash.isFunction(lodash.sub);
|
|
* // => true
|
|
*
|
|
* // using `context` to mock `Date#getTime` use in `_.now`
|
|
* var mock = _.runInContext({
|
|
* 'Date': function() {
|
|
* return { 'getTime': getTimeMock };
|
|
* }
|
|
* });
|
|
*
|
|
* // or creating a suped-up `defer` in Node.js
|
|
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
|
|
*/
|
|
function runInContext(context) {
|
|
// Avoid issues with some ES3 environments that attempt to use values, named
|
|
// after built-in constructors like `Object`, for the creation of literals.
|
|
// ES5 clears this up by stating that literals must use built-in constructors.
|
|
// See https://es5.github.io/#x11.1.5 for more details.
|
|
context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
|
|
|
|
/** Native constructor references. */
|
|
var Array = context.Array,
|
|
Date = context.Date,
|
|
Error = context.Error,
|
|
Function = context.Function,
|
|
Math = context.Math,
|
|
Number = context.Number,
|
|
Object = context.Object,
|
|
RegExp = context.RegExp,
|
|
String = context.String,
|
|
TypeError = context.TypeError;
|
|
|
|
/** Used for native method references. */
|
|
var arrayProto = Array.prototype,
|
|
objectProto = Object.prototype;
|
|
|
|
/** Used to detect DOM support. */
|
|
var document = (document = context.window) && document.document;
|
|
|
|
/** Used to resolve the decompiled source of functions. */
|
|
var fnToString = Function.prototype.toString;
|
|
|
|
/** Used to the length of n-tuples for `_.unzip`. */
|
|
var getLength = baseProperty('length');
|
|
|
|
/** Used to check objects for own properties. */
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
/** Used to generate unique IDs. */
|
|
var idCounter = 0;
|
|
|
|
/**
|
|
* Used to resolve the `toStringTag` of values.
|
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
|
* for more details.
|
|
*/
|
|
var objToString = objectProto.toString;
|
|
|
|
/** Used to restore the original `_` reference in `_.noConflict`. */
|
|
var oldDash = context._;
|
|
|
|
/** Used to detect if a method is native. */
|
|
var reNative = RegExp('^' +
|
|
escapeRegExp(objToString)
|
|
.replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
);
|
|
|
|
/** Native method references. */
|
|
var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer,
|
|
bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
|
|
ceil = Math.ceil,
|
|
clearTimeout = context.clearTimeout,
|
|
floor = Math.floor,
|
|
getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
|
push = arrayProto.push,
|
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
|
Set = isNative(Set = context.Set) && Set,
|
|
setTimeout = context.setTimeout,
|
|
splice = arrayProto.splice,
|
|
Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array,
|
|
WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap;
|
|
|
|
/** Used to clone array buffers. */
|
|
var Float64Array = (function() {
|
|
// Safari 5 errors when using an array buffer to initialize a typed array
|
|
// where the array buffer's `byteLength` is not a multiple of the typed
|
|
// array's `BYTES_PER_ELEMENT`.
|
|
try {
|
|
var func = isNative(func = context.Float64Array) && func,
|
|
result = new func(new ArrayBuffer(10), 0, 1) && func;
|
|
} catch(e) {}
|
|
return result;
|
|
}());
|
|
|
|
/* Native method references for those with the same name as other `lodash` methods. */
|
|
var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
|
|
nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate,
|
|
nativeIsFinite = context.isFinite,
|
|
nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
|
|
nativeMax = Math.max,
|
|
nativeMin = Math.min,
|
|
nativeNow = isNative(nativeNow = Date.now) && nativeNow,
|
|
nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite,
|
|
nativeParseInt = context.parseInt,
|
|
nativeRandom = Math.random;
|
|
|
|
/** Used as references for `-Infinity` and `Infinity`. */
|
|
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
|
|
POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
|
|
|
|
/** Used as references for the maximum length and index of an array. */
|
|
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
|
|
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
|
|
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
|
|
|
|
/** Used as the size, in bytes, of each `Float64Array` element. */
|
|
var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
|
|
|
|
/**
|
|
* Used as the maximum length of an array-like value.
|
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
|
|
* for more details.
|
|
*/
|
|
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
|
|
|
/** Used to store function metadata. */
|
|
var metaMap = WeakMap && new WeakMap;
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a `lodash` object which wraps `value` to enable implicit chaining.
|
|
* Methods that operate on and return arrays, collections, and functions can
|
|
* be chained together. Methods that return a boolean or single value will
|
|
* automatically end the chain returning the unwrapped value. Explicit chaining
|
|
* may be enabled using `_.chain`. The execution of chained methods is lazy,
|
|
* that is, execution is deferred until `_#value` is implicitly or explicitly
|
|
* called.
|
|
*
|
|
* Lazy evaluation allows several methods to support shortcut fusion. Shortcut
|
|
* fusion is an optimization that merges iteratees to avoid creating intermediate
|
|
* arrays and reduce the number of iteratee executions.
|
|
*
|
|
* Chaining is supported in custom builds as long as the `_#value` method is
|
|
* directly or indirectly included in the build.
|
|
*
|
|
* In addition to lodash methods, wrappers also have the following `Array` methods:
|
|
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
|
|
* and `unshift`
|
|
*
|
|
* The wrapper methods that support shortcut fusion are:
|
|
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
|
|
* `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
|
|
* `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
|
|
* and `where`
|
|
*
|
|
* The chainable wrapper methods are:
|
|
* `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
|
|
* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
|
|
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,
|
|
* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,
|
|
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
|
|
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
|
|
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
|
|
* `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`,
|
|
* `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
|
|
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
|
|
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
|
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`,
|
|
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
|
* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,
|
|
* `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`,
|
|
* `zip`, and `zipObject`
|
|
*
|
|
* The wrapper methods that are **not** chainable by default are:
|
|
* `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
|
|
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
|
|
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
|
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
|
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
|
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
|
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
|
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
|
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
|
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
|
* `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`,
|
|
* `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
|
*
|
|
* The wrapper method `sample` will return a wrapped value when `n` is provided,
|
|
* otherwise an unwrapped value is returned.
|
|
*
|
|
* @name _
|
|
* @constructor
|
|
* @category Chain
|
|
* @param {*} value The value to wrap in a `lodash` instance.
|
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var wrapped = _([1, 2, 3]);
|
|
*
|
|
* // returns an unwrapped value
|
|
* wrapped.reduce(function(sum, n) {
|
|
* return sum + n;
|
|
* });
|
|
* // => 6
|
|
*
|
|
* // returns a wrapped value
|
|
* var squares = wrapped.map(function(n) {
|
|
* return n * n;
|
|
* });
|
|
*
|
|
* _.isArray(squares);
|
|
* // => false
|
|
*
|
|
* _.isArray(squares.value());
|
|
* // => true
|
|
*/
|
|
function lodash(value) {
|
|
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
|
|
if (value instanceof LodashWrapper) {
|
|
return value;
|
|
}
|
|
if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
|
|
return wrapperClone(value);
|
|
}
|
|
}
|
|
return new LodashWrapper(value);
|
|
}
|
|
|
|
/**
|
|
* The function whose prototype all chaining wrappers inherit from.
|
|
*
|
|
* @private
|
|
*/
|
|
function baseLodash() {
|
|
// No operation performed.
|
|
}
|
|
|
|
/**
|
|
* The base constructor for creating `lodash` wrapper objects.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to wrap.
|
|
* @param {boolean} [chainAll] Enable chaining for all wrapper methods.
|
|
* @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
|
|
*/
|
|
function LodashWrapper(value, chainAll, actions) {
|
|
this.__wrapped__ = value;
|
|
this.__actions__ = actions || [];
|
|
this.__chain__ = !!chainAll;
|
|
}
|
|
|
|
/**
|
|
* An object environment feature flags.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Object
|
|
*/
|
|
var support = lodash.support = {};
|
|
|
|
(function(x) {
|
|
|
|
/**
|
|
* Detect if functions can be decompiled by `Function#toString`
|
|
* (all but Firefox OS certified apps, older Opera mobile browsers, and
|
|
* the PlayStation 3; forced `false` for Windows 8 apps).
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext);
|
|
|
|
/**
|
|
* Detect if `Function#name` is supported (all but IE).
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
support.funcNames = typeof Function.name == 'string';
|
|
|
|
/**
|
|
* Detect if the DOM is supported.
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
try {
|
|
support.dom = document.createDocumentFragment().nodeType === 11;
|
|
} catch(e) {
|
|
support.dom = false;
|
|
}
|
|
|
|
/**
|
|
* Detect if `arguments` object indexes are non-enumerable.
|
|
*
|
|
* In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
|
|
* indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
|
|
* `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
|
|
* checks for indexes that exceed their function's formal parameters with
|
|
* associated values of `0`.
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
try {
|
|
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
|
|
} catch(e) {
|
|
support.nonEnumArgs = true;
|
|
}
|
|
}(0, 0));
|
|
|
|
/**
|
|
* By default, the template delimiters used by lodash are like those in
|
|
* embedded Ruby (ERB). Change the following template settings to use
|
|
* alternative delimiters.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Object
|
|
*/
|
|
lodash.templateSettings = {
|
|
|
|
/**
|
|
* Used to detect `data` property values to be HTML-escaped.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'escape': reEscape,
|
|
|
|
/**
|
|
* Used to detect code to be evaluated.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'evaluate': reEvaluate,
|
|
|
|
/**
|
|
* Used to detect `data` property values to inject.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'interpolate': reInterpolate,
|
|
|
|
/**
|
|
* Used to reference the data object in the template text.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type string
|
|
*/
|
|
'variable': '',
|
|
|
|
/**
|
|
* Used to import variables into the compiled template.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type Object
|
|
*/
|
|
'imports': {
|
|
|
|
/**
|
|
* A reference to the `lodash` function.
|
|
*
|
|
* @memberOf _.templateSettings.imports
|
|
* @type Function
|
|
*/
|
|
'_': lodash
|
|
}
|
|
};
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to wrap.
|
|
*/
|
|
function LazyWrapper(value) {
|
|
this.__wrapped__ = value;
|
|
this.__actions__ = null;
|
|
this.__dir__ = 1;
|
|
this.__dropCount__ = 0;
|
|
this.__filtered__ = false;
|
|
this.__iteratees__ = null;
|
|
this.__takeCount__ = POSITIVE_INFINITY;
|
|
this.__views__ = null;
|
|
}
|
|
|
|
/**
|
|
* Creates a clone of the lazy wrapper object.
|
|
*
|
|
* @private
|
|
* @name clone
|
|
* @memberOf LazyWrapper
|
|
* @returns {Object} Returns the cloned `LazyWrapper` object.
|
|
*/
|
|
function lazyClone() {
|
|
var actions = this.__actions__,
|
|
iteratees = this.__iteratees__,
|
|
views = this.__views__,
|
|
result = new LazyWrapper(this.__wrapped__);
|
|
|
|
result.__actions__ = actions ? arrayCopy(actions) : null;
|
|
result.__dir__ = this.__dir__;
|
|
result.__dropCount__ = this.__dropCount__;
|
|
result.__filtered__ = this.__filtered__;
|
|
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
|
|
result.__takeCount__ = this.__takeCount__;
|
|
result.__views__ = views ? arrayCopy(views) : null;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Reverses the direction of lazy iteration.
|
|
*
|
|
* @private
|
|
* @name reverse
|
|
* @memberOf LazyWrapper
|
|
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
|
*/
|
|
function lazyReverse() {
|
|
if (this.__filtered__) {
|
|
var result = new LazyWrapper(this);
|
|
result.__dir__ = -1;
|
|
result.__filtered__ = true;
|
|
} else {
|
|
result = this.clone();
|
|
result.__dir__ *= -1;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Extracts the unwrapped value from its lazy wrapper.
|
|
*
|
|
* @private
|
|
* @name value
|
|
* @memberOf LazyWrapper
|
|
* @returns {*} Returns the unwrapped value.
|
|
*/
|
|
function lazyValue() {
|
|
var array = this.__wrapped__.value();
|
|
if (!isArray(array)) {
|
|
return baseWrapperValue(array, this.__actions__);
|
|
}
|
|
var dir = this.__dir__,
|
|
isRight = dir < 0,
|
|
view = getView(0, array.length, this.__views__),
|
|
start = view.start,
|
|
end = view.end,
|
|
length = end - start,
|
|
dropCount = this.__dropCount__,
|
|
takeCount = nativeMin(length, this.__takeCount__),
|
|
index = isRight ? end : start - 1,
|
|
iteratees = this.__iteratees__,
|
|
iterLength = iteratees ? iteratees.length : 0,
|
|
resIndex = 0,
|
|
result = [];
|
|
|
|
outer:
|
|
while (length-- && resIndex < takeCount) {
|
|
index += dir;
|
|
|
|
var iterIndex = -1,
|
|
value = array[index];
|
|
|
|
while (++iterIndex < iterLength) {
|
|
var data = iteratees[iterIndex],
|
|
iteratee = data.iteratee,
|
|
computed = iteratee(value, index, array),
|
|
type = data.type;
|
|
|
|
if (type == LAZY_MAP_FLAG) {
|
|
value = computed;
|
|
} else if (!computed) {
|
|
if (type == LAZY_FILTER_FLAG) {
|
|
continue outer;
|
|
} else {
|
|
break outer;
|
|
}
|
|
}
|
|
}
|
|
if (dropCount) {
|
|
dropCount--;
|
|
} else {
|
|
result[resIndex++] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a cache object to store key/value pairs.
|
|
*
|
|
* @private
|
|
* @static
|
|
* @name Cache
|
|
* @memberOf _.memoize
|
|
*/
|
|
function MapCache() {
|
|
this.__data__ = {};
|
|
}
|
|
|
|
/**
|
|
* Removes `key` and its value from the cache.
|
|
*
|
|
* @private
|
|
* @name delete
|
|
* @memberOf _.memoize.Cache
|
|
* @param {string} key The key of the value to remove.
|
|
* @returns {boolean} Returns `true` if the entry was removed successfully, else `false`.
|
|
*/
|
|
function mapDelete(key) {
|
|
return this.has(key) && delete this.__data__[key];
|
|
}
|
|
|
|
/**
|
|
* Gets the cached value for `key`.
|
|
*
|
|
* @private
|
|
* @name get
|
|
* @memberOf _.memoize.Cache
|
|
* @param {string} key The key of the value to get.
|
|
* @returns {*} Returns the cached value.
|
|
*/
|
|
function mapGet(key) {
|
|
return key == '__proto__' ? undefined : this.__data__[key];
|
|
}
|
|
|
|
/**
|
|
* Checks if a cached value for `key` exists.
|
|
*
|
|
* @private
|
|
* @name has
|
|
* @memberOf _.memoize.Cache
|
|
* @param {string} key The key of the entry to check.
|
|
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
*/
|
|
function mapHas(key) {
|
|
return key != '__proto__' && hasOwnProperty.call(this.__data__, key);
|
|
}
|
|
|
|
/**
|
|
* Adds `value` to `key` of the cache.
|
|
*
|
|
* @private
|
|
* @name set
|
|
* @memberOf _.memoize.Cache
|
|
* @param {string} key The key of the value to cache.
|
|
* @param {*} value The value to cache.
|
|
* @returns {Object} Returns the cache object.
|
|
*/
|
|
function mapSet(key, value) {
|
|
if (key != '__proto__') {
|
|
this.__data__[key] = value;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
*
|
|
* Creates a cache object to store unique values.
|
|
*
|
|
* @private
|
|
* @param {Array} [values] The values to cache.
|
|
*/
|
|
function SetCache(values) {
|
|
var length = values ? values.length : 0;
|
|
|
|
this.data = { 'hash': nativeCreate(null), 'set': new Set };
|
|
while (length--) {
|
|
this.push(values[length]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is in `cache` mimicking the return signature of
|
|
* `_.indexOf` by returning `0` if the value is found, else `-1`.
|
|
*
|
|
* @private
|
|
* @param {Object} cache The cache to search.
|
|
* @param {*} value The value to search for.
|
|
* @returns {number} Returns `0` if `value` is found, else `-1`.
|
|
*/
|
|
function cacheIndexOf(cache, value) {
|
|
var data = cache.data,
|
|
result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
|
|
|
|
return result ? 0 : -1;
|
|
}
|
|
|
|
/**
|
|
* Adds `value` to the cache.
|
|
*
|
|
* @private
|
|
* @name push
|
|
* @memberOf SetCache
|
|
* @param {*} value The value to cache.
|
|
*/
|
|
function cachePush(value) {
|
|
var data = this.data;
|
|
if (typeof value == 'string' || isObject(value)) {
|
|
data.set.add(value);
|
|
} else {
|
|
data.hash[value] = true;
|
|
}
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Copies the values of `source` to `array`.
|
|
*
|
|
* @private
|
|
* @param {Array} source The array to copy values from.
|
|
* @param {Array} [array=[]] The array to copy values to.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function arrayCopy(source, array) {
|
|
var index = -1,
|
|
length = source.length;
|
|
|
|
array || (array = Array(length));
|
|
while (++index < length) {
|
|
array[index] = source[index];
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.forEach` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function arrayEach(array, iteratee) {
|
|
var index = -1,
|
|
length = array.length;
|
|
|
|
while (++index < length) {
|
|
if (iteratee(array[index], index, array) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.forEachRight` for arrays without support for
|
|
* callback shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function arrayEachRight(array, iteratee) {
|
|
var length = array.length;
|
|
|
|
while (length--) {
|
|
if (iteratee(array[length], length, array) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.every` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
|
* else `false`.
|
|
*/
|
|
function arrayEvery(array, predicate) {
|
|
var index = -1,
|
|
length = array.length;
|
|
|
|
while (++index < length) {
|
|
if (!predicate(array[index], index, array)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.filter` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {Array} Returns the new filtered array.
|
|
*/
|
|
function arrayFilter(array, predicate) {
|
|
var index = -1,
|
|
length = array.length,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (predicate(value, index, array)) {
|
|
result[++resIndex] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.map` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array} Returns the new mapped array.
|
|
*/
|
|
function arrayMap(array, iteratee) {
|
|
var index = -1,
|
|
length = array.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = iteratee(array[index], index, array);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.max` for arrays without support for iteratees.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @returns {*} Returns the maximum value.
|
|
*/
|
|
function arrayMax(array) {
|
|
var index = -1,
|
|
length = array.length,
|
|
result = NEGATIVE_INFINITY;
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (value > result) {
|
|
result = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.min` for arrays without support for iteratees.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @returns {*} Returns the minimum value.
|
|
*/
|
|
function arrayMin(array) {
|
|
var index = -1,
|
|
length = array.length,
|
|
result = POSITIVE_INFINITY;
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (value < result) {
|
|
result = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.reduce` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {*} [accumulator] The initial value.
|
|
* @param {boolean} [initFromArray] Specify using the first element of `array`
|
|
* as the initial value.
|
|
* @returns {*} Returns the accumulated value.
|
|
*/
|
|
function arrayReduce(array, iteratee, accumulator, initFromArray) {
|
|
var index = -1,
|
|
length = array.length;
|
|
|
|
if (initFromArray && length) {
|
|
accumulator = array[++index];
|
|
}
|
|
while (++index < length) {
|
|
accumulator = iteratee(accumulator, array[index], index, array);
|
|
}
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.reduceRight` for arrays without support for
|
|
* callback shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {*} [accumulator] The initial value.
|
|
* @param {boolean} [initFromArray] Specify using the last element of `array`
|
|
* as the initial value.
|
|
* @returns {*} Returns the accumulated value.
|
|
*/
|
|
function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
|
|
var length = array.length;
|
|
if (initFromArray && length) {
|
|
accumulator = array[--length];
|
|
}
|
|
while (length--) {
|
|
accumulator = iteratee(accumulator, array[length], length, array);
|
|
}
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.some` for arrays without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
* else `false`.
|
|
*/
|
|
function arraySome(array, predicate) {
|
|
var index = -1,
|
|
length = array.length;
|
|
|
|
while (++index < length) {
|
|
if (predicate(array[index], index, array)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.defaults` to customize its `_.assign` use.
|
|
*
|
|
* @private
|
|
* @param {*} objectValue The destination object property value.
|
|
* @param {*} sourceValue The source object property value.
|
|
* @returns {*} Returns the value to assign to the destination object.
|
|
*/
|
|
function assignDefaults(objectValue, sourceValue) {
|
|
return typeof objectValue == 'undefined' ? sourceValue : objectValue;
|
|
}
|
|
|
|
/**
|
|
* Used by `_.template` to customize its `_.assign` use.
|
|
*
|
|
* **Note:** This method is like `assignDefaults` except that it ignores
|
|
* inherited property values when checking if a property is `undefined`.
|
|
*
|
|
* @private
|
|
* @param {*} objectValue The destination object property value.
|
|
* @param {*} sourceValue The source object property value.
|
|
* @param {string} key The key associated with the object and source values.
|
|
* @param {Object} object The destination object.
|
|
* @returns {*} Returns the value to assign to the destination object.
|
|
*/
|
|
function assignOwnDefaults(objectValue, sourceValue, key, object) {
|
|
return (typeof objectValue == 'undefined' || !hasOwnProperty.call(object, key))
|
|
? sourceValue
|
|
: objectValue;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.assign` without support for argument juggling,
|
|
* multiple sources, and `this` binding `customizer` functions.
|
|
*
|
|
* @private
|
|
* @param {Object} object The destination object.
|
|
* @param {Object} source The source object.
|
|
* @param {Function} [customizer] The function to customize assigning values.
|
|
* @returns {Object} Returns the destination object.
|
|
*/
|
|
function baseAssign(object, source, customizer) {
|
|
var props = keys(source);
|
|
if (!customizer) {
|
|
return baseCopy(source, object, props);
|
|
}
|
|
var index = -1,
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index],
|
|
value = object[key],
|
|
result = customizer(value, source[key], key, object, source);
|
|
|
|
if ((result === result ? result !== value : value === value) ||
|
|
(typeof value == 'undefined' && !(key in object))) {
|
|
object[key] = result;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.at` without support for strings and individual
|
|
* key arguments.
|
|
*
|
|
* @private
|
|
* @param {Array|Object} collection The collection to iterate over.
|
|
* @param {number[]|string[]} [props] The property names or indexes of elements to pick.
|
|
* @returns {Array} Returns the new array of picked elements.
|
|
*/
|
|
function baseAt(collection, props) {
|
|
var index = -1,
|
|
length = collection.length,
|
|
isArr = isLength(length),
|
|
propsLength = props.length,
|
|
result = Array(propsLength);
|
|
|
|
while(++index < propsLength) {
|
|
var key = props[index];
|
|
if (isArr) {
|
|
key = parseFloat(key);
|
|
result[index] = isIndex(key, length) ? collection[key] : undefined;
|
|
} else {
|
|
result[index] = collection[key];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Copies the properties of `source` to `object`.
|
|
*
|
|
* @private
|
|
* @param {Object} source The object to copy properties from.
|
|
* @param {Object} [object={}] The object to copy properties to.
|
|
* @param {Array} props The property names to copy.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseCopy(source, object, props) {
|
|
if (!props) {
|
|
props = object;
|
|
object = {};
|
|
}
|
|
var index = -1,
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
object[key] = source[key];
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.bindAll` without support for individual
|
|
* method name arguments.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to bind and assign the bound methods to.
|
|
* @param {string[]} methodNames The object method names to bind.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseBindAll(object, methodNames) {
|
|
var index = -1,
|
|
length = methodNames.length;
|
|
|
|
while (++index < length) {
|
|
var key = methodNames[index];
|
|
object[key] = createWrapper(object[key], BIND_FLAG, object);
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.callback` which supports specifying the
|
|
* number of arguments to provide to `func`.
|
|
*
|
|
* @private
|
|
* @param {*} [func=_.identity] The value to convert to a callback.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param {number} [argCount] The number of arguments to provide to `func`.
|
|
* @returns {Function} Returns the callback.
|
|
*/
|
|
function baseCallback(func, thisArg, argCount) {
|
|
var type = typeof func;
|
|
if (type == 'function') {
|
|
return (typeof thisArg != 'undefined' && isBindable(func))
|
|
? bindCallback(func, thisArg, argCount)
|
|
: func;
|
|
}
|
|
if (func == null) {
|
|
return identity;
|
|
}
|
|
if (type == 'object') {
|
|
return baseMatches(func);
|
|
}
|
|
return typeof thisArg == 'undefined'
|
|
? baseProperty(func + '')
|
|
: baseMatchesProperty(func + '', thisArg);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.clone` without support for argument juggling
|
|
* and `this` binding `customizer` functions.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to clone.
|
|
* @param {boolean} [isDeep] Specify a deep clone.
|
|
* @param {Function} [customizer] The function to customize cloning values.
|
|
* @param {string} [key] The key of `value`.
|
|
* @param {Object} [object] The object `value` belongs to.
|
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
|
* @param {Array} [stackB=[]] Associates clones with source counterparts.
|
|
* @returns {*} Returns the cloned value.
|
|
*/
|
|
function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
|
|
var result;
|
|
if (customizer) {
|
|
result = object ? customizer(value, key, object) : customizer(value);
|
|
}
|
|
if (typeof result != 'undefined') {
|
|
return result;
|
|
}
|
|
if (!isObject(value)) {
|
|
return value;
|
|
}
|
|
var isArr = isArray(value);
|
|
if (isArr) {
|
|
result = initCloneArray(value);
|
|
if (!isDeep) {
|
|
return arrayCopy(value, result);
|
|
}
|
|
} else {
|
|
var tag = objToString.call(value),
|
|
isFunc = tag == funcTag;
|
|
|
|
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
|
result = initCloneObject(isFunc ? {} : value);
|
|
if (!isDeep) {
|
|
return baseCopy(value, result, keys(value));
|
|
}
|
|
} else {
|
|
return cloneableTags[tag]
|
|
? initCloneByTag(value, tag, isDeep)
|
|
: (object ? value : {});
|
|
}
|
|
}
|
|
// Check for circular references and return corresponding clone.
|
|
stackA || (stackA = []);
|
|
stackB || (stackB = []);
|
|
|
|
var length = stackA.length;
|
|
while (length--) {
|
|
if (stackA[length] == value) {
|
|
return stackB[length];
|
|
}
|
|
}
|
|
// Add the source value to the stack of traversed objects and associate it with its clone.
|
|
stackA.push(value);
|
|
stackB.push(result);
|
|
|
|
// Recursively populate clone (susceptible to call stack limits).
|
|
(isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
|
|
result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.create` without support for assigning
|
|
* properties to the created object.
|
|
*
|
|
* @private
|
|
* @param {Object} prototype The object to inherit from.
|
|
* @returns {Object} Returns the new object.
|
|
*/
|
|
var baseCreate = (function() {
|
|
function Object() {}
|
|
return function(prototype) {
|
|
if (isObject(prototype)) {
|
|
Object.prototype = prototype;
|
|
var result = new Object;
|
|
Object.prototype = null;
|
|
}
|
|
return result || context.Object();
|
|
};
|
|
}());
|
|
|
|
/**
|
|
* The base implementation of `_.delay` and `_.defer` which accepts an index
|
|
* of where to slice the arguments to provide to `func`.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to delay.
|
|
* @param {number} wait The number of milliseconds to delay invocation.
|
|
* @param {Object} args The `arguments` object to slice and provide to `func`.
|
|
* @returns {number} Returns the timer id.
|
|
*/
|
|
function baseDelay(func, wait, args, fromIndex) {
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.difference` which accepts a single array
|
|
* of values to exclude.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to inspect.
|
|
* @param {Array} values The values to exclude.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
*/
|
|
function baseDifference(array, values) {
|
|
var length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
if (!length) {
|
|
return result;
|
|
}
|
|
var index = -1,
|
|
indexOf = getIndexOf(),
|
|
isCommon = indexOf == baseIndexOf,
|
|
cache = (isCommon && values.length >= 200) ? createCache(values) : null,
|
|
valuesLength = values.length;
|
|
|
|
if (cache) {
|
|
indexOf = cacheIndexOf;
|
|
isCommon = false;
|
|
values = cache;
|
|
}
|
|
outer:
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
|
|
if (isCommon && value === value) {
|
|
var valuesIndex = valuesLength;
|
|
while (valuesIndex--) {
|
|
if (values[valuesIndex] === value) {
|
|
continue outer;
|
|
}
|
|
}
|
|
result.push(value);
|
|
}
|
|
else if (indexOf(values, value) < 0) {
|
|
result.push(value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.forEach` without support for callback
|
|
* shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
*/
|
|
function baseEach(collection, iteratee) {
|
|
var length = collection ? collection.length : 0;
|
|
if (!isLength(length)) {
|
|
return baseForOwn(collection, iteratee);
|
|
}
|
|
var index = -1,
|
|
iterable = toObject(collection);
|
|
|
|
while (++index < length) {
|
|
if (iteratee(iterable[index], index, iterable) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return collection;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.forEachRight` without support for callback
|
|
* shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
*/
|
|
function baseEachRight(collection, iteratee) {
|
|
var length = collection ? collection.length : 0;
|
|
if (!isLength(length)) {
|
|
return baseForOwnRight(collection, iteratee);
|
|
}
|
|
var iterable = toObject(collection);
|
|
while (length--) {
|
|
if (iteratee(iterable[length], length, iterable) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return collection;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.every` without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
|
* else `false`
|
|
*/
|
|
function baseEvery(collection, predicate) {
|
|
var result = true;
|
|
baseEach(collection, function(value, index, collection) {
|
|
result = !!predicate(value, index, collection);
|
|
return result;
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.fill` without an iteratee call guard.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to fill.
|
|
* @param {*} value The value to fill `array` with.
|
|
* @param {number} [start=0] The start position.
|
|
* @param {number} [end=array.length] The end position.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function baseFill(array, value, start, end) {
|
|
var length = array.length;
|
|
|
|
start = start == null ? 0 : (+start || 0);
|
|
if (start < 0) {
|
|
start = -start > length ? 0 : (length + start);
|
|
}
|
|
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
|
if (end < 0) {
|
|
end += length;
|
|
}
|
|
length = start > end ? 0 : end >>> 0;
|
|
start >>>= 0;
|
|
|
|
while (start < length) {
|
|
array[start++] = value;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.filter` without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {Array} Returns the new filtered array.
|
|
*/
|
|
function baseFilter(collection, predicate) {
|
|
var result = [];
|
|
baseEach(collection, function(value, index, collection) {
|
|
if (predicate(value, index, collection)) {
|
|
result.push(value);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
|
|
* without support for callback shorthands and `this` binding, which iterates
|
|
* over `collection` using the provided `eachFunc`.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
|
* @param {boolean} [retKey] Specify returning the key of the found element
|
|
* instead of the element itself.
|
|
* @returns {*} Returns the found element or its key, else `undefined`.
|
|
*/
|
|
function baseFind(collection, predicate, eachFunc, retKey) {
|
|
var result;
|
|
eachFunc(collection, function(value, key, collection) {
|
|
if (predicate(value, key, collection)) {
|
|
result = retKey ? key : value;
|
|
return false;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.flatten` with added support for restricting
|
|
* flattening and specifying the start index.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to flatten.
|
|
* @param {boolean} [isDeep] Specify a deep flatten.
|
|
* @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects.
|
|
* @param {number} [fromIndex=0] The index to start from.
|
|
* @returns {Array} Returns the new flattened array.
|
|
*/
|
|
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
|
var index = (fromIndex || 0) - 1,
|
|
length = array.length,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
|
|
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
|
if (isDeep) {
|
|
// Recursively flatten arrays (susceptible to call stack limits).
|
|
value = baseFlatten(value, isDeep, isStrict);
|
|
}
|
|
var valIndex = -1,
|
|
valLength = value.length;
|
|
|
|
result.length += valLength;
|
|
while (++valIndex < valLength) {
|
|
result[++resIndex] = value[valIndex];
|
|
}
|
|
} else if (!isStrict) {
|
|
result[++resIndex] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `baseForIn` and `baseForOwn` which iterates
|
|
* over `object` properties returned by `keysFunc` invoking `iteratee` for
|
|
* each property. Iterator functions may exit iteration early by explicitly
|
|
* returning `false`.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseFor(object, iteratee, keysFunc) {
|
|
var index = -1,
|
|
iterable = toObject(object),
|
|
props = keysFunc(object),
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (iteratee(iterable[key], key, iterable) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* This function is like `baseFor` except that it iterates over properties
|
|
* in the opposite order.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseForRight(object, iteratee, keysFunc) {
|
|
var iterable = toObject(object),
|
|
props = keysFunc(object),
|
|
length = props.length;
|
|
|
|
while (length--) {
|
|
var key = props[length];
|
|
if (iteratee(iterable[key], key, iterable) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.forIn` without support for callback
|
|
* shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseForIn(object, iteratee) {
|
|
return baseFor(object, iteratee, keysIn);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.forOwn` without support for callback
|
|
* shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseForOwn(object, iteratee) {
|
|
return baseFor(object, iteratee, keys);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.forOwnRight` without support for callback
|
|
* shorthands and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Object} Returns `object`.
|
|
*/
|
|
function baseForOwnRight(object, iteratee) {
|
|
return baseForRight(object, iteratee, keys);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.functions` which creates an array of
|
|
* `object` function property names filtered from those provided.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to inspect.
|
|
* @param {Array} props The property names to filter.
|
|
* @returns {Array} Returns the new array of filtered property names.
|
|
*/
|
|
function baseFunctions(object, props) {
|
|
var index = -1,
|
|
length = props.length,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (isFunction(object[key])) {
|
|
result[++resIndex] = key;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.invoke` which requires additional arguments
|
|
* to be provided as an array of arguments rather than individually.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|string} methodName The name of the method to invoke or
|
|
* the function invoked per iteration.
|
|
* @param {Array} [args] The arguments to invoke the method with.
|
|
* @returns {Array} Returns the array of results.
|
|
*/
|
|
function baseInvoke(collection, methodName, args) {
|
|
var index = -1,
|
|
isFunc = typeof methodName == 'function',
|
|
length = collection ? collection.length : 0,
|
|
result = isLength(length) ? Array(length) : [];
|
|
|
|
baseEach(collection, function(value) {
|
|
var func = isFunc ? methodName : (value != null && value[methodName]);
|
|
result[++index] = func ? func.apply(value, args) : undefined;
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.isEqual` without support for `this` binding
|
|
* `customizer` functions.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to compare.
|
|
* @param {*} other The other value to compare.
|
|
* @param {Function} [customizer] The function to customize comparing values.
|
|
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
|
* @param {Array} [stackA] Tracks traversed `value` objects.
|
|
* @param {Array} [stackB] Tracks traversed `other` objects.
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
*/
|
|
function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) {
|
|
// Exit early for identical values.
|
|
if (value === other) {
|
|
// Treat `+0` vs. `-0` as not equal.
|
|
return value !== 0 || (1 / value == 1 / other);
|
|
}
|
|
var valType = typeof value,
|
|
othType = typeof other;
|
|
|
|
// Exit early for unlike primitive values.
|
|
if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
|
|
value == null || other == null) {
|
|
// Return `false` unless both values are `NaN`.
|
|
return value !== value && other !== other;
|
|
}
|
|
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB);
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseIsEqual` for arrays and objects which performs
|
|
* deep comparisons and tracks traversed objects enabling objects with circular
|
|
* references to be compared.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to compare.
|
|
* @param {Object} other The other object to compare.
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
* @param {Function} [customizer] The function to customize comparing objects.
|
|
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
|
* @param {Array} [stackA=[]] Tracks traversed `value` objects.
|
|
* @param {Array} [stackB=[]] Tracks traversed `other` objects.
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
*/
|
|
function baseIsEqualDeep(object, other, equalFunc, customizer, isWhere, stackA, stackB) {
|
|
var objIsArr = isArray(object),
|
|
othIsArr = isArray(other),
|
|
objTag = arrayTag,
|
|
othTag = arrayTag;
|
|
|
|
if (!objIsArr) {
|
|
objTag = objToString.call(object);
|
|
if (objTag == argsTag) {
|
|
objTag = objectTag;
|
|
} else if (objTag != objectTag) {
|
|
objIsArr = isTypedArray(object);
|
|
}
|
|
}
|
|
if (!othIsArr) {
|
|
othTag = objToString.call(other);
|
|
if (othTag == argsTag) {
|
|
othTag = objectTag;
|
|
} else if (othTag != objectTag) {
|
|
othIsArr = isTypedArray(other);
|
|
}
|
|
}
|
|
var objIsObj = objTag == objectTag,
|
|
othIsObj = othTag == objectTag,
|
|
isSameTag = objTag == othTag;
|
|
|
|
if (isSameTag && !(objIsArr || objIsObj)) {
|
|
return equalByTag(object, other, objTag);
|
|
}
|
|
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
|
|
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
|
|
|
|
if (valWrapped || othWrapped) {
|
|
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB);
|
|
}
|
|
if (!isSameTag) {
|
|
return false;
|
|
}
|
|
// Assume cyclic values are equal.
|
|
// For more information on detecting circular references see https://es5.github.io/#JO.
|
|
stackA || (stackA = []);
|
|
stackB || (stackB = []);
|
|
|
|
var length = stackA.length;
|
|
while (length--) {
|
|
if (stackA[length] == object) {
|
|
return stackB[length] == other;
|
|
}
|
|
}
|
|
// Add `object` and `other` to the stack of traversed objects.
|
|
stackA.push(object);
|
|
stackB.push(other);
|
|
|
|
var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB);
|
|
|
|
stackA.pop();
|
|
stackB.pop();
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.isMatch` without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to inspect.
|
|
* @param {Array} props The source property names to match.
|
|
* @param {Array} values The source values to match.
|
|
* @param {Array} strictCompareFlags Strict comparison flags for source values.
|
|
* @param {Function} [customizer] The function to customize comparing objects.
|
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
*/
|
|
function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
|
|
var length = props.length;
|
|
if (object == null) {
|
|
return !length;
|
|
}
|
|
var index = -1,
|
|
noCustomizer = !customizer;
|
|
|
|
while (++index < length) {
|
|
if ((noCustomizer && strictCompareFlags[index])
|
|
? values[index] !== object[props[index]]
|
|
: !hasOwnProperty.call(object, props[index])
|
|
) {
|
|
return false;
|
|
}
|
|
}
|
|
index = -1;
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (noCustomizer && strictCompareFlags[index]) {
|
|
var result = hasOwnProperty.call(object, key);
|
|
} else {
|
|
var objValue = object[key],
|
|
srcValue = values[index];
|
|
|
|
result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
|
if (typeof result == 'undefined') {
|
|
result = baseIsEqual(srcValue, objValue, customizer, true);
|
|
}
|
|
}
|
|
if (!result) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.map` without support for callback shorthands
|
|
* or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @returns {Array} Returns the new mapped array.
|
|
*/
|
|
function baseMap(collection, iteratee) {
|
|
var result = [];
|
|
baseEach(collection, function(value, key, collection) {
|
|
result.push(iteratee(value, key, collection));
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.matches` which does not clone `source`.
|
|
*
|
|
* @private
|
|
* @param {Object} source The object of property values to match.
|
|
* @returns {Function} Returns the new function.
|
|
*/
|
|
function baseMatches(source) {
|
|
var props = keys(source),
|
|
length = props.length;
|
|
|
|
if (length == 1) {
|
|
var key = props[0],
|
|
value = source[key];
|
|
|
|
if (isStrictComparable(value)) {
|
|
return function(object) {
|
|
return object != null && object[key] === value && hasOwnProperty.call(object, key);
|
|
};
|
|
}
|
|
}
|
|
var values = Array(length),
|
|
strictCompareFlags = Array(length);
|
|
|
|
while (length--) {
|
|
value = source[props[length]];
|
|
values[length] = value;
|
|
strictCompareFlags[length] = isStrictComparable(value);
|
|
}
|
|
return function(object) {
|
|
return baseIsMatch(object, props, values, strictCompareFlags);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
|
* to a string.
|
|
*
|
|
* @private
|
|
* @param {string} key The key of the property to get.
|
|
* @param {*} value The value to compare.
|
|
* @returns {Function} Returns the new function.
|
|
*/
|
|
function baseMatchesProperty(key, value) {
|
|
if (isStrictComparable(value)) {
|
|
return function(object) {
|
|
return object != null && object[key] === value;
|
|
};
|
|
}
|
|
return function(object) {
|
|
return object != null && baseIsEqual(value, object[key], null, true);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.merge` without support for argument juggling,
|
|
* multiple sources, and `this` binding `customizer` functions.
|
|
*
|
|
* @private
|
|
* @param {Object} object The destination object.
|
|
* @param {Object} source The source object.
|
|
* @param {Function} [customizer] The function to customize merging properties.
|
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
|
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
|
* @returns {Object} Returns the destination object.
|
|
*/
|
|
function baseMerge(object, source, customizer, stackA, stackB) {
|
|
if (!isObject(object)) {
|
|
return object;
|
|
}
|
|
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
|
|
(isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
|
|
if (isObjectLike(srcValue)) {
|
|
stackA || (stackA = []);
|
|
stackB || (stackB = []);
|
|
return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
|
}
|
|
var value = object[key],
|
|
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
|
isCommon = typeof result == 'undefined';
|
|
|
|
if (isCommon) {
|
|
result = srcValue;
|
|
}
|
|
if ((isSrcArr || typeof result != 'undefined') &&
|
|
(isCommon || (result === result ? result !== value : value === value))) {
|
|
object[key] = result;
|
|
}
|
|
});
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseMerge` for arrays and objects which performs
|
|
* deep merges and tracks traversed objects enabling objects with circular
|
|
* references to be merged.
|
|
*
|
|
* @private
|
|
* @param {Object} object The destination object.
|
|
* @param {Object} source The source object.
|
|
* @param {string} key The key of the value to merge.
|
|
* @param {Function} mergeFunc The function to merge values.
|
|
* @param {Function} [customizer] The function to customize merging properties.
|
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
|
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
*/
|
|
function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
|
|
var length = stackA.length,
|
|
srcValue = source[key];
|
|
|
|
while (length--) {
|
|
if (stackA[length] == srcValue) {
|
|
object[key] = stackB[length];
|
|
return;
|
|
}
|
|
}
|
|
var value = object[key],
|
|
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
|
isCommon = typeof result == 'undefined';
|
|
|
|
if (isCommon) {
|
|
result = srcValue;
|
|
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
|
|
result = isArray(value)
|
|
? value
|
|
: (value ? arrayCopy(value) : []);
|
|
}
|
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
result = isArguments(value)
|
|
? toPlainObject(value)
|
|
: (isPlainObject(value) ? value : {});
|
|
}
|
|
else {
|
|
isCommon = false;
|
|
}
|
|
}
|
|
// Add the source value to the stack of traversed objects and associate
|
|
// it with its merged value.
|
|
stackA.push(srcValue);
|
|
stackB.push(result);
|
|
|
|
if (isCommon) {
|
|
// Recursively merge objects and arrays (susceptible to call stack limits).
|
|
object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
|
|
} else if (result === result ? result !== value : value === value) {
|
|
object[key] = result;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.property` which does not coerce `key` to a string.
|
|
*
|
|
* @private
|
|
* @param {string} key The key of the property to get.
|
|
* @returns {Function} Returns the new function.
|
|
*/
|
|
function baseProperty(key) {
|
|
return function(object) {
|
|
return object == null ? undefined : object[key];
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.pullAt` without support for individual
|
|
* index arguments.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to modify.
|
|
* @param {number[]} indexes The indexes of elements to remove.
|
|
* @returns {Array} Returns the new array of removed elements.
|
|
*/
|
|
function basePullAt(array, indexes) {
|
|
var length = indexes.length,
|
|
result = baseAt(array, indexes);
|
|
|
|
indexes.sort(baseCompareAscending);
|
|
while (length--) {
|
|
var index = parseFloat(indexes[length]);
|
|
if (index != previous && isIndex(index)) {
|
|
var previous = index;
|
|
splice.call(array, index, 1);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.random` without support for argument juggling
|
|
* and returning floating-point numbers.
|
|
*
|
|
* @private
|
|
* @param {number} min The minimum possible value.
|
|
* @param {number} max The maximum possible value.
|
|
* @returns {number} Returns the random number.
|
|
*/
|
|
function baseRandom(min, max) {
|
|
return min + floor(nativeRandom() * (max - min + 1));
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.reduce` and `_.reduceRight` without support
|
|
* for callback shorthands or `this` binding, which iterates over `collection`
|
|
* using the provided `eachFunc`.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {*} accumulator The initial value.
|
|
* @param {boolean} initFromCollection Specify using the first or last element
|
|
* of `collection` as the initial value.
|
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
|
* @returns {*} Returns the accumulated value.
|
|
*/
|
|
function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
|
|
eachFunc(collection, function(value, index, collection) {
|
|
accumulator = initFromCollection
|
|
? (initFromCollection = false, value)
|
|
: iteratee(accumulator, value, index, collection);
|
|
});
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `setData` without support for hot loop detection.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to associate metadata with.
|
|
* @param {*} data The metadata.
|
|
* @returns {Function} Returns `func`.
|
|
*/
|
|
var baseSetData = !metaMap ? identity : function(func, data) {
|
|
metaMap.set(func, data);
|
|
return func;
|
|
};
|
|
|
|
/**
|
|
* The base implementation of `_.slice` without an iteratee call guard.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to slice.
|
|
* @param {number} [start=0] The start position.
|
|
* @param {number} [end=array.length] The end position.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
*/
|
|
function baseSlice(array, start, end) {
|
|
var index = -1,
|
|
length = array.length;
|
|
|
|
start = start == null ? 0 : (+start || 0);
|
|
if (start < 0) {
|
|
start = -start > length ? 0 : (length + start);
|
|
}
|
|
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
|
if (end < 0) {
|
|
end += length;
|
|
}
|
|
length = start > end ? 0 : (end - start) >>> 0;
|
|
start >>>= 0;
|
|
|
|
var result = Array(length);
|
|
while (++index < length) {
|
|
result[index] = array[index + start];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.some` without support for callback shorthands
|
|
* or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
* else `false`.
|
|
*/
|
|
function baseSome(collection, predicate) {
|
|
var result;
|
|
|
|
baseEach(collection, function(value, index, collection) {
|
|
result = predicate(value, index, collection);
|
|
return !result;
|
|
});
|
|
return !!result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.uniq` without support for callback shorthands
|
|
* and `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to inspect.
|
|
* @param {Function} [iteratee] The function invoked per iteration.
|
|
* @returns {Array} Returns the new duplicate-value-free array.
|
|
*/
|
|
function baseUniq(array, iteratee) {
|
|
var index = -1,
|
|
indexOf = getIndexOf(),
|
|
length = array.length,
|
|
isCommon = indexOf == baseIndexOf,
|
|
isLarge = isCommon && length >= 200,
|
|
seen = isLarge ? createCache() : null,
|
|
result = [];
|
|
|
|
if (seen) {
|
|
indexOf = cacheIndexOf;
|
|
isCommon = false;
|
|
} else {
|
|
isLarge = false;
|
|
seen = iteratee ? [] : result;
|
|
}
|
|
outer:
|
|
while (++index < length) {
|
|
var value = array[index],
|
|
computed = iteratee ? iteratee(value, index, array) : value;
|
|
|
|
if (isCommon && value === value) {
|
|
var seenIndex = seen.length;
|
|
while (seenIndex--) {
|
|
if (seen[seenIndex] === computed) {
|
|
continue outer;
|
|
}
|
|
}
|
|
if (iteratee) {
|
|
seen.push(computed);
|
|
}
|
|
result.push(value);
|
|
}
|
|
else if (indexOf(seen, computed) < 0) {
|
|
if (iteratee || isLarge) {
|
|
seen.push(computed);
|
|
}
|
|
result.push(value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.values` and `_.valuesIn` which creates an
|
|
* array of `object` property values corresponding to the property names
|
|
* returned by `keysFunc`.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to query.
|
|
* @param {Array} props The property names to get values for.
|
|
* @returns {Object} Returns the array of property values.
|
|
*/
|
|
function baseValues(object, props) {
|
|
var index = -1,
|
|
length = props.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = object[props[index]];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `wrapperValue` which returns the result of
|
|
* performing a sequence of actions on the unwrapped `value`, where each
|
|
* successive action is supplied the return value of the previous.
|
|
*
|
|
* @private
|
|
* @param {*} value The unwrapped value.
|
|
* @param {Array} actions Actions to peform to resolve the unwrapped value.
|
|
* @returns {*} Returns the resolved unwrapped value.
|
|
*/
|
|
function baseWrapperValue(value, actions) {
|
|
var result = value;
|
|
if (result instanceof LazyWrapper) {
|
|
result = result.value();
|
|
}
|
|
var index = -1,
|
|
length = actions.length;
|
|
|
|
while (++index < length) {
|
|
var args = [result],
|
|
action = actions[index];
|
|
|
|
push.apply(args, action.args);
|
|
result = action.func.apply(action.thisArg, args);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Performs a binary search of `array` to determine the index at which `value`
|
|
* should be inserted into `array` in order to maintain its sort order.
|
|
*
|
|
* @private
|
|
* @param {Array} array The sorted array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {boolean} [retHighest] Specify returning the highest, instead
|
|
* of the lowest, index at which a value should be inserted into `array`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
*/
|
|
function binaryIndex(array, value, retHighest) {
|
|
var low = 0,
|
|
high = array ? array.length : low;
|
|
|
|
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
|
|
while (low < high) {
|
|
var mid = (low + high) >>> 1,
|
|
computed = array[mid];
|
|
|
|
if (retHighest ? (computed <= value) : (computed < value)) {
|
|
low = mid + 1;
|
|
} else {
|
|
high = mid;
|
|
}
|
|
}
|
|
return high;
|
|
}
|
|
return binaryIndexBy(array, value, identity, retHighest);
|
|
}
|
|
|
|
/**
|
|
* This function is like `binaryIndex` except that it invokes `iteratee` for
|
|
* `value` and each element of `array` to compute their sort ranking. The
|
|
* iteratee is invoked with one argument; (value).
|
|
*
|
|
* @private
|
|
* @param {Array} array The sorted array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {boolean} [retHighest] Specify returning the highest, instead
|
|
* of the lowest, index at which a value should be inserted into `array`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
*/
|
|
function binaryIndexBy(array, value, iteratee, retHighest) {
|
|
value = iteratee(value);
|
|
|
|
var low = 0,
|
|
high = array ? array.length : 0,
|
|
valIsNaN = value !== value,
|
|
valIsUndef = typeof value == 'undefined';
|
|
|
|
while (low < high) {
|
|
var mid = floor((low + high) / 2),
|
|
computed = iteratee(array[mid]),
|
|
isReflexive = computed === computed;
|
|
|
|
if (valIsNaN) {
|
|
var setLow = isReflexive || retHighest;
|
|
} else if (valIsUndef) {
|
|
setLow = isReflexive && (retHighest || typeof computed != 'undefined');
|
|
} else {
|
|
setLow = retHighest ? (computed <= value) : (computed < value);
|
|
}
|
|
if (setLow) {
|
|
low = mid + 1;
|
|
} else {
|
|
high = mid;
|
|
}
|
|
}
|
|
return nativeMin(high, MAX_ARRAY_INDEX);
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseCallback` which only supports `this` binding
|
|
* and specifying the number of arguments to provide to `func`.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to bind.
|
|
* @param {*} thisArg The `this` binding of `func`.
|
|
* @param {number} [argCount] The number of arguments to provide to `func`.
|
|
* @returns {Function} Returns the callback.
|
|
*/
|
|
function bindCallback(func, thisArg, argCount) {
|
|
if (typeof func != 'function') {
|
|
return identity;
|
|
}
|
|
if (typeof thisArg == 'undefined') {
|
|
return func;
|
|
}
|
|
switch (argCount) {
|
|
case 1: return function(value) {
|
|
return func.call(thisArg, value);
|
|
};
|
|
case 3: return function(value, index, collection) {
|
|
return func.call(thisArg, value, index, collection);
|
|
};
|
|
case 4: return function(accumulator, value, index, collection) {
|
|
return func.call(thisArg, accumulator, value, index, collection);
|
|
};
|
|
case 5: return function(value, other, key, object, source) {
|
|
return func.call(thisArg, value, other, key, object, source);
|
|
};
|
|
}
|
|
return function() {
|
|
return func.apply(thisArg, arguments);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a clone of the given array buffer.
|
|
*
|
|
* @private
|
|
* @param {ArrayBuffer} buffer The array buffer to clone.
|
|
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
|
*/
|
|
function bufferClone(buffer) {
|
|
return bufferSlice.call(buffer, 0);
|
|
}
|
|
if (!bufferSlice) {
|
|
// PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`.
|
|
bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
|
|
var byteLength = buffer.byteLength,
|
|
floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
|
|
offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
|
|
result = new ArrayBuffer(byteLength);
|
|
|
|
if (floatLength) {
|
|
var view = new Float64Array(result, 0, floatLength);
|
|
view.set(new Float64Array(buffer, 0, floatLength));
|
|
}
|
|
if (byteLength != offset) {
|
|
view = new Uint8Array(result, offset);
|
|
view.set(new Uint8Array(buffer, offset));
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates an array that is the composition of partially applied arguments,
|
|
* placeholders, and provided arguments into a single array of arguments.
|
|
*
|
|
* @private
|
|
* @param {Array|Object} args The provided arguments.
|
|
* @param {Array} partials The arguments to prepend to those provided.
|
|
* @param {Array} holders The `partials` placeholder indexes.
|
|
* @returns {Array} Returns the new array of composed arguments.
|
|
*/
|
|
function composeArgs(args, partials, holders) {
|
|
var holdersLength = holders.length,
|
|
argsIndex = -1,
|
|
argsLength = nativeMax(args.length - holdersLength, 0),
|
|
leftIndex = -1,
|
|
leftLength = partials.length,
|
|
result = Array(argsLength + leftLength);
|
|
|
|
while (++leftIndex < leftLength) {
|
|
result[leftIndex] = partials[leftIndex];
|
|
}
|
|
while (++argsIndex < holdersLength) {
|
|
result[holders[argsIndex]] = args[argsIndex];
|
|
}
|
|
while (argsLength--) {
|
|
result[leftIndex++] = args[argsIndex++];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* This function is like `composeArgs` except that the arguments composition
|
|
* is tailored for `_.partialRight`.
|
|
*
|
|
* @private
|
|
* @param {Array|Object} args The provided arguments.
|
|
* @param {Array} partials The arguments to append to those provided.
|
|
* @param {Array} holders The `partials` placeholder indexes.
|
|
* @returns {Array} Returns the new array of composed arguments.
|
|
*/
|
|
function composeArgsRight(args, partials, holders) {
|
|
var holdersIndex = -1,
|
|
holdersLength = holders.length,
|
|
argsIndex = -1,
|
|
argsLength = nativeMax(args.length - holdersLength, 0),
|
|
rightIndex = -1,
|
|
rightLength = partials.length,
|
|
result = Array(argsLength + rightLength);
|
|
|
|
while (++argsIndex < argsLength) {
|
|
result[argsIndex] = args[argsIndex];
|
|
}
|
|
var pad = argsIndex;
|
|
while (++rightIndex < rightLength) {
|
|
result[pad + rightIndex] = partials[rightIndex];
|
|
}
|
|
while (++holdersIndex < holdersLength) {
|
|
result[pad + holders[holdersIndex]] = args[argsIndex++];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that aggregates a collection, creating an accumulator
|
|
* object composed from the results of running each element in the collection
|
|
* through an iteratee.
|
|
*
|
|
* @private
|
|
* @param {Function} setter The function to set keys and values of the accumulator object.
|
|
* @param {Function} [initializer] The function to initialize the accumulator object.
|
|
* @returns {Function} Returns the new aggregator function.
|
|
*/
|
|
function createAggregator(setter, initializer) {
|
|
return function(collection, iteratee, thisArg) {
|
|
var result = initializer ? initializer() : {};
|
|
iteratee = getCallback(iteratee, thisArg, 3);
|
|
|
|
if (isArray(collection)) {
|
|
var index = -1,
|
|
length = collection.length;
|
|
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
setter(result, value, iteratee(value, index, collection), collection);
|
|
}
|
|
} else {
|
|
baseEach(collection, function(value, key, collection) {
|
|
setter(result, value, iteratee(value, key, collection), collection);
|
|
});
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that assigns properties of source object(s) to a given
|
|
* destination object.
|
|
*
|
|
* @private
|
|
* @param {Function} assigner The function to assign values.
|
|
* @returns {Function} Returns the new assigner function.
|
|
*/
|
|
function createAssigner(assigner) {
|
|
return function() {
|
|
var length = arguments.length,
|
|
object = arguments[0];
|
|
|
|
if (length < 2 || object == null) {
|
|
return object;
|
|
}
|
|
if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) {
|
|
length = 2;
|
|
}
|
|
// Juggle arguments.
|
|
if (length > 3 && typeof arguments[length - 2] == 'function') {
|
|
var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5);
|
|
} else if (length > 2 && typeof arguments[length - 1] == 'function') {
|
|
customizer = arguments[--length];
|
|
}
|
|
var index = 0;
|
|
while (++index < length) {
|
|
var source = arguments[index];
|
|
if (source) {
|
|
assigner(object, source, customizer);
|
|
}
|
|
}
|
|
return object;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that wraps `func` and invokes it with the `this`
|
|
* binding of `thisArg`.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to bind.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @returns {Function} Returns the new bound function.
|
|
*/
|
|
function createBindWrapper(func, thisArg) {
|
|
var Ctor = createCtorWrapper(func);
|
|
|
|
function wrapper() {
|
|
return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments);
|
|
}
|
|
return wrapper;
|
|
}
|
|
|
|
/**
|
|
* Creates a `Set` cache object to optimize linear searches of large arrays.
|
|
*
|
|
* @private
|
|
* @param {Array} [values] The values to cache.
|
|
* @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
|
|
*/
|
|
var createCache = !(nativeCreate && Set) ? constant(null) : function(values) {
|
|
return new SetCache(values);
|
|
};
|
|
|
|
/**
|
|
* Creates a function that produces compound words out of the words in a
|
|
* given string.
|
|
*
|
|
* @private
|
|
* @param {Function} callback The function to combine each word.
|
|
* @returns {Function} Returns the new compounder function.
|
|
*/
|
|
function createCompounder(callback) {
|
|
return function(string) {
|
|
var index = -1,
|
|
array = words(deburr(string)),
|
|
length = array.length,
|
|
result = '';
|
|
|
|
while (++index < length) {
|
|
result = callback(result, array[index], index);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that produces an instance of `Ctor` regardless of
|
|
* whether it was invoked as part of a `new` expression or by `call` or `apply`.
|
|
*
|
|
* @private
|
|
* @param {Function} Ctor The constructor to wrap.
|
|
* @returns {Function} Returns the new wrapped function.
|
|
*/
|
|
function createCtorWrapper(Ctor) {
|
|
return function() {
|
|
var thisBinding = baseCreate(Ctor.prototype),
|
|
result = Ctor.apply(thisBinding, arguments);
|
|
|
|
// Mimic the constructor's `return` behavior.
|
|
// See https://es5.github.io/#x13.2.2 for more details.
|
|
return isObject(result) ? result : thisBinding;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that gets the extremum value of a collection.
|
|
*
|
|
* @private
|
|
* @param {Function} arrayFunc The function to get the extremum value from an array.
|
|
* @param {boolean} [isMin] Specify returning the minimum, instead of the maximum,
|
|
* extremum value.
|
|
* @returns {Function} Returns the new extremum function.
|
|
*/
|
|
function createExtremum(arrayFunc, isMin) {
|
|
return function(collection, iteratee, thisArg) {
|
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
|
iteratee = null;
|
|
}
|
|
var func = getCallback(),
|
|
noIteratee = iteratee == null;
|
|
|
|
if (!(func === baseCallback && noIteratee)) {
|
|
noIteratee = false;
|
|
iteratee = func(iteratee, thisArg, 3);
|
|
}
|
|
if (noIteratee) {
|
|
var isArr = isArray(collection);
|
|
if (!isArr && isString(collection)) {
|
|
iteratee = charAtCallback;
|
|
} else {
|
|
return arrayFunc(isArr ? collection : toIterable(collection));
|
|
}
|
|
}
|
|
return extremumBy(collection, iteratee, isMin);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that wraps `func` and invokes it with optional `this`
|
|
* binding of, partial application, and currying.
|
|
*
|
|
* @private
|
|
* @param {Function|string} func The function or method name to reference.
|
|
* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param {Array} [partials] The arguments to prepend to those provided to the new function.
|
|
* @param {Array} [holders] The `partials` placeholder indexes.
|
|
* @param {Array} [partialsRight] The arguments to append to those provided to the new function.
|
|
* @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
|
|
* @param {Array} [argPos] The argument positions of the new function.
|
|
* @param {number} [ary] The arity cap of `func`.
|
|
* @param {number} [arity] The arity of `func`.
|
|
* @returns {Function} Returns the new wrapped function.
|
|
*/
|
|
function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
|
|
var isAry = bitmask & ARY_FLAG,
|
|
isBind = bitmask & BIND_FLAG,
|
|
isBindKey = bitmask & BIND_KEY_FLAG,
|
|
isCurry = bitmask & CURRY_FLAG,
|
|
isCurryBound = bitmask & CURRY_BOUND_FLAG,
|
|
isCurryRight = bitmask & CURRY_RIGHT_FLAG;
|
|
|
|
var Ctor = !isBindKey && createCtorWrapper(func),
|
|
key = func;
|
|
|
|
function wrapper() {
|
|
// Avoid `arguments` object use disqualifying optimizations by
|
|
// converting it to an array before providing it to other functions.
|
|
var length = arguments.length,
|
|
index = length,
|
|
args = Array(length);
|
|
|
|
while (index--) {
|
|
args[index] = arguments[index];
|
|
}
|
|
if (partials) {
|
|
args = composeArgs(args, partials, holders);
|
|
}
|
|
if (partialsRight) {
|
|
args = composeArgsRight(args, partialsRight, holdersRight);
|
|
}
|
|
if (isCurry || isCurryRight) {
|
|
var placeholder = wrapper.placeholder,
|
|
argsHolders = replaceHolders(args, placeholder);
|
|
|
|
length -= argsHolders.length;
|
|
if (length < arity) {
|
|
var newArgPos = argPos ? arrayCopy(argPos) : null,
|
|
newArity = nativeMax(arity - length, 0),
|
|
newsHolders = isCurry ? argsHolders : null,
|
|
newHoldersRight = isCurry ? null : argsHolders,
|
|
newPartials = isCurry ? args : null,
|
|
newPartialsRight = isCurry ? null : args;
|
|
|
|
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
|
|
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
|
|
|
|
if (!isCurryBound) {
|
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
|
}
|
|
var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity);
|
|
result.placeholder = placeholder;
|
|
return result;
|
|
}
|
|
}
|
|
var thisBinding = isBind ? thisArg : this;
|
|
if (isBindKey) {
|
|
func = thisBinding[key];
|
|
}
|
|
if (argPos) {
|
|
args = reorder(args, argPos);
|
|
}
|
|
if (isAry && ary < args.length) {
|
|
args.length = ary;
|
|
}
|
|
return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args);
|
|
}
|
|
return wrapper;
|
|
}
|
|
|
|
/**
|
|
* Creates the pad required for `string` based on the given padding length.
|
|
* The `chars` string may be truncated if the number of padding characters
|
|
* exceeds the padding length.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to create padding for.
|
|
* @param {number} [length=0] The padding length.
|
|
* @param {string} [chars=' '] The string used as padding.
|
|
* @returns {string} Returns the pad for `string`.
|
|
*/
|
|
function createPad(string, length, chars) {
|
|
var strLength = string.length;
|
|
length = +length;
|
|
|
|
if (strLength >= length || !nativeIsFinite(length)) {
|
|
return '';
|
|
}
|
|
var padLength = length - strLength;
|
|
chars = chars == null ? ' ' : (chars + '');
|
|
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that wraps `func` and invokes it with the optional `this`
|
|
* binding of `thisArg` and the `partials` prepended to those provided to
|
|
* the wrapper.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to partially apply arguments to.
|
|
* @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
|
|
* @param {*} thisArg The `this` binding of `func`.
|
|
* @param {Array} partials The arguments to prepend to those provided to the new function.
|
|
* @returns {Function} Returns the new bound function.
|
|
*/
|
|
function createPartialWrapper(func, bitmask, thisArg, partials) {
|
|
var isBind = bitmask & BIND_FLAG,
|
|
Ctor = createCtorWrapper(func);
|
|
|
|
function wrapper() {
|
|
// Avoid `arguments` object use disqualifying optimizations by
|
|
// converting it to an array before providing it `func`.
|
|
var argsIndex = -1,
|
|
argsLength = arguments.length,
|
|
leftIndex = -1,
|
|
leftLength = partials.length,
|
|
args = Array(argsLength + leftLength);
|
|
|
|
while (++leftIndex < leftLength) {
|
|
args[leftIndex] = partials[leftIndex];
|
|
}
|
|
while (argsLength--) {
|
|
args[leftIndex++] = arguments[++argsIndex];
|
|
}
|
|
return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args);
|
|
}
|
|
return wrapper;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that either curries or invokes `func` with optional
|
|
* `this` binding and partially applied arguments.
|
|
*
|
|
* @private
|
|
* @param {Function|string} func The function or method name to reference.
|
|
* @param {number} bitmask The bitmask of flags.
|
|
* The bitmask may be composed of the following flags:
|
|
* 1 - `_.bind`
|
|
* 2 - `_.bindKey`
|
|
* 4 - `_.curry` or `_.curryRight` of a bound function
|
|
* 8 - `_.curry`
|
|
* 16 - `_.curryRight`
|
|
* 32 - `_.partial`
|
|
* 64 - `_.partialRight`
|
|
* 128 - `_.rearg`
|
|
* 256 - `_.ary`
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param {Array} [partials] The arguments to be partially applied.
|
|
* @param {Array} [holders] The `partials` placeholder indexes.
|
|
* @param {Array} [argPos] The argument positions of the new function.
|
|
* @param {number} [ary] The arity cap of `func`.
|
|
* @param {number} [arity] The arity of `func`.
|
|
* @returns {Function} Returns the new wrapped function.
|
|
*/
|
|
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
|
|
var isBindKey = bitmask & BIND_KEY_FLAG;
|
|
if (!isBindKey && typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
var length = partials ? partials.length : 0;
|
|
if (!length) {
|
|
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
|
|
partials = holders = null;
|
|
}
|
|
length -= (holders ? holders.length : 0);
|
|
if (bitmask & PARTIAL_RIGHT_FLAG) {
|
|
var partialsRight = partials,
|
|
holdersRight = holders;
|
|
|
|
partials = holders = null;
|
|
}
|
|
var data = !isBindKey && getData(func),
|
|
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
|
|
|
if (data && data !== true) {
|
|
mergeData(newData, data);
|
|
bitmask = newData[1];
|
|
arity = newData[9];
|
|
}
|
|
newData[9] = arity == null
|
|
? (isBindKey ? 0 : func.length)
|
|
: (nativeMax(arity - length, 0) || 0);
|
|
|
|
if (bitmask == BIND_FLAG) {
|
|
var result = createBindWrapper(newData[0], newData[2]);
|
|
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
|
|
result = createPartialWrapper.apply(undefined, newData);
|
|
} else {
|
|
result = createHybridWrapper.apply(undefined, newData);
|
|
}
|
|
var setter = data ? baseSetData : setData;
|
|
return setter(result, newData);
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseIsEqualDeep` for arrays with support for
|
|
* partial deep comparisons.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to compare.
|
|
* @param {Array} other The other array to compare.
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
* @param {Function} [customizer] The function to customize comparing arrays.
|
|
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
|
* @param {Array} [stackA] Tracks traversed `value` objects.
|
|
* @param {Array} [stackB] Tracks traversed `other` objects.
|
|
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
|
*/
|
|
function equalArrays(array, other, equalFunc, customizer, isWhere, stackA, stackB) {
|
|
var index = -1,
|
|
arrLength = array.length,
|
|
othLength = other.length,
|
|
result = true;
|
|
|
|
if (arrLength != othLength && !(isWhere && othLength > arrLength)) {
|
|
return false;
|
|
}
|
|
// Deep compare the contents, ignoring non-numeric properties.
|
|
while (result && ++index < arrLength) {
|
|
var arrValue = array[index],
|
|
othValue = other[index];
|
|
|
|
result = undefined;
|
|
if (customizer) {
|
|
result = isWhere
|
|
? customizer(othValue, arrValue, index)
|
|
: customizer(arrValue, othValue, index);
|
|
}
|
|
if (typeof result == 'undefined') {
|
|
// Recursively compare arrays (susceptible to call stack limits).
|
|
if (isWhere) {
|
|
var othIndex = othLength;
|
|
while (othIndex--) {
|
|
othValue = other[othIndex];
|
|
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB);
|
|
if (result) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB);
|
|
}
|
|
}
|
|
}
|
|
return !!result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseIsEqualDeep` for comparing objects of
|
|
* the same `toStringTag`.
|
|
*
|
|
* **Note:** This function only supports comparing values with tags of
|
|
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
*
|
|
* @private
|
|
* @param {Object} value The object to compare.
|
|
* @param {Object} other The other object to compare.
|
|
* @param {string} tag The `toStringTag` of the objects to compare.
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
*/
|
|
function equalByTag(object, other, tag) {
|
|
switch (tag) {
|
|
case boolTag:
|
|
case dateTag:
|
|
// Coerce dates and booleans to numbers, dates to milliseconds and booleans
|
|
// to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
|
|
return +object == +other;
|
|
|
|
case errorTag:
|
|
return object.name == other.name && object.message == other.message;
|
|
|
|
case numberTag:
|
|
// Treat `NaN` vs. `NaN` as equal.
|
|
return (object != +object)
|
|
? other != +other
|
|
// But, treat `-0` vs. `+0` as not equal.
|
|
: (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
|
|
|
|
case regexpTag:
|
|
case stringTag:
|
|
// Coerce regexes to strings and treat strings primitives and string
|
|
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
|
return object == (other + '');
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `baseIsEqualDeep` for objects with support for
|
|
* partial deep comparisons.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to compare.
|
|
* @param {Object} other The other object to compare.
|
|
* @param {Function} equalFunc The function to determine equivalents of values.
|
|
* @param {Function} [customizer] The function to customize comparing values.
|
|
* @param {boolean} [isWhere] Specify performing partial comparisons.
|
|
* @param {Array} [stackA] Tracks traversed `value` objects.
|
|
* @param {Array} [stackB] Tracks traversed `other` objects.
|
|
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
|
|
*/
|
|
function equalObjects(object, other, equalFunc, customizer, isWhere, stackA, stackB) {
|
|
var objProps = keys(object),
|
|
objLength = objProps.length,
|
|
othProps = keys(other),
|
|
othLength = othProps.length;
|
|
|
|
if (objLength != othLength && !isWhere) {
|
|
return false;
|
|
}
|
|
var hasCtor,
|
|
index = -1;
|
|
|
|
while (++index < objLength) {
|
|
var key = objProps[index],
|
|
result = hasOwnProperty.call(other, key);
|
|
|
|
if (result) {
|
|
var objValue = object[key],
|
|
othValue = other[key];
|
|
|
|
result = undefined;
|
|
if (customizer) {
|
|
result = isWhere
|
|
? customizer(othValue, objValue, key)
|
|
: customizer(objValue, othValue, key);
|
|
}
|
|
if (typeof result == 'undefined') {
|
|
// Recursively compare objects (susceptible to call stack limits).
|
|
result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB);
|
|
}
|
|
}
|
|
if (!result) {
|
|
return false;
|
|
}
|
|
hasCtor || (hasCtor = key == 'constructor');
|
|
}
|
|
if (!hasCtor) {
|
|
var objCtor = object.constructor,
|
|
othCtor = other.constructor;
|
|
|
|
// Non `Object` object instances with different constructors are not equal.
|
|
if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) &&
|
|
!(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Gets the extremum value of `collection` invoking `iteratee` for each value
|
|
* in `collection` to generate the criterion by which the value is ranked.
|
|
* The `iteratee` is invoked with three arguments; (value, index, collection).
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} iteratee The function invoked per iteration.
|
|
* @param {boolean} [isMin] Specify returning the minimum, instead of the
|
|
* maximum, extremum value.
|
|
* @returns {*} Returns the extremum value.
|
|
*/
|
|
function extremumBy(collection, iteratee, isMin) {
|
|
var exValue = isMin ? POSITIVE_INFINITY : NEGATIVE_INFINITY,
|
|
computed = exValue,
|
|
result = computed;
|
|
|
|
baseEach(collection, function(value, index, collection) {
|
|
var current = iteratee(value, index, collection);
|
|
if ((isMin ? current < computed : current > computed) || (current === exValue && current === result)) {
|
|
computed = current;
|
|
result = value;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets the appropriate "callback" function. If the `_.callback` method is
|
|
* customized this function returns the custom method, otherwise it returns
|
|
* the `baseCallback` function. If arguments are provided the chosen function
|
|
* is invoked with them and its result is returned.
|
|
*
|
|
* @private
|
|
* @returns {Function} Returns the chosen function or its result.
|
|
*/
|
|
function getCallback(func, thisArg, argCount) {
|
|
var result = lodash.callback || callback;
|
|
result = result === callback ? baseCallback : result;
|
|
return argCount ? result(func, thisArg, argCount) : result;
|
|
}
|
|
|
|
/**
|
|
* Gets metadata for `func`.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to query.
|
|
* @returns {*} Returns the metadata for `func`.
|
|
*/
|
|
var getData = !metaMap ? noop : function(func) {
|
|
return metaMap.get(func);
|
|
};
|
|
|
|
/**
|
|
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
|
* customized this function returns the custom method, otherwise it returns
|
|
* the `baseIndexOf` function. If arguments are provided the chosen function
|
|
* is invoked with them and its result is returned.
|
|
*
|
|
* @private
|
|
* @returns {Function|number} Returns the chosen function or its result.
|
|
*/
|
|
function getIndexOf(collection, target, fromIndex) {
|
|
var result = lodash.indexOf || indexOf;
|
|
result = result === indexOf ? baseIndexOf : result;
|
|
return collection ? result(collection, target, fromIndex) : result;
|
|
}
|
|
|
|
/**
|
|
* Gets the view, applying any `transforms` to the `start` and `end` positions.
|
|
*
|
|
* @private
|
|
* @param {number} start The start of the view.
|
|
* @param {number} end The end of the view.
|
|
* @param {Array} [transforms] The transformations to apply to the view.
|
|
* @returns {Object} Returns an object containing the `start` and `end`
|
|
* positions of the view.
|
|
*/
|
|
function getView(start, end, transforms) {
|
|
var index = -1,
|
|
length = transforms ? transforms.length : 0;
|
|
|
|
while (++index < length) {
|
|
var data = transforms[index],
|
|
size = data.size;
|
|
|
|
switch (data.type) {
|
|
case 'drop': start += size; break;
|
|
case 'dropRight': end -= size; break;
|
|
case 'take': end = nativeMin(end, start + size); break;
|
|
case 'takeRight': start = nativeMax(start, end - size); break;
|
|
}
|
|
}
|
|
return { 'start': start, 'end': end };
|
|
}
|
|
|
|
/**
|
|
* Initializes an array clone.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to clone.
|
|
* @returns {Array} Returns the initialized clone.
|
|
*/
|
|
function initCloneArray(array) {
|
|
var length = array.length,
|
|
result = new array.constructor(length);
|
|
|
|
// Add array properties assigned by `RegExp#exec`.
|
|
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
|
result.index = array.index;
|
|
result.input = array.input;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Initializes an object clone.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to clone.
|
|
* @returns {Object} Returns the initialized clone.
|
|
*/
|
|
function initCloneObject(object) {
|
|
var Ctor = object.constructor;
|
|
if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
|
|
Ctor = Object;
|
|
}
|
|
return new Ctor;
|
|
}
|
|
|
|
/**
|
|
* Initializes an object clone based on its `toStringTag`.
|
|
*
|
|
* **Note:** This function only supports cloning values with tags of
|
|
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
|
*
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to clone.
|
|
* @param {string} tag The `toStringTag` of the object to clone.
|
|
* @param {boolean} [isDeep] Specify a deep clone.
|
|
* @returns {Object} Returns the initialized clone.
|
|
*/
|
|
function initCloneByTag(object, tag, isDeep) {
|
|
var Ctor = object.constructor;
|
|
switch (tag) {
|
|
case arrayBufferTag:
|
|
return bufferClone(object);
|
|
|
|
case boolTag:
|
|
case dateTag:
|
|
return new Ctor(+object);
|
|
|
|
case float32Tag: case float64Tag:
|
|
case int8Tag: case int16Tag: case int32Tag:
|
|
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
|
var buffer = object.buffer;
|
|
return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
|
|
|
|
case numberTag:
|
|
case stringTag:
|
|
return new Ctor(object);
|
|
|
|
case regexpTag:
|
|
var result = new Ctor(object.source, reFlags.exec(object));
|
|
result.lastIndex = object.lastIndex;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Checks if `func` is eligible for `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to check.
|
|
* @returns {boolean} Returns `true` if `func` is eligible, else `false`.
|
|
*/
|
|
function isBindable(func) {
|
|
var support = lodash.support,
|
|
result = !(support.funcNames ? func.name : support.funcDecomp);
|
|
|
|
if (!result) {
|
|
var source = fnToString.call(func);
|
|
if (!support.funcNames) {
|
|
result = !reFuncName.test(source);
|
|
}
|
|
if (!result) {
|
|
// Check if `func` references the `this` keyword and store the result.
|
|
result = reThis.test(source) || isNative(func);
|
|
baseSetData(func, result);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a valid array-like index.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
*/
|
|
function isIndex(value, length) {
|
|
value = +value;
|
|
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
return value > -1 && value % 1 == 0 && value < length;
|
|
}
|
|
|
|
/**
|
|
* Checks if the provided arguments are from an iteratee call.
|
|
*
|
|
* @private
|
|
* @param {*} value The potential iteratee value argument.
|
|
* @param {*} index The potential iteratee index or key argument.
|
|
* @param {*} object The potential iteratee object argument.
|
|
* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
|
|
*/
|
|
function isIterateeCall(value, index, object) {
|
|
if (!isObject(object)) {
|
|
return false;
|
|
}
|
|
var type = typeof index;
|
|
if (type == 'number') {
|
|
var length = object.length,
|
|
prereq = isLength(length) && isIndex(index, length);
|
|
} else {
|
|
prereq = type == 'string' && index in object;
|
|
}
|
|
if (prereq) {
|
|
var other = object[index];
|
|
return value === value ? value === other : other !== other;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a valid array-like length.
|
|
*
|
|
* **Note:** This function is based on ES `ToLength`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
|
* for more details.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
*/
|
|
function isLength(value) {
|
|
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` if suitable for strict
|
|
* equality comparisons, else `false`.
|
|
*/
|
|
function isStrictComparable(value) {
|
|
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
|
|
}
|
|
|
|
/**
|
|
* Merges the function metadata of `source` into `data`.
|
|
*
|
|
* Merging metadata reduces the number of wrappers required to invoke a function.
|
|
* This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
|
|
* may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`
|
|
* augment function arguments, making the order in which they are executed important,
|
|
* preventing the merging of metadata. However, we make an exception for a safe
|
|
* common case where curried functions have `_.ary` and or `_.rearg` applied.
|
|
*
|
|
* @private
|
|
* @param {Array} data The destination metadata.
|
|
* @param {Array} source The source metadata.
|
|
* @returns {Array} Returns `data`.
|
|
*/
|
|
function mergeData(data, source) {
|
|
var bitmask = data[1],
|
|
srcBitmask = source[1],
|
|
newBitmask = bitmask | srcBitmask;
|
|
|
|
var arityFlags = ARY_FLAG | REARG_FLAG,
|
|
bindFlags = BIND_FLAG | BIND_KEY_FLAG,
|
|
comboFlags = arityFlags | bindFlags | CURRY_BOUND_FLAG | CURRY_RIGHT_FLAG;
|
|
|
|
var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG),
|
|
isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG),
|
|
argPos = (isRearg ? data : source)[7],
|
|
ary = (isAry ? data : source)[8];
|
|
|
|
var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) &&
|
|
!(bitmask > bindFlags && srcBitmask >= REARG_FLAG);
|
|
|
|
var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) &&
|
|
(bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary));
|
|
|
|
// Exit early if metadata can't be merged.
|
|
if (!(isCommon || isCombo)) {
|
|
return data;
|
|
}
|
|
// Use source `thisArg` if available.
|
|
if (srcBitmask & BIND_FLAG) {
|
|
data[2] = source[2];
|
|
// Set when currying a bound function.
|
|
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
|
|
}
|
|
// Compose partial arguments.
|
|
var value = source[3];
|
|
if (value) {
|
|
var partials = data[3];
|
|
data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);
|
|
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);
|
|
}
|
|
// Compose partial right arguments.
|
|
value = source[5];
|
|
if (value) {
|
|
partials = data[5];
|
|
data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);
|
|
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);
|
|
}
|
|
// Use source `argPos` if available.
|
|
value = source[7];
|
|
if (value) {
|
|
data[7] = arrayCopy(value);
|
|
}
|
|
// Use source `ary` if it's smaller.
|
|
if (srcBitmask & ARY_FLAG) {
|
|
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
|
|
}
|
|
// Use source `arity` if one is not provided.
|
|
if (data[9] == null) {
|
|
data[9] = source[9];
|
|
}
|
|
// Use source `func` and merge bitmasks.
|
|
data[0] = source[0];
|
|
data[1] = newBitmask;
|
|
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.pick` that picks `object` properties specified
|
|
* by the `props` array.
|
|
*
|
|
* @private
|
|
* @param {Object} object The source object.
|
|
* @param {string[]} props The property names to pick.
|
|
* @returns {Object} Returns the new object.
|
|
*/
|
|
function pickByArray(object, props) {
|
|
object = toObject(object);
|
|
|
|
var index = -1,
|
|
length = props.length,
|
|
result = {};
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (key in object) {
|
|
result[key] = object[key];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* A specialized version of `_.pick` that picks `object` properties `predicate`
|
|
* returns truthy for.
|
|
*
|
|
* @private
|
|
* @param {Object} object The source object.
|
|
* @param {Function} predicate The function invoked per iteration.
|
|
* @returns {Object} Returns the new object.
|
|
*/
|
|
function pickByCallback(object, predicate) {
|
|
var result = {};
|
|
baseForIn(object, function(value, key, object) {
|
|
if (predicate(value, key, object)) {
|
|
result[key] = value;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Reorder `array` according to the specified indexes where the element at
|
|
* the first index is assigned as the first element, the element at
|
|
* the second index is assigned as the second element, and so on.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to reorder.
|
|
* @param {Array} indexes The arranged array indexes.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function reorder(array, indexes) {
|
|
var arrLength = array.length,
|
|
length = nativeMin(indexes.length, arrLength),
|
|
oldArray = arrayCopy(array);
|
|
|
|
while (length--) {
|
|
var index = indexes[length];
|
|
array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* Sets metadata for `func`.
|
|
*
|
|
* **Note:** If this function becomes hot, i.e. is invoked a lot in a short
|
|
* period of time, it will trip its breaker and transition to an identity function
|
|
* to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)
|
|
* for more details.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to associate metadata with.
|
|
* @param {*} data The metadata.
|
|
* @returns {Function} Returns `func`.
|
|
*/
|
|
var setData = (function() {
|
|
var count = 0,
|
|
lastCalled = 0;
|
|
|
|
return function(key, value) {
|
|
var stamp = now(),
|
|
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
|
|
lastCalled = stamp;
|
|
if (remaining > 0) {
|
|
if (++count >= HOT_COUNT) {
|
|
return key;
|
|
}
|
|
} else {
|
|
count = 0;
|
|
}
|
|
return baseSetData(key, value);
|
|
};
|
|
}());
|
|
|
|
/**
|
|
* A fallback implementation of `_.isPlainObject` which checks if `value`
|
|
* is an object created by the `Object` constructor or has a `[[Prototype]]`
|
|
* of `null`.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
*/
|
|
function shimIsPlainObject(value) {
|
|
var Ctor,
|
|
support = lodash.support;
|
|
|
|
// Exit early for non `Object` objects.
|
|
if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
|
|
(!hasOwnProperty.call(value, 'constructor') &&
|
|
(Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
|
|
return false;
|
|
}
|
|
// IE < 9 iterates inherited properties before own properties. If the first
|
|
// iterated property is an object's own property then there are no inherited
|
|
// enumerable properties.
|
|
var result;
|
|
// In most environments an object's own properties are iterated before
|
|
// its inherited properties. If the last iterated property is an object's
|
|
// own property then there are no inherited enumerable properties.
|
|
baseForIn(value, function(subValue, key) {
|
|
result = key;
|
|
});
|
|
return typeof result == 'undefined' || hasOwnProperty.call(value, result);
|
|
}
|
|
|
|
/**
|
|
* A fallback implementation of `Object.keys` which creates an array of the
|
|
* own enumerable property names of `object`.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns the array of property names.
|
|
*/
|
|
function shimKeys(object) {
|
|
var props = keysIn(object),
|
|
propsLength = props.length,
|
|
length = propsLength && object.length,
|
|
support = lodash.support;
|
|
|
|
var allowIndexes = length && isLength(length) &&
|
|
(isArray(object) || (support.nonEnumArgs && isArguments(object)));
|
|
|
|
var index = -1,
|
|
result = [];
|
|
|
|
while (++index < propsLength) {
|
|
var key = props[index];
|
|
if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
|
|
result.push(key);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Converts `value` to an array-like object if it is not one.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to process.
|
|
* @returns {Array|Object} Returns the array-like object.
|
|
*/
|
|
function toIterable(value) {
|
|
if (value == null) {
|
|
return [];
|
|
}
|
|
if (!isLength(value.length)) {
|
|
return values(value);
|
|
}
|
|
return isObject(value) ? value : Object(value);
|
|
}
|
|
|
|
/**
|
|
* Converts `value` to an object if it is not one.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to process.
|
|
* @returns {Object} Returns the object.
|
|
*/
|
|
function toObject(value) {
|
|
return isObject(value) ? value : Object(value);
|
|
}
|
|
|
|
/**
|
|
* Creates a clone of `wrapper`.
|
|
*
|
|
* @private
|
|
* @param {Object} wrapper The wrapper to clone.
|
|
* @returns {Object} Returns the cloned wrapper.
|
|
*/
|
|
function wrapperClone(wrapper) {
|
|
return wrapper instanceof LazyWrapper
|
|
? wrapper.clone()
|
|
: new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates an array of elements split into groups the length of `size`.
|
|
* If `collection` can't be split evenly, the final chunk will be the remaining
|
|
* elements.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to process.
|
|
* @param {number} [size=1] The length of each chunk.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the new array containing chunks.
|
|
* @example
|
|
*
|
|
* _.chunk(['a', 'b', 'c', 'd'], 2);
|
|
* // => [['a', 'b'], ['c', 'd']]
|
|
*
|
|
* _.chunk(['a', 'b', 'c', 'd'], 3);
|
|
* // => [['a', 'b', 'c'], ['d']]
|
|
*/
|
|
function chunk(array, size, guard) {
|
|
if (guard ? isIterateeCall(array, size, guard) : size == null) {
|
|
size = 1;
|
|
} else {
|
|
size = nativeMax(+size || 1, 1);
|
|
}
|
|
var index = 0,
|
|
length = array ? array.length : 0,
|
|
resIndex = -1,
|
|
result = Array(ceil(length / size));
|
|
|
|
while (index < length) {
|
|
result[++resIndex] = baseSlice(array, index, (index += size));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array with all falsey values removed. The values `false`, `null`,
|
|
* `0`, `""`, `undefined`, and `NaN` are falsey.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to compact.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.compact([0, 1, false, 2, '', 3]);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function compact(array) {
|
|
var index = -1,
|
|
length = array ? array.length : 0,
|
|
resIndex = -1,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (value) {
|
|
result[++resIndex] = value;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array excluding all values of the provided arrays using
|
|
* `SameValueZero` for equality comparisons.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to inspect.
|
|
* @param {...Array} [values] The arrays of values to exclude.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.difference([1, 2, 3], [4, 2]);
|
|
* // => [1, 3]
|
|
*/
|
|
function difference() {
|
|
var index = -1,
|
|
length = arguments.length;
|
|
|
|
while (++index < length) {
|
|
var value = arguments[index];
|
|
if (isArray(value) || isArguments(value)) {
|
|
break;
|
|
}
|
|
}
|
|
return baseDifference(value, baseFlatten(arguments, false, true, ++index));
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with `n` elements dropped from the beginning.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {number} [n=1] The number of elements to drop.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.drop([1, 2, 3]);
|
|
* // => [2, 3]
|
|
*
|
|
* _.drop([1, 2, 3], 2);
|
|
* // => [3]
|
|
*
|
|
* _.drop([1, 2, 3], 5);
|
|
* // => []
|
|
*
|
|
* _.drop([1, 2, 3], 0);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function drop(array, n, guard) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
n = 1;
|
|
}
|
|
return baseSlice(array, n < 0 ? 0 : n);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with `n` elements dropped from the end.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {number} [n=1] The number of elements to drop.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.dropRight([1, 2, 3]);
|
|
* // => [1, 2]
|
|
*
|
|
* _.dropRight([1, 2, 3], 2);
|
|
* // => [1]
|
|
*
|
|
* _.dropRight([1, 2, 3], 5);
|
|
* // => []
|
|
*
|
|
* _.dropRight([1, 2, 3], 0);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function dropRight(array, n, guard) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
n = 1;
|
|
}
|
|
n = length - (+n || 0);
|
|
return baseSlice(array, 0, n < 0 ? 0 : n);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` excluding elements dropped from the end.
|
|
* Elements are dropped until `predicate` returns falsey. The predicate is
|
|
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that match the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.dropRightWhile([1, 2, 3], function(n) {
|
|
* return n > 1;
|
|
* });
|
|
* // => [1]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': true },
|
|
* { 'user': 'fred', 'active': false },
|
|
* { 'user': 'pebbles', 'active': false }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user');
|
|
* // => ['barney', 'fred']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.dropRightWhile(users, 'active', false), 'user');
|
|
* // => ['barney']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
|
|
* // => ['barney', 'fred', 'pebbles']
|
|
*/
|
|
function dropRightWhile(array, predicate, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (length-- && predicate(array[length], length, array)) {}
|
|
return baseSlice(array, 0, length + 1);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` excluding elements dropped from the beginning.
|
|
* Elements are dropped until `predicate` returns falsey. The predicate is
|
|
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.dropWhile([1, 2, 3], function(n) {
|
|
* return n < 3;
|
|
* });
|
|
* // => [3]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': false },
|
|
* { 'user': 'fred', 'active': false },
|
|
* { 'user': 'pebbles', 'active': true }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
|
|
* // => ['fred', 'pebbles']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.dropWhile(users, 'active', false), 'user');
|
|
* // => ['pebbles']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.dropWhile(users, 'active'), 'user');
|
|
* // => ['barney', 'fred', 'pebbles']
|
|
*/
|
|
function dropWhile(array, predicate, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
var index = -1;
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (++index < length && predicate(array[index], index, array)) {}
|
|
return baseSlice(array, index);
|
|
}
|
|
|
|
/**
|
|
* Fills elements of `array` with `value` from `start` up to, but not
|
|
* including, `end`.
|
|
*
|
|
* **Note:** This method mutates `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to fill.
|
|
* @param {*} value The value to fill `array` with.
|
|
* @param {number} [start=0] The start position.
|
|
* @param {number} [end=array.length] The end position.
|
|
* @returns {Array} Returns `array`.
|
|
*/
|
|
function fill(array, value, start, end) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
|
|
start = 0;
|
|
end = length;
|
|
}
|
|
return baseFill(array, value, start, end);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.find` except that it returns the index of the first
|
|
* element `predicate` returns truthy for, instead of the element itself.
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {number} Returns the index of the found element, else `-1`.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': false },
|
|
* { 'user': 'fred', 'active': false },
|
|
* { 'user': 'pebbles', 'active': true }
|
|
* ];
|
|
*
|
|
* _.findIndex(users, function(chr) {
|
|
* return chr.user == 'barney';
|
|
* });
|
|
* // => 0
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.findIndex(users, { 'user': 'fred', 'active': false });
|
|
* // => 1
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.findIndex(users, 'active', false);
|
|
* // => 0
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.findIndex(users, 'active');
|
|
* // => 2
|
|
*/
|
|
function findIndex(array, predicate, thisArg) {
|
|
var index = -1,
|
|
length = array ? array.length : 0;
|
|
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (++index < length) {
|
|
if (predicate(array[index], index, array)) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.findIndex` except that it iterates over elements
|
|
* of `collection` from right to left.
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {number} Returns the index of the found element, else `-1`.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': true },
|
|
* { 'user': 'fred', 'active': false },
|
|
* { 'user': 'pebbles', 'active': false }
|
|
* ];
|
|
*
|
|
* _.findLastIndex(users, function(chr) {
|
|
* return chr.user == 'pebbles';
|
|
* });
|
|
* // => 2
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
|
|
* // => 0
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.findLastIndex(users, 'active', false);
|
|
* // => 1
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.findLastIndex(users, 'active');
|
|
* // => 0
|
|
*/
|
|
function findLastIndex(array, predicate, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (length--) {
|
|
if (predicate(array[length], length, array)) {
|
|
return length;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Gets the first element of `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias head
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {*} Returns the first element of `array`.
|
|
* @example
|
|
*
|
|
* _.first([1, 2, 3]);
|
|
* // => 1
|
|
*
|
|
* _.first([]);
|
|
* // => undefined
|
|
*/
|
|
function first(array) {
|
|
return array ? array[0] : undefined;
|
|
}
|
|
|
|
/**
|
|
* Flattens a nested array. If `isDeep` is `true` the array is recursively
|
|
* flattened, otherwise it is only flattened a single level.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to flatten.
|
|
* @param {boolean} [isDeep] Specify a deep flatten.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the new flattened array.
|
|
* @example
|
|
*
|
|
* _.flatten([1, [2, 3, [4]]]);
|
|
* // => [1, 2, 3, [4]];
|
|
*
|
|
* // using `isDeep`
|
|
* _.flatten([1, [2, 3, [4]]], true);
|
|
* // => [1, 2, 3, 4];
|
|
*/
|
|
function flatten(array, isDeep, guard) {
|
|
var length = array ? array.length : 0;
|
|
if (guard && isIterateeCall(array, isDeep, guard)) {
|
|
isDeep = false;
|
|
}
|
|
return length ? baseFlatten(array, isDeep) : [];
|
|
}
|
|
|
|
/**
|
|
* Recursively flattens a nested array.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to recursively flatten.
|
|
* @returns {Array} Returns the new flattened array.
|
|
* @example
|
|
*
|
|
* _.flattenDeep([1, [2, 3, [4]]]);
|
|
* // => [1, 2, 3, 4];
|
|
*/
|
|
function flattenDeep(array) {
|
|
var length = array ? array.length : 0;
|
|
return length ? baseFlatten(array, true) : [];
|
|
}
|
|
|
|
/**
|
|
* Gets the index at which the first occurrence of `value` is found in `array`
|
|
* using `SameValueZero` for equality comparisons. If `fromIndex` is negative,
|
|
* it is used as the offset from the end of `array`. If `array` is sorted
|
|
* providing `true` for `fromIndex` performs a faster binary search.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {boolean|number} [fromIndex=0] The index to search from or `true`
|
|
* to perform a binary search on a sorted array.
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
* @example
|
|
*
|
|
* _.indexOf([1, 2, 1, 2], 2);
|
|
* // => 1
|
|
*
|
|
* // using `fromIndex`
|
|
* _.indexOf([1, 2, 1, 2], 2, 2);
|
|
* // => 3
|
|
*
|
|
* // performing a binary search
|
|
* _.indexOf([1, 1, 2, 2], 2, true);
|
|
* // => 2
|
|
*/
|
|
function indexOf(array, value, fromIndex) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return -1;
|
|
}
|
|
if (typeof fromIndex == 'number') {
|
|
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
|
} else if (fromIndex) {
|
|
var index = binaryIndex(array, value),
|
|
other = array[index];
|
|
|
|
return (value === value ? value === other : other !== other) ? index : -1;
|
|
}
|
|
return baseIndexOf(array, value, fromIndex);
|
|
}
|
|
|
|
/**
|
|
* Gets all but the last element of `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.initial([1, 2, 3]);
|
|
* // => [1, 2]
|
|
*/
|
|
function initial(array) {
|
|
return dropRight(array, 1);
|
|
}
|
|
|
|
/**
|
|
* Creates an array of unique values in all provided arrays using `SameValueZero`
|
|
* for equality comparisons.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {...Array} [arrays] The arrays to inspect.
|
|
* @returns {Array} Returns the new array of shared values.
|
|
* @example
|
|
* _.intersection([1, 2], [4, 2], [2, 1]);
|
|
* // => [2]
|
|
*/
|
|
function intersection() {
|
|
var args = [],
|
|
argsIndex = -1,
|
|
argsLength = arguments.length,
|
|
caches = [],
|
|
indexOf = getIndexOf(),
|
|
isCommon = indexOf == baseIndexOf;
|
|
|
|
while (++argsIndex < argsLength) {
|
|
var value = arguments[argsIndex];
|
|
if (isArray(value) || isArguments(value)) {
|
|
args.push(value);
|
|
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
|
|
}
|
|
}
|
|
argsLength = args.length;
|
|
var array = args[0],
|
|
index = -1,
|
|
length = array ? array.length : 0,
|
|
result = [],
|
|
seen = caches[0];
|
|
|
|
outer:
|
|
while (++index < length) {
|
|
value = array[index];
|
|
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) {
|
|
argsIndex = argsLength;
|
|
while (--argsIndex) {
|
|
var cache = caches[argsIndex];
|
|
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
|
|
continue outer;
|
|
}
|
|
}
|
|
if (seen) {
|
|
seen.push(value);
|
|
}
|
|
result.push(value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets the last element of `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {*} Returns the last element of `array`.
|
|
* @example
|
|
*
|
|
* _.last([1, 2, 3]);
|
|
* // => 3
|
|
*/
|
|
function last(array) {
|
|
var length = array ? array.length : 0;
|
|
return length ? array[length - 1] : undefined;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.indexOf` except that it iterates over elements of
|
|
* `array` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {boolean|number} [fromIndex=array.length-1] The index to search from
|
|
* or `true` to perform a binary search on a sorted array.
|
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
* @example
|
|
*
|
|
* _.lastIndexOf([1, 2, 1, 2], 2);
|
|
* // => 3
|
|
*
|
|
* // using `fromIndex`
|
|
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
|
|
* // => 1
|
|
*
|
|
* // performing a binary search
|
|
* _.lastIndexOf([1, 1, 2, 2], 2, true);
|
|
* // => 3
|
|
*/
|
|
function lastIndexOf(array, value, fromIndex) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return -1;
|
|
}
|
|
var index = length;
|
|
if (typeof fromIndex == 'number') {
|
|
index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;
|
|
} else if (fromIndex) {
|
|
index = binaryIndex(array, value, true) - 1;
|
|
var other = array[index];
|
|
return (value === value ? value === other : other !== other) ? index : -1;
|
|
}
|
|
if (value !== value) {
|
|
return indexOfNaN(array, index, true);
|
|
}
|
|
while (index--) {
|
|
if (array[index] === value) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Removes all provided values from `array` using `SameValueZero` for equality
|
|
* comparisons.
|
|
*
|
|
* **Notes:**
|
|
* - Unlike `_.without`, this method mutates `array`.
|
|
* - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`,
|
|
* except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to modify.
|
|
* @param {...*} [values] The values to remove.
|
|
* @returns {Array} Returns `array`.
|
|
* @example
|
|
*
|
|
* var array = [1, 2, 3, 1, 2, 3];
|
|
*
|
|
* _.pull(array, 2, 3);
|
|
* console.log(array);
|
|
* // => [1, 1]
|
|
*/
|
|
function pull() {
|
|
var array = arguments[0];
|
|
if (!(array && array.length)) {
|
|
return array;
|
|
}
|
|
var index = 0,
|
|
indexOf = getIndexOf(),
|
|
length = arguments.length;
|
|
|
|
while (++index < length) {
|
|
var fromIndex = 0,
|
|
value = arguments[index];
|
|
|
|
while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
|
|
splice.call(array, fromIndex, 1);
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* Removes elements from `array` corresponding to the given indexes and returns
|
|
* an array of the removed elements. Indexes may be specified as an array of
|
|
* indexes or as individual arguments.
|
|
*
|
|
* **Note:** Unlike `_.at`, this method mutates `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to modify.
|
|
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
|
|
* specified as individual indexes or arrays of indexes.
|
|
* @returns {Array} Returns the new array of removed elements.
|
|
* @example
|
|
*
|
|
* var array = [5, 10, 15, 20];
|
|
* var evens = _.pullAt(array, 1, 3);
|
|
*
|
|
* console.log(array);
|
|
* // => [5, 15]
|
|
*
|
|
* console.log(evens);
|
|
* // => [10, 20]
|
|
*/
|
|
function pullAt(array) {
|
|
return basePullAt(array || [], baseFlatten(arguments, false, false, 1));
|
|
}
|
|
|
|
/**
|
|
* Removes all elements from `array` that `predicate` returns truthy for
|
|
* and returns an array of the removed elements. The predicate is bound to
|
|
* `thisArg` and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* **Note:** Unlike `_.filter`, this method mutates `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to modify.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the new array of removed elements.
|
|
* @example
|
|
*
|
|
* var array = [1, 2, 3, 4];
|
|
* var evens = _.remove(array, function(n) {
|
|
* return n % 2 == 0;
|
|
* });
|
|
*
|
|
* console.log(array);
|
|
* // => [1, 3]
|
|
*
|
|
* console.log(evens);
|
|
* // => [2, 4]
|
|
*/
|
|
function remove(array, predicate, thisArg) {
|
|
var index = -1,
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (predicate(value, index, array)) {
|
|
result.push(value);
|
|
splice.call(array, index--, 1);
|
|
length--;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets all but the first element of `array`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias tail
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.rest([1, 2, 3]);
|
|
* // => [2, 3]
|
|
*/
|
|
function rest(array) {
|
|
return drop(array, 1);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
|
*
|
|
* **Note:** This function is used instead of `Array#slice` to support node
|
|
* lists in IE < 9 and to ensure dense arrays are returned.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to slice.
|
|
* @param {number} [start=0] The start position.
|
|
* @param {number} [end=array.length] The end position.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
*/
|
|
function slice(array, start, end) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
|
start = 0;
|
|
end = length;
|
|
}
|
|
return baseSlice(array, start, end);
|
|
}
|
|
|
|
/**
|
|
* Uses a binary search to determine the lowest index at which `value` should
|
|
* be inserted into `array` in order to maintain its sort order. If an iteratee
|
|
* function is provided it is invoked for `value` and each element of `array`
|
|
* to compute their sort ranking. The iteratee is bound to `thisArg` and
|
|
* invoked with one argument; (value).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The sorted array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
* @example
|
|
*
|
|
* _.sortedIndex([30, 50], 40);
|
|
* // => 1
|
|
*
|
|
* _.sortedIndex([4, 4, 5, 5], 5);
|
|
* // => 2
|
|
*
|
|
* var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
|
|
*
|
|
* // using an iteratee function
|
|
* _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {
|
|
* return this.data[word];
|
|
* }, dict);
|
|
* // => 1
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
|
* // => 1
|
|
*/
|
|
function sortedIndex(array, value, iteratee, thisArg) {
|
|
var func = getCallback(iteratee);
|
|
return (func === baseCallback && iteratee == null)
|
|
? binaryIndex(array, value)
|
|
: binaryIndexBy(array, value, func(iteratee, thisArg, 1));
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.sortedIndex` except that it returns the highest
|
|
* index at which `value` should be inserted into `array` in order to
|
|
* maintain its sort order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The sorted array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
* @example
|
|
*
|
|
* _.sortedLastIndex([4, 4, 5, 5], 5);
|
|
* // => 4
|
|
*/
|
|
function sortedLastIndex(array, value, iteratee, thisArg) {
|
|
var func = getCallback(iteratee);
|
|
return (func === baseCallback && iteratee == null)
|
|
? binaryIndex(array, value, true)
|
|
: binaryIndexBy(array, value, func(iteratee, thisArg, 1), true);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with `n` elements taken from the beginning.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {number} [n=1] The number of elements to take.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.take([1, 2, 3]);
|
|
* // => [1]
|
|
*
|
|
* _.take([1, 2, 3], 2);
|
|
* // => [1, 2]
|
|
*
|
|
* _.take([1, 2, 3], 5);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* _.take([1, 2, 3], 0);
|
|
* // => []
|
|
*/
|
|
function take(array, n, guard) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
n = 1;
|
|
}
|
|
return baseSlice(array, 0, n < 0 ? 0 : n);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with `n` elements taken from the end.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {number} [n=1] The number of elements to take.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.takeRight([1, 2, 3]);
|
|
* // => [3]
|
|
*
|
|
* _.takeRight([1, 2, 3], 2);
|
|
* // => [2, 3]
|
|
*
|
|
* _.takeRight([1, 2, 3], 5);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* _.takeRight([1, 2, 3], 0);
|
|
* // => []
|
|
*/
|
|
function takeRight(array, n, guard) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (guard ? isIterateeCall(array, n, guard) : n == null) {
|
|
n = 1;
|
|
}
|
|
n = length - (+n || 0);
|
|
return baseSlice(array, n < 0 ? 0 : n);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with elements taken from the end. Elements are
|
|
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
|
|
* and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.takeRightWhile([1, 2, 3], function(n) {
|
|
* return n > 1;
|
|
* });
|
|
* // => [2, 3]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': true },
|
|
* { 'user': 'fred', 'active': false },
|
|
* { 'user': 'pebbles', 'active': false }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
|
|
* // => ['pebbles']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.takeRightWhile(users, 'active', false), 'user');
|
|
* // => ['fred', 'pebbles']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.takeRightWhile(users, 'active'), 'user');
|
|
* // => []
|
|
*/
|
|
function takeRightWhile(array, predicate, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (length-- && predicate(array[length], length, array)) {}
|
|
return baseSlice(array, length + 1);
|
|
}
|
|
|
|
/**
|
|
* Creates a slice of `array` with elements taken from the beginning. Elements
|
|
* are taken until `predicate` returns falsey. The predicate is bound to
|
|
* `thisArg` and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* _.takeWhile([1, 2, 3], function(n) {
|
|
* return n < 3;
|
|
* });
|
|
* // => [1, 2]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': false },
|
|
* { 'user': 'fred', 'active': false},
|
|
* { 'user': 'pebbles', 'active': true }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user');
|
|
* // => ['barney']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.takeWhile(users, 'active', false), 'user');
|
|
* // => ['barney', 'fred']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.takeWhile(users, 'active'), 'user');
|
|
* // => []
|
|
*/
|
|
function takeWhile(array, predicate, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
var index = -1;
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
while (++index < length && predicate(array[index], index, array)) {}
|
|
return baseSlice(array, 0, index);
|
|
}
|
|
|
|
/**
|
|
* Creates an array of unique values, in order, of the provided arrays using
|
|
* `SameValueZero` for equality comparisons.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {...Array} [arrays] The arrays to inspect.
|
|
* @returns {Array} Returns the new array of combined values.
|
|
* @example
|
|
*
|
|
* _.union([1, 2], [4, 2], [2, 1]);
|
|
* // => [1, 2, 4]
|
|
*/
|
|
function union() {
|
|
return baseUniq(baseFlatten(arguments, false, true));
|
|
}
|
|
|
|
/**
|
|
* Creates a duplicate-value-free version of an array using `SameValueZero`
|
|
* for equality comparisons. Providing `true` for `isSorted` performs a faster
|
|
* search algorithm for sorted arrays. If an iteratee function is provided it
|
|
* is invoked for each value in the array to generate the criterion by which
|
|
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
|
|
* with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias unique
|
|
* @category Array
|
|
* @param {Array} array The array to inspect.
|
|
* @param {boolean} [isSorted] Specify the array is sorted.
|
|
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array} Returns the new duplicate-value-free array.
|
|
* @example
|
|
*
|
|
* _.uniq([1, 2, 1]);
|
|
* // => [1, 2]
|
|
*
|
|
* // using `isSorted`
|
|
* _.uniq([1, 1, 2], true);
|
|
* // => [1, 2]
|
|
*
|
|
* // using an iteratee function
|
|
* _.uniq([1, 2.5, 1.5, 2], function(n) {
|
|
* return this.floor(n);
|
|
* }, Math);
|
|
* // => [1, 2.5]
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
|
* // => [{ 'x': 1 }, { 'x': 2 }]
|
|
*/
|
|
function uniq(array, isSorted, iteratee, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
if (isSorted != null && typeof isSorted != 'boolean') {
|
|
thisArg = iteratee;
|
|
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
|
|
isSorted = false;
|
|
}
|
|
var func = getCallback();
|
|
if (!(func === baseCallback && iteratee == null)) {
|
|
iteratee = func(iteratee, thisArg, 3);
|
|
}
|
|
return (isSorted && getIndexOf() == baseIndexOf)
|
|
? sortedUniq(array, iteratee)
|
|
: baseUniq(array, iteratee);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.zip` except that it accepts an array of grouped
|
|
* elements and creates an array regrouping the elements to their pre-`_.zip`
|
|
* configuration.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array of grouped elements to process.
|
|
* @returns {Array} Returns the new array of regrouped elements.
|
|
* @example
|
|
*
|
|
* var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
|
* // => [['fred', 30, true], ['barney', 40, false]]
|
|
*
|
|
* _.unzip(zipped);
|
|
* // => [['fred', 'barney'], [30, 40], [true, false]]
|
|
*/
|
|
function unzip(array) {
|
|
var index = -1,
|
|
length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = arrayMap(array, baseProperty(index));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array excluding all provided values using `SameValueZero` for
|
|
* equality comparisons.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to filter.
|
|
* @param {...*} [values] The values to exclude.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.without([1, 2, 1, 3], 1, 2);
|
|
* // => [3]
|
|
*/
|
|
function without(array) {
|
|
return baseDifference(array, baseSlice(arguments, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates an array that is the symmetric difference of the provided arrays.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for
|
|
* more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {...Array} [arrays] The arrays to inspect.
|
|
* @returns {Array} Returns the new array of values.
|
|
* @example
|
|
*
|
|
* _.xor([1, 2], [4, 2]);
|
|
* // => [1, 4]
|
|
*/
|
|
function xor() {
|
|
var index = -1,
|
|
length = arguments.length;
|
|
|
|
while (++index < length) {
|
|
var array = arguments[index];
|
|
if (isArray(array) || isArguments(array)) {
|
|
var result = result
|
|
? baseDifference(result, array).concat(baseDifference(array, result))
|
|
: array;
|
|
}
|
|
}
|
|
return result ? baseUniq(result) : [];
|
|
}
|
|
|
|
/**
|
|
* Creates an array of grouped elements, the first of which contains the first
|
|
* elements of the given arrays, the second of which contains the second elements
|
|
* of the given arrays, and so on.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {...Array} [arrays] The arrays to process.
|
|
* @returns {Array} Returns the new array of grouped elements.
|
|
* @example
|
|
*
|
|
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
|
* // => [['fred', 30, true], ['barney', 40, false]]
|
|
*/
|
|
function zip() {
|
|
var length = arguments.length,
|
|
array = Array(length);
|
|
|
|
while (length--) {
|
|
array[length] = arguments[length];
|
|
}
|
|
return unzip(array);
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed from arrays of property names and values. Provide
|
|
* either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]`
|
|
* or two arrays, one of property names and one of corresponding values.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias object
|
|
* @category Array
|
|
* @param {Array} props The property names.
|
|
* @param {Array} [values=[]] The property values.
|
|
* @returns {Object} Returns the new object.
|
|
* @example
|
|
*
|
|
* _.zipObject(['fred', 'barney'], [30, 40]);
|
|
* // => { 'fred': 30, 'barney': 40 }
|
|
*/
|
|
function zipObject(props, values) {
|
|
var index = -1,
|
|
length = props ? props.length : 0,
|
|
result = {};
|
|
|
|
if (length && !values && !isArray(props[0])) {
|
|
values = [];
|
|
}
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (values) {
|
|
result[key] = values[index];
|
|
} else if (key) {
|
|
result[key[0]] = key[1];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a `lodash` object that wraps `value` with explicit method
|
|
* chaining enabled.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @param {*} value The value to wrap.
|
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 },
|
|
* { 'user': 'pebbles', 'age': 1 }
|
|
* ];
|
|
*
|
|
* var youngest = _.chain(users)
|
|
* .sortBy('age')
|
|
* .map(function(chr) {
|
|
* return chr.user + ' is ' + chr.age;
|
|
* })
|
|
* .first()
|
|
* .value();
|
|
* // => 'pebbles is 1'
|
|
*/
|
|
function chain(value) {
|
|
var result = lodash(value);
|
|
result.__chain__ = true;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* This method invokes `interceptor` and returns `value`. The interceptor is
|
|
* bound to `thisArg` and invoked with one argument; (value). The purpose of
|
|
* this method is to "tap into" a method chain in order to perform operations
|
|
* on intermediate results within the chain.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @param {*} value The value to provide to `interceptor`.
|
|
* @param {Function} interceptor The function to invoke.
|
|
* @param {*} [thisArg] The `this` binding of `interceptor`.
|
|
* @returns {*} Returns `value`.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3])
|
|
* .tap(function(array) {
|
|
* array.pop();
|
|
* })
|
|
* .reverse()
|
|
* .value();
|
|
* // => [2, 1]
|
|
*/
|
|
function tap(value, interceptor, thisArg) {
|
|
interceptor.call(thisArg, value);
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.tap` except that it returns the result of `interceptor`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @param {*} value The value to provide to `interceptor`.
|
|
* @param {Function} interceptor The function to invoke.
|
|
* @param {*} [thisArg] The `this` binding of `interceptor`.
|
|
* @returns {*} Returns the result of `interceptor`.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3])
|
|
* .last()
|
|
* .thru(function(value) {
|
|
* return [value];
|
|
* })
|
|
* .value();
|
|
* // => [3]
|
|
*/
|
|
function thru(value, interceptor, thisArg) {
|
|
return interceptor.call(thisArg, value);
|
|
}
|
|
|
|
/**
|
|
* Enables explicit method chaining on the wrapper object.
|
|
*
|
|
* @name chain
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // without explicit chaining
|
|
* _(users).first();
|
|
* // => { 'user': 'barney', 'age': 36 }
|
|
*
|
|
* // with explicit chaining
|
|
* _(users).chain()
|
|
* .first()
|
|
* .pick('user')
|
|
* .value();
|
|
* // => { 'user': 'barney' }
|
|
*/
|
|
function wrapperChain() {
|
|
return chain(this);
|
|
}
|
|
|
|
/**
|
|
* Executes the chained sequence and returns the wrapped result.
|
|
*
|
|
* @name commit
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var array = [1, 2];
|
|
* var wrapper = _(array).push(3);
|
|
*
|
|
* console.log(array);
|
|
* // => [1, 2]
|
|
*
|
|
* wrapper = wrapper.commit();
|
|
* console.log(array);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* wrapper.last();
|
|
* // => 3
|
|
*
|
|
* console.log(array);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function wrapperCommit() {
|
|
return new LodashWrapper(this.value(), this.__chain__);
|
|
}
|
|
|
|
/**
|
|
* Creates a clone of the chained sequence planting `value` as the wrapped value.
|
|
*
|
|
* @name plant
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @returns {Object} Returns the new `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var array = [1, 2];
|
|
* var wrapper = _(array).map(function(value) {
|
|
* return Math.pow(value, 2);
|
|
* });
|
|
*
|
|
* var other = [3, 4];
|
|
* var otherWrapper = wrapper.plant(other);
|
|
*
|
|
* otherWrapper.value();
|
|
* // => [9, 16]
|
|
*
|
|
* wrapper.value();
|
|
* // => [1, 4]
|
|
*/
|
|
function wrapperPlant(value) {
|
|
var result,
|
|
parent = this;
|
|
|
|
while (parent instanceof baseLodash) {
|
|
var clone = wrapperClone(parent);
|
|
if (result) {
|
|
previous.__wrapped__ = clone;
|
|
} else {
|
|
result = clone;
|
|
}
|
|
var previous = clone;
|
|
parent = parent.__wrapped__;
|
|
}
|
|
previous.__wrapped__ = value;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Reverses the wrapped array so the first element becomes the last, the
|
|
* second element becomes the second to last, and so on.
|
|
*
|
|
* **Note:** This method mutates the wrapped array.
|
|
*
|
|
* @name reverse
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @returns {Object} Returns the new reversed `lodash` wrapper instance.
|
|
* @example
|
|
*
|
|
* var array = [1, 2, 3];
|
|
*
|
|
* _(array).reverse().value()
|
|
* // => [3, 2, 1]
|
|
*
|
|
* console.log(array);
|
|
* // => [3, 2, 1]
|
|
*/
|
|
function wrapperReverse() {
|
|
var value = this.__wrapped__;
|
|
if (value instanceof LazyWrapper) {
|
|
if (this.__actions__.length) {
|
|
value = new LazyWrapper(this);
|
|
}
|
|
return new LodashWrapper(value.reverse(), this.__chain__);
|
|
}
|
|
return this.thru(function(value) {
|
|
return value.reverse();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Produces the result of coercing the unwrapped value to a string.
|
|
*
|
|
* @name toString
|
|
* @memberOf _
|
|
* @category Chain
|
|
* @returns {string} Returns the coerced string value.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).toString();
|
|
* // => '1,2,3'
|
|
*/
|
|
function wrapperToString() {
|
|
return (this.value() + '');
|
|
}
|
|
|
|
/**
|
|
* Executes the chained sequence to extract the unwrapped value.
|
|
*
|
|
* @name value
|
|
* @memberOf _
|
|
* @alias run, toJSON, valueOf
|
|
* @category Chain
|
|
* @returns {*} Returns the resolved unwrapped value.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).value();
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function wrapperValue() {
|
|
return baseWrapperValue(this.__wrapped__, this.__actions__);
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates an array of elements corresponding to the given keys, or indexes,
|
|
* of `collection`. Keys may be specified as individual arguments or as arrays
|
|
* of keys.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {...(number|number[]|string|string[])} [props] The property names
|
|
* or indexes of elements to pick, specified individually or in arrays.
|
|
* @returns {Array} Returns the new array of picked elements.
|
|
* @example
|
|
*
|
|
* _.at(['a', 'b', 'c'], [0, 2]);
|
|
* // => ['a', 'c']
|
|
*
|
|
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
|
|
* // => ['fred', 'pebbles']
|
|
*/
|
|
function at(collection) {
|
|
var length = collection ? collection.length : 0;
|
|
if (isLength(length)) {
|
|
collection = toIterable(collection);
|
|
}
|
|
return baseAt(collection, baseFlatten(arguments, false, false, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of `collection` through `iteratee`. The corresponding value
|
|
* of each key is the number of times the key was returned by `iteratee`.
|
|
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* _.countBy([4.3, 6.1, 6.4], function(n) {
|
|
* return Math.floor(n);
|
|
* });
|
|
* // => { '4': 1, '6': 2 }
|
|
*
|
|
* _.countBy([4.3, 6.1, 6.4], function(n) {
|
|
* return this.floor(n);
|
|
* }, Math);
|
|
* // => { '4': 1, '6': 2 }
|
|
*
|
|
* _.countBy(['one', 'two', 'three'], 'length');
|
|
* // => { '3': 2, '5': 1 }
|
|
*/
|
|
var countBy = createAggregator(function(result, value, key) {
|
|
hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
|
|
});
|
|
|
|
/**
|
|
* Checks if `predicate` returns truthy for **all** elements of `collection`.
|
|
* The predicate is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias all
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
|
* else `false`.
|
|
* @example
|
|
*
|
|
* _.every([true, 1, null, 'yes'], Boolean);
|
|
* // => false
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': false },
|
|
* { 'user': 'fred', 'active': false }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.every(users, { 'user': 'barney', 'active': false });
|
|
* // => false
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.every(users, 'active', false);
|
|
* // => true
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.every(users, 'active');
|
|
* // => false
|
|
*/
|
|
function every(collection, predicate, thisArg) {
|
|
var func = isArray(collection) ? arrayEvery : baseEvery;
|
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
}
|
|
return func(collection, predicate);
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of `collection`, returning an array of all elements
|
|
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
|
* invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias select
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the new filtered array.
|
|
* @example
|
|
*
|
|
* _.filter([4, 5, 6], function(n) {
|
|
* return n % 2 == 0;
|
|
* });
|
|
* // => [4, 6]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
|
* { 'user': 'fred', 'age': 40, 'active': false }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
|
|
* // => ['barney']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.filter(users, 'active', false), 'user');
|
|
* // => ['fred']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.filter(users, 'active'), 'user');
|
|
* // => ['barney']
|
|
*/
|
|
function filter(collection, predicate, thisArg) {
|
|
var func = isArray(collection) ? arrayFilter : baseFilter;
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return func(collection, predicate);
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of `collection`, returning the first element
|
|
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
|
* invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias detect
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {*} Returns the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
|
* { 'user': 'fred', 'age': 40, 'active': false },
|
|
* { 'user': 'pebbles', 'age': 1, 'active': true }
|
|
* ];
|
|
*
|
|
* _.result(_.find(users, function(chr) {
|
|
* return chr.age < 40;
|
|
* }), 'user');
|
|
* // => 'barney'
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
|
|
* // => 'pebbles'
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.result(_.find(users, 'active', false), 'user');
|
|
* // => 'fred'
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.result(_.find(users, 'active'), 'user');
|
|
* // => 'barney'
|
|
*/
|
|
function find(collection, predicate, thisArg) {
|
|
if (isArray(collection)) {
|
|
var index = findIndex(collection, predicate, thisArg);
|
|
return index > -1 ? collection[index] : undefined;
|
|
}
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return baseFind(collection, predicate, baseEach);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.find` except that it iterates over elements of
|
|
* `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {*} Returns the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* _.findLast([1, 2, 3, 4], function(n) {
|
|
* return n % 2 == 1;
|
|
* });
|
|
* // => 3
|
|
*/
|
|
function findLast(collection, predicate, thisArg) {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return baseFind(collection, predicate, baseEachRight);
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison between each element in `collection` and the
|
|
* source object, returning the first element that has equivalent property
|
|
* values.
|
|
*
|
|
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
|
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
|
* their own, not inherited, enumerable properties. For comparing a single
|
|
* own or inherited property value see `_.matchesProperty`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Object} source The object of property values to match.
|
|
* @returns {*} Returns the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
|
* { 'user': 'fred', 'age': 40, 'active': false }
|
|
* ];
|
|
*
|
|
* _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');
|
|
* // => 'barney'
|
|
*
|
|
* _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');
|
|
* // => 'fred'
|
|
*/
|
|
function findWhere(collection, source) {
|
|
return find(collection, baseMatches(source));
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
|
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection). Iterator functions may exit iteration early
|
|
* by explicitly returning `false`.
|
|
*
|
|
* **Note:** As with other "Collections" methods, objects with a `length` property
|
|
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
|
|
* may be used for object iteration.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias each
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
* @example
|
|
*
|
|
* _([1, 2]).forEach(function(n) {
|
|
* console.log(n);
|
|
* }).value();
|
|
* // => logs each value from left to right and returns the array
|
|
*
|
|
* _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
|
|
* console.log(n, key);
|
|
* });
|
|
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
|
|
*/
|
|
function forEach(collection, iteratee, thisArg) {
|
|
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
|
? arrayEach(collection, iteratee)
|
|
: baseEach(collection, bindCallback(iteratee, thisArg, 3));
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.forEach` except that it iterates over elements of
|
|
* `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias eachRight
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
* @example
|
|
*
|
|
* _([1, 2]).forEachRight(function(n) {
|
|
* console.log(n);
|
|
* }).join(',');
|
|
* // => logs each value from right to left and returns the array
|
|
*/
|
|
function forEachRight(collection, iteratee, thisArg) {
|
|
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
|
? arrayEachRight(collection, iteratee)
|
|
: baseEachRight(collection, bindCallback(iteratee, thisArg, 3));
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of `collection` through `iteratee`. The corresponding value
|
|
* of each key is an array of the elements responsible for generating the key.
|
|
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* _.groupBy([4.2, 6.1, 6.4], function(n) {
|
|
* return Math.floor(n);
|
|
* });
|
|
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
|
*
|
|
* _.groupBy([4.2, 6.1, 6.4], function(n) {
|
|
* return this.floor(n);
|
|
* }, Math);
|
|
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.groupBy(['one', 'two', 'three'], 'length');
|
|
* // => { '3': ['one', 'two'], '5': ['three'] }
|
|
*/
|
|
var groupBy = createAggregator(function(result, value, key) {
|
|
if (hasOwnProperty.call(result, key)) {
|
|
result[key].push(value);
|
|
} else {
|
|
result[key] = [value];
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Checks if `value` is in `collection` using `SameValueZero` for equality
|
|
* comparisons. If `fromIndex` is negative, it is used as the offset from
|
|
* the end of `collection`.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias contains, include
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {*} target The value to search for.
|
|
* @param {number} [fromIndex=0] The index to search from.
|
|
* @returns {boolean} Returns `true` if a matching element is found, else `false`.
|
|
* @example
|
|
*
|
|
* _.includes([1, 2, 3], 1);
|
|
* // => true
|
|
*
|
|
* _.includes([1, 2, 3], 1, 2);
|
|
* // => false
|
|
*
|
|
* _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
|
|
* // => true
|
|
*
|
|
* _.includes('pebbles', 'eb');
|
|
* // => true
|
|
*/
|
|
function includes(collection, target, fromIndex) {
|
|
var length = collection ? collection.length : 0;
|
|
if (!isLength(length)) {
|
|
collection = values(collection);
|
|
length = collection.length;
|
|
}
|
|
if (!length) {
|
|
return false;
|
|
}
|
|
if (typeof fromIndex == 'number') {
|
|
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
|
} else {
|
|
fromIndex = 0;
|
|
}
|
|
return (typeof collection == 'string' || !isArray(collection) && isString(collection))
|
|
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
|
|
: (getIndexOf(collection, target, fromIndex) > -1);
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of `collection` through `iteratee`. The corresponding value
|
|
* of each key is the last element responsible for generating the key. The
|
|
* iteratee function is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* var keyData = [
|
|
* { 'dir': 'left', 'code': 97 },
|
|
* { 'dir': 'right', 'code': 100 }
|
|
* ];
|
|
*
|
|
* _.indexBy(keyData, 'dir');
|
|
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
|
*
|
|
* _.indexBy(keyData, function(object) {
|
|
* return String.fromCharCode(object.code);
|
|
* });
|
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
|
*
|
|
* _.indexBy(keyData, function(object) {
|
|
* return this.fromCharCode(object.code);
|
|
* }, String);
|
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
|
*/
|
|
var indexBy = createAggregator(function(result, value, key) {
|
|
result[key] = value;
|
|
});
|
|
|
|
/**
|
|
* Invokes the method named by `methodName` on each element in `collection`,
|
|
* returning an array of the results of each invoked method. Any additional
|
|
* arguments are provided to each invoked method. If `methodName` is a function
|
|
* it is invoked for, and `this` bound to, each element in `collection`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|string} methodName The name of the method to invoke or
|
|
* the function invoked per iteration.
|
|
* @param {...*} [args] The arguments to invoke the method with.
|
|
* @returns {Array} Returns the array of results.
|
|
* @example
|
|
*
|
|
* _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
|
* // => [[1, 5, 7], [1, 2, 3]]
|
|
*
|
|
* _.invoke([123, 456], String.prototype.split, '');
|
|
* // => [['1', '2', '3'], ['4', '5', '6']]
|
|
*/
|
|
function invoke(collection, methodName) {
|
|
return baseInvoke(collection, methodName, baseSlice(arguments, 2));
|
|
}
|
|
|
|
/**
|
|
* Creates an array of values by running each element in `collection` through
|
|
* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* Many lodash methods are guarded to work as interatees for methods like
|
|
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
|
|
*
|
|
* The guarded methods are:
|
|
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
|
|
* `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
|
|
* `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
|
|
* `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias collect
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* create a `_.property` or `_.matches` style callback respectively.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array} Returns the new mapped array.
|
|
* @example
|
|
*
|
|
* function timesThree(n) {
|
|
* return n * 3;
|
|
* }
|
|
*
|
|
* _.map([1, 2], timesThree);
|
|
* // => [3, 6]
|
|
*
|
|
* _.map({ 'a': 1, 'b': 2 }, timesThree);
|
|
* // => [3, 6] (iteration order is not guaranteed)
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney' },
|
|
* { 'user': 'fred' }
|
|
* ];
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.map(users, 'user');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
function map(collection, iteratee, thisArg) {
|
|
var func = isArray(collection) ? arrayMap : baseMap;
|
|
iteratee = getCallback(iteratee, thisArg, 3);
|
|
return func(collection, iteratee);
|
|
}
|
|
|
|
/**
|
|
* Gets the maximum value of `collection`. If `collection` is empty or falsey
|
|
* `-Infinity` is returned. If an iteratee function is provided it is invoked
|
|
* for each value in `collection` to generate the criterion by which the value
|
|
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {*} Returns the maximum value.
|
|
* @example
|
|
*
|
|
* _.max([4, 2, 8, 6]);
|
|
* // => 8
|
|
*
|
|
* _.max([]);
|
|
* // => -Infinity
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.max(users, function(chr) {
|
|
* return chr.age;
|
|
* });
|
|
* // => { 'user': 'fred', 'age': 40 };
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.max(users, 'age');
|
|
* // => { 'user': 'fred', 'age': 40 };
|
|
*/
|
|
var max = createExtremum(arrayMax);
|
|
|
|
/**
|
|
* Gets the minimum value of `collection`. If `collection` is empty or falsey
|
|
* `Infinity` is returned. If an iteratee function is provided it is invoked
|
|
* for each value in `collection` to generate the criterion by which the value
|
|
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {*} Returns the minimum value.
|
|
* @example
|
|
*
|
|
* _.min([4, 2, 8, 6]);
|
|
* // => 2
|
|
*
|
|
* _.min([]);
|
|
* // => Infinity
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.min(users, function(chr) {
|
|
* return chr.age;
|
|
* });
|
|
* // => { 'user': 'barney', 'age': 36 };
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.min(users, 'age');
|
|
* // => { 'user': 'barney', 'age': 36 };
|
|
*/
|
|
var min = createExtremum(arrayMin, true);
|
|
|
|
/**
|
|
* Creates an array of elements split into two groups, the first of which
|
|
* contains elements `predicate` returns truthy for, while the second of which
|
|
* contains elements `predicate` returns falsey for. The predicate is bound
|
|
* to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the array of grouped elements.
|
|
* @example
|
|
*
|
|
* _.partition([1, 2, 3], function(n) {
|
|
* return n % 2;
|
|
* });
|
|
* // => [[1, 3], [2]]
|
|
*
|
|
* _.partition([1.2, 2.3, 3.4], function(n) {
|
|
* return this.floor(n) % 2;
|
|
* }, Math);
|
|
* // => [[1, 3], [2]]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': false },
|
|
* { 'user': 'fred', 'age': 40, 'active': true },
|
|
* { 'user': 'pebbles', 'age': 1, 'active': false }
|
|
* ];
|
|
*
|
|
* var mapper = function(array) {
|
|
* return _.pluck(array, 'user');
|
|
* };
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);
|
|
* // => [['pebbles'], ['barney', 'fred']]
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.map(_.partition(users, 'active', false), mapper);
|
|
* // => [['barney', 'pebbles'], ['fred']]
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.map(_.partition(users, 'active'), mapper);
|
|
* // => [['fred'], ['barney', 'pebbles']]
|
|
*/
|
|
var partition = createAggregator(function(result, value, key) {
|
|
result[key ? 0 : 1].push(value);
|
|
}, function() { return [[], []]; });
|
|
|
|
/**
|
|
* Gets the value of `key` from all elements in `collection`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {string} key The key of the property to pluck.
|
|
* @returns {Array} Returns the property values.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.pluck(users, 'user');
|
|
* // => ['barney', 'fred']
|
|
*
|
|
* var userIndex = _.indexBy(users, 'user');
|
|
* _.pluck(userIndex, 'age');
|
|
* // => [36, 40] (iteration order is not guaranteed)
|
|
*/
|
|
function pluck(collection, key) {
|
|
return map(collection, baseProperty(key));
|
|
}
|
|
|
|
/**
|
|
* Reduces `collection` to a value which is the accumulated result of running
|
|
* each element in `collection` through `iteratee`, where each successive
|
|
* invocation is supplied the return value of the previous. If `accumulator`
|
|
* is not provided the first element of `collection` is used as the initial
|
|
* value. The `iteratee` is bound to `thisArg`and invoked with four arguments;
|
|
* (accumulator, value, index|key, collection).
|
|
*
|
|
* Many lodash methods are guarded to work as interatees for methods like
|
|
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
|
*
|
|
* The guarded methods are:
|
|
* `assign`, `defaults`, `merge`, and `sortAllBy`
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias foldl, inject
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [accumulator] The initial value.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* _.reduce([1, 2], function(sum, n) {
|
|
* return sum + n;
|
|
* });
|
|
* // => 3
|
|
*
|
|
* _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
|
|
* result[key] = n * 3;
|
|
* return result;
|
|
* }, {});
|
|
* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
|
|
*/
|
|
function reduce(collection, iteratee, accumulator, thisArg) {
|
|
var func = isArray(collection) ? arrayReduce : baseReduce;
|
|
return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.reduce` except that it iterates over elements of
|
|
* `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias foldr
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [accumulator] The initial value.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* var array = [[0, 1], [2, 3], [4, 5]];
|
|
*
|
|
* _.reduceRight(array, function(flattened, other) {
|
|
* return flattened.concat(other);
|
|
* }, []);
|
|
* // => [4, 5, 2, 3, 0, 1]
|
|
*/
|
|
function reduceRight(collection, iteratee, accumulator, thisArg) {
|
|
var func = isArray(collection) ? arrayReduceRight : baseReduce;
|
|
return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
|
|
}
|
|
|
|
/**
|
|
* The opposite of `_.filter`; this method returns the elements of `collection`
|
|
* that `predicate` does **not** return truthy for.
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Array} Returns the new filtered array.
|
|
* @example
|
|
*
|
|
* _.reject([1, 2, 3, 4], function(n) {
|
|
* return n % 2 == 0;
|
|
* });
|
|
* // => [1, 3]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': false },
|
|
* { 'user': 'fred', 'age': 40, 'active': true }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
|
|
* // => ['barney']
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.pluck(_.reject(users, 'active', false), 'user');
|
|
* // => ['fred']
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.reject(users, 'active'), 'user');
|
|
* // => ['barney']
|
|
*/
|
|
function reject(collection, predicate, thisArg) {
|
|
var func = isArray(collection) ? arrayFilter : baseFilter;
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return func(collection, function(value, index, collection) {
|
|
return !predicate(value, index, collection);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Gets a random element or `n` random elements from a collection.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to sample.
|
|
* @param {number} [n] The number of elements to sample.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {*} Returns the random sample(s).
|
|
* @example
|
|
*
|
|
* _.sample([1, 2, 3, 4]);
|
|
* // => 2
|
|
*
|
|
* _.sample([1, 2, 3, 4], 2);
|
|
* // => [3, 1]
|
|
*/
|
|
function sample(collection, n, guard) {
|
|
if (guard ? isIterateeCall(collection, n, guard) : n == null) {
|
|
collection = toIterable(collection);
|
|
var length = collection.length;
|
|
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
|
}
|
|
var result = shuffle(collection);
|
|
result.length = nativeMin(n < 0 ? 0 : (+n || 0), result.length);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of shuffled values, using a version of the Fisher-Yates
|
|
* shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to shuffle.
|
|
* @returns {Array} Returns the new shuffled array.
|
|
* @example
|
|
*
|
|
* _.shuffle([1, 2, 3, 4]);
|
|
* // => [4, 1, 3, 2]
|
|
*/
|
|
function shuffle(collection) {
|
|
collection = toIterable(collection);
|
|
|
|
var index = -1,
|
|
length = collection.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
var rand = baseRandom(0, index);
|
|
if (index != rand) {
|
|
result[index] = result[rand];
|
|
}
|
|
result[rand] = collection[index];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets the size of `collection` by returning `collection.length` for
|
|
* array-like values or the number of own enumerable properties for objects.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to inspect.
|
|
* @returns {number} Returns the size of `collection`.
|
|
* @example
|
|
*
|
|
* _.size([1, 2, 3]);
|
|
* // => 3
|
|
*
|
|
* _.size({ 'a': 1, 'b': 2 });
|
|
* // => 2
|
|
*
|
|
* _.size('pebbles');
|
|
* // => 7
|
|
*/
|
|
function size(collection) {
|
|
var length = collection ? collection.length : 0;
|
|
return isLength(length) ? length : keys(collection).length;
|
|
}
|
|
|
|
/**
|
|
* Checks if `predicate` returns truthy for **any** element of `collection`.
|
|
* The function returns as soon as it finds a passing value and does not iterate
|
|
* over the entire collection. The predicate is bound to `thisArg` and invoked
|
|
* with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias any
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
|
* else `false`.
|
|
* @example
|
|
*
|
|
* _.some([null, 0, 'yes', false], Boolean);
|
|
* // => true
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'active': true },
|
|
* { 'user': 'fred', 'active': false }
|
|
* ];
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.some(users, { 'user': 'barney', 'active': false });
|
|
* // => false
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.some(users, 'active', false);
|
|
* // => true
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.some(users, 'active');
|
|
* // => true
|
|
*/
|
|
function some(collection, predicate, thisArg) {
|
|
var func = isArray(collection) ? arraySome : baseSome;
|
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
}
|
|
return func(collection, predicate);
|
|
}
|
|
|
|
/**
|
|
* Creates an array of elements, sorted in ascending order by the results of
|
|
* running each element in a collection through `iteratee`. This method performs
|
|
* a stable sort, that is, it preserves the original sort order of equal elements.
|
|
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Array|Function|Object|string} [iteratee=_.identity] The function
|
|
* invoked per iteration. If a property name or an object is provided it is
|
|
* used to create a `_.property` or `_.matches` style callback respectively.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array} Returns the new sorted array.
|
|
* @example
|
|
*
|
|
* _.sortBy([1, 2, 3], function(n) {
|
|
* return Math.sin(n);
|
|
* });
|
|
* // => [3, 1, 2]
|
|
*
|
|
* _.sortBy([1, 2, 3], function(n) {
|
|
* return this.sin(n);
|
|
* }, Math);
|
|
* // => [3, 1, 2]
|
|
*
|
|
* var users = [
|
|
* { 'user': 'fred' },
|
|
* { 'user': 'pebbles' },
|
|
* { 'user': 'barney' }
|
|
* ];
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.pluck(_.sortBy(users, 'user'), 'user');
|
|
* // => ['barney', 'fred', 'pebbles']
|
|
*/
|
|
function sortBy(collection, iteratee, thisArg) {
|
|
var index = -1,
|
|
length = collection ? collection.length : 0,
|
|
result = isLength(length) ? Array(length) : [];
|
|
|
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
|
iteratee = null;
|
|
}
|
|
iteratee = getCallback(iteratee, thisArg, 3);
|
|
baseEach(collection, function(value, key, collection) {
|
|
result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value };
|
|
});
|
|
return baseSortBy(result, compareAscending);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.sortBy` except that it sorts by property names
|
|
* instead of an iteratee function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {...(string|string[])} props The property names to sort by,
|
|
* specified as individual property names or arrays of property names.
|
|
* @returns {Array} Returns the new sorted array.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 },
|
|
* { 'user': 'barney', 'age': 26 },
|
|
* { 'user': 'fred', 'age': 30 }
|
|
* ];
|
|
*
|
|
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
|
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
|
*/
|
|
function sortByAll(collection) {
|
|
var args = arguments;
|
|
if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) {
|
|
args = [collection, args[1]];
|
|
}
|
|
var index = -1,
|
|
length = collection ? collection.length : 0,
|
|
props = baseFlatten(args, false, false, 1),
|
|
result = isLength(length) ? Array(length) : [];
|
|
|
|
baseEach(collection, function(value) {
|
|
var length = props.length,
|
|
criteria = Array(length);
|
|
|
|
while (length--) {
|
|
criteria[length] = value == null ? undefined : value[props[length]];
|
|
}
|
|
result[++index] = { 'criteria': criteria, 'index': index, 'value': value };
|
|
});
|
|
return baseSortBy(result, compareMultipleAscending);
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison between each element in `collection` and the
|
|
* source object, returning an array of all elements that have equivalent
|
|
* property values.
|
|
*
|
|
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
|
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
|
* their own, not inherited, enumerable properties. For comparing a single
|
|
* own or inherited property value see `_.matchesProperty`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Object} source The object of property values to match.
|
|
* @returns {Array} Returns the new filtered array.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
|
|
* { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
|
|
* ];
|
|
*
|
|
* _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
|
|
* // => ['barney']
|
|
*
|
|
* _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');
|
|
* // => ['fred']
|
|
*/
|
|
function where(collection, source) {
|
|
return filter(collection, baseMatches(source));
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
|
* (1 January 1970 00:00:00 UTC).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Date
|
|
* @example
|
|
*
|
|
* _.defer(function(stamp) {
|
|
* console.log(_.now() - stamp);
|
|
* }, _.now());
|
|
* // => logs the number of milliseconds it took for the deferred function to be invoked
|
|
*/
|
|
var now = nativeNow || function() {
|
|
return new Date().getTime();
|
|
};
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The opposite of `_.before`; this method creates a function that invokes
|
|
* `func` once it is called `n` or more times.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {number} n The number of calls before `func` is invoked.
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* var saves = ['profile', 'settings'];
|
|
*
|
|
* var done = _.after(saves.length, function() {
|
|
* console.log('done saving!');
|
|
* });
|
|
*
|
|
* _.forEach(saves, function(type) {
|
|
* asyncSave({ 'type': type, 'complete': done });
|
|
* });
|
|
* // => logs 'done saving!' after the two async saves have completed
|
|
*/
|
|
function after(n, func) {
|
|
if (typeof func != 'function') {
|
|
if (typeof n == 'function') {
|
|
var temp = n;
|
|
n = func;
|
|
func = temp;
|
|
} else {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
}
|
|
n = nativeIsFinite(n = +n) ? n : 0;
|
|
return function() {
|
|
if (--n < 1) {
|
|
return func.apply(this, arguments);
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that accepts up to `n` arguments ignoring any
|
|
* additional arguments.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to cap arguments for.
|
|
* @param {number} [n=func.length] The arity cap.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* _.map(['6', '8', '10'], _.ary(parseInt, 1));
|
|
* // => [6, 8, 10]
|
|
*/
|
|
function ary(func, n, guard) {
|
|
if (guard && isIterateeCall(func, n, guard)) {
|
|
n = null;
|
|
}
|
|
n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);
|
|
return createWrapper(func, ARY_FLAG, null, null, null, null, n);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func`, with the `this` binding and arguments
|
|
* of the created function, while it is called less than `n` times. Subsequent
|
|
* calls to the created function return the result of the last `func` invocation.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {number} n The number of calls at which `func` is no longer invoked.
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* jQuery('#add').on('click', _.before(5, addContactToList));
|
|
* // => allows adding up to 4 contacts to the list
|
|
*/
|
|
function before(n, func) {
|
|
var result;
|
|
if (typeof func != 'function') {
|
|
if (typeof n == 'function') {
|
|
var temp = n;
|
|
n = func;
|
|
func = temp;
|
|
} else {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
}
|
|
return function() {
|
|
if (--n > 0) {
|
|
result = func.apply(this, arguments);
|
|
} else {
|
|
func = null;
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
|
* and prepends any additional `_.bind` arguments to those provided to the
|
|
* bound function.
|
|
*
|
|
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
|
|
* may be used as a placeholder for partially applied arguments.
|
|
*
|
|
* **Note:** Unlike native `Function#bind` this method does not set the `length`
|
|
* property of bound functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to bind.
|
|
* @param {*} thisArg The `this` binding of `func`.
|
|
* @param {...*} [args] The arguments to be partially applied.
|
|
* @returns {Function} Returns the new bound function.
|
|
* @example
|
|
*
|
|
* var greet = function(greeting, punctuation) {
|
|
* return greeting + ' ' + this.user + punctuation;
|
|
* };
|
|
*
|
|
* var object = { 'user': 'fred' };
|
|
*
|
|
* var bound = _.bind(greet, object, 'hi');
|
|
* bound('!');
|
|
* // => 'hi fred!'
|
|
*
|
|
* // using placeholders
|
|
* var bound = _.bind(greet, object, _, '!');
|
|
* bound('hi');
|
|
* // => 'hi fred!'
|
|
*/
|
|
function bind(func, thisArg) {
|
|
var bitmask = BIND_FLAG;
|
|
if (arguments.length > 2) {
|
|
var partials = baseSlice(arguments, 2),
|
|
holders = replaceHolders(partials, bind.placeholder);
|
|
|
|
bitmask |= PARTIAL_FLAG;
|
|
}
|
|
return createWrapper(func, bitmask, thisArg, partials, holders);
|
|
}
|
|
|
|
/**
|
|
* Binds methods of an object to the object itself, overwriting the existing
|
|
* method. Method names may be specified as individual arguments or as arrays
|
|
* of method names. If no method names are provided all enumerable function
|
|
* properties, own and inherited, of `object` are bound.
|
|
*
|
|
* **Note:** This method does not set the `length` property of bound functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Object} object The object to bind and assign the bound methods to.
|
|
* @param {...(string|string[])} [methodNames] The object method names to bind,
|
|
* specified as individual method names or arrays of method names.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* var view = {
|
|
* 'label': 'docs',
|
|
* 'onClick': function() {
|
|
* console.log('clicked ' + this.label);
|
|
* }
|
|
* };
|
|
*
|
|
* _.bindAll(view);
|
|
* jQuery('#docs').on('click', view.onClick);
|
|
* // => logs 'clicked docs' when the element is clicked
|
|
*/
|
|
function bindAll(object) {
|
|
return baseBindAll(object,
|
|
arguments.length > 1
|
|
? baseFlatten(arguments, false, false, 1)
|
|
: functions(object)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes the method at `object[key]` and prepends
|
|
* any additional `_.bindKey` arguments to those provided to the bound function.
|
|
*
|
|
* This method differs from `_.bind` by allowing bound functions to reference
|
|
* methods that may be redefined or don't yet exist.
|
|
* See [Peter Michaux's article](http://michaux.ca/articles/lazy-function-definition-pattern)
|
|
* for more details.
|
|
*
|
|
* The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
|
|
* builds, may be used as a placeholder for partially applied arguments.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Object} object The object the method belongs to.
|
|
* @param {string} key The key of the method.
|
|
* @param {...*} [args] The arguments to be partially applied.
|
|
* @returns {Function} Returns the new bound function.
|
|
* @example
|
|
*
|
|
* var object = {
|
|
* 'user': 'fred',
|
|
* 'greet': function(greeting, punctuation) {
|
|
* return greeting + ' ' + this.user + punctuation;
|
|
* }
|
|
* };
|
|
*
|
|
* var bound = _.bindKey(object, 'greet', 'hi');
|
|
* bound('!');
|
|
* // => 'hi fred!'
|
|
*
|
|
* object.greet = function(greeting, punctuation) {
|
|
* return greeting + 'ya ' + this.user + punctuation;
|
|
* };
|
|
*
|
|
* bound('!');
|
|
* // => 'hiya fred!'
|
|
*
|
|
* // using placeholders
|
|
* var bound = _.bindKey(object, 'greet', _, '!');
|
|
* bound('hi');
|
|
* // => 'hiya fred!'
|
|
*/
|
|
function bindKey(object, key) {
|
|
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
|
|
if (arguments.length > 2) {
|
|
var partials = baseSlice(arguments, 2),
|
|
holders = replaceHolders(partials, bindKey.placeholder);
|
|
|
|
bitmask |= PARTIAL_FLAG;
|
|
}
|
|
return createWrapper(key, bitmask, object, partials, holders);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that accepts one or more arguments of `func` that when
|
|
* called either invokes `func` returning its result, if all `func` arguments
|
|
* have been provided, or returns a function that accepts one or more of the
|
|
* remaining `func` arguments, and so on. The arity of `func` may be specified
|
|
* if `func.length` is not sufficient.
|
|
*
|
|
* The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
|
|
* may be used as a placeholder for provided arguments.
|
|
*
|
|
* **Note:** This method does not set the `length` property of curried functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to curry.
|
|
* @param {number} [arity=func.length] The arity of `func`.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Function} Returns the new curried function.
|
|
* @example
|
|
*
|
|
* var abc = function(a, b, c) {
|
|
* return [a, b, c];
|
|
* };
|
|
*
|
|
* var curried = _.curry(abc);
|
|
*
|
|
* curried(1)(2)(3);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* curried(1, 2)(3);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* curried(1, 2, 3);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* // using placeholders
|
|
* curried(1)(_, 3)(2);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function curry(func, arity, guard) {
|
|
if (guard && isIterateeCall(func, arity, guard)) {
|
|
arity = null;
|
|
}
|
|
var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity);
|
|
result.placeholder = curry.placeholder;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.curry` except that arguments are applied to `func`
|
|
* in the manner of `_.partialRight` instead of `_.partial`.
|
|
*
|
|
* The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
|
|
* builds, may be used as a placeholder for provided arguments.
|
|
*
|
|
* **Note:** This method does not set the `length` property of curried functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to curry.
|
|
* @param {number} [arity=func.length] The arity of `func`.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Function} Returns the new curried function.
|
|
* @example
|
|
*
|
|
* var abc = function(a, b, c) {
|
|
* return [a, b, c];
|
|
* };
|
|
*
|
|
* var curried = _.curryRight(abc);
|
|
*
|
|
* curried(3)(2)(1);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* curried(2, 3)(1);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* curried(1, 2, 3);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* // using placeholders
|
|
* curried(3)(1, _)(2);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function curryRight(func, arity, guard) {
|
|
if (guard && isIterateeCall(func, arity, guard)) {
|
|
arity = null;
|
|
}
|
|
var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity);
|
|
result.placeholder = curryRight.placeholder;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that delays invoking `func` until after `wait` milliseconds
|
|
* have elapsed since the last time it was invoked. The created function comes
|
|
* with a `cancel` method to cancel delayed invocations. Provide an options
|
|
* object to indicate that `func` should be invoked on the leading and/or
|
|
* trailing edge of the `wait` timeout. Subsequent calls to the debounced
|
|
* function return the result of the last `func` invocation.
|
|
*
|
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
|
* on the trailing edge of the timeout only if the the debounced function is
|
|
* invoked more than once during the `wait` timeout.
|
|
*
|
|
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
|
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to debounce.
|
|
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.leading=false] Specify invoking on the leading
|
|
* edge of the timeout.
|
|
* @param {number} [options.maxWait] The maximum time `func` is allowed to be
|
|
* delayed before it is invoked.
|
|
* @param {boolean} [options.trailing=true] Specify invoking on the trailing
|
|
* edge of the timeout.
|
|
* @returns {Function} Returns the new debounced function.
|
|
* @example
|
|
*
|
|
* // avoid costly calculations while the window size is in flux
|
|
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
*
|
|
* // invoke `sendMail` when the click event is fired, debouncing subsequent calls
|
|
* jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
|
|
* 'leading': true,
|
|
* 'trailing': false
|
|
* }));
|
|
*
|
|
* // ensure `batchLog` is invoked once after 1 second of debounced calls
|
|
* var source = new EventSource('/stream');
|
|
* jQuery(source).on('message', _.debounce(batchLog, 250, {
|
|
* 'maxWait': 1000
|
|
* }));
|
|
*
|
|
* // cancel a debounced call
|
|
* var todoChanges = _.debounce(batchLog, 1000);
|
|
* Object.observe(models.todo, todoChanges);
|
|
*
|
|
* Object.observe(models, function(changes) {
|
|
* if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
|
|
* todoChanges.cancel();
|
|
* }
|
|
* }, ['delete']);
|
|
*
|
|
* // ...at some point `models.todo` is changed
|
|
* models.todo.completed = true;
|
|
*
|
|
* // ...before 1 second has passed `models.todo` is deleted
|
|
* // which cancels the debounced `todoChanges` call
|
|
* delete models.todo;
|
|
*/
|
|
function debounce(func, wait, options) {
|
|
var args,
|
|
maxTimeoutId,
|
|
result,
|
|
stamp,
|
|
thisArg,
|
|
timeoutId,
|
|
trailingCall,
|
|
lastCalled = 0,
|
|
maxWait = false,
|
|
trailing = true;
|
|
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
wait = wait < 0 ? 0 : (+wait || 0);
|
|
if (options === true) {
|
|
var leading = true;
|
|
trailing = false;
|
|
} else if (isObject(options)) {
|
|
leading = options.leading;
|
|
maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
|
|
trailing = 'trailing' in options ? options.trailing : trailing;
|
|
}
|
|
|
|
function cancel() {
|
|
if (timeoutId) {
|
|
clearTimeout(timeoutId);
|
|
}
|
|
if (maxTimeoutId) {
|
|
clearTimeout(maxTimeoutId);
|
|
}
|
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
|
}
|
|
|
|
function delayed() {
|
|
var remaining = wait - (now() - stamp);
|
|
if (remaining <= 0 || remaining > wait) {
|
|
if (maxTimeoutId) {
|
|
clearTimeout(maxTimeoutId);
|
|
}
|
|
var isCalled = trailingCall;
|
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
|
if (isCalled) {
|
|
lastCalled = now();
|
|
result = func.apply(thisArg, args);
|
|
if (!timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
}
|
|
} else {
|
|
timeoutId = setTimeout(delayed, remaining);
|
|
}
|
|
}
|
|
|
|
function maxDelayed() {
|
|
if (timeoutId) {
|
|
clearTimeout(timeoutId);
|
|
}
|
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
|
if (trailing || (maxWait !== wait)) {
|
|
lastCalled = now();
|
|
result = func.apply(thisArg, args);
|
|
if (!timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
function debounced() {
|
|
args = arguments;
|
|
stamp = now();
|
|
thisArg = this;
|
|
trailingCall = trailing && (timeoutId || !leading);
|
|
|
|
if (maxWait === false) {
|
|
var leadingCall = leading && !timeoutId;
|
|
} else {
|
|
if (!maxTimeoutId && !leading) {
|
|
lastCalled = stamp;
|
|
}
|
|
var remaining = maxWait - (stamp - lastCalled),
|
|
isCalled = remaining <= 0 || remaining > maxWait;
|
|
|
|
if (isCalled) {
|
|
if (maxTimeoutId) {
|
|
maxTimeoutId = clearTimeout(maxTimeoutId);
|
|
}
|
|
lastCalled = stamp;
|
|
result = func.apply(thisArg, args);
|
|
}
|
|
else if (!maxTimeoutId) {
|
|
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
|
}
|
|
}
|
|
if (isCalled && timeoutId) {
|
|
timeoutId = clearTimeout(timeoutId);
|
|
}
|
|
else if (!timeoutId && wait !== maxWait) {
|
|
timeoutId = setTimeout(delayed, wait);
|
|
}
|
|
if (leadingCall) {
|
|
isCalled = true;
|
|
result = func.apply(thisArg, args);
|
|
}
|
|
if (isCalled && !timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
return result;
|
|
}
|
|
debounced.cancel = cancel;
|
|
return debounced;
|
|
}
|
|
|
|
/**
|
|
* Defers invoking the `func` until the current call stack has cleared. Any
|
|
* additional arguments are provided to `func` when it is invoked.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to defer.
|
|
* @param {...*} [args] The arguments to invoke the function with.
|
|
* @returns {number} Returns the timer id.
|
|
* @example
|
|
*
|
|
* _.defer(function(text) {
|
|
* console.log(text);
|
|
* }, 'deferred');
|
|
* // logs 'deferred' after one or more milliseconds
|
|
*/
|
|
function defer(func) {
|
|
return baseDelay(func, 1, arguments, 1);
|
|
}
|
|
|
|
/**
|
|
* Invokes `func` after `wait` milliseconds. Any additional arguments are
|
|
* provided to `func` when it is invoked.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to delay.
|
|
* @param {number} wait The number of milliseconds to delay invocation.
|
|
* @param {...*} [args] The arguments to invoke the function with.
|
|
* @returns {number} Returns the timer id.
|
|
* @example
|
|
*
|
|
* _.delay(function(text) {
|
|
* console.log(text);
|
|
* }, 1000, 'later');
|
|
* // => logs 'later' after one second
|
|
*/
|
|
function delay(func, wait) {
|
|
return baseDelay(func, wait, arguments, 2);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that returns the result of invoking the provided
|
|
* functions with the `this` binding of the created function, where each
|
|
* successive invocation is supplied the return value of the previous.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {...Function} [funcs] Functions to invoke.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* function add(x, y) {
|
|
* return x + y;
|
|
* }
|
|
*
|
|
* function square(n) {
|
|
* return n * n;
|
|
* }
|
|
*
|
|
* var addSquare = _.flow(add, square);
|
|
* addSquare(1, 2);
|
|
* // => 9
|
|
*/
|
|
function flow() {
|
|
var funcs = arguments,
|
|
length = funcs.length;
|
|
|
|
if (!length) {
|
|
return function() { return arguments[0]; };
|
|
}
|
|
if (!arrayEvery(funcs, baseIsFunction)) {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
return function() {
|
|
var index = 0,
|
|
result = funcs[index].apply(this, arguments);
|
|
|
|
while (++index < length) {
|
|
result = funcs[index].call(this, result);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.flow` except that it creates a function that
|
|
* invokes the provided functions from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias backflow, compose
|
|
* @category Function
|
|
* @param {...Function} [funcs] Functions to invoke.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* function add(x, y) {
|
|
* return x + y;
|
|
* }
|
|
*
|
|
* function square(n) {
|
|
* return n * n;
|
|
* }
|
|
*
|
|
* var addSquare = _.flowRight(square, add);
|
|
* addSquare(1, 2);
|
|
* // => 9
|
|
*/
|
|
function flowRight() {
|
|
var funcs = arguments,
|
|
fromIndex = funcs.length - 1;
|
|
|
|
if (fromIndex < 0) {
|
|
return function() { return arguments[0]; };
|
|
}
|
|
if (!arrayEvery(funcs, baseIsFunction)) {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
return function() {
|
|
var index = fromIndex,
|
|
result = funcs[index].apply(this, arguments);
|
|
|
|
while (index--) {
|
|
result = funcs[index].call(this, result);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
* provided it determines the cache key for storing the result based on the
|
|
* arguments provided to the memoized function. By default, the first argument
|
|
* provided to the memoized function is coerced to a string and used as the
|
|
* cache key. The `func` is invoked with the `this` binding of the memoized
|
|
* function.
|
|
*
|
|
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
* constructor with one whose instances implement the ES `Map` method interface
|
|
* of `get`, `has`, and `set`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to have its output memoized.
|
|
* @param {Function} [resolver] The function to resolve the cache key.
|
|
* @returns {Function} Returns the new memoizing function.
|
|
* @example
|
|
*
|
|
* var upperCase = _.memoize(function(string) {
|
|
* return string.toUpperCase();
|
|
* });
|
|
*
|
|
* upperCase('fred');
|
|
* // => 'FRED'
|
|
*
|
|
* // modifying the result cache
|
|
* upperCase.cache.set('fred', 'BARNEY');
|
|
* upperCase('fred');
|
|
* // => 'BARNEY'
|
|
*
|
|
* // replacing `_.memoize.Cache`
|
|
* var object = { 'user': 'fred' };
|
|
* var other = { 'user': 'barney' };
|
|
* var identity = _.memoize(_.identity);
|
|
*
|
|
* identity(object);
|
|
* // => { 'user': 'fred' }
|
|
* identity(other);
|
|
* // => { 'user': 'fred' }
|
|
*
|
|
* _.memoize.Cache = WeakMap;
|
|
* var identity = _.memoize(_.identity);
|
|
*
|
|
* identity(object);
|
|
* // => { 'user': 'fred' }
|
|
* identity(other);
|
|
* // => { 'user': 'barney' }
|
|
*/
|
|
function memoize(func, resolver) {
|
|
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
var memoized = function() {
|
|
var cache = memoized.cache,
|
|
key = resolver ? resolver.apply(this, arguments) : arguments[0];
|
|
|
|
if (cache.has(key)) {
|
|
return cache.get(key);
|
|
}
|
|
var result = func.apply(this, arguments);
|
|
cache.set(key, result);
|
|
return result;
|
|
};
|
|
memoized.cache = new memoize.Cache;
|
|
return memoized;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that negates the result of the predicate `func`. The
|
|
* `func` predicate is invoked with the `this` binding and arguments of the
|
|
* created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} predicate The predicate to negate.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* function isEven(n) {
|
|
* return n % 2 == 0;
|
|
* }
|
|
*
|
|
* _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
|
|
* // => [1, 3, 5]
|
|
*/
|
|
function negate(predicate) {
|
|
if (typeof predicate != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
return function() {
|
|
return !predicate.apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that is restricted to invoking `func` once. Repeat calls
|
|
* to the function return the value of the first call. The `func` is invoked
|
|
* with the `this` binding of the created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* var initialize = _.once(createApplication);
|
|
* initialize();
|
|
* initialize();
|
|
* // `initialize` invokes `createApplication` once
|
|
*/
|
|
function once(func) {
|
|
return before(func, 2);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func` with `partial` arguments prepended
|
|
* to those provided to the new function. This method is like `_.bind` except
|
|
* it does **not** alter the `this` binding.
|
|
*
|
|
* The `_.partial.placeholder` value, which defaults to `_` in monolithic
|
|
* builds, may be used as a placeholder for partially applied arguments.
|
|
*
|
|
* **Note:** This method does not set the `length` property of partially
|
|
* applied functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to partially apply arguments to.
|
|
* @param {...*} [args] The arguments to be partially applied.
|
|
* @returns {Function} Returns the new partially applied function.
|
|
* @example
|
|
*
|
|
* var greet = function(greeting, name) {
|
|
* return greeting + ' ' + name;
|
|
* };
|
|
*
|
|
* var sayHelloTo = _.partial(greet, 'hello');
|
|
* sayHelloTo('fred');
|
|
* // => 'hello fred'
|
|
*
|
|
* // using placeholders
|
|
* var greetFred = _.partial(greet, _, 'fred');
|
|
* greetFred('hi');
|
|
* // => 'hi fred'
|
|
*/
|
|
function partial(func) {
|
|
var partials = baseSlice(arguments, 1),
|
|
holders = replaceHolders(partials, partial.placeholder);
|
|
|
|
return createWrapper(func, PARTIAL_FLAG, null, partials, holders);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.partial` except that partially applied arguments
|
|
* are appended to those provided to the new function.
|
|
*
|
|
* The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
|
|
* builds, may be used as a placeholder for partially applied arguments.
|
|
*
|
|
* **Note:** This method does not set the `length` property of partially
|
|
* applied functions.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to partially apply arguments to.
|
|
* @param {...*} [args] The arguments to be partially applied.
|
|
* @returns {Function} Returns the new partially applied function.
|
|
* @example
|
|
*
|
|
* var greet = function(greeting, name) {
|
|
* return greeting + ' ' + name;
|
|
* };
|
|
*
|
|
* var greetFred = _.partialRight(greet, 'fred');
|
|
* greetFred('hi');
|
|
* // => 'hi fred'
|
|
*
|
|
* // using placeholders
|
|
* var sayHelloTo = _.partialRight(greet, 'hello', _);
|
|
* sayHelloTo('fred');
|
|
* // => 'hello fred'
|
|
*/
|
|
function partialRight(func) {
|
|
var partials = baseSlice(arguments, 1),
|
|
holders = replaceHolders(partials, partialRight.placeholder);
|
|
|
|
return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func` with arguments arranged according
|
|
* to the specified indexes where the argument value at the first index is
|
|
* provided as the first argument, the argument value at the second index is
|
|
* provided as the second argument, and so on.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to rearrange arguments for.
|
|
* @param {...(number|number[])} indexes The arranged argument indexes,
|
|
* specified as individual indexes or arrays of indexes.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var rearged = _.rearg(function(a, b, c) {
|
|
* return [a, b, c];
|
|
* }, 2, 0, 1);
|
|
*
|
|
* rearged('b', 'c', 'a')
|
|
* // => ['a', 'b', 'c']
|
|
*
|
|
* var map = _.rearg(_.map, [1, 0]);
|
|
* map(function(n) {
|
|
* return n * 3;
|
|
* }, [1, 2, 3]);
|
|
* // => [3, 6, 9]
|
|
*/
|
|
function rearg(func) {
|
|
var indexes = baseFlatten(arguments, false, false, 1);
|
|
return createWrapper(func, REARG_FLAG, null, null, null, indexes);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func` with the `this` binding of the
|
|
* created function and the array of arguments provided to the created
|
|
* function much like [Function#apply](http://es5.github.io/#x15.3.4.3).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to spread arguments over.
|
|
* @returns {*} Returns the new function.
|
|
* @example
|
|
*
|
|
* var spread = _.spread(function(who, what) {
|
|
* return who + ' says ' + what;
|
|
* });
|
|
*
|
|
* spread(['Fred', 'hello']);
|
|
* // => 'Fred says hello'
|
|
*
|
|
* // with a Promise
|
|
* var numbers = Promise.all([
|
|
* Promise.resolve(40),
|
|
* Promise.resolve(36)
|
|
* ]);
|
|
*
|
|
* numbers.then(_.spread(function(x, y) {
|
|
* return x + y;
|
|
* }));
|
|
* // => a Promise of 76
|
|
*/
|
|
function spread(func) {
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
return function(array) {
|
|
return func.apply(this, array);
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that only invokes `func` at most once per every `wait`
|
|
* milliseconds. The created function comes with a `cancel` method to cancel
|
|
* delayed invocations. Provide an options object to indicate that `func`
|
|
* should be invoked on the leading and/or trailing edge of the `wait` timeout.
|
|
* Subsequent calls to the throttled function return the result of the last
|
|
* `func` call.
|
|
*
|
|
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
|
|
* on the trailing edge of the timeout only if the the throttled function is
|
|
* invoked more than once during the `wait` timeout.
|
|
*
|
|
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
|
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {Function} func The function to throttle.
|
|
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.leading=true] Specify invoking on the leading
|
|
* edge of the timeout.
|
|
* @param {boolean} [options.trailing=true] Specify invoking on the trailing
|
|
* edge of the timeout.
|
|
* @returns {Function} Returns the new throttled function.
|
|
* @example
|
|
*
|
|
* // avoid excessively updating the position while scrolling
|
|
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
*
|
|
* // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
|
|
* jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
|
|
* 'trailing': false
|
|
* }));
|
|
*
|
|
* // cancel a trailing throttled call
|
|
* jQuery(window).on('popstate', throttled.cancel);
|
|
*/
|
|
function throttle(func, wait, options) {
|
|
var leading = true,
|
|
trailing = true;
|
|
|
|
if (typeof func != 'function') {
|
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
}
|
|
if (options === false) {
|
|
leading = false;
|
|
} else if (isObject(options)) {
|
|
leading = 'leading' in options ? !!options.leading : leading;
|
|
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
}
|
|
debounceOptions.leading = leading;
|
|
debounceOptions.maxWait = +wait;
|
|
debounceOptions.trailing = trailing;
|
|
return debounce(func, wait, debounceOptions);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that provides `value` to the wrapper function as its
|
|
* first argument. Any additional arguments provided to the function are
|
|
* appended to those provided to the wrapper function. The wrapper is invoked
|
|
* with the `this` binding of the created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Function
|
|
* @param {*} value The value to wrap.
|
|
* @param {Function} wrapper The wrapper function.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var p = _.wrap(_.escape, function(func, text) {
|
|
* return '<p>' + func(text) + '</p>';
|
|
* });
|
|
*
|
|
* p('fred, barney, & pebbles');
|
|
* // => '<p>fred, barney, & pebbles</p>'
|
|
*/
|
|
function wrap(value, wrapper) {
|
|
wrapper = wrapper == null ? identity : wrapper;
|
|
return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []);
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
|
|
* otherwise they are assigned by reference. If `customizer` is provided it is
|
|
* invoked to produce the cloned values. If `customizer` returns `undefined`
|
|
* cloning is handled by the method instead. The `customizer` is bound to
|
|
* `thisArg` and invoked with two argument; (value [, index|key, object]).
|
|
*
|
|
* **Note:** This method is loosely based on the structured clone algorithm.
|
|
* The enumerable properties of `arguments` objects and objects created by
|
|
* constructors other than `Object` are cloned to plain `Object` objects. An
|
|
* empty object is returned for uncloneable values such as functions, DOM nodes,
|
|
* Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to clone.
|
|
* @param {boolean} [isDeep] Specify a deep clone.
|
|
* @param {Function} [customizer] The function to customize cloning values.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {*} Returns the cloned value.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney' },
|
|
* { 'user': 'fred' }
|
|
* ];
|
|
*
|
|
* var shallow = _.clone(users);
|
|
* shallow[0] === users[0];
|
|
* // => true
|
|
*
|
|
* var deep = _.clone(users, true);
|
|
* deep[0] === users[0];
|
|
* // => false
|
|
*
|
|
* // using a customizer callback
|
|
* var el = _.clone(document.body, function(value) {
|
|
* if (_.isElement(value)) {
|
|
* return value.cloneNode(false);
|
|
* }
|
|
* });
|
|
*
|
|
* el === document.body
|
|
* // => false
|
|
* el.nodeName
|
|
* // => BODY
|
|
* el.childNodes.length;
|
|
* // => 0
|
|
*/
|
|
function clone(value, isDeep, customizer, thisArg) {
|
|
if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
|
|
isDeep = false;
|
|
}
|
|
else if (typeof isDeep == 'function') {
|
|
thisArg = customizer;
|
|
customizer = isDeep;
|
|
isDeep = false;
|
|
}
|
|
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
|
|
return baseClone(value, isDeep, customizer);
|
|
}
|
|
|
|
/**
|
|
* Creates a deep clone of `value`. If `customizer` is provided it is invoked
|
|
* to produce the cloned values. If `customizer` returns `undefined` cloning
|
|
* is handled by the method instead. The `customizer` is bound to `thisArg`
|
|
* and invoked with two argument; (value [, index|key, object]).
|
|
*
|
|
* **Note:** This method is loosely based on the structured clone algorithm.
|
|
* The enumerable properties of `arguments` objects and objects created by
|
|
* constructors other than `Object` are cloned to plain `Object` objects. An
|
|
* empty object is returned for uncloneable values such as functions, DOM nodes,
|
|
* Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to deep clone.
|
|
* @param {Function} [customizer] The function to customize cloning values.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {*} Returns the deep cloned value.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney' },
|
|
* { 'user': 'fred' }
|
|
* ];
|
|
*
|
|
* var deep = _.cloneDeep(users);
|
|
* deep[0] === users[0];
|
|
* // => false
|
|
*
|
|
* // using a customizer callback
|
|
* var el = _.cloneDeep(document.body, function(value) {
|
|
* if (_.isElement(value)) {
|
|
* return value.cloneNode(true);
|
|
* }
|
|
* });
|
|
*
|
|
* el === document.body
|
|
* // => false
|
|
* el.nodeName
|
|
* // => BODY
|
|
* el.childNodes.length;
|
|
* // => 20
|
|
*/
|
|
function cloneDeep(value, customizer, thisArg) {
|
|
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
|
|
return baseClone(value, true, customizer);
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as an `arguments` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isArguments(function() { return arguments; }());
|
|
* // => true
|
|
*
|
|
* _.isArguments([1, 2, 3]);
|
|
* // => false
|
|
*/
|
|
function isArguments(value) {
|
|
var length = isObjectLike(value) ? value.length : undefined;
|
|
return (isLength(length) && objToString.call(value) == argsTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as an `Array` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isArray([1, 2, 3]);
|
|
* // => true
|
|
*
|
|
* _.isArray(function() { return arguments; }());
|
|
* // => false
|
|
*/
|
|
var isArray = nativeIsArray || function(value) {
|
|
return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false;
|
|
};
|
|
|
|
/**
|
|
* Checks if `value` is classified as a boolean primitive or object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isBoolean(false);
|
|
* // => true
|
|
*
|
|
* _.isBoolean(null);
|
|
* // => false
|
|
*/
|
|
function isBoolean(value) {
|
|
return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Date` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isDate(new Date);
|
|
* // => true
|
|
*
|
|
* _.isDate('Mon April 23 2012');
|
|
* // => false
|
|
*/
|
|
function isDate(value) {
|
|
return (isObjectLike(value) && objToString.call(value) == dateTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a DOM element.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
|
|
* @example
|
|
*
|
|
* _.isElement(document.body);
|
|
* // => true
|
|
*
|
|
* _.isElement('<body>');
|
|
* // => false
|
|
*/
|
|
function isElement(value) {
|
|
return (value && value.nodeType === 1 && isObjectLike(value) &&
|
|
objToString.call(value).indexOf('Element') > -1) || false;
|
|
}
|
|
// Fallback for environments without DOM support.
|
|
if (!support.dom) {
|
|
isElement = function(value) {
|
|
return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Checks if a value is empty. A value is considered empty unless it is an
|
|
* `arguments` object, array, string, or jQuery-like collection with a length
|
|
* greater than `0` or an object with own enumerable properties.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {Array|Object|string} value The value to inspect.
|
|
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
* @example
|
|
*
|
|
* _.isEmpty(null);
|
|
* // => true
|
|
*
|
|
* _.isEmpty(true);
|
|
* // => true
|
|
*
|
|
* _.isEmpty(1);
|
|
* // => true
|
|
*
|
|
* _.isEmpty([1, 2, 3]);
|
|
* // => false
|
|
*
|
|
* _.isEmpty({ 'a': 1 });
|
|
* // => false
|
|
*/
|
|
function isEmpty(value) {
|
|
if (value == null) {
|
|
return true;
|
|
}
|
|
var length = value.length;
|
|
if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
|
|
(isObjectLike(value) && isFunction(value.splice)))) {
|
|
return !length;
|
|
}
|
|
return !keys(value).length;
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison between two values to determine if they are
|
|
* equivalent. If `customizer` is provided it is invoked to compare values.
|
|
* If `customizer` returns `undefined` comparisons are handled by the method
|
|
* instead. The `customizer` is bound to `thisArg` and invoked with three
|
|
* arguments; (value, other [, index|key]).
|
|
*
|
|
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
|
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
|
* their own, not inherited, enumerable properties. Functions and DOM nodes
|
|
* are **not** supported. Provide a customizer function to extend support
|
|
* for comparing other values.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to compare.
|
|
* @param {*} other The other value to compare.
|
|
* @param {Function} [customizer] The function to customize comparing values.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred' };
|
|
* var other = { 'user': 'fred' };
|
|
*
|
|
* object == other;
|
|
* // => false
|
|
*
|
|
* _.isEqual(object, other);
|
|
* // => true
|
|
*
|
|
* // using a customizer callback
|
|
* var array = ['hello', 'goodbye'];
|
|
* var other = ['hi', 'goodbye'];
|
|
*
|
|
* _.isEqual(array, other, function(value, other) {
|
|
* if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {
|
|
* return true;
|
|
* }
|
|
* });
|
|
* // => true
|
|
*/
|
|
function isEqual(value, other, customizer, thisArg) {
|
|
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
|
|
if (!customizer && isStrictComparable(value) && isStrictComparable(other)) {
|
|
return value === other;
|
|
}
|
|
var result = customizer ? customizer(value, other) : undefined;
|
|
return typeof result == 'undefined' ? baseIsEqual(value, other, customizer) : !!result;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
|
|
* `SyntaxError`, `TypeError`, or `URIError` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is an error object, else `false`.
|
|
* @example
|
|
*
|
|
* _.isError(new Error);
|
|
* // => true
|
|
*
|
|
* _.isError(Error);
|
|
* // => false
|
|
*/
|
|
function isError(value) {
|
|
return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a finite primitive number.
|
|
*
|
|
* **Note:** This method is based on ES `Number.isFinite`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
|
|
* @example
|
|
*
|
|
* _.isFinite(10);
|
|
* // => true
|
|
*
|
|
* _.isFinite('10');
|
|
* // => false
|
|
*
|
|
* _.isFinite(true);
|
|
* // => false
|
|
*
|
|
* _.isFinite(Object(10));
|
|
* // => false
|
|
*
|
|
* _.isFinite(Infinity);
|
|
* // => false
|
|
*/
|
|
var isFinite = nativeNumIsFinite || function(value) {
|
|
return typeof value == 'number' && nativeIsFinite(value);
|
|
};
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Function` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isFunction(_);
|
|
* // => true
|
|
*
|
|
* _.isFunction(/abc/);
|
|
* // => false
|
|
*/
|
|
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
// in older versions of Chrome and Safari which return 'function' for regexes
|
|
// and Safari 8 equivalents which return 'object' for typed array constructors.
|
|
return objToString.call(value) == funcTag;
|
|
};
|
|
|
|
/**
|
|
* Checks if `value` is the language type of `Object`.
|
|
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
*
|
|
* **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
* @example
|
|
*
|
|
* _.isObject({});
|
|
* // => true
|
|
*
|
|
* _.isObject([1, 2, 3]);
|
|
* // => true
|
|
*
|
|
* _.isObject(1);
|
|
* // => false
|
|
*/
|
|
function isObject(value) {
|
|
// Avoid a V8 JIT bug in Chrome 19-20.
|
|
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
|
|
var type = typeof value;
|
|
return type == 'function' || (value && type == 'object') || false;
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison between `object` and `source` to determine if
|
|
* `object` contains equivalent property values. If `customizer` is provided
|
|
* it is invoked to compare values. If `customizer` returns `undefined`
|
|
* comparisons are handled by the method instead. The `customizer` is bound
|
|
* to `thisArg` and invoked with three arguments; (value, other, index|key).
|
|
*
|
|
* **Note:** This method supports comparing properties of arrays, booleans,
|
|
* `Date` objects, numbers, `Object` objects, regexes, and strings. Functions
|
|
* and DOM nodes are **not** supported. Provide a customizer function to extend
|
|
* support for comparing other values.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {Object} object The object to inspect.
|
|
* @param {Object} source The object of property values to match.
|
|
* @param {Function} [customizer] The function to customize comparing values.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred', 'age': 40 };
|
|
*
|
|
* _.isMatch(object, { 'age': 40 });
|
|
* // => true
|
|
*
|
|
* _.isMatch(object, { 'age': 36 });
|
|
* // => false
|
|
*
|
|
* // using a customizer callback
|
|
* var object = { 'greeting': 'hello' };
|
|
* var source = { 'greeting': 'hi' };
|
|
*
|
|
* _.isMatch(object, source, function(value, other) {
|
|
* return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined;
|
|
* });
|
|
* // => true
|
|
*/
|
|
function isMatch(object, source, customizer, thisArg) {
|
|
var props = keys(source),
|
|
length = props.length;
|
|
|
|
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
|
|
if (!customizer && length == 1) {
|
|
var key = props[0],
|
|
value = source[key];
|
|
|
|
if (isStrictComparable(value)) {
|
|
return object != null && value === object[key] && hasOwnProperty.call(object, key);
|
|
}
|
|
}
|
|
var values = Array(length),
|
|
strictCompareFlags = Array(length);
|
|
|
|
while (length--) {
|
|
value = values[length] = source[props[length]];
|
|
strictCompareFlags[length] = isStrictComparable(value);
|
|
}
|
|
return baseIsMatch(object, props, values, strictCompareFlags, customizer);
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `NaN`.
|
|
*
|
|
* **Note:** This method is not the same as native `isNaN` which returns `true`
|
|
* for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNaN(NaN);
|
|
* // => true
|
|
*
|
|
* _.isNaN(new Number(NaN));
|
|
* // => true
|
|
*
|
|
* isNaN(undefined);
|
|
* // => true
|
|
*
|
|
* _.isNaN(undefined);
|
|
* // => false
|
|
*/
|
|
function isNaN(value) {
|
|
// An `NaN` primitive is the only value that is not equal to itself.
|
|
// Perform the `toStringTag` check first to avoid errors with some host objects in IE.
|
|
return isNumber(value) && value != +value;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a native function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a native function, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNative(Array.prototype.push);
|
|
* // => true
|
|
*
|
|
* _.isNative(_);
|
|
* // => false
|
|
*/
|
|
function isNative(value) {
|
|
if (value == null) {
|
|
return false;
|
|
}
|
|
if (objToString.call(value) == funcTag) {
|
|
return reNative.test(fnToString.call(value));
|
|
}
|
|
return (isObjectLike(value) && reHostCtor.test(value)) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `null`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is `null`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNull(null);
|
|
* // => true
|
|
*
|
|
* _.isNull(void 0);
|
|
* // => false
|
|
*/
|
|
function isNull(value) {
|
|
return value === null;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Number` primitive or object.
|
|
*
|
|
* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
|
|
* as numbers, use the `_.isFinite` method.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNumber(8.4);
|
|
* // => true
|
|
*
|
|
* _.isNumber(NaN);
|
|
* // => true
|
|
*
|
|
* _.isNumber('8.4');
|
|
* // => false
|
|
*/
|
|
function isNumber(value) {
|
|
return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a plain object, that is, an object created by the
|
|
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
*
|
|
* **Note:** This method assumes objects created by the `Object` constructor
|
|
* have no inherited enumerable properties.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* }
|
|
*
|
|
* _.isPlainObject(new Foo);
|
|
* // => false
|
|
*
|
|
* _.isPlainObject([1, 2, 3]);
|
|
* // => false
|
|
*
|
|
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
* // => true
|
|
*
|
|
* _.isPlainObject(Object.create(null));
|
|
* // => true
|
|
*/
|
|
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
|
if (!(value && objToString.call(value) == objectTag)) {
|
|
return false;
|
|
}
|
|
var valueOf = value.valueOf,
|
|
objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
|
|
|
return objProto
|
|
? (value == objProto || getPrototypeOf(value) == objProto)
|
|
: shimIsPlainObject(value);
|
|
};
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `RegExp` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isRegExp(/abc/);
|
|
* // => true
|
|
*
|
|
* _.isRegExp('/abc/');
|
|
* // => false
|
|
*/
|
|
function isRegExp(value) {
|
|
return (isObjectLike(value) && objToString.call(value) == regexpTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `String` primitive or object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isString('abc');
|
|
* // => true
|
|
*
|
|
* _.isString(1);
|
|
* // => false
|
|
*/
|
|
function isString(value) {
|
|
return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is classified as a typed array.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
* @example
|
|
*
|
|
* _.isTypedArray(new Uint8Array);
|
|
* // => true
|
|
*
|
|
* _.isTypedArray([]);
|
|
* // => false
|
|
*/
|
|
function isTypedArray(value) {
|
|
return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `undefined`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isUndefined(void 0);
|
|
* // => true
|
|
*
|
|
* _.isUndefined(null);
|
|
* // => false
|
|
*/
|
|
function isUndefined(value) {
|
|
return typeof value == 'undefined';
|
|
}
|
|
|
|
/**
|
|
* Converts `value` to an array.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to convert.
|
|
* @returns {Array} Returns the converted array.
|
|
* @example
|
|
*
|
|
* (function() {
|
|
* return _.toArray(arguments).slice(1);
|
|
* }(1, 2, 3));
|
|
* // => [2, 3]
|
|
*/
|
|
function toArray(value) {
|
|
var length = value ? value.length : 0;
|
|
if (!isLength(length)) {
|
|
return values(value);
|
|
}
|
|
if (!length) {
|
|
return [];
|
|
}
|
|
return arrayCopy(value);
|
|
}
|
|
|
|
/**
|
|
* Converts `value` to a plain object flattening inherited enumerable
|
|
* properties of `value` to own properties of the plain object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Lang
|
|
* @param {*} value The value to convert.
|
|
* @returns {Object} Returns the converted plain object.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.assign({ 'a': 1 }, new Foo);
|
|
* // => { 'a': 1, 'b': 2 }
|
|
*
|
|
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
|
* // => { 'a': 1, 'b': 2, 'c': 3 }
|
|
*/
|
|
function toPlainObject(value) {
|
|
return baseCopy(value, keysIn(value));
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Assigns own enumerable properties of source object(s) to the destination
|
|
* object. Subsequent sources overwrite property assignments of previous sources.
|
|
* If `customizer` is provided it is invoked to produce the assigned values.
|
|
* The `customizer` is bound to `thisArg` and invoked with five arguments;
|
|
* (objectValue, sourceValue, key, object, source).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias extend
|
|
* @category Object
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [sources] The source objects.
|
|
* @param {Function} [customizer] The function to customize assigning values.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
|
|
* // => { 'user': 'fred', 'age': 40 }
|
|
*
|
|
* // using a customizer callback
|
|
* var defaults = _.partialRight(_.assign, function(value, other) {
|
|
* return typeof value == 'undefined' ? other : value;
|
|
* });
|
|
*
|
|
* defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
|
* // => { 'user': 'barney', 'age': 36 }
|
|
*/
|
|
var assign = createAssigner(baseAssign);
|
|
|
|
/**
|
|
* Creates an object that inherits from the given `prototype` object. If a
|
|
* `properties` object is provided its own enumerable properties are assigned
|
|
* to the created object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} prototype The object to inherit from.
|
|
* @param {Object} [properties] The properties to assign to the object.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Object} Returns the new object.
|
|
* @example
|
|
*
|
|
* function Shape() {
|
|
* this.x = 0;
|
|
* this.y = 0;
|
|
* }
|
|
*
|
|
* function Circle() {
|
|
* Shape.call(this);
|
|
* }
|
|
*
|
|
* Circle.prototype = _.create(Shape.prototype, {
|
|
* 'constructor': Circle
|
|
* });
|
|
*
|
|
* var circle = new Circle;
|
|
* circle instanceof Circle;
|
|
* // => true
|
|
*
|
|
* circle instanceof Shape;
|
|
* // => true
|
|
*/
|
|
function create(prototype, properties, guard) {
|
|
var result = baseCreate(prototype);
|
|
if (guard && isIterateeCall(prototype, properties, guard)) {
|
|
properties = null;
|
|
}
|
|
return properties ? baseCopy(properties, result, keys(properties)) : result;
|
|
}
|
|
|
|
/**
|
|
* Assigns own enumerable properties of source object(s) to the destination
|
|
* object for all destination properties that resolve to `undefined`. Once a
|
|
* property is set, additional defaults of the same property are ignored.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [sources] The source objects.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
|
* // => { 'user': 'barney', 'age': 36 }
|
|
*/
|
|
function defaults(object) {
|
|
if (object == null) {
|
|
return object;
|
|
}
|
|
var args = arrayCopy(arguments);
|
|
args.push(assignDefaults);
|
|
return assign.apply(undefined, args);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.findIndex` except that it returns the key of the
|
|
* first element `predicate` returns truthy for, instead of the element itself.
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {string|undefined} Returns the key of the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var users = {
|
|
* 'barney': { 'age': 36, 'active': true },
|
|
* 'fred': { 'age': 40, 'active': false },
|
|
* 'pebbles': { 'age': 1, 'active': true }
|
|
* };
|
|
*
|
|
* _.findKey(users, function(chr) {
|
|
* return chr.age < 40;
|
|
* });
|
|
* // => 'barney' (iteration order is not guaranteed)
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.findKey(users, { 'age': 1, 'active': true });
|
|
* // => 'pebbles'
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.findKey(users, 'active', false);
|
|
* // => 'fred'
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.findKey(users, 'active');
|
|
* // => 'barney'
|
|
*/
|
|
function findKey(object, predicate, thisArg) {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return baseFind(object, predicate, baseForOwn, true);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.findKey` except that it iterates over elements of
|
|
* a collection in the opposite order.
|
|
*
|
|
* If a property name is provided for `predicate` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `predicate` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {string|undefined} Returns the key of the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var users = {
|
|
* 'barney': { 'age': 36, 'active': true },
|
|
* 'fred': { 'age': 40, 'active': false },
|
|
* 'pebbles': { 'age': 1, 'active': true }
|
|
* };
|
|
*
|
|
* _.findLastKey(users, function(chr) {
|
|
* return chr.age < 40;
|
|
* });
|
|
* // => returns `pebbles` assuming `_.findKey` returns `barney`
|
|
*
|
|
* // using the `_.matches` callback shorthand
|
|
* _.findLastKey(users, { 'age': 36, 'active': true });
|
|
* // => 'barney'
|
|
*
|
|
* // using the `_.matchesProperty` callback shorthand
|
|
* _.findLastKey(users, 'active', false);
|
|
* // => 'fred'
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.findLastKey(users, 'active');
|
|
* // => 'pebbles'
|
|
*/
|
|
function findLastKey(object, predicate, thisArg) {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return baseFind(object, predicate, baseForOwnRight, true);
|
|
}
|
|
|
|
/**
|
|
* Iterates over own and inherited enumerable properties of an object invoking
|
|
* `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked
|
|
* with three arguments; (value, key, object). Iterator functions may exit
|
|
* iteration early by explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.forIn(new Foo, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'a', 'b', and 'c' (iteration order is not guaranteed)
|
|
*/
|
|
function forIn(object, iteratee, thisArg) {
|
|
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
|
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
|
}
|
|
return baseFor(object, iteratee, keysIn);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.forIn` except that it iterates over properties of
|
|
* `object` in the opposite order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.forInRight(new Foo, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c'
|
|
*/
|
|
function forInRight(object, iteratee, thisArg) {
|
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
|
return baseForRight(object, iteratee, keysIn);
|
|
}
|
|
|
|
/**
|
|
* Iterates over own enumerable properties of an object invoking `iteratee`
|
|
* for each property. The `iteratee` is bound to `thisArg` and invoked with
|
|
* three arguments; (value, key, object). Iterator functions may exit iteration
|
|
* early by explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.forOwn(new Foo, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'a' and 'b' (iteration order is not guaranteed)
|
|
*/
|
|
function forOwn(object, iteratee, thisArg) {
|
|
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
|
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
|
}
|
|
return baseForOwn(object, iteratee);
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.forOwn` except that it iterates over properties of
|
|
* `object` in the opposite order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.forOwnRight(new Foo, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'
|
|
*/
|
|
function forOwnRight(object, iteratee, thisArg) {
|
|
iteratee = bindCallback(iteratee, thisArg, 3);
|
|
return baseForRight(object, iteratee, keys);
|
|
}
|
|
|
|
/**
|
|
* Creates an array of function property names from all enumerable properties,
|
|
* own and inherited, of `object`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias methods
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns the new array of property names.
|
|
* @example
|
|
*
|
|
* _.functions(_);
|
|
* // => ['after', 'ary', 'assign', ...]
|
|
*/
|
|
function functions(object) {
|
|
return baseFunctions(object, keysIn(object));
|
|
}
|
|
|
|
/**
|
|
* Checks if `key` exists as a direct property of `object` instead of an
|
|
* inherited property.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @param {string} key The key to check.
|
|
* @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
|
|
* @example
|
|
*
|
|
* var object = { 'a': 1, 'b': 2, 'c': 3 };
|
|
*
|
|
* _.has(object, 'b');
|
|
* // => true
|
|
*/
|
|
function has(object, key) {
|
|
return object ? hasOwnProperty.call(object, key) : false;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of the inverted keys and values of `object`.
|
|
* If `object` contains duplicate values, subsequent values overwrite property
|
|
* assignments of previous values unless `multiValue` is `true`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to invert.
|
|
* @param {boolean} [multiValue] Allow multiple values per key.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Object} Returns the new inverted object.
|
|
* @example
|
|
*
|
|
* var object = { 'a': 1, 'b': 2, 'c': 1 };
|
|
*
|
|
* _.invert(object);
|
|
* // => { '1': 'c', '2': 'b' }
|
|
*
|
|
* // with `multiValue`
|
|
* _.invert(object, true);
|
|
* // => { '1': ['a', 'c'], '2': ['b'] }
|
|
*/
|
|
function invert(object, multiValue, guard) {
|
|
if (guard && isIterateeCall(object, multiValue, guard)) {
|
|
multiValue = null;
|
|
}
|
|
var index = -1,
|
|
props = keys(object),
|
|
length = props.length,
|
|
result = {};
|
|
|
|
while (++index < length) {
|
|
var key = props[index],
|
|
value = object[key];
|
|
|
|
if (multiValue) {
|
|
if (hasOwnProperty.call(result, value)) {
|
|
result[value].push(key);
|
|
} else {
|
|
result[value] = [key];
|
|
}
|
|
}
|
|
else {
|
|
result[value] = key;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of the own enumerable property names of `object`.
|
|
*
|
|
* **Note:** Non-object values are coerced to objects. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns the array of property names.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.keys(new Foo);
|
|
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
*
|
|
* _.keys('hi');
|
|
* // => ['0', '1']
|
|
*/
|
|
var keys = !nativeKeys ? shimKeys : function(object) {
|
|
if (object) {
|
|
var Ctor = object.constructor,
|
|
length = object.length;
|
|
}
|
|
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
|
|
(typeof object != 'function' && (length && isLength(length)))) {
|
|
return shimKeys(object);
|
|
}
|
|
return isObject(object) ? nativeKeys(object) : [];
|
|
};
|
|
|
|
/**
|
|
* Creates an array of the own and inherited enumerable property names of `object`.
|
|
*
|
|
* **Note:** Non-object values are coerced to objects.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns the array of property names.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.keysIn(new Foo);
|
|
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
|
*/
|
|
function keysIn(object) {
|
|
if (object == null) {
|
|
return [];
|
|
}
|
|
if (!isObject(object)) {
|
|
object = Object(object);
|
|
}
|
|
var length = object.length;
|
|
length = (length && isLength(length) &&
|
|
(isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
|
|
|
|
var Ctor = object.constructor,
|
|
index = -1,
|
|
isProto = typeof Ctor == 'function' && Ctor.prototype === object,
|
|
result = Array(length),
|
|
skipIndexes = length > 0;
|
|
|
|
while (++index < length) {
|
|
result[index] = (index + '');
|
|
}
|
|
for (var key in object) {
|
|
if (!(skipIndexes && isIndex(key, length)) &&
|
|
!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
|
result.push(key);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an object with the same keys as `object` and values generated by
|
|
* running each own enumerable property of `object` through `iteratee`. The
|
|
* iteratee function is bound to `thisArg` and invoked with three arguments;
|
|
* (value, key, object).
|
|
*
|
|
* If a property name is provided for `iteratee` the created `_.property`
|
|
* style callback returns the property value of the given element.
|
|
*
|
|
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
|
* style callback returns `true` for elements that have a matching property
|
|
* value, else `false`.
|
|
*
|
|
* If an object is provided for `iteratee` the created `_.matches` style
|
|
* callback returns `true` for elements that have the properties of the given
|
|
* object, else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Object} Returns the new mapped object.
|
|
* @example
|
|
*
|
|
* _.mapValues({ 'a': 1, 'b': 2 }, function(n) {
|
|
* return n * 3;
|
|
* });
|
|
* // => { 'a': 3, 'b': 6 }
|
|
*
|
|
* var users = {
|
|
* 'fred': { 'user': 'fred', 'age': 40 },
|
|
* 'pebbles': { 'user': 'pebbles', 'age': 1 }
|
|
* };
|
|
*
|
|
* // using the `_.property` callback shorthand
|
|
* _.mapValues(users, 'age');
|
|
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
|
|
*/
|
|
function mapValues(object, iteratee, thisArg) {
|
|
var result = {};
|
|
iteratee = getCallback(iteratee, thisArg, 3);
|
|
|
|
baseForOwn(object, function(value, key, object) {
|
|
result[key] = iteratee(value, key, object);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Recursively merges own enumerable properties of the source object(s), that
|
|
* don't resolve to `undefined` into the destination object. Subsequent sources
|
|
* overwrite property assignments of previous sources. If `customizer` is
|
|
* provided it is invoked to produce the merged values of the destination and
|
|
* source properties. If `customizer` returns `undefined` merging is handled
|
|
* by the method instead. The `customizer` is bound to `thisArg` and invoked
|
|
* with five arguments; (objectValue, sourceValue, key, object, source).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [sources] The source objects.
|
|
* @param {Function} [customizer] The function to customize merging properties.
|
|
* @param {*} [thisArg] The `this` binding of `customizer`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* var users = {
|
|
* 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
|
|
* };
|
|
*
|
|
* var ages = {
|
|
* 'data': [{ 'age': 36 }, { 'age': 40 }]
|
|
* };
|
|
*
|
|
* _.merge(users, ages);
|
|
* // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
|
|
*
|
|
* // using a customizer callback
|
|
* var object = {
|
|
* 'fruits': ['apple'],
|
|
* 'vegetables': ['beet']
|
|
* };
|
|
*
|
|
* var other = {
|
|
* 'fruits': ['banana'],
|
|
* 'vegetables': ['carrot']
|
|
* };
|
|
*
|
|
* _.merge(object, other, function(a, b) {
|
|
* if (_.isArray(a)) {
|
|
* return a.concat(b);
|
|
* }
|
|
* });
|
|
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
|
|
*/
|
|
var merge = createAssigner(baseMerge);
|
|
|
|
/**
|
|
* The opposite of `_.pick`; this method creates an object composed of the
|
|
* own and inherited enumerable properties of `object` that are not omitted.
|
|
* Property names may be specified as individual arguments or as arrays of
|
|
* property names. If `predicate` is provided it is invoked for each property
|
|
* of `object` omitting the properties `predicate` returns truthy for. The
|
|
* predicate is bound to `thisArg` and invoked with three arguments;
|
|
* (value, key, object).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The source object.
|
|
* @param {Function|...(string|string[])} [predicate] The function invoked per
|
|
* iteration or property names to omit, specified as individual property
|
|
* names or arrays of property names.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Object} Returns the new object.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred', 'age': 40 };
|
|
*
|
|
* _.omit(object, 'age');
|
|
* // => { 'user': 'fred' }
|
|
*
|
|
* _.omit(object, _.isNumber);
|
|
* // => { 'user': 'fred' }
|
|
*/
|
|
function omit(object, predicate, thisArg) {
|
|
if (object == null) {
|
|
return {};
|
|
}
|
|
if (typeof predicate != 'function') {
|
|
var props = arrayMap(baseFlatten(arguments, false, false, 1), String);
|
|
return pickByArray(object, baseDifference(keysIn(object), props));
|
|
}
|
|
predicate = bindCallback(predicate, thisArg, 3);
|
|
return pickByCallback(object, function(value, key, object) {
|
|
return !predicate(value, key, object);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Creates a two dimensional array of the key-value pairs for `object`,
|
|
* e.g. `[[key1, value1], [key2, value2]]`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns the new array of key-value pairs.
|
|
* @example
|
|
*
|
|
* _.pairs({ 'barney': 36, 'fred': 40 });
|
|
* // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
|
|
*/
|
|
function pairs(object) {
|
|
var index = -1,
|
|
props = keys(object),
|
|
length = props.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
result[index] = [key, object[key]];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of the picked `object` properties. Property
|
|
* names may be specified as individual arguments or as arrays of property
|
|
* names. If `predicate` is provided it is invoked for each property of `object`
|
|
* picking the properties `predicate` returns truthy for. The predicate is
|
|
* bound to `thisArg` and invoked with three arguments; (value, key, object).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The source object.
|
|
* @param {Function|...(string|string[])} [predicate] The function invoked per
|
|
* iteration or property names to pick, specified as individual property
|
|
* names or arrays of property names.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {Object} Returns the new object.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred', 'age': 40 };
|
|
*
|
|
* _.pick(object, 'user');
|
|
* // => { 'user': 'fred' }
|
|
*
|
|
* _.pick(object, _.isString);
|
|
* // => { 'user': 'fred' }
|
|
*/
|
|
function pick(object, predicate, thisArg) {
|
|
if (object == null) {
|
|
return {};
|
|
}
|
|
return typeof predicate == 'function'
|
|
? pickByCallback(object, bindCallback(predicate, thisArg, 3))
|
|
: pickByArray(object, baseFlatten(arguments, false, false, 1));
|
|
}
|
|
|
|
/**
|
|
* Resolves the value of property `key` on `object`. If the value of `key` is
|
|
* a function it is invoked with the `this` binding of `object` and its result
|
|
* is returned, else the property value is returned. If the property value is
|
|
* `undefined` the `defaultValue` is used in its place.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to query.
|
|
* @param {string} key The key of the property to resolve.
|
|
* @param {*} [defaultValue] The value returned if the property value
|
|
* resolves to `undefined`.
|
|
* @returns {*} Returns the resolved value.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred', 'age': _.constant(40) };
|
|
*
|
|
* _.result(object, 'user');
|
|
* // => 'fred'
|
|
*
|
|
* _.result(object, 'age');
|
|
* // => 40
|
|
*
|
|
* _.result(object, 'status', 'busy');
|
|
* // => 'busy'
|
|
*
|
|
* _.result(object, 'status', _.constant('busy'));
|
|
* // => 'busy'
|
|
*/
|
|
function result(object, key, defaultValue) {
|
|
var value = object == null ? undefined : object[key];
|
|
if (typeof value == 'undefined') {
|
|
value = defaultValue;
|
|
}
|
|
return isFunction(value) ? value.call(object) : value;
|
|
}
|
|
|
|
/**
|
|
* An alternative to `_.reduce`; this method transforms `object` to a new
|
|
* `accumulator` object which is the result of running each of its own enumerable
|
|
* properties through `iteratee`, with each invocation potentially mutating
|
|
* the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked
|
|
* with four arguments; (accumulator, value, key, object). Iterator functions
|
|
* may exit iteration early by explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Array|Object} object The object to iterate over.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [accumulator] The custom accumulator value.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* _.transform([2, 3, 4], function(result, n) {
|
|
* result.push(n *= n);
|
|
* return n % 2 == 0;
|
|
* });
|
|
* // => [4, 9]
|
|
*
|
|
* _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) {
|
|
* result[key] = n * 3;
|
|
* });
|
|
* // => { 'a': 3, 'b': 6 }
|
|
*/
|
|
function transform(object, iteratee, accumulator, thisArg) {
|
|
var isArr = isArray(object) || isTypedArray(object);
|
|
iteratee = getCallback(iteratee, thisArg, 4);
|
|
|
|
if (accumulator == null) {
|
|
if (isArr || isObject(object)) {
|
|
var Ctor = object.constructor;
|
|
if (isArr) {
|
|
accumulator = isArray(object) ? new Ctor : [];
|
|
} else {
|
|
accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype);
|
|
}
|
|
} else {
|
|
accumulator = {};
|
|
}
|
|
}
|
|
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
|
return iteratee(accumulator, value, index, object);
|
|
});
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of the own enumerable property values of `object`.
|
|
*
|
|
* **Note:** Non-object values are coerced to objects.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to query.
|
|
* @returns {Array} Returns the array of property values.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.values(new Foo);
|
|
* // => [1, 2] (iteration order is not guaranteed)
|
|
*
|
|
* _.values('hi');
|
|
* // => ['h', 'i']
|
|
*/
|
|
function values(object) {
|
|
return baseValues(object, keys(object));
|
|
}
|
|
|
|
/**
|
|
* Creates an array of the own and inherited enumerable property values
|
|
* of `object`.
|
|
*
|
|
* **Note:** Non-object values are coerced to objects.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Object
|
|
* @param {Object} object The object to query.
|
|
* @returns {Array} Returns the array of property values.
|
|
* @example
|
|
*
|
|
* function Foo() {
|
|
* this.a = 1;
|
|
* this.b = 2;
|
|
* }
|
|
*
|
|
* Foo.prototype.c = 3;
|
|
*
|
|
* _.valuesIn(new Foo);
|
|
* // => [1, 2, 3] (iteration order is not guaranteed)
|
|
*/
|
|
function valuesIn(object) {
|
|
return baseValues(object, keysIn(object));
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Checks if `n` is between `start` and up to but not including, `end`. If
|
|
* `end` is not specified it defaults to `start` with `start` becoming `0`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Number
|
|
* @param {number} n The number to check.
|
|
* @param {number} [start=0] The start of the range.
|
|
* @param {number} end The end of the range.
|
|
* @returns {boolean} Returns `true` if `n` is in the range, else `false`.
|
|
* @example
|
|
*
|
|
* _.inRange(3, 2, 4);
|
|
* // => true
|
|
*
|
|
* _.inRange(4, 8);
|
|
* // => true
|
|
*
|
|
* _.inRange(4, 2);
|
|
* // => false
|
|
*
|
|
* _.inRange(2, 2);
|
|
* // => false
|
|
*
|
|
* _.inRange(1.2, 2);
|
|
* // => true
|
|
*
|
|
* _.inRange(5.2, 4);
|
|
* // => false
|
|
*/
|
|
function inRange(value, start, end) {
|
|
start = +start || 0;
|
|
if (typeof end === 'undefined') {
|
|
end = start;
|
|
start = 0;
|
|
} else {
|
|
end = +end || 0;
|
|
}
|
|
return value >= start && value < end;
|
|
}
|
|
|
|
/**
|
|
* Produces a random number between `min` and `max` (inclusive). If only one
|
|
* argument is provided a number between `0` and the given number is returned.
|
|
* If `floating` is `true`, or either `min` or `max` are floats, a floating-point
|
|
* number is returned instead of an integer.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Number
|
|
* @param {number} [min=0] The minimum possible value.
|
|
* @param {number} [max=1] The maximum possible value.
|
|
* @param {boolean} [floating] Specify returning a floating-point number.
|
|
* @returns {number} Returns the random number.
|
|
* @example
|
|
*
|
|
* _.random(0, 5);
|
|
* // => an integer between 0 and 5
|
|
*
|
|
* _.random(5);
|
|
* // => also an integer between 0 and 5
|
|
*
|
|
* _.random(5, true);
|
|
* // => a floating-point number between 0 and 5
|
|
*
|
|
* _.random(1.2, 5.2);
|
|
* // => a floating-point number between 1.2 and 5.2
|
|
*/
|
|
function random(min, max, floating) {
|
|
if (floating && isIterateeCall(min, max, floating)) {
|
|
max = floating = null;
|
|
}
|
|
var noMin = min == null,
|
|
noMax = max == null;
|
|
|
|
if (floating == null) {
|
|
if (noMax && typeof min == 'boolean') {
|
|
floating = min;
|
|
min = 1;
|
|
}
|
|
else if (typeof max == 'boolean') {
|
|
floating = max;
|
|
noMax = true;
|
|
}
|
|
}
|
|
if (noMin && noMax) {
|
|
max = 1;
|
|
noMax = false;
|
|
}
|
|
min = +min || 0;
|
|
if (noMax) {
|
|
max = min;
|
|
min = 0;
|
|
} else {
|
|
max = +max || 0;
|
|
}
|
|
if (floating || min % 1 || max % 1) {
|
|
var rand = nativeRandom();
|
|
return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max);
|
|
}
|
|
return baseRandom(min, max);
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Converts `string` to camel case.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to convert.
|
|
* @returns {string} Returns the camel cased string.
|
|
* @example
|
|
*
|
|
* _.camelCase('Foo Bar');
|
|
* // => 'fooBar'
|
|
*
|
|
* _.camelCase('--foo-bar');
|
|
* // => 'fooBar'
|
|
*
|
|
* _.camelCase('__foo_bar__');
|
|
* // => 'fooBar'
|
|
*/
|
|
var camelCase = createCompounder(function(result, word, index) {
|
|
word = word.toLowerCase();
|
|
return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);
|
|
});
|
|
|
|
/**
|
|
* Capitalizes the first character of `string`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to capitalize.
|
|
* @returns {string} Returns the capitalized string.
|
|
* @example
|
|
*
|
|
* _.capitalize('fred');
|
|
* // => 'Fred'
|
|
*/
|
|
function capitalize(string) {
|
|
string = baseToString(string);
|
|
return string && (string.charAt(0).toUpperCase() + string.slice(1));
|
|
}
|
|
|
|
/**
|
|
* Deburrs `string` by converting latin-1 supplementary letters to basic latin letters.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to deburr.
|
|
* @returns {string} Returns the deburred string.
|
|
* @example
|
|
*
|
|
* _.deburr('déjà vu');
|
|
* // => 'deja vu'
|
|
*/
|
|
function deburr(string) {
|
|
string = baseToString(string);
|
|
return string && string.replace(reLatin1, deburrLetter);
|
|
}
|
|
|
|
/**
|
|
* Checks if `string` ends with the given target string.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to search.
|
|
* @param {string} [target] The string to search for.
|
|
* @param {number} [position=string.length] The position to search from.
|
|
* @returns {boolean} Returns `true` if `string` ends with `target`, else `false`.
|
|
* @example
|
|
*
|
|
* _.endsWith('abc', 'c');
|
|
* // => true
|
|
*
|
|
* _.endsWith('abc', 'b');
|
|
* // => false
|
|
*
|
|
* _.endsWith('abc', 'b', 2);
|
|
* // => true
|
|
*/
|
|
function endsWith(string, target, position) {
|
|
string = baseToString(string);
|
|
target = (target + '');
|
|
|
|
var length = string.length;
|
|
position = (typeof position == 'undefined' ? length : nativeMin(position < 0 ? 0 : (+position || 0), length)) - target.length;
|
|
return position >= 0 && string.indexOf(target, position) == position;
|
|
}
|
|
|
|
/**
|
|
* Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to
|
|
* their corresponding HTML entities.
|
|
*
|
|
* **Note:** No other characters are escaped. To escape additional characters
|
|
* use a third-party library like [_he_](https://mths.be/he).
|
|
*
|
|
* Though the ">" character is escaped for symmetry, characters like
|
|
* ">" and "/" don't require escaping in HTML and have no special meaning
|
|
* unless they're part of a tag or unquoted attribute value.
|
|
* See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
|
* (under "semi-related fun fact") for more details.
|
|
*
|
|
* Backticks are escaped because in Internet Explorer < 9, they can break out
|
|
* of attribute values or HTML comments. See [#102](https://html5sec.org/#102),
|
|
* [#108](https://html5sec.org/#108), and [#133](https://html5sec.org/#133) of
|
|
* the [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
|
|
*
|
|
* When working with HTML you should always quote attribute values to reduce
|
|
* XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to escape.
|
|
* @returns {string} Returns the escaped string.
|
|
* @example
|
|
*
|
|
* _.escape('fred, barney, & pebbles');
|
|
* // => 'fred, barney, & pebbles'
|
|
*/
|
|
function escape(string) {
|
|
// Reset `lastIndex` because in IE < 9 `String#replace` does not.
|
|
string = baseToString(string);
|
|
return (string && reHasUnescapedHtml.test(string))
|
|
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
|
: string;
|
|
}
|
|
|
|
/**
|
|
* Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*",
|
|
* "+", "(", ")", "[", "]", "{" and "}" in `string`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to escape.
|
|
* @returns {string} Returns the escaped string.
|
|
* @example
|
|
*
|
|
* _.escapeRegExp('[lodash](https://lodash.com/)');
|
|
* // => '\[lodash\]\(https://lodash\.com/\)'
|
|
*/
|
|
function escapeRegExp(string) {
|
|
string = baseToString(string);
|
|
return (string && reHasRegExpChars.test(string))
|
|
? string.replace(reRegExpChars, '\\$&')
|
|
: string;
|
|
}
|
|
|
|
/**
|
|
* Converts `string` to kebab case.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for
|
|
* more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to convert.
|
|
* @returns {string} Returns the kebab cased string.
|
|
* @example
|
|
*
|
|
* _.kebabCase('Foo Bar');
|
|
* // => 'foo-bar'
|
|
*
|
|
* _.kebabCase('fooBar');
|
|
* // => 'foo-bar'
|
|
*
|
|
* _.kebabCase('__foo_bar__');
|
|
* // => 'foo-bar'
|
|
*/
|
|
var kebabCase = createCompounder(function(result, word, index) {
|
|
return result + (index ? '-' : '') + word.toLowerCase();
|
|
});
|
|
|
|
/**
|
|
* Pads `string` on the left and right sides if it is shorter then the given
|
|
* padding length. The `chars` string may be truncated if the number of padding
|
|
* characters can't be evenly divided by the padding length.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to pad.
|
|
* @param {number} [length=0] The padding length.
|
|
* @param {string} [chars=' '] The string used as padding.
|
|
* @returns {string} Returns the padded string.
|
|
* @example
|
|
*
|
|
* _.pad('abc', 8);
|
|
* // => ' abc '
|
|
*
|
|
* _.pad('abc', 8, '_-');
|
|
* // => '_-abc_-_'
|
|
*
|
|
* _.pad('abc', 3);
|
|
* // => 'abc'
|
|
*/
|
|
function pad(string, length, chars) {
|
|
string = baseToString(string);
|
|
length = +length;
|
|
|
|
var strLength = string.length;
|
|
if (strLength >= length || !nativeIsFinite(length)) {
|
|
return string;
|
|
}
|
|
var mid = (length - strLength) / 2,
|
|
leftLength = floor(mid),
|
|
rightLength = ceil(mid);
|
|
|
|
chars = createPad('', rightLength, chars);
|
|
return chars.slice(0, leftLength) + string + chars;
|
|
}
|
|
|
|
/**
|
|
* Pads `string` on the left side if it is shorter then the given padding
|
|
* length. The `chars` string may be truncated if the number of padding
|
|
* characters exceeds the padding length.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to pad.
|
|
* @param {number} [length=0] The padding length.
|
|
* @param {string} [chars=' '] The string used as padding.
|
|
* @returns {string} Returns the padded string.
|
|
* @example
|
|
*
|
|
* _.padLeft('abc', 6);
|
|
* // => ' abc'
|
|
*
|
|
* _.padLeft('abc', 6, '_-');
|
|
* // => '_-_abc'
|
|
*
|
|
* _.padLeft('abc', 3);
|
|
* // => 'abc'
|
|
*/
|
|
function padLeft(string, length, chars) {
|
|
string = baseToString(string);
|
|
return string && (createPad(string, length, chars) + string);
|
|
}
|
|
|
|
/**
|
|
* Pads `string` on the right side if it is shorter then the given padding
|
|
* length. The `chars` string may be truncated if the number of padding
|
|
* characters exceeds the padding length.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to pad.
|
|
* @param {number} [length=0] The padding length.
|
|
* @param {string} [chars=' '] The string used as padding.
|
|
* @returns {string} Returns the padded string.
|
|
* @example
|
|
*
|
|
* _.padRight('abc', 6);
|
|
* // => 'abc '
|
|
*
|
|
* _.padRight('abc', 6, '_-');
|
|
* // => 'abc_-_'
|
|
*
|
|
* _.padRight('abc', 3);
|
|
* // => 'abc'
|
|
*/
|
|
function padRight(string, length, chars) {
|
|
string = baseToString(string);
|
|
return string && (string + createPad(string, length, chars));
|
|
}
|
|
|
|
/**
|
|
* Converts `string` to an integer of the specified radix. If `radix` is
|
|
* `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
|
|
* in which case a `radix` of `16` is used.
|
|
*
|
|
* **Note:** This method aligns with the ES5 implementation of `parseInt`.
|
|
* See the [ES5 spec](https://es5.github.io/#E) for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} string The string to convert.
|
|
* @param {number} [radix] The radix to interpret `value` by.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {number} Returns the converted integer.
|
|
* @example
|
|
*
|
|
* _.parseInt('08');
|
|
* // => 8
|
|
*
|
|
* _.map(['6', '08', '10'], _.parseInt);
|
|
* // => [6, 8, 10]
|
|
*/
|
|
function parseInt(string, radix, guard) {
|
|
if (guard && isIterateeCall(string, radix, guard)) {
|
|
radix = 0;
|
|
}
|
|
return nativeParseInt(string, radix);
|
|
}
|
|
// Fallback for environments with pre-ES5 implementations.
|
|
if (nativeParseInt(whitespace + '08') != 8) {
|
|
parseInt = function(string, radix, guard) {
|
|
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.
|
|
// Chrome fails to trim leading <BOM> whitespace characters.
|
|
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
|
|
if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
|
|
radix = 0;
|
|
} else if (radix) {
|
|
radix = +radix;
|
|
}
|
|
string = trim(string);
|
|
return nativeParseInt(string, radix || (reHexPrefix.test(string) ? 16 : 10));
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Repeats the given string `n` times.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to repeat.
|
|
* @param {number} [n=0] The number of times to repeat the string.
|
|
* @returns {string} Returns the repeated string.
|
|
* @example
|
|
*
|
|
* _.repeat('*', 3);
|
|
* // => '***'
|
|
*
|
|
* _.repeat('abc', 2);
|
|
* // => 'abcabc'
|
|
*
|
|
* _.repeat('abc', 0);
|
|
* // => ''
|
|
*/
|
|
function repeat(string, n) {
|
|
var result = '';
|
|
string = baseToString(string);
|
|
n = +n;
|
|
if (n < 1 || !string || !nativeIsFinite(n)) {
|
|
return result;
|
|
}
|
|
// Leverage the exponentiation by squaring algorithm for a faster repeat.
|
|
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
|
|
do {
|
|
if (n % 2) {
|
|
result += string;
|
|
}
|
|
n = floor(n / 2);
|
|
string += string;
|
|
} while (n);
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Converts `string` to snake case.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to convert.
|
|
* @returns {string} Returns the snake cased string.
|
|
* @example
|
|
*
|
|
* _.snakeCase('Foo Bar');
|
|
* // => 'foo_bar'
|
|
*
|
|
* _.snakeCase('fooBar');
|
|
* // => 'foo_bar'
|
|
*
|
|
* _.snakeCase('--foo-bar');
|
|
* // => 'foo_bar'
|
|
*/
|
|
var snakeCase = createCompounder(function(result, word, index) {
|
|
return result + (index ? '_' : '') + word.toLowerCase();
|
|
});
|
|
|
|
/**
|
|
* Converts `string` to start case.
|
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
|
|
* for more details.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to convert.
|
|
* @returns {string} Returns the start cased string.
|
|
* @example
|
|
*
|
|
* _.startCase('--foo-bar');
|
|
* // => 'Foo Bar'
|
|
*
|
|
* _.startCase('fooBar');
|
|
* // => 'Foo Bar'
|
|
*
|
|
* _.startCase('__foo_bar__');
|
|
* // => 'Foo Bar'
|
|
*/
|
|
var startCase = createCompounder(function(result, word, index) {
|
|
return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));
|
|
});
|
|
|
|
/**
|
|
* Checks if `string` starts with the given target string.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to search.
|
|
* @param {string} [target] The string to search for.
|
|
* @param {number} [position=0] The position to search from.
|
|
* @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.
|
|
* @example
|
|
*
|
|
* _.startsWith('abc', 'a');
|
|
* // => true
|
|
*
|
|
* _.startsWith('abc', 'b');
|
|
* // => false
|
|
*
|
|
* _.startsWith('abc', 'b', 1);
|
|
* // => true
|
|
*/
|
|
function startsWith(string, target, position) {
|
|
string = baseToString(string);
|
|
position = position == null ? 0 : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
|
|
return string.lastIndexOf(target, position) == position;
|
|
}
|
|
|
|
/**
|
|
* Creates a compiled template function that can interpolate data properties
|
|
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
|
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
|
|
* properties may be accessed as free variables in the template. If a setting
|
|
* object is provided it takes precedence over `_.templateSettings` values.
|
|
*
|
|
* **Note:** In the development build `_.template` utilizes sourceURLs for easier debugging.
|
|
* See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
|
|
* for more details.
|
|
*
|
|
* For more information on precompiling templates see
|
|
* [lodash's custom builds documentation](https://lodash.com/custom-builds).
|
|
*
|
|
* For more information on Chrome extension sandboxes see
|
|
* [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The template string.
|
|
* @param {Object} [options] The options object.
|
|
* @param {RegExp} [options.escape] The HTML "escape" delimiter.
|
|
* @param {RegExp} [options.evaluate] The "evaluate" delimiter.
|
|
* @param {Object} [options.imports] An object to import into the template as free variables.
|
|
* @param {RegExp} [options.interpolate] The "interpolate" delimiter.
|
|
* @param {string} [options.sourceURL] The sourceURL of the template's compiled source.
|
|
* @param {string} [options.variable] The data object variable name.
|
|
* @param- {Object} [otherOptions] Enables the legacy `options` param signature.
|
|
* @returns {Function} Returns the compiled template function.
|
|
* @example
|
|
*
|
|
* // using the "interpolate" delimiter to create a compiled template
|
|
* var compiled = _.template('hello <%= user %>!');
|
|
* compiled({ 'user': 'fred' });
|
|
* // => 'hello fred!'
|
|
*
|
|
* // using the HTML "escape" delimiter to escape data property values
|
|
* var compiled = _.template('<b><%- value %></b>');
|
|
* compiled({ 'value': '<script>' });
|
|
* // => '<b><script></b>'
|
|
*
|
|
* // using the "evaluate" delimiter to execute JavaScript and generate HTML
|
|
* var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
|
|
* compiled({ 'users': ['fred', 'barney'] });
|
|
* // => '<li>fred</li><li>barney</li>'
|
|
*
|
|
* // using the internal `print` function in "evaluate" delimiters
|
|
* var compiled = _.template('<% print("hello " + user); %>!');
|
|
* compiled({ 'user': 'barney' });
|
|
* // => 'hello barney!'
|
|
*
|
|
* // using the ES delimiter as an alternative to the default "interpolate" delimiter
|
|
* var compiled = _.template('hello ${ user }!');
|
|
* compiled({ 'user': 'pebbles' });
|
|
* // => 'hello pebbles!'
|
|
*
|
|
* // using custom template delimiters
|
|
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
* var compiled = _.template('hello {{ user }}!');
|
|
* compiled({ 'user': 'mustache' });
|
|
* // => 'hello mustache!'
|
|
*
|
|
* // using backslashes to treat delimiters as plain text
|
|
* var compiled = _.template('<%= "\\<%- value %\\>" %>');
|
|
* compiled({ 'value': 'ignored' });
|
|
* // => '<%- value %>'
|
|
*
|
|
* // using the `imports` option to import `jQuery` as `jq`
|
|
* var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
|
|
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
|
|
* compiled({ 'users': ['fred', 'barney'] });
|
|
* // => '<li>fred</li><li>barney</li>'
|
|
*
|
|
* // using the `sourceURL` option to specify a custom sourceURL for the template
|
|
* var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
|
|
* compiled(data);
|
|
* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
|
|
*
|
|
* // using the `variable` option to ensure a with-statement isn't used in the compiled template
|
|
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
|
|
* compiled.source;
|
|
* // => function(data) {
|
|
* // var __t, __p = '';
|
|
* // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
|
|
* // return __p;
|
|
* // }
|
|
*
|
|
* // using the `source` property to inline compiled templates for meaningful
|
|
* // line numbers in error messages and a stack trace
|
|
* fs.writeFileSync(path.join(cwd, 'jst.js'), '\
|
|
* var JST = {\
|
|
* "main": ' + _.template(mainText).source + '\
|
|
* };\
|
|
* ');
|
|
*/
|
|
function template(string, options, otherOptions) {
|
|
// Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/)
|
|
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
|
|
var settings = lodash.templateSettings;
|
|
|
|
if (otherOptions && isIterateeCall(string, options, otherOptions)) {
|
|
options = otherOptions = null;
|
|
}
|
|
string = baseToString(string);
|
|
options = baseAssign(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);
|
|
|
|
var imports = baseAssign(baseAssign({}, options.imports), settings.imports, assignOwnDefaults),
|
|
importsKeys = keys(imports),
|
|
importsValues = baseValues(imports, importsKeys);
|
|
|
|
var isEscaping,
|
|
isEvaluating,
|
|
index = 0,
|
|
interpolate = options.interpolate || reNoMatch,
|
|
source = "__p += '";
|
|
|
|
// Compile the regexp to match each delimiter.
|
|
var reDelimiters = RegExp(
|
|
(options.escape || reNoMatch).source + '|' +
|
|
interpolate.source + '|' +
|
|
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
|
(options.evaluate || reNoMatch).source + '|$'
|
|
, 'g');
|
|
|
|
// Use a sourceURL for easier debugging.
|
|
var sourceURL = '//# sourceURL=' +
|
|
('sourceURL' in options
|
|
? options.sourceURL
|
|
: ('lodash.templateSources[' + (++templateCounter) + ']')
|
|
) + '\n';
|
|
|
|
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
|
interpolateValue || (interpolateValue = esTemplateValue);
|
|
|
|
// Escape characters that can't be included in string literals.
|
|
source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
|
|
|
// Replace delimiters with snippets.
|
|
if (escapeValue) {
|
|
isEscaping = true;
|
|
source += "' +\n__e(" + escapeValue + ") +\n'";
|
|
}
|
|
if (evaluateValue) {
|
|
isEvaluating = true;
|
|
source += "';\n" + evaluateValue + ";\n__p += '";
|
|
}
|
|
if (interpolateValue) {
|
|
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
|
}
|
|
index = offset + match.length;
|
|
|
|
// The JS engine embedded in Adobe products requires returning the `match`
|
|
// string in order to produce the correct `offset` value.
|
|
return match;
|
|
});
|
|
|
|
source += "';\n";
|
|
|
|
// If `variable` is not specified wrap a with-statement around the generated
|
|
// code to add the data object to the top of the scope chain.
|
|
var variable = options.variable;
|
|
if (!variable) {
|
|
source = 'with (obj) {\n' + source + '\n}\n';
|
|
}
|
|
// Cleanup code by stripping empty strings.
|
|
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
|
.replace(reEmptyStringMiddle, '$1')
|
|
.replace(reEmptyStringTrailing, '$1;');
|
|
|
|
// Frame code as the function body.
|
|
source = 'function(' + (variable || 'obj') + ') {\n' +
|
|
(variable
|
|
? ''
|
|
: 'obj || (obj = {});\n'
|
|
) +
|
|
"var __t, __p = ''" +
|
|
(isEscaping
|
|
? ', __e = _.escape'
|
|
: ''
|
|
) +
|
|
(isEvaluating
|
|
? ', __j = Array.prototype.join;\n' +
|
|
"function print() { __p += __j.call(arguments, '') }\n"
|
|
: ';\n'
|
|
) +
|
|
source +
|
|
'return __p\n}';
|
|
|
|
var result = attempt(function() {
|
|
return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);
|
|
});
|
|
|
|
// Provide the compiled function's source by its `toString` method or
|
|
// the `source` property as a convenience for inlining compiled templates.
|
|
result.source = source;
|
|
if (isError(result)) {
|
|
throw result;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Removes leading and trailing whitespace or specified characters from `string`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to trim.
|
|
* @param {string} [chars=whitespace] The characters to trim.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {string} Returns the trimmed string.
|
|
* @example
|
|
*
|
|
* _.trim(' abc ');
|
|
* // => 'abc'
|
|
*
|
|
* _.trim('-_-abc-_-', '_-');
|
|
* // => 'abc'
|
|
*
|
|
* _.map([' foo ', ' bar '], _.trim);
|
|
* // => ['foo', 'bar]
|
|
*/
|
|
function trim(string, chars, guard) {
|
|
var value = string;
|
|
string = baseToString(string);
|
|
if (!string) {
|
|
return string;
|
|
}
|
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
|
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
|
}
|
|
chars = (chars + '');
|
|
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
|
}
|
|
|
|
/**
|
|
* Removes leading whitespace or specified characters from `string`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to trim.
|
|
* @param {string} [chars=whitespace] The characters to trim.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {string} Returns the trimmed string.
|
|
* @example
|
|
*
|
|
* _.trimLeft(' abc ');
|
|
* // => 'abc '
|
|
*
|
|
* _.trimLeft('-_-abc-_-', '_-');
|
|
* // => 'abc-_-'
|
|
*/
|
|
function trimLeft(string, chars, guard) {
|
|
var value = string;
|
|
string = baseToString(string);
|
|
if (!string) {
|
|
return string;
|
|
}
|
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
|
return string.slice(trimmedLeftIndex(string));
|
|
}
|
|
return string.slice(charsLeftIndex(string, (chars + '')));
|
|
}
|
|
|
|
/**
|
|
* Removes trailing whitespace or specified characters from `string`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to trim.
|
|
* @param {string} [chars=whitespace] The characters to trim.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {string} Returns the trimmed string.
|
|
* @example
|
|
*
|
|
* _.trimRight(' abc ');
|
|
* // => ' abc'
|
|
*
|
|
* _.trimRight('-_-abc-_-', '_-');
|
|
* // => '-_-abc'
|
|
*/
|
|
function trimRight(string, chars, guard) {
|
|
var value = string;
|
|
string = baseToString(string);
|
|
if (!string) {
|
|
return string;
|
|
}
|
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
|
return string.slice(0, trimmedRightIndex(string) + 1);
|
|
}
|
|
return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
|
|
}
|
|
|
|
/**
|
|
* Truncates `string` if it is longer than the given maximum string length.
|
|
* The last characters of the truncated string are replaced with the omission
|
|
* string which defaults to "...".
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to truncate.
|
|
* @param {Object|number} [options] The options object or maximum string length.
|
|
* @param {number} [options.length=30] The maximum string length.
|
|
* @param {string} [options.omission='...'] The string to indicate text is omitted.
|
|
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {string} Returns the truncated string.
|
|
* @example
|
|
*
|
|
* _.trunc('hi-diddly-ho there, neighborino');
|
|
* // => 'hi-diddly-ho there, neighbo...'
|
|
*
|
|
* _.trunc('hi-diddly-ho there, neighborino', 24);
|
|
* // => 'hi-diddly-ho there, n...'
|
|
*
|
|
* _.trunc('hi-diddly-ho there, neighborino', {
|
|
* 'length': 24,
|
|
* 'separator': ' '
|
|
* });
|
|
* // => 'hi-diddly-ho there,...'
|
|
*
|
|
* _.trunc('hi-diddly-ho there, neighborino', {
|
|
* 'length': 24,
|
|
* 'separator': /,? +/
|
|
* });
|
|
* //=> 'hi-diddly-ho there...'
|
|
*
|
|
* _.trunc('hi-diddly-ho there, neighborino', {
|
|
* 'omission': ' [...]'
|
|
* });
|
|
* // => 'hi-diddly-ho there, neig [...]'
|
|
*/
|
|
function trunc(string, options, guard) {
|
|
if (guard && isIterateeCall(string, options, guard)) {
|
|
options = null;
|
|
}
|
|
var length = DEFAULT_TRUNC_LENGTH,
|
|
omission = DEFAULT_TRUNC_OMISSION;
|
|
|
|
if (options != null) {
|
|
if (isObject(options)) {
|
|
var separator = 'separator' in options ? options.separator : separator;
|
|
length = 'length' in options ? +options.length || 0 : length;
|
|
omission = 'omission' in options ? baseToString(options.omission) : omission;
|
|
} else {
|
|
length = +options || 0;
|
|
}
|
|
}
|
|
string = baseToString(string);
|
|
if (length >= string.length) {
|
|
return string;
|
|
}
|
|
var end = length - omission.length;
|
|
if (end < 1) {
|
|
return omission;
|
|
}
|
|
var result = string.slice(0, end);
|
|
if (separator == null) {
|
|
return result + omission;
|
|
}
|
|
if (isRegExp(separator)) {
|
|
if (string.slice(end).search(separator)) {
|
|
var match,
|
|
newEnd,
|
|
substring = string.slice(0, end);
|
|
|
|
if (!separator.global) {
|
|
separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g');
|
|
}
|
|
separator.lastIndex = 0;
|
|
while ((match = separator.exec(substring))) {
|
|
newEnd = match.index;
|
|
}
|
|
result = result.slice(0, newEnd == null ? end : newEnd);
|
|
}
|
|
} else if (string.indexOf(separator, end) != end) {
|
|
var index = result.lastIndexOf(separator);
|
|
if (index > -1) {
|
|
result = result.slice(0, index);
|
|
}
|
|
}
|
|
return result + omission;
|
|
}
|
|
|
|
/**
|
|
* The inverse of `_.escape`; this method converts the HTML entities
|
|
* `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their
|
|
* corresponding characters.
|
|
*
|
|
* **Note:** No other HTML entities are unescaped. To unescape additional HTML
|
|
* entities use a third-party library like [_he_](https://mths.be/he).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to unescape.
|
|
* @returns {string} Returns the unescaped string.
|
|
* @example
|
|
*
|
|
* _.unescape('fred, barney, & pebbles');
|
|
* // => 'fred, barney, & pebbles'
|
|
*/
|
|
function unescape(string) {
|
|
string = baseToString(string);
|
|
return (string && reHasEscapedHtml.test(string))
|
|
? string.replace(reEscapedHtml, unescapeHtmlChar)
|
|
: string;
|
|
}
|
|
|
|
/**
|
|
* Splits `string` into an array of its words.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category String
|
|
* @param {string} [string=''] The string to inspect.
|
|
* @param {RegExp|string} [pattern] The pattern to match words.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Array} Returns the words of `string`.
|
|
* @example
|
|
*
|
|
* _.words('fred, barney, & pebbles');
|
|
* // => ['fred', 'barney', 'pebbles']
|
|
*
|
|
* _.words('fred, barney, & pebbles', /[^, ]+/g);
|
|
* // => ['fred', 'barney', '&', 'pebbles']
|
|
*/
|
|
function words(string, pattern, guard) {
|
|
if (guard && isIterateeCall(string, pattern, guard)) {
|
|
pattern = null;
|
|
}
|
|
string = baseToString(string);
|
|
return string.match(pattern || reWords) || [];
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Attempts to invoke `func`, returning either the result or the caught error
|
|
* object. Any additional arguments are provided to `func` when it is invoked.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {*} func The function to attempt.
|
|
* @returns {*} Returns the `func` result or error object.
|
|
* @example
|
|
*
|
|
* // avoid throwing errors for invalid selectors
|
|
* var elements = _.attempt(function(selector) {
|
|
* return document.querySelectorAll(selector);
|
|
* }, '>_>');
|
|
*
|
|
* if (_.isError(elements)) {
|
|
* elements = [];
|
|
* }
|
|
*/
|
|
function attempt() {
|
|
var length = arguments.length,
|
|
func = arguments[0];
|
|
|
|
try {
|
|
var args = Array(length ? length - 1 : 0);
|
|
while (--length > 0) {
|
|
args[length - 1] = arguments[length];
|
|
}
|
|
return func.apply(undefined, args);
|
|
} catch(e) {
|
|
return isError(e) ? e : new Error(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Creates a function that invokes `func` with the `this` binding of `thisArg`
|
|
* and arguments of the created function. If `func` is a property name the
|
|
* created callback returns the property value for a given element. If `func`
|
|
* is an object the created callback returns `true` for elements that contain
|
|
* the equivalent object properties, otherwise it returns `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias iteratee
|
|
* @category Utility
|
|
* @param {*} [func=_.identity] The value to convert to a callback.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
|
* @returns {Function} Returns the callback.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36 },
|
|
* { 'user': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // wrap to create custom callback shorthands
|
|
* _.callback = _.wrap(_.callback, function(callback, func, thisArg) {
|
|
* var match = /^(.+?)__([gl]t)(.+)$/.exec(func);
|
|
* if (!match) {
|
|
* return callback(func, thisArg);
|
|
* }
|
|
* return function(object) {
|
|
* return match[2] == 'gt'
|
|
* ? object[match[1]] > match[3]
|
|
* : object[match[1]] < match[3];
|
|
* };
|
|
* });
|
|
*
|
|
* _.filter(users, 'age__gt36');
|
|
* // => [{ 'user': 'fred', 'age': 40 }]
|
|
*/
|
|
function callback(func, thisArg, guard) {
|
|
if (guard && isIterateeCall(func, thisArg, guard)) {
|
|
thisArg = null;
|
|
}
|
|
return isObjectLike(func)
|
|
? matches(func)
|
|
: baseCallback(func, thisArg);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that returns `value`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {*} value The value to return from the new function.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred' };
|
|
* var getter = _.constant(object);
|
|
*
|
|
* getter() === object;
|
|
* // => true
|
|
*/
|
|
function constant(value) {
|
|
return function() {
|
|
return value;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* This method returns the first argument provided to it.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {*} value Any value.
|
|
* @returns {*} Returns `value`.
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred' };
|
|
*
|
|
* _.identity(object) === object;
|
|
* // => true
|
|
*/
|
|
function identity(value) {
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* Creates a function which performs a deep comparison between a given object
|
|
* and `source`, returning `true` if the given object has equivalent property
|
|
* values, else `false`.
|
|
*
|
|
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
|
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
|
* their own, not inherited, enumerable properties. For comparing a single
|
|
* own or inherited property value see `_.matchesProperty`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {Object} source The object of property values to match.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
|
* { 'user': 'fred', 'age': 40, 'active': false }
|
|
* ];
|
|
*
|
|
* _.filter(users, _.matches({ 'age': 40, 'active': false }));
|
|
* // => [{ 'user': 'fred', 'age': 40, 'active': false }]
|
|
*/
|
|
function matches(source) {
|
|
return baseMatches(baseClone(source, true));
|
|
}
|
|
|
|
/**
|
|
* Creates a function which compares the property value of `key` on a given
|
|
* object to `value`.
|
|
*
|
|
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
|
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
|
* their own, not inherited, enumerable properties.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {string} key The key of the property to get.
|
|
* @param {*} value The value to compare.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney' },
|
|
* { 'user': 'fred' },
|
|
* { 'user': 'pebbles' }
|
|
* ];
|
|
*
|
|
* _.find(users, _.matchesProperty('user', 'fred'));
|
|
* // => { 'user': 'fred', 'age': 40 }
|
|
*/
|
|
function matchesProperty(key, value) {
|
|
return baseMatchesProperty(key + '', baseClone(value, true));
|
|
}
|
|
|
|
/**
|
|
* Adds all own enumerable function properties of a source object to the
|
|
* destination object. If `object` is a function then methods are added to
|
|
* its prototype as well.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {Function|Object} [object=this] object The destination object.
|
|
* @param {Object} source The object of functions to add.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.chain=true] Specify whether the functions added
|
|
* are chainable.
|
|
* @returns {Function|Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function vowels(string) {
|
|
* return _.filter(string, function(v) {
|
|
* return /[aeiou]/i.test(v);
|
|
* });
|
|
* }
|
|
*
|
|
* // use `_.runInContext` to avoid potential conflicts (esp. in Node.js)
|
|
* var _ = require('lodash').runInContext();
|
|
*
|
|
* _.mixin({ 'vowels': vowels });
|
|
* _.vowels('fred');
|
|
* // => ['e']
|
|
*
|
|
* _('fred').vowels().value();
|
|
* // => ['e']
|
|
*
|
|
* _.mixin({ 'vowels': vowels }, { 'chain': false });
|
|
* _('fred').vowels();
|
|
* // => ['e']
|
|
*/
|
|
function mixin(object, source, options) {
|
|
if (options == null) {
|
|
var isObj = isObject(source),
|
|
props = isObj && keys(source),
|
|
methodNames = props && props.length && baseFunctions(source, props);
|
|
|
|
if (!(methodNames ? methodNames.length : isObj)) {
|
|
methodNames = false;
|
|
options = source;
|
|
source = object;
|
|
object = this;
|
|
}
|
|
}
|
|
if (!methodNames) {
|
|
methodNames = baseFunctions(source, keys(source));
|
|
}
|
|
var chain = true,
|
|
index = -1,
|
|
isFunc = isFunction(object),
|
|
length = methodNames.length;
|
|
|
|
if (options === false) {
|
|
chain = false;
|
|
} else if (isObject(options) && 'chain' in options) {
|
|
chain = options.chain;
|
|
}
|
|
while (++index < length) {
|
|
var methodName = methodNames[index],
|
|
func = source[methodName];
|
|
|
|
object[methodName] = func;
|
|
if (isFunc) {
|
|
object.prototype[methodName] = (function(func) {
|
|
return function() {
|
|
var chainAll = this.__chain__;
|
|
if (chain || chainAll) {
|
|
var result = object(this.__wrapped__);
|
|
(result.__actions__ = arrayCopy(this.__actions__)).push({ 'func': func, 'args': arguments, 'thisArg': object });
|
|
result.__chain__ = chainAll;
|
|
return result;
|
|
}
|
|
var args = [this.value()];
|
|
push.apply(args, arguments);
|
|
return func.apply(object, args);
|
|
};
|
|
}(func));
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* Reverts the `_` variable to its previous value and returns a reference to
|
|
* the `lodash` function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @returns {Function} Returns the `lodash` function.
|
|
* @example
|
|
*
|
|
* var lodash = _.noConflict();
|
|
*/
|
|
function noConflict() {
|
|
context._ = oldDash;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* A no-operation function which returns `undefined` regardless of the
|
|
* arguments it receives.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @example
|
|
*
|
|
* var object = { 'user': 'fred' };
|
|
*
|
|
* _.noop(object) === undefined;
|
|
* // => true
|
|
*/
|
|
function noop() {
|
|
// No operation performed.
|
|
}
|
|
|
|
/**
|
|
* Creates a function which returns the property value of `key` on a given object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {string} key The key of the property to get.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'fred' },
|
|
* { 'user': 'barney' }
|
|
* ];
|
|
*
|
|
* var getName = _.property('user');
|
|
*
|
|
* _.map(users, getName);
|
|
* // => ['fred', barney']
|
|
*
|
|
* _.pluck(_.sortBy(users, getName), 'user');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
function property(key) {
|
|
return baseProperty(key + '');
|
|
}
|
|
|
|
/**
|
|
* The inverse of `_.property`; this method creates a function which returns
|
|
* the property value of a given key on `object`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var object = { 'a': 3, 'b': 1, 'c': 2 };
|
|
*
|
|
* _.map(['a', 'c'], _.propertyOf(object));
|
|
* // => [3, 2]
|
|
*
|
|
* _.sortBy(['a', 'b', 'c'], _.propertyOf(object));
|
|
* // => ['b', 'c', 'a']
|
|
*/
|
|
function propertyOf(object) {
|
|
return function(key) {
|
|
return object == null ? undefined : object[key];
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates an array of numbers (positive and/or negative) progressing from
|
|
* `start` up to, but not including, `end`. If `end` is not specified it
|
|
* defaults to `start` with `start` becoming `0`. If `start` is less than
|
|
* `end` a zero-length range is created unless a negative `step` is specified.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {number} [start=0] The start of the range.
|
|
* @param {number} end The end of the range.
|
|
* @param {number} [step=1] The value to increment or decrement by.
|
|
* @returns {Array} Returns the new array of numbers.
|
|
* @example
|
|
*
|
|
* _.range(4);
|
|
* // => [0, 1, 2, 3]
|
|
*
|
|
* _.range(1, 5);
|
|
* // => [1, 2, 3, 4]
|
|
*
|
|
* _.range(0, 20, 5);
|
|
* // => [0, 5, 10, 15]
|
|
*
|
|
* _.range(0, -4, -1);
|
|
* // => [0, -1, -2, -3]
|
|
*
|
|
* _.range(1, 4, 0);
|
|
* // => [1, 1, 1]
|
|
*
|
|
* _.range(0);
|
|
* // => []
|
|
*/
|
|
function range(start, end, step) {
|
|
if (step && isIterateeCall(start, end, step)) {
|
|
end = step = null;
|
|
}
|
|
start = +start || 0;
|
|
step = step == null ? 1 : (+step || 0);
|
|
|
|
if (end == null) {
|
|
end = start;
|
|
start = 0;
|
|
} else {
|
|
end = +end || 0;
|
|
}
|
|
// Use `Array(length)` so engines like Chakra and V8 avoid slower modes.
|
|
// See https://youtu.be/XAqIpGU8ZZk#t=17m25s for more details.
|
|
var index = -1,
|
|
length = nativeMax(ceil((end - start) / (step || 1)), 0),
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = start;
|
|
start += step;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Invokes the iteratee function `n` times, returning an array of the results
|
|
* of each invocation. The `iteratee` is bound to `thisArg` and invoked with
|
|
* one argument; (index).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {number} n The number of times to invoke `iteratee`.
|
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {Array} Returns the array of results.
|
|
* @example
|
|
*
|
|
* var diceRolls = _.times(3, _.partial(_.random, 1, 6, false));
|
|
* // => [3, 6, 4]
|
|
*
|
|
* _.times(3, function(n) {
|
|
* mage.castSpell(n);
|
|
* });
|
|
* // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively
|
|
*
|
|
* _.times(3, function(n) {
|
|
* this.cast(n);
|
|
* }, mage);
|
|
* // => also invokes `mage.castSpell(n)` three times
|
|
*/
|
|
function times(n, iteratee, thisArg) {
|
|
n = +n;
|
|
|
|
// Exit early to avoid a JSC JIT bug in Safari 8
|
|
// where `Array(0)` is treated as `Array(1)`.
|
|
if (n < 1 || !nativeIsFinite(n)) {
|
|
return [];
|
|
}
|
|
var index = -1,
|
|
result = Array(nativeMin(n, MAX_ARRAY_LENGTH));
|
|
|
|
iteratee = bindCallback(iteratee, thisArg, 1);
|
|
while (++index < n) {
|
|
if (index < MAX_ARRAY_LENGTH) {
|
|
result[index] = iteratee(index);
|
|
} else {
|
|
iteratee(index);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generates a unique ID. If `prefix` is provided the ID is appended to it.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utility
|
|
* @param {string} [prefix] The value to prefix the ID with.
|
|
* @returns {string} Returns the unique ID.
|
|
* @example
|
|
*
|
|
* _.uniqueId('contact_');
|
|
* // => 'contact_104'
|
|
*
|
|
* _.uniqueId();
|
|
* // => '105'
|
|
*/
|
|
function uniqueId(prefix) {
|
|
var id = ++idCounter;
|
|
return baseToString(prefix) + id;
|
|
}
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
// Ensure wrappers are instances of `baseLodash`.
|
|
lodash.prototype = baseLodash.prototype;
|
|
|
|
LodashWrapper.prototype = baseCreate(baseLodash.prototype);
|
|
LodashWrapper.prototype.constructor = LodashWrapper;
|
|
|
|
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
|
|
LazyWrapper.prototype.constructor = LazyWrapper;
|
|
|
|
// Add functions to the `Map` cache.
|
|
MapCache.prototype['delete'] = mapDelete;
|
|
MapCache.prototype.get = mapGet;
|
|
MapCache.prototype.has = mapHas;
|
|
MapCache.prototype.set = mapSet;
|
|
|
|
// Add functions to the `Set` cache.
|
|
SetCache.prototype.push = cachePush;
|
|
|
|
// Assign cache to `_.memoize`.
|
|
memoize.Cache = MapCache;
|
|
|
|
// Add functions that return wrapped values when chaining.
|
|
lodash.after = after;
|
|
lodash.ary = ary;
|
|
lodash.assign = assign;
|
|
lodash.at = at;
|
|
lodash.before = before;
|
|
lodash.bind = bind;
|
|
lodash.bindAll = bindAll;
|
|
lodash.bindKey = bindKey;
|
|
lodash.callback = callback;
|
|
lodash.chain = chain;
|
|
lodash.chunk = chunk;
|
|
lodash.compact = compact;
|
|
lodash.constant = constant;
|
|
lodash.countBy = countBy;
|
|
lodash.create = create;
|
|
lodash.curry = curry;
|
|
lodash.curryRight = curryRight;
|
|
lodash.debounce = debounce;
|
|
lodash.defaults = defaults;
|
|
lodash.defer = defer;
|
|
lodash.delay = delay;
|
|
lodash.difference = difference;
|
|
lodash.drop = drop;
|
|
lodash.dropRight = dropRight;
|
|
lodash.dropRightWhile = dropRightWhile;
|
|
lodash.dropWhile = dropWhile;
|
|
lodash.fill = fill;
|
|
lodash.filter = filter;
|
|
lodash.flatten = flatten;
|
|
lodash.flattenDeep = flattenDeep;
|
|
lodash.flow = flow;
|
|
lodash.flowRight = flowRight;
|
|
lodash.forEach = forEach;
|
|
lodash.forEachRight = forEachRight;
|
|
lodash.forIn = forIn;
|
|
lodash.forInRight = forInRight;
|
|
lodash.forOwn = forOwn;
|
|
lodash.forOwnRight = forOwnRight;
|
|
lodash.functions = functions;
|
|
lodash.groupBy = groupBy;
|
|
lodash.indexBy = indexBy;
|
|
lodash.initial = initial;
|
|
lodash.intersection = intersection;
|
|
lodash.invert = invert;
|
|
lodash.invoke = invoke;
|
|
lodash.keys = keys;
|
|
lodash.keysIn = keysIn;
|
|
lodash.map = map;
|
|
lodash.mapValues = mapValues;
|
|
lodash.matches = matches;
|
|
lodash.matchesProperty = matchesProperty;
|
|
lodash.memoize = memoize;
|
|
lodash.merge = merge;
|
|
lodash.mixin = mixin;
|
|
lodash.negate = negate;
|
|
lodash.omit = omit;
|
|
lodash.once = once;
|
|
lodash.pairs = pairs;
|
|
lodash.partial = partial;
|
|
lodash.partialRight = partialRight;
|
|
lodash.partition = partition;
|
|
lodash.pick = pick;
|
|
lodash.pluck = pluck;
|
|
lodash.property = property;
|
|
lodash.propertyOf = propertyOf;
|
|
lodash.pull = pull;
|
|
lodash.pullAt = pullAt;
|
|
lodash.range = range;
|
|
lodash.rearg = rearg;
|
|
lodash.reject = reject;
|
|
lodash.remove = remove;
|
|
lodash.rest = rest;
|
|
lodash.shuffle = shuffle;
|
|
lodash.slice = slice;
|
|
lodash.sortBy = sortBy;
|
|
lodash.sortByAll = sortByAll;
|
|
lodash.spread = spread;
|
|
lodash.take = take;
|
|
lodash.takeRight = takeRight;
|
|
lodash.takeRightWhile = takeRightWhile;
|
|
lodash.takeWhile = takeWhile;
|
|
lodash.tap = tap;
|
|
lodash.throttle = throttle;
|
|
lodash.thru = thru;
|
|
lodash.times = times;
|
|
lodash.toArray = toArray;
|
|
lodash.toPlainObject = toPlainObject;
|
|
lodash.transform = transform;
|
|
lodash.union = union;
|
|
lodash.uniq = uniq;
|
|
lodash.unzip = unzip;
|
|
lodash.values = values;
|
|
lodash.valuesIn = valuesIn;
|
|
lodash.where = where;
|
|
lodash.without = without;
|
|
lodash.wrap = wrap;
|
|
lodash.xor = xor;
|
|
lodash.zip = zip;
|
|
lodash.zipObject = zipObject;
|
|
|
|
// Add aliases.
|
|
lodash.backflow = flowRight;
|
|
lodash.collect = map;
|
|
lodash.compose = flowRight;
|
|
lodash.each = forEach;
|
|
lodash.eachRight = forEachRight;
|
|
lodash.extend = assign;
|
|
lodash.iteratee = callback;
|
|
lodash.methods = functions;
|
|
lodash.object = zipObject;
|
|
lodash.select = filter;
|
|
lodash.tail = rest;
|
|
lodash.unique = uniq;
|
|
|
|
// Add functions to `lodash.prototype`.
|
|
mixin(lodash, lodash);
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
// Add functions that return unwrapped values when chaining.
|
|
lodash.attempt = attempt;
|
|
lodash.camelCase = camelCase;
|
|
lodash.capitalize = capitalize;
|
|
lodash.clone = clone;
|
|
lodash.cloneDeep = cloneDeep;
|
|
lodash.deburr = deburr;
|
|
lodash.endsWith = endsWith;
|
|
lodash.escape = escape;
|
|
lodash.escapeRegExp = escapeRegExp;
|
|
lodash.every = every;
|
|
lodash.find = find;
|
|
lodash.findIndex = findIndex;
|
|
lodash.findKey = findKey;
|
|
lodash.findLast = findLast;
|
|
lodash.findLastIndex = findLastIndex;
|
|
lodash.findLastKey = findLastKey;
|
|
lodash.findWhere = findWhere;
|
|
lodash.first = first;
|
|
lodash.has = has;
|
|
lodash.identity = identity;
|
|
lodash.includes = includes;
|
|
lodash.indexOf = indexOf;
|
|
lodash.inRange = inRange;
|
|
lodash.isArguments = isArguments;
|
|
lodash.isArray = isArray;
|
|
lodash.isBoolean = isBoolean;
|
|
lodash.isDate = isDate;
|
|
lodash.isElement = isElement;
|
|
lodash.isEmpty = isEmpty;
|
|
lodash.isEqual = isEqual;
|
|
lodash.isError = isError;
|
|
lodash.isFinite = isFinite;
|
|
lodash.isFunction = isFunction;
|
|
lodash.isMatch = isMatch;
|
|
lodash.isNaN = isNaN;
|
|
lodash.isNative = isNative;
|
|
lodash.isNull = isNull;
|
|
lodash.isNumber = isNumber;
|
|
lodash.isObject = isObject;
|
|
lodash.isPlainObject = isPlainObject;
|
|
lodash.isRegExp = isRegExp;
|
|
lodash.isString = isString;
|
|
lodash.isTypedArray = isTypedArray;
|
|
lodash.isUndefined = isUndefined;
|
|
lodash.kebabCase = kebabCase;
|
|
lodash.last = last;
|
|
lodash.lastIndexOf = lastIndexOf;
|
|
lodash.max = max;
|
|
lodash.min = min;
|
|
lodash.noConflict = noConflict;
|
|
lodash.noop = noop;
|
|
lodash.now = now;
|
|
lodash.pad = pad;
|
|
lodash.padLeft = padLeft;
|
|
lodash.padRight = padRight;
|
|
lodash.parseInt = parseInt;
|
|
lodash.random = random;
|
|
lodash.reduce = reduce;
|
|
lodash.reduceRight = reduceRight;
|
|
lodash.repeat = repeat;
|
|
lodash.result = result;
|
|
lodash.runInContext = runInContext;
|
|
lodash.size = size;
|
|
lodash.snakeCase = snakeCase;
|
|
lodash.some = some;
|
|
lodash.sortedIndex = sortedIndex;
|
|
lodash.sortedLastIndex = sortedLastIndex;
|
|
lodash.startCase = startCase;
|
|
lodash.startsWith = startsWith;
|
|
lodash.template = template;
|
|
lodash.trim = trim;
|
|
lodash.trimLeft = trimLeft;
|
|
lodash.trimRight = trimRight;
|
|
lodash.trunc = trunc;
|
|
lodash.unescape = unescape;
|
|
lodash.uniqueId = uniqueId;
|
|
lodash.words = words;
|
|
|
|
// Add aliases.
|
|
lodash.all = every;
|
|
lodash.any = some;
|
|
lodash.contains = includes;
|
|
lodash.detect = find;
|
|
lodash.foldl = reduce;
|
|
lodash.foldr = reduceRight;
|
|
lodash.head = first;
|
|
lodash.include = includes;
|
|
lodash.inject = reduce;
|
|
|
|
mixin(lodash, (function() {
|
|
var source = {};
|
|
baseForOwn(lodash, function(func, methodName) {
|
|
if (!lodash.prototype[methodName]) {
|
|
source[methodName] = func;
|
|
}
|
|
});
|
|
return source;
|
|
}()), false);
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
// Add functions capable of returning wrapped and unwrapped values when chaining.
|
|
lodash.sample = sample;
|
|
|
|
lodash.prototype.sample = function(n) {
|
|
if (!this.__chain__ && n == null) {
|
|
return sample(this.value());
|
|
}
|
|
return this.thru(function(value) {
|
|
return sample(value, n);
|
|
});
|
|
};
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The semantic version number.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type string
|
|
*/
|
|
lodash.VERSION = VERSION;
|
|
|
|
// Assign default placeholders.
|
|
arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
|
|
lodash[methodName].placeholder = lodash;
|
|
});
|
|
|
|
// Add `LazyWrapper` methods that accept an `iteratee` value.
|
|
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
|
|
var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG;
|
|
|
|
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
|
var result = this.clone(),
|
|
iteratees = result.__iteratees__ || (result.__iteratees__ = []);
|
|
|
|
result.__filtered__ = result.__filtered__ || isFilter;
|
|
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
|
|
return result;
|
|
};
|
|
});
|
|
|
|
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
|
|
arrayEach(['drop', 'take'], function(methodName, index) {
|
|
var countName = '__' + methodName + 'Count__',
|
|
whileName = methodName + 'While';
|
|
|
|
LazyWrapper.prototype[methodName] = function(n) {
|
|
n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
|
|
|
|
var result = this.clone();
|
|
if (result.__filtered__) {
|
|
var value = result[countName];
|
|
result[countName] = index ? nativeMin(value, n) : (value + n);
|
|
} else {
|
|
var views = result.__views__ || (result.__views__ = []);
|
|
views.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
|
|
}
|
|
return result;
|
|
};
|
|
|
|
LazyWrapper.prototype[methodName + 'Right'] = function(n) {
|
|
return this.reverse()[methodName](n).reverse();
|
|
};
|
|
|
|
LazyWrapper.prototype[methodName + 'RightWhile'] = function(predicate, thisArg) {
|
|
return this.reverse()[whileName](predicate, thisArg).reverse();
|
|
};
|
|
});
|
|
|
|
// Add `LazyWrapper` methods for `_.first` and `_.last`.
|
|
arrayEach(['first', 'last'], function(methodName, index) {
|
|
var takeName = 'take' + (index ? 'Right' : '');
|
|
|
|
LazyWrapper.prototype[methodName] = function() {
|
|
return this[takeName](1).value()[0];
|
|
};
|
|
});
|
|
|
|
// Add `LazyWrapper` methods for `_.initial` and `_.rest`.
|
|
arrayEach(['initial', 'rest'], function(methodName, index) {
|
|
var dropName = 'drop' + (index ? '' : 'Right');
|
|
|
|
LazyWrapper.prototype[methodName] = function() {
|
|
return this[dropName](1);
|
|
};
|
|
});
|
|
|
|
// Add `LazyWrapper` methods for `_.pluck` and `_.where`.
|
|
arrayEach(['pluck', 'where'], function(methodName, index) {
|
|
var operationName = index ? 'filter' : 'map',
|
|
createCallback = index ? baseMatches : baseProperty;
|
|
|
|
LazyWrapper.prototype[methodName] = function(value) {
|
|
return this[operationName](createCallback(value));
|
|
};
|
|
});
|
|
|
|
LazyWrapper.prototype.compact = function() {
|
|
return this.filter(identity);
|
|
};
|
|
|
|
LazyWrapper.prototype.dropWhile = function(predicate, thisArg) {
|
|
var done,
|
|
lastIndex,
|
|
isRight = this.__dir__ < 0;
|
|
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return this.filter(function(value, index, array) {
|
|
done = done && (isRight ? index < lastIndex : index > lastIndex);
|
|
lastIndex = index;
|
|
return done || (done = !predicate(value, index, array));
|
|
});
|
|
};
|
|
|
|
LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
|
predicate = getCallback(predicate, thisArg, 3);
|
|
return this.filter(function(value, index, array) {
|
|
return !predicate(value, index, array);
|
|
});
|
|
};
|
|
|
|
LazyWrapper.prototype.slice = function(start, end) {
|
|
start = start == null ? 0 : (+start || 0);
|
|
var result = start < 0 ? this.takeRight(-start) : this.drop(start);
|
|
|
|
if (typeof end != 'undefined') {
|
|
end = (+end || 0);
|
|
result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
|
}
|
|
return result;
|
|
};
|
|
|
|
LazyWrapper.prototype.toArray = function() {
|
|
return this.drop(0);
|
|
};
|
|
|
|
// Add `LazyWrapper` methods to `lodash.prototype`.
|
|
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
|
var lodashFunc = lodash[methodName],
|
|
retUnwrapped = /^(?:first|last)$/.test(methodName);
|
|
|
|
lodash.prototype[methodName] = function() {
|
|
var value = this.__wrapped__,
|
|
args = arguments,
|
|
chainAll = this.__chain__,
|
|
isHybrid = !!this.__actions__.length,
|
|
isLazy = value instanceof LazyWrapper,
|
|
onlyLazy = isLazy && !isHybrid;
|
|
|
|
if (retUnwrapped && !chainAll) {
|
|
return onlyLazy
|
|
? func.call(value)
|
|
: lodashFunc.call(lodash, this.value());
|
|
}
|
|
var interceptor = function(value) {
|
|
var otherArgs = [value];
|
|
push.apply(otherArgs, args);
|
|
return lodashFunc.apply(lodash, otherArgs);
|
|
};
|
|
if (isLazy || isArray(value)) {
|
|
var wrapper = onlyLazy ? value : new LazyWrapper(this),
|
|
result = func.apply(wrapper, args);
|
|
|
|
if (!retUnwrapped && (isHybrid || result.__actions__)) {
|
|
var actions = result.__actions__ || (result.__actions__ = []);
|
|
actions.push({ 'func': thru, 'args': [interceptor], 'thisArg': lodash });
|
|
}
|
|
return new LodashWrapper(result, chainAll);
|
|
}
|
|
return this.thru(interceptor);
|
|
};
|
|
});
|
|
|
|
// Add `Array.prototype` functions to `lodash.prototype`.
|
|
arrayEach(['concat', 'join', 'pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
|
var func = arrayProto[methodName],
|
|
chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
|
|
retUnwrapped = /^(?:join|pop|shift)$/.test(methodName);
|
|
|
|
lodash.prototype[methodName] = function() {
|
|
var args = arguments;
|
|
if (retUnwrapped && !this.__chain__) {
|
|
return func.apply(this.value(), args);
|
|
}
|
|
return this[chainName](function(value) {
|
|
return func.apply(value, args);
|
|
});
|
|
};
|
|
});
|
|
|
|
// Add functions to the lazy wrapper.
|
|
LazyWrapper.prototype.clone = lazyClone;
|
|
LazyWrapper.prototype.reverse = lazyReverse;
|
|
LazyWrapper.prototype.value = lazyValue;
|
|
|
|
// Add chaining functions to the `lodash` wrapper.
|
|
lodash.prototype.chain = wrapperChain;
|
|
lodash.prototype.commit = wrapperCommit;
|
|
lodash.prototype.plant = wrapperPlant;
|
|
lodash.prototype.reverse = wrapperReverse;
|
|
lodash.prototype.toString = wrapperToString;
|
|
lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
|
|
|
|
// Add function aliases to the `lodash` wrapper.
|
|
lodash.prototype.collect = lodash.prototype.map;
|
|
lodash.prototype.head = lodash.prototype.first;
|
|
lodash.prototype.select = lodash.prototype.filter;
|
|
lodash.prototype.tail = lodash.prototype.rest;
|
|
|
|
return lodash;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
// Export lodash.
|
|
var _ = runInContext();
|
|
|
|
// Some AMD build optimizers like r.js check for condition patterns like the following:
|
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
// Expose lodash to the global object when an AMD loader is present to avoid
|
|
// errors in cases where lodash is loaded by a script tag and not intended
|
|
// as an AMD module. See http://requirejs.org/docs/errors.html#mismatch for
|
|
// more details.
|
|
root._ = _;
|
|
|
|
// Define as an anonymous module so, through path mapping, it can be
|
|
// referenced as the "underscore" module.
|
|
define(function() {
|
|
return _;
|
|
});
|
|
}
|
|
// Check for `exports` after `define` in case a build optimizer adds an `exports` object.
|
|
else if (freeExports && freeModule) {
|
|
// Export for Node.js or RingoJS.
|
|
if (moduleExports) {
|
|
(freeModule.exports = _)._ = _;
|
|
}
|
|
// Export for Narwhal or Rhino -require.
|
|
else {
|
|
freeExports._ = _;
|
|
}
|
|
}
|
|
else {
|
|
// Export for a browser or Rhino.
|
|
root._ = _;
|
|
}
|
|
}.call(this));
|
|
|
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
|
|
},{}],"react-router":[function(require,module,exports){
|
|
"use strict";
|
|
|
|
exports.DefaultRoute = require("./components/DefaultRoute");
|
|
exports.Link = require("./components/Link");
|
|
exports.NotFoundRoute = require("./components/NotFoundRoute");
|
|
exports.Redirect = require("./components/Redirect");
|
|
exports.Route = require("./components/Route");
|
|
exports.RouteHandler = require("./components/RouteHandler");
|
|
|
|
exports.HashLocation = require("./locations/HashLocation");
|
|
exports.HistoryLocation = require("./locations/HistoryLocation");
|
|
exports.RefreshLocation = require("./locations/RefreshLocation");
|
|
exports.StaticLocation = require("./locations/StaticLocation");
|
|
|
|
exports.ImitateBrowserBehavior = require("./behaviors/ImitateBrowserBehavior");
|
|
exports.ScrollToTopBehavior = require("./behaviors/ScrollToTopBehavior");
|
|
|
|
exports.History = require("./History");
|
|
exports.Navigation = require("./Navigation");
|
|
exports.RouteHandlerMixin = require("./RouteHandlerMixin");
|
|
exports.State = require("./State");
|
|
|
|
exports.createRoute = require("./Route").createRoute;
|
|
exports.createDefaultRoute = require("./Route").createDefaultRoute;
|
|
exports.createNotFoundRoute = require("./Route").createNotFoundRoute;
|
|
exports.createRedirect = require("./Route").createRedirect;
|
|
exports.createRoutesFromReactChildren = require("./createRoutesFromReactChildren");
|
|
exports.create = require("./createRouter");
|
|
exports.run = require("./runRouter");
|
|
},{"./History":6,"./Navigation":8,"./Route":13,"./RouteHandlerMixin":14,"./State":16,"./behaviors/ImitateBrowserBehavior":20,"./behaviors/ScrollToTopBehavior":21,"./components/DefaultRoute":22,"./components/Link":23,"./components/NotFoundRoute":24,"./components/Redirect":25,"./components/Route":26,"./components/RouteHandler":27,"./createRouter":28,"./createRoutesFromReactChildren":29,"./locations/HashLocation":32,"./locations/HistoryLocation":33,"./locations/RefreshLocation":34,"./locations/StaticLocation":35,"./runRouter":36}],"react/addons":[function(require,module,exports){
|
|
module.exports = require('./lib/ReactWithAddons');
|
|
|
|
},{"./lib/ReactWithAddons":133}],"react":[function(require,module,exports){
|
|
module.exports = require('./lib/React');
|
|
|
|
},{"./lib/React":72}]},{},["jquery","lodash","react","react-router","flux","react/addons"])
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlc1xcYnJvd3NlcmlmeVxcbm9kZV9tb2R1bGVzXFxicm93c2VyLXBhY2tcXF9wcmVsdWRlLmpzIiwibm9kZV9tb2R1bGVzXFxicm93c2VyaWZ5XFxub2RlX21vZHVsZXNcXHByb2Nlc3NcXGJyb3dzZXIuanMiLCJub2RlX21vZHVsZXNcXGZsdXhcXGxpYlxcRGlzcGF0Y2hlci5qcyIsIm5vZGVfbW9kdWxlc1xcZmx1eFxcbGliXFxpbnZhcmlhbnQuanMiLCJub2RlX21vZHVsZXNcXHJlYWN0LXJvdXRlclxcbGliXFxDYW5jZWxsYXRpb24uanMiLCJub2RlX21vZHVsZXNcXHJlYWN0LXJvdXRlclxcbGliXFxDb25maWd1cmF0aW9uLmpzIiwibm9kZV9tb2R1bGVzXFxyZWFjdC1yb3V0ZXJcXGxpYlxcSGlzdG9yeS5qcyIsIm5vZGVfbW9kdWxlc1xccmVhY3Qtcm91dGVyXFxsaWJcXE1hdGNoLmpzIiwibm9kZV9tb2R1bGVzXFxyZWFjdC1yb3V0ZXJcXGxpYlxcTmF2aWdhdGlvbi5qcyIsIm5vZGVfbW9kdWxlc1xccmVhY3Qtcm91dGVyXFxsaWJcXE5hdmlnYXRpb25Db250ZXh0LmpzIiwibm9kZV9tb2R1bGVzXFxyZWFjdC1yb3V0ZXJcXGxpYlxcUGF0aFV0aWxzLmpzIiwibm9kZV9tb2R1bGVzXFxyZWFjdC1yb3V0ZXJcXGxpYlxcUHJvcFR5cGVzLmpzIiwibm9kZV9tb2R1bGVzXFxyZWFjdC1yb3V0ZXJcXGxpYlxcUmVkaX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nNlcnZlciA9IG5ldyBNdXRhdGlvbk9ic2VydmVyKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBxdWV1ZUxpc3QgPSBxdWV1ZS5zbGljZSgpO1xuICAgICAgICAgICAgcXVldWUubGVuZ3RoID0gMDtcbiAgICAgICAgICAgIHF1ZXVlTGlzdC5mb3JFYWNoKGZ1bmN0aW9uIChmbikge1xuICAgICAgICAgICAgICAgIGZuKCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgb2JzZXJ2ZXIub2JzZXJ2ZShoaWRkZW5EaXYsIHsgYXR0cmlidXRlczogdHJ1ZSB9KTtcblxuICAgICAgICByZXR1cm4gZnVuY3Rpb24gbmV4dFRpY2soZm4pIHtcbiAgICAgICAgICAgIGlmICghcXVldWUubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgaGlkZGVuRGl2LnNldEF0dHJpYnV0ZSgneWVzJywgJ25vJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBxdWV1ZS5wdXNoKGZuKTtcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBpZiAoY2FuUG9zdCkge1xuICAgICAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbWVzc2FnZScsIGZ1bmN0aW9uIChldikge1xuICAgICAgICAgICAgdmFyIHNvdXJjZSA9IGV2LnNvdXJjZTtcbiAgICAgICAgICAgIGlmICgoc291cmNlID09PSB3aW5kb3cgfHwgc291cmNlID09PSBudWxsKSAmJiBldi5kYXRhID09PSAncHJvY2Vzcy10aWNrJykge1xuICAgICAgICAgICAgICAgIGV2LnN0b3BQcm9wYWdhdGlvbigpO1xuICAgICAgICAgICAgICAgIGlmIChxdWV1ZS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmbiA9IHF1ZXVlLnNoaWZ0KCk7XG4gICAgICAgICAgICAgICAgICAgIGZuKCk7XG4gICAgICAgICAgICAgICAgfVxuICA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V0dXJucyBhIG5ldyByb3V0ZS4gT3B0aW9ucyBtYXkgYmUgYSBVUkwgcGF0aG5hbWUgc3RyaW5nXG4gICAgICAgKiB3aXRoIHBsYWNlaG9sZGVycyBmb3IgbmFtZWQgcGFyYW1zIG9yIGFuIG9iamVjdCB3aXRoIGFueSBvZiB0aGUgZm9sbG93aW5nXG4gICAgICAgKiBwcm9wZXJ0aWVzOlxuICAgICAgICpcbiAgICAgICAqIC0gbmFtZSAgICAgICAgICAgICAgICAgICAgIFRoZSBuYW1lIG9mIHRoZSByb3V0ZS4gVGhpcyBpcyB1c2VkIHRvIGxvb2t1cCBhXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3V0ZSByZWxhdGl2ZSB0byBpdHMgcGFyZW50IHJvdXRlIGFuZCBzaG91bGQgYmVcbiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuaXF1ZSBhbW9uZyBhbGwgY2hpbGQgcm91dGVzIG9mIHRoZSBzYW1lIHBhcmVudFxuICAgICAgICogLSBwYXRoICAgICAgICAgICAgICAgICAgICAgQSBVUkwgcGF0aG5hbWUgc3RyaW5nIHdpdGggb3B0aW9uYWwgcGxhY2Vob2xkZXJzXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0IHNwZWNpZnkgdGhlIG5hbWVzIG9mIHBhcmFtcyB0byBleHRyYWN0IGZyb21cbiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSBVUkwgd2hlbiB0aGUgcGF0aCBtYXRjaGVzLiBEZWZhdWx0cyB0byBgLyR7bmFtZX1gXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGVuIHRoZXJlIGlzIGEgbmFtZSBnaXZlbiwgb3IgdGhlIHBhdGggb2YgdGhlIHBhcmVudFxuICAgICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm91dGUsIG9yIC9cbiAgICAgICAqIC0gaWdub3JlU2Nyb2xsQmVoYXZpb3IgICAgIFRydWUgdG8gbWFrZSB0aGlzIHJvdXRlIChhbmQgYWxsIGRlc2NlbmRhbnRzKSBpZ25vcmVcbiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSBzY3JvbGwgYmVoYXZpb3Igb2YgdGhlIHJvdXRlclxuICAgICAgICogLSBpc0RlZmF1bHQgICAgICAgICAgICAgICAgVHJ1ZSB0byBtYWtlIHRoaXMgcm91dGUgdGhlIGRlZmF1bHQgcm91dGUgYW1vbmcgYWxsXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdHMgc2libGluZ3NcbiAgICAgICAqIC0gaXNOb3RGb3VuZCAgICAgICAgICAgICAgIFRydWUgdG8gbWFrZSB0aGlzIHJvdXRlIHRoZSBcIm5vdCBmb3VuZFwiIHJvdXRlIGFtb25nXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGwgaXRzIHNpYmxpbmdzXG4gICAgICAgKiAtIG9uRW50ZXIgICAgICAgICAgICAgICAgICBBIHRyYW5zaXRpb24gaG9vayB0aGF0IHdpbGwgYmUgY2FsbGVkIHdoZW4gdGhlXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3V0ZXIgaXMgZ29pbmcgdG8gZW50ZXIgdGhpcyByb3V0ZVxuICAgICAgICogLSBvbkxlYXZlICAgICAgICAgICAgICAgICAgQSB0cmFuc2l0aW9uIGhvb2sgdGhhdCB3aWxsIGJlIGNhbGxlZCB3aGVuIHRoZVxuICAgICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm91dGVyIGlzIGdvaW5nIHRvIGxlYXZlIHRoaXMgcm91dGVcbiAgICAgICAqIC0gaGFuZGxlciAgICAgICAgICAgICAgICAgIEEgUmVhY3QgY29tcG9uZW50IHRoYXQgd2lsbCBiZSByZW5kZXJlZCB3aGVuXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzIHJvdXRlIGlzIGFjdGl2ZVxuICAgICAgICogLSBwYXJlbnRSb3V0ZSAgICAgICAgICAgICAgVGhlIHBhcmVudCByb3V0ZSB0byB1c2UgZm9yIHRoaXMgcm91dGUuIFRoaXMgb3B0aW9uXG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpcyBhdXRvbWF0aWNhbGx5IHN1cHBsaWVkIHdoZW4gY3JlYXRpbmcgcm91dGVzIGluc2lkZVxuICAgICAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIGNhbGxiYWNrIHRvIGFub3RoZXIgaW52b2NhdGlvbiBvZiBjcmVhdGVSb3V0ZS4gWW91XG4gICAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbmx5IGV2ZXIgbmVlZCB0byB1c2UgdGhpcyB3aGVuIGRlY2xhcmluZyByb3V0ZXNcbiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGVwZW5kZW50bHkgb2Ygb25lIGFub3RoZXIgdG8gbWFudWFsbHkgcGllY2UgdG9nZXRoZXJcbiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSByb3V0ZSBoaWVyYXJjaHlcbiAgICAgICAqXG4gICAgICAgKiBUaGUgY2FsbGJhY2sgbWF5IGJlIHVzZWQgdG8gc3RydWN0dXJlIHlvdXIgcm91dGUgaGllcmFyY2h5LiBBbnkgY2FsbCB0b1xuICAgICAgICogY3JlYXRlUm91dGUsIGNyZWF0ZURlZmF1bHRSb3V0ZSwgY3JlYXRlTm90Rm91bmRSb3V0ZSwgb3IgY3JlYXRlUmVkaXJlY3RcbiAgICAgICAqIGluc2lkZSB0aGUgY2FsbGJhY2sgYXV0b21hdGljYWxseSB1c2VzIHRoaXMgcm91dGUgYXMgaXRzIHBhcmVudC5cbiAgICAgICAqL1xuXG4gICAgICB2YWx1ZTogZnVuY3Rpb24gY3JlYXRlUm91dGUob3B0aW9ucywgY2FsbGJhY2spIHtcbi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XJuYWxzLnBhcnNlT2JqZWN0KGNoYWluLCB2YWwsIG9wdGlvbnMpKTtcbiAgICB9XG4gICAgZWxzZSB7XG4gICAgICAgIHZhciBjbGVhblJvb3QgPSByb290WzBdID09PSAnWycgJiYgcm9vdFtyb290Lmxlbmd0aCAtIDFdID09PSAnXScgPyByb290LnNsaWNlKDEsIHJvb3QubGVuZ3RoIC0gMSkgOiByb290O1xuICAgICAgICB2YXIgaW5kZXggPSBwYXJzZUludChjbGVhblJvb3QsIDEwKTtcbiAgICAgICAgdmFyIGluZGV4U3RyaW5nID0gJycgKyBpbmRleDtcbiAgICAgICAgaWYgKCFpc05hTihpbmRleCkgJiZcbiAgICAgICAgICAgIHJvb3QgIT09IGNsZWFuUm9vdCAmJlxuICAgICAgICAgICAgaW5kZXhTdHJpbmcgPT09IGNsZWFuUm9vdCAmJlxuICAgICAgICAgICAgaW5kZXggPj0gMCAmJlxuICAgICAgICAgICAgaW5kZXggPD0gb3B0aW9ucy5hcnJheUxpbWl0KSB7XG5cbiAgICAgICAgICAgIG9iaiA9IFtdO1xuICAgICAgICAgICAgb2JqW2luZGV4XSA9IGludGVybmFscy5wYXJzZU9iamVjdChjaGFpbiwgdmFsLCBvcHRpb25zKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIG9ialtjbGVhblJvb3RdID0gaW50ZXJuYWxzLnBhcnNlT2JqZWN0KGNoYWluLCB2YWwsIG9wdGlvbnMpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIG9iajtcbn07XG5cblxuaW50ZXJuYWxzLnBhcnNlS2V5cyA9IGZ1bmN0aW9uIChrZXksIHZhbCwgb3B0aW9ucykge1xuXG4gICAgaWYgKCFrZXkpIHtcbiAgICAgICAgcmV0dXJuO1xuICAgIH1cblxuICAgIC8vIFRoZSByZWdleCBjaHVua3NcblxuICAgIHZhciBwYXJlbnQgPSAvXihbXlxcW1xcXV0qKS87XG4gICAgdmFyIGNoaWxk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ICAgIHR5cGVvZiBvYmogPT09ICdib29sZWFuJykge1xuXG4gICAgICAgIHJldHVybiBbZW5jb2RlVVJJQ29tcG9uZW50KHByZWZpeCkgKyAnPScgKyBlbmNvZGVVUklDb21wb25lbnQob2JqKV07XG4gICAgfVxuXG4gICAgdmFyIHZhbHVlcyA9IFtdO1xuXG4gICAgaWYgKHR5cGVvZiBvYmogPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgIHJldHVybiB2YWx1ZXM7XG4gICAgfVxuXG4gICAgdmFyIG9iaktleXMgPSBPYmplY3Qua2V5cyhvYmopO1xuICAgIGZvciAodmFyIGkgPSAwLCBpbCA9IG9iaktleXMubGVuZ3RoOyBpIDwgaWw7ICsraSkge1xuICAgICAgICB2YXIga2V5ID0gb2JqS2V5c1tpXTtcbiAgICAgICAgaWYgKCFvcHRpb25zLmluZGljZXMgJiZcbiAgICAgICAgICAgIEFycmF5LmlzQXJyYXkob2JqKSkge1xuXG4gICAgICAgICAgICB2YWx1ZXMgPSB2YWx1ZXMuY29uY2F0KGludGVybmFscy5zdHJpbmdpZnkob2JqW2tleV0sIHByZWZpeCwgb3B0aW9ucykpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdmFsdWVzID0gdmFsdWVzLmNvbmNhdChpbnRlcm5hbHMuc3RyaW5naWZ5KG9ialtrZXldLCBwcmVmaXggKyAnWycgKyBrZXkgKyAnXScsIG9wdGlvbnMpKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiB2YWx1ZXM7XG59O1xuXG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9iaiwgb3B0aW9ucykge1xuXG4gICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XG4gICAgdmFyIGRlbGltaXRlciA9IHR5cGVvZiBvcHRpb25zLmRlbGltaXRlciA9PT0gJ3VuZGVmaW5lZCcgPyBpbnRlcm5hbHMuZGVsaW1pdGVyIDogb3B0aW9ucy5k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2V0LCBzb3VyY2UpIHtcblxuICAgIGlmICghc291cmNlKSB7XG4gICAgICAgIHJldHVybiB0YXJnZXQ7XG4gICAgfVxuXG4gICAgaWYgKHR5cGVvZiBzb3VyY2UgIT09ICdvYmplY3QnKSB7XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KHRhcmdldCkpIHtcbiAgICAgICAgICAgIHRhcmdldC5wdXNoKHNvdXJjZSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICB0YXJnZXRbc291cmNlXSA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdGFyZ2V0O1xuICAgIH1cblxuICAgIGlmICh0eXBlb2YgdGFyZ2V0ICE9PSAnb2JqZWN0Jykge1xuICAgICAgICB0YXJnZXQgPSBbdGFyZ2V0XS5jb25jYXQoc291cmNlKTtcbiAgICAgICAgcmV0dXJuIHRhcmdldDtcbiAgICB9XG5cbiAgICBpZiAoQXJyYXkuaXNBcnJheSh0YXJnZXQpICYmXG4gICAgICAgICFBcnJheS5pc0FycmF5KHNvdXJjZSkpIHtcblxuICAgICAgICB0YXJnZXQgPSBleHBvcnRzLmFycmF5VG9PYmplY3QodGFyZ2V0KTtcbiAgICB9XG5cbiAgICB2YXIga2V5cyA9IE9iamVjdC5rZXlzKHNvdXJjZSk7XG4gICAgZm9yICh2YXIgayA9IDAsIGtsID0ga2V5cy5sZW5ndGg7IGsgPCBrbDsgKytrKSB7XG4gICAgICAgIHZhciBrZXkgPSBrZXlzW2tdO1xuICAgICAgICB2YXIgdmFsdWUgPSBzb3VyY2Vba2V5XTtcblxuICAgICAgICBpZiAoIXRhcmdldFtrZXldKSB7XG4gICAgICAgICAgICB0YXJnZXRba2V5XSA9IHZhbHVlO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdGFyZ2V0W2tleV0gPSBleHBvcnRzLm1lcmdlKHRhcmdldFtrZXldLCB2YWx1ZSk7XG4gICAgICAg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vLyBjaGFycy4gUGFzdGUgZXZlbnRzIHNob3VsZCBub3QgbGVhZCB0byBCZWZvcmVJbnB1dCBldmVudHMuXG4gICAgICAgICAgZmFsbGJhY2tDaGFycyA9IG51bGw7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgdG9wTGV2ZWxUeXBlcy50b3BLZXlQcmVzczpcbiAgICAgICAgICAvKipcbiAgICAgICAgICAgKiBBcyBvZiB2MjcsIEZpcmVmb3ggbWF5IGZpcmUga2V5cHJlc3MgZXZlbnRzIGV2ZW4gd2hlbiBubyBjaGFyYWN0ZXJcbiAgICAgICAgICAgKiB3aWxsIGJlIGluc2VydGVkLiBBIGZldyBwb3NzaWJpbGl0aWVzOlxuICAgICAgICAgICAqXG4gICAgICAgICAgICogLSBgd2hpY2hgIGlzIGAwYC4gQXJyb3cga2V5cywgRXNjIGtleSwgZXRjLlxuICAgICAgICAgICAqXG4gICAgICAgICAgICogLSBgd2hpY2hgIGlzIHRoZSBwcmVzc2VkIGtleSBjb2RlLCBidXQgbm8gY2hhciBpcyBhdmFpbGFibGUuXG4gICAgICAgICAgICogICBFeDogJ0FsdEdyICsgZGAgaW4gUG9saXNoLiBUaGVyZSBpcyBubyBtb2RpZmllZCBjaGFyYWN0ZXIgZm9yXG4gICAgICAgICAgICogICB0aGlzIGtleSBjb21iaW5hdGlvbiBhbmQgbm8gY2hhcmFjdGVyIGlzIGluc2VydGVkIGludG8gdGhlXG4gICAgICAgICAgICogICBkb2N1bWVudCwgYnV0IEZGIGZpcmVzIHRoZSBrZXlwcmVzcyBmb3IgY2hhciBjb2RlIGAxMDBgIGFueXdheS5cbiAgICAgICAgICAgKiAgIE5vIGBpbnB1dGAgZXZlbnQgd2lsbCBvY2N1ci5cbiAgICAgICAgICAgKlxuICAgICAgICAgICAqIC0gYHdoaWNoYCBpcyB0aGUgcHJlc3NlZCBrZXkgY29kZSwgYnV0IGEgY29tbWFuZCBjb21iaW5hdGlvbiBpc1xuICAgICAgICAgIC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WFjdEV2ZW50IHwgICAgLlxuICogfCAgTGlzdGVuZXIgIHwgICAgLlxuICogKy0tLS0tLS0tLS0tLSsgICAgLiAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tLS0rXG4gKiAgICAgICB8ICAgICAgICAgICAuICAgICAgICAgICAgICAgKy0tLS0tLS0tK3xTaW1wbGVFdmVudHxcbiAqICAgICAgIHwgICAgICAgICAgIC4gICAgICAgICAgICAgICB8ICAgICAgICAgfFBsdWdpbiAgICAgfFxuICogKy0tLS0tfC0tLS0tLSsgICAgLiAgICAgICAgICAgICAgIHYgICAgICAgICArLS0tLS0tLS0tLS0rXG4gKiB8ICAgICB8ICAgICAgfCAgICAuICAgICstLS0tLS0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICAgICstLS0tLS0tLS0tLS0rXG4gKiB8ICAgICArLS0tLS0tLS0tLS0uLS0tPnxFdmVudFBsdWdpbkh1YnwgICAgICAgICAgICAgICAgICAgIHwgICAgRXZlbnQgICB8XG4gKiB8ICAgICAgICAgICAgfCAgICAuICAgIHwgICAgICAgICAgICAgIHwgICAgICstLS0tLS0tLS0tLSsgIHwgUHJvcGFnYXRvcnN8XG4gKiB8IFJlYWN0RXZlbnQgfCAgICAuICAgIHwgICAgICAgICAgICAgIHwgICAgIHxUYXBFdmVudCAgIHwgIHwtLS0tLS0tLS0tLS18XG4gKiB8ICBFbWl0dGVyICAgfCAgICAuICAgIHwgICAgICAgICAgICAgIHw8LS0tK3xQbHVnaW4gICAgIHwgIHxvdGhlciBwbHVnaW58XG4gKiB8ICAgICAgICAgICAgfCAgICAuICAgIHwgICAgICAgICAgICAgIHwgICAgICstLS0tLS0tLS0tLSsgIHwgIHV0aWxpdGllcyB8XG4gKiB8ICAgICArLS0tLS0tLS0tLS0uLS0tPnwgICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAgICstLS0tLS0tLS0tLS0rXG4gKiB8ICAgICB8ICAgICAgfCAgICAuICAgICstLS0tLS0tLS0tL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BpZiAoaXNFdmVudFN1cHBvcnRlZCgnbW91c2V3aGVlbCcpKSB7XG4gICAgICAgICAgICBSZWFjdEJyb3dzZXJFdmVudEVtaXR0ZXIuUmVhY3RFdmVudExpc3RlbmVyLnRyYXBCdWJibGVkRXZlbnQoXG4gICAgICAgICAgICAgIHRvcExldmVsVHlwZXMudG9wV2hlZWwsXG4gICAgICAgICAgICAgICdtb3VzZXdoZWVsJyxcbiAgICAgICAgICAgICAgbW91bnRBdFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gRmlyZWZveCBuZWVkcyB0byBjYXB0dXJlIGEgZGlmZmVyZW50IG1vdXNlIHNjcm9sbCBldmVudC5cbiAgICAgICAgICAgIC8vIEBzZWUgaHR0cDovL3d3dy5xdWlya3Ntb2RlLm9yZy9kb20vZXZlbnRzL3Rlc3RzL3Njcm9sbC5odG1sXG4gICAgICAgICAgICBSZWFjdEJyb3dzZXJFdmVudEVtaXR0ZXIuUmVhY3RFdmVudExpc3RlbmVyLnRyYXBCdWJibGVkRXZlbnQoXG4gICAgICAgICAgICAgIHRvcExldmVsVHlwZXMudG9wV2hlZWwsXG4gICAgICAgICAgICAgICdET01Nb3VzZVNjcm9sbCcsXG4gICAgICAgICAgICAgIG1vdW50QXRcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKGRlcGVuZGVuY3kgPT09IHRvcExldmVsVHlwZXMudG9wU2Nyb2xsKSB7XG5cbiAgICAgICAgICBpZiAoaXNFdmVudFN1cHBvcnRlZCgnc2Nyb2xsJywgdHJ1ZSkpIHtcbiAgICAgICAgICAgIFJlYWN0QnJvd3NlckV2ZW50RW1pdHRlci5SZWFjdEV2ZW50TGlzdGVuZXIudHJhcENhcHR1cmVkRXZlbnQoXG4gICAgICAgICAgICAgIHRvcExldmVsVHlwZXMudG9wU2Nyb2xsLFxuICAgICAgICAgICAgICAnc2Nyb2xsJyxcbiAgICAgICAgICAgICAgbW91bnRBdFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgUmVhY3RCcm93c2VyRXZlbnRFbWl0dGVyLlJlYWN0RXZlbnRMaXN0ZW5lci50cmFwQnViYmxlZEV2ZW50KFxuICAgICAgICAgICAgICB0b3BMZXZlbFR5cGVzLnRvcFNjcm9sbCxcbiAgICAgICAgICAgICAgJ3Njcm9sbCcsXG4gICAgICAgICAgICAgIFJlYWN0QnJvd3NlckV2ZW50RW1pdHRlci5SZWFjdEV2ZW50TGlzdGVuZXIuV0lORE9XX0hBTkRMRVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoZGVwZW5kZW5jeSA9PT0gdG9wTGV2ZWxUeXBlcy50b3BGb2N1cyB8fFxuICAgICAgICAgICAgZGVwZW5kZW5jeSA9PT0gdG9wTGV2ZWxUeXBlcy50b3BCbHVyKSB7XG5cbiAgICAgICAgICBpZiAoaXNFdmVudFN1cHBvcnRlZCgnZm9jdXMnLCB0cnVlKSkge1xuICAgICAgICAgICAgUmVhY3RCcm93c2VyRXZlbnRFbWl0dGVyLlJlYWN0RXZlbnRMaXN0ZW5lci50cmFwQ2FwdHVyZWRFdmVudChcbiAgICAgICAgICAgICAgdG9wTGV2ZWxUeXBlcy50b3BGb2N1cyxcbiAgICAgICAgICAgICAgJ2ZvY3VzJyxcbiAgICAgICAgICAgICAgbW91bnRBdFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIFJlYWN0QnJvd3NlckV2ZW50RW1pdHRlci5SZWFjdEV2ZW50TGlzdGVuZXIudHJhcENhcHR1cmVkRXZlbnQoXG4gICAgICAgICAgICAgIHRvcExldmVsVHlwZXMudG9wQmx1cixcbiAgICAgICAgICAgICAgJ2JsdXInLFxuICAgICAgICAgICAgICBtb3VudEF0XG4gICAgICAgICAgICApO1xuICAgICAgICAgIH0gZWxzZSBpZiAoaXNFdmVudF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biAgICAgKiBSZWxlYXNlcyBhbnkgcmVzb3VyY2VzIGFsbG9jYXRlZCBieSBgbW91bnRDb21wb25lbnRgLlxuICAgICAqXG4gICAgICogTk9URTogVGhpcyBkb2VzIG5vdCByZW1vdmUgYW55IG5vZGVzIGZyb20gdGhlIERPTS5cbiAgICAgKlxuICAgICAqIFN1YmNsYXNzZXMgdGhhdCBvdmVycmlkZSB0aGlzIG1ldGhvZCBzaG91bGQgbWFrZSBzdXJlIHRvIGludm9rZVxuICAgICAqIGBSZWFjdENvbXBvbmVudC5NaXhpbi51bm1vdW50Q29tcG9uZW50LmNhbGwodGhpcylgLlxuICAgICAqXG4gICAgICogQGludGVybmFsXG4gICAgICovXG4gICAgdW5tb3VudENvbXBvbmVudDogZnVuY3Rpb24oKSB7XG4gICAgICAoXCJwcm9kdWN0aW9uXCIgIT09IHByb2Nlc3MuZW52Lk5PREVfRU5WID8gaW52YXJpYW50KFxuICAgICAgICB0aGlzLmlzTW91bnRlZCgpLFxuICAgICAgICAndW5tb3VudENvbXBvbmVudCgpOiBDYW4gb25seSB1bm1vdW50IGEgbW91bnRlZCBjb21wb25lbnQuJ1xuICAgICAgKSA6IGludmFyaWFudCh0aGlzLmlzTW91bnRlZCgpKSk7XG4gICAgICB2YXIgcmVmID0gdGhpcy5fY3VycmVudEVsZW1lbnQucmVmO1xuICAgICAgaWYgKHJlZiAhPSBudWxsKSB7XG4gICAgICAgIFJlYWN0T3duZXIucmVtb3ZlQ29tcG9uZW50QXNSZWZGcm9tKHRoaXMsIHJlZiwgdGhpcy5fb3duZXIpO1xuICAgICAgfVxuICAgICAgdW5tb3VudElERnJvbUVudmlyb25tZW50KHRoaXMuX3Jvb3ROb2RlSUQpO1xuICAgICAgdGhpcy5fcm9vdE5vZGVJRCA9IG51bGw7XG4gICAgICB0aGlzLl9saWZlQ3ljbGVTdGF0ZSA9IENvbXBvbmVudExpZmVDeWNsZS5VTk1PVU5URUQ7XG4gICAgfSxcblxuICAgIC8qKlxuICA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V2RWxlbWVudC5fb3duZXIgfHxcbiAgICAgICAgICBuZXh0RWxlbWVudC5yZWYgIT09IHByZXZFbGVtZW50LnJlZikge1xuICAgICAgICBpZiAocHJldkVsZW1lbnQucmVmICE9IG51bGwpIHtcbiAgICAgICAgICBSZWFjdE93bmVyLnJlbW92ZUNvbXBvbmVudEFzUmVmRnJvbShcbiAgICAgICAgICAgIHRoaXMsIHByZXZFbGVtZW50LnJlZiwgcHJldkVsZW1lbnQuX293bmVyXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgICAvLyBDb3JyZWN0LCBldmVuIGlmIHRoZSBvd25lciBpcyB0aGUgc2FtZSwgYW5kIG9ubHkgdGhlIHJlZiBoYXMgY2hhbmdlZC5cbiAgICAgICAgaWYgKG5leHRFbGVtZW50LnJlZiAhPSBudWxsKSB7XG4gICAgICAgICAgUmVhY3RPd25lci5hZGRDb21wb25lbnRBc1JlZlRvKFxuICAgICAgICAgICAgdGhpcyxcbiAgICAgICAgICAgIG5leHRFbGVtZW50LnJlZixcbiAgICAgICAgICAgIG5leHRFbGVtZW50Ll9vd25lclxuICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogTW91bnRzIHRoaXMgY29tcG9uZW50IGFuZCBpbnNlcnRzIGl0IGludG8gdGhlIERPTS5cbiAgICAgKlxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSByb290SUQgRE9NIElEIG9mIHRoZSByb290IG5vZGUuXG4gICAgICogQHBhcmFtIHtET01FbGVtZW50fSBjb250YWluZXIgRE9NIGVsZW1lbnQgdG8gbW91bnQgaW50by5cbiAgICAgKiBAcGFyYW0ge2Jvb2xlYW59IHNob3VsZFJldXNlTWFya3VwIElmIHRydWUsIGRvIG5vdCBpbnNlcnQgbWFya3VwXG4gICAgICogQGZpbmFsXG4gICAgICogQGludGVybmFsXG4gICAgICogQHNlZSB7UmVhY3RNb3VudC5yZW5kZXJ9XG4gIC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NYXJrdXApIHtcbiAgICAgIHZhciBtYXJrdXAgPSB0aGlzLm1vdW50Q29tcG9uZW50KHJvb3RJRCwgdHJhbnNhY3Rpb24sIDApO1xuICAgICAgbW91bnRJbWFnZUludG9Ob2RlKG1hcmt1cCwgY29udGFpbmVyLCBzaG91bGRSZXVzZU1hcmt1cCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIENoZWNrcyBpZiB0aGlzIGNvbXBvbmVudCBpcyBvd25lZCBieSB0aGUgc3VwcGxpZWQgYG93bmVyYCBjb21wb25lbnQuXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge1JlYWN0Q29tcG9uZW50fSBvd25lciBDb21wb25lbnQgdG8gY2hlY2suXG4gICAgICogQHJldHVybiB7Ym9vbGVhbn0gVHJ1ZSBpZiBgb3duZXJzYCBvd25zIHRoaXMgY29tcG9uZW50LlxuICAgICAqIEBmaW5hbFxuICAgICAqIEBpbnRlcm5hbFxuICAgICAqL1xuICAgIGlzT3duZWRCeTogZnVuY3Rpb24ob3duZXIpIHtcbiAgICAgIHJldHVybiB0aGlzLl9vd25lciA9PT0gb3duZXI7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEdldHMgYW5vdGhlciBjb21wb25lbnQsIHRoYXQgc2hhcmVzIHRoZSBzYW1lIG93bmVyIGFzIHRoaXMgb25lLCBieSByZWYuXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gcmVmIG9mIGEgc2libGluZyBDb21wb25lbnQuXG4gICAgICogQHJldHVybiB7P1JlYWN0Q29tcG9uZW50fSB0aGUgYWN0dWFsIHNpYmxpbmcgQ29tcG9uZW50LlxuICAgICAqIEBmaW5hbFxuICAgICAqIEBpbnRlcm5hbFxuICAgICAqL1xuICAgIGdldFNpYmxpbmdCeVJlZjogZnVuY3Rpb24ocmVmKSB7XG4gICAgICB2YXIgb3duZXIgPSB0aGlzLl9vd25lcjtcbiAgICAgIGlmICghb3duZXIgfHwgIW93bmVyLnJlZn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iYWNrKTtcbiAgICB9XG4gIH0sXG5cbiAgLyoqXG4gICAqIEZpbHRlcnMgdGhlIGNvbnRleHQgb2JqZWN0IHRvIG9ubHkgY29udGFpbiBrZXlzIHNwZWNpZmllZCBpblxuICAgKiBgY29udGV4dFR5cGVzYCwgYW5kIGFzc2VydHMgdGhhdCB0aGV5IGFyZSB2YWxpZC5cbiAgICpcbiAgICogQHBhcmFtIHtvYmplY3R9IGNvbnRleHRcbiAgICogQHJldHVybiB7P29iamVjdH1cbiAgICogQHByaXZhdGVcbiAgICovXG4gIF9wcm9jZXNzQ29udGV4dDogZnVuY3Rpb24oY29udGV4dCkge1xuICAgIHZhciBtYXNrZWRDb250ZXh0ID0gbnVsbDtcbiAgICB2YXIgY29udGV4dFR5cGVzID0gdGhpcy5jb25zdHJ1Y3Rvci5jb250ZXh0VHlwZXM7XG4gICAgaWYgKGNvbnRleHRUeXBlcykge1xuICAgICAgbWFza2VkQ29udGV4dCA9IHt9O1xuICAgICAgZm9yICh2YXIgY29udGV4dE5hbWUgaW4gY29udGV4dFR5cGVzKSB7XG4gICAgICAgIG1hc2tlZENvbnRleHRbY29udGV4dE5hbWVdID0gY29udGV4dFtjb250ZXh0TmFtZV07XG4gICAgICB9XG4gICAgICBpZiAoXCJwcm9kdWN0aW9uXCIgIT09IHByb2Nlc3MuZW52Lk5PREVfRU5WKSB7XG4gICAgICAgIHRoaXMuX2NoZWNrUHJvcFR5cGVzKFxuICAgICAgICAgIGNvbnRleHRUeXBlcyxcbiAgICAgICAgICBtYXNrZWRDb250ZXh0LFxuICAgICAgICAgIFJlYWN0UHJvcFR5cGVMb2NhdGlvbnMuY29udGV4dFxuICAgICAgICApO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gbWFza2VkQ29udGV4dDtcbiAgfSxcblxuICAvKipcbiAgICogQHBhcmFtIHtvYmplY3R9IGN1cnJlbnRDb250ZXh0XG4gICAqIEByZXR1cm4ge29iamVjdH1cbiAgICogQHByaXZhdGVcbiAgICovXG4gIF9wcm9jZXNzQ2hpbGRDb250ZXh0OiBmdW5jdGlvbihjdXJyZW50Q29udGV4dCkge1xuICAgIHZhciBjaGlsZENvbnRleHQgPSB0aGlzLmdldENoaWxkQ29udGV4dCAmJiB0aGlzLmdldENoaWxkQ29udGV4dCgpO1xuICAgIHZhciBkaXNwbGF5TmFtZSA9IHRoaXMuY29uc3RydWN0b3IuZGlzcGxheU5hbWUgfHwgJ1JlYWN0Q29tcG9zaXRlQ29tcG9uZW50JztcbiAgICBpZiAoY2hpbGRDb250ZXh0KSB7XG4gICAgICAoXCJwcm9kdWN0aW9uXCIgIT09IHByb2Nlc3MuZW52Lk5PREVfRU5WID8gaW52YXJpYW50KFxuICAgICAgICB0eXBlb2YgdGhpcy5jb25zdHJ1Y3Rvci5jaGlsZENvbnRleHRUeXBlcyA9PT0gJ29iamVjdCcsXG4gICAgICAgICclcy5nZXRDaGlsZENvbnRleHQoKTogY2hpbGRDb250ZXh0VHlwZXMgbXVzdCBiZSBkZWZpbmVkIGluIG9yZGVyIHRvICcgK1xuICAgICAgICAndXNlIGdldENoaWxkQ29udGV4dCgpLicsXG4gICAgICAgIGRpc3BsYXlOYW1lXG4gICAgICApIDogaW52YXJpYW50KHR5cGVvZiB0aGlzLmNvbnN0cnVjdG9yLmNoaWxkQ29udGV4dFR5cGVzID09PSAnb2JqZWN0JykpO1xuICAgICAgaWYgKFwicHJvZHVjdGlvblwiICE9PSBwcm9jZXNzLmVudi5OT0RFX0VOVikge1xuICAgICAgICB0aGlzLl9jaGVja1Byb3BUeXBlcyhcbiAgICAgICAgICB0aGlzLmNvbnN0cnVjdG9yLmNoaWxkQ29udGV4dFR5cGVzLFxuICAgICAgICAgIGNoaWxkQ29udGV4dCxcbiAgICAgICAgICBSZWFjdFByb3BUeXBlTG9jYXRpb25zLmNoaWxkQ29udGV4dFxuICAgICAgICApO1xuICAgICAgfVxuICAgICAgZm9yICh2YXIgbmFtZSBpbiBjaGlsZENvbnRleHQpIHtcb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ENvbXBvbmVudCgpO1xuICAgICAgICB0aGlzLl9yZW5kZXJlZENvbXBvbmVudCA9IGluc3RhbnRpYXRlUmVhY3RDb21wb25lbnQoXG4gICAgICAgICAgbmV4dEVsZW1lbnQsXG4gICAgICAgICAgdGhpcy5fY3VycmVudEVsZW1lbnQudHlwZVxuICAgICAgICApO1xuICAgICAgICB2YXIgbmV4dE1hcmt1cCA9IHRoaXMuX3JlbmRlcmVkQ29tcG9uZW50Lm1vdW50Q29tcG9uZW50KFxuICAgICAgICAgIHRoaXNJRCxcbiAgICAgICAgICB0cmFuc2FjdGlvbixcbiAgICAgICAgICB0aGlzLl9tb3VudERlcHRoICsgMVxuICAgICAgICApO1xuICAgICAgICBSZWFjdENvbXBvbmVudC5CYWNrZW5kSURPcGVyYXRpb25zLmRhbmdlcm91c2x5UmVwbGFjZU5vZGVXaXRoTWFya3VwQnlJRChcbiAgICAgICAgICBwcmV2Q29tcG9uZW50SUQsXG4gICAgICAgICAgbmV4dE1hcmt1cFxuICAgICAgICApO1xuICAgICAgfVxuICAgIH1cbiAgKSxcblxuICAvKipcbiAgICogRm9yY2VzIGFuIHVwZGF0ZS4gVGhpcyBzaG91bGQgb25seSBiZSBpbnZva2VkIHdoZW4gaXQgaXMga25vd24gd2l0aFxuICAgKiBjZXJ0YWludHkgdGhhdCB3ZSBhcmUgKipub3QqKiBpbiBhIERPTSB0cmFuc2FjdGlvbi5cbiAgICpcbiAgICogWW91IG1heSB3YW50IHRvIGNhbGwgdGhpcyB3aGVuIHlvdSBrbm93IHRoYXQgc29tZSBkZWVwZXIgYXNwZWN0IG9mIHRoZVxuICAgKiBjb21wb25lbnQncyBzdGF0ZSBoYXMgY2hhbmdlZCBidXQgYHNldFN0YXRlYCB3YXMgbm90IGNhbGxlZC5cbiAgICpcbiAgICogVGhpcyB3aWxsIG5vdCBpbnZva2UgYHNob3VsZFVwZGF0ZUNvbXBvbmVudGAsIGJ1dCBpdCB3aWxsIGludm9rZVxuICAgKiBgY29tcG9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5vZGVJRCxcbiAgICAgICAgICBwcm9wS2V5XG4gICAgICAgICk7XG4gICAgICB9XG4gICAgfVxuICAgIGZvciAocHJvcEtleSBpbiBuZXh0UHJvcHMpIHtcbiAgICAgIHZhciBuZXh0UHJvcCA9IG5leHRQcm9wc1twcm9wS2V5XTtcbiAgICAgIHZhciBsYXN0UHJvcCA9IGxhc3RQcm9wc1twcm9wS2V5XTtcbiAgICAgIGlmICghbmV4dFByb3BzLmhhc093blByb3BlcnR5KHByb3BLZXkpIHx8IG5leHRQcm9wID09PSBsYXN0UHJvcCkge1xuICAgICAgICBjb250aW51ZTtcbiAgICAgIH1cbiAgICAgIGlmIChwcm9wS2V5ID09PSBTVFlMRSkge1xuICAgICAgICBpZiAobmV4dFByb3ApIHtcbiAgICAgICAgICBuZXh0UHJvcCA9IG5leHRQcm9wcy5zdHlsZSA9IGFzc2lnbih7fSwgbmV4dFByb3ApO1xuICAgICAgICB9XG4gICAgICAgIGlmIChsYXN0UHJvcCkge1xuICAgICAgICAgIC8vIFVuc2V0IHN0eWxlcyBvbiBgbGFzdFByb3BgIGJ1dCBub3Qgb24gYG5leHRQcm9wYC5cbiAgICAgICAgICBmb3IgKHN0eWxlTmFtZSBpbiBsYXN0UHJvcCkge1xuICAgICAgICAgICAgaWYgKGxhc3RQcm9wLmhhc093blByb3BlcnR5KHN0eWxlTmFtZSkgJiZcbiAgICAgICAgICAgICAgICAoIW5leHRQcm9wIHx8ICFuZXh0UHJvcC5oYXNPd25Qcm9wZXJ0eShzdHlsZU5hbWUpKSkge1xuICAgICAgICAgICAgICBzdHlsZVVwZGF0ZXMgPSBzdHlsZVVwZGF0ZXMgfHwge307XG4gICAgICAgICAgICAgIHN0eWxlVXBkYXRlc1tzdHlsZU5hbWVdID0gJyc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vIFVwZGF0ZSBzdHlsZXMgdGhhdCBjaGFuZ2VkIHNpbmNlIGBsYXN0UHJvcGAuXG4gICA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pbnB1dFtuYW1lPScgKyBKU09OLnN0cmluZ2lmeSgnJyArIG5hbWUpICsgJ11bdHlwZT1cInJhZGlvXCJdJyk7XG5cbiAgICAgIGZvciAodmFyIGkgPSAwLCBncm91cExlbiA9IGdyb3VwLmxlbmd0aDsgaSA8IGdyb3VwTGVuOyBpKyspIHtcbiAgICAgICAgdmFyIG90aGVyTm9kZSA9IGdyb3VwW2ldO1xuICAgICAgICBpZiAob3RoZXJOb2RlID09PSByb290Tm9kZSB8fFxuICAgICAgICAgICAgb3RoZXJOb2RlLmZvcm0gIT09IHJvb3ROb2RlLmZvcm0pIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgb3RoZXJJRCA9IFJlYWN0TW91bnQuZ2V0SUQob3RoZXJOb2RlKTtcbiAgICAgICAgKFwicHJvZHVjdGlvblwiICE9PSBwcm9jZXNzLmVudi5OT0RFX0VOViA/IGludmFyaWFudChcbiAgICAgICAgICBvdGhlcklELFxuICAgICAgICAgICdSZWFjdERPTUlucHV0OiBNaXhpbmcgUmVhY3QgYW5kIG5vbi1SZWFjdCByYWRpbyBpbnB1dHMgd2l0aCB0aGUgJyArXG4gICAgICAgICAgJ3NhbWUgYG5hbWVgIGlzIG5vdCBzdXBwb3J0ZWQuJ1xuICAgICAgICApIDogaW52YXJpYW50KG90aGVySUQpKTtcbiAgICAgICAgdmFyIG90aGVySW5zdGFuY2UgPSBpbnN0YW5jZXNCeVJlYWN0SURbb3RoZXJJRF07XG4gICAgICAgIChcInByb2R1Y3Rpb25cIiAhPT0gcHJvY2Vzcy5lbnYuTk9ERV9FTlYgPyBpbnZhcmlhbnQoXG4gICAgICAgICAgb3RoZXJJbnN0YW5jZSxcbiAgICAgICAgICAnUmVhY3RET01JbnB1dDogVW5rbm93biByYWRpbyBidXR0b24gSUQgJXMuJyxcbiAgICAgICAgICBvdGhlcklEXG4gICAgICAgICkgOiBpbnZhcmlhbnQob3RoZXJJbnN0YW5jZSkpO1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b3JtYW5jZU5vdygpO1xuICAgICAgICBydiA9IGZ1bmMuYXBwbHkodGhpcywgYXJncyk7XG4gICAgICAgIHRvdGFsVGltZSA9IHBlcmZvcm1hbmNlTm93KCkgLSBzdGFydDtcblxuICAgICAgICBpZiAoZm5OYW1lID09PSAnbW91bnRJbWFnZUludG9Ob2RlJykge1xuICAgICAgICAgIHZhciBtb3VudElEID0gUmVhY3RNb3VudC5nZXRJRChhcmdzWzFdKTtcbiAgICAgICAgICBSZWFjdERlZmF1bHRQZXJmLl9yZWNvcmRXcml0ZShtb3VudElELCBmbk5hbWUsIHRvdGFsVGltZSwgYXJnc1swXSk7XG4gICAgICAgIH0gZWxzZSBpZiAoZm5OYW1lID09PSAnZGFuZ2Vyb3VzbHlQcm9jZXNzQ2hpbGRyZW5VcGRhdGVzJykge1xuICAgICAgICAgIC8vIHNwZWNpYWwgZm9ybWF0XG4gICAgICAgICAgYXJnc1swXS5mb3JFYWNoKGZ1bmN0aW9uKHVwZGF0ZSkge1xuICAgICAgICAgICAgdmFyIHdyaXRlQXJncyA9IHt9O1xuICAgICAgICAgICAgaWYgKHVwZGF0ZS5mcm9tSW5kZXggIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgd3JpdGVBcmdzLmZyb21JbmRleCA9IHVwZGF0ZS5mcm9tSW5kZXg7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodXBkYXRlLnRvSW5kZXggIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgd3JpdGVBcmdzLnRvSW5kZXggPSB1cGRhdGUudG9JbmRleDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh1cGRhdGUudGV4dENvbnRlbnQgIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgd3JpdGVBcmdzLnRleHRDb250ZW50ID0gdXBkYXRlLnRleHRDb250ZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHVwZGF0ZS5tYXJrdXBJbmRleCAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICB3cml0ZUFyZ3MubWFya3VwID0gYXJnc1sxXVt1cGRhdGUubWFya3VwSW5kZXhdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgUmVhY3REZWZhdWx0UGVyZi5fcmVjb3JkV3JpdGUoXG4gICAgICAgICAgICAgIHVwZGF0ZS5wYXJlbnRJRCxcbiAgICAgICAgICAgICAgdXBkYXRlLnR5cGUsXG4gICAgICAgICAgICAgIHRvdGFsVGltZSxcbiAgICAgICAgICAgICAgd3JpdGVBcmdzXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIGJhc2ljIGZvcm1hdFxuICAgICAgICAgIFJlYWN0RGVmYXVsdFBlcmYuX3JlY29yZFdyaXRlKFxuICAgICAgICAgICAgYXJnc1swXSxcbiAgICAgICAgICAgIGZuTmFtZSxcbiAgICAgICAgICAgIHRvdGFsVGltZSxcbiAgICAgICAgICAgIEFycmF5LnByb3RvdHlwZS5zbGljZS5jYWxsKGFyZ3MsIDEpXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcnY7XG4gICAgICB9IGVsc2UgaWYgKG1vZHVsZU5hbWUgPT09ICdSZWFjdENvbXBvc2l0ZUNvbXBvbmVudCcgJiYgKFxuICAgICAgICBmbk5hbWUgPT09ICdtb3VudENvbXBvbmVudCcgfHxcbiAgICAgICAgZm5OYW1lID09PSAndXBkYXRlQ29tcG9uZW50JyB8fCAvLyBUT0RPOiByZWNlaXZlQ29tcG9uZW50KCk/XG4gICAgICAgIGZuTmFtZSA9PT0gJ19yZW5kZXJWYWxpZGF0ZWRDb21wb25lbnQnKSkge1xuXG4gICAgICAgIHZhciByb290Tm9kZUlEID0gZm5OYW1lID09PSAnbW91bnRDb21wb25lbnQnID9cbiAgICAgICAgICBhcmdzWzBdIDpcbiAgICAgICAgICB0aGlzLl9yb290Tm9kZUlEO1xuICAgICAgICB2YXIgaX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XRzIHRyYW5zcGxhbnRlZC5cbiAgICAgIHJvb3RFbGVtZW50c0J5UmVhY3RSb290SURbZ2V0UmVhY3RSb290SUQoY29udGFpbmVyKV0gPVxuICAgICAgICBnZXRSZWFjdFJvb3RFbGVtZW50SW5Db250YWluZXIoY29udGFpbmVyKTtcbiAgICB9XG5cbiAgICByZXR1cm4gcHJldkNvbXBvbmVudDtcbiAgfSxcblxuICAvKipcbiAgICogUmVnaXN0ZXIgYSBjb21wb25lbnQgaW50byB0aGUgaW5zdGFuY2UgbWFwIGFuZCBzdGFydHMgc2Nyb2xsIHZhbHVlXG4gICAqIG1vbml0b3JpbmdcbiAgICogQHBhcmFtIHtSZWFjdENvbXBvbmVudH0gbmV4dENvbXBvbmVudCBjb21wb25lbnQgaW5zdGFuY2UgdG8gcmVuZGVyXG4gICAqIEBwYXJhbSB7RE9NRWxlbWVudH0gY29udGFpbmVyIGNvbnRhaW5lciB0byByZW5kZXIgaW50b1xuICAgKiBAcmV0dXJuIHtzdHJpbmd9IHJlYWN0Um9vdCBJRCBwcmVmaXhcbiAgICovXG4gIF9yZWdpc3RlckNvbXBvbmVudDogZnVuY3Rpb24obmV4dENvbXBvbmVudCwgY29udGFpbmVyKSB7XG4gICAgKFwicHJvZHVjdGlvblwiICE9PSBwcm9jZXNzLmVudi5OT0RFX0VOViA/IGludmFyaWFudChcbiAgICAgIGNvbnRhaW5lciAmJiAoXG4gICAgICAgIGNvbnRhaW5lci5ub2RlVHlwZSA9PT0gRUxFTUVOVF9OT0RFX1RZUEUgfHxcbiAgICAgICAgY29udGFpbmVyLm5vZGVUeXBlID09PSBET0NfTk9ERV9UWVBFXG4gICAgICApLFxuICAgICAgJ19yZWdpc3RlckNvbXBvbmVudCguLi4pOiBUYXJnZXQgY29udGFpbmVyIGlzIG5vdCBhIERPTSBlbGVtZW50LidcbiAgICApIDogaW52YXJpYW50KGNvbnRhaW5lciAmJiAoXG4gICAgICBjb250YWluZXIubm9kZVR5cGUgPT09IEVMRU1F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VudCAnICtcbiAgICAgICAgICAnY29waWVzIG9mIFJlYWN0LicgOlxuICAgICAgICAgICcnXG4gICAgICApXG4gICAgKSA6IGludmFyaWFudChSZWFjdEVsZW1lbnQuaXNWYWxpZEVsZW1lbnQobmV4dEVsZW1lbnQpKSk7XG5cbiAgICB2YXIgcHJldkNvbXBvbmVudCA9IGluc3RhbmNlc0J5UmVhY3RSb290SURbZ2V0UmVhY3RSb290SUQoY29udGFpbmVyKV07XG5cbiAgICBpZiAocHJldkNvbXBvbmVudCkge1xuICAgICAgdmFyIHByZXZFbGVtZW50ID0gcHJldkNvbXBvbmVudC5fY3VycmVudEVsZW1lbnQ7XG4gICAgICBpZiAoc2hvdWxkVXBkYXRlUmVhY3RDb21wb25lbnQocHJldkVsZW1lbnQsIG5leHRFbGVtZW50KSkge1xuICAgICAgICByZXR1cm4gUmVhY3RNb3VudC5fdXBkYXRlUm9vdENvbXBvbmVudChcbiAgICAgICAgICBwcmV2Q29tcG9uZW50LFxuICAgICAgICAgIG5leHRFbGVtZW50LFxuICAgICAgICAgIGNvbnRhaW5lcixcbiAgICAgICAgICBjYWxsYmFja1xuICAgICAgICApO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgUmVhY3RNb3VudC51bm1vdW50Q29tcG9uZW50QXROb2RlKGNvbnRhaW5lcik7XG4gICAgICB9XG4gICAgfVxuXG4gICAgdmFyIHJlYWN0Um9vdEVsZW1lbnQgPSBnZXRSZWFjdFJvb3RFbGVtZW50SW5Db250YWluZXIoY29udGFpbmVyKTtcbiAgICB2YXIgY29udGFpbmVySGFzUmVhY3RNYXJrdXAgPVxuICAgICAgcmVhY3RSb290RWxlbWVudCAmJiBSZWFjdE1vdW50LmlzUmVuZGVyZWRCeVJlYWN0KHJlYWN0Um9vdEVsZW1lbnQpO1xuXG4gICAgdmFyIHNob3VsZFJldXNlTWFya3VwID0gY29udGFpbmVySGFzUmVhY3RNYXJrdXAgJiYgIXByZXZDb21wb25lbnQ7XG5cbiAgICB2Y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lckNoaWxkID0gY29udGFpbmVyLmZpcnN0Q2hpbGQ7XG4gICAgICAgIGlmIChjb250YWluZXJDaGlsZCAmJlxuICAgICAgICAgICAgcmVhY3RSb290SUQgPT09IGludGVybmFsR2V0SUQoY29udGFpbmVyQ2hpbGQpKSB7XG4gICAgICAgICAgLy8gSWYgdGhlIGNvbnRhaW5lciBoYXMgYSBuZXcgY2hpbGQgd2l0aCB0aGUgc2FtZSBJRCBhcyB0aGUgb2xkXG4gICAgICAgICAgLy8gcm9vdCBlbGVtZW50LCB0aGVuIHJvb3RFbGVtZW50c0J5UmVhY3RSb290SURbcmVhY3RSb290SURdIGlzXG4gICAgICAgICAgLy8ganVzdCBzdGFsZSBhbmQgbmVlZHMgdG8gYmUgdXBkYXRlZC4gVGhlIGNhc2UgdGhhdCBkZXNlcnZlcyBhXG4gICAgICAgICAgLy8gd2FybmluZyBpcyB3aGVuIHRoZSBjb250YWluZXIgaXMgZW1wdHkuXG4gICAgICAgICAgcm9vdEVsZW1lbnRzQnlSZWFjdFJvb3RJRFtyZWFjdFJvb3RJRF0gPSBjb250YWluZXJDaGlsZDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBjb25zb2xlLndhcm4oXG4gICAgICAgICAgICAnUmVhY3RNb3VudDogUm9vdCBlbGVtZW50IGhhcyBiZWVuIHJlbW92ZWQgZnJvbSBpdHMgb3JpZ2luYWwgJyArXG4gICAgICAgICAgICAnY29udGFpbmVyLiBOZXcgY29udGFpbmVyOicsIHJvb3RFbGVtZW50LnBhcmVudE5vZGVcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIGNvbnRhaW5lcjtcbiAgfSxcblxuICAvKipcbiAgICogRmluZHMgYW4gZWxlbWVudCByZW5kZXJlZCBieSBSZWFjdCB3aXRoIHRoZSBzdXBwbGllZCBJRC5cbiAgICpcbiAgICogQHBhcmFtIHtzdHJpbmd9IGlkIElEIG9mIGEgRE9NIG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BpbnN0YW5jZXMgYXMgdGhleSdyZVxuICAgICAgICAgIC8vIG1vdW50ZWQuXG4gICAgICAgICAgdmFyIGNoaWxkSW5zdGFuY2UgPSBpbnN0YW50aWF0ZVJlYWN0Q29tcG9uZW50KGNoaWxkLCBudWxsKTtcbiAgICAgICAgICBjaGlsZHJlbltuYW1lXSA9IGNoaWxkSW5zdGFuY2U7XG4gICAgICAgICAgLy8gSW5saW5lZCBmb3IgcGVyZm9ybWFuY2UsIHNlZSBgUmVhY3RJbnN0YW5jZUhhbmRsZXMuY3JlYXRlUmVhY3RJRGAuXG4gICAgICAgICAgdmFyIHJvb3RJRCA9IHRoaXMuX3Jvb3ROb2RlSUQgKyBuYW1lO1xuICAgICAgICAgIHZhciBtb3VudEltYWdlID0gY2hpbGRJbnN0YW5jZS5tb3VudENvbXBvbmVudChcbiAgICAgICAgICAgIHJvb3RJRCxcbiAgICAgICAgICAgIHRyYW5zYWN0aW9uLFxuICAgICAgICAgICAgdGhpcy5fbW91bnREZXB0aCArIDFcbiAgICAgICAgICApO1xuICAgICAgICAgIGNoaWxkSW5zdGFuY2UuX21vdW50SW5kZXggPSBpbmRleDtcbiAgICAgICAgICBtb3VudEltYWdlcy5wdXNoKG1vdW50SW1hZ2UpO1xuICAgICAgICAgIGluZGV4Kys7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBtb3VudEltYWdlcztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogUmVwbGFjZXMgYW55IHJlbmRlcmVkIGNoaWxkcmVuIHdpdGggYSB0ZXh0IGNvbnRlbnQgc3RyaW5nLlxuICAgICAqXG4gICAgICogQHBhcmFtIHtzdHJpbmd9IG5leHRDb250ZW50IFN0cmluZyBvZiBjb250ZW50LlxuICAgICAqIEBpbnRlcm5hbFxuICAgICAqL1xuICAgIHVwZGF0ZVRleHRDb250ZW50OiBmdW5jdGlvbihuZXh0Q29udGVudCkge1xuICAgICAgdXBkYXRlRGVwdGgrKztcbiAgIC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NhY3Rpb24pO1xuICAgICAgICAgIHByZXZDaGlsZC5fbW91bnRJbmRleCA9IG5leHRJbmRleDtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBpZiAocHJldkNoaWxkKSB7XG4gICAgICAgICAgICAvLyBVcGRhdGUgYGxhc3RJbmRleGAgYmVmb3JlIGBfbW91bnRJbmRleGAgZ2V0cyB1bnNldCBieSB1bm1vdW50aW5nLlxuICAgICAgICAgICAgbGFzdEluZGV4ID0gTWF0aC5tYXgocHJldkNoaWxkLl9tb3VudEluZGV4LCBsYXN0SW5kZXgpO1xuICAgICAgICAgICAgdGhpcy5fdW5tb3VudENoaWxkQnlOYW1lKHByZXZDaGlsZCwgbmFtZSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIC8vIFRoZSBjaGlsZCBtdXN0IGJlIGluc3RhbnRpYXRlZCBiZWZvcmUgaXQncyBtb3VudGVkLlxuICAgICAgICAgIHZhciBuZXh0Q2hpbGRJbnN0YW5jZSA9IGluc3RhbnRpYXRlUmVhY3RDb21wb25lbnQoXG4gICAgICAgICAgICBuZXh0RWxlbWVudCxcbiAgICAgICAgICAgIG51bGxcbiAgICAgICAgICApO1xuICAgICAgICAgIHRoaXMuX21vdW50Q2hpbGRCeU5hbWVBdEluZGV4KFxuICAgICAgICAgICAgbmV4dENoaWxkSW5zdGFuY2UsIG5hbWUsIG5leHRJbmRleCwgdHJhbnNhY3Rpb25cbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICAgIG5leHRJbmRleCsrO1xuICAgICAgfVxuICAgICAgLy8gUmVtb3ZlIGNoaWxkcmVuIHRoYXQgYXJlIG5vIGxvbmdlciBwcmVzZW50LlxuICAgICAgZm9yIChuYW1lIGluIHByZXZDaGlsZHJlbikge1xuICAgICAgICBpZiAocHJldkNoaWxkcmVuLmhhc093blByb3BlcnR5KG5hbWUpICYmXG4gICAgICAgICAgICAhKG5leHRDaGlsZHJlbiAmJiBuZXh0Q2hpbGRyZW5bbmFtZV0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GlvbiB0aW1lKVxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgICAgICAgICtcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICB8XG4gKiAgICAgICAgICAgICAgICAgICAgKy0tLS0tLS0tLS0tLS0tLS0tfC0tLS0tLS0tfC0tLS0tLS0tLS0tLS0tK1xuICogICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAgIHYgICAgICAgIHwgICAgICAgICAgICAgIHxcbiAqICAgICAgICAgICAgICAgICAgICB8ICAgICAgKy0tLS0tLS0tLS0tLS0tLSsgICB8ICAgICAgICAgICAgICB8XG4gKiAgICAgICAgICAgICAgICAgICAgfCAgICstLXwgICAgd3JhcHBlcjEgICB8LS0tfC0tLS0rICAgICAgICAgfFxuICogICAgICAgICAgICAgICAgICAgIHwgICB8ICArLS0tLS0tLS0tLS0tLS0tKyAgIHYgICAgfCAgICAgICAgIHxcbiAqICAgICAgICAgICAgICAgICAgICB8ICAgfCAgICAgICAgICArLS0tLS0tLS0tLS0tLSsgIHwgICAgICAgICB8XG4gKiAgICAgICAgICAgICAgICAgICAgfCAgIHwgICAgICstLS0tfCAgIHdyYXBwZXIyICB8LS0tLS0tLS0rICAgfFxuICogICAgICAgICAgICAgICAgICAgIHwgICB8ICAgICB8ICAgICstLS0tLS0tLS0tLS0tKyAgfCAgICAgfCAgIHxcbiAqICAgICAgICAgICAgICAgICAgICB8ICAgfCAgICAgfCAgICAgICAgICAgICAgICAgICAgIHwgICAgIHwgICB8XG4gKiAgICAgICAgICAgICAgICAgICAgfCAgIHYgICAgIHYgICAgICAgICAgICAgICAgICAgICB2ICAgICB2ICAgfCB3cmFwcGVyXG4gKiAgICAgICAgICAgICAgICAgICAgfCArLS0tKyArLS0tKyAgICstLS0tLS0tLS0rICAgKy0tLSsgKy0tLSsgfCBpbnZhcmlhbnRzXG4gKiBwZXJmb3JtKGFueU1ldGhvZCkgfCB8ICAgfCB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udHlwZTtcblxuICAgICAgICAgIGlmICh0eXBlID09IExBWllfTUFQX0ZMQUcpIHtcbiAgICAgICAgICAgIHZhbHVlID0gY29tcHV0ZWQ7XG4gICAgICAgICAgfSBlbHNlIGlmICghY29tcHV0ZWQpIHtcbiAgICAgICAgICAgIGlmICh0eXBlID09IExBWllfRklMVEVSX0ZMQUcpIHtcbiAgICAgICAgICAgICAgY29udGludWUgb3V0ZXI7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBicmVhayBvdXRlcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGRyb3BDb3VudCkge1xuICAgICAgICAgIGRyb3BDb3VudC0tO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJlc3VsdFtyZXNJbmRleCsrXSA9IHZhbHVlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH1cblxuICAgIC8qLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKi9cblxuICAgIC8qKlxuICAgICAqIENyZWF0ZXMgYSBjYWNoZSBvYmplY3QgdG8gc3RvcmUga2V5L3ZhbHVlIHBhaXJzLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG5hbWUgQ2FjaGVcbiAgICAgKiBAbWVtYmVyT2YgXy5tZW1vaXplXG4gICAgICovXG4gICAgZnVuY3Rpb24gTWFwQ2FjaGUoKSB7XG4gICAgICB0aGlzLl9fZGF0YV9fID0ge307XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogUmVtb3ZlcyBga2V5YCBhbmQgaXRzIHZhbHVlIGZyb20gdGhlIGNhY2hlLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAbmFtZSBkZWxldGV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PCBwcm9wc0xlbmd0aCkge1xuICAgICAgICB2YXIga2V5ID0gcHJvcHNbaW5kZXhdO1xuICAgICAgICBpZiAoaXNBcnIpIHtcbiAgICAgICAgICBrZXkgPSBwYXJzZUZsb2F0KGtleSk7XG4gICAgICAgICAgcmVzdWx0W2luZGV4XSA9IGlzSW5kZXgoa2V5LCBsZW5ndGgpID8gY29sbGVjdGlvbltrZXldIDogdW5kZWZpbmVkO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHJlc3VsdFtpbmRleF0gPSBjb2xsZWN0aW9uW2tleV07XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ29waWVzIHRoZSBwcm9wZXJ0aWVzIG9mIGBzb3VyY2VgIHRvIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIGZyb20uXG4gICAgICogQHBhcmFtIHtPYmplY3R9IFtvYmplY3Q9e31dIFRoZSBvYmplY3QgdG8gY29weSBwcm9wZXJ0aWVzIHRvLlxuICAgICAqIEBwYXJhbSB7QXJyYXl9IHByb3BzIFRoZSBwcm9wZXJ0eSBuYW1lcyB0byBjb3B5LlxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgYG9iamVjdGAuXG4gICAgICovXG4gICAgZnVuY3Rpb24gYmFzZUNvcHkoc291cmNlLCBvYmplY3QsIHByb3BzKSB7XG4gICAgICBpZiAoIXByb3BzKSB7XG4gICAgICAgIHByb3BzID0gb2JqZWN0O1xuICAgICAgICBvYmplY3QgPSB7fTtcbiAgICAgIH1cbiAgICAgIHZhciBpbmRleCA9IC0xLFxuICAgICAgICAgIGxlbmd0aCA9IHByb3BzLmxlbmd0aDtcblxuICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW5nd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FnID09IGFyZ3NUYWcpIHtcbiAgICAgICAgICBvdGhUYWcgPSBvYmplY3RUYWc7XG4gICAgICAgIH0gZWxzZSBpZiAob3RoVGFnICE9IG9iamVjdFRhZykge1xuICAgICAgICAgIG90aElzQXJyID0gaXNUeXBlZEFycmF5KG90aGVyKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgdmFyIG9iaklzT2JqID0gb2JqVGFnID09IG9iamVjdFRhZyxcbiAgICAgICAgICBvdGhJc09iaiA9IG90aFRhZyA9PSBvYmplY3RUYWcsXG4gICAgICAgICAgaXNTYW1lVGFnID0gb2JqVGFnID09IG90aFRhZztcblxuICAgICAgaWYgKGlzU2FtZVRhZyAmJiAhKG9iaklzQXJyIHx8IG9iaklzT2JqKSkge1xuICAgICAgICByZXR1cm4gZXF1YWxCeVRhZyhvYmplY3QsIG90aGVyLCBvYmpUYWcpO1xuICAgICAgfVxuICAgICAgdmFyIHZhbFdyYXBwZWQgPSBvYmpJc09iaiAmJiBoYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwgJ19fd3JhcHBlZF9fJyksXG4gICAgICAgICAgb3RoV3JhcHBlZCA9IG90aElzT2JqICYmIGhhc093blByb3BlcnR5LmNhbGwob3RoZXIsICdfX3dyYXBwZWRfXycpO1xuXG4gICAgICBpZiAodmFsV3JhcHBlZCB8fCBvdGhXcmFwcGVkKSB7XG4gICAgICAgIHJldHVybiBlcXVhbEZ1bmModmFsV3JhcHBlZCA/IG9iamVjdC52YWx1ZSgpIDogb2JqZWN0LCBvdGhXcmFwcGVkID8gb3RoZXIudmFsdWUoKSA6IG90aGVyLCBjdXN0b21pemVyLCBpc1doZXJlLCBzdGFja0EsIHN0YWNrQik7XG4gICAgICB9XG4gICAgICBpZiAoIWlzU2FtZVRhZykge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICAvLyBBc3N1bWUgY3ljbGljIHZhbHVlcyBhcmUgZXF1YWwuXG4gICAgICAvLyBGb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AgICAgfVxuICAgICAgb3V0ZXI6XG4gICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICB2YXIgdmFsdWUgPSBhcnJheVtpbmRleF0sXG4gICAgICAgICAgICBjb21wdXRlZCA9IGl0ZXJhdGVlID8gaXRlcmF0ZWUodmFsdWUsIGluZGV4LCBhcnJheSkgOiB2YWx1ZTtcblxuICAgICAgICBpZiAoaXNDb21tb24gJiYgdmFsdWUgPT09IHZhbHVlKSB7XG4gICAgICAgICAgdmFyIHNlZW5JbmRleCA9IHNlZW4ubGVuZ3RoO1xuICAgICAgICAgIHdoaWxlIChzZWVuSW5kZXgtLSkge1xuICAgICAgICAgICAgaWYgKHNlZW5bc2VlbkluZGV4XSA9PT0gY29tcHV0ZWQpIHtcbiAgICAgICAgICAgICAgY29udGludWUgb3V0ZXI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChpdGVyYXRlZSkge1xuICAgICAgICAgICAgc2Vlbi5wdXNoKGNvbXB1dGVkKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgcmVzdWx0LnB1c2godmFsdWUpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGluZGV4T2Yoc2VlbiwgY29tcHV0ZWQpIDwgMCkge1xuICAgICAgICAgIGlmIChpdGVyYXRlZSB8fCBpc0xhcmdlKSB7XG4gICAgICAgICAgICBzZWVuLnB1c2goY29tcHV0ZWQpO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXN1bHQucHVzaCh2YWx1ZSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogVGhlIGJhc2UgaW1wbGVtZW50YXRpb24gb2YgYF8udmFsdWVzYCBhbmQgYF8udmFsdWVzSW5gIHdoaWNoIGNyZWF0ZXMgYW5cbiAgICAgKiBhcnJheSBvZiBgb2JqZWN0YCBwcm9wZXJ0eSB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uZ3RoKSB7XG4gICAgICAgIHZhciBhcnJWYWx1ZSA9IGFycmF5W2luZGV4XSxcbiAgICAgICAgICAgIG90aFZhbHVlID0gb3RoZXJbaW5kZXhdO1xuXG4gICAgICAgIHJlc3VsdCA9IHVuZGVmaW5lZDtcbiAgICAgICAgaWYgKGN1c3RvbWl6ZXIpIHtcbiAgICAgICAgICByZXN1bHQgPSBpc1doZXJlXG4gICAgICAgICAgICA/IGN1c3RvbWl6ZXIob3RoVmFsdWUsIGFyclZhbHVlLCBpbmRleClcbiAgICAgICAgICAgIDogY3VzdG9taXplcihhcnJWYWx1ZSwgb3RoVmFsdWUsIGluZGV4KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodHlwZW9mIHJlc3VsdCA9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgIC8vIFJlY3Vyc2l2ZWx5IGNvbXBhcmUgYXJyYXlzIChzdXNjZXB0aWJsZSB0byBjYWxsIHN0YWNrIGxpbWl0cykuXG4gICAgICAgICAgaWYgKGlzV2hlcmUpIHtcbiAgICAgICAgICAgIHZhciBvdGhJbmRleCA9IG90aExlbmd0aDtcbiAgICAgICAgICAgIHdoaWxlIChvdGhJbmRleC0tKSB7XG4gICAgICAgICAgICAgIG90aFZhbHVlID0gb3RoZXJbb3RoSW5kZXhdO1xuICAgICAgICAgICAgICByZXN1bHQgPSAoYXJyVmFsdWUgJiYgYXJyVmFsdWUgPT09IG90aFZhbHVlKSB8fCBlcXVhbEZ1bmMoYXJyVmFsdWUsIG90aFZhbHVlLCBjdXN0b21pemVyLCBpc1doZXJlLCBzdGFja0EsIHN0YWNrQik7XG4gICAgICAgICAgICAgIGlmIChyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXN1bHQgPSAoYXJyVmFsdWUgJiYgYXJyVmFsdWUgPT09IG90aFZhbHVlKSB8fC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N0aW9uIGVxdWFsT2JqZWN0cyhvYmplY3QsIG90aGVyLCBlcXVhbEZ1bmMsIGN1c3RvbWl6ZXIsIGlzV2hlcmUsIHN0YWNrQSwgc3RhY2tCKSB7XG4gICAgICB2YXIgb2JqUHJvcHMgPSBrZXlzKG9iamVjdCksXG4gICAgICAgICAgb2JqTGVuZ3RoID0gb2JqUHJvcHMubGVuZ3RoLFxuICAgICAgICAgIG90aFByb3BzID0ga2V5cyhvdGhlciksXG4gICAgICAgICAgb3RoTGVuZ3RoID0gb3RoUHJvcHMubGVuZ3RoO1xuXG4gICAgICBpZiAob2JqTGVuZ3RoICE9IG90aExlbmd0aCAmJiAhaXNXaGVyZSkge1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG4gICAgICB2YXIgaGFzQ3RvcixcbiAgICAgICAgICBpbmRleCA9IC0xO1xuXG4gICAgICB3aGlsZSAoKytpbmRleCA8IG9iakxlbmd0aCkge1xuICAgICAgICB2YXIga2V5ID0gb2JqUHJvcHNbaW5kZXhdLFxuICAgICAgICAgICAgcmVzdWx0ID0gaGFzT3duUHJvcGVydHkuY2FsbChvdGhlciwga2V5KTtcblxuICAgICAgICBpZiAocmVzdWx0KSB7XG4gICAgICAgICAgdmFyIG9ialZhbHVlID0gb2JqZWN0W2tleV0sXG4gICAgICAgICAgICAgIG90aFZhbHVlID0gb3RoZXJba2V5XTtcblxuICAgICAgICAgIHJlc3VsdCA9IHVuZGVmaW5lZDtcbiAgICAgICAgICBpZiAoY3VzdG9taXplcikge1xuICAgICAgICAgICAgcmVzdWx0ID0gaXNXaGVyZVxuICAgICAgICAgICAgICA/IGN1c3RvbWl6ZXIob3RoVmFsdWUsIG9ialZhbHVlLCBrZXkpXG4gICAgICAgICAgICAgIDogY3VzdG9taXplcihvYmpWYWx1ZSwgb3RoVmFsdWUsIGtleSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0eXBlb2YgcmVzdWx0ID09ICd1bmRlZmluZWQnKSB7X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YgfSxcbiAgICAgKiAgIHsgJ3VzZXInOiAnZnJlZCcsICAgJ2FnZSc6IDQwIH1cbiAgICAgKiBdO1xuICAgICAqXG4gICAgICogLy8gd2l0aG91dCBleHBsaWNpdCBjaGFpbmluZ1xuICAgICAqIF8odXNlcnMpLmZpcnN0KCk7XG4gICAgICogLy8gPT4geyAndXNlcic6ICdiYXJuZXknLCAnYWdlJzogMzYgfVxuICAgICAqXG4gICAgICogLy8gd2l0aCBleHBsaWNpdCBjaGFpbmluZ1xuICAgICAqIF8odXNlcnMpLmNoYWluKClcbiAgICAgKiAgIC5maXJzdCgpXG4gICAgICogICAucGljaygndXNlcicpXG4gICAgICogICAudmFsdWUoKTtcbiAgICAgKiAvLyA9PiB7ICd1c2VyJzogJ2Jhcm5leScgfVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHdyYXBwZXJDaGFpbigpIHtcbiAgICAgIHJldHVybiBjaGFpbih0aGlzKTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBFeGVjdXRlcyB0aGUgY2hhaW5lZCBzZXF1ZW5jZSBhbmQgcmV0dXJucyB0aGUgd3JhcHBlZCByZXN1bHQuXG4gICAgICpcbiAgICAgKiBAbmFtZSBjb21taXRcbiAgICAgKiBAbWVtYmVyT2YgX1xuICAgICAqIEBjYXRlZ29yeSBDaGFpblxuICAgICAqIEByZXR1cm5zIHtPYmplY3R9IFJldHVybnMgdGhlIG5ldyBgbG9kYXNoYCB3cmFwcGVyIGluc3RhbmNlLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiB2YXIgYXJyYXkgPSBbMSwgMl07XG4gICAgICogdmFyIHdyYXBwZXIgPSBfKGFycmF5KS5wdXNoKDMpO1xuICAgICAqXG4gICAgICogY29uc29sZS5sb2coYXJyYXkpO1xuICAgICAqIC8vID0+IFsxLCAyXVxuICAgICAqXG4gICAgICogd3JhcHBlciA9IHdyYXBwZXIuY29tbWl0KCk7XG4gICAgICogY29uc29sZS5sb2coYX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ncyB0by5cbiAgICAgKiBAcGFyYW0ge3N0cmluZ30ga2V5IFRoZSBrZXkgb2YgdGhlIG1ldGhvZC5cbiAgICAgKiBAcGFyYW0gey4uLip9IFthcmdzXSBUaGUgYXJndW1lbnRzIHRvIGJlIHBhcnRpYWxseSBhcHBsaWVkLlxuICAgICAqIEByZXR1cm5zIHtGdW5jdGlvbn0gUmV0dXJucyB0aGUgbmV3IGJvdW5kIGZ1bmN0aW9uLlxuICAgICAqIEBleGFtcGxlXG4gICAgICpcbiAgICAgKiB2YXIgb2JqZWN0ID0ge1xuICAgICAqICAgJ3VzZXInOiAnZnJlZCcsXG4gICAgICogICAnZ3JlZXQnOiBmdW5jdGlvbihncmVldGluZywgcHVuY3R1YXRpb24pIHtcbiAgICAgKiAgICAgcmV0dXJuIGdyZWV0aW5nICsgJyAnICsgdGhpcy51c2VyICsgcHVuY3R1YXRpb247XG4gICAgICogICB9XG4gICAgICogfTtcbiAgICAgKlxuICAgICAqIHZhciBib3VuZCA9IF8uYmluZEtleShvYmplY3QsICdncmVldCcsICdoaScpO1xuICAgICAqIGJvdW5kKCchJyk7XG4gICAgICogLy8gPT4gJ2hpIGZyZWQhJ1xuICAgICAqXG4gICAgICogb2JqZWN0LmdyZWV0ID0gZnVuY3Rpb24oZ3JlZXRpbmcsIHB1bmN0dWF0aW9uKSB7XG4gICAgICogICByZXR1cm4gZ3JlZXRpbmcgKyAneWEgJyArIHRoaXMudXNlciArIHB1bmN0dWF0aW9uO1xuICAgICAqIH07XG4gICAgICpcbiAgICAgKiBib3VuZCgnIScpO1xuICAgICAqIC8vID0+ICdoaXlhIGZyZWQhJ1xuICAgICAqXG4gICAgICogLy8gdXNpbmcgcGxhY2Vob2xkZXJzXG4gICAgICogdmFyIGJvdW5kID0gXy5iaW5kS2V5KG9iamVjdCwgJ2dyZWV0JywgXywgJyEnKTtcbiAgICAgKiBib3VuZCgnaGknKTtcbiAgICAgKiAvLyA9PiAnaGl5YSBmcmVkISdcbiAgICAgKi9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1cblxuICAgICAgZnVuY3Rpb24gZGVsYXllZCgpIHtcbiAgICAgICAgdmFyIHJlbWFpbmluZyA9IHdhaXQgLSAobm93KCkgLSBzdGFtcCk7XG4gICAgICAgIGlmIChyZW1haW5pbmcgPD0gMCB8fCByZW1haW5pbmcgPiB3YWl0KSB7XG4gICAgICAgICAgaWYgKG1heFRpbWVvdXRJZCkge1xuICAgICAgICAgICAgY2xlYXJUaW1lb3V0KG1heFRpbWVvdXRJZCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHZhciBpc0NhbGxlZCA9IHRyYWlsaW5nQ2FsbDtcbiAgICAgICAgICBtYXhUaW1lb3V0SWQgPSB0aW1lb3V0SWQgPSB0cmFpbGluZ0NhbGwgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgaWYgKGlzQ2FsbGVkKSB7XG4gICAgICAgICAgICBsYXN0Q2FsbGVkID0gbm93KCk7XG4gICAgICAgICAgICByZXN1bHQgPSBmdW5jLmFwcGx5KHRoaXNBcmcsIGFyZ3MpO1xuICAgICAgICAgICAgaWYgKCF0aW1lb3V0SWQgJiYgIW1heFRpbWVvdXRJZCkge1xuICAgICAgICAgICAgICBhcmdzID0gdGhpc0FyZyA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRpbWVvdXRJZCA9IHNldFRpbWVvdXQoZGVsYXllZCwgcmVtYWluaW5nKTtcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBtYXhEZWxheWVkKCkge1xuICAgICAgICBpZiAodGltZW91dElkKSB7XG4gICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXRJZCk7XG4gICAgICAgIH1cbiAgICAgICAgbWF4VGltZW91dElkID0gdGltZW91dElkID0gdHJhaWxpbmdDYWxsID0gdW5kZWZpbmVkO1xuICAgICAgICBpZiAodHJhaWxpbmcgfHwgKG1heFdhaXQgIT09IHdhaXQpKSB7XG4gICAgICAgICAgbGFzdENhbGxlZCA9IG5vdygpO1xuICAgICAgICAgIHJlc3VsdCA9IGZ1bmMuYXBwbHkodGhpc0FyZywgYXJncyk7XG4gICAgICAgICAgaWYgKCF0aW1lb3V0SWQgJiYgIW1heFRpbWVvdXRJZCkge1xuICAgICAgICAgICAgYXJncyA9IHRoaXNBcmcgPSBudWxsO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBmdW5jdGlvbiBkZWJvdW5jZWQoKSB7XG4gICAgICAgIGFyZ3MgPSBhcmd1bWVudHM7XG4gICAgICAgIHN0YW1wID0gbm93KCk7XG4gICAgICAgIHRoaXNBcmcgPSB0aGlzO1xuICAgICAgICB0cmFpbGluZ0NhbGwgPSB0cmFpbGluZyAmJiAodGltZW91dElkIHx8ICFsZWFkaW5nKTtcblxuICAgICAgICBpZiAobWF4V2FpdCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICB2YXIgbGVhZGluZ0NhbGwgPSBsZWFkaW5nICYmICF0aW1lb3V0SWQ7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKCFtYXhUaW1lb3V0SWQgJiYgIWxlYWRpbmcpIHtcbiAgICAgICAgICAgIGxhc3RDYWxsZWQgPSBzdGFtcDtcbiAgICAgICAgICB9XG4gICAgICAgICAgdmFyIHJlbWFpbmluZyA9IG1heFdhaXQgLSAoc3RhbXAgLSBsYXN0Q2FsbGVkKSxcbiAgICAgICAgICAgICAgaXNDYWxsZWQgPSByZW1haW5pbmcgPD0gMCB8fCByZW1haW5pbmcgPiBtYXhXYWl0O1xuXG4gICAgICAgICAgaWYgKGlzQ2FsbGVkKSB7XG4gICAgICAgICAgICBpZiAobWF4VGltZW91dElkKSB7XG4gICAgICAgICAgICAgIG1heFRpbWVvdXRJZCA9IGNsZWFyVGltZW91dChtYXhUaW1lb3V0SWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgbGFzdENhbGxlZCA9IHN0YW1wO1xuICAgICAgICAgICAgcmVzdWx0ID0gZnVuYy5hcHBseSh0aGlzQXJnLCBhcmdzKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgZWxzZSBpZiAoIW1heFRpbWVvdXRJZCkge1xuICAgICAgICAgICAgbWF4VGltZW91dElkID0gc2V0VGltZW91dChtYXhEZWxheWVkLCByZW1haW5pbmcpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNDYWxsZWQgJiYgdGltZW91dElkKSB7XG4gICAgICAgICAgdGltZW91dElkID0gY2xlYXJUaW1lb3V0KHRpbWVvdXRJZCk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoIXRpbWVvdXRJZCAmJiB3YWl0ICE9PSBtYXhXYWl0KSB7XG4gICAgICAgICAgdGltZW91dElkID0gc2V0VGltZW91dChkZWxheWVkLCB3YWl0KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAobGVhZGluZ0NhbGwpIHtcbiAgICAgICAgICBpc0NhbGxlZCA9IHRydWU7XG4gICAgICAgICAgcmVzdWx0ID0gZnVuYy5hcHBseSh0aGlzQXJnLCBhcmdzKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNDYWxsZWQgJiYgIXRpbWVvdXRJZCAmJiAhbWF4VGltZW91dElkKSB7XG4gICAgICAgICAgYXJncyA9IHRoaXNBcmcgPSBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICB9XG4gICAgICBkZWJvdW5jZWQuY2FuY2VsID0gY2FuY2VsO1xuICAgICAgcmV0dXJuIGRlYm91bmNlZDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBEZWZlcnMgaW52b2tpbmcgdGhlIGBmdW5jYCB1bnRpbCB0aGUgY3VycmVudCBjYWxsIHN0YWNrIGhhcyBjbGVhcmVkLiBBbnlcbiAgICAgKiBhZGRpdGlvbmFsIGFyZ3VtZW50cyBhcmUgcHJvdmlkZWQgdG8g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HJldHVybnMge0Z1bmN0aW9ufSBSZXR1cm5zIHRoZSBuZXcgZnVuY3Rpb24uXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIGZ1bmN0aW9uIGFkZCh4LCB5KSB7XG4gICAgICogICByZXR1cm4geCArIHk7XG4gICAgICogfVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gc3F1YXJlKG4pIHtcbiAgICAgKiAgIHJldHVybiBuICogbjtcbiAgICAgKiB9XG4gICAgICpcbiAgICAgKiB2YXIgYWRkU3F1YXJlID0gXy5mbG93KGFkZCwgc3F1YXJlKTtcbiAgICAgKiBhZGRTcXVhcmUoMSwgMik7XG4gICAgICogLy8gPT4gOVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIGZsb3coKSB7XG4gICAgICB2YXIgZnVuY3MgPSBhcmd1bWVudHMsXG4gICAgICAgICAgbGVuZ3RoID0gZnVuY3MubGVuZ3RoO1xuXG4gICAgICBpZiAoIWxlbmd0aCkge1xuICAgICAgICByZXR1cm4gZnVuY3Rpb24oKSB7IHJldHVybiBhcmd1bWVudHNbMF07IH07XG4gICAgICB9XG4gICAgICBpZiAoIWFycmF5RXZlcnkoZnVuY3MsIGJhc2VJc0Z1bmN0aW9uKSkge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKEZVTkNfRVJST1JfVEVYVCk7XG4gICAgICB9XG4gICAgICByZXR1cm4gZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBpbmRleCA9IDAsXG4gICAgICAgICAgICByZXN1bHQgPSBmdW5jc1tpbmRleF0uYXBwbHkodGhpcywgYXJndW1lbnRzKTtcblxuICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgIHJlc3VsdCA9IGZ1bmNzW2luZGV4XS5jYWxsKHRoaXMsIHJlc3VsdCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgIH07XG4gICAgfVxuXG4gICAgLy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Y29lcmNlZCB0byBvYmplY3RzLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQGNhdGVnb3J5IE9iamVjdFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBvYmplY3QgVGhlIG9iamVjdCB0byBxdWVyeS5cbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9IFJldHVybnMgdGhlIGFycmF5IG9mIHByb3BlcnR5IHZhbHVlcy5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogZnVuY3Rpb24gRm9vKCkge1xuICAgICAqICAgdGhpcy5hID0gMTtcbiAgICAgKiAgIHRoaXMuYiA9IDI7XG4gICAgICogfVxuICAgICAqXG4gICAgICogRm9vLnByb3RvdHlwZS5jID0gMztcbiAgICAgKlxuICAgICAqIF8udmFsdWVzKG5ldyBGb28pO1xuICAgICAqIC8vID0+IFsxLCAyXSAoaXRlcmF0aW9uIG9yZGVyIGlzIG5vdCBndWFyYW50ZWVkKVxuICAgICAqXG4gICAgICogXy52YWx1ZXMoJ2hpJyk7XG4gICAgICogLy8gPT4gWydoJywgJ2knXVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHZhbHVlcyhvYmplY3QpIHtcbiAgICAgIHJldHVybiBiYXNlVmFsdWVzKG9iamVjdCwga2V5cyhvYmplY3QpKTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGFuIGFycmF5IG9mIHRoZSBvd24gYW5kIGluaGVyaXRlZCBlbnVtZXJhYmxlIHByb3BlcnR5IHZhbHVlc1xuICAgICAqIG9mIGBvYmplY3RgLlxuICAgICAqXG4gICAgICogKipOb3RlOioqIE5vbi1vYmplY3QgdmFsdWVzIGFyZSBjb2VyY2VkIHRvIG9iamVjdHMuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAY2F0ZWdvcnkgT2JqZWN0XG4gICAgICogQHBhcm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mVyIGJldHdlZW4gMCBhbmQgNVxuICAgICAqXG4gICAgICogXy5yYW5kb20oMS4yLCA1LjIpO1xuICAgICAqIC8vID0+IGEgZmxvYXRpbmctcG9pbnQgbnVtYmVyIGJldHdlZW4gMS4yIGFuZCA1LjJcbiAgICAgKi9cbiAgICBmdW5jdGlvbiByYW5kb20obWluLCBtYXgsIGZsb2F0aW5nKSB7XG4gICAgICBpZiAoZmxvYXRpbmcgJiYgaXNJdGVyYXRlZUNhbGwobWluLCBtYXgsIGZsb2F0aW5nKSkge1xuICAgICAgICBtYXggPSBmbG9hdGluZyA9IG51bGw7XG4gICAgICB9XG4gICAgICB2YXIgbm9NaW4gPSBtaW4gPT0gbnVsbCxcbiAgICAgICAgICBub01heCA9IG1heCA9PSBudWxsO1xuXG4gICAgICBpZiAoZmxvYXRpbmcgPT0gbnVsbCkge1xuICAgICAgICBpZiAobm9NYXggJiYgdHlwZW9mIG1pbiA9PSAnYm9vbGVhbicpIHtcbiAgICAgICAgICBmbG9hdGluZyA9IG1pbjtcbiAgICAgICAgICBtaW4gPSAxO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHR5cGVvZiBtYXggPT0gJ2Jvb2xlYW4nKSB7XG4gICAgICAgICAgZmxvYXRpbmcgPSBtYXg7XG4gICAgICAgICAgbm9NYXggPSB0cnVlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAobm9NaW4gJiYgbm9NYXgpIHtcbiAgICAgICAgbWF4ID0gMTtcbiAgICAgICAgbm9NYXggPSBmYWxzZTtcbiAgICAgIH1cbiAgICAgIG1pbiA9ICttaW4gfHwgMDtcbiAgICAgIGlmIChub01heCkge1xuICAgICAgICBtYXggPSBtaW47XG4gICAgICAgIG1pbiA9IDA7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBtYXggPSArbWF4IHx8IDA7XG4gICAgICB9XG4gICAgICBpZiAoZmxvYXRpbmcgfHwgbWluICUgMSB8fCBtYXggJSAxKSB7XG4gICAgIC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2NvcGUgY2hhaW4uXG4gICAgICB2YXIgdmFyaWFibGUgPSBvcHRpb25zLnZhcmlhYmxlO1xuICAgICAgaWYgKCF2YXJpYWJsZSkge1xuICAgICAgICBzb3VyY2UgPSAnd2l0aCAob2JqKSB7XFxuJyArIHNvdXJjZSArICdcXG59XFxuJztcbiAgICAgIH1cbiAgICAgIC8vIENsZWFudXAgY29kZSBieSBzdHJpcHBpbmcgZW1wdHkgc3RyaW5ncy5cbiAgICAgIHNvdXJjZSA9IChpc0V2YWx1YXRpbmcgPyBzb3VyY2UucmVwbGFjZShyZUVtcHR5U3RyaW5nTGVhZGluZywgJycpIDogc291cmNlKVxuICAgICAgICAucmVwbGFjZShyZUVtcHR5U3RyaW5nTWlkZGxlLCAnJDEnKVxuICAgICAgICAucmVwbGFjZShyZUVtcHR5U3RyaW5nVHJhaWxpbmcsICckMTsnKTtcblxuICAgICAgLy8gRnJhbWUgY29kZSBhcyB0aGUgZnVuY3Rpb24gYm9keS5cbiAgICAgIHNvdXJjZSA9ICdmdW5jdGlvbignICsgKHZhcmlhYmxlIHx8ICdvYmonKSArICcpIHtcXG4nICtcbiAgICAgICAgKHZhcmlhYmxlXG4gICAgICAgICAgPyAnJ1xuICAgICAgICAgIDogJ29iaiB8fCAob2JqID0ge30pO1xcbidcbiAgICAgICAgKSArXG4gICAgICAgIFwidmFyIF9fdCwgX19wID0gJydcIiArXG4gICAgICAgIChpc0VzY2FwaW5nXG4gICAgICAgICAgID8gJywgX19lID0gXy5lc2NhcGUnXG4gICAgICAgICAgIDogJydcbiAgICAgICAgKSArXG4gICAgICAgIChpc0V2YWx1YXRpbmdcbiAgICAgICAgICA/ICcsIF9faiA9IEFycmF5LnByb3RvdHlwZS5qb2luO1xcbicgK1xuICAgICAgICAgICAgXCJmdW5jdGlvbiBwcmludCgpIHsgX19wICs9IF9fai5jYWxsKGFyZ3VtZW50cywgJycpIH1cXG5cIlxuICAgICAgICAgIDogJztcXG4nXG4gICAgICAgICkgK1xuICAgIC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ZSddXG4gICAgICovXG4gICAgZnVuY3Rpb24gbWl4aW4ob2JqZWN0LCBzb3VyY2UsIG9wdGlvbnMpIHtcbiAgICAgIGlmIChvcHRpb25zID09IG51bGwpIHtcbiAgICAgICAgdmFyIGlzT2JqID0gaXNPYmplY3Qoc291cmNlKSxcbiAgICAgICAgICAgIHByb3BzID0gaXNPYmogJiYga2V5cyhzb3VyY2UpLFxuICAgICAgICAgICAgbWV0aG9kTmFtZXMgPSBwcm9wcyAmJiBwcm9wcy5sZW5ndGggJiYgYmFzZUZ1bmN0aW9ucyhzb3VyY2UsIHByb3BzKTtcblxuICAgICAgICBpZiAoIShtZXRob2ROYW1lcyA/IG1ldGhvZE5hbWVzLmxlbmd0aCA6IGlzT2JqKSkge1xuICAgICAgICAgIG1ldGhvZE5hbWVzID0gZmFsc2U7XG4gICAgICAgICAgb3B0aW9ucyA9IHNvdXJjZTtcbiAgICAgICAgICBzb3VyY2UgPSBvYmplY3Q7XG4gICAgICAgICAgb2JqZWN0ID0gdGhpcztcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKCFtZXRob2ROYW1lcykge1xuICAgICAgICBtZXRob2ROYW1lcyA9IGJhc2VGdW5jdGlvbnMoc291cmNlLCBrZXlzKHNvdXJjZSkpO1xuICAgICAgfVxuICAgICAgdmFyIGNoYWluID0gdHJ1ZSxcbiAgICAgICAgICBpbmRleCA9IC0xLFxuICAgICAgICAgIGlzRnVuYyA9IGlzRnVuY3Rpb24ob2JqZWN0KSxcbiAgICAgICAgICBsZW5ndGggPSBtZXRob2ROYW1lcy5sZW5ndGg7XG5cbiAgICAgIGlmIChvcHRpb25zID09PSBmYWxzZSkge1xuICAgICAgICBjaGFpbiA9IGZhbHNlO1xuICAgICAgfSBlbHNlIGlmIChpc09iamVjdChvcHRpb25zKSAmJiAnY2hhaW4nIGluIG9wdGlvbnMpIHtcbiAgICAgICAgY2hhaW4gPSBvcHRpb25zLmNoYWluO1xuICAgICAgfVxuICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgdmFyIG1ldGhvZE5hbWUgPSBtZXRob2ROYW1lc1tpbmRleF0sXG4gICAgICAgICAgICBmdW5jID0gc291cmNlW21ldGhvZE5hbWVdO1xuXG4gICAgICAgIG9iamVjdFttZXRob2ROYW1lXSA9IGZ1bmM7XG4gICAgICAgIGlmIChpc0Z1bmMpIHtcbiAgICAgICAgICBvYmplY3QucHJvdG90eXBlW21ldGhvZE5hbWVdID0gKGZ1bmN0aW9uKGZ1bmMpIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgdmFyIGNoYWluQWxsID0gdGhpcy5fX2NoYWluX187XG4gICAgICAgICAgICAgIGlmIChjaGFpbiB8fCBjaGFpbkFsbCkge1xuICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBvYmplY3QodGhpcy5fX3dyYXBwZWRfXyk7XG4gICAgICAgICAgICAgICAgKHJlc3VsdC5fX2FjdGlvbnNfXyA9IGFycmF5Q29weSh0aGlzLl9fYWN0aW9uc19fKSkucHVzaCh7ICdmdW5jJzogZnVuYywgJ2FyZ3MnOiBhcmd1bWVudHMsICd0aGlzQXJnJzogb2JqZWN0IH0pO1xuICAgICAgICAgICAgICAgIHJlc3VsdC5fX2NoYWluX18gPSBjaGFpbkFsbDtcbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHZhciBhcmdzID0gW3RoaXMudmFsdWUoKV07XG4gICAgICAgICAgICAgIHB1c2guYXBwbHkoYXJncywgYXJndW1lbnRzKTtcbiAgICAgICAgICAgICAgcmV0dXJuIGZ1bmMuYXBwbHkob2JqZWN0LCBhcmdzKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgfShmdW5jKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiBvYmplY3Q7XG4gICAgfVxuXG4gICAgLyo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