scratch-www/static/js/lib/react.js

20707 lines
689 KiB
JavaScript
Raw Normal View History

2015-10-14 22:58:32 -04:00
/**
* React (with addons) v0.14.0
*/
2015-09-02 15:08:58 -04:00
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.React = f()}})(function(){var define,module,exports;return (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(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var LinkedStateMixin = _dereq_(22);
var React = _dereq_(26);
var ReactComponentWithPureRenderMixin = _dereq_(37);
var ReactCSSTransitionGroup = _dereq_(29);
var ReactFragment = _dereq_(64);
var ReactTransitionGroup = _dereq_(94);
var ReactUpdates = _dereq_(96);
var cloneWithProps = _dereq_(117);
var shallowCompare = _dereq_(139);
var update = _dereq_(142);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var warnedAboutBatchedUpdates = false;
2015-09-02 15:08:58 -04:00
React.addons = {
CSSTransitionGroup: ReactCSSTransitionGroup,
LinkedStateMixin: LinkedStateMixin,
PureRenderMixin: ReactComponentWithPureRenderMixin,
TransitionGroup: ReactTransitionGroup,
2015-10-14 22:58:32 -04:00
batchedUpdates: function () {
if ("development" !== 'production') {
"development" !== 'production' ? warning(warnedAboutBatchedUpdates, 'React.addons.batchedUpdates is deprecated. Use ' + 'ReactDOM.unstable_batchedUpdates instead.') : undefined;
warnedAboutBatchedUpdates = true;
}
return ReactUpdates.batchedUpdates.apply(this, arguments);
},
2015-09-02 15:08:58 -04:00
cloneWithProps: cloneWithProps,
createFragment: ReactFragment.create,
2015-10-14 22:58:32 -04:00
shallowCompare: shallowCompare,
2015-09-02 15:08:58 -04:00
update: update
};
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
React.addons.Perf = _dereq_(55);
React.addons.TestUtils = _dereq_(91);
2015-09-02 15:08:58 -04:00
}
module.exports = React;
2015-10-14 22:58:32 -04:00
},{"117":117,"139":139,"142":142,"172":172,"22":22,"26":26,"29":29,"37":37,"55":55,"64":64,"91":91,"94":94,"96":96}],2:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule AutoFocusUtils
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactMount = _dereq_(72);
var findDOMNode = _dereq_(121);
var focusNode = _dereq_(154);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var Mixin = {
componentDidMount: function () {
2015-09-02 15:08:58 -04:00
if (this.props.autoFocus) {
2015-10-14 22:58:32 -04:00
focusNode(findDOMNode(this));
2015-09-02 15:08:58 -04:00
}
}
};
2015-10-14 22:58:32 -04:00
var AutoFocusUtils = {
Mixin: Mixin,
focusDOMComponent: function () {
focusNode(ReactMount.getNode(this._rootNodeID));
}
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = AutoFocusUtils;
},{"121":121,"154":154,"72":72}],3:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPropagators = _dereq_(19);
var ExecutionEnvironment = _dereq_(146);
var FallbackCompositionState = _dereq_(20);
var SyntheticCompositionEvent = _dereq_(103);
var SyntheticInputEvent = _dereq_(107);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var keyOf = _dereq_(165);
2015-09-02 15:08:58 -04:00
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
var START_KEYCODE = 229;
2015-10-14 22:58:32 -04:00
var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window;
2015-09-02 15:08:58 -04:00
var documentMode = null;
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
documentMode = document.documentMode;
}
// Webkit offers a very useful `textInput` event that can be used to
// directly represent `beforeInput`. The IE `textinput` event is not as
// useful, so we don't use it.
2015-10-14 22:58:32 -04:00
var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto();
2015-09-02 15:08:58 -04:00
// In IE9+, we have access to composition events, but the data supplied
// by the native compositionend event may be incorrect. Japanese ideographic
// spaces, for instance (\u3000) are not recorded correctly.
2015-10-14 22:58:32 -04:00
var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
2015-09-02 15:08:58 -04:00
/**
* Opera <= 12 includes TextEvent in window, but does not fire
* text input events. Rely on keypress instead.
*/
function isPresto() {
var opera = window.opera;
2015-10-14 22:58:32 -04:00
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
2015-09-02 15:08:58 -04:00
}
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: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onBeforeInput: null }),
captured: keyOf({ onBeforeInputCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste]
2015-09-02 15:08:58 -04:00
},
compositionEnd: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onCompositionEnd: null }),
captured: keyOf({ onCompositionEndCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
2015-09-02 15:08:58 -04:00
},
compositionStart: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onCompositionStart: null }),
captured: keyOf({ onCompositionStartCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
2015-09-02 15:08:58 -04:00
},
compositionUpdate: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onCompositionUpdate: null }),
captured: keyOf({ onCompositionUpdateCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
2015-09-02 15:08:58 -04:00
}
};
// 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) {
2015-10-14 22:58:32 -04:00
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
!(nativeEvent.ctrlKey && nativeEvent.altKey);
2015-09-02 15:08:58 -04:00
}
/**
* 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 isFallbackCompositionStart(topLevelType, nativeEvent) {
2015-10-14 22:58:32 -04:00
return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE;
2015-09-02 15:08:58 -04:00
}
/**
* Does our fallback mode think that this event is the end of composition?
*
* @param {string} topLevelType
* @param {object} nativeEvent
* @return {boolean}
*/
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
switch (topLevelType) {
case topLevelTypes.topKeyUp:
// Command keys insert or clear IME input.
2015-10-14 22:58:32 -04:00
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
2015-09-02 15:08:58 -04:00
case topLevelTypes.topKeyDown:
// Expect IME keyCode on each keydown. If we get any other
// code we must have exited earlier.
2015-10-14 22:58:32 -04:00
return nativeEvent.keyCode !== START_KEYCODE;
2015-09-02 15:08:58 -04:00
case topLevelTypes.topKeyPress:
case topLevelTypes.topMouseDown:
case topLevelTypes.topBlur:
// Events are not possible without cancelling IME.
return true;
default:
return false;
}
}
/**
* Google Input Tools provides composition data via a CustomEvent,
* with the `data` property populated in the `detail` object. If this
* is available on the event object, use it. If not, this is a plain
* composition event and we have nothing special to extract.
*
* @param {object} nativeEvent
* @return {?string}
*/
function getDataFromCustomEvent(nativeEvent) {
var detail = nativeEvent.detail;
if (typeof detail === 'object' && 'data' in detail) {
return detail.data;
}
return null;
}
// Track the current IME composition fallback object, if any.
var currentComposition = 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 {?object} A SyntheticCompositionEvent.
*/
2015-10-14 22:58:32 -04:00
function extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
var eventType;
var fallbackData;
if (canUseCompositionEvent) {
eventType = getCompositionEventType(topLevelType);
} else if (!currentComposition) {
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
eventType = eventTypes.compositionStart;
}
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
eventType = eventTypes.compositionEnd;
}
if (!eventType) {
return null;
}
if (useFallbackCompositionData) {
// The current composition is stored statically and must not be
// overwritten while composition continues.
if (!currentComposition && eventType === eventTypes.compositionStart) {
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
} else if (eventType === eventTypes.compositionEnd) {
if (currentComposition) {
fallbackData = currentComposition.getData();
}
}
}
2015-10-14 22:58:32 -04:00
var event = SyntheticCompositionEvent.getPooled(eventType, topLevelTargetID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
if (fallbackData) {
// Inject data generated from fallback path into the synthetic event.
// This matches the property of native CompositionEventInterface.
event.data = fallbackData;
} else {
var customData = getDataFromCustomEvent(nativeEvent);
if (customData !== null) {
event.data = customData;
}
}
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
/**
* @param {string} topLevelType Record from `EventConstants`.
* @param {object} nativeEvent Native browser event.
* @return {?string} The string corresponding to this `beforeInput` event.
*/
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
switch (topLevelType) {
case topLevelTypes.topCompositionEnd:
return getDataFromCustomEvent(nativeEvent);
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 null;
}
hasSpaceKeypress = true;
return SPACEBAR_CHAR;
case topLevelTypes.topTextInput:
// Record the characters to be added to the DOM.
var 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 null;
}
return chars;
default:
// For other native event types, do nothing.
return null;
}
}
/**
* For browsers that do not provide the `textInput` event, extract the
* appropriate string to use for SyntheticInputEvent.
*
* @param {string} topLevelType Record from `EventConstants`.
* @param {object} nativeEvent Native browser event.
* @return {?string} The fallback string for this `beforeInput` event.
*/
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
// If we are currently composing (IME) and using a fallback to do so,
// try to extract the composed characters from the fallback object.
if (currentComposition) {
2015-10-14 22:58:32 -04:00
if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) {
2015-09-02 15:08:58 -04:00
var chars = currentComposition.getData();
FallbackCompositionState.release(currentComposition);
currentComposition = null;
return chars;
}
return null;
}
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.
return null;
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)) {
return String.fromCharCode(nativeEvent.which);
}
return null;
case topLevelTypes.topCompositionEnd:
return useFallbackCompositionData ? null : nativeEvent.data;
default:
return null;
}
}
/**
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
* `textInput` or fallback behavior.
*
* @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 {?object} A SyntheticInputEvent.
*/
2015-10-14 22:58:32 -04:00
function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
var chars;
if (canUseTextInputEvent) {
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
} else {
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
}
// If no characters are being inserted, no BeforeInput event should
// be fired.
if (!chars) {
return null;
}
2015-10-14 22:58:32 -04:00
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
event.data = chars;
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
/**
* 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.
*
* This plugin is also responsible for emitting `composition` events, thus
* allowing us to share composition fallback code for both `beforeInput` and
* `composition` event types.
*/
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}
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
return [extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget)];
2015-09-02 15:08:58 -04:00
}
};
module.exports = BeforeInputEventPlugin;
2015-10-14 22:58:32 -04:00
},{"103":103,"107":107,"146":146,"15":15,"165":165,"19":19,"20":20}],4:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 = {
2015-10-14 22:58:32 -04:00
animationIterationCount: true,
2015-09-02 15:08:58 -04:00
boxFlex: true,
boxFlexGroup: true,
2015-10-14 22:58:32 -04:00
boxOrdinalGroup: true,
2015-09-02 15:08:58 -04:00
columnCount: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
2015-10-14 22:58:32 -04:00
flexOrder: true,
2015-09-02 15:08:58 -04:00
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
2015-10-14 22:58:32 -04:00
tabSize: true,
2015-09-02 15:08:58 -04:00
widows: true,
zIndex: true,
zoom: true,
// SVG-related properties
fillOpacity: true,
2015-10-14 22:58:32 -04:00
stopOpacity: true,
2015-09-02 15:08:58 -04:00
strokeDashoffset: true,
strokeOpacity: true,
strokeWidth: 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.
2015-10-14 22:58:32 -04:00
Object.keys(isUnitlessNumber).forEach(function (prop) {
prefixes.forEach(function (prefix) {
2015-09-02 15:08:58 -04:00
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: {
2015-10-14 22:58:32 -04:00
backgroundAttachment: true,
backgroundColor: true,
2015-09-02 15:08:58 -04:00
backgroundImage: true,
2015-10-14 22:58:32 -04:00
backgroundPositionX: true,
backgroundPositionY: true,
backgroundRepeat: true
},
backgroundPosition: {
backgroundPositionX: true,
backgroundPositionY: true
2015-09-02 15:08:58 -04:00
},
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
2015-10-14 22:58:32 -04:00
},
outline: {
outlineWidth: true,
outlineStyle: true,
outlineColor: true
2015-09-02 15:08:58 -04:00
}
};
var CSSProperty = {
isUnitlessNumber: isUnitlessNumber,
shorthandPropertyExpansions: shorthandPropertyExpansions
};
module.exports = CSSProperty;
2015-10-14 22:58:32 -04:00
},{}],5:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var CSSProperty = _dereq_(4);
var ExecutionEnvironment = _dereq_(146);
var ReactPerf = _dereq_(78);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var camelizeStyleName = _dereq_(148);
var dangerousStyleValue = _dereq_(118);
var hyphenateStyleName = _dereq_(159);
var memoizeStringOnly = _dereq_(167);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var processStyleName = memoizeStringOnly(function (styleName) {
2015-09-02 15:08:58 -04:00
return hyphenateStyleName(styleName);
});
2015-10-14 22:58:32 -04:00
var hasShorthandPropertyBug = false;
2015-09-02 15:08:58 -04:00
var styleFloatAccessor = 'cssFloat';
if (ExecutionEnvironment.canUseDOM) {
2015-10-14 22:58:32 -04:00
var tempStyle = document.createElement('div').style;
try {
// IE8 throws "Invalid argument." if resetting shorthand style properties.
tempStyle.font = '';
} catch (e) {
hasShorthandPropertyBug = true;
}
2015-09-02 15:08:58 -04:00
// IE8 only supports accessing cssFloat (standard) as styleFloat
if (document.documentElement.style.cssFloat === undefined) {
styleFloatAccessor = 'styleFloat';
}
}
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// 'msTransform' is correct, but the other prefixes should be capitalized
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
// style values shouldn't contain a semicolon
var badStyleValueWithSemicolonPattern = /;\s*$/;
var warnedStyleNames = {};
var warnedStyleValues = {};
2015-10-14 22:58:32 -04:00
var warnHyphenatedStyleName = function (name) {
2015-09-02 15:08:58 -04:00
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Unsupported style property %s. Did you mean %s?', name, camelizeStyleName(name)) : undefined;
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var warnBadVendoredStyleName = function (name) {
2015-09-02 15:08:58 -04:00
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)) : undefined;
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var warnStyleValueWithSemicolon = function (name, value) {
2015-09-02 15:08:58 -04:00
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
return;
}
warnedStyleValues[value] = true;
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon. ' + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')) : undefined;
2015-09-02 15:08:58 -04:00
};
/**
* @param {string} name
* @param {*} value
*/
2015-10-14 22:58:32 -04:00
var warnValidStyle = function (name, value) {
2015-09-02 15:08:58 -04:00
if (name.indexOf('-') > -1) {
warnHyphenatedStyleName(name);
} else if (badVendoredStyleNamePattern.test(name)) {
warnBadVendoredStyleName(name);
} else if (badStyleValueWithSemicolonPattern.test(value)) {
warnStyleValueWithSemicolon(name, value);
}
};
}
/**
* 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}
*/
2015-10-14 22:58:32 -04:00
createMarkupForStyles: function (styles) {
2015-09-02 15:08:58 -04:00
var serialized = '';
for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
var styleValue = styles[styleName];
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
warnValidStyle(styleName, styleValue);
}
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
*/
2015-10-14 22:58:32 -04:00
setValueForStyles: function (node, styles) {
2015-09-02 15:08:58 -04:00
var style = node.style;
for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
warnValidStyle(styleName, styles[styleName]);
}
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
if (styleName === 'float') {
styleName = styleFloatAccessor;
}
if (styleValue) {
style[styleName] = styleValue;
} else {
2015-10-14 22:58:32 -04:00
var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName];
2015-09-02 15:08:58 -04:00
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] = '';
}
}
}
}
};
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(CSSPropertyOperations, 'CSSPropertyOperations', {
setValueForStyles: 'setValueForStyles'
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = CSSPropertyOperations;
},{"118":118,"146":146,"148":148,"159":159,"167":167,"172":172,"4":4,"78":78}],6:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var PooledClass = _dereq_(25);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
enqueue: function (callback, context) {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
notifyAll: function () {
2015-09-02 15:08:58 -04:00
var callbacks = this._callbacks;
var contexts = this._contexts;
if (callbacks) {
2015-10-14 22:58:32 -04:00
!(callbacks.length === contexts.length) ? "development" !== 'production' ? invariant(false, 'Mismatched list of contexts in callback queue') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
this._callbacks = null;
this._contexts = null;
2015-10-14 22:58:32 -04:00
for (var i = 0; i < callbacks.length; i++) {
2015-09-02 15:08:58 -04:00
callbacks[i].call(contexts[i]);
}
callbacks.length = 0;
contexts.length = 0;
}
},
/**
* Resets the internal queue.
*
* @internal
*/
2015-10-14 22:58:32 -04:00
reset: function () {
2015-09-02 15:08:58 -04:00
this._callbacks = null;
this._contexts = null;
},
/**
* `PooledClass` looks for this.
*/
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
this.reset();
}
});
PooledClass.addPoolingTo(CallbackQueue);
module.exports = CallbackQueue;
2015-10-14 22:58:32 -04:00
},{"160":160,"24":24,"25":25}],7:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPluginHub = _dereq_(16);
var EventPropagators = _dereq_(19);
var ExecutionEnvironment = _dereq_(146);
var ReactUpdates = _dereq_(96);
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getEventTarget = _dereq_(127);
var isEventSupported = _dereq_(132);
var isTextInputElement = _dereq_(133);
var keyOf = _dereq_(165);
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
var eventTypes = {
change: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onChange: null }),
captured: keyOf({ onChangeCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
2015-09-02 15:08:58 -04:00
}
};
/**
* For IE shims
*/
var activeElement = null;
var activeElementID = null;
var activeElementValue = null;
var activeElementValueProp = null;
/**
* SECTION: handle `change` event
*/
function shouldUseChangeEvent(elem) {
2015-10-14 22:58:32 -04:00
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
2015-09-02 15:08:58 -04:00
}
var doesChangeEventBubble = false;
if (ExecutionEnvironment.canUseDOM) {
// See `handleChange` comment below
2015-10-14 22:58:32 -04:00
doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
2015-09-02 15:08:58 -04:00
}
function manualDispatchChangeEvent(nativeEvent) {
2015-10-14 22:58:32 -04:00
var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent, getEventTarget(nativeEvent));
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
EventPluginHub.processEventQueue(false);
2015-09-02 15:08:58 -04:00
}
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;
}
2015-10-14 22:58:32 -04:00
function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) {
2015-09-02 15:08:58 -04:00
if (topLevelType === topLevelTypes.topChange) {
return topLevelTargetID;
}
}
2015-10-14 22:58:32 -04:00
function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) {
2015-09-02 15:08:58 -04:00
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
2015-10-14 22:58:32 -04:00
isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9);
2015-09-02 15:08:58 -04:00
}
/**
* (For old IE.) Replacement getter/setter for the `value` property that gets
* set on the active element.
*/
2015-10-14 22:58:32 -04:00
var newValueProp = {
get: function () {
2015-09-02 15:08:58 -04:00
return activeElementValueProp.get.call(this);
},
2015-10-14 22:58:32 -04:00
set: function (val) {
2015-09-02 15:08:58 -04:00
// 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;
2015-10-14 22:58:32 -04:00
activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) {
2015-09-02 15:08:58 -04:00
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}
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID);
2015-09-02 15:08:58 -04:00
if (targetID) {
2015-10-14 22:58:32 -04:00
var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent, nativeEventTarget);
event.type = 'change';
2015-09-02 15:08:58 -04:00
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
}
if (handleEventFunc) {
2015-10-14 22:58:32 -04:00
handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID);
2015-09-02 15:08:58 -04:00
}
}
};
module.exports = ChangeEventPlugin;
2015-10-14 22:58:32 -04:00
},{"105":105,"127":127,"132":132,"133":133,"146":146,"15":15,"16":16,"165":165,"19":19,"96":96}],8:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 = {
2015-10-14 22:58:32 -04:00
createReactRootIndex: function () {
2015-09-02 15:08:58 -04:00
return nextReactRootIndex++;
}
};
module.exports = ClientReactRootIndex;
2015-10-14 22:58:32 -04:00
},{}],9:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var Danger = _dereq_(12);
var ReactMultiChildUpdateTypes = _dereq_(74);
var ReactPerf = _dereq_(78);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var setInnerHTML = _dereq_(137);
var setTextContent = _dereq_(138);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
* 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`.
2015-10-14 22:58:32 -04:00
// fix render order error in safari
// IE8 will throw error when index out of list size.
var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
parentNode.insertBefore(childNode, beforeChild);
2015-09-02 15:08:58 -04:00
}
/**
* Operations for updating with DOM children.
*/
var DOMChildrenOperations = {
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
updateTextContent: setTextContent,
/**
* 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
*/
2015-10-14 22:58:32 -04:00
processUpdates: function (updates, markupList) {
2015-09-02 15:08:58 -04:00
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; i < updates.length; i++) {
update = updates[i];
2015-10-14 22:58:32 -04:00
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
2015-09-02 15:08:58 -04:00
var updatedIndex = update.fromIndex;
var updatedChild = update.parentNode.childNodes[updatedIndex];
var parentID = update.parentID;
2015-10-14 22:58:32 -04:00
!updatedChild ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
2015-09-02 15:08:58 -04:00
initialChildren = initialChildren || {};
initialChildren[parentID] = initialChildren[parentID] || [];
initialChildren[parentID][updatedIndex] = updatedChild;
updatedChildren = updatedChildren || [];
updatedChildren.push(updatedChild);
}
}
2015-10-14 22:58:32 -04:00
var renderedMarkup;
// markupList is either a list of markup or just a list of elements
if (markupList.length && typeof markupList[0] === 'string') {
renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
} else {
renderedMarkup = markupList;
}
2015-09-02 15:08:58 -04:00
// 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; k < updates.length; k++) {
update = updates[k];
switch (update.type) {
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
2015-10-14 22:58:32 -04:00
insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
2015-09-02 15:08:58 -04:00
break;
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
2015-10-14 22:58:32 -04:00
insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
break;
case ReactMultiChildUpdateTypes.SET_MARKUP:
setInnerHTML(update.parentNode, update.content);
2015-09-02 15:08:58 -04:00
break;
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
2015-10-14 22:58:32 -04:00
setTextContent(update.parentNode, update.content);
2015-09-02 15:08:58 -04:00
break;
case ReactMultiChildUpdateTypes.REMOVE_NODE:
// Already removed by the for-loop above.
break;
}
}
}
};
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', {
updateTextContent: 'updateTextContent'
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = DOMChildrenOperations;
},{"12":12,"137":137,"138":138,"160":160,"74":74,"78":78}],10:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
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.
*
2015-10-14 22:58:32 -04:00
* DOMAttributeNamespaces: object mapping React attribute name to the DOM
* attribute namespace URL. (Attribute names not specified use no namespace.)
*
2015-09-02 15:08:58 -04:00
* 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.
*/
2015-10-14 22:58:32 -04:00
injectDOMPropertyConfig: function (domPropertyConfig) {
var Injection = DOMPropertyInjection;
2015-09-02 15:08:58 -04:00
var Properties = domPropertyConfig.Properties || {};
2015-10-14 22:58:32 -04:00
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
2015-09-02 15:08:58 -04:00
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
if (domPropertyConfig.isCustomAttribute) {
2015-10-14 22:58:32 -04:00
DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
2015-09-02 15:08:58 -04:00
}
for (var propName in Properties) {
2015-10-14 22:58:32 -04:00
!!DOMProperty.properties.hasOwnProperty(propName) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
2015-09-02 15:08:58 -04:00
var lowerCased = propName.toLowerCase();
2015-10-14 22:58:32 -04:00
var propConfig = Properties[propName];
var propertyInfo = {
attributeName: lowerCased,
attributeNamespace: null,
propertyName: propName,
mutationMethod: null,
mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE),
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE),
hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
};
!(!propertyInfo.mustUseAttribute || !propertyInfo.mustUseProperty) ? "development" !== 'production' ? invariant(false, 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(false) : undefined;
!(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? "development" !== 'production' ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : undefined;
!(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? "development" !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined;
if ("development" !== 'production') {
DOMProperty.getPossibleStandardName[lowerCased] = propName;
}
2015-09-02 15:08:58 -04:00
if (DOMAttributeNames.hasOwnProperty(propName)) {
var attributeName = DOMAttributeNames[propName];
2015-10-14 22:58:32 -04:00
propertyInfo.attributeName = attributeName;
if ("development" !== 'production') {
DOMProperty.getPossibleStandardName[attributeName] = propName;
}
}
if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (DOMPropertyNames.hasOwnProperty(propName)) {
propertyInfo.propertyName = DOMPropertyNames[propName];
}
2015-09-02 15:08:58 -04:00
if (DOMMutationMethods.hasOwnProperty(propName)) {
2015-10-14 22:58:32 -04:00
propertyInfo.mutationMethod = DOMMutationMethods[propName];
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
DOMProperty.properties[propName] = propertyInfo;
2015-09-02 15:08:58 -04:00
}
}
};
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',
/**
2015-10-14 22:58:32 -04:00
* Map from property "standard name" to an object with info about how to set
* the property in the DOM. Each object contains:
*
* attributeName:
* Used when rendering markup or with `*Attribute()`.
* attributeNamespace
* propertyName:
* Used on DOM node instances. (This includes properties that mutate due to
* external factors.)
* mutationMethod:
* If non-null, used instead of the property or `setAttribute()` after
* initial render.
* mustUseAttribute:
* Whether the property must be accessed and mutated using `*Attribute()`.
* (This includes anything that fails `<propName> in <element>`.)
* mustUseProperty:
* Whether the property must be accessed and mutated as an object property.
* hasSideEffects:
* Whether or not setting a value causes side effects such as triggering
* resources to be loaded or text selection changes. If true, we read from
* the DOM before updating to ensure that the value is only set if it has
* changed.
* hasBooleanValue:
* Whether the property should be removed when set to a falsey value.
* hasNumericValue:
* Whether the property must be numeric or parse as a numeric and should be
* removed when set to a falsey value.
* hasPositiveNumericValue:
* Whether the property must be positive numeric or parse as a positive
* numeric and should be removed when set to a falsey value.
* hasOverloadedBooleanValue:
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
properties: {},
2015-09-02 15:08:58 -04:00
/**
* Mapping from lowercase property names to the properly cased version, used
2015-10-14 22:58:32 -04:00
* to warn in the case of missing properties. Available only in __DEV__.
2015-09-02 15:08:58 -04:00
* @type {Object}
*/
2015-10-14 22:58:32 -04:00
getPossibleStandardName: "development" !== 'production' ? {} : null,
2015-09-02 15:08:58 -04:00
/**
* All of the isCustomAttribute() functions that have been injected.
*/
_isCustomAttributeFunctions: [],
/**
* Checks whether a property name is a custom attribute.
* @method
*/
2015-10-14 22:58:32 -04:00
isCustomAttribute: function (attributeName) {
2015-09-02 15:08:58 -04:00
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?
*/
2015-10-14 22:58:32 -04:00
getDefaultValueForProperty: function (nodeName, prop) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"160":160}],11:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
var ReactPerf = _dereq_(78);
var quoteAttributeValueForBrowser = _dereq_(135);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Simplified subset
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
var illegalAttributeNameCache = {};
var validatedAttributeNameCache = {};
function isAttributeNameSafe(attributeName) {
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
return true;
}
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
return false;
}
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
validatedAttributeNameCache[attributeName] = true;
return true;
}
illegalAttributeNameCache[attributeName] = true;
"development" !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
return false;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function shouldIgnoreValue(propertyInfo, value) {
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
var reactProps = {
children: true,
dangerouslySetInnerHTML: true,
key: true,
ref: true
};
var warnedProperties = {};
2015-10-14 22:58:32 -04:00
var warnUnknownProperty = function (name) {
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
2015-09-02 15:08:58 -04:00
return;
}
warnedProperties[name] = true;
var lowerCasedName = name.toLowerCase();
// data-* attributes should be lowercase; suggest the lowercase version
2015-10-14 22:58:32 -04:00
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
2015-09-02 15:08:58 -04:00
// For now, only warn when we have a suggested correction. This prevents
// logging too much when using transferPropsTo.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
2015-09-02 15:08:58 -04:00
};
}
/**
* Operations for dealing with DOM properties.
*/
var DOMPropertyOperations = {
/**
* Creates markup for the ID property.
*
* @param {string} id Unescaped ID.
* @return {string} Markup string.
*/
2015-10-14 22:58:32 -04:00
createMarkupForID: function (id) {
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
},
setAttributeForID: function (node, id) {
node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
2015-09-02 15:08:58 -04:00
},
/**
* Creates markup for a property.
*
* @param {string} name
* @param {*} value
* @return {?string} Markup string, or null if the property was invalid.
*/
2015-10-14 22:58:32 -04:00
createMarkupForProperty: function (name, value) {
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
if (propertyInfo) {
if (shouldIgnoreValue(propertyInfo, value)) {
2015-09-02 15:08:58 -04:00
return '';
}
2015-10-14 22:58:32 -04:00
var attributeName = propertyInfo.attributeName;
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
return attributeName + '=""';
2015-09-02 15:08:58 -04:00
}
return attributeName + '=' + quoteAttributeValueForBrowser(value);
} else if (DOMProperty.isCustomAttribute(name)) {
if (value == null) {
return '';
}
return name + '=' + quoteAttributeValueForBrowser(value);
2015-10-14 22:58:32 -04:00
} else if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
warnUnknownProperty(name);
}
return null;
},
2015-10-14 22:58:32 -04:00
/**
* Creates markup for a custom property.
*
* @param {string} name
* @param {*} value
* @return {string} Markup string, or empty string if the property was invalid.
*/
createMarkupForCustomAttribute: function (name, value) {
if (!isAttributeNameSafe(name) || value == null) {
return '';
}
return name + '=' + quoteAttributeValueForBrowser(value);
},
2015-09-02 15:08:58 -04:00
/**
* Sets the value for a property on a node.
*
* @param {DOMElement} node
* @param {string} name
* @param {*} value
*/
2015-10-14 22:58:32 -04:00
setValueForProperty: function (node, name, value) {
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
if (propertyInfo) {
var mutationMethod = propertyInfo.mutationMethod;
2015-09-02 15:08:58 -04:00
if (mutationMethod) {
mutationMethod(node, value);
2015-10-14 22:58:32 -04:00
} else if (shouldIgnoreValue(propertyInfo, value)) {
2015-09-02 15:08:58 -04:00
this.deleteValueForProperty(node, name);
2015-10-14 22:58:32 -04:00
} else if (propertyInfo.mustUseAttribute) {
var attributeName = propertyInfo.attributeName;
var namespace = propertyInfo.attributeNamespace;
2015-09-02 15:08:58 -04:00
// `setAttribute` with objects becomes only `[object]` in IE8/9,
// ('' + value) makes it output the correct toString()-value.
2015-10-14 22:58:32 -04:00
if (namespace) {
node.setAttributeNS(namespace, attributeName, '' + value);
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
node.setAttribute(attributeName, '');
} else {
node.setAttribute(attributeName, '' + value);
}
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
var propName = propertyInfo.propertyName;
2015-09-02 15:08:58 -04:00
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
// property type before comparing; only `value` does and is string.
2015-10-14 22:58:32 -04:00
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
2015-09-02 15:08:58 -04:00
// Contrary to `setAttribute`, object properties are properly
// `toString`ed by IE8/9.
node[propName] = value;
}
}
} else if (DOMProperty.isCustomAttribute(name)) {
2015-10-14 22:58:32 -04:00
DOMPropertyOperations.setValueForAttribute(node, name, value);
} else if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
warnUnknownProperty(name);
}
},
2015-10-14 22:58:32 -04:00
setValueForAttribute: function (node, name, value) {
if (!isAttributeNameSafe(name)) {
return;
}
if (value == null) {
node.removeAttribute(name);
} else {
node.setAttribute(name, '' + value);
}
},
2015-09-02 15:08:58 -04:00
/**
* Deletes the value for a property on a node.
*
* @param {DOMElement} node
* @param {string} name
*/
2015-10-14 22:58:32 -04:00
deleteValueForProperty: function (node, name) {
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
if (propertyInfo) {
var mutationMethod = propertyInfo.mutationMethod;
2015-09-02 15:08:58 -04:00
if (mutationMethod) {
mutationMethod(node, undefined);
2015-10-14 22:58:32 -04:00
} else if (propertyInfo.mustUseAttribute) {
node.removeAttribute(propertyInfo.attributeName);
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
var propName = propertyInfo.propertyName;
var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) {
2015-09-02 15:08:58 -04:00
node[propName] = defaultValue;
}
}
} else if (DOMProperty.isCustomAttribute(name)) {
node.removeAttribute(name);
2015-10-14 22:58:32 -04:00
} else if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
warnUnknownProperty(name);
}
}
};
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
setValueForProperty: 'setValueForProperty',
setValueForAttribute: 'setValueForAttribute',
deleteValueForProperty: 'deleteValueForProperty'
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = DOMPropertyOperations;
},{"10":10,"135":135,"172":172,"78":78}],12:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var createNodesFromMarkup = _dereq_(151);
var emptyFunction = _dereq_(152);
var getMarkupWrap = _dereq_(156);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
dangerouslyRenderMarkup: function (markupList) {
!ExecutionEnvironment.canUseDOM ? "development" !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var nodeName;
var markupByNodeName = {};
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
for (var i = 0; i < markupList.length; i++) {
2015-10-14 22:58:32 -04:00
!markupList[i] ? "development" !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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.
var resultIndex;
for (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).
2015-10-14 22:58:32 -04:00
markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP,
// This index will be parsed back out below.
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" ');
2015-09-02 15:08:58 -04:00
}
}
// Render each group of markup with similar wrapping `nodeName`.
2015-10-14 22:58:32 -04:00
var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags.
2015-09-02 15:08:58 -04:00
);
for (var j = 0; j < renderNodes.length; ++j) {
var renderNode = renderNodes[j];
2015-10-14 22:58:32 -04:00
if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
2015-09-02 15:08:58 -04:00
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
renderNode.removeAttribute(RESULT_INDEX_ATTR);
2015-10-14 22:58:32 -04:00
!!resultList.hasOwnProperty(resultIndex) ? "development" !== 'production' ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
resultList[resultIndex] = renderNode;
// This should match resultList.length and markupList.length when
// we're done.
resultListAssignmentCount += 1;
2015-10-14 22:58:32 -04:00
} else if ("development" !== 'production') {
console.error('Danger: Discarding unexpected node:', renderNode);
2015-09-02 15:08:58 -04:00
}
}
}
// Although resultList was populated out of order, it should now be a dense
// array.
2015-10-14 22:58:32 -04:00
!(resultListAssignmentCount === resultList.length) ? "development" !== 'production' ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
!(resultList.length === markupList.length) ? "development" !== 'production' ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
!ExecutionEnvironment.canUseDOM ? "development" !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
!markup ? "development" !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
!(oldChild.tagName.toLowerCase() !== 'html') ? "development" !== 'production' ? invariant(false, '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 ReactDOMServer.renderToString().') : invariant(false) : undefined;
var newChild;
if (typeof markup === 'string') {
newChild = createNodesFromMarkup(markup, emptyFunction)[0];
} else {
newChild = markup;
}
2015-09-02 15:08:58 -04:00
oldChild.parentNode.replaceChild(newChild, oldChild);
}
};
module.exports = Danger;
2015-10-14 22:58:32 -04:00
},{"146":146,"151":151,"152":152,"156":156,"160":160}],13:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var keyOf = _dereq_(165);
2015-09-02 15:08:58 -04:00
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })];
2015-09-02 15:08:58 -04:00
module.exports = DefaultEventPluginOrder;
2015-10-14 22:58:32 -04:00
},{"165":165}],14:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPropagators = _dereq_(19);
var SyntheticMouseEvent = _dereq_(109);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var ReactMount = _dereq_(72);
var keyOf = _dereq_(165);
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
var getFirstReactDOM = ReactMount.getFirstReactDOM;
var eventTypes = {
mouseEnter: {
2015-10-14 22:58:32 -04:00
registrationName: keyOf({ onMouseEnter: null }),
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
2015-09-02 15:08:58 -04:00
},
mouseLeave: {
2015-10-14 22:58:32 -04:00
registrationName: keyOf({ onMouseLeave: null }),
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
2015-09-02 15:08:58 -04:00
}
};
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}
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
2015-09-02 15:08:58 -04:00
return null;
}
2015-10-14 22:58:32 -04:00
if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
2015-09-02 15:08:58 -04:00
// 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;
}
}
2015-10-14 22:58:32 -04:00
var from;
var to;
var fromID = '';
var toID = '';
2015-09-02 15:08:58 -04:00
if (topLevelType === topLevelTypes.topMouseOut) {
from = topLevelTarget;
2015-10-14 22:58:32 -04:00
fromID = topLevelTargetID;
to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement);
if (to) {
toID = ReactMount.getID(to);
} else {
to = win;
}
to = to || win;
2015-09-02 15:08:58 -04:00
} else {
from = win;
to = topLevelTarget;
2015-10-14 22:58:32 -04:00
toID = topLevelTargetID;
2015-09-02 15:08:58 -04:00
}
if (from === to) {
// Nothing pertains to our managed components.
return null;
}
2015-10-14 22:58:32 -04:00
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
leave.type = 'mouseleave';
leave.target = from;
leave.relatedTarget = to;
2015-10-14 22:58:32 -04:00
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"109":109,"15":15,"165":165,"19":19,"72":72}],15:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var keyMirror = _dereq_(164);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var PropagationPhases = keyMirror({ bubbled: null, captured: null });
2015-09-02 15:08:58 -04:00
/**
* Types of raw signals from the browser caught at the top level.
*/
var topLevelTypes = keyMirror({
2015-10-14 22:58:32 -04:00
topAbort: null,
2015-09-02 15:08:58 -04:00
topBlur: null,
2015-10-14 22:58:32 -04:00
topCanPlay: null,
topCanPlayThrough: null,
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
topDurationChange: null,
topEmptied: null,
topEncrypted: null,
topEnded: null,
2015-09-02 15:08:58 -04:00
topError: null,
topFocus: null,
topInput: null,
topKeyDown: null,
topKeyPress: null,
topKeyUp: null,
topLoad: null,
2015-10-14 22:58:32 -04:00
topLoadedData: null,
topLoadedMetadata: null,
topLoadStart: null,
2015-09-02 15:08:58 -04:00
topMouseDown: null,
topMouseMove: null,
topMouseOut: null,
topMouseOver: null,
topMouseUp: null,
topPaste: null,
2015-10-14 22:58:32 -04:00
topPause: null,
topPlay: null,
topPlaying: null,
topProgress: null,
topRateChange: null,
2015-09-02 15:08:58 -04:00
topReset: null,
topScroll: null,
2015-10-14 22:58:32 -04:00
topSeeked: null,
topSeeking: null,
2015-09-02 15:08:58 -04:00
topSelectionChange: null,
2015-10-14 22:58:32 -04:00
topStalled: null,
2015-09-02 15:08:58 -04:00
topSubmit: null,
2015-10-14 22:58:32 -04:00
topSuspend: null,
2015-09-02 15:08:58 -04:00
topTextInput: null,
2015-10-14 22:58:32 -04:00
topTimeUpdate: null,
2015-09-02 15:08:58 -04:00
topTouchCancel: null,
topTouchEnd: null,
topTouchMove: null,
topTouchStart: null,
2015-10-14 22:58:32 -04:00
topVolumeChange: null,
topWaiting: null,
2015-09-02 15:08:58 -04:00
topWheel: null
});
var EventConstants = {
topLevelTypes: topLevelTypes,
PropagationPhases: PropagationPhases
};
module.exports = EventConstants;
2015-10-14 22:58:32 -04:00
},{"164":164}],16:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, Facebook, Inc.
2015-10-14 22:58:32 -04:00
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
* @providesModule EventPluginHub
*/
'use strict';
2015-10-14 22:58:32 -04:00
var EventPluginRegistry = _dereq_(17);
var EventPluginUtils = _dereq_(18);
var ReactErrorUtils = _dereq_(61);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var accumulateInto = _dereq_(115);
var forEachAccumulated = _dereq_(123);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
* 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.
2015-10-14 22:58:32 -04:00
* @param {boolean} simulated If the event is simulated (changes exn behavior)
2015-09-02 15:08:58 -04:00
* @private
*/
2015-10-14 22:58:32 -04:00
var executeDispatchesAndRelease = function (event, simulated) {
2015-09-02 15:08:58 -04:00
if (event) {
2015-10-14 22:58:32 -04:00
EventPluginUtils.executeDispatchesInOrder(event, simulated);
2015-09-02 15:08:58 -04:00
if (!event.isPersistent()) {
event.constructor.release(event);
}
}
};
2015-10-14 22:58:32 -04:00
var executeDispatchesAndReleaseSimulated = function (e) {
return executeDispatchesAndRelease(e, true);
};
var executeDispatchesAndReleaseTopLevel = function (e) {
return executeDispatchesAndRelease(e, false);
};
2015-09-02 15:08:58 -04:00
/**
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
* hierarchy given ids of the logical DOM elements involved.
*/
var InstanceHandle = null;
function validateInstanceHandle() {
2015-10-14 22:58:32 -04:00
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
"development" !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
2015-09-02 15:08:58 -04:00
}
/**
* 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
*/
2015-10-14 22:58:32 -04:00
injectInstanceHandle: function (InjectedInstanceHandle) {
2015-09-02 15:08:58 -04:00
InstanceHandle = InjectedInstanceHandle;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
validateInstanceHandle();
}
},
2015-10-14 22:58:32 -04:00
getInstanceHandle: function () {
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
putListener: function (id, registrationName, listener) {
!(typeof listener === 'function') ? "development" !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
2015-09-02 15:08:58 -04:00
bankForRegistrationName[id] = listener;
2015-10-14 22:58:32 -04:00
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.didPutListener) {
PluginModule.didPutListener(id, registrationName, listener);
}
2015-09-02 15:08:58 -04:00
},
/**
* @param {string} id ID of the DOM element.
* @param {string} registrationName Name of listener (e.g. `onClick`).
* @return {?function} The stored callback.
*/
2015-10-14 22:58:32 -04:00
getListener: function (id, registrationName) {
2015-09-02 15:08:58 -04:00
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`).
*/
2015-10-14 22:58:32 -04:00
deleteListener: function (id, registrationName) {
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
}
2015-09-02 15:08:58 -04:00
var bankForRegistrationName = listenerBank[registrationName];
2015-10-14 22:58:32 -04:00
// TODO: This should never be null -- when is it?
2015-09-02 15:08:58 -04:00
if (bankForRegistrationName) {
delete bankForRegistrationName[id];
}
},
/**
* Deletes all listeners for the DOM element with the supplied ID.
*
* @param {string} id ID of the DOM element.
*/
2015-10-14 22:58:32 -04:00
deleteAllListeners: function (id) {
2015-09-02 15:08:58 -04:00
for (var registrationName in listenerBank) {
2015-10-14 22:58:32 -04:00
if (!listenerBank[registrationName][id]) {
continue;
}
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.willDeleteListener) {
PluginModule.willDeleteListener(id, registrationName);
}
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
var events;
var plugins = EventPluginRegistry.plugins;
2015-10-14 22:58:32 -04:00
for (var i = 0; i < plugins.length; i++) {
2015-09-02 15:08:58 -04:00
// Not every plugin in the ordering may be loaded at runtime.
var possiblePlugin = plugins[i];
if (possiblePlugin) {
2015-10-14 22:58:32 -04:00
var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
enqueueEvents: function (events) {
2015-09-02 15:08:58 -04:00
if (events) {
eventQueue = accumulateInto(eventQueue, events);
}
},
/**
* Dispatches all synthetic events on the event queue.
*
* @internal
*/
2015-10-14 22:58:32 -04:00
processEventQueue: function (simulated) {
2015-09-02 15:08:58 -04:00
// Set `eventQueue` to null before processing it so that we can tell if more
// events get enqueued while processing.
var processingEventQueue = eventQueue;
eventQueue = null;
2015-10-14 22:58:32 -04:00
if (simulated) {
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
} else {
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
}
!!eventQueue ? "development" !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined;
// This would be a good time to rethrow if any of the event handlers threw.
ReactErrorUtils.rethrowCaughtError();
2015-09-02 15:08:58 -04:00
},
/**
* These are needed for tests only. Do not use!
*/
2015-10-14 22:58:32 -04:00
__purge: function () {
2015-09-02 15:08:58 -04:00
listenerBank = {};
},
2015-10-14 22:58:32 -04:00
__getListenerBank: function () {
2015-09-02 15:08:58 -04:00
return listenerBank;
}
};
module.exports = EventPluginHub;
2015-10-14 22:58:32 -04:00
},{"115":115,"123":123,"160":160,"17":17,"172":172,"18":18,"61":61}],17:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
* 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);
2015-10-14 22:58:32 -04:00
!(pluginIndex > -1) ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
2015-10-14 22:58:32 -04:00
!PluginModule.extractEvents ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
var publishedEvents = PluginModule.eventTypes;
for (var eventName in publishedEvents) {
2015-10-14 22:58:32 -04:00
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
/**
* 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) {
2015-10-14 22:58:32 -04:00
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? "development" !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
2015-10-14 22:58:32 -04:00
publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
2015-09-02 15:08:58 -04:00
}
}
return true;
} else if (dispatchConfig.registrationName) {
2015-10-14 22:58:32 -04:00
publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
!!EventPluginRegistry.registrationNameModules[registrationName] ? "development" !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
2015-10-14 22:58:32 -04:00
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
2015-09-02 15:08:58 -04:00
}
/**
* 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}
*/
2015-10-14 22:58:32 -04:00
injectEventPluginOrder: function (InjectedEventPluginOrder) {
!!EventPluginOrder ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
// 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}
*/
2015-10-14 22:58:32 -04:00
injectEventPluginsByName: function (injectedNamesToPlugins) {
2015-09-02 15:08:58 -04:00
var isOrderingDirty = false;
for (var pluginName in injectedNamesToPlugins) {
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
continue;
}
var PluginModule = injectedNamesToPlugins[pluginName];
2015-10-14 22:58:32 -04:00
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
!!namesToPlugins[pluginName] ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
getPluginModuleForEvent: function (event) {
2015-09-02 15:08:58 -04:00
var dispatchConfig = event.dispatchConfig;
if (dispatchConfig.registrationName) {
2015-10-14 22:58:32 -04:00
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
2015-09-02 15:08:58 -04:00
}
for (var phase in dispatchConfig.phasedRegistrationNames) {
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
continue;
}
2015-10-14 22:58:32 -04:00
var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
2015-09-02 15:08:58 -04:00
if (PluginModule) {
return PluginModule;
}
}
return null;
},
/**
* Exposed for unit testing.
* @private
*/
2015-10-14 22:58:32 -04:00
_resetEventPlugins: function () {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"160":160}],18:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var ReactErrorUtils = _dereq_(61);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
* Injected dependencies:
*/
/**
* - `Mount`: [required] Module that can convert between React dom IDs and
* actual node references.
*/
var injection = {
Mount: null,
2015-10-14 22:58:32 -04:00
injectMount: function (InjectedMount) {
2015-09-02 15:08:58 -04:00
injection.Mount = InjectedMount;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
2015-09-02 15:08:58 -04:00
}
}
};
var topLevelTypes = EventConstants.topLevelTypes;
function isEndish(topLevelType) {
2015-10-14 22:58:32 -04:00
return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
2015-09-02 15:08:58 -04:00
}
function isMoveish(topLevelType) {
2015-10-14 22:58:32 -04:00
return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
2015-09-02 15:08:58 -04:00
}
function isStartish(topLevelType) {
2015-10-14 22:58:32 -04:00
return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
2015-09-02 15:08:58 -04:00
}
var validateEventDispatches;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
validateEventDispatches = function (event) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
"development" !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
2015-09-02 15:08:58 -04:00
};
}
/**
2015-10-14 22:58:32 -04:00
* Dispatch the event to the listener.
* @param {SyntheticEvent} event SyntheticEvent to handle
* @param {boolean} simulated If the event is simulated (changes exn behavior)
* @param {function} listener Application-level callback
* @param {string} domID DOM id to pass to the callback.
*/
function executeDispatch(event, simulated, listener, domID) {
var type = event.type || 'unknown-event';
event.currentTarget = injection.Mount.getNode(domID);
if (simulated) {
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID);
} else {
ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID);
}
event.currentTarget = null;
}
/**
* Standard/simple iteration through an event's collected dispatches.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function executeDispatchesInOrder(event, simulated) {
2015-09-02 15:08:58 -04:00
var dispatchListeners = event._dispatchListeners;
var dispatchIDs = event._dispatchIDs;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]);
2015-09-02 15:08:58 -04:00
}
} else if (dispatchListeners) {
2015-10-14 22:58:32 -04:00
executeDispatch(event, simulated, dispatchListeners, dispatchIDs);
2015-09-02 15:08:58 -04:00
}
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.
*
2015-10-14 22:58:32 -04:00
* @return {?string} id of the first dispatch execution who's listener returns
* true, or null if no listener returned true.
2015-09-02 15:08:58 -04:00
*/
function executeDispatchesInOrderStopAtTrueImpl(event) {
var dispatchListeners = event._dispatchListeners;
var dispatchIDs = event._dispatchIDs;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
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.
*
2015-10-14 22:58:32 -04:00
* @return {*} The return value of executing the single dispatch.
2015-09-02 15:08:58 -04:00
*/
function executeDirectDispatch(event) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
validateEventDispatches(event);
}
var dispatchListener = event._dispatchListeners;
var dispatchID = event._dispatchIDs;
2015-10-14 22:58:32 -04:00
!!Array.isArray(dispatchListener) ? "development" !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
2015-09-02 15:08:58 -04:00
event._dispatchListeners = null;
event._dispatchIDs = null;
return res;
}
/**
* @param {SyntheticEvent} event
2015-10-14 22:58:32 -04:00
* @return {boolean} True iff number of dispatches accumulated is greater than 0.
2015-09-02 15:08:58 -04:00
*/
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,
executeDispatchesInOrder: executeDispatchesInOrder,
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
hasDispatches: hasDispatches,
2015-10-14 22:58:32 -04:00
getNode: function (id) {
return injection.Mount.getNode(id);
},
getID: function (node) {
return injection.Mount.getID(node);
},
injection: injection
2015-09-02 15:08:58 -04:00
};
module.exports = EventPluginUtils;
2015-10-14 22:58:32 -04:00
},{"15":15,"160":160,"172":172,"61":61}],19:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPluginHub = _dereq_(16);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var accumulateInto = _dereq_(115);
var forEachAccumulated = _dereq_(123);
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined;
2015-09-02 15:08:58 -04:00
}
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
var listener = listenerAtPhase(domID, event, phase);
if (listener) {
2015-10-14 22:58:32 -04:00
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
2015-09-02 15:08:58 -04:00
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
2015-10-14 22:58:32 -04:00
* each event and perform the traversal for each one. We cannot perform a
2015-09-02 15:08:58 -04:00
* single traversal for the entire collection of events because each event may
* have a different target.
*/
function accumulateTwoPhaseDispatchesSingle(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
2015-10-14 22:58:32 -04:00
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event);
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
/**
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
*/
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event);
}
}
2015-09-02 15:08:58 -04:00
/**
* 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) {
2015-10-14 22:58:32 -04:00
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
2015-09-02 15:08:58 -04:00
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);
}
2015-10-14 22:58:32 -04:00
function accumulateTwoPhaseDispatchesSkipTarget(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter);
}
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
2015-09-02 15:08:58 -04:00
accumulateDirectDispatches: accumulateDirectDispatches,
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
};
module.exports = EventPropagators;
2015-10-14 22:58:32 -04:00
},{"115":115,"123":123,"15":15,"16":16,"172":172}],20:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 FallbackCompositionState
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var PooledClass = _dereq_(25);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var getTextContentAccessor = _dereq_(130);
2015-09-02 15:08:58 -04:00
/**
* This helper class stores information about text content of a target node,
* allowing comparison of content before and after a given event.
*
* Identify the node where selection currently begins, then observe
* both its text content and its current position in the DOM. Since the
* browser may natively replace the target node during composition, we can
* use its position to find its replacement.
*
* @param {DOMEventTarget} root
*/
function FallbackCompositionState(root) {
this._root = root;
this._startText = this.getText();
this._fallbackText = null;
}
assign(FallbackCompositionState.prototype, {
2015-10-14 22:58:32 -04:00
destructor: function () {
this._root = null;
this._startText = null;
this._fallbackText = null;
},
2015-09-02 15:08:58 -04:00
/**
* Get current text of input.
*
* @return {string}
*/
2015-10-14 22:58:32 -04:00
getText: function () {
2015-09-02 15:08:58 -04:00
if ('value' in this._root) {
return this._root.value;
}
return this._root[getTextContentAccessor()];
},
/**
* Determine the differing substring between the initially stored
* text content and the current content.
*
* @return {string}
*/
2015-10-14 22:58:32 -04:00
getData: function () {
2015-09-02 15:08:58 -04:00
if (this._fallbackText) {
return this._fallbackText;
}
var start;
var startValue = this._startText;
var startLength = startValue.length;
var end;
var endValue = this.getText();
var endLength = endValue.length;
for (start = 0; start < startLength; start++) {
if (startValue[start] !== endValue[start]) {
break;
}
}
var minEnd = startLength - start;
for (end = 1; end <= minEnd; end++) {
if (startValue[startLength - end] !== endValue[endLength - end]) {
break;
}
}
var sliceTail = end > 1 ? 1 - end : undefined;
this._fallbackText = endValue.slice(start, sliceTail);
return this._fallbackText;
}
});
PooledClass.addPoolingTo(FallbackCompositionState);
module.exports = FallbackCompositionState;
2015-10-14 22:58:32 -04:00
},{"130":130,"24":24,"25":25}],21:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
2015-09-02 15:08:58 -04:00
var hasSVG;
if (ExecutionEnvironment.canUseDOM) {
var implementation = document.implementation;
2015-10-14 22:58:32 -04:00
hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
2015-09-02 15:08:58 -04:00
}
var HTMLDOMPropertyConfig = {
2015-10-14 22:58:32 -04:00
isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/),
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
// autoFocus is polyfilled/normalized by AutoFocusUtils
2015-09-02 15:08:58 -04:00
// autoFocus: HAS_BOOLEAN_VALUE,
autoPlay: HAS_BOOLEAN_VALUE,
2015-10-14 22:58:32 -04:00
capture: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
2015-09-02 15:08:58 -04:00
cellPadding: null,
cellSpacing: null,
charSet: MUST_USE_ATTRIBUTE,
2015-10-14 22:58:32 -04:00
challenge: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
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,
headers: null,
height: MUST_USE_ATTRIBUTE,
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
high: null,
href: null,
hrefLang: null,
htmlFor: null,
httpEquiv: null,
icon: null,
id: MUST_USE_PROPERTY,
2015-10-14 22:58:32 -04:00
inputMode: MUST_USE_ATTRIBUTE,
is: MUST_USE_ATTRIBUTE,
keyParams: MUST_USE_ATTRIBUTE,
keyType: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
label: null,
lang: null,
list: MUST_USE_ATTRIBUTE,
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
low: null,
manifest: MUST_USE_ATTRIBUTE,
marginHeight: null,
marginWidth: null,
max: null,
maxLength: MUST_USE_ATTRIBUTE,
media: MUST_USE_ATTRIBUTE,
mediaGroup: null,
method: null,
min: null,
2015-10-14 22:58:32 -04:00
minLength: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
name: null,
noValidate: HAS_BOOLEAN_VALUE,
open: HAS_BOOLEAN_VALUE,
optimum: 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,
scoped: HAS_BOOLEAN_VALUE,
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,
2015-10-14 22:58:32 -04:00
summary: null,
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
wrap: null,
/**
* RDFa Properties
*/
about: MUST_USE_ATTRIBUTE,
datatype: MUST_USE_ATTRIBUTE,
inlist: MUST_USE_ATTRIBUTE,
prefix: MUST_USE_ATTRIBUTE,
// property is also supported for OpenGraph in meta tags.
property: MUST_USE_ATTRIBUTE,
resource: MUST_USE_ATTRIBUTE,
'typeof': MUST_USE_ATTRIBUTE,
vocab: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
/**
* Non-standard Properties
*/
// autoCapitalize and autoCorrect are supported in Mobile Safari for
// keyboard hints.
autoCapitalize: null,
autoCorrect: null,
2015-10-14 22:58:32 -04:00
// autoSave allows WebKit/Blink to persist values of input fields on page reloads
autoSave: null,
2015-09-02 15:08:58 -04:00
// itemProp, itemScope, itemType are for
// Microdata support. See http://schema.org/docs/gs.html
itemProp: MUST_USE_ATTRIBUTE,
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
itemType: MUST_USE_ATTRIBUTE,
// itemID and itemRef are for Microdata support as well but
// only specified in the the WHATWG spec document. See
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
itemID: MUST_USE_ATTRIBUTE,
itemRef: MUST_USE_ATTRIBUTE,
2015-10-14 22:58:32 -04:00
// results show looking glass icon and recent searches on input
// search fields in WebKit/Blink
results: null,
// IE-only attribute that specifies security restrictions on an iframe
// as an alternative to the sandbox attribute on IE<10
security: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
// IE-only attribute that controls focus behavior
unselectable: MUST_USE_ATTRIBUTE
},
DOMAttributeNames: {
acceptCharset: 'accept-charset',
className: 'class',
htmlFor: 'for',
httpEquiv: 'http-equiv'
},
DOMPropertyNames: {
autoCapitalize: 'autocapitalize',
autoComplete: 'autocomplete',
autoCorrect: 'autocorrect',
autoFocus: 'autofocus',
autoPlay: 'autoplay',
2015-10-14 22:58:32 -04:00
autoSave: 'autosave',
2015-09-02 15:08:58 -04:00
// `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
// http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
encType: 'encoding',
hrefLang: 'hreflang',
radioGroup: 'radiogroup',
spellCheck: 'spellcheck',
srcDoc: 'srcdoc',
srcSet: 'srcset'
}
};
module.exports = HTMLDOMPropertyConfig;
2015-10-14 22:58:32 -04:00
},{"10":10,"146":146}],22:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactLink = _dereq_(70);
var ReactStateSetters = _dereq_(90);
2015-09-02 15:08:58 -04:00
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
linkState: function (key) {
return new ReactLink(this.state[key], ReactStateSetters.createStateKeySetter(this, key));
2015-09-02 15:08:58 -04:00
}
};
module.exports = LinkedStateMixin;
2015-10-14 22:58:32 -04:00
},{"70":70,"90":90}],23:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactPropTypes = _dereq_(82);
var ReactPropTypeLocations = _dereq_(81);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
var hasReadOnlyValue = {
'button': true,
'checkbox': true,
'image': true,
'hidden': true,
'radio': true,
'reset': true,
'submit': true
};
2015-10-14 22:58:32 -04:00
function _assertSingleLink(inputProps) {
!(inputProps.checkedLink == null || inputProps.valueLink == null) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
function _assertValueLink(inputProps) {
_assertSingleLink(inputProps);
!(inputProps.value == null && inputProps.onChange == null) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
function _assertCheckedLink(inputProps) {
_assertSingleLink(inputProps);
!(inputProps.checked == null && inputProps.onChange == null) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var propTypes = {
value: function (props, propName, componentName) {
if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
return null;
}
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 null;
}
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
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var loggedTypeFailures = {};
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
2015-09-02 15:08:58 -04:00
}
/**
* Provide a linked `value` attribute for controlled forms. You should not use
* this outside of the ReactDOM controlled form components.
*/
var LinkedValueUtils = {
2015-10-14 22:58:32 -04:00
checkPropTypes: function (tagName, props, owner) {
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop);
}
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;
var addendum = getDeclarationErrorAddendum(owner);
"development" !== 'production' ? warning(false, 'Failed form propType: %s%s', error.message, addendum) : undefined;
}
2015-09-02 15:08:58 -04:00
}
},
/**
2015-10-14 22:58:32 -04:00
* @param {object} inputProps Props for form component
2015-09-02 15:08:58 -04:00
* @return {*} current value of the input either from value prop or link.
*/
2015-10-14 22:58:32 -04:00
getValue: function (inputProps) {
if (inputProps.valueLink) {
_assertValueLink(inputProps);
return inputProps.valueLink.value;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return inputProps.value;
2015-09-02 15:08:58 -04:00
},
/**
2015-10-14 22:58:32 -04:00
* @param {object} inputProps Props for form component
2015-09-02 15:08:58 -04:00
* @return {*} current checked status of the input either from checked prop
* or link.
*/
2015-10-14 22:58:32 -04:00
getChecked: function (inputProps) {
if (inputProps.checkedLink) {
_assertCheckedLink(inputProps);
return inputProps.checkedLink.value;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return inputProps.checked;
2015-09-02 15:08:58 -04:00
},
/**
2015-10-14 22:58:32 -04:00
* @param {object} inputProps Props for form component
* @param {SyntheticEvent} event change event to handle
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
executeOnChange: function (inputProps, event) {
if (inputProps.valueLink) {
_assertValueLink(inputProps);
return inputProps.valueLink.requestChange(event.target.value);
} else if (inputProps.checkedLink) {
_assertCheckedLink(inputProps);
return inputProps.checkedLink.requestChange(event.target.checked);
} else if (inputProps.onChange) {
return inputProps.onChange.call(undefined, event);
2015-09-02 15:08:58 -04:00
}
}
};
module.exports = LinkedValueUtils;
2015-10-14 22:58:32 -04:00
},{"160":160,"172":172,"81":81,"82":82}],24:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule Object.assign
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
function assign(target, sources) {
if (target == null) {
throw new TypeError('Object.assign target cannot be null or undefined');
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var to = Object(target);
var hasOwnProperty = Object.prototype.hasOwnProperty;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
var nextSource = arguments[nextIndex];
if (nextSource == null) {
continue;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var from = Object(nextSource);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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.
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
return to;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = assign;
},{}],25:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule PooledClass
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var oneArgumentPooler = function (copyFieldsFrom) {
2015-09-02 15:08:58 -04:00
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, copyFieldsFrom);
return instance;
} else {
return new Klass(copyFieldsFrom);
}
};
2015-10-14 22:58:32 -04:00
var twoArgumentPooler = function (a1, a2) {
2015-09-02 15:08:58 -04:00
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);
}
};
2015-10-14 22:58:32 -04:00
var threeArgumentPooler = function (a1, a2, a3) {
2015-09-02 15:08:58 -04:00
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);
}
};
2015-10-14 22:58:32 -04:00
var fourArgumentPooler = function (a1, a2, a3, a4) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3, a4);
return instance;
} else {
return new Klass(a1, a2, a3, a4);
}
};
var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
2015-09-02 15:08:58 -04:00
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);
}
};
2015-10-14 22:58:32 -04:00
var standardReleaser = function (instance) {
2015-09-02 15:08:58 -04:00
var Klass = this;
2015-10-14 22:58:32 -04:00
!(instance instanceof Klass) ? "development" !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined;
instance.destructor();
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
var addPoolingTo = function (CopyConstructor, pooler) {
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
fourArgumentPooler: fourArgumentPooler,
2015-09-02 15:08:58 -04:00
fiveArgumentPooler: fiveArgumentPooler
};
module.exports = PooledClass;
2015-10-14 22:58:32 -04:00
},{"160":160}],26:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactDOM = _dereq_(40);
var ReactDOMServer = _dereq_(50);
var ReactIsomorphic = _dereq_(69);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var deprecated = _dereq_(119);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// `version` will be added here by ReactIsomorphic.
var React = {};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
assign(React, ReactIsomorphic);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
assign(React, {
// ReactDOM
findDOMNode: deprecated('findDOMNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.findDOMNode),
render: deprecated('render', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.render),
unmountComponentAtNode: deprecated('unmountComponentAtNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.unmountComponentAtNode),
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// ReactDOMServer
renderToString: deprecated('renderToString', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToString),
renderToStaticMarkup: deprecated('renderToStaticMarkup', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToStaticMarkup)
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;
2015-09-02 15:08:58 -04:00
module.exports = React;
2015-10-14 22:58:32 -04:00
},{"119":119,"24":24,"40":40,"50":50,"69":69}],27:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactInstanceMap = _dereq_(68);
var findDOMNode = _dereq_(121);
var warning = _dereq_(172);
var didWarnKey = '_getDOMNodeDidWarn';
2015-09-02 15:08:58 -04:00
var ReactBrowserComponentMixin = {
/**
* Returns the DOM node rendered by this component.
*
* @return {DOMElement} The root node of this component.
* @final
* @protected
*/
2015-10-14 22:58:32 -04:00
getDOMNode: function () {
"development" !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + 'ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined;
this.constructor[didWarnKey] = true;
2015-09-02 15:08:58 -04:00
return findDOMNode(this);
}
};
module.exports = ReactBrowserComponentMixin;
2015-10-14 22:58:32 -04:00
},{"121":121,"172":172,"68":68}],28:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPluginHub = _dereq_(16);
var EventPluginRegistry = _dereq_(17);
var ReactEventEmitterMixin = _dereq_(62);
var ReactPerf = _dereq_(78);
var ViewportMetrics = _dereq_(114);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var isEventSupported = _dereq_(132);
2015-09-02 15:08:58 -04:00
/**
* 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 = {
2015-10-14 22:58:32 -04:00
topAbort: 'abort',
2015-09-02 15:08:58 -04:00
topBlur: 'blur',
2015-10-14 22:58:32 -04:00
topCanPlay: 'canplay',
topCanPlayThrough: 'canplaythrough',
2015-09-02 15:08:58 -04:00
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',
2015-10-14 22:58:32 -04:00
topDurationChange: 'durationchange',
topEmptied: 'emptied',
topEncrypted: 'encrypted',
topEnded: 'ended',
topError: 'error',
2015-09-02 15:08:58 -04:00
topFocus: 'focus',
topInput: 'input',
topKeyDown: 'keydown',
topKeyPress: 'keypress',
topKeyUp: 'keyup',
2015-10-14 22:58:32 -04:00
topLoadedData: 'loadeddata',
topLoadedMetadata: 'loadedmetadata',
topLoadStart: 'loadstart',
2015-09-02 15:08:58 -04:00
topMouseDown: 'mousedown',
topMouseMove: 'mousemove',
topMouseOut: 'mouseout',
topMouseOver: 'mouseover',
topMouseUp: 'mouseup',
topPaste: 'paste',
2015-10-14 22:58:32 -04:00
topPause: 'pause',
topPlay: 'play',
topPlaying: 'playing',
topProgress: 'progress',
topRateChange: 'ratechange',
2015-09-02 15:08:58 -04:00
topScroll: 'scroll',
2015-10-14 22:58:32 -04:00
topSeeked: 'seeked',
topSeeking: 'seeking',
2015-09-02 15:08:58 -04:00
topSelectionChange: 'selectionchange',
2015-10-14 22:58:32 -04:00
topStalled: 'stalled',
topSuspend: 'suspend',
2015-09-02 15:08:58 -04:00
topTextInput: 'textInput',
2015-10-14 22:58:32 -04:00
topTimeUpdate: 'timeupdate',
2015-09-02 15:08:58 -04:00
topTouchCancel: 'touchcancel',
topTouchEnd: 'touchend',
topTouchMove: 'touchmove',
topTouchStart: 'touchstart',
2015-10-14 22:58:32 -04:00
topVolumeChange: 'volumechange',
topWaiting: 'waiting',
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
injectReactEventListener: function (ReactEventListener) {
ReactEventListener.setHandleTopLevel(ReactBrowserEventEmitter.handleTopLevel);
2015-09-02 15:08:58 -04:00
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
}
},
/**
* Sets whether or not any created callbacks should be enabled.
*
* @param {boolean} enabled True if callbacks should be enabled.
*/
2015-10-14 22:58:32 -04:00
setEnabled: function (enabled) {
2015-09-02 15:08:58 -04:00
if (ReactBrowserEventEmitter.ReactEventListener) {
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
}
},
/**
* @return {boolean} True if callbacks are enabled.
*/
2015-10-14 22:58:32 -04:00
isEnabled: function () {
return !!(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled());
2015-09-02 15:08:58 -04:00
},
/**
* 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
*/
2015-10-14 22:58:32 -04:00
listenTo: function (registrationName, contentDocumentHandle) {
2015-09-02 15:08:58 -04:00
var mountAt = contentDocumentHandle;
var isListening = getListeningForDocument(mountAt);
2015-10-14 22:58:32 -04:00
var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName];
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
2015-10-14 22:58:32 -04:00
for (var i = 0; i < dependencies.length; i++) {
2015-09-02 15:08:58 -04:00
var dependency = dependencies[i];
2015-10-14 22:58:32 -04:00
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
2015-09-02 15:08:58 -04:00
if (dependency === topLevelTypes.topWheel) {
if (isEventSupported('wheel')) {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt);
2015-09-02 15:08:58 -04:00
} else if (isEventSupported('mousewheel')) {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt);
2015-09-02 15:08:58 -04:00
} else {
// Firefox needs to capture a different mouse scroll event.
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt);
2015-09-02 15:08:58 -04:00
}
} else if (dependency === topLevelTypes.topScroll) {
if (isEventSupported('scroll', true)) {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt);
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topScroll, 'scroll', ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
} else if (dependency === topLevelTypes.topFocus || dependency === topLevelTypes.topBlur) {
2015-09-02 15:08:58 -04:00
if (isEventSupported('focus', true)) {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt);
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt);
2015-09-02 15:08:58 -04:00
} else if (isEventSupported('focusin')) {
// IE has `focusin` and `focusout` events which bubble.
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt);
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt);
2015-09-02 15:08:58 -04:00
}
// 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)) {
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt);
2015-09-02 15:08:58 -04:00
}
isListening[dependency] = true;
}
}
},
2015-10-14 22:58:32 -04:00
trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelType, handlerBaseName, handle);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelType, handlerBaseName, handle);
2015-09-02 15:08:58 -04:00
},
/**
* 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
*/
2015-10-14 22:58:32 -04:00
ensureScrollValueMonitoring: function () {
2015-09-02 15:08:58 -04:00
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
});
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(ReactBrowserEventEmitter, 'ReactBrowserEventEmitter', {
putListener: 'putListener',
deleteListener: 'deleteListener'
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactBrowserEventEmitter;
},{"114":114,"132":132,"15":15,"16":16,"17":17,"24":24,"62":62,"78":78}],29:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var React = _dereq_(26);
var assign = _dereq_(24);
var ReactTransitionGroup = _dereq_(94);
var ReactCSSTransitionGroupChild = _dereq_(30);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function createTransitionTimeoutPropValidator(transitionType) {
var timeoutPropName = 'transition' + transitionType + 'Timeout';
var enabledPropName = 'transition' + transitionType;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
return function (props) {
// If the transition is enabled
if (props[enabledPropName]) {
// If no timeout duration is provided
if (!props[timeoutPropName]) {
return new Error(timeoutPropName + ' wasn\'t supplied to ReactCSSTransitionGroup: ' + 'this can cause unreliable animations and won\'t be supported in ' + 'a future version of React. See ' + 'https://fb.me/react-animation-transition-group-timeout for more ' + 'information.');
// If the duration isn't a number
} else if (typeof props[timeoutPropName] !== 'number') {
return new Error(timeoutPropName + ' must be a number (in milliseconds)');
}
}
};
}
2015-09-02 15:08:58 -04:00
var ReactCSSTransitionGroup = React.createClass({
displayName: 'ReactCSSTransitionGroup',
propTypes: {
2015-10-14 22:58:32 -04:00
transitionName: ReactCSSTransitionGroupChild.propTypes.name,
2015-09-02 15:08:58 -04:00
transitionAppear: React.PropTypes.bool,
transitionEnter: React.PropTypes.bool,
2015-10-14 22:58:32 -04:00
transitionLeave: React.PropTypes.bool,
transitionAppearTimeout: createTransitionTimeoutPropValidator('Appear'),
transitionEnterTimeout: createTransitionTimeoutPropValidator('Enter'),
transitionLeaveTimeout: createTransitionTimeoutPropValidator('Leave')
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
getDefaultProps: function () {
2015-09-02 15:08:58 -04:00
return {
transitionAppear: false,
transitionEnter: true,
transitionLeave: true
};
},
2015-10-14 22:58:32 -04:00
_wrapChild: function (child) {
2015-09-02 15:08:58 -04:00
// We need to provide this childFactory so that
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
// leave while it is leaving.
2015-10-14 22:58:32 -04:00
return React.createElement(ReactCSSTransitionGroupChild, {
name: this.props.transitionName,
appear: this.props.transitionAppear,
enter: this.props.transitionEnter,
leave: this.props.transitionLeave,
appearTimeout: this.props.transitionAppearTimeout,
enterTimeout: this.props.transitionEnterTimeout,
leaveTimeout: this.props.transitionLeaveTimeout
}, child);
},
render: function () {
return React.createElement(ReactTransitionGroup, assign({}, this.props, { childFactory: this._wrapChild }));
2015-09-02 15:08:58 -04:00
}
});
module.exports = ReactCSSTransitionGroup;
2015-10-14 22:58:32 -04:00
},{"24":24,"26":26,"30":30,"94":94}],30:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var React = _dereq_(26);
var ReactDOM = _dereq_(40);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var CSSCore = _dereq_(144);
var ReactTransitionEvents = _dereq_(93);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var onlyChild = _dereq_(134);
2015-09-02 15:08:58 -04:00
// 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 ReactCSSTransitionGroupChild = React.createClass({
displayName: 'ReactCSSTransitionGroupChild',
2015-10-14 22:58:32 -04:00
propTypes: {
name: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.shape({
enter: React.PropTypes.string,
leave: React.PropTypes.string,
active: React.PropTypes.string
}), React.PropTypes.shape({
enter: React.PropTypes.string,
enterActive: React.PropTypes.string,
leave: React.PropTypes.string,
leaveActive: React.PropTypes.string,
appear: React.PropTypes.string,
appearActive: React.PropTypes.string
})]).isRequired,
// Once we require timeouts to be specified, we can remove the
// boolean flags (appear etc.) and just accept a number
// or a bool for the timeout flags (appearTimeout etc.)
appear: React.PropTypes.bool,
enter: React.PropTypes.bool,
leave: React.PropTypes.bool,
appearTimeout: React.PropTypes.number,
enterTimeout: React.PropTypes.number,
leaveTimeout: React.PropTypes.number
},
transition: function (animationType, finishCallback, userSpecifiedDelay) {
var node = ReactDOM.findDOMNode(this);
if (!node) {
if (finishCallback) {
finishCallback();
}
return;
}
var className = this.props.name[animationType] || this.props.name + '-' + animationType;
var activeClassName = this.props.name[animationType + 'Active'] || className + '-active';
var timeout = null;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var endListener = function (e) {
2015-09-02 15:08:58 -04:00
if (e && e.target !== node) {
return;
}
2015-10-14 22:58:32 -04:00
clearTimeout(timeout);
2015-09-02 15:08:58 -04:00
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.
if (finishCallback) {
finishCallback();
}
};
CSSCore.addClass(node, className);
// Need to do this to actually trigger a transition.
this.queueClass(activeClassName);
2015-10-14 22:58:32 -04:00
// If the user specified a timeout delay.
if (userSpecifiedDelay) {
// Clean-up the animation after the specified delay
timeout = setTimeout(endListener, userSpecifiedDelay);
} else {
// DEPRECATED: this listener will be removed in a future version of react
ReactTransitionEvents.addEndEventListener(node, endListener);
2015-09-02 15:08:58 -04:00
}
},
2015-10-14 22:58:32 -04:00
queueClass: function (className) {
2015-09-02 15:08:58 -04:00
this.classNameQueue.push(className);
if (!this.timeout) {
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
}
},
2015-10-14 22:58:32 -04:00
flushClassNameQueue: function () {
2015-09-02 15:08:58 -04:00
if (this.isMounted()) {
2015-10-14 22:58:32 -04:00
this.classNameQueue.forEach(CSSCore.addClass.bind(CSSCore, ReactDOM.findDOMNode(this)));
2015-09-02 15:08:58 -04:00
}
this.classNameQueue.length = 0;
this.timeout = null;
},
2015-10-14 22:58:32 -04:00
componentWillMount: function () {
2015-09-02 15:08:58 -04:00
this.classNameQueue = [];
},
2015-10-14 22:58:32 -04:00
componentWillUnmount: function () {
2015-09-02 15:08:58 -04:00
if (this.timeout) {
clearTimeout(this.timeout);
}
},
2015-10-14 22:58:32 -04:00
componentWillAppear: function (done) {
2015-09-02 15:08:58 -04:00
if (this.props.appear) {
2015-10-14 22:58:32 -04:00
this.transition('appear', done, this.props.appearTimeout);
2015-09-02 15:08:58 -04:00
} else {
done();
}
},
2015-10-14 22:58:32 -04:00
componentWillEnter: function (done) {
2015-09-02 15:08:58 -04:00
if (this.props.enter) {
2015-10-14 22:58:32 -04:00
this.transition('enter', done, this.props.enterTimeout);
2015-09-02 15:08:58 -04:00
} else {
done();
}
},
2015-10-14 22:58:32 -04:00
componentWillLeave: function (done) {
2015-09-02 15:08:58 -04:00
if (this.props.leave) {
2015-10-14 22:58:32 -04:00
this.transition('leave', done, this.props.leaveTimeout);
2015-09-02 15:08:58 -04:00
} else {
done();
}
},
2015-10-14 22:58:32 -04:00
render: function () {
2015-09-02 15:08:58 -04:00
return onlyChild(this.props.children);
}
});
module.exports = ReactCSSTransitionGroupChild;
2015-10-14 22:58:32 -04:00
},{"134":134,"144":144,"26":26,"40":40,"93":93}],31:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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 ReactChildReconciler
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactReconciler = _dereq_(84);
var instantiateReactComponent = _dereq_(131);
var shouldUpdateReactComponent = _dereq_(140);
var traverseAllChildren = _dereq_(141);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function instantiateChild(childInstances, child, name) {
// We found a component instance.
var keyUnique = childInstances[name] === undefined;
if ("development" !== 'production') {
"development" !== 'production' ? 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) : undefined;
}
if (child != null && keyUnique) {
childInstances[name] = instantiateReactComponent(child, null);
}
}
2015-09-02 15:08:58 -04:00
/**
* ReactChildReconciler provides helpers for initializing or updating a set of
* children. Its output is suitable for passing it onto ReactMultiChild which
* does diffed reordering and insertion.
*/
var ReactChildReconciler = {
/**
* 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} nestedChildNodes Nested child maps.
* @return {?object} A set of child instances.
* @internal
*/
2015-10-14 22:58:32 -04:00
instantiateChildren: function (nestedChildNodes, transaction, context) {
if (nestedChildNodes == null) {
return null;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var childInstances = {};
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
return childInstances;
2015-09-02 15:08:58 -04:00
},
/**
* Updates the rendered children and returns a new set of children.
*
* @param {?object} prevChildren Previously initialized set of children.
2015-10-14 22:58:32 -04:00
* @param {?object} nextChildren Flat child element maps.
2015-09-02 15:08:58 -04:00
* @param {ReactReconcileTransaction} transaction
* @param {object} context
* @return {?object} A new set of child instances.
* @internal
*/
2015-10-14 22:58:32 -04:00
updateChildren: function (prevChildren, nextChildren, transaction, context) {
2015-09-02 15:08:58 -04:00
// We currently don't have a way to track moves here but if we use iterators
// instead of for..in we can zip the iterators and check if an item has
// moved.
// TODO: If nothing has changed, return the prevChildren object so that we
// can quickly bailout if nothing has changed.
if (!nextChildren && !prevChildren) {
return null;
}
var name;
for (name in nextChildren) {
if (!nextChildren.hasOwnProperty(name)) {
continue;
}
var prevChild = prevChildren && prevChildren[name];
var prevElement = prevChild && prevChild._currentElement;
var nextElement = nextChildren[name];
2015-10-14 22:58:32 -04:00
if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
2015-09-02 15:08:58 -04:00
nextChildren[name] = prevChild;
} else {
if (prevChild) {
ReactReconciler.unmountComponent(prevChild, name);
}
// The child must be instantiated before it's mounted.
2015-10-14 22:58:32 -04:00
var nextChildInstance = instantiateReactComponent(nextElement, null);
2015-09-02 15:08:58 -04:00
nextChildren[name] = nextChildInstance;
}
}
// Unmount children that are no longer present.
for (name in prevChildren) {
2015-10-14 22:58:32 -04:00
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
2015-09-02 15:08:58 -04:00
ReactReconciler.unmountComponent(prevChildren[name]);
}
}
return nextChildren;
},
/**
* Unmounts all rendered children. This should be used to clean up children
* when this component is unmounted.
*
* @param {?object} renderedChildren Previously initialized set of children.
* @internal
*/
2015-10-14 22:58:32 -04:00
unmountChildren: function (renderedChildren) {
2015-09-02 15:08:58 -04:00
for (var name in renderedChildren) {
2015-10-14 22:58:32 -04:00
if (renderedChildren.hasOwnProperty(name)) {
var renderedChild = renderedChildren[name];
ReactReconciler.unmountComponent(renderedChild);
}
2015-09-02 15:08:58 -04:00
}
}
};
module.exports = ReactChildReconciler;
2015-10-14 22:58:32 -04:00
},{"131":131,"140":140,"141":141,"172":172,"84":84}],32:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var PooledClass = _dereq_(25);
var ReactElement = _dereq_(57);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyFunction = _dereq_(152);
var traverseAllChildren = _dereq_(141);
2015-09-02 15:08:58 -04:00
var twoArgumentPooler = PooledClass.twoArgumentPooler;
2015-10-14 22:58:32 -04:00
var fourArgumentPooler = PooledClass.fourArgumentPooler;
var userProvidedKeyEscapeRegex = /\/(?!\/)/g;
function escapeUserProvidedKey(text) {
return ('' + text).replace(userProvidedKeyEscapeRegex, '//');
}
2015-09-02 15:08:58 -04:00
/**
* 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) {
2015-10-14 22:58:32 -04:00
this.func = forEachFunction;
this.context = forEachContext;
this.count = 0;
}
ForEachBookKeeping.prototype.destructor = function () {
this.func = null;
this.context = null;
this.count = 0;
};
2015-09-02 15:08:58 -04:00
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
2015-10-14 22:58:32 -04:00
function forEachSingleChild(bookKeeping, child, name) {
var func = bookKeeping.func;
var context = bookKeeping.context;
func.call(context, child, bookKeeping.count++);
2015-09-02 15:08:58 -04:00
}
/**
* 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.
2015-10-14 22:58:32 -04:00
* @param {function(*, int)} forEachFunc
2015-09-02 15:08:58 -04:00
* @param {*} forEachContext Context for forEachContext.
*/
function forEachChildren(children, forEachFunc, forEachContext) {
if (children == null) {
return children;
}
2015-10-14 22:58:32 -04:00
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
this.result = mapResult;
this.keyPrefix = keyPrefix;
this.func = mapFunction;
this.context = mapContext;
this.count = 0;
}
MapBookKeeping.prototype.destructor = function () {
this.result = null;
this.keyPrefix = null;
this.func = null;
this.context = null;
this.count = 0;
};
PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
var result = bookKeeping.result;
var keyPrefix = bookKeeping.keyPrefix;
var func = bookKeeping.func;
var context = bookKeeping.context;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var mappedChild = func.call(context, child, bookKeeping.count++);
if (Array.isArray(mappedChild)) {
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
} else if (mappedChild != null) {
if (ReactElement.isValidElement(mappedChild)) {
mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
// Keep both the (mapped) and old keys if they differ, just as
// traverseAllChildren used to do for objects as children
keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey);
}
result.push(mappedChild);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
var escapedPrefix = '';
if (prefix != null) {
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
MapBookKeeping.release(traverseContext);
2015-09-02 15:08:58 -04:00
}
/**
* Maps children that are typically specified as `props.children`.
*
* The provided mapFunction(child, key, index) will be called for each
* leaf child.
*
* @param {?*} children Children tree container.
2015-10-14 22:58:32 -04:00
* @param {function(*, int)} func The map function.
* @param {*} context Context for mapFunction.
2015-09-02 15:08:58 -04:00
* @return {object} Object containing the ordered map of results.
*/
function mapChildren(children, func, context) {
if (children == null) {
return children;
}
2015-10-14 22:58:32 -04:00
var result = [];
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
return result;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
function forEachSingleChildDummy(traverseContext, child, name) {
2015-09-02 15:08:58 -04:00
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);
}
2015-10-14 22:58:32 -04:00
/**
* Flatten a children object (typically specified as `props.children`) and
* return an array with appropriately re-keyed children.
*/
function toArray(children) {
var result = [];
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
return result;
}
2015-09-02 15:08:58 -04:00
var ReactChildren = {
forEach: forEachChildren,
map: mapChildren,
2015-10-14 22:58:32 -04:00
mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
count: countChildren,
toArray: toArray
2015-09-02 15:08:58 -04:00
};
module.exports = ReactChildren;
2015-10-14 22:58:32 -04:00
},{"141":141,"152":152,"25":25,"57":57}],33:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ReactClass
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactComponent = _dereq_(34);
var ReactElement = _dereq_(57);
var ReactPropTypeLocations = _dereq_(81);
var ReactPropTypeLocationNames = _dereq_(80);
var ReactNoopUpdateQueue = _dereq_(76);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyObject = _dereq_(153);
var invariant = _dereq_(160);
var keyMirror = _dereq_(164);
var keyOf = _dereq_(165);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var MIXINS_KEY = keyOf({ mixins: null });
2015-09-02 15:08:58 -04:00
/**
* Policies that describe methods in `ReactClassInterface`.
*/
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 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 = [];
2015-10-14 22:58:32 -04:00
var warnedSetProps = false;
function warnSetProps() {
if (!warnedSetProps) {
warnedSetProps = true;
"development" !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
}
}
2015-09-02 15:08:58 -04:00
/**
* Composite components are higher-level components that compose other composite
* or native components.
*
* To create a new type of `ReactClass`, 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 `ReactClassInterface` for
* more the comprehensive protocol. Any other properties and methods in the
2015-10-14 22:58:32 -04:00
* class specification will be available on the prototype.
2015-09-02 15:08:58 -04:00
*
* @interface ReactClassInterface
* @internal
*/
var ReactClassInterface = {
/**
* 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 = {
2015-10-14 22:58:32 -04:00
displayName: function (Constructor, displayName) {
2015-09-02 15:08:58 -04:00
Constructor.displayName = displayName;
},
2015-10-14 22:58:32 -04:00
mixins: function (Constructor, mixins) {
2015-09-02 15:08:58 -04:00
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
mixSpecIntoComponent(Constructor, mixins[i]);
}
}
},
2015-10-14 22:58:32 -04:00
childContextTypes: function (Constructor, childContextTypes) {
if ("development" !== 'production') {
validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
},
contextTypes: function (Constructor, contextTypes) {
if ("development" !== 'production') {
validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
2015-09-02 15:08:58 -04:00
},
/**
* Special case getDefaultProps which should move into statics but requires
* automatic merging.
*/
2015-10-14 22:58:32 -04:00
getDefaultProps: function (Constructor, getDefaultProps) {
2015-09-02 15:08:58 -04:00
if (Constructor.getDefaultProps) {
2015-10-14 22:58:32 -04:00
Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
2015-09-02 15:08:58 -04:00
} else {
Constructor.getDefaultProps = getDefaultProps;
}
},
2015-10-14 22:58:32 -04:00
propTypes: function (Constructor, propTypes) {
if ("development" !== 'production') {
validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
statics: function (Constructor, statics) {
2015-09-02 15:08:58 -04:00
mixStaticSpecIntoComponent(Constructor, statics);
2015-10-14 22:58:32 -04:00
},
autobind: function () {} };
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// noop
2015-09-02 15:08:58 -04:00
function validateTypeDef(Constructor, typeDef, location) {
for (var propName in typeDef) {
if (typeDef.hasOwnProperty(propName)) {
// use a warning instead of an invariant so components
// don't show up in prod but not in __DEV__
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
function validateMethodOverride(proto, name) {
2015-10-14 22:58:32 -04:00
var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
2015-09-02 15:08:58 -04:00
// Disallow overriding of base class methods unless explicitly allowed.
if (ReactClassMixin.hasOwnProperty(name)) {
2015-10-14 22:58:32 -04:00
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? "development" !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
// Disallow defining methods more than once unless explicitly allowed.
if (proto.hasOwnProperty(name)) {
2015-10-14 22:58:32 -04:00
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? "development" !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
}
/**
* Mixin helper which handles policy validation and reserved
* specification keys when building React classses.
*/
function mixSpecIntoComponent(Constructor, spec) {
if (!spec) {
return;
}
2015-10-14 22:58:32 -04:00
!(typeof spec !== 'function') ? "development" !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
!!ReactElement.isValidElement(spec) ? "development" !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
// We have already handled mixins in a special case above.
2015-09-02 15:08:58 -04:00
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 ReactClass methods (in the "interface").
// 2. Overridden methods (that were mixed in).
2015-10-14 22:58:32 -04:00
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
2015-09-02 15:08:58 -04:00
var isAlreadyDefined = proto.hasOwnProperty(name);
var isFunction = typeof property === 'function';
2015-10-14 22:58:32 -04:00
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
2015-09-02 15:08:58 -04:00
if (shouldAutoBind) {
if (!proto.__reactAutoBindMap) {
proto.__reactAutoBindMap = {};
}
proto.__reactAutoBindMap[name] = property;
proto[name] = property;
} else {
if (isAlreadyDefined) {
var specPolicy = ReactClassInterface[name];
2015-10-14 22:58:32 -04:00
// These cases should already be caught by validateMethodOverride.
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? "development" !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
// 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;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// 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;
}
2015-10-14 22:58:32 -04:00
var isReserved = (name in RESERVED_SPEC_KEYS);
!!isReserved ? "development" !== 'production' ? invariant(false, 'ReactClass: 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(false) : undefined;
var isInherited = (name in Constructor);
!!isInherited ? "development" !== 'production' ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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 mergeIntoWithNoDuplicateKeys(one, two) {
2015-10-14 22:58:32 -04:00
!(one && two && typeof one === 'object' && typeof two === 'object') ? "development" !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
for (var key in two) {
if (two.hasOwnProperty(key)) {
2015-10-14 22:58:32 -04:00
!(one[key] === undefined) ? "development" !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + '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(false) : undefined;
2015-09-02 15:08:58 -04:00
one[key] = two[key];
}
}
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;
}
var c = {};
mergeIntoWithNoDuplicateKeys(c, a);
mergeIntoWithNoDuplicateKeys(c, b);
return c;
};
}
/**
* 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);
};
}
/**
* Binds a method to the component.
*
* @param {object} component Component whose method is going to be bound.
* @param {function} method Method to be bound.
* @return {function} The bound method.
*/
function bindAutoBindMethod(component, method) {
var boundMethod = method.bind(component);
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
boundMethod.__reactBoundContext = component;
boundMethod.__reactBoundMethod = method;
boundMethod.__reactBoundArguments = null;
var componentName = component.constructor.displayName;
var _bind = boundMethod.bind;
/* eslint-disable block-scoped-var, no-undef */
2015-10-14 22:58:32 -04:00
boundMethod.bind = function (newThis) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
2015-09-02 15:08:58 -04:00
// 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) {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
2015-09-02 15:08:58 -04:00
} else if (!args.length) {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, '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 %s', componentName) : undefined;
2015-09-02 15:08:58 -04:00
return boundMethod;
}
var reboundMethod = _bind.apply(boundMethod, arguments);
reboundMethod.__reactBoundContext = component;
reboundMethod.__reactBoundMethod = method;
reboundMethod.__reactBoundArguments = args;
return reboundMethod;
/* eslint-enable */
};
}
return boundMethod;
}
/**
* Binds all auto-bound methods in a component.
*
* @param {object} component Component whose method is going to be bound.
*/
function bindAutoBindMethods(component) {
for (var autoBindKey in component.__reactAutoBindMap) {
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
var method = component.__reactAutoBindMap[autoBindKey];
2015-10-14 22:58:32 -04:00
component[autoBindKey] = bindAutoBindMethod(component, method);
2015-09-02 15:08:58 -04:00
}
}
}
/**
* Add more to the ReactClass base class. These are all legacy features and
* therefore not already part of the modern ReactComponent.
*/
var ReactClassMixin = {
/**
* TODO: This will be deprecated because state should always keep a consistent
* type signature and the only use case for this, is to avoid that.
*/
2015-10-14 22:58:32 -04:00
replaceState: function (newState, callback) {
this.updater.enqueueReplaceState(this, newState);
2015-09-02 15:08:58 -04:00
if (callback) {
2015-10-14 22:58:32 -04:00
this.updater.enqueueCallback(this, callback);
2015-09-02 15:08:58 -04:00
}
},
/**
* Checks whether or not this composite component is mounted.
* @return {boolean} True if mounted, false otherwise.
* @protected
* @final
*/
2015-10-14 22:58:32 -04:00
isMounted: function () {
return this.updater.isMounted(this);
2015-09-02 15:08:58 -04:00
},
/**
* Sets a subset of the props.
*
* @param {object} partialProps Subset of the next props.
* @param {?function} callback Called after props are updated.
* @final
* @public
* @deprecated
*/
2015-10-14 22:58:32 -04:00
setProps: function (partialProps, callback) {
if ("development" !== 'production') {
warnSetProps();
}
this.updater.enqueueSetProps(this, partialProps);
2015-09-02 15:08:58 -04:00
if (callback) {
2015-10-14 22:58:32 -04:00
this.updater.enqueueCallback(this, callback);
2015-09-02 15:08:58 -04:00
}
},
/**
* Replace all the props.
*
* @param {object} newProps Subset of the next props.
* @param {?function} callback Called after props are updated.
* @final
* @public
* @deprecated
*/
2015-10-14 22:58:32 -04:00
replaceProps: function (newProps, callback) {
if ("development" !== 'production') {
warnSetProps();
}
this.updater.enqueueReplaceProps(this, newProps);
2015-09-02 15:08:58 -04:00
if (callback) {
2015-10-14 22:58:32 -04:00
this.updater.enqueueCallback(this, callback);
2015-09-02 15:08:58 -04:00
}
}
};
2015-10-14 22:58:32 -04:00
var ReactClassComponent = function () {};
assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
2015-09-02 15:08:58 -04:00
/**
* Module for creating composite components.
*
* @class ReactClass
*/
var ReactClass = {
/**
* Creates a composite component class given a class specification.
*
* @param {object} spec Class specification (which must define `render`).
* @return {function} Component constructor function.
* @public
*/
2015-10-14 22:58:32 -04:00
createClass: function (spec) {
var Constructor = function (props, context, updater) {
2015-09-02 15:08:58 -04:00
// This constructor is overridden by mocks. The argument is used
// by mocks to assert on what gets mounted.
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
2015-09-02 15:08:58 -04:00
}
// Wire up auto-binding
if (this.__reactAutoBindMap) {
bindAutoBindMethods(this);
}
this.props = props;
this.context = context;
2015-10-14 22:58:32 -04:00
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
2015-09-02 15:08:58 -04:00
this.state = null;
// ReactClasses doesn't have constructors. Instead, they use the
// getInitialState and componentWillMount methods for initialization.
var initialState = this.getInitialState ? this.getInitialState() : null;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// We allow auto-mocks to proceed as if they're returning null.
2015-10-14 22:58:32 -04:00
if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
2015-09-02 15:08:58 -04:00
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
initialState = null;
}
}
2015-10-14 22:58:32 -04:00
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? "development" !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
this.state = initialState;
};
Constructor.prototype = new ReactClassComponent();
Constructor.prototype.constructor = Constructor;
2015-10-14 22:58:32 -04:00
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
2015-09-02 15:08:58 -04:00
mixSpecIntoComponent(Constructor, spec);
2015-10-14 22:58:32 -04:00
// Initialize the defaultProps property after all mixins have been merged.
2015-09-02 15:08:58 -04:00
if (Constructor.getDefaultProps) {
Constructor.defaultProps = Constructor.getDefaultProps();
}
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// This is a tag to indicate that the use of these method names is ok,
// since it's used with createClass. If it's not, then it's likely a
// mistake so we'll warn you to use the static property, property
// initializer or constructor respectively.
if (Constructor.getDefaultProps) {
Constructor.getDefaultProps.isReactClassApproved = {};
}
if (Constructor.prototype.getInitialState) {
Constructor.prototype.getInitialState.isReactClassApproved = {};
}
}
2015-10-14 22:58:32 -04:00
!Constructor.prototype.render ? "development" !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s 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.', spec.displayName || 'A component') : undefined;
"development" !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
2015-09-02 15:08:58 -04:00
}
// Reduce time spent doing lookups by setting these on the prototype.
for (var methodName in ReactClassInterface) {
if (!Constructor.prototype[methodName]) {
Constructor.prototype[methodName] = null;
}
}
return Constructor;
},
injection: {
2015-10-14 22:58:32 -04:00
injectMixin: function (mixin) {
2015-09-02 15:08:58 -04:00
injectedMixins.push(mixin);
}
}
};
module.exports = ReactClass;
2015-10-14 22:58:32 -04:00
},{"153":153,"160":160,"164":164,"165":165,"172":172,"24":24,"34":34,"57":57,"76":76,"80":80,"81":81}],34:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactNoopUpdateQueue = _dereq_(76);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyObject = _dereq_(153);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
* Base class helpers for the updating state of a component.
*/
2015-10-14 22:58:32 -04:00
function ReactComponent(props, context, updater) {
2015-09-02 15:08:58 -04:00
this.props = props;
this.context = context;
2015-10-14 22:58:32 -04:00
this.refs = emptyObject;
// We initialize the default updater but the real one gets injected by the
// renderer.
this.updater = updater || ReactNoopUpdateQueue;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
ReactComponent.prototype.isReactComponent = {};
2015-09-02 15:08:58 -04:00
/**
* Sets a subset of the state. Always use this 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.
*
* When a function is provided to setState, it will be called at some point in
* the future (not synchronously). It will be called with the up to date
* component arguments (state, props, context). These values can be different
* from this.* because your function may be called after receiveProps but before
* shouldComponentUpdate, and this new state, props, and context will not yet be
* assigned to this.
*
* @param {object|function} partialState Next partial state or function to
* produce next partial state to be merged with current state.
* @param {?function} callback Called after state is updated.
* @final
* @protected
*/
2015-10-14 22:58:32 -04:00
ReactComponent.prototype.setState = function (partialState, callback) {
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? "development" !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : undefined;
if ("development" !== 'production') {
"development" !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined;
}
this.updater.enqueueSetState(this, partialState);
2015-09-02 15:08:58 -04:00
if (callback) {
2015-10-14 22:58:32 -04:00
this.updater.enqueueCallback(this, callback);
2015-09-02 15:08:58 -04:00
}
};
/**
* 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 `shouldComponentUpdate`, but it will invoke
* `componentWillUpdate` and `componentDidUpdate`.
*
* @param {?function} callback Called after update is complete.
* @final
* @protected
*/
2015-10-14 22:58:32 -04:00
ReactComponent.prototype.forceUpdate = function (callback) {
this.updater.enqueueForceUpdate(this);
2015-09-02 15:08:58 -04:00
if (callback) {
2015-10-14 22:58:32 -04:00
this.updater.enqueueCallback(this, callback);
2015-09-02 15:08:58 -04:00
}
};
/**
* Deprecated APIs. These APIs used to exist on classic React classes but since
* we would like to deprecate them, we're not going to move them over to this
* modern base class. Instead, we define a getter that warns if it's accessed.
*/
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
var deprecatedAPIs = {
2015-10-14 22:58:32 -04:00
getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'],
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
replaceProps: ['replaceProps', 'Instead, call render again at the top level.'],
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
setProps: ['setProps', 'Instead, call render again at the top level.']
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var defineDeprecationWarning = function (methodName, info) {
2015-09-02 15:08:58 -04:00
try {
Object.defineProperty(ReactComponent.prototype, methodName, {
2015-10-14 22:58:32 -04:00
get: function () {
"development" !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : undefined;
2015-09-02 15:08:58 -04:00
return undefined;
}
});
} catch (x) {
// IE will fail on defineProperty (es5-shim/sham too)
}
};
for (var fnName in deprecatedAPIs) {
if (deprecatedAPIs.hasOwnProperty(fnName)) {
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
}
}
}
module.exports = ReactComponent;
2015-10-14 22:58:32 -04:00
},{"153":153,"160":160,"172":172,"76":76}],35:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactDOMIDOperations = _dereq_(45);
var ReactMount = _dereq_(72);
2015-09-02 15:08:58 -04:00
/**
* Abstracts away all functionality of the reconciler that requires knowledge of
* the browser context. TODO: These callers should be refactored to avoid the
* need for this injection.
*/
var ReactComponentBrowserEnvironment = {
2015-10-14 22:58:32 -04:00
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
replaceNodeWithMarkupByID: ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
unmountIDFromEnvironment: function (rootNodeID) {
2015-09-02 15:08:58 -04:00
ReactMount.purgeID(rootNodeID);
}
};
module.exports = ReactComponentBrowserEnvironment;
2015-10-14 22:58:32 -04:00
},{"45":45,"72":72}],36:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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 ReactComponentEnvironment
*/
'use strict';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var injected = false;
var ReactComponentEnvironment = {
/**
* 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.
*/
unmountIDFromEnvironment: null,
/**
* Optionally injectable hook for swapping out mount images in the middle of
* the tree.
*/
replaceNodeWithMarkupByID: null,
/**
* Optionally injectable hook for processing a queue of child updates. Will
* later move into MultiChildComponents.
*/
processChildrenUpdates: null,
injection: {
2015-10-14 22:58:32 -04:00
injectEnvironment: function (environment) {
!!injected ? "development" !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
2015-09-02 15:08:58 -04:00
injected = true;
}
}
};
module.exports = ReactComponentEnvironment;
2015-10-14 22:58:32 -04:00
},{"160":160}],37:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactComponentWithPureRenderMixin
*/
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var shallowCompare = _dereq_(139);
2015-09-02 15:08:58 -04:00
/**
* 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 = {
2015-10-14 22:58:32 -04:00
shouldComponentUpdate: function (nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
2015-09-02 15:08:58 -04:00
}
};
module.exports = ReactComponentWithPureRenderMixin;
2015-10-14 22:58:32 -04:00
},{"139":139}],38:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactComponentEnvironment = _dereq_(36);
var ReactCurrentOwner = _dereq_(39);
var ReactElement = _dereq_(57);
var ReactInstanceMap = _dereq_(68);
var ReactPerf = _dereq_(78);
var ReactPropTypeLocations = _dereq_(81);
var ReactPropTypeLocationNames = _dereq_(80);
var ReactReconciler = _dereq_(84);
var ReactUpdateQueue = _dereq_(95);
var assign = _dereq_(24);
var emptyObject = _dereq_(153);
var invariant = _dereq_(160);
var shouldUpdateReactComponent = _dereq_(140);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
function getDeclarationErrorAddendum(component) {
var owner = component._currentElement._owner || null;
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
}
2015-10-14 22:58:32 -04:00
function StatelessComponent(Component) {}
StatelessComponent.prototype.render = function () {
var Component = ReactInstanceMap.get(this)._currentElement.type;
return Component(this.props, this.context, this.updater);
};
2015-09-02 15:08:58 -04:00
/**
* ------------------ The Life-Cycle of a Composite Component ------------------
*
* - constructor: Initialization of state. The instance is now retained.
* - componentWillMount
* - render
* - [children's constructors]
* - [children's componentWillMount and render]
* - [children's componentDidMount]
* - componentDidMount
*
* Update Phases:
* - componentWillReceiveProps (only called if parent updated)
* - shouldComponentUpdate
* - componentWillUpdate
* - render
* - [children's constructors or receive props phases]
* - componentDidUpdate
*
* - componentWillUnmount
* - [children's componentWillUnmount]
* - [children destroyed]
* - (destroyed): The instance is now blank, released by React and ready for GC.
*
* -----------------------------------------------------------------------------
*/
/**
* An incrementing ID assigned to each component when it is mounted. This is
* used to enforce the order in which `ReactUpdates` updates dirty components.
*
* @private
*/
var nextMountID = 1;
/**
* @lends {ReactCompositeComponent.prototype}
*/
var ReactCompositeComponentMixin = {
/**
* Base constructor for all composite component.
*
* @param {ReactElement} element
* @final
* @internal
*/
2015-10-14 22:58:32 -04:00
construct: function (element) {
2015-09-02 15:08:58 -04:00
this._currentElement = element;
this._rootNodeID = null;
this._instance = null;
// See ReactUpdateQueue
this._pendingElement = null;
this._pendingStateQueue = null;
this._pendingReplaceState = false;
this._pendingForceUpdate = false;
this._renderedComponent = null;
this._context = null;
this._mountOrder = 0;
2015-10-14 22:58:32 -04:00
this._topLevelWrapper = null;
2015-09-02 15:08:58 -04:00
// See ReactUpdates and ReactUpdateQueue.
this._pendingCallbacks = null;
},
/**
* Initializes the component, renders markup, and registers event listeners.
*
* @param {string} rootID DOM ID of the root node.
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
* @return {?string} Rendered markup to be inserted into the DOM.
* @final
* @internal
*/
2015-10-14 22:58:32 -04:00
mountComponent: function (rootID, transaction, context) {
2015-09-02 15:08:58 -04:00
this._context = context;
this._mountOrder = nextMountID++;
this._rootNodeID = rootID;
var publicProps = this._processProps(this._currentElement.props);
2015-10-14 22:58:32 -04:00
var publicContext = this._processContext(context);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var Component = this._currentElement.type;
2015-09-02 15:08:58 -04:00
// Initialize the public class
2015-10-14 22:58:32 -04:00
var inst;
var renderedElement;
// This is a way to detect if Component is a stateless arrow function
// component, which is not newable. It might not be 100% reliable but is
// something we can do until we start detecting that Component extends
// React.Component. We already assume that typeof Component === 'function'.
var canInstantiate = ('prototype' in Component);
if (canInstantiate) {
if ("development" !== 'production') {
ReactCurrentOwner.current = this;
try {
inst = new Component(publicProps, publicContext, ReactUpdateQueue);
} finally {
ReactCurrentOwner.current = null;
}
} else {
inst = new Component(publicProps, publicContext, ReactUpdateQueue);
}
}
if (!canInstantiate || inst === null || inst === false || ReactElement.isValidElement(inst)) {
renderedElement = inst;
inst = new StatelessComponent(Component);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// This will throw later in _renderValidatedComponent, but add an early
// warning now to help debugging
2015-10-14 22:58:32 -04:00
if (inst.render == null) {
"development" !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`, returned ' + 'null/false from a stateless component, or tried to render an ' + 'element whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
} else {
// We support ES6 inheriting from React.Component, the module pattern,
// and stateless components, but not ES6 classes that don't extend
"development" !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
}
2015-09-02 15:08:58 -04:00
}
// These should be set up in the constructor, but as a convenience for
// simpler class abstractions, we set them up after the fact.
inst.props = publicProps;
inst.context = publicContext;
inst.refs = emptyObject;
2015-10-14 22:58:32 -04:00
inst.updater = ReactUpdateQueue;
2015-09-02 15:08:58 -04:00
this._instance = inst;
// Store a reference from the instance back to the internal representation
ReactInstanceMap.set(inst, this);
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// Since plain JS classes are defined without any special initialization
// logic, we can not catch common errors early. Therefore, we have to
// catch them here, at initialization time, instead.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : undefined;
"development" !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : undefined;
"development" !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined;
"development" !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined;
"development" !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s 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.', this.getName() || 'A component') : undefined;
"development" !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : undefined;
"development" !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
2015-09-02 15:08:58 -04:00
}
var initialState = inst.state;
if (initialState === undefined) {
inst.state = initialState = null;
}
2015-10-14 22:58:32 -04:00
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? "development" !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
this._pendingStateQueue = null;
this._pendingReplaceState = false;
this._pendingForceUpdate = false;
2015-10-14 22:58:32 -04:00
if (inst.componentWillMount) {
inst.componentWillMount();
// When mounting, calls to `setState` by `componentWillMount` will set
// `this._pendingStateQueue` without triggering a re-render.
if (this._pendingStateQueue) {
inst.state = this._processPendingState(inst.props, inst.context);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// If not a stateless component, we now render
if (renderedElement === undefined) {
renderedElement = this._renderValidatedComponent();
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
this._renderedComponent = this._instantiateReactComponent(renderedElement);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
2015-09-02 15:08:58 -04:00
if (inst.componentDidMount) {
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
}
return markup;
},
/**
* Releases any resources allocated by `mountComponent`.
*
* @final
* @internal
*/
2015-10-14 22:58:32 -04:00
unmountComponent: function () {
2015-09-02 15:08:58 -04:00
var inst = this._instance;
if (inst.componentWillUnmount) {
2015-10-14 22:58:32 -04:00
inst.componentWillUnmount();
2015-09-02 15:08:58 -04:00
}
ReactReconciler.unmountComponent(this._renderedComponent);
this._renderedComponent = null;
2015-10-14 22:58:32 -04:00
this._instance = null;
2015-09-02 15:08:58 -04:00
// Reset pending fields
2015-10-14 22:58:32 -04:00
// Even if this component is scheduled for another update in ReactUpdates,
// it would still be ignored because these fields are reset.
2015-09-02 15:08:58 -04:00
this._pendingStateQueue = null;
this._pendingReplaceState = false;
this._pendingForceUpdate = false;
this._pendingCallbacks = null;
this._pendingElement = null;
// These fields do not really need to be reset since this object is no
// longer accessible.
this._context = null;
this._rootNodeID = null;
2015-10-14 22:58:32 -04:00
this._topLevelWrapper = null;
2015-09-02 15:08:58 -04:00
// Delete the reference from the instance to this internal representation
// which allow the internals to be properly cleaned up even if the user
// leaks a reference to the public instance.
ReactInstanceMap.remove(inst);
// Some existing components rely on inst.props even after they've been
// destroyed (in event handlers).
// TODO: inst.props = null;
// TODO: inst.state = null;
// TODO: inst.context = null;
},
/**
* Filters the context object to only contain keys specified in
* `contextTypes`
*
* @param {object} context
* @return {?object}
* @private
*/
2015-10-14 22:58:32 -04:00
_maskContext: function (context) {
2015-09-02 15:08:58 -04:00
var maskedContext = null;
2015-10-14 22:58:32 -04:00
var Component = this._currentElement.type;
var contextTypes = Component.contextTypes;
2015-09-02 15:08:58 -04:00
if (!contextTypes) {
return emptyObject;
}
maskedContext = {};
for (var contextName in contextTypes) {
maskedContext[contextName] = context[contextName];
}
return maskedContext;
},
/**
* Filters the context object to only contain keys specified in
* `contextTypes`, and asserts that they are valid.
*
* @param {object} context
* @return {?object}
* @private
*/
2015-10-14 22:58:32 -04:00
_processContext: function (context) {
2015-09-02 15:08:58 -04:00
var maskedContext = this._maskContext(context);
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
var Component = this._currentElement.type;
2015-09-02 15:08:58 -04:00
if (Component.contextTypes) {
2015-10-14 22:58:32 -04:00
this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
2015-09-02 15:08:58 -04:00
}
}
return maskedContext;
},
/**
* @param {object} currentContext
* @return {object}
* @private
*/
2015-10-14 22:58:32 -04:00
_processChildContext: function (currentContext) {
var Component = this._currentElement.type;
2015-09-02 15:08:58 -04:00
var inst = this._instance;
var childContext = inst.getChildContext && inst.getChildContext();
if (childContext) {
2015-10-14 22:58:32 -04:00
!(typeof Component.childContextTypes === 'object') ? "development" !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
if ("development" !== 'production') {
this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
2015-09-02 15:08:58 -04:00
}
for (var name in childContext) {
2015-10-14 22:58:32 -04:00
!(name in Component.childContextTypes) ? "development" !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
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
*/
2015-10-14 22:58:32 -04:00
_processProps: function (newProps) {
if ("development" !== 'production') {
var Component = this._currentElement.type;
2015-09-02 15:08:58 -04:00
if (Component.propTypes) {
2015-10-14 22:58:32 -04:00
this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
2015-09-02 15:08:58 -04:00
}
}
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
*/
2015-10-14 22:58:32 -04:00
_checkPropTypes: function (propTypes, props, location) {
2015-09-02 15:08:58 -04:00
// TODO: Stop validating prop types here and only use the element
// validation.
var componentName = this.getName();
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error;
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
2015-10-14 22:58:32 -04:00
!(typeof propTypes[propName] === 'function') ? "development" !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
error = propTypes[propName](props, propName, componentName, location);
} catch (ex) {
error = ex;
}
if (error instanceof Error) {
// We may want to extend this logic for similar errors in
2015-10-14 22:58:32 -04:00
// top-level render calls, so I'm abstracting it away into
2015-09-02 15:08:58 -04:00
// a function to minimize refactoring in the future
var addendum = getDeclarationErrorAddendum(this);
if (location === ReactPropTypeLocations.prop) {
// Preface gives us something to blacklist in warning module
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
}
},
2015-10-14 22:58:32 -04:00
receiveComponent: function (nextElement, transaction, nextContext) {
2015-09-02 15:08:58 -04:00
var prevElement = this._currentElement;
var prevContext = this._context;
this._pendingElement = null;
2015-10-14 22:58:32 -04:00
this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext);
2015-09-02 15:08:58 -04:00
},
/**
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
* is set, update the component.
*
* @param {ReactReconcileTransaction} transaction
* @internal
*/
2015-10-14 22:58:32 -04:00
performUpdateIfNecessary: function (transaction) {
2015-09-02 15:08:58 -04:00
if (this._pendingElement != null) {
2015-10-14 22:58:32 -04:00
ReactReconciler.receiveComponent(this, this._pendingElement || this._currentElement, transaction, this._context);
2015-09-02 15:08:58 -04:00
}
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
2015-10-14 22:58:32 -04:00
this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
2015-09-02 15:08:58 -04:00
}
},
/**
* Perform an update to a mounted component. The componentWillReceiveProps and
* shouldComponentUpdate methods are called, then (assuming the update isn't
* skipped) the remaining update lifecycle methods are called and the DOM
* representation is updated.
*
* By default, this implements React's rendering and reconciliation algorithm.
* Sophisticated clients may wish to override this.
*
* @param {ReactReconcileTransaction} transaction
* @param {ReactElement} prevParentElement
* @param {ReactElement} nextParentElement
* @internal
* @overridable
*/
2015-10-14 22:58:32 -04:00
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
2015-09-02 15:08:58 -04:00
var inst = this._instance;
2015-10-14 22:58:32 -04:00
var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext);
var nextProps;
2015-09-02 15:08:58 -04:00
// Distinguish between a props update versus a simple state update
2015-10-14 22:58:32 -04:00
if (prevParentElement === nextParentElement) {
// Skip checking prop types again -- we don't read inst.props to avoid
// warning for DOM component props in this upgrade
nextProps = nextParentElement.props;
} else {
2015-09-02 15:08:58 -04:00
nextProps = this._processProps(nextParentElement.props);
// An update here will schedule an update but immediately set
// _pendingStateQueue which will ensure that any state updates gets
// immediately reconciled instead of waiting for the next batch.
if (inst.componentWillReceiveProps) {
inst.componentWillReceiveProps(nextProps, nextContext);
}
}
var nextState = this._processPendingState(nextProps, nextContext);
2015-10-14 22:58:32 -04:00
var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
2015-09-02 15:08:58 -04:00
}
if (shouldUpdate) {
this._pendingForceUpdate = false;
// Will set `this.props`, `this.state` and `this.context`.
2015-10-14 22:58:32 -04:00
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext);
2015-09-02 15:08:58 -04:00
} else {
// If it's determined that a component should not update, we still want
// to set props and state but we shortcut the rest of the update.
this._currentElement = nextParentElement;
this._context = nextUnmaskedContext;
inst.props = nextProps;
inst.state = nextState;
inst.context = nextContext;
}
},
2015-10-14 22:58:32 -04:00
_processPendingState: function (props, context) {
2015-09-02 15:08:58 -04:00
var inst = this._instance;
var queue = this._pendingStateQueue;
var replace = this._pendingReplaceState;
this._pendingReplaceState = false;
this._pendingStateQueue = null;
if (!queue) {
return inst.state;
}
if (replace && queue.length === 1) {
return queue[0];
}
var nextState = assign({}, replace ? queue[0] : inst.state);
for (var i = replace ? 1 : 0; i < queue.length; i++) {
var partial = queue[i];
2015-10-14 22:58:32 -04:00
assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
2015-09-02 15:08:58 -04:00
}
return nextState;
},
/**
* 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
* @param {?object} unmaskedContext
* @private
*/
2015-10-14 22:58:32 -04:00
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
2015-09-02 15:08:58 -04:00
var inst = this._instance;
2015-10-14 22:58:32 -04:00
var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
var prevProps;
var prevState;
var prevContext;
if (hasComponentDidUpdate) {
prevProps = inst.props;
prevState = inst.state;
prevContext = inst.context;
}
2015-09-02 15:08:58 -04:00
if (inst.componentWillUpdate) {
inst.componentWillUpdate(nextProps, nextState, nextContext);
}
this._currentElement = nextElement;
this._context = unmaskedContext;
inst.props = nextProps;
inst.state = nextState;
inst.context = nextContext;
this._updateRenderedComponent(transaction, unmaskedContext);
2015-10-14 22:58:32 -04:00
if (hasComponentDidUpdate) {
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
2015-09-02 15:08:58 -04:00
}
},
/**
* Call the component's `render` method and update the DOM accordingly.
*
* @param {ReactReconcileTransaction} transaction
* @internal
*/
2015-10-14 22:58:32 -04:00
_updateRenderedComponent: function (transaction, context) {
2015-09-02 15:08:58 -04:00
var prevComponentInstance = this._renderedComponent;
var prevRenderedElement = prevComponentInstance._currentElement;
2015-10-14 22:58:32 -04:00
var nextRenderedElement = this._renderValidatedComponent();
2015-09-02 15:08:58 -04:00
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
2015-10-14 22:58:32 -04:00
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
2015-09-02 15:08:58 -04:00
} else {
// These two IDs are actually the same! But nothing should rely on that.
var thisID = this._rootNodeID;
var prevComponentID = prevComponentInstance._rootNodeID;
ReactReconciler.unmountComponent(prevComponentInstance);
2015-10-14 22:58:32 -04:00
this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
2015-09-02 15:08:58 -04:00
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
}
},
/**
* @protected
*/
2015-10-14 22:58:32 -04:00
_replaceNodeWithMarkupByID: function (prevComponentID, nextMarkup) {
ReactComponentEnvironment.replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
2015-09-02 15:08:58 -04:00
},
/**
* @protected
*/
2015-10-14 22:58:32 -04:00
_renderValidatedComponentWithoutOwnerOrContext: function () {
2015-09-02 15:08:58 -04:00
var inst = this._instance;
var renderedComponent = inst.render();
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// We allow auto-mocks to proceed as if they're returning null.
2015-10-14 22:58:32 -04:00
if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
2015-09-02 15:08:58 -04:00
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
renderedComponent = null;
}
}
return renderedComponent;
},
/**
* @private
*/
2015-10-14 22:58:32 -04:00
_renderValidatedComponent: function () {
2015-09-02 15:08:58 -04:00
var renderedComponent;
ReactCurrentOwner.current = this;
try {
2015-10-14 22:58:32 -04:00
renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
2015-09-02 15:08:58 -04:00
} finally {
ReactCurrentOwner.current = null;
}
2015-10-14 22:58:32 -04:00
!(
// TODO: An `isValidNode` function would probably be more appropriate
renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? "development" !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
return renderedComponent;
},
/**
* 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
*/
2015-10-14 22:58:32 -04:00
attachRef: function (ref, component) {
2015-09-02 15:08:58 -04:00
var inst = this.getPublicInstance();
2015-10-14 22:58:32 -04:00
!(inst != null) ? "development" !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : undefined;
var publicComponentInstance = component.getPublicInstance();
if ("development" !== 'production') {
var componentName = component && component.getName ? component.getName() : 'a component';
"development" !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : undefined;
}
var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
refs[ref] = publicComponentInstance;
2015-09-02 15:08:58 -04:00
},
/**
* Detaches a reference name.
*
* @param {string} ref Name to dereference.
* @final
* @private
*/
2015-10-14 22:58:32 -04:00
detachRef: function (ref) {
2015-09-02 15:08:58 -04:00
var refs = this.getPublicInstance().refs;
delete refs[ref];
},
/**
* Get a text description of the component that can be used to identify it
* in error messages.
* @return {string} The name or null.
* @internal
*/
2015-10-14 22:58:32 -04:00
getName: function () {
2015-09-02 15:08:58 -04:00
var type = this._currentElement.type;
var constructor = this._instance && this._instance.constructor;
2015-10-14 22:58:32 -04:00
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
2015-09-02 15:08:58 -04:00
},
/**
* Get the publicly accessible representation of this component - i.e. what
2015-10-14 22:58:32 -04:00
* is exposed by refs and returned by render. Can be null for stateless
2015-09-02 15:08:58 -04:00
* components.
*
* @return {ReactComponent} the public component instance.
* @internal
*/
2015-10-14 22:58:32 -04:00
getPublicInstance: function () {
var inst = this._instance;
if (inst instanceof StatelessComponent) {
return null;
}
return inst;
2015-09-02 15:08:58 -04:00
},
// Stub
_instantiateReactComponent: null
};
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(ReactCompositeComponentMixin, 'ReactCompositeComponent', {
mountComponent: 'mountComponent',
updateComponent: 'updateComponent',
_renderValidatedComponent: '_renderValidatedComponent'
});
2015-09-02 15:08:58 -04:00
var ReactCompositeComponent = {
Mixin: ReactCompositeComponentMixin
};
module.exports = ReactCompositeComponent;
2015-10-14 22:58:32 -04:00
},{"140":140,"153":153,"160":160,"172":172,"24":24,"36":36,"39":39,"57":57,"68":68,"78":78,"80":80,"81":81,"84":84,"95":95}],39:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactCurrentOwner
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* Keeps track of the current owner.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* The current owner is the component who should own any components that are
* currently being constructed.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var ReactCurrentOwner = {
2015-09-02 15:08:58 -04:00
/**
* @internal
2015-10-14 22:58:32 -04:00
* @type {ReactComponent}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
current: null
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactCurrentOwner;
},{}],40:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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
*/
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
'use strict';
var ReactCurrentOwner = _dereq_(39);
var ReactDOMTextComponent = _dereq_(51);
var ReactDefaultInjection = _dereq_(54);
var ReactInstanceHandles = _dereq_(67);
var ReactMount = _dereq_(72);
var ReactPerf = _dereq_(78);
var ReactReconciler = _dereq_(84);
var ReactUpdates = _dereq_(96);
var ReactVersion = _dereq_(97);
var findDOMNode = _dereq_(121);
var renderSubtreeIntoContainer = _dereq_(136);
var warning = _dereq_(172);
ReactDefaultInjection.inject();
var render = ReactPerf.measure('React', 'render', ReactMount.render);
var React = {
findDOMNode: findDOMNode,
render: render,
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
version: ReactVersion,
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/* eslint-disable camelcase */
unstable_batchedUpdates: ReactUpdates.batchedUpdates,
unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
// Inject the runtime into a devtools global hook regardless of browser.
// Allows for debugging when the hook is injected on the page.
/* eslint-enable camelcase */
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
CurrentOwner: ReactCurrentOwner,
InstanceHandles: ReactInstanceHandles,
Mount: ReactMount,
Reconciler: ReactReconciler,
TextComponent: ReactDOMTextComponent
});
}
if ("development" !== 'production') {
var ExecutionEnvironment = _dereq_(146);
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
// First check if devtools is not installed
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
// If we're in Chrome or Firefox, provide a download link if not installed.
if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools');
}
}
// If we're in IE8, check to see if we are in compatibility mode and provide
// information on preventing compatibility mode
var ieCompatibilityMode = document.documentMode && document.documentMode < 8;
"development" !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />') : undefined;
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: ' + 'https://fb.me/react-warning-polyfills');
break;
}
}
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = React;
},{"121":121,"136":136,"146":146,"172":172,"39":39,"51":51,"54":54,"67":67,"72":72,"78":78,"84":84,"96":96,"97":97}],41:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactDOMButton
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var mouseListenerNames = {
onClick: true,
onDoubleClick: true,
onMouseDown: true,
onMouseMove: true,
onMouseUp: true,
onClickCapture: true,
onDoubleClickCapture: true,
onMouseDownCapture: true,
onMouseMoveCapture: true,
onMouseUpCapture: true
};
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Implements a <button> native component that does not receive mouse events
* when `disabled` is set.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var ReactDOMButton = {
getNativeProps: function (inst, props, context) {
if (!props.disabled) {
return props;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Copy the props, except the mouse listeners
var nativeProps = {};
for (var key in props) {
if (props.hasOwnProperty(key) && !mouseListenerNames[key]) {
nativeProps[key] = props[key];
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
return nativeProps;
}
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
module.exports = ReactDOMButton;
},{}],42:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactDOMComponent
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
2015-10-14 22:58:32 -04:00
/* global hasOwnProperty:true */
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var AutoFocusUtils = _dereq_(2);
var CSSPropertyOperations = _dereq_(5);
var DOMProperty = _dereq_(10);
var DOMPropertyOperations = _dereq_(11);
var EventConstants = _dereq_(15);
var ReactBrowserEventEmitter = _dereq_(28);
var ReactComponentBrowserEnvironment = _dereq_(35);
var ReactDOMButton = _dereq_(41);
var ReactDOMInput = _dereq_(46);
var ReactDOMOption = _dereq_(47);
var ReactDOMSelect = _dereq_(48);
var ReactDOMTextarea = _dereq_(52);
var ReactMount = _dereq_(72);
var ReactMultiChild = _dereq_(73);
var ReactPerf = _dereq_(78);
var ReactUpdateQueue = _dereq_(95);
var assign = _dereq_(24);
var escapeTextContentForBrowser = _dereq_(120);
var invariant = _dereq_(160);
var isEventSupported = _dereq_(132);
var keyOf = _dereq_(165);
var setInnerHTML = _dereq_(137);
var setTextContent = _dereq_(138);
var shallowEqual = _dereq_(170);
var validateDOMNesting = _dereq_(143);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var deleteListener = ReactBrowserEventEmitter.deleteListener;
var listenTo = ReactBrowserEventEmitter.listenTo;
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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;
var canDefineProperty = false;
try {
Object.defineProperty({}, 'test', { get: function () {} });
canDefineProperty = true;
} catch (e) {}
function getDeclarationErrorAddendum(internalInstance) {
if (internalInstance) {
var owner = internalInstance._currentElement._owner || null;
if (owner) {
var name = owner.getName();
if (name) {
return ' This DOM node was rendered by `' + name + '`.';
}
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var legacyPropsDescriptor;
if ("development" !== 'production') {
legacyPropsDescriptor = {
props: {
enumerable: false,
get: function () {
var component = this._reactInternalComponent;
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .props of a DOM node; instead, ' + 'recreate the props as `render` did originally or read the DOM ' + 'properties/attributes directly from this node (e.g., ' + 'this.refs.box.className).%s', getDeclarationErrorAddendum(component)) : undefined;
return component._currentElement.props;
}
}
};
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function legacyGetDOMNode() {
if ("development" !== 'production') {
var component = this._reactInternalComponent;
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .getDOMNode() of a DOM node; ' + 'instead, use the node directly.%s', getDeclarationErrorAddendum(component)) : undefined;
}
return this;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function legacyIsMounted() {
var component = this._reactInternalComponent;
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .isMounted() of a DOM node.%s', getDeclarationErrorAddendum(component)) : undefined;
}
return !!component;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function legacySetStateEtc() {
if ("development" !== 'production') {
var component = this._reactInternalComponent;
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setState(), .replaceState(), or ' + '.forceUpdate() of a DOM node. This is a no-op.%s', getDeclarationErrorAddendum(component)) : undefined;
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function legacySetProps(partialProps, callback) {
var component = this._reactInternalComponent;
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
}
if (!component) {
return;
}
ReactUpdateQueue.enqueueSetPropsInternal(component, partialProps);
if (callback) {
ReactUpdateQueue.enqueueCallbackInternal(component, callback);
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function legacyReplaceProps(partialProps, callback) {
var component = this._reactInternalComponent;
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
}
if (!component) {
return;
}
ReactUpdateQueue.enqueueReplacePropsInternal(component, partialProps);
if (callback) {
ReactUpdateQueue.enqueueCallbackInternal(component, callback);
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function friendlyStringify(obj) {
if (typeof obj === 'object') {
if (Array.isArray(obj)) {
return '[' + obj.map(friendlyStringify).join(', ') + ']';
} else {
var pairs = [];
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key);
pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key]));
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return '{' + pairs.join(', ') + '}';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
} else if (typeof obj === 'string') {
return JSON.stringify(obj);
} else if (typeof obj === 'function') {
return '[function object]';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
// Differs from JSON.stringify in that undefined becauses undefined and that
// inf and nan don't become null
return String(obj);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var styleMutationWarning = {};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function checkAndWarnForMutatedStyle(style1, style2, component) {
if (style1 == null || style2 == null) {
return;
}
if (shallowEqual(style1, style2)) {
return;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var componentName = component._tag;
var owner = component._currentElement._owner;
var ownerName;
if (owner) {
ownerName = owner.getName();
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var hash = ownerName + '|' + componentName;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (styleMutationWarning.hasOwnProperty(hash)) {
return;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
styleMutationWarning[hash] = true;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : undefined;
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* @param {object} component
2015-09-02 15:08:58 -04:00
* @param {?object} props
*/
2015-10-14 22:58:32 -04:00
function assertValidProps(component, props) {
2015-09-02 15:08:58 -04:00
if (!props) {
return;
}
// Note the use of `==` which checks for null or undefined.
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
if (voidElementTags[component._tag]) {
"development" !== 'production' ? warning(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : undefined;
}
}
2015-09-02 15:08:58 -04:00
if (props.dangerouslySetInnerHTML != null) {
2015-10-14 22:58:32 -04:00
!(props.children == null) ? "development" !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : undefined;
!(typeof props.dangerouslySetInnerHTML === 'object' && '__html' in props.dangerouslySetInnerHTML) ? "development" !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : undefined;
}
if ("development" !== 'production') {
"development" !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : undefined;
"development" !== 'production' ? warning(!props.contentEditable || props.children == null, '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.') : undefined;
}
!(props.style == null || typeof props.style === 'object') ? "development" !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined;
}
function enqueuePutListener(id, registrationName, listener, transaction) {
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// IE8 has no API for event capturing and the `onScroll` event doesn't
// bubble.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : undefined;
2015-09-02 15:08:58 -04:00
}
var container = ReactMount.findReactContainerForID(id);
if (container) {
2015-10-14 22:58:32 -04:00
var doc = container.nodeType === ELEMENT_NODE_TYPE ? container.ownerDocument : container;
2015-09-02 15:08:58 -04:00
listenTo(registrationName, doc);
}
2015-10-14 22:58:32 -04:00
transaction.getReactMountReady().enqueue(putListener, {
id: id,
registrationName: registrationName,
listener: listener
});
}
function putListener() {
var listenerToPut = this;
ReactBrowserEventEmitter.putListener(listenerToPut.id, listenerToPut.registrationName, listenerToPut.listener);
}
// There are so many media events, it makes sense to just
// maintain a list rather than create a `trapBubbledEvent` for each
var mediaEvents = {
topAbort: 'abort',
topCanPlay: 'canplay',
topCanPlayThrough: 'canplaythrough',
topDurationChange: 'durationchange',
topEmptied: 'emptied',
topEncrypted: 'encrypted',
topEnded: 'ended',
topError: 'error',
topLoadedData: 'loadeddata',
topLoadedMetadata: 'loadedmetadata',
topLoadStart: 'loadstart',
topPause: 'pause',
topPlay: 'play',
topPlaying: 'playing',
topProgress: 'progress',
topRateChange: 'ratechange',
topSeeked: 'seeked',
topSeeking: 'seeking',
topStalled: 'stalled',
topSuspend: 'suspend',
topTimeUpdate: 'timeupdate',
topVolumeChange: 'volumechange',
topWaiting: 'waiting'
};
function trapBubbledEventsLocal() {
var inst = this;
// If a component renders to null or if another component fatals and causes
// the state of the tree to be corrupted, `node` here can be null.
!inst._rootNodeID ? "development" !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined;
var node = ReactMount.getNode(inst._rootNodeID);
!node ? "development" !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined;
switch (inst._tag) {
case 'iframe':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
break;
case 'video':
case 'audio':
inst._wrapperState.listeners = [];
// create listener for each media event
for (var event in mediaEvents) {
if (mediaEvents.hasOwnProperty(event)) {
inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
}
}
break;
case 'img':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
break;
case 'form':
inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)];
break;
}
}
function mountReadyInputWrapper() {
ReactDOMInput.mountReadyWrapper(this);
}
function postUpdateSelectWrapper() {
ReactDOMSelect.postUpdateWrapper(this);
2015-09-02 15:08:58 -04:00
}
// 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
};
2015-10-14 22:58:32 -04:00
// NOTE: menuitem's close tag should be omitted, but that causes problems.
var newlineEatingTags = {
'listing': true,
'pre': true,
'textarea': true
};
// For HTML, certain tags cannot have children. This has the same purpose as
// `omittedCloseTags` except that `menuitem` should still have its closing tag.
var voidElementTags = assign({
'menuitem': true
}, omittedCloseTags);
// We accept any tag to be rendered but since this gets injected into arbitrary
2015-09-02 15:08:58 -04:00
// 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 = {};
2015-10-14 22:58:32 -04:00
var hasOwnProperty = ({}).hasOwnProperty;
2015-09-02 15:08:58 -04:00
function validateDangerousTag(tag) {
if (!hasOwnProperty.call(validatedTagCache, tag)) {
2015-10-14 22:58:32 -04:00
!VALID_TAG_REGEX.test(tag) ? "development" !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
validatedTagCache[tag] = true;
}
}
2015-10-14 22:58:32 -04:00
function processChildContextDev(context, inst) {
// Pass down our tag name to child components for validation purposes
context = assign({}, context);
var info = context[validateDOMNesting.ancestorInfoContextKey];
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
return context;
}
function isCustomComponent(tagName, props) {
return tagName.indexOf('-') >= 0 || props.is != null;
}
2015-09-02 15:08:58 -04:00
/**
* 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 ReactMultiChild
*/
function ReactDOMComponent(tag) {
validateDangerousTag(tag);
2015-10-14 22:58:32 -04:00
this._tag = tag.toLowerCase();
2015-09-02 15:08:58 -04:00
this._renderedChildren = null;
2015-10-14 22:58:32 -04:00
this._previousStyle = null;
2015-09-02 15:08:58 -04:00
this._previousStyleCopy = null;
this._rootNodeID = null;
2015-10-14 22:58:32 -04:00
this._wrapperState = null;
this._topLevelWrapper = null;
this._nodeWithLegacyProperties = null;
if ("development" !== 'production') {
this._unprocessedContextDev = null;
this._processedContextDev = null;
}
2015-09-02 15:08:58 -04:00
}
ReactDOMComponent.displayName = 'ReactDOMComponent';
ReactDOMComponent.Mixin = {
2015-10-14 22:58:32 -04:00
construct: function (element) {
2015-09-02 15:08:58 -04:00
this._currentElement = element;
},
/**
* 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
2015-10-14 22:58:32 -04:00
* @param {object} context
2015-09-02 15:08:58 -04:00
* @return {string} The computed markup.
*/
2015-10-14 22:58:32 -04:00
mountComponent: function (rootID, transaction, context) {
2015-09-02 15:08:58 -04:00
this._rootNodeID = rootID;
var props = this._currentElement.props;
2015-10-14 22:58:32 -04:00
switch (this._tag) {
case 'iframe':
case 'img':
case 'form':
case 'video':
case 'audio':
this._wrapperState = {
listeners: null
};
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
break;
case 'button':
props = ReactDOMButton.getNativeProps(this, props, context);
break;
case 'input':
ReactDOMInput.mountWrapper(this, props, context);
props = ReactDOMInput.getNativeProps(this, props, context);
break;
case 'option':
ReactDOMOption.mountWrapper(this, props, context);
props = ReactDOMOption.getNativeProps(this, props, context);
break;
case 'select':
ReactDOMSelect.mountWrapper(this, props, context);
props = ReactDOMSelect.getNativeProps(this, props, context);
context = ReactDOMSelect.processChildContext(this, props, context);
break;
case 'textarea':
ReactDOMTextarea.mountWrapper(this, props, context);
props = ReactDOMTextarea.getNativeProps(this, props, context);
break;
}
assertValidProps(this, props);
if ("development" !== 'production') {
if (context[validateDOMNesting.ancestorInfoContextKey]) {
validateDOMNesting(this._tag, this, context[validateDOMNesting.ancestorInfoContextKey]);
}
}
if ("development" !== 'production') {
this._unprocessedContextDev = context;
this._processedContextDev = processChildContextDev(context, this);
context = this._processedContextDev;
}
var mountImage;
if (transaction.useCreateElement) {
var ownerDocument = context[ReactMount.ownerDocumentContextKey];
var el = ownerDocument.createElement(this._currentElement.type);
DOMPropertyOperations.setAttributeForID(el, this._rootNodeID);
// Populate node cache
ReactMount.getID(el);
this._updateDOMProperties({}, props, transaction, el);
this._createInitialChildren(transaction, props, context, el);
mountImage = el;
} else {
var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
var tagContent = this._createContentMarkup(transaction, props, context);
if (!tagContent && omittedCloseTags[this._tag]) {
mountImage = tagOpen + '/>';
} else {
mountImage = tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
}
}
switch (this._tag) {
case 'input':
transaction.getReactMountReady().enqueue(mountReadyInputWrapper, this);
// falls through
case 'button':
case 'select':
case 'textarea':
if (props.autoFocus) {
transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this);
}
break;
}
return mountImage;
},
/**
* 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
* @param {object} props
* @return {string} Markup of opening tag.
*/
_createOpenTagMarkupAndPutListeners: function (transaction, props) {
var ret = '<' + this._currentElement.type;
2015-09-02 15:08:58 -04:00
for (var propKey in props) {
if (!props.hasOwnProperty(propKey)) {
continue;
}
var propValue = props[propKey];
if (propValue == null) {
continue;
}
if (registrationNameModules.hasOwnProperty(propKey)) {
2015-10-14 22:58:32 -04:00
if (propValue) {
enqueuePutListener(this._rootNodeID, propKey, propValue, transaction);
}
2015-09-02 15:08:58 -04:00
} else {
if (propKey === STYLE) {
if (propValue) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
// See `_updateDOMProperties`. style block
this._previousStyle = propValue;
}
2015-09-02 15:08:58 -04:00
propValue = this._previousStyleCopy = assign({}, props.style);
}
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
}
2015-10-14 22:58:32 -04:00
var markup = null;
if (this._tag != null && isCustomComponent(this._tag, props)) {
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
} else {
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
}
2015-09-02 15:08:58 -04:00
if (markup) {
ret += ' ' + markup;
}
}
}
// For static pages, no need to put React ID and checksum. Saves lots of
// bytes.
if (transaction.renderToStaticMarkup) {
2015-10-14 22:58:32 -04:00
return ret;
2015-09-02 15:08:58 -04:00
}
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
2015-10-14 22:58:32 -04:00
return ret + ' ' + markupForID;
2015-09-02 15:08:58 -04:00
},
/**
* Creates markup for the content between the tags.
*
* @private
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
2015-10-14 22:58:32 -04:00
* @param {object} props
2015-09-02 15:08:58 -04:00
* @param {object} context
* @return {string} Content markup.
*/
2015-10-14 22:58:32 -04:00
_createContentMarkup: function (transaction, props, context) {
var ret = '';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Intentional use of != to avoid catching zero/false.
var innerHTML = props.dangerouslySetInnerHTML;
if (innerHTML != null) {
if (innerHTML.__html != null) {
ret = innerHTML.__html;
}
} else {
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
var childrenToUse = contentToUse != null ? null : props.children;
if (contentToUse != null) {
// TODO: Validate that text is allowed as a child of this node
ret = escapeTextContentForBrowser(contentToUse);
} else if (childrenToUse != null) {
var mountImages = this.mountChildren(childrenToUse, transaction, context);
ret = mountImages.join('');
}
}
if (newlineEatingTags[this._tag] && ret.charAt(0) === '\n') {
// text/html ignores the first character in these tags if it's a newline
// Prefer to break application/xml over text/html (for now) by adding
// a newline specifically to get eaten by the parser. (Alternately for
// textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
// \r is normalized out by HTMLTextAreaElement#value.)
// See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
// See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
// See: <http://www.w3.org/TR/html5/syntax.html#newlines>
// See: Parsing of "textarea" "listing" and "pre" elements
// from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
return '\n' + ret;
} else {
return ret;
}
},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
_createInitialChildren: function (transaction, props, context, el) {
2015-09-02 15:08:58 -04:00
// Intentional use of != to avoid catching zero/false.
var innerHTML = props.dangerouslySetInnerHTML;
if (innerHTML != null) {
if (innerHTML.__html != null) {
2015-10-14 22:58:32 -04:00
setInnerHTML(el, innerHTML.__html);
2015-09-02 15:08:58 -04:00
}
} else {
2015-10-14 22:58:32 -04:00
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
2015-09-02 15:08:58 -04:00
var childrenToUse = contentToUse != null ? null : props.children;
if (contentToUse != null) {
2015-10-14 22:58:32 -04:00
// TODO: Validate that text is allowed as a child of this node
setTextContent(el, contentToUse);
2015-09-02 15:08:58 -04:00
} else if (childrenToUse != null) {
2015-10-14 22:58:32 -04:00
var mountImages = this.mountChildren(childrenToUse, transaction, context);
for (var i = 0; i < mountImages.length; i++) {
el.appendChild(mountImages[i]);
}
2015-09-02 15:08:58 -04:00
}
}
},
2015-10-14 22:58:32 -04:00
/**
* Receives a next element and updates the component.
*
* @internal
* @param {ReactElement} nextElement
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
* @param {object} context
*/
receiveComponent: function (nextElement, transaction, context) {
2015-09-02 15:08:58 -04:00
var prevElement = this._currentElement;
this._currentElement = nextElement;
this.updateComponent(transaction, prevElement, nextElement, context);
},
/**
* 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
* @param {ReactElement} nextElement
* @internal
* @overridable
*/
2015-10-14 22:58:32 -04:00
updateComponent: function (transaction, prevElement, nextElement, context) {
var lastProps = prevElement.props;
var nextProps = this._currentElement.props;
switch (this._tag) {
case 'button':
lastProps = ReactDOMButton.getNativeProps(this, lastProps);
nextProps = ReactDOMButton.getNativeProps(this, nextProps);
break;
case 'input':
ReactDOMInput.updateWrapper(this);
lastProps = ReactDOMInput.getNativeProps(this, lastProps);
nextProps = ReactDOMInput.getNativeProps(this, nextProps);
break;
case 'option':
lastProps = ReactDOMOption.getNativeProps(this, lastProps);
nextProps = ReactDOMOption.getNativeProps(this, nextProps);
break;
case 'select':
lastProps = ReactDOMSelect.getNativeProps(this, lastProps);
nextProps = ReactDOMSelect.getNativeProps(this, nextProps);
break;
case 'textarea':
ReactDOMTextarea.updateWrapper(this);
lastProps = ReactDOMTextarea.getNativeProps(this, lastProps);
nextProps = ReactDOMTextarea.getNativeProps(this, nextProps);
break;
}
if ("development" !== 'production') {
// If the context is reference-equal to the old one, pass down the same
// processed object so the update bailout in ReactReconciler behaves
// correctly (and identically in dev and prod). See #5005.
if (this._unprocessedContextDev !== context) {
this._unprocessedContextDev = context;
this._processedContextDev = processChildContextDev(context, this);
}
context = this._processedContextDev;
}
assertValidProps(this, nextProps);
this._updateDOMProperties(lastProps, nextProps, transaction, null);
this._updateDOMChildren(lastProps, nextProps, transaction, context);
if (!canDefineProperty && this._nodeWithLegacyProperties) {
this._nodeWithLegacyProperties.props = nextProps;
}
if (this._tag === 'select') {
// <select> value update needs to occur after <option> children
// reconciliation
transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this);
}
2015-09-02 15:08:58 -04:00
},
/**
* 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
2015-10-14 22:58:32 -04:00
* @param {object} nextProps
2015-09-02 15:08:58 -04:00
* @param {ReactReconcileTransaction} transaction
2015-10-14 22:58:32 -04:00
* @param {?DOMElement} node
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
_updateDOMProperties: function (lastProps, nextProps, transaction, node) {
2015-09-02 15:08:58 -04:00
var propKey;
var styleName;
var styleUpdates;
for (propKey in lastProps) {
2015-10-14 22:58:32 -04:00
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey)) {
2015-09-02 15:08:58 -04:00
continue;
}
if (propKey === STYLE) {
var lastStyle = this._previousStyleCopy;
for (styleName in lastStyle) {
if (lastStyle.hasOwnProperty(styleName)) {
styleUpdates = styleUpdates || {};
styleUpdates[styleName] = '';
}
}
this._previousStyleCopy = null;
} else if (registrationNameModules.hasOwnProperty(propKey)) {
2015-10-14 22:58:32 -04:00
if (lastProps[propKey]) {
// Only call deleteListener if there was a listener previously or
// else willDeleteListener gets called when there wasn't actually a
// listener (e.g., onClick={null})
deleteListener(this._rootNodeID, propKey);
}
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
if (!node) {
node = ReactMount.getNode(this._rootNodeID);
}
DOMPropertyOperations.deleteValueForProperty(node, propKey);
2015-09-02 15:08:58 -04:00
}
}
for (propKey in nextProps) {
var nextProp = nextProps[propKey];
2015-10-14 22:58:32 -04:00
var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps[propKey];
2015-09-02 15:08:58 -04:00
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
continue;
}
if (propKey === STYLE) {
if (nextProp) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
checkAndWarnForMutatedStyle(this._previousStyleCopy, this._previousStyle, this);
this._previousStyle = nextProp;
}
2015-09-02 15:08:58 -04:00
nextProp = this._previousStyleCopy = assign({}, nextProp);
} else {
this._previousStyleCopy = null;
}
if (lastProp) {
// Unset styles on `lastProp` but not on `nextProp`.
for (styleName in lastProp) {
2015-10-14 22:58:32 -04:00
if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
2015-09-02 15:08:58 -04:00
styleUpdates = styleUpdates || {};
styleUpdates[styleName] = '';
}
}
// Update styles that changed since `lastProp`.
for (styleName in nextProp) {
2015-10-14 22:58:32 -04:00
if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
2015-09-02 15:08:58 -04:00
styleUpdates = styleUpdates || {};
styleUpdates[styleName] = nextProp[styleName];
}
}
} else {
// Relies on `updateStylesByID` not mutating `styleUpdates`.
styleUpdates = nextProp;
}
} else if (registrationNameModules.hasOwnProperty(propKey)) {
2015-10-14 22:58:32 -04:00
if (nextProp) {
enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction);
} else if (lastProp) {
deleteListener(this._rootNodeID, propKey);
}
} else if (isCustomComponent(this._tag, nextProps)) {
if (!node) {
node = ReactMount.getNode(this._rootNodeID);
}
DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp);
} else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
if (!node) {
node = ReactMount.getNode(this._rootNodeID);
}
// 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 (nextProp != null) {
DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
} else {
DOMPropertyOperations.deleteValueForProperty(node, propKey);
}
2015-09-02 15:08:58 -04:00
}
}
if (styleUpdates) {
2015-10-14 22:58:32 -04:00
if (!node) {
node = ReactMount.getNode(this._rootNodeID);
}
CSSPropertyOperations.setValueForStyles(node, styleUpdates);
2015-09-02 15:08:58 -04:00
}
},
/**
* Reconciles the children with the various properties that affect the
* children content.
*
* @param {object} lastProps
2015-10-14 22:58:32 -04:00
* @param {object} nextProps
2015-09-02 15:08:58 -04:00
* @param {ReactReconcileTransaction} transaction
2015-10-14 22:58:32 -04:00
* @param {object} context
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
_updateDOMChildren: function (lastProps, nextProps, transaction, context) {
var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
var nextContent = CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var lastHtml = lastProps.dangerouslySetInnerHTML && lastProps.dangerouslySetInnerHTML.__html;
var nextHtml = nextProps.dangerouslySetInnerHTML && nextProps.dangerouslySetInnerHTML.__html;
2015-09-02 15:08:58 -04:00
// 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, context);
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
this.updateTextContent('');
}
if (nextContent != null) {
if (lastContent !== nextContent) {
this.updateTextContent('' + nextContent);
}
} else if (nextHtml != null) {
if (lastHtml !== nextHtml) {
2015-10-14 22:58:32 -04:00
this.updateMarkup('' + nextHtml);
2015-09-02 15:08:58 -04:00
}
} else if (nextChildren != null) {
this.updateChildren(nextChildren, transaction, context);
}
},
/**
* Destroys all event registrations for this instance. Does not remove from
* the DOM. That must be done by the parent.
*
* @internal
*/
2015-10-14 22:58:32 -04:00
unmountComponent: function () {
switch (this._tag) {
case 'iframe':
case 'img':
case 'form':
case 'video':
case 'audio':
var listeners = this._wrapperState.listeners;
if (listeners) {
for (var i = 0; i < listeners.length; i++) {
listeners[i].remove();
}
}
break;
case 'input':
ReactDOMInput.unmountWrapper(this);
break;
case 'html':
case 'head':
case 'body':
/**
* 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.
*/
!false ? "development" !== 'production' ? 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._tag) : invariant(false) : undefined;
break;
}
2015-09-02 15:08:58 -04:00
this.unmountChildren();
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
this._rootNodeID = null;
2015-10-14 22:58:32 -04:00
this._wrapperState = null;
if (this._nodeWithLegacyProperties) {
var node = this._nodeWithLegacyProperties;
node._reactInternalComponent = null;
this._nodeWithLegacyProperties = null;
}
},
getPublicInstance: function () {
if (!this._nodeWithLegacyProperties) {
var node = ReactMount.getNode(this._rootNodeID);
node._reactInternalComponent = this;
node.getDOMNode = legacyGetDOMNode;
node.isMounted = legacyIsMounted;
node.setState = legacySetStateEtc;
node.replaceState = legacySetStateEtc;
node.forceUpdate = legacySetStateEtc;
node.setProps = legacySetProps;
node.replaceProps = legacyReplaceProps;
if ("development" !== 'production') {
if (canDefineProperty) {
Object.defineProperties(node, legacyPropsDescriptor);
} else {
// updateComponent will update this property on subsequent renders
node.props = this._currentElement.props;
}
} else {
// updateComponent will update this property on subsequent renders
node.props = this._currentElement.props;
}
this._nodeWithLegacyProperties = node;
}
return this._nodeWithLegacyProperties;
2015-09-02 15:08:58 -04:00
}
};
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
mountComponent: 'mountComponent',
updateComponent: 'updateComponent'
});
2015-10-14 22:58:32 -04:00
assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin);
2015-09-02 15:08:58 -04:00
module.exports = ReactDOMComponent;
2015-10-14 22:58:32 -04:00
},{"10":10,"11":11,"120":120,"132":132,"137":137,"138":138,"143":143,"15":15,"160":160,"165":165,"170":170,"172":172,"2":2,"24":24,"28":28,"35":35,"41":41,"46":46,"47":47,"48":48,"5":5,"52":52,"72":72,"73":73,"78":78,"95":95}],43:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactDOMFactories
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var ReactElementValidator = _dereq_(58);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var mapObject = _dereq_(166);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Create a factory that creates HTML tag elements.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {string} tag Tag name (e.g. `div`).
2015-09-02 15:08:58 -04:00
* @private
*/
2015-10-14 22:58:32 -04:00
function createDOMFactory(tag) {
if ("development" !== 'production') {
return ReactElementValidator.createFactory(tag);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return ReactElement.createFactory(tag);
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
* This is also accessible via `React.DOM`.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @public
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var ReactDOMFactories = 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',
hgroup: 'hgroup',
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',
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// SVG
circle: 'circle',
clipPath: 'clipPath',
defs: 'defs',
ellipse: 'ellipse',
g: 'g',
image: 'image',
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'
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
}, createDOMFactory);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactDOMFactories;
},{"166":166,"57":57,"58":58}],44:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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 ReactDOMFeatureFlags
*/
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var ReactDOMFeatureFlags = {
useCreateElement: false
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactDOMFeatureFlags;
},{}],45:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactDOMIDOperations
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var DOMChildrenOperations = _dereq_(9);
var DOMPropertyOperations = _dereq_(11);
var ReactMount = _dereq_(72);
var ReactPerf = _dereq_(78);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
/**
* 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()`.'
};
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Operations used to process updates to DOM nodes.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var ReactDOMIDOperations = {
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* 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: function (id, name, value) {
var node = ReactMount.getNode(id);
!!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? "development" !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
// 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);
}
},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* 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: function (id, markup) {
var node = ReactMount.getNode(id);
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
/**
* 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: function (updates, markup) {
for (var i = 0; i < updates.length; i++) {
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
}
DOMChildrenOperations.processUpdates(updates, markup);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactDOMIDOperations;
},{"11":11,"160":160,"72":72,"78":78,"9":9}],46:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactDOMIDOperations = _dereq_(45);
var LinkedValueUtils = _dereq_(23);
var ReactMount = _dereq_(72);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var instancesByReactID = {};
function forceUpdateIfMounted() {
2015-10-14 22:58:32 -04:00
if (this._rootNodeID) {
// DOM component is still mounted; update
ReactDOMInput.updateWrapper(this);
2015-09-02 15:08:58 -04:00
}
}
/**
* 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
*/
2015-10-14 22:58:32 -04:00
var ReactDOMInput = {
getNativeProps: function (inst, props, context) {
var value = LinkedValueUtils.getValue(props);
var checked = LinkedValueUtils.getChecked(props);
var nativeProps = assign({}, props, {
defaultChecked: undefined,
defaultValue: undefined,
value: value != null ? value : inst._wrapperState.initialValue,
checked: checked != null ? checked : inst._wrapperState.initialChecked,
onChange: inst._wrapperState.onChange
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
return nativeProps;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
mountWrapper: function (inst, props) {
if ("development" !== 'production') {
LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var defaultValue = props.defaultValue;
inst._wrapperState = {
initialChecked: props.defaultChecked || false,
initialValue: defaultValue != null ? defaultValue : null,
onChange: _handleChange.bind(inst)
};
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
mountReadyWrapper: function (inst) {
// Can't be in mountWrapper or else server rendering leaks.
instancesByReactID[inst._rootNodeID] = inst;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
unmountWrapper: function (inst) {
delete instancesByReactID[inst._rootNodeID];
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
updateWrapper: function (inst) {
var props = inst._currentElement.props;
// TODO: Shouldn't this be getChecked(props)?
var checked = props.checked;
if (checked != null) {
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'checked', checked || false);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var value = LinkedValueUtils.getValue(props);
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
}
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function _handleChange(event) {
var props = this._currentElement.props;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var returnValue = LinkedValueUtils.executeOnChange(props, event);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var name = props.name;
if (props.type === 'radio' && name != null) {
var rootNode = ReactMount.getNode(this._rootNodeID);
var queryRoot = rootNode;
while (queryRoot.parentNode) {
queryRoot = queryRoot.parentNode;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
// 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; i < group.length; i++) {
var otherNode = group[i];
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
continue;
}
// This will throw if radio buttons rendered by different copies of React
// and the same name are rendered into the same form (same as #1939).
// That's probably okay; we don't support it just as we don't support
// mixing React with non-React.
var otherID = ReactMount.getID(otherNode);
!otherID ? "development" !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(false) : undefined;
var otherInstance = instancesByReactID[otherID];
!otherInstance ? "development" !== 'production' ? invariant(false, 'ReactDOMInput: Unknown radio button ID %s.', otherID) : invariant(false) : undefined;
// 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);
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return returnValue;
}
2015-09-02 15:08:58 -04:00
module.exports = ReactDOMInput;
2015-10-14 22:58:32 -04:00
},{"160":160,"23":23,"24":24,"45":45,"72":72,"96":96}],47:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactChildren = _dereq_(32);
var ReactDOMSelect = _dereq_(48);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var valueContextKey = ReactDOMSelect.valueContextKey;
2015-09-02 15:08:58 -04:00
/**
* Implements an <option> native component that warns when `selected` is set.
*/
2015-10-14 22:58:32 -04:00
var ReactDOMOption = {
mountWrapper: function (inst, props, context) {
2015-09-02 15:08:58 -04:00
// TODO (yungsters): Remove support for `selected` in <option>.
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : undefined;
}
// Look up whether this option is 'selected' via context
var selectValue = context[valueContextKey];
// If context key is null (e.g., no specified value or after initial mount)
// or missing (e.g., for <datalist>), we don't change props.selected
var selected = null;
if (selectValue != null) {
selected = false;
if (Array.isArray(selectValue)) {
// multiple
for (var i = 0; i < selectValue.length; i++) {
if ('' + selectValue[i] === '' + props.value) {
selected = true;
break;
}
}
} else {
selected = '' + selectValue === '' + props.value;
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
inst._wrapperState = { selected: selected };
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
getNativeProps: function (inst, props, context) {
var nativeProps = assign({ selected: undefined, children: undefined }, props);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Read state only from initial mount because <select> updates value
// manually; we need the initial state only for server rendering
if (inst._wrapperState.selected != null) {
nativeProps.selected = inst._wrapperState.selected;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var content = '';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Flatten children and warn if they aren't strings or numbers;
// invalid types are ignored.
ReactChildren.forEach(props.children, function (child) {
if (child == null) {
return;
}
if (typeof child === 'string' || typeof child === 'number') {
content += child;
} else {
"development" !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : undefined;
}
});
nativeProps.children = content;
return nativeProps;
}
};
module.exports = ReactDOMOption;
},{"172":172,"24":24,"32":32,"48":48}],48:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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
2015-09-02 15:08:58 -04:00
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactDOMSelect
*/
'use strict';
2015-10-14 22:58:32 -04:00
var LinkedValueUtils = _dereq_(23);
var ReactMount = _dereq_(72);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2);
2015-09-02 15:08:58 -04:00
function updateOptionsIfPendingUpdateAndMounted() {
2015-10-14 22:58:32 -04:00
if (this._rootNodeID && this._wrapperState.pendingUpdate) {
this._wrapperState.pendingUpdate = false;
var props = this._currentElement.props;
var value = LinkedValueUtils.getValue(props);
if (value != null) {
updateOptions(this, props, value);
}
}
}
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
return '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var valuePropNames = ['value', 'defaultValue'];
2015-09-02 15:08:58 -04:00
/**
* Validation function for `value` and `defaultValue`.
* @private
*/
2015-10-14 22:58:32 -04:00
function checkSelectPropTypes(inst, props) {
var owner = inst._currentElement._owner;
LinkedValueUtils.checkPropTypes('select', props, owner);
for (var i = 0; i < valuePropNames.length; i++) {
var propName = valuePropNames[i];
if (props[propName] == null) {
continue;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (props.multiple) {
"development" !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
} else {
"development" !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
/**
2015-10-14 22:58:32 -04:00
* @param {ReactDOMComponent} inst
* @param {boolean} multiple
2015-09-02 15:08:58 -04:00
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
* @private
*/
2015-10-14 22:58:32 -04:00
function updateOptions(inst, multiple, propValue) {
var selectedValue, i;
var options = ReactMount.getNode(inst._rootNodeID).options;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (multiple) {
2015-09-02 15:08:58 -04:00
selectedValue = {};
2015-10-14 22:58:32 -04:00
for (i = 0; i < propValue.length; i++) {
2015-09-02 15:08:58 -04:00
selectedValue['' + propValue[i]] = true;
}
2015-10-14 22:58:32 -04:00
for (i = 0; i < options.length; i++) {
2015-09-02 15:08:58 -04:00
var selected = selectedValue.hasOwnProperty(options[i].value);
if (options[i].selected !== selected) {
options[i].selected = selected;
}
}
} else {
// Do not set `select.value` as exact behavior isn't consistent across all
// browsers for all cases.
selectedValue = '' + propValue;
2015-10-14 22:58:32 -04:00
for (i = 0; i < options.length; i++) {
2015-09-02 15:08:58 -04:00
if (options[i].value === selectedValue) {
options[i].selected = true;
return;
}
}
if (options.length) {
options[0].selected = true;
}
}
}
/**
* Implements a <select> native component that allows optionally setting the
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
* stringable. If `multiple` is true, the prop must be an array of stringables.
*
* 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.
*/
2015-10-14 22:58:32 -04:00
var ReactDOMSelect = {
valueContextKey: valueContextKey,
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
getNativeProps: function (inst, props, context) {
return assign({}, props, {
onChange: inst._wrapperState.onChange,
value: undefined
});
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
mountWrapper: function (inst, props) {
if ("development" !== 'production') {
checkSelectPropTypes(inst, props);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var value = LinkedValueUtils.getValue(props);
inst._wrapperState = {
pendingUpdate: false,
initialValue: value != null ? value : props.defaultValue,
onChange: _handleChange.bind(inst),
wasMultiple: Boolean(props.multiple)
};
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
processChildContext: function (inst, props, context) {
// Pass down initial value so initial generated markup has correct
// `selected` attributes
var childContext = assign({}, context);
childContext[valueContextKey] = inst._wrapperState.initialValue;
return childContext;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
postUpdateWrapper: function (inst) {
var props = inst._currentElement.props;
// After the initial mount, we control selected-ness manually so don't pass
// the context value down
inst._wrapperState.initialValue = undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var wasMultiple = inst._wrapperState.wasMultiple;
inst._wrapperState.wasMultiple = Boolean(props.multiple);
var value = LinkedValueUtils.getValue(props);
2015-09-02 15:08:58 -04:00
if (value != null) {
2015-10-14 22:58:32 -04:00
inst._wrapperState.pendingUpdate = false;
updateOptions(inst, Boolean(props.multiple), value);
} else if (wasMultiple !== Boolean(props.multiple)) {
2015-09-02 15:08:58 -04:00
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
2015-10-14 22:58:32 -04:00
if (props.defaultValue != null) {
updateOptions(inst, Boolean(props.multiple), props.defaultValue);
2015-09-02 15:08:58 -04:00
} else {
// Revert the select back to its default unselected state.
2015-10-14 22:58:32 -04:00
updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
2015-09-02 15:08:58 -04:00
}
}
}
2015-10-14 22:58:32 -04:00
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function _handleChange(event) {
var props = this._currentElement.props;
var returnValue = LinkedValueUtils.executeOnChange(props, event);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
this._wrapperState.pendingUpdate = true;
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
return returnValue;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactDOMSelect;
},{"172":172,"23":23,"24":24,"72":72,"96":96}],49:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getNodeForCharacterOffset = _dereq_(129);
var getTextContentAccessor = _dereq_(130);
2015-09-02 15:08:58 -04:00
/**
* 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);
2015-10-14 22:58:32 -04:00
// In Firefox, range.startContainer and range.endContainer can be "anonymous
// divs", e.g. the up/down buttons on an <input type="number">. Anonymous
// divs do not seem to expose properties, triggering a "Permission denied
// error" if any of its properties are accessed. The only seemingly possible
// way to avoid erroring is to access a property that typically works for
// non-anonymous divs and catch any error that may otherwise arise. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=208427
try {
/* eslint-disable no-unused-expressions */
currentRange.startContainer.nodeType;
currentRange.endContainer.nodeType;
/* eslint-enable no-unused-expressions */
} catch (e) {
return null;
}
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
2015-09-02 15:08:58 -04:00
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
var tempRange = currentRange.cloneRange();
tempRange.selectNodeContents(node);
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
2015-10-14 22:58:32 -04:00
var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset);
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
var end = typeof offsets.end === 'undefined' ? start : Math.min(offsets.end, length);
2015-09-02 15:08:58 -04:00
// 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);
}
}
}
2015-10-14 22:58:32 -04:00
var useIEOffsets = ExecutionEnvironment.canUseDOM && 'selection' in document && !('getSelection' in window);
2015-09-02 15:08:58 -04:00
var ReactDOMSelection = {
/**
* @param {DOMElement} node
*/
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
/**
* @param {DOMElement|DOMTextNode} node
* @param {object} offsets
*/
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
};
module.exports = ReactDOMSelection;
2015-10-14 22:58:32 -04:00
},{"129":129,"130":130,"146":146}],50:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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 ReactDOMServer
*/
'use strict';
var ReactDefaultInjection = _dereq_(54);
var ReactServerRendering = _dereq_(88);
var ReactVersion = _dereq_(97);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
ReactDefaultInjection.inject();
var ReactDOMServer = {
renderToString: ReactServerRendering.renderToString,
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
version: ReactVersion
};
module.exports = ReactDOMServer;
},{"54":54,"88":88,"97":97}],51:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ReactDOMTextComponent
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var DOMChildrenOperations = _dereq_(9);
var DOMPropertyOperations = _dereq_(11);
var ReactComponentBrowserEnvironment = _dereq_(35);
var ReactMount = _dereq_(72);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var escapeTextContentForBrowser = _dereq_(120);
var setTextContent = _dereq_(138);
var validateDOMNesting = _dereq_(143);
2015-09-02 15:08:58 -04:00
/**
* 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 ReactDOMTextComponent
* @extends ReactComponent
* @internal
*/
2015-10-14 22:58:32 -04:00
var ReactDOMTextComponent = function (props) {
2015-09-02 15:08:58 -04:00
// This constructor and its argument is currently used by mocks.
};
assign(ReactDOMTextComponent.prototype, {
/**
* @param {ReactText} text
* @internal
*/
2015-10-14 22:58:32 -04:00
construct: function (text) {
2015-09-02 15:08:58 -04:00
// TODO: This is really a ReactText (ReactNode), not a ReactElement
this._currentElement = text;
this._stringText = '' + text;
// Properties
this._rootNodeID = null;
this._mountIndex = 0;
},
/**
* 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
* @return {string} Markup for this text node.
* @internal
*/
2015-10-14 22:58:32 -04:00
mountComponent: function (rootID, transaction, context) {
if ("development" !== 'production') {
if (context[validateDOMNesting.ancestorInfoContextKey]) {
validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
}
}
2015-09-02 15:08:58 -04:00
this._rootNodeID = rootID;
2015-10-14 22:58:32 -04:00
if (transaction.useCreateElement) {
var ownerDocument = context[ReactMount.ownerDocumentContextKey];
var el = ownerDocument.createElement('span');
DOMPropertyOperations.setAttributeForID(el, rootID);
// Populate node cache
ReactMount.getID(el);
setTextContent(el, this._stringText);
return el;
} else {
var escapedText = escapeTextContentForBrowser(this._stringText);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
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;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>';
}
2015-09-02 15:08:58 -04:00
},
/**
* Updates this component by updating the text content.
*
* @param {ReactText} nextText The next text content
* @param {ReactReconcileTransaction} transaction
* @internal
*/
2015-10-14 22:58:32 -04:00
receiveComponent: function (nextText, transaction) {
2015-09-02 15:08:58 -04:00
if (nextText !== this._currentElement) {
this._currentElement = nextText;
var nextStringText = '' + nextText;
if (nextStringText !== this._stringText) {
// TODO: Save this as pending props and use performUpdateIfNecessary
// and/or updateComponent to do the actual update for consistency with
// other component types?
this._stringText = nextStringText;
2015-10-14 22:58:32 -04:00
var node = ReactMount.getNode(this._rootNodeID);
DOMChildrenOperations.updateTextContent(node, nextStringText);
2015-09-02 15:08:58 -04:00
}
}
},
2015-10-14 22:58:32 -04:00
unmountComponent: function () {
2015-09-02 15:08:58 -04:00
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
}
});
module.exports = ReactDOMTextComponent;
2015-10-14 22:58:32 -04:00
},{"11":11,"120":120,"138":138,"143":143,"24":24,"35":35,"72":72,"9":9}],52:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var LinkedValueUtils = _dereq_(23);
var ReactDOMIDOperations = _dereq_(45);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
function forceUpdateIfMounted() {
2015-10-14 22:58:32 -04:00
if (this._rootNodeID) {
// DOM component is still mounted; update
ReactDOMTextarea.updateWrapper(this);
2015-09-02 15:08:58 -04:00
}
}
/**
* 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).
*/
2015-10-14 22:58:32 -04:00
var ReactDOMTextarea = {
getNativeProps: function (inst, props, context) {
!(props.dangerouslySetInnerHTML == null) ? "development" !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
// Always set children to the same thing. In IE9, the selection range will
// get reset if `textContent` is mutated.
var nativeProps = assign({}, props, {
defaultValue: undefined,
value: undefined,
children: inst._wrapperState.initialValue,
onChange: inst._wrapperState.onChange
});
return nativeProps;
},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
mountWrapper: function (inst, props) {
if ("development" !== 'production') {
LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var defaultValue = props.defaultValue;
2015-09-02 15:08:58 -04:00
// TODO (yungsters): Remove support for children content in <textarea>.
2015-10-14 22:58:32 -04:00
var children = props.children;
2015-09-02 15:08:58 -04:00
if (children != null) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
!(defaultValue == null) ? "development" !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
if (Array.isArray(children)) {
2015-10-14 22:58:32 -04:00
!(children.length <= 1) ? "development" !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
children = children[0];
}
defaultValue = '' + children;
}
if (defaultValue == null) {
defaultValue = '';
}
2015-10-14 22:58:32 -04:00
var value = LinkedValueUtils.getValue(props);
inst._wrapperState = {
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
initialValue: '' + (value != null ? value : defaultValue),
onChange: _handleChange.bind(inst)
2015-09-02 15:08:58 -04:00
};
},
2015-10-14 22:58:32 -04:00
updateWrapper: function (inst) {
var props = inst._currentElement.props;
var value = LinkedValueUtils.getValue(props);
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function _handleChange(event) {
var props = this._currentElement.props;
var returnValue = LinkedValueUtils.executeOnChange(props, event);
ReactUpdates.asap(forceUpdateIfMounted, this);
return returnValue;
}
2015-09-02 15:08:58 -04:00
module.exports = ReactDOMTextarea;
2015-10-14 22:58:32 -04:00
},{"160":160,"172":172,"23":23,"24":24,"45":45,"96":96}],53:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactUpdates = _dereq_(96);
var Transaction = _dereq_(113);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
2015-09-02 15:08:58 -04:00
var RESET_BATCHED_UPDATES = {
initialize: emptyFunction,
2015-10-14 22:58:32 -04:00
close: function () {
2015-09-02 15:08:58 -04:00
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();
}
2015-10-14 22:58:32 -04:00
assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction.Mixin, {
getTransactionWrappers: function () {
return TRANSACTION_WRAPPERS;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
});
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
batchedUpdates: function (callback, a, b, c, d, e) {
2015-09-02 15:08:58 -04:00
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
ReactDefaultBatchingStrategy.isBatchingUpdates = true;
// The code is written this way to avoid extra allocations
if (alreadyBatchingUpdates) {
2015-10-14 22:58:32 -04:00
callback(a, b, c, d, e);
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
transaction.perform(callback, null, a, b, c, d, e);
2015-09-02 15:08:58 -04:00
}
}
};
module.exports = ReactDefaultBatchingStrategy;
2015-10-14 22:58:32 -04:00
},{"113":113,"152":152,"24":24,"96":96}],54:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 = _dereq_(3);
2015-10-14 22:58:32 -04:00
var ChangeEventPlugin = _dereq_(7);
var ClientReactRootIndex = _dereq_(8);
var DefaultEventPluginOrder = _dereq_(13);
var EnterLeaveEventPlugin = _dereq_(14);
var ExecutionEnvironment = _dereq_(146);
var HTMLDOMPropertyConfig = _dereq_(21);
var ReactBrowserComponentMixin = _dereq_(27);
var ReactComponentBrowserEnvironment = _dereq_(35);
var ReactDefaultBatchingStrategy = _dereq_(53);
var ReactDOMComponent = _dereq_(42);
var ReactDOMTextComponent = _dereq_(51);
var ReactEventListener = _dereq_(63);
var ReactInjection = _dereq_(65);
var ReactInstanceHandles = _dereq_(67);
var ReactMount = _dereq_(72);
var ReactReconcileTransaction = _dereq_(83);
var SelectEventPlugin = _dereq_(99);
var ServerReactRootIndex = _dereq_(100);
var SimpleEventPlugin = _dereq_(101);
var SVGDOMPropertyConfig = _dereq_(98);
var alreadyInjected = false;
2015-09-02 15:08:58 -04:00
function inject() {
2015-10-14 22:58:32 -04:00
if (alreadyInjected) {
// TODO: This is currently true because these injections are shared between
// the client and the server package. They should be built independently
// and not share any injection state. Then this problem will be solved.
return;
}
alreadyInjected = true;
ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);
2015-09-02 15:08:58 -04:00
/**
* 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,
SelectEventPlugin: SelectEventPlugin,
BeforeInputEventPlugin: BeforeInputEventPlugin
});
2015-10-14 22:58:32 -04:00
ReactInjection.NativeComponent.injectGenericComponentClass(ReactDOMComponent);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent);
2015-09-02 15:08:58 -04:00
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
2015-10-14 22:58:32 -04:00
ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
2015-09-02 15:08:58 -04:00
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
if (/[?&]react_perf\b/.test(url)) {
var ReactDefaultPerf = _dereq_(55);
2015-09-02 15:08:58 -04:00
ReactDefaultPerf.start();
}
}
}
module.exports = {
inject: inject
};
2015-10-14 22:58:32 -04:00
},{"100":100,"101":101,"13":13,"14":14,"146":146,"21":21,"27":27,"3":3,"35":35,"42":42,"51":51,"53":53,"55":55,"63":63,"65":65,"67":67,"7":7,"72":72,"8":8,"83":83,"98":98,"99":99}],55:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
var ReactDefaultPerfAnalysis = _dereq_(56);
var ReactMount = _dereq_(72);
var ReactPerf = _dereq_(78);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var performanceNow = _dereq_(169);
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
start: function () {
2015-09-02 15:08:58 -04:00
if (!ReactDefaultPerf._injected) {
ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
}
ReactDefaultPerf._allMeasurements.length = 0;
ReactPerf.enableMeasure = true;
},
2015-10-14 22:58:32 -04:00
stop: function () {
2015-09-02 15:08:58 -04:00
ReactPerf.enableMeasure = false;
},
2015-10-14 22:58:32 -04:00
getLastMeasurements: function () {
2015-09-02 15:08:58 -04:00
return ReactDefaultPerf._allMeasurements;
},
2015-10-14 22:58:32 -04:00
printExclusive: function (measurements) {
2015-09-02 15:08:58 -04:00
measurements = measurements || ReactDefaultPerf._allMeasurements;
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
2015-10-14 22:58:32 -04:00
console.table(summary.map(function (item) {
2015-09-02 15:08:58 -04:00
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.
},
2015-10-14 22:58:32 -04:00
printInclusive: function (measurements) {
2015-09-02 15:08:58 -04:00
measurements = measurements || ReactDefaultPerf._allMeasurements;
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
2015-10-14 22:58:32 -04:00
console.table(summary.map(function (item) {
2015-09-02 15:08:58 -04:00
return {
'Owner > component': item.componentName,
'Inclusive time (ms)': roundFloat(item.time),
'Instances': item.count
};
}));
2015-10-14 22:58:32 -04:00
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
},
getMeasurementsSummaryMap: function (measurements) {
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true);
return summary.map(function (item) {
2015-09-02 15:08:58 -04:00
return {
'Owner > component': item.componentName,
'Wasted time (ms)': item.time,
'Instances': item.count
};
});
},
2015-10-14 22:58:32 -04:00
printWasted: function (measurements) {
2015-09-02 15:08:58 -04:00
measurements = measurements || ReactDefaultPerf._allMeasurements;
console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
2015-10-14 22:58:32 -04:00
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
printDOM: function (measurements) {
2015-09-02 15:08:58 -04:00
measurements = measurements || ReactDefaultPerf._allMeasurements;
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
2015-10-14 22:58:32 -04:00
console.table(summary.map(function (item) {
2015-09-02 15:08:58 -04:00
var result = {};
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
2015-10-14 22:58:32 -04:00
result.type = item.type;
result.args = JSON.stringify(item.args);
2015-09-02 15:08:58 -04:00
return result;
}));
2015-10-14 22:58:32 -04:00
console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
_recordWrite: function (id, fnName, totalTime, args) {
2015-09-02 15:08:58 -04:00
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
2015-10-14 22:58:32 -04:00
var writes = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].writes;
2015-09-02 15:08:58 -04:00
writes[id] = writes[id] || [];
writes[id].push({
type: fnName,
time: totalTime,
args: args
});
},
2015-10-14 22:58:32 -04:00
measure: function (moduleName, fnName, func) {
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
2015-09-02 15:08:58 -04:00
var totalTime;
var rv;
var start;
2015-10-14 22:58:32 -04:00
if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') {
2015-09-02 15:08:58 -04:00
// 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: {},
2015-10-14 22:58:32 -04:00
totalTime: 0,
created: {}
2015-09-02 15:08:58 -04:00
});
start = performanceNow();
rv = func.apply(this, args);
2015-10-14 22:58:32 -04:00
ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].totalTime = performanceNow() - start;
2015-09-02 15:08:58 -04:00
return rv;
2015-10-14 22:58:32 -04:00
} else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactBrowserEventEmitter' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations') {
2015-09-02 15:08:58 -04:00
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
2015-10-14 22:58:32 -04:00
args[0].forEach(function (update) {
2015-09-02 15:08:58 -04:00
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];
}
2015-10-14 22:58:32 -04:00
ReactDefaultPerf._recordWrite(update.parentID, update.type, totalTime, writeArgs);
2015-09-02 15:08:58 -04:00
});
} else {
// basic format
2015-10-14 22:58:32 -04:00
var id = args[0];
if (typeof id === 'object') {
id = ReactMount.getID(args[0]);
}
ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
2015-09-02 15:08:58 -04:00
}
return rv;
2015-10-14 22:58:32 -04:00
} else if (moduleName === 'ReactCompositeComponent' && (fnName === 'mountComponent' || fnName === 'updateComponent' || // TODO: receiveComponent()?
fnName === '_renderValidatedComponent')) {
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (this._currentElement.type === ReactMount.TopLevelWrapper) {
2015-09-02 15:08:58 -04:00
return func.apply(this, args);
}
2015-10-14 22:58:32 -04:00
var rootNodeID = fnName === 'mountComponent' ? args[0] : this._rootNodeID;
2015-09-02 15:08:58 -04:00
var isRender = fnName === '_renderValidatedComponent';
var isMount = fnName === 'mountComponent';
var mountStack = ReactDefaultPerf._mountStack;
2015-10-14 22:58:32 -04:00
var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
2015-09-02 15:08:58 -04:00
if (isRender) {
addValue(entry.counts, rootNodeID, 1);
} else if (isMount) {
2015-10-14 22:58:32 -04:00
entry.created[rootNodeID] = true;
2015-09-02 15:08:58 -04:00
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.getName(),
2015-10-14 22:58:32 -04:00
owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>'
2015-09-02 15:08:58 -04:00
};
return rv;
} else {
return func.apply(this, args);
}
};
}
};
module.exports = ReactDefaultPerf;
2015-10-14 22:58:32 -04:00
},{"10":10,"169":169,"56":56,"72":72,"78":78}],56:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
2015-10-14 22:58:32 -04:00
'use strict';
var assign = _dereq_(24);
2015-09-02 15:08:58 -04:00
// 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',
2015-10-14 22:58:32 -04:00
SET_MARKUP: 'set innerHTML',
2015-09-02 15:08:58 -04:00
TEXT_CONTENT: 'set textContent',
2015-10-14 22:58:32 -04:00
'setValueForProperty': 'update attribute',
'setValueForAttribute': 'update attribute',
'deleteValueForProperty': 'remove attribute',
2015-09-02 15:08:58 -04:00
'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 = [];
2015-10-14 22:58:32 -04:00
measurements.forEach(function (measurement) {
Object.keys(measurement.writes).forEach(function (id) {
measurement.writes[id].forEach(function (write) {
2015-09-02 15:08:58 -04:00
items.push({
id: id,
type: DOM_OPERATION_TYPES[write.type] || write.type,
args: write.args
});
});
2015-10-14 22:58:32 -04:00
});
});
2015-09-02 15:08:58 -04:00
return items;
}
function getExclusiveSummary(measurements) {
var candidates = {};
var displayName;
for (var i = 0; i < measurements.length; i++) {
var measurement = measurements[i];
2015-10-14 22:58:32 -04:00
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
2015-09-02 15:08:58 -04:00
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]);
}
}
2015-10-14 22:58:32 -04:00
arr.sort(function (a, b) {
2015-09-02 15:08:58 -04:00
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];
2015-10-14 22:58:32 -04:00
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
2015-09-02 15:08:58 -04:00
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]);
}
}
2015-10-14 22:58:32 -04:00
arr.sort(function (a, b) {
2015-09-02 15:08:58 -04:00
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;
}
}
2015-10-14 22:58:32 -04:00
// check if component newly created
if (measurement.created[id]) {
isDirty = true;
}
2015-09-02 15:08:58 -04:00
if (!isDirty && measurement.counts[id] > 0) {
cleanComponents[id] = true;
}
}
return cleanComponents;
}
var ReactDefaultPerfAnalysis = {
getExclusiveSummary: getExclusiveSummary,
getInclusiveSummary: getInclusiveSummary,
getDOMSummary: getDOMSummary,
getTotalTime: getTotalTime
};
module.exports = ReactDefaultPerfAnalysis;
2015-10-14 22:58:32 -04:00
},{"24":24}],57:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactCurrentOwner = _dereq_(39);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
// The Symbol used to tag the ReactElement type. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
2015-09-02 15:08:58 -04:00
var RESERVED_PROPS = {
key: true,
2015-10-14 22:58:32 -04:00
ref: true,
__self: true,
__source: true
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var canDefineProperty = false;
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
try {
2015-10-14 22:58:32 -04:00
Object.defineProperty({}, 'x', {});
canDefineProperty = true;
2015-09-02 15:08:58 -04:00
} 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 {*} key
2015-10-14 22:58:32 -04:00
* @param {string|object} ref
* @param {*} self A *temporary* helper to detect places where `this` is
* different from the `owner` when React.createElement is called, so that we
* can warn. We want to get rid of owner and replace string `ref`s with arrow
* functions, and as long as `this` and owner are the same, there will be no
* change in behavior.
* @param {*} source An annotation object (added by a transpiler or otherwise)
* indicating filename, line number, and/or other information.
* @param {*} owner
2015-09-02 15:08:58 -04:00
* @param {*} props
* @internal
*/
2015-10-14 22:58:32 -04:00
var ReactElement = function (type, key, ref, self, source, owner, props) {
var element = {
// This tag allow us to uniquely identify this as a React Element
$$typeof: REACT_ELEMENT_TYPE,
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Built-in properties that belong on the element
type: type,
key: key,
ref: ref,
props: props,
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Record the component responsible for creating this element.
_owner: owner
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
// The validation flag is currently mutative. We put it on
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
element._store = {};
2015-09-02 15:08:58 -04:00
// To make comparing ReactElements easier for testing purposes, we make
// the validation flag non-enumerable (where possible, which should
// include every environment we run tests in), so the test framework
// ignores it.
2015-10-14 22:58:32 -04:00
if (canDefineProperty) {
Object.defineProperty(element._store, 'validated', {
2015-09-02 15:08:58 -04:00
configurable: false,
enumerable: false,
2015-10-14 22:58:32 -04:00
writable: true,
value: false
2015-09-02 15:08:58 -04:00
});
2015-10-14 22:58:32 -04:00
// self and source are DEV only properties.
Object.defineProperty(element, '_self', {
configurable: false,
enumerable: false,
writable: false,
value: self
});
// Two elements created in two different places should be considered
// equal for testing purposes and therefore we hide it from enumeration.
Object.defineProperty(element, '_source', {
configurable: false,
enumerable: false,
writable: false,
value: source
});
} else {
element._store.validated = false;
element._self = self;
element._source = source;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
Object.freeze(element.props);
Object.freeze(element);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return element;
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
ReactElement.createElement = function (type, config, children) {
2015-09-02 15:08:58 -04:00
var propName;
// Reserved names are extracted
var props = {};
var key = null;
var ref = null;
2015-10-14 22:58:32 -04:00
var self = null;
var source = null;
2015-09-02 15:08:58 -04:00
if (config != null) {
ref = config.ref === undefined ? null : config.ref;
key = config.key === undefined ? null : '' + config.key;
2015-10-14 22:58:32 -04:00
self = config.__self === undefined ? null : config.__self;
source = config.__source === undefined ? null : config.__source;
2015-09-02 15:08:58 -04:00
// Remaining properties are added to a new props object
for (propName in config) {
2015-10-14 22:58:32 -04:00
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
2015-09-02 15:08:58 -04:00
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];
}
}
}
2015-10-14 22:58:32 -04:00
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
ReactElement.createFactory = function (type) {
2015-09-02 15:08:58 -04:00
var factory = ReactElement.createElement.bind(null, type);
// Expose the type on the factory and the prototype so that it can be
2015-10-14 22:58:32 -04:00
// easily accessed on elements. E.g. `<Foo />.type === Foo`.
2015-09-02 15:08:58 -04:00
// 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.
// Legacy hook TODO: Warn if this is accessed
factory.type = type;
return factory;
};
2015-10-14 22:58:32 -04:00
ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
return newElement;
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// If the key on the original is valid, then the clone is valid
newElement._store.validated = oldElement._store.validated;
}
2015-10-14 22:58:32 -04:00
2015-09-02 15:08:58 -04:00
return newElement;
};
2015-10-14 22:58:32 -04:00
ReactElement.cloneElement = function (element, config, children) {
2015-09-02 15:08:58 -04:00
var propName;
// Original props are copied
var props = assign({}, element.props);
// Reserved names are extracted
var key = element.key;
var ref = element.ref;
2015-10-14 22:58:32 -04:00
// Self is preserved since the owner is preserved.
var self = element._self;
// Source is preserved since cloneElement is unlikely to be targeted by a
// transpiler, and the original source is probably a better indicator of the
// true owner.
var source = element._source;
2015-09-02 15:08:58 -04:00
// Owner will be preserved, unless ref is overridden
var owner = element._owner;
if (config != null) {
if (config.ref !== undefined) {
// Silently steal the ref from the parent.
ref = config.ref;
owner = ReactCurrentOwner.current;
}
if (config.key !== undefined) {
key = '' + config.key;
}
// Remaining properties override existing props
for (propName in config) {
2015-10-14 22:58:32 -04:00
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
return ReactElement(element.type, key, ref, self, source, owner, props);
2015-09-02 15:08:58 -04:00
};
/**
* @param {?object} object
* @return {boolean} True if `object` is a valid component.
* @final
*/
2015-10-14 22:58:32 -04:00
ReactElement.isValidElement = function (object) {
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2015-09-02 15:08:58 -04:00
};
module.exports = ReactElement;
2015-10-14 22:58:32 -04:00
},{"24":24,"39":39}],58:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var ReactPropTypeLocations = _dereq_(81);
var ReactPropTypeLocationNames = _dereq_(80);
var ReactCurrentOwner = _dereq_(39);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getIteratorFn = _dereq_(128);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
function getDeclarationErrorAddendum() {
if (ReactCurrentOwner.current) {
var name = ReactCurrentOwner.current.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
}
/**
* 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 = {};
var loggedTypeFailures = {};
/**
* Warn if the element doesn't have an explicit key assigned to it.
* This element 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 {ReactElement} element Element that requires a key.
* @param {*} parentType element's parent's type.
*/
function validateExplicitKey(element, parentType) {
2015-10-14 22:58:32 -04:00
if (!element._store || element._store.validated || element.key != null) {
2015-09-02 15:08:58 -04:00
return;
}
element._store.validated = true;
2015-10-14 22:58:32 -04:00
var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
if (addenda === null) {
// we already showed the warning
2015-09-02 15:08:58 -04:00
return;
}
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
2015-09-02 15:08:58 -04:00
}
/**
* Shared warning and monitoring code for the key warnings.
*
* @internal
2015-10-14 22:58:32 -04:00
* @param {string} messageType A key used for de-duping warnings.
2015-09-02 15:08:58 -04:00
* @param {ReactElement} element Component that requires a key.
* @param {*} parentType element's parent's type.
2015-10-14 22:58:32 -04:00
* @returns {?object} A set of addenda to use in the warning message, or null
* if the warning has already been shown before (and shouldn't be shown again).
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getAddendaForKeyUse(messageType, element, parentType) {
var addendum = getDeclarationErrorAddendum();
if (!addendum) {
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
if (parentName) {
addendum = ' Check the top-level render call using <' + parentName + '>.';
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
if (memoizer[addendum]) {
return null;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
memoizer[addendum] = true;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var addenda = {
parentOrOwner: addendum,
url: ' See https://fb.me/react-warning-keys for more information.',
childOwner: null
};
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
// Give the component that originally created this child.
addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return addenda;
2015-09-02 15:08:58 -04:00
}
/**
* Ensure that every element 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 {ReactNode} node Statically passed child of any type.
* @param {*} parentType node's parent's type.
*/
function validateChildKeys(node, parentType) {
2015-10-14 22:58:32 -04:00
if (typeof node !== 'object') {
return;
}
2015-09-02 15:08:58 -04:00
if (Array.isArray(node)) {
for (var i = 0; i < node.length; i++) {
var child = node[i];
if (ReactElement.isValidElement(child)) {
validateExplicitKey(child, parentType);
}
}
} else if (ReactElement.isValidElement(node)) {
// This element was passed in a valid location.
2015-10-14 22:58:32 -04:00
if (node._store) {
node._store.validated = true;
}
2015-09-02 15:08:58 -04:00
} else if (node) {
var iteratorFn = getIteratorFn(node);
// Entry iterators provide implicit keys.
if (iteratorFn) {
if (iteratorFn !== node.entries) {
var iterator = iteratorFn.call(node);
var step;
while (!(step = iterator.next()).done) {
if (ReactElement.isValidElement(step.value)) {
validateExplicitKey(step.value, 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 {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
2015-10-14 22:58:32 -04:00
!(typeof propTypes[propName] === 'function') ? "development" !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
error = propTypes[propName](props, propName, componentName, location);
} catch (ex) {
error = ex;
}
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
var addendum = getDeclarationErrorAddendum();
"development" !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
}
/**
* Given an element, validate that its props follow the propTypes definition,
* provided by the type.
*
* @param {ReactElement} element
*/
function validatePropTypes(element) {
2015-10-14 22:58:32 -04:00
var componentClass = element.type;
if (typeof componentClass !== 'function') {
2015-09-02 15:08:58 -04:00
return;
}
var name = componentClass.displayName || componentClass.name;
if (componentClass.propTypes) {
2015-10-14 22:58:32 -04:00
checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
2015-09-02 15:08:58 -04:00
}
if (typeof componentClass.getDefaultProps === 'function') {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
2015-09-02 15:08:58 -04:00
}
}
var ReactElementValidator = {
2015-10-14 22:58:32 -04:00
createElement: function (type, props, children) {
var validType = typeof type === 'string' || typeof type === 'function';
2015-09-02 15:08:58 -04:00
// We warn in this case but don't throw. We expect the element creation to
// succeed and there will likely be errors in render.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
// Skip key warning if the type isn't valid since our key validation logic
// doesn't expect a non-string/function type and can throw confusing errors.
// We don't want exception behavior to differ between dev and prod.
// (Rendering will throw with a helpful message and as soon as the type is
// fixed, the key warnings will appear.)
if (validType) {
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], type);
}
2015-09-02 15:08:58 -04:00
}
validatePropTypes(element);
return element;
},
2015-10-14 22:58:32 -04:00
createFactory: function (type) {
var validatedFactory = ReactElementValidator.createElement.bind(null, type);
2015-09-02 15:08:58 -04:00
// Legacy hook TODO: Warn if this is accessed
validatedFactory.type = type;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
try {
2015-10-14 22:58:32 -04:00
Object.defineProperty(validatedFactory, 'type', {
enumerable: false,
get: function () {
"development" !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
Object.defineProperty(this, 'type', {
value: type
});
return type;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
});
2015-09-02 15:08:58 -04:00
} catch (x) {
// IE will fail on defineProperty (es5-shim/sham too)
}
}
return validatedFactory;
},
2015-10-14 22:58:32 -04:00
cloneElement: function (element, props, children) {
2015-09-02 15:08:58 -04:00
var newElement = ReactElement.cloneElement.apply(this, arguments);
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], newElement.type);
}
validatePropTypes(newElement);
return newElement;
}
};
module.exports = ReactElementValidator;
2015-10-14 22:58:32 -04:00
},{"128":128,"160":160,"172":172,"39":39,"57":57,"80":80,"81":81}],59:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var ReactEmptyComponentRegistry = _dereq_(60);
var ReactReconciler = _dereq_(84);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var placeholderElement;
2015-09-02 15:08:58 -04:00
var ReactEmptyComponentInjection = {
2015-10-14 22:58:32 -04:00
injectEmptyComponent: function (component) {
placeholderElement = ReactElement.createElement(component);
2015-09-02 15:08:58 -04:00
}
};
2015-10-14 22:58:32 -04:00
var ReactEmptyComponent = function (instantiate) {
this._currentElement = null;
this._rootNodeID = null;
this._renderedComponent = instantiate(placeholderElement);
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
assign(ReactEmptyComponent.prototype, {
construct: function (element) {},
mountComponent: function (rootID, transaction, context) {
ReactEmptyComponentRegistry.registerNullComponentID(rootID);
this._rootNodeID = rootID;
return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
},
receiveComponent: function () {},
unmountComponent: function (rootID, transaction, context) {
ReactReconciler.unmountComponent(this._renderedComponent);
ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
this._rootNodeID = null;
this._renderedComponent = null;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
});
ReactEmptyComponent.injection = ReactEmptyComponentInjection;
module.exports = ReactEmptyComponent;
},{"24":24,"57":57,"60":60,"84":84}],60:[function(_dereq_,module,exports){
/**
* Copyright 2014-2015, 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 ReactEmptyComponentRegistry
*/
'use strict';
// This registry keeps track of the React IDs of the components that rendered to
// `null` (in reality a placeholder such as `noscript`)
var nullComponentIDsRegistry = {};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* @param {string} id Component's `_rootNodeID`.
* @return {boolean} True if the component is rendered to null.
*/
function isNullComponentID(id) {
return !!nullComponentIDsRegistry[id];
}
2015-09-02 15:08:58 -04:00
/**
* 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];
}
2015-10-14 22:58:32 -04:00
var ReactEmptyComponentRegistry = {
isNullComponentID: isNullComponentID,
registerNullComponentID: registerNullComponentID,
deregisterNullComponentID: deregisterNullComponentID
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
module.exports = ReactEmptyComponentRegistry;
},{}],61:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
2015-10-14 22:58:32 -04:00
'use strict';
var caughtError = null;
/**
* Call a function while guarding against errors that happens within it.
*
* @param {?String} name of the guard to use for logging or debugging
* @param {Function} func The function to invoke
* @param {*} a First argument
* @param {*} b Second argument
*/
function invokeGuardedCallback(name, func, a, b) {
try {
return func(a, b);
} catch (x) {
if (caughtError === null) {
caughtError = x;
}
return undefined;
}
}
2015-09-02 15:08:58 -04:00
var ReactErrorUtils = {
2015-10-14 22:58:32 -04:00
invokeGuardedCallback: invokeGuardedCallback,
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Invoked by ReactTestUtils.Simulate so that any errors thrown by the event
* handler are sure to be rethrown by rethrowCaughtError.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
invokeGuardedCallbackWithCatch: invokeGuardedCallback,
/**
* During execution of guarded functions we will capture the first error which
* we will rethrow to be handled by the top level error handler.
*/
rethrowCaughtError: function () {
if (caughtError) {
var error = caughtError;
caughtError = null;
throw error;
}
2015-09-02 15:08:58 -04:00
}
};
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
/**
* To help development we can get better devtools integration by simulating a
* real browser event.
*/
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof Event === 'function') {
var fakeNode = document.createElement('react');
ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
var boundFunc = func.bind(null, a, b);
fakeNode.addEventListener(name, boundFunc, false);
fakeNode.dispatchEvent(new Event(name));
fakeNode.removeEventListener(name, boundFunc, false);
};
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactErrorUtils;
},{}],62:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventPluginHub = _dereq_(16);
2015-09-02 15:08:58 -04:00
function runEventQueueInBatch(events) {
EventPluginHub.enqueueEvents(events);
2015-10-14 22:58:32 -04:00
EventPluginHub.processEventQueue(false);
2015-09-02 15:08:58 -04:00
}
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.
*/
2015-10-14 22:58:32 -04:00
handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
runEventQueueInBatch(events);
}
};
module.exports = ReactEventEmitterMixin;
2015-10-14 22:58:32 -04:00
},{"16":16}],63:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventListener = _dereq_(145);
var ExecutionEnvironment = _dereq_(146);
var PooledClass = _dereq_(25);
var ReactInstanceHandles = _dereq_(67);
var ReactMount = _dereq_(72);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var getEventTarget = _dereq_(127);
var getUnboundedScrollPosition = _dereq_(157);
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
2015-09-02 15:08:58 -04:00
/**
* 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, {
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
this.topLevelType = null;
this.nativeEvent = null;
this.ancestors.length = 0;
}
});
2015-10-14 22:58:32 -04:00
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
2015-09-02 15:08:58 -04:00
function handleTopLevelImpl(bookKeeping) {
2015-10-14 22:58:32 -04:00
// TODO: Re-enable event.path handling
//
// if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
// // New browsers have a path attribute on native events
// handleTopLevelWithPath(bookKeeping);
// } else {
// // Legacy browsers don't have a path attribute on native events
// handleTopLevelWithoutPath(bookKeeping);
// }
void handleTopLevelWithPath; // temporarily unused
handleTopLevelWithoutPath(bookKeeping);
}
// Legacy browsers don't have a path attribute on native events
function handleTopLevelWithoutPath(bookKeeping) {
var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
2015-09-02 15:08:58 -04:00
// 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);
}
2015-10-14 22:58:32 -04:00
for (var i = 0; i < bookKeeping.ancestors.length; i++) {
2015-09-02 15:08:58 -04:00
topLevelTarget = bookKeeping.ancestors[i];
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
2015-10-14 22:58:32 -04:00
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
}
}
// New browsers have a path attribute on native events
function handleTopLevelWithPath(bookKeeping) {
var path = bookKeeping.nativeEvent.path;
var currentNativeTarget = path[0];
var eventsFired = 0;
for (var i = 0; i < path.length; i++) {
var currentPathElement = path[i];
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
currentNativeTarget = path[i + 1];
}
// TODO: slow
var reactParent = ReactMount.getFirstReactDOM(currentPathElement);
if (reactParent === currentPathElement) {
var currentPathElementID = ReactMount.getID(currentPathElement);
var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
bookKeeping.ancestors.push(currentPathElement);
var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
eventsFired++;
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
// Jump to the root of this React render tree
while (currentPathElementID !== newRootID) {
i++;
currentPathElement = path[i];
currentPathElementID = ReactMount.getID(currentPathElement);
}
}
}
if (eventsFired === 0) {
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
2015-09-02 15:08:58 -04:00
}
}
function scrollValueMonitor(cb) {
var scrollPosition = getUnboundedScrollPosition(window);
cb(scrollPosition);
}
var ReactEventListener = {
_enabled: true,
_handleTopLevel: null,
WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
2015-10-14 22:58:32 -04:00
setHandleTopLevel: function (handleTopLevel) {
2015-09-02 15:08:58 -04:00
ReactEventListener._handleTopLevel = handleTopLevel;
},
2015-10-14 22:58:32 -04:00
setEnabled: function (enabled) {
2015-09-02 15:08:58 -04:00
ReactEventListener._enabled = !!enabled;
},
2015-10-14 22:58:32 -04:00
isEnabled: function () {
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
* @return {?object} An object with a remove function which will forcefully
2015-09-02 15:08:58 -04:00
* remove the listener.
* @internal
*/
2015-10-14 22:58:32 -04:00
trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
2015-09-02 15:08:58 -04:00
var element = handle;
if (!element) {
return null;
}
2015-10-14 22:58:32 -04:00
return EventListener.listen(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
2015-09-02 15:08:58 -04:00
},
/**
* 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.
2015-10-14 22:58:32 -04:00
* @return {?object} An object with a remove function which will forcefully
2015-09-02 15:08:58 -04:00
* remove the listener.
* @internal
*/
2015-10-14 22:58:32 -04:00
trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
2015-09-02 15:08:58 -04:00
var element = handle;
if (!element) {
return null;
}
2015-10-14 22:58:32 -04:00
return EventListener.capture(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
monitorScrollValue: function (refresh) {
2015-09-02 15:08:58 -04:00
var callback = scrollValueMonitor.bind(null, refresh);
EventListener.listen(window, 'scroll', callback);
},
2015-10-14 22:58:32 -04:00
dispatchEvent: function (topLevelType, nativeEvent) {
2015-09-02 15:08:58 -04:00
if (!ReactEventListener._enabled) {
return;
}
2015-10-14 22:58:32 -04:00
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent);
2015-09-02 15:08:58 -04:00
try {
// Event queue being processed in the same cycle allows
// `preventDefault`.
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
} finally {
TopLevelCallbackBookKeeping.release(bookKeeping);
}
}
};
module.exports = ReactEventListener;
2015-10-14 22:58:32 -04:00
},{"127":127,"145":145,"146":146,"157":157,"24":24,"25":25,"67":67,"72":72,"96":96}],64:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactFragment
*/
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var ReactChildren = _dereq_(32);
var ReactElement = _dereq_(57);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyFunction = _dereq_(152);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
* We used to allow keyed objects to serve as a collection of ReactElements,
* or nested sets. This allowed us a way to explicitly key a set a fragment of
* components. This is now being replaced with an opaque data structure.
* The upgrade path is to call React.addons.createFragment({ key: value }) to
2015-10-14 22:58:32 -04:00
* create a keyed fragment. The resulting data structure is an array.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var numericPropertyRegex = /^\d+$/;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var warnedAboutNumeric = false;
2015-09-02 15:08:58 -04:00
var ReactFragment = {
// Wrap a keyed object in an opaque proxy that warns you if you access any
// of its properties.
2015-10-14 22:58:32 -04:00
create: function (object) {
if (typeof object !== 'object' || !object || Array.isArray(object)) {
"development" !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : undefined;
return object;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (ReactElement.isValidElement(object)) {
"development" !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : undefined;
return object;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
!(object.nodeType !== 1) ? "development" !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM ' + 'elements are not valid children of React components.') : invariant(false) : undefined;
var result = [];
for (var key in object) {
if ("development" !== 'production') {
if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
"development" !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : undefined;
warnedAboutNumeric = true;
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
ReactChildren.mapIntoWithKeyPrefixInternal(object[key], result, key, emptyFunction.thatReturnsArgument);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return result;
2015-09-02 15:08:58 -04:00
}
};
module.exports = ReactFragment;
2015-10-14 22:58:32 -04:00
},{"152":152,"160":160,"172":172,"32":32,"57":57}],65:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
var EventPluginHub = _dereq_(16);
var ReactComponentEnvironment = _dereq_(36);
var ReactClass = _dereq_(33);
var ReactEmptyComponent = _dereq_(59);
var ReactBrowserEventEmitter = _dereq_(28);
var ReactNativeComponent = _dereq_(75);
var ReactPerf = _dereq_(78);
var ReactRootIndex = _dereq_(86);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
var ReactInjection = {
Component: ReactComponentEnvironment.injection,
Class: ReactClass.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;
2015-10-14 22:58:32 -04:00
},{"10":10,"16":16,"28":28,"33":33,"36":36,"59":59,"75":75,"78":78,"86":86,"96":96}],66:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactDOMSelection = _dereq_(49);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var containsNode = _dereq_(149);
var focusNode = _dereq_(154);
var getActiveElement = _dereq_(155);
2015-09-02 15:08:58 -04:00
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 = {
2015-10-14 22:58:32 -04:00
hasSelectionCapabilities: function (elem) {
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
getSelectionInformation: function () {
2015-09-02 15:08:58 -04:00
var focusedElem = getActiveElement();
return {
focusedElem: focusedElem,
2015-10-14 22:58:32 -04:00
selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null
2015-09-02 15:08:58 -04:00
};
},
/**
* @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.
*/
2015-10-14 22:58:32 -04:00
restoreSelection: function (priorSelectionInformation) {
2015-09-02 15:08:58 -04:00
var curFocusedElem = getActiveElement();
var priorFocusedElem = priorSelectionInformation.focusedElem;
var priorSelectionRange = priorSelectionInformation.selectionRange;
2015-10-14 22:58:32 -04:00
if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
2015-09-02 15:08:58 -04:00
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
2015-10-14 22:58:32 -04:00
ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange);
2015-09-02 15:08:58 -04:00
}
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}
*/
2015-10-14 22:58:32 -04:00
getSelection: function (input) {
2015-09-02 15:08:58 -04:00
var selection;
if ('selectionStart' in input) {
// Modern browser with input or textarea.
selection = {
start: input.selectionStart,
end: input.selectionEnd
};
2015-10-14 22:58:32 -04:00
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
2015-09-02 15:08:58 -04:00
// 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);
}
2015-10-14 22:58:32 -04:00
return selection || { start: 0, end: 0 };
2015-09-02 15:08:58 -04:00
},
/**
* @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*
*/
2015-10-14 22:58:32 -04:00
setSelection: function (input, offsets) {
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
} else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"149":149,"154":154,"155":155,"49":49}],67:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactRootIndex = _dereq_(86);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var SEPARATOR = '.';
var SEPARATOR_LENGTH = SEPARATOR.length;
/**
* Maximum depth of traversals before we consider the possibility of a bad ID.
*/
2015-10-14 22:58:32 -04:00
var MAX_TREE_DEPTH = 10000;
2015-09-02 15:08:58 -04:00
/**
* 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) {
2015-10-14 22:58:32 -04:00
return id === '' || id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR;
2015-09-02 15:08:58 -04:00
}
/**
* 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) {
2015-10-14 22:58:32 -04:00
return descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length);
2015-09-02 15:08:58 -04:00
}
/**
* 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) {
2015-10-14 22:58:32 -04:00
!(isValidID(ancestorID) && isValidID(destinationID)) ? "development" !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
!isAncestorIDOf(ancestorID, destinationID) ? "development" !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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;
var i;
for (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);
2015-10-14 22:58:32 -04:00
!isValidID(longestCommonID) ? "development" !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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.
2015-10-14 22:58:32 -04:00
* @param {*} arg Argument to invoke the callback with.
2015-09-02 15:08:58 -04:00
* @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 || '';
2015-10-14 22:58:32 -04:00
!(start !== stop) ? "development" !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var traverseUp = isAncestorIDOf(stop, start);
2015-10-14 22:58:32 -04:00
!(traverseUp || isAncestorIDOf(start, stop)) ? "development" !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
// Traverse from `start` to `stop` one depth at a time.
var depth = 0;
var traverse = traverseUp ? getParentID : getNextDescendantID;
2015-10-14 22:58:32 -04:00
for (var id = start;; /* until break */id = traverse(id, stop)) {
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
!(depth++ < MAX_TREE_DEPTH) ? "development" !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
}
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
createReactRootID: function () {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
createReactID: function (rootID, name) {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
getReactRootIDFromNodeID: function (id) {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
traverseEnterLeave: function (leaveID, enterID, cb, upArg, downArg) {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
traverseTwoPhase: function (targetID, cb, arg) {
2015-09-02 15:08:58 -04:00
if (targetID) {
traverseParentPath('', targetID, cb, arg, true, false);
traverseParentPath(targetID, '', cb, arg, false, true);
}
},
2015-10-14 22:58:32 -04:00
/**
* Same as `traverseTwoPhase` but skips the `targetID`.
*/
traverseTwoPhaseSkipTarget: function (targetID, cb, arg) {
if (targetID) {
traverseParentPath('', targetID, cb, arg, true, true);
traverseParentPath(targetID, '', cb, arg, true, true);
}
},
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
traverseAncestors: function (targetID, cb, arg) {
2015-09-02 15:08:58 -04:00
traverseParentPath('', targetID, cb, arg, true, false);
},
2015-10-14 22:58:32 -04:00
getFirstCommonAncestorID: getFirstCommonAncestorID,
2015-09-02 15:08:58 -04:00
/**
* Exposed for unit testing.
* @private
*/
_getNextDescendantID: getNextDescendantID,
isAncestorIDOf: isAncestorIDOf,
SEPARATOR: SEPARATOR
};
module.exports = ReactInstanceHandles;
2015-10-14 22:58:32 -04:00
},{"160":160,"86":86}],68:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ReactInstanceMap
*/
'use strict';
/**
* `ReactInstanceMap` maintains a mapping from a public facing stateful
* instance (key) and the internal representation (value). This allows public
* methods to accept the user facing instance as an argument and map them back
* to internal methods.
*/
// TODO: Replace this with ES6: var ReactInstanceMap = new Map();
var ReactInstanceMap = {
/**
* This API should be called `delete` but we'd have to make sure to always
* transform these to strings for IE support. When this transform is fully
* supported we can rename it.
*/
2015-10-14 22:58:32 -04:00
remove: function (key) {
2015-09-02 15:08:58 -04:00
key._reactInternalInstance = undefined;
},
2015-10-14 22:58:32 -04:00
get: function (key) {
2015-09-02 15:08:58 -04:00
return key._reactInternalInstance;
},
2015-10-14 22:58:32 -04:00
has: function (key) {
2015-09-02 15:08:58 -04:00
return key._reactInternalInstance !== undefined;
},
2015-10-14 22:58:32 -04:00
set: function (key, value) {
2015-09-02 15:08:58 -04:00
key._reactInternalInstance = value;
}
};
module.exports = ReactInstanceMap;
2015-10-14 22:58:32 -04:00
},{}],69:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
2015-09-02 15:08:58 -04:00
* 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactIsomorphic
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactChildren = _dereq_(32);
var ReactComponent = _dereq_(34);
var ReactClass = _dereq_(33);
var ReactDOMFactories = _dereq_(43);
var ReactElement = _dereq_(57);
var ReactElementValidator = _dereq_(58);
var ReactPropTypes = _dereq_(82);
var ReactVersion = _dereq_(97);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var onlyChild = _dereq_(134);
var createElement = ReactElement.createElement;
var createFactory = ReactElement.createFactory;
var cloneElement = ReactElement.cloneElement;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
createElement = ReactElementValidator.createElement;
createFactory = ReactElementValidator.createFactory;
cloneElement = ReactElementValidator.cloneElement;
}
var React = {
// Modern
Children: {
map: ReactChildren.map,
forEach: ReactChildren.forEach,
count: ReactChildren.count,
toArray: ReactChildren.toArray,
only: onlyChild
},
Component: ReactComponent,
createElement: createElement,
cloneElement: cloneElement,
isValidElement: ReactElement.isValidElement,
// Classic
PropTypes: ReactPropTypes,
createClass: ReactClass.createClass,
createFactory: createFactory,
createMixin: function (mixin) {
// Currently a noop. Will be used to validate and trace mixins.
return mixin;
},
// This looks DOM specific but these are actually isomorphic helpers
// since they are just generating DOM strings.
DOM: ReactDOMFactories,
version: ReactVersion,
// Hook for JSX spread, don't use this for anything else.
__spread: assign
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = React;
},{"134":134,"24":24,"32":32,"33":33,"34":34,"43":43,"57":57,"58":58,"82":82,"97":97}],70:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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} />;
* },
2015-10-14 22:58:32 -04:00
* _handleValueChange: function(newValue) {
2015-09-02 15:08:58 -04:00
* this.setState({value: newValue});
* }
* });
*
* We have provided some sugary mixins to make the creation and
* consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
*/
2015-10-14 22:58:32 -04:00
var React = _dereq_(26);
2015-09-02 15:08:58 -04:00
/**
* @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 = {
2015-10-14 22:58:32 -04:00
value: typeof linkType === 'undefined' ? React.PropTypes.any.isRequired : linkType.isRequired,
2015-09-02 15:08:58 -04:00
requestChange: React.PropTypes.func.isRequired
};
return React.PropTypes.shape(shapes);
}
ReactLink.PropTypes = {
link: createLinkTypeChecker
};
module.exports = ReactLink;
2015-10-14 22:58:32 -04:00
},{"26":26}],71:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var adler32 = _dereq_(116);
var TAG_END = /\/?>/;
2015-09-02 15:08:58 -04:00
var ReactMarkupChecksum = {
CHECKSUM_ATTR_NAME: 'data-react-checksum',
/**
* @param {string} markup Markup string
* @return {string} Markup string with checksum attribute attached
*/
2015-10-14 22:58:32 -04:00
addChecksumToMarkup: function (markup) {
2015-09-02 15:08:58 -04:00
var checksum = adler32(markup);
2015-10-14 22:58:32 -04:00
// Add checksum (handle both parent tags and self-closing tags)
return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
2015-09-02 15:08:58 -04:00
},
/**
* @param {string} markup to use
* @param {DOMElement} element root React element
* @returns {boolean} whether or not the markup is the same
*/
2015-10-14 22:58:32 -04:00
canReuseMarkup: function (markup, element) {
var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
2015-09-02 15:08:58 -04:00
existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
var markupChecksum = adler32(markup);
return markupChecksum === existingChecksum;
}
};
module.exports = ReactMarkupChecksum;
2015-10-14 22:58:32 -04:00
},{"116":116}],72:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
var ReactBrowserEventEmitter = _dereq_(28);
var ReactCurrentOwner = _dereq_(39);
var ReactDOMFeatureFlags = _dereq_(44);
var ReactElement = _dereq_(57);
var ReactEmptyComponentRegistry = _dereq_(60);
var ReactInstanceHandles = _dereq_(67);
var ReactInstanceMap = _dereq_(68);
var ReactMarkupChecksum = _dereq_(71);
var ReactPerf = _dereq_(78);
var ReactReconciler = _dereq_(84);
var ReactUpdateQueue = _dereq_(95);
var ReactUpdates = _dereq_(96);
var assign = _dereq_(24);
var emptyObject = _dereq_(153);
var containsNode = _dereq_(149);
var instantiateReactComponent = _dereq_(131);
var invariant = _dereq_(160);
var setInnerHTML = _dereq_(137);
var shouldUpdateReactComponent = _dereq_(140);
var validateDOMNesting = _dereq_(143);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
var nodeCache = {};
var ELEMENT_NODE_TYPE = 1;
var DOC_NODE_TYPE = 9;
2015-10-14 22:58:32 -04:00
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
2015-09-02 15:08:58 -04:00
/** Mapping from reactRootID to React component instance. */
var instancesByReactRootID = {};
/** Mapping from reactRootID to `container` nodes. */
var containersByReactRootID = {};
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
/** __DEV__-only mapping from reactRootID to root elements. */
var rootElementsByReactRootID = {};
}
// Used to store breadth-first search state in findComponentRoot.
var findComponentRootReusableArray = [];
/**
* Finds the index of the first character
* that's not common between the two given strings.
*
* @return {number} the index of the character where the strings diverge
*/
function firstDifferenceIndex(string1, string2) {
var minLen = Math.min(string1.length, string2.length);
for (var i = 0; i < minLen; i++) {
if (string1.charAt(i) !== string2.charAt(i)) {
return i;
}
}
return string1.length === string2.length ? -1 : minLen;
}
2015-10-14 22:58:32 -04:00
/**
* @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;
}
}
2015-09-02 15:08:58 -04:00
/**
* @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) {
2015-10-14 22:58:32 -04:00
!!isValid(cached, id) ? "development" !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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];
}
/**
* Finds the node with the supplied public React instance.
*
* @param {*} instance A public React instance.
* @return {?DOMElement} DOM node with the suppled `id`.
* @internal
*/
function getNodeFromInstance(instance) {
var id = ReactInstanceMap.get(instance)._rootNodeID;
2015-10-14 22:58:32 -04:00
if (ReactEmptyComponentRegistry.isNullComponentID(id)) {
2015-09-02 15:08:58 -04:00
return null;
}
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) {
2015-10-14 22:58:32 -04:00
!(internalGetID(node) === id) ? "development" !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
ReactInstanceHandles.traverseAncestors(targetID, findDeepestCachedAncestorImpl);
2015-09-02 15:08:58 -04:00
var foundNode = deepestNodeSoFar;
deepestNodeSoFar = null;
return foundNode;
}
/**
* Mounts this component and inserts it into the DOM.
*
* @param {ReactComponent} componentInstance The instance to mount.
* @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
*/
2015-10-14 22:58:32 -04:00
function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
if (ReactDOMFeatureFlags.useCreateElement) {
context = assign({}, context);
if (container.nodeType === DOC_NODE_TYPE) {
context[ownerDocumentContextKey] = container;
} else {
context[ownerDocumentContextKey] = container.ownerDocument;
}
}
if ("development" !== 'production') {
if (context === emptyObject) {
context = {};
}
var tag = container.nodeName.toLowerCase();
context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
}
var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
componentInstance._renderedComponent._topLevelWrapper = componentInstance;
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction);
}
/**
* Batched mount.
2015-09-02 15:08:58 -04:00
*
* @param {ReactComponent} componentInstance The instance to mount.
* @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
*/
2015-10-14 22:58:32 -04:00
function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
/* forceHTML */shouldReuseMarkup);
transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
2015-09-02 15:08:58 -04:00
ReactUpdates.ReactReconcileTransaction.release(transaction);
}
2015-10-14 22:58:32 -04:00
/**
* 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}
*/
function unmountComponentFromNode(instance, container) {
ReactReconciler.unmountComponent(instance);
if (container.nodeType === DOC_NODE_TYPE) {
container = container.documentElement;
}
// http://jsperf.com/emptying-a-node
while (container.lastChild) {
container.removeChild(container.lastChild);
}
}
/**
* True if the supplied DOM node has a direct React-rendered child that is
* not a React root element. Useful for warning in `render`,
* `unmountComponentAtNode`, etc.
*
* @param {?DOMElement} node The candidate DOM node.
* @return {boolean} True if the DOM element contains a direct child that was
* rendered by React but is not a root element.
* @internal
*/
function hasNonRootReactChild(node) {
var reactRootID = getReactRootID(node);
return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false;
}
/**
* Returns the first (deepest) ancestor of a node which is rendered by this copy
* of React.
*/
function findFirstReactDOMImpl(node) {
// This node might be from another React instance, so we make sure not to
// examine the node cache here
for (; node && node.parentNode !== node; node = node.parentNode) {
if (node.nodeType !== 1) {
// Not a DOMElement, therefore not a React component
continue;
}
var nodeID = internalGetID(node);
if (!nodeID) {
continue;
}
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
// If containersByReactRootID contains the container we find by crawling up
// the tree, we know that this instance of React rendered the node.
// nb. isValid's strategy (with containsNode) does not work because render
// trees may be nested and we don't want a false positive in that case.
var current = node;
var lastID;
do {
lastID = internalGetID(current);
current = current.parentNode;
if (current == null) {
// The passed-in node has been detached from the container it was
// originally rendered into.
return null;
}
} while (lastID !== reactRootID);
if (current === containersByReactRootID[reactRootID]) {
return node;
}
}
return null;
}
/**
* Temporary (?) hack so that we can store all top-level pending updates on
* composites instead of having to worry about different types of components
* here.
*/
var TopLevelWrapper = function () {};
TopLevelWrapper.prototype.isReactComponent = {};
if ("development" !== 'production') {
TopLevelWrapper.displayName = 'TopLevelWrapper';
}
TopLevelWrapper.prototype.render = function () {
// this.props is actually a ReactElement
return this.props;
};
2015-09-02 15:08:58 -04:00
/**
* Mounting is the process of initializing a React component by creating 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 = {
2015-10-14 22:58:32 -04:00
TopLevelWrapper: TopLevelWrapper,
2015-09-02 15:08:58 -04:00
/** 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.
*/
2015-10-14 22:58:32 -04:00
scrollMonitor: function (container, renderCallback) {
2015-09-02 15:08:58 -04:00
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 {ReactElement} nextElement component instance to render
* @param {DOMElement} container container to render into
* @param {?function} callback function triggered on completion
*/
2015-10-14 22:58:32 -04:00
_updateRootComponent: function (prevComponent, nextElement, container, callback) {
ReactMount.scrollMonitor(container, function () {
2015-09-02 15:08:58 -04:00
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
if (callback) {
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
}
});
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// Record the root element in case it later gets transplanted.
2015-10-14 22:58:32 -04:00
rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
2015-09-02 15:08:58 -04:00
}
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
*/
2015-10-14 22:58:32 -04:00
_registerComponent: function (nextComponent, container) {
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? "development" !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
var reactRootID = ReactMount.registerContainer(container);
instancesByReactRootID[reactRootID] = nextComponent;
return reactRootID;
},
/**
* Render a new component into the DOM.
* @param {ReactElement} nextElement element to render
* @param {DOMElement} container container to render into
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion
* @return {ReactComponent} nextComponent
*/
2015-10-14 22:58:32 -04:00
_renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
2015-09-02 15:08:58 -04:00
// Various parts of our code (such as ReactCompositeComponent's
// _renderValidatedComponent) assume that calls to render aren't nested;
// verify that that's the case.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? 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. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
2015-09-02 15:08:58 -04:00
var componentInstance = instantiateReactComponent(nextElement, null);
2015-10-14 22:58:32 -04:00
var reactRootID = ReactMount._registerComponent(componentInstance, container);
2015-09-02 15:08:58 -04:00
// The initial render is synchronous but any updates that happen during
// rendering, in componentWillMount or componentDidMount, will be batched
// according to the current batching strategy.
2015-10-14 22:58:32 -04:00
ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// Record the root element in case it later gets transplanted.
2015-10-14 22:58:32 -04:00
rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
2015-09-02 15:08:58 -04:00
}
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.
*
2015-10-14 22:58:32 -04:00
* @param {ReactComponent} parentComponent The conceptual parent of this render tree.
2015-09-02 15:08:58 -04:00
* @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`.
*/
2015-10-14 22:58:32 -04:00
renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
!(parentComponent != null && parentComponent._reactInternalInstance != null) ? "development" !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
},
_renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
!ReactElement.isValidElement(nextElement) ? "development" !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
// Check if it quacks like an element
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
"development" !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
2015-09-02 15:08:58 -04:00
var prevComponent = instancesByReactRootID[getReactRootID(container)];
if (prevComponent) {
2015-10-14 22:58:32 -04:00
var prevWrappedElement = prevComponent._currentElement;
var prevElement = prevWrappedElement.props;
2015-09-02 15:08:58 -04:00
if (shouldUpdateReactComponent(prevElement, nextElement)) {
2015-10-14 22:58:32 -04:00
return ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, callback)._renderedComponent.getPublicInstance();
2015-09-02 15:08:58 -04:00
} else {
ReactMount.unmountComponentAtNode(container);
}
}
var reactRootElement = getReactRootElementInContainer(container);
2015-10-14 22:58:32 -04:00
var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement);
var containerHasNonRootReactChild = hasNonRootReactChild(container);
if ("development" !== 'production') {
"development" !== 'production' ? warning(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : undefined;
2015-09-02 15:08:58 -04:00
if (!containerHasReactMarkup || reactRootElement.nextSibling) {
var rootElementSibling = reactRootElement;
while (rootElementSibling) {
2015-10-14 22:58:32 -04:00
if (internalGetID(rootElementSibling)) {
"development" !== 'production' ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined;
2015-09-02 15:08:58 -04:00
break;
}
rootElementSibling = rootElementSibling.nextSibling;
}
}
}
2015-10-14 22:58:32 -04:00
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
2015-09-02 15:08:58 -04:00
if (callback) {
callback.call(component);
}
return component;
},
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {ReactElement} nextElement Component element to render.
2015-09-02 15:08:58 -04:00
* @param {DOMElement} container DOM element to render into.
2015-10-14 22:58:32 -04:00
* @param {?function} callback function triggered on completion
2015-09-02 15:08:58 -04:00
* @return {ReactComponent} Component instance rendered in `container`.
*/
2015-10-14 22:58:32 -04:00
render: function (nextElement, container, callback) {
return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
2015-09-02 15:08:58 -04:00
},
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
registerContainer: function (container) {
2015-09-02 15:08:58 -04:00
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`
*/
2015-10-14 22:58:32 -04:00
unmountComponentAtNode: function (container) {
2015-09-02 15:08:58 -04:00
// 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.)
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? 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. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? "development" !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var reactRootID = getReactRootID(container);
var component = instancesByReactRootID[reactRootID];
if (!component) {
2015-10-14 22:58:32 -04:00
// Check if the node being unmounted was rendered by React, but isn't a
// root node.
var containerHasNonRootReactChild = hasNonRootReactChild(container);
// Check if the container itself is a React root node.
var containerID = internalGetID(container);
var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID);
if ("development" !== 'production') {
"development" !== 'production' ? warning(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : undefined;
}
2015-09-02 15:08:58 -04:00
return false;
}
2015-10-14 22:58:32 -04:00
ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
2015-09-02 15:08:58 -04:00
delete instancesByReactRootID[reactRootID];
delete containersByReactRootID[reactRootID];
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
delete rootElementsByReactRootID[reactRootID];
}
return true;
},
/**
* 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`.
*/
2015-10-14 22:58:32 -04:00
findReactContainerForID: function (id) {
2015-09-02 15:08:58 -04:00
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
var container = containersByReactRootID[reactRootID];
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
var rootElement = rootElementsByReactRootID[reactRootID];
if (rootElement && rootElement.parentNode !== container) {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(
// Call internalGetID here because getID calls isValid which calls
2015-09-02 15:08:58 -04:00
// findReactContainerForID (this function).
2015-10-14 22:58:32 -04:00
internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
2015-09-02 15:08:58 -04:00
var containerChild = container.firstChild;
2015-10-14 22:58:32 -04:00
if (containerChild && reactRootID === internalGetID(containerChild)) {
2015-09-02 15:08:58 -04:00
// 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 {
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
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.
*/
2015-10-14 22:58:32 -04:00
findReactNodeByID: function (id) {
2015-09-02 15:08:58 -04:00
var reactRoot = ReactMount.findReactContainerForID(id);
return ReactMount.findComponentRoot(reactRoot, id);
},
/**
* Traverses up the ancestors of the supplied node to find a node that is a
2015-10-14 22:58:32 -04:00
* DOM representation of a React component rendered by this copy of React.
2015-09-02 15:08:58 -04:00
*
* @param {*} node
* @return {?DOMEventTarget}
* @internal
*/
2015-10-14 22:58:32 -04:00
getFirstReactDOM: function (node) {
return findFirstReactDOMImpl(node);
2015-09-02 15:08:58 -04:00
},
/**
* 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
*/
2015-10-14 22:58:32 -04:00
findComponentRoot: function (ancestorNode, targetID) {
2015-09-02 15:08:58 -04:00
var firstChildren = findComponentRootReusableArray;
var childIndex = 0;
var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
// This will throw on the next line; give an early warning
"development" !== 'production' ? warning(deepestAncestor != null, 'React can\'t find the root component node for data-reactid value ' + '`%s`. If you\'re seeing this message, it probably means that ' + 'you\'ve loaded two copies of React on the page. At this time, only ' + 'a single copy of React can be loaded at a time.', targetID) : undefined;
}
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
!false ? "development" !== 'production' ? 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) : undefined;
},
_mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) {
!(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? "development" !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
if (shouldReuseMarkup) {
var rootElement = getReactRootElementInContainer(container);
if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
return;
} else {
2015-10-14 22:58:32 -04:00
var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
2015-09-02 15:08:58 -04:00
rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
var rootMarkup = rootElement.outerHTML;
2015-10-14 22:58:32 -04:00
rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
var normalizedMarkup = markup;
if ("development" !== 'production') {
// because rootMarkup is retrieved from the DOM, various normalizations
// will have occurred which will not be present in `markup`. Here,
// insert markup into a <div> or <iframe> depending on the container
// type to perform the same normalizations before comparing.
var normalizer;
if (container.nodeType === ELEMENT_NODE_TYPE) {
normalizer = document.createElement('div');
normalizer.innerHTML = markup;
normalizedMarkup = normalizer.innerHTML;
} else {
normalizer = document.createElement('iframe');
document.body.appendChild(normalizer);
normalizer.contentDocument.write(markup);
normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
document.body.removeChild(normalizer);
}
}
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
!(container.nodeType !== DOC_NODE_TYPE) ? "development" !== 'production' ? invariant(false, '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:\n%s', difference) : invariant(false) : undefined;
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, 'React attempted to 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:\n%s', difference) : undefined;
2015-09-02 15:08:58 -04:00
}
}
}
2015-10-14 22:58:32 -04:00
!(container.nodeType !== DOC_NODE_TYPE) ? "development" !== 'production' ? invariant(false, '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 ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (transaction.useCreateElement) {
while (container.lastChild) {
container.removeChild(container.lastChild);
}
container.appendChild(markup);
} else {
setInnerHTML(container, markup);
}
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
ownerDocumentContextKey: ownerDocumentContextKey,
2015-09-02 15:08:58 -04:00
/**
* React ID utilities.
*/
getReactRootID: getReactRootID,
getID: getID,
setID: setID,
getNode: getNode,
getNodeFromInstance: getNodeFromInstance,
2015-10-14 22:58:32 -04:00
isValid: isValid,
2015-09-02 15:08:58 -04:00
purgeID: purgeID
};
ReactPerf.measureMethods(ReactMount, 'ReactMount', {
_renderNewRootComponent: '_renderNewRootComponent',
_mountImageIntoNode: '_mountImageIntoNode'
});
module.exports = ReactMount;
2015-10-14 22:58:32 -04:00
},{"10":10,"131":131,"137":137,"140":140,"143":143,"149":149,"153":153,"160":160,"172":172,"24":24,"28":28,"39":39,"44":44,"57":57,"60":60,"67":67,"68":68,"71":71,"78":78,"84":84,"95":95,"96":96}],73:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactComponentEnvironment = _dereq_(36);
var ReactMultiChildUpdateTypes = _dereq_(74);
var ReactCurrentOwner = _dereq_(39);
var ReactReconciler = _dereq_(84);
var ReactChildReconciler = _dereq_(31);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var flattenChildren = _dereq_(122);
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
function enqueueInsertMarkup(parentID, markup, toIndex) {
2015-09-02 15:08:58 -04:00
// NOTE: Null values reduce hidden classes.
updateQueue.push({
parentID: parentID,
parentNode: null,
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
markupIndex: markupQueue.push(markup) - 1,
2015-10-14 22:58:32 -04:00
content: null,
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
content: null,
2015-09-02 15:08:58 -04:00
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,
2015-10-14 22:58:32 -04:00
content: null,
2015-09-02 15:08:58 -04:00
fromIndex: fromIndex,
toIndex: null
});
}
2015-10-14 22:58:32 -04:00
/**
* Enqueues setting the markup of a node.
*
* @param {string} parentID ID of the parent component.
* @param {string} markup Markup that renders into an element.
* @private
*/
function enqueueSetMarkup(parentID, markup) {
// NOTE: Null values reduce hidden classes.
updateQueue.push({
parentID: parentID,
parentNode: null,
type: ReactMultiChildUpdateTypes.SET_MARKUP,
markupIndex: null,
content: markup,
fromIndex: null,
toIndex: null
});
}
2015-09-02 15:08:58 -04:00
/**
* 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,
2015-10-14 22:58:32 -04:00
content: textContent,
2015-09-02 15:08:58 -04:00
fromIndex: null,
toIndex: null
});
}
/**
* Processes any enqueued updates.
*
* @private
*/
function processQueue() {
if (updateQueue.length) {
2015-10-14 22:58:32 -04:00
ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
2015-09-02 15:08:58 -04:00
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: {
2015-10-14 22:58:32 -04:00
_reconcilerInstantiateChildren: function (nestedChildren, transaction, context) {
if ("development" !== 'production') {
if (this._currentElement) {
try {
ReactCurrentOwner.current = this._currentElement._owner;
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
} finally {
ReactCurrentOwner.current = null;
}
}
}
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
},
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
var nextChildren;
if ("development" !== 'production') {
if (this._currentElement) {
try {
ReactCurrentOwner.current = this._currentElement._owner;
nextChildren = flattenChildren(nextNestedChildrenElements);
} finally {
ReactCurrentOwner.current = null;
}
return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
}
}
nextChildren = flattenChildren(nextNestedChildrenElements);
return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
},
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
mountChildren: function (nestedChildren, transaction, context) {
var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);
2015-09-02 15:08:58 -04:00
this._renderedChildren = children;
var mountImages = [];
var index = 0;
for (var name in children) {
if (children.hasOwnProperty(name)) {
var child = children[name];
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
var rootID = this._rootNodeID + name;
2015-10-14 22:58:32 -04:00
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
child._mountIndex = index++;
2015-09-02 15:08:58 -04:00
mountImages.push(mountImage);
}
}
return mountImages;
},
/**
* Replaces any rendered children with a text content string.
*
* @param {string} nextContent String of content.
* @internal
*/
2015-10-14 22:58:32 -04:00
updateTextContent: function (nextContent) {
2015-09-02 15:08:58 -04:00
updateDepth++;
var errorThrown = true;
try {
var prevChildren = this._renderedChildren;
// Remove any rendered children.
ReactChildReconciler.unmountChildren(prevChildren);
// TODO: The setTextContent operation should be enough
for (var name in prevChildren) {
if (prevChildren.hasOwnProperty(name)) {
2015-10-14 22:58:32 -04:00
this._unmountChild(prevChildren[name]);
2015-09-02 15:08:58 -04:00
}
}
// Set new text content.
this.setTextContent(nextContent);
errorThrown = false;
} finally {
updateDepth--;
if (!updateDepth) {
if (errorThrown) {
clearQueue();
} else {
processQueue();
}
}
}
},
2015-10-14 22:58:32 -04:00
/**
* Replaces any rendered children with a markup string.
*
* @param {string} nextMarkup String of markup.
* @internal
*/
updateMarkup: function (nextMarkup) {
updateDepth++;
var errorThrown = true;
try {
var prevChildren = this._renderedChildren;
// Remove any rendered children.
ReactChildReconciler.unmountChildren(prevChildren);
for (var name in prevChildren) {
if (prevChildren.hasOwnProperty(name)) {
this._unmountChildByName(prevChildren[name], name);
}
}
this.setMarkup(nextMarkup);
errorThrown = false;
} finally {
updateDepth--;
if (!updateDepth) {
if (errorThrown) {
clearQueue();
} else {
processQueue();
}
}
}
},
2015-09-02 15:08:58 -04:00
/**
* Updates the rendered children with new children.
*
2015-10-14 22:58:32 -04:00
* @param {?object} nextNestedChildrenElements Nested child element maps.
2015-09-02 15:08:58 -04:00
* @param {ReactReconcileTransaction} transaction
* @internal
*/
2015-10-14 22:58:32 -04:00
updateChildren: function (nextNestedChildrenElements, transaction, context) {
2015-09-02 15:08:58 -04:00
updateDepth++;
var errorThrown = true;
try {
2015-10-14 22:58:32 -04:00
this._updateChildren(nextNestedChildrenElements, transaction, context);
2015-09-02 15:08:58 -04:00
errorThrown = false;
} finally {
updateDepth--;
if (!updateDepth) {
if (errorThrown) {
clearQueue();
} else {
processQueue();
}
}
}
},
/**
* Improve performance by isolating this hot code path from the try/catch
* block in `updateChildren`.
*
2015-10-14 22:58:32 -04:00
* @param {?object} nextNestedChildrenElements Nested child element maps.
2015-09-02 15:08:58 -04:00
* @param {ReactReconcileTransaction} transaction
* @final
* @protected
*/
2015-10-14 22:58:32 -04:00
_updateChildren: function (nextNestedChildrenElements, transaction, context) {
2015-09-02 15:08:58 -04:00
var prevChildren = this._renderedChildren;
2015-10-14 22:58:32 -04:00
var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, transaction, context);
2015-09-02 15:08:58 -04:00
this._renderedChildren = nextChildren;
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 nextChild = nextChildren[name];
if (prevChild === nextChild) {
this.moveChild(prevChild, nextIndex, lastIndex);
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
prevChild._mountIndex = nextIndex;
} else {
if (prevChild) {
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
2015-10-14 22:58:32 -04:00
this._unmountChild(prevChild);
2015-09-02 15:08:58 -04:00
}
// The child must be instantiated before it's mounted.
2015-10-14 22:58:32 -04:00
this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
2015-09-02 15:08:58 -04:00
}
nextIndex++;
}
// Remove children that are no longer present.
for (name in prevChildren) {
2015-10-14 22:58:32 -04:00
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
this._unmountChild(prevChildren[name]);
2015-09-02 15:08:58 -04:00
}
}
},
/**
* Unmounts all rendered children. This should be used to clean up children
* when this component is unmounted.
*
* @internal
*/
2015-10-14 22:58:32 -04:00
unmountChildren: function () {
2015-09-02 15:08:58 -04:00
var renderedChildren = this._renderedChildren;
ReactChildReconciler.unmountChildren(renderedChildren);
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
*/
2015-10-14 22:58:32 -04:00
moveChild: function (child, toIndex, lastIndex) {
2015-09-02 15:08:58 -04:00
// 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
*/
2015-10-14 22:58:32 -04:00
createChild: function (child, mountImage) {
enqueueInsertMarkup(this._rootNodeID, mountImage, child._mountIndex);
2015-09-02 15:08:58 -04:00
},
/**
* Removes a child component.
*
* @param {ReactComponent} child Child to remove.
* @protected
*/
2015-10-14 22:58:32 -04:00
removeChild: function (child) {
2015-09-02 15:08:58 -04:00
enqueueRemove(this._rootNodeID, child._mountIndex);
},
/**
* Sets this text content string.
*
* @param {string} textContent Text content to set.
* @protected
*/
2015-10-14 22:58:32 -04:00
setTextContent: function (textContent) {
2015-09-02 15:08:58 -04:00
enqueueTextContent(this._rootNodeID, textContent);
},
2015-10-14 22:58:32 -04:00
/**
* Sets this markup string.
*
* @param {string} markup Markup to set.
* @protected
*/
setMarkup: function (markup) {
enqueueSetMarkup(this._rootNodeID, markup);
},
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
_mountChildByNameAtIndex: function (child, name, index, transaction, context) {
2015-09-02 15:08:58 -04:00
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
var rootID = this._rootNodeID + name;
2015-10-14 22:58:32 -04:00
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
2015-09-02 15:08:58 -04:00
child._mountIndex = index;
this.createChild(child, mountImage);
},
/**
2015-10-14 22:58:32 -04:00
* Unmounts a rendered child.
2015-09-02 15:08:58 -04:00
*
* NOTE: This is part of `updateChildren` and is here for readability.
*
* @param {ReactComponent} child Component to unmount.
* @private
*/
2015-10-14 22:58:32 -04:00
_unmountChild: function (child) {
2015-09-02 15:08:58 -04:00
this.removeChild(child);
child._mountIndex = null;
}
}
};
module.exports = ReactMultiChild;
2015-10-14 22:58:32 -04:00
},{"122":122,"31":31,"36":36,"39":39,"74":74,"84":84}],74:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var keyMirror = _dereq_(164);
2015-09-02 15:08:58 -04:00
/**
* 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,
2015-10-14 22:58:32 -04:00
SET_MARKUP: null,
2015-09-02 15:08:58 -04:00
TEXT_CONTENT: null
});
module.exports = ReactMultiChildUpdateTypes;
2015-10-14 22:58:32 -04:00
},{"164":164}],75:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var autoGenerateWrapperClass = null;
var genericComponentClass = null;
2015-10-14 22:58:32 -04:00
// This registry keeps track of wrapper classes around native tags.
2015-09-02 15:08:58 -04:00
var tagToComponentClass = {};
var textComponentClass = null;
var ReactNativeComponentInjection = {
// This accepts a class that receives the tag string. This is a catch all
// that can render any kind of tag.
2015-10-14 22:58:32 -04:00
injectGenericComponentClass: function (componentClass) {
2015-09-02 15:08:58 -04:00
genericComponentClass = componentClass;
},
// This accepts a text component class that takes the text string to be
// rendered as props.
2015-10-14 22:58:32 -04:00
injectTextComponentClass: function (componentClass) {
2015-09-02 15:08:58 -04:00
textComponentClass = 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.
2015-10-14 22:58:32 -04:00
injectComponentClasses: function (componentClasses) {
2015-09-02 15:08:58 -04:00
assign(tagToComponentClass, componentClasses);
}
};
/**
* Get a composite component wrapper class for a specific tag.
*
* @param {ReactElement} element The tag for which to get the class.
* @return {function} The React class constructor function.
*/
function getComponentClassForElement(element) {
if (typeof element.type === 'function') {
return element.type;
}
var tag = element.type;
var componentClass = tagToComponentClass[tag];
if (componentClass == null) {
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
}
return componentClass;
}
/**
* Get a native internal component class for a specific tag.
*
* @param {ReactElement} element The element to create.
* @return {function} The internal class constructor function.
*/
function createInternalComponent(element) {
2015-10-14 22:58:32 -04:00
!genericComponentClass ? "development" !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
return new genericComponentClass(element.type, element.props);
}
/**
* @param {ReactText} text
* @return {ReactComponent}
*/
function createInstanceForText(text) {
return new textComponentClass(text);
}
/**
* @param {ReactComponent} component
* @return {boolean}
*/
function isTextComponent(component) {
return component instanceof textComponentClass;
}
var ReactNativeComponent = {
getComponentClassForElement: getComponentClassForElement,
createInternalComponent: createInternalComponent,
createInstanceForText: createInstanceForText,
isTextComponent: isTextComponent,
injection: ReactNativeComponentInjection
};
module.exports = ReactNativeComponent;
2015-10-14 22:58:32 -04:00
},{"160":160,"24":24}],76:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2015, Facebook, Inc.
2015-09-02 15:08:58 -04:00
* 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule ReactNoopUpdateQueue
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var warning = _dereq_(172);
function warnTDZ(publicInstance, callerName) {
if ("development" !== 'production') {
"development" !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
}
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* This is the abstract API for an update queue.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var ReactNoopUpdateQueue = {
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Checks whether or not this composite component is mounted.
* @param {ReactClass} publicInstance The instance we want to test.
* @return {boolean} True if mounted, false otherwise.
* @protected
2015-09-02 15:08:58 -04:00
* @final
*/
2015-10-14 22:58:32 -04:00
isMounted: function (publicInstance) {
return false;
2015-09-02 15:08:58 -04:00
},
/**
2015-10-14 22:58:32 -04:00
* Enqueue a callback that will be executed after all the pending updates
* have processed.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {ReactClass} publicInstance The instance to use as `this` context.
* @param {?function} callback Called after state is updated.
2015-09-02 15:08:58 -04:00
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueCallback: function (publicInstance, callback) {},
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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 `shouldComponentUpdate`, but it will invoke
* `componentWillUpdate` and `componentDidUpdate`.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @internal
*/
enqueueForceUpdate: function (publicInstance) {
warnTDZ(publicInstance, 'forceUpdate');
},
/**
* 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 {ReactClass} publicInstance The instance that should rerender.
* @param {object} completeState Next state.
* @internal
*/
enqueueReplaceState: function (publicInstance, completeState) {
warnTDZ(publicInstance, 'replaceState');
},
/**
* Sets a subset of the state. This only exists because _pendingState is
* internal. This provides a merging strategy that is not available to deep
* properties which is confusing. TODO: Expose pendingState or don't use it
* during the merge.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} partialState Next partial state to be merged with state.
* @internal
*/
enqueueSetState: function (publicInstance, partialState) {
warnTDZ(publicInstance, 'setState');
},
/**
* Sets a subset of the props.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} partialProps Subset of the next props.
* @internal
*/
enqueueSetProps: function (publicInstance, partialProps) {
warnTDZ(publicInstance, 'setProps');
},
/**
* Replaces all of the props.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} props New props.
* @internal
*/
enqueueReplaceProps: function (publicInstance, props) {
warnTDZ(publicInstance, 'replaceProps');
}
};
module.exports = ReactNoopUpdateQueue;
},{"172":172}],77:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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 invariant = _dereq_(160);
/**
* 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) {
!ReactOwner.isValidOwner(owner) ? "development" !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
owner.attachRef(ref, component);
},
/**
* Removes a component by ref from an owner component.
*
2015-09-02 15:08:58 -04:00
* @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
*/
2015-10-14 22:58:32 -04:00
removeComponentAsRefFrom: function (component, ref, owner) {
!ReactOwner.isValidOwner(owner) ? "development" !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
// Check that `component` is still the current ref because we do not want to
// detach the ref if another component stole it.
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
owner.detachRef(ref);
}
}
};
module.exports = ReactOwner;
2015-10-14 22:58:32 -04:00
},{"160":160}],78:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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,
/**
* @param {object} object
* @param {string} objectName
* @param {object<string>} methodNames
*/
2015-10-14 22:58:32 -04:00
measureMethods: function (object, objectName, methodNames) {
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
for (var key in methodNames) {
if (!methodNames.hasOwnProperty(key)) {
continue;
}
2015-10-14 22:58:32 -04:00
object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]);
2015-09-02 15:08:58 -04:00
}
}
},
/**
* Use this to wrap methods you want to measure. Zero overhead in production.
*
* @param {string} objName
* @param {string} fnName
* @param {function} func
* @return {function}
*/
2015-10-14 22:58:32 -04:00
measure: function (objName, fnName, func) {
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
var measuredFunc = null;
2015-10-14 22:58:32 -04:00
var wrapper = function () {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
injectMeasure: function (measure) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{}],79:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
var joinClasses = _dereq_(163);
2015-09-02 15:08:58 -04:00
/**
* 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) {
2015-10-14 22:58:32 -04:00
return function (props, key, value) {
2015-09-02 15:08:58 -04:00
if (!props.hasOwnProperty(key)) {
props[key] = value;
} else {
props[key] = mergeStrategy(props[key], value);
}
};
}
2015-10-14 22:58:32 -04:00
var transferStrategyMerge = createTransferStrategy(function (a, b) {
2015-09-02 15:08:58 -04:00
// `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 = {
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
mergeProps: function (oldProps, newProps) {
2015-09-02 15:08:58 -04:00
return transferInto(assign({}, oldProps), newProps);
}
};
module.exports = ReactPropTransferer;
2015-10-14 22:58:32 -04:00
},{"152":152,"163":163,"24":24}],80:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 = {};
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
ReactPropTypeLocationNames = {
prop: 'prop',
context: 'context',
childContext: 'child context'
};
}
module.exports = ReactPropTypeLocationNames;
2015-10-14 22:58:32 -04:00
},{}],81:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var keyMirror = _dereq_(164);
2015-09-02 15:08:58 -04:00
var ReactPropTypeLocations = keyMirror({
prop: null,
context: null,
childContext: null
});
module.exports = ReactPropTypeLocations;
2015-10-14 22:58:32 -04:00
},{"164":164}],82:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var ReactPropTypeLocationNames = _dereq_(80);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyFunction = _dereq_(152);
var getIteratorFn = _dereq_(128);
2015-09-02 15:08:58 -04:00
/**
* 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 ReactPropTypes = {
array: createPrimitiveTypeChecker('array'),
bool: createPrimitiveTypeChecker('boolean'),
func: createPrimitiveTypeChecker('function'),
number: createPrimitiveTypeChecker('number'),
object: createPrimitiveTypeChecker('object'),
string: createPrimitiveTypeChecker('string'),
any: createAnyTypeChecker(),
arrayOf: createArrayOfTypeChecker,
2015-10-14 22:58:32 -04:00
element: createElementTypeChecker(),
2015-09-02 15:08:58 -04:00
instanceOf: createInstanceTypeChecker,
2015-10-14 22:58:32 -04:00
node: createNodeChecker(),
2015-09-02 15:08:58 -04:00
objectOf: createObjectOfTypeChecker,
oneOf: createEnumTypeChecker,
oneOfType: createUnionTypeChecker,
shape: createShapeTypeChecker
};
function createChainableTypeChecker(validate) {
2015-10-14 22:58:32 -04:00
function checkType(isRequired, props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
componentName = componentName || ANONYMOUS;
2015-10-14 22:58:32 -04:00
propFullName = propFullName || propName;
2015-09-02 15:08:58 -04:00
if (props[propName] == null) {
var locationName = ReactPropTypeLocationNames[location];
if (isRequired) {
2015-10-14 22:58:32 -04:00
return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
2015-09-02 15:08:58 -04:00
}
return null;
} else {
2015-10-14 22:58:32 -04:00
return validate(props, propName, componentName, location, propFullName);
2015-09-02 15:08:58 -04:00
}
}
var chainedCheckType = checkType.bind(null, false);
chainedCheckType.isRequired = checkType.bind(null, true);
return chainedCheckType;
}
function createPrimitiveTypeChecker(expectedType) {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
2015-09-02 15:08:58 -04:00
}
return null;
}
return createChainableTypeChecker(validate);
}
function createAnyTypeChecker() {
return createChainableTypeChecker(emptyFunction.thatReturns(null));
}
function createArrayOfTypeChecker(typeChecker) {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
var propValue = props[propName];
if (!Array.isArray(propValue)) {
var locationName = ReactPropTypeLocationNames[location];
var propType = getPropType(propValue);
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
2015-09-02 15:08:58 -04:00
}
for (var i = 0; i < propValue.length; i++) {
2015-10-14 22:58:32 -04:00
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
2015-09-02 15:08:58 -04:00
if (error instanceof Error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createElementTypeChecker() {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
if (!ReactElement.isValidElement(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
2015-09-02 15:08:58 -04:00
}
return null;
}
return createChainableTypeChecker(validate);
}
function createInstanceTypeChecker(expectedClass) {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
if (!(props[propName] instanceof expectedClass)) {
var locationName = ReactPropTypeLocationNames[location];
var expectedClassName = expectedClass.name || ANONYMOUS;
2015-10-14 22:58:32 -04:00
var actualClassName = getClassName(props[propName]);
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
2015-09-02 15:08:58 -04:00
}
return null;
}
return createChainableTypeChecker(validate);
}
function createEnumTypeChecker(expectedValues) {
2015-10-14 22:58:32 -04:00
if (!Array.isArray(expectedValues)) {
return createChainableTypeChecker(function () {
return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
});
}
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
var propValue = props[propName];
for (var i = 0; i < expectedValues.length; i++) {
if (propValue === expectedValues[i]) {
return null;
}
}
var locationName = ReactPropTypeLocationNames[location];
var valuesString = JSON.stringify(expectedValues);
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
2015-09-02 15:08:58 -04:00
}
return createChainableTypeChecker(validate);
}
function createObjectOfTypeChecker(typeChecker) {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
var locationName = ReactPropTypeLocationNames[location];
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
2015-09-02 15:08:58 -04:00
}
for (var key in propValue) {
if (propValue.hasOwnProperty(key)) {
2015-10-14 22:58:32 -04:00
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
2015-09-02 15:08:58 -04:00
if (error instanceof Error) {
return error;
}
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function createUnionTypeChecker(arrayOfTypeCheckers) {
2015-10-14 22:58:32 -04:00
if (!Array.isArray(arrayOfTypeCheckers)) {
return createChainableTypeChecker(function () {
return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
});
}
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
2015-10-14 22:58:32 -04:00
if (checker(props, propName, componentName, location, propFullName) == null) {
2015-09-02 15:08:58 -04:00
return null;
}
}
var locationName = ReactPropTypeLocationNames[location];
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
2015-09-02 15:08:58 -04:00
}
return createChainableTypeChecker(validate);
}
function createNodeChecker() {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
if (!isNode(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
2015-09-02 15:08:58 -04:00
}
return null;
}
return createChainableTypeChecker(validate);
}
function createShapeTypeChecker(shapeTypes) {
2015-10-14 22:58:32 -04:00
function validate(props, propName, componentName, location, propFullName) {
2015-09-02 15:08:58 -04:00
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== 'object') {
var locationName = ReactPropTypeLocationNames[location];
2015-10-14 22:58:32 -04:00
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
2015-09-02 15:08:58 -04:00
}
for (var key in shapeTypes) {
var checker = shapeTypes[key];
if (!checker) {
continue;
}
2015-10-14 22:58:32 -04:00
var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
2015-09-02 15:08:58 -04:00
if (error) {
return error;
}
}
return null;
}
return createChainableTypeChecker(validate);
}
function isNode(propValue) {
switch (typeof propValue) {
case 'number':
case 'string':
case 'undefined':
return true;
case 'boolean':
return !propValue;
case 'object':
if (Array.isArray(propValue)) {
return propValue.every(isNode);
}
if (propValue === null || ReactElement.isValidElement(propValue)) {
return true;
}
2015-10-14 22:58:32 -04:00
var iteratorFn = getIteratorFn(propValue);
if (iteratorFn) {
var iterator = iteratorFn.call(propValue);
var step;
if (iteratorFn !== propValue.entries) {
while (!(step = iterator.next()).done) {
if (!isNode(step.value)) {
return false;
}
}
} else {
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
if (!isNode(entry[1])) {
return false;
}
}
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
} else {
return false;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
// Returns class name of the object, if any.
function getClassName(propValue) {
if (!propValue.constructor || !propValue.constructor.name) {
return '<<anonymous>>';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return propValue.constructor.name;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactPropTypes;
},{"128":128,"152":152,"57":57,"80":80}],83:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var CallbackQueue = _dereq_(6);
var PooledClass = _dereq_(25);
var ReactBrowserEventEmitter = _dereq_(28);
var ReactDOMFeatureFlags = _dereq_(44);
var ReactInputSelection = _dereq_(66);
var Transaction = _dereq_(113);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
2015-09-02 15:08:58 -04:00
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
initialize: function () {
2015-09-02 15:08:58 -04:00
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
ReactBrowserEventEmitter.setEnabled(false);
return currentlyEnabled;
},
/**
* @param {boolean} previouslyEnabled Enabled status of
2015-10-14 22:58:32 -04:00
* `ReactBrowserEventEmitter` before the reconciliation occurred. `close`
2015-09-02 15:08:58 -04:00
* restores the previous value.
*/
2015-10-14 22:58:32 -04:00
close: function (previouslyEnabled) {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
initialize: function () {
2015-09-02 15:08:58 -04:00
this.reactMountReady.reset();
},
/**
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
*/
2015-10-14 22:58:32 -04:00
close: function () {
2015-09-02 15:08:58 -04:00
this.reactMountReady.notifyAll();
}
};
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING];
2015-09-02 15:08:58 -04:00
/**
* 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
*/
2015-10-14 22:58:32 -04:00
function ReactReconcileTransaction(forceHTML) {
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
this.useCreateElement = !forceHTML && ReactDOMFeatureFlags.useCreateElement;
2015-09-02 15:08:58 -04:00
}
var Mixin = {
/**
* @see Transaction
* @abstract
* @final
2015-10-14 22:58:32 -04:00
* @return {array<object>} List of operation wrap procedures.
2015-09-02 15:08:58 -04:00
* TODO: convert to array<TransactionWrapper>
*/
2015-10-14 22:58:32 -04:00
getTransactionWrappers: function () {
2015-09-02 15:08:58 -04:00
return TRANSACTION_WRAPPERS;
},
/**
* @return {object} The queue to collect `onDOMReady` callbacks with.
*/
2015-10-14 22:58:32 -04:00
getReactMountReady: function () {
2015-09-02 15:08:58 -04:00
return this.reactMountReady;
},
/**
* `PooledClass` looks for this, and will invoke this before allowing this
2015-10-14 22:58:32 -04:00
* instance to be reused.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
CallbackQueue.release(this.reactMountReady);
this.reactMountReady = null;
}
};
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
PooledClass.addPoolingTo(ReactReconcileTransaction);
module.exports = ReactReconcileTransaction;
2015-10-14 22:58:32 -04:00
},{"113":113,"24":24,"25":25,"28":28,"44":44,"6":6,"66":66}],84:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ReactReconciler
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactRef = _dereq_(85);
2015-09-02 15:08:58 -04:00
/**
* Helper to call ReactRef.attachRefs with this composite component, split out
* to avoid allocations in the transaction mount-ready queue.
*/
function attachRefs() {
ReactRef.attachRefs(this, this._currentElement);
}
var ReactReconciler = {
/**
* Initializes the component, renders markup, and registers event listeners.
*
* @param {ReactComponent} internalInstance
* @param {string} rootID DOM ID of the root node.
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
* @return {?string} Rendered markup to be inserted into the DOM.
* @final
* @internal
*/
2015-10-14 22:58:32 -04:00
mountComponent: function (internalInstance, rootID, transaction, context) {
2015-09-02 15:08:58 -04:00
var markup = internalInstance.mountComponent(rootID, transaction, context);
2015-10-14 22:58:32 -04:00
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
2015-09-02 15:08:58 -04:00
}
return markup;
},
/**
* Releases any resources allocated by `mountComponent`.
*
* @final
* @internal
*/
2015-10-14 22:58:32 -04:00
unmountComponent: function (internalInstance) {
2015-09-02 15:08:58 -04:00
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
internalInstance.unmountComponent();
},
/**
* Update a component using a new element.
*
* @param {ReactComponent} internalInstance
* @param {ReactElement} nextElement
* @param {ReactReconcileTransaction} transaction
* @param {object} context
* @internal
*/
2015-10-14 22:58:32 -04:00
receiveComponent: function (internalInstance, nextElement, transaction, context) {
2015-09-02 15:08:58 -04:00
var prevElement = internalInstance._currentElement;
2015-10-14 22:58:32 -04:00
if (nextElement === prevElement && context === internalInstance._context) {
2015-09-02 15:08:58 -04:00
// 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 an element created outside a composite to be
// deeply mutated and reused.
2015-10-14 22:58:32 -04:00
// TODO: Bailing out early is just a perf optimization right?
// TODO: Removing the return statement should affect correctness?
return;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
2015-09-02 15:08:58 -04:00
if (refsChanged) {
ReactRef.detachRefs(internalInstance, prevElement);
}
internalInstance.receiveComponent(nextElement, transaction, context);
2015-10-14 22:58:32 -04:00
if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
2015-09-02 15:08:58 -04:00
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
}
},
/**
* Flush any dirty changes in a component.
*
* @param {ReactComponent} internalInstance
* @param {ReactReconcileTransaction} transaction
* @internal
*/
2015-10-14 22:58:32 -04:00
performUpdateIfNecessary: function (internalInstance, transaction) {
2015-09-02 15:08:58 -04:00
internalInstance.performUpdateIfNecessary(transaction);
}
};
module.exports = ReactReconciler;
2015-10-14 22:58:32 -04:00
},{"85":85}],85:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ReactRef
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactOwner = _dereq_(77);
2015-09-02 15:08:58 -04:00
var ReactRef = {};
function attachRef(ref, component, owner) {
if (typeof ref === 'function') {
ref(component.getPublicInstance());
} else {
// Legacy ref
ReactOwner.addComponentAsRefTo(component, ref, owner);
}
}
function detachRef(ref, component, owner) {
if (typeof ref === 'function') {
ref(null);
} else {
// Legacy ref
ReactOwner.removeComponentAsRefFrom(component, ref, owner);
}
}
2015-10-14 22:58:32 -04:00
ReactRef.attachRefs = function (instance, element) {
if (element === null || element === false) {
return;
}
2015-09-02 15:08:58 -04:00
var ref = element.ref;
if (ref != null) {
attachRef(ref, instance, element._owner);
}
};
2015-10-14 22:58:32 -04:00
ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
var prevEmpty = prevElement === null || prevElement === false;
var nextEmpty = nextElement === null || nextElement === false;
return(
// This has a few false positives w/r/t empty components.
prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref
2015-09-02 15:08:58 -04:00
);
};
2015-10-14 22:58:32 -04:00
ReactRef.detachRefs = function (instance, element) {
if (element === null || element === false) {
return;
}
2015-09-02 15:08:58 -04:00
var ref = element.ref;
if (ref != null) {
detachRef(ref, instance, element._owner);
}
};
module.exports = ReactRef;
2015-10-14 22:58:32 -04:00
},{"77":77}],86:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
2015-10-14 22:58:32 -04:00
injectCreateReactRootIndex: function (_createReactRootIndex) {
2015-09-02 15:08:58 -04:00
ReactRootIndex.createReactRootIndex = _createReactRootIndex;
}
};
var ReactRootIndex = {
createReactRootIndex: null,
injection: ReactRootIndexInjection
};
module.exports = ReactRootIndex;
2015-10-14 22:58:32 -04:00
},{}],87:[function(_dereq_,module,exports){
/**
* Copyright 2014-2015, 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 ReactServerBatchingStrategy
* @typechecks
*/
'use strict';
var ReactServerBatchingStrategy = {
isBatchingUpdates: false,
batchedUpdates: function (callback) {
// Don't do anything here. During the server rendering we don't want to
// schedule any updates. We will simply ignore them.
}
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactServerBatchingStrategy;
},{}],88:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ReactDefaultBatchingStrategy = _dereq_(53);
var ReactElement = _dereq_(57);
var ReactInstanceHandles = _dereq_(67);
var ReactMarkupChecksum = _dereq_(71);
var ReactServerBatchingStrategy = _dereq_(87);
var ReactServerRenderingTransaction = _dereq_(89);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyObject = _dereq_(153);
var instantiateReactComponent = _dereq_(131);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
* @param {ReactElement} element
* @return {string} the HTML markup
*/
function renderToString(element) {
2015-10-14 22:58:32 -04:00
!ReactElement.isValidElement(element) ? "development" !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var transaction;
try {
2015-10-14 22:58:32 -04:00
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
2015-09-02 15:08:58 -04:00
var id = ReactInstanceHandles.createReactRootID();
transaction = ReactServerRenderingTransaction.getPooled(false);
2015-10-14 22:58:32 -04:00
return transaction.perform(function () {
2015-09-02 15:08:58 -04:00
var componentInstance = instantiateReactComponent(element, null);
2015-10-14 22:58:32 -04:00
var markup = componentInstance.mountComponent(id, transaction, emptyObject);
2015-09-02 15:08:58 -04:00
return ReactMarkupChecksum.addChecksumToMarkup(markup);
}, null);
} finally {
ReactServerRenderingTransaction.release(transaction);
2015-10-14 22:58:32 -04:00
// Revert to the DOM batching strategy since these two renderers
// currently share these stateful modules.
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
2015-09-02 15:08:58 -04:00
}
}
/**
* @param {ReactElement} element
* @return {string} the HTML markup, without the extra React ID and checksum
* (for generating static pages)
*/
function renderToStaticMarkup(element) {
2015-10-14 22:58:32 -04:00
!ReactElement.isValidElement(element) ? "development" !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var transaction;
try {
2015-10-14 22:58:32 -04:00
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
2015-09-02 15:08:58 -04:00
var id = ReactInstanceHandles.createReactRootID();
transaction = ReactServerRenderingTransaction.getPooled(true);
2015-10-14 22:58:32 -04:00
return transaction.perform(function () {
2015-09-02 15:08:58 -04:00
var componentInstance = instantiateReactComponent(element, null);
return componentInstance.mountComponent(id, transaction, emptyObject);
}, null);
} finally {
ReactServerRenderingTransaction.release(transaction);
2015-10-14 22:58:32 -04:00
// Revert to the DOM batching strategy since these two renderers
// currently share these stateful modules.
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
2015-09-02 15:08:58 -04:00
}
}
module.exports = {
renderToString: renderToString,
renderToStaticMarkup: renderToStaticMarkup
};
2015-10-14 22:58:32 -04:00
},{"131":131,"153":153,"160":160,"53":53,"57":57,"67":67,"71":71,"87":87,"89":89,"96":96}],89:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var PooledClass = _dereq_(25);
var CallbackQueue = _dereq_(6);
var Transaction = _dereq_(113);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
2015-09-02 15:08:58 -04:00
/**
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
* during the performing of the transaction.
*/
var ON_DOM_READY_QUEUEING = {
/**
* Initializes the internal `onDOMReady` queue.
*/
2015-10-14 22:58:32 -04:00
initialize: function () {
2015-09-02 15:08:58 -04:00
this.reactMountReady.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.
*/
2015-10-14 22:58:32 -04:00
var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
2015-09-02 15:08:58 -04:00
/**
* @class ReactServerRenderingTransaction
* @param {boolean} renderToStaticMarkup
*/
function ReactServerRenderingTransaction(renderToStaticMarkup) {
this.reinitializeTransaction();
this.renderToStaticMarkup = renderToStaticMarkup;
this.reactMountReady = CallbackQueue.getPooled(null);
2015-10-14 22:58:32 -04:00
this.useCreateElement = false;
2015-09-02 15:08:58 -04:00
}
var Mixin = {
/**
* @see Transaction
* @abstract
* @final
2015-10-14 22:58:32 -04:00
* @return {array} Empty list of operation wrap procedures.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
getTransactionWrappers: function () {
2015-09-02 15:08:58 -04:00
return TRANSACTION_WRAPPERS;
},
/**
* @return {object} The queue to collect `onDOMReady` callbacks with.
*/
2015-10-14 22:58:32 -04:00
getReactMountReady: function () {
2015-09-02 15:08:58 -04:00
return this.reactMountReady;
},
/**
* `PooledClass` looks for this, and will invoke this before allowing this
2015-10-14 22:58:32 -04:00
* instance to be reused.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
CallbackQueue.release(this.reactMountReady);
this.reactMountReady = null;
}
};
2015-10-14 22:58:32 -04:00
assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
2015-09-02 15:08:58 -04:00
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
module.exports = ReactServerRenderingTransaction;
2015-10-14 22:58:32 -04:00
},{"113":113,"152":152,"24":24,"25":25,"6":6}],90:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*/
2015-10-14 22:58:32 -04:00
createStateSetter: function (component, funcReturningState) {
return function (a, b, c, d, e, f) {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
createStateKeySetter: function (component, key) {
2015-09-02 15:08:58 -04:00
// 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.
*/
2015-10-14 22:58:32 -04:00
createStateSetter: function (funcReturningState) {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
createStateKeySetter: function (key) {
2015-09-02 15:08:58 -04:00
return ReactStateSetters.createStateKeySetter(this, key);
}
};
module.exports = ReactStateSetters;
2015-10-14 22:58:32 -04:00
},{}],91:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPluginHub = _dereq_(16);
var EventPropagators = _dereq_(19);
var React = _dereq_(26);
var ReactDOM = _dereq_(40);
var ReactElement = _dereq_(57);
var ReactBrowserEventEmitter = _dereq_(28);
var ReactCompositeComponent = _dereq_(38);
var ReactInstanceHandles = _dereq_(67);
var ReactInstanceMap = _dereq_(68);
var ReactMount = _dereq_(72);
var ReactUpdates = _dereq_(96);
var SyntheticEvent = _dereq_(105);
var assign = _dereq_(24);
var emptyObject = _dereq_(153);
var findDOMNode = _dereq_(121);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
function Event(suffix) {}
/**
* @class ReactTestUtils
*/
2015-10-14 22:58:32 -04:00
function findAllInRenderedTreeInternal(inst, test) {
if (!inst || !inst.getPublicInstance) {
return [];
}
var publicInst = inst.getPublicInstance();
var ret = test(publicInst) ? [publicInst] : [];
var currentElement = inst._currentElement;
if (ReactTestUtils.isDOMComponent(publicInst)) {
var renderedChildren = inst._renderedChildren;
var key;
for (key in renderedChildren) {
if (!renderedChildren.hasOwnProperty(key)) {
continue;
}
ret = ret.concat(findAllInRenderedTreeInternal(renderedChildren[key], test));
}
} else if (ReactElement.isValidElement(currentElement) && typeof currentElement.type === 'function') {
ret = ret.concat(findAllInRenderedTreeInternal(inst._renderedComponent, test));
}
return ret;
}
2015-09-02 15:08:58 -04:00
/**
* Todo: Support the entire DOM.scry query syntax. For now, these simple
* utilities will suffice for testing purposes.
* @lends ReactTestUtils
*/
var ReactTestUtils = {
2015-10-14 22:58:32 -04:00
renderIntoDocument: function (instance) {
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
return ReactDOM.render(instance, div);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
isElement: function (element) {
2015-09-02 15:08:58 -04:00
return ReactElement.isValidElement(element);
},
2015-10-14 22:58:32 -04:00
isElementOfType: function (inst, convenienceConstructor) {
return ReactElement.isValidElement(inst) && inst.type === convenienceConstructor;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
isDOMComponent: function (inst) {
2015-09-02 15:08:58 -04:00
// TODO: Fix this heuristic. It's just here because composites can currently
// pretend to be DOM components.
2015-10-14 22:58:32 -04:00
return !!(inst && inst.nodeType === 1 && inst.tagName);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
isDOMComponentElement: function (inst) {
return !!(inst && ReactElement.isValidElement(inst) && !!inst.tagName);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
isCompositeComponent: function (inst) {
if (ReactTestUtils.isDOMComponent(inst)) {
// Accessing inst.setState warns; just return false as that'll be what
// this returns when we have DOM nodes as refs directly
return false;
}
return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
},
isCompositeComponentWithType: function (inst, type) {
if (!ReactTestUtils.isCompositeComponent(inst)) {
return false;
}
var internalInstance = ReactInstanceMap.get(inst);
var constructor = internalInstance._currentElement.type;
return constructor === type;
},
isCompositeComponentElement: function (inst) {
if (!ReactElement.isValidElement(inst)) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
return typeof prototype.render === 'function' && typeof prototype.setState === 'function';
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
isCompositeComponentElementWithType: function (inst, type) {
var internalInstance = ReactInstanceMap.get(inst);
var constructor = internalInstance._currentElement.type;
return !!(ReactTestUtils.isCompositeComponentElement(inst) && constructor === type);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
getRenderedChildOfCompositeComponent: function (inst) {
2015-09-02 15:08:58 -04:00
if (!ReactTestUtils.isCompositeComponent(inst)) {
return null;
}
var internalInstance = ReactInstanceMap.get(inst);
return internalInstance._renderedComponent.getPublicInstance();
},
2015-10-14 22:58:32 -04:00
findAllInRenderedTree: function (inst, test) {
2015-09-02 15:08:58 -04:00
if (!inst) {
return [];
}
2015-10-14 22:58:32 -04:00
!ReactTestUtils.isCompositeComponent(inst) ? "development" !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : undefined;
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
2015-09-02 15:08:58 -04:00
},
/**
* Finds all instance of components in the rendered tree that are DOM
* components with the class name matching `className`.
2015-10-14 22:58:32 -04:00
* @return {array} an array of all the matches.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
scryRenderedDOMComponentsWithClass: function (root, classNames) {
if (!Array.isArray(classNames)) {
classNames = classNames.split(/\s+/);
}
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
if (ReactTestUtils.isDOMComponent(inst)) {
var classList = ReactDOM.findDOMNode(inst).className.split(/\s+/);
return classNames.every(function (className) {
return classList.indexOf(className) !== -1;
});
}
return false;
2015-09-02 15:08:58 -04:00
});
},
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
findRenderedDOMComponentWithClass: function (root, className) {
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
2015-09-02 15:08:58 -04:00
if (all.length !== 1) {
2015-10-14 22:58:32 -04:00
throw new Error('Did not find exactly one match ' + '(found: ' + all.length + ') for class:' + className);
2015-09-02 15:08:58 -04:00
}
return all[0];
},
/**
* Finds all instance of components in the rendered tree that are DOM
* components with the tag name matching `tagName`.
2015-10-14 22:58:32 -04:00
* @return {array} an array of all the matches.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
scryRenderedDOMComponentsWithTag: function (root, tagName) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
2015-09-02 15:08:58 -04:00
});
},
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
findRenderedDOMComponentWithTag: function (root, tagName) {
2015-09-02 15:08:58 -04:00
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`.
2015-10-14 22:58:32 -04:00
* @return {array} an array of all the matches.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
scryRenderedComponentsWithType: function (root, componentType) {
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
2015-09-02 15:08:58 -04:00
});
},
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
findRenderedComponentWithType: function (root, componentType) {
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
2015-09-02 15:08:58 -04:00
if (all.length !== 1) {
2015-10-14 22:58:32 -04:00
throw new Error('Did not find exactly one match for componentType:' + componentType + ' (found ' + all.length + ')');
2015-09-02 15:08:58 -04:00
}
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)
*/
2015-10-14 22:58:32 -04:00
mockComponent: function (module, mockTagName) {
mockTagName = mockTagName || module.mockTagName || 'div';
module.prototype.render.mockImplementation(function () {
return React.createElement(mockTagName, null, this.props.children);
2015-09-02 15:08:58 -04:00
});
return this;
},
/**
2015-10-14 22:58:32 -04:00
* Simulates a top level event being dispatched from a raw event that occurred
2015-09-02 15:08:58 -04:00
* on an `Element` node.
2015-10-14 22:58:32 -04:00
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`
2015-09-02 15:08:58 -04:00
* @param {!Element} node The dom to simulate an event occurring on.
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
*/
2015-10-14 22:58:32 -04:00
simulateNativeEventOnNode: function (topLevelType, node, fakeNativeEvent) {
2015-09-02 15:08:58 -04:00
fakeNativeEvent.target = node;
2015-10-14 22:58:32 -04:00
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
2015-09-02 15:08:58 -04:00
},
/**
2015-10-14 22:58:32 -04:00
* Simulates a top level event being dispatched from a raw event that occurred
2015-09-02 15:08:58 -04:00
* on the `ReactDOMComponent` `comp`.
2015-10-14 22:58:32 -04:00
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`.
* @param {!ReactDOMComponent} comp
2015-09-02 15:08:58 -04:00
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
*/
2015-10-14 22:58:32 -04:00
simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
},
nativeTouchData: function (x, y) {
2015-09-02 15:08:58 -04:00
return {
2015-10-14 22:58:32 -04:00
touches: [{ pageX: x, pageY: y }]
2015-09-02 15:08:58 -04:00
};
},
2015-10-14 22:58:32 -04:00
createRenderer: function () {
2015-09-02 15:08:58 -04:00
return new ReactShallowRenderer();
},
Simulate: null,
SimulateNative: {}
};
/**
* @class ReactShallowRenderer
*/
2015-10-14 22:58:32 -04:00
var ReactShallowRenderer = function () {
2015-09-02 15:08:58 -04:00
this._instance = null;
};
2015-10-14 22:58:32 -04:00
ReactShallowRenderer.prototype.getRenderOutput = function () {
return this._instance && this._instance._renderedComponent && this._instance._renderedComponent._renderedOutput || null;
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var NoopInternalComponent = function (element) {
2015-09-02 15:08:58 -04:00
this._renderedOutput = element;
2015-10-14 22:58:32 -04:00
this._currentElement = element;
2015-09-02 15:08:58 -04:00
};
NoopInternalComponent.prototype = {
2015-10-14 22:58:32 -04:00
mountComponent: function () {},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
receiveComponent: function (element) {
2015-09-02 15:08:58 -04:00
this._renderedOutput = element;
2015-10-14 22:58:32 -04:00
this._currentElement = element;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
unmountComponent: function () {}
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
var ShallowComponentWrapper = function () {};
assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
_instantiateReactComponent: function (element) {
return new NoopInternalComponent(element);
},
_replaceNodeWithMarkupByID: function () {},
_renderValidatedComponent: ReactCompositeComponent.Mixin._renderValidatedComponentWithoutOwnerOrContext
});
ReactShallowRenderer.prototype.render = function (element, context) {
!ReactElement.isValidElement(element) ? "development" !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : invariant(false) : undefined;
!(typeof element.type !== 'string') ? "development" !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom ' + 'components, not primitives (%s). Instead of calling `.render(el)` and ' + 'inspecting the rendered output, look at `el.props` directly instead.', element.type) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
if (!context) {
context = emptyObject;
}
2015-10-14 22:58:32 -04:00
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(false);
2015-09-02 15:08:58 -04:00
this._render(element, transaction, context);
ReactUpdates.ReactReconcileTransaction.release(transaction);
};
2015-10-14 22:58:32 -04:00
ReactShallowRenderer.prototype.unmount = function () {
2015-09-02 15:08:58 -04:00
if (this._instance) {
this._instance.unmountComponent();
}
};
2015-10-14 22:58:32 -04:00
ReactShallowRenderer.prototype._render = function (element, transaction, context) {
if (this._instance) {
this._instance.receiveComponent(element, transaction, context);
} else {
2015-09-02 15:08:58 -04:00
var rootID = ReactInstanceHandles.createReactRootID();
var instance = new ShallowComponentWrapper(element.type);
instance.construct(element);
instance.mountComponent(rootID, transaction, context);
this._instance = instance;
}
};
/**
* 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) {
2015-10-14 22:58:32 -04:00
return function (domComponentOrNode, eventData) {
2015-09-02 15:08:58 -04:00
var node;
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
2015-10-14 22:58:32 -04:00
node = findDOMNode(domComponentOrNode);
2015-09-02 15:08:58 -04:00
} else if (domComponentOrNode.tagName) {
node = domComponentOrNode;
}
2015-10-14 22:58:32 -04:00
var dispatchConfig = ReactBrowserEventEmitter.eventNameDispatchConfigs[eventType];
2015-09-02 15:08:58 -04:00
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
2015-10-14 22:58:32 -04:00
var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent, node);
2015-09-02 15:08:58 -04:00
assign(event, eventData);
2015-10-14 22:58:32 -04:00
if (dispatchConfig.phasedRegistrationNames) {
EventPropagators.accumulateTwoPhaseDispatches(event);
} else {
EventPropagators.accumulateDirectDispatches(event);
}
ReactUpdates.batchedUpdates(function () {
2015-09-02 15:08:58 -04:00
EventPluginHub.enqueueEvents(event);
2015-10-14 22:58:32 -04:00
EventPluginHub.processEventQueue(true);
2015-09-02 15:08:58 -04:00
});
};
}
function buildSimulators() {
ReactTestUtils.Simulate = {};
var eventType;
for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
/**
2015-10-14 22:58:32 -04:00
* @param {!Element|ReactDOMComponent} domComponentOrNode
2015-09-02 15:08:58 -04:00
* @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;
2015-10-14 22:58:32 -04:00
EventPluginHub.injection.injectEventPluginOrder = function () {
2015-09-02 15:08:58 -04:00
oldInjectEventPluginOrder.apply(this, arguments);
buildSimulators();
};
var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
2015-10-14 22:58:32 -04:00
EventPluginHub.injection.injectEventPluginsByName = function () {
2015-09-02 15:08:58 -04:00
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) {
2015-10-14 22:58:32 -04:00
return function (domComponentOrNode, nativeEventData) {
2015-09-02 15:08:58 -04:00
var fakeNativeEvent = new Event(eventType);
assign(fakeNativeEvent, nativeEventData);
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
2015-10-14 22:58:32 -04:00
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
} else if (domComponentOrNode.tagName) {
2015-09-02 15:08:58 -04:00
// Will allow on actual dom nodes.
2015-10-14 22:58:32 -04:00
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
2015-09-02 15:08:58 -04:00
}
};
}
2015-10-14 22:58:32 -04:00
Object.keys(topLevelTypes).forEach(function (eventType) {
2015-09-02 15:08:58 -04:00
// Event type is stored as 'topClick' - we transform that to 'click'
2015-10-14 22:58:32 -04:00
var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* @param {!Element|ReactDOMComponent} domComponentOrNode
2015-09-02 15:08:58 -04:00
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
*/
2015-10-14 22:58:32 -04:00
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
});
2015-09-02 15:08:58 -04:00
module.exports = ReactTestUtils;
2015-10-14 22:58:32 -04:00
},{"105":105,"121":121,"15":15,"153":153,"16":16,"160":160,"19":19,"24":24,"26":26,"28":28,"38":38,"40":40,"57":57,"67":67,"68":68,"72":72,"96":96}],92:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var flattenChildren = _dereq_(122);
2015-09-02 15:08:58 -04:00
var ReactTransitionChildMapping = {
/**
* Given `this.props.children`, return an object mapping key to child. Just
2015-10-14 22:58:32 -04:00
* simple syntactic sugar around flattenChildren().
2015-09-02 15:08:58 -04:00
*
* @param {*} children `this.props.children`
* @return {object} Mapping of key to child
*/
2015-10-14 22:58:32 -04:00
getChildMapping: function (children) {
2015-09-02 15:08:58 -04:00
if (!children) {
return children;
}
2015-10-14 22:58:32 -04:00
return flattenChildren(children);
2015-09-02 15:08:58 -04:00
},
/**
* 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.
*/
2015-10-14 22:58:32 -04:00
mergeChildMappings: function (prev, next) {
2015-09-02 15:08:58 -04:00
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];
2015-10-14 22:58:32 -04:00
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
2015-09-02 15:08:58 -04:00
}
}
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;
2015-10-14 22:58:32 -04:00
},{"122":122}],93:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
/**
* 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 = {
2015-10-14 22:58:32 -04:00
addEndEventListener: function (node, eventListener) {
2015-09-02 15:08:58 -04:00
if (endEvents.length === 0) {
// If CSS transitions are not supported, trigger an "end animation"
// event immediately.
window.setTimeout(eventListener, 0);
return;
}
2015-10-14 22:58:32 -04:00
endEvents.forEach(function (endEvent) {
2015-09-02 15:08:58 -04:00
addEventListener(node, endEvent, eventListener);
});
},
2015-10-14 22:58:32 -04:00
removeEndEventListener: function (node, eventListener) {
2015-09-02 15:08:58 -04:00
if (endEvents.length === 0) {
return;
}
2015-10-14 22:58:32 -04:00
endEvents.forEach(function (endEvent) {
2015-09-02 15:08:58 -04:00
removeEventListener(node, endEvent, eventListener);
});
}
};
module.exports = ReactTransitionEvents;
2015-10-14 22:58:32 -04:00
},{"146":146}],94:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var React = _dereq_(26);
var ReactTransitionChildMapping = _dereq_(92);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
2015-09-02 15:08:58 -04:00
var ReactTransitionGroup = React.createClass({
displayName: 'ReactTransitionGroup',
propTypes: {
component: React.PropTypes.any,
childFactory: React.PropTypes.func
},
2015-10-14 22:58:32 -04:00
getDefaultProps: function () {
2015-09-02 15:08:58 -04:00
return {
component: 'span',
childFactory: emptyFunction.thatReturnsArgument
};
},
2015-10-14 22:58:32 -04:00
getInitialState: function () {
2015-09-02 15:08:58 -04:00
return {
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
};
},
2015-10-14 22:58:32 -04:00
componentWillMount: function () {
2015-09-02 15:08:58 -04:00
this.currentlyTransitioningKeys = {};
this.keysToEnter = [];
this.keysToLeave = [];
},
2015-10-14 22:58:32 -04:00
componentDidMount: function () {
2015-09-02 15:08:58 -04:00
var initialChildMapping = this.state.children;
for (var key in initialChildMapping) {
if (initialChildMapping[key]) {
this.performAppear(key);
}
}
},
2015-10-14 22:58:32 -04:00
componentWillReceiveProps: function (nextProps) {
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children);
2015-09-02 15:08:58 -04:00
var prevChildMapping = this.state.children;
this.setState({
2015-10-14 22:58:32 -04:00
children: ReactTransitionChildMapping.mergeChildMappings(prevChildMapping, nextChildMapping)
2015-09-02 15:08:58 -04:00
});
var key;
for (key in nextChildMapping) {
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
2015-10-14 22:58:32 -04:00
if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {
2015-09-02 15:08:58 -04:00
this.keysToEnter.push(key);
}
}
for (key in prevChildMapping) {
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
2015-10-14 22:58:32 -04:00
if (prevChildMapping[key] && !hasNext && !this.currentlyTransitioningKeys[key]) {
2015-09-02 15:08:58 -04:00
this.keysToLeave.push(key);
}
}
// If we want to someday check for reordering, we could do it here.
},
2015-10-14 22:58:32 -04:00
componentDidUpdate: function () {
2015-09-02 15:08:58 -04:00
var keysToEnter = this.keysToEnter;
this.keysToEnter = [];
keysToEnter.forEach(this.performEnter);
var keysToLeave = this.keysToLeave;
this.keysToLeave = [];
keysToLeave.forEach(this.performLeave);
},
2015-10-14 22:58:32 -04:00
performAppear: function (key) {
2015-09-02 15:08:58 -04:00
this.currentlyTransitioningKeys[key] = true;
var component = this.refs[key];
if (component.componentWillAppear) {
2015-10-14 22:58:32 -04:00
component.componentWillAppear(this._handleDoneAppearing.bind(this, key));
2015-09-02 15:08:58 -04:00
} else {
this._handleDoneAppearing(key);
}
},
2015-10-14 22:58:32 -04:00
_handleDoneAppearing: function (key) {
2015-09-02 15:08:58 -04:00
var component = this.refs[key];
if (component.componentDidAppear) {
component.componentDidAppear();
}
delete this.currentlyTransitioningKeys[key];
2015-10-14 22:58:32 -04:00
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
2015-09-02 15:08:58 -04:00
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
// This was removed before it had fully appeared. Remove it.
this.performLeave(key);
}
},
2015-10-14 22:58:32 -04:00
performEnter: function (key) {
2015-09-02 15:08:58 -04:00
this.currentlyTransitioningKeys[key] = true;
var component = this.refs[key];
if (component.componentWillEnter) {
2015-10-14 22:58:32 -04:00
component.componentWillEnter(this._handleDoneEntering.bind(this, key));
2015-09-02 15:08:58 -04:00
} else {
this._handleDoneEntering(key);
}
},
2015-10-14 22:58:32 -04:00
_handleDoneEntering: function (key) {
2015-09-02 15:08:58 -04:00
var component = this.refs[key];
if (component.componentDidEnter) {
component.componentDidEnter();
}
delete this.currentlyTransitioningKeys[key];
2015-10-14 22:58:32 -04:00
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
2015-09-02 15:08:58 -04:00
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
// This was removed before it had fully entered. Remove it.
this.performLeave(key);
}
},
2015-10-14 22:58:32 -04:00
performLeave: function (key) {
2015-09-02 15:08:58 -04:00
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);
}
},
2015-10-14 22:58:32 -04:00
_handleDoneLeaving: function (key) {
2015-09-02 15:08:58 -04:00
var component = this.refs[key];
if (component.componentDidLeave) {
component.componentDidLeave();
}
delete this.currentlyTransitioningKeys[key];
2015-10-14 22:58:32 -04:00
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
2015-09-02 15:08:58 -04:00
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
// This entered again before it fully left. Add it again.
this.performEnter(key);
} else {
2015-10-14 22:58:32 -04:00
this.setState(function (state) {
var newChildren = assign({}, state.children);
delete newChildren[key];
return { children: newChildren };
});
2015-09-02 15:08:58 -04:00
}
},
2015-10-14 22:58:32 -04:00
render: function () {
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
return React.createElement(this.props.component, this.props, childrenToRender);
2015-09-02 15:08:58 -04:00
}
});
module.exports = ReactTransitionGroup;
2015-10-14 22:58:32 -04:00
},{"152":152,"24":24,"26":26,"92":92}],95:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2015, 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 ReactUpdateQueue
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactCurrentOwner = _dereq_(39);
var ReactElement = _dereq_(57);
var ReactInstanceMap = _dereq_(68);
var ReactUpdates = _dereq_(96);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
function enqueueUpdate(internalInstance) {
2015-10-14 22:58:32 -04:00
ReactUpdates.enqueueUpdate(internalInstance);
2015-09-02 15:08:58 -04:00
}
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
var internalInstance = ReactInstanceMap.get(publicInstance);
if (!internalInstance) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
2015-09-02 15:08:58 -04:00
// Only warn when we have a callerName. Otherwise we should be silent.
// We're probably calling from enqueueCallback. We don't want to warn
// there because we already warned for the corresponding lifecycle method.
2015-10-14 22:58:32 -04:00
"development" !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
2015-09-02 15:08:58 -04:00
}
return null;
}
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
2015-09-02 15:08:58 -04:00
}
return internalInstance;
}
/**
* ReactUpdateQueue allows for state updates to be scheduled into a later
* reconciliation step.
*/
var ReactUpdateQueue = {
2015-10-14 22:58:32 -04:00
/**
* Checks whether or not this composite component is mounted.
* @param {ReactClass} publicInstance The instance we want to test.
* @return {boolean} True if mounted, false otherwise.
* @protected
* @final
*/
isMounted: function (publicInstance) {
if ("development" !== 'production') {
var owner = ReactCurrentOwner.current;
if (owner !== null) {
"development" !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
owner._warnedAboutRefsInRender = true;
}
}
var internalInstance = ReactInstanceMap.get(publicInstance);
if (internalInstance) {
// During componentWillMount and render this will still be null but after
// that will always render to something. At least for now. So we can use
// this hack.
return !!internalInstance._renderedComponent;
} else {
return false;
}
},
2015-09-02 15:08:58 -04:00
/**
* Enqueue a callback that will be executed after all the pending updates
* have processed.
*
* @param {ReactClass} publicInstance The instance to use as `this` context.
* @param {?function} callback Called after state is updated.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueCallback: function (publicInstance, callback) {
!(typeof callback === 'function') ? "development" !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
// Previously we would throw an error if we didn't have an internal
// instance. Since we want to make it a no-op instead, we mirror the same
// behavior we have in other enqueue* methods.
// We also need to ignore callbacks in componentWillMount. See
// enqueueUpdates.
2015-10-14 22:58:32 -04:00
if (!internalInstance) {
2015-09-02 15:08:58 -04:00
return null;
}
if (internalInstance._pendingCallbacks) {
internalInstance._pendingCallbacks.push(callback);
} else {
internalInstance._pendingCallbacks = [callback];
}
// TODO: The callback here is ignored when setState is called from
// componentWillMount. Either fix it or disallow doing so completely in
// favor of getInitialState. Alternatively, we can disallow
// componentWillMount during server-side rendering.
enqueueUpdate(internalInstance);
},
2015-10-14 22:58:32 -04:00
enqueueCallbackInternal: function (internalInstance, callback) {
!(typeof callback === 'function') ? "development" !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
if (internalInstance._pendingCallbacks) {
internalInstance._pendingCallbacks.push(callback);
} else {
internalInstance._pendingCallbacks = [callback];
}
enqueueUpdate(internalInstance);
},
/**
* 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.
*
2015-10-14 22:58:32 -04:00
* This will not invoke `shouldComponentUpdate`, but it will invoke
2015-09-02 15:08:58 -04:00
* `componentWillUpdate` and `componentDidUpdate`.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueForceUpdate: function (publicInstance) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate');
2015-09-02 15:08:58 -04:00
if (!internalInstance) {
return;
}
internalInstance._pendingForceUpdate = true;
enqueueUpdate(internalInstance);
},
/**
* 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 {ReactClass} publicInstance The instance that should rerender.
* @param {object} completeState Next state.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueReplaceState: function (publicInstance, completeState) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');
2015-09-02 15:08:58 -04:00
if (!internalInstance) {
return;
}
internalInstance._pendingStateQueue = [completeState];
internalInstance._pendingReplaceState = true;
enqueueUpdate(internalInstance);
},
/**
* Sets a subset of the state. This only exists because _pendingState is
* internal. This provides a merging strategy that is not available to deep
* properties which is confusing. TODO: Expose pendingState or don't use it
* during the merge.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} partialState Next partial state to be merged with state.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueSetState: function (publicInstance, partialState) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
2015-09-02 15:08:58 -04:00
if (!internalInstance) {
return;
}
2015-10-14 22:58:32 -04:00
var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []);
2015-09-02 15:08:58 -04:00
queue.push(partialState);
enqueueUpdate(internalInstance);
},
/**
* Sets a subset of the props.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} partialProps Subset of the next props.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueSetProps: function (publicInstance, partialProps) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
2015-09-02 15:08:58 -04:00
if (!internalInstance) {
return;
}
2015-10-14 22:58:32 -04:00
ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
enqueueSetPropsInternal: function (internalInstance, partialProps) {
var topLevelWrapper = internalInstance._topLevelWrapper;
!topLevelWrapper ? "development" !== 'production' ? invariant(false, 'setProps(...): You called `setProps` 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(false) : undefined;
2015-09-02 15:08:58 -04:00
// Merge with the pending element if it exists, otherwise with existing
// element props.
2015-10-14 22:58:32 -04:00
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
var element = wrapElement.props;
2015-09-02 15:08:58 -04:00
var props = assign({}, element.props, partialProps);
2015-10-14 22:58:32 -04:00
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
enqueueUpdate(topLevelWrapper);
2015-09-02 15:08:58 -04:00
},
/**
* Replaces all of the props.
*
* @param {ReactClass} publicInstance The instance that should rerender.
* @param {object} props New props.
* @internal
*/
2015-10-14 22:58:32 -04:00
enqueueReplaceProps: function (publicInstance, props) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
2015-09-02 15:08:58 -04:00
if (!internalInstance) {
return;
}
2015-10-14 22:58:32 -04:00
ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
},
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
enqueueReplacePropsInternal: function (internalInstance, props) {
var topLevelWrapper = internalInstance._topLevelWrapper;
!topLevelWrapper ? "development" !== 'production' ? invariant(false, 'replaceProps(...): You called `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(false) : undefined;
2015-09-02 15:08:58 -04:00
// Merge with the pending element if it exists, otherwise with existing
// element props.
2015-10-14 22:58:32 -04:00
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
var element = wrapElement.props;
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
enqueueUpdate(topLevelWrapper);
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
enqueueElementInternal: function (internalInstance, newElement) {
2015-09-02 15:08:58 -04:00
internalInstance._pendingElement = newElement;
enqueueUpdate(internalInstance);
}
};
module.exports = ReactUpdateQueue;
2015-10-14 22:58:32 -04:00
},{"160":160,"172":172,"24":24,"39":39,"57":57,"68":68,"96":96}],96:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var CallbackQueue = _dereq_(6);
var PooledClass = _dereq_(25);
var ReactPerf = _dereq_(78);
var ReactReconciler = _dereq_(84);
var Transaction = _dereq_(113);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
var dirtyComponents = [];
var asapCallbackQueue = CallbackQueue.getPooled();
var asapEnqueued = false;
var batchingStrategy = null;
function ensureInjected() {
2015-10-14 22:58:32 -04:00
!(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? "development" !== 'production' ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
var NESTED_UPDATES = {
2015-10-14 22:58:32 -04:00
initialize: function () {
2015-09-02 15:08:58 -04:00
this.dirtyComponentsLength = dirtyComponents.length;
},
2015-10-14 22:58:32 -04:00
close: function () {
2015-09-02 15:08:58 -04:00
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 = {
2015-10-14 22:58:32 -04:00
initialize: function () {
2015-09-02 15:08:58 -04:00
this.callbackQueue.reset();
},
2015-10-14 22:58:32 -04:00
close: function () {
2015-09-02 15:08:58 -04:00
this.callbackQueue.notifyAll();
}
};
var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
function ReactUpdatesFlushTransaction() {
this.reinitializeTransaction();
this.dirtyComponentsLength = null;
this.callbackQueue = CallbackQueue.getPooled();
2015-10-14 22:58:32 -04:00
this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled( /* forceHTML */false);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
getTransactionWrappers: function () {
2015-09-02 15:08:58 -04:00
return TRANSACTION_WRAPPERS;
},
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
this.dirtyComponentsLength = null;
CallbackQueue.release(this.callbackQueue);
this.callbackQueue = null;
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
this.reconcileTransaction = null;
},
2015-10-14 22:58:32 -04:00
perform: function (method, scope, a) {
2015-09-02 15:08:58 -04:00
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
// with this transaction's wrappers around it.
2015-10-14 22:58:32 -04:00
return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
2015-09-02 15:08:58 -04:00
}
});
PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
2015-10-14 22:58:32 -04:00
function batchedUpdates(callback, a, b, c, d, e) {
2015-09-02 15:08:58 -04:00
ensureInjected();
2015-10-14 22:58:32 -04:00
batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
2015-09-02 15:08:58 -04:00
}
/**
* Array comparator for ReactComponents by mount ordering.
*
* @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 mountOrderComparator(c1, c2) {
return c1._mountOrder - c2._mountOrder;
}
function runBatchedUpdates(transaction) {
var len = transaction.dirtyComponentsLength;
2015-10-14 22:58:32 -04:00
!(len === dirtyComponents.length) ? "development" !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
// 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(mountOrderComparator);
for (var i = 0; i < len; i++) {
// If a component is unmounted before pending changes apply, it will still
// be here, but we assume that it has cleared its _pendingCallbacks and
// that performUpdateIfNecessary is a noop.
var component = dirtyComponents[i];
// 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;
2015-10-14 22:58:32 -04:00
ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction);
2015-09-02 15:08:58 -04:00
if (callbacks) {
for (var j = 0; j < callbacks.length; j++) {
2015-10-14 22:58:32 -04:00
transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
2015-09-02 15:08:58 -04:00
}
}
}
}
2015-10-14 22:58:32 -04:00
var flushBatchedUpdates = function () {
2015-09-02 15:08:58 -04:00
// 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);
}
}
};
2015-10-14 22:58:32 -04:00
flushBatchedUpdates = ReactPerf.measure('ReactUpdates', 'flushBatchedUpdates', flushBatchedUpdates);
2015-09-02 15:08:58 -04:00
/**
* 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) {
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.)
if (!batchingStrategy.isBatchingUpdates) {
batchingStrategy.batchedUpdates(enqueueUpdate, component);
return;
}
dirtyComponents.push(component);
}
/**
* 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) {
2015-10-14 22:58:32 -04:00
!batchingStrategy.isBatchingUpdates ? "development" !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' + 'updates are not being batched.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
asapCallbackQueue.enqueue(callback, context);
asapEnqueued = true;
}
var ReactUpdatesInjection = {
2015-10-14 22:58:32 -04:00
injectReconcileTransaction: function (ReconcileTransaction) {
!ReconcileTransaction ? "development" !== 'production' ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
},
2015-10-14 22:58:32 -04:00
injectBatchingStrategy: function (_batchingStrategy) {
!_batchingStrategy ? "development" !== 'production' ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined;
!(typeof _batchingStrategy.batchedUpdates === 'function') ? "development" !== 'production' ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined;
!(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? "development" !== 'production' ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"113":113,"160":160,"24":24,"25":25,"6":6,"78":78,"84":84}],97:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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 ReactVersion
*/
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
'use strict';
module.exports = '0.14.0';
},{}],98:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
2015-10-14 22:58:32 -04:00
var DOMProperty = _dereq_(10);
2015-09-02 15:08:58 -04:00
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
2015-10-14 22:58:32 -04:00
var NS = {
xlink: 'http://www.w3.org/1999/xlink',
xml: 'http://www.w3.org/XML/1998/namespace'
};
2015-09-02 15:08:58 -04:00
var SVGDOMPropertyConfig = {
Properties: {
clipPath: MUST_USE_ATTRIBUTE,
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,
2015-10-14 22:58:32 -04:00
xlinkActuate: MUST_USE_ATTRIBUTE,
xlinkArcrole: MUST_USE_ATTRIBUTE,
xlinkHref: MUST_USE_ATTRIBUTE,
xlinkRole: MUST_USE_ATTRIBUTE,
xlinkShow: MUST_USE_ATTRIBUTE,
xlinkTitle: MUST_USE_ATTRIBUTE,
xlinkType: MUST_USE_ATTRIBUTE,
xmlBase: MUST_USE_ATTRIBUTE,
xmlLang: MUST_USE_ATTRIBUTE,
xmlSpace: MUST_USE_ATTRIBUTE,
2015-09-02 15:08:58 -04:00
y1: MUST_USE_ATTRIBUTE,
y2: MUST_USE_ATTRIBUTE,
y: MUST_USE_ATTRIBUTE
},
2015-10-14 22:58:32 -04:00
DOMAttributeNamespaces: {
xlinkActuate: NS.xlink,
xlinkArcrole: NS.xlink,
xlinkHref: NS.xlink,
xlinkRole: NS.xlink,
xlinkShow: NS.xlink,
xlinkTitle: NS.xlink,
xlinkType: NS.xlink,
xmlBase: NS.xml,
xmlLang: NS.xml,
xmlSpace: NS.xml
},
2015-09-02 15:08:58 -04:00
DOMAttributeNames: {
clipPath: 'clip-path',
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',
2015-10-14 22:58:32 -04:00
viewBox: 'viewBox',
xlinkActuate: 'xlink:actuate',
xlinkArcrole: 'xlink:arcrole',
xlinkHref: 'xlink:href',
xlinkRole: 'xlink:role',
xlinkShow: 'xlink:show',
xlinkTitle: 'xlink:title',
xlinkType: 'xlink:type',
xmlBase: 'xml:base',
xmlLang: 'xml:lang',
xmlSpace: 'xml:space'
2015-09-02 15:08:58 -04:00
}
};
module.exports = SVGDOMPropertyConfig;
2015-10-14 22:58:32 -04:00
},{"10":10}],99:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventPropagators = _dereq_(19);
var ExecutionEnvironment = _dereq_(146);
var ReactInputSelection = _dereq_(66);
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getActiveElement = _dereq_(155);
var isTextInputElement = _dereq_(133);
var keyOf = _dereq_(165);
var shallowEqual = _dereq_(170);
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
2015-10-14 22:58:32 -04:00
var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
2015-09-02 15:08:58 -04:00
var eventTypes = {
select: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onSelect: null }),
captured: keyOf({ onSelectCapture: null })
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
dependencies: [topLevelTypes.topBlur, topLevelTypes.topContextMenu, topLevelTypes.topFocus, topLevelTypes.topKeyDown, topLevelTypes.topMouseDown, topLevelTypes.topMouseUp, topLevelTypes.topSelectionChange]
2015-09-02 15:08:58 -04:00
}
};
var activeElement = null;
var activeElementID = null;
var lastSelection = null;
var mouseDown = false;
2015-10-14 22:58:32 -04:00
// Track whether a listener exists for this plugin. If none exist, we do
// not extract events.
var hasListener = false;
var ON_SELECT_KEY = keyOf({ onSelect: null });
2015-09-02 15:08:58 -04:00
/**
* 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
2015-10-14 22:58:32 -04:00
* @return {object}
2015-09-02 15:08:58 -04:00
*/
function getSelection(node) {
2015-10-14 22:58:32 -04:00
if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) {
2015-09-02 15:08:58 -04:00
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}
*/
2015-10-14 22:58:32 -04:00
function constructSelectEvent(nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
if (mouseDown || activeElement == null || activeElement !== getActiveElement()) {
2015-09-02 15:08:58 -04:00
return null;
}
// Only fire when selection has actually changed.
var currentSelection = getSelection(activeElement);
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
lastSelection = currentSelection;
2015-10-14 22:58:32 -04:00
var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
syntheticEvent.type = 'select';
syntheticEvent.target = activeElement;
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
return syntheticEvent;
}
2015-10-14 22:58:32 -04:00
return null;
2015-09-02 15:08:58 -04:00
}
/**
* 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}
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
if (!hasListener) {
return null;
}
2015-09-02 15:08:58 -04:00
switch (topLevelType) {
// Track the input node that has focus.
case topLevelTypes.topFocus:
2015-10-14 22:58:32 -04:00
if (isTextInputElement(topLevelTarget) || topLevelTarget.contentEditable === 'true') {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
return constructSelectEvent(nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
// Chrome and IE fire non-standard event when selection is changed (and
2015-10-14 22:58:32 -04:00
// sometimes when it hasn't). IE's event fires out of order with respect
// to key and input events on deletion, so we discard it.
//
2015-09-02 15:08:58 -04:00
// 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.
2015-10-14 22:58:32 -04:00
// This is also our approach for IE handling, for the reason above.
2015-09-02 15:08:58 -04:00
case topLevelTypes.topSelectionChange:
2015-10-14 22:58:32 -04:00
if (skipSelectionChangeEvent) {
break;
}
// falls through
2015-09-02 15:08:58 -04:00
case topLevelTypes.topKeyDown:
case topLevelTypes.topKeyUp:
2015-10-14 22:58:32 -04:00
return constructSelectEvent(nativeEvent, nativeEventTarget);
}
return null;
},
didPutListener: function (id, registrationName, listener) {
if (registrationName === ON_SELECT_KEY) {
hasListener = true;
2015-09-02 15:08:58 -04:00
}
}
};
module.exports = SelectEventPlugin;
2015-10-14 22:58:32 -04:00
},{"105":105,"133":133,"146":146,"15":15,"155":155,"165":165,"170":170,"19":19,"66":66}],100:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 = {
2015-10-14 22:58:32 -04:00
createReactRootIndex: function () {
2015-09-02 15:08:58 -04:00
return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
}
};
module.exports = ServerReactRootIndex;
2015-10-14 22:58:32 -04:00
},{}],101:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var EventConstants = _dereq_(15);
var EventListener = _dereq_(145);
var EventPropagators = _dereq_(19);
var ReactMount = _dereq_(72);
var SyntheticClipboardEvent = _dereq_(102);
var SyntheticEvent = _dereq_(105);
var SyntheticFocusEvent = _dereq_(106);
var SyntheticKeyboardEvent = _dereq_(108);
var SyntheticMouseEvent = _dereq_(109);
var SyntheticDragEvent = _dereq_(104);
var SyntheticTouchEvent = _dereq_(110);
var SyntheticUIEvent = _dereq_(111);
var SyntheticWheelEvent = _dereq_(112);
var emptyFunction = _dereq_(152);
var getEventCharCode = _dereq_(124);
var invariant = _dereq_(160);
var keyOf = _dereq_(165);
2015-09-02 15:08:58 -04:00
var topLevelTypes = EventConstants.topLevelTypes;
var eventTypes = {
2015-10-14 22:58:32 -04:00
abort: {
phasedRegistrationNames: {
bubbled: keyOf({ onAbort: true }),
captured: keyOf({ onAbortCapture: true })
}
},
2015-09-02 15:08:58 -04:00
blur: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onBlur: true }),
captured: keyOf({ onBlurCapture: true })
}
},
canPlay: {
phasedRegistrationNames: {
bubbled: keyOf({ onCanPlay: true }),
captured: keyOf({ onCanPlayCapture: true })
}
},
canPlayThrough: {
phasedRegistrationNames: {
bubbled: keyOf({ onCanPlayThrough: true }),
captured: keyOf({ onCanPlayThroughCapture: true })
2015-09-02 15:08:58 -04:00
}
},
click: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onClick: true }),
captured: keyOf({ onClickCapture: true })
2015-09-02 15:08:58 -04:00
}
},
contextMenu: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onContextMenu: true }),
captured: keyOf({ onContextMenuCapture: true })
2015-09-02 15:08:58 -04:00
}
},
copy: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onCopy: true }),
captured: keyOf({ onCopyCapture: true })
2015-09-02 15:08:58 -04:00
}
},
cut: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onCut: true }),
captured: keyOf({ onCutCapture: true })
2015-09-02 15:08:58 -04:00
}
},
doubleClick: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDoubleClick: true }),
captured: keyOf({ onDoubleClickCapture: true })
2015-09-02 15:08:58 -04:00
}
},
drag: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDrag: true }),
captured: keyOf({ onDragCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragEnd: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragEnd: true }),
captured: keyOf({ onDragEndCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragEnter: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragEnter: true }),
captured: keyOf({ onDragEnterCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragExit: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragExit: true }),
captured: keyOf({ onDragExitCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragLeave: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragLeave: true }),
captured: keyOf({ onDragLeaveCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragOver: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragOver: true }),
captured: keyOf({ onDragOverCapture: true })
2015-09-02 15:08:58 -04:00
}
},
dragStart: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDragStart: true }),
captured: keyOf({ onDragStartCapture: true })
2015-09-02 15:08:58 -04:00
}
},
drop: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onDrop: true }),
captured: keyOf({ onDropCapture: true })
}
},
durationChange: {
phasedRegistrationNames: {
bubbled: keyOf({ onDurationChange: true }),
captured: keyOf({ onDurationChangeCapture: true })
}
},
emptied: {
phasedRegistrationNames: {
bubbled: keyOf({ onEmptied: true }),
captured: keyOf({ onEmptiedCapture: true })
}
},
encrypted: {
phasedRegistrationNames: {
bubbled: keyOf({ onEncrypted: true }),
captured: keyOf({ onEncryptedCapture: true })
}
},
ended: {
phasedRegistrationNames: {
bubbled: keyOf({ onEnded: true }),
captured: keyOf({ onEndedCapture: true })
}
},
error: {
phasedRegistrationNames: {
bubbled: keyOf({ onError: true }),
captured: keyOf({ onErrorCapture: true })
2015-09-02 15:08:58 -04:00
}
},
focus: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onFocus: true }),
captured: keyOf({ onFocusCapture: true })
2015-09-02 15:08:58 -04:00
}
},
input: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onInput: true }),
captured: keyOf({ onInputCapture: true })
2015-09-02 15:08:58 -04:00
}
},
keyDown: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onKeyDown: true }),
captured: keyOf({ onKeyDownCapture: true })
2015-09-02 15:08:58 -04:00
}
},
keyPress: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onKeyPress: true }),
captured: keyOf({ onKeyPressCapture: true })
2015-09-02 15:08:58 -04:00
}
},
keyUp: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onKeyUp: true }),
captured: keyOf({ onKeyUpCapture: true })
2015-09-02 15:08:58 -04:00
}
},
load: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onLoad: true }),
captured: keyOf({ onLoadCapture: true })
2015-09-02 15:08:58 -04:00
}
},
2015-10-14 22:58:32 -04:00
loadedData: {
phasedRegistrationNames: {
bubbled: keyOf({ onLoadedData: true }),
captured: keyOf({ onLoadedDataCapture: true })
}
},
loadedMetadata: {
2015-09-02 15:08:58 -04:00
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onLoadedMetadata: true }),
captured: keyOf({ onLoadedMetadataCapture: true })
}
},
loadStart: {
phasedRegistrationNames: {
bubbled: keyOf({ onLoadStart: true }),
captured: keyOf({ onLoadStartCapture: true })
2015-09-02 15:08:58 -04:00
}
},
// Note: We do not allow listening to mouseOver events. Instead, use the
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
mouseDown: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onMouseDown: true }),
captured: keyOf({ onMouseDownCapture: true })
2015-09-02 15:08:58 -04:00
}
},
mouseMove: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onMouseMove: true }),
captured: keyOf({ onMouseMoveCapture: true })
2015-09-02 15:08:58 -04:00
}
},
mouseOut: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onMouseOut: true }),
captured: keyOf({ onMouseOutCapture: true })
2015-09-02 15:08:58 -04:00
}
},
mouseOver: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onMouseOver: true }),
captured: keyOf({ onMouseOverCapture: true })
2015-09-02 15:08:58 -04:00
}
},
mouseUp: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onMouseUp: true }),
captured: keyOf({ onMouseUpCapture: true })
2015-09-02 15:08:58 -04:00
}
},
paste: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onPaste: true }),
captured: keyOf({ onPasteCapture: true })
}
},
pause: {
phasedRegistrationNames: {
bubbled: keyOf({ onPause: true }),
captured: keyOf({ onPauseCapture: true })
}
},
play: {
phasedRegistrationNames: {
bubbled: keyOf({ onPlay: true }),
captured: keyOf({ onPlayCapture: true })
}
},
playing: {
phasedRegistrationNames: {
bubbled: keyOf({ onPlaying: true }),
captured: keyOf({ onPlayingCapture: true })
}
},
progress: {
phasedRegistrationNames: {
bubbled: keyOf({ onProgress: true }),
captured: keyOf({ onProgressCapture: true })
}
},
rateChange: {
phasedRegistrationNames: {
bubbled: keyOf({ onRateChange: true }),
captured: keyOf({ onRateChangeCapture: true })
2015-09-02 15:08:58 -04:00
}
},
reset: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onReset: true }),
captured: keyOf({ onResetCapture: true })
2015-09-02 15:08:58 -04:00
}
},
scroll: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onScroll: true }),
captured: keyOf({ onScrollCapture: true })
}
},
seeked: {
phasedRegistrationNames: {
bubbled: keyOf({ onSeeked: true }),
captured: keyOf({ onSeekedCapture: true })
}
},
seeking: {
phasedRegistrationNames: {
bubbled: keyOf({ onSeeking: true }),
captured: keyOf({ onSeekingCapture: true })
}
},
stalled: {
phasedRegistrationNames: {
bubbled: keyOf({ onStalled: true }),
captured: keyOf({ onStalledCapture: true })
2015-09-02 15:08:58 -04:00
}
},
submit: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onSubmit: true }),
captured: keyOf({ onSubmitCapture: true })
}
},
suspend: {
phasedRegistrationNames: {
bubbled: keyOf({ onSuspend: true }),
captured: keyOf({ onSuspendCapture: true })
}
},
timeUpdate: {
phasedRegistrationNames: {
bubbled: keyOf({ onTimeUpdate: true }),
captured: keyOf({ onTimeUpdateCapture: true })
2015-09-02 15:08:58 -04:00
}
},
touchCancel: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onTouchCancel: true }),
captured: keyOf({ onTouchCancelCapture: true })
2015-09-02 15:08:58 -04:00
}
},
touchEnd: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onTouchEnd: true }),
captured: keyOf({ onTouchEndCapture: true })
2015-09-02 15:08:58 -04:00
}
},
touchMove: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onTouchMove: true }),
captured: keyOf({ onTouchMoveCapture: true })
2015-09-02 15:08:58 -04:00
}
},
touchStart: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onTouchStart: true }),
captured: keyOf({ onTouchStartCapture: true })
}
},
volumeChange: {
phasedRegistrationNames: {
bubbled: keyOf({ onVolumeChange: true }),
captured: keyOf({ onVolumeChangeCapture: true })
}
},
waiting: {
phasedRegistrationNames: {
bubbled: keyOf({ onWaiting: true }),
captured: keyOf({ onWaitingCapture: true })
2015-09-02 15:08:58 -04:00
}
},
wheel: {
phasedRegistrationNames: {
2015-10-14 22:58:32 -04:00
bubbled: keyOf({ onWheel: true }),
captured: keyOf({ onWheelCapture: true })
2015-09-02 15:08:58 -04:00
}
}
};
var topLevelEventsToDispatchConfig = {
2015-10-14 22:58:32 -04:00
topAbort: eventTypes.abort,
topBlur: eventTypes.blur,
topCanPlay: eventTypes.canPlay,
topCanPlayThrough: eventTypes.canPlayThrough,
topClick: eventTypes.click,
2015-09-02 15:08:58 -04:00
topContextMenu: eventTypes.contextMenu,
2015-10-14 22:58:32 -04:00
topCopy: eventTypes.copy,
topCut: eventTypes.cut,
2015-09-02 15:08:58 -04:00
topDoubleClick: eventTypes.doubleClick,
2015-10-14 22:58:32 -04:00
topDrag: eventTypes.drag,
topDragEnd: eventTypes.dragEnd,
topDragEnter: eventTypes.dragEnter,
topDragExit: eventTypes.dragExit,
topDragLeave: eventTypes.dragLeave,
topDragOver: eventTypes.dragOver,
topDragStart: eventTypes.dragStart,
topDrop: eventTypes.drop,
topDurationChange: eventTypes.durationChange,
topEmptied: eventTypes.emptied,
topEncrypted: eventTypes.encrypted,
topEnded: eventTypes.ended,
topError: eventTypes.error,
topFocus: eventTypes.focus,
topInput: eventTypes.input,
topKeyDown: eventTypes.keyDown,
topKeyPress: eventTypes.keyPress,
topKeyUp: eventTypes.keyUp,
topLoad: eventTypes.load,
topLoadedData: eventTypes.loadedData,
topLoadedMetadata: eventTypes.loadedMetadata,
topLoadStart: eventTypes.loadStart,
topMouseDown: eventTypes.mouseDown,
topMouseMove: eventTypes.mouseMove,
topMouseOut: eventTypes.mouseOut,
topMouseOver: eventTypes.mouseOver,
topMouseUp: eventTypes.mouseUp,
topPaste: eventTypes.paste,
topPause: eventTypes.pause,
topPlay: eventTypes.play,
topPlaying: eventTypes.playing,
topProgress: eventTypes.progress,
topRateChange: eventTypes.rateChange,
topReset: eventTypes.reset,
topScroll: eventTypes.scroll,
topSeeked: eventTypes.seeked,
topSeeking: eventTypes.seeking,
topStalled: eventTypes.stalled,
topSubmit: eventTypes.submit,
topSuspend: eventTypes.suspend,
topTimeUpdate: eventTypes.timeUpdate,
2015-09-02 15:08:58 -04:00
topTouchCancel: eventTypes.touchCancel,
2015-10-14 22:58:32 -04:00
topTouchEnd: eventTypes.touchEnd,
topTouchMove: eventTypes.touchMove,
topTouchStart: eventTypes.touchStart,
topVolumeChange: eventTypes.volumeChange,
topWaiting: eventTypes.waiting,
topWheel: eventTypes.wheel
2015-09-02 15:08:58 -04:00
};
for (var type in topLevelEventsToDispatchConfig) {
topLevelEventsToDispatchConfig[type].dependencies = [type];
}
2015-10-14 22:58:32 -04:00
var ON_CLICK_KEY = keyOf({ onClick: null });
var onClickListeners = {};
2015-09-02 15:08:58 -04:00
var SimpleEventPlugin = {
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}
*/
2015-10-14 22:58:32 -04:00
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
if (!dispatchConfig) {
return null;
}
var EventConstructor;
switch (topLevelType) {
2015-10-14 22:58:32 -04:00
case topLevelTypes.topAbort:
case topLevelTypes.topCanPlay:
case topLevelTypes.topCanPlayThrough:
case topLevelTypes.topDurationChange:
case topLevelTypes.topEmptied:
case topLevelTypes.topEncrypted:
case topLevelTypes.topEnded:
case topLevelTypes.topError:
2015-09-02 15:08:58 -04:00
case topLevelTypes.topInput:
case topLevelTypes.topLoad:
2015-10-14 22:58:32 -04:00
case topLevelTypes.topLoadedData:
case topLevelTypes.topLoadedMetadata:
case topLevelTypes.topLoadStart:
case topLevelTypes.topPause:
case topLevelTypes.topPlay:
case topLevelTypes.topPlaying:
case topLevelTypes.topProgress:
case topLevelTypes.topRateChange:
2015-09-02 15:08:58 -04:00
case topLevelTypes.topReset:
2015-10-14 22:58:32 -04:00
case topLevelTypes.topSeeked:
case topLevelTypes.topSeeking:
case topLevelTypes.topStalled:
2015-09-02 15:08:58 -04:00
case topLevelTypes.topSubmit:
2015-10-14 22:58:32 -04:00
case topLevelTypes.topSuspend:
case topLevelTypes.topTimeUpdate:
case topLevelTypes.topVolumeChange:
case topLevelTypes.topWaiting:
2015-09-02 15:08:58 -04:00
// 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;
}
2015-10-14 22:58:32 -04:00
/* falls through */
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
/* falls through */
2015-09-02 15:08:58 -04:00
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;
}
2015-10-14 22:58:32 -04:00
!EventConstructor ? "development" !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) : undefined;
var event = EventConstructor.getPooled(dispatchConfig, topLevelTargetID, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
2015-10-14 22:58:32 -04:00
},
didPutListener: function (id, registrationName, listener) {
// 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.
if (registrationName === ON_CLICK_KEY) {
var node = ReactMount.getNode(id);
if (!onClickListeners[id]) {
onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
}
}
},
willDeleteListener: function (id, registrationName) {
if (registrationName === ON_CLICK_KEY) {
onClickListeners[id].remove();
delete onClickListeners[id];
}
2015-09-02 15:08:58 -04:00
}
};
module.exports = SimpleEventPlugin;
2015-10-14 22:58:32 -04:00
},{"102":102,"104":104,"105":105,"106":106,"108":108,"109":109,"110":110,"111":111,"112":112,"124":124,"145":145,"15":15,"152":152,"160":160,"165":165,"19":19,"72":72}],102:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
/**
* @interface Event
* @see http://www.w3.org/TR/clipboard-apis/
*/
var ClipboardEventInterface = {
2015-10-14 22:58:32 -04:00
clipboardData: function (event) {
return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
2015-09-02 15:08:58 -04:00
}
};
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
module.exports = SyntheticClipboardEvent;
2015-10-14 22:58:32 -04:00
},{"105":105}],103:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface);
2015-09-02 15:08:58 -04:00
module.exports = SyntheticCompositionEvent;
2015-10-14 22:58:32 -04:00
},{"105":105}],104:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticMouseEvent = _dereq_(109);
2015-09-02 15:08:58 -04:00
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
module.exports = SyntheticDragEvent;
2015-10-14 22:58:32 -04:00
},{"109":109}],105:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var PooledClass = _dereq_(25);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
* @interface Event
* @see http://www.w3.org/TR/DOM-Level-3-Events/
*/
var EventInterface = {
type: null,
// currentTarget is set when dispatching; no use in copying it here
currentTarget: emptyFunction.thatReturnsNull,
eventPhase: null,
bubbles: null,
cancelable: null,
2015-10-14 22:58:32 -04:00
timeStamp: function (event) {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
2015-09-02 15:08:58 -04:00
this.dispatchConfig = dispatchConfig;
this.dispatchMarker = dispatchMarker;
this.nativeEvent = nativeEvent;
2015-10-14 22:58:32 -04:00
this.target = nativeEventTarget;
this.currentTarget = nativeEventTarget;
2015-09-02 15:08:58 -04:00
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];
}
}
2015-10-14 22:58:32 -04:00
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
2015-09-02 15:08:58 -04:00
if (defaultPrevented) {
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
} else {
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
}
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
}
assign(SyntheticEvent.prototype, {
2015-10-14 22:58:32 -04:00
preventDefault: function () {
2015-09-02 15:08:58 -04:00
this.defaultPrevented = true;
var event = this.nativeEvent;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
}
if (!event) {
return;
}
2015-09-02 15:08:58 -04:00
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
},
2015-10-14 22:58:32 -04:00
stopPropagation: function () {
2015-09-02 15:08:58 -04:00
var event = this.nativeEvent;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
}
if (!event) {
return;
}
2015-09-02 15:08:58 -04:00
if (event.stopPropagation) {
event.stopPropagation();
} else {
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.
*/
2015-10-14 22:58:32 -04:00
persist: function () {
2015-09-02 15:08:58 -04:00
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.
*/
2015-10-14 22:58:32 -04:00
destructor: function () {
2015-09-02 15:08:58 -04:00
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
*/
2015-10-14 22:58:32 -04:00
SyntheticEvent.augmentClass = function (Class, Interface) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
2015-09-02 15:08:58 -04:00
module.exports = SyntheticEvent;
2015-10-14 22:58:32 -04:00
},{"152":152,"172":172,"24":24,"25":25}],106:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticUIEvent = _dereq_(111);
2015-09-02 15:08:58 -04:00
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
module.exports = SyntheticFocusEvent;
2015-10-14 22:58:32 -04:00
},{"111":111}],107:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
SyntheticEvent.augmentClass(SyntheticInputEvent, InputEventInterface);
2015-09-02 15:08:58 -04:00
module.exports = SyntheticInputEvent;
2015-10-14 22:58:32 -04:00
},{"105":105}],108:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticUIEvent = _dereq_(111);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getEventCharCode = _dereq_(124);
var getEventKey = _dereq_(125);
var getEventModifierState = _dereq_(126);
2015-09-02 15:08:58 -04:00
/**
* @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
2015-10-14 22:58:32 -04:00
charCode: function (event) {
2015-09-02 15:08:58 -04:00
// `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;
},
2015-10-14 22:58:32 -04:00
keyCode: function (event) {
2015-09-02 15:08:58 -04:00
// `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;
},
2015-10-14 22:58:32 -04:00
which: function (event) {
2015-09-02 15:08:58 -04:00
// `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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
module.exports = SyntheticKeyboardEvent;
2015-10-14 22:58:32 -04:00
},{"111":111,"124":124,"125":125,"126":126}],109:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticUIEvent = _dereq_(111);
var ViewportMetrics = _dereq_(114);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getEventModifierState = _dereq_(126);
2015-09-02 15:08:58 -04:00
/**
* @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,
2015-10-14 22:58:32 -04:00
button: function (event) {
2015-09-02 15:08:58 -04:00
// 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,
2015-10-14 22:58:32 -04:00
relatedTarget: function (event) {
return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
2015-09-02 15:08:58 -04:00
},
// "Proprietary" Interface.
2015-10-14 22:58:32 -04:00
pageX: function (event) {
return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft;
2015-09-02 15:08:58 -04:00
},
2015-10-14 22:58:32 -04:00
pageY: function (event) {
return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop;
2015-09-02 15:08:58 -04:00
}
};
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
module.exports = SyntheticMouseEvent;
2015-10-14 22:58:32 -04:00
},{"111":111,"114":114,"126":126}],110:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticUIEvent = _dereq_(111);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getEventModifierState = _dereq_(126);
2015-09-02 15:08:58 -04:00
/**
* @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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
module.exports = SyntheticTouchEvent;
2015-10-14 22:58:32 -04:00
},{"111":111,"126":126}],111:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticEvent = _dereq_(105);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var getEventTarget = _dereq_(127);
2015-09-02 15:08:58 -04:00
/**
* @interface UIEvent
* @see http://www.w3.org/TR/DOM-Level-3-Events/
*/
var UIEventInterface = {
2015-10-14 22:58:32 -04:00
view: function (event) {
2015-09-02 15:08:58 -04:00
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;
}
},
2015-10-14 22:58:32 -04:00
detail: function (event) {
2015-09-02 15:08:58 -04:00
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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
module.exports = SyntheticUIEvent;
2015-10-14 22:58:32 -04:00
},{"105":105,"127":127}],112:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var SyntheticMouseEvent = _dereq_(109);
2015-09-02 15:08:58 -04:00
/**
* @interface WheelEvent
* @see http://www.w3.org/TR/DOM-Level-3-Events/
*/
var WheelEventInterface = {
2015-10-14 22:58:32 -04:00
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;
2015-09-02 15:08:58 -04:00
},
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}
*/
2015-10-14 22:58:32 -04:00
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
2015-09-02 15:08:58 -04:00
}
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
module.exports = SyntheticWheelEvent;
2015-10-14 22:58:32 -04:00
},{"109":109}],113:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
* `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 updates.
*
* 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".
*/
2015-10-14 22:58:32 -04:00
reinitializeTransaction: function () {
2015-09-02 15:08:58 -04:00
this.transactionWrappers = this.getTransactionWrappers();
2015-10-14 22:58:32 -04:00
if (this.wrapperInitData) {
2015-09-02 15:08:58 -04:00
this.wrapperInitData.length = 0;
2015-10-14 22:58:32 -04:00
} else {
this.wrapperInitData = [];
2015-09-02 15:08:58 -04:00
}
this._isInTransaction = false;
},
_isInTransaction: false,
/**
* @abstract
* @return {Array<TransactionWrapper>} Array of transaction wrappers.
*/
getTransactionWrappers: null,
2015-10-14 22:58:32 -04:00
isInTransaction: function () {
2015-09-02 15:08:58 -04:00
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
2015-10-14 22:58:32 -04:00
* need to be safety checked. The optional arguments helps prevent the need
* to bind in many cases.
2015-09-02 15:08:58 -04:00
*
* @param {function} method Member of scope to call.
* @param {Object} scope Scope to invoke from.
2015-10-14 22:58:32 -04:00
* @param {Object?=} a Argument to pass to the method.
* @param {Object?=} b Argument to pass to the method.
* @param {Object?=} c Argument to pass to the method.
* @param {Object?=} d Argument to pass to the method.
* @param {Object?=} e Argument to pass to the method.
* @param {Object?=} f Argument to pass to the method.
*
* @return {*} Return value from `method`.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
perform: function (method, scope, a, b, c, d, e, f) {
!!this.isInTransaction() ? "development" !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
} catch (err) {}
2015-09-02 15:08:58 -04:00
} else {
// Since `method` didn't throw, we don't want to silence the exception
// here.
this.closeAll(0);
}
} finally {
this._isInTransaction = false;
}
}
return ret;
},
2015-10-14 22:58:32 -04:00
initializeAll: function (startIndex) {
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null;
2015-09-02 15:08:58 -04:00
} 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);
2015-10-14 22:58:32 -04:00
} catch (err) {}
2015-09-02 15:08:58 -04:00
}
}
}
},
/**
* 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).
*/
2015-10-14 22:58:32 -04:00
closeAll: function (startIndex) {
!this.isInTransaction() ? "development" !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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);
2015-10-14 22:58:32 -04:00
} catch (e) {}
2015-09-02 15:08:58 -04:00
}
}
}
this.wrapperInitData.length = 0;
}
};
var Transaction = {
Mixin: Mixin,
/**
2015-10-14 22:58:32 -04:00
* Token to look for to determine if an error occurred.
2015-09-02 15:08:58 -04:00
*/
OBSERVED_ERROR: {}
};
module.exports = Transaction;
2015-10-14 22:58:32 -04:00
},{"160":160}],114:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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 ViewportMetrics = {
currentScrollLeft: 0,
currentScrollTop: 0,
2015-10-14 22:58:32 -04:00
refreshScrollValues: function (scrollPosition) {
2015-09-02 15:08:58 -04:00
ViewportMetrics.currentScrollLeft = scrollPosition.x;
ViewportMetrics.currentScrollTop = scrollPosition.y;
}
};
module.exports = ViewportMetrics;
2015-10-14 22:58:32 -04:00
},{}],115:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
*
* 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) {
2015-10-14 22:58:32 -04:00
!(next != null) ? "development" !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
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;
2015-10-14 22:58:32 -04:00
},{"160":160}],116:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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
*/
'use strict';
var MOD = 65521;
2015-10-14 22:58:32 -04:00
// adler32 is not cryptographically strong, and is only used to sanity check that
// markup generated on the server matches the markup generated on the client.
// This implementation (a modified version of the SheetJS version) has been optimized
// for our use case, at the expense of conforming to the adler32 specification
// for non-ascii inputs.
2015-09-02 15:08:58 -04:00
function adler32(data) {
var a = 1;
var b = 0;
2015-10-14 22:58:32 -04:00
var i = 0;
var l = data.length;
var m = l & ~0x3;
while (i < m) {
for (; i < Math.min(i + 4096, m); i += 4) {
b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3));
}
a %= MOD;
b %= MOD;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
for (; i < l; i++) {
b += a += data.charCodeAt(i);
}
a %= MOD;
b %= MOD;
return a | b << 16;
2015-09-02 15:08:58 -04:00
}
module.exports = adler32;
2015-10-14 22:58:32 -04:00
},{}],117:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @typechecks static-only
* @providesModule cloneWithProps
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var ReactPropTransferer = _dereq_(79);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var keyOf = _dereq_(165);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var CHILDREN_PROP = keyOf({ children: null });
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var didDeprecatedWarn = false;
2015-09-02 15:08:58 -04:00
/**
* Sometimes you want to change the props of a child passed to you. Usually
* this is to add a CSS class.
*
* @param {ReactElement} child child element you'd like to clone
* @param {object} props props you'd like to modify. className and style will be
* merged automatically.
* @return {ReactElement} a clone of child with props merged in.
2015-10-14 22:58:32 -04:00
* @deprecated
2015-09-02 15:08:58 -04:00
*/
function cloneWithProps(child, props) {
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
"development" !== 'production' ? warning(didDeprecatedWarn, 'cloneWithProps(...) is deprecated. ' + 'Please use React.cloneElement instead.') : undefined;
didDeprecatedWarn = true;
"development" !== 'production' ? 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.') : undefined;
2015-09-02 15:08:58 -04:00
}
var newProps = ReactPropTransferer.mergeProps(props, child.props);
// Use `child.props.children` if it is provided.
2015-10-14 22:58:32 -04:00
if (!newProps.hasOwnProperty(CHILDREN_PROP) && child.props.hasOwnProperty(CHILDREN_PROP)) {
2015-09-02 15:08:58 -04:00
newProps.children = child.props.children;
}
2015-10-14 22:58:32 -04:00
// The current API doesn't retain _owner, which is why this
2015-09-02 15:08:58 -04:00
// doesn't use ReactElement.cloneAndReplaceProps.
return ReactElement.createElement(child.type, newProps);
}
module.exports = cloneWithProps;
2015-10-14 22:58:32 -04:00
},{"165":165,"172":172,"57":57,"79":79}],118:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule dangerousStyleValue
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var CSSProperty = _dereq_(4);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var isUnitlessNumber = CSSProperty.isUnitlessNumber;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Convert a value into the proper css writable value. The style name `name`
* should be logical (no hyphens), as specified
* in `CSSProperty.isUnitlessNumber`.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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 '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var isNonNumeric = isNaN(value);
if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
return '' + value; // cast to string
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (typeof value === 'string') {
value = value.trim();
}
return value + 'px';
}
module.exports = dangerousStyleValue;
},{"4":4}],119:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule deprecated
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var assign = _dereq_(24);
var warning = _dereq_(172);
/**
* This will log a single deprecation notice per function and forward the call
* on to the new API.
*
* @param {string} fnName The name of the function
* @param {string} newModule The module that fn will exist in
* @param {string} newPackage The module that fn will exist in
* @param {*} ctx The context this forwarded call should run in
* @param {function} fn The function to forward on to
* @return {function} The function that will warn once and then call fn
*/
function deprecated(fnName, newModule, newPackage, ctx, fn) {
var warned = false;
if ("development" !== 'production') {
var newFn = function () {
"development" !== 'production' ? warning(warned,
// Require examples in this string must be split to prevent React's
// build tools from mistaking them for real requires.
// Otherwise the build tools will attempt to build a '%s' module.
'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : undefined;
warned = true;
return fn.apply(ctx, arguments);
};
// 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;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = deprecated;
},{"172":172,"24":24}],120:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @providesModule escapeTextContentForBrowser
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var ESCAPE_LOOKUP = {
'&': '&amp;',
'>': '&gt;',
'<': '&lt;',
'"': '&quot;',
'\'': '&#x27;'
};
var ESCAPE_REGEX = /[&><"']/g;
function escaper(match) {
return ESCAPE_LOOKUP[match];
2015-09-02 15:08:58 -04:00
}
/**
2015-10-14 22:58:32 -04:00
* Escapes text to prevent scripting attacks.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {*} text Text value to escape.
* @return {string} An escaped string.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function escapeTextContentForBrowser(text) {
return ('' + text).replace(ESCAPE_REGEX, escaper);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = escapeTextContentForBrowser;
},{}],121:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule findDOMNode
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactCurrentOwner = _dereq_(39);
var ReactInstanceMap = _dereq_(68);
var ReactMount = _dereq_(72);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Returns the DOM node rendered by this element.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {ReactComponent|DOMElement} componentOrElement
* @return {?DOMElement} The root node of this element.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function findDOMNode(componentOrElement) {
if ("development" !== 'production') {
var owner = ReactCurrentOwner.current;
if (owner !== null) {
"development" !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing getDOMNode or findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
owner._warnedAboutRefsInRender = true;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
}
if (componentOrElement == null) {
return null;
}
if (componentOrElement.nodeType === 1) {
return componentOrElement;
}
if (ReactInstanceMap.has(componentOrElement)) {
return ReactMount.getNodeFromInstance(componentOrElement);
}
!(componentOrElement.render == null || typeof componentOrElement.render !== 'function') ? "development" !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : undefined;
!false ? "development" !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = findDOMNode;
},{"160":160,"172":172,"39":39,"68":68,"72":72}],122:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule flattenChildren
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var traverseAllChildren = _dereq_(141);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* @param {function} traverseContext Context passed through traversal.
* @param {?ReactComponent} child React child component.
* @param {!string} name String name of key path to child.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function flattenSingleChildIntoContext(traverseContext, child, name) {
// We found a component instance.
var result = traverseContext;
var keyUnique = result[name] === undefined;
if ("development" !== 'production') {
"development" !== 'production' ? 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) : undefined;
}
if (keyUnique && child != null) {
result[name] = child;
}
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function flattenChildren(children) {
if (children == null) {
return children;
}
var result = {};
traverseAllChildren(children, flattenSingleChildIntoContext, result);
return result;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = flattenChildren;
},{"141":141,"172":172}],123:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* @param {array} arr 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);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = forEachAccumulated;
},{}],124:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getEventCharCode
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* `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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {object} nativeEvent Native browser event.
* @return {number} Normalized `charCode` property.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getEventCharCode(nativeEvent) {
var charCode;
var keyCode = nativeEvent.keyCode;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ('charCode' in nativeEvent) {
charCode = nativeEvent.charCode;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
// 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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return 0;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = getEventCharCode;
},{}],125:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getEventKey
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var getEventCharCode = _dereq_(124);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* 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'
};
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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'
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* @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.
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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;
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
// 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);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
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 '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = getEventKey;
},{"124":124}],126:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getEventModifierState
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Translation from modifier key to the associated property in the event.
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var modifierKeyToProp = {
'Alt': 'altKey',
'Control': 'ctrlKey',
'Meta': 'metaKey',
'Shift': 'shiftKey'
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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) {
var syntheticEvent = this;
var nativeEvent = syntheticEvent.nativeEvent;
if (nativeEvent.getModifierState) {
return nativeEvent.getModifierState(keyArg);
}
var keyProp = modifierKeyToProp[keyArg];
return keyProp ? !!nativeEvent[keyProp] : false;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function getEventModifierState(nativeEvent) {
return modifierStateGetter;
}
module.exports = getEventModifierState;
},{}],127:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getEventTarget
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* Gets the target node from a native browser event by accounting for
* inconsistencies in browser DOM APIs.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {object} nativeEvent Native browser event.
* @return {DOMEventTarget} Target node.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = getEventTarget;
},{}],128:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getIteratorFn
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
/* global Symbol */
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Returns the iterator method function contained on the iterable object.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* Be sure to invoke the function with the iterable as context:
*
* var iteratorFn = getIteratorFn(myIterable);
* if (iteratorFn) {
* var iterator = iteratorFn.call(myIterable);
* ...
* }
*
* @param {?object} maybeIterable
* @return {?function}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getIteratorFn(maybeIterable) {
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
if (typeof iteratorFn === 'function') {
return iteratorFn;
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
module.exports = getIteratorFn;
},{}],129:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getNodeForCharacterOffset
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* Given any node return the first leaf node without children.
*
* @param {DOMElement|DOMTextNode} node
* @return {DOMElement|DOMTextNode}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getLeafNode(node) {
while (node && node.firstChild) {
node = node.firstChild;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return node;
2015-09-02 15:08:58 -04:00
}
/**
2015-10-14 22:58:32 -04:00
* 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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getSiblingNode(node) {
while (node) {
if (node.nextSibling) {
return node.nextSibling;
}
node = node.parentNode;
2015-09-02 15:08:58 -04:00
}
}
/**
2015-10-14 22:58:32 -04:00
* Get object describing the nodes which contain characters at offset.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {DOMElement|DOMTextNode} root
* @param {number} offset
* @return {?object}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getNodeForCharacterOffset(root, offset) {
var node = getLeafNode(root);
var nodeStart = 0;
var nodeEnd = 0;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
while (node) {
if (node.nodeType === 3) {
nodeEnd = nodeStart + node.textContent.length;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (nodeStart <= offset && nodeEnd >= offset) {
return {
node: node,
offset: offset - nodeStart
};
}
nodeStart = nodeEnd;
}
node = getLeafNode(getSiblingNode(node));
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
module.exports = getNodeForCharacterOffset;
},{}],130:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getTextContentAccessor
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var contentKey = null;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Gets the key used to access text content on a DOM node.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @return {?string} Key used to access text content.
* @internal
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return contentKey;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = getTextContentAccessor;
},{"146":146}],131:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule instantiateReactComponent
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactCompositeComponent = _dereq_(38);
var ReactEmptyComponent = _dereq_(59);
var ReactNativeComponent = _dereq_(75);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var assign = _dereq_(24);
var invariant = _dereq_(160);
var warning = _dereq_(172);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// To avoid a cyclic dependency, we create the final class in this module
var ReactCompositeComponentWrapper = function () {};
assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
_instantiateReactComponent: instantiateReactComponent
});
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
/**
* Check if the type reference is a known internal type. I.e. not a user
* provided composite type.
*
* @param {function} type
* @return {boolean} Returns true if this is a valid internal type.
*/
function isInternalComponentType(type) {
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
}
/**
* Given a ReactNode, create an instance that will actually be mounted.
*
* @param {ReactNode} node
* @return {object} A new instance of the element's constructor.
* @protected
*/
function instantiateReactComponent(node) {
var instance;
if (node === null || node === false) {
instance = new ReactEmptyComponent(instantiateReactComponent);
} else if (typeof node === 'object') {
var element = node;
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? "development" !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
// Special case string values
if (typeof element.type === 'string') {
instance = ReactNativeComponent.createInternalComponent(element);
} else if (isInternalComponentType(element.type)) {
// This is temporarily available for custom components that are not string
// representations. I.e. ART. Once those are updated to use the string
// representation, we can drop this code path.
instance = new element.type(element);
} else {
instance = new ReactCompositeComponentWrapper();
}
} else if (typeof node === 'string' || typeof node === 'number') {
instance = ReactNativeComponent.createInstanceForText(node);
} else {
!false ? "development" !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined;
}
if ("development" !== 'production') {
"development" !== 'production' ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined;
}
// Sets up the instance. This can probably just move into the constructor now.
instance.construct(node);
// These two fields are used by the DOM and ART diffing algorithms
// respectively. Instead of using expandos on components, we should be
// storing the state needed by the diffing algorithms elsewhere.
instance._mountIndex = 0;
instance._mountImage = null;
if ("development" !== 'production') {
instance._isOwnerNecessary = false;
instance._warnedAboutRefsInRender = false;
}
// Internal instances should fully constructed at this point, so they should
// not get any new fields added to them at this point.
if ("development" !== 'production') {
if (Object.preventExtensions) {
Object.preventExtensions(instance);
}
}
return instance;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = instantiateReactComponent;
},{"160":160,"172":172,"24":24,"38":38,"59":59,"75":75}],132:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule isEventSupported
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
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;
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function isEventSupported(eventNameSuffix, capture) {
if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
return false;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var eventName = 'on' + eventNameSuffix;
var isSupported = (eventName in document);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (!isSupported) {
var element = document.createElement('div');
element.setAttribute(eventName, 'return;');
isSupported = typeof element[eventName] === 'function';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
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');
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return isSupported;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = isEventSupported;
},{"146":146}],133:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule isTextInputElement
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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
2015-09-02 15:08:58 -04:00
};
2015-10-14 22:58:32 -04:00
function isTextInputElement(elem) {
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = isTextInputElement;
},{}],134:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule onlyChild
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ReactElement = _dereq_(57);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {?object} children Child collection structure.
* @return {ReactComponent} The first and only `ReactComponent` contained in the
* structure.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function onlyChild(children) {
!ReactElement.isValidElement(children) ? "development" !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined;
return children;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = onlyChild;
},{"160":160,"57":57}],135:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule quoteAttributeValueForBrowser
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var escapeTextContentForBrowser = _dereq_(120);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Escapes attribute value to prevent scripting attacks.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {*} value Value to escape.
* @return {string} An escaped string.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function quoteAttributeValueForBrowser(value) {
return '"' + escapeTextContentForBrowser(value) + '"';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = quoteAttributeValueForBrowser;
},{"120":120}],136:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule renderSubtreeIntoContainer
*/
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var ReactMount = _dereq_(72);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = ReactMount.renderSubtreeIntoContainer;
},{"72":72}],137:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
/* globals MSApp */
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Set the innerHTML property of a node, ensuring that whitespace is preserved
* even in IE8.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {DOMElement} node
* @param {string} html
* @internal
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var setInnerHTML = function (node, html) {
node.innerHTML = html;
};
// Win8 apps: Allow all html to be inserted
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
setInnerHTML = function (node, html) {
MSApp.execUnsafeLocalFunction(function () {
node.innerHTML = html;
});
};
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
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
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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.
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode
// in hopes that this is preserved even if "\uFEFF" is transformed to
// the actual Unicode character (by Babel, for example).
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
node.innerHTML = String.fromCharCode(0xFEFF) + 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;
}
};
}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = setInnerHTML;
},{"146":146}],138:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule setTextContent
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
var escapeTextContentForBrowser = _dereq_(120);
var setInnerHTML = _dereq_(137);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Set the textContent property of a node, ensuring that whitespace is preserved
* even in IE8. innerText is a poor substitute for textContent and, among many
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
* as it should.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {DOMElement} node
* @param {string} text
* @internal
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var setTextContent = function (node, text) {
node.textContent = text;
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (ExecutionEnvironment.canUseDOM) {
if (!('textContent' in document.documentElement)) {
setTextContent = function (node, text) {
setInnerHTML(node, escapeTextContentForBrowser(text));
};
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
module.exports = setTextContent;
},{"120":120,"137":137,"146":146}],139:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule shallowCompare
*/
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var shallowEqual = _dereq_(170);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Does a shallow comparison for props and state.
* See ReactComponentWithPureRenderMixin
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function shallowCompare(instance, nextProps, nextState) {
return !shallowEqual(instance.props, nextProps) || !shallowEqual(instance.state, nextState);
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = shallowCompare;
},{"170":170}],140:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule shouldUpdateReactComponent
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {?object} prevElement
* @param {?object} nextElement
* @return {boolean} True if the existing instance should be updated.
* @protected
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function shouldUpdateReactComponent(prevElement, nextElement) {
var prevEmpty = prevElement === null || prevElement === false;
var nextEmpty = nextElement === null || nextElement === false;
if (prevEmpty || nextEmpty) {
return prevEmpty === nextEmpty;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var prevType = typeof prevElement;
var nextType = typeof nextElement;
if (prevType === 'string' || prevType === 'number') {
return nextType === 'string' || nextType === 'number';
} else {
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
}
return false;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = shouldUpdateReactComponent;
},{}],141:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule traverseAllChildren
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var ReactCurrentOwner = _dereq_(39);
var ReactElement = _dereq_(57);
var ReactInstanceHandles = _dereq_(67);
var getIteratorFn = _dereq_(128);
var invariant = _dereq_(160);
var warning = _dereq_(172);
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
var SUBSEPARATOR = ':';
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/
var userProvidedKeyEscaperLookup = {
'=': '=0',
'.': '=1',
':': '=2'
};
var userProvidedKeyEscapeRegex = /[=.:]/g;
var didWarnAboutMaps = false;
function userProvidedKeyEscaper(match) {
return userProvidedKeyEscaperLookup[match];
}
/**
* Generate a key string that identifies a component within a set.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {*} text Component key to be escaped.
* @return {string} An escaped string.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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 {!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.
*/
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
var type = typeof children;
if (type === 'undefined' || type === 'boolean') {
// All of the above are perceived as null.
children = null;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) {
callback(traverseContext, children,
// 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.
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
return 1;
}
var child;
var nextName;
var subtreeCount = 0; // Count of children found in the current subtree.
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
child = children[i];
nextName = nextNamePrefix + getComponentKey(child, i);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
var iteratorFn = getIteratorFn(children);
if (iteratorFn) {
var iterator = iteratorFn.call(children);
var step;
if (iteratorFn !== children.entries) {
var ii = 0;
while (!(step = iterator.next()).done) {
child = step.value;
nextName = nextNamePrefix + getComponentKey(child, ii++);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
if ("development" !== 'production') {
"development" !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : undefined;
didWarnAboutMaps = true;
}
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
child = entry[1];
nextName = nextNamePrefix + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
}
}
} else if (type === 'object') {
var addendum = '';
if ("development" !== 'production') {
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
if (children._isReactElement) {
addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
}
if (ReactCurrentOwner.current) {
var name = ReactCurrentOwner.current.getName();
if (name) {
addendum += ' Check the render method of `' + name + '`.';
}
}
}
var childrenString = String(children);
!false ? "development" !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : undefined;
}
}
return subtreeCount;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
/**
* 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;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
return traverseAllChildrenImpl(children, '', callback, traverseContext);
}
module.exports = traverseAllChildren;
},{"128":128,"160":160,"172":172,"39":39,"57":57,"67":67}],142:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule update
*/
/* global hasOwnProperty:true */
'use strict';
var assign = _dereq_(24);
var keyOf = _dereq_(165);
var invariant = _dereq_(160);
var hasOwnProperty = ({}).hasOwnProperty;
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) {
!Array.isArray(value) ? "development" !== 'production' ? invariant(false, 'update(): expected target of %s to be an array; got %s.', command, value) : invariant(false) : undefined;
var specValue = spec[command];
!Array.isArray(specValue) ? "development" !== 'production' ? invariant(false, 'update(): expected spec of %s to be an array; got %s. ' + 'Did you forget to wrap your parameter in an array?', command, specValue) : invariant(false) : undefined;
}
function update(value, spec) {
!(typeof spec === 'object') ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
if (hasOwnProperty.call(spec, COMMAND_SET)) {
!(Object.keys(spec).length === 1) ? "development" !== 'production' ? invariant(false, 'Cannot have more than one key in an object with %s', COMMAND_SET) : invariant(false) : undefined;
return spec[COMMAND_SET];
}
var nextValue = shallowCopy(value);
if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
var mergeObj = spec[COMMAND_MERGE];
!(mergeObj && typeof mergeObj === 'object') ? "development" !== 'production' ? invariant(false, 'update(): %s expects a spec of type \'object\'; got %s', COMMAND_MERGE, mergeObj) : invariant(false) : undefined;
!(nextValue && typeof nextValue === 'object') ? "development" !== 'production' ? invariant(false, 'update(): %s expects a target of type \'object\'; got %s', COMMAND_MERGE, nextValue) : invariant(false) : undefined;
assign(nextValue, spec[COMMAND_MERGE]);
}
if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
invariantArrayCase(value, spec, COMMAND_PUSH);
spec[COMMAND_PUSH].forEach(function (item) {
nextValue.push(item);
});
}
if (hasOwnProperty.call(spec, COMMAND_UNSHIFT)) {
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
spec[COMMAND_UNSHIFT].forEach(function (item) {
nextValue.unshift(item);
});
}
if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
!Array.isArray(value) ? "development" !== 'production' ? invariant(false, 'Expected %s target to be an array; got %s', COMMAND_SPLICE, value) : invariant(false) : undefined;
!Array.isArray(spec[COMMAND_SPLICE]) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
spec[COMMAND_SPLICE].forEach(function (args) {
!Array.isArray(args) ? "development" !== 'production' ? invariant(false, '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(false) : undefined;
nextValue.splice.apply(nextValue, args);
});
}
if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
!(typeof spec[COMMAND_APPLY] === 'function') ? "development" !== 'production' ? invariant(false, 'update(): expected spec of %s to be a function; got %s.', COMMAND_APPLY, spec[COMMAND_APPLY]) : invariant(false) : undefined;
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;
},{"160":160,"165":165,"24":24}],143:[function(_dereq_,module,exports){
/**
* Copyright 2015, 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 validateDOMNesting
*/
'use strict';
var assign = _dereq_(24);
var emptyFunction = _dereq_(152);
var warning = _dereq_(172);
var validateDOMNesting = emptyFunction;
if ("development" !== 'production') {
// This validation code was written based on the HTML5 parsing spec:
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
//
// Note: this does not catch all invalid nesting, nor does it try to (as it's
// not clear what practical benefit doing so provides); instead, we warn only
// for cases where the parser will give a parse tree differing from what React
// intended. For example, <b><div></div></b> is invalid but we don't warn
// because it still parses correctly; we do warn for other cases like nested
// <p> tags where the beginning of the second element implicitly closes the
// first, causing a confusing mess.
// https://html.spec.whatwg.org/multipage/syntax.html#special
var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp'];
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',
// https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
// TODO: Distinguish by namespace here -- for <title>, including it here
// errs on the side of fewer warnings
'foreignObject', 'desc', 'title'];
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
var buttonScopeTags = inScopeTags.concat(['button']);
// https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
var emptyAncestorInfo = {
parentTag: null,
formTag: null,
aTagInScope: null,
buttonTagInScope: null,
nobrTagInScope: null,
pTagInButtonScope: null,
listItemTagAutoclosing: null,
dlItemTagAutoclosing: null
};
var updatedAncestorInfo = function (oldInfo, tag, instance) {
var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
var info = { tag: tag, instance: instance };
if (inScopeTags.indexOf(tag) !== -1) {
ancestorInfo.aTagInScope = null;
ancestorInfo.buttonTagInScope = null;
ancestorInfo.nobrTagInScope = null;
}
if (buttonScopeTags.indexOf(tag) !== -1) {
ancestorInfo.pTagInButtonScope = null;
}
// See rules for 'li', 'dd', 'dt' start tags in
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
ancestorInfo.listItemTagAutoclosing = null;
ancestorInfo.dlItemTagAutoclosing = null;
}
ancestorInfo.parentTag = info;
if (tag === 'form') {
ancestorInfo.formTag = info;
}
if (tag === 'a') {
ancestorInfo.aTagInScope = info;
}
if (tag === 'button') {
ancestorInfo.buttonTagInScope = info;
}
if (tag === 'nobr') {
ancestorInfo.nobrTagInScope = info;
}
if (tag === 'p') {
ancestorInfo.pTagInButtonScope = info;
}
if (tag === 'li') {
ancestorInfo.listItemTagAutoclosing = info;
}
if (tag === 'dd' || tag === 'dt') {
ancestorInfo.dlItemTagAutoclosing = info;
}
return ancestorInfo;
};
/**
* Returns whether
*/
var isTagValidWithParent = function (tag, parentTag) {
// First, let's check if we're in an unusual parsing mode...
switch (parentTag) {
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
case 'select':
return tag === 'option' || tag === 'optgroup' || tag === '#text';
case 'optgroup':
return tag === 'option' || tag === '#text';
// Strictly speaking, seeing an <option> doesn't mean we're in a <select>
// but
case 'option':
return tag === '#text';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
// No special behavior since these rules fall back to "in body" mode for
// all except special table nodes which cause bad parsing behavior anyway.
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
case 'tr':
return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
case 'tbody':
case 'thead':
case 'tfoot':
return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
case 'colgroup':
return tag === 'col' || tag === 'template';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
case 'table':
return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
case 'head':
return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
case 'html':
return tag === 'head' || tag === 'body';
}
// Probably in the "in body" parsing mode, so we outlaw only tag combos
// where the parsing rules cause implicit opens or closes to be added.
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
switch (tag) {
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
case 'rp':
case 'rt':
return impliedEndTags.indexOf(parentTag) === -1;
case 'caption':
case 'col':
case 'colgroup':
case 'frame':
case 'head':
case 'tbody':
case 'td':
case 'tfoot':
case 'th':
case 'thead':
case 'tr':
// These tags are only valid with a few parents that have special child
// parsing rules -- if we're down here, then none of those matched and
// so we allow it only if we don't know what the parent is, as all other
// cases are invalid.
return parentTag == null;
}
return true;
};
/**
* Returns whether
*/
var findInvalidAncestorForTag = function (tag, ancestorInfo) {
switch (tag) {
case 'address':
case 'article':
case 'aside':
case 'blockquote':
case 'center':
case 'details':
case 'dialog':
case 'dir':
case 'div':
case 'dl':
case 'fieldset':
case 'figcaption':
case 'figure':
case 'footer':
case 'header':
case 'hgroup':
case 'main':
case 'menu':
case 'nav':
case 'ol':
case 'p':
case 'section':
case 'summary':
case 'ul':
case 'pre':
case 'listing':
case 'table':
case 'hr':
case 'xmp':
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
return ancestorInfo.pTagInButtonScope;
case 'form':
return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
case 'li':
return ancestorInfo.listItemTagAutoclosing;
case 'dd':
case 'dt':
return ancestorInfo.dlItemTagAutoclosing;
case 'button':
return ancestorInfo.buttonTagInScope;
case 'a':
// Spec says something about storing a list of markers, but it sounds
// equivalent to this check.
return ancestorInfo.aTagInScope;
case 'nobr':
return ancestorInfo.nobrTagInScope;
}
return null;
};
/**
* Given a ReactCompositeComponent instance, return a list of its recursive
* owners, starting at the root and ending with the instance itself.
*/
var findOwnerStack = function (instance) {
if (!instance) {
return [];
}
var stack = [];
/*eslint-disable space-after-keywords */
do {
/*eslint-enable space-after-keywords */
stack.push(instance);
} while (instance = instance._currentElement._owner);
stack.reverse();
return stack;
};
var didWarn = {};
validateDOMNesting = function (childTag, childInstance, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.parentTag;
var parentTag = parentInfo && parentInfo.tag;
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
var problematic = invalidParent || invalidAncestor;
if (problematic) {
var ancestorTag = problematic.tag;
var ancestorInstance = problematic.instance;
var childOwner = childInstance && childInstance._currentElement._owner;
var ancestorOwner = ancestorInstance && ancestorInstance._currentElement._owner;
var childOwners = findOwnerStack(childOwner);
var ancestorOwners = findOwnerStack(ancestorOwner);
var minStackLen = Math.min(childOwners.length, ancestorOwners.length);
var i;
var deepestCommon = -1;
for (i = 0; i < minStackLen; i++) {
if (childOwners[i] === ancestorOwners[i]) {
deepestCommon = i;
} else {
break;
}
}
var UNKNOWN = '(unknown)';
var childOwnerNames = childOwners.slice(deepestCommon + 1).map(function (inst) {
return inst.getName() || UNKNOWN;
});
var ancestorOwnerNames = ancestorOwners.slice(deepestCommon + 1).map(function (inst) {
return inst.getName() || UNKNOWN;
});
var ownerInfo = [].concat(
// If the parent and child instances have a common owner ancestor, start
// with that -- otherwise we just start with the parent's owners.
deepestCommon !== -1 ? childOwners[deepestCommon].getName() || UNKNOWN : [], ancestorOwnerNames, ancestorTag,
// If we're warning about an invalid (non-parent) ancestry, add '...'
invalidAncestor ? ['...'] : [], childOwnerNames, childTag).join(' > ');
var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + ownerInfo;
if (didWarn[warnKey]) {
return;
}
didWarn[warnKey] = true;
if (invalidParent) {
var info = '';
if (ancestorTag === 'table' && childTag === 'tr') {
info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
}
"development" !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s>. ' + 'See %s.%s', childTag, ancestorTag, ownerInfo, info) : undefined;
} else {
"development" !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a descendant of ' + '<%s>. See %s.', childTag, ancestorTag, ownerInfo) : undefined;
}
}
};
validateDOMNesting.ancestorInfoContextKey = '__validateDOMNesting_ancestorInfo$' + Math.random().toString(36).slice(2);
validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo;
// For testing
validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.parentTag;
var parentTag = parentInfo && parentInfo.tag;
return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo);
};
}
module.exports = validateDOMNesting;
},{"152":152,"172":172,"24":24}],144:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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
2015-09-02 15:08:58 -04:00
* @typechecks
*/
2015-10-14 22:58:32 -04:00
'use strict';
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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) {
!!/\s/.test(className) ? "development" !== 'production' ? invariant(false, 'CSSCore.addClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : undefined;
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) {
!!/\s/.test(className) ? "development" !== 'production' ? invariant(false, 'CSSCore.removeClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : undefined;
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) {
!!/\s/.test(className) ? "development" !== 'production' ? invariant(false, 'CSS.hasClass takes only a single class name.') : invariant(false) : undefined;
if (element.classList) {
return !!className && element.classList.contains(className);
}
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
}
};
module.exports = CSSCore;
},{"160":160}],145:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, Facebook, Inc.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* http://www.apache.org/licenses/LICENSE-2.0
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var emptyFunction = _dereq_(152);
/**
* 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) {
target.addEventListener(eventType, callback, true);
return {
remove: function () {
target.removeEventListener(eventType, callback, true);
}
};
} else {
if ("development" !== 'production') {
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
};
}
},
registerDefault: function () {}
};
module.exports = EventListener;
},{"152":152}],146:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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
*/
'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.
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
};
module.exports = ExecutionEnvironment;
},{}],147:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule camelize
2015-09-02 15:08:58 -04:00
* @typechecks
*/
"use strict";
2015-10-14 22:58:32 -04:00
var _hyphenPattern = /-(.)/g;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Camelcases a hyphenated string, for example:
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* > camelize('background-color')
* < "backgroundColor"
2015-09-02 15:08:58 -04:00
*
* @param {string} string
* @return {string}
*/
2015-10-14 22:58:32 -04:00
function camelize(string) {
return string.replace(_hyphenPattern, function (_, character) {
return character.toUpperCase();
});
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = camelize;
},{}],148:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule camelizeStyleName
* @typechecks
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var camelize = _dereq_(147);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var msPattern = /^-ms-/;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Camelcases a hyphenated CSS property name, for example:
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* > camelizeStyleName('background-color')
* < "backgroundColor"
* > camelizeStyleName('-moz-transition')
* < "MozTransition"
* > camelizeStyleName('-ms-transition')
* < "msTransition"
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function camelizeStyleName(string) {
return camelize(string.replace(msPattern, 'ms-'));
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = camelizeStyleName;
},{"147":147}],149:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule containsNode
* @typechecks
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var isTextNode = _dereq_(162);
/*eslint-disable no-bitwise */
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Checks if a given DOM node contains or is another DOM node.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {?DOMNode} outerNode Outer DOM node.
* @param {?DOMNode} innerNode Inner DOM node.
* @return {boolean} True if `outerNode` contains or is `innerNode`.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function containsNode(_x, _x2) {
var _again = true;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
_function: while (_again) {
var outerNode = _x,
innerNode = _x2;
_again = false;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (!outerNode || !innerNode) {
return false;
} else if (outerNode === innerNode) {
return true;
} else if (isTextNode(outerNode)) {
return false;
} else if (isTextNode(innerNode)) {
_x = outerNode;
_x2 = innerNode.parentNode;
_again = true;
continue _function;
} else if (outerNode.contains) {
return outerNode.contains(innerNode);
} else if (outerNode.compareDocumentPosition) {
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
2015-09-02 15:08:58 -04:00
} else {
2015-10-14 22:58:32 -04:00
return false;
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = containsNode;
},{"162":162}],150:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule createArrayFromMixed
* @typechecks
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var toArray = _dereq_(171);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Perform a heuristic test to determine if an object is "array-like".
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
* Joshu replied: "Mu."
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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()).
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* It will return false for other array-like objects like Filelist.
*
* @param {*} obj
* @return {boolean}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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
Array.isArray(obj) ||
// arguments
'callee' in obj ||
// HTMLCollection/NodeList
'item' in obj)
);
2015-09-02 15:08:58 -04:00
}
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* This is mostly useful idiomatically:
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* var createArrayFromMixed = require('createArrayFromMixed');
*
* function takesOneOrMoreThings(things) {
* things = createArrayFromMixed(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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function createArrayFromMixed(obj) {
if (!hasArrayNature(obj)) {
return [obj];
} else if (Array.isArray(obj)) {
return obj.slice();
} else {
return toArray(obj);
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = createArrayFromMixed;
},{"171":171}],151:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule createNodesFromMarkup
* @typechecks
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
/*eslint-disable fb-www/unsafe-html*/
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
var createArrayFromMixed = _dereq_(150);
var getMarkupWrap = _dereq_(156);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Dummy container used to render all markup.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* Pattern used by `getNodeName`.
*/
var nodeNamePattern = /^\s*<(\w+)/;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Extracts the `nodeName` of the first element in a string of markup.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {string} markup String of markup.
* @return {?string} Node name of the supplied markup.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getNodeName(markup) {
var nodeNameMatch = markup.match(nodeNamePattern);
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function createNodesFromMarkup(markup, handleScript) {
var node = dummyNode;
!!!dummyNode ? "development" !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : undefined;
var nodeName = getNodeName(markup);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
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) {
!handleScript ? "development" !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : undefined;
createArrayFromMixed(scripts).forEach(handleScript);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var nodes = createArrayFromMixed(node.childNodes);
while (node.lastChild) {
node.removeChild(node.lastChild);
}
return nodes;
}
module.exports = createNodesFromMarkup;
},{"146":146,"150":150,"156":156,"160":160}],152:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule emptyFunction
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
"use strict";
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function emptyFunction() {}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
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;
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = emptyFunction;
},{}],153:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule emptyObject
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var emptyObject = {};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
Object.freeze(emptyObject);
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = emptyObject;
},{}],154:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule focusNode
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* @param {DOMElement} node input/textarea to focus
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
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) {}
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = focusNode;
},{}],155:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getActiveElement
* @typechecks
2015-09-02 15:08:58 -04:00
*/
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* The activeElement will be null only if the document or document body is not yet defined.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
function getActiveElement() /*?DOMElement*/{
if (typeof document === 'undefined') {
2015-09-02 15:08:58 -04:00
return null;
}
2015-10-14 22:58:32 -04:00
try {
return document.activeElement || document.body;
} catch (e) {
return document.body;
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
module.exports = getActiveElement;
},{}],156:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getMarkupWrap
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
/*eslint-disable fb-www/unsafe-html */
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Dummy container used to detect which wraps are necessary.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Some browsers cannot use `innerHTML` to render certain elements standalone,
* so we wrap them, render the wrapped nodes, then extract the desired node.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var shouldWrap = {};
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 xmlns="http://www.w3.org/2000/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
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Initialize the SVG elements since we know they'll always need to be wrapped
// consistently. If they are created inside a <div> they will be initialized in
// the wrong namespace (and will not display).
var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
svgElements.forEach(function (nodeName) {
markupWrap[nodeName] = svgWrap;
shouldWrap[nodeName] = true;
});
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Gets the markup wrap configuration for the supplied `nodeName`.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* NOTE: This lazily detects which wraps are necessary for the current browser.
*
* @param {string} nodeName Lowercase `nodeName`.
* @return {?array} Markup wrap configuration, if applicable.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function getMarkupWrap(nodeName) {
!!!dummyNode ? "development" !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : undefined;
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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = getMarkupWrap;
},{"146":146,"160":160}],157:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule getUnboundedScrollPosition
2015-09-02 15:08:58 -04:00
* @typechecks
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* 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
};
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = getUnboundedScrollPosition;
},{}],158:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule hyphenate
2015-09-02 15:08:58 -04:00
* @typechecks
*/
2015-10-14 22:58:32 -04:00
'use strict';
var _uppercasePattern = /([A-Z])/g;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function hyphenate(string) {
return string.replace(_uppercasePattern, '-$1').toLowerCase();
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = hyphenate;
},{}],159:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule hyphenateStyleName
* @typechecks
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var hyphenate = _dereq_(158);
var msPattern = /^ms-/;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Hyphenates a camelcased CSS property name, for example:
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* > 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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function hyphenateStyleName(string) {
return hyphenate(string).replace(msPattern, '-ms-');
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = hyphenateStyleName;
},{"158":158}],160:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule invariant
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* Use invariant() to assert state which your program assumes to be true.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var invariant = function (condition, format, a, b, c, d, e, f) {
if ("development" !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
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;
}
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = invariant;
},{}],161:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule isNode
* @typechecks
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
/**
* @param {*} object The object to check.
* @return {boolean} Whether or not the object is a DOM node.
*/
2015-09-02 15:08:58 -04:00
'use strict';
2015-10-14 22:58:32 -04:00
function isNode(object) {
return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = isNode;
},{}],162:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var isNode = _dereq_(161);
/**
* @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;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = isTextNode;
},{"161":161}],163:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule joinClasses
* @typechecks static-only
2015-09-02 15:08:58 -04:00
*/
'use strict';
/**
2015-10-14 22:58:32 -04:00
* Combines multiple className strings into one.
* http://jsperf.com/joinclasses-args-vs-array
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @param {...?string} className
* @return {string}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function joinClasses(className /*, ... */) {
if (!className) {
className = '';
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
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;
}
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
return className;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = joinClasses;
},{}],164:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule keyMirror
2015-09-02 15:08:58 -04:00
* @typechecks static-only
*/
'use strict';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Constructs an enumeration with keys equal to their value.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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}
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
var keyMirror = function (obj) {
var ret = {};
var key;
!(obj instanceof Object && !Array.isArray(obj)) ? "development" !== 'production' ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : undefined;
for (key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
ret[key] = key;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return ret;
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = keyMirror;
},{"160":160}],165:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
2015-09-02 15:08:58 -04:00
* 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule keyOf
*/
/**
* Allows extraction of a minified key. Let's the build system minify keys
* without losing 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
"use strict";
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var keyOf = function (oneKeyObj) {
var key;
for (key in oneKeyObj) {
if (!oneKeyObj.hasOwnProperty(key)) {
continue;
}
return key;
}
return null;
};
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = keyOf;
},{}],166:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* @providesModule mapObject
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var hasOwnProperty = Object.prototype.hasOwnProperty;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* 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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var result = {};
for (var name in object) {
if (hasOwnProperty.call(object, name)) {
result[name] = callback.call(context, object[name], name, object);
}
}
return result;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = mapObject;
},{}],167:[function(_dereq_,module,exports){
/**
* Copyright 2013-2015, 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)) {
cache[string] = callback.call(this, string);
}
return cache[string];
};
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = memoizeStringOnly;
},{}],168:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule performance
* @typechecks
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var ExecutionEnvironment = _dereq_(146);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var performance;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (ExecutionEnvironment.canUseDOM) {
performance = window.performance || window.msPerformance || window.webkitPerformance;
}
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = performance || {};
},{"146":146}],169:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, 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
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var performance = _dereq_(168);
var curPerformance = performance;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* 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.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
if (!curPerformance || !curPerformance.now) {
curPerformance = Date;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var performanceNow = curPerformance.now.bind(curPerformance);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
module.exports = performanceNow;
},{"168":168}],170:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
2015-09-02 15:08:58 -04:00
*
2015-10-14 22:58:32 -04:00
* 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
* @typechecks
*
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty;
2015-09-02 15:08:58 -04:00
/**
2015-10-14 22:58:32 -04:00
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
2015-09-02 15:08:58 -04:00
*/
2015-10-14 22:58:32 -04:00
function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
if (keysA.length !== keysB.length) {
return false;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
// Test for A's keys different from B.
var bHasOwnProperty = hasOwnProperty.bind(objB);
for (var i = 0; i < keysA.length; i++) {
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
return false;
}
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
return true;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = shallowEqual;
},{}],171:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2013-2015, 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.
*
2015-10-14 22:58:32 -04:00
* @providesModule toArray
* @typechecks
2015-09-02 15:08:58 -04:00
*/
'use strict';
2015-10-14 22:58:32 -04:00
var invariant = _dereq_(160);
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
/**
* Convert array-like objects to arrays.
*
* This API assumes the caller knows the contents of the data type. For less
* well defined inputs use createArrayFromMixed.
*
* @param {object|function|filelist} obj
* @return {array}
*/
function toArray(obj) {
var length = obj.length;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
// old versions of Safari).
!(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? "development" !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
!(typeof length === 'number') ? "development" !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
!(length === 0 || length - 1 in obj) ? "development" !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : undefined;
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
// 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
2015-09-02 15:08:58 -04:00
}
}
2015-10-14 22:58:32 -04:00
// 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;
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
module.exports = toArray;
},{"160":160}],172:[function(_dereq_,module,exports){
2015-09-02 15:08:58 -04:00
/**
* Copyright 2014-2015, 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
*/
2015-10-14 22:58:32 -04:00
'use strict';
2015-09-02 15:08:58 -04:00
2015-10-14 22:58:32 -04:00
var emptyFunction = _dereq_(152);
2015-09-02 15:08:58 -04:00
/**
* 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;
2015-10-14 22:58:32 -04:00
if ("development" !== 'production') {
warning = function (condition, format) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
2015-09-02 15:08:58 -04:00
}
2015-10-14 22:58:32 -04:00
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
2015-09-02 15:08:58 -04:00
}
if (format.indexOf('Failed Composite propType: ') === 0) {
return; // Ignore CompositeComponent proptype check.
}
if (!condition) {
var argIndex = 0;
2015-10-14 22:58:32 -04:00
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
2015-09-02 15:08:58 -04:00
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
2015-10-14 22:58:32 -04:00
} catch (x) {}
2015-09-02 15:08:58 -04:00
}
};
}
module.exports = warning;
2015-10-14 22:58:32 -04:00
},{"152":152}]},{},[1])(1)
});