UNPKG

573 kBJavaScriptView Raw
1/**
2 * React v0.12.2
3 */
4!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.React=e()}}(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){
5/**
6 * Copyright 2013-2014, Facebook, Inc.
7 * All rights reserved.
8 *
9 * This source code is licensed under the BSD-style license found in the
10 * LICENSE file in the root directory of this source tree. An additional grant
11 * of patent rights can be found in the PATENTS file in the same directory.
12 *
13 * @providesModule React
14 */
15
16"use strict";
17
18var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
19var EventPluginUtils = _dereq_("./EventPluginUtils");
20var ReactChildren = _dereq_("./ReactChildren");
21var ReactComponent = _dereq_("./ReactComponent");
22var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
23var ReactContext = _dereq_("./ReactContext");
24var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
25var ReactElement = _dereq_("./ReactElement");
26var ReactElementValidator = _dereq_("./ReactElementValidator");
27var ReactDOM = _dereq_("./ReactDOM");
28var ReactDOMComponent = _dereq_("./ReactDOMComponent");
29var ReactDefaultInjection = _dereq_("./ReactDefaultInjection");
30var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
31var ReactLegacyElement = _dereq_("./ReactLegacyElement");
32var ReactMount = _dereq_("./ReactMount");
33var ReactMultiChild = _dereq_("./ReactMultiChild");
34var ReactPerf = _dereq_("./ReactPerf");
35var ReactPropTypes = _dereq_("./ReactPropTypes");
36var ReactServerRendering = _dereq_("./ReactServerRendering");
37var ReactTextComponent = _dereq_("./ReactTextComponent");
38
39var assign = _dereq_("./Object.assign");
40var deprecated = _dereq_("./deprecated");
41var onlyChild = _dereq_("./onlyChild");
42
43ReactDefaultInjection.inject();
44
45var createElement = ReactElement.createElement;
46var createFactory = ReactElement.createFactory;
47
48if ("production" !== "development") {
49 createElement = ReactElementValidator.createElement;
50 createFactory = ReactElementValidator.createFactory;
51}
52
53// TODO: Drop legacy elements once classes no longer export these factories
54createElement = ReactLegacyElement.wrapCreateElement(
55 createElement
56);
57createFactory = ReactLegacyElement.wrapCreateFactory(
58 createFactory
59);
60
61var render = ReactPerf.measure('React', 'render', ReactMount.render);
62
63var React = {
64 Children: {
65 map: ReactChildren.map,
66 forEach: ReactChildren.forEach,
67 count: ReactChildren.count,
68 only: onlyChild
69 },
70 DOM: ReactDOM,
71 PropTypes: ReactPropTypes,
72 initializeTouchEvents: function(shouldUseTouch) {
73 EventPluginUtils.useTouchEvents = shouldUseTouch;
74 },
75 createClass: ReactCompositeComponent.createClass,
76 createElement: createElement,
77 createFactory: createFactory,
78 constructAndRenderComponent: ReactMount.constructAndRenderComponent,
79 constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
80 render: render,
81 renderToString: ReactServerRendering.renderToString,
82 renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
83 unmountComponentAtNode: ReactMount.unmountComponentAtNode,
84 isValidClass: ReactLegacyElement.isValidClass,
85 isValidElement: ReactElement.isValidElement,
86 withContext: ReactContext.withContext,
87
88 // Hook for JSX spread, don't use this for anything else.
89 __spread: assign,
90
91 // Deprecations (remove for 0.13)
92 renderComponent: deprecated(
93 'React',
94 'renderComponent',
95 'render',
96 this,
97 render
98 ),
99 renderComponentToString: deprecated(
100 'React',
101 'renderComponentToString',
102 'renderToString',
103 this,
104 ReactServerRendering.renderToString
105 ),
106 renderComponentToStaticMarkup: deprecated(
107 'React',
108 'renderComponentToStaticMarkup',
109 'renderToStaticMarkup',
110 this,
111 ReactServerRendering.renderToStaticMarkup
112 ),
113 isValidComponent: deprecated(
114 'React',
115 'isValidComponent',
116 'isValidElement',
117 this,
118 ReactElement.isValidElement
119 )
120};
121
122// Inject the runtime into a devtools global hook regardless of browser.
123// Allows for debugging when the hook is injected on the page.
124if (
125 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
126 typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
127 __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
128 Component: ReactComponent,
129 CurrentOwner: ReactCurrentOwner,
130 DOMComponent: ReactDOMComponent,
131 DOMPropertyOperations: DOMPropertyOperations,
132 InstanceHandles: ReactInstanceHandles,
133 Mount: ReactMount,
134 MultiChild: ReactMultiChild,
135 TextComponent: ReactTextComponent
136 });
137}
138
139if ("production" !== "development") {
140 var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
141 if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
142
143 // If we're in Chrome, look for the devtools marker and provide a download
144 // link if not installed.
145 if (navigator.userAgent.indexOf('Chrome') > -1) {
146 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
147 console.debug(
148 'Download the React DevTools for a better development experience: ' +
149 'http://fb.me/react-devtools'
150 );
151 }
152 }
153
154 var expectedFeatures = [
155 // shims
156 Array.isArray,
157 Array.prototype.every,
158 Array.prototype.forEach,
159 Array.prototype.indexOf,
160 Array.prototype.map,
161 Date.now,
162 Function.prototype.bind,
163 Object.keys,
164 String.prototype.split,
165 String.prototype.trim,
166
167 // shams
168 Object.create,
169 Object.freeze
170 ];
171
172 for (var i = 0; i < expectedFeatures.length; i++) {
173 if (!expectedFeatures[i]) {
174 console.error(
175 'One or more ES5 shim/shams expected by React are not available: ' +
176 'http://fb.me/react-warning-polyfills'
177 );
178 break;
179 }
180 }
181 }
182}
183
184// Version exists only in the open-source version of React, not in Facebook's
185// internal version.
186React.version = '0.12.2';
187
188module.exports = React;
189
190},{"./DOMPropertyOperations":12,"./EventPluginUtils":20,"./ExecutionEnvironment":22,"./Object.assign":27,"./ReactChildren":31,"./ReactComponent":32,"./ReactCompositeComponent":34,"./ReactContext":35,"./ReactCurrentOwner":36,"./ReactDOM":37,"./ReactDOMComponent":39,"./ReactDefaultInjection":49,"./ReactElement":52,"./ReactElementValidator":53,"./ReactInstanceHandles":60,"./ReactLegacyElement":61,"./ReactMount":63,"./ReactMultiChild":64,"./ReactPerf":68,"./ReactPropTypes":72,"./ReactServerRendering":76,"./ReactTextComponent":78,"./deprecated":106,"./onlyChild":137}],2:[function(_dereq_,module,exports){
191/**
192 * Copyright 2013-2014, Facebook, Inc.
193 * All rights reserved.
194 *
195 * This source code is licensed under the BSD-style license found in the
196 * LICENSE file in the root directory of this source tree. An additional grant
197 * of patent rights can be found in the PATENTS file in the same directory.
198 *
199 * @providesModule AutoFocusMixin
200 * @typechecks static-only
201 */
202
203"use strict";
204
205var focusNode = _dereq_("./focusNode");
206
207var AutoFocusMixin = {
208 componentDidMount: function() {
209 if (this.props.autoFocus) {
210 focusNode(this.getDOMNode());
211 }
212 }
213};
214
215module.exports = AutoFocusMixin;
216
217},{"./focusNode":111}],3:[function(_dereq_,module,exports){
218/**
219 * Copyright 2013 Facebook, Inc.
220 * All rights reserved.
221 *
222 * This source code is licensed under the BSD-style license found in the
223 * LICENSE file in the root directory of this source tree. An additional grant
224 * of patent rights can be found in the PATENTS file in the same directory.
225 *
226 * @providesModule BeforeInputEventPlugin
227 * @typechecks static-only
228 */
229
230"use strict";
231
232var EventConstants = _dereq_("./EventConstants");
233var EventPropagators = _dereq_("./EventPropagators");
234var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
235var SyntheticInputEvent = _dereq_("./SyntheticInputEvent");
236
237var keyOf = _dereq_("./keyOf");
238
239var canUseTextInputEvent = (
240 ExecutionEnvironment.canUseDOM &&
241 'TextEvent' in window &&
242 !('documentMode' in document || isPresto())
243);
244
245/**
246 * Opera <= 12 includes TextEvent in window, but does not fire
247 * text input events. Rely on keypress instead.
248 */
249function isPresto() {
250 var opera = window.opera;
251 return (
252 typeof opera === 'object' &&
253 typeof opera.version === 'function' &&
254 parseInt(opera.version(), 10) <= 12
255 );
256}
257
258var SPACEBAR_CODE = 32;
259var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
260
261var topLevelTypes = EventConstants.topLevelTypes;
262
263// Events and their corresponding property names.
264var eventTypes = {
265 beforeInput: {
266 phasedRegistrationNames: {
267 bubbled: keyOf({onBeforeInput: null}),
268 captured: keyOf({onBeforeInputCapture: null})
269 },
270 dependencies: [
271 topLevelTypes.topCompositionEnd,
272 topLevelTypes.topKeyPress,
273 topLevelTypes.topTextInput,
274 topLevelTypes.topPaste
275 ]
276 }
277};
278
279// Track characters inserted via keypress and composition events.
280var fallbackChars = null;
281
282// Track whether we've ever handled a keypress on the space key.
283var hasSpaceKeypress = false;
284
285/**
286 * Return whether a native keypress event is assumed to be a command.
287 * This is required because Firefox fires `keypress` events for key commands
288 * (cut, copy, select-all, etc.) even though no character is inserted.
289 */
290function isKeypressCommand(nativeEvent) {
291 return (
292 (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
293 // ctrlKey && altKey is equivalent to AltGr, and is not a command.
294 !(nativeEvent.ctrlKey && nativeEvent.altKey)
295 );
296}
297
298/**
299 * Create an `onBeforeInput` event to match
300 * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
301 *
302 * This event plugin is based on the native `textInput` event
303 * available in Chrome, Safari, Opera, and IE. This event fires after
304 * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
305 *
306 * `beforeInput` is spec'd but not implemented in any browsers, and
307 * the `input` event does not provide any useful information about what has
308 * actually been added, contrary to the spec. Thus, `textInput` is the best
309 * available event to identify the characters that have actually been inserted
310 * into the target node.
311 */
312var BeforeInputEventPlugin = {
313
314 eventTypes: eventTypes,
315
316 /**
317 * @param {string} topLevelType Record from `EventConstants`.
318 * @param {DOMEventTarget} topLevelTarget The listening component root node.
319 * @param {string} topLevelTargetID ID of `topLevelTarget`.
320 * @param {object} nativeEvent Native browser event.
321 * @return {*} An accumulation of synthetic events.
322 * @see {EventPluginHub.extractEvents}
323 */
324 extractEvents: function(
325 topLevelType,
326 topLevelTarget,
327 topLevelTargetID,
328 nativeEvent) {
329
330 var chars;
331
332 if (canUseTextInputEvent) {
333 switch (topLevelType) {
334 case topLevelTypes.topKeyPress:
335 /**
336 * If native `textInput` events are available, our goal is to make
337 * use of them. However, there is a special case: the spacebar key.
338 * In Webkit, preventing default on a spacebar `textInput` event
339 * cancels character insertion, but it *also* causes the browser
340 * to fall back to its default spacebar behavior of scrolling the
341 * page.
342 *
343 * Tracking at:
344 * https://code.google.com/p/chromium/issues/detail?id=355103
345 *
346 * To avoid this issue, use the keypress event as if no `textInput`
347 * event is available.
348 */
349 var which = nativeEvent.which;
350 if (which !== SPACEBAR_CODE) {
351 return;
352 }
353
354 hasSpaceKeypress = true;
355 chars = SPACEBAR_CHAR;
356 break;
357
358 case topLevelTypes.topTextInput:
359 // Record the characters to be added to the DOM.
360 chars = nativeEvent.data;
361
362 // If it's a spacebar character, assume that we have already handled
363 // it at the keypress level and bail immediately. Android Chrome
364 // doesn't give us keycodes, so we need to blacklist it.
365 if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
366 return;
367 }
368
369 // Otherwise, carry on.
370 break;
371
372 default:
373 // For other native event types, do nothing.
374 return;
375 }
376 } else {
377 switch (topLevelType) {
378 case topLevelTypes.topPaste:
379 // If a paste event occurs after a keypress, throw out the input
380 // chars. Paste events should not lead to BeforeInput events.
381 fallbackChars = null;
382 break;
383 case topLevelTypes.topKeyPress:
384 /**
385 * As of v27, Firefox may fire keypress events even when no character
386 * will be inserted. A few possibilities:
387 *
388 * - `which` is `0`. Arrow keys, Esc key, etc.
389 *
390 * - `which` is the pressed key code, but no char is available.
391 * Ex: 'AltGr + d` in Polish. There is no modified character for
392 * this key combination and no character is inserted into the
393 * document, but FF fires the keypress for char code `100` anyway.
394 * No `input` event will occur.
395 *
396 * - `which` is the pressed key code, but a command combination is
397 * being used. Ex: `Cmd+C`. No character is inserted, and no
398 * `input` event will occur.
399 */
400 if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
401 fallbackChars = String.fromCharCode(nativeEvent.which);
402 }
403 break;
404 case topLevelTypes.topCompositionEnd:
405 fallbackChars = nativeEvent.data;
406 break;
407 }
408
409 // If no changes have occurred to the fallback string, no relevant
410 // event has fired and we're done.
411 if (fallbackChars === null) {
412 return;
413 }
414
415 chars = fallbackChars;
416 }
417
418 // If no characters are being inserted, no BeforeInput event should
419 // be fired.
420 if (!chars) {
421 return;
422 }
423
424 var event = SyntheticInputEvent.getPooled(
425 eventTypes.beforeInput,
426 topLevelTargetID,
427 nativeEvent
428 );
429
430 event.data = chars;
431 fallbackChars = null;
432 EventPropagators.accumulateTwoPhaseDispatches(event);
433 return event;
434 }
435};
436
437module.exports = BeforeInputEventPlugin;
438
439},{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./SyntheticInputEvent":89,"./keyOf":133}],4:[function(_dereq_,module,exports){
440/**
441 * Copyright 2013-2014, Facebook, Inc.
442 * All rights reserved.
443 *
444 * This source code is licensed under the BSD-style license found in the
445 * LICENSE file in the root directory of this source tree. An additional grant
446 * of patent rights can be found in the PATENTS file in the same directory.
447 *
448 * @providesModule CSSProperty
449 */
450
451"use strict";
452
453/**
454 * CSS properties which accept numbers but are not in units of "px".
455 */
456var isUnitlessNumber = {
457 columnCount: true,
458 flex: true,
459 flexGrow: true,
460 flexShrink: true,
461 fontWeight: true,
462 lineClamp: true,
463 lineHeight: true,
464 opacity: true,
465 order: true,
466 orphans: true,
467 widows: true,
468 zIndex: true,
469 zoom: true,
470
471 // SVG-related properties
472 fillOpacity: true,
473 strokeOpacity: true
474};
475
476/**
477 * @param {string} prefix vendor-specific prefix, eg: Webkit
478 * @param {string} key style name, eg: transitionDuration
479 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
480 * WebkitTransitionDuration
481 */
482function prefixKey(prefix, key) {
483 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
484}
485
486/**
487 * Support style names that may come passed in prefixed by adding permutations
488 * of vendor prefixes.
489 */
490var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
491
492// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
493// infinite loop, because it iterates over the newly added props too.
494Object.keys(isUnitlessNumber).forEach(function(prop) {
495 prefixes.forEach(function(prefix) {
496 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
497 });
498});
499
500/**
501 * Most style properties can be unset by doing .style[prop] = '' but IE8
502 * doesn't like doing that with shorthand properties so for the properties that
503 * IE8 breaks on, which are listed here, we instead unset each of the
504 * individual properties. See http://bugs.jquery.com/ticket/12385.
505 * The 4-value 'clock' properties like margin, padding, border-width seem to
506 * behave without any problems. Curiously, list-style works too without any
507 * special prodding.
508 */
509var shorthandPropertyExpansions = {
510 background: {
511 backgroundImage: true,
512 backgroundPosition: true,
513 backgroundRepeat: true,
514 backgroundColor: true
515 },
516 border: {
517 borderWidth: true,
518 borderStyle: true,
519 borderColor: true
520 },
521 borderBottom: {
522 borderBottomWidth: true,
523 borderBottomStyle: true,
524 borderBottomColor: true
525 },
526 borderLeft: {
527 borderLeftWidth: true,
528 borderLeftStyle: true,
529 borderLeftColor: true
530 },
531 borderRight: {
532 borderRightWidth: true,
533 borderRightStyle: true,
534 borderRightColor: true
535 },
536 borderTop: {
537 borderTopWidth: true,
538 borderTopStyle: true,
539 borderTopColor: true
540 },
541 font: {
542 fontStyle: true,
543 fontVariant: true,
544 fontWeight: true,
545 fontSize: true,
546 lineHeight: true,
547 fontFamily: true
548 }
549};
550
551var CSSProperty = {
552 isUnitlessNumber: isUnitlessNumber,
553 shorthandPropertyExpansions: shorthandPropertyExpansions
554};
555
556module.exports = CSSProperty;
557
558},{}],5:[function(_dereq_,module,exports){
559/**
560 * Copyright 2013-2014, Facebook, Inc.
561 * All rights reserved.
562 *
563 * This source code is licensed under the BSD-style license found in the
564 * LICENSE file in the root directory of this source tree. An additional grant
565 * of patent rights can be found in the PATENTS file in the same directory.
566 *
567 * @providesModule CSSPropertyOperations
568 * @typechecks static-only
569 */
570
571"use strict";
572
573var CSSProperty = _dereq_("./CSSProperty");
574var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
575
576var camelizeStyleName = _dereq_("./camelizeStyleName");
577var dangerousStyleValue = _dereq_("./dangerousStyleValue");
578var hyphenateStyleName = _dereq_("./hyphenateStyleName");
579var memoizeStringOnly = _dereq_("./memoizeStringOnly");
580var warning = _dereq_("./warning");
581
582var processStyleName = memoizeStringOnly(function(styleName) {
583 return hyphenateStyleName(styleName);
584});
585
586var styleFloatAccessor = 'cssFloat';
587if (ExecutionEnvironment.canUseDOM) {
588 // IE8 only supports accessing cssFloat (standard) as styleFloat
589 if (document.documentElement.style.cssFloat === undefined) {
590 styleFloatAccessor = 'styleFloat';
591 }
592}
593
594if ("production" !== "development") {
595 var warnedStyleNames = {};
596
597 var warnHyphenatedStyleName = function(name) {
598 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
599 return;
600 }
601
602 warnedStyleNames[name] = true;
603 ("production" !== "development" ? warning(
604 false,
605 'Unsupported style property ' + name + '. Did you mean ' +
606 camelizeStyleName(name) + '?'
607 ) : null);
608 };
609}
610
611/**
612 * Operations for dealing with CSS properties.
613 */
614var CSSPropertyOperations = {
615
616 /**
617 * Serializes a mapping of style properties for use as inline styles:
618 *
619 * > createMarkupForStyles({width: '200px', height: 0})
620 * "width:200px;height:0;"
621 *
622 * Undefined values are ignored so that declarative programming is easier.
623 * The result should be HTML-escaped before insertion into the DOM.
624 *
625 * @param {object} styles
626 * @return {?string}
627 */
628 createMarkupForStyles: function(styles) {
629 var serialized = '';
630 for (var styleName in styles) {
631 if (!styles.hasOwnProperty(styleName)) {
632 continue;
633 }
634 if ("production" !== "development") {
635 if (styleName.indexOf('-') > -1) {
636 warnHyphenatedStyleName(styleName);
637 }
638 }
639 var styleValue = styles[styleName];
640 if (styleValue != null) {
641 serialized += processStyleName(styleName) + ':';
642 serialized += dangerousStyleValue(styleName, styleValue) + ';';
643 }
644 }
645 return serialized || null;
646 },
647
648 /**
649 * Sets the value for multiple styles on a node. If a value is specified as
650 * '' (empty string), the corresponding style property will be unset.
651 *
652 * @param {DOMElement} node
653 * @param {object} styles
654 */
655 setValueForStyles: function(node, styles) {
656 var style = node.style;
657 for (var styleName in styles) {
658 if (!styles.hasOwnProperty(styleName)) {
659 continue;
660 }
661 if ("production" !== "development") {
662 if (styleName.indexOf('-') > -1) {
663 warnHyphenatedStyleName(styleName);
664 }
665 }
666 var styleValue = dangerousStyleValue(styleName, styles[styleName]);
667 if (styleName === 'float') {
668 styleName = styleFloatAccessor;
669 }
670 if (styleValue) {
671 style[styleName] = styleValue;
672 } else {
673 var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
674 if (expansion) {
675 // Shorthand property that IE8 won't like unsetting, so unset each
676 // component to placate it
677 for (var individualStyleName in expansion) {
678 style[individualStyleName] = '';
679 }
680 } else {
681 style[styleName] = '';
682 }
683 }
684 }
685 }
686
687};
688
689module.exports = CSSPropertyOperations;
690
691},{"./CSSProperty":4,"./ExecutionEnvironment":22,"./camelizeStyleName":100,"./dangerousStyleValue":105,"./hyphenateStyleName":124,"./memoizeStringOnly":135,"./warning":145}],6:[function(_dereq_,module,exports){
692/**
693 * Copyright 2013-2014, Facebook, Inc.
694 * All rights reserved.
695 *
696 * This source code is licensed under the BSD-style license found in the
697 * LICENSE file in the root directory of this source tree. An additional grant
698 * of patent rights can be found in the PATENTS file in the same directory.
699 *
700 * @providesModule CallbackQueue
701 */
702
703"use strict";
704
705var PooledClass = _dereq_("./PooledClass");
706
707var assign = _dereq_("./Object.assign");
708var invariant = _dereq_("./invariant");
709
710/**
711 * A specialized pseudo-event module to help keep track of components waiting to
712 * be notified when their DOM representations are available for use.
713 *
714 * This implements `PooledClass`, so you should never need to instantiate this.
715 * Instead, use `CallbackQueue.getPooled()`.
716 *
717 * @class ReactMountReady
718 * @implements PooledClass
719 * @internal
720 */
721function CallbackQueue() {
722 this._callbacks = null;
723 this._contexts = null;
724}
725
726assign(CallbackQueue.prototype, {
727
728 /**
729 * Enqueues a callback to be invoked when `notifyAll` is invoked.
730 *
731 * @param {function} callback Invoked when `notifyAll` is invoked.
732 * @param {?object} context Context to call `callback` with.
733 * @internal
734 */
735 enqueue: function(callback, context) {
736 this._callbacks = this._callbacks || [];
737 this._contexts = this._contexts || [];
738 this._callbacks.push(callback);
739 this._contexts.push(context);
740 },
741
742 /**
743 * Invokes all enqueued callbacks and clears the queue. This is invoked after
744 * the DOM representation of a component has been created or updated.
745 *
746 * @internal
747 */
748 notifyAll: function() {
749 var callbacks = this._callbacks;
750 var contexts = this._contexts;
751 if (callbacks) {
752 ("production" !== "development" ? invariant(
753 callbacks.length === contexts.length,
754 "Mismatched list of contexts in callback queue"
755 ) : invariant(callbacks.length === contexts.length));
756 this._callbacks = null;
757 this._contexts = null;
758 for (var i = 0, l = callbacks.length; i < l; i++) {
759 callbacks[i].call(contexts[i]);
760 }
761 callbacks.length = 0;
762 contexts.length = 0;
763 }
764 },
765
766 /**
767 * Resets the internal queue.
768 *
769 * @internal
770 */
771 reset: function() {
772 this._callbacks = null;
773 this._contexts = null;
774 },
775
776 /**
777 * `PooledClass` looks for this.
778 */
779 destructor: function() {
780 this.reset();
781 }
782
783});
784
785PooledClass.addPoolingTo(CallbackQueue);
786
787module.exports = CallbackQueue;
788
789},{"./Object.assign":27,"./PooledClass":28,"./invariant":126}],7:[function(_dereq_,module,exports){
790/**
791 * Copyright 2013-2014, Facebook, Inc.
792 * All rights reserved.
793 *
794 * This source code is licensed under the BSD-style license found in the
795 * LICENSE file in the root directory of this source tree. An additional grant
796 * of patent rights can be found in the PATENTS file in the same directory.
797 *
798 * @providesModule ChangeEventPlugin
799 */
800
801"use strict";
802
803var EventConstants = _dereq_("./EventConstants");
804var EventPluginHub = _dereq_("./EventPluginHub");
805var EventPropagators = _dereq_("./EventPropagators");
806var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
807var ReactUpdates = _dereq_("./ReactUpdates");
808var SyntheticEvent = _dereq_("./SyntheticEvent");
809
810var isEventSupported = _dereq_("./isEventSupported");
811var isTextInputElement = _dereq_("./isTextInputElement");
812var keyOf = _dereq_("./keyOf");
813
814var topLevelTypes = EventConstants.topLevelTypes;
815
816var eventTypes = {
817 change: {
818 phasedRegistrationNames: {
819 bubbled: keyOf({onChange: null}),
820 captured: keyOf({onChangeCapture: null})
821 },
822 dependencies: [
823 topLevelTypes.topBlur,
824 topLevelTypes.topChange,
825 topLevelTypes.topClick,
826 topLevelTypes.topFocus,
827 topLevelTypes.topInput,
828 topLevelTypes.topKeyDown,
829 topLevelTypes.topKeyUp,
830 topLevelTypes.topSelectionChange
831 ]
832 }
833};
834
835/**
836 * For IE shims
837 */
838var activeElement = null;
839var activeElementID = null;
840var activeElementValue = null;
841var activeElementValueProp = null;
842
843/**
844 * SECTION: handle `change` event
845 */
846function shouldUseChangeEvent(elem) {
847 return (
848 elem.nodeName === 'SELECT' ||
849 (elem.nodeName === 'INPUT' && elem.type === 'file')
850 );
851}
852
853var doesChangeEventBubble = false;
854if (ExecutionEnvironment.canUseDOM) {
855 // See `handleChange` comment below
856 doesChangeEventBubble = isEventSupported('change') && (
857 !('documentMode' in document) || document.documentMode > 8
858 );
859}
860
861function manualDispatchChangeEvent(nativeEvent) {
862 var event = SyntheticEvent.getPooled(
863 eventTypes.change,
864 activeElementID,
865 nativeEvent
866 );
867 EventPropagators.accumulateTwoPhaseDispatches(event);
868
869 // If change and propertychange bubbled, we'd just bind to it like all the
870 // other events and have it go through ReactBrowserEventEmitter. Since it
871 // doesn't, we manually listen for the events and so we have to enqueue and
872 // process the abstract event manually.
873 //
874 // Batching is necessary here in order to ensure that all event handlers run
875 // before the next rerender (including event handlers attached to ancestor
876 // elements instead of directly on the input). Without this, controlled
877 // components don't work properly in conjunction with event bubbling because
878 // the component is rerendered and the value reverted before all the event
879 // handlers can run. See https://github.com/facebook/react/issues/708.
880 ReactUpdates.batchedUpdates(runEventInBatch, event);
881}
882
883function runEventInBatch(event) {
884 EventPluginHub.enqueueEvents(event);
885 EventPluginHub.processEventQueue();
886}
887
888function startWatchingForChangeEventIE8(target, targetID) {
889 activeElement = target;
890 activeElementID = targetID;
891 activeElement.attachEvent('onchange', manualDispatchChangeEvent);
892}
893
894function stopWatchingForChangeEventIE8() {
895 if (!activeElement) {
896 return;
897 }
898 activeElement.detachEvent('onchange', manualDispatchChangeEvent);
899 activeElement = null;
900 activeElementID = null;
901}
902
903function getTargetIDForChangeEvent(
904 topLevelType,
905 topLevelTarget,
906 topLevelTargetID) {
907 if (topLevelType === topLevelTypes.topChange) {
908 return topLevelTargetID;
909 }
910}
911function handleEventsForChangeEventIE8(
912 topLevelType,
913 topLevelTarget,
914 topLevelTargetID) {
915 if (topLevelType === topLevelTypes.topFocus) {
916 // stopWatching() should be a noop here but we call it just in case we
917 // missed a blur event somehow.
918 stopWatchingForChangeEventIE8();
919 startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
920 } else if (topLevelType === topLevelTypes.topBlur) {
921 stopWatchingForChangeEventIE8();
922 }
923}
924
925
926/**
927 * SECTION: handle `input` event
928 */
929var isInputEventSupported = false;
930if (ExecutionEnvironment.canUseDOM) {
931 // IE9 claims to support the input event but fails to trigger it when
932 // deleting text, so we ignore its input events
933 isInputEventSupported = isEventSupported('input') && (
934 !('documentMode' in document) || document.documentMode > 9
935 );
936}
937
938/**
939 * (For old IE.) Replacement getter/setter for the `value` property that gets
940 * set on the active element.
941 */
942var newValueProp = {
943 get: function() {
944 return activeElementValueProp.get.call(this);
945 },
946 set: function(val) {
947 // Cast to a string so we can do equality checks.
948 activeElementValue = '' + val;
949 activeElementValueProp.set.call(this, val);
950 }
951};
952
953/**
954 * (For old IE.) Starts tracking propertychange events on the passed-in element
955 * and override the value property so that we can distinguish user events from
956 * value changes in JS.
957 */
958function startWatchingForValueChange(target, targetID) {
959 activeElement = target;
960 activeElementID = targetID;
961 activeElementValue = target.value;
962 activeElementValueProp = Object.getOwnPropertyDescriptor(
963 target.constructor.prototype,
964 'value'
965 );
966
967 Object.defineProperty(activeElement, 'value', newValueProp);
968 activeElement.attachEvent('onpropertychange', handlePropertyChange);
969}
970
971/**
972 * (For old IE.) Removes the event listeners from the currently-tracked element,
973 * if any exists.
974 */
975function stopWatchingForValueChange() {
976 if (!activeElement) {
977 return;
978 }
979
980 // delete restores the original property definition
981 delete activeElement.value;
982 activeElement.detachEvent('onpropertychange', handlePropertyChange);
983
984 activeElement = null;
985 activeElementID = null;
986 activeElementValue = null;
987 activeElementValueProp = null;
988}
989
990/**
991 * (For old IE.) Handles a propertychange event, sending a `change` event if
992 * the value of the active element has changed.
993 */
994function handlePropertyChange(nativeEvent) {
995 if (nativeEvent.propertyName !== 'value') {
996 return;
997 }
998 var value = nativeEvent.srcElement.value;
999 if (value === activeElementValue) {
1000 return;
1001 }
1002 activeElementValue = value;
1003
1004 manualDispatchChangeEvent(nativeEvent);
1005}
1006
1007/**
1008 * If a `change` event should be fired, returns the target's ID.
1009 */
1010function getTargetIDForInputEvent(
1011 topLevelType,
1012 topLevelTarget,
1013 topLevelTargetID) {
1014 if (topLevelType === topLevelTypes.topInput) {
1015 // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
1016 // what we want so fall through here and trigger an abstract event
1017 return topLevelTargetID;
1018 }
1019}
1020
1021// For IE8 and IE9.
1022function handleEventsForInputEventIE(
1023 topLevelType,
1024 topLevelTarget,
1025 topLevelTargetID) {
1026 if (topLevelType === topLevelTypes.topFocus) {
1027 // In IE8, we can capture almost all .value changes by adding a
1028 // propertychange handler and looking for events with propertyName
1029 // equal to 'value'
1030 // In IE9, propertychange fires for most input events but is buggy and
1031 // doesn't fire when text is deleted, but conveniently, selectionchange
1032 // appears to fire in all of the remaining cases so we catch those and
1033 // forward the event if the value has changed
1034 // In either case, we don't want to call the event handler if the value
1035 // is changed from JS so we redefine a setter for `.value` that updates
1036 // our activeElementValue variable, allowing us to ignore those changes
1037 //
1038 // stopWatching() should be a noop here but we call it just in case we
1039 // missed a blur event somehow.
1040 stopWatchingForValueChange();
1041 startWatchingForValueChange(topLevelTarget, topLevelTargetID);
1042 } else if (topLevelType === topLevelTypes.topBlur) {
1043 stopWatchingForValueChange();
1044 }
1045}
1046
1047// For IE8 and IE9.
1048function getTargetIDForInputEventIE(
1049 topLevelType,
1050 topLevelTarget,
1051 topLevelTargetID) {
1052 if (topLevelType === topLevelTypes.topSelectionChange ||
1053 topLevelType === topLevelTypes.topKeyUp ||
1054 topLevelType === topLevelTypes.topKeyDown) {
1055 // On the selectionchange event, the target is just document which isn't
1056 // helpful for us so just check activeElement instead.
1057 //
1058 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
1059 // propertychange on the first input event after setting `value` from a
1060 // script and fires only keydown, keypress, keyup. Catching keyup usually
1061 // gets it and catching keydown lets us fire an event for the first
1062 // keystroke if user does a key repeat (it'll be a little delayed: right
1063 // before the second keystroke). Other input methods (e.g., paste) seem to
1064 // fire selectionchange normally.
1065 if (activeElement && activeElement.value !== activeElementValue) {
1066 activeElementValue = activeElement.value;
1067 return activeElementID;
1068 }
1069 }
1070}
1071
1072
1073/**
1074 * SECTION: handle `click` event
1075 */
1076function shouldUseClickEvent(elem) {
1077 // Use the `click` event to detect changes to checkbox and radio inputs.
1078 // This approach works across all browsers, whereas `change` does not fire
1079 // until `blur` in IE8.
1080 return (
1081 elem.nodeName === 'INPUT' &&
1082 (elem.type === 'checkbox' || elem.type === 'radio')
1083 );
1084}
1085
1086function getTargetIDForClickEvent(
1087 topLevelType,
1088 topLevelTarget,
1089 topLevelTargetID) {
1090 if (topLevelType === topLevelTypes.topClick) {
1091 return topLevelTargetID;
1092 }
1093}
1094
1095/**
1096 * This plugin creates an `onChange` event that normalizes change events
1097 * across form elements. This event fires at a time when it's possible to
1098 * change the element's value without seeing a flicker.
1099 *
1100 * Supported elements are:
1101 * - input (see `isTextInputElement`)
1102 * - textarea
1103 * - select
1104 */
1105var ChangeEventPlugin = {
1106
1107 eventTypes: eventTypes,
1108
1109 /**
1110 * @param {string} topLevelType Record from `EventConstants`.
1111 * @param {DOMEventTarget} topLevelTarget The listening component root node.
1112 * @param {string} topLevelTargetID ID of `topLevelTarget`.
1113 * @param {object} nativeEvent Native browser event.
1114 * @return {*} An accumulation of synthetic events.
1115 * @see {EventPluginHub.extractEvents}
1116 */
1117 extractEvents: function(
1118 topLevelType,
1119 topLevelTarget,
1120 topLevelTargetID,
1121 nativeEvent) {
1122
1123 var getTargetIDFunc, handleEventFunc;
1124 if (shouldUseChangeEvent(topLevelTarget)) {
1125 if (doesChangeEventBubble) {
1126 getTargetIDFunc = getTargetIDForChangeEvent;
1127 } else {
1128 handleEventFunc = handleEventsForChangeEventIE8;
1129 }
1130 } else if (isTextInputElement(topLevelTarget)) {
1131 if (isInputEventSupported) {
1132 getTargetIDFunc = getTargetIDForInputEvent;
1133 } else {
1134 getTargetIDFunc = getTargetIDForInputEventIE;
1135 handleEventFunc = handleEventsForInputEventIE;
1136 }
1137 } else if (shouldUseClickEvent(topLevelTarget)) {
1138 getTargetIDFunc = getTargetIDForClickEvent;
1139 }
1140
1141 if (getTargetIDFunc) {
1142 var targetID = getTargetIDFunc(
1143 topLevelType,
1144 topLevelTarget,
1145 topLevelTargetID
1146 );
1147 if (targetID) {
1148 var event = SyntheticEvent.getPooled(
1149 eventTypes.change,
1150 targetID,
1151 nativeEvent
1152 );
1153 EventPropagators.accumulateTwoPhaseDispatches(event);
1154 return event;
1155 }
1156 }
1157
1158 if (handleEventFunc) {
1159 handleEventFunc(
1160 topLevelType,
1161 topLevelTarget,
1162 topLevelTargetID
1163 );
1164 }
1165 }
1166
1167};
1168
1169module.exports = ChangeEventPlugin;
1170
1171},{"./EventConstants":16,"./EventPluginHub":18,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactUpdates":79,"./SyntheticEvent":87,"./isEventSupported":127,"./isTextInputElement":129,"./keyOf":133}],8:[function(_dereq_,module,exports){
1172/**
1173 * Copyright 2013-2014, Facebook, Inc.
1174 * All rights reserved.
1175 *
1176 * This source code is licensed under the BSD-style license found in the
1177 * LICENSE file in the root directory of this source tree. An additional grant
1178 * of patent rights can be found in the PATENTS file in the same directory.
1179 *
1180 * @providesModule ClientReactRootIndex
1181 * @typechecks
1182 */
1183
1184"use strict";
1185
1186var nextReactRootIndex = 0;
1187
1188var ClientReactRootIndex = {
1189 createReactRootIndex: function() {
1190 return nextReactRootIndex++;
1191 }
1192};
1193
1194module.exports = ClientReactRootIndex;
1195
1196},{}],9:[function(_dereq_,module,exports){
1197/**
1198 * Copyright 2013-2014, Facebook, Inc.
1199 * All rights reserved.
1200 *
1201 * This source code is licensed under the BSD-style license found in the
1202 * LICENSE file in the root directory of this source tree. An additional grant
1203 * of patent rights can be found in the PATENTS file in the same directory.
1204 *
1205 * @providesModule CompositionEventPlugin
1206 * @typechecks static-only
1207 */
1208
1209"use strict";
1210
1211var EventConstants = _dereq_("./EventConstants");
1212var EventPropagators = _dereq_("./EventPropagators");
1213var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
1214var ReactInputSelection = _dereq_("./ReactInputSelection");
1215var SyntheticCompositionEvent = _dereq_("./SyntheticCompositionEvent");
1216
1217var getTextContentAccessor = _dereq_("./getTextContentAccessor");
1218var keyOf = _dereq_("./keyOf");
1219
1220var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
1221var START_KEYCODE = 229;
1222
1223var useCompositionEvent = (
1224 ExecutionEnvironment.canUseDOM &&
1225 'CompositionEvent' in window
1226);
1227
1228// In IE9+, we have access to composition events, but the data supplied
1229// by the native compositionend event may be incorrect. In Korean, for example,
1230// the compositionend event contains only one character regardless of
1231// how many characters have been composed since compositionstart.
1232// We therefore use the fallback data while still using the native
1233// events as triggers.
1234var useFallbackData = (
1235 !useCompositionEvent ||
1236 (
1237 'documentMode' in document &&
1238 document.documentMode > 8 &&
1239 document.documentMode <= 11
1240 )
1241);
1242
1243var topLevelTypes = EventConstants.topLevelTypes;
1244var currentComposition = null;
1245
1246// Events and their corresponding property names.
1247var eventTypes = {
1248 compositionEnd: {
1249 phasedRegistrationNames: {
1250 bubbled: keyOf({onCompositionEnd: null}),
1251 captured: keyOf({onCompositionEndCapture: null})
1252 },
1253 dependencies: [
1254 topLevelTypes.topBlur,
1255 topLevelTypes.topCompositionEnd,
1256 topLevelTypes.topKeyDown,
1257 topLevelTypes.topKeyPress,
1258 topLevelTypes.topKeyUp,
1259 topLevelTypes.topMouseDown
1260 ]
1261 },
1262 compositionStart: {
1263 phasedRegistrationNames: {
1264 bubbled: keyOf({onCompositionStart: null}),
1265 captured: keyOf({onCompositionStartCapture: null})
1266 },
1267 dependencies: [
1268 topLevelTypes.topBlur,
1269 topLevelTypes.topCompositionStart,
1270 topLevelTypes.topKeyDown,
1271 topLevelTypes.topKeyPress,
1272 topLevelTypes.topKeyUp,
1273 topLevelTypes.topMouseDown
1274 ]
1275 },
1276 compositionUpdate: {
1277 phasedRegistrationNames: {
1278 bubbled: keyOf({onCompositionUpdate: null}),
1279 captured: keyOf({onCompositionUpdateCapture: null})
1280 },
1281 dependencies: [
1282 topLevelTypes.topBlur,
1283 topLevelTypes.topCompositionUpdate,
1284 topLevelTypes.topKeyDown,
1285 topLevelTypes.topKeyPress,
1286 topLevelTypes.topKeyUp,
1287 topLevelTypes.topMouseDown
1288 ]
1289 }
1290};
1291
1292/**
1293 * Translate native top level events into event types.
1294 *
1295 * @param {string} topLevelType
1296 * @return {object}
1297 */
1298function getCompositionEventType(topLevelType) {
1299 switch (topLevelType) {
1300 case topLevelTypes.topCompositionStart:
1301 return eventTypes.compositionStart;
1302 case topLevelTypes.topCompositionEnd:
1303 return eventTypes.compositionEnd;
1304 case topLevelTypes.topCompositionUpdate:
1305 return eventTypes.compositionUpdate;
1306 }
1307}
1308
1309/**
1310 * Does our fallback best-guess model think this event signifies that
1311 * composition has begun?
1312 *
1313 * @param {string} topLevelType
1314 * @param {object} nativeEvent
1315 * @return {boolean}
1316 */
1317function isFallbackStart(topLevelType, nativeEvent) {
1318 return (
1319 topLevelType === topLevelTypes.topKeyDown &&
1320 nativeEvent.keyCode === START_KEYCODE
1321 );
1322}
1323
1324/**
1325 * Does our fallback mode think that this event is the end of composition?
1326 *
1327 * @param {string} topLevelType
1328 * @param {object} nativeEvent
1329 * @return {boolean}
1330 */
1331function isFallbackEnd(topLevelType, nativeEvent) {
1332 switch (topLevelType) {
1333 case topLevelTypes.topKeyUp:
1334 // Command keys insert or clear IME input.
1335 return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
1336 case topLevelTypes.topKeyDown:
1337 // Expect IME keyCode on each keydown. If we get any other
1338 // code we must have exited earlier.
1339 return (nativeEvent.keyCode !== START_KEYCODE);
1340 case topLevelTypes.topKeyPress:
1341 case topLevelTypes.topMouseDown:
1342 case topLevelTypes.topBlur:
1343 // Events are not possible without cancelling IME.
1344 return true;
1345 default:
1346 return false;
1347 }
1348}
1349
1350/**
1351 * Helper class stores information about selection and document state
1352 * so we can figure out what changed at a later date.
1353 *
1354 * @param {DOMEventTarget} root
1355 */
1356function FallbackCompositionState(root) {
1357 this.root = root;
1358 this.startSelection = ReactInputSelection.getSelection(root);
1359 this.startValue = this.getText();
1360}
1361
1362/**
1363 * Get current text of input.
1364 *
1365 * @return {string}
1366 */
1367FallbackCompositionState.prototype.getText = function() {
1368 return this.root.value || this.root[getTextContentAccessor()];
1369};
1370
1371/**
1372 * Text that has changed since the start of composition.
1373 *
1374 * @return {string}
1375 */
1376FallbackCompositionState.prototype.getData = function() {
1377 var endValue = this.getText();
1378 var prefixLength = this.startSelection.start;
1379 var suffixLength = this.startValue.length - this.startSelection.end;
1380
1381 return endValue.substr(
1382 prefixLength,
1383 endValue.length - suffixLength - prefixLength
1384 );
1385};
1386
1387/**
1388 * This plugin creates `onCompositionStart`, `onCompositionUpdate` and
1389 * `onCompositionEnd` events on inputs, textareas and contentEditable
1390 * nodes.
1391 */
1392var CompositionEventPlugin = {
1393
1394 eventTypes: eventTypes,
1395
1396 /**
1397 * @param {string} topLevelType Record from `EventConstants`.
1398 * @param {DOMEventTarget} topLevelTarget The listening component root node.
1399 * @param {string} topLevelTargetID ID of `topLevelTarget`.
1400 * @param {object} nativeEvent Native browser event.
1401 * @return {*} An accumulation of synthetic events.
1402 * @see {EventPluginHub.extractEvents}
1403 */
1404 extractEvents: function(
1405 topLevelType,
1406 topLevelTarget,
1407 topLevelTargetID,
1408 nativeEvent) {
1409
1410 var eventType;
1411 var data;
1412
1413 if (useCompositionEvent) {
1414 eventType = getCompositionEventType(topLevelType);
1415 } else if (!currentComposition) {
1416 if (isFallbackStart(topLevelType, nativeEvent)) {
1417 eventType = eventTypes.compositionStart;
1418 }
1419 } else if (isFallbackEnd(topLevelType, nativeEvent)) {
1420 eventType = eventTypes.compositionEnd;
1421 }
1422
1423 if (useFallbackData) {
1424 // The current composition is stored statically and must not be
1425 // overwritten while composition continues.
1426 if (!currentComposition && eventType === eventTypes.compositionStart) {
1427 currentComposition = new FallbackCompositionState(topLevelTarget);
1428 } else if (eventType === eventTypes.compositionEnd) {
1429 if (currentComposition) {
1430 data = currentComposition.getData();
1431 currentComposition = null;
1432 }
1433 }
1434 }
1435
1436 if (eventType) {
1437 var event = SyntheticCompositionEvent.getPooled(
1438 eventType,
1439 topLevelTargetID,
1440 nativeEvent
1441 );
1442 if (data) {
1443 // Inject data generated from fallback path into the synthetic event.
1444 // This matches the property of native CompositionEventInterface.
1445 event.data = data;
1446 }
1447 EventPropagators.accumulateTwoPhaseDispatches(event);
1448 return event;
1449 }
1450 }
1451};
1452
1453module.exports = CompositionEventPlugin;
1454
1455},{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactInputSelection":59,"./SyntheticCompositionEvent":85,"./getTextContentAccessor":121,"./keyOf":133}],10:[function(_dereq_,module,exports){
1456/**
1457 * Copyright 2013-2014, Facebook, Inc.
1458 * All rights reserved.
1459 *
1460 * This source code is licensed under the BSD-style license found in the
1461 * LICENSE file in the root directory of this source tree. An additional grant
1462 * of patent rights can be found in the PATENTS file in the same directory.
1463 *
1464 * @providesModule DOMChildrenOperations
1465 * @typechecks static-only
1466 */
1467
1468"use strict";
1469
1470var Danger = _dereq_("./Danger");
1471var ReactMultiChildUpdateTypes = _dereq_("./ReactMultiChildUpdateTypes");
1472
1473var getTextContentAccessor = _dereq_("./getTextContentAccessor");
1474var invariant = _dereq_("./invariant");
1475
1476/**
1477 * The DOM property to use when setting text content.
1478 *
1479 * @type {string}
1480 * @private
1481 */
1482var textContentAccessor = getTextContentAccessor();
1483
1484/**
1485 * Inserts `childNode` as a child of `parentNode` at the `index`.
1486 *
1487 * @param {DOMElement} parentNode Parent node in which to insert.
1488 * @param {DOMElement} childNode Child node to insert.
1489 * @param {number} index Index at which to insert the child.
1490 * @internal
1491 */
1492function insertChildAt(parentNode, childNode, index) {
1493 // By exploiting arrays returning `undefined` for an undefined index, we can
1494 // rely exclusively on `insertBefore(node, null)` instead of also using
1495 // `appendChild(node)`. However, using `undefined` is not allowed by all
1496 // browsers so we must replace it with `null`.
1497 parentNode.insertBefore(
1498 childNode,
1499 parentNode.childNodes[index] || null
1500 );
1501}
1502
1503var updateTextContent;
1504if (textContentAccessor === 'textContent') {
1505 /**
1506 * Sets the text content of `node` to `text`.
1507 *
1508 * @param {DOMElement} node Node to change
1509 * @param {string} text New text content
1510 */
1511 updateTextContent = function(node, text) {
1512 node.textContent = text;
1513 };
1514} else {
1515 /**
1516 * Sets the text content of `node` to `text`.
1517 *
1518 * @param {DOMElement} node Node to change
1519 * @param {string} text New text content
1520 */
1521 updateTextContent = function(node, text) {
1522 // In order to preserve newlines correctly, we can't use .innerText to set
1523 // the contents (see #1080), so we empty the element then append a text node
1524 while (node.firstChild) {
1525 node.removeChild(node.firstChild);
1526 }
1527 if (text) {
1528 var doc = node.ownerDocument || document;
1529 node.appendChild(doc.createTextNode(text));
1530 }
1531 };
1532}
1533
1534/**
1535 * Operations for updating with DOM children.
1536 */
1537var DOMChildrenOperations = {
1538
1539 dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
1540
1541 updateTextContent: updateTextContent,
1542
1543 /**
1544 * Updates a component's children by processing a series of updates. The
1545 * update configurations are each expected to have a `parentNode` property.
1546 *
1547 * @param {array<object>} updates List of update configurations.
1548 * @param {array<string>} markupList List of markup strings.
1549 * @internal
1550 */
1551 processUpdates: function(updates, markupList) {
1552 var update;
1553 // Mapping from parent IDs to initial child orderings.
1554 var initialChildren = null;
1555 // List of children that will be moved or removed.
1556 var updatedChildren = null;
1557
1558 for (var i = 0; update = updates[i]; i++) {
1559 if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
1560 update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
1561 var updatedIndex = update.fromIndex;
1562 var updatedChild = update.parentNode.childNodes[updatedIndex];
1563 var parentID = update.parentID;
1564
1565 ("production" !== "development" ? invariant(
1566 updatedChild,
1567 'processUpdates(): Unable to find child %s of element. This ' +
1568 'probably means the DOM was unexpectedly mutated (e.g., by the ' +
1569 'browser), usually due to forgetting a <tbody> when using tables, ' +
1570 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements '+
1571 'in an <svg> parent. Try inspecting the child nodes of the element ' +
1572 'with React ID `%s`.',
1573 updatedIndex,
1574 parentID
1575 ) : invariant(updatedChild));
1576
1577 initialChildren = initialChildren || {};
1578 initialChildren[parentID] = initialChildren[parentID] || [];
1579 initialChildren[parentID][updatedIndex] = updatedChild;
1580
1581 updatedChildren = updatedChildren || [];
1582 updatedChildren.push(updatedChild);
1583 }
1584 }
1585
1586 var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
1587
1588 // Remove updated children first so that `toIndex` is consistent.
1589 if (updatedChildren) {
1590 for (var j = 0; j < updatedChildren.length; j++) {
1591 updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
1592 }
1593 }
1594
1595 for (var k = 0; update = updates[k]; k++) {
1596 switch (update.type) {
1597 case ReactMultiChildUpdateTypes.INSERT_MARKUP:
1598 insertChildAt(
1599 update.parentNode,
1600 renderedMarkup[update.markupIndex],
1601 update.toIndex
1602 );
1603 break;
1604 case ReactMultiChildUpdateTypes.MOVE_EXISTING:
1605 insertChildAt(
1606 update.parentNode,
1607 initialChildren[update.parentID][update.fromIndex],
1608 update.toIndex
1609 );
1610 break;
1611 case ReactMultiChildUpdateTypes.TEXT_CONTENT:
1612 updateTextContent(
1613 update.parentNode,
1614 update.textContent
1615 );
1616 break;
1617 case ReactMultiChildUpdateTypes.REMOVE_NODE:
1618 // Already removed by the for-loop above.
1619 break;
1620 }
1621 }
1622 }
1623
1624};
1625
1626module.exports = DOMChildrenOperations;
1627
1628},{"./Danger":13,"./ReactMultiChildUpdateTypes":65,"./getTextContentAccessor":121,"./invariant":126}],11:[function(_dereq_,module,exports){
1629/**
1630 * Copyright 2013-2014, Facebook, Inc.
1631 * All rights reserved.
1632 *
1633 * This source code is licensed under the BSD-style license found in the
1634 * LICENSE file in the root directory of this source tree. An additional grant
1635 * of patent rights can be found in the PATENTS file in the same directory.
1636 *
1637 * @providesModule DOMProperty
1638 * @typechecks static-only
1639 */
1640
1641/*jslint bitwise: true */
1642
1643"use strict";
1644
1645var invariant = _dereq_("./invariant");
1646
1647function checkMask(value, bitmask) {
1648 return (value & bitmask) === bitmask;
1649}
1650
1651var DOMPropertyInjection = {
1652 /**
1653 * Mapping from normalized, camelcased property names to a configuration that
1654 * specifies how the associated DOM property should be accessed or rendered.
1655 */
1656 MUST_USE_ATTRIBUTE: 0x1,
1657 MUST_USE_PROPERTY: 0x2,
1658 HAS_SIDE_EFFECTS: 0x4,
1659 HAS_BOOLEAN_VALUE: 0x8,
1660 HAS_NUMERIC_VALUE: 0x10,
1661 HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
1662 HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
1663
1664 /**
1665 * Inject some specialized knowledge about the DOM. This takes a config object
1666 * with the following properties:
1667 *
1668 * isCustomAttribute: function that given an attribute name will return true
1669 * if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
1670 * attributes where it's impossible to enumerate all of the possible
1671 * attribute names,
1672 *
1673 * Properties: object mapping DOM property name to one of the
1674 * DOMPropertyInjection constants or null. If your attribute isn't in here,
1675 * it won't get written to the DOM.
1676 *
1677 * DOMAttributeNames: object mapping React attribute name to the DOM
1678 * attribute name. Attribute names not specified use the **lowercase**
1679 * normalized name.
1680 *
1681 * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
1682 * Property names not specified use the normalized name.
1683 *
1684 * DOMMutationMethods: Properties that require special mutation methods. If
1685 * `value` is undefined, the mutation method should unset the property.
1686 *
1687 * @param {object} domPropertyConfig the config as described above.
1688 */
1689 injectDOMPropertyConfig: function(domPropertyConfig) {
1690 var Properties = domPropertyConfig.Properties || {};
1691 var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
1692 var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
1693 var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
1694
1695 if (domPropertyConfig.isCustomAttribute) {
1696 DOMProperty._isCustomAttributeFunctions.push(
1697 domPropertyConfig.isCustomAttribute
1698 );
1699 }
1700
1701 for (var propName in Properties) {
1702 ("production" !== "development" ? invariant(
1703 !DOMProperty.isStandardName.hasOwnProperty(propName),
1704 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
1705 '\'%s\' which has already been injected. You may be accidentally ' +
1706 'injecting the same DOM property config twice, or you may be ' +
1707 'injecting two configs that have conflicting property names.',
1708 propName
1709 ) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
1710
1711 DOMProperty.isStandardName[propName] = true;
1712
1713 var lowerCased = propName.toLowerCase();
1714 DOMProperty.getPossibleStandardName[lowerCased] = propName;
1715
1716 if (DOMAttributeNames.hasOwnProperty(propName)) {
1717 var attributeName = DOMAttributeNames[propName];
1718 DOMProperty.getPossibleStandardName[attributeName] = propName;
1719 DOMProperty.getAttributeName[propName] = attributeName;
1720 } else {
1721 DOMProperty.getAttributeName[propName] = lowerCased;
1722 }
1723
1724 DOMProperty.getPropertyName[propName] =
1725 DOMPropertyNames.hasOwnProperty(propName) ?
1726 DOMPropertyNames[propName] :
1727 propName;
1728
1729 if (DOMMutationMethods.hasOwnProperty(propName)) {
1730 DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
1731 } else {
1732 DOMProperty.getMutationMethod[propName] = null;
1733 }
1734
1735 var propConfig = Properties[propName];
1736 DOMProperty.mustUseAttribute[propName] =
1737 checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
1738 DOMProperty.mustUseProperty[propName] =
1739 checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
1740 DOMProperty.hasSideEffects[propName] =
1741 checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
1742 DOMProperty.hasBooleanValue[propName] =
1743 checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
1744 DOMProperty.hasNumericValue[propName] =
1745 checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
1746 DOMProperty.hasPositiveNumericValue[propName] =
1747 checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
1748 DOMProperty.hasOverloadedBooleanValue[propName] =
1749 checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
1750
1751 ("production" !== "development" ? invariant(
1752 !DOMProperty.mustUseAttribute[propName] ||
1753 !DOMProperty.mustUseProperty[propName],
1754 'DOMProperty: Cannot require using both attribute and property: %s',
1755 propName
1756 ) : invariant(!DOMProperty.mustUseAttribute[propName] ||
1757 !DOMProperty.mustUseProperty[propName]));
1758 ("production" !== "development" ? invariant(
1759 DOMProperty.mustUseProperty[propName] ||
1760 !DOMProperty.hasSideEffects[propName],
1761 'DOMProperty: Properties that have side effects must use property: %s',
1762 propName
1763 ) : invariant(DOMProperty.mustUseProperty[propName] ||
1764 !DOMProperty.hasSideEffects[propName]));
1765 ("production" !== "development" ? invariant(
1766 !!DOMProperty.hasBooleanValue[propName] +
1767 !!DOMProperty.hasNumericValue[propName] +
1768 !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
1769 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
1770 'numeric value, but not a combination: %s',
1771 propName
1772 ) : invariant(!!DOMProperty.hasBooleanValue[propName] +
1773 !!DOMProperty.hasNumericValue[propName] +
1774 !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
1775 }
1776 }
1777};
1778var defaultValueCache = {};
1779
1780/**
1781 * DOMProperty exports lookup objects that can be used like functions:
1782 *
1783 * > DOMProperty.isValid['id']
1784 * true
1785 * > DOMProperty.isValid['foobar']
1786 * undefined
1787 *
1788 * Although this may be confusing, it performs better in general.
1789 *
1790 * @see http://jsperf.com/key-exists
1791 * @see http://jsperf.com/key-missing
1792 */
1793var DOMProperty = {
1794
1795 ID_ATTRIBUTE_NAME: 'data-reactid',
1796
1797 /**
1798 * Checks whether a property name is a standard property.
1799 * @type {Object}
1800 */
1801 isStandardName: {},
1802
1803 /**
1804 * Mapping from lowercase property names to the properly cased version, used
1805 * to warn in the case of missing properties.
1806 * @type {Object}
1807 */
1808 getPossibleStandardName: {},
1809
1810 /**
1811 * Mapping from normalized names to attribute names that differ. Attribute
1812 * names are used when rendering markup or with `*Attribute()`.
1813 * @type {Object}
1814 */
1815 getAttributeName: {},
1816
1817 /**
1818 * Mapping from normalized names to properties on DOM node instances.
1819 * (This includes properties that mutate due to external factors.)
1820 * @type {Object}
1821 */
1822 getPropertyName: {},
1823
1824 /**
1825 * Mapping from normalized names to mutation methods. This will only exist if
1826 * mutation cannot be set simply by the property or `setAttribute()`.
1827 * @type {Object}
1828 */
1829 getMutationMethod: {},
1830
1831 /**
1832 * Whether the property must be accessed and mutated as an object property.
1833 * @type {Object}
1834 */
1835 mustUseAttribute: {},
1836
1837 /**
1838 * Whether the property must be accessed and mutated using `*Attribute()`.
1839 * (This includes anything that fails `<propName> in <element>`.)
1840 * @type {Object}
1841 */
1842 mustUseProperty: {},
1843
1844 /**
1845 * Whether or not setting a value causes side effects such as triggering
1846 * resources to be loaded or text selection changes. We must ensure that
1847 * the value is only set if it has changed.
1848 * @type {Object}
1849 */
1850 hasSideEffects: {},
1851
1852 /**
1853 * Whether the property should be removed when set to a falsey value.
1854 * @type {Object}
1855 */
1856 hasBooleanValue: {},
1857
1858 /**
1859 * Whether the property must be numeric or parse as a
1860 * numeric and should be removed when set to a falsey value.
1861 * @type {Object}
1862 */
1863 hasNumericValue: {},
1864
1865 /**
1866 * Whether the property must be positive numeric or parse as a positive
1867 * numeric and should be removed when set to a falsey value.
1868 * @type {Object}
1869 */
1870 hasPositiveNumericValue: {},
1871
1872 /**
1873 * Whether the property can be used as a flag as well as with a value. Removed
1874 * when strictly equal to false; present without a value when strictly equal
1875 * to true; present with a value otherwise.
1876 * @type {Object}
1877 */
1878 hasOverloadedBooleanValue: {},
1879
1880 /**
1881 * All of the isCustomAttribute() functions that have been injected.
1882 */
1883 _isCustomAttributeFunctions: [],
1884
1885 /**
1886 * Checks whether a property name is a custom attribute.
1887 * @method
1888 */
1889 isCustomAttribute: function(attributeName) {
1890 for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
1891 var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
1892 if (isCustomAttributeFn(attributeName)) {
1893 return true;
1894 }
1895 }
1896 return false;
1897 },
1898
1899 /**
1900 * Returns the default property value for a DOM property (i.e., not an
1901 * attribute). Most default values are '' or false, but not all. Worse yet,
1902 * some (in particular, `type`) vary depending on the type of element.
1903 *
1904 * TODO: Is it better to grab all the possible properties when creating an
1905 * element to avoid having to create the same element twice?
1906 */
1907 getDefaultValueForProperty: function(nodeName, prop) {
1908 var nodeDefaults = defaultValueCache[nodeName];
1909 var testElement;
1910 if (!nodeDefaults) {
1911 defaultValueCache[nodeName] = nodeDefaults = {};
1912 }
1913 if (!(prop in nodeDefaults)) {
1914 testElement = document.createElement(nodeName);
1915 nodeDefaults[prop] = testElement[prop];
1916 }
1917 return nodeDefaults[prop];
1918 },
1919
1920 injection: DOMPropertyInjection
1921};
1922
1923module.exports = DOMProperty;
1924
1925},{"./invariant":126}],12:[function(_dereq_,module,exports){
1926/**
1927 * Copyright 2013-2014, Facebook, Inc.
1928 * All rights reserved.
1929 *
1930 * This source code is licensed under the BSD-style license found in the
1931 * LICENSE file in the root directory of this source tree. An additional grant
1932 * of patent rights can be found in the PATENTS file in the same directory.
1933 *
1934 * @providesModule DOMPropertyOperations
1935 * @typechecks static-only
1936 */
1937
1938"use strict";
1939
1940var DOMProperty = _dereq_("./DOMProperty");
1941
1942var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
1943var memoizeStringOnly = _dereq_("./memoizeStringOnly");
1944var warning = _dereq_("./warning");
1945
1946function shouldIgnoreValue(name, value) {
1947 return value == null ||
1948 (DOMProperty.hasBooleanValue[name] && !value) ||
1949 (DOMProperty.hasNumericValue[name] && isNaN(value)) ||
1950 (DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
1951 (DOMProperty.hasOverloadedBooleanValue[name] && value === false);
1952}
1953
1954var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
1955 return escapeTextForBrowser(name) + '="';
1956});
1957
1958if ("production" !== "development") {
1959 var reactProps = {
1960 children: true,
1961 dangerouslySetInnerHTML: true,
1962 key: true,
1963 ref: true
1964 };
1965 var warnedProperties = {};
1966
1967 var warnUnknownProperty = function(name) {
1968 if (reactProps.hasOwnProperty(name) && reactProps[name] ||
1969 warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
1970 return;
1971 }
1972
1973 warnedProperties[name] = true;
1974 var lowerCasedName = name.toLowerCase();
1975
1976 // data-* attributes should be lowercase; suggest the lowercase version
1977 var standardName = (
1978 DOMProperty.isCustomAttribute(lowerCasedName) ?
1979 lowerCasedName :
1980 DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
1981 DOMProperty.getPossibleStandardName[lowerCasedName] :
1982 null
1983 );
1984
1985 // For now, only warn when we have a suggested correction. This prevents
1986 // logging too much when using transferPropsTo.
1987 ("production" !== "development" ? warning(
1988 standardName == null,
1989 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
1990 ) : null);
1991
1992 };
1993}
1994
1995/**
1996 * Operations for dealing with DOM properties.
1997 */
1998var DOMPropertyOperations = {
1999
2000 /**
2001 * Creates markup for the ID property.
2002 *
2003 * @param {string} id Unescaped ID.
2004 * @return {string} Markup string.
2005 */
2006 createMarkupForID: function(id) {
2007 return processAttributeNameAndPrefix(DOMProperty.ID_ATTRIBUTE_NAME) +
2008 escapeTextForBrowser(id) + '"';
2009 },
2010
2011 /**
2012 * Creates markup for a property.
2013 *
2014 * @param {string} name
2015 * @param {*} value
2016 * @return {?string} Markup string, or null if the property was invalid.
2017 */
2018 createMarkupForProperty: function(name, value) {
2019 if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2020 DOMProperty.isStandardName[name]) {
2021 if (shouldIgnoreValue(name, value)) {
2022 return '';
2023 }
2024 var attributeName = DOMProperty.getAttributeName[name];
2025 if (DOMProperty.hasBooleanValue[name] ||
2026 (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
2027 return escapeTextForBrowser(attributeName);
2028 }
2029 return processAttributeNameAndPrefix(attributeName) +
2030 escapeTextForBrowser(value) + '"';
2031 } else if (DOMProperty.isCustomAttribute(name)) {
2032 if (value == null) {
2033 return '';
2034 }
2035 return processAttributeNameAndPrefix(name) +
2036 escapeTextForBrowser(value) + '"';
2037 } else if ("production" !== "development") {
2038 warnUnknownProperty(name);
2039 }
2040 return null;
2041 },
2042
2043 /**
2044 * Sets the value for a property on a node.
2045 *
2046 * @param {DOMElement} node
2047 * @param {string} name
2048 * @param {*} value
2049 */
2050 setValueForProperty: function(node, name, value) {
2051 if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2052 DOMProperty.isStandardName[name]) {
2053 var mutationMethod = DOMProperty.getMutationMethod[name];
2054 if (mutationMethod) {
2055 mutationMethod(node, value);
2056 } else if (shouldIgnoreValue(name, value)) {
2057 this.deleteValueForProperty(node, name);
2058 } else if (DOMProperty.mustUseAttribute[name]) {
2059 // `setAttribute` with objects becomes only `[object]` in IE8/9,
2060 // ('' + value) makes it output the correct toString()-value.
2061 node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
2062 } else {
2063 var propName = DOMProperty.getPropertyName[name];
2064 // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
2065 // property type before comparing; only `value` does and is string.
2066 if (!DOMProperty.hasSideEffects[name] ||
2067 ('' + node[propName]) !== ('' + value)) {
2068 // Contrary to `setAttribute`, object properties are properly
2069 // `toString`ed by IE8/9.
2070 node[propName] = value;
2071 }
2072 }
2073 } else if (DOMProperty.isCustomAttribute(name)) {
2074 if (value == null) {
2075 node.removeAttribute(name);
2076 } else {
2077 node.setAttribute(name, '' + value);
2078 }
2079 } else if ("production" !== "development") {
2080 warnUnknownProperty(name);
2081 }
2082 },
2083
2084 /**
2085 * Deletes the value for a property on a node.
2086 *
2087 * @param {DOMElement} node
2088 * @param {string} name
2089 */
2090 deleteValueForProperty: function(node, name) {
2091 if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2092 DOMProperty.isStandardName[name]) {
2093 var mutationMethod = DOMProperty.getMutationMethod[name];
2094 if (mutationMethod) {
2095 mutationMethod(node, undefined);
2096 } else if (DOMProperty.mustUseAttribute[name]) {
2097 node.removeAttribute(DOMProperty.getAttributeName[name]);
2098 } else {
2099 var propName = DOMProperty.getPropertyName[name];
2100 var defaultValue = DOMProperty.getDefaultValueForProperty(
2101 node.nodeName,
2102 propName
2103 );
2104 if (!DOMProperty.hasSideEffects[name] ||
2105 ('' + node[propName]) !== defaultValue) {
2106 node[propName] = defaultValue;
2107 }
2108 }
2109 } else if (DOMProperty.isCustomAttribute(name)) {
2110 node.removeAttribute(name);
2111 } else if ("production" !== "development") {
2112 warnUnknownProperty(name);
2113 }
2114 }
2115
2116};
2117
2118module.exports = DOMPropertyOperations;
2119
2120},{"./DOMProperty":11,"./escapeTextForBrowser":109,"./memoizeStringOnly":135,"./warning":145}],13:[function(_dereq_,module,exports){
2121/**
2122 * Copyright 2013-2014, Facebook, Inc.
2123 * All rights reserved.
2124 *
2125 * This source code is licensed under the BSD-style license found in the
2126 * LICENSE file in the root directory of this source tree. An additional grant
2127 * of patent rights can be found in the PATENTS file in the same directory.
2128 *
2129 * @providesModule Danger
2130 * @typechecks static-only
2131 */
2132
2133/*jslint evil: true, sub: true */
2134
2135"use strict";
2136
2137var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
2138
2139var createNodesFromMarkup = _dereq_("./createNodesFromMarkup");
2140var emptyFunction = _dereq_("./emptyFunction");
2141var getMarkupWrap = _dereq_("./getMarkupWrap");
2142var invariant = _dereq_("./invariant");
2143
2144var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
2145var RESULT_INDEX_ATTR = 'data-danger-index';
2146
2147/**
2148 * Extracts the `nodeName` from a string of markup.
2149 *
2150 * NOTE: Extracting the `nodeName` does not require a regular expression match
2151 * because we make assumptions about React-generated markup (i.e. there are no
2152 * spaces surrounding the opening tag and there is at least one attribute).
2153 *
2154 * @param {string} markup String of markup.
2155 * @return {string} Node name of the supplied markup.
2156 * @see http://jsperf.com/extract-nodename
2157 */
2158function getNodeName(markup) {
2159 return markup.substring(1, markup.indexOf(' '));
2160}
2161
2162var Danger = {
2163
2164 /**
2165 * Renders markup into an array of nodes. The markup is expected to render
2166 * into a list of root nodes. Also, the length of `resultList` and
2167 * `markupList` should be the same.
2168 *
2169 * @param {array<string>} markupList List of markup strings to render.
2170 * @return {array<DOMElement>} List of rendered nodes.
2171 * @internal
2172 */
2173 dangerouslyRenderMarkup: function(markupList) {
2174 ("production" !== "development" ? invariant(
2175 ExecutionEnvironment.canUseDOM,
2176 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
2177 'thread. Make sure `window` and `document` are available globally ' +
2178 'before requiring React when unit testing or use ' +
2179 'React.renderToString for server rendering.'
2180 ) : invariant(ExecutionEnvironment.canUseDOM));
2181 var nodeName;
2182 var markupByNodeName = {};
2183 // Group markup by `nodeName` if a wrap is necessary, else by '*'.
2184 for (var i = 0; i < markupList.length; i++) {
2185 ("production" !== "development" ? invariant(
2186 markupList[i],
2187 'dangerouslyRenderMarkup(...): Missing markup.'
2188 ) : invariant(markupList[i]));
2189 nodeName = getNodeName(markupList[i]);
2190 nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
2191 markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
2192 markupByNodeName[nodeName][i] = markupList[i];
2193 }
2194 var resultList = [];
2195 var resultListAssignmentCount = 0;
2196 for (nodeName in markupByNodeName) {
2197 if (!markupByNodeName.hasOwnProperty(nodeName)) {
2198 continue;
2199 }
2200 var markupListByNodeName = markupByNodeName[nodeName];
2201
2202 // This for-in loop skips the holes of the sparse array. The order of
2203 // iteration should follow the order of assignment, which happens to match
2204 // numerical index order, but we don't rely on that.
2205 for (var resultIndex in markupListByNodeName) {
2206 if (markupListByNodeName.hasOwnProperty(resultIndex)) {
2207 var markup = markupListByNodeName[resultIndex];
2208
2209 // Push the requested markup with an additional RESULT_INDEX_ATTR
2210 // attribute. If the markup does not start with a < character, it
2211 // will be discarded below (with an appropriate console.error).
2212 markupListByNodeName[resultIndex] = markup.replace(
2213 OPEN_TAG_NAME_EXP,
2214 // This index will be parsed back out below.
2215 '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
2216 );
2217 }
2218 }
2219
2220 // Render each group of markup with similar wrapping `nodeName`.
2221 var renderNodes = createNodesFromMarkup(
2222 markupListByNodeName.join(''),
2223 emptyFunction // Do nothing special with <script> tags.
2224 );
2225
2226 for (i = 0; i < renderNodes.length; ++i) {
2227 var renderNode = renderNodes[i];
2228 if (renderNode.hasAttribute &&
2229 renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
2230
2231 resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
2232 renderNode.removeAttribute(RESULT_INDEX_ATTR);
2233
2234 ("production" !== "development" ? invariant(
2235 !resultList.hasOwnProperty(resultIndex),
2236 'Danger: Assigning to an already-occupied result index.'
2237 ) : invariant(!resultList.hasOwnProperty(resultIndex)));
2238
2239 resultList[resultIndex] = renderNode;
2240
2241 // This should match resultList.length and markupList.length when
2242 // we're done.
2243 resultListAssignmentCount += 1;
2244
2245 } else if ("production" !== "development") {
2246 console.error(
2247 "Danger: Discarding unexpected node:",
2248 renderNode
2249 );
2250 }
2251 }
2252 }
2253
2254 // Although resultList was populated out of order, it should now be a dense
2255 // array.
2256 ("production" !== "development" ? invariant(
2257 resultListAssignmentCount === resultList.length,
2258 'Danger: Did not assign to every index of resultList.'
2259 ) : invariant(resultListAssignmentCount === resultList.length));
2260
2261 ("production" !== "development" ? invariant(
2262 resultList.length === markupList.length,
2263 'Danger: Expected markup to render %s nodes, but rendered %s.',
2264 markupList.length,
2265 resultList.length
2266 ) : invariant(resultList.length === markupList.length));
2267
2268 return resultList;
2269 },
2270
2271 /**
2272 * Replaces a node with a string of markup at its current position within its
2273 * parent. The markup must render into a single root node.
2274 *
2275 * @param {DOMElement} oldChild Child node to replace.
2276 * @param {string} markup Markup to render in place of the child node.
2277 * @internal
2278 */
2279 dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
2280 ("production" !== "development" ? invariant(
2281 ExecutionEnvironment.canUseDOM,
2282 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
2283 'worker thread. Make sure `window` and `document` are available ' +
2284 'globally before requiring React when unit testing or use ' +
2285 'React.renderToString for server rendering.'
2286 ) : invariant(ExecutionEnvironment.canUseDOM));
2287 ("production" !== "development" ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
2288 ("production" !== "development" ? invariant(
2289 oldChild.tagName.toLowerCase() !== 'html',
2290 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
2291 '<html> node. This is because browser quirks make this unreliable ' +
2292 'and/or slow. If you want to render to the root you must use ' +
2293 'server rendering. See renderComponentToString().'
2294 ) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
2295
2296 var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
2297 oldChild.parentNode.replaceChild(newChild, oldChild);
2298 }
2299
2300};
2301
2302module.exports = Danger;
2303
2304},{"./ExecutionEnvironment":22,"./createNodesFromMarkup":104,"./emptyFunction":107,"./getMarkupWrap":118,"./invariant":126}],14:[function(_dereq_,module,exports){
2305/**
2306 * Copyright 2013-2014, Facebook, Inc.
2307 * All rights reserved.
2308 *
2309 * This source code is licensed under the BSD-style license found in the
2310 * LICENSE file in the root directory of this source tree. An additional grant
2311 * of patent rights can be found in the PATENTS file in the same directory.
2312 *
2313 * @providesModule DefaultEventPluginOrder
2314 */
2315
2316"use strict";
2317
2318 var keyOf = _dereq_("./keyOf");
2319
2320/**
2321 * Module that is injectable into `EventPluginHub`, that specifies a
2322 * deterministic ordering of `EventPlugin`s. A convenient way to reason about
2323 * plugins, without having to package every one of them. This is better than
2324 * having plugins be ordered in the same order that they are injected because
2325 * that ordering would be influenced by the packaging order.
2326 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
2327 * preventing default on events is convenient in `SimpleEventPlugin` handlers.
2328 */
2329var DefaultEventPluginOrder = [
2330 keyOf({ResponderEventPlugin: null}),
2331 keyOf({SimpleEventPlugin: null}),
2332 keyOf({TapEventPlugin: null}),
2333 keyOf({EnterLeaveEventPlugin: null}),
2334 keyOf({ChangeEventPlugin: null}),
2335 keyOf({SelectEventPlugin: null}),
2336 keyOf({CompositionEventPlugin: null}),
2337 keyOf({BeforeInputEventPlugin: null}),
2338 keyOf({AnalyticsEventPlugin: null}),
2339 keyOf({MobileSafariClickEventPlugin: null})
2340];
2341
2342module.exports = DefaultEventPluginOrder;
2343
2344},{"./keyOf":133}],15:[function(_dereq_,module,exports){
2345/**
2346 * Copyright 2013-2014, Facebook, Inc.
2347 * All rights reserved.
2348 *
2349 * This source code is licensed under the BSD-style license found in the
2350 * LICENSE file in the root directory of this source tree. An additional grant
2351 * of patent rights can be found in the PATENTS file in the same directory.
2352 *
2353 * @providesModule EnterLeaveEventPlugin
2354 * @typechecks static-only
2355 */
2356
2357"use strict";
2358
2359var EventConstants = _dereq_("./EventConstants");
2360var EventPropagators = _dereq_("./EventPropagators");
2361var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
2362
2363var ReactMount = _dereq_("./ReactMount");
2364var keyOf = _dereq_("./keyOf");
2365
2366var topLevelTypes = EventConstants.topLevelTypes;
2367var getFirstReactDOM = ReactMount.getFirstReactDOM;
2368
2369var eventTypes = {
2370 mouseEnter: {
2371 registrationName: keyOf({onMouseEnter: null}),
2372 dependencies: [
2373 topLevelTypes.topMouseOut,
2374 topLevelTypes.topMouseOver
2375 ]
2376 },
2377 mouseLeave: {
2378 registrationName: keyOf({onMouseLeave: null}),
2379 dependencies: [
2380 topLevelTypes.topMouseOut,
2381 topLevelTypes.topMouseOver
2382 ]
2383 }
2384};
2385
2386var extractedEvents = [null, null];
2387
2388var EnterLeaveEventPlugin = {
2389
2390 eventTypes: eventTypes,
2391
2392 /**
2393 * For almost every interaction we care about, there will be both a top-level
2394 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
2395 * we do not extract duplicate events. However, moving the mouse into the
2396 * browser from outside will not fire a `mouseout` event. In this case, we use
2397 * the `mouseover` top-level event.
2398 *
2399 * @param {string} topLevelType Record from `EventConstants`.
2400 * @param {DOMEventTarget} topLevelTarget The listening component root node.
2401 * @param {string} topLevelTargetID ID of `topLevelTarget`.
2402 * @param {object} nativeEvent Native browser event.
2403 * @return {*} An accumulation of synthetic events.
2404 * @see {EventPluginHub.extractEvents}
2405 */
2406 extractEvents: function(
2407 topLevelType,
2408 topLevelTarget,
2409 topLevelTargetID,
2410 nativeEvent) {
2411 if (topLevelType === topLevelTypes.topMouseOver &&
2412 (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
2413 return null;
2414 }
2415 if (topLevelType !== topLevelTypes.topMouseOut &&
2416 topLevelType !== topLevelTypes.topMouseOver) {
2417 // Must not be a mouse in or mouse out - ignoring.
2418 return null;
2419 }
2420
2421 var win;
2422 if (topLevelTarget.window === topLevelTarget) {
2423 // `topLevelTarget` is probably a window object.
2424 win = topLevelTarget;
2425 } else {
2426 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
2427 var doc = topLevelTarget.ownerDocument;
2428 if (doc) {
2429 win = doc.defaultView || doc.parentWindow;
2430 } else {
2431 win = window;
2432 }
2433 }
2434
2435 var from, to;
2436 if (topLevelType === topLevelTypes.topMouseOut) {
2437 from = topLevelTarget;
2438 to =
2439 getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
2440 win;
2441 } else {
2442 from = win;
2443 to = topLevelTarget;
2444 }
2445
2446 if (from === to) {
2447 // Nothing pertains to our managed components.
2448 return null;
2449 }
2450
2451 var fromID = from ? ReactMount.getID(from) : '';
2452 var toID = to ? ReactMount.getID(to) : '';
2453
2454 var leave = SyntheticMouseEvent.getPooled(
2455 eventTypes.mouseLeave,
2456 fromID,
2457 nativeEvent
2458 );
2459 leave.type = 'mouseleave';
2460 leave.target = from;
2461 leave.relatedTarget = to;
2462
2463 var enter = SyntheticMouseEvent.getPooled(
2464 eventTypes.mouseEnter,
2465 toID,
2466 nativeEvent
2467 );
2468 enter.type = 'mouseenter';
2469 enter.target = to;
2470 enter.relatedTarget = from;
2471
2472 EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
2473
2474 extractedEvents[0] = leave;
2475 extractedEvents[1] = enter;
2476
2477 return extractedEvents;
2478 }
2479
2480};
2481
2482module.exports = EnterLeaveEventPlugin;
2483
2484},{"./EventConstants":16,"./EventPropagators":21,"./ReactMount":63,"./SyntheticMouseEvent":91,"./keyOf":133}],16:[function(_dereq_,module,exports){
2485/**
2486 * Copyright 2013-2014, Facebook, Inc.
2487 * All rights reserved.
2488 *
2489 * This source code is licensed under the BSD-style license found in the
2490 * LICENSE file in the root directory of this source tree. An additional grant
2491 * of patent rights can be found in the PATENTS file in the same directory.
2492 *
2493 * @providesModule EventConstants
2494 */
2495
2496"use strict";
2497
2498var keyMirror = _dereq_("./keyMirror");
2499
2500var PropagationPhases = keyMirror({bubbled: null, captured: null});
2501
2502/**
2503 * Types of raw signals from the browser caught at the top level.
2504 */
2505var topLevelTypes = keyMirror({
2506 topBlur: null,
2507 topChange: null,
2508 topClick: null,
2509 topCompositionEnd: null,
2510 topCompositionStart: null,
2511 topCompositionUpdate: null,
2512 topContextMenu: null,
2513 topCopy: null,
2514 topCut: null,
2515 topDoubleClick: null,
2516 topDrag: null,
2517 topDragEnd: null,
2518 topDragEnter: null,
2519 topDragExit: null,
2520 topDragLeave: null,
2521 topDragOver: null,
2522 topDragStart: null,
2523 topDrop: null,
2524 topError: null,
2525 topFocus: null,
2526 topInput: null,
2527 topKeyDown: null,
2528 topKeyPress: null,
2529 topKeyUp: null,
2530 topLoad: null,
2531 topMouseDown: null,
2532 topMouseMove: null,
2533 topMouseOut: null,
2534 topMouseOver: null,
2535 topMouseUp: null,
2536 topPaste: null,
2537 topReset: null,
2538 topScroll: null,
2539 topSelectionChange: null,
2540 topSubmit: null,
2541 topTextInput: null,
2542 topTouchCancel: null,
2543 topTouchEnd: null,
2544 topTouchMove: null,
2545 topTouchStart: null,
2546 topWheel: null
2547});
2548
2549var EventConstants = {
2550 topLevelTypes: topLevelTypes,
2551 PropagationPhases: PropagationPhases
2552};
2553
2554module.exports = EventConstants;
2555
2556},{"./keyMirror":132}],17:[function(_dereq_,module,exports){
2557/**
2558 * Copyright 2013-2014 Facebook, Inc.
2559 *
2560 * Licensed under the Apache License, Version 2.0 (the "License");
2561 * you may not use this file except in compliance with the License.
2562 * You may obtain a copy of the License at
2563 *
2564 * http://www.apache.org/licenses/LICENSE-2.0
2565 *
2566 * Unless required by applicable law or agreed to in writing, software
2567 * distributed under the License is distributed on an "AS IS" BASIS,
2568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2569 * See the License for the specific language governing permissions and
2570 * limitations under the License.
2571 *
2572 * @providesModule EventListener
2573 * @typechecks
2574 */
2575
2576var emptyFunction = _dereq_("./emptyFunction");
2577
2578/**
2579 * Upstream version of event listener. Does not take into account specific
2580 * nature of platform.
2581 */
2582var EventListener = {
2583 /**
2584 * Listen to DOM events during the bubble phase.
2585 *
2586 * @param {DOMEventTarget} target DOM element to register listener on.
2587 * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2588 * @param {function} callback Callback function.
2589 * @return {object} Object with a `remove` method.
2590 */
2591 listen: function(target, eventType, callback) {
2592 if (target.addEventListener) {
2593 target.addEventListener(eventType, callback, false);
2594 return {
2595 remove: function() {
2596 target.removeEventListener(eventType, callback, false);
2597 }
2598 };
2599 } else if (target.attachEvent) {
2600 target.attachEvent('on' + eventType, callback);
2601 return {
2602 remove: function() {
2603 target.detachEvent('on' + eventType, callback);
2604 }
2605 };
2606 }
2607 },
2608
2609 /**
2610 * Listen to DOM events during the capture phase.
2611 *
2612 * @param {DOMEventTarget} target DOM element to register listener on.
2613 * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2614 * @param {function} callback Callback function.
2615 * @return {object} Object with a `remove` method.
2616 */
2617 capture: function(target, eventType, callback) {
2618 if (!target.addEventListener) {
2619 if ("production" !== "development") {
2620 console.error(
2621 'Attempted to listen to events during the capture phase on a ' +
2622 'browser that does not support the capture phase. Your application ' +
2623 'will not receive some events.'
2624 );
2625 }
2626 return {
2627 remove: emptyFunction
2628 };
2629 } else {
2630 target.addEventListener(eventType, callback, true);
2631 return {
2632 remove: function() {
2633 target.removeEventListener(eventType, callback, true);
2634 }
2635 };
2636 }
2637 },
2638
2639 registerDefault: function() {}
2640};
2641
2642module.exports = EventListener;
2643
2644},{"./emptyFunction":107}],18:[function(_dereq_,module,exports){
2645/**
2646 * Copyright 2013-2014, Facebook, Inc.
2647 * All rights reserved.
2648 *
2649 * This source code is licensed under the BSD-style license found in the
2650 * LICENSE file in the root directory of this source tree. An additional grant
2651 * of patent rights can be found in the PATENTS file in the same directory.
2652 *
2653 * @providesModule EventPluginHub
2654 */
2655
2656"use strict";
2657
2658var EventPluginRegistry = _dereq_("./EventPluginRegistry");
2659var EventPluginUtils = _dereq_("./EventPluginUtils");
2660
2661var accumulateInto = _dereq_("./accumulateInto");
2662var forEachAccumulated = _dereq_("./forEachAccumulated");
2663var invariant = _dereq_("./invariant");
2664
2665/**
2666 * Internal store for event listeners
2667 */
2668var listenerBank = {};
2669
2670/**
2671 * Internal queue of events that have accumulated their dispatches and are
2672 * waiting to have their dispatches executed.
2673 */
2674var eventQueue = null;
2675
2676/**
2677 * Dispatches an event and releases it back into the pool, unless persistent.
2678 *
2679 * @param {?object} event Synthetic event to be dispatched.
2680 * @private
2681 */
2682var executeDispatchesAndRelease = function(event) {
2683 if (event) {
2684 var executeDispatch = EventPluginUtils.executeDispatch;
2685 // Plugins can provide custom behavior when dispatching events.
2686 var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
2687 if (PluginModule && PluginModule.executeDispatch) {
2688 executeDispatch = PluginModule.executeDispatch;
2689 }
2690 EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
2691
2692 if (!event.isPersistent()) {
2693 event.constructor.release(event);
2694 }
2695 }
2696};
2697
2698/**
2699 * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
2700 * hierarchy given ids of the logical DOM elements involved.
2701 */
2702var InstanceHandle = null;
2703
2704function validateInstanceHandle() {
2705 var invalid = !InstanceHandle||
2706 !InstanceHandle.traverseTwoPhase ||
2707 !InstanceHandle.traverseEnterLeave;
2708 if (invalid) {
2709 throw new Error('InstanceHandle not injected before use!');
2710 }
2711}
2712
2713/**
2714 * This is a unified interface for event plugins to be installed and configured.
2715 *
2716 * Event plugins can implement the following properties:
2717 *
2718 * `extractEvents` {function(string, DOMEventTarget, string, object): *}
2719 * Required. When a top-level event is fired, this method is expected to
2720 * extract synthetic events that will in turn be queued and dispatched.
2721 *
2722 * `eventTypes` {object}
2723 * Optional, plugins that fire events must publish a mapping of registration
2724 * names that are used to register listeners. Values of this mapping must
2725 * be objects that contain `registrationName` or `phasedRegistrationNames`.
2726 *
2727 * `executeDispatch` {function(object, function, string)}
2728 * Optional, allows plugins to override how an event gets dispatched. By
2729 * default, the listener is simply invoked.
2730 *
2731 * Each plugin that is injected into `EventsPluginHub` is immediately operable.
2732 *
2733 * @public
2734 */
2735var EventPluginHub = {
2736
2737 /**
2738 * Methods for injecting dependencies.
2739 */
2740 injection: {
2741
2742 /**
2743 * @param {object} InjectedMount
2744 * @public
2745 */
2746 injectMount: EventPluginUtils.injection.injectMount,
2747
2748 /**
2749 * @param {object} InjectedInstanceHandle
2750 * @public
2751 */
2752 injectInstanceHandle: function(InjectedInstanceHandle) {
2753 InstanceHandle = InjectedInstanceHandle;
2754 if ("production" !== "development") {
2755 validateInstanceHandle();
2756 }
2757 },
2758
2759 getInstanceHandle: function() {
2760 if ("production" !== "development") {
2761 validateInstanceHandle();
2762 }
2763 return InstanceHandle;
2764 },
2765
2766 /**
2767 * @param {array} InjectedEventPluginOrder
2768 * @public
2769 */
2770 injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
2771
2772 /**
2773 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
2774 */
2775 injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
2776
2777 },
2778
2779 eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
2780
2781 registrationNameModules: EventPluginRegistry.registrationNameModules,
2782
2783 /**
2784 * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
2785 *
2786 * @param {string} id ID of the DOM element.
2787 * @param {string} registrationName Name of listener (e.g. `onClick`).
2788 * @param {?function} listener The callback to store.
2789 */
2790 putListener: function(id, registrationName, listener) {
2791 ("production" !== "development" ? invariant(
2792 !listener || typeof listener === 'function',
2793 'Expected %s listener to be a function, instead got type %s',
2794 registrationName, typeof listener
2795 ) : invariant(!listener || typeof listener === 'function'));
2796
2797 var bankForRegistrationName =
2798 listenerBank[registrationName] || (listenerBank[registrationName] = {});
2799 bankForRegistrationName[id] = listener;
2800 },
2801
2802 /**
2803 * @param {string} id ID of the DOM element.
2804 * @param {string} registrationName Name of listener (e.g. `onClick`).
2805 * @return {?function} The stored callback.
2806 */
2807 getListener: function(id, registrationName) {
2808 var bankForRegistrationName = listenerBank[registrationName];
2809 return bankForRegistrationName && bankForRegistrationName[id];
2810 },
2811
2812 /**
2813 * Deletes a listener from the registration bank.
2814 *
2815 * @param {string} id ID of the DOM element.
2816 * @param {string} registrationName Name of listener (e.g. `onClick`).
2817 */
2818 deleteListener: function(id, registrationName) {
2819 var bankForRegistrationName = listenerBank[registrationName];
2820 if (bankForRegistrationName) {
2821 delete bankForRegistrationName[id];
2822 }
2823 },
2824
2825 /**
2826 * Deletes all listeners for the DOM element with the supplied ID.
2827 *
2828 * @param {string} id ID of the DOM element.
2829 */
2830 deleteAllListeners: function(id) {
2831 for (var registrationName in listenerBank) {
2832 delete listenerBank[registrationName][id];
2833 }
2834 },
2835
2836 /**
2837 * Allows registered plugins an opportunity to extract events from top-level
2838 * native browser events.
2839 *
2840 * @param {string} topLevelType Record from `EventConstants`.
2841 * @param {DOMEventTarget} topLevelTarget The listening component root node.
2842 * @param {string} topLevelTargetID ID of `topLevelTarget`.
2843 * @param {object} nativeEvent Native browser event.
2844 * @return {*} An accumulation of synthetic events.
2845 * @internal
2846 */
2847 extractEvents: function(
2848 topLevelType,
2849 topLevelTarget,
2850 topLevelTargetID,
2851 nativeEvent) {
2852 var events;
2853 var plugins = EventPluginRegistry.plugins;
2854 for (var i = 0, l = plugins.length; i < l; i++) {
2855 // Not every plugin in the ordering may be loaded at runtime.
2856 var possiblePlugin = plugins[i];
2857 if (possiblePlugin) {
2858 var extractedEvents = possiblePlugin.extractEvents(
2859 topLevelType,
2860 topLevelTarget,
2861 topLevelTargetID,
2862 nativeEvent
2863 );
2864 if (extractedEvents) {
2865 events = accumulateInto(events, extractedEvents);
2866 }
2867 }
2868 }
2869 return events;
2870 },
2871
2872 /**
2873 * Enqueues a synthetic event that should be dispatched when
2874 * `processEventQueue` is invoked.
2875 *
2876 * @param {*} events An accumulation of synthetic events.
2877 * @internal
2878 */
2879 enqueueEvents: function(events) {
2880 if (events) {
2881 eventQueue = accumulateInto(eventQueue, events);
2882 }
2883 },
2884
2885 /**
2886 * Dispatches all synthetic events on the event queue.
2887 *
2888 * @internal
2889 */
2890 processEventQueue: function() {
2891 // Set `eventQueue` to null before processing it so that we can tell if more
2892 // events get enqueued while processing.
2893 var processingEventQueue = eventQueue;
2894 eventQueue = null;
2895 forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
2896 ("production" !== "development" ? invariant(
2897 !eventQueue,
2898 'processEventQueue(): Additional events were enqueued while processing ' +
2899 'an event queue. Support for this has not yet been implemented.'
2900 ) : invariant(!eventQueue));
2901 },
2902
2903 /**
2904 * These are needed for tests only. Do not use!
2905 */
2906 __purge: function() {
2907 listenerBank = {};
2908 },
2909
2910 __getListenerBank: function() {
2911 return listenerBank;
2912 }
2913
2914};
2915
2916module.exports = EventPluginHub;
2917
2918},{"./EventPluginRegistry":19,"./EventPluginUtils":20,"./accumulateInto":97,"./forEachAccumulated":112,"./invariant":126}],19:[function(_dereq_,module,exports){
2919/**
2920 * Copyright 2013-2014, Facebook, Inc.
2921 * All rights reserved.
2922 *
2923 * This source code is licensed under the BSD-style license found in the
2924 * LICENSE file in the root directory of this source tree. An additional grant
2925 * of patent rights can be found in the PATENTS file in the same directory.
2926 *
2927 * @providesModule EventPluginRegistry
2928 * @typechecks static-only
2929 */
2930
2931"use strict";
2932
2933var invariant = _dereq_("./invariant");
2934
2935/**
2936 * Injectable ordering of event plugins.
2937 */
2938var EventPluginOrder = null;
2939
2940/**
2941 * Injectable mapping from names to event plugin modules.
2942 */
2943var namesToPlugins = {};
2944
2945/**
2946 * Recomputes the plugin list using the injected plugins and plugin ordering.
2947 *
2948 * @private
2949 */
2950function recomputePluginOrdering() {
2951 if (!EventPluginOrder) {
2952 // Wait until an `EventPluginOrder` is injected.
2953 return;
2954 }
2955 for (var pluginName in namesToPlugins) {
2956 var PluginModule = namesToPlugins[pluginName];
2957 var pluginIndex = EventPluginOrder.indexOf(pluginName);
2958 ("production" !== "development" ? invariant(
2959 pluginIndex > -1,
2960 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
2961 'the plugin ordering, `%s`.',
2962 pluginName
2963 ) : invariant(pluginIndex > -1));
2964 if (EventPluginRegistry.plugins[pluginIndex]) {
2965 continue;
2966 }
2967 ("production" !== "development" ? invariant(
2968 PluginModule.extractEvents,
2969 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
2970 'method, but `%s` does not.',
2971 pluginName
2972 ) : invariant(PluginModule.extractEvents));
2973 EventPluginRegistry.plugins[pluginIndex] = PluginModule;
2974 var publishedEvents = PluginModule.eventTypes;
2975 for (var eventName in publishedEvents) {
2976 ("production" !== "development" ? invariant(
2977 publishEventForPlugin(
2978 publishedEvents[eventName],
2979 PluginModule,
2980 eventName
2981 ),
2982 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
2983 eventName,
2984 pluginName
2985 ) : invariant(publishEventForPlugin(
2986 publishedEvents[eventName],
2987 PluginModule,
2988 eventName
2989 )));
2990 }
2991 }
2992}
2993
2994/**
2995 * Publishes an event so that it can be dispatched by the supplied plugin.
2996 *
2997 * @param {object} dispatchConfig Dispatch configuration for the event.
2998 * @param {object} PluginModule Plugin publishing the event.
2999 * @return {boolean} True if the event was successfully published.
3000 * @private
3001 */
3002function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
3003 ("production" !== "development" ? invariant(
3004 !EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
3005 'EventPluginHub: More than one plugin attempted to publish the same ' +
3006 'event name, `%s`.',
3007 eventName
3008 ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
3009 EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
3010
3011 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
3012 if (phasedRegistrationNames) {
3013 for (var phaseName in phasedRegistrationNames) {
3014 if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
3015 var phasedRegistrationName = phasedRegistrationNames[phaseName];
3016 publishRegistrationName(
3017 phasedRegistrationName,
3018 PluginModule,
3019 eventName
3020 );
3021 }
3022 }
3023 return true;
3024 } else if (dispatchConfig.registrationName) {
3025 publishRegistrationName(
3026 dispatchConfig.registrationName,
3027 PluginModule,
3028 eventName
3029 );
3030 return true;
3031 }
3032 return false;
3033}
3034
3035/**
3036 * Publishes a registration name that is used to identify dispatched events and
3037 * can be used with `EventPluginHub.putListener` to register listeners.
3038 *
3039 * @param {string} registrationName Registration name to add.
3040 * @param {object} PluginModule Plugin publishing the event.
3041 * @private
3042 */
3043function publishRegistrationName(registrationName, PluginModule, eventName) {
3044 ("production" !== "development" ? invariant(
3045 !EventPluginRegistry.registrationNameModules[registrationName],
3046 'EventPluginHub: More than one plugin attempted to publish the same ' +
3047 'registration name, `%s`.',
3048 registrationName
3049 ) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
3050 EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
3051 EventPluginRegistry.registrationNameDependencies[registrationName] =
3052 PluginModule.eventTypes[eventName].dependencies;
3053}
3054
3055/**
3056 * Registers plugins so that they can extract and dispatch events.
3057 *
3058 * @see {EventPluginHub}
3059 */
3060var EventPluginRegistry = {
3061
3062 /**
3063 * Ordered list of injected plugins.
3064 */
3065 plugins: [],
3066
3067 /**
3068 * Mapping from event name to dispatch config
3069 */
3070 eventNameDispatchConfigs: {},
3071
3072 /**
3073 * Mapping from registration name to plugin module
3074 */
3075 registrationNameModules: {},
3076
3077 /**
3078 * Mapping from registration name to event name
3079 */
3080 registrationNameDependencies: {},
3081
3082 /**
3083 * Injects an ordering of plugins (by plugin name). This allows the ordering
3084 * to be decoupled from injection of the actual plugins so that ordering is
3085 * always deterministic regardless of packaging, on-the-fly injection, etc.
3086 *
3087 * @param {array} InjectedEventPluginOrder
3088 * @internal
3089 * @see {EventPluginHub.injection.injectEventPluginOrder}
3090 */
3091 injectEventPluginOrder: function(InjectedEventPluginOrder) {
3092 ("production" !== "development" ? invariant(
3093 !EventPluginOrder,
3094 'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
3095 'once. You are likely trying to load more than one copy of React.'
3096 ) : invariant(!EventPluginOrder));
3097 // Clone the ordering so it cannot be dynamically mutated.
3098 EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
3099 recomputePluginOrdering();
3100 },
3101
3102 /**
3103 * Injects plugins to be used by `EventPluginHub`. The plugin names must be
3104 * in the ordering injected by `injectEventPluginOrder`.
3105 *
3106 * Plugins can be injected as part of page initialization or on-the-fly.
3107 *
3108 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
3109 * @internal
3110 * @see {EventPluginHub.injection.injectEventPluginsByName}
3111 */
3112 injectEventPluginsByName: function(injectedNamesToPlugins) {
3113 var isOrderingDirty = false;
3114 for (var pluginName in injectedNamesToPlugins) {
3115 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
3116 continue;
3117 }
3118 var PluginModule = injectedNamesToPlugins[pluginName];
3119 if (!namesToPlugins.hasOwnProperty(pluginName) ||
3120 namesToPlugins[pluginName] !== PluginModule) {
3121 ("production" !== "development" ? invariant(
3122 !namesToPlugins[pluginName],
3123 'EventPluginRegistry: Cannot inject two different event plugins ' +
3124 'using the same name, `%s`.',
3125 pluginName
3126 ) : invariant(!namesToPlugins[pluginName]));
3127 namesToPlugins[pluginName] = PluginModule;
3128 isOrderingDirty = true;
3129 }
3130 }
3131 if (isOrderingDirty) {
3132 recomputePluginOrdering();
3133 }
3134 },
3135
3136 /**
3137 * Looks up the plugin for the supplied event.
3138 *
3139 * @param {object} event A synthetic event.
3140 * @return {?object} The plugin that created the supplied event.
3141 * @internal
3142 */
3143 getPluginModuleForEvent: function(event) {
3144 var dispatchConfig = event.dispatchConfig;
3145 if (dispatchConfig.registrationName) {
3146 return EventPluginRegistry.registrationNameModules[
3147 dispatchConfig.registrationName
3148 ] || null;
3149 }
3150 for (var phase in dispatchConfig.phasedRegistrationNames) {
3151 if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
3152 continue;
3153 }
3154 var PluginModule = EventPluginRegistry.registrationNameModules[
3155 dispatchConfig.phasedRegistrationNames[phase]
3156 ];
3157 if (PluginModule) {
3158 return PluginModule;
3159 }
3160 }
3161 return null;
3162 },
3163
3164 /**
3165 * Exposed for unit testing.
3166 * @private
3167 */
3168 _resetEventPlugins: function() {
3169 EventPluginOrder = null;
3170 for (var pluginName in namesToPlugins) {
3171 if (namesToPlugins.hasOwnProperty(pluginName)) {
3172 delete namesToPlugins[pluginName];
3173 }
3174 }
3175 EventPluginRegistry.plugins.length = 0;
3176
3177 var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
3178 for (var eventName in eventNameDispatchConfigs) {
3179 if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
3180 delete eventNameDispatchConfigs[eventName];
3181 }
3182 }
3183
3184 var registrationNameModules = EventPluginRegistry.registrationNameModules;
3185 for (var registrationName in registrationNameModules) {
3186 if (registrationNameModules.hasOwnProperty(registrationName)) {
3187 delete registrationNameModules[registrationName];
3188 }
3189 }
3190 }
3191
3192};
3193
3194module.exports = EventPluginRegistry;
3195
3196},{"./invariant":126}],20:[function(_dereq_,module,exports){
3197/**
3198 * Copyright 2013-2014, Facebook, Inc.
3199 * All rights reserved.
3200 *
3201 * This source code is licensed under the BSD-style license found in the
3202 * LICENSE file in the root directory of this source tree. An additional grant
3203 * of patent rights can be found in the PATENTS file in the same directory.
3204 *
3205 * @providesModule EventPluginUtils
3206 */
3207
3208"use strict";
3209
3210var EventConstants = _dereq_("./EventConstants");
3211
3212var invariant = _dereq_("./invariant");
3213
3214/**
3215 * Injected dependencies:
3216 */
3217
3218/**
3219 * - `Mount`: [required] Module that can convert between React dom IDs and
3220 * actual node references.
3221 */
3222var injection = {
3223 Mount: null,
3224 injectMount: function(InjectedMount) {
3225 injection.Mount = InjectedMount;
3226 if ("production" !== "development") {
3227 ("production" !== "development" ? invariant(
3228 InjectedMount && InjectedMount.getNode,
3229 'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
3230 'is missing getNode.'
3231 ) : invariant(InjectedMount && InjectedMount.getNode));
3232 }
3233 }
3234};
3235
3236var topLevelTypes = EventConstants.topLevelTypes;
3237
3238function isEndish(topLevelType) {
3239 return topLevelType === topLevelTypes.topMouseUp ||
3240 topLevelType === topLevelTypes.topTouchEnd ||
3241 topLevelType === topLevelTypes.topTouchCancel;
3242}
3243
3244function isMoveish(topLevelType) {
3245 return topLevelType === topLevelTypes.topMouseMove ||
3246 topLevelType === topLevelTypes.topTouchMove;
3247}
3248function isStartish(topLevelType) {
3249 return topLevelType === topLevelTypes.topMouseDown ||
3250 topLevelType === topLevelTypes.topTouchStart;
3251}
3252
3253
3254var validateEventDispatches;
3255if ("production" !== "development") {
3256 validateEventDispatches = function(event) {
3257 var dispatchListeners = event._dispatchListeners;
3258 var dispatchIDs = event._dispatchIDs;
3259
3260 var listenersIsArr = Array.isArray(dispatchListeners);
3261 var idsIsArr = Array.isArray(dispatchIDs);
3262 var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
3263 var listenersLen = listenersIsArr ?
3264 dispatchListeners.length :
3265 dispatchListeners ? 1 : 0;
3266
3267 ("production" !== "development" ? invariant(
3268 idsIsArr === listenersIsArr && IDsLen === listenersLen,
3269 'EventPluginUtils: Invalid `event`.'
3270 ) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
3271 };
3272}
3273
3274/**
3275 * Invokes `cb(event, listener, id)`. Avoids using call if no scope is
3276 * provided. The `(listener,id)` pair effectively forms the "dispatch" but are
3277 * kept separate to conserve memory.
3278 */
3279function forEachEventDispatch(event, cb) {
3280 var dispatchListeners = event._dispatchListeners;
3281 var dispatchIDs = event._dispatchIDs;
3282 if ("production" !== "development") {
3283 validateEventDispatches(event);
3284 }
3285 if (Array.isArray(dispatchListeners)) {
3286 for (var i = 0; i < dispatchListeners.length; i++) {
3287 if (event.isPropagationStopped()) {
3288 break;
3289 }
3290 // Listeners and IDs are two parallel arrays that are always in sync.
3291 cb(event, dispatchListeners[i], dispatchIDs[i]);
3292 }
3293 } else if (dispatchListeners) {
3294 cb(event, dispatchListeners, dispatchIDs);
3295 }
3296}
3297
3298/**
3299 * Default implementation of PluginModule.executeDispatch().
3300 * @param {SyntheticEvent} SyntheticEvent to handle
3301 * @param {function} Application-level callback
3302 * @param {string} domID DOM id to pass to the callback.
3303 */
3304function executeDispatch(event, listener, domID) {
3305 event.currentTarget = injection.Mount.getNode(domID);
3306 var returnValue = listener(event, domID);
3307 event.currentTarget = null;
3308 return returnValue;
3309}
3310
3311/**
3312 * Standard/simple iteration through an event's collected dispatches.
3313 */
3314function executeDispatchesInOrder(event, executeDispatch) {
3315 forEachEventDispatch(event, executeDispatch);
3316 event._dispatchListeners = null;
3317 event._dispatchIDs = null;
3318}
3319
3320/**
3321 * Standard/simple iteration through an event's collected dispatches, but stops
3322 * at the first dispatch execution returning true, and returns that id.
3323 *
3324 * @return id of the first dispatch execution who's listener returns true, or
3325 * null if no listener returned true.
3326 */
3327function executeDispatchesInOrderStopAtTrueImpl(event) {
3328 var dispatchListeners = event._dispatchListeners;
3329 var dispatchIDs = event._dispatchIDs;
3330 if ("production" !== "development") {
3331 validateEventDispatches(event);
3332 }
3333 if (Array.isArray(dispatchListeners)) {
3334 for (var i = 0; i < dispatchListeners.length; i++) {
3335 if (event.isPropagationStopped()) {
3336 break;
3337 }
3338 // Listeners and IDs are two parallel arrays that are always in sync.
3339 if (dispatchListeners[i](event, dispatchIDs[i])) {
3340 return dispatchIDs[i];
3341 }
3342 }
3343 } else if (dispatchListeners) {
3344 if (dispatchListeners(event, dispatchIDs)) {
3345 return dispatchIDs;
3346 }
3347 }
3348 return null;
3349}
3350
3351/**
3352 * @see executeDispatchesInOrderStopAtTrueImpl
3353 */
3354function executeDispatchesInOrderStopAtTrue(event) {
3355 var ret = executeDispatchesInOrderStopAtTrueImpl(event);
3356 event._dispatchIDs = null;
3357 event._dispatchListeners = null;
3358 return ret;
3359}
3360
3361/**
3362 * Execution of a "direct" dispatch - there must be at most one dispatch
3363 * accumulated on the event or it is considered an error. It doesn't really make
3364 * sense for an event with multiple dispatches (bubbled) to keep track of the
3365 * return values at each dispatch execution, but it does tend to make sense when
3366 * dealing with "direct" dispatches.
3367 *
3368 * @return The return value of executing the single dispatch.
3369 */
3370function executeDirectDispatch(event) {
3371 if ("production" !== "development") {
3372 validateEventDispatches(event);
3373 }
3374 var dispatchListener = event._dispatchListeners;
3375 var dispatchID = event._dispatchIDs;
3376 ("production" !== "development" ? invariant(
3377 !Array.isArray(dispatchListener),
3378 'executeDirectDispatch(...): Invalid `event`.'
3379 ) : invariant(!Array.isArray(dispatchListener)));
3380 var res = dispatchListener ?
3381 dispatchListener(event, dispatchID) :
3382 null;
3383 event._dispatchListeners = null;
3384 event._dispatchIDs = null;
3385 return res;
3386}
3387
3388/**
3389 * @param {SyntheticEvent} event
3390 * @return {bool} True iff number of dispatches accumulated is greater than 0.
3391 */
3392function hasDispatches(event) {
3393 return !!event._dispatchListeners;
3394}
3395
3396/**
3397 * General utilities that are useful in creating custom Event Plugins.
3398 */
3399var EventPluginUtils = {
3400 isEndish: isEndish,
3401 isMoveish: isMoveish,
3402 isStartish: isStartish,
3403
3404 executeDirectDispatch: executeDirectDispatch,
3405 executeDispatch: executeDispatch,
3406 executeDispatchesInOrder: executeDispatchesInOrder,
3407 executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
3408 hasDispatches: hasDispatches,
3409 injection: injection,
3410 useTouchEvents: false
3411};
3412
3413module.exports = EventPluginUtils;
3414
3415},{"./EventConstants":16,"./invariant":126}],21:[function(_dereq_,module,exports){
3416/**
3417 * Copyright 2013-2014, Facebook, Inc.
3418 * All rights reserved.
3419 *
3420 * This source code is licensed under the BSD-style license found in the
3421 * LICENSE file in the root directory of this source tree. An additional grant
3422 * of patent rights can be found in the PATENTS file in the same directory.
3423 *
3424 * @providesModule EventPropagators
3425 */
3426
3427"use strict";
3428
3429var EventConstants = _dereq_("./EventConstants");
3430var EventPluginHub = _dereq_("./EventPluginHub");
3431
3432var accumulateInto = _dereq_("./accumulateInto");
3433var forEachAccumulated = _dereq_("./forEachAccumulated");
3434
3435var PropagationPhases = EventConstants.PropagationPhases;
3436var getListener = EventPluginHub.getListener;
3437
3438/**
3439 * Some event types have a notion of different registration names for different
3440 * "phases" of propagation. This finds listeners by a given phase.
3441 */
3442function listenerAtPhase(id, event, propagationPhase) {
3443 var registrationName =
3444 event.dispatchConfig.phasedRegistrationNames[propagationPhase];
3445 return getListener(id, registrationName);
3446}
3447
3448/**
3449 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
3450 * here, allows us to not have to bind or create functions for each event.
3451 * Mutating the event's members allows us to not have to create a wrapping
3452 * "dispatch" object that pairs the event with the listener.
3453 */
3454function accumulateDirectionalDispatches(domID, upwards, event) {
3455 if ("production" !== "development") {
3456 if (!domID) {
3457 throw new Error('Dispatching id must not be null');
3458 }
3459 }
3460 var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
3461 var listener = listenerAtPhase(domID, event, phase);
3462 if (listener) {
3463 event._dispatchListeners =
3464 accumulateInto(event._dispatchListeners, listener);
3465 event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
3466 }
3467}
3468
3469/**
3470 * Collect dispatches (must be entirely collected before dispatching - see unit
3471 * tests). Lazily allocate the array to conserve memory. We must loop through
3472 * each event and perform the traversal for each one. We can not perform a
3473 * single traversal for the entire collection of events because each event may
3474 * have a different target.
3475 */
3476function accumulateTwoPhaseDispatchesSingle(event) {
3477 if (event && event.dispatchConfig.phasedRegistrationNames) {
3478 EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
3479 event.dispatchMarker,
3480 accumulateDirectionalDispatches,
3481 event
3482 );
3483 }
3484}
3485
3486
3487/**
3488 * Accumulates without regard to direction, does not look for phased
3489 * registration names. Same as `accumulateDirectDispatchesSingle` but without
3490 * requiring that the `dispatchMarker` be the same as the dispatched ID.
3491 */
3492function accumulateDispatches(id, ignoredDirection, event) {
3493 if (event && event.dispatchConfig.registrationName) {
3494 var registrationName = event.dispatchConfig.registrationName;
3495 var listener = getListener(id, registrationName);
3496 if (listener) {
3497 event._dispatchListeners =
3498 accumulateInto(event._dispatchListeners, listener);
3499 event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
3500 }
3501 }
3502}
3503
3504/**
3505 * Accumulates dispatches on an `SyntheticEvent`, but only for the
3506 * `dispatchMarker`.
3507 * @param {SyntheticEvent} event
3508 */
3509function accumulateDirectDispatchesSingle(event) {
3510 if (event && event.dispatchConfig.registrationName) {
3511 accumulateDispatches(event.dispatchMarker, null, event);
3512 }
3513}
3514
3515function accumulateTwoPhaseDispatches(events) {
3516 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
3517}
3518
3519function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
3520 EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
3521 fromID,
3522 toID,
3523 accumulateDispatches,
3524 leave,
3525 enter
3526 );
3527}
3528
3529
3530function accumulateDirectDispatches(events) {
3531 forEachAccumulated(events, accumulateDirectDispatchesSingle);
3532}
3533
3534
3535
3536/**
3537 * A small set of propagation patterns, each of which will accept a small amount
3538 * of information, and generate a set of "dispatch ready event objects" - which
3539 * are sets of events that have already been annotated with a set of dispatched
3540 * listener functions/ids. The API is designed this way to discourage these
3541 * propagation strategies from actually executing the dispatches, since we
3542 * always want to collect the entire set of dispatches before executing event a
3543 * single one.
3544 *
3545 * @constructor EventPropagators
3546 */
3547var EventPropagators = {
3548 accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
3549 accumulateDirectDispatches: accumulateDirectDispatches,
3550 accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
3551};
3552
3553module.exports = EventPropagators;
3554
3555},{"./EventConstants":16,"./EventPluginHub":18,"./accumulateInto":97,"./forEachAccumulated":112}],22:[function(_dereq_,module,exports){
3556/**
3557 * Copyright 2013-2014, Facebook, Inc.
3558 * All rights reserved.
3559 *
3560 * This source code is licensed under the BSD-style license found in the
3561 * LICENSE file in the root directory of this source tree. An additional grant
3562 * of patent rights can be found in the PATENTS file in the same directory.
3563 *
3564 * @providesModule ExecutionEnvironment
3565 */
3566
3567/*jslint evil: true */
3568
3569"use strict";
3570
3571var canUseDOM = !!(
3572 typeof window !== 'undefined' &&
3573 window.document &&
3574 window.document.createElement
3575);
3576
3577/**
3578 * Simple, lightweight module assisting with the detection and context of
3579 * Worker. Helps avoid circular dependencies and allows code to reason about
3580 * whether or not they are in a Worker, even if they never include the main
3581 * `ReactWorker` dependency.
3582 */
3583var ExecutionEnvironment = {
3584
3585 canUseDOM: canUseDOM,
3586
3587 canUseWorkers: typeof Worker !== 'undefined',
3588
3589 canUseEventListeners:
3590 canUseDOM && !!(window.addEventListener || window.attachEvent),
3591
3592 canUseViewport: canUseDOM && !!window.screen,
3593
3594 isInWorker: !canUseDOM // For now, this is true - might change in the future.
3595
3596};
3597
3598module.exports = ExecutionEnvironment;
3599
3600},{}],23:[function(_dereq_,module,exports){
3601/**
3602 * Copyright 2013-2014, Facebook, Inc.
3603 * All rights reserved.
3604 *
3605 * This source code is licensed under the BSD-style license found in the
3606 * LICENSE file in the root directory of this source tree. An additional grant
3607 * of patent rights can be found in the PATENTS file in the same directory.
3608 *
3609 * @providesModule HTMLDOMPropertyConfig
3610 */
3611
3612/*jslint bitwise: true*/
3613
3614"use strict";
3615
3616var DOMProperty = _dereq_("./DOMProperty");
3617var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
3618
3619var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
3620var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
3621var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
3622var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
3623var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
3624var HAS_POSITIVE_NUMERIC_VALUE =
3625 DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
3626var HAS_OVERLOADED_BOOLEAN_VALUE =
3627 DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
3628
3629var hasSVG;
3630if (ExecutionEnvironment.canUseDOM) {
3631 var implementation = document.implementation;
3632 hasSVG = (
3633 implementation &&
3634 implementation.hasFeature &&
3635 implementation.hasFeature(
3636 'http://www.w3.org/TR/SVG11/feature#BasicStructure',
3637 '1.1'
3638 )
3639 );
3640}
3641
3642
3643var HTMLDOMPropertyConfig = {
3644 isCustomAttribute: RegExp.prototype.test.bind(
3645 /^(data|aria)-[a-z_][a-z\d_.\-]*$/
3646 ),
3647 Properties: {
3648 /**
3649 * Standard Properties
3650 */
3651 accept: null,
3652 acceptCharset: null,
3653 accessKey: null,
3654 action: null,
3655 allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3656 allowTransparency: MUST_USE_ATTRIBUTE,
3657 alt: null,
3658 async: HAS_BOOLEAN_VALUE,
3659 autoComplete: null,
3660 // autoFocus is polyfilled/normalized by AutoFocusMixin
3661 // autoFocus: HAS_BOOLEAN_VALUE,
3662 autoPlay: HAS_BOOLEAN_VALUE,
3663 cellPadding: null,
3664 cellSpacing: null,
3665 charSet: MUST_USE_ATTRIBUTE,
3666 checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3667 classID: MUST_USE_ATTRIBUTE,
3668 // To set className on SVG elements, it's necessary to use .setAttribute;
3669 // this works on HTML elements too in all browsers except IE8. Conveniently,
3670 // IE8 doesn't support SVG and so we can simply use the attribute in
3671 // browsers that support SVG and the property in browsers that don't,
3672 // regardless of whether the element is HTML or SVG.
3673 className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
3674 cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3675 colSpan: null,
3676 content: null,
3677 contentEditable: null,
3678 contextMenu: MUST_USE_ATTRIBUTE,
3679 controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3680 coords: null,
3681 crossOrigin: null,
3682 data: null, // For `<object />` acts as `src`.
3683 dateTime: MUST_USE_ATTRIBUTE,
3684 defer: HAS_BOOLEAN_VALUE,
3685 dir: null,
3686 disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3687 download: HAS_OVERLOADED_BOOLEAN_VALUE,
3688 draggable: null,
3689 encType: null,
3690 form: MUST_USE_ATTRIBUTE,
3691 formAction: MUST_USE_ATTRIBUTE,
3692 formEncType: MUST_USE_ATTRIBUTE,
3693 formMethod: MUST_USE_ATTRIBUTE,
3694 formNoValidate: HAS_BOOLEAN_VALUE,
3695 formTarget: MUST_USE_ATTRIBUTE,
3696 frameBorder: MUST_USE_ATTRIBUTE,
3697 height: MUST_USE_ATTRIBUTE,
3698 hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3699 href: null,
3700 hrefLang: null,
3701 htmlFor: null,
3702 httpEquiv: null,
3703 icon: null,
3704 id: MUST_USE_PROPERTY,
3705 label: null,
3706 lang: null,
3707 list: MUST_USE_ATTRIBUTE,
3708 loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3709 manifest: MUST_USE_ATTRIBUTE,
3710 marginHeight: null,
3711 marginWidth: null,
3712 max: null,
3713 maxLength: MUST_USE_ATTRIBUTE,
3714 media: MUST_USE_ATTRIBUTE,
3715 mediaGroup: null,
3716 method: null,
3717 min: null,
3718 multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3719 muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3720 name: null,
3721 noValidate: HAS_BOOLEAN_VALUE,
3722 open: null,
3723 pattern: null,
3724 placeholder: null,
3725 poster: null,
3726 preload: null,
3727 radioGroup: null,
3728 readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3729 rel: null,
3730 required: HAS_BOOLEAN_VALUE,
3731 role: MUST_USE_ATTRIBUTE,
3732 rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3733 rowSpan: null,
3734 sandbox: null,
3735 scope: null,
3736 scrolling: null,
3737 seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3738 selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3739 shape: null,
3740 size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3741 sizes: MUST_USE_ATTRIBUTE,
3742 span: HAS_POSITIVE_NUMERIC_VALUE,
3743 spellCheck: null,
3744 src: null,
3745 srcDoc: MUST_USE_PROPERTY,
3746 srcSet: MUST_USE_ATTRIBUTE,
3747 start: HAS_NUMERIC_VALUE,
3748 step: null,
3749 style: null,
3750 tabIndex: null,
3751 target: null,
3752 title: null,
3753 type: null,
3754 useMap: null,
3755 value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
3756 width: MUST_USE_ATTRIBUTE,
3757 wmode: MUST_USE_ATTRIBUTE,
3758
3759 /**
3760 * Non-standard Properties
3761 */
3762 autoCapitalize: null, // Supported in Mobile Safari for keyboard hints
3763 autoCorrect: null, // Supported in Mobile Safari for keyboard hints
3764 itemProp: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
3765 itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE, // Microdata: http://schema.org/docs/gs.html
3766 itemType: MUST_USE_ATTRIBUTE, // Microdata: http://schema.org/docs/gs.html
3767 property: null // Supports OG in meta tags
3768 },
3769 DOMAttributeNames: {
3770 acceptCharset: 'accept-charset',
3771 className: 'class',
3772 htmlFor: 'for',
3773 httpEquiv: 'http-equiv'
3774 },
3775 DOMPropertyNames: {
3776 autoCapitalize: 'autocapitalize',
3777 autoComplete: 'autocomplete',
3778 autoCorrect: 'autocorrect',
3779 autoFocus: 'autofocus',
3780 autoPlay: 'autoplay',
3781 encType: 'enctype',
3782 hrefLang: 'hreflang',
3783 radioGroup: 'radiogroup',
3784 spellCheck: 'spellcheck',
3785 srcDoc: 'srcdoc',
3786 srcSet: 'srcset'
3787 }
3788};
3789
3790module.exports = HTMLDOMPropertyConfig;
3791
3792},{"./DOMProperty":11,"./ExecutionEnvironment":22}],24:[function(_dereq_,module,exports){
3793/**
3794 * Copyright 2013-2014, Facebook, Inc.
3795 * All rights reserved.
3796 *
3797 * This source code is licensed under the BSD-style license found in the
3798 * LICENSE file in the root directory of this source tree. An additional grant
3799 * of patent rights can be found in the PATENTS file in the same directory.
3800 *
3801 * @providesModule LinkedValueUtils
3802 * @typechecks static-only
3803 */
3804
3805"use strict";
3806
3807var ReactPropTypes = _dereq_("./ReactPropTypes");
3808
3809var invariant = _dereq_("./invariant");
3810
3811var hasReadOnlyValue = {
3812 'button': true,
3813 'checkbox': true,
3814 'image': true,
3815 'hidden': true,
3816 'radio': true,
3817 'reset': true,
3818 'submit': true
3819};
3820
3821function _assertSingleLink(input) {
3822 ("production" !== "development" ? invariant(
3823 input.props.checkedLink == null || input.props.valueLink == null,
3824 'Cannot provide a checkedLink and a valueLink. If you want to use ' +
3825 'checkedLink, you probably don\'t want to use valueLink and vice versa.'
3826 ) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
3827}
3828function _assertValueLink(input) {
3829 _assertSingleLink(input);
3830 ("production" !== "development" ? invariant(
3831 input.props.value == null && input.props.onChange == null,
3832 'Cannot provide a valueLink and a value or onChange event. If you want ' +
3833 'to use value or onChange, you probably don\'t want to use valueLink.'
3834 ) : invariant(input.props.value == null && input.props.onChange == null));
3835}
3836
3837function _assertCheckedLink(input) {
3838 _assertSingleLink(input);
3839 ("production" !== "development" ? invariant(
3840 input.props.checked == null && input.props.onChange == null,
3841 'Cannot provide a checkedLink and a checked property or onChange event. ' +
3842 'If you want to use checked or onChange, you probably don\'t want to ' +
3843 'use checkedLink'
3844 ) : invariant(input.props.checked == null && input.props.onChange == null));
3845}
3846
3847/**
3848 * @param {SyntheticEvent} e change event to handle
3849 */
3850function _handleLinkedValueChange(e) {
3851 /*jshint validthis:true */
3852 this.props.valueLink.requestChange(e.target.value);
3853}
3854
3855/**
3856 * @param {SyntheticEvent} e change event to handle
3857 */
3858function _handleLinkedCheckChange(e) {
3859 /*jshint validthis:true */
3860 this.props.checkedLink.requestChange(e.target.checked);
3861}
3862
3863/**
3864 * Provide a linked `value` attribute for controlled forms. You should not use
3865 * this outside of the ReactDOM controlled form components.
3866 */
3867var LinkedValueUtils = {
3868 Mixin: {
3869 propTypes: {
3870 value: function(props, propName, componentName) {
3871 if (!props[propName] ||
3872 hasReadOnlyValue[props.type] ||
3873 props.onChange ||
3874 props.readOnly ||
3875 props.disabled) {
3876 return;
3877 }
3878 return new Error(
3879 'You provided a `value` prop to a form field without an ' +
3880 '`onChange` handler. This will render a read-only field. If ' +
3881 'the field should be mutable use `defaultValue`. Otherwise, ' +
3882 'set either `onChange` or `readOnly`.'
3883 );
3884 },
3885 checked: function(props, propName, componentName) {
3886 if (!props[propName] ||
3887 props.onChange ||
3888 props.readOnly ||
3889 props.disabled) {
3890 return;
3891 }
3892 return new Error(
3893 'You provided a `checked` prop to a form field without an ' +
3894 '`onChange` handler. This will render a read-only field. If ' +
3895 'the field should be mutable use `defaultChecked`. Otherwise, ' +
3896 'set either `onChange` or `readOnly`.'
3897 );
3898 },
3899 onChange: ReactPropTypes.func
3900 }
3901 },
3902
3903 /**
3904 * @param {ReactComponent} input Form component
3905 * @return {*} current value of the input either from value prop or link.
3906 */
3907 getValue: function(input) {
3908 if (input.props.valueLink) {
3909 _assertValueLink(input);
3910 return input.props.valueLink.value;
3911 }
3912 return input.props.value;
3913 },
3914
3915 /**
3916 * @param {ReactComponent} input Form component
3917 * @return {*} current checked status of the input either from checked prop
3918 * or link.
3919 */
3920 getChecked: function(input) {
3921 if (input.props.checkedLink) {
3922 _assertCheckedLink(input);
3923 return input.props.checkedLink.value;
3924 }
3925 return input.props.checked;
3926 },
3927
3928 /**
3929 * @param {ReactComponent} input Form component
3930 * @return {function} change callback either from onChange prop or link.
3931 */
3932 getOnChange: function(input) {
3933 if (input.props.valueLink) {
3934 _assertValueLink(input);
3935 return _handleLinkedValueChange;
3936 } else if (input.props.checkedLink) {
3937 _assertCheckedLink(input);
3938 return _handleLinkedCheckChange;
3939 }
3940 return input.props.onChange;
3941 }
3942};
3943
3944module.exports = LinkedValueUtils;
3945
3946},{"./ReactPropTypes":72,"./invariant":126}],25:[function(_dereq_,module,exports){
3947/**
3948 * Copyright 2014, Facebook, Inc.
3949 * All rights reserved.
3950 *
3951 * This source code is licensed under the BSD-style license found in the
3952 * LICENSE file in the root directory of this source tree. An additional grant
3953 * of patent rights can be found in the PATENTS file in the same directory.
3954 *
3955 * @providesModule LocalEventTrapMixin
3956 */
3957
3958"use strict";
3959
3960var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
3961
3962var accumulateInto = _dereq_("./accumulateInto");
3963var forEachAccumulated = _dereq_("./forEachAccumulated");
3964var invariant = _dereq_("./invariant");
3965
3966function remove(event) {
3967 event.remove();
3968}
3969
3970var LocalEventTrapMixin = {
3971 trapBubbledEvent:function(topLevelType, handlerBaseName) {
3972 ("production" !== "development" ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
3973 var listener = ReactBrowserEventEmitter.trapBubbledEvent(
3974 topLevelType,
3975 handlerBaseName,
3976 this.getDOMNode()
3977 );
3978 this._localEventListeners =
3979 accumulateInto(this._localEventListeners, listener);
3980 },
3981
3982 // trapCapturedEvent would look nearly identical. We don't implement that
3983 // method because it isn't currently needed.
3984
3985 componentWillUnmount:function() {
3986 if (this._localEventListeners) {
3987 forEachAccumulated(this._localEventListeners, remove);
3988 }
3989 }
3990};
3991
3992module.exports = LocalEventTrapMixin;
3993
3994},{"./ReactBrowserEventEmitter":30,"./accumulateInto":97,"./forEachAccumulated":112,"./invariant":126}],26:[function(_dereq_,module,exports){
3995/**
3996 * Copyright 2013-2014, Facebook, Inc.
3997 * All rights reserved.
3998 *
3999 * This source code is licensed under the BSD-style license found in the
4000 * LICENSE file in the root directory of this source tree. An additional grant
4001 * of patent rights can be found in the PATENTS file in the same directory.
4002 *
4003 * @providesModule MobileSafariClickEventPlugin
4004 * @typechecks static-only
4005 */
4006
4007"use strict";
4008
4009var EventConstants = _dereq_("./EventConstants");
4010
4011var emptyFunction = _dereq_("./emptyFunction");
4012
4013var topLevelTypes = EventConstants.topLevelTypes;
4014
4015/**
4016 * Mobile Safari does not fire properly bubble click events on non-interactive
4017 * elements, which means delegated click listeners do not fire. The workaround
4018 * for this bug involves attaching an empty click listener on the target node.
4019 *
4020 * This particular plugin works around the bug by attaching an empty click
4021 * listener on `touchstart` (which does fire on every element).
4022 */
4023var MobileSafariClickEventPlugin = {
4024
4025 eventTypes: null,
4026
4027 /**
4028 * @param {string} topLevelType Record from `EventConstants`.
4029 * @param {DOMEventTarget} topLevelTarget The listening component root node.
4030 * @param {string} topLevelTargetID ID of `topLevelTarget`.
4031 * @param {object} nativeEvent Native browser event.
4032 * @return {*} An accumulation of synthetic events.
4033 * @see {EventPluginHub.extractEvents}
4034 */
4035 extractEvents: function(
4036 topLevelType,
4037 topLevelTarget,
4038 topLevelTargetID,
4039 nativeEvent) {
4040 if (topLevelType === topLevelTypes.topTouchStart) {
4041 var target = nativeEvent.target;
4042 if (target && !target.onclick) {
4043 target.onclick = emptyFunction;
4044 }
4045 }
4046 }
4047
4048};
4049
4050module.exports = MobileSafariClickEventPlugin;
4051
4052},{"./EventConstants":16,"./emptyFunction":107}],27:[function(_dereq_,module,exports){
4053/**
4054 * Copyright 2014, Facebook, Inc.
4055 * All rights reserved.
4056 *
4057 * This source code is licensed under the BSD-style license found in the
4058 * LICENSE file in the root directory of this source tree. An additional grant
4059 * of patent rights can be found in the PATENTS file in the same directory.
4060 *
4061 * @providesModule Object.assign
4062 */
4063
4064// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
4065
4066function assign(target, sources) {
4067 if (target == null) {
4068 throw new TypeError('Object.assign target cannot be null or undefined');
4069 }
4070
4071 var to = Object(target);
4072 var hasOwnProperty = Object.prototype.hasOwnProperty;
4073
4074 for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
4075 var nextSource = arguments[nextIndex];
4076 if (nextSource == null) {
4077 continue;
4078 }
4079
4080 var from = Object(nextSource);
4081
4082 // We don't currently support accessors nor proxies. Therefore this
4083 // copy cannot throw. If we ever supported this then we must handle
4084 // exceptions and side-effects. We don't support symbols so they won't
4085 // be transferred.
4086
4087 for (var key in from) {
4088 if (hasOwnProperty.call(from, key)) {
4089 to[key] = from[key];
4090 }
4091 }
4092 }
4093
4094 return to;
4095};
4096
4097module.exports = assign;
4098
4099},{}],28:[function(_dereq_,module,exports){
4100/**
4101 * Copyright 2013-2014, Facebook, Inc.
4102 * All rights reserved.
4103 *
4104 * This source code is licensed under the BSD-style license found in the
4105 * LICENSE file in the root directory of this source tree. An additional grant
4106 * of patent rights can be found in the PATENTS file in the same directory.
4107 *
4108 * @providesModule PooledClass
4109 */
4110
4111"use strict";
4112
4113var invariant = _dereq_("./invariant");
4114
4115/**
4116 * Static poolers. Several custom versions for each potential number of
4117 * arguments. A completely generic pooler is easy to implement, but would
4118 * require accessing the `arguments` object. In each of these, `this` refers to
4119 * the Class itself, not an instance. If any others are needed, simply add them
4120 * here, or in their own files.
4121 */
4122var oneArgumentPooler = function(copyFieldsFrom) {
4123 var Klass = this;
4124 if (Klass.instancePool.length) {
4125 var instance = Klass.instancePool.pop();
4126 Klass.call(instance, copyFieldsFrom);
4127 return instance;
4128 } else {
4129 return new Klass(copyFieldsFrom);
4130 }
4131};
4132
4133var twoArgumentPooler = function(a1, a2) {
4134 var Klass = this;
4135 if (Klass.instancePool.length) {
4136 var instance = Klass.instancePool.pop();
4137 Klass.call(instance, a1, a2);
4138 return instance;
4139 } else {
4140 return new Klass(a1, a2);
4141 }
4142};
4143
4144var threeArgumentPooler = function(a1, a2, a3) {
4145 var Klass = this;
4146 if (Klass.instancePool.length) {
4147 var instance = Klass.instancePool.pop();
4148 Klass.call(instance, a1, a2, a3);
4149 return instance;
4150 } else {
4151 return new Klass(a1, a2, a3);
4152 }
4153};
4154
4155var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
4156 var Klass = this;
4157 if (Klass.instancePool.length) {
4158 var instance = Klass.instancePool.pop();
4159 Klass.call(instance, a1, a2, a3, a4, a5);
4160 return instance;
4161 } else {
4162 return new Klass(a1, a2, a3, a4, a5);
4163 }
4164};
4165
4166var standardReleaser = function(instance) {
4167 var Klass = this;
4168 ("production" !== "development" ? invariant(
4169 instance instanceof Klass,
4170 'Trying to release an instance into a pool of a different type.'
4171 ) : invariant(instance instanceof Klass));
4172 if (instance.destructor) {
4173 instance.destructor();
4174 }
4175 if (Klass.instancePool.length < Klass.poolSize) {
4176 Klass.instancePool.push(instance);
4177 }
4178};
4179
4180var DEFAULT_POOL_SIZE = 10;
4181var DEFAULT_POOLER = oneArgumentPooler;
4182
4183/**
4184 * Augments `CopyConstructor` to be a poolable class, augmenting only the class
4185 * itself (statically) not adding any prototypical fields. Any CopyConstructor
4186 * you give this may have a `poolSize` property, and will look for a
4187 * prototypical `destructor` on instances (optional).
4188 *
4189 * @param {Function} CopyConstructor Constructor that can be used to reset.
4190 * @param {Function} pooler Customizable pooler.
4191 */
4192var addPoolingTo = function(CopyConstructor, pooler) {
4193 var NewKlass = CopyConstructor;
4194 NewKlass.instancePool = [];
4195 NewKlass.getPooled = pooler || DEFAULT_POOLER;
4196 if (!NewKlass.poolSize) {
4197 NewKlass.poolSize = DEFAULT_POOL_SIZE;
4198 }
4199 NewKlass.release = standardReleaser;
4200 return NewKlass;
4201};
4202
4203var PooledClass = {
4204 addPoolingTo: addPoolingTo,
4205 oneArgumentPooler: oneArgumentPooler,
4206 twoArgumentPooler: twoArgumentPooler,
4207 threeArgumentPooler: threeArgumentPooler,
4208 fiveArgumentPooler: fiveArgumentPooler
4209};
4210
4211module.exports = PooledClass;
4212
4213},{"./invariant":126}],29:[function(_dereq_,module,exports){
4214/**
4215 * Copyright 2013-2014, Facebook, Inc.
4216 * All rights reserved.
4217 *
4218 * This source code is licensed under the BSD-style license found in the
4219 * LICENSE file in the root directory of this source tree. An additional grant
4220 * of patent rights can be found in the PATENTS file in the same directory.
4221 *
4222 * @providesModule ReactBrowserComponentMixin
4223 */
4224
4225"use strict";
4226
4227var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
4228var ReactMount = _dereq_("./ReactMount");
4229
4230var invariant = _dereq_("./invariant");
4231
4232var ReactBrowserComponentMixin = {
4233 /**
4234 * Returns the DOM node rendered by this component.
4235 *
4236 * @return {DOMElement} The root node of this component.
4237 * @final
4238 * @protected
4239 */
4240 getDOMNode: function() {
4241 ("production" !== "development" ? invariant(
4242 this.isMounted(),
4243 'getDOMNode(): A component must be mounted to have a DOM node.'
4244 ) : invariant(this.isMounted()));
4245 if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
4246 return null;
4247 }
4248 return ReactMount.getNode(this._rootNodeID);
4249 }
4250};
4251
4252module.exports = ReactBrowserComponentMixin;
4253
4254},{"./ReactEmptyComponent":54,"./ReactMount":63,"./invariant":126}],30:[function(_dereq_,module,exports){
4255/**
4256 * Copyright 2013-2014, Facebook, Inc.
4257 * All rights reserved.
4258 *
4259 * This source code is licensed under the BSD-style license found in the
4260 * LICENSE file in the root directory of this source tree. An additional grant
4261 * of patent rights can be found in the PATENTS file in the same directory.
4262 *
4263 * @providesModule ReactBrowserEventEmitter
4264 * @typechecks static-only
4265 */
4266
4267"use strict";
4268
4269var EventConstants = _dereq_("./EventConstants");
4270var EventPluginHub = _dereq_("./EventPluginHub");
4271var EventPluginRegistry = _dereq_("./EventPluginRegistry");
4272var ReactEventEmitterMixin = _dereq_("./ReactEventEmitterMixin");
4273var ViewportMetrics = _dereq_("./ViewportMetrics");
4274
4275var assign = _dereq_("./Object.assign");
4276var isEventSupported = _dereq_("./isEventSupported");
4277
4278/**
4279 * Summary of `ReactBrowserEventEmitter` event handling:
4280 *
4281 * - Top-level delegation is used to trap most native browser events. This
4282 * may only occur in the main thread and is the responsibility of
4283 * ReactEventListener, which is injected and can therefore support pluggable
4284 * event sources. This is the only work that occurs in the main thread.
4285 *
4286 * - We normalize and de-duplicate events to account for browser quirks. This
4287 * may be done in the worker thread.
4288 *
4289 * - Forward these native events (with the associated top-level type used to
4290 * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
4291 * to extract any synthetic events.
4292 *
4293 * - The `EventPluginHub` will then process each event by annotating them with
4294 * "dispatches", a sequence of listeners and IDs that care about that event.
4295 *
4296 * - The `EventPluginHub` then dispatches the events.
4297 *
4298 * Overview of React and the event system:
4299 *
4300 * +------------+ .
4301 * | DOM | .
4302 * +------------+ .
4303 * | .
4304 * v .
4305 * +------------+ .
4306 * | ReactEvent | .
4307 * | Listener | .
4308 * +------------+ . +-----------+
4309 * | . +--------+|SimpleEvent|
4310 * | . | |Plugin |
4311 * +-----|------+ . v +-----------+
4312 * | | | . +--------------+ +------------+
4313 * | +-----------.--->|EventPluginHub| | Event |
4314 * | | . | | +-----------+ | Propagators|
4315 * | ReactEvent | . | | |TapEvent | |------------|
4316 * | Emitter | . | |<---+|Plugin | |other plugin|
4317 * | | . | | +-----------+ | utilities |
4318 * | +-----------.--->| | +------------+
4319 * | | | . +--------------+
4320 * +-----|------+ . ^ +-----------+
4321 * | . | |Enter/Leave|
4322 * + . +-------+|Plugin |
4323 * +-------------+ . +-----------+
4324 * | application | .
4325 * |-------------| .
4326 * | | .
4327 * | | .
4328 * +-------------+ .
4329 * .
4330 * React Core . General Purpose Event Plugin System
4331 */
4332
4333var alreadyListeningTo = {};
4334var isMonitoringScrollValue = false;
4335var reactTopListenersCounter = 0;
4336
4337// For events like 'submit' which don't consistently bubble (which we trap at a
4338// lower node than `document`), binding at `document` would cause duplicate
4339// events so we don't include them here
4340var topEventMapping = {
4341 topBlur: 'blur',
4342 topChange: 'change',
4343 topClick: 'click',
4344 topCompositionEnd: 'compositionend',
4345 topCompositionStart: 'compositionstart',
4346 topCompositionUpdate: 'compositionupdate',
4347 topContextMenu: 'contextmenu',
4348 topCopy: 'copy',
4349 topCut: 'cut',
4350 topDoubleClick: 'dblclick',
4351 topDrag: 'drag',
4352 topDragEnd: 'dragend',
4353 topDragEnter: 'dragenter',
4354 topDragExit: 'dragexit',
4355 topDragLeave: 'dragleave',
4356 topDragOver: 'dragover',
4357 topDragStart: 'dragstart',
4358 topDrop: 'drop',
4359 topFocus: 'focus',
4360 topInput: 'input',
4361 topKeyDown: 'keydown',
4362 topKeyPress: 'keypress',
4363 topKeyUp: 'keyup',
4364 topMouseDown: 'mousedown',
4365 topMouseMove: 'mousemove',
4366 topMouseOut: 'mouseout',
4367 topMouseOver: 'mouseover',
4368 topMouseUp: 'mouseup',
4369 topPaste: 'paste',
4370 topScroll: 'scroll',
4371 topSelectionChange: 'selectionchange',
4372 topTextInput: 'textInput',
4373 topTouchCancel: 'touchcancel',
4374 topTouchEnd: 'touchend',
4375 topTouchMove: 'touchmove',
4376 topTouchStart: 'touchstart',
4377 topWheel: 'wheel'
4378};
4379
4380/**
4381 * To ensure no conflicts with other potential React instances on the page
4382 */
4383var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2);
4384
4385function getListeningForDocument(mountAt) {
4386 // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
4387 // directly.
4388 if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
4389 mountAt[topListenersIDKey] = reactTopListenersCounter++;
4390 alreadyListeningTo[mountAt[topListenersIDKey]] = {};
4391 }
4392 return alreadyListeningTo[mountAt[topListenersIDKey]];
4393}
4394
4395/**
4396 * `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
4397 * example:
4398 *
4399 * ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
4400 *
4401 * This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
4402 *
4403 * @internal
4404 */
4405var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
4406
4407 /**
4408 * Injectable event backend
4409 */
4410 ReactEventListener: null,
4411
4412 injection: {
4413 /**
4414 * @param {object} ReactEventListener
4415 */
4416 injectReactEventListener: function(ReactEventListener) {
4417 ReactEventListener.setHandleTopLevel(
4418 ReactBrowserEventEmitter.handleTopLevel
4419 );
4420 ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
4421 }
4422 },
4423
4424 /**
4425 * Sets whether or not any created callbacks should be enabled.
4426 *
4427 * @param {boolean} enabled True if callbacks should be enabled.
4428 */
4429 setEnabled: function(enabled) {
4430 if (ReactBrowserEventEmitter.ReactEventListener) {
4431 ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
4432 }
4433 },
4434
4435 /**
4436 * @return {boolean} True if callbacks are enabled.
4437 */
4438 isEnabled: function() {
4439 return !!(
4440 ReactBrowserEventEmitter.ReactEventListener &&
4441 ReactBrowserEventEmitter.ReactEventListener.isEnabled()
4442 );
4443 },
4444
4445 /**
4446 * We listen for bubbled touch events on the document object.
4447 *
4448 * Firefox v8.01 (and possibly others) exhibited strange behavior when
4449 * mounting `onmousemove` events at some node that was not the document
4450 * element. The symptoms were that if your mouse is not moving over something
4451 * contained within that mount point (for example on the background) the
4452 * top-level listeners for `onmousemove` won't be called. However, if you
4453 * register the `mousemove` on the document object, then it will of course
4454 * catch all `mousemove`s. This along with iOS quirks, justifies restricting
4455 * top-level listeners to the document object only, at least for these
4456 * movement types of events and possibly all events.
4457 *
4458 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
4459 *
4460 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
4461 * they bubble to document.
4462 *
4463 * @param {string} registrationName Name of listener (e.g. `onClick`).
4464 * @param {object} contentDocumentHandle Document which owns the container
4465 */
4466 listenTo: function(registrationName, contentDocumentHandle) {
4467 var mountAt = contentDocumentHandle;
4468 var isListening = getListeningForDocument(mountAt);
4469 var dependencies = EventPluginRegistry.
4470 registrationNameDependencies[registrationName];
4471
4472 var topLevelTypes = EventConstants.topLevelTypes;
4473 for (var i = 0, l = dependencies.length; i < l; i++) {
4474 var dependency = dependencies[i];
4475 if (!(
4476 isListening.hasOwnProperty(dependency) &&
4477 isListening[dependency]
4478 )) {
4479 if (dependency === topLevelTypes.topWheel) {
4480 if (isEventSupported('wheel')) {
4481 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4482 topLevelTypes.topWheel,
4483 'wheel',
4484 mountAt
4485 );
4486 } else if (isEventSupported('mousewheel')) {
4487 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4488 topLevelTypes.topWheel,
4489 'mousewheel',
4490 mountAt
4491 );
4492 } else {
4493 // Firefox needs to capture a different mouse scroll event.
4494 // @see http://www.quirksmode.org/dom/events/tests/scroll.html
4495 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4496 topLevelTypes.topWheel,
4497 'DOMMouseScroll',
4498 mountAt
4499 );
4500 }
4501 } else if (dependency === topLevelTypes.topScroll) {
4502
4503 if (isEventSupported('scroll', true)) {
4504 ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4505 topLevelTypes.topScroll,
4506 'scroll',
4507 mountAt
4508 );
4509 } else {
4510 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4511 topLevelTypes.topScroll,
4512 'scroll',
4513 ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
4514 );
4515 }
4516 } else if (dependency === topLevelTypes.topFocus ||
4517 dependency === topLevelTypes.topBlur) {
4518
4519 if (isEventSupported('focus', true)) {
4520 ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4521 topLevelTypes.topFocus,
4522 'focus',
4523 mountAt
4524 );
4525 ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4526 topLevelTypes.topBlur,
4527 'blur',
4528 mountAt
4529 );
4530 } else if (isEventSupported('focusin')) {
4531 // IE has `focusin` and `focusout` events which bubble.
4532 // @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
4533 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4534 topLevelTypes.topFocus,
4535 'focusin',
4536 mountAt
4537 );
4538 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4539 topLevelTypes.topBlur,
4540 'focusout',
4541 mountAt
4542 );
4543 }
4544
4545 // to make sure blur and focus event listeners are only attached once
4546 isListening[topLevelTypes.topBlur] = true;
4547 isListening[topLevelTypes.topFocus] = true;
4548 } else if (topEventMapping.hasOwnProperty(dependency)) {
4549 ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4550 dependency,
4551 topEventMapping[dependency],
4552 mountAt
4553 );
4554 }
4555
4556 isListening[dependency] = true;
4557 }
4558 }
4559 },
4560
4561 trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
4562 return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4563 topLevelType,
4564 handlerBaseName,
4565 handle
4566 );
4567 },
4568
4569 trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
4570 return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4571 topLevelType,
4572 handlerBaseName,
4573 handle
4574 );
4575 },
4576
4577 /**
4578 * Listens to window scroll and resize events. We cache scroll values so that
4579 * application code can access them without triggering reflows.
4580 *
4581 * NOTE: Scroll events do not bubble.
4582 *
4583 * @see http://www.quirksmode.org/dom/events/scroll.html
4584 */
4585 ensureScrollValueMonitoring: function(){
4586 if (!isMonitoringScrollValue) {
4587 var refresh = ViewportMetrics.refreshScrollValues;
4588 ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
4589 isMonitoringScrollValue = true;
4590 }
4591 },
4592
4593 eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
4594
4595 registrationNameModules: EventPluginHub.registrationNameModules,
4596
4597 putListener: EventPluginHub.putListener,
4598
4599 getListener: EventPluginHub.getListener,
4600
4601 deleteListener: EventPluginHub.deleteListener,
4602
4603 deleteAllListeners: EventPluginHub.deleteAllListeners
4604
4605});
4606
4607module.exports = ReactBrowserEventEmitter;
4608
4609},{"./EventConstants":16,"./EventPluginHub":18,"./EventPluginRegistry":19,"./Object.assign":27,"./ReactEventEmitterMixin":56,"./ViewportMetrics":96,"./isEventSupported":127}],31:[function(_dereq_,module,exports){
4610/**
4611 * Copyright 2013-2014, Facebook, Inc.
4612 * All rights reserved.
4613 *
4614 * This source code is licensed under the BSD-style license found in the
4615 * LICENSE file in the root directory of this source tree. An additional grant
4616 * of patent rights can be found in the PATENTS file in the same directory.
4617 *
4618 * @providesModule ReactChildren
4619 */
4620
4621"use strict";
4622
4623var PooledClass = _dereq_("./PooledClass");
4624
4625var traverseAllChildren = _dereq_("./traverseAllChildren");
4626var warning = _dereq_("./warning");
4627
4628var twoArgumentPooler = PooledClass.twoArgumentPooler;
4629var threeArgumentPooler = PooledClass.threeArgumentPooler;
4630
4631/**
4632 * PooledClass representing the bookkeeping associated with performing a child
4633 * traversal. Allows avoiding binding callbacks.
4634 *
4635 * @constructor ForEachBookKeeping
4636 * @param {!function} forEachFunction Function to perform traversal with.
4637 * @param {?*} forEachContext Context to perform context with.
4638 */
4639function ForEachBookKeeping(forEachFunction, forEachContext) {
4640 this.forEachFunction = forEachFunction;
4641 this.forEachContext = forEachContext;
4642}
4643PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
4644
4645function forEachSingleChild(traverseContext, child, name, i) {
4646 var forEachBookKeeping = traverseContext;
4647 forEachBookKeeping.forEachFunction.call(
4648 forEachBookKeeping.forEachContext, child, i);
4649}
4650
4651/**
4652 * Iterates through children that are typically specified as `props.children`.
4653 *
4654 * The provided forEachFunc(child, index) will be called for each
4655 * leaf child.
4656 *
4657 * @param {?*} children Children tree container.
4658 * @param {function(*, int)} forEachFunc.
4659 * @param {*} forEachContext Context for forEachContext.
4660 */
4661function forEachChildren(children, forEachFunc, forEachContext) {
4662 if (children == null) {
4663 return children;
4664 }
4665
4666 var traverseContext =
4667 ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
4668 traverseAllChildren(children, forEachSingleChild, traverseContext);
4669 ForEachBookKeeping.release(traverseContext);
4670}
4671
4672/**
4673 * PooledClass representing the bookkeeping associated with performing a child
4674 * mapping. Allows avoiding binding callbacks.
4675 *
4676 * @constructor MapBookKeeping
4677 * @param {!*} mapResult Object containing the ordered map of results.
4678 * @param {!function} mapFunction Function to perform mapping with.
4679 * @param {?*} mapContext Context to perform mapping with.
4680 */
4681function MapBookKeeping(mapResult, mapFunction, mapContext) {
4682 this.mapResult = mapResult;
4683 this.mapFunction = mapFunction;
4684 this.mapContext = mapContext;
4685}
4686PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
4687
4688function mapSingleChildIntoContext(traverseContext, child, name, i) {
4689 var mapBookKeeping = traverseContext;
4690 var mapResult = mapBookKeeping.mapResult;
4691
4692 var keyUnique = !mapResult.hasOwnProperty(name);
4693 ("production" !== "development" ? warning(
4694 keyUnique,
4695 'ReactChildren.map(...): Encountered two children with the same key, ' +
4696 '`%s`. Child keys must be unique; when two children share a key, only ' +
4697 'the first child will be used.',
4698 name
4699 ) : null);
4700
4701 if (keyUnique) {
4702 var mappedChild =
4703 mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
4704 mapResult[name] = mappedChild;
4705 }
4706}
4707
4708/**
4709 * Maps children that are typically specified as `props.children`.
4710 *
4711 * The provided mapFunction(child, key, index) will be called for each
4712 * leaf child.
4713 *
4714 * TODO: This may likely break any calls to `ReactChildren.map` that were
4715 * previously relying on the fact that we guarded against null children.
4716 *
4717 * @param {?*} children Children tree container.
4718 * @param {function(*, int)} mapFunction.
4719 * @param {*} mapContext Context for mapFunction.
4720 * @return {object} Object containing the ordered map of results.
4721 */
4722function mapChildren(children, func, context) {
4723 if (children == null) {
4724 return children;
4725 }
4726
4727 var mapResult = {};
4728 var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
4729 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
4730 MapBookKeeping.release(traverseContext);
4731 return mapResult;
4732}
4733
4734function forEachSingleChildDummy(traverseContext, child, name, i) {
4735 return null;
4736}
4737
4738/**
4739 * Count the number of children that are typically specified as
4740 * `props.children`.
4741 *
4742 * @param {?*} children Children tree container.
4743 * @return {number} The number of children.
4744 */
4745function countChildren(children, context) {
4746 return traverseAllChildren(children, forEachSingleChildDummy, null);
4747}
4748
4749var ReactChildren = {
4750 forEach: forEachChildren,
4751 map: mapChildren,
4752 count: countChildren
4753};
4754
4755module.exports = ReactChildren;
4756
4757},{"./PooledClass":28,"./traverseAllChildren":144,"./warning":145}],32:[function(_dereq_,module,exports){
4758/**
4759 * Copyright 2013-2014, Facebook, Inc.
4760 * All rights reserved.
4761 *
4762 * This source code is licensed under the BSD-style license found in the
4763 * LICENSE file in the root directory of this source tree. An additional grant
4764 * of patent rights can be found in the PATENTS file in the same directory.
4765 *
4766 * @providesModule ReactComponent
4767 */
4768
4769"use strict";
4770
4771var ReactElement = _dereq_("./ReactElement");
4772var ReactOwner = _dereq_("./ReactOwner");
4773var ReactUpdates = _dereq_("./ReactUpdates");
4774
4775var assign = _dereq_("./Object.assign");
4776var invariant = _dereq_("./invariant");
4777var keyMirror = _dereq_("./keyMirror");
4778
4779/**
4780 * Every React component is in one of these life cycles.
4781 */
4782var ComponentLifeCycle = keyMirror({
4783 /**
4784 * Mounted components have a DOM node representation and are capable of
4785 * receiving new props.
4786 */
4787 MOUNTED: null,
4788 /**
4789 * Unmounted components are inactive and cannot receive new props.
4790 */
4791 UNMOUNTED: null
4792});
4793
4794var injected = false;
4795
4796/**
4797 * Optionally injectable environment dependent cleanup hook. (server vs.
4798 * browser etc). Example: A browser system caches DOM nodes based on component
4799 * ID and must remove that cache entry when this instance is unmounted.
4800 *
4801 * @private
4802 */
4803var unmountIDFromEnvironment = null;
4804
4805/**
4806 * The "image" of a component tree, is the platform specific (typically
4807 * serialized) data that represents a tree of lower level UI building blocks.
4808 * On the web, this "image" is HTML markup which describes a construction of
4809 * low level `div` and `span` nodes. Other platforms may have different
4810 * encoding of this "image". This must be injected.
4811 *
4812 * @private
4813 */
4814var mountImageIntoNode = null;
4815
4816/**
4817 * Components are the basic units of composition in React.
4818 *
4819 * Every component accepts a set of keyed input parameters known as "props" that
4820 * are initialized by the constructor. Once a component is mounted, the props
4821 * can be mutated using `setProps` or `replaceProps`.
4822 *
4823 * Every component is capable of the following operations:
4824 *
4825 * `mountComponent`
4826 * Initializes the component, renders markup, and registers event listeners.
4827 *
4828 * `receiveComponent`
4829 * Updates the rendered DOM nodes to match the given component.
4830 *
4831 * `unmountComponent`
4832 * Releases any resources allocated by this component.
4833 *
4834 * Components can also be "owned" by other components. Being owned by another
4835 * component means being constructed by that component. This is different from
4836 * being the child of a component, which means having a DOM representation that
4837 * is a child of the DOM representation of that component.
4838 *
4839 * @class ReactComponent
4840 */
4841var ReactComponent = {
4842
4843 injection: {
4844 injectEnvironment: function(ReactComponentEnvironment) {
4845 ("production" !== "development" ? invariant(
4846 !injected,
4847 'ReactComponent: injectEnvironment() can only be called once.'
4848 ) : invariant(!injected));
4849 mountImageIntoNode = ReactComponentEnvironment.mountImageIntoNode;
4850 unmountIDFromEnvironment =
4851 ReactComponentEnvironment.unmountIDFromEnvironment;
4852 ReactComponent.BackendIDOperations =
4853 ReactComponentEnvironment.BackendIDOperations;
4854 injected = true;
4855 }
4856 },
4857
4858 /**
4859 * @internal
4860 */
4861 LifeCycle: ComponentLifeCycle,
4862
4863 /**
4864 * Injected module that provides ability to mutate individual properties.
4865 * Injected into the base class because many different subclasses need access
4866 * to this.
4867 *
4868 * @internal
4869 */
4870 BackendIDOperations: null,
4871
4872 /**
4873 * Base functionality for every ReactComponent constructor. Mixed into the
4874 * `ReactComponent` prototype, but exposed statically for easy access.
4875 *
4876 * @lends {ReactComponent.prototype}
4877 */
4878 Mixin: {
4879
4880 /**
4881 * Checks whether or not this component is mounted.
4882 *
4883 * @return {boolean} True if mounted, false otherwise.
4884 * @final
4885 * @protected
4886 */
4887 isMounted: function() {
4888 return this._lifeCycleState === ComponentLifeCycle.MOUNTED;
4889 },
4890
4891 /**
4892 * Sets a subset of the props.
4893 *
4894 * @param {object} partialProps Subset of the next props.
4895 * @param {?function} callback Called after props are updated.
4896 * @final
4897 * @public
4898 */
4899 setProps: function(partialProps, callback) {
4900 // Merge with the pending element if it exists, otherwise with existing
4901 // element props.
4902 var element = this._pendingElement || this._currentElement;
4903 this.replaceProps(
4904 assign({}, element.props, partialProps),
4905 callback
4906 );
4907 },
4908
4909 /**
4910 * Replaces all of the props.
4911 *
4912 * @param {object} props New props.
4913 * @param {?function} callback Called after props are updated.
4914 * @final
4915 * @public
4916 */
4917 replaceProps: function(props, callback) {
4918 ("production" !== "development" ? invariant(
4919 this.isMounted(),
4920 'replaceProps(...): Can only update a mounted component.'
4921 ) : invariant(this.isMounted()));
4922 ("production" !== "development" ? invariant(
4923 this._mountDepth === 0,
4924 'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
4925 'component with a parent. This is an anti-pattern since props will ' +
4926 'get reactively updated when rendered. Instead, change the owner\'s ' +
4927 '`render` method to pass the correct value as props to the component ' +
4928 'where it is created.'
4929 ) : invariant(this._mountDepth === 0));
4930 // This is a deoptimized path. We optimize for always having a element.
4931 // This creates an extra internal element.
4932 this._pendingElement = ReactElement.cloneAndReplaceProps(
4933 this._pendingElement || this._currentElement,
4934 props
4935 );
4936 ReactUpdates.enqueueUpdate(this, callback);
4937 },
4938
4939 /**
4940 * Schedule a partial update to the props. Only used for internal testing.
4941 *
4942 * @param {object} partialProps Subset of the next props.
4943 * @param {?function} callback Called after props are updated.
4944 * @final
4945 * @internal
4946 */
4947 _setPropsInternal: function(partialProps, callback) {
4948 // This is a deoptimized path. We optimize for always having a element.
4949 // This creates an extra internal element.
4950 var element = this._pendingElement || this._currentElement;
4951 this._pendingElement = ReactElement.cloneAndReplaceProps(
4952 element,
4953 assign({}, element.props, partialProps)
4954 );
4955 ReactUpdates.enqueueUpdate(this, callback);
4956 },
4957
4958 /**
4959 * Base constructor for all React components.
4960 *
4961 * Subclasses that override this method should make sure to invoke
4962 * `ReactComponent.Mixin.construct.call(this, ...)`.
4963 *
4964 * @param {ReactElement} element
4965 * @internal
4966 */
4967 construct: function(element) {
4968 // This is the public exposed props object after it has been processed
4969 // with default props. The element's props represents the true internal
4970 // state of the props.
4971 this.props = element.props;
4972 // Record the component responsible for creating this component.
4973 // This is accessible through the element but we maintain an extra
4974 // field for compatibility with devtools and as a way to make an
4975 // incremental update. TODO: Consider deprecating this field.
4976 this._owner = element._owner;
4977
4978 // All components start unmounted.
4979 this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
4980
4981 // See ReactUpdates.
4982 this._pendingCallbacks = null;
4983
4984 // We keep the old element and a reference to the pending element
4985 // to track updates.
4986 this._currentElement = element;
4987 this._pendingElement = null;
4988 },
4989
4990 /**
4991 * Initializes the component, renders markup, and registers event listeners.
4992 *
4993 * NOTE: This does not insert any nodes into the DOM.
4994 *
4995 * Subclasses that override this method should make sure to invoke
4996 * `ReactComponent.Mixin.mountComponent.call(this, ...)`.
4997 *
4998 * @param {string} rootID DOM ID of the root node.
4999 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
5000 * @param {number} mountDepth number of components in the owner hierarchy.
5001 * @return {?string} Rendered markup to be inserted into the DOM.
5002 * @internal
5003 */
5004 mountComponent: function(rootID, transaction, mountDepth) {
5005 ("production" !== "development" ? invariant(
5006 !this.isMounted(),
5007 'mountComponent(%s, ...): Can only mount an unmounted component. ' +
5008 'Make sure to avoid storing components between renders or reusing a ' +
5009 'single component instance in multiple places.',
5010 rootID
5011 ) : invariant(!this.isMounted()));
5012 var ref = this._currentElement.ref;
5013 if (ref != null) {
5014 var owner = this._currentElement._owner;
5015 ReactOwner.addComponentAsRefTo(this, ref, owner);
5016 }
5017 this._rootNodeID = rootID;
5018 this._lifeCycleState = ComponentLifeCycle.MOUNTED;
5019 this._mountDepth = mountDepth;
5020 // Effectively: return '';
5021 },
5022
5023 /**
5024 * Releases any resources allocated by `mountComponent`.
5025 *
5026 * NOTE: This does not remove any nodes from the DOM.
5027 *
5028 * Subclasses that override this method should make sure to invoke
5029 * `ReactComponent.Mixin.unmountComponent.call(this)`.
5030 *
5031 * @internal
5032 */
5033 unmountComponent: function() {
5034 ("production" !== "development" ? invariant(
5035 this.isMounted(),
5036 'unmountComponent(): Can only unmount a mounted component.'
5037 ) : invariant(this.isMounted()));
5038 var ref = this._currentElement.ref;
5039 if (ref != null) {
5040 ReactOwner.removeComponentAsRefFrom(this, ref, this._owner);
5041 }
5042 unmountIDFromEnvironment(this._rootNodeID);
5043 this._rootNodeID = null;
5044 this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
5045 },
5046
5047 /**
5048 * Given a new instance of this component, updates the rendered DOM nodes
5049 * as if that instance was rendered instead.
5050 *
5051 * Subclasses that override this method should make sure to invoke
5052 * `ReactComponent.Mixin.receiveComponent.call(this, ...)`.
5053 *
5054 * @param {object} nextComponent Next set of properties.
5055 * @param {ReactReconcileTransaction} transaction
5056 * @internal
5057 */
5058 receiveComponent: function(nextElement, transaction) {
5059 ("production" !== "development" ? invariant(
5060 this.isMounted(),
5061 'receiveComponent(...): Can only update a mounted component.'
5062 ) : invariant(this.isMounted()));
5063 this._pendingElement = nextElement;
5064 this.performUpdateIfNecessary(transaction);
5065 },
5066
5067 /**
5068 * If `_pendingElement` is set, update the component.
5069 *
5070 * @param {ReactReconcileTransaction} transaction
5071 * @internal
5072 */
5073 performUpdateIfNecessary: function(transaction) {
5074 if (this._pendingElement == null) {
5075 return;
5076 }
5077 var prevElement = this._currentElement;
5078 var nextElement = this._pendingElement;
5079 this._currentElement = nextElement;
5080 this.props = nextElement.props;
5081 this._owner = nextElement._owner;
5082 this._pendingElement = null;
5083 this.updateComponent(transaction, prevElement);
5084 },
5085
5086 /**
5087 * Updates the component's currently mounted representation.
5088 *
5089 * @param {ReactReconcileTransaction} transaction
5090 * @param {object} prevElement
5091 * @internal
5092 */
5093 updateComponent: function(transaction, prevElement) {
5094 var nextElement = this._currentElement;
5095
5096 // If either the owner or a `ref` has changed, make sure the newest owner
5097 // has stored a reference to `this`, and the previous owner (if different)
5098 // has forgotten the reference to `this`. We use the element instead
5099 // of the public this.props because the post processing cannot determine
5100 // a ref. The ref conceptually lives on the element.
5101
5102 // TODO: Should this even be possible? The owner cannot change because
5103 // it's forbidden by shouldUpdateReactComponent. The ref can change
5104 // if you swap the keys of but not the refs. Reconsider where this check
5105 // is made. It probably belongs where the key checking and
5106 // instantiateReactComponent is done.
5107
5108 if (nextElement._owner !== prevElement._owner ||
5109 nextElement.ref !== prevElement.ref) {
5110 if (prevElement.ref != null) {
5111 ReactOwner.removeComponentAsRefFrom(
5112 this, prevElement.ref, prevElement._owner
5113 );
5114 }
5115 // Correct, even if the owner is the same, and only the ref has changed.
5116 if (nextElement.ref != null) {
5117 ReactOwner.addComponentAsRefTo(
5118 this,
5119 nextElement.ref,
5120 nextElement._owner
5121 );
5122 }
5123 }
5124 },
5125
5126 /**
5127 * Mounts this component and inserts it into the DOM.
5128 *
5129 * @param {string} rootID DOM ID of the root node.
5130 * @param {DOMElement} container DOM element to mount into.
5131 * @param {boolean} shouldReuseMarkup If true, do not insert markup
5132 * @final
5133 * @internal
5134 * @see {ReactMount.render}
5135 */
5136 mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
5137 var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
5138 transaction.perform(
5139 this._mountComponentIntoNode,
5140 this,
5141 rootID,
5142 container,
5143 transaction,
5144 shouldReuseMarkup
5145 );
5146 ReactUpdates.ReactReconcileTransaction.release(transaction);
5147 },
5148
5149 /**
5150 * @param {string} rootID DOM ID of the root node.
5151 * @param {DOMElement} container DOM element to mount into.
5152 * @param {ReactReconcileTransaction} transaction
5153 * @param {boolean} shouldReuseMarkup If true, do not insert markup
5154 * @final
5155 * @private
5156 */
5157 _mountComponentIntoNode: function(
5158 rootID,
5159 container,
5160 transaction,
5161 shouldReuseMarkup) {
5162 var markup = this.mountComponent(rootID, transaction, 0);
5163 mountImageIntoNode(markup, container, shouldReuseMarkup);
5164 },
5165
5166 /**
5167 * Checks if this component is owned by the supplied `owner` component.
5168 *
5169 * @param {ReactComponent} owner Component to check.
5170 * @return {boolean} True if `owners` owns this component.
5171 * @final
5172 * @internal
5173 */
5174 isOwnedBy: function(owner) {
5175 return this._owner === owner;
5176 },
5177
5178 /**
5179 * Gets another component, that shares the same owner as this one, by ref.
5180 *
5181 * @param {string} ref of a sibling Component.
5182 * @return {?ReactComponent} the actual sibling Component.
5183 * @final
5184 * @internal
5185 */
5186 getSiblingByRef: function(ref) {
5187 var owner = this._owner;
5188 if (!owner || !owner.refs) {
5189 return null;
5190 }
5191 return owner.refs[ref];
5192 }
5193 }
5194};
5195
5196module.exports = ReactComponent;
5197
5198},{"./Object.assign":27,"./ReactElement":52,"./ReactOwner":67,"./ReactUpdates":79,"./invariant":126,"./keyMirror":132}],33:[function(_dereq_,module,exports){
5199/**
5200 * Copyright 2013-2014, Facebook, Inc.
5201 * All rights reserved.
5202 *
5203 * This source code is licensed under the BSD-style license found in the
5204 * LICENSE file in the root directory of this source tree. An additional grant
5205 * of patent rights can be found in the PATENTS file in the same directory.
5206 *
5207 * @providesModule ReactComponentBrowserEnvironment
5208 */
5209
5210/*jslint evil: true */
5211
5212"use strict";
5213
5214var ReactDOMIDOperations = _dereq_("./ReactDOMIDOperations");
5215var ReactMarkupChecksum = _dereq_("./ReactMarkupChecksum");
5216var ReactMount = _dereq_("./ReactMount");
5217var ReactPerf = _dereq_("./ReactPerf");
5218var ReactReconcileTransaction = _dereq_("./ReactReconcileTransaction");
5219
5220var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer");
5221var invariant = _dereq_("./invariant");
5222var setInnerHTML = _dereq_("./setInnerHTML");
5223
5224
5225var ELEMENT_NODE_TYPE = 1;
5226var DOC_NODE_TYPE = 9;
5227
5228
5229/**
5230 * Abstracts away all functionality of `ReactComponent` requires knowledge of
5231 * the browser context.
5232 */
5233var ReactComponentBrowserEnvironment = {
5234 ReactReconcileTransaction: ReactReconcileTransaction,
5235
5236 BackendIDOperations: ReactDOMIDOperations,
5237
5238 /**
5239 * If a particular environment requires that some resources be cleaned up,
5240 * specify this in the injected Mixin. In the DOM, we would likely want to
5241 * purge any cached node ID lookups.
5242 *
5243 * @private
5244 */
5245 unmountIDFromEnvironment: function(rootNodeID) {
5246 ReactMount.purgeID(rootNodeID);
5247 },
5248
5249 /**
5250 * @param {string} markup Markup string to place into the DOM Element.
5251 * @param {DOMElement} container DOM Element to insert markup into.
5252 * @param {boolean} shouldReuseMarkup Should reuse the existing markup in the
5253 * container if possible.
5254 */
5255 mountImageIntoNode: ReactPerf.measure(
5256 'ReactComponentBrowserEnvironment',
5257 'mountImageIntoNode',
5258 function(markup, container, shouldReuseMarkup) {
5259 ("production" !== "development" ? invariant(
5260 container && (
5261 container.nodeType === ELEMENT_NODE_TYPE ||
5262 container.nodeType === DOC_NODE_TYPE
5263 ),
5264 'mountComponentIntoNode(...): Target container is not valid.'
5265 ) : invariant(container && (
5266 container.nodeType === ELEMENT_NODE_TYPE ||
5267 container.nodeType === DOC_NODE_TYPE
5268 )));
5269
5270 if (shouldReuseMarkup) {
5271 if (ReactMarkupChecksum.canReuseMarkup(
5272 markup,
5273 getReactRootElementInContainer(container))) {
5274 return;
5275 } else {
5276 ("production" !== "development" ? invariant(
5277 container.nodeType !== DOC_NODE_TYPE,
5278 'You\'re trying to render a component to the document using ' +
5279 'server rendering but the checksum was invalid. This usually ' +
5280 'means you rendered a different component type or props on ' +
5281 'the client from the one on the server, or your render() ' +
5282 'methods are impure. React cannot handle this case due to ' +
5283 'cross-browser quirks by rendering at the document root. You ' +
5284 'should look for environment dependent code in your components ' +
5285 'and ensure the props are the same client and server side.'
5286 ) : invariant(container.nodeType !== DOC_NODE_TYPE));
5287
5288 if ("production" !== "development") {
5289 console.warn(
5290 'React attempted to use reuse markup in a container but the ' +
5291 'checksum was invalid. This generally means that you are ' +
5292 'using server rendering and the markup generated on the ' +
5293 'server was not what the client was expecting. React injected ' +
5294 'new markup to compensate which works but you have lost many ' +
5295 'of the benefits of server rendering. Instead, figure out ' +
5296 'why the markup being generated is different on the client ' +
5297 'or server.'
5298 );
5299 }
5300 }
5301 }
5302
5303 ("production" !== "development" ? invariant(
5304 container.nodeType !== DOC_NODE_TYPE,
5305 'You\'re trying to render a component to the document but ' +
5306 'you didn\'t use server rendering. We can\'t do this ' +
5307 'without using server rendering due to cross-browser quirks. ' +
5308 'See renderComponentToString() for server rendering.'
5309 ) : invariant(container.nodeType !== DOC_NODE_TYPE));
5310
5311 setInnerHTML(container, markup);
5312 }
5313 )
5314};
5315
5316module.exports = ReactComponentBrowserEnvironment;
5317
5318},{"./ReactDOMIDOperations":41,"./ReactMarkupChecksum":62,"./ReactMount":63,"./ReactPerf":68,"./ReactReconcileTransaction":74,"./getReactRootElementInContainer":120,"./invariant":126,"./setInnerHTML":140}],34:[function(_dereq_,module,exports){
5319/**
5320 * Copyright 2013-2014, Facebook, Inc.
5321 * All rights reserved.
5322 *
5323 * This source code is licensed under the BSD-style license found in the
5324 * LICENSE file in the root directory of this source tree. An additional grant
5325 * of patent rights can be found in the PATENTS file in the same directory.
5326 *
5327 * @providesModule ReactCompositeComponent
5328 */
5329
5330"use strict";
5331
5332var ReactComponent = _dereq_("./ReactComponent");
5333var ReactContext = _dereq_("./ReactContext");
5334var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
5335var ReactElement = _dereq_("./ReactElement");
5336var ReactElementValidator = _dereq_("./ReactElementValidator");
5337var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
5338var ReactErrorUtils = _dereq_("./ReactErrorUtils");
5339var ReactLegacyElement = _dereq_("./ReactLegacyElement");
5340var ReactOwner = _dereq_("./ReactOwner");
5341var ReactPerf = _dereq_("./ReactPerf");
5342var ReactPropTransferer = _dereq_("./ReactPropTransferer");
5343var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
5344var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
5345var ReactUpdates = _dereq_("./ReactUpdates");
5346
5347var assign = _dereq_("./Object.assign");
5348var instantiateReactComponent = _dereq_("./instantiateReactComponent");
5349var invariant = _dereq_("./invariant");
5350var keyMirror = _dereq_("./keyMirror");
5351var keyOf = _dereq_("./keyOf");
5352var monitorCodeUse = _dereq_("./monitorCodeUse");
5353var mapObject = _dereq_("./mapObject");
5354var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
5355var warning = _dereq_("./warning");
5356
5357var MIXINS_KEY = keyOf({mixins: null});
5358
5359/**
5360 * Policies that describe methods in `ReactCompositeComponentInterface`.
5361 */
5362var SpecPolicy = keyMirror({
5363 /**
5364 * These methods may be defined only once by the class specification or mixin.
5365 */
5366 DEFINE_ONCE: null,
5367 /**
5368 * These methods may be defined by both the class specification and mixins.
5369 * Subsequent definitions will be chained. These methods must return void.
5370 */
5371 DEFINE_MANY: null,
5372 /**
5373 * These methods are overriding the base ReactCompositeComponent class.
5374 */
5375 OVERRIDE_BASE: null,
5376 /**
5377 * These methods are similar to DEFINE_MANY, except we assume they return
5378 * objects. We try to merge the keys of the return values of all the mixed in
5379 * functions. If there is a key conflict we throw.
5380 */
5381 DEFINE_MANY_MERGED: null
5382});
5383
5384
5385var injectedMixins = [];
5386
5387/**
5388 * Composite components are higher-level components that compose other composite
5389 * or native components.
5390 *
5391 * To create a new type of `ReactCompositeComponent`, pass a specification of
5392 * your new class to `React.createClass`. The only requirement of your class
5393 * specification is that you implement a `render` method.
5394 *
5395 * var MyComponent = React.createClass({
5396 * render: function() {
5397 * return <div>Hello World</div>;
5398 * }
5399 * });
5400 *
5401 * The class specification supports a specific protocol of methods that have
5402 * special meaning (e.g. `render`). See `ReactCompositeComponentInterface` for
5403 * more the comprehensive protocol. Any other properties and methods in the
5404 * class specification will available on the prototype.
5405 *
5406 * @interface ReactCompositeComponentInterface
5407 * @internal
5408 */
5409var ReactCompositeComponentInterface = {
5410
5411 /**
5412 * An array of Mixin objects to include when defining your component.
5413 *
5414 * @type {array}
5415 * @optional
5416 */
5417 mixins: SpecPolicy.DEFINE_MANY,
5418
5419 /**
5420 * An object containing properties and methods that should be defined on
5421 * the component's constructor instead of its prototype (static methods).
5422 *
5423 * @type {object}
5424 * @optional
5425 */
5426 statics: SpecPolicy.DEFINE_MANY,
5427
5428 /**
5429 * Definition of prop types for this component.
5430 *
5431 * @type {object}
5432 * @optional
5433 */
5434 propTypes: SpecPolicy.DEFINE_MANY,
5435
5436 /**
5437 * Definition of context types for this component.
5438 *
5439 * @type {object}
5440 * @optional
5441 */
5442 contextTypes: SpecPolicy.DEFINE_MANY,
5443
5444 /**
5445 * Definition of context types this component sets for its children.
5446 *
5447 * @type {object}
5448 * @optional
5449 */
5450 childContextTypes: SpecPolicy.DEFINE_MANY,
5451
5452 // ==== Definition methods ====
5453
5454 /**
5455 * Invoked when the component is mounted. Values in the mapping will be set on
5456 * `this.props` if that prop is not specified (i.e. using an `in` check).
5457 *
5458 * This method is invoked before `getInitialState` and therefore cannot rely
5459 * on `this.state` or use `this.setState`.
5460 *
5461 * @return {object}
5462 * @optional
5463 */
5464 getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
5465
5466 /**
5467 * Invoked once before the component is mounted. The return value will be used
5468 * as the initial value of `this.state`.
5469 *
5470 * getInitialState: function() {
5471 * return {
5472 * isOn: false,
5473 * fooBaz: new BazFoo()
5474 * }
5475 * }
5476 *
5477 * @return {object}
5478 * @optional
5479 */
5480 getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
5481
5482 /**
5483 * @return {object}
5484 * @optional
5485 */
5486 getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
5487
5488 /**
5489 * Uses props from `this.props` and state from `this.state` to render the
5490 * structure of the component.
5491 *
5492 * No guarantees are made about when or how often this method is invoked, so
5493 * it must not have side effects.
5494 *
5495 * render: function() {
5496 * var name = this.props.name;
5497 * return <div>Hello, {name}!</div>;
5498 * }
5499 *
5500 * @return {ReactComponent}
5501 * @nosideeffects
5502 * @required
5503 */
5504 render: SpecPolicy.DEFINE_ONCE,
5505
5506
5507
5508 // ==== Delegate methods ====
5509
5510 /**
5511 * Invoked when the component is initially created and about to be mounted.
5512 * This may have side effects, but any external subscriptions or data created
5513 * by this method must be cleaned up in `componentWillUnmount`.
5514 *
5515 * @optional
5516 */
5517 componentWillMount: SpecPolicy.DEFINE_MANY,
5518
5519 /**
5520 * Invoked when the component has been mounted and has a DOM representation.
5521 * However, there is no guarantee that the DOM node is in the document.
5522 *
5523 * Use this as an opportunity to operate on the DOM when the component has
5524 * been mounted (initialized and rendered) for the first time.
5525 *
5526 * @param {DOMElement} rootNode DOM element representing the component.
5527 * @optional
5528 */
5529 componentDidMount: SpecPolicy.DEFINE_MANY,
5530
5531 /**
5532 * Invoked before the component receives new props.
5533 *
5534 * Use this as an opportunity to react to a prop transition by updating the
5535 * state using `this.setState`. Current props are accessed via `this.props`.
5536 *
5537 * componentWillReceiveProps: function(nextProps, nextContext) {
5538 * this.setState({
5539 * likesIncreasing: nextProps.likeCount > this.props.likeCount
5540 * });
5541 * }
5542 *
5543 * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
5544 * transition may cause a state change, but the opposite is not true. If you
5545 * need it, you are probably looking for `componentWillUpdate`.
5546 *
5547 * @param {object} nextProps
5548 * @optional
5549 */
5550 componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
5551
5552 /**
5553 * Invoked while deciding if the component should be updated as a result of
5554 * receiving new props, state and/or context.
5555 *
5556 * Use this as an opportunity to `return false` when you're certain that the
5557 * transition to the new props/state/context will not require a component
5558 * update.
5559 *
5560 * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
5561 * return !equal(nextProps, this.props) ||
5562 * !equal(nextState, this.state) ||
5563 * !equal(nextContext, this.context);
5564 * }
5565 *
5566 * @param {object} nextProps
5567 * @param {?object} nextState
5568 * @param {?object} nextContext
5569 * @return {boolean} True if the component should update.
5570 * @optional
5571 */
5572 shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
5573
5574 /**
5575 * Invoked when the component is about to update due to a transition from
5576 * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
5577 * and `nextContext`.
5578 *
5579 * Use this as an opportunity to perform preparation before an update occurs.
5580 *
5581 * NOTE: You **cannot** use `this.setState()` in this method.
5582 *
5583 * @param {object} nextProps
5584 * @param {?object} nextState
5585 * @param {?object} nextContext
5586 * @param {ReactReconcileTransaction} transaction
5587 * @optional
5588 */
5589 componentWillUpdate: SpecPolicy.DEFINE_MANY,
5590
5591 /**
5592 * Invoked when the component's DOM representation has been updated.
5593 *
5594 * Use this as an opportunity to operate on the DOM when the component has
5595 * been updated.
5596 *
5597 * @param {object} prevProps
5598 * @param {?object} prevState
5599 * @param {?object} prevContext
5600 * @param {DOMElement} rootNode DOM element representing the component.
5601 * @optional
5602 */
5603 componentDidUpdate: SpecPolicy.DEFINE_MANY,
5604
5605 /**
5606 * Invoked when the component is about to be removed from its parent and have
5607 * its DOM representation destroyed.
5608 *
5609 * Use this as an opportunity to deallocate any external resources.
5610 *
5611 * NOTE: There is no `componentDidUnmount` since your component will have been
5612 * destroyed by that point.
5613 *
5614 * @optional
5615 */
5616 componentWillUnmount: SpecPolicy.DEFINE_MANY,
5617
5618
5619
5620 // ==== Advanced methods ====
5621
5622 /**
5623 * Updates the component's currently mounted DOM representation.
5624 *
5625 * By default, this implements React's rendering and reconciliation algorithm.
5626 * Sophisticated clients may wish to override this.
5627 *
5628 * @param {ReactReconcileTransaction} transaction
5629 * @internal
5630 * @overridable
5631 */
5632 updateComponent: SpecPolicy.OVERRIDE_BASE
5633
5634};
5635
5636/**
5637 * Mapping from class specification keys to special processing functions.
5638 *
5639 * Although these are declared like instance properties in the specification
5640 * when defining classes using `React.createClass`, they are actually static
5641 * and are accessible on the constructor instead of the prototype. Despite
5642 * being static, they must be defined outside of the "statics" key under
5643 * which all other static methods are defined.
5644 */
5645var RESERVED_SPEC_KEYS = {
5646 displayName: function(Constructor, displayName) {
5647 Constructor.displayName = displayName;
5648 },
5649 mixins: function(Constructor, mixins) {
5650 if (mixins) {
5651 for (var i = 0; i < mixins.length; i++) {
5652 mixSpecIntoComponent(Constructor, mixins[i]);
5653 }
5654 }
5655 },
5656 childContextTypes: function(Constructor, childContextTypes) {
5657 validateTypeDef(
5658 Constructor,
5659 childContextTypes,
5660 ReactPropTypeLocations.childContext
5661 );
5662 Constructor.childContextTypes = assign(
5663 {},
5664 Constructor.childContextTypes,
5665 childContextTypes
5666 );
5667 },
5668 contextTypes: function(Constructor, contextTypes) {
5669 validateTypeDef(
5670 Constructor,
5671 contextTypes,
5672 ReactPropTypeLocations.context
5673 );
5674 Constructor.contextTypes = assign(
5675 {},
5676 Constructor.contextTypes,
5677 contextTypes
5678 );
5679 },
5680 /**
5681 * Special case getDefaultProps which should move into statics but requires
5682 * automatic merging.
5683 */
5684 getDefaultProps: function(Constructor, getDefaultProps) {
5685 if (Constructor.getDefaultProps) {
5686 Constructor.getDefaultProps = createMergedResultFunction(
5687 Constructor.getDefaultProps,
5688 getDefaultProps
5689 );
5690 } else {
5691 Constructor.getDefaultProps = getDefaultProps;
5692 }
5693 },
5694 propTypes: function(Constructor, propTypes) {
5695 validateTypeDef(
5696 Constructor,
5697 propTypes,
5698 ReactPropTypeLocations.prop
5699 );
5700 Constructor.propTypes = assign(
5701 {},
5702 Constructor.propTypes,
5703 propTypes
5704 );
5705 },
5706 statics: function(Constructor, statics) {
5707 mixStaticSpecIntoComponent(Constructor, statics);
5708 }
5709};
5710
5711function getDeclarationErrorAddendum(component) {
5712 var owner = component._owner || null;
5713 if (owner && owner.constructor && owner.constructor.displayName) {
5714 return ' Check the render method of `' + owner.constructor.displayName +
5715 '`.';
5716 }
5717 return '';
5718}
5719
5720function validateTypeDef(Constructor, typeDef, location) {
5721 for (var propName in typeDef) {
5722 if (typeDef.hasOwnProperty(propName)) {
5723 ("production" !== "development" ? invariant(
5724 typeof typeDef[propName] == 'function',
5725 '%s: %s type `%s` is invalid; it must be a function, usually from ' +
5726 'React.PropTypes.',
5727 Constructor.displayName || 'ReactCompositeComponent',
5728 ReactPropTypeLocationNames[location],
5729 propName
5730 ) : invariant(typeof typeDef[propName] == 'function'));
5731 }
5732 }
5733}
5734
5735function validateMethodOverride(proto, name) {
5736 var specPolicy = ReactCompositeComponentInterface.hasOwnProperty(name) ?
5737 ReactCompositeComponentInterface[name] :
5738 null;
5739
5740 // Disallow overriding of base class methods unless explicitly allowed.
5741 if (ReactCompositeComponentMixin.hasOwnProperty(name)) {
5742 ("production" !== "development" ? invariant(
5743 specPolicy === SpecPolicy.OVERRIDE_BASE,
5744 'ReactCompositeComponentInterface: You are attempting to override ' +
5745 '`%s` from your class specification. Ensure that your method names ' +
5746 'do not overlap with React methods.',
5747 name
5748 ) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
5749 }
5750
5751 // Disallow defining methods more than once unless explicitly allowed.
5752 if (proto.hasOwnProperty(name)) {
5753 ("production" !== "development" ? invariant(
5754 specPolicy === SpecPolicy.DEFINE_MANY ||
5755 specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
5756 'ReactCompositeComponentInterface: You are attempting to define ' +
5757 '`%s` on your component more than once. This conflict may be due ' +
5758 'to a mixin.',
5759 name
5760 ) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
5761 specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
5762 }
5763}
5764
5765function validateLifeCycleOnReplaceState(instance) {
5766 var compositeLifeCycleState = instance._compositeLifeCycleState;
5767 ("production" !== "development" ? invariant(
5768 instance.isMounted() ||
5769 compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
5770 'replaceState(...): Can only update a mounted or mounting component.'
5771 ) : invariant(instance.isMounted() ||
5772 compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
5773 ("production" !== "development" ? invariant(
5774 ReactCurrentOwner.current == null,
5775 'replaceState(...): Cannot update during an existing state transition ' +
5776 '(such as within `render`). Render methods should be a pure function ' +
5777 'of props and state.'
5778 ) : invariant(ReactCurrentOwner.current == null));
5779 ("production" !== "development" ? invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
5780 'replaceState(...): Cannot update while unmounting component. This ' +
5781 'usually means you called setState() on an unmounted component.'
5782 ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
5783}
5784
5785/**
5786 * Mixin helper which handles policy validation and reserved
5787 * specification keys when building `ReactCompositeComponent` classses.
5788 */
5789function mixSpecIntoComponent(Constructor, spec) {
5790 if (!spec) {
5791 return;
5792 }
5793
5794 ("production" !== "development" ? invariant(
5795 !ReactLegacyElement.isValidFactory(spec),
5796 'ReactCompositeComponent: You\'re attempting to ' +
5797 'use a component class as a mixin. Instead, just use a regular object.'
5798 ) : invariant(!ReactLegacyElement.isValidFactory(spec)));
5799 ("production" !== "development" ? invariant(
5800 !ReactElement.isValidElement(spec),
5801 'ReactCompositeComponent: You\'re attempting to ' +
5802 'use a component as a mixin. Instead, just use a regular object.'
5803 ) : invariant(!ReactElement.isValidElement(spec)));
5804
5805 var proto = Constructor.prototype;
5806
5807 // By handling mixins before any other properties, we ensure the same
5808 // chaining order is applied to methods with DEFINE_MANY policy, whether
5809 // mixins are listed before or after these methods in the spec.
5810 if (spec.hasOwnProperty(MIXINS_KEY)) {
5811 RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
5812 }
5813
5814 for (var name in spec) {
5815 if (!spec.hasOwnProperty(name)) {
5816 continue;
5817 }
5818
5819 if (name === MIXINS_KEY) {
5820 // We have already handled mixins in a special case above
5821 continue;
5822 }
5823
5824 var property = spec[name];
5825 validateMethodOverride(proto, name);
5826
5827 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
5828 RESERVED_SPEC_KEYS[name](Constructor, property);
5829 } else {
5830 // Setup methods on prototype:
5831 // The following member methods should not be automatically bound:
5832 // 1. Expected ReactCompositeComponent methods (in the "interface").
5833 // 2. Overridden methods (that were mixed in).
5834 var isCompositeComponentMethod =
5835 ReactCompositeComponentInterface.hasOwnProperty(name);
5836 var isAlreadyDefined = proto.hasOwnProperty(name);
5837 var markedDontBind = property && property.__reactDontBind;
5838 var isFunction = typeof property === 'function';
5839 var shouldAutoBind =
5840 isFunction &&
5841 !isCompositeComponentMethod &&
5842 !isAlreadyDefined &&
5843 !markedDontBind;
5844
5845 if (shouldAutoBind) {
5846 if (!proto.__reactAutoBindMap) {
5847 proto.__reactAutoBindMap = {};
5848 }
5849 proto.__reactAutoBindMap[name] = property;
5850 proto[name] = property;
5851 } else {
5852 if (isAlreadyDefined) {
5853 var specPolicy = ReactCompositeComponentInterface[name];
5854
5855 // These cases should already be caught by validateMethodOverride
5856 ("production" !== "development" ? invariant(
5857 isCompositeComponentMethod && (
5858 specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
5859 specPolicy === SpecPolicy.DEFINE_MANY
5860 ),
5861 'ReactCompositeComponent: Unexpected spec policy %s for key %s ' +
5862 'when mixing in component specs.',
5863 specPolicy,
5864 name
5865 ) : invariant(isCompositeComponentMethod && (
5866 specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
5867 specPolicy === SpecPolicy.DEFINE_MANY
5868 )));
5869
5870 // For methods which are defined more than once, call the existing
5871 // methods before calling the new property, merging if appropriate.
5872 if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
5873 proto[name] = createMergedResultFunction(proto[name], property);
5874 } else if (specPolicy === SpecPolicy.DEFINE_MANY) {
5875 proto[name] = createChainedFunction(proto[name], property);
5876 }
5877 } else {
5878 proto[name] = property;
5879 if ("production" !== "development") {
5880 // Add verbose displayName to the function, which helps when looking
5881 // at profiling tools.
5882 if (typeof property === 'function' && spec.displayName) {
5883 proto[name].displayName = spec.displayName + '_' + name;
5884 }
5885 }
5886 }
5887 }
5888 }
5889 }
5890}
5891
5892function mixStaticSpecIntoComponent(Constructor, statics) {
5893 if (!statics) {
5894 return;
5895 }
5896 for (var name in statics) {
5897 var property = statics[name];
5898 if (!statics.hasOwnProperty(name)) {
5899 continue;
5900 }
5901
5902 var isReserved = name in RESERVED_SPEC_KEYS;
5903 ("production" !== "development" ? invariant(
5904 !isReserved,
5905 'ReactCompositeComponent: You are attempting to define a reserved ' +
5906 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
5907 'as an instance property instead; it will still be accessible on the ' +
5908 'constructor.',
5909 name
5910 ) : invariant(!isReserved));
5911
5912 var isInherited = name in Constructor;
5913 ("production" !== "development" ? invariant(
5914 !isInherited,
5915 'ReactCompositeComponent: You are attempting to define ' +
5916 '`%s` on your component more than once. This conflict may be ' +
5917 'due to a mixin.',
5918 name
5919 ) : invariant(!isInherited));
5920 Constructor[name] = property;
5921 }
5922}
5923
5924/**
5925 * Merge two objects, but throw if both contain the same key.
5926 *
5927 * @param {object} one The first object, which is mutated.
5928 * @param {object} two The second object
5929 * @return {object} one after it has been mutated to contain everything in two.
5930 */
5931function mergeObjectsWithNoDuplicateKeys(one, two) {
5932 ("production" !== "development" ? invariant(
5933 one && two && typeof one === 'object' && typeof two === 'object',
5934 'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects'
5935 ) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
5936
5937 mapObject(two, function(value, key) {
5938 ("production" !== "development" ? invariant(
5939 one[key] === undefined,
5940 'mergeObjectsWithNoDuplicateKeys(): ' +
5941 'Tried to merge two objects with the same key: `%s`. This conflict ' +
5942 'may be due to a mixin; in particular, this may be caused by two ' +
5943 'getInitialState() or getDefaultProps() methods returning objects ' +
5944 'with clashing keys.',
5945 key
5946 ) : invariant(one[key] === undefined));
5947 one[key] = value;
5948 });
5949 return one;
5950}
5951
5952/**
5953 * Creates a function that invokes two functions and merges their return values.
5954 *
5955 * @param {function} one Function to invoke first.
5956 * @param {function} two Function to invoke second.
5957 * @return {function} Function that invokes the two argument functions.
5958 * @private
5959 */
5960function createMergedResultFunction(one, two) {
5961 return function mergedResult() {
5962 var a = one.apply(this, arguments);
5963 var b = two.apply(this, arguments);
5964 if (a == null) {
5965 return b;
5966 } else if (b == null) {
5967 return a;
5968 }
5969 return mergeObjectsWithNoDuplicateKeys(a, b);
5970 };
5971}
5972
5973/**
5974 * Creates a function that invokes two functions and ignores their return vales.
5975 *
5976 * @param {function} one Function to invoke first.
5977 * @param {function} two Function to invoke second.
5978 * @return {function} Function that invokes the two argument functions.
5979 * @private
5980 */
5981function createChainedFunction(one, two) {
5982 return function chainedFunction() {
5983 one.apply(this, arguments);
5984 two.apply(this, arguments);
5985 };
5986}
5987
5988/**
5989 * `ReactCompositeComponent` maintains an auxiliary life cycle state in
5990 * `this._compositeLifeCycleState` (which can be null).
5991 *
5992 * This is different from the life cycle state maintained by `ReactComponent` in
5993 * `this._lifeCycleState`. The following diagram shows how the states overlap in
5994 * time. There are times when the CompositeLifeCycle is null - at those times it
5995 * is only meaningful to look at ComponentLifeCycle alone.
5996 *
5997 * Top Row: ReactComponent.ComponentLifeCycle
5998 * Low Row: ReactComponent.CompositeLifeCycle
5999 *
6000 * +-------+---------------------------------+--------+
6001 * | UN | MOUNTED | UN |
6002 * |MOUNTED| | MOUNTED|
6003 * +-------+---------------------------------+--------+
6004 * | ^--------+ +-------+ +--------^ |
6005 * | | | | | | | |
6006 * | 0--|MOUNTING|-0-|RECEIVE|-0-| UN |--->0 |
6007 * | | | |PROPS | |MOUNTING| |
6008 * | | | | | | | |
6009 * | | | | | | | |
6010 * | +--------+ +-------+ +--------+ |
6011 * | | | |
6012 * +-------+---------------------------------+--------+
6013 */
6014var CompositeLifeCycle = keyMirror({
6015 /**
6016 * Components in the process of being mounted respond to state changes
6017 * differently.
6018 */
6019 MOUNTING: null,
6020 /**
6021 * Components in the process of being unmounted are guarded against state
6022 * changes.
6023 */
6024 UNMOUNTING: null,
6025 /**
6026 * Components that are mounted and receiving new props respond to state
6027 * changes differently.
6028 */
6029 RECEIVING_PROPS: null
6030});
6031
6032/**
6033 * @lends {ReactCompositeComponent.prototype}
6034 */
6035var ReactCompositeComponentMixin = {
6036
6037 /**
6038 * Base constructor for all composite component.
6039 *
6040 * @param {ReactElement} element
6041 * @final
6042 * @internal
6043 */
6044 construct: function(element) {
6045 // Children can be either an array or more than one argument
6046 ReactComponent.Mixin.construct.apply(this, arguments);
6047 ReactOwner.Mixin.construct.apply(this, arguments);
6048
6049 this.state = null;
6050 this._pendingState = null;
6051
6052 // This is the public post-processed context. The real context and pending
6053 // context lives on the element.
6054 this.context = null;
6055
6056 this._compositeLifeCycleState = null;
6057 },
6058
6059 /**
6060 * Checks whether or not this composite component is mounted.
6061 * @return {boolean} True if mounted, false otherwise.
6062 * @protected
6063 * @final
6064 */
6065 isMounted: function() {
6066 return ReactComponent.Mixin.isMounted.call(this) &&
6067 this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING;
6068 },
6069
6070 /**
6071 * Initializes the component, renders markup, and registers event listeners.
6072 *
6073 * @param {string} rootID DOM ID of the root node.
6074 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
6075 * @param {number} mountDepth number of components in the owner hierarchy
6076 * @return {?string} Rendered markup to be inserted into the DOM.
6077 * @final
6078 * @internal
6079 */
6080 mountComponent: ReactPerf.measure(
6081 'ReactCompositeComponent',
6082 'mountComponent',
6083 function(rootID, transaction, mountDepth) {
6084 ReactComponent.Mixin.mountComponent.call(
6085 this,
6086 rootID,
6087 transaction,
6088 mountDepth
6089 );
6090 this._compositeLifeCycleState = CompositeLifeCycle.MOUNTING;
6091
6092 if (this.__reactAutoBindMap) {
6093 this._bindAutoBindMethods();
6094 }
6095
6096 this.context = this._processContext(this._currentElement._context);
6097 this.props = this._processProps(this.props);
6098
6099 this.state = this.getInitialState ? this.getInitialState() : null;
6100 ("production" !== "development" ? invariant(
6101 typeof this.state === 'object' && !Array.isArray(this.state),
6102 '%s.getInitialState(): must return an object or null',
6103 this.constructor.displayName || 'ReactCompositeComponent'
6104 ) : invariant(typeof this.state === 'object' && !Array.isArray(this.state)));
6105
6106 this._pendingState = null;
6107 this._pendingForceUpdate = false;
6108
6109 if (this.componentWillMount) {
6110 this.componentWillMount();
6111 // When mounting, calls to `setState` by `componentWillMount` will set
6112 // `this._pendingState` without triggering a re-render.
6113 if (this._pendingState) {
6114 this.state = this._pendingState;
6115 this._pendingState = null;
6116 }
6117 }
6118
6119 this._renderedComponent = instantiateReactComponent(
6120 this._renderValidatedComponent(),
6121 this._currentElement.type // The wrapping type
6122 );
6123
6124 // Done with mounting, `setState` will now trigger UI changes.
6125 this._compositeLifeCycleState = null;
6126 var markup = this._renderedComponent.mountComponent(
6127 rootID,
6128 transaction,
6129 mountDepth + 1
6130 );
6131 if (this.componentDidMount) {
6132 transaction.getReactMountReady().enqueue(this.componentDidMount, this);
6133 }
6134 return markup;
6135 }
6136 ),
6137
6138 /**
6139 * Releases any resources allocated by `mountComponent`.
6140 *
6141 * @final
6142 * @internal
6143 */
6144 unmountComponent: function() {
6145 this._compositeLifeCycleState = CompositeLifeCycle.UNMOUNTING;
6146 if (this.componentWillUnmount) {
6147 this.componentWillUnmount();
6148 }
6149 this._compositeLifeCycleState = null;
6150
6151 this._renderedComponent.unmountComponent();
6152 this._renderedComponent = null;
6153
6154 ReactComponent.Mixin.unmountComponent.call(this);
6155
6156 // Some existing components rely on this.props even after they've been
6157 // destroyed (in event handlers).
6158 // TODO: this.props = null;
6159 // TODO: this.state = null;
6160 },
6161
6162 /**
6163 * Sets a subset of the state. Always use this or `replaceState` to mutate
6164 * state. You should treat `this.state` as immutable.
6165 *
6166 * There is no guarantee that `this.state` will be immediately updated, so
6167 * accessing `this.state` after calling this method may return the old value.
6168 *
6169 * There is no guarantee that calls to `setState` will run synchronously,
6170 * as they may eventually be batched together. You can provide an optional
6171 * callback that will be executed when the call to setState is actually
6172 * completed.
6173 *
6174 * @param {object} partialState Next partial state to be merged with state.
6175 * @param {?function} callback Called after state is updated.
6176 * @final
6177 * @protected
6178 */
6179 setState: function(partialState, callback) {
6180 ("production" !== "development" ? invariant(
6181 typeof partialState === 'object' || partialState == null,
6182 'setState(...): takes an object of state variables to update.'
6183 ) : invariant(typeof partialState === 'object' || partialState == null));
6184 if ("production" !== "development"){
6185 ("production" !== "development" ? warning(
6186 partialState != null,
6187 'setState(...): You passed an undefined or null state object; ' +
6188 'instead, use forceUpdate().'
6189 ) : null);
6190 }
6191 // Merge with `_pendingState` if it exists, otherwise with existing state.
6192 this.replaceState(
6193 assign({}, this._pendingState || this.state, partialState),
6194 callback
6195 );
6196 },
6197
6198 /**
6199 * Replaces all of the state. Always use this or `setState` to mutate state.
6200 * You should treat `this.state` as immutable.
6201 *
6202 * There is no guarantee that `this.state` will be immediately updated, so
6203 * accessing `this.state` after calling this method may return the old value.
6204 *
6205 * @param {object} completeState Next state.
6206 * @param {?function} callback Called after state is updated.
6207 * @final
6208 * @protected
6209 */
6210 replaceState: function(completeState, callback) {
6211 validateLifeCycleOnReplaceState(this);
6212 this._pendingState = completeState;
6213 if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) {
6214 // If we're in a componentWillMount handler, don't enqueue a rerender
6215 // because ReactUpdates assumes we're in a browser context (which is wrong
6216 // for server rendering) and we're about to do a render anyway.
6217 // TODO: The callback here is ignored when setState is called from
6218 // componentWillMount. Either fix it or disallow doing so completely in
6219 // favor of getInitialState.
6220 ReactUpdates.enqueueUpdate(this, callback);
6221 }
6222 },
6223
6224 /**
6225 * Filters the context object to only contain keys specified in
6226 * `contextTypes`, and asserts that they are valid.
6227 *
6228 * @param {object} context
6229 * @return {?object}
6230 * @private
6231 */
6232 _processContext: function(context) {
6233 var maskedContext = null;
6234 var contextTypes = this.constructor.contextTypes;
6235 if (contextTypes) {
6236 maskedContext = {};
6237 for (var contextName in contextTypes) {
6238 maskedContext[contextName] = context[contextName];
6239 }
6240 if ("production" !== "development") {
6241 this._checkPropTypes(
6242 contextTypes,
6243 maskedContext,
6244 ReactPropTypeLocations.context
6245 );
6246 }
6247 }
6248 return maskedContext;
6249 },
6250
6251 /**
6252 * @param {object} currentContext
6253 * @return {object}
6254 * @private
6255 */
6256 _processChildContext: function(currentContext) {
6257 var childContext = this.getChildContext && this.getChildContext();
6258 var displayName = this.constructor.displayName || 'ReactCompositeComponent';
6259 if (childContext) {
6260 ("production" !== "development" ? invariant(
6261 typeof this.constructor.childContextTypes === 'object',
6262 '%s.getChildContext(): childContextTypes must be defined in order to ' +
6263 'use getChildContext().',
6264 displayName
6265 ) : invariant(typeof this.constructor.childContextTypes === 'object'));
6266 if ("production" !== "development") {
6267 this._checkPropTypes(
6268 this.constructor.childContextTypes,
6269 childContext,
6270 ReactPropTypeLocations.childContext
6271 );
6272 }
6273 for (var name in childContext) {
6274 ("production" !== "development" ? invariant(
6275 name in this.constructor.childContextTypes,
6276 '%s.getChildContext(): key "%s" is not defined in childContextTypes.',
6277 displayName,
6278 name
6279 ) : invariant(name in this.constructor.childContextTypes));
6280 }
6281 return assign({}, currentContext, childContext);
6282 }
6283 return currentContext;
6284 },
6285
6286 /**
6287 * Processes props by setting default values for unspecified props and
6288 * asserting that the props are valid. Does not mutate its argument; returns
6289 * a new props object with defaults merged in.
6290 *
6291 * @param {object} newProps
6292 * @return {object}
6293 * @private
6294 */
6295 _processProps: function(newProps) {
6296 if ("production" !== "development") {
6297 var propTypes = this.constructor.propTypes;
6298 if (propTypes) {
6299 this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
6300 }
6301 }
6302 return newProps;
6303 },
6304
6305 /**
6306 * Assert that the props are valid
6307 *
6308 * @param {object} propTypes Map of prop name to a ReactPropType
6309 * @param {object} props
6310 * @param {string} location e.g. "prop", "context", "child context"
6311 * @private
6312 */
6313 _checkPropTypes: function(propTypes, props, location) {
6314 // TODO: Stop validating prop types here and only use the element
6315 // validation.
6316 var componentName = this.constructor.displayName;
6317 for (var propName in propTypes) {
6318 if (propTypes.hasOwnProperty(propName)) {
6319 var error =
6320 propTypes[propName](props, propName, componentName, location);
6321 if (error instanceof Error) {
6322 // We may want to extend this logic for similar errors in
6323 // renderComponent calls, so I'm abstracting it away into
6324 // a function to minimize refactoring in the future
6325 var addendum = getDeclarationErrorAddendum(this);
6326 ("production" !== "development" ? warning(false, error.message + addendum) : null);
6327 }
6328 }
6329 }
6330 },
6331
6332 /**
6333 * If any of `_pendingElement`, `_pendingState`, or `_pendingForceUpdate`
6334 * is set, update the component.
6335 *
6336 * @param {ReactReconcileTransaction} transaction
6337 * @internal
6338 */
6339 performUpdateIfNecessary: function(transaction) {
6340 var compositeLifeCycleState = this._compositeLifeCycleState;
6341 // Do not trigger a state transition if we are in the middle of mounting or
6342 // receiving props because both of those will already be doing this.
6343 if (compositeLifeCycleState === CompositeLifeCycle.MOUNTING ||
6344 compositeLifeCycleState === CompositeLifeCycle.RECEIVING_PROPS) {
6345 return;
6346 }
6347
6348 if (this._pendingElement == null &&
6349 this._pendingState == null &&
6350 !this._pendingForceUpdate) {
6351 return;
6352 }
6353
6354 var nextContext = this.context;
6355 var nextProps = this.props;
6356 var nextElement = this._currentElement;
6357 if (this._pendingElement != null) {
6358 nextElement = this._pendingElement;
6359 nextContext = this._processContext(nextElement._context);
6360 nextProps = this._processProps(nextElement.props);
6361 this._pendingElement = null;
6362
6363 this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
6364 if (this.componentWillReceiveProps) {
6365 this.componentWillReceiveProps(nextProps, nextContext);
6366 }
6367 }
6368
6369 this._compositeLifeCycleState = null;
6370
6371 var nextState = this._pendingState || this.state;
6372 this._pendingState = null;
6373
6374 var shouldUpdate =
6375 this._pendingForceUpdate ||
6376 !this.shouldComponentUpdate ||
6377 this.shouldComponentUpdate(nextProps, nextState, nextContext);
6378
6379 if ("production" !== "development") {
6380 if (typeof shouldUpdate === "undefined") {
6381 console.warn(
6382 (this.constructor.displayName || 'ReactCompositeComponent') +
6383 '.shouldComponentUpdate(): Returned undefined instead of a ' +
6384 'boolean value. Make sure to return true or false.'
6385 );
6386 }
6387 }
6388
6389 if (shouldUpdate) {
6390 this._pendingForceUpdate = false;
6391 // Will set `this.props`, `this.state` and `this.context`.
6392 this._performComponentUpdate(
6393 nextElement,
6394 nextProps,
6395 nextState,
6396 nextContext,
6397 transaction
6398 );
6399 } else {
6400 // If it's determined that a component should not update, we still want
6401 // to set props and state.
6402 this._currentElement = nextElement;
6403 this.props = nextProps;
6404 this.state = nextState;
6405 this.context = nextContext;
6406
6407 // Owner cannot change because shouldUpdateReactComponent doesn't allow
6408 // it. TODO: Remove this._owner completely.
6409 this._owner = nextElement._owner;
6410 }
6411 },
6412
6413 /**
6414 * Merges new props and state, notifies delegate methods of update and
6415 * performs update.
6416 *
6417 * @param {ReactElement} nextElement Next element
6418 * @param {object} nextProps Next public object to set as properties.
6419 * @param {?object} nextState Next object to set as state.
6420 * @param {?object} nextContext Next public object to set as context.
6421 * @param {ReactReconcileTransaction} transaction
6422 * @private
6423 */
6424 _performComponentUpdate: function(
6425 nextElement,
6426 nextProps,
6427 nextState,
6428 nextContext,
6429 transaction
6430 ) {
6431 var prevElement = this._currentElement;
6432 var prevProps = this.props;
6433 var prevState = this.state;
6434 var prevContext = this.context;
6435
6436 if (this.componentWillUpdate) {
6437 this.componentWillUpdate(nextProps, nextState, nextContext);
6438 }
6439
6440 this._currentElement = nextElement;
6441 this.props = nextProps;
6442 this.state = nextState;
6443 this.context = nextContext;
6444
6445 // Owner cannot change because shouldUpdateReactComponent doesn't allow
6446 // it. TODO: Remove this._owner completely.
6447 this._owner = nextElement._owner;
6448
6449 this.updateComponent(
6450 transaction,
6451 prevElement
6452 );
6453
6454 if (this.componentDidUpdate) {
6455 transaction.getReactMountReady().enqueue(
6456 this.componentDidUpdate.bind(this, prevProps, prevState, prevContext),
6457 this
6458 );
6459 }
6460 },
6461
6462 receiveComponent: function(nextElement, transaction) {
6463 if (nextElement === this._currentElement &&
6464 nextElement._owner != null) {
6465 // Since elements are immutable after the owner is rendered,
6466 // we can do a cheap identity compare here to determine if this is a
6467 // superfluous reconcile. It's possible for state to be mutable but such
6468 // change should trigger an update of the owner which would recreate
6469 // the element. We explicitly check for the existence of an owner since
6470 // it's possible for a element created outside a composite to be
6471 // deeply mutated and reused.
6472 return;
6473 }
6474
6475 ReactComponent.Mixin.receiveComponent.call(
6476 this,
6477 nextElement,
6478 transaction
6479 );
6480 },
6481
6482 /**
6483 * Updates the component's currently mounted DOM representation.
6484 *
6485 * By default, this implements React's rendering and reconciliation algorithm.
6486 * Sophisticated clients may wish to override this.
6487 *
6488 * @param {ReactReconcileTransaction} transaction
6489 * @param {ReactElement} prevElement
6490 * @internal
6491 * @overridable
6492 */
6493 updateComponent: ReactPerf.measure(
6494 'ReactCompositeComponent',
6495 'updateComponent',
6496 function(transaction, prevParentElement) {
6497 ReactComponent.Mixin.updateComponent.call(
6498 this,
6499 transaction,
6500 prevParentElement
6501 );
6502
6503 var prevComponentInstance = this._renderedComponent;
6504 var prevElement = prevComponentInstance._currentElement;
6505 var nextElement = this._renderValidatedComponent();
6506 if (shouldUpdateReactComponent(prevElement, nextElement)) {
6507 prevComponentInstance.receiveComponent(nextElement, transaction);
6508 } else {
6509 // These two IDs are actually the same! But nothing should rely on that.
6510 var thisID = this._rootNodeID;
6511 var prevComponentID = prevComponentInstance._rootNodeID;
6512 prevComponentInstance.unmountComponent();
6513 this._renderedComponent = instantiateReactComponent(
6514 nextElement,
6515 this._currentElement.type
6516 );
6517 var nextMarkup = this._renderedComponent.mountComponent(
6518 thisID,
6519 transaction,
6520 this._mountDepth + 1
6521 );
6522 ReactComponent.BackendIDOperations.dangerouslyReplaceNodeWithMarkupByID(
6523 prevComponentID,
6524 nextMarkup
6525 );
6526 }
6527 }
6528 ),
6529
6530 /**
6531 * Forces an update. This should only be invoked when it is known with
6532 * certainty that we are **not** in a DOM transaction.
6533 *
6534 * You may want to call this when you know that some deeper aspect of the
6535 * component's state has changed but `setState` was not called.
6536 *
6537 * This will not invoke `shouldUpdateComponent`, but it will invoke
6538 * `componentWillUpdate` and `componentDidUpdate`.
6539 *
6540 * @param {?function} callback Called after update is complete.
6541 * @final
6542 * @protected
6543 */
6544 forceUpdate: function(callback) {
6545 var compositeLifeCycleState = this._compositeLifeCycleState;
6546 ("production" !== "development" ? invariant(
6547 this.isMounted() ||
6548 compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
6549 'forceUpdate(...): Can only force an update on mounted or mounting ' +
6550 'components.'
6551 ) : invariant(this.isMounted() ||
6552 compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
6553 ("production" !== "development" ? invariant(
6554 compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
6555 ReactCurrentOwner.current == null,
6556 'forceUpdate(...): Cannot force an update while unmounting component ' +
6557 'or within a `render` function.'
6558 ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
6559 ReactCurrentOwner.current == null));
6560 this._pendingForceUpdate = true;
6561 ReactUpdates.enqueueUpdate(this, callback);
6562 },
6563
6564 /**
6565 * @private
6566 */
6567 _renderValidatedComponent: ReactPerf.measure(
6568 'ReactCompositeComponent',
6569 '_renderValidatedComponent',
6570 function() {
6571 var renderedComponent;
6572 var previousContext = ReactContext.current;
6573 ReactContext.current = this._processChildContext(
6574 this._currentElement._context
6575 );
6576 ReactCurrentOwner.current = this;
6577 try {
6578 renderedComponent = this.render();
6579 if (renderedComponent === null || renderedComponent === false) {
6580 renderedComponent = ReactEmptyComponent.getEmptyComponent();
6581 ReactEmptyComponent.registerNullComponentID(this._rootNodeID);
6582 } else {
6583 ReactEmptyComponent.deregisterNullComponentID(this._rootNodeID);
6584 }
6585 } finally {
6586 ReactContext.current = previousContext;
6587 ReactCurrentOwner.current = null;
6588 }
6589 ("production" !== "development" ? invariant(
6590 ReactElement.isValidElement(renderedComponent),
6591 '%s.render(): A valid ReactComponent must be returned. You may have ' +
6592 'returned undefined, an array or some other invalid object.',
6593 this.constructor.displayName || 'ReactCompositeComponent'
6594 ) : invariant(ReactElement.isValidElement(renderedComponent)));
6595 return renderedComponent;
6596 }
6597 ),
6598
6599 /**
6600 * @private
6601 */
6602 _bindAutoBindMethods: function() {
6603 for (var autoBindKey in this.__reactAutoBindMap) {
6604 if (!this.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
6605 continue;
6606 }
6607 var method = this.__reactAutoBindMap[autoBindKey];
6608 this[autoBindKey] = this._bindAutoBindMethod(ReactErrorUtils.guard(
6609 method,
6610 this.constructor.displayName + '.' + autoBindKey
6611 ));
6612 }
6613 },
6614
6615 /**
6616 * Binds a method to the component.
6617 *
6618 * @param {function} method Method to be bound.
6619 * @private
6620 */
6621 _bindAutoBindMethod: function(method) {
6622 var component = this;
6623 var boundMethod = method.bind(component);
6624 if ("production" !== "development") {
6625 boundMethod.__reactBoundContext = component;
6626 boundMethod.__reactBoundMethod = method;
6627 boundMethod.__reactBoundArguments = null;
6628 var componentName = component.constructor.displayName;
6629 var _bind = boundMethod.bind;
6630 boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
6631 // User is trying to bind() an autobound method; we effectively will
6632 // ignore the value of "this" that the user is trying to use, so
6633 // let's warn.
6634 if (newThis !== component && newThis !== null) {
6635 monitorCodeUse('react_bind_warning', { component: componentName });
6636 console.warn(
6637 'bind(): React component methods may only be bound to the ' +
6638 'component instance. See ' + componentName
6639 );
6640 } else if (!args.length) {
6641 monitorCodeUse('react_bind_warning', { component: componentName });
6642 console.warn(
6643 'bind(): You are binding a component method to the component. ' +
6644 'React does this for you automatically in a high-performance ' +
6645 'way, so you can safely remove this call. See ' + componentName
6646 );
6647 return boundMethod;
6648 }
6649 var reboundMethod = _bind.apply(boundMethod, arguments);
6650 reboundMethod.__reactBoundContext = component;
6651 reboundMethod.__reactBoundMethod = method;
6652 reboundMethod.__reactBoundArguments = args;
6653 return reboundMethod;
6654 };
6655 }
6656 return boundMethod;
6657 }
6658};
6659
6660var ReactCompositeComponentBase = function() {};
6661assign(
6662 ReactCompositeComponentBase.prototype,
6663 ReactComponent.Mixin,
6664 ReactOwner.Mixin,
6665 ReactPropTransferer.Mixin,
6666 ReactCompositeComponentMixin
6667);
6668
6669/**
6670 * Module for creating composite components.
6671 *
6672 * @class ReactCompositeComponent
6673 * @extends ReactComponent
6674 * @extends ReactOwner
6675 * @extends ReactPropTransferer
6676 */
6677var ReactCompositeComponent = {
6678
6679 LifeCycle: CompositeLifeCycle,
6680
6681 Base: ReactCompositeComponentBase,
6682
6683 /**
6684 * Creates a composite component class given a class specification.
6685 *
6686 * @param {object} spec Class specification (which must define `render`).
6687 * @return {function} Component constructor function.
6688 * @public
6689 */
6690 createClass: function(spec) {
6691 var Constructor = function(props) {
6692 // This constructor is overridden by mocks. The argument is used
6693 // by mocks to assert on what gets mounted. This will later be used
6694 // by the stand-alone class implementation.
6695 };
6696 Constructor.prototype = new ReactCompositeComponentBase();
6697 Constructor.prototype.constructor = Constructor;
6698
6699 injectedMixins.forEach(
6700 mixSpecIntoComponent.bind(null, Constructor)
6701 );
6702
6703 mixSpecIntoComponent(Constructor, spec);
6704
6705 // Initialize the defaultProps property after all mixins have been merged
6706 if (Constructor.getDefaultProps) {
6707 Constructor.defaultProps = Constructor.getDefaultProps();
6708 }
6709
6710 ("production" !== "development" ? invariant(
6711 Constructor.prototype.render,
6712 'createClass(...): Class specification must implement a `render` method.'
6713 ) : invariant(Constructor.prototype.render));
6714
6715 if ("production" !== "development") {
6716 if (Constructor.prototype.componentShouldUpdate) {
6717 monitorCodeUse(
6718 'react_component_should_update_warning',
6719 { component: spec.displayName }
6720 );
6721 console.warn(
6722 (spec.displayName || 'A component') + ' has a method called ' +
6723 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
6724 'The name is phrased as a question because the function is ' +
6725 'expected to return a value.'
6726 );
6727 }
6728 }
6729
6730 // Reduce time spent doing lookups by setting these on the prototype.
6731 for (var methodName in ReactCompositeComponentInterface) {
6732 if (!Constructor.prototype[methodName]) {
6733 Constructor.prototype[methodName] = null;
6734 }
6735 }
6736
6737 if ("production" !== "development") {
6738 return ReactLegacyElement.wrapFactory(
6739 ReactElementValidator.createFactory(Constructor)
6740 );
6741 }
6742 return ReactLegacyElement.wrapFactory(
6743 ReactElement.createFactory(Constructor)
6744 );
6745 },
6746
6747 injection: {
6748 injectMixin: function(mixin) {
6749 injectedMixins.push(mixin);
6750 }
6751 }
6752};
6753
6754module.exports = ReactCompositeComponent;
6755
6756},{"./Object.assign":27,"./ReactComponent":32,"./ReactContext":35,"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactElementValidator":53,"./ReactEmptyComponent":54,"./ReactErrorUtils":55,"./ReactLegacyElement":61,"./ReactOwner":67,"./ReactPerf":68,"./ReactPropTransferer":69,"./ReactPropTypeLocationNames":70,"./ReactPropTypeLocations":71,"./ReactUpdates":79,"./instantiateReactComponent":125,"./invariant":126,"./keyMirror":132,"./keyOf":133,"./mapObject":134,"./monitorCodeUse":136,"./shouldUpdateReactComponent":142,"./warning":145}],35:[function(_dereq_,module,exports){
6757/**
6758 * Copyright 2013-2014, Facebook, Inc.
6759 * All rights reserved.
6760 *
6761 * This source code is licensed under the BSD-style license found in the
6762 * LICENSE file in the root directory of this source tree. An additional grant
6763 * of patent rights can be found in the PATENTS file in the same directory.
6764 *
6765 * @providesModule ReactContext
6766 */
6767
6768"use strict";
6769
6770var assign = _dereq_("./Object.assign");
6771
6772/**
6773 * Keeps track of the current context.
6774 *
6775 * The context is automatically passed down the component ownership hierarchy
6776 * and is accessible via `this.context` on ReactCompositeComponents.
6777 */
6778var ReactContext = {
6779
6780 /**
6781 * @internal
6782 * @type {object}
6783 */
6784 current: {},
6785
6786 /**
6787 * Temporarily extends the current context while executing scopedCallback.
6788 *
6789 * A typical use case might look like
6790 *
6791 * render: function() {
6792 * var children = ReactContext.withContext({foo: 'foo'}, () => (
6793 *
6794 * ));
6795 * return <div>{children}</div>;
6796 * }
6797 *
6798 * @param {object} newContext New context to merge into the existing context
6799 * @param {function} scopedCallback Callback to run with the new context
6800 * @return {ReactComponent|array<ReactComponent>}
6801 */
6802 withContext: function(newContext, scopedCallback) {
6803 var result;
6804 var previousContext = ReactContext.current;
6805 ReactContext.current = assign({}, previousContext, newContext);
6806 try {
6807 result = scopedCallback();
6808 } finally {
6809 ReactContext.current = previousContext;
6810 }
6811 return result;
6812 }
6813
6814};
6815
6816module.exports = ReactContext;
6817
6818},{"./Object.assign":27}],36:[function(_dereq_,module,exports){
6819/**
6820 * Copyright 2013-2014, Facebook, Inc.
6821 * All rights reserved.
6822 *
6823 * This source code is licensed under the BSD-style license found in the
6824 * LICENSE file in the root directory of this source tree. An additional grant
6825 * of patent rights can be found in the PATENTS file in the same directory.
6826 *
6827 * @providesModule ReactCurrentOwner
6828 */
6829
6830"use strict";
6831
6832/**
6833 * Keeps track of the current owner.
6834 *
6835 * The current owner is the component who should own any components that are
6836 * currently being constructed.
6837 *
6838 * The depth indicate how many composite components are above this render level.
6839 */
6840var ReactCurrentOwner = {
6841
6842 /**
6843 * @internal
6844 * @type {ReactComponent}
6845 */
6846 current: null
6847
6848};
6849
6850module.exports = ReactCurrentOwner;
6851
6852},{}],37:[function(_dereq_,module,exports){
6853/**
6854 * Copyright 2013-2014, Facebook, Inc.
6855 * All rights reserved.
6856 *
6857 * This source code is licensed under the BSD-style license found in the
6858 * LICENSE file in the root directory of this source tree. An additional grant
6859 * of patent rights can be found in the PATENTS file in the same directory.
6860 *
6861 * @providesModule ReactDOM
6862 * @typechecks static-only
6863 */
6864
6865"use strict";
6866
6867var ReactElement = _dereq_("./ReactElement");
6868var ReactElementValidator = _dereq_("./ReactElementValidator");
6869var ReactLegacyElement = _dereq_("./ReactLegacyElement");
6870
6871var mapObject = _dereq_("./mapObject");
6872
6873/**
6874 * Create a factory that creates HTML tag elements.
6875 *
6876 * @param {string} tag Tag name (e.g. `div`).
6877 * @private
6878 */
6879function createDOMFactory(tag) {
6880 if ("production" !== "development") {
6881 return ReactLegacyElement.markNonLegacyFactory(
6882 ReactElementValidator.createFactory(tag)
6883 );
6884 }
6885 return ReactLegacyElement.markNonLegacyFactory(
6886 ReactElement.createFactory(tag)
6887 );
6888}
6889
6890/**
6891 * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
6892 * This is also accessible via `React.DOM`.
6893 *
6894 * @public
6895 */
6896var ReactDOM = mapObject({
6897 a: 'a',
6898 abbr: 'abbr',
6899 address: 'address',
6900 area: 'area',
6901 article: 'article',
6902 aside: 'aside',
6903 audio: 'audio',
6904 b: 'b',
6905 base: 'base',
6906 bdi: 'bdi',
6907 bdo: 'bdo',
6908 big: 'big',
6909 blockquote: 'blockquote',
6910 body: 'body',
6911 br: 'br',
6912 button: 'button',
6913 canvas: 'canvas',
6914 caption: 'caption',
6915 cite: 'cite',
6916 code: 'code',
6917 col: 'col',
6918 colgroup: 'colgroup',
6919 data: 'data',
6920 datalist: 'datalist',
6921 dd: 'dd',
6922 del: 'del',
6923 details: 'details',
6924 dfn: 'dfn',
6925 dialog: 'dialog',
6926 div: 'div',
6927 dl: 'dl',
6928 dt: 'dt',
6929 em: 'em',
6930 embed: 'embed',
6931 fieldset: 'fieldset',
6932 figcaption: 'figcaption',
6933 figure: 'figure',
6934 footer: 'footer',
6935 form: 'form',
6936 h1: 'h1',
6937 h2: 'h2',
6938 h3: 'h3',
6939 h4: 'h4',
6940 h5: 'h5',
6941 h6: 'h6',
6942 head: 'head',
6943 header: 'header',
6944 hr: 'hr',
6945 html: 'html',
6946 i: 'i',
6947 iframe: 'iframe',
6948 img: 'img',
6949 input: 'input',
6950 ins: 'ins',
6951 kbd: 'kbd',
6952 keygen: 'keygen',
6953 label: 'label',
6954 legend: 'legend',
6955 li: 'li',
6956 link: 'link',
6957 main: 'main',
6958 map: 'map',
6959 mark: 'mark',
6960 menu: 'menu',
6961 menuitem: 'menuitem',
6962 meta: 'meta',
6963 meter: 'meter',
6964 nav: 'nav',
6965 noscript: 'noscript',
6966 object: 'object',
6967 ol: 'ol',
6968 optgroup: 'optgroup',
6969 option: 'option',
6970 output: 'output',
6971 p: 'p',
6972 param: 'param',
6973 picture: 'picture',
6974 pre: 'pre',
6975 progress: 'progress',
6976 q: 'q',
6977 rp: 'rp',
6978 rt: 'rt',
6979 ruby: 'ruby',
6980 s: 's',
6981 samp: 'samp',
6982 script: 'script',
6983 section: 'section',
6984 select: 'select',
6985 small: 'small',
6986 source: 'source',
6987 span: 'span',
6988 strong: 'strong',
6989 style: 'style',
6990 sub: 'sub',
6991 summary: 'summary',
6992 sup: 'sup',
6993 table: 'table',
6994 tbody: 'tbody',
6995 td: 'td',
6996 textarea: 'textarea',
6997 tfoot: 'tfoot',
6998 th: 'th',
6999 thead: 'thead',
7000 time: 'time',
7001 title: 'title',
7002 tr: 'tr',
7003 track: 'track',
7004 u: 'u',
7005 ul: 'ul',
7006 'var': 'var',
7007 video: 'video',
7008 wbr: 'wbr',
7009
7010 // SVG
7011 circle: 'circle',
7012 defs: 'defs',
7013 ellipse: 'ellipse',
7014 g: 'g',
7015 line: 'line',
7016 linearGradient: 'linearGradient',
7017 mask: 'mask',
7018 path: 'path',
7019 pattern: 'pattern',
7020 polygon: 'polygon',
7021 polyline: 'polyline',
7022 radialGradient: 'radialGradient',
7023 rect: 'rect',
7024 stop: 'stop',
7025 svg: 'svg',
7026 text: 'text',
7027 tspan: 'tspan',
7028 feColorMatrix: 'feColorMatrix',
7029 feGaussianBlur: 'feGaussianBlur',
7030 feOffset: 'feOffset',
7031 feFlood: 'feFlood',
7032 feComposite: 'feComposite',
7033 feMerge: 'feMerge',
7034 feMergeNode: 'feMergeNode',
7035 filter: 'filter',
7036 image: 'image',
7037 clipPath: 'clipPath',
7038
7039
7040
7041
7042}, createDOMFactory);
7043
7044module.exports = ReactDOM;
7045
7046},{"./ReactElement":52,"./ReactElementValidator":53,"./ReactLegacyElement":61,"./mapObject":134}],38:[function(_dereq_,module,exports){
7047/**
7048 * Copyright 2013-2014, Facebook, Inc.
7049 * All rights reserved.
7050 *
7051 * This source code is licensed under the BSD-style license found in the
7052 * LICENSE file in the root directory of this source tree. An additional grant
7053 * of patent rights can be found in the PATENTS file in the same directory.
7054 *
7055 * @providesModule ReactDOMButton
7056 */
7057
7058"use strict";
7059
7060var AutoFocusMixin = _dereq_("./AutoFocusMixin");
7061var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
7062var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
7063var ReactElement = _dereq_("./ReactElement");
7064var ReactDOM = _dereq_("./ReactDOM");
7065
7066var keyMirror = _dereq_("./keyMirror");
7067
7068// Store a reference to the <button> `ReactDOMComponent`. TODO: use string
7069var button = ReactElement.createFactory(ReactDOM.button.type);
7070
7071var mouseListenerNames = keyMirror({
7072 onClick: true,
7073 onDoubleClick: true,
7074 onMouseDown: true,
7075 onMouseMove: true,
7076 onMouseUp: true,
7077 onClickCapture: true,
7078 onDoubleClickCapture: true,
7079 onMouseDownCapture: true,
7080 onMouseMoveCapture: true,
7081 onMouseUpCapture: true
7082});
7083
7084/**
7085 * Implements a <button> native component that does not receive mouse events
7086 * when `disabled` is set.
7087 */
7088var ReactDOMButton = ReactCompositeComponent.createClass({
7089 displayName: 'ReactDOMButton',
7090
7091 mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
7092
7093 render: function() {
7094 var props = {};
7095
7096 // Copy the props; except the mouse listeners if we're disabled
7097 for (var key in this.props) {
7098 if (this.props.hasOwnProperty(key) &&
7099 (!this.props.disabled || !mouseListenerNames[key])) {
7100 props[key] = this.props[key];
7101 }
7102 }
7103
7104 return button(props, this.props.children);
7105 }
7106
7107});
7108
7109module.exports = ReactDOMButton;
7110
7111},{"./AutoFocusMixin":2,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./keyMirror":132}],39:[function(_dereq_,module,exports){
7112/**
7113 * Copyright 2013-2014, Facebook, Inc.
7114 * All rights reserved.
7115 *
7116 * This source code is licensed under the BSD-style license found in the
7117 * LICENSE file in the root directory of this source tree. An additional grant
7118 * of patent rights can be found in the PATENTS file in the same directory.
7119 *
7120 * @providesModule ReactDOMComponent
7121 * @typechecks static-only
7122 */
7123
7124"use strict";
7125
7126var CSSPropertyOperations = _dereq_("./CSSPropertyOperations");
7127var DOMProperty = _dereq_("./DOMProperty");
7128var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
7129var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
7130var ReactComponent = _dereq_("./ReactComponent");
7131var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
7132var ReactMount = _dereq_("./ReactMount");
7133var ReactMultiChild = _dereq_("./ReactMultiChild");
7134var ReactPerf = _dereq_("./ReactPerf");
7135
7136var assign = _dereq_("./Object.assign");
7137var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
7138var invariant = _dereq_("./invariant");
7139var isEventSupported = _dereq_("./isEventSupported");
7140var keyOf = _dereq_("./keyOf");
7141var monitorCodeUse = _dereq_("./monitorCodeUse");
7142
7143var deleteListener = ReactBrowserEventEmitter.deleteListener;
7144var listenTo = ReactBrowserEventEmitter.listenTo;
7145var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
7146
7147// For quickly matching children type, to test if can be treated as content.
7148var CONTENT_TYPES = {'string': true, 'number': true};
7149
7150var STYLE = keyOf({style: null});
7151
7152var ELEMENT_NODE_TYPE = 1;
7153
7154/**
7155 * @param {?object} props
7156 */
7157function assertValidProps(props) {
7158 if (!props) {
7159 return;
7160 }
7161 // Note the use of `==` which checks for null or undefined.
7162 ("production" !== "development" ? invariant(
7163 props.children == null || props.dangerouslySetInnerHTML == null,
7164 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
7165 ) : invariant(props.children == null || props.dangerouslySetInnerHTML == null));
7166 if ("production" !== "development") {
7167 if (props.contentEditable && props.children != null) {
7168 console.warn(
7169 'A component is `contentEditable` and contains `children` managed by ' +
7170 'React. It is now your responsibility to guarantee that none of those '+
7171 'nodes are unexpectedly modified or duplicated. This is probably not ' +
7172 'intentional.'
7173 );
7174 }
7175 }
7176 ("production" !== "development" ? invariant(
7177 props.style == null || typeof props.style === 'object',
7178 'The `style` prop expects a mapping from style properties to values, ' +
7179 'not a string.'
7180 ) : invariant(props.style == null || typeof props.style === 'object'));
7181}
7182
7183function putListener(id, registrationName, listener, transaction) {
7184 if ("production" !== "development") {
7185 // IE8 has no API for event capturing and the `onScroll` event doesn't
7186 // bubble.
7187 if (registrationName === 'onScroll' &&
7188 !isEventSupported('scroll', true)) {
7189 monitorCodeUse('react_no_scroll_event');
7190 console.warn('This browser doesn\'t support the `onScroll` event');
7191 }
7192 }
7193 var container = ReactMount.findReactContainerForID(id);
7194 if (container) {
7195 var doc = container.nodeType === ELEMENT_NODE_TYPE ?
7196 container.ownerDocument :
7197 container;
7198 listenTo(registrationName, doc);
7199 }
7200 transaction.getPutListenerQueue().enqueuePutListener(
7201 id,
7202 registrationName,
7203 listener
7204 );
7205}
7206
7207// For HTML, certain tags should omit their close tag. We keep a whitelist for
7208// those special cased tags.
7209
7210var omittedCloseTags = {
7211 'area': true,
7212 'base': true,
7213 'br': true,
7214 'col': true,
7215 'embed': true,
7216 'hr': true,
7217 'img': true,
7218 'input': true,
7219 'keygen': true,
7220 'link': true,
7221 'meta': true,
7222 'param': true,
7223 'source': true,
7224 'track': true,
7225 'wbr': true
7226 // NOTE: menuitem's close tag should be omitted, but that causes problems.
7227};
7228
7229// We accept any tag to be rendered but since this gets injected into abitrary
7230// HTML, we want to make sure that it's a safe tag.
7231// http://www.w3.org/TR/REC-xml/#NT-Name
7232
7233var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
7234var validatedTagCache = {};
7235var hasOwnProperty = {}.hasOwnProperty;
7236
7237function validateDangerousTag(tag) {
7238 if (!hasOwnProperty.call(validatedTagCache, tag)) {
7239 ("production" !== "development" ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
7240 validatedTagCache[tag] = true;
7241 }
7242}
7243
7244/**
7245 * Creates a new React class that is idempotent and capable of containing other
7246 * React components. It accepts event listeners and DOM properties that are
7247 * valid according to `DOMProperty`.
7248 *
7249 * - Event listeners: `onClick`, `onMouseDown`, etc.
7250 * - DOM properties: `className`, `name`, `title`, etc.
7251 *
7252 * The `style` property functions differently from the DOM API. It accepts an
7253 * object mapping of style properties to values.
7254 *
7255 * @constructor ReactDOMComponent
7256 * @extends ReactComponent
7257 * @extends ReactMultiChild
7258 */
7259function ReactDOMComponent(tag) {
7260 validateDangerousTag(tag);
7261 this._tag = tag;
7262 this.tagName = tag.toUpperCase();
7263}
7264
7265ReactDOMComponent.displayName = 'ReactDOMComponent';
7266
7267ReactDOMComponent.Mixin = {
7268
7269 /**
7270 * Generates root tag markup then recurses. This method has side effects and
7271 * is not idempotent.
7272 *
7273 * @internal
7274 * @param {string} rootID The root DOM ID for this node.
7275 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7276 * @param {number} mountDepth number of components in the owner hierarchy
7277 * @return {string} The computed markup.
7278 */
7279 mountComponent: ReactPerf.measure(
7280 'ReactDOMComponent',
7281 'mountComponent',
7282 function(rootID, transaction, mountDepth) {
7283 ReactComponent.Mixin.mountComponent.call(
7284 this,
7285 rootID,
7286 transaction,
7287 mountDepth
7288 );
7289 assertValidProps(this.props);
7290 var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
7291 return (
7292 this._createOpenTagMarkupAndPutListeners(transaction) +
7293 this._createContentMarkup(transaction) +
7294 closeTag
7295 );
7296 }
7297 ),
7298
7299 /**
7300 * Creates markup for the open tag and all attributes.
7301 *
7302 * This method has side effects because events get registered.
7303 *
7304 * Iterating over object properties is faster than iterating over arrays.
7305 * @see http://jsperf.com/obj-vs-arr-iteration
7306 *
7307 * @private
7308 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7309 * @return {string} Markup of opening tag.
7310 */
7311 _createOpenTagMarkupAndPutListeners: function(transaction) {
7312 var props = this.props;
7313 var ret = '<' + this._tag;
7314
7315 for (var propKey in props) {
7316 if (!props.hasOwnProperty(propKey)) {
7317 continue;
7318 }
7319 var propValue = props[propKey];
7320 if (propValue == null) {
7321 continue;
7322 }
7323 if (registrationNameModules.hasOwnProperty(propKey)) {
7324 putListener(this._rootNodeID, propKey, propValue, transaction);
7325 } else {
7326 if (propKey === STYLE) {
7327 if (propValue) {
7328 propValue = props.style = assign({}, props.style);
7329 }
7330 propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
7331 }
7332 var markup =
7333 DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
7334 if (markup) {
7335 ret += ' ' + markup;
7336 }
7337 }
7338 }
7339
7340 // For static pages, no need to put React ID and checksum. Saves lots of
7341 // bytes.
7342 if (transaction.renderToStaticMarkup) {
7343 return ret + '>';
7344 }
7345
7346 var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
7347 return ret + ' ' + markupForID + '>';
7348 },
7349
7350 /**
7351 * Creates markup for the content between the tags.
7352 *
7353 * @private
7354 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7355 * @return {string} Content markup.
7356 */
7357 _createContentMarkup: function(transaction) {
7358 // Intentional use of != to avoid catching zero/false.
7359 var innerHTML = this.props.dangerouslySetInnerHTML;
7360 if (innerHTML != null) {
7361 if (innerHTML.__html != null) {
7362 return innerHTML.__html;
7363 }
7364 } else {
7365 var contentToUse =
7366 CONTENT_TYPES[typeof this.props.children] ? this.props.children : null;
7367 var childrenToUse = contentToUse != null ? null : this.props.children;
7368 if (contentToUse != null) {
7369 return escapeTextForBrowser(contentToUse);
7370 } else if (childrenToUse != null) {
7371 var mountImages = this.mountChildren(
7372 childrenToUse,
7373 transaction
7374 );
7375 return mountImages.join('');
7376 }
7377 }
7378 return '';
7379 },
7380
7381 receiveComponent: function(nextElement, transaction) {
7382 if (nextElement === this._currentElement &&
7383 nextElement._owner != null) {
7384 // Since elements are immutable after the owner is rendered,
7385 // we can do a cheap identity compare here to determine if this is a
7386 // superfluous reconcile. It's possible for state to be mutable but such
7387 // change should trigger an update of the owner which would recreate
7388 // the element. We explicitly check for the existence of an owner since
7389 // it's possible for a element created outside a composite to be
7390 // deeply mutated and reused.
7391 return;
7392 }
7393
7394 ReactComponent.Mixin.receiveComponent.call(
7395 this,
7396 nextElement,
7397 transaction
7398 );
7399 },
7400
7401 /**
7402 * Updates a native DOM component after it has already been allocated and
7403 * attached to the DOM. Reconciles the root DOM node, then recurses.
7404 *
7405 * @param {ReactReconcileTransaction} transaction
7406 * @param {ReactElement} prevElement
7407 * @internal
7408 * @overridable
7409 */
7410 updateComponent: ReactPerf.measure(
7411 'ReactDOMComponent',
7412 'updateComponent',
7413 function(transaction, prevElement) {
7414 assertValidProps(this._currentElement.props);
7415 ReactComponent.Mixin.updateComponent.call(
7416 this,
7417 transaction,
7418 prevElement
7419 );
7420 this._updateDOMProperties(prevElement.props, transaction);
7421 this._updateDOMChildren(prevElement.props, transaction);
7422 }
7423 ),
7424
7425 /**
7426 * Reconciles the properties by detecting differences in property values and
7427 * updating the DOM as necessary. This function is probably the single most
7428 * critical path for performance optimization.
7429 *
7430 * TODO: Benchmark whether checking for changed values in memory actually
7431 * improves performance (especially statically positioned elements).
7432 * TODO: Benchmark the effects of putting this at the top since 99% of props
7433 * do not change for a given reconciliation.
7434 * TODO: Benchmark areas that can be improved with caching.
7435 *
7436 * @private
7437 * @param {object} lastProps
7438 * @param {ReactReconcileTransaction} transaction
7439 */
7440 _updateDOMProperties: function(lastProps, transaction) {
7441 var nextProps = this.props;
7442 var propKey;
7443 var styleName;
7444 var styleUpdates;
7445 for (propKey in lastProps) {
7446 if (nextProps.hasOwnProperty(propKey) ||
7447 !lastProps.hasOwnProperty(propKey)) {
7448 continue;
7449 }
7450 if (propKey === STYLE) {
7451 var lastStyle = lastProps[propKey];
7452 for (styleName in lastStyle) {
7453 if (lastStyle.hasOwnProperty(styleName)) {
7454 styleUpdates = styleUpdates || {};
7455 styleUpdates[styleName] = '';
7456 }
7457 }
7458 } else if (registrationNameModules.hasOwnProperty(propKey)) {
7459 deleteListener(this._rootNodeID, propKey);
7460 } else if (
7461 DOMProperty.isStandardName[propKey] ||
7462 DOMProperty.isCustomAttribute(propKey)) {
7463 ReactComponent.BackendIDOperations.deletePropertyByID(
7464 this._rootNodeID,
7465 propKey
7466 );
7467 }
7468 }
7469 for (propKey in nextProps) {
7470 var nextProp = nextProps[propKey];
7471 var lastProp = lastProps[propKey];
7472 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
7473 continue;
7474 }
7475 if (propKey === STYLE) {
7476 if (nextProp) {
7477 nextProp = nextProps.style = assign({}, nextProp);
7478 }
7479 if (lastProp) {
7480 // Unset styles on `lastProp` but not on `nextProp`.
7481 for (styleName in lastProp) {
7482 if (lastProp.hasOwnProperty(styleName) &&
7483 (!nextProp || !nextProp.hasOwnProperty(styleName))) {
7484 styleUpdates = styleUpdates || {};
7485 styleUpdates[styleName] = '';
7486 }
7487 }
7488 // Update styles that changed since `lastProp`.
7489 for (styleName in nextProp) {
7490 if (nextProp.hasOwnProperty(styleName) &&
7491 lastProp[styleName] !== nextProp[styleName]) {
7492 styleUpdates = styleUpdates || {};
7493 styleUpdates[styleName] = nextProp[styleName];
7494 }
7495 }
7496 } else {
7497 // Relies on `updateStylesByID` not mutating `styleUpdates`.
7498 styleUpdates = nextProp;
7499 }
7500 } else if (registrationNameModules.hasOwnProperty(propKey)) {
7501 putListener(this._rootNodeID, propKey, nextProp, transaction);
7502 } else if (
7503 DOMProperty.isStandardName[propKey] ||
7504 DOMProperty.isCustomAttribute(propKey)) {
7505 ReactComponent.BackendIDOperations.updatePropertyByID(
7506 this._rootNodeID,
7507 propKey,
7508 nextProp
7509 );
7510 }
7511 }
7512 if (styleUpdates) {
7513 ReactComponent.BackendIDOperations.updateStylesByID(
7514 this._rootNodeID,
7515 styleUpdates
7516 );
7517 }
7518 },
7519
7520 /**
7521 * Reconciles the children with the various properties that affect the
7522 * children content.
7523 *
7524 * @param {object} lastProps
7525 * @param {ReactReconcileTransaction} transaction
7526 */
7527 _updateDOMChildren: function(lastProps, transaction) {
7528 var nextProps = this.props;
7529
7530 var lastContent =
7531 CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
7532 var nextContent =
7533 CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
7534
7535 var lastHtml =
7536 lastProps.dangerouslySetInnerHTML &&
7537 lastProps.dangerouslySetInnerHTML.__html;
7538 var nextHtml =
7539 nextProps.dangerouslySetInnerHTML &&
7540 nextProps.dangerouslySetInnerHTML.__html;
7541
7542 // Note the use of `!=` which checks for null or undefined.
7543 var lastChildren = lastContent != null ? null : lastProps.children;
7544 var nextChildren = nextContent != null ? null : nextProps.children;
7545
7546 // If we're switching from children to content/html or vice versa, remove
7547 // the old content
7548 var lastHasContentOrHtml = lastContent != null || lastHtml != null;
7549 var nextHasContentOrHtml = nextContent != null || nextHtml != null;
7550 if (lastChildren != null && nextChildren == null) {
7551 this.updateChildren(null, transaction);
7552 } else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
7553 this.updateTextContent('');
7554 }
7555
7556 if (nextContent != null) {
7557 if (lastContent !== nextContent) {
7558 this.updateTextContent('' + nextContent);
7559 }
7560 } else if (nextHtml != null) {
7561 if (lastHtml !== nextHtml) {
7562 ReactComponent.BackendIDOperations.updateInnerHTMLByID(
7563 this._rootNodeID,
7564 nextHtml
7565 );
7566 }
7567 } else if (nextChildren != null) {
7568 this.updateChildren(nextChildren, transaction);
7569 }
7570 },
7571
7572 /**
7573 * Destroys all event registrations for this instance. Does not remove from
7574 * the DOM. That must be done by the parent.
7575 *
7576 * @internal
7577 */
7578 unmountComponent: function() {
7579 this.unmountChildren();
7580 ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
7581 ReactComponent.Mixin.unmountComponent.call(this);
7582 }
7583
7584};
7585
7586assign(
7587 ReactDOMComponent.prototype,
7588 ReactComponent.Mixin,
7589 ReactDOMComponent.Mixin,
7590 ReactMultiChild.Mixin,
7591 ReactBrowserComponentMixin
7592);
7593
7594module.exports = ReactDOMComponent;
7595
7596},{"./CSSPropertyOperations":5,"./DOMProperty":11,"./DOMPropertyOperations":12,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactBrowserEventEmitter":30,"./ReactComponent":32,"./ReactMount":63,"./ReactMultiChild":64,"./ReactPerf":68,"./escapeTextForBrowser":109,"./invariant":126,"./isEventSupported":127,"./keyOf":133,"./monitorCodeUse":136}],40:[function(_dereq_,module,exports){
7597/**
7598 * Copyright 2013-2014, Facebook, Inc.
7599 * All rights reserved.
7600 *
7601 * This source code is licensed under the BSD-style license found in the
7602 * LICENSE file in the root directory of this source tree. An additional grant
7603 * of patent rights can be found in the PATENTS file in the same directory.
7604 *
7605 * @providesModule ReactDOMForm
7606 */
7607
7608"use strict";
7609
7610var EventConstants = _dereq_("./EventConstants");
7611var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
7612var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
7613var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
7614var ReactElement = _dereq_("./ReactElement");
7615var ReactDOM = _dereq_("./ReactDOM");
7616
7617// Store a reference to the <form> `ReactDOMComponent`. TODO: use string
7618var form = ReactElement.createFactory(ReactDOM.form.type);
7619
7620/**
7621 * Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
7622 * to capture it on the <form> element itself. There are lots of hacks we could
7623 * do to accomplish this, but the most reliable is to make <form> a
7624 * composite component and use `componentDidMount` to attach the event handlers.
7625 */
7626var ReactDOMForm = ReactCompositeComponent.createClass({
7627 displayName: 'ReactDOMForm',
7628
7629 mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
7630
7631 render: function() {
7632 // TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
7633 // `jshint` fails to parse JSX so in order for linting to work in the open
7634 // source repo, we need to just use `ReactDOM.form`.
7635 return form(this.props);
7636 },
7637
7638 componentDidMount: function() {
7639 this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
7640 this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
7641 }
7642});
7643
7644module.exports = ReactDOMForm;
7645
7646},{"./EventConstants":16,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52}],41:[function(_dereq_,module,exports){
7647/**
7648 * Copyright 2013-2014, Facebook, Inc.
7649 * All rights reserved.
7650 *
7651 * This source code is licensed under the BSD-style license found in the
7652 * LICENSE file in the root directory of this source tree. An additional grant
7653 * of patent rights can be found in the PATENTS file in the same directory.
7654 *
7655 * @providesModule ReactDOMIDOperations
7656 * @typechecks static-only
7657 */
7658
7659/*jslint evil: true */
7660
7661"use strict";
7662
7663var CSSPropertyOperations = _dereq_("./CSSPropertyOperations");
7664var DOMChildrenOperations = _dereq_("./DOMChildrenOperations");
7665var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
7666var ReactMount = _dereq_("./ReactMount");
7667var ReactPerf = _dereq_("./ReactPerf");
7668
7669var invariant = _dereq_("./invariant");
7670var setInnerHTML = _dereq_("./setInnerHTML");
7671
7672/**
7673 * Errors for properties that should not be updated with `updatePropertyById()`.
7674 *
7675 * @type {object}
7676 * @private
7677 */
7678var INVALID_PROPERTY_ERRORS = {
7679 dangerouslySetInnerHTML:
7680 '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
7681 style: '`style` must be set using `updateStylesByID()`.'
7682};
7683
7684/**
7685 * Operations used to process updates to DOM nodes. This is made injectable via
7686 * `ReactComponent.BackendIDOperations`.
7687 */
7688var ReactDOMIDOperations = {
7689
7690 /**
7691 * Updates a DOM node with new property values. This should only be used to
7692 * update DOM properties in `DOMProperty`.
7693 *
7694 * @param {string} id ID of the node to update.
7695 * @param {string} name A valid property name, see `DOMProperty`.
7696 * @param {*} value New value of the property.
7697 * @internal
7698 */
7699 updatePropertyByID: ReactPerf.measure(
7700 'ReactDOMIDOperations',
7701 'updatePropertyByID',
7702 function(id, name, value) {
7703 var node = ReactMount.getNode(id);
7704 ("production" !== "development" ? invariant(
7705 !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
7706 'updatePropertyByID(...): %s',
7707 INVALID_PROPERTY_ERRORS[name]
7708 ) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
7709
7710 // If we're updating to null or undefined, we should remove the property
7711 // from the DOM node instead of inadvertantly setting to a string. This
7712 // brings us in line with the same behavior we have on initial render.
7713 if (value != null) {
7714 DOMPropertyOperations.setValueForProperty(node, name, value);
7715 } else {
7716 DOMPropertyOperations.deleteValueForProperty(node, name);
7717 }
7718 }
7719 ),
7720
7721 /**
7722 * Updates a DOM node to remove a property. This should only be used to remove
7723 * DOM properties in `DOMProperty`.
7724 *
7725 * @param {string} id ID of the node to update.
7726 * @param {string} name A property name to remove, see `DOMProperty`.
7727 * @internal
7728 */
7729 deletePropertyByID: ReactPerf.measure(
7730 'ReactDOMIDOperations',
7731 'deletePropertyByID',
7732 function(id, name, value) {
7733 var node = ReactMount.getNode(id);
7734 ("production" !== "development" ? invariant(
7735 !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
7736 'updatePropertyByID(...): %s',
7737 INVALID_PROPERTY_ERRORS[name]
7738 ) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
7739 DOMPropertyOperations.deleteValueForProperty(node, name, value);
7740 }
7741 ),
7742
7743 /**
7744 * Updates a DOM node with new style values. If a value is specified as '',
7745 * the corresponding style property will be unset.
7746 *
7747 * @param {string} id ID of the node to update.
7748 * @param {object} styles Mapping from styles to values.
7749 * @internal
7750 */
7751 updateStylesByID: ReactPerf.measure(
7752 'ReactDOMIDOperations',
7753 'updateStylesByID',
7754 function(id, styles) {
7755 var node = ReactMount.getNode(id);
7756 CSSPropertyOperations.setValueForStyles(node, styles);
7757 }
7758 ),
7759
7760 /**
7761 * Updates a DOM node's innerHTML.
7762 *
7763 * @param {string} id ID of the node to update.
7764 * @param {string} html An HTML string.
7765 * @internal
7766 */
7767 updateInnerHTMLByID: ReactPerf.measure(
7768 'ReactDOMIDOperations',
7769 'updateInnerHTMLByID',
7770 function(id, html) {
7771 var node = ReactMount.getNode(id);
7772 setInnerHTML(node, html);
7773 }
7774 ),
7775
7776 /**
7777 * Updates a DOM node's text content set by `props.content`.
7778 *
7779 * @param {string} id ID of the node to update.
7780 * @param {string} content Text content.
7781 * @internal
7782 */
7783 updateTextContentByID: ReactPerf.measure(
7784 'ReactDOMIDOperations',
7785 'updateTextContentByID',
7786 function(id, content) {
7787 var node = ReactMount.getNode(id);
7788 DOMChildrenOperations.updateTextContent(node, content);
7789 }
7790 ),
7791
7792 /**
7793 * Replaces a DOM node that exists in the document with markup.
7794 *
7795 * @param {string} id ID of child to be replaced.
7796 * @param {string} markup Dangerous markup to inject in place of child.
7797 * @internal
7798 * @see {Danger.dangerouslyReplaceNodeWithMarkup}
7799 */
7800 dangerouslyReplaceNodeWithMarkupByID: ReactPerf.measure(
7801 'ReactDOMIDOperations',
7802 'dangerouslyReplaceNodeWithMarkupByID',
7803 function(id, markup) {
7804 var node = ReactMount.getNode(id);
7805 DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
7806 }
7807 ),
7808
7809 /**
7810 * Updates a component's children by processing a series of updates.
7811 *
7812 * @param {array<object>} updates List of update configurations.
7813 * @param {array<string>} markup List of markup strings.
7814 * @internal
7815 */
7816 dangerouslyProcessChildrenUpdates: ReactPerf.measure(
7817 'ReactDOMIDOperations',
7818 'dangerouslyProcessChildrenUpdates',
7819 function(updates, markup) {
7820 for (var i = 0; i < updates.length; i++) {
7821 updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
7822 }
7823 DOMChildrenOperations.processUpdates(updates, markup);
7824 }
7825 )
7826};
7827
7828module.exports = ReactDOMIDOperations;
7829
7830},{"./CSSPropertyOperations":5,"./DOMChildrenOperations":10,"./DOMPropertyOperations":12,"./ReactMount":63,"./ReactPerf":68,"./invariant":126,"./setInnerHTML":140}],42:[function(_dereq_,module,exports){
7831/**
7832 * Copyright 2013-2014, Facebook, Inc.
7833 * All rights reserved.
7834 *
7835 * This source code is licensed under the BSD-style license found in the
7836 * LICENSE file in the root directory of this source tree. An additional grant
7837 * of patent rights can be found in the PATENTS file in the same directory.
7838 *
7839 * @providesModule ReactDOMImg
7840 */
7841
7842"use strict";
7843
7844var EventConstants = _dereq_("./EventConstants");
7845var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
7846var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
7847var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
7848var ReactElement = _dereq_("./ReactElement");
7849var ReactDOM = _dereq_("./ReactDOM");
7850
7851// Store a reference to the <img> `ReactDOMComponent`. TODO: use string
7852var img = ReactElement.createFactory(ReactDOM.img.type);
7853
7854/**
7855 * Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
7856 * capture it on the <img> element itself. There are lots of hacks we could do
7857 * to accomplish this, but the most reliable is to make <img> a composite
7858 * component and use `componentDidMount` to attach the event handlers.
7859 */
7860var ReactDOMImg = ReactCompositeComponent.createClass({
7861 displayName: 'ReactDOMImg',
7862 tagName: 'IMG',
7863
7864 mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
7865
7866 render: function() {
7867 return img(this.props);
7868 },
7869
7870 componentDidMount: function() {
7871 this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
7872 this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
7873 }
7874});
7875
7876module.exports = ReactDOMImg;
7877
7878},{"./EventConstants":16,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52}],43:[function(_dereq_,module,exports){
7879/**
7880 * Copyright 2013-2014, Facebook, Inc.
7881 * All rights reserved.
7882 *
7883 * This source code is licensed under the BSD-style license found in the
7884 * LICENSE file in the root directory of this source tree. An additional grant
7885 * of patent rights can be found in the PATENTS file in the same directory.
7886 *
7887 * @providesModule ReactDOMInput
7888 */
7889
7890"use strict";
7891
7892var AutoFocusMixin = _dereq_("./AutoFocusMixin");
7893var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
7894var LinkedValueUtils = _dereq_("./LinkedValueUtils");
7895var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
7896var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
7897var ReactElement = _dereq_("./ReactElement");
7898var ReactDOM = _dereq_("./ReactDOM");
7899var ReactMount = _dereq_("./ReactMount");
7900var ReactUpdates = _dereq_("./ReactUpdates");
7901
7902var assign = _dereq_("./Object.assign");
7903var invariant = _dereq_("./invariant");
7904
7905// Store a reference to the <input> `ReactDOMComponent`. TODO: use string
7906var input = ReactElement.createFactory(ReactDOM.input.type);
7907
7908var instancesByReactID = {};
7909
7910function forceUpdateIfMounted() {
7911 /*jshint validthis:true */
7912 if (this.isMounted()) {
7913 this.forceUpdate();
7914 }
7915}
7916
7917/**
7918 * Implements an <input> native component that allows setting these optional
7919 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
7920 *
7921 * If `checked` or `value` are not supplied (or null/undefined), user actions
7922 * that affect the checked state or value will trigger updates to the element.
7923 *
7924 * If they are supplied (and not null/undefined), the rendered element will not
7925 * trigger updates to the element. Instead, the props must change in order for
7926 * the rendered element to be updated.
7927 *
7928 * The rendered element will be initialized as unchecked (or `defaultChecked`)
7929 * with an empty value (or `defaultValue`).
7930 *
7931 * @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
7932 */
7933var ReactDOMInput = ReactCompositeComponent.createClass({
7934 displayName: 'ReactDOMInput',
7935
7936 mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
7937
7938 getInitialState: function() {
7939 var defaultValue = this.props.defaultValue;
7940 return {
7941 initialChecked: this.props.defaultChecked || false,
7942 initialValue: defaultValue != null ? defaultValue : null
7943 };
7944 },
7945
7946 render: function() {
7947 // Clone `this.props` so we don't mutate the input.
7948 var props = assign({}, this.props);
7949
7950 props.defaultChecked = null;
7951 props.defaultValue = null;
7952
7953 var value = LinkedValueUtils.getValue(this);
7954 props.value = value != null ? value : this.state.initialValue;
7955
7956 var checked = LinkedValueUtils.getChecked(this);
7957 props.checked = checked != null ? checked : this.state.initialChecked;
7958
7959 props.onChange = this._handleChange;
7960
7961 return input(props, this.props.children);
7962 },
7963
7964 componentDidMount: function() {
7965 var id = ReactMount.getID(this.getDOMNode());
7966 instancesByReactID[id] = this;
7967 },
7968
7969 componentWillUnmount: function() {
7970 var rootNode = this.getDOMNode();
7971 var id = ReactMount.getID(rootNode);
7972 delete instancesByReactID[id];
7973 },
7974
7975 componentDidUpdate: function(prevProps, prevState, prevContext) {
7976 var rootNode = this.getDOMNode();
7977 if (this.props.checked != null) {
7978 DOMPropertyOperations.setValueForProperty(
7979 rootNode,
7980 'checked',
7981 this.props.checked || false
7982 );
7983 }
7984
7985 var value = LinkedValueUtils.getValue(this);
7986 if (value != null) {
7987 // Cast `value` to a string to ensure the value is set correctly. While
7988 // browsers typically do this as necessary, jsdom doesn't.
7989 DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
7990 }
7991 },
7992
7993 _handleChange: function(event) {
7994 var returnValue;
7995 var onChange = LinkedValueUtils.getOnChange(this);
7996 if (onChange) {
7997 returnValue = onChange.call(this, event);
7998 }
7999 // Here we use asap to wait until all updates have propagated, which
8000 // is important when using controlled components within layers:
8001 // https://github.com/facebook/react/issues/1698
8002 ReactUpdates.asap(forceUpdateIfMounted, this);
8003
8004 var name = this.props.name;
8005 if (this.props.type === 'radio' && name != null) {
8006 var rootNode = this.getDOMNode();
8007 var queryRoot = rootNode;
8008
8009 while (queryRoot.parentNode) {
8010 queryRoot = queryRoot.parentNode;
8011 }
8012
8013 // If `rootNode.form` was non-null, then we could try `form.elements`,
8014 // but that sometimes behaves strangely in IE8. We could also try using
8015 // `form.getElementsByName`, but that will only return direct children
8016 // and won't include inputs that use the HTML5 `form=` attribute. Since
8017 // the input might not even be in a form, let's just use the global
8018 // `querySelectorAll` to ensure we don't miss anything.
8019 var group = queryRoot.querySelectorAll(
8020 'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
8021
8022 for (var i = 0, groupLen = group.length; i < groupLen; i++) {
8023 var otherNode = group[i];
8024 if (otherNode === rootNode ||
8025 otherNode.form !== rootNode.form) {
8026 continue;
8027 }
8028 var otherID = ReactMount.getID(otherNode);
8029 ("production" !== "development" ? invariant(
8030 otherID,
8031 'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
8032 'same `name` is not supported.'
8033 ) : invariant(otherID));
8034 var otherInstance = instancesByReactID[otherID];
8035 ("production" !== "development" ? invariant(
8036 otherInstance,
8037 'ReactDOMInput: Unknown radio button ID %s.',
8038 otherID
8039 ) : invariant(otherInstance));
8040 // If this is a controlled radio button group, forcing the input that
8041 // was previously checked to update will cause it to be come re-checked
8042 // as appropriate.
8043 ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
8044 }
8045 }
8046
8047 return returnValue;
8048 }
8049
8050});
8051
8052module.exports = ReactDOMInput;
8053
8054},{"./AutoFocusMixin":2,"./DOMPropertyOperations":12,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactMount":63,"./ReactUpdates":79,"./invariant":126}],44:[function(_dereq_,module,exports){
8055/**
8056 * Copyright 2013-2014, Facebook, Inc.
8057 * All rights reserved.
8058 *
8059 * This source code is licensed under the BSD-style license found in the
8060 * LICENSE file in the root directory of this source tree. An additional grant
8061 * of patent rights can be found in the PATENTS file in the same directory.
8062 *
8063 * @providesModule ReactDOMOption
8064 */
8065
8066"use strict";
8067
8068var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
8069var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
8070var ReactElement = _dereq_("./ReactElement");
8071var ReactDOM = _dereq_("./ReactDOM");
8072
8073var warning = _dereq_("./warning");
8074
8075// Store a reference to the <option> `ReactDOMComponent`. TODO: use string
8076var option = ReactElement.createFactory(ReactDOM.option.type);
8077
8078/**
8079 * Implements an <option> native component that warns when `selected` is set.
8080 */
8081var ReactDOMOption = ReactCompositeComponent.createClass({
8082 displayName: 'ReactDOMOption',
8083
8084 mixins: [ReactBrowserComponentMixin],
8085
8086 componentWillMount: function() {
8087 // TODO (yungsters): Remove support for `selected` in <option>.
8088 if ("production" !== "development") {
8089 ("production" !== "development" ? warning(
8090 this.props.selected == null,
8091 'Use the `defaultValue` or `value` props on <select> instead of ' +
8092 'setting `selected` on <option>.'
8093 ) : null);
8094 }
8095 },
8096
8097 render: function() {
8098 return option(this.props, this.props.children);
8099 }
8100
8101});
8102
8103module.exports = ReactDOMOption;
8104
8105},{"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./warning":145}],45:[function(_dereq_,module,exports){
8106/**
8107 * Copyright 2013-2014, Facebook, Inc.
8108 * All rights reserved.
8109 *
8110 * This source code is licensed under the BSD-style license found in the
8111 * LICENSE file in the root directory of this source tree. An additional grant
8112 * of patent rights can be found in the PATENTS file in the same directory.
8113 *
8114 * @providesModule ReactDOMSelect
8115 */
8116
8117"use strict";
8118
8119var AutoFocusMixin = _dereq_("./AutoFocusMixin");
8120var LinkedValueUtils = _dereq_("./LinkedValueUtils");
8121var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
8122var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
8123var ReactElement = _dereq_("./ReactElement");
8124var ReactDOM = _dereq_("./ReactDOM");
8125var ReactUpdates = _dereq_("./ReactUpdates");
8126
8127var assign = _dereq_("./Object.assign");
8128
8129// Store a reference to the <select> `ReactDOMComponent`. TODO: use string
8130var select = ReactElement.createFactory(ReactDOM.select.type);
8131
8132function updateWithPendingValueIfMounted() {
8133 /*jshint validthis:true */
8134 if (this.isMounted()) {
8135 this.setState({value: this._pendingValue});
8136 this._pendingValue = 0;
8137 }
8138}
8139
8140/**
8141 * Validation function for `value` and `defaultValue`.
8142 * @private
8143 */
8144function selectValueType(props, propName, componentName) {
8145 if (props[propName] == null) {
8146 return;
8147 }
8148 if (props.multiple) {
8149 if (!Array.isArray(props[propName])) {
8150 return new Error(
8151 ("The `" + propName + "` prop supplied to <select> must be an array if ") +
8152 ("`multiple` is true.")
8153 );
8154 }
8155 } else {
8156 if (Array.isArray(props[propName])) {
8157 return new Error(
8158 ("The `" + propName + "` prop supplied to <select> must be a scalar ") +
8159 ("value if `multiple` is false.")
8160 );
8161 }
8162 }
8163}
8164
8165/**
8166 * If `value` is supplied, updates <option> elements on mount and update.
8167 * @param {ReactComponent} component Instance of ReactDOMSelect
8168 * @param {?*} propValue For uncontrolled components, null/undefined. For
8169 * controlled components, a string (or with `multiple`, a list of strings).
8170 * @private
8171 */
8172function updateOptions(component, propValue) {
8173 var multiple = component.props.multiple;
8174 var value = propValue != null ? propValue : component.state.value;
8175 var options = component.getDOMNode().options;
8176 var selectedValue, i, l;
8177 if (multiple) {
8178 selectedValue = {};
8179 for (i = 0, l = value.length; i < l; ++i) {
8180 selectedValue['' + value[i]] = true;
8181 }
8182 } else {
8183 selectedValue = '' + value;
8184 }
8185 for (i = 0, l = options.length; i < l; i++) {
8186 var selected = multiple ?
8187 selectedValue.hasOwnProperty(options[i].value) :
8188 options[i].value === selectedValue;
8189
8190 if (selected !== options[i].selected) {
8191 options[i].selected = selected;
8192 }
8193 }
8194}
8195
8196/**
8197 * Implements a <select> native component that allows optionally setting the
8198 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
8199 * string. If `multiple` is true, the prop must be an array of strings.
8200 *
8201 * If `value` is not supplied (or null/undefined), user actions that change the
8202 * selected option will trigger updates to the rendered options.
8203 *
8204 * If it is supplied (and not null/undefined), the rendered options will not
8205 * update in response to user actions. Instead, the `value` prop must change in
8206 * order for the rendered options to update.
8207 *
8208 * If `defaultValue` is provided, any options with the supplied values will be
8209 * selected.
8210 */
8211var ReactDOMSelect = ReactCompositeComponent.createClass({
8212 displayName: 'ReactDOMSelect',
8213
8214 mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
8215
8216 propTypes: {
8217 defaultValue: selectValueType,
8218 value: selectValueType
8219 },
8220
8221 getInitialState: function() {
8222 return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
8223 },
8224
8225 componentWillMount: function() {
8226 this._pendingValue = null;
8227 },
8228
8229 componentWillReceiveProps: function(nextProps) {
8230 if (!this.props.multiple && nextProps.multiple) {
8231 this.setState({value: [this.state.value]});
8232 } else if (this.props.multiple && !nextProps.multiple) {
8233 this.setState({value: this.state.value[0]});
8234 }
8235 },
8236
8237 render: function() {
8238 // Clone `this.props` so we don't mutate the input.
8239 var props = assign({}, this.props);
8240
8241 props.onChange = this._handleChange;
8242 props.value = null;
8243
8244 return select(props, this.props.children);
8245 },
8246
8247 componentDidMount: function() {
8248 updateOptions(this, LinkedValueUtils.getValue(this));
8249 },
8250
8251 componentDidUpdate: function(prevProps) {
8252 var value = LinkedValueUtils.getValue(this);
8253 var prevMultiple = !!prevProps.multiple;
8254 var multiple = !!this.props.multiple;
8255 if (value != null || prevMultiple !== multiple) {
8256 updateOptions(this, value);
8257 }
8258 },
8259
8260 _handleChange: function(event) {
8261 var returnValue;
8262 var onChange = LinkedValueUtils.getOnChange(this);
8263 if (onChange) {
8264 returnValue = onChange.call(this, event);
8265 }
8266
8267 var selectedValue;
8268 if (this.props.multiple) {
8269 selectedValue = [];
8270 var options = event.target.options;
8271 for (var i = 0, l = options.length; i < l; i++) {
8272 if (options[i].selected) {
8273 selectedValue.push(options[i].value);
8274 }
8275 }
8276 } else {
8277 selectedValue = event.target.value;
8278 }
8279
8280 this._pendingValue = selectedValue;
8281 ReactUpdates.asap(updateWithPendingValueIfMounted, this);
8282 return returnValue;
8283 }
8284
8285});
8286
8287module.exports = ReactDOMSelect;
8288
8289},{"./AutoFocusMixin":2,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactUpdates":79}],46:[function(_dereq_,module,exports){
8290/**
8291 * Copyright 2013-2014, Facebook, Inc.
8292 * All rights reserved.
8293 *
8294 * This source code is licensed under the BSD-style license found in the
8295 * LICENSE file in the root directory of this source tree. An additional grant
8296 * of patent rights can be found in the PATENTS file in the same directory.
8297 *
8298 * @providesModule ReactDOMSelection
8299 */
8300
8301"use strict";
8302
8303var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
8304
8305var getNodeForCharacterOffset = _dereq_("./getNodeForCharacterOffset");
8306var getTextContentAccessor = _dereq_("./getTextContentAccessor");
8307
8308/**
8309 * While `isCollapsed` is available on the Selection object and `collapsed`
8310 * is available on the Range object, IE11 sometimes gets them wrong.
8311 * If the anchor/focus nodes and offsets are the same, the range is collapsed.
8312 */
8313function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
8314 return anchorNode === focusNode && anchorOffset === focusOffset;
8315}
8316
8317/**
8318 * Get the appropriate anchor and focus node/offset pairs for IE.
8319 *
8320 * The catch here is that IE's selection API doesn't provide information
8321 * about whether the selection is forward or backward, so we have to
8322 * behave as though it's always forward.
8323 *
8324 * IE text differs from modern selection in that it behaves as though
8325 * block elements end with a new line. This means character offsets will
8326 * differ between the two APIs.
8327 *
8328 * @param {DOMElement} node
8329 * @return {object}
8330 */
8331function getIEOffsets(node) {
8332 var selection = document.selection;
8333 var selectedRange = selection.createRange();
8334 var selectedLength = selectedRange.text.length;
8335
8336 // Duplicate selection so we can move range without breaking user selection.
8337 var fromStart = selectedRange.duplicate();
8338 fromStart.moveToElementText(node);
8339 fromStart.setEndPoint('EndToStart', selectedRange);
8340
8341 var startOffset = fromStart.text.length;
8342 var endOffset = startOffset + selectedLength;
8343
8344 return {
8345 start: startOffset,
8346 end: endOffset
8347 };
8348}
8349
8350/**
8351 * @param {DOMElement} node
8352 * @return {?object}
8353 */
8354function getModernOffsets(node) {
8355 var selection = window.getSelection && window.getSelection();
8356
8357 if (!selection || selection.rangeCount === 0) {
8358 return null;
8359 }
8360
8361 var anchorNode = selection.anchorNode;
8362 var anchorOffset = selection.anchorOffset;
8363 var focusNode = selection.focusNode;
8364 var focusOffset = selection.focusOffset;
8365
8366 var currentRange = selection.getRangeAt(0);
8367
8368 // If the node and offset values are the same, the selection is collapsed.
8369 // `Selection.isCollapsed` is available natively, but IE sometimes gets
8370 // this value wrong.
8371 var isSelectionCollapsed = isCollapsed(
8372 selection.anchorNode,
8373 selection.anchorOffset,
8374 selection.focusNode,
8375 selection.focusOffset
8376 );
8377
8378 var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
8379
8380 var tempRange = currentRange.cloneRange();
8381 tempRange.selectNodeContents(node);
8382 tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
8383
8384 var isTempRangeCollapsed = isCollapsed(
8385 tempRange.startContainer,
8386 tempRange.startOffset,
8387 tempRange.endContainer,
8388 tempRange.endOffset
8389 );
8390
8391 var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
8392 var end = start + rangeLength;
8393
8394 // Detect whether the selection is backward.
8395 var detectionRange = document.createRange();
8396 detectionRange.setStart(anchorNode, anchorOffset);
8397 detectionRange.setEnd(focusNode, focusOffset);
8398 var isBackward = detectionRange.collapsed;
8399
8400 return {
8401 start: isBackward ? end : start,
8402 end: isBackward ? start : end
8403 };
8404}
8405
8406/**
8407 * @param {DOMElement|DOMTextNode} node
8408 * @param {object} offsets
8409 */
8410function setIEOffsets(node, offsets) {
8411 var range = document.selection.createRange().duplicate();
8412 var start, end;
8413
8414 if (typeof offsets.end === 'undefined') {
8415 start = offsets.start;
8416 end = start;
8417 } else if (offsets.start > offsets.end) {
8418 start = offsets.end;
8419 end = offsets.start;
8420 } else {
8421 start = offsets.start;
8422 end = offsets.end;
8423 }
8424
8425 range.moveToElementText(node);
8426 range.moveStart('character', start);
8427 range.setEndPoint('EndToStart', range);
8428 range.moveEnd('character', end - start);
8429 range.select();
8430}
8431
8432/**
8433 * In modern non-IE browsers, we can support both forward and backward
8434 * selections.
8435 *
8436 * Note: IE10+ supports the Selection object, but it does not support
8437 * the `extend` method, which means that even in modern IE, it's not possible
8438 * to programatically create a backward selection. Thus, for all IE
8439 * versions, we use the old IE API to create our selections.
8440 *
8441 * @param {DOMElement|DOMTextNode} node
8442 * @param {object} offsets
8443 */
8444function setModernOffsets(node, offsets) {
8445 if (!window.getSelection) {
8446 return;
8447 }
8448
8449 var selection = window.getSelection();
8450 var length = node[getTextContentAccessor()].length;
8451 var start = Math.min(offsets.start, length);
8452 var end = typeof offsets.end === 'undefined' ?
8453 start : Math.min(offsets.end, length);
8454
8455 // IE 11 uses modern selection, but doesn't support the extend method.
8456 // Flip backward selections, so we can set with a single range.
8457 if (!selection.extend && start > end) {
8458 var temp = end;
8459 end = start;
8460 start = temp;
8461 }
8462
8463 var startMarker = getNodeForCharacterOffset(node, start);
8464 var endMarker = getNodeForCharacterOffset(node, end);
8465
8466 if (startMarker && endMarker) {
8467 var range = document.createRange();
8468 range.setStart(startMarker.node, startMarker.offset);
8469 selection.removeAllRanges();
8470
8471 if (start > end) {
8472 selection.addRange(range);
8473 selection.extend(endMarker.node, endMarker.offset);
8474 } else {
8475 range.setEnd(endMarker.node, endMarker.offset);
8476 selection.addRange(range);
8477 }
8478 }
8479}
8480
8481var useIEOffsets = ExecutionEnvironment.canUseDOM && document.selection;
8482
8483var ReactDOMSelection = {
8484 /**
8485 * @param {DOMElement} node
8486 */
8487 getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
8488
8489 /**
8490 * @param {DOMElement|DOMTextNode} node
8491 * @param {object} offsets
8492 */
8493 setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
8494};
8495
8496module.exports = ReactDOMSelection;
8497
8498},{"./ExecutionEnvironment":22,"./getNodeForCharacterOffset":119,"./getTextContentAccessor":121}],47:[function(_dereq_,module,exports){
8499/**
8500 * Copyright 2013-2014, Facebook, Inc.
8501 * All rights reserved.
8502 *
8503 * This source code is licensed under the BSD-style license found in the
8504 * LICENSE file in the root directory of this source tree. An additional grant
8505 * of patent rights can be found in the PATENTS file in the same directory.
8506 *
8507 * @providesModule ReactDOMTextarea
8508 */
8509
8510"use strict";
8511
8512var AutoFocusMixin = _dereq_("./AutoFocusMixin");
8513var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
8514var LinkedValueUtils = _dereq_("./LinkedValueUtils");
8515var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
8516var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
8517var ReactElement = _dereq_("./ReactElement");
8518var ReactDOM = _dereq_("./ReactDOM");
8519var ReactUpdates = _dereq_("./ReactUpdates");
8520
8521var assign = _dereq_("./Object.assign");
8522var invariant = _dereq_("./invariant");
8523
8524var warning = _dereq_("./warning");
8525
8526// Store a reference to the <textarea> `ReactDOMComponent`. TODO: use string
8527var textarea = ReactElement.createFactory(ReactDOM.textarea.type);
8528
8529function forceUpdateIfMounted() {
8530 /*jshint validthis:true */
8531 if (this.isMounted()) {
8532 this.forceUpdate();
8533 }
8534}
8535
8536/**
8537 * Implements a <textarea> native component that allows setting `value`, and
8538 * `defaultValue`. This differs from the traditional DOM API because value is
8539 * usually set as PCDATA children.
8540 *
8541 * If `value` is not supplied (or null/undefined), user actions that affect the
8542 * value will trigger updates to the element.
8543 *
8544 * If `value` is supplied (and not null/undefined), the rendered element will
8545 * not trigger updates to the element. Instead, the `value` prop must change in
8546 * order for the rendered element to be updated.
8547 *
8548 * The rendered element will be initialized with an empty value, the prop
8549 * `defaultValue` if specified, or the children content (deprecated).
8550 */
8551var ReactDOMTextarea = ReactCompositeComponent.createClass({
8552 displayName: 'ReactDOMTextarea',
8553
8554 mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
8555
8556 getInitialState: function() {
8557 var defaultValue = this.props.defaultValue;
8558 // TODO (yungsters): Remove support for children content in <textarea>.
8559 var children = this.props.children;
8560 if (children != null) {
8561 if ("production" !== "development") {
8562 ("production" !== "development" ? warning(
8563 false,
8564 'Use the `defaultValue` or `value` props instead of setting ' +
8565 'children on <textarea>.'
8566 ) : null);
8567 }
8568 ("production" !== "development" ? invariant(
8569 defaultValue == null,
8570 'If you supply `defaultValue` on a <textarea>, do not pass children.'
8571 ) : invariant(defaultValue == null));
8572 if (Array.isArray(children)) {
8573 ("production" !== "development" ? invariant(
8574 children.length <= 1,
8575 '<textarea> can only have at most one child.'
8576 ) : invariant(children.length <= 1));
8577 children = children[0];
8578 }
8579
8580 defaultValue = '' + children;
8581 }
8582 if (defaultValue == null) {
8583 defaultValue = '';
8584 }
8585 var value = LinkedValueUtils.getValue(this);
8586 return {
8587 // We save the initial value so that `ReactDOMComponent` doesn't update
8588 // `textContent` (unnecessary since we update value).
8589 // The initial value can be a boolean or object so that's why it's
8590 // forced to be a string.
8591 initialValue: '' + (value != null ? value : defaultValue)
8592 };
8593 },
8594
8595 render: function() {
8596 // Clone `this.props` so we don't mutate the input.
8597 var props = assign({}, this.props);
8598
8599 ("production" !== "development" ? invariant(
8600 props.dangerouslySetInnerHTML == null,
8601 '`dangerouslySetInnerHTML` does not make sense on <textarea>.'
8602 ) : invariant(props.dangerouslySetInnerHTML == null));
8603
8604 props.defaultValue = null;
8605 props.value = null;
8606 props.onChange = this._handleChange;
8607
8608 // Always set children to the same thing. In IE9, the selection range will
8609 // get reset if `textContent` is mutated.
8610 return textarea(props, this.state.initialValue);
8611 },
8612
8613 componentDidUpdate: function(prevProps, prevState, prevContext) {
8614 var value = LinkedValueUtils.getValue(this);
8615 if (value != null) {
8616 var rootNode = this.getDOMNode();
8617 // Cast `value` to a string to ensure the value is set correctly. While
8618 // browsers typically do this as necessary, jsdom doesn't.
8619 DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
8620 }
8621 },
8622
8623 _handleChange: function(event) {
8624 var returnValue;
8625 var onChange = LinkedValueUtils.getOnChange(this);
8626 if (onChange) {
8627 returnValue = onChange.call(this, event);
8628 }
8629 ReactUpdates.asap(forceUpdateIfMounted, this);
8630 return returnValue;
8631 }
8632
8633});
8634
8635module.exports = ReactDOMTextarea;
8636
8637},{"./AutoFocusMixin":2,"./DOMPropertyOperations":12,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactUpdates":79,"./invariant":126,"./warning":145}],48:[function(_dereq_,module,exports){
8638/**
8639 * Copyright 2013-2014, Facebook, Inc.
8640 * All rights reserved.
8641 *
8642 * This source code is licensed under the BSD-style license found in the
8643 * LICENSE file in the root directory of this source tree. An additional grant
8644 * of patent rights can be found in the PATENTS file in the same directory.
8645 *
8646 * @providesModule ReactDefaultBatchingStrategy
8647 */
8648
8649"use strict";
8650
8651var ReactUpdates = _dereq_("./ReactUpdates");
8652var Transaction = _dereq_("./Transaction");
8653
8654var assign = _dereq_("./Object.assign");
8655var emptyFunction = _dereq_("./emptyFunction");
8656
8657var RESET_BATCHED_UPDATES = {
8658 initialize: emptyFunction,
8659 close: function() {
8660 ReactDefaultBatchingStrategy.isBatchingUpdates = false;
8661 }
8662};
8663
8664var FLUSH_BATCHED_UPDATES = {
8665 initialize: emptyFunction,
8666 close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
8667};
8668
8669var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
8670
8671function ReactDefaultBatchingStrategyTransaction() {
8672 this.reinitializeTransaction();
8673}
8674
8675assign(
8676 ReactDefaultBatchingStrategyTransaction.prototype,
8677 Transaction.Mixin,
8678 {
8679 getTransactionWrappers: function() {
8680 return TRANSACTION_WRAPPERS;
8681 }
8682 }
8683);
8684
8685var transaction = new ReactDefaultBatchingStrategyTransaction();
8686
8687var ReactDefaultBatchingStrategy = {
8688 isBatchingUpdates: false,
8689
8690 /**
8691 * Call the provided function in a context within which calls to `setState`
8692 * and friends are batched such that components aren't updated unnecessarily.
8693 */
8694 batchedUpdates: function(callback, a, b) {
8695 var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
8696
8697 ReactDefaultBatchingStrategy.isBatchingUpdates = true;
8698
8699 // The code is written this way to avoid extra allocations
8700 if (alreadyBatchingUpdates) {
8701 callback(a, b);
8702 } else {
8703 transaction.perform(callback, null, a, b);
8704 }
8705 }
8706};
8707
8708module.exports = ReactDefaultBatchingStrategy;
8709
8710},{"./Object.assign":27,"./ReactUpdates":79,"./Transaction":95,"./emptyFunction":107}],49:[function(_dereq_,module,exports){
8711/**
8712 * Copyright 2013-2014, Facebook, Inc.
8713 * All rights reserved.
8714 *
8715 * This source code is licensed under the BSD-style license found in the
8716 * LICENSE file in the root directory of this source tree. An additional grant
8717 * of patent rights can be found in the PATENTS file in the same directory.
8718 *
8719 * @providesModule ReactDefaultInjection
8720 */
8721
8722"use strict";
8723
8724var BeforeInputEventPlugin = _dereq_("./BeforeInputEventPlugin");
8725var ChangeEventPlugin = _dereq_("./ChangeEventPlugin");
8726var ClientReactRootIndex = _dereq_("./ClientReactRootIndex");
8727var CompositionEventPlugin = _dereq_("./CompositionEventPlugin");
8728var DefaultEventPluginOrder = _dereq_("./DefaultEventPluginOrder");
8729var EnterLeaveEventPlugin = _dereq_("./EnterLeaveEventPlugin");
8730var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
8731var HTMLDOMPropertyConfig = _dereq_("./HTMLDOMPropertyConfig");
8732var MobileSafariClickEventPlugin = _dereq_("./MobileSafariClickEventPlugin");
8733var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
8734var ReactComponentBrowserEnvironment =
8735 _dereq_("./ReactComponentBrowserEnvironment");
8736var ReactDefaultBatchingStrategy = _dereq_("./ReactDefaultBatchingStrategy");
8737var ReactDOMComponent = _dereq_("./ReactDOMComponent");
8738var ReactDOMButton = _dereq_("./ReactDOMButton");
8739var ReactDOMForm = _dereq_("./ReactDOMForm");
8740var ReactDOMImg = _dereq_("./ReactDOMImg");
8741var ReactDOMInput = _dereq_("./ReactDOMInput");
8742var ReactDOMOption = _dereq_("./ReactDOMOption");
8743var ReactDOMSelect = _dereq_("./ReactDOMSelect");
8744var ReactDOMTextarea = _dereq_("./ReactDOMTextarea");
8745var ReactEventListener = _dereq_("./ReactEventListener");
8746var ReactInjection = _dereq_("./ReactInjection");
8747var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
8748var ReactMount = _dereq_("./ReactMount");
8749var SelectEventPlugin = _dereq_("./SelectEventPlugin");
8750var ServerReactRootIndex = _dereq_("./ServerReactRootIndex");
8751var SimpleEventPlugin = _dereq_("./SimpleEventPlugin");
8752var SVGDOMPropertyConfig = _dereq_("./SVGDOMPropertyConfig");
8753
8754var createFullPageComponent = _dereq_("./createFullPageComponent");
8755
8756function inject() {
8757 ReactInjection.EventEmitter.injectReactEventListener(
8758 ReactEventListener
8759 );
8760
8761 /**
8762 * Inject modules for resolving DOM hierarchy and plugin ordering.
8763 */
8764 ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
8765 ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
8766 ReactInjection.EventPluginHub.injectMount(ReactMount);
8767
8768 /**
8769 * Some important event plugins included by default (without having to require
8770 * them).
8771 */
8772 ReactInjection.EventPluginHub.injectEventPluginsByName({
8773 SimpleEventPlugin: SimpleEventPlugin,
8774 EnterLeaveEventPlugin: EnterLeaveEventPlugin,
8775 ChangeEventPlugin: ChangeEventPlugin,
8776 CompositionEventPlugin: CompositionEventPlugin,
8777 MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
8778 SelectEventPlugin: SelectEventPlugin,
8779 BeforeInputEventPlugin: BeforeInputEventPlugin
8780 });
8781
8782 ReactInjection.NativeComponent.injectGenericComponentClass(
8783 ReactDOMComponent
8784 );
8785
8786 ReactInjection.NativeComponent.injectComponentClasses({
8787 'button': ReactDOMButton,
8788 'form': ReactDOMForm,
8789 'img': ReactDOMImg,
8790 'input': ReactDOMInput,
8791 'option': ReactDOMOption,
8792 'select': ReactDOMSelect,
8793 'textarea': ReactDOMTextarea,
8794
8795 'html': createFullPageComponent('html'),
8796 'head': createFullPageComponent('head'),
8797 'body': createFullPageComponent('body')
8798 });
8799
8800 // This needs to happen after createFullPageComponent() otherwise the mixin
8801 // gets double injected.
8802 ReactInjection.CompositeComponent.injectMixin(ReactBrowserComponentMixin);
8803
8804 ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
8805 ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
8806
8807 ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
8808
8809 ReactInjection.Updates.injectReconcileTransaction(
8810 ReactComponentBrowserEnvironment.ReactReconcileTransaction
8811 );
8812 ReactInjection.Updates.injectBatchingStrategy(
8813 ReactDefaultBatchingStrategy
8814 );
8815
8816 ReactInjection.RootIndex.injectCreateReactRootIndex(
8817 ExecutionEnvironment.canUseDOM ?
8818 ClientReactRootIndex.createReactRootIndex :
8819 ServerReactRootIndex.createReactRootIndex
8820 );
8821
8822 ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
8823
8824 if ("production" !== "development") {
8825 var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
8826 if ((/[?&]react_perf\b/).test(url)) {
8827 var ReactDefaultPerf = _dereq_("./ReactDefaultPerf");
8828 ReactDefaultPerf.start();
8829 }
8830 }
8831}
8832
8833module.exports = {
8834 inject: inject
8835};
8836
8837},{"./BeforeInputEventPlugin":3,"./ChangeEventPlugin":7,"./ClientReactRootIndex":8,"./CompositionEventPlugin":9,"./DefaultEventPluginOrder":14,"./EnterLeaveEventPlugin":15,"./ExecutionEnvironment":22,"./HTMLDOMPropertyConfig":23,"./MobileSafariClickEventPlugin":26,"./ReactBrowserComponentMixin":29,"./ReactComponentBrowserEnvironment":33,"./ReactDOMButton":38,"./ReactDOMComponent":39,"./ReactDOMForm":40,"./ReactDOMImg":42,"./ReactDOMInput":43,"./ReactDOMOption":44,"./ReactDOMSelect":45,"./ReactDOMTextarea":47,"./ReactDefaultBatchingStrategy":48,"./ReactDefaultPerf":50,"./ReactEventListener":57,"./ReactInjection":58,"./ReactInstanceHandles":60,"./ReactMount":63,"./SVGDOMPropertyConfig":80,"./SelectEventPlugin":81,"./ServerReactRootIndex":82,"./SimpleEventPlugin":83,"./createFullPageComponent":103}],50:[function(_dereq_,module,exports){
8838/**
8839 * Copyright 2013-2014, Facebook, Inc.
8840 * All rights reserved.
8841 *
8842 * This source code is licensed under the BSD-style license found in the
8843 * LICENSE file in the root directory of this source tree. An additional grant
8844 * of patent rights can be found in the PATENTS file in the same directory.
8845 *
8846 * @providesModule ReactDefaultPerf
8847 * @typechecks static-only
8848 */
8849
8850"use strict";
8851
8852var DOMProperty = _dereq_("./DOMProperty");
8853var ReactDefaultPerfAnalysis = _dereq_("./ReactDefaultPerfAnalysis");
8854var ReactMount = _dereq_("./ReactMount");
8855var ReactPerf = _dereq_("./ReactPerf");
8856
8857var performanceNow = _dereq_("./performanceNow");
8858
8859function roundFloat(val) {
8860 return Math.floor(val * 100) / 100;
8861}
8862
8863function addValue(obj, key, val) {
8864 obj[key] = (obj[key] || 0) + val;
8865}
8866
8867var ReactDefaultPerf = {
8868 _allMeasurements: [], // last item in the list is the current one
8869 _mountStack: [0],
8870 _injected: false,
8871
8872 start: function() {
8873 if (!ReactDefaultPerf._injected) {
8874 ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
8875 }
8876
8877 ReactDefaultPerf._allMeasurements.length = 0;
8878 ReactPerf.enableMeasure = true;
8879 },
8880
8881 stop: function() {
8882 ReactPerf.enableMeasure = false;
8883 },
8884
8885 getLastMeasurements: function() {
8886 return ReactDefaultPerf._allMeasurements;
8887 },
8888
8889 printExclusive: function(measurements) {
8890 measurements = measurements || ReactDefaultPerf._allMeasurements;
8891 var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
8892 console.table(summary.map(function(item) {
8893 return {
8894 'Component class name': item.componentName,
8895 'Total inclusive time (ms)': roundFloat(item.inclusive),
8896 'Exclusive mount time (ms)': roundFloat(item.exclusive),
8897 'Exclusive render time (ms)': roundFloat(item.render),
8898 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
8899 'Render time per instance (ms)': roundFloat(item.render / item.count),
8900 'Instances': item.count
8901 };
8902 }));
8903 // TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
8904 // number.
8905 },
8906
8907 printInclusive: function(measurements) {
8908 measurements = measurements || ReactDefaultPerf._allMeasurements;
8909 var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
8910 console.table(summary.map(function(item) {
8911 return {
8912 'Owner > component': item.componentName,
8913 'Inclusive time (ms)': roundFloat(item.time),
8914 'Instances': item.count
8915 };
8916 }));
8917 console.log(
8918 'Total time:',
8919 ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
8920 );
8921 },
8922
8923 getMeasurementsSummaryMap: function(measurements) {
8924 var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
8925 measurements,
8926 true
8927 );
8928 return summary.map(function(item) {
8929 return {
8930 'Owner > component': item.componentName,
8931 'Wasted time (ms)': item.time,
8932 'Instances': item.count
8933 };
8934 });
8935 },
8936
8937 printWasted: function(measurements) {
8938 measurements = measurements || ReactDefaultPerf._allMeasurements;
8939 console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
8940 console.log(
8941 'Total time:',
8942 ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
8943 );
8944 },
8945
8946 printDOM: function(measurements) {
8947 measurements = measurements || ReactDefaultPerf._allMeasurements;
8948 var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
8949 console.table(summary.map(function(item) {
8950 var result = {};
8951 result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
8952 result['type'] = item.type;
8953 result['args'] = JSON.stringify(item.args);
8954 return result;
8955 }));
8956 console.log(
8957 'Total time:',
8958 ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
8959 );
8960 },
8961
8962 _recordWrite: function(id, fnName, totalTime, args) {
8963 // TODO: totalTime isn't that useful since it doesn't count paints/reflows
8964 var writes =
8965 ReactDefaultPerf
8966 ._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
8967 .writes;
8968 writes[id] = writes[id] || [];
8969 writes[id].push({
8970 type: fnName,
8971 time: totalTime,
8972 args: args
8973 });
8974 },
8975
8976 measure: function(moduleName, fnName, func) {
8977 return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
8978 var totalTime;
8979 var rv;
8980 var start;
8981
8982 if (fnName === '_renderNewRootComponent' ||
8983 fnName === 'flushBatchedUpdates') {
8984 // A "measurement" is a set of metrics recorded for each flush. We want
8985 // to group the metrics for a given flush together so we can look at the
8986 // components that rendered and the DOM operations that actually
8987 // happened to determine the amount of "wasted work" performed.
8988 ReactDefaultPerf._allMeasurements.push({
8989 exclusive: {},
8990 inclusive: {},
8991 render: {},
8992 counts: {},
8993 writes: {},
8994 displayNames: {},
8995 totalTime: 0
8996 });
8997 start = performanceNow();
8998 rv = func.apply(this, args);
8999 ReactDefaultPerf._allMeasurements[
9000 ReactDefaultPerf._allMeasurements.length - 1
9001 ].totalTime = performanceNow() - start;
9002 return rv;
9003 } else if (moduleName === 'ReactDOMIDOperations' ||
9004 moduleName === 'ReactComponentBrowserEnvironment') {
9005 start = performanceNow();
9006 rv = func.apply(this, args);
9007 totalTime = performanceNow() - start;
9008
9009 if (fnName === 'mountImageIntoNode') {
9010 var mountID = ReactMount.getID(args[1]);
9011 ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
9012 } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
9013 // special format
9014 args[0].forEach(function(update) {
9015 var writeArgs = {};
9016 if (update.fromIndex !== null) {
9017 writeArgs.fromIndex = update.fromIndex;
9018 }
9019 if (update.toIndex !== null) {
9020 writeArgs.toIndex = update.toIndex;
9021 }
9022 if (update.textContent !== null) {
9023 writeArgs.textContent = update.textContent;
9024 }
9025 if (update.markupIndex !== null) {
9026 writeArgs.markup = args[1][update.markupIndex];
9027 }
9028 ReactDefaultPerf._recordWrite(
9029 update.parentID,
9030 update.type,
9031 totalTime,
9032 writeArgs
9033 );
9034 });
9035 } else {
9036 // basic format
9037 ReactDefaultPerf._recordWrite(
9038 args[0],
9039 fnName,
9040 totalTime,
9041 Array.prototype.slice.call(args, 1)
9042 );
9043 }
9044 return rv;
9045 } else if (moduleName === 'ReactCompositeComponent' && (
9046 fnName === 'mountComponent' ||
9047 fnName === 'updateComponent' || // TODO: receiveComponent()?
9048 fnName === '_renderValidatedComponent')) {
9049
9050 var rootNodeID = fnName === 'mountComponent' ?
9051 args[0] :
9052 this._rootNodeID;
9053 var isRender = fnName === '_renderValidatedComponent';
9054 var isMount = fnName === 'mountComponent';
9055
9056 var mountStack = ReactDefaultPerf._mountStack;
9057 var entry = ReactDefaultPerf._allMeasurements[
9058 ReactDefaultPerf._allMeasurements.length - 1
9059 ];
9060
9061 if (isRender) {
9062 addValue(entry.counts, rootNodeID, 1);
9063 } else if (isMount) {
9064 mountStack.push(0);
9065 }
9066
9067 start = performanceNow();
9068 rv = func.apply(this, args);
9069 totalTime = performanceNow() - start;
9070
9071 if (isRender) {
9072 addValue(entry.render, rootNodeID, totalTime);
9073 } else if (isMount) {
9074 var subMountTime = mountStack.pop();
9075 mountStack[mountStack.length - 1] += totalTime;
9076 addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
9077 addValue(entry.inclusive, rootNodeID, totalTime);
9078 } else {
9079 addValue(entry.inclusive, rootNodeID, totalTime);
9080 }
9081
9082 entry.displayNames[rootNodeID] = {
9083 current: this.constructor.displayName,
9084 owner: this._owner ? this._owner.constructor.displayName : '<root>'
9085 };
9086
9087 return rv;
9088 } else {
9089 return func.apply(this, args);
9090 }
9091 };
9092 }
9093};
9094
9095module.exports = ReactDefaultPerf;
9096
9097},{"./DOMProperty":11,"./ReactDefaultPerfAnalysis":51,"./ReactMount":63,"./ReactPerf":68,"./performanceNow":139}],51:[function(_dereq_,module,exports){
9098/**
9099 * Copyright 2013-2014, Facebook, Inc.
9100 * All rights reserved.
9101 *
9102 * This source code is licensed under the BSD-style license found in the
9103 * LICENSE file in the root directory of this source tree. An additional grant
9104 * of patent rights can be found in the PATENTS file in the same directory.
9105 *
9106 * @providesModule ReactDefaultPerfAnalysis
9107 */
9108
9109var assign = _dereq_("./Object.assign");
9110
9111// Don't try to save users less than 1.2ms (a number I made up)
9112var DONT_CARE_THRESHOLD = 1.2;
9113var DOM_OPERATION_TYPES = {
9114 'mountImageIntoNode': 'set innerHTML',
9115 INSERT_MARKUP: 'set innerHTML',
9116 MOVE_EXISTING: 'move',
9117 REMOVE_NODE: 'remove',
9118 TEXT_CONTENT: 'set textContent',
9119 'updatePropertyByID': 'update attribute',
9120 'deletePropertyByID': 'delete attribute',
9121 'updateStylesByID': 'update styles',
9122 'updateInnerHTMLByID': 'set innerHTML',
9123 'dangerouslyReplaceNodeWithMarkupByID': 'replace'
9124};
9125
9126function getTotalTime(measurements) {
9127 // TODO: return number of DOM ops? could be misleading.
9128 // TODO: measure dropped frames after reconcile?
9129 // TODO: log total time of each reconcile and the top-level component
9130 // class that triggered it.
9131 var totalTime = 0;
9132 for (var i = 0; i < measurements.length; i++) {
9133 var measurement = measurements[i];
9134 totalTime += measurement.totalTime;
9135 }
9136 return totalTime;
9137}
9138
9139function getDOMSummary(measurements) {
9140 var items = [];
9141 for (var i = 0; i < measurements.length; i++) {
9142 var measurement = measurements[i];
9143 var id;
9144
9145 for (id in measurement.writes) {
9146 measurement.writes[id].forEach(function(write) {
9147 items.push({
9148 id: id,
9149 type: DOM_OPERATION_TYPES[write.type] || write.type,
9150 args: write.args
9151 });
9152 });
9153 }
9154 }
9155 return items;
9156}
9157
9158function getExclusiveSummary(measurements) {
9159 var candidates = {};
9160 var displayName;
9161
9162 for (var i = 0; i < measurements.length; i++) {
9163 var measurement = measurements[i];
9164 var allIDs = assign(
9165 {},
9166 measurement.exclusive,
9167 measurement.inclusive
9168 );
9169
9170 for (var id in allIDs) {
9171 displayName = measurement.displayNames[id].current;
9172
9173 candidates[displayName] = candidates[displayName] || {
9174 componentName: displayName,
9175 inclusive: 0,
9176 exclusive: 0,
9177 render: 0,
9178 count: 0
9179 };
9180 if (measurement.render[id]) {
9181 candidates[displayName].render += measurement.render[id];
9182 }
9183 if (measurement.exclusive[id]) {
9184 candidates[displayName].exclusive += measurement.exclusive[id];
9185 }
9186 if (measurement.inclusive[id]) {
9187 candidates[displayName].inclusive += measurement.inclusive[id];
9188 }
9189 if (measurement.counts[id]) {
9190 candidates[displayName].count += measurement.counts[id];
9191 }
9192 }
9193 }
9194
9195 // Now make a sorted array with the results.
9196 var arr = [];
9197 for (displayName in candidates) {
9198 if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
9199 arr.push(candidates[displayName]);
9200 }
9201 }
9202
9203 arr.sort(function(a, b) {
9204 return b.exclusive - a.exclusive;
9205 });
9206
9207 return arr;
9208}
9209
9210function getInclusiveSummary(measurements, onlyClean) {
9211 var candidates = {};
9212 var inclusiveKey;
9213
9214 for (var i = 0; i < measurements.length; i++) {
9215 var measurement = measurements[i];
9216 var allIDs = assign(
9217 {},
9218 measurement.exclusive,
9219 measurement.inclusive
9220 );
9221 var cleanComponents;
9222
9223 if (onlyClean) {
9224 cleanComponents = getUnchangedComponents(measurement);
9225 }
9226
9227 for (var id in allIDs) {
9228 if (onlyClean && !cleanComponents[id]) {
9229 continue;
9230 }
9231
9232 var displayName = measurement.displayNames[id];
9233
9234 // Inclusive time is not useful for many components without knowing where
9235 // they are instantiated. So we aggregate inclusive time with both the
9236 // owner and current displayName as the key.
9237 inclusiveKey = displayName.owner + ' > ' + displayName.current;
9238
9239 candidates[inclusiveKey] = candidates[inclusiveKey] || {
9240 componentName: inclusiveKey,
9241 time: 0,
9242 count: 0
9243 };
9244
9245 if (measurement.inclusive[id]) {
9246 candidates[inclusiveKey].time += measurement.inclusive[id];
9247 }
9248 if (measurement.counts[id]) {
9249 candidates[inclusiveKey].count += measurement.counts[id];
9250 }
9251 }
9252 }
9253
9254 // Now make a sorted array with the results.
9255 var arr = [];
9256 for (inclusiveKey in candidates) {
9257 if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
9258 arr.push(candidates[inclusiveKey]);
9259 }
9260 }
9261
9262 arr.sort(function(a, b) {
9263 return b.time - a.time;
9264 });
9265
9266 return arr;
9267}
9268
9269function getUnchangedComponents(measurement) {
9270 // For a given reconcile, look at which components did not actually
9271 // render anything to the DOM and return a mapping of their ID to
9272 // the amount of time it took to render the entire subtree.
9273 var cleanComponents = {};
9274 var dirtyLeafIDs = Object.keys(measurement.writes);
9275 var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
9276
9277 for (var id in allIDs) {
9278 var isDirty = false;
9279 // For each component that rendered, see if a component that triggered
9280 // a DOM op is in its subtree.
9281 for (var i = 0; i < dirtyLeafIDs.length; i++) {
9282 if (dirtyLeafIDs[i].indexOf(id) === 0) {
9283 isDirty = true;
9284 break;
9285 }
9286 }
9287 if (!isDirty && measurement.counts[id] > 0) {
9288 cleanComponents[id] = true;
9289 }
9290 }
9291 return cleanComponents;
9292}
9293
9294var ReactDefaultPerfAnalysis = {
9295 getExclusiveSummary: getExclusiveSummary,
9296 getInclusiveSummary: getInclusiveSummary,
9297 getDOMSummary: getDOMSummary,
9298 getTotalTime: getTotalTime
9299};
9300
9301module.exports = ReactDefaultPerfAnalysis;
9302
9303},{"./Object.assign":27}],52:[function(_dereq_,module,exports){
9304/**
9305 * Copyright 2014, Facebook, Inc.
9306 * All rights reserved.
9307 *
9308 * This source code is licensed under the BSD-style license found in the
9309 * LICENSE file in the root directory of this source tree. An additional grant
9310 * of patent rights can be found in the PATENTS file in the same directory.
9311 *
9312 * @providesModule ReactElement
9313 */
9314
9315"use strict";
9316
9317var ReactContext = _dereq_("./ReactContext");
9318var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
9319
9320var warning = _dereq_("./warning");
9321
9322var RESERVED_PROPS = {
9323 key: true,
9324 ref: true
9325};
9326
9327/**
9328 * Warn for mutations.
9329 *
9330 * @internal
9331 * @param {object} object
9332 * @param {string} key
9333 */
9334function defineWarningProperty(object, key) {
9335 Object.defineProperty(object, key, {
9336
9337 configurable: false,
9338 enumerable: true,
9339
9340 get: function() {
9341 if (!this._store) {
9342 return null;
9343 }
9344 return this._store[key];
9345 },
9346
9347 set: function(value) {
9348 ("production" !== "development" ? warning(
9349 false,
9350 'Don\'t set the ' + key + ' property of the component. ' +
9351 'Mutate the existing props object instead.'
9352 ) : null);
9353 this._store[key] = value;
9354 }
9355
9356 });
9357}
9358
9359/**
9360 * This is updated to true if the membrane is successfully created.
9361 */
9362var useMutationMembrane = false;
9363
9364/**
9365 * Warn for mutations.
9366 *
9367 * @internal
9368 * @param {object} element
9369 */
9370function defineMutationMembrane(prototype) {
9371 try {
9372 var pseudoFrozenProperties = {
9373 props: true
9374 };
9375 for (var key in pseudoFrozenProperties) {
9376 defineWarningProperty(prototype, key);
9377 }
9378 useMutationMembrane = true;
9379 } catch (x) {
9380 // IE will fail on defineProperty
9381 }
9382}
9383
9384/**
9385 * Base constructor for all React elements. This is only used to make this
9386 * work with a dynamic instanceof check. Nothing should live on this prototype.
9387 *
9388 * @param {*} type
9389 * @param {string|object} ref
9390 * @param {*} key
9391 * @param {*} props
9392 * @internal
9393 */
9394var ReactElement = function(type, key, ref, owner, context, props) {
9395 // Built-in properties that belong on the element
9396 this.type = type;
9397 this.key = key;
9398 this.ref = ref;
9399
9400 // Record the component responsible for creating this element.
9401 this._owner = owner;
9402
9403 // TODO: Deprecate withContext, and then the context becomes accessible
9404 // through the owner.
9405 this._context = context;
9406
9407 if ("production" !== "development") {
9408 // The validation flag and props are currently mutative. We put them on
9409 // an external backing store so that we can freeze the whole object.
9410 // This can be replaced with a WeakMap once they are implemented in
9411 // commonly used development environments.
9412 this._store = { validated: false, props: props };
9413
9414 // We're not allowed to set props directly on the object so we early
9415 // return and rely on the prototype membrane to forward to the backing
9416 // store.
9417 if (useMutationMembrane) {
9418 Object.freeze(this);
9419 return;
9420 }
9421 }
9422
9423 this.props = props;
9424};
9425
9426// We intentionally don't expose the function on the constructor property.
9427// ReactElement should be indistinguishable from a plain object.
9428ReactElement.prototype = {
9429 _isReactElement: true
9430};
9431
9432if ("production" !== "development") {
9433 defineMutationMembrane(ReactElement.prototype);
9434}
9435
9436ReactElement.createElement = function(type, config, children) {
9437 var propName;
9438
9439 // Reserved names are extracted
9440 var props = {};
9441
9442 var key = null;
9443 var ref = null;
9444
9445 if (config != null) {
9446 ref = config.ref === undefined ? null : config.ref;
9447 if ("production" !== "development") {
9448 ("production" !== "development" ? warning(
9449 config.key !== null,
9450 'createElement(...): Encountered component with a `key` of null. In ' +
9451 'a future version, this will be treated as equivalent to the string ' +
9452 '\'null\'; instead, provide an explicit key or use undefined.'
9453 ) : null);
9454 }
9455 // TODO: Change this back to `config.key === undefined`
9456 key = config.key == null ? null : '' + config.key;
9457 // Remaining properties are added to a new props object
9458 for (propName in config) {
9459 if (config.hasOwnProperty(propName) &&
9460 !RESERVED_PROPS.hasOwnProperty(propName)) {
9461 props[propName] = config[propName];
9462 }
9463 }
9464 }
9465
9466 // Children can be more than one argument, and those are transferred onto
9467 // the newly allocated props object.
9468 var childrenLength = arguments.length - 2;
9469 if (childrenLength === 1) {
9470 props.children = children;
9471 } else if (childrenLength > 1) {
9472 var childArray = Array(childrenLength);
9473 for (var i = 0; i < childrenLength; i++) {
9474 childArray[i] = arguments[i + 2];
9475 }
9476 props.children = childArray;
9477 }
9478
9479 // Resolve default props
9480 if (type && type.defaultProps) {
9481 var defaultProps = type.defaultProps;
9482 for (propName in defaultProps) {
9483 if (typeof props[propName] === 'undefined') {
9484 props[propName] = defaultProps[propName];
9485 }
9486 }
9487 }
9488
9489 return new ReactElement(
9490 type,
9491 key,
9492 ref,
9493 ReactCurrentOwner.current,
9494 ReactContext.current,
9495 props
9496 );
9497};
9498
9499ReactElement.createFactory = function(type) {
9500 var factory = ReactElement.createElement.bind(null, type);
9501 // Expose the type on the factory and the prototype so that it can be
9502 // easily accessed on elements. E.g. <Foo />.type === Foo.type.
9503 // This should not be named `constructor` since this may not be the function
9504 // that created the element, and it may not even be a constructor.
9505 factory.type = type;
9506 return factory;
9507};
9508
9509ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
9510 var newElement = new ReactElement(
9511 oldElement.type,
9512 oldElement.key,
9513 oldElement.ref,
9514 oldElement._owner,
9515 oldElement._context,
9516 newProps
9517 );
9518
9519 if ("production" !== "development") {
9520 // If the key on the original is valid, then the clone is valid
9521 newElement._store.validated = oldElement._store.validated;
9522 }
9523 return newElement;
9524};
9525
9526/**
9527 * @param {?object} object
9528 * @return {boolean} True if `object` is a valid component.
9529 * @final
9530 */
9531ReactElement.isValidElement = function(object) {
9532 // ReactTestUtils is often used outside of beforeEach where as React is
9533 // within it. This leads to two different instances of React on the same
9534 // page. To identify a element from a different React instance we use
9535 // a flag instead of an instanceof check.
9536 var isElement = !!(object && object._isReactElement);
9537 // if (isElement && !(object instanceof ReactElement)) {
9538 // This is an indicator that you're using multiple versions of React at the
9539 // same time. This will screw with ownership and stuff. Fix it, please.
9540 // TODO: We could possibly warn here.
9541 // }
9542 return isElement;
9543};
9544
9545module.exports = ReactElement;
9546
9547},{"./ReactContext":35,"./ReactCurrentOwner":36,"./warning":145}],53:[function(_dereq_,module,exports){
9548/**
9549 * Copyright 2014, Facebook, Inc.
9550 * All rights reserved.
9551 *
9552 * This source code is licensed under the BSD-style license found in the
9553 * LICENSE file in the root directory of this source tree. An additional grant
9554 * of patent rights can be found in the PATENTS file in the same directory.
9555 *
9556 * @providesModule ReactElementValidator
9557 */
9558
9559/**
9560 * ReactElementValidator provides a wrapper around a element factory
9561 * which validates the props passed to the element. This is intended to be
9562 * used only in DEV and could be replaced by a static type checker for languages
9563 * that support it.
9564 */
9565
9566"use strict";
9567
9568var ReactElement = _dereq_("./ReactElement");
9569var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
9570var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
9571
9572var monitorCodeUse = _dereq_("./monitorCodeUse");
9573var warning = _dereq_("./warning");
9574
9575/**
9576 * Warn if there's no key explicitly set on dynamic arrays of children or
9577 * object keys are not valid. This allows us to keep track of children between
9578 * updates.
9579 */
9580var ownerHasKeyUseWarning = {
9581 'react_key_warning': {},
9582 'react_numeric_key_warning': {}
9583};
9584var ownerHasMonitoredObjectMap = {};
9585
9586var loggedTypeFailures = {};
9587
9588var NUMERIC_PROPERTY_REGEX = /^\d+$/;
9589
9590/**
9591 * Gets the current owner's displayName for use in warnings.
9592 *
9593 * @internal
9594 * @return {?string} Display name or undefined
9595 */
9596function getCurrentOwnerDisplayName() {
9597 var current = ReactCurrentOwner.current;
9598 return current && current.constructor.displayName || undefined;
9599}
9600
9601/**
9602 * Warn if the component doesn't have an explicit key assigned to it.
9603 * This component is in an array. The array could grow and shrink or be
9604 * reordered. All children that haven't already been validated are required to
9605 * have a "key" property assigned to it.
9606 *
9607 * @internal
9608 * @param {ReactComponent} component Component that requires a key.
9609 * @param {*} parentType component's parent's type.
9610 */
9611function validateExplicitKey(component, parentType) {
9612 if (component._store.validated || component.key != null) {
9613 return;
9614 }
9615 component._store.validated = true;
9616
9617 warnAndMonitorForKeyUse(
9618 'react_key_warning',
9619 'Each child in an array should have a unique "key" prop.',
9620 component,
9621 parentType
9622 );
9623}
9624
9625/**
9626 * Warn if the key is being defined as an object property but has an incorrect
9627 * value.
9628 *
9629 * @internal
9630 * @param {string} name Property name of the key.
9631 * @param {ReactComponent} component Component that requires a key.
9632 * @param {*} parentType component's parent's type.
9633 */
9634function validatePropertyKey(name, component, parentType) {
9635 if (!NUMERIC_PROPERTY_REGEX.test(name)) {
9636 return;
9637 }
9638 warnAndMonitorForKeyUse(
9639 'react_numeric_key_warning',
9640 'Child objects should have non-numeric keys so ordering is preserved.',
9641 component,
9642 parentType
9643 );
9644}
9645
9646/**
9647 * Shared warning and monitoring code for the key warnings.
9648 *
9649 * @internal
9650 * @param {string} warningID The id used when logging.
9651 * @param {string} message The base warning that gets output.
9652 * @param {ReactComponent} component Component that requires a key.
9653 * @param {*} parentType component's parent's type.
9654 */
9655function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
9656 var ownerName = getCurrentOwnerDisplayName();
9657 var parentName = parentType.displayName;
9658
9659 var useName = ownerName || parentName;
9660 var memoizer = ownerHasKeyUseWarning[warningID];
9661 if (memoizer.hasOwnProperty(useName)) {
9662 return;
9663 }
9664 memoizer[useName] = true;
9665
9666 message += ownerName ?
9667 (" Check the render method of " + ownerName + ".") :
9668 (" Check the renderComponent call using <" + parentName + ">.");
9669
9670 // Usually the current owner is the offender, but if it accepts children as a
9671 // property, it may be the creator of the child that's responsible for
9672 // assigning it a key.
9673 var childOwnerName = null;
9674 if (component._owner && component._owner !== ReactCurrentOwner.current) {
9675 // Name of the component that originally created this child.
9676 childOwnerName = component._owner.constructor.displayName;
9677
9678 message += (" It was passed a child from " + childOwnerName + ".");
9679 }
9680
9681 message += ' See http://fb.me/react-warning-keys for more information.';
9682 monitorCodeUse(warningID, {
9683 component: useName,
9684 componentOwner: childOwnerName
9685 });
9686 console.warn(message);
9687}
9688
9689/**
9690 * Log that we're using an object map. We're considering deprecating this
9691 * feature and replace it with proper Map and ImmutableMap data structures.
9692 *
9693 * @internal
9694 */
9695function monitorUseOfObjectMap() {
9696 var currentName = getCurrentOwnerDisplayName() || '';
9697 if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) {
9698 return;
9699 }
9700 ownerHasMonitoredObjectMap[currentName] = true;
9701 monitorCodeUse('react_object_map_children');
9702}
9703
9704/**
9705 * Ensure that every component either is passed in a static location, in an
9706 * array with an explicit keys property defined, or in an object literal
9707 * with valid key property.
9708 *
9709 * @internal
9710 * @param {*} component Statically passed child of any type.
9711 * @param {*} parentType component's parent's type.
9712 * @return {boolean}
9713 */
9714function validateChildKeys(component, parentType) {
9715 if (Array.isArray(component)) {
9716 for (var i = 0; i < component.length; i++) {
9717 var child = component[i];
9718 if (ReactElement.isValidElement(child)) {
9719 validateExplicitKey(child, parentType);
9720 }
9721 }
9722 } else if (ReactElement.isValidElement(component)) {
9723 // This component was passed in a valid location.
9724 component._store.validated = true;
9725 } else if (component && typeof component === 'object') {
9726 monitorUseOfObjectMap();
9727 for (var name in component) {
9728 validatePropertyKey(name, component[name], parentType);
9729 }
9730 }
9731}
9732
9733/**
9734 * Assert that the props are valid
9735 *
9736 * @param {string} componentName Name of the component for error messages.
9737 * @param {object} propTypes Map of prop name to a ReactPropType
9738 * @param {object} props
9739 * @param {string} location e.g. "prop", "context", "child context"
9740 * @private
9741 */
9742function checkPropTypes(componentName, propTypes, props, location) {
9743 for (var propName in propTypes) {
9744 if (propTypes.hasOwnProperty(propName)) {
9745 var error;
9746 // Prop type validation may throw. In case they do, we don't want to
9747 // fail the render phase where it didn't fail before. So we log it.
9748 // After these have been cleaned up, we'll let them throw.
9749 try {
9750 error = propTypes[propName](props, propName, componentName, location);
9751 } catch (ex) {
9752 error = ex;
9753 }
9754 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
9755 // Only monitor this failure once because there tends to be a lot of the
9756 // same error.
9757 loggedTypeFailures[error.message] = true;
9758 // This will soon use the warning module
9759 monitorCodeUse(
9760 'react_failed_descriptor_type_check',
9761 { message: error.message }
9762 );
9763 }
9764 }
9765 }
9766}
9767
9768var ReactElementValidator = {
9769
9770 createElement: function(type, props, children) {
9771 // We warn in this case but don't throw. We expect the element creation to
9772 // succeed and there will likely be errors in render.
9773 ("production" !== "development" ? warning(
9774 type != null,
9775 'React.createElement: type should not be null or undefined. It should ' +
9776 'be a string (for DOM elements) or a ReactClass (for composite ' +
9777 'components).'
9778 ) : null);
9779
9780 var element = ReactElement.createElement.apply(this, arguments);
9781
9782 // The result can be nullish if a mock or a custom function is used.
9783 // TODO: Drop this when these are no longer allowed as the type argument.
9784 if (element == null) {
9785 return element;
9786 }
9787
9788 for (var i = 2; i < arguments.length; i++) {
9789 validateChildKeys(arguments[i], type);
9790 }
9791
9792 if (type) {
9793 var name = type.displayName;
9794 if (type.propTypes) {
9795 checkPropTypes(
9796 name,
9797 type.propTypes,
9798 element.props,
9799 ReactPropTypeLocations.prop
9800 );
9801 }
9802 if (type.contextTypes) {
9803 checkPropTypes(
9804 name,
9805 type.contextTypes,
9806 element._context,
9807 ReactPropTypeLocations.context
9808 );
9809 }
9810 }
9811 return element;
9812 },
9813
9814 createFactory: function(type) {
9815 var validatedFactory = ReactElementValidator.createElement.bind(
9816 null,
9817 type
9818 );
9819 validatedFactory.type = type;
9820 return validatedFactory;
9821 }
9822
9823};
9824
9825module.exports = ReactElementValidator;
9826
9827},{"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactPropTypeLocations":71,"./monitorCodeUse":136,"./warning":145}],54:[function(_dereq_,module,exports){
9828/**
9829 * Copyright 2014, Facebook, Inc.
9830 * All rights reserved.
9831 *
9832 * This source code is licensed under the BSD-style license found in the
9833 * LICENSE file in the root directory of this source tree. An additional grant
9834 * of patent rights can be found in the PATENTS file in the same directory.
9835 *
9836 * @providesModule ReactEmptyComponent
9837 */
9838
9839"use strict";
9840
9841var ReactElement = _dereq_("./ReactElement");
9842
9843var invariant = _dereq_("./invariant");
9844
9845var component;
9846// This registry keeps track of the React IDs of the components that rendered to
9847// `null` (in reality a placeholder such as `noscript`)
9848var nullComponentIdsRegistry = {};
9849
9850var ReactEmptyComponentInjection = {
9851 injectEmptyComponent: function(emptyComponent) {
9852 component = ReactElement.createFactory(emptyComponent);
9853 }
9854};
9855
9856/**
9857 * @return {ReactComponent} component The injected empty component.
9858 */
9859function getEmptyComponent() {
9860 ("production" !== "development" ? invariant(
9861 component,
9862 'Trying to return null from a render, but no null placeholder component ' +
9863 'was injected.'
9864 ) : invariant(component));
9865 return component();
9866}
9867
9868/**
9869 * Mark the component as having rendered to null.
9870 * @param {string} id Component's `_rootNodeID`.
9871 */
9872function registerNullComponentID(id) {
9873 nullComponentIdsRegistry[id] = true;
9874}
9875
9876/**
9877 * Unmark the component as having rendered to null: it renders to something now.
9878 * @param {string} id Component's `_rootNodeID`.
9879 */
9880function deregisterNullComponentID(id) {
9881 delete nullComponentIdsRegistry[id];
9882}
9883
9884/**
9885 * @param {string} id Component's `_rootNodeID`.
9886 * @return {boolean} True if the component is rendered to null.
9887 */
9888function isNullComponentID(id) {
9889 return nullComponentIdsRegistry[id];
9890}
9891
9892var ReactEmptyComponent = {
9893 deregisterNullComponentID: deregisterNullComponentID,
9894 getEmptyComponent: getEmptyComponent,
9895 injection: ReactEmptyComponentInjection,
9896 isNullComponentID: isNullComponentID,
9897 registerNullComponentID: registerNullComponentID
9898};
9899
9900module.exports = ReactEmptyComponent;
9901
9902},{"./ReactElement":52,"./invariant":126}],55:[function(_dereq_,module,exports){
9903/**
9904 * Copyright 2013-2014, Facebook, Inc.
9905 * All rights reserved.
9906 *
9907 * This source code is licensed under the BSD-style license found in the
9908 * LICENSE file in the root directory of this source tree. An additional grant
9909 * of patent rights can be found in the PATENTS file in the same directory.
9910 *
9911 * @providesModule ReactErrorUtils
9912 * @typechecks
9913 */
9914
9915"use strict";
9916
9917var ReactErrorUtils = {
9918 /**
9919 * Creates a guarded version of a function. This is supposed to make debugging
9920 * of event handlers easier. To aid debugging with the browser's debugger,
9921 * this currently simply returns the original function.
9922 *
9923 * @param {function} func Function to be executed
9924 * @param {string} name The name of the guard
9925 * @return {function}
9926 */
9927 guard: function(func, name) {
9928 return func;
9929 }
9930};
9931
9932module.exports = ReactErrorUtils;
9933
9934},{}],56:[function(_dereq_,module,exports){
9935/**
9936 * Copyright 2013-2014, Facebook, Inc.
9937 * All rights reserved.
9938 *
9939 * This source code is licensed under the BSD-style license found in the
9940 * LICENSE file in the root directory of this source tree. An additional grant
9941 * of patent rights can be found in the PATENTS file in the same directory.
9942 *
9943 * @providesModule ReactEventEmitterMixin
9944 */
9945
9946"use strict";
9947
9948var EventPluginHub = _dereq_("./EventPluginHub");
9949
9950function runEventQueueInBatch(events) {
9951 EventPluginHub.enqueueEvents(events);
9952 EventPluginHub.processEventQueue();
9953}
9954
9955var ReactEventEmitterMixin = {
9956
9957 /**
9958 * Streams a fired top-level event to `EventPluginHub` where plugins have the
9959 * opportunity to create `ReactEvent`s to be dispatched.
9960 *
9961 * @param {string} topLevelType Record from `EventConstants`.
9962 * @param {object} topLevelTarget The listening component root node.
9963 * @param {string} topLevelTargetID ID of `topLevelTarget`.
9964 * @param {object} nativeEvent Native environment event.
9965 */
9966 handleTopLevel: function(
9967 topLevelType,
9968 topLevelTarget,
9969 topLevelTargetID,
9970 nativeEvent) {
9971 var events = EventPluginHub.extractEvents(
9972 topLevelType,
9973 topLevelTarget,
9974 topLevelTargetID,
9975 nativeEvent
9976 );
9977
9978 runEventQueueInBatch(events);
9979 }
9980};
9981
9982module.exports = ReactEventEmitterMixin;
9983
9984},{"./EventPluginHub":18}],57:[function(_dereq_,module,exports){
9985/**
9986 * Copyright 2013-2014, Facebook, Inc.
9987 * All rights reserved.
9988 *
9989 * This source code is licensed under the BSD-style license found in the
9990 * LICENSE file in the root directory of this source tree. An additional grant
9991 * of patent rights can be found in the PATENTS file in the same directory.
9992 *
9993 * @providesModule ReactEventListener
9994 * @typechecks static-only
9995 */
9996
9997"use strict";
9998
9999var EventListener = _dereq_("./EventListener");
10000var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
10001var PooledClass = _dereq_("./PooledClass");
10002var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
10003var ReactMount = _dereq_("./ReactMount");
10004var ReactUpdates = _dereq_("./ReactUpdates");
10005
10006var assign = _dereq_("./Object.assign");
10007var getEventTarget = _dereq_("./getEventTarget");
10008var getUnboundedScrollPosition = _dereq_("./getUnboundedScrollPosition");
10009
10010/**
10011 * Finds the parent React component of `node`.
10012 *
10013 * @param {*} node
10014 * @return {?DOMEventTarget} Parent container, or `null` if the specified node
10015 * is not nested.
10016 */
10017function findParent(node) {
10018 // TODO: It may be a good idea to cache this to prevent unnecessary DOM
10019 // traversal, but caching is difficult to do correctly without using a
10020 // mutation observer to listen for all DOM changes.
10021 var nodeID = ReactMount.getID(node);
10022 var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
10023 var container = ReactMount.findReactContainerForID(rootID);
10024 var parent = ReactMount.getFirstReactDOM(container);
10025 return parent;
10026}
10027
10028// Used to store ancestor hierarchy in top level callback
10029function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
10030 this.topLevelType = topLevelType;
10031 this.nativeEvent = nativeEvent;
10032 this.ancestors = [];
10033}
10034assign(TopLevelCallbackBookKeeping.prototype, {
10035 destructor: function() {
10036 this.topLevelType = null;
10037 this.nativeEvent = null;
10038 this.ancestors.length = 0;
10039 }
10040});
10041PooledClass.addPoolingTo(
10042 TopLevelCallbackBookKeeping,
10043 PooledClass.twoArgumentPooler
10044);
10045
10046function handleTopLevelImpl(bookKeeping) {
10047 var topLevelTarget = ReactMount.getFirstReactDOM(
10048 getEventTarget(bookKeeping.nativeEvent)
10049 ) || window;
10050
10051 // Loop through the hierarchy, in case there's any nested components.
10052 // It's important that we build the array of ancestors before calling any
10053 // event handlers, because event handlers can modify the DOM, leading to
10054 // inconsistencies with ReactMount's node cache. See #1105.
10055 var ancestor = topLevelTarget;
10056 while (ancestor) {
10057 bookKeeping.ancestors.push(ancestor);
10058 ancestor = findParent(ancestor);
10059 }
10060
10061 for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
10062 topLevelTarget = bookKeeping.ancestors[i];
10063 var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
10064 ReactEventListener._handleTopLevel(
10065 bookKeeping.topLevelType,
10066 topLevelTarget,
10067 topLevelTargetID,
10068 bookKeeping.nativeEvent
10069 );
10070 }
10071}
10072
10073function scrollValueMonitor(cb) {
10074 var scrollPosition = getUnboundedScrollPosition(window);
10075 cb(scrollPosition);
10076}
10077
10078var ReactEventListener = {
10079 _enabled: true,
10080 _handleTopLevel: null,
10081
10082 WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
10083
10084 setHandleTopLevel: function(handleTopLevel) {
10085 ReactEventListener._handleTopLevel = handleTopLevel;
10086 },
10087
10088 setEnabled: function(enabled) {
10089 ReactEventListener._enabled = !!enabled;
10090 },
10091
10092 isEnabled: function() {
10093 return ReactEventListener._enabled;
10094 },
10095
10096
10097 /**
10098 * Traps top-level events by using event bubbling.
10099 *
10100 * @param {string} topLevelType Record from `EventConstants`.
10101 * @param {string} handlerBaseName Event name (e.g. "click").
10102 * @param {object} handle Element on which to attach listener.
10103 * @return {object} An object with a remove function which will forcefully
10104 * remove the listener.
10105 * @internal
10106 */
10107 trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
10108 var element = handle;
10109 if (!element) {
10110 return;
10111 }
10112 return EventListener.listen(
10113 element,
10114 handlerBaseName,
10115 ReactEventListener.dispatchEvent.bind(null, topLevelType)
10116 );
10117 },
10118
10119 /**
10120 * Traps a top-level event by using event capturing.
10121 *
10122 * @param {string} topLevelType Record from `EventConstants`.
10123 * @param {string} handlerBaseName Event name (e.g. "click").
10124 * @param {object} handle Element on which to attach listener.
10125 * @return {object} An object with a remove function which will forcefully
10126 * remove the listener.
10127 * @internal
10128 */
10129 trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
10130 var element = handle;
10131 if (!element) {
10132 return;
10133 }
10134 return EventListener.capture(
10135 element,
10136 handlerBaseName,
10137 ReactEventListener.dispatchEvent.bind(null, topLevelType)
10138 );
10139 },
10140
10141 monitorScrollValue: function(refresh) {
10142 var callback = scrollValueMonitor.bind(null, refresh);
10143 EventListener.listen(window, 'scroll', callback);
10144 EventListener.listen(window, 'resize', callback);
10145 },
10146
10147 dispatchEvent: function(topLevelType, nativeEvent) {
10148 if (!ReactEventListener._enabled) {
10149 return;
10150 }
10151
10152 var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
10153 topLevelType,
10154 nativeEvent
10155 );
10156 try {
10157 // Event queue being processed in the same cycle allows
10158 // `preventDefault`.
10159 ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
10160 } finally {
10161 TopLevelCallbackBookKeeping.release(bookKeeping);
10162 }
10163 }
10164};
10165
10166module.exports = ReactEventListener;
10167
10168},{"./EventListener":17,"./ExecutionEnvironment":22,"./Object.assign":27,"./PooledClass":28,"./ReactInstanceHandles":60,"./ReactMount":63,"./ReactUpdates":79,"./getEventTarget":117,"./getUnboundedScrollPosition":122}],58:[function(_dereq_,module,exports){
10169/**
10170 * Copyright 2013-2014, Facebook, Inc.
10171 * All rights reserved.
10172 *
10173 * This source code is licensed under the BSD-style license found in the
10174 * LICENSE file in the root directory of this source tree. An additional grant
10175 * of patent rights can be found in the PATENTS file in the same directory.
10176 *
10177 * @providesModule ReactInjection
10178 */
10179
10180"use strict";
10181
10182var DOMProperty = _dereq_("./DOMProperty");
10183var EventPluginHub = _dereq_("./EventPluginHub");
10184var ReactComponent = _dereq_("./ReactComponent");
10185var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
10186var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
10187var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
10188var ReactNativeComponent = _dereq_("./ReactNativeComponent");
10189var ReactPerf = _dereq_("./ReactPerf");
10190var ReactRootIndex = _dereq_("./ReactRootIndex");
10191var ReactUpdates = _dereq_("./ReactUpdates");
10192
10193var ReactInjection = {
10194 Component: ReactComponent.injection,
10195 CompositeComponent: ReactCompositeComponent.injection,
10196 DOMProperty: DOMProperty.injection,
10197 EmptyComponent: ReactEmptyComponent.injection,
10198 EventPluginHub: EventPluginHub.injection,
10199 EventEmitter: ReactBrowserEventEmitter.injection,
10200 NativeComponent: ReactNativeComponent.injection,
10201 Perf: ReactPerf.injection,
10202 RootIndex: ReactRootIndex.injection,
10203 Updates: ReactUpdates.injection
10204};
10205
10206module.exports = ReactInjection;
10207
10208},{"./DOMProperty":11,"./EventPluginHub":18,"./ReactBrowserEventEmitter":30,"./ReactComponent":32,"./ReactCompositeComponent":34,"./ReactEmptyComponent":54,"./ReactNativeComponent":66,"./ReactPerf":68,"./ReactRootIndex":75,"./ReactUpdates":79}],59:[function(_dereq_,module,exports){
10209/**
10210 * Copyright 2013-2014, Facebook, Inc.
10211 * All rights reserved.
10212 *
10213 * This source code is licensed under the BSD-style license found in the
10214 * LICENSE file in the root directory of this source tree. An additional grant
10215 * of patent rights can be found in the PATENTS file in the same directory.
10216 *
10217 * @providesModule ReactInputSelection
10218 */
10219
10220"use strict";
10221
10222var ReactDOMSelection = _dereq_("./ReactDOMSelection");
10223
10224var containsNode = _dereq_("./containsNode");
10225var focusNode = _dereq_("./focusNode");
10226var getActiveElement = _dereq_("./getActiveElement");
10227
10228function isInDocument(node) {
10229 return containsNode(document.documentElement, node);
10230}
10231
10232/**
10233 * @ReactInputSelection: React input selection module. Based on Selection.js,
10234 * but modified to be suitable for react and has a couple of bug fixes (doesn't
10235 * assume buttons have range selections allowed).
10236 * Input selection module for React.
10237 */
10238var ReactInputSelection = {
10239
10240 hasSelectionCapabilities: function(elem) {
10241 return elem && (
10242 (elem.nodeName === 'INPUT' && elem.type === 'text') ||
10243 elem.nodeName === 'TEXTAREA' ||
10244 elem.contentEditable === 'true'
10245 );
10246 },
10247
10248 getSelectionInformation: function() {
10249 var focusedElem = getActiveElement();
10250 return {
10251 focusedElem: focusedElem,
10252 selectionRange:
10253 ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
10254 ReactInputSelection.getSelection(focusedElem) :
10255 null
10256 };
10257 },
10258
10259 /**
10260 * @restoreSelection: If any selection information was potentially lost,
10261 * restore it. This is useful when performing operations that could remove dom
10262 * nodes and place them back in, resulting in focus being lost.
10263 */
10264 restoreSelection: function(priorSelectionInformation) {
10265 var curFocusedElem = getActiveElement();
10266 var priorFocusedElem = priorSelectionInformation.focusedElem;
10267 var priorSelectionRange = priorSelectionInformation.selectionRange;
10268 if (curFocusedElem !== priorFocusedElem &&
10269 isInDocument(priorFocusedElem)) {
10270 if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
10271 ReactInputSelection.setSelection(
10272 priorFocusedElem,
10273 priorSelectionRange
10274 );
10275 }
10276 focusNode(priorFocusedElem);
10277 }
10278 },
10279
10280 /**
10281 * @getSelection: Gets the selection bounds of a focused textarea, input or
10282 * contentEditable node.
10283 * -@input: Look up selection bounds of this input
10284 * -@return {start: selectionStart, end: selectionEnd}
10285 */
10286 getSelection: function(input) {
10287 var selection;
10288
10289 if ('selectionStart' in input) {
10290 // Modern browser with input or textarea.
10291 selection = {
10292 start: input.selectionStart,
10293 end: input.selectionEnd
10294 };
10295 } else if (document.selection && input.nodeName === 'INPUT') {
10296 // IE8 input.
10297 var range = document.selection.createRange();
10298 // There can only be one selection per document in IE, so it must
10299 // be in our element.
10300 if (range.parentElement() === input) {
10301 selection = {
10302 start: -range.moveStart('character', -input.value.length),
10303 end: -range.moveEnd('character', -input.value.length)
10304 };
10305 }
10306 } else {
10307 // Content editable or old IE textarea.
10308 selection = ReactDOMSelection.getOffsets(input);
10309 }
10310
10311 return selection || {start: 0, end: 0};
10312 },
10313
10314 /**
10315 * @setSelection: Sets the selection bounds of a textarea or input and focuses
10316 * the input.
10317 * -@input Set selection bounds of this input or textarea
10318 * -@offsets Object of same form that is returned from get*
10319 */
10320 setSelection: function(input, offsets) {
10321 var start = offsets.start;
10322 var end = offsets.end;
10323 if (typeof end === 'undefined') {
10324 end = start;
10325 }
10326
10327 if ('selectionStart' in input) {
10328 input.selectionStart = start;
10329 input.selectionEnd = Math.min(end, input.value.length);
10330 } else if (document.selection && input.nodeName === 'INPUT') {
10331 var range = input.createTextRange();
10332 range.collapse(true);
10333 range.moveStart('character', start);
10334 range.moveEnd('character', end - start);
10335 range.select();
10336 } else {
10337 ReactDOMSelection.setOffsets(input, offsets);
10338 }
10339 }
10340};
10341
10342module.exports = ReactInputSelection;
10343
10344},{"./ReactDOMSelection":46,"./containsNode":101,"./focusNode":111,"./getActiveElement":113}],60:[function(_dereq_,module,exports){
10345/**
10346 * Copyright 2013-2014, Facebook, Inc.
10347 * All rights reserved.
10348 *
10349 * This source code is licensed under the BSD-style license found in the
10350 * LICENSE file in the root directory of this source tree. An additional grant
10351 * of patent rights can be found in the PATENTS file in the same directory.
10352 *
10353 * @providesModule ReactInstanceHandles
10354 * @typechecks static-only
10355 */
10356
10357"use strict";
10358
10359var ReactRootIndex = _dereq_("./ReactRootIndex");
10360
10361var invariant = _dereq_("./invariant");
10362
10363var SEPARATOR = '.';
10364var SEPARATOR_LENGTH = SEPARATOR.length;
10365
10366/**
10367 * Maximum depth of traversals before we consider the possibility of a bad ID.
10368 */
10369var MAX_TREE_DEPTH = 100;
10370
10371/**
10372 * Creates a DOM ID prefix to use when mounting React components.
10373 *
10374 * @param {number} index A unique integer
10375 * @return {string} React root ID.
10376 * @internal
10377 */
10378function getReactRootIDString(index) {
10379 return SEPARATOR + index.toString(36);
10380}
10381
10382/**
10383 * Checks if a character in the supplied ID is a separator or the end.
10384 *
10385 * @param {string} id A React DOM ID.
10386 * @param {number} index Index of the character to check.
10387 * @return {boolean} True if the character is a separator or end of the ID.
10388 * @private
10389 */
10390function isBoundary(id, index) {
10391 return id.charAt(index) === SEPARATOR || index === id.length;
10392}
10393
10394/**
10395 * Checks if the supplied string is a valid React DOM ID.
10396 *
10397 * @param {string} id A React DOM ID, maybe.
10398 * @return {boolean} True if the string is a valid React DOM ID.
10399 * @private
10400 */
10401function isValidID(id) {
10402 return id === '' || (
10403 id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
10404 );
10405}
10406
10407/**
10408 * Checks if the first ID is an ancestor of or equal to the second ID.
10409 *
10410 * @param {string} ancestorID
10411 * @param {string} descendantID
10412 * @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
10413 * @internal
10414 */
10415function isAncestorIDOf(ancestorID, descendantID) {
10416 return (
10417 descendantID.indexOf(ancestorID) === 0 &&
10418 isBoundary(descendantID, ancestorID.length)
10419 );
10420}
10421
10422/**
10423 * Gets the parent ID of the supplied React DOM ID, `id`.
10424 *
10425 * @param {string} id ID of a component.
10426 * @return {string} ID of the parent, or an empty string.
10427 * @private
10428 */
10429function getParentID(id) {
10430 return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
10431}
10432
10433/**
10434 * Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
10435 * supplied `destinationID`. If they are equal, the ID is returned.
10436 *
10437 * @param {string} ancestorID ID of an ancestor node of `destinationID`.
10438 * @param {string} destinationID ID of the destination node.
10439 * @return {string} Next ID on the path from `ancestorID` to `destinationID`.
10440 * @private
10441 */
10442function getNextDescendantID(ancestorID, destinationID) {
10443 ("production" !== "development" ? invariant(
10444 isValidID(ancestorID) && isValidID(destinationID),
10445 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
10446 ancestorID,
10447 destinationID
10448 ) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
10449 ("production" !== "development" ? invariant(
10450 isAncestorIDOf(ancestorID, destinationID),
10451 'getNextDescendantID(...): React has made an invalid assumption about ' +
10452 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
10453 ancestorID,
10454 destinationID
10455 ) : invariant(isAncestorIDOf(ancestorID, destinationID)));
10456 if (ancestorID === destinationID) {
10457 return ancestorID;
10458 }
10459 // Skip over the ancestor and the immediate separator. Traverse until we hit
10460 // another separator or we reach the end of `destinationID`.
10461 var start = ancestorID.length + SEPARATOR_LENGTH;
10462 for (var i = start; i < destinationID.length; i++) {
10463 if (isBoundary(destinationID, i)) {
10464 break;
10465 }
10466 }
10467 return destinationID.substr(0, i);
10468}
10469
10470/**
10471 * Gets the nearest common ancestor ID of two IDs.
10472 *
10473 * Using this ID scheme, the nearest common ancestor ID is the longest common
10474 * prefix of the two IDs that immediately preceded a "marker" in both strings.
10475 *
10476 * @param {string} oneID
10477 * @param {string} twoID
10478 * @return {string} Nearest common ancestor ID, or the empty string if none.
10479 * @private
10480 */
10481function getFirstCommonAncestorID(oneID, twoID) {
10482 var minLength = Math.min(oneID.length, twoID.length);
10483 if (minLength === 0) {
10484 return '';
10485 }
10486 var lastCommonMarkerIndex = 0;
10487 // Use `<=` to traverse until the "EOL" of the shorter string.
10488 for (var i = 0; i <= minLength; i++) {
10489 if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
10490 lastCommonMarkerIndex = i;
10491 } else if (oneID.charAt(i) !== twoID.charAt(i)) {
10492 break;
10493 }
10494 }
10495 var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
10496 ("production" !== "development" ? invariant(
10497 isValidID(longestCommonID),
10498 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
10499 oneID,
10500 twoID,
10501 longestCommonID
10502 ) : invariant(isValidID(longestCommonID)));
10503 return longestCommonID;
10504}
10505
10506/**
10507 * Traverses the parent path between two IDs (either up or down). The IDs must
10508 * not be the same, and there must exist a parent path between them. If the
10509 * callback returns `false`, traversal is stopped.
10510 *
10511 * @param {?string} start ID at which to start traversal.
10512 * @param {?string} stop ID at which to end traversal.
10513 * @param {function} cb Callback to invoke each ID with.
10514 * @param {?boolean} skipFirst Whether or not to skip the first node.
10515 * @param {?boolean} skipLast Whether or not to skip the last node.
10516 * @private
10517 */
10518function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
10519 start = start || '';
10520 stop = stop || '';
10521 ("production" !== "development" ? invariant(
10522 start !== stop,
10523 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
10524 start
10525 ) : invariant(start !== stop));
10526 var traverseUp = isAncestorIDOf(stop, start);
10527 ("production" !== "development" ? invariant(
10528 traverseUp || isAncestorIDOf(start, stop),
10529 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
10530 'not have a parent path.',
10531 start,
10532 stop
10533 ) : invariant(traverseUp || isAncestorIDOf(start, stop)));
10534 // Traverse from `start` to `stop` one depth at a time.
10535 var depth = 0;
10536 var traverse = traverseUp ? getParentID : getNextDescendantID;
10537 for (var id = start; /* until break */; id = traverse(id, stop)) {
10538 var ret;
10539 if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
10540 ret = cb(id, traverseUp, arg);
10541 }
10542 if (ret === false || id === stop) {
10543 // Only break //after// visiting `stop`.
10544 break;
10545 }
10546 ("production" !== "development" ? invariant(
10547 depth++ < MAX_TREE_DEPTH,
10548 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
10549 'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
10550 start, stop
10551 ) : invariant(depth++ < MAX_TREE_DEPTH));
10552 }
10553}
10554
10555/**
10556 * Manages the IDs assigned to DOM representations of React components. This
10557 * uses a specific scheme in order to traverse the DOM efficiently (e.g. in
10558 * order to simulate events).
10559 *
10560 * @internal
10561 */
10562var ReactInstanceHandles = {
10563
10564 /**
10565 * Constructs a React root ID
10566 * @return {string} A React root ID.
10567 */
10568 createReactRootID: function() {
10569 return getReactRootIDString(ReactRootIndex.createReactRootIndex());
10570 },
10571
10572 /**
10573 * Constructs a React ID by joining a root ID with a name.
10574 *
10575 * @param {string} rootID Root ID of a parent component.
10576 * @param {string} name A component's name (as flattened children).
10577 * @return {string} A React ID.
10578 * @internal
10579 */
10580 createReactID: function(rootID, name) {
10581 return rootID + name;
10582 },
10583
10584 /**
10585 * Gets the DOM ID of the React component that is the root of the tree that
10586 * contains the React component with the supplied DOM ID.
10587 *
10588 * @param {string} id DOM ID of a React component.
10589 * @return {?string} DOM ID of the React component that is the root.
10590 * @internal
10591 */
10592 getReactRootIDFromNodeID: function(id) {
10593 if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
10594 var index = id.indexOf(SEPARATOR, 1);
10595 return index > -1 ? id.substr(0, index) : id;
10596 }
10597 return null;
10598 },
10599
10600 /**
10601 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
10602 * should would receive a `mouseEnter` or `mouseLeave` event.
10603 *
10604 * NOTE: Does not invoke the callback on the nearest common ancestor because
10605 * nothing "entered" or "left" that element.
10606 *
10607 * @param {string} leaveID ID being left.
10608 * @param {string} enterID ID being entered.
10609 * @param {function} cb Callback to invoke on each entered/left ID.
10610 * @param {*} upArg Argument to invoke the callback with on left IDs.
10611 * @param {*} downArg Argument to invoke the callback with on entered IDs.
10612 * @internal
10613 */
10614 traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
10615 var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
10616 if (ancestorID !== leaveID) {
10617 traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
10618 }
10619 if (ancestorID !== enterID) {
10620 traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
10621 }
10622 },
10623
10624 /**
10625 * Simulates the traversal of a two-phase, capture/bubble event dispatch.
10626 *
10627 * NOTE: This traversal happens on IDs without touching the DOM.
10628 *
10629 * @param {string} targetID ID of the target node.
10630 * @param {function} cb Callback to invoke.
10631 * @param {*} arg Argument to invoke the callback with.
10632 * @internal
10633 */
10634 traverseTwoPhase: function(targetID, cb, arg) {
10635 if (targetID) {
10636 traverseParentPath('', targetID, cb, arg, true, false);
10637 traverseParentPath(targetID, '', cb, arg, false, true);
10638 }
10639 },
10640
10641 /**
10642 * Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
10643 * example, passing `.0.$row-0.1` would result in `cb` getting called
10644 * with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
10645 *
10646 * NOTE: This traversal happens on IDs without touching the DOM.
10647 *
10648 * @param {string} targetID ID of the target node.
10649 * @param {function} cb Callback to invoke.
10650 * @param {*} arg Argument to invoke the callback with.
10651 * @internal
10652 */
10653 traverseAncestors: function(targetID, cb, arg) {
10654 traverseParentPath('', targetID, cb, arg, true, false);
10655 },
10656
10657 /**
10658 * Exposed for unit testing.
10659 * @private
10660 */
10661 _getFirstCommonAncestorID: getFirstCommonAncestorID,
10662
10663 /**
10664 * Exposed for unit testing.
10665 * @private
10666 */
10667 _getNextDescendantID: getNextDescendantID,
10668
10669 isAncestorIDOf: isAncestorIDOf,
10670
10671 SEPARATOR: SEPARATOR
10672
10673};
10674
10675module.exports = ReactInstanceHandles;
10676
10677},{"./ReactRootIndex":75,"./invariant":126}],61:[function(_dereq_,module,exports){
10678/**
10679 * Copyright 2014, Facebook, Inc.
10680 * All rights reserved.
10681 *
10682 * This source code is licensed under the BSD-style license found in the
10683 * LICENSE file in the root directory of this source tree. An additional grant
10684 * of patent rights can be found in the PATENTS file in the same directory.
10685 *
10686 * @providesModule ReactLegacyElement
10687 */
10688
10689"use strict";
10690
10691var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
10692
10693var invariant = _dereq_("./invariant");
10694var monitorCodeUse = _dereq_("./monitorCodeUse");
10695var warning = _dereq_("./warning");
10696
10697var legacyFactoryLogs = {};
10698function warnForLegacyFactoryCall() {
10699 if (!ReactLegacyElementFactory._isLegacyCallWarningEnabled) {
10700 return;
10701 }
10702 var owner = ReactCurrentOwner.current;
10703 var name = owner && owner.constructor ? owner.constructor.displayName : '';
10704 if (!name) {
10705 name = 'Something';
10706 }
10707 if (legacyFactoryLogs.hasOwnProperty(name)) {
10708 return;
10709 }
10710 legacyFactoryLogs[name] = true;
10711 ("production" !== "development" ? warning(
10712 false,
10713 name + ' is calling a React component directly. ' +
10714 'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
10715 ) : null);
10716 monitorCodeUse('react_legacy_factory_call', { version: 3, name: name });
10717}
10718
10719function warnForPlainFunctionType(type) {
10720 var isReactClass =
10721 type.prototype &&
10722 typeof type.prototype.mountComponent === 'function' &&
10723 typeof type.prototype.receiveComponent === 'function';
10724 if (isReactClass) {
10725 ("production" !== "development" ? warning(
10726 false,
10727 'Did not expect to get a React class here. Use `Component` instead ' +
10728 'of `Component.type` or `this.constructor`.'
10729 ) : null);
10730 } else {
10731 if (!type._reactWarnedForThisType) {
10732 try {
10733 type._reactWarnedForThisType = true;
10734 } catch (x) {
10735 // just incase this is a frozen object or some special object
10736 }
10737 monitorCodeUse(
10738 'react_non_component_in_jsx',
10739 { version: 3, name: type.name }
10740 );
10741 }
10742 ("production" !== "development" ? warning(
10743 false,
10744 'This JSX uses a plain function. Only React components are ' +
10745 'valid in React\'s JSX transform.'
10746 ) : null);
10747 }
10748}
10749
10750function warnForNonLegacyFactory(type) {
10751 ("production" !== "development" ? warning(
10752 false,
10753 'Do not pass React.DOM.' + type.type + ' to JSX or createFactory. ' +
10754 'Use the string "' + type.type + '" instead.'
10755 ) : null);
10756}
10757
10758/**
10759 * Transfer static properties from the source to the target. Functions are
10760 * rebound to have this reflect the original source.
10761 */
10762function proxyStaticMethods(target, source) {
10763 if (typeof source !== 'function') {
10764 return;
10765 }
10766 for (var key in source) {
10767 if (source.hasOwnProperty(key)) {
10768 var value = source[key];
10769 if (typeof value === 'function') {
10770 var bound = value.bind(source);
10771 // Copy any properties defined on the function, such as `isRequired` on
10772 // a PropTypes validator.
10773 for (var k in value) {
10774 if (value.hasOwnProperty(k)) {
10775 bound[k] = value[k];
10776 }
10777 }
10778 target[key] = bound;
10779 } else {
10780 target[key] = value;
10781 }
10782 }
10783 }
10784}
10785
10786// We use an object instead of a boolean because booleans are ignored by our
10787// mocking libraries when these factories gets mocked.
10788var LEGACY_MARKER = {};
10789var NON_LEGACY_MARKER = {};
10790
10791var ReactLegacyElementFactory = {};
10792
10793ReactLegacyElementFactory.wrapCreateFactory = function(createFactory) {
10794 var legacyCreateFactory = function(type) {
10795 if (typeof type !== 'function') {
10796 // Non-function types cannot be legacy factories
10797 return createFactory(type);
10798 }
10799
10800 if (type.isReactNonLegacyFactory) {
10801 // This is probably a factory created by ReactDOM we unwrap it to get to
10802 // the underlying string type. It shouldn't have been passed here so we
10803 // warn.
10804 if ("production" !== "development") {
10805 warnForNonLegacyFactory(type);
10806 }
10807 return createFactory(type.type);
10808 }
10809
10810 if (type.isReactLegacyFactory) {
10811 // This is probably a legacy factory created by ReactCompositeComponent.
10812 // We unwrap it to get to the underlying class.
10813 return createFactory(type.type);
10814 }
10815
10816 if ("production" !== "development") {
10817 warnForPlainFunctionType(type);
10818 }
10819
10820 // Unless it's a legacy factory, then this is probably a plain function,
10821 // that is expecting to be invoked by JSX. We can just return it as is.
10822 return type;
10823 };
10824 return legacyCreateFactory;
10825};
10826
10827ReactLegacyElementFactory.wrapCreateElement = function(createElement) {
10828 var legacyCreateElement = function(type, props, children) {
10829 if (typeof type !== 'function') {
10830 // Non-function types cannot be legacy factories
10831 return createElement.apply(this, arguments);
10832 }
10833
10834 var args;
10835
10836 if (type.isReactNonLegacyFactory) {
10837 // This is probably a factory created by ReactDOM we unwrap it to get to
10838 // the underlying string type. It shouldn't have been passed here so we
10839 // warn.
10840 if ("production" !== "development") {
10841 warnForNonLegacyFactory(type);
10842 }
10843 args = Array.prototype.slice.call(arguments, 0);
10844 args[0] = type.type;
10845 return createElement.apply(this, args);
10846 }
10847
10848 if (type.isReactLegacyFactory) {
10849 // This is probably a legacy factory created by ReactCompositeComponent.
10850 // We unwrap it to get to the underlying class.
10851 if (type._isMockFunction) {
10852 // If this is a mock function, people will expect it to be called. We
10853 // will actually call the original mock factory function instead. This
10854 // future proofs unit testing that assume that these are classes.
10855 type.type._mockedReactClassConstructor = type;
10856 }
10857 args = Array.prototype.slice.call(arguments, 0);
10858 args[0] = type.type;
10859 return createElement.apply(this, args);
10860 }
10861
10862 if ("production" !== "development") {
10863 warnForPlainFunctionType(type);
10864 }
10865
10866 // This is being called with a plain function we should invoke it
10867 // immediately as if this was used with legacy JSX.
10868 return type.apply(null, Array.prototype.slice.call(arguments, 1));
10869 };
10870 return legacyCreateElement;
10871};
10872
10873ReactLegacyElementFactory.wrapFactory = function(factory) {
10874 ("production" !== "development" ? invariant(
10875 typeof factory === 'function',
10876 'This is suppose to accept a element factory'
10877 ) : invariant(typeof factory === 'function'));
10878 var legacyElementFactory = function(config, children) {
10879 // This factory should not be called when JSX is used. Use JSX instead.
10880 if ("production" !== "development") {
10881 warnForLegacyFactoryCall();
10882 }
10883 return factory.apply(this, arguments);
10884 };
10885 proxyStaticMethods(legacyElementFactory, factory.type);
10886 legacyElementFactory.isReactLegacyFactory = LEGACY_MARKER;
10887 legacyElementFactory.type = factory.type;
10888 return legacyElementFactory;
10889};
10890
10891// This is used to mark a factory that will remain. E.g. we're allowed to call
10892// it as a function. However, you're not suppose to pass it to createElement
10893// or createFactory, so it will warn you if you do.
10894ReactLegacyElementFactory.markNonLegacyFactory = function(factory) {
10895 factory.isReactNonLegacyFactory = NON_LEGACY_MARKER;
10896 return factory;
10897};
10898
10899// Checks if a factory function is actually a legacy factory pretending to
10900// be a class.
10901ReactLegacyElementFactory.isValidFactory = function(factory) {
10902 // TODO: This will be removed and moved into a class validator or something.
10903 return typeof factory === 'function' &&
10904 factory.isReactLegacyFactory === LEGACY_MARKER;
10905};
10906
10907ReactLegacyElementFactory.isValidClass = function(factory) {
10908 if ("production" !== "development") {
10909 ("production" !== "development" ? warning(
10910 false,
10911 'isValidClass is deprecated and will be removed in a future release. ' +
10912 'Use a more specific validator instead.'
10913 ) : null);
10914 }
10915 return ReactLegacyElementFactory.isValidFactory(factory);
10916};
10917
10918ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
10919
10920module.exports = ReactLegacyElementFactory;
10921
10922},{"./ReactCurrentOwner":36,"./invariant":126,"./monitorCodeUse":136,"./warning":145}],62:[function(_dereq_,module,exports){
10923/**
10924 * Copyright 2013-2014, Facebook, Inc.
10925 * All rights reserved.
10926 *
10927 * This source code is licensed under the BSD-style license found in the
10928 * LICENSE file in the root directory of this source tree. An additional grant
10929 * of patent rights can be found in the PATENTS file in the same directory.
10930 *
10931 * @providesModule ReactMarkupChecksum
10932 */
10933
10934"use strict";
10935
10936var adler32 = _dereq_("./adler32");
10937
10938var ReactMarkupChecksum = {
10939 CHECKSUM_ATTR_NAME: 'data-react-checksum',
10940
10941 /**
10942 * @param {string} markup Markup string
10943 * @return {string} Markup string with checksum attribute attached
10944 */
10945 addChecksumToMarkup: function(markup) {
10946 var checksum = adler32(markup);
10947 return markup.replace(
10948 '>',
10949 ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
10950 );
10951 },
10952
10953 /**
10954 * @param {string} markup to use
10955 * @param {DOMElement} element root React element
10956 * @returns {boolean} whether or not the markup is the same
10957 */
10958 canReuseMarkup: function(markup, element) {
10959 var existingChecksum = element.getAttribute(
10960 ReactMarkupChecksum.CHECKSUM_ATTR_NAME
10961 );
10962 existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
10963 var markupChecksum = adler32(markup);
10964 return markupChecksum === existingChecksum;
10965 }
10966};
10967
10968module.exports = ReactMarkupChecksum;
10969
10970},{"./adler32":98}],63:[function(_dereq_,module,exports){
10971/**
10972 * Copyright 2013-2014, Facebook, Inc.
10973 * All rights reserved.
10974 *
10975 * This source code is licensed under the BSD-style license found in the
10976 * LICENSE file in the root directory of this source tree. An additional grant
10977 * of patent rights can be found in the PATENTS file in the same directory.
10978 *
10979 * @providesModule ReactMount
10980 */
10981
10982"use strict";
10983
10984var DOMProperty = _dereq_("./DOMProperty");
10985var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
10986var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
10987var ReactElement = _dereq_("./ReactElement");
10988var ReactLegacyElement = _dereq_("./ReactLegacyElement");
10989var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
10990var ReactPerf = _dereq_("./ReactPerf");
10991
10992var containsNode = _dereq_("./containsNode");
10993var deprecated = _dereq_("./deprecated");
10994var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer");
10995var instantiateReactComponent = _dereq_("./instantiateReactComponent");
10996var invariant = _dereq_("./invariant");
10997var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
10998var warning = _dereq_("./warning");
10999
11000var createElement = ReactLegacyElement.wrapCreateElement(
11001 ReactElement.createElement
11002);
11003
11004var SEPARATOR = ReactInstanceHandles.SEPARATOR;
11005
11006var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
11007var nodeCache = {};
11008
11009var ELEMENT_NODE_TYPE = 1;
11010var DOC_NODE_TYPE = 9;
11011
11012/** Mapping from reactRootID to React component instance. */
11013var instancesByReactRootID = {};
11014
11015/** Mapping from reactRootID to `container` nodes. */
11016var containersByReactRootID = {};
11017
11018if ("production" !== "development") {
11019 /** __DEV__-only mapping from reactRootID to root elements. */
11020 var rootElementsByReactRootID = {};
11021}
11022
11023// Used to store breadth-first search state in findComponentRoot.
11024var findComponentRootReusableArray = [];
11025
11026/**
11027 * @param {DOMElement} container DOM element that may contain a React component.
11028 * @return {?string} A "reactRoot" ID, if a React component is rendered.
11029 */
11030function getReactRootID(container) {
11031 var rootElement = getReactRootElementInContainer(container);
11032 return rootElement && ReactMount.getID(rootElement);
11033}
11034
11035/**
11036 * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
11037 * element can return its control whose name or ID equals ATTR_NAME. All
11038 * DOM nodes support `getAttributeNode` but this can also get called on
11039 * other objects so just return '' if we're given something other than a
11040 * DOM node (such as window).
11041 *
11042 * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
11043 * @return {string} ID of the supplied `domNode`.
11044 */
11045function getID(node) {
11046 var id = internalGetID(node);
11047 if (id) {
11048 if (nodeCache.hasOwnProperty(id)) {
11049 var cached = nodeCache[id];
11050 if (cached !== node) {
11051 ("production" !== "development" ? invariant(
11052 !isValid(cached, id),
11053 'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
11054 ATTR_NAME, id
11055 ) : invariant(!isValid(cached, id)));
11056
11057 nodeCache[id] = node;
11058 }
11059 } else {
11060 nodeCache[id] = node;
11061 }
11062 }
11063
11064 return id;
11065}
11066
11067function internalGetID(node) {
11068 // If node is something like a window, document, or text node, none of
11069 // which support attributes or a .getAttribute method, gracefully return
11070 // the empty string, as if the attribute were missing.
11071 return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
11072}
11073
11074/**
11075 * Sets the React-specific ID of the given node.
11076 *
11077 * @param {DOMElement} node The DOM node whose ID will be set.
11078 * @param {string} id The value of the ID attribute.
11079 */
11080function setID(node, id) {
11081 var oldID = internalGetID(node);
11082 if (oldID !== id) {
11083 delete nodeCache[oldID];
11084 }
11085 node.setAttribute(ATTR_NAME, id);
11086 nodeCache[id] = node;
11087}
11088
11089/**
11090 * Finds the node with the supplied React-generated DOM ID.
11091 *
11092 * @param {string} id A React-generated DOM ID.
11093 * @return {DOMElement} DOM node with the suppled `id`.
11094 * @internal
11095 */
11096function getNode(id) {
11097 if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
11098 nodeCache[id] = ReactMount.findReactNodeByID(id);
11099 }
11100 return nodeCache[id];
11101}
11102
11103/**
11104 * A node is "valid" if it is contained by a currently mounted container.
11105 *
11106 * This means that the node does not have to be contained by a document in
11107 * order to be considered valid.
11108 *
11109 * @param {?DOMElement} node The candidate DOM node.
11110 * @param {string} id The expected ID of the node.
11111 * @return {boolean} Whether the node is contained by a mounted container.
11112 */
11113function isValid(node, id) {
11114 if (node) {
11115 ("production" !== "development" ? invariant(
11116 internalGetID(node) === id,
11117 'ReactMount: Unexpected modification of `%s`',
11118 ATTR_NAME
11119 ) : invariant(internalGetID(node) === id));
11120
11121 var container = ReactMount.findReactContainerForID(id);
11122 if (container && containsNode(container, node)) {
11123 return true;
11124 }
11125 }
11126
11127 return false;
11128}
11129
11130/**
11131 * Causes the cache to forget about one React-specific ID.
11132 *
11133 * @param {string} id The ID to forget.
11134 */
11135function purgeID(id) {
11136 delete nodeCache[id];
11137}
11138
11139var deepestNodeSoFar = null;
11140function findDeepestCachedAncestorImpl(ancestorID) {
11141 var ancestor = nodeCache[ancestorID];
11142 if (ancestor && isValid(ancestor, ancestorID)) {
11143 deepestNodeSoFar = ancestor;
11144 } else {
11145 // This node isn't populated in the cache, so presumably none of its
11146 // descendants are. Break out of the loop.
11147 return false;
11148 }
11149}
11150
11151/**
11152 * Return the deepest cached node whose ID is a prefix of `targetID`.
11153 */
11154function findDeepestCachedAncestor(targetID) {
11155 deepestNodeSoFar = null;
11156 ReactInstanceHandles.traverseAncestors(
11157 targetID,
11158 findDeepestCachedAncestorImpl
11159 );
11160
11161 var foundNode = deepestNodeSoFar;
11162 deepestNodeSoFar = null;
11163 return foundNode;
11164}
11165
11166/**
11167 * Mounting is the process of initializing a React component by creatings its
11168 * representative DOM elements and inserting them into a supplied `container`.
11169 * Any prior content inside `container` is destroyed in the process.
11170 *
11171 * ReactMount.render(
11172 * component,
11173 * document.getElementById('container')
11174 * );
11175 *
11176 * <div id="container"> <-- Supplied `container`.
11177 * <div data-reactid=".3"> <-- Rendered reactRoot of React
11178 * // ... component.
11179 * </div>
11180 * </div>
11181 *
11182 * Inside of `container`, the first element rendered is the "reactRoot".
11183 */
11184var ReactMount = {
11185 /** Exposed for debugging purposes **/
11186 _instancesByReactRootID: instancesByReactRootID,
11187
11188 /**
11189 * This is a hook provided to support rendering React components while
11190 * ensuring that the apparent scroll position of its `container` does not
11191 * change.
11192 *
11193 * @param {DOMElement} container The `container` being rendered into.
11194 * @param {function} renderCallback This must be called once to do the render.
11195 */
11196 scrollMonitor: function(container, renderCallback) {
11197 renderCallback();
11198 },
11199
11200 /**
11201 * Take a component that's already mounted into the DOM and replace its props
11202 * @param {ReactComponent} prevComponent component instance already in the DOM
11203 * @param {ReactComponent} nextComponent component instance to render
11204 * @param {DOMElement} container container to render into
11205 * @param {?function} callback function triggered on completion
11206 */
11207 _updateRootComponent: function(
11208 prevComponent,
11209 nextComponent,
11210 container,
11211 callback) {
11212 var nextProps = nextComponent.props;
11213 ReactMount.scrollMonitor(container, function() {
11214 prevComponent.replaceProps(nextProps, callback);
11215 });
11216
11217 if ("production" !== "development") {
11218 // Record the root element in case it later gets transplanted.
11219 rootElementsByReactRootID[getReactRootID(container)] =
11220 getReactRootElementInContainer(container);
11221 }
11222
11223 return prevComponent;
11224 },
11225
11226 /**
11227 * Register a component into the instance map and starts scroll value
11228 * monitoring
11229 * @param {ReactComponent} nextComponent component instance to render
11230 * @param {DOMElement} container container to render into
11231 * @return {string} reactRoot ID prefix
11232 */
11233 _registerComponent: function(nextComponent, container) {
11234 ("production" !== "development" ? invariant(
11235 container && (
11236 container.nodeType === ELEMENT_NODE_TYPE ||
11237 container.nodeType === DOC_NODE_TYPE
11238 ),
11239 '_registerComponent(...): Target container is not a DOM element.'
11240 ) : invariant(container && (
11241 container.nodeType === ELEMENT_NODE_TYPE ||
11242 container.nodeType === DOC_NODE_TYPE
11243 )));
11244
11245 ReactBrowserEventEmitter.ensureScrollValueMonitoring();
11246
11247 var reactRootID = ReactMount.registerContainer(container);
11248 instancesByReactRootID[reactRootID] = nextComponent;
11249 return reactRootID;
11250 },
11251
11252 /**
11253 * Render a new component into the DOM.
11254 * @param {ReactComponent} nextComponent component instance to render
11255 * @param {DOMElement} container container to render into
11256 * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
11257 * @return {ReactComponent} nextComponent
11258 */
11259 _renderNewRootComponent: ReactPerf.measure(
11260 'ReactMount',
11261 '_renderNewRootComponent',
11262 function(
11263 nextComponent,
11264 container,
11265 shouldReuseMarkup) {
11266 // Various parts of our code (such as ReactCompositeComponent's
11267 // _renderValidatedComponent) assume that calls to render aren't nested;
11268 // verify that that's the case.
11269 ("production" !== "development" ? warning(
11270 ReactCurrentOwner.current == null,
11271 '_renderNewRootComponent(): Render methods should be a pure function ' +
11272 'of props and state; triggering nested component updates from ' +
11273 'render is not allowed. If necessary, trigger nested updates in ' +
11274 'componentDidUpdate.'
11275 ) : null);
11276
11277 var componentInstance = instantiateReactComponent(nextComponent, null);
11278 var reactRootID = ReactMount._registerComponent(
11279 componentInstance,
11280 container
11281 );
11282 componentInstance.mountComponentIntoNode(
11283 reactRootID,
11284 container,
11285 shouldReuseMarkup
11286 );
11287
11288 if ("production" !== "development") {
11289 // Record the root element in case it later gets transplanted.
11290 rootElementsByReactRootID[reactRootID] =
11291 getReactRootElementInContainer(container);
11292 }
11293
11294 return componentInstance;
11295 }
11296 ),
11297
11298 /**
11299 * Renders a React component into the DOM in the supplied `container`.
11300 *
11301 * If the React component was previously rendered into `container`, this will
11302 * perform an update on it and only mutate the DOM as necessary to reflect the
11303 * latest React component.
11304 *
11305 * @param {ReactElement} nextElement Component element to render.
11306 * @param {DOMElement} container DOM element to render into.
11307 * @param {?function} callback function triggered on completion
11308 * @return {ReactComponent} Component instance rendered in `container`.
11309 */
11310 render: function(nextElement, container, callback) {
11311 ("production" !== "development" ? invariant(
11312 ReactElement.isValidElement(nextElement),
11313 'renderComponent(): Invalid component element.%s',
11314 (
11315 typeof nextElement === 'string' ?
11316 ' Instead of passing an element string, make sure to instantiate ' +
11317 'it by passing it to React.createElement.' :
11318 ReactLegacyElement.isValidFactory(nextElement) ?
11319 ' Instead of passing a component class, make sure to instantiate ' +
11320 'it by passing it to React.createElement.' :
11321 // Check if it quacks like a element
11322 typeof nextElement.props !== "undefined" ?
11323 ' This may be caused by unintentionally loading two independent ' +
11324 'copies of React.' :
11325 ''
11326 )
11327 ) : invariant(ReactElement.isValidElement(nextElement)));
11328
11329 var prevComponent = instancesByReactRootID[getReactRootID(container)];
11330
11331 if (prevComponent) {
11332 var prevElement = prevComponent._currentElement;
11333 if (shouldUpdateReactComponent(prevElement, nextElement)) {
11334 return ReactMount._updateRootComponent(
11335 prevComponent,
11336 nextElement,
11337 container,
11338 callback
11339 );
11340 } else {
11341 ReactMount.unmountComponentAtNode(container);
11342 }
11343 }
11344
11345 var reactRootElement = getReactRootElementInContainer(container);
11346 var containerHasReactMarkup =
11347 reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
11348
11349 var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
11350
11351 var component = ReactMount._renderNewRootComponent(
11352 nextElement,
11353 container,
11354 shouldReuseMarkup
11355 );
11356 callback && callback.call(component);
11357 return component;
11358 },
11359
11360 /**
11361 * Constructs a component instance of `constructor` with `initialProps` and
11362 * renders it into the supplied `container`.
11363 *
11364 * @param {function} constructor React component constructor.
11365 * @param {?object} props Initial props of the component instance.
11366 * @param {DOMElement} container DOM element to render into.
11367 * @return {ReactComponent} Component instance rendered in `container`.
11368 */
11369 constructAndRenderComponent: function(constructor, props, container) {
11370 var element = createElement(constructor, props);
11371 return ReactMount.render(element, container);
11372 },
11373
11374 /**
11375 * Constructs a component instance of `constructor` with `initialProps` and
11376 * renders it into a container node identified by supplied `id`.
11377 *
11378 * @param {function} componentConstructor React component constructor
11379 * @param {?object} props Initial props of the component instance.
11380 * @param {string} id ID of the DOM element to render into.
11381 * @return {ReactComponent} Component instance rendered in the container node.
11382 */
11383 constructAndRenderComponentByID: function(constructor, props, id) {
11384 var domNode = document.getElementById(id);
11385 ("production" !== "development" ? invariant(
11386 domNode,
11387 'Tried to get element with id of "%s" but it is not present on the page.',
11388 id
11389 ) : invariant(domNode));
11390 return ReactMount.constructAndRenderComponent(constructor, props, domNode);
11391 },
11392
11393 /**
11394 * Registers a container node into which React components will be rendered.
11395 * This also creates the "reactRoot" ID that will be assigned to the element
11396 * rendered within.
11397 *
11398 * @param {DOMElement} container DOM element to register as a container.
11399 * @return {string} The "reactRoot" ID of elements rendered within.
11400 */
11401 registerContainer: function(container) {
11402 var reactRootID = getReactRootID(container);
11403 if (reactRootID) {
11404 // If one exists, make sure it is a valid "reactRoot" ID.
11405 reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
11406 }
11407 if (!reactRootID) {
11408 // No valid "reactRoot" ID found, create one.
11409 reactRootID = ReactInstanceHandles.createReactRootID();
11410 }
11411 containersByReactRootID[reactRootID] = container;
11412 return reactRootID;
11413 },
11414
11415 /**
11416 * Unmounts and destroys the React component rendered in the `container`.
11417 *
11418 * @param {DOMElement} container DOM element containing a React component.
11419 * @return {boolean} True if a component was found in and unmounted from
11420 * `container`
11421 */
11422 unmountComponentAtNode: function(container) {
11423 // Various parts of our code (such as ReactCompositeComponent's
11424 // _renderValidatedComponent) assume that calls to render aren't nested;
11425 // verify that that's the case. (Strictly speaking, unmounting won't cause a
11426 // render but we still don't expect to be in a render call here.)
11427 ("production" !== "development" ? warning(
11428 ReactCurrentOwner.current == null,
11429 'unmountComponentAtNode(): Render methods should be a pure function of ' +
11430 'props and state; triggering nested component updates from render is ' +
11431 'not allowed. If necessary, trigger nested updates in ' +
11432 'componentDidUpdate.'
11433 ) : null);
11434
11435 var reactRootID = getReactRootID(container);
11436 var component = instancesByReactRootID[reactRootID];
11437 if (!component) {
11438 return false;
11439 }
11440 ReactMount.unmountComponentFromNode(component, container);
11441 delete instancesByReactRootID[reactRootID];
11442 delete containersByReactRootID[reactRootID];
11443 if ("production" !== "development") {
11444 delete rootElementsByReactRootID[reactRootID];
11445 }
11446 return true;
11447 },
11448
11449 /**
11450 * Unmounts a component and removes it from the DOM.
11451 *
11452 * @param {ReactComponent} instance React component instance.
11453 * @param {DOMElement} container DOM element to unmount from.
11454 * @final
11455 * @internal
11456 * @see {ReactMount.unmountComponentAtNode}
11457 */
11458 unmountComponentFromNode: function(instance, container) {
11459 instance.unmountComponent();
11460
11461 if (container.nodeType === DOC_NODE_TYPE) {
11462 container = container.documentElement;
11463 }
11464
11465 // http://jsperf.com/emptying-a-node
11466 while (container.lastChild) {
11467 container.removeChild(container.lastChild);
11468 }
11469 },
11470
11471 /**
11472 * Finds the container DOM element that contains React component to which the
11473 * supplied DOM `id` belongs.
11474 *
11475 * @param {string} id The ID of an element rendered by a React component.
11476 * @return {?DOMElement} DOM element that contains the `id`.
11477 */
11478 findReactContainerForID: function(id) {
11479 var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
11480 var container = containersByReactRootID[reactRootID];
11481
11482 if ("production" !== "development") {
11483 var rootElement = rootElementsByReactRootID[reactRootID];
11484 if (rootElement && rootElement.parentNode !== container) {
11485 ("production" !== "development" ? invariant(
11486 // Call internalGetID here because getID calls isValid which calls
11487 // findReactContainerForID (this function).
11488 internalGetID(rootElement) === reactRootID,
11489 'ReactMount: Root element ID differed from reactRootID.'
11490 ) : invariant(// Call internalGetID here because getID calls isValid which calls
11491 // findReactContainerForID (this function).
11492 internalGetID(rootElement) === reactRootID));
11493
11494 var containerChild = container.firstChild;
11495 if (containerChild &&
11496 reactRootID === internalGetID(containerChild)) {
11497 // If the container has a new child with the same ID as the old
11498 // root element, then rootElementsByReactRootID[reactRootID] is
11499 // just stale and needs to be updated. The case that deserves a
11500 // warning is when the container is empty.
11501 rootElementsByReactRootID[reactRootID] = containerChild;
11502 } else {
11503 console.warn(
11504 'ReactMount: Root element has been removed from its original ' +
11505 'container. New container:', rootElement.parentNode
11506 );
11507 }
11508 }
11509 }
11510
11511 return container;
11512 },
11513
11514 /**
11515 * Finds an element rendered by React with the supplied ID.
11516 *
11517 * @param {string} id ID of a DOM node in the React component.
11518 * @return {DOMElement} Root DOM node of the React component.
11519 */
11520 findReactNodeByID: function(id) {
11521 var reactRoot = ReactMount.findReactContainerForID(id);
11522 return ReactMount.findComponentRoot(reactRoot, id);
11523 },
11524
11525 /**
11526 * True if the supplied `node` is rendered by React.
11527 *
11528 * @param {*} node DOM Element to check.
11529 * @return {boolean} True if the DOM Element appears to be rendered by React.
11530 * @internal
11531 */
11532 isRenderedByReact: function(node) {
11533 if (node.nodeType !== 1) {
11534 // Not a DOMElement, therefore not a React component
11535 return false;
11536 }
11537 var id = ReactMount.getID(node);
11538 return id ? id.charAt(0) === SEPARATOR : false;
11539 },
11540
11541 /**
11542 * Traverses up the ancestors of the supplied node to find a node that is a
11543 * DOM representation of a React component.
11544 *
11545 * @param {*} node
11546 * @return {?DOMEventTarget}
11547 * @internal
11548 */
11549 getFirstReactDOM: function(node) {
11550 var current = node;
11551 while (current && current.parentNode !== current) {
11552 if (ReactMount.isRenderedByReact(current)) {
11553 return current;
11554 }
11555 current = current.parentNode;
11556 }
11557 return null;
11558 },
11559
11560 /**
11561 * Finds a node with the supplied `targetID` inside of the supplied
11562 * `ancestorNode`. Exploits the ID naming scheme to perform the search
11563 * quickly.
11564 *
11565 * @param {DOMEventTarget} ancestorNode Search from this root.
11566 * @pararm {string} targetID ID of the DOM representation of the component.
11567 * @return {DOMEventTarget} DOM node with the supplied `targetID`.
11568 * @internal
11569 */
11570 findComponentRoot: function(ancestorNode, targetID) {
11571 var firstChildren = findComponentRootReusableArray;
11572 var childIndex = 0;
11573
11574 var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
11575
11576 firstChildren[0] = deepestAncestor.firstChild;
11577 firstChildren.length = 1;
11578
11579 while (childIndex < firstChildren.length) {
11580 var child = firstChildren[childIndex++];
11581 var targetChild;
11582
11583 while (child) {
11584 var childID = ReactMount.getID(child);
11585 if (childID) {
11586 // Even if we find the node we're looking for, we finish looping
11587 // through its siblings to ensure they're cached so that we don't have
11588 // to revisit this node again. Otherwise, we make n^2 calls to getID
11589 // when visiting the many children of a single node in order.
11590
11591 if (targetID === childID) {
11592 targetChild = child;
11593 } else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
11594 // If we find a child whose ID is an ancestor of the given ID,
11595 // then we can be sure that we only want to search the subtree
11596 // rooted at this child, so we can throw out the rest of the
11597 // search state.
11598 firstChildren.length = childIndex = 0;
11599 firstChildren.push(child.firstChild);
11600 }
11601
11602 } else {
11603 // If this child had no ID, then there's a chance that it was
11604 // injected automatically by the browser, as when a `<table>`
11605 // element sprouts an extra `<tbody>` child as a side effect of
11606 // `.innerHTML` parsing. Optimistically continue down this
11607 // branch, but not before examining the other siblings.
11608 firstChildren.push(child.firstChild);
11609 }
11610
11611 child = child.nextSibling;
11612 }
11613
11614 if (targetChild) {
11615 // Emptying firstChildren/findComponentRootReusableArray is
11616 // not necessary for correctness, but it helps the GC reclaim
11617 // any nodes that were left at the end of the search.
11618 firstChildren.length = 0;
11619
11620 return targetChild;
11621 }
11622 }
11623
11624 firstChildren.length = 0;
11625
11626 ("production" !== "development" ? invariant(
11627 false,
11628 'findComponentRoot(..., %s): Unable to find element. This probably ' +
11629 'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
11630 'usually due to forgetting a <tbody> when using tables, nesting tags ' +
11631 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
11632 'parent. ' +
11633 'Try inspecting the child nodes of the element with React ID `%s`.',
11634 targetID,
11635 ReactMount.getID(ancestorNode)
11636 ) : invariant(false));
11637 },
11638
11639
11640 /**
11641 * React ID utilities.
11642 */
11643
11644 getReactRootID: getReactRootID,
11645
11646 getID: getID,
11647
11648 setID: setID,
11649
11650 getNode: getNode,
11651
11652 purgeID: purgeID
11653};
11654
11655// Deprecations (remove for 0.13)
11656ReactMount.renderComponent = deprecated(
11657 'ReactMount',
11658 'renderComponent',
11659 'render',
11660 this,
11661 ReactMount.render
11662);
11663
11664module.exports = ReactMount;
11665
11666},{"./DOMProperty":11,"./ReactBrowserEventEmitter":30,"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactInstanceHandles":60,"./ReactLegacyElement":61,"./ReactPerf":68,"./containsNode":101,"./deprecated":106,"./getReactRootElementInContainer":120,"./instantiateReactComponent":125,"./invariant":126,"./shouldUpdateReactComponent":142,"./warning":145}],64:[function(_dereq_,module,exports){
11667/**
11668 * Copyright 2013-2014, Facebook, Inc.
11669 * All rights reserved.
11670 *
11671 * This source code is licensed under the BSD-style license found in the
11672 * LICENSE file in the root directory of this source tree. An additional grant
11673 * of patent rights can be found in the PATENTS file in the same directory.
11674 *
11675 * @providesModule ReactMultiChild
11676 * @typechecks static-only
11677 */
11678
11679"use strict";
11680
11681var ReactComponent = _dereq_("./ReactComponent");
11682var ReactMultiChildUpdateTypes = _dereq_("./ReactMultiChildUpdateTypes");
11683
11684var flattenChildren = _dereq_("./flattenChildren");
11685var instantiateReactComponent = _dereq_("./instantiateReactComponent");
11686var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
11687
11688/**
11689 * Updating children of a component may trigger recursive updates. The depth is
11690 * used to batch recursive updates to render markup more efficiently.
11691 *
11692 * @type {number}
11693 * @private
11694 */
11695var updateDepth = 0;
11696
11697/**
11698 * Queue of update configuration objects.
11699 *
11700 * Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
11701 *
11702 * @type {array<object>}
11703 * @private
11704 */
11705var updateQueue = [];
11706
11707/**
11708 * Queue of markup to be rendered.
11709 *
11710 * @type {array<string>}
11711 * @private
11712 */
11713var markupQueue = [];
11714
11715/**
11716 * Enqueues markup to be rendered and inserted at a supplied index.
11717 *
11718 * @param {string} parentID ID of the parent component.
11719 * @param {string} markup Markup that renders into an element.
11720 * @param {number} toIndex Destination index.
11721 * @private
11722 */
11723function enqueueMarkup(parentID, markup, toIndex) {
11724 // NOTE: Null values reduce hidden classes.
11725 updateQueue.push({
11726 parentID: parentID,
11727 parentNode: null,
11728 type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
11729 markupIndex: markupQueue.push(markup) - 1,
11730 textContent: null,
11731 fromIndex: null,
11732 toIndex: toIndex
11733 });
11734}
11735
11736/**
11737 * Enqueues moving an existing element to another index.
11738 *
11739 * @param {string} parentID ID of the parent component.
11740 * @param {number} fromIndex Source index of the existing element.
11741 * @param {number} toIndex Destination index of the element.
11742 * @private
11743 */
11744function enqueueMove(parentID, fromIndex, toIndex) {
11745 // NOTE: Null values reduce hidden classes.
11746 updateQueue.push({
11747 parentID: parentID,
11748 parentNode: null,
11749 type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
11750 markupIndex: null,
11751 textContent: null,
11752 fromIndex: fromIndex,
11753 toIndex: toIndex
11754 });
11755}
11756
11757/**
11758 * Enqueues removing an element at an index.
11759 *
11760 * @param {string} parentID ID of the parent component.
11761 * @param {number} fromIndex Index of the element to remove.
11762 * @private
11763 */
11764function enqueueRemove(parentID, fromIndex) {
11765 // NOTE: Null values reduce hidden classes.
11766 updateQueue.push({
11767 parentID: parentID,
11768 parentNode: null,
11769 type: ReactMultiChildUpdateTypes.REMOVE_NODE,
11770 markupIndex: null,
11771 textContent: null,
11772 fromIndex: fromIndex,
11773 toIndex: null
11774 });
11775}
11776
11777/**
11778 * Enqueues setting the text content.
11779 *
11780 * @param {string} parentID ID of the parent component.
11781 * @param {string} textContent Text content to set.
11782 * @private
11783 */
11784function enqueueTextContent(parentID, textContent) {
11785 // NOTE: Null values reduce hidden classes.
11786 updateQueue.push({
11787 parentID: parentID,
11788 parentNode: null,
11789 type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
11790 markupIndex: null,
11791 textContent: textContent,
11792 fromIndex: null,
11793 toIndex: null
11794 });
11795}
11796
11797/**
11798 * Processes any enqueued updates.
11799 *
11800 * @private
11801 */
11802function processQueue() {
11803 if (updateQueue.length) {
11804 ReactComponent.BackendIDOperations.dangerouslyProcessChildrenUpdates(
11805 updateQueue,
11806 markupQueue
11807 );
11808 clearQueue();
11809 }
11810}
11811
11812/**
11813 * Clears any enqueued updates.
11814 *
11815 * @private
11816 */
11817function clearQueue() {
11818 updateQueue.length = 0;
11819 markupQueue.length = 0;
11820}
11821
11822/**
11823 * ReactMultiChild are capable of reconciling multiple children.
11824 *
11825 * @class ReactMultiChild
11826 * @internal
11827 */
11828var ReactMultiChild = {
11829
11830 /**
11831 * Provides common functionality for components that must reconcile multiple
11832 * children. This is used by `ReactDOMComponent` to mount, update, and
11833 * unmount child components.
11834 *
11835 * @lends {ReactMultiChild.prototype}
11836 */
11837 Mixin: {
11838
11839 /**
11840 * Generates a "mount image" for each of the supplied children. In the case
11841 * of `ReactDOMComponent`, a mount image is a string of markup.
11842 *
11843 * @param {?object} nestedChildren Nested child maps.
11844 * @return {array} An array of mounted representations.
11845 * @internal
11846 */
11847 mountChildren: function(nestedChildren, transaction) {
11848 var children = flattenChildren(nestedChildren);
11849 var mountImages = [];
11850 var index = 0;
11851 this._renderedChildren = children;
11852 for (var name in children) {
11853 var child = children[name];
11854 if (children.hasOwnProperty(name)) {
11855 // The rendered children must be turned into instances as they're
11856 // mounted.
11857 var childInstance = instantiateReactComponent(child, null);
11858 children[name] = childInstance;
11859 // Inlined for performance, see `ReactInstanceHandles.createReactID`.
11860 var rootID = this._rootNodeID + name;
11861 var mountImage = childInstance.mountComponent(
11862 rootID,
11863 transaction,
11864 this._mountDepth + 1
11865 );
11866 childInstance._mountIndex = index;
11867 mountImages.push(mountImage);
11868 index++;
11869 }
11870 }
11871 return mountImages;
11872 },
11873
11874 /**
11875 * Replaces any rendered children with a text content string.
11876 *
11877 * @param {string} nextContent String of content.
11878 * @internal
11879 */
11880 updateTextContent: function(nextContent) {
11881 updateDepth++;
11882 var errorThrown = true;
11883 try {
11884 var prevChildren = this._renderedChildren;
11885 // Remove any rendered children.
11886 for (var name in prevChildren) {
11887 if (prevChildren.hasOwnProperty(name)) {
11888 this._unmountChildByName(prevChildren[name], name);
11889 }
11890 }
11891 // Set new text content.
11892 this.setTextContent(nextContent);
11893 errorThrown = false;
11894 } finally {
11895 updateDepth--;
11896 if (!updateDepth) {
11897 errorThrown ? clearQueue() : processQueue();
11898 }
11899 }
11900 },
11901
11902 /**
11903 * Updates the rendered children with new children.
11904 *
11905 * @param {?object} nextNestedChildren Nested child maps.
11906 * @param {ReactReconcileTransaction} transaction
11907 * @internal
11908 */
11909 updateChildren: function(nextNestedChildren, transaction) {
11910 updateDepth++;
11911 var errorThrown = true;
11912 try {
11913 this._updateChildren(nextNestedChildren, transaction);
11914 errorThrown = false;
11915 } finally {
11916 updateDepth--;
11917 if (!updateDepth) {
11918 errorThrown ? clearQueue() : processQueue();
11919 }
11920 }
11921 },
11922
11923 /**
11924 * Improve performance by isolating this hot code path from the try/catch
11925 * block in `updateChildren`.
11926 *
11927 * @param {?object} nextNestedChildren Nested child maps.
11928 * @param {ReactReconcileTransaction} transaction
11929 * @final
11930 * @protected
11931 */
11932 _updateChildren: function(nextNestedChildren, transaction) {
11933 var nextChildren = flattenChildren(nextNestedChildren);
11934 var prevChildren = this._renderedChildren;
11935 if (!nextChildren && !prevChildren) {
11936 return;
11937 }
11938 var name;
11939 // `nextIndex` will increment for each child in `nextChildren`, but
11940 // `lastIndex` will be the last index visited in `prevChildren`.
11941 var lastIndex = 0;
11942 var nextIndex = 0;
11943 for (name in nextChildren) {
11944 if (!nextChildren.hasOwnProperty(name)) {
11945 continue;
11946 }
11947 var prevChild = prevChildren && prevChildren[name];
11948 var prevElement = prevChild && prevChild._currentElement;
11949 var nextElement = nextChildren[name];
11950 if (shouldUpdateReactComponent(prevElement, nextElement)) {
11951 this.moveChild(prevChild, nextIndex, lastIndex);
11952 lastIndex = Math.max(prevChild._mountIndex, lastIndex);
11953 prevChild.receiveComponent(nextElement, transaction);
11954 prevChild._mountIndex = nextIndex;
11955 } else {
11956 if (prevChild) {
11957 // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
11958 lastIndex = Math.max(prevChild._mountIndex, lastIndex);
11959 this._unmountChildByName(prevChild, name);
11960 }
11961 // The child must be instantiated before it's mounted.
11962 var nextChildInstance = instantiateReactComponent(
11963 nextElement,
11964 null
11965 );
11966 this._mountChildByNameAtIndex(
11967 nextChildInstance, name, nextIndex, transaction
11968 );
11969 }
11970 nextIndex++;
11971 }
11972 // Remove children that are no longer present.
11973 for (name in prevChildren) {
11974 if (prevChildren.hasOwnProperty(name) &&
11975 !(nextChildren && nextChildren[name])) {
11976 this._unmountChildByName(prevChildren[name], name);
11977 }
11978 }
11979 },
11980
11981 /**
11982 * Unmounts all rendered children. This should be used to clean up children
11983 * when this component is unmounted.
11984 *
11985 * @internal
11986 */
11987 unmountChildren: function() {
11988 var renderedChildren = this._renderedChildren;
11989 for (var name in renderedChildren) {
11990 var renderedChild = renderedChildren[name];
11991 // TODO: When is this not true?
11992 if (renderedChild.unmountComponent) {
11993 renderedChild.unmountComponent();
11994 }
11995 }
11996 this._renderedChildren = null;
11997 },
11998
11999 /**
12000 * Moves a child component to the supplied index.
12001 *
12002 * @param {ReactComponent} child Component to move.
12003 * @param {number} toIndex Destination index of the element.
12004 * @param {number} lastIndex Last index visited of the siblings of `child`.
12005 * @protected
12006 */
12007 moveChild: function(child, toIndex, lastIndex) {
12008 // If the index of `child` is less than `lastIndex`, then it needs to
12009 // be moved. Otherwise, we do not need to move it because a child will be
12010 // inserted or moved before `child`.
12011 if (child._mountIndex < lastIndex) {
12012 enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
12013 }
12014 },
12015
12016 /**
12017 * Creates a child component.
12018 *
12019 * @param {ReactComponent} child Component to create.
12020 * @param {string} mountImage Markup to insert.
12021 * @protected
12022 */
12023 createChild: function(child, mountImage) {
12024 enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
12025 },
12026
12027 /**
12028 * Removes a child component.
12029 *
12030 * @param {ReactComponent} child Child to remove.
12031 * @protected
12032 */
12033 removeChild: function(child) {
12034 enqueueRemove(this._rootNodeID, child._mountIndex);
12035 },
12036
12037 /**
12038 * Sets this text content string.
12039 *
12040 * @param {string} textContent Text content to set.
12041 * @protected
12042 */
12043 setTextContent: function(textContent) {
12044 enqueueTextContent(this._rootNodeID, textContent);
12045 },
12046
12047 /**
12048 * Mounts a child with the supplied name.
12049 *
12050 * NOTE: This is part of `updateChildren` and is here for readability.
12051 *
12052 * @param {ReactComponent} child Component to mount.
12053 * @param {string} name Name of the child.
12054 * @param {number} index Index at which to insert the child.
12055 * @param {ReactReconcileTransaction} transaction
12056 * @private
12057 */
12058 _mountChildByNameAtIndex: function(child, name, index, transaction) {
12059 // Inlined for performance, see `ReactInstanceHandles.createReactID`.
12060 var rootID = this._rootNodeID + name;
12061 var mountImage = child.mountComponent(
12062 rootID,
12063 transaction,
12064 this._mountDepth + 1
12065 );
12066 child._mountIndex = index;
12067 this.createChild(child, mountImage);
12068 this._renderedChildren = this._renderedChildren || {};
12069 this._renderedChildren[name] = child;
12070 },
12071
12072 /**
12073 * Unmounts a rendered child by name.
12074 *
12075 * NOTE: This is part of `updateChildren` and is here for readability.
12076 *
12077 * @param {ReactComponent} child Component to unmount.
12078 * @param {string} name Name of the child in `this._renderedChildren`.
12079 * @private
12080 */
12081 _unmountChildByName: function(child, name) {
12082 this.removeChild(child);
12083 child._mountIndex = null;
12084 child.unmountComponent();
12085 delete this._renderedChildren[name];
12086 }
12087
12088 }
12089
12090};
12091
12092module.exports = ReactMultiChild;
12093
12094},{"./ReactComponent":32,"./ReactMultiChildUpdateTypes":65,"./flattenChildren":110,"./instantiateReactComponent":125,"./shouldUpdateReactComponent":142}],65:[function(_dereq_,module,exports){
12095/**
12096 * Copyright 2013-2014, Facebook, Inc.
12097 * All rights reserved.
12098 *
12099 * This source code is licensed under the BSD-style license found in the
12100 * LICENSE file in the root directory of this source tree. An additional grant
12101 * of patent rights can be found in the PATENTS file in the same directory.
12102 *
12103 * @providesModule ReactMultiChildUpdateTypes
12104 */
12105
12106"use strict";
12107
12108var keyMirror = _dereq_("./keyMirror");
12109
12110/**
12111 * When a component's children are updated, a series of update configuration
12112 * objects are created in order to batch and serialize the required changes.
12113 *
12114 * Enumerates all the possible types of update configurations.
12115 *
12116 * @internal
12117 */
12118var ReactMultiChildUpdateTypes = keyMirror({
12119 INSERT_MARKUP: null,
12120 MOVE_EXISTING: null,
12121 REMOVE_NODE: null,
12122 TEXT_CONTENT: null
12123});
12124
12125module.exports = ReactMultiChildUpdateTypes;
12126
12127},{"./keyMirror":132}],66:[function(_dereq_,module,exports){
12128/**
12129 * Copyright 2014, Facebook, Inc.
12130 * All rights reserved.
12131 *
12132 * This source code is licensed under the BSD-style license found in the
12133 * LICENSE file in the root directory of this source tree. An additional grant
12134 * of patent rights can be found in the PATENTS file in the same directory.
12135 *
12136 * @providesModule ReactNativeComponent
12137 */
12138
12139"use strict";
12140
12141var assign = _dereq_("./Object.assign");
12142var invariant = _dereq_("./invariant");
12143
12144var genericComponentClass = null;
12145// This registry keeps track of wrapper classes around native tags
12146var tagToComponentClass = {};
12147
12148var ReactNativeComponentInjection = {
12149 // This accepts a class that receives the tag string. This is a catch all
12150 // that can render any kind of tag.
12151 injectGenericComponentClass: function(componentClass) {
12152 genericComponentClass = componentClass;
12153 },
12154 // This accepts a keyed object with classes as values. Each key represents a
12155 // tag. That particular tag will use this class instead of the generic one.
12156 injectComponentClasses: function(componentClasses) {
12157 assign(tagToComponentClass, componentClasses);
12158 }
12159};
12160
12161/**
12162 * Create an internal class for a specific tag.
12163 *
12164 * @param {string} tag The tag for which to create an internal instance.
12165 * @param {any} props The props passed to the instance constructor.
12166 * @return {ReactComponent} component The injected empty component.
12167 */
12168function createInstanceForTag(tag, props, parentType) {
12169 var componentClass = tagToComponentClass[tag];
12170 if (componentClass == null) {
12171 ("production" !== "development" ? invariant(
12172 genericComponentClass,
12173 'There is no registered component for the tag %s',
12174 tag
12175 ) : invariant(genericComponentClass));
12176 return new genericComponentClass(tag, props);
12177 }
12178 if (parentType === tag) {
12179 // Avoid recursion
12180 ("production" !== "development" ? invariant(
12181 genericComponentClass,
12182 'There is no registered component for the tag %s',
12183 tag
12184 ) : invariant(genericComponentClass));
12185 return new genericComponentClass(tag, props);
12186 }
12187 // Unwrap legacy factories
12188 return new componentClass.type(props);
12189}
12190
12191var ReactNativeComponent = {
12192 createInstanceForTag: createInstanceForTag,
12193 injection: ReactNativeComponentInjection
12194};
12195
12196module.exports = ReactNativeComponent;
12197
12198},{"./Object.assign":27,"./invariant":126}],67:[function(_dereq_,module,exports){
12199/**
12200 * Copyright 2013-2014, Facebook, Inc.
12201 * All rights reserved.
12202 *
12203 * This source code is licensed under the BSD-style license found in the
12204 * LICENSE file in the root directory of this source tree. An additional grant
12205 * of patent rights can be found in the PATENTS file in the same directory.
12206 *
12207 * @providesModule ReactOwner
12208 */
12209
12210"use strict";
12211
12212var emptyObject = _dereq_("./emptyObject");
12213var invariant = _dereq_("./invariant");
12214
12215/**
12216 * ReactOwners are capable of storing references to owned components.
12217 *
12218 * All components are capable of //being// referenced by owner components, but
12219 * only ReactOwner components are capable of //referencing// owned components.
12220 * The named reference is known as a "ref".
12221 *
12222 * Refs are available when mounted and updated during reconciliation.
12223 *
12224 * var MyComponent = React.createClass({
12225 * render: function() {
12226 * return (
12227 * <div onClick={this.handleClick}>
12228 * <CustomComponent ref="custom" />
12229 * </div>
12230 * );
12231 * },
12232 * handleClick: function() {
12233 * this.refs.custom.handleClick();
12234 * },
12235 * componentDidMount: function() {
12236 * this.refs.custom.initialize();
12237 * }
12238 * });
12239 *
12240 * Refs should rarely be used. When refs are used, they should only be done to
12241 * control data that is not handled by React's data flow.
12242 *
12243 * @class ReactOwner
12244 */
12245var ReactOwner = {
12246
12247 /**
12248 * @param {?object} object
12249 * @return {boolean} True if `object` is a valid owner.
12250 * @final
12251 */
12252 isValidOwner: function(object) {
12253 return !!(
12254 object &&
12255 typeof object.attachRef === 'function' &&
12256 typeof object.detachRef === 'function'
12257 );
12258 },
12259
12260 /**
12261 * Adds a component by ref to an owner component.
12262 *
12263 * @param {ReactComponent} component Component to reference.
12264 * @param {string} ref Name by which to refer to the component.
12265 * @param {ReactOwner} owner Component on which to record the ref.
12266 * @final
12267 * @internal
12268 */
12269 addComponentAsRefTo: function(component, ref, owner) {
12270 ("production" !== "development" ? invariant(
12271 ReactOwner.isValidOwner(owner),
12272 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
12273 'usually means that you\'re trying to add a ref to a component that ' +
12274 'doesn\'t have an owner (that is, was not created inside of another ' +
12275 'component\'s `render` method). Try rendering this component inside of ' +
12276 'a new top-level component which will hold the ref.'
12277 ) : invariant(ReactOwner.isValidOwner(owner)));
12278 owner.attachRef(ref, component);
12279 },
12280
12281 /**
12282 * Removes a component by ref from an owner component.
12283 *
12284 * @param {ReactComponent} component Component to dereference.
12285 * @param {string} ref Name of the ref to remove.
12286 * @param {ReactOwner} owner Component on which the ref is recorded.
12287 * @final
12288 * @internal
12289 */
12290 removeComponentAsRefFrom: function(component, ref, owner) {
12291 ("production" !== "development" ? invariant(
12292 ReactOwner.isValidOwner(owner),
12293 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
12294 'usually means that you\'re trying to remove a ref to a component that ' +
12295 'doesn\'t have an owner (that is, was not created inside of another ' +
12296 'component\'s `render` method). Try rendering this component inside of ' +
12297 'a new top-level component which will hold the ref.'
12298 ) : invariant(ReactOwner.isValidOwner(owner)));
12299 // Check that `component` is still the current ref because we do not want to
12300 // detach the ref if another component stole it.
12301 if (owner.refs[ref] === component) {
12302 owner.detachRef(ref);
12303 }
12304 },
12305
12306 /**
12307 * A ReactComponent must mix this in to have refs.
12308 *
12309 * @lends {ReactOwner.prototype}
12310 */
12311 Mixin: {
12312
12313 construct: function() {
12314 this.refs = emptyObject;
12315 },
12316
12317 /**
12318 * Lazily allocates the refs object and stores `component` as `ref`.
12319 *
12320 * @param {string} ref Reference name.
12321 * @param {component} component Component to store as `ref`.
12322 * @final
12323 * @private
12324 */
12325 attachRef: function(ref, component) {
12326 ("production" !== "development" ? invariant(
12327 component.isOwnedBy(this),
12328 'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
12329 ref
12330 ) : invariant(component.isOwnedBy(this)));
12331 var refs = this.refs === emptyObject ? (this.refs = {}) : this.refs;
12332 refs[ref] = component;
12333 },
12334
12335 /**
12336 * Detaches a reference name.
12337 *
12338 * @param {string} ref Name to dereference.
12339 * @final
12340 * @private
12341 */
12342 detachRef: function(ref) {
12343 delete this.refs[ref];
12344 }
12345
12346 }
12347
12348};
12349
12350module.exports = ReactOwner;
12351
12352},{"./emptyObject":108,"./invariant":126}],68:[function(_dereq_,module,exports){
12353/**
12354 * Copyright 2013-2014, Facebook, Inc.
12355 * All rights reserved.
12356 *
12357 * This source code is licensed under the BSD-style license found in the
12358 * LICENSE file in the root directory of this source tree. An additional grant
12359 * of patent rights can be found in the PATENTS file in the same directory.
12360 *
12361 * @providesModule ReactPerf
12362 * @typechecks static-only
12363 */
12364
12365"use strict";
12366
12367/**
12368 * ReactPerf is a general AOP system designed to measure performance. This
12369 * module only has the hooks: see ReactDefaultPerf for the analysis tool.
12370 */
12371var ReactPerf = {
12372 /**
12373 * Boolean to enable/disable measurement. Set to false by default to prevent
12374 * accidental logging and perf loss.
12375 */
12376 enableMeasure: false,
12377
12378 /**
12379 * Holds onto the measure function in use. By default, don't measure
12380 * anything, but we'll override this if we inject a measure function.
12381 */
12382 storedMeasure: _noMeasure,
12383
12384 /**
12385 * Use this to wrap methods you want to measure. Zero overhead in production.
12386 *
12387 * @param {string} objName
12388 * @param {string} fnName
12389 * @param {function} func
12390 * @return {function}
12391 */
12392 measure: function(objName, fnName, func) {
12393 if ("production" !== "development") {
12394 var measuredFunc = null;
12395 var wrapper = function() {
12396 if (ReactPerf.enableMeasure) {
12397 if (!measuredFunc) {
12398 measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
12399 }
12400 return measuredFunc.apply(this, arguments);
12401 }
12402 return func.apply(this, arguments);
12403 };
12404 wrapper.displayName = objName + '_' + fnName;
12405 return wrapper;
12406 }
12407 return func;
12408 },
12409
12410 injection: {
12411 /**
12412 * @param {function} measure
12413 */
12414 injectMeasure: function(measure) {
12415 ReactPerf.storedMeasure = measure;
12416 }
12417 }
12418};
12419
12420/**
12421 * Simply passes through the measured function, without measuring it.
12422 *
12423 * @param {string} objName
12424 * @param {string} fnName
12425 * @param {function} func
12426 * @return {function}
12427 */
12428function _noMeasure(objName, fnName, func) {
12429 return func;
12430}
12431
12432module.exports = ReactPerf;
12433
12434},{}],69:[function(_dereq_,module,exports){
12435/**
12436 * Copyright 2013-2014, Facebook, Inc.
12437 * All rights reserved.
12438 *
12439 * This source code is licensed under the BSD-style license found in the
12440 * LICENSE file in the root directory of this source tree. An additional grant
12441 * of patent rights can be found in the PATENTS file in the same directory.
12442 *
12443 * @providesModule ReactPropTransferer
12444 */
12445
12446"use strict";
12447
12448var assign = _dereq_("./Object.assign");
12449var emptyFunction = _dereq_("./emptyFunction");
12450var invariant = _dereq_("./invariant");
12451var joinClasses = _dereq_("./joinClasses");
12452var warning = _dereq_("./warning");
12453
12454var didWarn = false;
12455
12456/**
12457 * Creates a transfer strategy that will merge prop values using the supplied
12458 * `mergeStrategy`. If a prop was previously unset, this just sets it.
12459 *
12460 * @param {function} mergeStrategy
12461 * @return {function}
12462 */
12463function createTransferStrategy(mergeStrategy) {
12464 return function(props, key, value) {
12465 if (!props.hasOwnProperty(key)) {
12466 props[key] = value;
12467 } else {
12468 props[key] = mergeStrategy(props[key], value);
12469 }
12470 };
12471}
12472
12473var transferStrategyMerge = createTransferStrategy(function(a, b) {
12474 // `merge` overrides the first object's (`props[key]` above) keys using the
12475 // second object's (`value`) keys. An object's style's existing `propA` would
12476 // get overridden. Flip the order here.
12477 return assign({}, b, a);
12478});
12479
12480/**
12481 * Transfer strategies dictate how props are transferred by `transferPropsTo`.
12482 * NOTE: if you add any more exceptions to this list you should be sure to
12483 * update `cloneWithProps()` accordingly.
12484 */
12485var TransferStrategies = {
12486 /**
12487 * Never transfer `children`.
12488 */
12489 children: emptyFunction,
12490 /**
12491 * Transfer the `className` prop by merging them.
12492 */
12493 className: createTransferStrategy(joinClasses),
12494 /**
12495 * Transfer the `style` prop (which is an object) by merging them.
12496 */
12497 style: transferStrategyMerge
12498};
12499
12500/**
12501 * Mutates the first argument by transferring the properties from the second
12502 * argument.
12503 *
12504 * @param {object} props
12505 * @param {object} newProps
12506 * @return {object}
12507 */
12508function transferInto(props, newProps) {
12509 for (var thisKey in newProps) {
12510 if (!newProps.hasOwnProperty(thisKey)) {
12511 continue;
12512 }
12513
12514 var transferStrategy = TransferStrategies[thisKey];
12515
12516 if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
12517 transferStrategy(props, thisKey, newProps[thisKey]);
12518 } else if (!props.hasOwnProperty(thisKey)) {
12519 props[thisKey] = newProps[thisKey];
12520 }
12521 }
12522 return props;
12523}
12524
12525/**
12526 * ReactPropTransferer are capable of transferring props to another component
12527 * using a `transferPropsTo` method.
12528 *
12529 * @class ReactPropTransferer
12530 */
12531var ReactPropTransferer = {
12532
12533 TransferStrategies: TransferStrategies,
12534
12535 /**
12536 * Merge two props objects using TransferStrategies.
12537 *
12538 * @param {object} oldProps original props (they take precedence)
12539 * @param {object} newProps new props to merge in
12540 * @return {object} a new object containing both sets of props merged.
12541 */
12542 mergeProps: function(oldProps, newProps) {
12543 return transferInto(assign({}, oldProps), newProps);
12544 },
12545
12546 /**
12547 * @lends {ReactPropTransferer.prototype}
12548 */
12549 Mixin: {
12550
12551 /**
12552 * Transfer props from this component to a target component.
12553 *
12554 * Props that do not have an explicit transfer strategy will be transferred
12555 * only if the target component does not already have the prop set.
12556 *
12557 * This is usually used to pass down props to a returned root component.
12558 *
12559 * @param {ReactElement} element Component receiving the properties.
12560 * @return {ReactElement} The supplied `component`.
12561 * @final
12562 * @protected
12563 */
12564 transferPropsTo: function(element) {
12565 ("production" !== "development" ? invariant(
12566 element._owner === this,
12567 '%s: You can\'t call transferPropsTo() on a component that you ' +
12568 'don\'t own, %s. This usually means you are calling ' +
12569 'transferPropsTo() on a component passed in as props or children.',
12570 this.constructor.displayName,
12571 typeof element.type === 'string' ?
12572 element.type :
12573 element.type.displayName
12574 ) : invariant(element._owner === this));
12575
12576 if ("production" !== "development") {
12577 if (!didWarn) {
12578 didWarn = true;
12579 ("production" !== "development" ? warning(
12580 false,
12581 'transferPropsTo is deprecated. ' +
12582 'See http://fb.me/react-transferpropsto for more information.'
12583 ) : null);
12584 }
12585 }
12586
12587 // Because elements are immutable we have to merge into the existing
12588 // props object rather than clone it.
12589 transferInto(element.props, this.props);
12590
12591 return element;
12592 }
12593
12594 }
12595};
12596
12597module.exports = ReactPropTransferer;
12598
12599},{"./Object.assign":27,"./emptyFunction":107,"./invariant":126,"./joinClasses":131,"./warning":145}],70:[function(_dereq_,module,exports){
12600/**
12601 * Copyright 2013-2014, Facebook, Inc.
12602 * All rights reserved.
12603 *
12604 * This source code is licensed under the BSD-style license found in the
12605 * LICENSE file in the root directory of this source tree. An additional grant
12606 * of patent rights can be found in the PATENTS file in the same directory.
12607 *
12608 * @providesModule ReactPropTypeLocationNames
12609 */
12610
12611"use strict";
12612
12613var ReactPropTypeLocationNames = {};
12614
12615if ("production" !== "development") {
12616 ReactPropTypeLocationNames = {
12617 prop: 'prop',
12618 context: 'context',
12619 childContext: 'child context'
12620 };
12621}
12622
12623module.exports = ReactPropTypeLocationNames;
12624
12625},{}],71:[function(_dereq_,module,exports){
12626/**
12627 * Copyright 2013-2014, Facebook, Inc.
12628 * All rights reserved.
12629 *
12630 * This source code is licensed under the BSD-style license found in the
12631 * LICENSE file in the root directory of this source tree. An additional grant
12632 * of patent rights can be found in the PATENTS file in the same directory.
12633 *
12634 * @providesModule ReactPropTypeLocations
12635 */
12636
12637"use strict";
12638
12639var keyMirror = _dereq_("./keyMirror");
12640
12641var ReactPropTypeLocations = keyMirror({
12642 prop: null,
12643 context: null,
12644 childContext: null
12645});
12646
12647module.exports = ReactPropTypeLocations;
12648
12649},{"./keyMirror":132}],72:[function(_dereq_,module,exports){
12650/**
12651 * Copyright 2013-2014, Facebook, Inc.
12652 * All rights reserved.
12653 *
12654 * This source code is licensed under the BSD-style license found in the
12655 * LICENSE file in the root directory of this source tree. An additional grant
12656 * of patent rights can be found in the PATENTS file in the same directory.
12657 *
12658 * @providesModule ReactPropTypes
12659 */
12660
12661"use strict";
12662
12663var ReactElement = _dereq_("./ReactElement");
12664var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
12665
12666var deprecated = _dereq_("./deprecated");
12667var emptyFunction = _dereq_("./emptyFunction");
12668
12669/**
12670 * Collection of methods that allow declaration and validation of props that are
12671 * supplied to React components. Example usage:
12672 *
12673 * var Props = require('ReactPropTypes');
12674 * var MyArticle = React.createClass({
12675 * propTypes: {
12676 * // An optional string prop named "description".
12677 * description: Props.string,
12678 *
12679 * // A required enum prop named "category".
12680 * category: Props.oneOf(['News','Photos']).isRequired,
12681 *
12682 * // A prop named "dialog" that requires an instance of Dialog.
12683 * dialog: Props.instanceOf(Dialog).isRequired
12684 * },
12685 * render: function() { ... }
12686 * });
12687 *
12688 * A more formal specification of how these methods are used:
12689 *
12690 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
12691 * decl := ReactPropTypes.{type}(.isRequired)?
12692 *
12693 * Each and every declaration produces a function with the same signature. This
12694 * allows the creation of custom validation functions. For example:
12695 *
12696 * var MyLink = React.createClass({
12697 * propTypes: {
12698 * // An optional string or URI prop named "href".
12699 * href: function(props, propName, componentName) {
12700 * var propValue = props[propName];
12701 * if (propValue != null && typeof propValue !== 'string' &&
12702 * !(propValue instanceof URI)) {
12703 * return new Error(
12704 * 'Expected a string or an URI for ' + propName + ' in ' +
12705 * componentName
12706 * );
12707 * }
12708 * }
12709 * },
12710 * render: function() {...}
12711 * });
12712 *
12713 * @internal
12714 */
12715
12716var ANONYMOUS = '<<anonymous>>';
12717
12718var elementTypeChecker = createElementTypeChecker();
12719var nodeTypeChecker = createNodeChecker();
12720
12721var ReactPropTypes = {
12722 array: createPrimitiveTypeChecker('array'),
12723 bool: createPrimitiveTypeChecker('boolean'),
12724 func: createPrimitiveTypeChecker('function'),
12725 number: createPrimitiveTypeChecker('number'),
12726 object: createPrimitiveTypeChecker('object'),
12727 string: createPrimitiveTypeChecker('string'),
12728
12729 any: createAnyTypeChecker(),
12730 arrayOf: createArrayOfTypeChecker,
12731 element: elementTypeChecker,
12732 instanceOf: createInstanceTypeChecker,
12733 node: nodeTypeChecker,
12734 objectOf: createObjectOfTypeChecker,
12735 oneOf: createEnumTypeChecker,
12736 oneOfType: createUnionTypeChecker,
12737 shape: createShapeTypeChecker,
12738
12739 component: deprecated(
12740 'React.PropTypes',
12741 'component',
12742 'element',
12743 this,
12744 elementTypeChecker
12745 ),
12746 renderable: deprecated(
12747 'React.PropTypes',
12748 'renderable',
12749 'node',
12750 this,
12751 nodeTypeChecker
12752 )
12753};
12754
12755function createChainableTypeChecker(validate) {
12756 function checkType(isRequired, props, propName, componentName, location) {
12757 componentName = componentName || ANONYMOUS;
12758 if (props[propName] == null) {
12759 var locationName = ReactPropTypeLocationNames[location];
12760 if (isRequired) {
12761 return new Error(
12762 ("Required " + locationName + " `" + propName + "` was not specified in ")+
12763 ("`" + componentName + "`.")
12764 );
12765 }
12766 } else {
12767 return validate(props, propName, componentName, location);
12768 }
12769 }
12770
12771 var chainedCheckType = checkType.bind(null, false);
12772 chainedCheckType.isRequired = checkType.bind(null, true);
12773
12774 return chainedCheckType;
12775}
12776
12777function createPrimitiveTypeChecker(expectedType) {
12778 function validate(props, propName, componentName, location) {
12779 var propValue = props[propName];
12780 var propType = getPropType(propValue);
12781 if (propType !== expectedType) {
12782 var locationName = ReactPropTypeLocationNames[location];
12783 // `propValue` being instance of, say, date/regexp, pass the 'object'
12784 // check, but we can offer a more precise error message here rather than
12785 // 'of type `object`'.
12786 var preciseType = getPreciseType(propValue);
12787
12788 return new Error(
12789 ("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
12790 ("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
12791 );
12792 }
12793 }
12794 return createChainableTypeChecker(validate);
12795}
12796
12797function createAnyTypeChecker() {
12798 return createChainableTypeChecker(emptyFunction.thatReturns());
12799}
12800
12801function createArrayOfTypeChecker(typeChecker) {
12802 function validate(props, propName, componentName, location) {
12803 var propValue = props[propName];
12804 if (!Array.isArray(propValue)) {
12805 var locationName = ReactPropTypeLocationNames[location];
12806 var propType = getPropType(propValue);
12807 return new Error(
12808 ("Invalid " + locationName + " `" + propName + "` of type ") +
12809 ("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
12810 );
12811 }
12812 for (var i = 0; i < propValue.length; i++) {
12813 var error = typeChecker(propValue, i, componentName, location);
12814 if (error instanceof Error) {
12815 return error;
12816 }
12817 }
12818 }
12819 return createChainableTypeChecker(validate);
12820}
12821
12822function createElementTypeChecker() {
12823 function validate(props, propName, componentName, location) {
12824 if (!ReactElement.isValidElement(props[propName])) {
12825 var locationName = ReactPropTypeLocationNames[location];
12826 return new Error(
12827 ("Invalid " + locationName + " `" + propName + "` supplied to ") +
12828 ("`" + componentName + "`, expected a ReactElement.")
12829 );
12830 }
12831 }
12832 return createChainableTypeChecker(validate);
12833}
12834
12835function createInstanceTypeChecker(expectedClass) {
12836 function validate(props, propName, componentName, location) {
12837 if (!(props[propName] instanceof expectedClass)) {
12838 var locationName = ReactPropTypeLocationNames[location];
12839 var expectedClassName = expectedClass.name || ANONYMOUS;
12840 return new Error(
12841 ("Invalid " + locationName + " `" + propName + "` supplied to ") +
12842 ("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
12843 );
12844 }
12845 }
12846 return createChainableTypeChecker(validate);
12847}
12848
12849function createEnumTypeChecker(expectedValues) {
12850 function validate(props, propName, componentName, location) {
12851 var propValue = props[propName];
12852 for (var i = 0; i < expectedValues.length; i++) {
12853 if (propValue === expectedValues[i]) {
12854 return;
12855 }
12856 }
12857
12858 var locationName = ReactPropTypeLocationNames[location];
12859 var valuesString = JSON.stringify(expectedValues);
12860 return new Error(
12861 ("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
12862 ("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
12863 );
12864 }
12865 return createChainableTypeChecker(validate);
12866}
12867
12868function createObjectOfTypeChecker(typeChecker) {
12869 function validate(props, propName, componentName, location) {
12870 var propValue = props[propName];
12871 var propType = getPropType(propValue);
12872 if (propType !== 'object') {
12873 var locationName = ReactPropTypeLocationNames[location];
12874 return new Error(
12875 ("Invalid " + locationName + " `" + propName + "` of type ") +
12876 ("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
12877 );
12878 }
12879 for (var key in propValue) {
12880 if (propValue.hasOwnProperty(key)) {
12881 var error = typeChecker(propValue, key, componentName, location);
12882 if (error instanceof Error) {
12883 return error;
12884 }
12885 }
12886 }
12887 }
12888 return createChainableTypeChecker(validate);
12889}
12890
12891function createUnionTypeChecker(arrayOfTypeCheckers) {
12892 function validate(props, propName, componentName, location) {
12893 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
12894 var checker = arrayOfTypeCheckers[i];
12895 if (checker(props, propName, componentName, location) == null) {
12896 return;
12897 }
12898 }
12899
12900 var locationName = ReactPropTypeLocationNames[location];
12901 return new Error(
12902 ("Invalid " + locationName + " `" + propName + "` supplied to ") +
12903 ("`" + componentName + "`.")
12904 );
12905 }
12906 return createChainableTypeChecker(validate);
12907}
12908
12909function createNodeChecker() {
12910 function validate(props, propName, componentName, location) {
12911 if (!isNode(props[propName])) {
12912 var locationName = ReactPropTypeLocationNames[location];
12913 return new Error(
12914 ("Invalid " + locationName + " `" + propName + "` supplied to ") +
12915 ("`" + componentName + "`, expected a ReactNode.")
12916 );
12917 }
12918 }
12919 return createChainableTypeChecker(validate);
12920}
12921
12922function createShapeTypeChecker(shapeTypes) {
12923 function validate(props, propName, componentName, location) {
12924 var propValue = props[propName];
12925 var propType = getPropType(propValue);
12926 if (propType !== 'object') {
12927 var locationName = ReactPropTypeLocationNames[location];
12928 return new Error(
12929 ("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
12930 ("supplied to `" + componentName + "`, expected `object`.")
12931 );
12932 }
12933 for (var key in shapeTypes) {
12934 var checker = shapeTypes[key];
12935 if (!checker) {
12936 continue;
12937 }
12938 var error = checker(propValue, key, componentName, location);
12939 if (error) {
12940 return error;
12941 }
12942 }
12943 }
12944 return createChainableTypeChecker(validate, 'expected `object`');
12945}
12946
12947function isNode(propValue) {
12948 switch(typeof propValue) {
12949 case 'number':
12950 case 'string':
12951 return true;
12952 case 'boolean':
12953 return !propValue;
12954 case 'object':
12955 if (Array.isArray(propValue)) {
12956 return propValue.every(isNode);
12957 }
12958 if (ReactElement.isValidElement(propValue)) {
12959 return true;
12960 }
12961 for (var k in propValue) {
12962 if (!isNode(propValue[k])) {
12963 return false;
12964 }
12965 }
12966 return true;
12967 default:
12968 return false;
12969 }
12970}
12971
12972// Equivalent of `typeof` but with special handling for array and regexp.
12973function getPropType(propValue) {
12974 var propType = typeof propValue;
12975 if (Array.isArray(propValue)) {
12976 return 'array';
12977 }
12978 if (propValue instanceof RegExp) {
12979 // Old webkits (at least until Android 4.0) return 'function' rather than
12980 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
12981 // passes PropTypes.object.
12982 return 'object';
12983 }
12984 return propType;
12985}
12986
12987// This handles more types than `getPropType`. Only used for error messages.
12988// See `createPrimitiveTypeChecker`.
12989function getPreciseType(propValue) {
12990 var propType = getPropType(propValue);
12991 if (propType === 'object') {
12992 if (propValue instanceof Date) {
12993 return 'date';
12994 } else if (propValue instanceof RegExp) {
12995 return 'regexp';
12996 }
12997 }
12998 return propType;
12999}
13000
13001module.exports = ReactPropTypes;
13002
13003},{"./ReactElement":52,"./ReactPropTypeLocationNames":70,"./deprecated":106,"./emptyFunction":107}],73:[function(_dereq_,module,exports){
13004/**
13005 * Copyright 2013-2014, Facebook, Inc.
13006 * All rights reserved.
13007 *
13008 * This source code is licensed under the BSD-style license found in the
13009 * LICENSE file in the root directory of this source tree. An additional grant
13010 * of patent rights can be found in the PATENTS file in the same directory.
13011 *
13012 * @providesModule ReactPutListenerQueue
13013 */
13014
13015"use strict";
13016
13017var PooledClass = _dereq_("./PooledClass");
13018var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
13019
13020var assign = _dereq_("./Object.assign");
13021
13022function ReactPutListenerQueue() {
13023 this.listenersToPut = [];
13024}
13025
13026assign(ReactPutListenerQueue.prototype, {
13027 enqueuePutListener: function(rootNodeID, propKey, propValue) {
13028 this.listenersToPut.push({
13029 rootNodeID: rootNodeID,
13030 propKey: propKey,
13031 propValue: propValue
13032 });
13033 },
13034
13035 putListeners: function() {
13036 for (var i = 0; i < this.listenersToPut.length; i++) {
13037 var listenerToPut = this.listenersToPut[i];
13038 ReactBrowserEventEmitter.putListener(
13039 listenerToPut.rootNodeID,
13040 listenerToPut.propKey,
13041 listenerToPut.propValue
13042 );
13043 }
13044 },
13045
13046 reset: function() {
13047 this.listenersToPut.length = 0;
13048 },
13049
13050 destructor: function() {
13051 this.reset();
13052 }
13053});
13054
13055PooledClass.addPoolingTo(ReactPutListenerQueue);
13056
13057module.exports = ReactPutListenerQueue;
13058
13059},{"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":30}],74:[function(_dereq_,module,exports){
13060/**
13061 * Copyright 2013-2014, Facebook, Inc.
13062 * All rights reserved.
13063 *
13064 * This source code is licensed under the BSD-style license found in the
13065 * LICENSE file in the root directory of this source tree. An additional grant
13066 * of patent rights can be found in the PATENTS file in the same directory.
13067 *
13068 * @providesModule ReactReconcileTransaction
13069 * @typechecks static-only
13070 */
13071
13072"use strict";
13073
13074var CallbackQueue = _dereq_("./CallbackQueue");
13075var PooledClass = _dereq_("./PooledClass");
13076var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
13077var ReactInputSelection = _dereq_("./ReactInputSelection");
13078var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
13079var Transaction = _dereq_("./Transaction");
13080
13081var assign = _dereq_("./Object.assign");
13082
13083/**
13084 * Ensures that, when possible, the selection range (currently selected text
13085 * input) is not disturbed by performing the transaction.
13086 */
13087var SELECTION_RESTORATION = {
13088 /**
13089 * @return {Selection} Selection information.
13090 */
13091 initialize: ReactInputSelection.getSelectionInformation,
13092 /**
13093 * @param {Selection} sel Selection information returned from `initialize`.
13094 */
13095 close: ReactInputSelection.restoreSelection
13096};
13097
13098/**
13099 * Suppresses events (blur/focus) that could be inadvertently dispatched due to
13100 * high level DOM manipulations (like temporarily removing a text input from the
13101 * DOM).
13102 */
13103var EVENT_SUPPRESSION = {
13104 /**
13105 * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
13106 * the reconciliation.
13107 */
13108 initialize: function() {
13109 var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
13110 ReactBrowserEventEmitter.setEnabled(false);
13111 return currentlyEnabled;
13112 },
13113
13114 /**
13115 * @param {boolean} previouslyEnabled Enabled status of
13116 * `ReactBrowserEventEmitter` before the reconciliation occured. `close`
13117 * restores the previous value.
13118 */
13119 close: function(previouslyEnabled) {
13120 ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
13121 }
13122};
13123
13124/**
13125 * Provides a queue for collecting `componentDidMount` and
13126 * `componentDidUpdate` callbacks during the the transaction.
13127 */
13128var ON_DOM_READY_QUEUEING = {
13129 /**
13130 * Initializes the internal `onDOMReady` queue.
13131 */
13132 initialize: function() {
13133 this.reactMountReady.reset();
13134 },
13135
13136 /**
13137 * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
13138 */
13139 close: function() {
13140 this.reactMountReady.notifyAll();
13141 }
13142};
13143
13144var PUT_LISTENER_QUEUEING = {
13145 initialize: function() {
13146 this.putListenerQueue.reset();
13147 },
13148
13149 close: function() {
13150 this.putListenerQueue.putListeners();
13151 }
13152};
13153
13154/**
13155 * Executed within the scope of the `Transaction` instance. Consider these as
13156 * being member methods, but with an implied ordering while being isolated from
13157 * each other.
13158 */
13159var TRANSACTION_WRAPPERS = [
13160 PUT_LISTENER_QUEUEING,
13161 SELECTION_RESTORATION,
13162 EVENT_SUPPRESSION,
13163 ON_DOM_READY_QUEUEING
13164];
13165
13166/**
13167 * Currently:
13168 * - The order that these are listed in the transaction is critical:
13169 * - Suppresses events.
13170 * - Restores selection range.
13171 *
13172 * Future:
13173 * - Restore document/overflow scroll positions that were unintentionally
13174 * modified via DOM insertions above the top viewport boundary.
13175 * - Implement/integrate with customized constraint based layout system and keep
13176 * track of which dimensions must be remeasured.
13177 *
13178 * @class ReactReconcileTransaction
13179 */
13180function ReactReconcileTransaction() {
13181 this.reinitializeTransaction();
13182 // Only server-side rendering really needs this option (see
13183 // `ReactServerRendering`), but server-side uses
13184 // `ReactServerRenderingTransaction` instead. This option is here so that it's
13185 // accessible and defaults to false when `ReactDOMComponent` and
13186 // `ReactTextComponent` checks it in `mountComponent`.`
13187 this.renderToStaticMarkup = false;
13188 this.reactMountReady = CallbackQueue.getPooled(null);
13189 this.putListenerQueue = ReactPutListenerQueue.getPooled();
13190}
13191
13192var Mixin = {
13193 /**
13194 * @see Transaction
13195 * @abstract
13196 * @final
13197 * @return {array<object>} List of operation wrap proceedures.
13198 * TODO: convert to array<TransactionWrapper>
13199 */
13200 getTransactionWrappers: function() {
13201 return TRANSACTION_WRAPPERS;
13202 },
13203
13204 /**
13205 * @return {object} The queue to collect `onDOMReady` callbacks with.
13206 */
13207 getReactMountReady: function() {
13208 return this.reactMountReady;
13209 },
13210
13211 getPutListenerQueue: function() {
13212 return this.putListenerQueue;
13213 },
13214
13215 /**
13216 * `PooledClass` looks for this, and will invoke this before allowing this
13217 * instance to be resused.
13218 */
13219 destructor: function() {
13220 CallbackQueue.release(this.reactMountReady);
13221 this.reactMountReady = null;
13222
13223 ReactPutListenerQueue.release(this.putListenerQueue);
13224 this.putListenerQueue = null;
13225 }
13226};
13227
13228
13229assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
13230
13231PooledClass.addPoolingTo(ReactReconcileTransaction);
13232
13233module.exports = ReactReconcileTransaction;
13234
13235},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":30,"./ReactInputSelection":59,"./ReactPutListenerQueue":73,"./Transaction":95}],75:[function(_dereq_,module,exports){
13236/**
13237 * Copyright 2013-2014, Facebook, Inc.
13238 * All rights reserved.
13239 *
13240 * This source code is licensed under the BSD-style license found in the
13241 * LICENSE file in the root directory of this source tree. An additional grant
13242 * of patent rights can be found in the PATENTS file in the same directory.
13243 *
13244 * @providesModule ReactRootIndex
13245 * @typechecks
13246 */
13247
13248"use strict";
13249
13250var ReactRootIndexInjection = {
13251 /**
13252 * @param {function} _createReactRootIndex
13253 */
13254 injectCreateReactRootIndex: function(_createReactRootIndex) {
13255 ReactRootIndex.createReactRootIndex = _createReactRootIndex;
13256 }
13257};
13258
13259var ReactRootIndex = {
13260 createReactRootIndex: null,
13261 injection: ReactRootIndexInjection
13262};
13263
13264module.exports = ReactRootIndex;
13265
13266},{}],76:[function(_dereq_,module,exports){
13267/**
13268 * Copyright 2013-2014, Facebook, Inc.
13269 * All rights reserved.
13270 *
13271 * This source code is licensed under the BSD-style license found in the
13272 * LICENSE file in the root directory of this source tree. An additional grant
13273 * of patent rights can be found in the PATENTS file in the same directory.
13274 *
13275 * @typechecks static-only
13276 * @providesModule ReactServerRendering
13277 */
13278"use strict";
13279
13280var ReactElement = _dereq_("./ReactElement");
13281var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
13282var ReactMarkupChecksum = _dereq_("./ReactMarkupChecksum");
13283var ReactServerRenderingTransaction =
13284 _dereq_("./ReactServerRenderingTransaction");
13285
13286var instantiateReactComponent = _dereq_("./instantiateReactComponent");
13287var invariant = _dereq_("./invariant");
13288
13289/**
13290 * @param {ReactElement} element
13291 * @return {string} the HTML markup
13292 */
13293function renderToString(element) {
13294 ("production" !== "development" ? invariant(
13295 ReactElement.isValidElement(element),
13296 'renderToString(): You must pass a valid ReactElement.'
13297 ) : invariant(ReactElement.isValidElement(element)));
13298
13299 var transaction;
13300 try {
13301 var id = ReactInstanceHandles.createReactRootID();
13302 transaction = ReactServerRenderingTransaction.getPooled(false);
13303
13304 return transaction.perform(function() {
13305 var componentInstance = instantiateReactComponent(element, null);
13306 var markup = componentInstance.mountComponent(id, transaction, 0);
13307 return ReactMarkupChecksum.addChecksumToMarkup(markup);
13308 }, null);
13309 } finally {
13310 ReactServerRenderingTransaction.release(transaction);
13311 }
13312}
13313
13314/**
13315 * @param {ReactElement} element
13316 * @return {string} the HTML markup, without the extra React ID and checksum
13317 * (for generating static pages)
13318 */
13319function renderToStaticMarkup(element) {
13320 ("production" !== "development" ? invariant(
13321 ReactElement.isValidElement(element),
13322 'renderToStaticMarkup(): You must pass a valid ReactElement.'
13323 ) : invariant(ReactElement.isValidElement(element)));
13324
13325 var transaction;
13326 try {
13327 var id = ReactInstanceHandles.createReactRootID();
13328 transaction = ReactServerRenderingTransaction.getPooled(true);
13329
13330 return transaction.perform(function() {
13331 var componentInstance = instantiateReactComponent(element, null);
13332 return componentInstance.mountComponent(id, transaction, 0);
13333 }, null);
13334 } finally {
13335 ReactServerRenderingTransaction.release(transaction);
13336 }
13337}
13338
13339module.exports = {
13340 renderToString: renderToString,
13341 renderToStaticMarkup: renderToStaticMarkup
13342};
13343
13344},{"./ReactElement":52,"./ReactInstanceHandles":60,"./ReactMarkupChecksum":62,"./ReactServerRenderingTransaction":77,"./instantiateReactComponent":125,"./invariant":126}],77:[function(_dereq_,module,exports){
13345/**
13346 * Copyright 2014, Facebook, Inc.
13347 * All rights reserved.
13348 *
13349 * This source code is licensed under the BSD-style license found in the
13350 * LICENSE file in the root directory of this source tree. An additional grant
13351 * of patent rights can be found in the PATENTS file in the same directory.
13352 *
13353 * @providesModule ReactServerRenderingTransaction
13354 * @typechecks
13355 */
13356
13357"use strict";
13358
13359var PooledClass = _dereq_("./PooledClass");
13360var CallbackQueue = _dereq_("./CallbackQueue");
13361var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
13362var Transaction = _dereq_("./Transaction");
13363
13364var assign = _dereq_("./Object.assign");
13365var emptyFunction = _dereq_("./emptyFunction");
13366
13367/**
13368 * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
13369 * during the performing of the transaction.
13370 */
13371var ON_DOM_READY_QUEUEING = {
13372 /**
13373 * Initializes the internal `onDOMReady` queue.
13374 */
13375 initialize: function() {
13376 this.reactMountReady.reset();
13377 },
13378
13379 close: emptyFunction
13380};
13381
13382var PUT_LISTENER_QUEUEING = {
13383 initialize: function() {
13384 this.putListenerQueue.reset();
13385 },
13386
13387 close: emptyFunction
13388};
13389
13390/**
13391 * Executed within the scope of the `Transaction` instance. Consider these as
13392 * being member methods, but with an implied ordering while being isolated from
13393 * each other.
13394 */
13395var TRANSACTION_WRAPPERS = [
13396 PUT_LISTENER_QUEUEING,
13397 ON_DOM_READY_QUEUEING
13398];
13399
13400/**
13401 * @class ReactServerRenderingTransaction
13402 * @param {boolean} renderToStaticMarkup
13403 */
13404function ReactServerRenderingTransaction(renderToStaticMarkup) {
13405 this.reinitializeTransaction();
13406 this.renderToStaticMarkup = renderToStaticMarkup;
13407 this.reactMountReady = CallbackQueue.getPooled(null);
13408 this.putListenerQueue = ReactPutListenerQueue.getPooled();
13409}
13410
13411var Mixin = {
13412 /**
13413 * @see Transaction
13414 * @abstract
13415 * @final
13416 * @return {array} Empty list of operation wrap proceedures.
13417 */
13418 getTransactionWrappers: function() {
13419 return TRANSACTION_WRAPPERS;
13420 },
13421
13422 /**
13423 * @return {object} The queue to collect `onDOMReady` callbacks with.
13424 */
13425 getReactMountReady: function() {
13426 return this.reactMountReady;
13427 },
13428
13429 getPutListenerQueue: function() {
13430 return this.putListenerQueue;
13431 },
13432
13433 /**
13434 * `PooledClass` looks for this, and will invoke this before allowing this
13435 * instance to be resused.
13436 */
13437 destructor: function() {
13438 CallbackQueue.release(this.reactMountReady);
13439 this.reactMountReady = null;
13440
13441 ReactPutListenerQueue.release(this.putListenerQueue);
13442 this.putListenerQueue = null;
13443 }
13444};
13445
13446
13447assign(
13448 ReactServerRenderingTransaction.prototype,
13449 Transaction.Mixin,
13450 Mixin
13451);
13452
13453PooledClass.addPoolingTo(ReactServerRenderingTransaction);
13454
13455module.exports = ReactServerRenderingTransaction;
13456
13457},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactPutListenerQueue":73,"./Transaction":95,"./emptyFunction":107}],78:[function(_dereq_,module,exports){
13458/**
13459 * Copyright 2013-2014, Facebook, Inc.
13460 * All rights reserved.
13461 *
13462 * This source code is licensed under the BSD-style license found in the
13463 * LICENSE file in the root directory of this source tree. An additional grant
13464 * of patent rights can be found in the PATENTS file in the same directory.
13465 *
13466 * @providesModule ReactTextComponent
13467 * @typechecks static-only
13468 */
13469
13470"use strict";
13471
13472var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
13473var ReactComponent = _dereq_("./ReactComponent");
13474var ReactElement = _dereq_("./ReactElement");
13475
13476var assign = _dereq_("./Object.assign");
13477var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
13478
13479/**
13480 * Text nodes violate a couple assumptions that React makes about components:
13481 *
13482 * - When mounting text into the DOM, adjacent text nodes are merged.
13483 * - Text nodes cannot be assigned a React root ID.
13484 *
13485 * This component is used to wrap strings in elements so that they can undergo
13486 * the same reconciliation that is applied to elements.
13487 *
13488 * TODO: Investigate representing React components in the DOM with text nodes.
13489 *
13490 * @class ReactTextComponent
13491 * @extends ReactComponent
13492 * @internal
13493 */
13494var ReactTextComponent = function(props) {
13495 // This constructor and it's argument is currently used by mocks.
13496};
13497
13498assign(ReactTextComponent.prototype, ReactComponent.Mixin, {
13499
13500 /**
13501 * Creates the markup for this text node. This node is not intended to have
13502 * any features besides containing text content.
13503 *
13504 * @param {string} rootID DOM ID of the root node.
13505 * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
13506 * @param {number} mountDepth number of components in the owner hierarchy
13507 * @return {string} Markup for this text node.
13508 * @internal
13509 */
13510 mountComponent: function(rootID, transaction, mountDepth) {
13511 ReactComponent.Mixin.mountComponent.call(
13512 this,
13513 rootID,
13514 transaction,
13515 mountDepth
13516 );
13517
13518 var escapedText = escapeTextForBrowser(this.props);
13519
13520 if (transaction.renderToStaticMarkup) {
13521 // Normally we'd wrap this in a `span` for the reasons stated above, but
13522 // since this is a situation where React won't take over (static pages),
13523 // we can simply return the text as it is.
13524 return escapedText;
13525 }
13526
13527 return (
13528 '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
13529 escapedText +
13530 '</span>'
13531 );
13532 },
13533
13534 /**
13535 * Updates this component by updating the text content.
13536 *
13537 * @param {object} nextComponent Contains the next text content.
13538 * @param {ReactReconcileTransaction} transaction
13539 * @internal
13540 */
13541 receiveComponent: function(nextComponent, transaction) {
13542 var nextProps = nextComponent.props;
13543 if (nextProps !== this.props) {
13544 this.props = nextProps;
13545 ReactComponent.BackendIDOperations.updateTextContentByID(
13546 this._rootNodeID,
13547 nextProps
13548 );
13549 }
13550 }
13551
13552});
13553
13554var ReactTextComponentFactory = function(text) {
13555 // Bypass validation and configuration
13556 return new ReactElement(ReactTextComponent, null, null, null, null, text);
13557};
13558
13559ReactTextComponentFactory.type = ReactTextComponent;
13560
13561module.exports = ReactTextComponentFactory;
13562
13563},{"./DOMPropertyOperations":12,"./Object.assign":27,"./ReactComponent":32,"./ReactElement":52,"./escapeTextForBrowser":109}],79:[function(_dereq_,module,exports){
13564/**
13565 * Copyright 2013-2014, Facebook, Inc.
13566 * All rights reserved.
13567 *
13568 * This source code is licensed under the BSD-style license found in the
13569 * LICENSE file in the root directory of this source tree. An additional grant
13570 * of patent rights can be found in the PATENTS file in the same directory.
13571 *
13572 * @providesModule ReactUpdates
13573 */
13574
13575"use strict";
13576
13577var CallbackQueue = _dereq_("./CallbackQueue");
13578var PooledClass = _dereq_("./PooledClass");
13579var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
13580var ReactPerf = _dereq_("./ReactPerf");
13581var Transaction = _dereq_("./Transaction");
13582
13583var assign = _dereq_("./Object.assign");
13584var invariant = _dereq_("./invariant");
13585var warning = _dereq_("./warning");
13586
13587var dirtyComponents = [];
13588var asapCallbackQueue = CallbackQueue.getPooled();
13589var asapEnqueued = false;
13590
13591var batchingStrategy = null;
13592
13593function ensureInjected() {
13594 ("production" !== "development" ? invariant(
13595 ReactUpdates.ReactReconcileTransaction && batchingStrategy,
13596 'ReactUpdates: must inject a reconcile transaction class and batching ' +
13597 'strategy'
13598 ) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
13599}
13600
13601var NESTED_UPDATES = {
13602 initialize: function() {
13603 this.dirtyComponentsLength = dirtyComponents.length;
13604 },
13605 close: function() {
13606 if (this.dirtyComponentsLength !== dirtyComponents.length) {
13607 // Additional updates were enqueued by componentDidUpdate handlers or
13608 // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
13609 // these new updates so that if A's componentDidUpdate calls setState on
13610 // B, B will update before the callback A's updater provided when calling
13611 // setState.
13612 dirtyComponents.splice(0, this.dirtyComponentsLength);
13613 flushBatchedUpdates();
13614 } else {
13615 dirtyComponents.length = 0;
13616 }
13617 }
13618};
13619
13620var UPDATE_QUEUEING = {
13621 initialize: function() {
13622 this.callbackQueue.reset();
13623 },
13624 close: function() {
13625 this.callbackQueue.notifyAll();
13626 }
13627};
13628
13629var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
13630
13631function ReactUpdatesFlushTransaction() {
13632 this.reinitializeTransaction();
13633 this.dirtyComponentsLength = null;
13634 this.callbackQueue = CallbackQueue.getPooled();
13635 this.reconcileTransaction =
13636 ReactUpdates.ReactReconcileTransaction.getPooled();
13637}
13638
13639assign(
13640 ReactUpdatesFlushTransaction.prototype,
13641 Transaction.Mixin, {
13642 getTransactionWrappers: function() {
13643 return TRANSACTION_WRAPPERS;
13644 },
13645
13646 destructor: function() {
13647 this.dirtyComponentsLength = null;
13648 CallbackQueue.release(this.callbackQueue);
13649 this.callbackQueue = null;
13650 ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
13651 this.reconcileTransaction = null;
13652 },
13653
13654 perform: function(method, scope, a) {
13655 // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
13656 // with this transaction's wrappers around it.
13657 return Transaction.Mixin.perform.call(
13658 this,
13659 this.reconcileTransaction.perform,
13660 this.reconcileTransaction,
13661 method,
13662 scope,
13663 a
13664 );
13665 }
13666});
13667
13668PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
13669
13670function batchedUpdates(callback, a, b) {
13671 ensureInjected();
13672 batchingStrategy.batchedUpdates(callback, a, b);
13673}
13674
13675/**
13676 * Array comparator for ReactComponents by owner depth
13677 *
13678 * @param {ReactComponent} c1 first component you're comparing
13679 * @param {ReactComponent} c2 second component you're comparing
13680 * @return {number} Return value usable by Array.prototype.sort().
13681 */
13682function mountDepthComparator(c1, c2) {
13683 return c1._mountDepth - c2._mountDepth;
13684}
13685
13686function runBatchedUpdates(transaction) {
13687 var len = transaction.dirtyComponentsLength;
13688 ("production" !== "development" ? invariant(
13689 len === dirtyComponents.length,
13690 'Expected flush transaction\'s stored dirty-components length (%s) to ' +
13691 'match dirty-components array length (%s).',
13692 len,
13693 dirtyComponents.length
13694 ) : invariant(len === dirtyComponents.length));
13695
13696 // Since reconciling a component higher in the owner hierarchy usually (not
13697 // always -- see shouldComponentUpdate()) will reconcile children, reconcile
13698 // them before their children by sorting the array.
13699 dirtyComponents.sort(mountDepthComparator);
13700
13701 for (var i = 0; i < len; i++) {
13702 // If a component is unmounted before pending changes apply, ignore them
13703 // TODO: Queue unmounts in the same list to avoid this happening at all
13704 var component = dirtyComponents[i];
13705 if (component.isMounted()) {
13706 // If performUpdateIfNecessary happens to enqueue any new updates, we
13707 // shouldn't execute the callbacks until the next render happens, so
13708 // stash the callbacks first
13709 var callbacks = component._pendingCallbacks;
13710 component._pendingCallbacks = null;
13711 component.performUpdateIfNecessary(transaction.reconcileTransaction);
13712
13713 if (callbacks) {
13714 for (var j = 0; j < callbacks.length; j++) {
13715 transaction.callbackQueue.enqueue(
13716 callbacks[j],
13717 component
13718 );
13719 }
13720 }
13721 }
13722 }
13723}
13724
13725var flushBatchedUpdates = ReactPerf.measure(
13726 'ReactUpdates',
13727 'flushBatchedUpdates',
13728 function() {
13729 // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
13730 // array and perform any updates enqueued by mount-ready handlers (i.e.,
13731 // componentDidUpdate) but we need to check here too in order to catch
13732 // updates enqueued by setState callbacks and asap calls.
13733 while (dirtyComponents.length || asapEnqueued) {
13734 if (dirtyComponents.length) {
13735 var transaction = ReactUpdatesFlushTransaction.getPooled();
13736 transaction.perform(runBatchedUpdates, null, transaction);
13737 ReactUpdatesFlushTransaction.release(transaction);
13738 }
13739
13740 if (asapEnqueued) {
13741 asapEnqueued = false;
13742 var queue = asapCallbackQueue;
13743 asapCallbackQueue = CallbackQueue.getPooled();
13744 queue.notifyAll();
13745 CallbackQueue.release(queue);
13746 }
13747 }
13748 }
13749);
13750
13751/**
13752 * Mark a component as needing a rerender, adding an optional callback to a
13753 * list of functions which will be executed once the rerender occurs.
13754 */
13755function enqueueUpdate(component, callback) {
13756 ("production" !== "development" ? invariant(
13757 !callback || typeof callback === "function",
13758 'enqueueUpdate(...): You called `setProps`, `replaceProps`, ' +
13759 '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
13760 'isn\'t callable.'
13761 ) : invariant(!callback || typeof callback === "function"));
13762 ensureInjected();
13763
13764 // Various parts of our code (such as ReactCompositeComponent's
13765 // _renderValidatedComponent) assume that calls to render aren't nested;
13766 // verify that that's the case. (This is called by each top-level update
13767 // function, like setProps, setState, forceUpdate, etc.; creation and
13768 // destruction of top-level components is guarded in ReactMount.)
13769 ("production" !== "development" ? warning(
13770 ReactCurrentOwner.current == null,
13771 'enqueueUpdate(): Render methods should be a pure function of props ' +
13772 'and state; triggering nested component updates from render is not ' +
13773 'allowed. If necessary, trigger nested updates in ' +
13774 'componentDidUpdate.'
13775 ) : null);
13776
13777 if (!batchingStrategy.isBatchingUpdates) {
13778 batchingStrategy.batchedUpdates(enqueueUpdate, component, callback);
13779 return;
13780 }
13781
13782 dirtyComponents.push(component);
13783
13784 if (callback) {
13785 if (component._pendingCallbacks) {
13786 component._pendingCallbacks.push(callback);
13787 } else {
13788 component._pendingCallbacks = [callback];
13789 }
13790 }
13791}
13792
13793/**
13794 * Enqueue a callback to be run at the end of the current batching cycle. Throws
13795 * if no updates are currently being performed.
13796 */
13797function asap(callback, context) {
13798 ("production" !== "development" ? invariant(
13799 batchingStrategy.isBatchingUpdates,
13800 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
13801 'updates are not being batched.'
13802 ) : invariant(batchingStrategy.isBatchingUpdates));
13803 asapCallbackQueue.enqueue(callback, context);
13804 asapEnqueued = true;
13805}
13806
13807var ReactUpdatesInjection = {
13808 injectReconcileTransaction: function(ReconcileTransaction) {
13809 ("production" !== "development" ? invariant(
13810 ReconcileTransaction,
13811 'ReactUpdates: must provide a reconcile transaction class'
13812 ) : invariant(ReconcileTransaction));
13813 ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
13814 },
13815
13816 injectBatchingStrategy: function(_batchingStrategy) {
13817 ("production" !== "development" ? invariant(
13818 _batchingStrategy,
13819 'ReactUpdates: must provide a batching strategy'
13820 ) : invariant(_batchingStrategy));
13821 ("production" !== "development" ? invariant(
13822 typeof _batchingStrategy.batchedUpdates === 'function',
13823 'ReactUpdates: must provide a batchedUpdates() function'
13824 ) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
13825 ("production" !== "development" ? invariant(
13826 typeof _batchingStrategy.isBatchingUpdates === 'boolean',
13827 'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
13828 ) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
13829 batchingStrategy = _batchingStrategy;
13830 }
13831};
13832
13833var ReactUpdates = {
13834 /**
13835 * React references `ReactReconcileTransaction` using this property in order
13836 * to allow dependency injection.
13837 *
13838 * @internal
13839 */
13840 ReactReconcileTransaction: null,
13841
13842 batchedUpdates: batchedUpdates,
13843 enqueueUpdate: enqueueUpdate,
13844 flushBatchedUpdates: flushBatchedUpdates,
13845 injection: ReactUpdatesInjection,
13846 asap: asap
13847};
13848
13849module.exports = ReactUpdates;
13850
13851},{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactCurrentOwner":36,"./ReactPerf":68,"./Transaction":95,"./invariant":126,"./warning":145}],80:[function(_dereq_,module,exports){
13852/**
13853 * Copyright 2013-2014, Facebook, Inc.
13854 * All rights reserved.
13855 *
13856 * This source code is licensed under the BSD-style license found in the
13857 * LICENSE file in the root directory of this source tree. An additional grant
13858 * of patent rights can be found in the PATENTS file in the same directory.
13859 *
13860 * @providesModule SVGDOMPropertyConfig
13861 */
13862
13863/*jslint bitwise: true*/
13864
13865"use strict";
13866
13867var DOMProperty = _dereq_("./DOMProperty");
13868
13869var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
13870
13871var SVGDOMPropertyConfig = {
13872 Properties: {
13873 clipPath: MUST_USE_ATTRIBUTE,
13874 cx: MUST_USE_ATTRIBUTE,
13875 cy: MUST_USE_ATTRIBUTE,
13876 d: MUST_USE_ATTRIBUTE,
13877 dx: MUST_USE_ATTRIBUTE,
13878 dy: MUST_USE_ATTRIBUTE,
13879 fill: MUST_USE_ATTRIBUTE,
13880 fillOpacity: MUST_USE_ATTRIBUTE,
13881 filter: MUST_USE_ATTRIBUTE,
13882 fontFamily: MUST_USE_ATTRIBUTE,
13883 fontSize: MUST_USE_ATTRIBUTE,
13884 fontWeight: MUST_USE_ATTRIBUTE,
13885 fx: MUST_USE_ATTRIBUTE,
13886 fy: MUST_USE_ATTRIBUTE,
13887 gradientTransform: MUST_USE_ATTRIBUTE,
13888 gradientUnits: MUST_USE_ATTRIBUTE,
13889 k2: MUST_USE_ATTRIBUTE,
13890 k3: MUST_USE_ATTRIBUTE,
13891 in: MUST_USE_ATTRIBUTE,
13892 in2: MUST_USE_ATTRIBUTE,
13893 operator: MUST_USE_ATTRIBUTE,
13894 floodColor: MUST_USE_ATTRIBUTE,
13895 floodOpacity: MUST_USE_ATTRIBUTE,
13896 stdDeviation: MUST_USE_ATTRIBUTE,
13897 result: MUST_USE_ATTRIBUTE,
13898 out: MUST_USE_ATTRIBUTE,
13899 markerEnd: MUST_USE_ATTRIBUTE,
13900 markerMid: MUST_USE_ATTRIBUTE,
13901 markerStart: MUST_USE_ATTRIBUTE,
13902 mask: MUST_USE_ATTRIBUTE,
13903 offset: MUST_USE_ATTRIBUTE,
13904 opacity: MUST_USE_ATTRIBUTE,
13905 patternContentUnits: MUST_USE_ATTRIBUTE,
13906 patternUnits: MUST_USE_ATTRIBUTE,
13907 points: MUST_USE_ATTRIBUTE,
13908 preserveAspectRatio: MUST_USE_ATTRIBUTE,
13909 r: MUST_USE_ATTRIBUTE,
13910 rx: MUST_USE_ATTRIBUTE,
13911 ry: MUST_USE_ATTRIBUTE,
13912 spreadMethod: MUST_USE_ATTRIBUTE,
13913 stopColor: MUST_USE_ATTRIBUTE,
13914 stopOpacity: MUST_USE_ATTRIBUTE,
13915 stroke: MUST_USE_ATTRIBUTE,
13916 strokeDasharray: MUST_USE_ATTRIBUTE,
13917 strokeLinecap: MUST_USE_ATTRIBUTE,
13918 strokeOpacity: MUST_USE_ATTRIBUTE,
13919 strokeWidth: MUST_USE_ATTRIBUTE,
13920 textAnchor: MUST_USE_ATTRIBUTE,
13921 transform: MUST_USE_ATTRIBUTE,
13922 values: MUST_USE_ATTRIBUTE,
13923 version: MUST_USE_ATTRIBUTE,
13924 viewBox: MUST_USE_ATTRIBUTE,
13925 'xlink:href': MUST_USE_ATTRIBUTE,
13926 x0: MUST_USE_ATTRIBUTE,
13927 y0: MUST_USE_ATTRIBUTE,
13928 x1: MUST_USE_ATTRIBUTE,
13929 x2: MUST_USE_ATTRIBUTE,
13930 x: MUST_USE_ATTRIBUTE,
13931 y1: MUST_USE_ATTRIBUTE,
13932 y2: MUST_USE_ATTRIBUTE,
13933 y: MUST_USE_ATTRIBUTE
13934 },
13935 DOMAttributeNames: {
13936 fillOpacity: 'fill-opacity',
13937 fontFamily: 'font-family',
13938 fontSize: 'font-size',
13939 gradientTransform: 'gradientTransform',
13940 gradientUnits: 'gradientUnits',
13941 markerEnd: 'marker-end',
13942 markerMid: 'marker-mid',
13943 markerStart: 'marker-start',
13944 patternContentUnits: 'patternContentUnits',
13945 patternUnits: 'patternUnits',
13946 preserveAspectRatio: 'preserveAspectRatio',
13947 spreadMethod: 'spreadMethod',
13948 stopColor: 'stop-color',
13949 stopOpacity: 'stop-opacity',
13950 strokeDasharray: 'stroke-dasharray',
13951 strokeLinecap: 'stroke-linecap',
13952 strokeOpacity: 'stroke-opacity',
13953 strokeWidth: 'stroke-width',
13954 textAnchor: 'text-anchor',
13955 viewBox: 'viewBox'
13956 }
13957};
13958
13959module.exports = SVGDOMPropertyConfig;
13960
13961},{"./DOMProperty":11}],81:[function(_dereq_,module,exports){
13962/**
13963 * Copyright 2013-2014, Facebook, Inc.
13964 * All rights reserved.
13965 *
13966 * This source code is licensed under the BSD-style license found in the
13967 * LICENSE file in the root directory of this source tree. An additional grant
13968 * of patent rights can be found in the PATENTS file in the same directory.
13969 *
13970 * @providesModule SelectEventPlugin
13971 */
13972
13973"use strict";
13974
13975var EventConstants = _dereq_("./EventConstants");
13976var EventPropagators = _dereq_("./EventPropagators");
13977var ReactInputSelection = _dereq_("./ReactInputSelection");
13978var SyntheticEvent = _dereq_("./SyntheticEvent");
13979
13980var getActiveElement = _dereq_("./getActiveElement");
13981var isTextInputElement = _dereq_("./isTextInputElement");
13982var keyOf = _dereq_("./keyOf");
13983var shallowEqual = _dereq_("./shallowEqual");
13984
13985var topLevelTypes = EventConstants.topLevelTypes;
13986
13987var eventTypes = {
13988 select: {
13989 phasedRegistrationNames: {
13990 bubbled: keyOf({onSelect: null}),
13991 captured: keyOf({onSelectCapture: null})
13992 },
13993 dependencies: [
13994 topLevelTypes.topBlur,
13995 topLevelTypes.topContextMenu,
13996 topLevelTypes.topFocus,
13997 topLevelTypes.topKeyDown,
13998 topLevelTypes.topMouseDown,
13999 topLevelTypes.topMouseUp,
14000 topLevelTypes.topSelectionChange
14001 ]
14002 }
14003};
14004
14005var activeElement = null;
14006var activeElementID = null;
14007var lastSelection = null;
14008var mouseDown = false;
14009
14010/**
14011 * Get an object which is a unique representation of the current selection.
14012 *
14013 * The return value will not be consistent across nodes or browsers, but
14014 * two identical selections on the same node will return identical objects.
14015 *
14016 * @param {DOMElement} node
14017 * @param {object}
14018 */
14019function getSelection(node) {
14020 if ('selectionStart' in node &&
14021 ReactInputSelection.hasSelectionCapabilities(node)) {
14022 return {
14023 start: node.selectionStart,
14024 end: node.selectionEnd
14025 };
14026 } else if (window.getSelection) {
14027 var selection = window.getSelection();
14028 return {
14029 anchorNode: selection.anchorNode,
14030 anchorOffset: selection.anchorOffset,
14031 focusNode: selection.focusNode,
14032 focusOffset: selection.focusOffset
14033 };
14034 } else if (document.selection) {
14035 var range = document.selection.createRange();
14036 return {
14037 parentElement: range.parentElement(),
14038 text: range.text,
14039 top: range.boundingTop,
14040 left: range.boundingLeft
14041 };
14042 }
14043}
14044
14045/**
14046 * Poll selection to see whether it's changed.
14047 *
14048 * @param {object} nativeEvent
14049 * @return {?SyntheticEvent}
14050 */
14051function constructSelectEvent(nativeEvent) {
14052 // Ensure we have the right element, and that the user is not dragging a
14053 // selection (this matches native `select` event behavior). In HTML5, select
14054 // fires only on input and textarea thus if there's no focused element we
14055 // won't dispatch.
14056 if (mouseDown ||
14057 activeElement == null ||
14058 activeElement != getActiveElement()) {
14059 return;
14060 }
14061
14062 // Only fire when selection has actually changed.
14063 var currentSelection = getSelection(activeElement);
14064 if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
14065 lastSelection = currentSelection;
14066
14067 var syntheticEvent = SyntheticEvent.getPooled(
14068 eventTypes.select,
14069 activeElementID,
14070 nativeEvent
14071 );
14072
14073 syntheticEvent.type = 'select';
14074 syntheticEvent.target = activeElement;
14075
14076 EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
14077
14078 return syntheticEvent;
14079 }
14080}
14081
14082/**
14083 * This plugin creates an `onSelect` event that normalizes select events
14084 * across form elements.
14085 *
14086 * Supported elements are:
14087 * - input (see `isTextInputElement`)
14088 * - textarea
14089 * - contentEditable
14090 *
14091 * This differs from native browser implementations in the following ways:
14092 * - Fires on contentEditable fields as well as inputs.
14093 * - Fires for collapsed selection.
14094 * - Fires after user input.
14095 */
14096var SelectEventPlugin = {
14097
14098 eventTypes: eventTypes,
14099
14100 /**
14101 * @param {string} topLevelType Record from `EventConstants`.
14102 * @param {DOMEventTarget} topLevelTarget The listening component root node.
14103 * @param {string} topLevelTargetID ID of `topLevelTarget`.
14104 * @param {object} nativeEvent Native browser event.
14105 * @return {*} An accumulation of synthetic events.
14106 * @see {EventPluginHub.extractEvents}
14107 */
14108 extractEvents: function(
14109 topLevelType,
14110 topLevelTarget,
14111 topLevelTargetID,
14112 nativeEvent) {
14113
14114 switch (topLevelType) {
14115 // Track the input node that has focus.
14116 case topLevelTypes.topFocus:
14117 if (isTextInputElement(topLevelTarget) ||
14118 topLevelTarget.contentEditable === 'true') {
14119 activeElement = topLevelTarget;
14120 activeElementID = topLevelTargetID;
14121 lastSelection = null;
14122 }
14123 break;
14124 case topLevelTypes.topBlur:
14125 activeElement = null;
14126 activeElementID = null;
14127 lastSelection = null;
14128 break;
14129
14130 // Don't fire the event while the user is dragging. This matches the
14131 // semantics of the native select event.
14132 case topLevelTypes.topMouseDown:
14133 mouseDown = true;
14134 break;
14135 case topLevelTypes.topContextMenu:
14136 case topLevelTypes.topMouseUp:
14137 mouseDown = false;
14138 return constructSelectEvent(nativeEvent);
14139
14140 // Chrome and IE fire non-standard event when selection is changed (and
14141 // sometimes when it hasn't).
14142 // Firefox doesn't support selectionchange, so check selection status
14143 // after each key entry. The selection changes after keydown and before
14144 // keyup, but we check on keydown as well in the case of holding down a
14145 // key, when multiple keydown events are fired but only one keyup is.
14146 case topLevelTypes.topSelectionChange:
14147 case topLevelTypes.topKeyDown:
14148 case topLevelTypes.topKeyUp:
14149 return constructSelectEvent(nativeEvent);
14150 }
14151 }
14152};
14153
14154module.exports = SelectEventPlugin;
14155
14156},{"./EventConstants":16,"./EventPropagators":21,"./ReactInputSelection":59,"./SyntheticEvent":87,"./getActiveElement":113,"./isTextInputElement":129,"./keyOf":133,"./shallowEqual":141}],82:[function(_dereq_,module,exports){
14157/**
14158 * Copyright 2013-2014, Facebook, Inc.
14159 * All rights reserved.
14160 *
14161 * This source code is licensed under the BSD-style license found in the
14162 * LICENSE file in the root directory of this source tree. An additional grant
14163 * of patent rights can be found in the PATENTS file in the same directory.
14164 *
14165 * @providesModule ServerReactRootIndex
14166 * @typechecks
14167 */
14168
14169"use strict";
14170
14171/**
14172 * Size of the reactRoot ID space. We generate random numbers for React root
14173 * IDs and if there's a collision the events and DOM update system will
14174 * get confused. In the future we need a way to generate GUIDs but for
14175 * now this will work on a smaller scale.
14176 */
14177var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
14178
14179var ServerReactRootIndex = {
14180 createReactRootIndex: function() {
14181 return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
14182 }
14183};
14184
14185module.exports = ServerReactRootIndex;
14186
14187},{}],83:[function(_dereq_,module,exports){
14188/**
14189 * Copyright 2013-2014, Facebook, Inc.
14190 * All rights reserved.
14191 *
14192 * This source code is licensed under the BSD-style license found in the
14193 * LICENSE file in the root directory of this source tree. An additional grant
14194 * of patent rights can be found in the PATENTS file in the same directory.
14195 *
14196 * @providesModule SimpleEventPlugin
14197 */
14198
14199"use strict";
14200
14201var EventConstants = _dereq_("./EventConstants");
14202var EventPluginUtils = _dereq_("./EventPluginUtils");
14203var EventPropagators = _dereq_("./EventPropagators");
14204var SyntheticClipboardEvent = _dereq_("./SyntheticClipboardEvent");
14205var SyntheticEvent = _dereq_("./SyntheticEvent");
14206var SyntheticFocusEvent = _dereq_("./SyntheticFocusEvent");
14207var SyntheticKeyboardEvent = _dereq_("./SyntheticKeyboardEvent");
14208var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
14209var SyntheticDragEvent = _dereq_("./SyntheticDragEvent");
14210var SyntheticTouchEvent = _dereq_("./SyntheticTouchEvent");
14211var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
14212var SyntheticWheelEvent = _dereq_("./SyntheticWheelEvent");
14213
14214var getEventCharCode = _dereq_("./getEventCharCode");
14215
14216var invariant = _dereq_("./invariant");
14217var keyOf = _dereq_("./keyOf");
14218var warning = _dereq_("./warning");
14219
14220var topLevelTypes = EventConstants.topLevelTypes;
14221
14222var eventTypes = {
14223 blur: {
14224 phasedRegistrationNames: {
14225 bubbled: keyOf({onBlur: true}),
14226 captured: keyOf({onBlurCapture: true})
14227 }
14228 },
14229 click: {
14230 phasedRegistrationNames: {
14231 bubbled: keyOf({onClick: true}),
14232 captured: keyOf({onClickCapture: true})
14233 }
14234 },
14235 contextMenu: {
14236 phasedRegistrationNames: {
14237 bubbled: keyOf({onContextMenu: true}),
14238 captured: keyOf({onContextMenuCapture: true})
14239 }
14240 },
14241 copy: {
14242 phasedRegistrationNames: {
14243 bubbled: keyOf({onCopy: true}),
14244 captured: keyOf({onCopyCapture: true})
14245 }
14246 },
14247 cut: {
14248 phasedRegistrationNames: {
14249 bubbled: keyOf({onCut: true}),
14250 captured: keyOf({onCutCapture: true})
14251 }
14252 },
14253 doubleClick: {
14254 phasedRegistrationNames: {
14255 bubbled: keyOf({onDoubleClick: true}),
14256 captured: keyOf({onDoubleClickCapture: true})
14257 }
14258 },
14259 drag: {
14260 phasedRegistrationNames: {
14261 bubbled: keyOf({onDrag: true}),
14262 captured: keyOf({onDragCapture: true})
14263 }
14264 },
14265 dragEnd: {
14266 phasedRegistrationNames: {
14267 bubbled: keyOf({onDragEnd: true}),
14268 captured: keyOf({onDragEndCapture: true})
14269 }
14270 },
14271 dragEnter: {
14272 phasedRegistrationNames: {
14273 bubbled: keyOf({onDragEnter: true}),
14274 captured: keyOf({onDragEnterCapture: true})
14275 }
14276 },
14277 dragExit: {
14278 phasedRegistrationNames: {
14279 bubbled: keyOf({onDragExit: true}),
14280 captured: keyOf({onDragExitCapture: true})
14281 }
14282 },
14283 dragLeave: {
14284 phasedRegistrationNames: {
14285 bubbled: keyOf({onDragLeave: true}),
14286 captured: keyOf({onDragLeaveCapture: true})
14287 }
14288 },
14289 dragOver: {
14290 phasedRegistrationNames: {
14291 bubbled: keyOf({onDragOver: true}),
14292 captured: keyOf({onDragOverCapture: true})
14293 }
14294 },
14295 dragStart: {
14296 phasedRegistrationNames: {
14297 bubbled: keyOf({onDragStart: true}),
14298 captured: keyOf({onDragStartCapture: true})
14299 }
14300 },
14301 drop: {
14302 phasedRegistrationNames: {
14303 bubbled: keyOf({onDrop: true}),
14304 captured: keyOf({onDropCapture: true})
14305 }
14306 },
14307 focus: {
14308 phasedRegistrationNames: {
14309 bubbled: keyOf({onFocus: true}),
14310 captured: keyOf({onFocusCapture: true})
14311 }
14312 },
14313 input: {
14314 phasedRegistrationNames: {
14315 bubbled: keyOf({onInput: true}),
14316 captured: keyOf({onInputCapture: true})
14317 }
14318 },
14319 keyDown: {
14320 phasedRegistrationNames: {
14321 bubbled: keyOf({onKeyDown: true}),
14322 captured: keyOf({onKeyDownCapture: true})
14323 }
14324 },
14325 keyPress: {
14326 phasedRegistrationNames: {
14327 bubbled: keyOf({onKeyPress: true}),
14328 captured: keyOf({onKeyPressCapture: true})
14329 }
14330 },
14331 keyUp: {
14332 phasedRegistrationNames: {
14333 bubbled: keyOf({onKeyUp: true}),
14334 captured: keyOf({onKeyUpCapture: true})
14335 }
14336 },
14337 load: {
14338 phasedRegistrationNames: {
14339 bubbled: keyOf({onLoad: true}),
14340 captured: keyOf({onLoadCapture: true})
14341 }
14342 },
14343 error: {
14344 phasedRegistrationNames: {
14345 bubbled: keyOf({onError: true}),
14346 captured: keyOf({onErrorCapture: true})
14347 }
14348 },
14349 // Note: We do not allow listening to mouseOver events. Instead, use the
14350 // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
14351 mouseDown: {
14352 phasedRegistrationNames: {
14353 bubbled: keyOf({onMouseDown: true}),
14354 captured: keyOf({onMouseDownCapture: true})
14355 }
14356 },
14357 mouseMove: {
14358 phasedRegistrationNames: {
14359 bubbled: keyOf({onMouseMove: true}),
14360 captured: keyOf({onMouseMoveCapture: true})
14361 }
14362 },
14363 mouseOut: {
14364 phasedRegistrationNames: {
14365 bubbled: keyOf({onMouseOut: true}),
14366 captured: keyOf({onMouseOutCapture: true})
14367 }
14368 },
14369 mouseOver: {
14370 phasedRegistrationNames: {
14371 bubbled: keyOf({onMouseOver: true}),
14372 captured: keyOf({onMouseOverCapture: true})
14373 }
14374 },
14375 mouseUp: {
14376 phasedRegistrationNames: {
14377 bubbled: keyOf({onMouseUp: true}),
14378 captured: keyOf({onMouseUpCapture: true})
14379 }
14380 },
14381 paste: {
14382 phasedRegistrationNames: {
14383 bubbled: keyOf({onPaste: true}),
14384 captured: keyOf({onPasteCapture: true})
14385 }
14386 },
14387 reset: {
14388 phasedRegistrationNames: {
14389 bubbled: keyOf({onReset: true}),
14390 captured: keyOf({onResetCapture: true})
14391 }
14392 },
14393 scroll: {
14394 phasedRegistrationNames: {
14395 bubbled: keyOf({onScroll: true}),
14396 captured: keyOf({onScrollCapture: true})
14397 }
14398 },
14399 submit: {
14400 phasedRegistrationNames: {
14401 bubbled: keyOf({onSubmit: true}),
14402 captured: keyOf({onSubmitCapture: true})
14403 }
14404 },
14405 touchCancel: {
14406 phasedRegistrationNames: {
14407 bubbled: keyOf({onTouchCancel: true}),
14408 captured: keyOf({onTouchCancelCapture: true})
14409 }
14410 },
14411 touchEnd: {
14412 phasedRegistrationNames: {
14413 bubbled: keyOf({onTouchEnd: true}),
14414 captured: keyOf({onTouchEndCapture: true})
14415 }
14416 },
14417 touchMove: {
14418 phasedRegistrationNames: {
14419 bubbled: keyOf({onTouchMove: true}),
14420 captured: keyOf({onTouchMoveCapture: true})
14421 }
14422 },
14423 touchStart: {
14424 phasedRegistrationNames: {
14425 bubbled: keyOf({onTouchStart: true}),
14426 captured: keyOf({onTouchStartCapture: true})
14427 }
14428 },
14429 wheel: {
14430 phasedRegistrationNames: {
14431 bubbled: keyOf({onWheel: true}),
14432 captured: keyOf({onWheelCapture: true})
14433 }
14434 }
14435};
14436
14437var topLevelEventsToDispatchConfig = {
14438 topBlur: eventTypes.blur,
14439 topClick: eventTypes.click,
14440 topContextMenu: eventTypes.contextMenu,
14441 topCopy: eventTypes.copy,
14442 topCut: eventTypes.cut,
14443 topDoubleClick: eventTypes.doubleClick,
14444 topDrag: eventTypes.drag,
14445 topDragEnd: eventTypes.dragEnd,
14446 topDragEnter: eventTypes.dragEnter,
14447 topDragExit: eventTypes.dragExit,
14448 topDragLeave: eventTypes.dragLeave,
14449 topDragOver: eventTypes.dragOver,
14450 topDragStart: eventTypes.dragStart,
14451 topDrop: eventTypes.drop,
14452 topError: eventTypes.error,
14453 topFocus: eventTypes.focus,
14454 topInput: eventTypes.input,
14455 topKeyDown: eventTypes.keyDown,
14456 topKeyPress: eventTypes.keyPress,
14457 topKeyUp: eventTypes.keyUp,
14458 topLoad: eventTypes.load,
14459 topMouseDown: eventTypes.mouseDown,
14460 topMouseMove: eventTypes.mouseMove,
14461 topMouseOut: eventTypes.mouseOut,
14462 topMouseOver: eventTypes.mouseOver,
14463 topMouseUp: eventTypes.mouseUp,
14464 topPaste: eventTypes.paste,
14465 topReset: eventTypes.reset,
14466 topScroll: eventTypes.scroll,
14467 topSubmit: eventTypes.submit,
14468 topTouchCancel: eventTypes.touchCancel,
14469 topTouchEnd: eventTypes.touchEnd,
14470 topTouchMove: eventTypes.touchMove,
14471 topTouchStart: eventTypes.touchStart,
14472 topWheel: eventTypes.wheel
14473};
14474
14475for (var topLevelType in topLevelEventsToDispatchConfig) {
14476 topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType];
14477}
14478
14479var SimpleEventPlugin = {
14480
14481 eventTypes: eventTypes,
14482
14483 /**
14484 * Same as the default implementation, except cancels the event when return
14485 * value is false. This behavior will be disabled in a future release.
14486 *
14487 * @param {object} Event to be dispatched.
14488 * @param {function} Application-level callback.
14489 * @param {string} domID DOM ID to pass to the callback.
14490 */
14491 executeDispatch: function(event, listener, domID) {
14492 var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
14493
14494 ("production" !== "development" ? warning(
14495 typeof returnValue !== 'boolean',
14496 'Returning `false` from an event handler is deprecated and will be ' +
14497 'ignored in a future release. Instead, manually call ' +
14498 'e.stopPropagation() or e.preventDefault(), as appropriate.'
14499 ) : null);
14500
14501 if (returnValue === false) {
14502 event.stopPropagation();
14503 event.preventDefault();
14504 }
14505 },
14506
14507 /**
14508 * @param {string} topLevelType Record from `EventConstants`.
14509 * @param {DOMEventTarget} topLevelTarget The listening component root node.
14510 * @param {string} topLevelTargetID ID of `topLevelTarget`.
14511 * @param {object} nativeEvent Native browser event.
14512 * @return {*} An accumulation of synthetic events.
14513 * @see {EventPluginHub.extractEvents}
14514 */
14515 extractEvents: function(
14516 topLevelType,
14517 topLevelTarget,
14518 topLevelTargetID,
14519 nativeEvent) {
14520 var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
14521 if (!dispatchConfig) {
14522 return null;
14523 }
14524 var EventConstructor;
14525 switch (topLevelType) {
14526 case topLevelTypes.topInput:
14527 case topLevelTypes.topLoad:
14528 case topLevelTypes.topError:
14529 case topLevelTypes.topReset:
14530 case topLevelTypes.topSubmit:
14531 // HTML Events
14532 // @see http://www.w3.org/TR/html5/index.html#events-0
14533 EventConstructor = SyntheticEvent;
14534 break;
14535 case topLevelTypes.topKeyPress:
14536 // FireFox creates a keypress event for function keys too. This removes
14537 // the unwanted keypress events. Enter is however both printable and
14538 // non-printable. One would expect Tab to be as well (but it isn't).
14539 if (getEventCharCode(nativeEvent) === 0) {
14540 return null;
14541 }
14542 /* falls through */
14543 case topLevelTypes.topKeyDown:
14544 case topLevelTypes.topKeyUp:
14545 EventConstructor = SyntheticKeyboardEvent;
14546 break;
14547 case topLevelTypes.topBlur:
14548 case topLevelTypes.topFocus:
14549 EventConstructor = SyntheticFocusEvent;
14550 break;
14551 case topLevelTypes.topClick:
14552 // Firefox creates a click event on right mouse clicks. This removes the
14553 // unwanted click events.
14554 if (nativeEvent.button === 2) {
14555 return null;
14556 }
14557 /* falls through */
14558 case topLevelTypes.topContextMenu:
14559 case topLevelTypes.topDoubleClick:
14560 case topLevelTypes.topMouseDown:
14561 case topLevelTypes.topMouseMove:
14562 case topLevelTypes.topMouseOut:
14563 case topLevelTypes.topMouseOver:
14564 case topLevelTypes.topMouseUp:
14565 EventConstructor = SyntheticMouseEvent;
14566 break;
14567 case topLevelTypes.topDrag:
14568 case topLevelTypes.topDragEnd:
14569 case topLevelTypes.topDragEnter:
14570 case topLevelTypes.topDragExit:
14571 case topLevelTypes.topDragLeave:
14572 case topLevelTypes.topDragOver:
14573 case topLevelTypes.topDragStart:
14574 case topLevelTypes.topDrop:
14575 EventConstructor = SyntheticDragEvent;
14576 break;
14577 case topLevelTypes.topTouchCancel:
14578 case topLevelTypes.topTouchEnd:
14579 case topLevelTypes.topTouchMove:
14580 case topLevelTypes.topTouchStart:
14581 EventConstructor = SyntheticTouchEvent;
14582 break;
14583 case topLevelTypes.topScroll:
14584 EventConstructor = SyntheticUIEvent;
14585 break;
14586 case topLevelTypes.topWheel:
14587 EventConstructor = SyntheticWheelEvent;
14588 break;
14589 case topLevelTypes.topCopy:
14590 case topLevelTypes.topCut:
14591 case topLevelTypes.topPaste:
14592 EventConstructor = SyntheticClipboardEvent;
14593 break;
14594 }
14595 ("production" !== "development" ? invariant(
14596 EventConstructor,
14597 'SimpleEventPlugin: Unhandled event type, `%s`.',
14598 topLevelType
14599 ) : invariant(EventConstructor));
14600 var event = EventConstructor.getPooled(
14601 dispatchConfig,
14602 topLevelTargetID,
14603 nativeEvent
14604 );
14605 EventPropagators.accumulateTwoPhaseDispatches(event);
14606 return event;
14607 }
14608
14609};
14610
14611module.exports = SimpleEventPlugin;
14612
14613},{"./EventConstants":16,"./EventPluginUtils":20,"./EventPropagators":21,"./SyntheticClipboardEvent":84,"./SyntheticDragEvent":86,"./SyntheticEvent":87,"./SyntheticFocusEvent":88,"./SyntheticKeyboardEvent":90,"./SyntheticMouseEvent":91,"./SyntheticTouchEvent":92,"./SyntheticUIEvent":93,"./SyntheticWheelEvent":94,"./getEventCharCode":114,"./invariant":126,"./keyOf":133,"./warning":145}],84:[function(_dereq_,module,exports){
14614/**
14615 * Copyright 2013-2014, Facebook, Inc.
14616 * All rights reserved.
14617 *
14618 * This source code is licensed under the BSD-style license found in the
14619 * LICENSE file in the root directory of this source tree. An additional grant
14620 * of patent rights can be found in the PATENTS file in the same directory.
14621 *
14622 * @providesModule SyntheticClipboardEvent
14623 * @typechecks static-only
14624 */
14625
14626"use strict";
14627
14628var SyntheticEvent = _dereq_("./SyntheticEvent");
14629
14630/**
14631 * @interface Event
14632 * @see http://www.w3.org/TR/clipboard-apis/
14633 */
14634var ClipboardEventInterface = {
14635 clipboardData: function(event) {
14636 return (
14637 'clipboardData' in event ?
14638 event.clipboardData :
14639 window.clipboardData
14640 );
14641 }
14642};
14643
14644/**
14645 * @param {object} dispatchConfig Configuration used to dispatch this event.
14646 * @param {string} dispatchMarker Marker identifying the event target.
14647 * @param {object} nativeEvent Native browser event.
14648 * @extends {SyntheticUIEvent}
14649 */
14650function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
14651 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
14652}
14653
14654SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
14655
14656module.exports = SyntheticClipboardEvent;
14657
14658
14659},{"./SyntheticEvent":87}],85:[function(_dereq_,module,exports){
14660/**
14661 * Copyright 2013-2014, Facebook, Inc.
14662 * All rights reserved.
14663 *
14664 * This source code is licensed under the BSD-style license found in the
14665 * LICENSE file in the root directory of this source tree. An additional grant
14666 * of patent rights can be found in the PATENTS file in the same directory.
14667 *
14668 * @providesModule SyntheticCompositionEvent
14669 * @typechecks static-only
14670 */
14671
14672"use strict";
14673
14674var SyntheticEvent = _dereq_("./SyntheticEvent");
14675
14676/**
14677 * @interface Event
14678 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
14679 */
14680var CompositionEventInterface = {
14681 data: null
14682};
14683
14684/**
14685 * @param {object} dispatchConfig Configuration used to dispatch this event.
14686 * @param {string} dispatchMarker Marker identifying the event target.
14687 * @param {object} nativeEvent Native browser event.
14688 * @extends {SyntheticUIEvent}
14689 */
14690function SyntheticCompositionEvent(
14691 dispatchConfig,
14692 dispatchMarker,
14693 nativeEvent) {
14694 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
14695}
14696
14697SyntheticEvent.augmentClass(
14698 SyntheticCompositionEvent,
14699 CompositionEventInterface
14700);
14701
14702module.exports = SyntheticCompositionEvent;
14703
14704
14705},{"./SyntheticEvent":87}],86:[function(_dereq_,module,exports){
14706/**
14707 * Copyright 2013-2014, Facebook, Inc.
14708 * All rights reserved.
14709 *
14710 * This source code is licensed under the BSD-style license found in the
14711 * LICENSE file in the root directory of this source tree. An additional grant
14712 * of patent rights can be found in the PATENTS file in the same directory.
14713 *
14714 * @providesModule SyntheticDragEvent
14715 * @typechecks static-only
14716 */
14717
14718"use strict";
14719
14720var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
14721
14722/**
14723 * @interface DragEvent
14724 * @see http://www.w3.org/TR/DOM-Level-3-Events/
14725 */
14726var DragEventInterface = {
14727 dataTransfer: null
14728};
14729
14730/**
14731 * @param {object} dispatchConfig Configuration used to dispatch this event.
14732 * @param {string} dispatchMarker Marker identifying the event target.
14733 * @param {object} nativeEvent Native browser event.
14734 * @extends {SyntheticUIEvent}
14735 */
14736function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
14737 SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
14738}
14739
14740SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
14741
14742module.exports = SyntheticDragEvent;
14743
14744},{"./SyntheticMouseEvent":91}],87:[function(_dereq_,module,exports){
14745/**
14746 * Copyright 2013-2014, Facebook, Inc.
14747 * All rights reserved.
14748 *
14749 * This source code is licensed under the BSD-style license found in the
14750 * LICENSE file in the root directory of this source tree. An additional grant
14751 * of patent rights can be found in the PATENTS file in the same directory.
14752 *
14753 * @providesModule SyntheticEvent
14754 * @typechecks static-only
14755 */
14756
14757"use strict";
14758
14759var PooledClass = _dereq_("./PooledClass");
14760
14761var assign = _dereq_("./Object.assign");
14762var emptyFunction = _dereq_("./emptyFunction");
14763var getEventTarget = _dereq_("./getEventTarget");
14764
14765/**
14766 * @interface Event
14767 * @see http://www.w3.org/TR/DOM-Level-3-Events/
14768 */
14769var EventInterface = {
14770 type: null,
14771 target: getEventTarget,
14772 // currentTarget is set when dispatching; no use in copying it here
14773 currentTarget: emptyFunction.thatReturnsNull,
14774 eventPhase: null,
14775 bubbles: null,
14776 cancelable: null,
14777 timeStamp: function(event) {
14778 return event.timeStamp || Date.now();
14779 },
14780 defaultPrevented: null,
14781 isTrusted: null
14782};
14783
14784/**
14785 * Synthetic events are dispatched by event plugins, typically in response to a
14786 * top-level event delegation handler.
14787 *
14788 * These systems should generally use pooling to reduce the frequency of garbage
14789 * collection. The system should check `isPersistent` to determine whether the
14790 * event should be released into the pool after being dispatched. Users that
14791 * need a persisted event should invoke `persist`.
14792 *
14793 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
14794 * normalizing browser quirks. Subclasses do not necessarily have to implement a
14795 * DOM interface; custom application-specific events can also subclass this.
14796 *
14797 * @param {object} dispatchConfig Configuration used to dispatch this event.
14798 * @param {string} dispatchMarker Marker identifying the event target.
14799 * @param {object} nativeEvent Native browser event.
14800 */
14801function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
14802 this.dispatchConfig = dispatchConfig;
14803 this.dispatchMarker = dispatchMarker;
14804 this.nativeEvent = nativeEvent;
14805
14806 var Interface = this.constructor.Interface;
14807 for (var propName in Interface) {
14808 if (!Interface.hasOwnProperty(propName)) {
14809 continue;
14810 }
14811 var normalize = Interface[propName];
14812 if (normalize) {
14813 this[propName] = normalize(nativeEvent);
14814 } else {
14815 this[propName] = nativeEvent[propName];
14816 }
14817 }
14818
14819 var defaultPrevented = nativeEvent.defaultPrevented != null ?
14820 nativeEvent.defaultPrevented :
14821 nativeEvent.returnValue === false;
14822 if (defaultPrevented) {
14823 this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
14824 } else {
14825 this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
14826 }
14827 this.isPropagationStopped = emptyFunction.thatReturnsFalse;
14828}
14829
14830assign(SyntheticEvent.prototype, {
14831
14832 preventDefault: function() {
14833 this.defaultPrevented = true;
14834 var event = this.nativeEvent;
14835 event.preventDefault ? event.preventDefault() : event.returnValue = false;
14836 this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
14837 },
14838
14839 stopPropagation: function() {
14840 var event = this.nativeEvent;
14841 event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
14842 this.isPropagationStopped = emptyFunction.thatReturnsTrue;
14843 },
14844
14845 /**
14846 * We release all dispatched `SyntheticEvent`s after each event loop, adding
14847 * them back into the pool. This allows a way to hold onto a reference that
14848 * won't be added back into the pool.
14849 */
14850 persist: function() {
14851 this.isPersistent = emptyFunction.thatReturnsTrue;
14852 },
14853
14854 /**
14855 * Checks if this event should be released back into the pool.
14856 *
14857 * @return {boolean} True if this should not be released, false otherwise.
14858 */
14859 isPersistent: emptyFunction.thatReturnsFalse,
14860
14861 /**
14862 * `PooledClass` looks for `destructor` on each instance it releases.
14863 */
14864 destructor: function() {
14865 var Interface = this.constructor.Interface;
14866 for (var propName in Interface) {
14867 this[propName] = null;
14868 }
14869 this.dispatchConfig = null;
14870 this.dispatchMarker = null;
14871 this.nativeEvent = null;
14872 }
14873
14874});
14875
14876SyntheticEvent.Interface = EventInterface;
14877
14878/**
14879 * Helper to reduce boilerplate when creating subclasses.
14880 *
14881 * @param {function} Class
14882 * @param {?object} Interface
14883 */
14884SyntheticEvent.augmentClass = function(Class, Interface) {
14885 var Super = this;
14886
14887 var prototype = Object.create(Super.prototype);
14888 assign(prototype, Class.prototype);
14889 Class.prototype = prototype;
14890 Class.prototype.constructor = Class;
14891
14892 Class.Interface = assign({}, Super.Interface, Interface);
14893 Class.augmentClass = Super.augmentClass;
14894
14895 PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
14896};
14897
14898PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
14899
14900module.exports = SyntheticEvent;
14901
14902},{"./Object.assign":27,"./PooledClass":28,"./emptyFunction":107,"./getEventTarget":117}],88:[function(_dereq_,module,exports){
14903/**
14904 * Copyright 2013-2014, Facebook, Inc.
14905 * All rights reserved.
14906 *
14907 * This source code is licensed under the BSD-style license found in the
14908 * LICENSE file in the root directory of this source tree. An additional grant
14909 * of patent rights can be found in the PATENTS file in the same directory.
14910 *
14911 * @providesModule SyntheticFocusEvent
14912 * @typechecks static-only
14913 */
14914
14915"use strict";
14916
14917var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
14918
14919/**
14920 * @interface FocusEvent
14921 * @see http://www.w3.org/TR/DOM-Level-3-Events/
14922 */
14923var FocusEventInterface = {
14924 relatedTarget: null
14925};
14926
14927/**
14928 * @param {object} dispatchConfig Configuration used to dispatch this event.
14929 * @param {string} dispatchMarker Marker identifying the event target.
14930 * @param {object} nativeEvent Native browser event.
14931 * @extends {SyntheticUIEvent}
14932 */
14933function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
14934 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
14935}
14936
14937SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
14938
14939module.exports = SyntheticFocusEvent;
14940
14941},{"./SyntheticUIEvent":93}],89:[function(_dereq_,module,exports){
14942/**
14943 * Copyright 2013 Facebook, Inc.
14944 * All rights reserved.
14945 *
14946 * This source code is licensed under the BSD-style license found in the
14947 * LICENSE file in the root directory of this source tree. An additional grant
14948 * of patent rights can be found in the PATENTS file in the same directory.
14949 *
14950 * @providesModule SyntheticInputEvent
14951 * @typechecks static-only
14952 */
14953
14954"use strict";
14955
14956var SyntheticEvent = _dereq_("./SyntheticEvent");
14957
14958/**
14959 * @interface Event
14960 * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
14961 * /#events-inputevents
14962 */
14963var InputEventInterface = {
14964 data: null
14965};
14966
14967/**
14968 * @param {object} dispatchConfig Configuration used to dispatch this event.
14969 * @param {string} dispatchMarker Marker identifying the event target.
14970 * @param {object} nativeEvent Native browser event.
14971 * @extends {SyntheticUIEvent}
14972 */
14973function SyntheticInputEvent(
14974 dispatchConfig,
14975 dispatchMarker,
14976 nativeEvent) {
14977 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
14978}
14979
14980SyntheticEvent.augmentClass(
14981 SyntheticInputEvent,
14982 InputEventInterface
14983);
14984
14985module.exports = SyntheticInputEvent;
14986
14987
14988},{"./SyntheticEvent":87}],90:[function(_dereq_,module,exports){
14989/**
14990 * Copyright 2013-2014, Facebook, Inc.
14991 * All rights reserved.
14992 *
14993 * This source code is licensed under the BSD-style license found in the
14994 * LICENSE file in the root directory of this source tree. An additional grant
14995 * of patent rights can be found in the PATENTS file in the same directory.
14996 *
14997 * @providesModule SyntheticKeyboardEvent
14998 * @typechecks static-only
14999 */
15000
15001"use strict";
15002
15003var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
15004
15005var getEventCharCode = _dereq_("./getEventCharCode");
15006var getEventKey = _dereq_("./getEventKey");
15007var getEventModifierState = _dereq_("./getEventModifierState");
15008
15009/**
15010 * @interface KeyboardEvent
15011 * @see http://www.w3.org/TR/DOM-Level-3-Events/
15012 */
15013var KeyboardEventInterface = {
15014 key: getEventKey,
15015 location: null,
15016 ctrlKey: null,
15017 shiftKey: null,
15018 altKey: null,
15019 metaKey: null,
15020 repeat: null,
15021 locale: null,
15022 getModifierState: getEventModifierState,
15023 // Legacy Interface
15024 charCode: function(event) {
15025 // `charCode` is the result of a KeyPress event and represents the value of
15026 // the actual printable character.
15027
15028 // KeyPress is deprecated, but its replacement is not yet final and not
15029 // implemented in any major browser. Only KeyPress has charCode.
15030 if (event.type === 'keypress') {
15031 return getEventCharCode(event);
15032 }
15033 return 0;
15034 },
15035 keyCode: function(event) {
15036 // `keyCode` is the result of a KeyDown/Up event and represents the value of
15037 // physical keyboard key.
15038
15039 // The actual meaning of the value depends on the users' keyboard layout
15040 // which cannot be detected. Assuming that it is a US keyboard layout
15041 // provides a surprisingly accurate mapping for US and European users.
15042 // Due to this, it is left to the user to implement at this time.
15043 if (event.type === 'keydown' || event.type === 'keyup') {
15044 return event.keyCode;
15045 }
15046 return 0;
15047 },
15048 which: function(event) {
15049 // `which` is an alias for either `keyCode` or `charCode` depending on the
15050 // type of the event.
15051 if (event.type === 'keypress') {
15052 return getEventCharCode(event);
15053 }
15054 if (event.type === 'keydown' || event.type === 'keyup') {
15055 return event.keyCode;
15056 }
15057 return 0;
15058 }
15059};
15060
15061/**
15062 * @param {object} dispatchConfig Configuration used to dispatch this event.
15063 * @param {string} dispatchMarker Marker identifying the event target.
15064 * @param {object} nativeEvent Native browser event.
15065 * @extends {SyntheticUIEvent}
15066 */
15067function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15068 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15069}
15070
15071SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
15072
15073module.exports = SyntheticKeyboardEvent;
15074
15075},{"./SyntheticUIEvent":93,"./getEventCharCode":114,"./getEventKey":115,"./getEventModifierState":116}],91:[function(_dereq_,module,exports){
15076/**
15077 * Copyright 2013-2014, Facebook, Inc.
15078 * All rights reserved.
15079 *
15080 * This source code is licensed under the BSD-style license found in the
15081 * LICENSE file in the root directory of this source tree. An additional grant
15082 * of patent rights can be found in the PATENTS file in the same directory.
15083 *
15084 * @providesModule SyntheticMouseEvent
15085 * @typechecks static-only
15086 */
15087
15088"use strict";
15089
15090var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
15091var ViewportMetrics = _dereq_("./ViewportMetrics");
15092
15093var getEventModifierState = _dereq_("./getEventModifierState");
15094
15095/**
15096 * @interface MouseEvent
15097 * @see http://www.w3.org/TR/DOM-Level-3-Events/
15098 */
15099var MouseEventInterface = {
15100 screenX: null,
15101 screenY: null,
15102 clientX: null,
15103 clientY: null,
15104 ctrlKey: null,
15105 shiftKey: null,
15106 altKey: null,
15107 metaKey: null,
15108 getModifierState: getEventModifierState,
15109 button: function(event) {
15110 // Webkit, Firefox, IE9+
15111 // which: 1 2 3
15112 // button: 0 1 2 (standard)
15113 var button = event.button;
15114 if ('which' in event) {
15115 return button;
15116 }
15117 // IE<9
15118 // which: undefined
15119 // button: 0 0 0
15120 // button: 1 4 2 (onmouseup)
15121 return button === 2 ? 2 : button === 4 ? 1 : 0;
15122 },
15123 buttons: null,
15124 relatedTarget: function(event) {
15125 return event.relatedTarget || (
15126 event.fromElement === event.srcElement ?
15127 event.toElement :
15128 event.fromElement
15129 );
15130 },
15131 // "Proprietary" Interface.
15132 pageX: function(event) {
15133 return 'pageX' in event ?
15134 event.pageX :
15135 event.clientX + ViewportMetrics.currentScrollLeft;
15136 },
15137 pageY: function(event) {
15138 return 'pageY' in event ?
15139 event.pageY :
15140 event.clientY + ViewportMetrics.currentScrollTop;
15141 }
15142};
15143
15144/**
15145 * @param {object} dispatchConfig Configuration used to dispatch this event.
15146 * @param {string} dispatchMarker Marker identifying the event target.
15147 * @param {object} nativeEvent Native browser event.
15148 * @extends {SyntheticUIEvent}
15149 */
15150function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15151 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15152}
15153
15154SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
15155
15156module.exports = SyntheticMouseEvent;
15157
15158},{"./SyntheticUIEvent":93,"./ViewportMetrics":96,"./getEventModifierState":116}],92:[function(_dereq_,module,exports){
15159/**
15160 * Copyright 2013-2014, Facebook, Inc.
15161 * All rights reserved.
15162 *
15163 * This source code is licensed under the BSD-style license found in the
15164 * LICENSE file in the root directory of this source tree. An additional grant
15165 * of patent rights can be found in the PATENTS file in the same directory.
15166 *
15167 * @providesModule SyntheticTouchEvent
15168 * @typechecks static-only
15169 */
15170
15171"use strict";
15172
15173var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
15174
15175var getEventModifierState = _dereq_("./getEventModifierState");
15176
15177/**
15178 * @interface TouchEvent
15179 * @see http://www.w3.org/TR/touch-events/
15180 */
15181var TouchEventInterface = {
15182 touches: null,
15183 targetTouches: null,
15184 changedTouches: null,
15185 altKey: null,
15186 metaKey: null,
15187 ctrlKey: null,
15188 shiftKey: null,
15189 getModifierState: getEventModifierState
15190};
15191
15192/**
15193 * @param {object} dispatchConfig Configuration used to dispatch this event.
15194 * @param {string} dispatchMarker Marker identifying the event target.
15195 * @param {object} nativeEvent Native browser event.
15196 * @extends {SyntheticUIEvent}
15197 */
15198function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15199 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15200}
15201
15202SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
15203
15204module.exports = SyntheticTouchEvent;
15205
15206},{"./SyntheticUIEvent":93,"./getEventModifierState":116}],93:[function(_dereq_,module,exports){
15207/**
15208 * Copyright 2013-2014, Facebook, Inc.
15209 * All rights reserved.
15210 *
15211 * This source code is licensed under the BSD-style license found in the
15212 * LICENSE file in the root directory of this source tree. An additional grant
15213 * of patent rights can be found in the PATENTS file in the same directory.
15214 *
15215 * @providesModule SyntheticUIEvent
15216 * @typechecks static-only
15217 */
15218
15219"use strict";
15220
15221var SyntheticEvent = _dereq_("./SyntheticEvent");
15222
15223var getEventTarget = _dereq_("./getEventTarget");
15224
15225/**
15226 * @interface UIEvent
15227 * @see http://www.w3.org/TR/DOM-Level-3-Events/
15228 */
15229var UIEventInterface = {
15230 view: function(event) {
15231 if (event.view) {
15232 return event.view;
15233 }
15234
15235 var target = getEventTarget(event);
15236 if (target != null && target.window === target) {
15237 // target is a window object
15238 return target;
15239 }
15240
15241 var doc = target.ownerDocument;
15242 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
15243 if (doc) {
15244 return doc.defaultView || doc.parentWindow;
15245 } else {
15246 return window;
15247 }
15248 },
15249 detail: function(event) {
15250 return event.detail || 0;
15251 }
15252};
15253
15254/**
15255 * @param {object} dispatchConfig Configuration used to dispatch this event.
15256 * @param {string} dispatchMarker Marker identifying the event target.
15257 * @param {object} nativeEvent Native browser event.
15258 * @extends {SyntheticEvent}
15259 */
15260function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15261 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15262}
15263
15264SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
15265
15266module.exports = SyntheticUIEvent;
15267
15268},{"./SyntheticEvent":87,"./getEventTarget":117}],94:[function(_dereq_,module,exports){
15269/**
15270 * Copyright 2013-2014, Facebook, Inc.
15271 * All rights reserved.
15272 *
15273 * This source code is licensed under the BSD-style license found in the
15274 * LICENSE file in the root directory of this source tree. An additional grant
15275 * of patent rights can be found in the PATENTS file in the same directory.
15276 *
15277 * @providesModule SyntheticWheelEvent
15278 * @typechecks static-only
15279 */
15280
15281"use strict";
15282
15283var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
15284
15285/**
15286 * @interface WheelEvent
15287 * @see http://www.w3.org/TR/DOM-Level-3-Events/
15288 */
15289var WheelEventInterface = {
15290 deltaX: function(event) {
15291 return (
15292 'deltaX' in event ? event.deltaX :
15293 // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
15294 'wheelDeltaX' in event ? -event.wheelDeltaX : 0
15295 );
15296 },
15297 deltaY: function(event) {
15298 return (
15299 'deltaY' in event ? event.deltaY :
15300 // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
15301 'wheelDeltaY' in event ? -event.wheelDeltaY :
15302 // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
15303 'wheelDelta' in event ? -event.wheelDelta : 0
15304 );
15305 },
15306 deltaZ: null,
15307
15308 // Browsers without "deltaMode" is reporting in raw wheel delta where one
15309 // notch on the scroll is always +/- 120, roughly equivalent to pixels.
15310 // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
15311 // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
15312 deltaMode: null
15313};
15314
15315/**
15316 * @param {object} dispatchConfig Configuration used to dispatch this event.
15317 * @param {string} dispatchMarker Marker identifying the event target.
15318 * @param {object} nativeEvent Native browser event.
15319 * @extends {SyntheticMouseEvent}
15320 */
15321function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15322 SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15323}
15324
15325SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
15326
15327module.exports = SyntheticWheelEvent;
15328
15329},{"./SyntheticMouseEvent":91}],95:[function(_dereq_,module,exports){
15330/**
15331 * Copyright 2013-2014, Facebook, Inc.
15332 * All rights reserved.
15333 *
15334 * This source code is licensed under the BSD-style license found in the
15335 * LICENSE file in the root directory of this source tree. An additional grant
15336 * of patent rights can be found in the PATENTS file in the same directory.
15337 *
15338 * @providesModule Transaction
15339 */
15340
15341"use strict";
15342
15343var invariant = _dereq_("./invariant");
15344
15345/**
15346 * `Transaction` creates a black box that is able to wrap any method such that
15347 * certain invariants are maintained before and after the method is invoked
15348 * (Even if an exception is thrown while invoking the wrapped method). Whoever
15349 * instantiates a transaction can provide enforcers of the invariants at
15350 * creation time. The `Transaction` class itself will supply one additional
15351 * automatic invariant for you - the invariant that any transaction instance
15352 * should not be run while it is already being run. You would typically create a
15353 * single instance of a `Transaction` for reuse multiple times, that potentially
15354 * is used to wrap several different methods. Wrappers are extremely simple -
15355 * they only require implementing two methods.
15356 *
15357 * <pre>
15358 * wrappers (injected at creation time)
15359 * + +
15360 * | |
15361 * +-----------------|--------|--------------+
15362 * | v | |
15363 * | +---------------+ | |
15364 * | +--| wrapper1 |---|----+ |
15365 * | | +---------------+ v | |
15366 * | | +-------------+ | |
15367 * | | +----| wrapper2 |--------+ |
15368 * | | | +-------------+ | | |
15369 * | | | | | |
15370 * | v v v v | wrapper
15371 * | +---+ +---+ +---------+ +---+ +---+ | invariants
15372 * perform(anyMethod) | | | | | | | | | | | | maintained
15373 * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
15374 * | | | | | | | | | | | |
15375 * | | | | | | | | | | | |
15376 * | | | | | | | | | | | |
15377 * | +---+ +---+ +---------+ +---+ +---+ |
15378 * | initialize close |
15379 * +-----------------------------------------+
15380 * </pre>
15381 *
15382 * Use cases:
15383 * - Preserving the input selection ranges before/after reconciliation.
15384 * Restoring selection even in the event of an unexpected error.
15385 * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
15386 * while guaranteeing that afterwards, the event system is reactivated.
15387 * - Flushing a queue of collected DOM mutations to the main UI thread after a
15388 * reconciliation takes place in a worker thread.
15389 * - Invoking any collected `componentDidUpdate` callbacks after rendering new
15390 * content.
15391 * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
15392 * to preserve the `scrollTop` (an automatic scroll aware DOM).
15393 * - (Future use case): Layout calculations before and after DOM upates.
15394 *
15395 * Transactional plugin API:
15396 * - A module that has an `initialize` method that returns any precomputation.
15397 * - and a `close` method that accepts the precomputation. `close` is invoked
15398 * when the wrapped process is completed, or has failed.
15399 *
15400 * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
15401 * that implement `initialize` and `close`.
15402 * @return {Transaction} Single transaction for reuse in thread.
15403 *
15404 * @class Transaction
15405 */
15406var Mixin = {
15407 /**
15408 * Sets up this instance so that it is prepared for collecting metrics. Does
15409 * so such that this setup method may be used on an instance that is already
15410 * initialized, in a way that does not consume additional memory upon reuse.
15411 * That can be useful if you decide to make your subclass of this mixin a
15412 * "PooledClass".
15413 */
15414 reinitializeTransaction: function() {
15415 this.transactionWrappers = this.getTransactionWrappers();
15416 if (!this.wrapperInitData) {
15417 this.wrapperInitData = [];
15418 } else {
15419 this.wrapperInitData.length = 0;
15420 }
15421 this._isInTransaction = false;
15422 },
15423
15424 _isInTransaction: false,
15425
15426 /**
15427 * @abstract
15428 * @return {Array<TransactionWrapper>} Array of transaction wrappers.
15429 */
15430 getTransactionWrappers: null,
15431
15432 isInTransaction: function() {
15433 return !!this._isInTransaction;
15434 },
15435
15436 /**
15437 * Executes the function within a safety window. Use this for the top level
15438 * methods that result in large amounts of computation/mutations that would
15439 * need to be safety checked.
15440 *
15441 * @param {function} method Member of scope to call.
15442 * @param {Object} scope Scope to invoke from.
15443 * @param {Object?=} args... Arguments to pass to the method (optional).
15444 * Helps prevent need to bind in many cases.
15445 * @return Return value from `method`.
15446 */
15447 perform: function(method, scope, a, b, c, d, e, f) {
15448 ("production" !== "development" ? invariant(
15449 !this.isInTransaction(),
15450 'Transaction.perform(...): Cannot initialize a transaction when there ' +
15451 'is already an outstanding transaction.'
15452 ) : invariant(!this.isInTransaction()));
15453 var errorThrown;
15454 var ret;
15455 try {
15456 this._isInTransaction = true;
15457 // Catching errors makes debugging more difficult, so we start with
15458 // errorThrown set to true before setting it to false after calling
15459 // close -- if it's still set to true in the finally block, it means
15460 // one of these calls threw.
15461 errorThrown = true;
15462 this.initializeAll(0);
15463 ret = method.call(scope, a, b, c, d, e, f);
15464 errorThrown = false;
15465 } finally {
15466 try {
15467 if (errorThrown) {
15468 // If `method` throws, prefer to show that stack trace over any thrown
15469 // by invoking `closeAll`.
15470 try {
15471 this.closeAll(0);
15472 } catch (err) {
15473 }
15474 } else {
15475 // Since `method` didn't throw, we don't want to silence the exception
15476 // here.
15477 this.closeAll(0);
15478 }
15479 } finally {
15480 this._isInTransaction = false;
15481 }
15482 }
15483 return ret;
15484 },
15485
15486 initializeAll: function(startIndex) {
15487 var transactionWrappers = this.transactionWrappers;
15488 for (var i = startIndex; i < transactionWrappers.length; i++) {
15489 var wrapper = transactionWrappers[i];
15490 try {
15491 // Catching errors makes debugging more difficult, so we start with the
15492 // OBSERVED_ERROR state before overwriting it with the real return value
15493 // of initialize -- if it's still set to OBSERVED_ERROR in the finally
15494 // block, it means wrapper.initialize threw.
15495 this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
15496 this.wrapperInitData[i] = wrapper.initialize ?
15497 wrapper.initialize.call(this) :
15498 null;
15499 } finally {
15500 if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
15501 // The initializer for wrapper i threw an error; initialize the
15502 // remaining wrappers but silence any exceptions from them to ensure
15503 // that the first error is the one to bubble up.
15504 try {
15505 this.initializeAll(i + 1);
15506 } catch (err) {
15507 }
15508 }
15509 }
15510 }
15511 },
15512
15513 /**
15514 * Invokes each of `this.transactionWrappers.close[i]` functions, passing into
15515 * them the respective return values of `this.transactionWrappers.init[i]`
15516 * (`close`rs that correspond to initializers that failed will not be
15517 * invoked).
15518 */
15519 closeAll: function(startIndex) {
15520 ("production" !== "development" ? invariant(
15521 this.isInTransaction(),
15522 'Transaction.closeAll(): Cannot close transaction when none are open.'
15523 ) : invariant(this.isInTransaction()));
15524 var transactionWrappers = this.transactionWrappers;
15525 for (var i = startIndex; i < transactionWrappers.length; i++) {
15526 var wrapper = transactionWrappers[i];
15527 var initData = this.wrapperInitData[i];
15528 var errorThrown;
15529 try {
15530 // Catching errors makes debugging more difficult, so we start with
15531 // errorThrown set to true before setting it to false after calling
15532 // close -- if it's still set to true in the finally block, it means
15533 // wrapper.close threw.
15534 errorThrown = true;
15535 if (initData !== Transaction.OBSERVED_ERROR) {
15536 wrapper.close && wrapper.close.call(this, initData);
15537 }
15538 errorThrown = false;
15539 } finally {
15540 if (errorThrown) {
15541 // The closer for wrapper i threw an error; close the remaining
15542 // wrappers but silence any exceptions from them to ensure that the
15543 // first error is the one to bubble up.
15544 try {
15545 this.closeAll(i + 1);
15546 } catch (e) {
15547 }
15548 }
15549 }
15550 }
15551 this.wrapperInitData.length = 0;
15552 }
15553};
15554
15555var Transaction = {
15556
15557 Mixin: Mixin,
15558
15559 /**
15560 * Token to look for to determine if an error occured.
15561 */
15562 OBSERVED_ERROR: {}
15563
15564};
15565
15566module.exports = Transaction;
15567
15568},{"./invariant":126}],96:[function(_dereq_,module,exports){
15569/**
15570 * Copyright 2013-2014, Facebook, Inc.
15571 * All rights reserved.
15572 *
15573 * This source code is licensed under the BSD-style license found in the
15574 * LICENSE file in the root directory of this source tree. An additional grant
15575 * of patent rights can be found in the PATENTS file in the same directory.
15576 *
15577 * @providesModule ViewportMetrics
15578 */
15579
15580"use strict";
15581
15582var getUnboundedScrollPosition = _dereq_("./getUnboundedScrollPosition");
15583
15584var ViewportMetrics = {
15585
15586 currentScrollLeft: 0,
15587
15588 currentScrollTop: 0,
15589
15590 refreshScrollValues: function() {
15591 var scrollPosition = getUnboundedScrollPosition(window);
15592 ViewportMetrics.currentScrollLeft = scrollPosition.x;
15593 ViewportMetrics.currentScrollTop = scrollPosition.y;
15594 }
15595
15596};
15597
15598module.exports = ViewportMetrics;
15599
15600},{"./getUnboundedScrollPosition":122}],97:[function(_dereq_,module,exports){
15601/**
15602 * Copyright 2014, Facebook, Inc.
15603 * All rights reserved.
15604 *
15605 * This source code is licensed under the BSD-style license found in the
15606 * LICENSE file in the root directory of this source tree. An additional grant
15607 * of patent rights can be found in the PATENTS file in the same directory.
15608 *
15609 * @providesModule accumulateInto
15610 */
15611
15612"use strict";
15613
15614var invariant = _dereq_("./invariant");
15615
15616/**
15617 *
15618 * Accumulates items that must not be null or undefined into the first one. This
15619 * is used to conserve memory by avoiding array allocations, and thus sacrifices
15620 * API cleanness. Since `current` can be null before being passed in and not
15621 * null after this function, make sure to assign it back to `current`:
15622 *
15623 * `a = accumulateInto(a, b);`
15624 *
15625 * This API should be sparingly used. Try `accumulate` for something cleaner.
15626 *
15627 * @return {*|array<*>} An accumulation of items.
15628 */
15629
15630function accumulateInto(current, next) {
15631 ("production" !== "development" ? invariant(
15632 next != null,
15633 'accumulateInto(...): Accumulated items must not be null or undefined.'
15634 ) : invariant(next != null));
15635 if (current == null) {
15636 return next;
15637 }
15638
15639 // Both are not empty. Warning: Never call x.concat(y) when you are not
15640 // certain that x is an Array (x could be a string with concat method).
15641 var currentIsArray = Array.isArray(current);
15642 var nextIsArray = Array.isArray(next);
15643
15644 if (currentIsArray && nextIsArray) {
15645 current.push.apply(current, next);
15646 return current;
15647 }
15648
15649 if (currentIsArray) {
15650 current.push(next);
15651 return current;
15652 }
15653
15654 if (nextIsArray) {
15655 // A bit too dangerous to mutate `next`.
15656 return [current].concat(next);
15657 }
15658
15659 return [current, next];
15660}
15661
15662module.exports = accumulateInto;
15663
15664},{"./invariant":126}],98:[function(_dereq_,module,exports){
15665/**
15666 * Copyright 2013-2014, Facebook, Inc.
15667 * All rights reserved.
15668 *
15669 * This source code is licensed under the BSD-style license found in the
15670 * LICENSE file in the root directory of this source tree. An additional grant
15671 * of patent rights can be found in the PATENTS file in the same directory.
15672 *
15673 * @providesModule adler32
15674 */
15675
15676/* jslint bitwise:true */
15677
15678"use strict";
15679
15680var MOD = 65521;
15681
15682// This is a clean-room implementation of adler32 designed for detecting
15683// if markup is not what we expect it to be. It does not need to be
15684// cryptographically strong, only reasonably good at detecting if markup
15685// generated on the server is different than that on the client.
15686function adler32(data) {
15687 var a = 1;
15688 var b = 0;
15689 for (var i = 0; i < data.length; i++) {
15690 a = (a + data.charCodeAt(i)) % MOD;
15691 b = (b + a) % MOD;
15692 }
15693 return a | (b << 16);
15694}
15695
15696module.exports = adler32;
15697
15698},{}],99:[function(_dereq_,module,exports){
15699/**
15700 * Copyright 2013-2014, Facebook, Inc.
15701 * All rights reserved.
15702 *
15703 * This source code is licensed under the BSD-style license found in the
15704 * LICENSE file in the root directory of this source tree. An additional grant
15705 * of patent rights can be found in the PATENTS file in the same directory.
15706 *
15707 * @providesModule camelize
15708 * @typechecks
15709 */
15710
15711var _hyphenPattern = /-(.)/g;
15712
15713/**
15714 * Camelcases a hyphenated string, for example:
15715 *
15716 * > camelize('background-color')
15717 * < "backgroundColor"
15718 *
15719 * @param {string} string
15720 * @return {string}
15721 */
15722function camelize(string) {
15723 return string.replace(_hyphenPattern, function(_, character) {
15724 return character.toUpperCase();
15725 });
15726}
15727
15728module.exports = camelize;
15729
15730},{}],100:[function(_dereq_,module,exports){
15731/**
15732 * Copyright 2014, Facebook, Inc.
15733 * All rights reserved.
15734 *
15735 * This source code is licensed under the BSD-style license found in the
15736 * LICENSE file in the root directory of this source tree. An additional grant
15737 * of patent rights can be found in the PATENTS file in the same directory.
15738 *
15739 * @providesModule camelizeStyleName
15740 * @typechecks
15741 */
15742
15743"use strict";
15744
15745var camelize = _dereq_("./camelize");
15746
15747var msPattern = /^-ms-/;
15748
15749/**
15750 * Camelcases a hyphenated CSS property name, for example:
15751 *
15752 * > camelizeStyleName('background-color')
15753 * < "backgroundColor"
15754 * > camelizeStyleName('-moz-transition')
15755 * < "MozTransition"
15756 * > camelizeStyleName('-ms-transition')
15757 * < "msTransition"
15758 *
15759 * As Andi Smith suggests
15760 * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
15761 * is converted to lowercase `ms`.
15762 *
15763 * @param {string} string
15764 * @return {string}
15765 */
15766function camelizeStyleName(string) {
15767 return camelize(string.replace(msPattern, 'ms-'));
15768}
15769
15770module.exports = camelizeStyleName;
15771
15772},{"./camelize":99}],101:[function(_dereq_,module,exports){
15773/**
15774 * Copyright 2013-2014, Facebook, Inc.
15775 * All rights reserved.
15776 *
15777 * This source code is licensed under the BSD-style license found in the
15778 * LICENSE file in the root directory of this source tree. An additional grant
15779 * of patent rights can be found in the PATENTS file in the same directory.
15780 *
15781 * @providesModule containsNode
15782 * @typechecks
15783 */
15784
15785var isTextNode = _dereq_("./isTextNode");
15786
15787/*jslint bitwise:true */
15788
15789/**
15790 * Checks if a given DOM node contains or is another DOM node.
15791 *
15792 * @param {?DOMNode} outerNode Outer DOM node.
15793 * @param {?DOMNode} innerNode Inner DOM node.
15794 * @return {boolean} True if `outerNode` contains or is `innerNode`.
15795 */
15796function containsNode(outerNode, innerNode) {
15797 if (!outerNode || !innerNode) {
15798 return false;
15799 } else if (outerNode === innerNode) {
15800 return true;
15801 } else if (isTextNode(outerNode)) {
15802 return false;
15803 } else if (isTextNode(innerNode)) {
15804 return containsNode(outerNode, innerNode.parentNode);
15805 } else if (outerNode.contains) {
15806 return outerNode.contains(innerNode);
15807 } else if (outerNode.compareDocumentPosition) {
15808 return !!(outerNode.compareDocumentPosition(innerNode) & 16);
15809 } else {
15810 return false;
15811 }
15812}
15813
15814module.exports = containsNode;
15815
15816},{"./isTextNode":130}],102:[function(_dereq_,module,exports){
15817/**
15818 * Copyright 2013-2014, Facebook, Inc.
15819 * All rights reserved.
15820 *
15821 * This source code is licensed under the BSD-style license found in the
15822 * LICENSE file in the root directory of this source tree. An additional grant
15823 * of patent rights can be found in the PATENTS file in the same directory.
15824 *
15825 * @providesModule createArrayFrom
15826 * @typechecks
15827 */
15828
15829var toArray = _dereq_("./toArray");
15830
15831/**
15832 * Perform a heuristic test to determine if an object is "array-like".
15833 *
15834 * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
15835 * Joshu replied: "Mu."
15836 *
15837 * This function determines if its argument has "array nature": it returns
15838 * true if the argument is an actual array, an `arguments' object, or an
15839 * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
15840 *
15841 * It will return false for other array-like objects like Filelist.
15842 *
15843 * @param {*} obj
15844 * @return {boolean}
15845 */
15846function hasArrayNature(obj) {
15847 return (
15848 // not null/false
15849 !!obj &&
15850 // arrays are objects, NodeLists are functions in Safari
15851 (typeof obj == 'object' || typeof obj == 'function') &&
15852 // quacks like an array
15853 ('length' in obj) &&
15854 // not window
15855 !('setInterval' in obj) &&
15856 // no DOM node should be considered an array-like
15857 // a 'select' element has 'length' and 'item' properties on IE8
15858 (typeof obj.nodeType != 'number') &&
15859 (
15860 // a real array
15861 (// HTMLCollection/NodeList
15862 (Array.isArray(obj) ||
15863 // arguments
15864 ('callee' in obj) || 'item' in obj))
15865 )
15866 );
15867}
15868
15869/**
15870 * Ensure that the argument is an array by wrapping it in an array if it is not.
15871 * Creates a copy of the argument if it is already an array.
15872 *
15873 * This is mostly useful idiomatically:
15874 *
15875 * var createArrayFrom = require('createArrayFrom');
15876 *
15877 * function takesOneOrMoreThings(things) {
15878 * things = createArrayFrom(things);
15879 * ...
15880 * }
15881 *
15882 * This allows you to treat `things' as an array, but accept scalars in the API.
15883 *
15884 * If you need to convert an array-like object, like `arguments`, into an array
15885 * use toArray instead.
15886 *
15887 * @param {*} obj
15888 * @return {array}
15889 */
15890function createArrayFrom(obj) {
15891 if (!hasArrayNature(obj)) {
15892 return [obj];
15893 } else if (Array.isArray(obj)) {
15894 return obj.slice();
15895 } else {
15896 return toArray(obj);
15897 }
15898}
15899
15900module.exports = createArrayFrom;
15901
15902},{"./toArray":143}],103:[function(_dereq_,module,exports){
15903/**
15904 * Copyright 2013-2014, Facebook, Inc.
15905 * All rights reserved.
15906 *
15907 * This source code is licensed under the BSD-style license found in the
15908 * LICENSE file in the root directory of this source tree. An additional grant
15909 * of patent rights can be found in the PATENTS file in the same directory.
15910 *
15911 * @providesModule createFullPageComponent
15912 * @typechecks
15913 */
15914
15915"use strict";
15916
15917// Defeat circular references by requiring this directly.
15918var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
15919var ReactElement = _dereq_("./ReactElement");
15920
15921var invariant = _dereq_("./invariant");
15922
15923/**
15924 * Create a component that will throw an exception when unmounted.
15925 *
15926 * Components like <html> <head> and <body> can't be removed or added
15927 * easily in a cross-browser way, however it's valuable to be able to
15928 * take advantage of React's reconciliation for styling and <title>
15929 * management. So we just document it and throw in dangerous cases.
15930 *
15931 * @param {string} tag The tag to wrap
15932 * @return {function} convenience constructor of new component
15933 */
15934function createFullPageComponent(tag) {
15935 var elementFactory = ReactElement.createFactory(tag);
15936
15937 var FullPageComponent = ReactCompositeComponent.createClass({
15938 displayName: 'ReactFullPageComponent' + tag,
15939
15940 componentWillUnmount: function() {
15941 ("production" !== "development" ? invariant(
15942 false,
15943 '%s tried to unmount. Because of cross-browser quirks it is ' +
15944 'impossible to unmount some top-level components (eg <html>, <head>, ' +
15945 'and <body>) reliably and efficiently. To fix this, have a single ' +
15946 'top-level component that never unmounts render these elements.',
15947 this.constructor.displayName
15948 ) : invariant(false));
15949 },
15950
15951 render: function() {
15952 return elementFactory(this.props);
15953 }
15954 });
15955
15956 return FullPageComponent;
15957}
15958
15959module.exports = createFullPageComponent;
15960
15961},{"./ReactCompositeComponent":34,"./ReactElement":52,"./invariant":126}],104:[function(_dereq_,module,exports){
15962/**
15963 * Copyright 2013-2014, Facebook, Inc.
15964 * All rights reserved.
15965 *
15966 * This source code is licensed under the BSD-style license found in the
15967 * LICENSE file in the root directory of this source tree. An additional grant
15968 * of patent rights can be found in the PATENTS file in the same directory.
15969 *
15970 * @providesModule createNodesFromMarkup
15971 * @typechecks
15972 */
15973
15974/*jslint evil: true, sub: true */
15975
15976var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
15977
15978var createArrayFrom = _dereq_("./createArrayFrom");
15979var getMarkupWrap = _dereq_("./getMarkupWrap");
15980var invariant = _dereq_("./invariant");
15981
15982/**
15983 * Dummy container used to render all markup.
15984 */
15985var dummyNode =
15986 ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
15987
15988/**
15989 * Pattern used by `getNodeName`.
15990 */
15991var nodeNamePattern = /^\s*<(\w+)/;
15992
15993/**
15994 * Extracts the `nodeName` of the first element in a string of markup.
15995 *
15996 * @param {string} markup String of markup.
15997 * @return {?string} Node name of the supplied markup.
15998 */
15999function getNodeName(markup) {
16000 var nodeNameMatch = markup.match(nodeNamePattern);
16001 return nodeNameMatch && nodeNameMatch[1].toLowerCase();
16002}
16003
16004/**
16005 * Creates an array containing the nodes rendered from the supplied markup. The
16006 * optionally supplied `handleScript` function will be invoked once for each
16007 * <script> element that is rendered. If no `handleScript` function is supplied,
16008 * an exception is thrown if any <script> elements are rendered.
16009 *
16010 * @param {string} markup A string of valid HTML markup.
16011 * @param {?function} handleScript Invoked once for each rendered <script>.
16012 * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
16013 */
16014function createNodesFromMarkup(markup, handleScript) {
16015 var node = dummyNode;
16016 ("production" !== "development" ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
16017 var nodeName = getNodeName(markup);
16018
16019 var wrap = nodeName && getMarkupWrap(nodeName);
16020 if (wrap) {
16021 node.innerHTML = wrap[1] + markup + wrap[2];
16022
16023 var wrapDepth = wrap[0];
16024 while (wrapDepth--) {
16025 node = node.lastChild;
16026 }
16027 } else {
16028 node.innerHTML = markup;
16029 }
16030
16031 var scripts = node.getElementsByTagName('script');
16032 if (scripts.length) {
16033 ("production" !== "development" ? invariant(
16034 handleScript,
16035 'createNodesFromMarkup(...): Unexpected <script> element rendered.'
16036 ) : invariant(handleScript));
16037 createArrayFrom(scripts).forEach(handleScript);
16038 }
16039
16040 var nodes = createArrayFrom(node.childNodes);
16041 while (node.lastChild) {
16042 node.removeChild(node.lastChild);
16043 }
16044 return nodes;
16045}
16046
16047module.exports = createNodesFromMarkup;
16048
16049},{"./ExecutionEnvironment":22,"./createArrayFrom":102,"./getMarkupWrap":118,"./invariant":126}],105:[function(_dereq_,module,exports){
16050/**
16051 * Copyright 2013-2014, Facebook, Inc.
16052 * All rights reserved.
16053 *
16054 * This source code is licensed under the BSD-style license found in the
16055 * LICENSE file in the root directory of this source tree. An additional grant
16056 * of patent rights can be found in the PATENTS file in the same directory.
16057 *
16058 * @providesModule dangerousStyleValue
16059 * @typechecks static-only
16060 */
16061
16062"use strict";
16063
16064var CSSProperty = _dereq_("./CSSProperty");
16065
16066var isUnitlessNumber = CSSProperty.isUnitlessNumber;
16067
16068/**
16069 * Convert a value into the proper css writable value. The style name `name`
16070 * should be logical (no hyphens), as specified
16071 * in `CSSProperty.isUnitlessNumber`.
16072 *
16073 * @param {string} name CSS property name such as `topMargin`.
16074 * @param {*} value CSS property value such as `10px`.
16075 * @return {string} Normalized style value with dimensions applied.
16076 */
16077function dangerousStyleValue(name, value) {
16078 // Note that we've removed escapeTextForBrowser() calls here since the
16079 // whole string will be escaped when the attribute is injected into
16080 // the markup. If you provide unsafe user data here they can inject
16081 // arbitrary CSS which may be problematic (I couldn't repro this):
16082 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
16083 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
16084 // This is not an XSS hole but instead a potential CSS injection issue
16085 // which has lead to a greater discussion about how we're going to
16086 // trust URLs moving forward. See #2115901
16087
16088 var isEmpty = value == null || typeof value === 'boolean' || value === '';
16089 if (isEmpty) {
16090 return '';
16091 }
16092
16093 var isNonNumeric = isNaN(value);
16094 if (isNonNumeric || value === 0 ||
16095 isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
16096 return '' + value; // cast to string
16097 }
16098
16099 if (typeof value === 'string') {
16100 value = value.trim();
16101 }
16102 return value + 'px';
16103}
16104
16105module.exports = dangerousStyleValue;
16106
16107},{"./CSSProperty":4}],106:[function(_dereq_,module,exports){
16108/**
16109 * Copyright 2013-2014, Facebook, Inc.
16110 * All rights reserved.
16111 *
16112 * This source code is licensed under the BSD-style license found in the
16113 * LICENSE file in the root directory of this source tree. An additional grant
16114 * of patent rights can be found in the PATENTS file in the same directory.
16115 *
16116 * @providesModule deprecated
16117 */
16118
16119var assign = _dereq_("./Object.assign");
16120var warning = _dereq_("./warning");
16121
16122/**
16123 * This will log a single deprecation notice per function and forward the call
16124 * on to the new API.
16125 *
16126 * @param {string} namespace The namespace of the call, eg 'React'
16127 * @param {string} oldName The old function name, eg 'renderComponent'
16128 * @param {string} newName The new function name, eg 'render'
16129 * @param {*} ctx The context this forwarded call should run in
16130 * @param {function} fn The function to forward on to
16131 * @return {*} Will be the value as returned from `fn`
16132 */
16133function deprecated(namespace, oldName, newName, ctx, fn) {
16134 var warned = false;
16135 if ("production" !== "development") {
16136 var newFn = function() {
16137 ("production" !== "development" ? warning(
16138 warned,
16139 (namespace + "." + oldName + " will be deprecated in a future version. ") +
16140 ("Use " + namespace + "." + newName + " instead.")
16141 ) : null);
16142 warned = true;
16143 return fn.apply(ctx, arguments);
16144 };
16145 newFn.displayName = (namespace + "_" + oldName);
16146 // We need to make sure all properties of the original fn are copied over.
16147 // In particular, this is needed to support PropTypes
16148 return assign(newFn, fn);
16149 }
16150
16151 return fn;
16152}
16153
16154module.exports = deprecated;
16155
16156},{"./Object.assign":27,"./warning":145}],107:[function(_dereq_,module,exports){
16157/**
16158 * Copyright 2013-2014, Facebook, Inc.
16159 * All rights reserved.
16160 *
16161 * This source code is licensed under the BSD-style license found in the
16162 * LICENSE file in the root directory of this source tree. An additional grant
16163 * of patent rights can be found in the PATENTS file in the same directory.
16164 *
16165 * @providesModule emptyFunction
16166 */
16167
16168function makeEmptyFunction(arg) {
16169 return function() {
16170 return arg;
16171 };
16172}
16173
16174/**
16175 * This function accepts and discards inputs; it has no side effects. This is
16176 * primarily useful idiomatically for overridable function endpoints which
16177 * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
16178 */
16179function emptyFunction() {}
16180
16181emptyFunction.thatReturns = makeEmptyFunction;
16182emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
16183emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
16184emptyFunction.thatReturnsNull = makeEmptyFunction(null);
16185emptyFunction.thatReturnsThis = function() { return this; };
16186emptyFunction.thatReturnsArgument = function(arg) { return arg; };
16187
16188module.exports = emptyFunction;
16189
16190},{}],108:[function(_dereq_,module,exports){
16191/**
16192 * Copyright 2013-2014, Facebook, Inc.
16193 * All rights reserved.
16194 *
16195 * This source code is licensed under the BSD-style license found in the
16196 * LICENSE file in the root directory of this source tree. An additional grant
16197 * of patent rights can be found in the PATENTS file in the same directory.
16198 *
16199 * @providesModule emptyObject
16200 */
16201
16202"use strict";
16203
16204var emptyObject = {};
16205
16206if ("production" !== "development") {
16207 Object.freeze(emptyObject);
16208}
16209
16210module.exports = emptyObject;
16211
16212},{}],109:[function(_dereq_,module,exports){
16213/**
16214 * Copyright 2013-2014, Facebook, Inc.
16215 * All rights reserved.
16216 *
16217 * This source code is licensed under the BSD-style license found in the
16218 * LICENSE file in the root directory of this source tree. An additional grant
16219 * of patent rights can be found in the PATENTS file in the same directory.
16220 *
16221 * @providesModule escapeTextForBrowser
16222 * @typechecks static-only
16223 */
16224
16225"use strict";
16226
16227var ESCAPE_LOOKUP = {
16228 "&": "&amp;",
16229 ">": "&gt;",
16230 "<": "&lt;",
16231 "\"": "&quot;",
16232 "'": "&#x27;"
16233};
16234
16235var ESCAPE_REGEX = /[&><"']/g;
16236
16237function escaper(match) {
16238 return ESCAPE_LOOKUP[match];
16239}
16240
16241/**
16242 * Escapes text to prevent scripting attacks.
16243 *
16244 * @param {*} text Text value to escape.
16245 * @return {string} An escaped string.
16246 */
16247function escapeTextForBrowser(text) {
16248 return ('' + text).replace(ESCAPE_REGEX, escaper);
16249}
16250
16251module.exports = escapeTextForBrowser;
16252
16253},{}],110:[function(_dereq_,module,exports){
16254/**
16255 * Copyright 2013-2014, Facebook, Inc.
16256 * All rights reserved.
16257 *
16258 * This source code is licensed under the BSD-style license found in the
16259 * LICENSE file in the root directory of this source tree. An additional grant
16260 * of patent rights can be found in the PATENTS file in the same directory.
16261 *
16262 * @providesModule flattenChildren
16263 */
16264
16265"use strict";
16266
16267var ReactTextComponent = _dereq_("./ReactTextComponent");
16268
16269var traverseAllChildren = _dereq_("./traverseAllChildren");
16270var warning = _dereq_("./warning");
16271
16272/**
16273 * @param {function} traverseContext Context passed through traversal.
16274 * @param {?ReactComponent} child React child component.
16275 * @param {!string} name String name of key path to child.
16276 */
16277function flattenSingleChildIntoContext(traverseContext, child, name) {
16278 // We found a component instance.
16279 var result = traverseContext;
16280 var keyUnique = !result.hasOwnProperty(name);
16281 ("production" !== "development" ? warning(
16282 keyUnique,
16283 'flattenChildren(...): Encountered two children with the same key, ' +
16284 '`%s`. Child keys must be unique; when two children share a key, only ' +
16285 'the first child will be used.',
16286 name
16287 ) : null);
16288 if (keyUnique && child != null) {
16289 var type = typeof child;
16290 var normalizedValue;
16291
16292 if (type === 'string') {
16293 normalizedValue = ReactTextComponent(child);
16294 } else if (type === 'number') {
16295 normalizedValue = ReactTextComponent('' + child);
16296 } else {
16297 normalizedValue = child;
16298 }
16299
16300 result[name] = normalizedValue;
16301 }
16302}
16303
16304/**
16305 * Flattens children that are typically specified as `props.children`. Any null
16306 * children will not be included in the resulting object.
16307 * @return {!object} flattened children keyed by name.
16308 */
16309function flattenChildren(children) {
16310 if (children == null) {
16311 return children;
16312 }
16313 var result = {};
16314 traverseAllChildren(children, flattenSingleChildIntoContext, result);
16315 return result;
16316}
16317
16318module.exports = flattenChildren;
16319
16320},{"./ReactTextComponent":78,"./traverseAllChildren":144,"./warning":145}],111:[function(_dereq_,module,exports){
16321/**
16322 * Copyright 2014, Facebook, Inc.
16323 * All rights reserved.
16324 *
16325 * This source code is licensed under the BSD-style license found in the
16326 * LICENSE file in the root directory of this source tree. An additional grant
16327 * of patent rights can be found in the PATENTS file in the same directory.
16328 *
16329 * @providesModule focusNode
16330 */
16331
16332"use strict";
16333
16334/**
16335 * @param {DOMElement} node input/textarea to focus
16336 */
16337function focusNode(node) {
16338 // IE8 can throw "Can't move focus to the control because it is invisible,
16339 // not enabled, or of a type that does not accept the focus." for all kinds of
16340 // reasons that are too expensive and fragile to test.
16341 try {
16342 node.focus();
16343 } catch(e) {
16344 }
16345}
16346
16347module.exports = focusNode;
16348
16349},{}],112:[function(_dereq_,module,exports){
16350/**
16351 * Copyright 2013-2014, Facebook, Inc.
16352 * All rights reserved.
16353 *
16354 * This source code is licensed under the BSD-style license found in the
16355 * LICENSE file in the root directory of this source tree. An additional grant
16356 * of patent rights can be found in the PATENTS file in the same directory.
16357 *
16358 * @providesModule forEachAccumulated
16359 */
16360
16361"use strict";
16362
16363/**
16364 * @param {array} an "accumulation" of items which is either an Array or
16365 * a single item. Useful when paired with the `accumulate` module. This is a
16366 * simple utility that allows us to reason about a collection of items, but
16367 * handling the case when there is exactly one item (and we do not need to
16368 * allocate an array).
16369 */
16370var forEachAccumulated = function(arr, cb, scope) {
16371 if (Array.isArray(arr)) {
16372 arr.forEach(cb, scope);
16373 } else if (arr) {
16374 cb.call(scope, arr);
16375 }
16376};
16377
16378module.exports = forEachAccumulated;
16379
16380},{}],113:[function(_dereq_,module,exports){
16381/**
16382 * Copyright 2013-2014, Facebook, Inc.
16383 * All rights reserved.
16384 *
16385 * This source code is licensed under the BSD-style license found in the
16386 * LICENSE file in the root directory of this source tree. An additional grant
16387 * of patent rights can be found in the PATENTS file in the same directory.
16388 *
16389 * @providesModule getActiveElement
16390 * @typechecks
16391 */
16392
16393/**
16394 * Same as document.activeElement but wraps in a try-catch block. In IE it is
16395 * not safe to call document.activeElement if there is nothing focused.
16396 *
16397 * The activeElement will be null only if the document body is not yet defined.
16398 */
16399function getActiveElement() /*?DOMElement*/ {
16400 try {
16401 return document.activeElement || document.body;
16402 } catch (e) {
16403 return document.body;
16404 }
16405}
16406
16407module.exports = getActiveElement;
16408
16409},{}],114:[function(_dereq_,module,exports){
16410/**
16411 * Copyright 2013-2014, Facebook, Inc.
16412 * All rights reserved.
16413 *
16414 * This source code is licensed under the BSD-style license found in the
16415 * LICENSE file in the root directory of this source tree. An additional grant
16416 * of patent rights can be found in the PATENTS file in the same directory.
16417 *
16418 * @providesModule getEventCharCode
16419 * @typechecks static-only
16420 */
16421
16422"use strict";
16423
16424/**
16425 * `charCode` represents the actual "character code" and is safe to use with
16426 * `String.fromCharCode`. As such, only keys that correspond to printable
16427 * characters produce a valid `charCode`, the only exception to this is Enter.
16428 * The Tab-key is considered non-printable and does not have a `charCode`,
16429 * presumably because it does not produce a tab-character in browsers.
16430 *
16431 * @param {object} nativeEvent Native browser event.
16432 * @return {string} Normalized `charCode` property.
16433 */
16434function getEventCharCode(nativeEvent) {
16435 var charCode;
16436 var keyCode = nativeEvent.keyCode;
16437
16438 if ('charCode' in nativeEvent) {
16439 charCode = nativeEvent.charCode;
16440
16441 // FF does not set `charCode` for the Enter-key, check against `keyCode`.
16442 if (charCode === 0 && keyCode === 13) {
16443 charCode = 13;
16444 }
16445 } else {
16446 // IE8 does not implement `charCode`, but `keyCode` has the correct value.
16447 charCode = keyCode;
16448 }
16449
16450 // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
16451 // Must not discard the (non-)printable Enter-key.
16452 if (charCode >= 32 || charCode === 13) {
16453 return charCode;
16454 }
16455
16456 return 0;
16457}
16458
16459module.exports = getEventCharCode;
16460
16461},{}],115:[function(_dereq_,module,exports){
16462/**
16463 * Copyright 2013-2014, Facebook, Inc.
16464 * All rights reserved.
16465 *
16466 * This source code is licensed under the BSD-style license found in the
16467 * LICENSE file in the root directory of this source tree. An additional grant
16468 * of patent rights can be found in the PATENTS file in the same directory.
16469 *
16470 * @providesModule getEventKey
16471 * @typechecks static-only
16472 */
16473
16474"use strict";
16475
16476var getEventCharCode = _dereq_("./getEventCharCode");
16477
16478/**
16479 * Normalization of deprecated HTML5 `key` values
16480 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
16481 */
16482var normalizeKey = {
16483 'Esc': 'Escape',
16484 'Spacebar': ' ',
16485 'Left': 'ArrowLeft',
16486 'Up': 'ArrowUp',
16487 'Right': 'ArrowRight',
16488 'Down': 'ArrowDown',
16489 'Del': 'Delete',
16490 'Win': 'OS',
16491 'Menu': 'ContextMenu',
16492 'Apps': 'ContextMenu',
16493 'Scroll': 'ScrollLock',
16494 'MozPrintableKey': 'Unidentified'
16495};
16496
16497/**
16498 * Translation from legacy `keyCode` to HTML5 `key`
16499 * Only special keys supported, all others depend on keyboard layout or browser
16500 * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
16501 */
16502var translateToKey = {
16503 8: 'Backspace',
16504 9: 'Tab',
16505 12: 'Clear',
16506 13: 'Enter',
16507 16: 'Shift',
16508 17: 'Control',
16509 18: 'Alt',
16510 19: 'Pause',
16511 20: 'CapsLock',
16512 27: 'Escape',
16513 32: ' ',
16514 33: 'PageUp',
16515 34: 'PageDown',
16516 35: 'End',
16517 36: 'Home',
16518 37: 'ArrowLeft',
16519 38: 'ArrowUp',
16520 39: 'ArrowRight',
16521 40: 'ArrowDown',
16522 45: 'Insert',
16523 46: 'Delete',
16524 112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
16525 118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
16526 144: 'NumLock',
16527 145: 'ScrollLock',
16528 224: 'Meta'
16529};
16530
16531/**
16532 * @param {object} nativeEvent Native browser event.
16533 * @return {string} Normalized `key` property.
16534 */
16535function getEventKey(nativeEvent) {
16536 if (nativeEvent.key) {
16537 // Normalize inconsistent values reported by browsers due to
16538 // implementations of a working draft specification.
16539
16540 // FireFox implements `key` but returns `MozPrintableKey` for all
16541 // printable characters (normalized to `Unidentified`), ignore it.
16542 var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
16543 if (key !== 'Unidentified') {
16544 return key;
16545 }
16546 }
16547
16548 // Browser does not implement `key`, polyfill as much of it as we can.
16549 if (nativeEvent.type === 'keypress') {
16550 var charCode = getEventCharCode(nativeEvent);
16551
16552 // The enter-key is technically both printable and non-printable and can
16553 // thus be captured by `keypress`, no other non-printable key should.
16554 return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
16555 }
16556 if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
16557 // While user keyboard layout determines the actual meaning of each
16558 // `keyCode` value, almost all function keys have a universal value.
16559 return translateToKey[nativeEvent.keyCode] || 'Unidentified';
16560 }
16561 return '';
16562}
16563
16564module.exports = getEventKey;
16565
16566},{"./getEventCharCode":114}],116:[function(_dereq_,module,exports){
16567/**
16568 * Copyright 2013 Facebook, Inc.
16569 * All rights reserved.
16570 *
16571 * This source code is licensed under the BSD-style license found in the
16572 * LICENSE file in the root directory of this source tree. An additional grant
16573 * of patent rights can be found in the PATENTS file in the same directory.
16574 *
16575 * @providesModule getEventModifierState
16576 * @typechecks static-only
16577 */
16578
16579"use strict";
16580
16581/**
16582 * Translation from modifier key to the associated property in the event.
16583 * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
16584 */
16585
16586var modifierKeyToProp = {
16587 'Alt': 'altKey',
16588 'Control': 'ctrlKey',
16589 'Meta': 'metaKey',
16590 'Shift': 'shiftKey'
16591};
16592
16593// IE8 does not implement getModifierState so we simply map it to the only
16594// modifier keys exposed by the event itself, does not support Lock-keys.
16595// Currently, all major browsers except Chrome seems to support Lock-keys.
16596function modifierStateGetter(keyArg) {
16597 /*jshint validthis:true */
16598 var syntheticEvent = this;
16599 var nativeEvent = syntheticEvent.nativeEvent;
16600 if (nativeEvent.getModifierState) {
16601 return nativeEvent.getModifierState(keyArg);
16602 }
16603 var keyProp = modifierKeyToProp[keyArg];
16604 return keyProp ? !!nativeEvent[keyProp] : false;
16605}
16606
16607function getEventModifierState(nativeEvent) {
16608 return modifierStateGetter;
16609}
16610
16611module.exports = getEventModifierState;
16612
16613},{}],117:[function(_dereq_,module,exports){
16614/**
16615 * Copyright 2013-2014, Facebook, Inc.
16616 * All rights reserved.
16617 *
16618 * This source code is licensed under the BSD-style license found in the
16619 * LICENSE file in the root directory of this source tree. An additional grant
16620 * of patent rights can be found in the PATENTS file in the same directory.
16621 *
16622 * @providesModule getEventTarget
16623 * @typechecks static-only
16624 */
16625
16626"use strict";
16627
16628/**
16629 * Gets the target node from a native browser event by accounting for
16630 * inconsistencies in browser DOM APIs.
16631 *
16632 * @param {object} nativeEvent Native browser event.
16633 * @return {DOMEventTarget} Target node.
16634 */
16635function getEventTarget(nativeEvent) {
16636 var target = nativeEvent.target || nativeEvent.srcElement || window;
16637 // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
16638 // @see http://www.quirksmode.org/js/events_properties.html
16639 return target.nodeType === 3 ? target.parentNode : target;
16640}
16641
16642module.exports = getEventTarget;
16643
16644},{}],118:[function(_dereq_,module,exports){
16645/**
16646 * Copyright 2013-2014, Facebook, Inc.
16647 * All rights reserved.
16648 *
16649 * This source code is licensed under the BSD-style license found in the
16650 * LICENSE file in the root directory of this source tree. An additional grant
16651 * of patent rights can be found in the PATENTS file in the same directory.
16652 *
16653 * @providesModule getMarkupWrap
16654 */
16655
16656var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
16657
16658var invariant = _dereq_("./invariant");
16659
16660/**
16661 * Dummy container used to detect which wraps are necessary.
16662 */
16663var dummyNode =
16664 ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
16665
16666/**
16667 * Some browsers cannot use `innerHTML` to render certain elements standalone,
16668 * so we wrap them, render the wrapped nodes, then extract the desired node.
16669 *
16670 * In IE8, certain elements cannot render alone, so wrap all elements ('*').
16671 */
16672var shouldWrap = {
16673 // Force wrapping for SVG elements because if they get created inside a <div>,
16674 // they will be initialized in the wrong namespace (and will not display).
16675 'circle': true,
16676 'defs': true,
16677 'ellipse': true,
16678 'g': true,
16679 'line': true,
16680 'linearGradient': true,
16681 'path': true,
16682 'polygon': true,
16683 'polyline': true,
16684 'radialGradient': true,
16685 'rect': true,
16686 'stop': true,
16687 'text': true
16688};
16689
16690var selectWrap = [1, '<select multiple="true">', '</select>'];
16691var tableWrap = [1, '<table>', '</table>'];
16692var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
16693
16694var svgWrap = [1, '<svg>', '</svg>'];
16695
16696var markupWrap = {
16697 '*': [1, '?<div>', '</div>'],
16698
16699 'area': [1, '<map>', '</map>'],
16700 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
16701 'legend': [1, '<fieldset>', '</fieldset>'],
16702 'param': [1, '<object>', '</object>'],
16703 'tr': [2, '<table><tbody>', '</tbody></table>'],
16704
16705 'optgroup': selectWrap,
16706 'option': selectWrap,
16707
16708 'caption': tableWrap,
16709 'colgroup': tableWrap,
16710 'tbody': tableWrap,
16711 'tfoot': tableWrap,
16712 'thead': tableWrap,
16713
16714 'td': trWrap,
16715 'th': trWrap,
16716
16717 'circle': svgWrap,
16718 'defs': svgWrap,
16719 'ellipse': svgWrap,
16720 'g': svgWrap,
16721 'line': svgWrap,
16722 'linearGradient': svgWrap,
16723 'path': svgWrap,
16724 'polygon': svgWrap,
16725 'polyline': svgWrap,
16726 'radialGradient': svgWrap,
16727 'rect': svgWrap,
16728 'stop': svgWrap,
16729 'text': svgWrap
16730};
16731
16732/**
16733 * Gets the markup wrap configuration for the supplied `nodeName`.
16734 *
16735 * NOTE: This lazily detects which wraps are necessary for the current browser.
16736 *
16737 * @param {string} nodeName Lowercase `nodeName`.
16738 * @return {?array} Markup wrap configuration, if applicable.
16739 */
16740function getMarkupWrap(nodeName) {
16741 ("production" !== "development" ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
16742 if (!markupWrap.hasOwnProperty(nodeName)) {
16743 nodeName = '*';
16744 }
16745 if (!shouldWrap.hasOwnProperty(nodeName)) {
16746 if (nodeName === '*') {
16747 dummyNode.innerHTML = '<link />';
16748 } else {
16749 dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
16750 }
16751 shouldWrap[nodeName] = !dummyNode.firstChild;
16752 }
16753 return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
16754}
16755
16756
16757module.exports = getMarkupWrap;
16758
16759},{"./ExecutionEnvironment":22,"./invariant":126}],119:[function(_dereq_,module,exports){
16760/**
16761 * Copyright 2013-2014, Facebook, Inc.
16762 * All rights reserved.
16763 *
16764 * This source code is licensed under the BSD-style license found in the
16765 * LICENSE file in the root directory of this source tree. An additional grant
16766 * of patent rights can be found in the PATENTS file in the same directory.
16767 *
16768 * @providesModule getNodeForCharacterOffset
16769 */
16770
16771"use strict";
16772
16773/**
16774 * Given any node return the first leaf node without children.
16775 *
16776 * @param {DOMElement|DOMTextNode} node
16777 * @return {DOMElement|DOMTextNode}
16778 */
16779function getLeafNode(node) {
16780 while (node && node.firstChild) {
16781 node = node.firstChild;
16782 }
16783 return node;
16784}
16785
16786/**
16787 * Get the next sibling within a container. This will walk up the
16788 * DOM if a node's siblings have been exhausted.
16789 *
16790 * @param {DOMElement|DOMTextNode} node
16791 * @return {?DOMElement|DOMTextNode}
16792 */
16793function getSiblingNode(node) {
16794 while (node) {
16795 if (node.nextSibling) {
16796 return node.nextSibling;
16797 }
16798 node = node.parentNode;
16799 }
16800}
16801
16802/**
16803 * Get object describing the nodes which contain characters at offset.
16804 *
16805 * @param {DOMElement|DOMTextNode} root
16806 * @param {number} offset
16807 * @return {?object}
16808 */
16809function getNodeForCharacterOffset(root, offset) {
16810 var node = getLeafNode(root);
16811 var nodeStart = 0;
16812 var nodeEnd = 0;
16813
16814 while (node) {
16815 if (node.nodeType == 3) {
16816 nodeEnd = nodeStart + node.textContent.length;
16817
16818 if (nodeStart <= offset && nodeEnd >= offset) {
16819 return {
16820 node: node,
16821 offset: offset - nodeStart
16822 };
16823 }
16824
16825 nodeStart = nodeEnd;
16826 }
16827
16828 node = getLeafNode(getSiblingNode(node));
16829 }
16830}
16831
16832module.exports = getNodeForCharacterOffset;
16833
16834},{}],120:[function(_dereq_,module,exports){
16835/**
16836 * Copyright 2013-2014, Facebook, Inc.
16837 * All rights reserved.
16838 *
16839 * This source code is licensed under the BSD-style license found in the
16840 * LICENSE file in the root directory of this source tree. An additional grant
16841 * of patent rights can be found in the PATENTS file in the same directory.
16842 *
16843 * @providesModule getReactRootElementInContainer
16844 */
16845
16846"use strict";
16847
16848var DOC_NODE_TYPE = 9;
16849
16850/**
16851 * @param {DOMElement|DOMDocument} container DOM element that may contain
16852 * a React component
16853 * @return {?*} DOM element that may have the reactRoot ID, or null.
16854 */
16855function getReactRootElementInContainer(container) {
16856 if (!container) {
16857 return null;
16858 }
16859
16860 if (container.nodeType === DOC_NODE_TYPE) {
16861 return container.documentElement;
16862 } else {
16863 return container.firstChild;
16864 }
16865}
16866
16867module.exports = getReactRootElementInContainer;
16868
16869},{}],121:[function(_dereq_,module,exports){
16870/**
16871 * Copyright 2013-2014, Facebook, Inc.
16872 * All rights reserved.
16873 *
16874 * This source code is licensed under the BSD-style license found in the
16875 * LICENSE file in the root directory of this source tree. An additional grant
16876 * of patent rights can be found in the PATENTS file in the same directory.
16877 *
16878 * @providesModule getTextContentAccessor
16879 */
16880
16881"use strict";
16882
16883var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
16884
16885var contentKey = null;
16886
16887/**
16888 * Gets the key used to access text content on a DOM node.
16889 *
16890 * @return {?string} Key used to access text content.
16891 * @internal
16892 */
16893function getTextContentAccessor() {
16894 if (!contentKey && ExecutionEnvironment.canUseDOM) {
16895 // Prefer textContent to innerText because many browsers support both but
16896 // SVG <text> elements don't support innerText even when <div> does.
16897 contentKey = 'textContent' in document.documentElement ?
16898 'textContent' :
16899 'innerText';
16900 }
16901 return contentKey;
16902}
16903
16904module.exports = getTextContentAccessor;
16905
16906},{"./ExecutionEnvironment":22}],122:[function(_dereq_,module,exports){
16907/**
16908 * Copyright 2013-2014, Facebook, Inc.
16909 * All rights reserved.
16910 *
16911 * This source code is licensed under the BSD-style license found in the
16912 * LICENSE file in the root directory of this source tree. An additional grant
16913 * of patent rights can be found in the PATENTS file in the same directory.
16914 *
16915 * @providesModule getUnboundedScrollPosition
16916 * @typechecks
16917 */
16918
16919"use strict";
16920
16921/**
16922 * Gets the scroll position of the supplied element or window.
16923 *
16924 * The return values are unbounded, unlike `getScrollPosition`. This means they
16925 * may be negative or exceed the element boundaries (which is possible using
16926 * inertial scrolling).
16927 *
16928 * @param {DOMWindow|DOMElement} scrollable
16929 * @return {object} Map with `x` and `y` keys.
16930 */
16931function getUnboundedScrollPosition(scrollable) {
16932 if (scrollable === window) {
16933 return {
16934 x: window.pageXOffset || document.documentElement.scrollLeft,
16935 y: window.pageYOffset || document.documentElement.scrollTop
16936 };
16937 }
16938 return {
16939 x: scrollable.scrollLeft,
16940 y: scrollable.scrollTop
16941 };
16942}
16943
16944module.exports = getUnboundedScrollPosition;
16945
16946},{}],123:[function(_dereq_,module,exports){
16947/**
16948 * Copyright 2013-2014, Facebook, Inc.
16949 * All rights reserved.
16950 *
16951 * This source code is licensed under the BSD-style license found in the
16952 * LICENSE file in the root directory of this source tree. An additional grant
16953 * of patent rights can be found in the PATENTS file in the same directory.
16954 *
16955 * @providesModule hyphenate
16956 * @typechecks
16957 */
16958
16959var _uppercasePattern = /([A-Z])/g;
16960
16961/**
16962 * Hyphenates a camelcased string, for example:
16963 *
16964 * > hyphenate('backgroundColor')
16965 * < "background-color"
16966 *
16967 * For CSS style names, use `hyphenateStyleName` instead which works properly
16968 * with all vendor prefixes, including `ms`.
16969 *
16970 * @param {string} string
16971 * @return {string}
16972 */
16973function hyphenate(string) {
16974 return string.replace(_uppercasePattern, '-$1').toLowerCase();
16975}
16976
16977module.exports = hyphenate;
16978
16979},{}],124:[function(_dereq_,module,exports){
16980/**
16981 * Copyright 2013-2014, Facebook, Inc.
16982 * All rights reserved.
16983 *
16984 * This source code is licensed under the BSD-style license found in the
16985 * LICENSE file in the root directory of this source tree. An additional grant
16986 * of patent rights can be found in the PATENTS file in the same directory.
16987 *
16988 * @providesModule hyphenateStyleName
16989 * @typechecks
16990 */
16991
16992"use strict";
16993
16994var hyphenate = _dereq_("./hyphenate");
16995
16996var msPattern = /^ms-/;
16997
16998/**
16999 * Hyphenates a camelcased CSS property name, for example:
17000 *
17001 * > hyphenateStyleName('backgroundColor')
17002 * < "background-color"
17003 * > hyphenateStyleName('MozTransition')
17004 * < "-moz-transition"
17005 * > hyphenateStyleName('msTransition')
17006 * < "-ms-transition"
17007 *
17008 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
17009 * is converted to `-ms-`.
17010 *
17011 * @param {string} string
17012 * @return {string}
17013 */
17014function hyphenateStyleName(string) {
17015 return hyphenate(string).replace(msPattern, '-ms-');
17016}
17017
17018module.exports = hyphenateStyleName;
17019
17020},{"./hyphenate":123}],125:[function(_dereq_,module,exports){
17021/**
17022 * Copyright 2013-2014, Facebook, Inc.
17023 * All rights reserved.
17024 *
17025 * This source code is licensed under the BSD-style license found in the
17026 * LICENSE file in the root directory of this source tree. An additional grant
17027 * of patent rights can be found in the PATENTS file in the same directory.
17028 *
17029 * @providesModule instantiateReactComponent
17030 * @typechecks static-only
17031 */
17032
17033"use strict";
17034
17035var warning = _dereq_("./warning");
17036
17037var ReactElement = _dereq_("./ReactElement");
17038var ReactLegacyElement = _dereq_("./ReactLegacyElement");
17039var ReactNativeComponent = _dereq_("./ReactNativeComponent");
17040var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
17041
17042/**
17043 * Given an `element` create an instance that will actually be mounted.
17044 *
17045 * @param {object} element
17046 * @param {*} parentCompositeType The composite type that resolved this.
17047 * @return {object} A new instance of the element's constructor.
17048 * @protected
17049 */
17050function instantiateReactComponent(element, parentCompositeType) {
17051 var instance;
17052
17053 if ("production" !== "development") {
17054 ("production" !== "development" ? warning(
17055 element && (typeof element.type === 'function' ||
17056 typeof element.type === 'string'),
17057 'Only functions or strings can be mounted as React components.'
17058 ) : null);
17059
17060 // Resolve mock instances
17061 if (element.type._mockedReactClassConstructor) {
17062 // If this is a mocked class, we treat the legacy factory as if it was the
17063 // class constructor for future proofing unit tests. Because this might
17064 // be mocked as a legacy factory, we ignore any warnings triggerd by
17065 // this temporary hack.
17066 ReactLegacyElement._isLegacyCallWarningEnabled = false;
17067 try {
17068 instance = new element.type._mockedReactClassConstructor(
17069 element.props
17070 );
17071 } finally {
17072 ReactLegacyElement._isLegacyCallWarningEnabled = true;
17073 }
17074
17075 // If the mock implementation was a legacy factory, then it returns a
17076 // element. We need to turn this into a real component instance.
17077 if (ReactElement.isValidElement(instance)) {
17078 instance = new instance.type(instance.props);
17079 }
17080
17081 var render = instance.render;
17082 if (!render) {
17083 // For auto-mocked factories, the prototype isn't shimmed and therefore
17084 // there is no render function on the instance. We replace the whole
17085 // component with an empty component instance instead.
17086 element = ReactEmptyComponent.getEmptyComponent();
17087 } else {
17088 if (render._isMockFunction && !render._getMockImplementation()) {
17089 // Auto-mocked components may have a prototype with a mocked render
17090 // function. For those, we'll need to mock the result of the render
17091 // since we consider undefined to be invalid results from render.
17092 render.mockImplementation(
17093 ReactEmptyComponent.getEmptyComponent
17094 );
17095 }
17096 instance.construct(element);
17097 return instance;
17098 }
17099 }
17100 }
17101
17102 // Special case string values
17103 if (typeof element.type === 'string') {
17104 instance = ReactNativeComponent.createInstanceForTag(
17105 element.type,
17106 element.props,
17107 parentCompositeType
17108 );
17109 } else {
17110 // Normal case for non-mocks and non-strings
17111 instance = new element.type(element.props);
17112 }
17113
17114 if ("production" !== "development") {
17115 ("production" !== "development" ? warning(
17116 typeof instance.construct === 'function' &&
17117 typeof instance.mountComponent === 'function' &&
17118 typeof instance.receiveComponent === 'function',
17119 'Only React Components can be mounted.'
17120 ) : null);
17121 }
17122
17123 // This actually sets up the internal instance. This will become decoupled
17124 // from the public instance in a future diff.
17125 instance.construct(element);
17126
17127 return instance;
17128}
17129
17130module.exports = instantiateReactComponent;
17131
17132},{"./ReactElement":52,"./ReactEmptyComponent":54,"./ReactLegacyElement":61,"./ReactNativeComponent":66,"./warning":145}],126:[function(_dereq_,module,exports){
17133/**
17134 * Copyright 2013-2014, Facebook, Inc.
17135 * All rights reserved.
17136 *
17137 * This source code is licensed under the BSD-style license found in the
17138 * LICENSE file in the root directory of this source tree. An additional grant
17139 * of patent rights can be found in the PATENTS file in the same directory.
17140 *
17141 * @providesModule invariant
17142 */
17143
17144"use strict";
17145
17146/**
17147 * Use invariant() to assert state which your program assumes to be true.
17148 *
17149 * Provide sprintf-style format (only %s is supported) and arguments
17150 * to provide information about what broke and what you were
17151 * expecting.
17152 *
17153 * The invariant message will be stripped in production, but the invariant
17154 * will remain to ensure logic does not differ in production.
17155 */
17156
17157var invariant = function(condition, format, a, b, c, d, e, f) {
17158 if ("production" !== "development") {
17159 if (format === undefined) {
17160 throw new Error('invariant requires an error message argument');
17161 }
17162 }
17163
17164 if (!condition) {
17165 var error;
17166 if (format === undefined) {
17167 error = new Error(
17168 'Minified exception occurred; use the non-minified dev environment ' +
17169 'for the full error message and additional helpful warnings.'
17170 );
17171 } else {
17172 var args = [a, b, c, d, e, f];
17173 var argIndex = 0;
17174 error = new Error(
17175 'Invariant Violation: ' +
17176 format.replace(/%s/g, function() { return args[argIndex++]; })
17177 );
17178 }
17179
17180 error.framesToPop = 1; // we don't care about invariant's own frame
17181 throw error;
17182 }
17183};
17184
17185module.exports = invariant;
17186
17187},{}],127:[function(_dereq_,module,exports){
17188/**
17189 * Copyright 2013-2014, Facebook, Inc.
17190 * All rights reserved.
17191 *
17192 * This source code is licensed under the BSD-style license found in the
17193 * LICENSE file in the root directory of this source tree. An additional grant
17194 * of patent rights can be found in the PATENTS file in the same directory.
17195 *
17196 * @providesModule isEventSupported
17197 */
17198
17199"use strict";
17200
17201var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
17202
17203var useHasFeature;
17204if (ExecutionEnvironment.canUseDOM) {
17205 useHasFeature =
17206 document.implementation &&
17207 document.implementation.hasFeature &&
17208 // always returns true in newer browsers as per the standard.
17209 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
17210 document.implementation.hasFeature('', '') !== true;
17211}
17212
17213/**
17214 * Checks if an event is supported in the current execution environment.
17215 *
17216 * NOTE: This will not work correctly for non-generic events such as `change`,
17217 * `reset`, `load`, `error`, and `select`.
17218 *
17219 * Borrows from Modernizr.
17220 *
17221 * @param {string} eventNameSuffix Event name, e.g. "click".
17222 * @param {?boolean} capture Check if the capture phase is supported.
17223 * @return {boolean} True if the event is supported.
17224 * @internal
17225 * @license Modernizr 3.0.0pre (Custom Build) | MIT
17226 */
17227function isEventSupported(eventNameSuffix, capture) {
17228 if (!ExecutionEnvironment.canUseDOM ||
17229 capture && !('addEventListener' in document)) {
17230 return false;
17231 }
17232
17233 var eventName = 'on' + eventNameSuffix;
17234 var isSupported = eventName in document;
17235
17236 if (!isSupported) {
17237 var element = document.createElement('div');
17238 element.setAttribute(eventName, 'return;');
17239 isSupported = typeof element[eventName] === 'function';
17240 }
17241
17242 if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
17243 // This is the only way to test support for the `wheel` event in IE9+.
17244 isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
17245 }
17246
17247 return isSupported;
17248}
17249
17250module.exports = isEventSupported;
17251
17252},{"./ExecutionEnvironment":22}],128:[function(_dereq_,module,exports){
17253/**
17254 * Copyright 2013-2014, Facebook, Inc.
17255 * All rights reserved.
17256 *
17257 * This source code is licensed under the BSD-style license found in the
17258 * LICENSE file in the root directory of this source tree. An additional grant
17259 * of patent rights can be found in the PATENTS file in the same directory.
17260 *
17261 * @providesModule isNode
17262 * @typechecks
17263 */
17264
17265/**
17266 * @param {*} object The object to check.
17267 * @return {boolean} Whether or not the object is a DOM node.
17268 */
17269function isNode(object) {
17270 return !!(object && (
17271 typeof Node === 'function' ? object instanceof Node :
17272 typeof object === 'object' &&
17273 typeof object.nodeType === 'number' &&
17274 typeof object.nodeName === 'string'
17275 ));
17276}
17277
17278module.exports = isNode;
17279
17280},{}],129:[function(_dereq_,module,exports){
17281/**
17282 * Copyright 2013-2014, Facebook, Inc.
17283 * All rights reserved.
17284 *
17285 * This source code is licensed under the BSD-style license found in the
17286 * LICENSE file in the root directory of this source tree. An additional grant
17287 * of patent rights can be found in the PATENTS file in the same directory.
17288 *
17289 * @providesModule isTextInputElement
17290 */
17291
17292"use strict";
17293
17294/**
17295 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
17296 */
17297var supportedInputTypes = {
17298 'color': true,
17299 'date': true,
17300 'datetime': true,
17301 'datetime-local': true,
17302 'email': true,
17303 'month': true,
17304 'number': true,
17305 'password': true,
17306 'range': true,
17307 'search': true,
17308 'tel': true,
17309 'text': true,
17310 'time': true,
17311 'url': true,
17312 'week': true
17313};
17314
17315function isTextInputElement(elem) {
17316 return elem && (
17317 (elem.nodeName === 'INPUT' && supportedInputTypes[elem.type]) ||
17318 elem.nodeName === 'TEXTAREA'
17319 );
17320}
17321
17322module.exports = isTextInputElement;
17323
17324},{}],130:[function(_dereq_,module,exports){
17325/**
17326 * Copyright 2013-2014, Facebook, Inc.
17327 * All rights reserved.
17328 *
17329 * This source code is licensed under the BSD-style license found in the
17330 * LICENSE file in the root directory of this source tree. An additional grant
17331 * of patent rights can be found in the PATENTS file in the same directory.
17332 *
17333 * @providesModule isTextNode
17334 * @typechecks
17335 */
17336
17337var isNode = _dereq_("./isNode");
17338
17339/**
17340 * @param {*} object The object to check.
17341 * @return {boolean} Whether or not the object is a DOM text node.
17342 */
17343function isTextNode(object) {
17344 return isNode(object) && object.nodeType == 3;
17345}
17346
17347module.exports = isTextNode;
17348
17349},{"./isNode":128}],131:[function(_dereq_,module,exports){
17350/**
17351 * Copyright 2013-2014, Facebook, Inc.
17352 * All rights reserved.
17353 *
17354 * This source code is licensed under the BSD-style license found in the
17355 * LICENSE file in the root directory of this source tree. An additional grant
17356 * of patent rights can be found in the PATENTS file in the same directory.
17357 *
17358 * @providesModule joinClasses
17359 * @typechecks static-only
17360 */
17361
17362"use strict";
17363
17364/**
17365 * Combines multiple className strings into one.
17366 * http://jsperf.com/joinclasses-args-vs-array
17367 *
17368 * @param {...?string} classes
17369 * @return {string}
17370 */
17371function joinClasses(className/*, ... */) {
17372 if (!className) {
17373 className = '';
17374 }
17375 var nextClass;
17376 var argLength = arguments.length;
17377 if (argLength > 1) {
17378 for (var ii = 1; ii < argLength; ii++) {
17379 nextClass = arguments[ii];
17380 if (nextClass) {
17381 className = (className ? className + ' ' : '') + nextClass;
17382 }
17383 }
17384 }
17385 return className;
17386}
17387
17388module.exports = joinClasses;
17389
17390},{}],132:[function(_dereq_,module,exports){
17391/**
17392 * Copyright 2013-2014, Facebook, Inc.
17393 * All rights reserved.
17394 *
17395 * This source code is licensed under the BSD-style license found in the
17396 * LICENSE file in the root directory of this source tree. An additional grant
17397 * of patent rights can be found in the PATENTS file in the same directory.
17398 *
17399 * @providesModule keyMirror
17400 * @typechecks static-only
17401 */
17402
17403"use strict";
17404
17405var invariant = _dereq_("./invariant");
17406
17407/**
17408 * Constructs an enumeration with keys equal to their value.
17409 *
17410 * For example:
17411 *
17412 * var COLORS = keyMirror({blue: null, red: null});
17413 * var myColor = COLORS.blue;
17414 * var isColorValid = !!COLORS[myColor];
17415 *
17416 * The last line could not be performed if the values of the generated enum were
17417 * not equal to their keys.
17418 *
17419 * Input: {key1: val1, key2: val2}
17420 * Output: {key1: key1, key2: key2}
17421 *
17422 * @param {object} obj
17423 * @return {object}
17424 */
17425var keyMirror = function(obj) {
17426 var ret = {};
17427 var key;
17428 ("production" !== "development" ? invariant(
17429 obj instanceof Object && !Array.isArray(obj),
17430 'keyMirror(...): Argument must be an object.'
17431 ) : invariant(obj instanceof Object && !Array.isArray(obj)));
17432 for (key in obj) {
17433 if (!obj.hasOwnProperty(key)) {
17434 continue;
17435 }
17436 ret[key] = key;
17437 }
17438 return ret;
17439};
17440
17441module.exports = keyMirror;
17442
17443},{"./invariant":126}],133:[function(_dereq_,module,exports){
17444/**
17445 * Copyright 2013-2014, Facebook, Inc.
17446 * All rights reserved.
17447 *
17448 * This source code is licensed under the BSD-style license found in the
17449 * LICENSE file in the root directory of this source tree. An additional grant
17450 * of patent rights can be found in the PATENTS file in the same directory.
17451 *
17452 * @providesModule keyOf
17453 */
17454
17455/**
17456 * Allows extraction of a minified key. Let's the build system minify keys
17457 * without loosing the ability to dynamically use key strings as values
17458 * themselves. Pass in an object with a single key/val pair and it will return
17459 * you the string key of that single record. Suppose you want to grab the
17460 * value for a key 'className' inside of an object. Key/val minification may
17461 * have aliased that key to be 'xa12'. keyOf({className: null}) will return
17462 * 'xa12' in that case. Resolve keys you want to use once at startup time, then
17463 * reuse those resolutions.
17464 */
17465var keyOf = function(oneKeyObj) {
17466 var key;
17467 for (key in oneKeyObj) {
17468 if (!oneKeyObj.hasOwnProperty(key)) {
17469 continue;
17470 }
17471 return key;
17472 }
17473 return null;
17474};
17475
17476
17477module.exports = keyOf;
17478
17479},{}],134:[function(_dereq_,module,exports){
17480/**
17481 * Copyright 2013-2014, Facebook, Inc.
17482 * All rights reserved.
17483 *
17484 * This source code is licensed under the BSD-style license found in the
17485 * LICENSE file in the root directory of this source tree. An additional grant
17486 * of patent rights can be found in the PATENTS file in the same directory.
17487 *
17488 * @providesModule mapObject
17489 */
17490
17491'use strict';
17492
17493var hasOwnProperty = Object.prototype.hasOwnProperty;
17494
17495/**
17496 * Executes the provided `callback` once for each enumerable own property in the
17497 * object and constructs a new object from the results. The `callback` is
17498 * invoked with three arguments:
17499 *
17500 * - the property value
17501 * - the property name
17502 * - the object being traversed
17503 *
17504 * Properties that are added after the call to `mapObject` will not be visited
17505 * by `callback`. If the values of existing properties are changed, the value
17506 * passed to `callback` will be the value at the time `mapObject` visits them.
17507 * Properties that are deleted before being visited are not visited.
17508 *
17509 * @grep function objectMap()
17510 * @grep function objMap()
17511 *
17512 * @param {?object} object
17513 * @param {function} callback
17514 * @param {*} context
17515 * @return {?object}
17516 */
17517function mapObject(object, callback, context) {
17518 if (!object) {
17519 return null;
17520 }
17521 var result = {};
17522 for (var name in object) {
17523 if (hasOwnProperty.call(object, name)) {
17524 result[name] = callback.call(context, object[name], name, object);
17525 }
17526 }
17527 return result;
17528}
17529
17530module.exports = mapObject;
17531
17532},{}],135:[function(_dereq_,module,exports){
17533/**
17534 * Copyright 2013-2014, Facebook, Inc.
17535 * All rights reserved.
17536 *
17537 * This source code is licensed under the BSD-style license found in the
17538 * LICENSE file in the root directory of this source tree. An additional grant
17539 * of patent rights can be found in the PATENTS file in the same directory.
17540 *
17541 * @providesModule memoizeStringOnly
17542 * @typechecks static-only
17543 */
17544
17545"use strict";
17546
17547/**
17548 * Memoizes the return value of a function that accepts one string argument.
17549 *
17550 * @param {function} callback
17551 * @return {function}
17552 */
17553function memoizeStringOnly(callback) {
17554 var cache = {};
17555 return function(string) {
17556 if (cache.hasOwnProperty(string)) {
17557 return cache[string];
17558 } else {
17559 return cache[string] = callback.call(this, string);
17560 }
17561 };
17562}
17563
17564module.exports = memoizeStringOnly;
17565
17566},{}],136:[function(_dereq_,module,exports){
17567/**
17568 * Copyright 2014, Facebook, Inc.
17569 * All rights reserved.
17570 *
17571 * This source code is licensed under the BSD-style license found in the
17572 * LICENSE file in the root directory of this source tree. An additional grant
17573 * of patent rights can be found in the PATENTS file in the same directory.
17574 *
17575 * @providesModule monitorCodeUse
17576 */
17577
17578"use strict";
17579
17580var invariant = _dereq_("./invariant");
17581
17582/**
17583 * Provides open-source compatible instrumentation for monitoring certain API
17584 * uses before we're ready to issue a warning or refactor. It accepts an event
17585 * name which may only contain the characters [a-z0-9_] and an optional data
17586 * object with further information.
17587 */
17588
17589function monitorCodeUse(eventName, data) {
17590 ("production" !== "development" ? invariant(
17591 eventName && !/[^a-z0-9_]/.test(eventName),
17592 'You must provide an eventName using only the characters [a-z0-9_]'
17593 ) : invariant(eventName && !/[^a-z0-9_]/.test(eventName)));
17594}
17595
17596module.exports = monitorCodeUse;
17597
17598},{"./invariant":126}],137:[function(_dereq_,module,exports){
17599/**
17600 * Copyright 2013-2014, Facebook, Inc.
17601 * All rights reserved.
17602 *
17603 * This source code is licensed under the BSD-style license found in the
17604 * LICENSE file in the root directory of this source tree. An additional grant
17605 * of patent rights can be found in the PATENTS file in the same directory.
17606 *
17607 * @providesModule onlyChild
17608 */
17609"use strict";
17610
17611var ReactElement = _dereq_("./ReactElement");
17612
17613var invariant = _dereq_("./invariant");
17614
17615/**
17616 * Returns the first child in a collection of children and verifies that there
17617 * is only one child in the collection. The current implementation of this
17618 * function assumes that a single child gets passed without a wrapper, but the
17619 * purpose of this helper function is to abstract away the particular structure
17620 * of children.
17621 *
17622 * @param {?object} children Child collection structure.
17623 * @return {ReactComponent} The first and only `ReactComponent` contained in the
17624 * structure.
17625 */
17626function onlyChild(children) {
17627 ("production" !== "development" ? invariant(
17628 ReactElement.isValidElement(children),
17629 'onlyChild must be passed a children with exactly one child.'
17630 ) : invariant(ReactElement.isValidElement(children)));
17631 return children;
17632}
17633
17634module.exports = onlyChild;
17635
17636},{"./ReactElement":52,"./invariant":126}],138:[function(_dereq_,module,exports){
17637/**
17638 * Copyright 2013-2014, Facebook, Inc.
17639 * All rights reserved.
17640 *
17641 * This source code is licensed under the BSD-style license found in the
17642 * LICENSE file in the root directory of this source tree. An additional grant
17643 * of patent rights can be found in the PATENTS file in the same directory.
17644 *
17645 * @providesModule performance
17646 * @typechecks
17647 */
17648
17649"use strict";
17650
17651var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
17652
17653var performance;
17654
17655if (ExecutionEnvironment.canUseDOM) {
17656 performance =
17657 window.performance ||
17658 window.msPerformance ||
17659 window.webkitPerformance;
17660}
17661
17662module.exports = performance || {};
17663
17664},{"./ExecutionEnvironment":22}],139:[function(_dereq_,module,exports){
17665/**
17666 * Copyright 2013-2014, Facebook, Inc.
17667 * All rights reserved.
17668 *
17669 * This source code is licensed under the BSD-style license found in the
17670 * LICENSE file in the root directory of this source tree. An additional grant
17671 * of patent rights can be found in the PATENTS file in the same directory.
17672 *
17673 * @providesModule performanceNow
17674 * @typechecks
17675 */
17676
17677var performance = _dereq_("./performance");
17678
17679/**
17680 * Detect if we can use `window.performance.now()` and gracefully fallback to
17681 * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
17682 * because of Facebook's testing infrastructure.
17683 */
17684if (!performance || !performance.now) {
17685 performance = Date;
17686}
17687
17688var performanceNow = performance.now.bind(performance);
17689
17690module.exports = performanceNow;
17691
17692},{"./performance":138}],140:[function(_dereq_,module,exports){
17693/**
17694 * Copyright 2013-2014, Facebook, Inc.
17695 * All rights reserved.
17696 *
17697 * This source code is licensed under the BSD-style license found in the
17698 * LICENSE file in the root directory of this source tree. An additional grant
17699 * of patent rights can be found in the PATENTS file in the same directory.
17700 *
17701 * @providesModule setInnerHTML
17702 */
17703
17704"use strict";
17705
17706var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
17707
17708var WHITESPACE_TEST = /^[ \r\n\t\f]/;
17709var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
17710
17711/**
17712 * Set the innerHTML property of a node, ensuring that whitespace is preserved
17713 * even in IE8.
17714 *
17715 * @param {DOMElement} node
17716 * @param {string} html
17717 * @internal
17718 */
17719var setInnerHTML = function(node, html) {
17720 node.innerHTML = html;
17721};
17722
17723if (ExecutionEnvironment.canUseDOM) {
17724 // IE8: When updating a just created node with innerHTML only leading
17725 // whitespace is removed. When updating an existing node with innerHTML
17726 // whitespace in root TextNodes is also collapsed.
17727 // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
17728
17729 // Feature detection; only IE8 is known to behave improperly like this.
17730 var testElement = document.createElement('div');
17731 testElement.innerHTML = ' ';
17732 if (testElement.innerHTML === '') {
17733 setInnerHTML = function(node, html) {
17734 // Magic theory: IE8 supposedly differentiates between added and updated
17735 // nodes when processing innerHTML, innerHTML on updated nodes suffers
17736 // from worse whitespace behavior. Re-adding a node like this triggers
17737 // the initial and more favorable whitespace behavior.
17738 // TODO: What to do on a detached node?
17739 if (node.parentNode) {
17740 node.parentNode.replaceChild(node, node);
17741 }
17742
17743 // We also implement a workaround for non-visible tags disappearing into
17744 // thin air on IE8, this only happens if there is no visible text
17745 // in-front of the non-visible tags. Piggyback on the whitespace fix
17746 // and simply check if any non-visible tags appear in the source.
17747 if (WHITESPACE_TEST.test(html) ||
17748 html[0] === '<' && NONVISIBLE_TEST.test(html)) {
17749 // Recover leading whitespace by temporarily prepending any character.
17750 // \uFEFF has the potential advantage of being zero-width/invisible.
17751 node.innerHTML = '\uFEFF' + html;
17752
17753 // deleteData leaves an empty `TextNode` which offsets the index of all
17754 // children. Definitely want to avoid this.
17755 var textNode = node.firstChild;
17756 if (textNode.data.length === 1) {
17757 node.removeChild(textNode);
17758 } else {
17759 textNode.deleteData(0, 1);
17760 }
17761 } else {
17762 node.innerHTML = html;
17763 }
17764 };
17765 }
17766}
17767
17768module.exports = setInnerHTML;
17769
17770},{"./ExecutionEnvironment":22}],141:[function(_dereq_,module,exports){
17771/**
17772 * Copyright 2013-2014, Facebook, Inc.
17773 * All rights reserved.
17774 *
17775 * This source code is licensed under the BSD-style license found in the
17776 * LICENSE file in the root directory of this source tree. An additional grant
17777 * of patent rights can be found in the PATENTS file in the same directory.
17778 *
17779 * @providesModule shallowEqual
17780 */
17781
17782"use strict";
17783
17784/**
17785 * Performs equality by iterating through keys on an object and returning
17786 * false when any key has values which are not strictly equal between
17787 * objA and objB. Returns true when the values of all keys are strictly equal.
17788 *
17789 * @return {boolean}
17790 */
17791function shallowEqual(objA, objB) {
17792 if (objA === objB) {
17793 return true;
17794 }
17795 var key;
17796 // Test for A's keys different from B.
17797 for (key in objA) {
17798 if (objA.hasOwnProperty(key) &&
17799 (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
17800 return false;
17801 }
17802 }
17803 // Test for B's keys missing from A.
17804 for (key in objB) {
17805 if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
17806 return false;
17807 }
17808 }
17809 return true;
17810}
17811
17812module.exports = shallowEqual;
17813
17814},{}],142:[function(_dereq_,module,exports){
17815/**
17816 * Copyright 2013-2014, Facebook, Inc.
17817 * All rights reserved.
17818 *
17819 * This source code is licensed under the BSD-style license found in the
17820 * LICENSE file in the root directory of this source tree. An additional grant
17821 * of patent rights can be found in the PATENTS file in the same directory.
17822 *
17823 * @providesModule shouldUpdateReactComponent
17824 * @typechecks static-only
17825 */
17826
17827"use strict";
17828
17829/**
17830 * Given a `prevElement` and `nextElement`, determines if the existing
17831 * instance should be updated as opposed to being destroyed or replaced by a new
17832 * instance. Both arguments are elements. This ensures that this logic can
17833 * operate on stateless trees without any backing instance.
17834 *
17835 * @param {?object} prevElement
17836 * @param {?object} nextElement
17837 * @return {boolean} True if the existing instance should be updated.
17838 * @protected
17839 */
17840function shouldUpdateReactComponent(prevElement, nextElement) {
17841 if (prevElement && nextElement &&
17842 prevElement.type === nextElement.type &&
17843 prevElement.key === nextElement.key &&
17844 prevElement._owner === nextElement._owner) {
17845 return true;
17846 }
17847 return false;
17848}
17849
17850module.exports = shouldUpdateReactComponent;
17851
17852},{}],143:[function(_dereq_,module,exports){
17853/**
17854 * Copyright 2014, Facebook, Inc.
17855 * All rights reserved.
17856 *
17857 * This source code is licensed under the BSD-style license found in the
17858 * LICENSE file in the root directory of this source tree. An additional grant
17859 * of patent rights can be found in the PATENTS file in the same directory.
17860 *
17861 * @providesModule toArray
17862 * @typechecks
17863 */
17864
17865var invariant = _dereq_("./invariant");
17866
17867/**
17868 * Convert array-like objects to arrays.
17869 *
17870 * This API assumes the caller knows the contents of the data type. For less
17871 * well defined inputs use createArrayFrom.
17872 *
17873 * @param {object|function|filelist} obj
17874 * @return {array}
17875 */
17876function toArray(obj) {
17877 var length = obj.length;
17878
17879 // Some browse builtin objects can report typeof 'function' (e.g. NodeList in
17880 // old versions of Safari).
17881 ("production" !== "development" ? invariant(
17882 !Array.isArray(obj) &&
17883 (typeof obj === 'object' || typeof obj === 'function'),
17884 'toArray: Array-like object expected'
17885 ) : invariant(!Array.isArray(obj) &&
17886 (typeof obj === 'object' || typeof obj === 'function')));
17887
17888 ("production" !== "development" ? invariant(
17889 typeof length === 'number',
17890 'toArray: Object needs a length property'
17891 ) : invariant(typeof length === 'number'));
17892
17893 ("production" !== "development" ? invariant(
17894 length === 0 ||
17895 (length - 1) in obj,
17896 'toArray: Object should have keys for indices'
17897 ) : invariant(length === 0 ||
17898 (length - 1) in obj));
17899
17900 // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
17901 // without method will throw during the slice call and skip straight to the
17902 // fallback.
17903 if (obj.hasOwnProperty) {
17904 try {
17905 return Array.prototype.slice.call(obj);
17906 } catch (e) {
17907 // IE < 9 does not support Array#slice on collections objects
17908 }
17909 }
17910
17911 // Fall back to copying key by key. This assumes all keys have a value,
17912 // so will not preserve sparsely populated inputs.
17913 var ret = Array(length);
17914 for (var ii = 0; ii < length; ii++) {
17915 ret[ii] = obj[ii];
17916 }
17917 return ret;
17918}
17919
17920module.exports = toArray;
17921
17922},{"./invariant":126}],144:[function(_dereq_,module,exports){
17923/**
17924 * Copyright 2013-2014, Facebook, Inc.
17925 * All rights reserved.
17926 *
17927 * This source code is licensed under the BSD-style license found in the
17928 * LICENSE file in the root directory of this source tree. An additional grant
17929 * of patent rights can be found in the PATENTS file in the same directory.
17930 *
17931 * @providesModule traverseAllChildren
17932 */
17933
17934"use strict";
17935
17936var ReactElement = _dereq_("./ReactElement");
17937var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
17938
17939var invariant = _dereq_("./invariant");
17940
17941var SEPARATOR = ReactInstanceHandles.SEPARATOR;
17942var SUBSEPARATOR = ':';
17943
17944/**
17945 * TODO: Test that:
17946 * 1. `mapChildren` transforms strings and numbers into `ReactTextComponent`.
17947 * 2. it('should fail when supplied duplicate key', function() {
17948 * 3. That a single child and an array with one item have the same key pattern.
17949 * });
17950 */
17951
17952var userProvidedKeyEscaperLookup = {
17953 '=': '=0',
17954 '.': '=1',
17955 ':': '=2'
17956};
17957
17958var userProvidedKeyEscapeRegex = /[=.:]/g;
17959
17960function userProvidedKeyEscaper(match) {
17961 return userProvidedKeyEscaperLookup[match];
17962}
17963
17964/**
17965 * Generate a key string that identifies a component within a set.
17966 *
17967 * @param {*} component A component that could contain a manual key.
17968 * @param {number} index Index that is used if a manual key is not provided.
17969 * @return {string}
17970 */
17971function getComponentKey(component, index) {
17972 if (component && component.key != null) {
17973 // Explicit key
17974 return wrapUserProvidedKey(component.key);
17975 }
17976 // Implicit key determined by the index in the set
17977 return index.toString(36);
17978}
17979
17980/**
17981 * Escape a component key so that it is safe to use in a reactid.
17982 *
17983 * @param {*} key Component key to be escaped.
17984 * @return {string} An escaped string.
17985 */
17986function escapeUserProvidedKey(text) {
17987 return ('' + text).replace(
17988 userProvidedKeyEscapeRegex,
17989 userProvidedKeyEscaper
17990 );
17991}
17992
17993/**
17994 * Wrap a `key` value explicitly provided by the user to distinguish it from
17995 * implicitly-generated keys generated by a component's index in its parent.
17996 *
17997 * @param {string} key Value of a user-provided `key` attribute
17998 * @return {string}
17999 */
18000function wrapUserProvidedKey(key) {
18001 return '$' + escapeUserProvidedKey(key);
18002}
18003
18004/**
18005 * @param {?*} children Children tree container.
18006 * @param {!string} nameSoFar Name of the key path so far.
18007 * @param {!number} indexSoFar Number of children encountered until this point.
18008 * @param {!function} callback Callback to invoke with each child found.
18009 * @param {?*} traverseContext Used to pass information throughout the traversal
18010 * process.
18011 * @return {!number} The number of children in this subtree.
18012 */
18013var traverseAllChildrenImpl =
18014 function(children, nameSoFar, indexSoFar, callback, traverseContext) {
18015 var nextName, nextIndex;
18016 var subtreeCount = 0; // Count of children found in the current subtree.
18017 if (Array.isArray(children)) {
18018 for (var i = 0; i < children.length; i++) {
18019 var child = children[i];
18020 nextName = (
18021 nameSoFar +
18022 (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
18023 getComponentKey(child, i)
18024 );
18025 nextIndex = indexSoFar + subtreeCount;
18026 subtreeCount += traverseAllChildrenImpl(
18027 child,
18028 nextName,
18029 nextIndex,
18030 callback,
18031 traverseContext
18032 );
18033 }
18034 } else {
18035 var type = typeof children;
18036 var isOnlyChild = nameSoFar === '';
18037 // If it's the only child, treat the name as if it was wrapped in an array
18038 // so that it's consistent if the number of children grows
18039 var storageName =
18040 isOnlyChild ? SEPARATOR + getComponentKey(children, 0) : nameSoFar;
18041 if (children == null || type === 'boolean') {
18042 // All of the above are perceived as null.
18043 callback(traverseContext, null, storageName, indexSoFar);
18044 subtreeCount = 1;
18045 } else if (type === 'string' || type === 'number' ||
18046 ReactElement.isValidElement(children)) {
18047 callback(traverseContext, children, storageName, indexSoFar);
18048 subtreeCount = 1;
18049 } else if (type === 'object') {
18050 ("production" !== "development" ? invariant(
18051 !children || children.nodeType !== 1,
18052 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
18053 'elements are not valid children of React components.'
18054 ) : invariant(!children || children.nodeType !== 1));
18055 for (var key in children) {
18056 if (children.hasOwnProperty(key)) {
18057 nextName = (
18058 nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
18059 wrapUserProvidedKey(key) + SUBSEPARATOR +
18060 getComponentKey(children[key], 0)
18061 );
18062 nextIndex = indexSoFar + subtreeCount;
18063 subtreeCount += traverseAllChildrenImpl(
18064 children[key],
18065 nextName,
18066 nextIndex,
18067 callback,
18068 traverseContext
18069 );
18070 }
18071 }
18072 }
18073 }
18074 return subtreeCount;
18075 };
18076
18077/**
18078 * Traverses children that are typically specified as `props.children`, but
18079 * might also be specified through attributes:
18080 *
18081 * - `traverseAllChildren(this.props.children, ...)`
18082 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
18083 *
18084 * The `traverseContext` is an optional argument that is passed through the
18085 * entire traversal. It can be used to store accumulations or anything else that
18086 * the callback might find relevant.
18087 *
18088 * @param {?*} children Children tree object.
18089 * @param {!function} callback To invoke upon traversing each child.
18090 * @param {?*} traverseContext Context for traversal.
18091 * @return {!number} The number of children in this subtree.
18092 */
18093function traverseAllChildren(children, callback, traverseContext) {
18094 if (children == null) {
18095 return 0;
18096 }
18097
18098 return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
18099}
18100
18101module.exports = traverseAllChildren;
18102
18103},{"./ReactElement":52,"./ReactInstanceHandles":60,"./invariant":126}],145:[function(_dereq_,module,exports){
18104/**
18105 * Copyright 2014, Facebook, Inc.
18106 * All rights reserved.
18107 *
18108 * This source code is licensed under the BSD-style license found in the
18109 * LICENSE file in the root directory of this source tree. An additional grant
18110 * of patent rights can be found in the PATENTS file in the same directory.
18111 *
18112 * @providesModule warning
18113 */
18114
18115"use strict";
18116
18117var emptyFunction = _dereq_("./emptyFunction");
18118
18119/**
18120 * Similar to invariant but only logs a warning if the condition is not met.
18121 * This can be used to log issues in development environments in critical
18122 * paths. Removing the logging code for production environments will keep the
18123 * same logic and follow the same code paths.
18124 */
18125
18126var warning = emptyFunction;
18127
18128if ("production" !== "development") {
18129 warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
18130 if (format === undefined) {
18131 throw new Error(
18132 '`warning(condition, format, ...args)` requires a warning ' +
18133 'message argument'
18134 );
18135 }
18136
18137 if (!condition) {
18138 var argIndex = 0;
18139 console.warn('Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}));
18140 }
18141 };
18142}
18143
18144module.exports = warning;
18145
18146},{"./emptyFunction":107}]},{},[1])(1)
18147});
\No newline at end of file