summaryrefslogtreecommitdiff
path: root/frontend/delta/js/React/react-0.4.1.js
Unidiff
Diffstat (limited to 'frontend/delta/js/React/react-0.4.1.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/delta/js/React/react-0.4.1.js11491
1 files changed, 11491 insertions, 0 deletions
diff --git a/frontend/delta/js/React/react-0.4.1.js b/frontend/delta/js/React/react-0.4.1.js
new file mode 100644
index 0000000..d029de2
--- a/dev/null
+++ b/frontend/delta/js/React/react-0.4.1.js
@@ -0,0 +1,11491 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24/**
25 * React v0.4.1
26 */
27(function(e){if("function"==typeof bootstrap)bootstrap("react",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeReact=e}else"undefined"!=typeof window?window.React=e():global.React=e()})(function(){var define,ses,bootstrap,module,exports;
28return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
29/**
30 * Copyright 2013 Facebook, Inc.
31 *
32 * Licensed under the Apache License, Version 2.0 (the "License");
33 * you may not use this file except in compliance with the License.
34 * You may obtain a copy of the License at
35 *
36 * http://www.apache.org/licenses/LICENSE-2.0
37 *
38 * Unless required by applicable law or agreed to in writing, software
39 * distributed under the License is distributed on an "AS IS" BASIS,
40 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 * See the License for the specific language governing permissions and
42 * limitations under the License.
43 *
44 * @providesModule $
45 * @typechecks
46 */
47
48var ge = require("./ge");
49var ex = require("./ex");
50
51/**
52 * @param {string|DOMDocument|DOMElement|DOMTextNode} id
53 * @return {DOMDocument|DOMElement|DOMTextNode}
54 *
55 * Find a node by ID.
56 *
57 * If your application code depends on the existence of the element, use $,
58 * which will throw if the element doesn't exist.
59 *
60 * If you're not sure whether or not the element exists, use ge instead, and
61 * manually check for the element's existence in your application code.
62 */
63function $(id) {
64 var element = ge(id);
65 if (!element) {
66 throw new Error(ex(
67 'Tried to get element with id of "%s" but it is not present on the page.',
68 id
69 ));
70 }
71 return element;
72}
73
74module.exports = $;
75
76},{"./ex":68,"./ge":71}],2:[function(require,module,exports){
77/**
78 * Copyright 2013 Facebook, Inc.
79 *
80 * Licensed under the Apache License, Version 2.0 (the "License");
81 * you may not use this file except in compliance with the License.
82 * You may obtain a copy of the License at
83 *
84 * http://www.apache.org/licenses/LICENSE-2.0
85 *
86 * Unless required by applicable law or agreed to in writing, software
87 * distributed under the License is distributed on an "AS IS" BASIS,
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 * See the License for the specific language governing permissions and
90 * limitations under the License.
91 *
92 * @providesModule CSSProperty
93 */
94
95"use strict";
96
97/**
98 * CSS properties which accept numbers but are not in units of "px".
99 */
100var isUnitlessNumber = {
101 fillOpacity: true,
102 fontWeight: true,
103 opacity: true,
104 orphans: true,
105 zIndex: true,
106 zoom: true
107};
108
109/**
110 * Most style properties can be unset by doing .style[prop] = '' but IE8
111 * doesn't like doing that with shorthand properties so for the properties that
112 * IE8 breaks on, which are listed here, we instead unset each of the
113 * individual properties. See http://bugs.jquery.com/ticket/12385.
114 * The 4-value 'clock' properties like margin, padding, border-width seem to
115 * behave without any problems. Curiously, list-style works too without any
116 * special prodding.
117 */
118var shorthandPropertyExpansions = {
119 background: {
120 backgroundImage: true,
121 backgroundPosition: true,
122 backgroundRepeat: true,
123 backgroundColor: true
124 },
125 border: {
126 borderWidth: true,
127 borderStyle: true,
128 borderColor: true
129 },
130 borderBottom: {
131 borderBottomWidth: true,
132 borderBottomStyle: true,
133 borderBottomColor: true
134 },
135 borderLeft: {
136 borderLeftWidth: true,
137 borderLeftStyle: true,
138 borderLeftColor: true
139 },
140 borderRight: {
141 borderRightWidth: true,
142 borderRightStyle: true,
143 borderRightColor: true
144 },
145 borderTop: {
146 borderTopWidth: true,
147 borderTopStyle: true,
148 borderTopColor: true
149 },
150 font: {
151 fontStyle: true,
152 fontVariant: true,
153 fontWeight: true,
154 fontSize: true,
155 lineHeight: true,
156 fontFamily: true
157 }
158};
159
160var CSSProperty = {
161 isUnitlessNumber: isUnitlessNumber,
162 shorthandPropertyExpansions: shorthandPropertyExpansions
163};
164
165module.exports = CSSProperty;
166
167},{}],3:[function(require,module,exports){
168/**
169 * Copyright 2013 Facebook, Inc.
170 *
171 * Licensed under the Apache License, Version 2.0 (the "License");
172 * you may not use this file except in compliance with the License.
173 * You may obtain a copy of the License at
174 *
175 * http://www.apache.org/licenses/LICENSE-2.0
176 *
177 * Unless required by applicable law or agreed to in writing, software
178 * distributed under the License is distributed on an "AS IS" BASIS,
179 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
180 * See the License for the specific language governing permissions and
181 * limitations under the License.
182 *
183 * @providesModule CSSPropertyOperations
184 * @typechecks static-only
185 */
186
187"use strict";
188
189var CSSProperty = require("./CSSProperty");
190
191var dangerousStyleValue = require("./dangerousStyleValue");
192var escapeTextForBrowser = require("./escapeTextForBrowser");
193var hyphenate = require("./hyphenate");
194var memoizeStringOnly = require("./memoizeStringOnly");
195
196var processStyleName = memoizeStringOnly(function(styleName) {
197 return escapeTextForBrowser(hyphenate(styleName));
198});
199
200/**
201 * Operations for dealing with CSS properties.
202 */
203var CSSPropertyOperations = {
204
205 /**
206 * Serializes a mapping of style properties for use as inline styles:
207 *
208 * > createMarkupForStyles({width: '200px', height: 0})
209 * "width:200px;height:0;"
210 *
211 * Undefined values are ignored so that declarative programming is easier.
212 *
213 * @param {object} styles
214 * @return {?string}
215 */
216 createMarkupForStyles: function(styles) {
217 var serialized = '';
218 for (var styleName in styles) {
219 if (!styles.hasOwnProperty(styleName)) {
220 continue;
221 }
222 var styleValue = styles[styleName];
223 if (styleValue != null) {
224 serialized += processStyleName(styleName) + ':';
225 serialized += dangerousStyleValue(styleName, styleValue) + ';';
226 }
227 }
228 return serialized || null;
229 },
230
231 /**
232 * Sets the value for multiple styles on a node. If a value is specified as
233 * '' (empty string), the corresponding style property will be unset.
234 *
235 * @param {DOMElement} node
236 * @param {object} styles
237 */
238 setValueForStyles: function(node, styles) {
239 var style = node.style;
240 for (var styleName in styles) {
241 if (!styles.hasOwnProperty(styleName)) {
242 continue;
243 }
244 var styleValue = dangerousStyleValue(styleName, styles[styleName]);
245 if (styleValue) {
246 style[styleName] = styleValue;
247 } else {
248 var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
249 if (expansion) {
250 // Shorthand property that IE8 won't like unsetting, so unset each
251 // component to placate it
252 for (var individualStyleName in expansion) {
253 style[individualStyleName] = '';
254 }
255 } else {
256 style[styleName] = '';
257 }
258 }
259 }
260 }
261
262};
263
264module.exports = CSSPropertyOperations;
265
266},{"./CSSProperty":2,"./dangerousStyleValue":65,"./escapeTextForBrowser":67,"./hyphenate":76,"./memoizeStringOnly":83}],4:[function(require,module,exports){
267/**
268 * Copyright 2013 Facebook, Inc.
269 *
270 * Licensed under the Apache License, Version 2.0 (the "License");
271 * you may not use this file except in compliance with the License.
272 * You may obtain a copy of the License at
273 *
274 * http://www.apache.org/licenses/LICENSE-2.0
275 *
276 * Unless required by applicable law or agreed to in writing, software
277 * distributed under the License is distributed on an "AS IS" BASIS,
278 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279 * See the License for the specific language governing permissions and
280 * limitations under the License.
281 *
282 * @providesModule CallbackRegistry
283 * @typechecks static-only
284 */
285
286"use strict";
287
288var listenerBank = {};
289
290/**
291 * Stores "listeners" by `registrationName`/`id`. There should be at most one
292 * "listener" per `registrationName`/`id` in the `listenerBank`.
293 *
294 * Access listeners via `listenerBank[registrationName][id]`.
295 *
296 * @class CallbackRegistry
297 * @internal
298 */
299var CallbackRegistry = {
300
301 /**
302 * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
303 *
304 * @param {string} id ID of the DOM element.
305 * @param {string} registrationName Name of listener (e.g. `onClick`).
306 * @param {?function} listener The callback to store.
307 */
308 putListener: function(id, registrationName, listener) {
309 var bankForRegistrationName =
310 listenerBank[registrationName] || (listenerBank[registrationName] = {});
311 bankForRegistrationName[id] = listener;
312 },
313
314 /**
315 * @param {string} id ID of the DOM element.
316 * @param {string} registrationName Name of listener (e.g. `onClick`).
317 * @return {?function} The stored callback.
318 */
319 getListener: function(id, registrationName) {
320 var bankForRegistrationName = listenerBank[registrationName];
321 return bankForRegistrationName && bankForRegistrationName[id];
322 },
323
324 /**
325 * Deletes a listener from the registration bank.
326 *
327 * @param {string} id ID of the DOM element.
328 * @param {string} registrationName Name of listener (e.g. `onClick`).
329 */
330 deleteListener: function(id, registrationName) {
331 var bankForRegistrationName = listenerBank[registrationName];
332 if (bankForRegistrationName) {
333 delete bankForRegistrationName[id];
334 }
335 },
336
337 /**
338 * Deletes all listeners for the DOM element with the supplied ID.
339 *
340 * @param {string} id ID of the DOM element.
341 */
342 deleteAllListeners: function(id) {
343 for (var registrationName in listenerBank) {
344 delete listenerBank[registrationName][id];
345 }
346 },
347
348 /**
349 * This is needed for tests only. Do not use!
350 */
351 __purge: function() {
352 listenerBank = {};
353 }
354
355};
356
357module.exports = CallbackRegistry;
358
359},{}],5:[function(require,module,exports){
360(function(){/**
361 * Copyright 2013 Facebook, Inc.
362 *
363 * Licensed under the Apache License, Version 2.0 (the "License");
364 * you may not use this file except in compliance with the License.
365 * You may obtain a copy of the License at
366 *
367 * http://www.apache.org/licenses/LICENSE-2.0
368 *
369 * Unless required by applicable law or agreed to in writing, software
370 * distributed under the License is distributed on an "AS IS" BASIS,
371 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
372 * See the License for the specific language governing permissions and
373 * limitations under the License.
374 *
375 * @providesModule ChangeEventPlugin
376 */
377
378"use strict";
379
380var EventConstants = require("./EventConstants");
381var EventPluginHub = require("./EventPluginHub");
382var EventPropagators = require("./EventPropagators");
383var ExecutionEnvironment = require("./ExecutionEnvironment");
384var SyntheticEvent = require("./SyntheticEvent");
385
386var isEventSupported = require("./isEventSupported");
387var keyOf = require("./keyOf");
388
389var topLevelTypes = EventConstants.topLevelTypes;
390
391var eventTypes = {
392 change: {
393 phasedRegistrationNames: {
394 bubbled: keyOf({onChange: null}),
395 captured: keyOf({onChangeCapture: null})
396 }
397 }
398};
399
400/**
401 * For IE shims
402 */
403var activeElement = null;
404var activeElementID = null;
405var activeElementValue = null;
406var activeElementValueProp = null;
407
408
409/**
410 * SECTION: handle `change` event
411 */
412function shouldUseChangeEvent(elem) {
413 return (
414 elem.nodeName === 'SELECT' ||
415 (elem.nodeName === 'INPUT' && elem.type === 'file')
416 );
417}
418
419var doesChangeEventBubble = false;
420if (ExecutionEnvironment.canUseDOM) {
421 // See `handleChange` comment below
422 doesChangeEventBubble = isEventSupported('change') && (
423 !('documentMode' in document) || document.documentMode > 8
424 );
425}
426
427function manualDispatchChangeEvent(nativeEvent) {
428 var event = SyntheticEvent.getPooled(
429 eventTypes.change,
430 activeElementID,
431 nativeEvent
432 );
433 EventPropagators.accumulateTwoPhaseDispatches(event);
434
435 // If change bubbled, we'd just bind to it like all the other events
436 // and have it go through ReactEventTopLevelCallback. Since it doesn't, we
437 // manually listen for the change event and so we have to enqueue and
438 // process the abstract event manually.
439 EventPluginHub.enqueueEvents(event);
440 EventPluginHub.processEventQueue();
441}
442
443function startWatchingForChangeEventIE8(target, targetID) {
444 activeElement = target;
445 activeElementID = targetID;
446 activeElement.attachEvent('onchange', manualDispatchChangeEvent);
447}
448
449function stopWatchingForChangeEventIE8() {
450 if (!activeElement) {
451 return;
452 }
453 activeElement.detachEvent('onchange', manualDispatchChangeEvent);
454 activeElement = null;
455 activeElementID = null;
456}
457
458function getTargetIDForChangeEvent(
459 topLevelType,
460 topLevelTarget,
461 topLevelTargetID) {
462 if (topLevelType === topLevelTypes.topChange) {
463 return topLevelTargetID;
464 }
465}
466function handleEventsForChangeEventIE8(
467 topLevelType,
468 topLevelTarget,
469 topLevelTargetID) {
470 if (topLevelType === topLevelTypes.topFocus) {
471 // stopWatching() should be a noop here but we call it just in case we
472 // missed a blur event somehow.
473 stopWatchingForChangeEventIE8();
474 startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
475 } else if (topLevelType === topLevelTypes.topBlur) {
476 stopWatchingForChangeEventIE8();
477 }
478}
479
480
481/**
482 * SECTION: handle `input` event
483 */
484var isInputEventSupported = false;
485if (ExecutionEnvironment.canUseDOM) {
486 // IE9 claims to support the input event but fails to trigger it when
487 // deleting text, so we ignore its input events
488 isInputEventSupported = isEventSupported('input') && (
489 !('documentMode' in document) || document.documentMode > 9
490 );
491}
492
493
494/**
495 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
496 */
497var supportedInputTypes = {
498 'color': true,
499 'date': true,
500 'datetime': true,
501 'datetime-local': true,
502 'email': true,
503 'month': true,
504 'number': true,
505 'password': true,
506 'range': true,
507 'search': true,
508 'tel': true,
509 'text': true,
510 'time': true,
511 'url': true,
512 'week': true
513};
514
515function shouldUseInputEvent(elem) {
516 return (
517 (elem.nodeName === 'INPUT' && supportedInputTypes[elem.type]) ||
518 elem.nodeName === 'TEXTAREA'
519 );
520}
521
522/**
523 * (For old IE.) Replacement getter/setter for the `value` property that gets
524 * set on the active element.
525 */
526var newValueProp = {
527 get: function() {
528 return activeElementValueProp.get.call(this);
529 },
530 set: function(val) {
531 // Cast to a string so we can do equality checks.
532 activeElementValue = '' + val;
533 activeElementValueProp.set.call(this, val);
534 }
535};
536
537/**
538 * (For old IE.) Starts tracking propertychange events on the passed-in element
539 * and override the value property so that we can distinguish user events from
540 * value changes in JS.
541 */
542function startWatchingForValueChange(target, targetID) {
543 activeElement = target;
544 activeElementID = targetID;
545 activeElementValue = target.value;
546 activeElementValueProp = Object.getOwnPropertyDescriptor(
547 target.constructor.prototype,
548 'value'
549 );
550
551 Object.defineProperty(activeElement, 'value', newValueProp);
552 activeElement.attachEvent('onpropertychange', handlePropertyChange);
553}
554
555/**
556 * (For old IE.) Removes the event listeners from the currently-tracked element,
557 * if any exists.
558 */
559function stopWatchingForValueChange() {
560 if (!activeElement) {
561 return;
562 }
563
564 // delete restores the original property definition
565 delete activeElement.value;
566 activeElement.detachEvent('onpropertychange', handlePropertyChange);
567
568 activeElement = null;
569 activeElementID = null;
570 activeElementValue = null;
571 activeElementValueProp = null;
572}
573
574/**
575 * (For old IE.) Handles a propertychange event, sending a `change` event if
576 * the value of the active element has changed.
577 */
578function handlePropertyChange(nativeEvent) {
579 if (nativeEvent.propertyName !== 'value') {
580 return;
581 }
582 var value = nativeEvent.srcElement.value;
583 if (value === activeElementValue) {
584 return;
585 }
586 activeElementValue = value;
587
588 manualDispatchChangeEvent(nativeEvent);
589}
590
591/**
592 * If a `change` event should be fired, returns the target's ID.
593 */
594function getTargetIDForInputEvent(
595 topLevelType,
596 topLevelTarget,
597 topLevelTargetID) {
598 if (topLevelType === topLevelTypes.topInput) {
599 // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
600 // what we want so fall through here and trigger an abstract event
601 return topLevelTargetID;
602 }
603}
604
605// For IE8 and IE9.
606function handleEventsForInputEventIE(
607 topLevelType,
608 topLevelTarget,
609 topLevelTargetID) {
610 if (topLevelType === topLevelTypes.topFocus) {
611 // In IE8, we can capture almost all .value changes by adding a
612 // propertychange handler and looking for events with propertyName
613 // equal to 'value'
614 // In IE9, propertychange fires for most input events but is buggy and
615 // doesn't fire when text is deleted, but conveniently, selectionchange
616 // appears to fire in all of the remaining cases so we catch those and
617 // forward the event if the value has changed
618 // In either case, we don't want to call the event handler if the value
619 // is changed from JS so we redefine a setter for `.value` that updates
620 // our activeElementValue variable, allowing us to ignore those changes
621 //
622 // stopWatching() should be a noop here but we call it just in case we
623 // missed a blur event somehow.
624 stopWatchingForValueChange();
625 startWatchingForValueChange(topLevelTarget, topLevelTargetID);
626 } else if (topLevelType === topLevelTypes.topBlur) {
627 stopWatchingForValueChange();
628 }
629}
630
631// For IE8 and IE9.
632function getTargetIDForInputEventIE(
633 topLevelType,
634 topLevelTarget,
635 topLevelTargetID) {
636 if (topLevelType === topLevelTypes.topSelectionChange ||
637 topLevelType === topLevelTypes.topKeyUp ||
638 topLevelType === topLevelTypes.topKeyDown) {
639 // On the selectionchange event, the target is just document which isn't
640 // helpful for us so just check activeElement instead.
641 //
642 // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
643 // propertychange on the first input event after setting `value` from a
644 // script and fires only keydown, keypress, keyup. Catching keyup usually
645 // gets it and catching keydown lets us fire an event for the first
646 // keystroke if user does a key repeat (it'll be a little delayed: right
647 // before the second keystroke). Other input methods (e.g., paste) seem to
648 // fire selectionchange normally.
649 if (activeElement && activeElement.value !== activeElementValue) {
650 activeElementValue = activeElement.value;
651 return activeElementID;
652 }
653 }
654}
655
656
657/**
658 * SECTION: handle `click` event
659 */
660function shouldUseClickEvent(elem) {
661 // Use the `click` event to detect changes to checkbox and radio inputs.
662 // This approach works across all browsers, whereas `change` does not fire
663 // until `blur` in IE8.
664 return (
665 elem.nodeName === 'INPUT' &&
666 (elem.type === 'checkbox' || elem.type === 'radio')
667 );
668}
669
670function getTargetIDForClickEvent(
671 topLevelType,
672 topLevelTarget,
673 topLevelTargetID) {
674 if (topLevelType === topLevelTypes.topClick) {
675 return topLevelTargetID;
676 }
677}
678
679/**
680 * This plugin creates an `onChange` event that normalizes change events
681 * across form elements. This event fires at a time when it's possible to
682 * change the element's value without seeing a flicker.
683 *
684 * Supported elements are:
685 * - input (see `supportedInputTypes`)
686 * - textarea
687 * - select
688 */
689var ChangeEventPlugin = {
690
691 eventTypes: eventTypes,
692
693 /**
694 * @param {string} topLevelType Record from `EventConstants`.
695 * @param {DOMEventTarget} topLevelTarget The listening component root node.
696 * @param {string} topLevelTargetID ID of `topLevelTarget`.
697 * @param {object} nativeEvent Native browser event.
698 * @return {*} An accumulation of synthetic events.
699 * @see {EventPluginHub.extractEvents}
700 */
701 extractEvents: function(
702 topLevelType,
703 topLevelTarget,
704 topLevelTargetID,
705 nativeEvent) {
706
707 var getTargetIDFunc, handleEventFunc;
708 if (shouldUseChangeEvent(topLevelTarget)) {
709 if (doesChangeEventBubble) {
710 getTargetIDFunc = getTargetIDForChangeEvent;
711 } else {
712 handleEventFunc = handleEventsForChangeEventIE8;
713 }
714 } else if (shouldUseInputEvent(topLevelTarget)) {
715 if (isInputEventSupported) {
716 getTargetIDFunc = getTargetIDForInputEvent;
717 } else {
718 getTargetIDFunc = getTargetIDForInputEventIE;
719 handleEventFunc = handleEventsForInputEventIE;
720 }
721 } else if (shouldUseClickEvent(topLevelTarget)) {
722 getTargetIDFunc = getTargetIDForClickEvent;
723 }
724
725 if (getTargetIDFunc) {
726 var targetID = getTargetIDFunc(
727 topLevelType,
728 topLevelTarget,
729 topLevelTargetID
730 );
731 if (targetID) {
732 var event = SyntheticEvent.getPooled(
733 eventTypes.change,
734 targetID,
735 nativeEvent
736 );
737 EventPropagators.accumulateTwoPhaseDispatches(event);
738 return event;
739 }
740 }
741
742 if (handleEventFunc) {
743 handleEventFunc(
744 topLevelType,
745 topLevelTarget,
746 topLevelTargetID
747 );
748 }
749 }
750
751};
752
753module.exports = ChangeEventPlugin;
754
755})()
756},{"./EventConstants":13,"./EventPluginHub":15,"./EventPropagators":18,"./ExecutionEnvironment":19,"./SyntheticEvent":51,"./isEventSupported":79,"./keyOf":82}],6:[function(require,module,exports){
757(function(){/**
758 * Copyright 2013 Facebook, Inc.
759 *
760 * Licensed under the Apache License, Version 2.0 (the "License");
761 * you may not use this file except in compliance with the License.
762 * You may obtain a copy of the License at
763 *
764 * http://www.apache.org/licenses/LICENSE-2.0
765 *
766 * Unless required by applicable law or agreed to in writing, software
767 * distributed under the License is distributed on an "AS IS" BASIS,
768 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
769 * See the License for the specific language governing permissions and
770 * limitations under the License.
771 *
772 * @providesModule DOMChildrenOperations
773 */
774
775// Empty blocks improve readability so disable that warning
776// jshint -W035
777
778"use strict";
779
780var Danger = require("./Danger");
781
782var insertNodeAt = require("./insertNodeAt");
783var keyOf = require("./keyOf");
784var throwIf = require("./throwIf");
785
786var NON_INCREASING_OPERATIONS;
787if (true) {
788 NON_INCREASING_OPERATIONS =
789 'DOM child management operations must be provided in order ' +
790 'of increasing destination index. This is likely an issue with ' +
791 'the core framework.';
792}
793
794var MOVE_NODE_AT_ORIG_INDEX = keyOf({moveFrom: null});
795var INSERT_MARKUP = keyOf({insertMarkup: null});
796var REMOVE_AT = keyOf({removeAt: null});
797
798/**
799 * In order to carry out movement of DOM nodes without knowing their IDs, we
800 * have to first store knowledge about nodes' original indices before beginning
801 * to carry out the sequence of operations. Once we begin the sequence, the DOM
802 * indices in future instructions are no longer valid.
803 *
804 * @param {Element} parent Parent DOM node.
805 * @param {Object} childOperations Description of child operations.
806 * @return {Array?} Sparse array containing elements by their current index in
807 * the DOM.
808 */
809var _getNodesByOriginalIndex = function(parent, childOperations) {
810 var nodesByOriginalIndex; // Sparse array.
811 var childOperation;
812 var origIndex;
813 for (var i = 0; i < childOperations.length; i++) {
814 childOperation = childOperations[i];
815 if (MOVE_NODE_AT_ORIG_INDEX in childOperation) {
816 nodesByOriginalIndex = nodesByOriginalIndex || [];
817 origIndex = childOperation.moveFrom;
818 nodesByOriginalIndex[origIndex] = parent.childNodes[origIndex];
819 } else if (REMOVE_AT in childOperation) {
820 nodesByOriginalIndex = nodesByOriginalIndex || [];
821 origIndex = childOperation.removeAt;
822 nodesByOriginalIndex[origIndex] = parent.childNodes[origIndex];
823 }
824 }
825 return nodesByOriginalIndex;
826};
827
828/**
829 * Removes DOM elements from their parent, or moved.
830 * @param {Element} parent Parent DOM node.
831 * @param {Array} nodesByOriginalIndex Child nodes by their original index
832 * (potentially sparse.)
833 */
834var _removeChildrenByOriginalIndex = function(parent, nodesByOriginalIndex) {
835 for (var j = 0; j < nodesByOriginalIndex.length; j++) {
836 var nodeToRemove = nodesByOriginalIndex[j];
837 if (nodeToRemove) { // We used a sparse array.
838 parent.removeChild(nodesByOriginalIndex[j]);
839 }
840 }
841};
842
843/**
844 * Once all nodes that will be removed or moved - are removed from the parent
845 * node, we can begin the process of placing nodes into their final locations.
846 * We must perform all operations in the order of the final DOM index -
847 * otherwise, we couldn't count on the fact that an insertion at index X, will
848 * remain at index X. This will iterate through the child operations, adding
849 * content where needed, skip over removals (they've already been removed) and
850 * insert "moved" Elements that were previously removed. The "moved" elements
851 * are only temporarily removed from the parent, so that index calculations can
852 * be manageable and perform well in the cases that matter.
853 */
854var _placeNodesAtDestination =
855 function(parent, childOperations, nodesByOriginalIndex) {
856 var origNode;
857 var finalIndex;
858 var lastFinalIndex = -1;
859 var childOperation;
860 for (var k = 0; k < childOperations.length; k++) {
861 childOperation = childOperations[k];
862 if (MOVE_NODE_AT_ORIG_INDEX in childOperation) {
863 origNode = nodesByOriginalIndex[childOperation.moveFrom];
864 finalIndex = childOperation.finalIndex;
865 insertNodeAt(parent, origNode, finalIndex);
866 if (true) {
867 throwIf(finalIndex <= lastFinalIndex, NON_INCREASING_OPERATIONS);
868 lastFinalIndex = finalIndex;
869 }
870 } else if (REMOVE_AT in childOperation) {
871 } else if (INSERT_MARKUP in childOperation) {
872 finalIndex = childOperation.finalIndex;
873 var markup = childOperation.insertMarkup;
874 Danger.dangerouslyInsertMarkupAt(parent, markup, finalIndex);
875 if (true) {
876 throwIf(finalIndex <= lastFinalIndex, NON_INCREASING_OPERATIONS);
877 lastFinalIndex = finalIndex;
878 }
879 }
880 }
881 };
882
883var manageChildren = function(parent, childOperations) {
884 var nodesByOriginalIndex = _getNodesByOriginalIndex(parent, childOperations);
885 if (nodesByOriginalIndex) {
886 _removeChildrenByOriginalIndex(parent, nodesByOriginalIndex);
887 }
888 _placeNodesAtDestination(parent, childOperations, nodesByOriginalIndex);
889};
890
891/**
892 * Also reexport all of the dangerous functions. It helps to have all dangerous
893 * functions located in a single module `Danger`.
894 */
895var DOMChildrenOperations = {
896 dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
897 manageChildren: manageChildren
898};
899
900module.exports = DOMChildrenOperations;
901
902})()
903},{"./Danger":9,"./insertNodeAt":77,"./keyOf":82,"./throwIf":89}],7:[function(require,module,exports){
904/**
905 * Copyright 2013 Facebook, Inc.
906 *
907 * Licensed under the Apache License, Version 2.0 (the "License");
908 * you may not use this file except in compliance with the License.
909 * You may obtain a copy of the License at
910 *
911 * http://www.apache.org/licenses/LICENSE-2.0
912 *
913 * Unless required by applicable law or agreed to in writing, software
914 * distributed under the License is distributed on an "AS IS" BASIS,
915 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
916 * See the License for the specific language governing permissions and
917 * limitations under the License.
918 *
919 * @providesModule DOMProperty
920 * @typechecks static-only
921 */
922
923/*jslint bitwise: true */
924
925"use strict";
926
927var invariant = require("./invariant");
928
929var DOMPropertyInjection = {
930 /**
931 * Mapping from normalized, camelcased property names to a configuration that
932 * specifies how the associated DOM property should be accessed or rendered.
933 */
934 MUST_USE_ATTRIBUTE: 0x1,
935 MUST_USE_PROPERTY: 0x2,
936 HAS_BOOLEAN_VALUE: 0x4,
937 HAS_SIDE_EFFECTS: 0x8,
938
939 /**
940 * Inject some specialized knowledge about the DOM. This takes a config object
941 * with the following properties:
942 *
943 * isCustomAttribute: function that given an attribute name will return true
944 * if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
945 * attributes where it's impossible to enumerate all of the possible
946 * attribute names,
947 *
948 * Properties: object mapping DOM property name to one of the
949 * DOMPropertyInjection constants or null. If your attribute isn't in here,
950 * it won't get written to the DOM.
951 *
952 * DOMAttributeNames: object mapping React attribute name to the DOM
953 * attribute name. Attribute names not specified use the **lowercase**
954 * normalized name.
955 *
956 * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
957 * Property names not specified use the normalized name.
958 *
959 * DOMMutationMethods: Properties that require special mutation methods. If
960 * `value` is undefined, the mutation method should unset the property.
961 *
962 * @param {object} domPropertyConfig the config as described above.
963 */
964 injectDOMPropertyConfig: function(domPropertyConfig) {
965 var Properties = domPropertyConfig.Properties || {};
966 var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
967 var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
968 var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
969
970 if (domPropertyConfig.isCustomAttribute) {
971 DOMProperty._isCustomAttributeFunctions.push(
972 domPropertyConfig.isCustomAttribute
973 );
974 }
975
976 for (var propName in Properties) {
977 invariant(
978 !DOMProperty.isStandardName[propName],
979 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
980 '\'%s\' which has already been injected. You may be accidentally ' +
981 'injecting the same DOM property config twice, or you may be ' +
982 'injecting two configs that have conflicting property names.',
983 propName
984 );
985
986 DOMProperty.isStandardName[propName] = true;
987
988 DOMProperty.getAttributeName[propName] =
989 DOMAttributeNames[propName] || propName.toLowerCase();
990
991 DOMProperty.getPropertyName[propName] =
992 DOMPropertyNames[propName] || propName;
993
994 var mutationMethod = DOMMutationMethods[propName];
995 if (mutationMethod) {
996 DOMProperty.getMutationMethod[propName] = mutationMethod;
997 }
998
999 var propConfig = Properties[propName];
1000 DOMProperty.mustUseAttribute[propName] =
1001 propConfig & DOMPropertyInjection.MUST_USE_ATTRIBUTE;
1002 DOMProperty.mustUseProperty[propName] =
1003 propConfig & DOMPropertyInjection.MUST_USE_PROPERTY;
1004 DOMProperty.hasBooleanValue[propName] =
1005 propConfig & DOMPropertyInjection.HAS_BOOLEAN_VALUE;
1006 DOMProperty.hasSideEffects[propName] =
1007 propConfig & DOMPropertyInjection.HAS_SIDE_EFFECTS;
1008
1009 invariant(
1010 !DOMProperty.mustUseAttribute[propName] ||
1011 !DOMProperty.mustUseProperty[propName],
1012 'DOMProperty: Cannot use require using both attribute and property: %s',
1013 propName
1014 );
1015 invariant(
1016 DOMProperty.mustUseProperty[propName] ||
1017 !DOMProperty.hasSideEffects[propName],
1018 'DOMProperty: Properties that have side effects must use property: %s',
1019 propName
1020 );
1021 }
1022 }
1023};
1024var defaultValueCache = {};
1025
1026/**
1027 * DOMProperty exports lookup objects that can be used like functions:
1028 *
1029 * > DOMProperty.isValid['id']
1030 * true
1031 * > DOMProperty.isValid['foobar']
1032 * undefined
1033 *
1034 * Although this may be confusing, it performs better in general.
1035 *
1036 * @see http://jsperf.com/key-exists
1037 * @see http://jsperf.com/key-missing
1038 */
1039var DOMProperty = {
1040
1041 /**
1042 * Checks whether a property name is a standard property.
1043 * @type {Object}
1044 */
1045 isStandardName: {},
1046
1047 /**
1048 * Mapping from normalized names to attribute names that differ. Attribute
1049 * names are used when rendering markup or with `*Attribute()`.
1050 * @type {Object}
1051 */
1052 getAttributeName: {},
1053
1054 /**
1055 * Mapping from normalized names to properties on DOM node instances.
1056 * (This includes properties that mutate due to external factors.)
1057 * @type {Object}
1058 */
1059 getPropertyName: {},
1060
1061 /**
1062 * Mapping from normalized names to mutation methods. This will only exist if
1063 * mutation cannot be set simply by the property or `setAttribute()`.
1064 * @type {Object}
1065 */
1066 getMutationMethod: {},
1067
1068 /**
1069 * Whether the property must be accessed and mutated as an object property.
1070 * @type {Object}
1071 */
1072 mustUseAttribute: {},
1073
1074 /**
1075 * Whether the property must be accessed and mutated using `*Attribute()`.
1076 * (This includes anything that fails `<propName> in <element>`.)
1077 * @type {Object}
1078 */
1079 mustUseProperty: {},
1080
1081 /**
1082 * Whether the property should be removed when set to a falsey value.
1083 * @type {Object}
1084 */
1085 hasBooleanValue: {},
1086
1087 /**
1088 * Whether or not setting a value causes side effects such as triggering
1089 * resources to be loaded or text selection changes. We must ensure that
1090 * the value is only set if it has changed.
1091 * @type {Object}
1092 */
1093 hasSideEffects: {},
1094
1095 /**
1096 * All of the isCustomAttribute() functions that have been injected.
1097 */
1098 _isCustomAttributeFunctions: [],
1099
1100 /**
1101 * Checks whether a property name is a custom attribute.
1102 * @method
1103 */
1104 isCustomAttribute: function(attributeName) {
1105 return DOMProperty._isCustomAttributeFunctions.some(
1106 function(isCustomAttributeFn) {
1107 return isCustomAttributeFn.call(null, attributeName);
1108 }
1109 );
1110 },
1111
1112 /**
1113 * Returns the default property value for a DOM property (i.e., not an
1114 * attribute). Most default values are '' or false, but not all. Worse yet,
1115 * some (in particular, `type`) vary depending on the type of element.
1116 *
1117 * TODO: Is it better to grab all the possible properties when creating an
1118 * element to avoid having to create the same element twice?
1119 */
1120 getDefaultValueForProperty: function(nodeName, prop) {
1121 var nodeDefaults = defaultValueCache[nodeName];
1122 var testElement;
1123 if (!nodeDefaults) {
1124 defaultValueCache[nodeName] = nodeDefaults = {};
1125 }
1126 if (!(prop in nodeDefaults)) {
1127 testElement = document.createElement(nodeName);
1128 nodeDefaults[prop] = testElement[prop];
1129 }
1130 return nodeDefaults[prop];
1131 },
1132
1133 injection: DOMPropertyInjection
1134};
1135
1136module.exports = DOMProperty;
1137
1138},{"./invariant":78}],8:[function(require,module,exports){
1139/**
1140 * Copyright 2013 Facebook, Inc.
1141 *
1142 * Licensed under the Apache License, Version 2.0 (the "License");
1143 * you may not use this file except in compliance with the License.
1144 * You may obtain a copy of the License at
1145 *
1146 * http://www.apache.org/licenses/LICENSE-2.0
1147 *
1148 * Unless required by applicable law or agreed to in writing, software
1149 * distributed under the License is distributed on an "AS IS" BASIS,
1150 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1151 * See the License for the specific language governing permissions and
1152 * limitations under the License.
1153 *
1154 * @providesModule DOMPropertyOperations
1155 * @typechecks static-only
1156 */
1157
1158"use strict";
1159
1160var DOMProperty = require("./DOMProperty");
1161
1162var escapeTextForBrowser = require("./escapeTextForBrowser");
1163var memoizeStringOnly = require("./memoizeStringOnly");
1164
1165var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
1166 return escapeTextForBrowser(name) + '="';
1167});
1168
1169/**
1170 * Operations for dealing with DOM properties.
1171 */
1172var DOMPropertyOperations = {
1173
1174 /**
1175 * Creates markup for a property.
1176 *
1177 * @param {string} name
1178 * @param {*} value
1179 * @return {?string} Markup string, or null if the property was invalid.
1180 */
1181 createMarkupForProperty: function(name, value) {
1182 if (DOMProperty.isStandardName[name]) {
1183 if (value == null || DOMProperty.hasBooleanValue[name] && !value) {
1184 return '';
1185 }
1186 var attributeName = DOMProperty.getAttributeName[name];
1187 return processAttributeNameAndPrefix(attributeName) +
1188 escapeTextForBrowser(value) + '"';
1189 } else if (DOMProperty.isCustomAttribute(name)) {
1190 if (value == null) {
1191 return '';
1192 }
1193 return processAttributeNameAndPrefix(name) +
1194 escapeTextForBrowser(value) + '"';
1195 } else {
1196 return null;
1197 }
1198 },
1199
1200 /**
1201 * Sets the value for a property on a node.
1202 *
1203 * @param {DOMElement} node
1204 * @param {string} name
1205 * @param {*} value
1206 */
1207 setValueForProperty: function(node, name, value) {
1208 if (DOMProperty.isStandardName[name]) {
1209 var mutationMethod = DOMProperty.getMutationMethod[name];
1210 if (mutationMethod) {
1211 mutationMethod(node, value);
1212 } else if (DOMProperty.mustUseAttribute[name]) {
1213 if (DOMProperty.hasBooleanValue[name] && !value) {
1214 node.removeAttribute(DOMProperty.getAttributeName[name]);
1215 } else {
1216 node.setAttribute(DOMProperty.getAttributeName[name], value);
1217 }
1218 } else {
1219 var propName = DOMProperty.getPropertyName[name];
1220 if (!DOMProperty.hasSideEffects[name] || node[propName] !== value) {
1221 node[propName] = value;
1222 }
1223 }
1224 } else if (DOMProperty.isCustomAttribute(name)) {
1225 node.setAttribute(name, value);
1226 }
1227 },
1228
1229 /**
1230 * Deletes the value for a property on a node.
1231 *
1232 * @param {DOMElement} node
1233 * @param {string} name
1234 */
1235 deleteValueForProperty: function(node, name) {
1236 if (DOMProperty.isStandardName[name]) {
1237 var mutationMethod = DOMProperty.getMutationMethod[name];
1238 if (mutationMethod) {
1239 mutationMethod(node, undefined);
1240 } else if (DOMProperty.mustUseAttribute[name]) {
1241 node.removeAttribute(DOMProperty.getAttributeName[name]);
1242 } else {
1243 var propName = DOMProperty.getPropertyName[name];
1244 node[propName] = DOMProperty.getDefaultValueForProperty(
1245 node.nodeName,
1246 name
1247 );
1248 }
1249 } else if (DOMProperty.isCustomAttribute(name)) {
1250 node.removeAttribute(name);
1251 }
1252 }
1253
1254};
1255
1256module.exports = DOMPropertyOperations;
1257
1258},{"./DOMProperty":7,"./escapeTextForBrowser":67,"./memoizeStringOnly":83}],9:[function(require,module,exports){
1259/**
1260 * Copyright 2013 Facebook, Inc.
1261 *
1262 * Licensed under the Apache License, Version 2.0 (the "License");
1263 * you may not use this file except in compliance with the License.
1264 * You may obtain a copy of the License at
1265 *
1266 * http://www.apache.org/licenses/LICENSE-2.0
1267 *
1268 * Unless required by applicable law or agreed to in writing, software
1269 * distributed under the License is distributed on an "AS IS" BASIS,
1270 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1271 * See the License for the specific language governing permissions and
1272 * limitations under the License.
1273 *
1274 * @providesModule Danger
1275 */
1276
1277/*jslint evil: true, sub: true */
1278
1279"use strict";
1280
1281var ExecutionEnvironment = require("./ExecutionEnvironment");
1282
1283var throwIf = require("./throwIf");
1284
1285var DOM_UNSUPPORTED;
1286var NO_MARKUP_PARENT;
1287var NO_MULTI_MARKUP;
1288if (true) {
1289 DOM_UNSUPPORTED =
1290 'You may not insert markup into the document while you are in a worker ' +
1291 'thread. It\'s not you, it\'s me. This is likely the fault of the ' +
1292 'framework. Please report this immediately.';
1293 NO_MARKUP_PARENT =
1294 'You have attempted to inject markup without a suitable parent. This is ' +
1295 'likely the fault of the framework - please report immediately.';
1296 NO_MULTI_MARKUP =
1297 'The framework has attempted to either insert zero or multiple markup ' +
1298 'roots into a single location when it should not. This is a serious ' +
1299 'error - a fault of the framework - please report immediately.';
1300}
1301
1302var validateMarkupParams;
1303if (true) {
1304 validateMarkupParams = function(parentNode, markup) {
1305 throwIf(!ExecutionEnvironment.canUseDOM, DOM_UNSUPPORTED);
1306 throwIf(!parentNode || !parentNode.tagName, NO_MARKUP_PARENT);
1307 throwIf(!markup, NO_MULTI_MARKUP);
1308 };
1309}
1310
1311/**
1312 * Dummy container used to render all markup.
1313 */
1314var dummyNode = ExecutionEnvironment.canUseDOM ?
1315 document.createElement('div') :
1316 null;
1317
1318/**
1319 * Some browsers cannot use `innerHTML` to render certain elements standalone,
1320 * so we wrap them, render the wrapped nodes, then extract the desired node.
1321 */
1322var markupWrap = {
1323 'option': [1, '<select multiple="true">', '</select>'],
1324 'legend': [1, '<fieldset>', '</fieldset>'],
1325 'area': [1, '<map>', '</map>'],
1326 'param': [1, '<object>', '</object>'],
1327 'thead': [1, '<table>', '</table>'],
1328 'tr': [2, '<table><tbody>', '</tbody></table>'],
1329 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
1330 'td': [3, '<table><tbody><tr>', '</tr></tbody></table>']
1331};
1332markupWrap['optgroup'] = markupWrap['option'];
1333markupWrap['tbody'] = markupWrap['thead'];
1334markupWrap['tfoot'] = markupWrap['thead'];
1335markupWrap['colgroup'] = markupWrap['thead'];
1336markupWrap['caption'] = markupWrap['thead'];
1337markupWrap['th'] = markupWrap['td'];
1338
1339/**
1340 * In IE8, certain elements cannot render alone, so wrap all elements.
1341 */
1342var defaultWrap = [1, '?<div>', '</div>'];
1343
1344/**
1345 * Feature detection, remove wraps that are unnecessary for the current browser.
1346 */
1347if (dummyNode) {
1348 for (var nodeName in markupWrap) {
1349 if (!markupWrap.hasOwnProperty(nodeName)) {
1350 continue;
1351 }
1352 dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
1353 if (dummyNode.firstChild) {
1354 markupWrap[nodeName] = null;
1355 }
1356 }
1357 dummyNode.innerHTML = '<link />';
1358 if (dummyNode.firstChild) {
1359 defaultWrap = null;
1360 }
1361}
1362
1363/**
1364 * Renders markup into nodes. The returned HTMLCollection is live and should be
1365 * used immediately (or at least before the next invocation to `renderMarkup`).
1366 *
1367 * NOTE: Extracting the `nodeName` does not require a regular expression match
1368 * because we make assumptions about React-generated markup (i.e. there are no
1369 * spaces surrounding the opening tag and there is at least one attribute).
1370 * @see http://jsperf.com/extract-nodename
1371 *
1372 * @param {string} markup
1373 * @return {*} An HTMLCollection.
1374 */
1375function renderMarkup(markup) {
1376 var node = dummyNode;
1377 var nodeName = markup.substring(1, markup.indexOf(' '));
1378
1379 var wrap = markupWrap[nodeName.toLowerCase()] || defaultWrap;
1380 if (wrap) {
1381 node.innerHTML = wrap[1] + markup + wrap[2];
1382
1383 var wrapDepth = wrap[0];
1384 while (wrapDepth--) {
1385 node = node.lastChild;
1386 }
1387 } else {
1388 node.innerHTML = markup;
1389 }
1390 return node.childNodes;
1391}
1392
1393/**
1394 * Inserts node after 'after'. If 'after' is null, inserts it after nothing,
1395 * which is inserting it at the beginning.
1396 *
1397 * @param {Element} elem Parent element.
1398 * @param {Element} insert Element to insert.
1399 * @param {Element} after Element to insert after.
1400 * @return {Element} Element that was inserted.
1401 */
1402function insertNodeAfterNode(elem, insert, after) {
1403 if (true) {
1404 throwIf(!ExecutionEnvironment.canUseDOM, DOM_UNSUPPORTED);
1405 }
1406 if (after) {
1407 if (after.nextSibling) {
1408 return elem.insertBefore(insert, after.nextSibling);
1409 } else {
1410 return elem.appendChild(insert);
1411 }
1412 } else {
1413 return elem.insertBefore(insert, elem.firstChild);
1414 }
1415}
1416
1417/**
1418 * Slow: Should only be used when it is known there are a few (or one) element
1419 * in the node list.
1420 * @param {Element} parentRootDomNode Parent element.
1421 * @param {HTMLCollection} htmlCollection HTMLCollection to insert.
1422 * @param {Element} after Element to insert the node list after.
1423 */
1424function inefficientlyInsertHTMLCollectionAfter(
1425 parentRootDomNode,
1426 htmlCollection,
1427 after) {
1428
1429 if (true) {
1430 throwIf(!ExecutionEnvironment.canUseDOM, DOM_UNSUPPORTED);
1431 }
1432 var ret;
1433 var originalLength = htmlCollection.length;
1434 // Access htmlCollection[0] because htmlCollection shrinks as we remove items.
1435 // `insertNodeAfterNode` will remove items from the htmlCollection.
1436 for (var i = 0; i < originalLength; i++) {
1437 ret =
1438 insertNodeAfterNode(parentRootDomNode, htmlCollection[0], ret || after);
1439 }
1440}
1441
1442/**
1443 * Super-dangerously inserts markup into existing DOM structure. Seriously, you
1444 * don't want to use this module unless you are building a framework. This
1445 * requires that the markup that you are inserting represents the root of a
1446 * tree. We do not support the case where there `markup` represents several
1447 * roots.
1448 *
1449 * @param {Element} parentNode Parent DOM element.
1450 * @param {string} markup Markup to dangerously insert.
1451 * @param {number} index Position to insert markup at.
1452 */
1453function dangerouslyInsertMarkupAt(parentNode, markup, index) {
1454 if (true) {
1455 validateMarkupParams(parentNode, markup);
1456 }
1457 var htmlCollection = renderMarkup(markup);
1458 var afterNode = index ? parentNode.childNodes[index - 1] : null;
1459 inefficientlyInsertHTMLCollectionAfter(parentNode, htmlCollection, afterNode);
1460}
1461
1462/**
1463 * Replaces a node with a string of markup at its current position within its
1464 * parent. `childNode` must be in the document (or at least within a parent
1465 * node). The string of markup must represent a tree of markup with a single
1466 * root.
1467 *
1468 * @param {Element} childNode Child node to replace.
1469 * @param {string} markup Markup to dangerously replace child with.
1470 */
1471function dangerouslyReplaceNodeWithMarkup(childNode, markup) {
1472 var parentNode = childNode.parentNode;
1473 if (true) {
1474 validateMarkupParams(parentNode, markup);
1475 }
1476 var htmlCollection = renderMarkup(markup);
1477 if (true) {
1478 throwIf(htmlCollection.length !== 1, NO_MULTI_MARKUP);
1479 }
1480 parentNode.replaceChild(htmlCollection[0], childNode);
1481}
1482
1483var Danger = {
1484 dangerouslyInsertMarkupAt: dangerouslyInsertMarkupAt,
1485 dangerouslyReplaceNodeWithMarkup: dangerouslyReplaceNodeWithMarkup
1486};
1487
1488module.exports = Danger;
1489
1490},{"./ExecutionEnvironment":19,"./throwIf":89}],10:[function(require,module,exports){
1491/**
1492 * Copyright 2013 Facebook, Inc.
1493 *
1494 * Licensed under the Apache License, Version 2.0 (the "License");
1495 * you may not use this file except in compliance with the License.
1496 * You may obtain a copy of the License at
1497 *
1498 * http://www.apache.org/licenses/LICENSE-2.0
1499 *
1500 * Unless required by applicable law or agreed to in writing, software
1501 * distributed under the License is distributed on an "AS IS" BASIS,
1502 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1503 * See the License for the specific language governing permissions and
1504 * limitations under the License.
1505 *
1506 * @providesModule DefaultDOMPropertyConfig
1507 */
1508
1509"use strict";
1510
1511var DOMProperty = require("./DOMProperty");
1512
1513var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
1514var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
1515var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
1516var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
1517
1518var DefaultDOMPropertyConfig = {
1519 isCustomAttribute: RegExp.prototype.test.bind(
1520 /^(data|aria)-[a-z_][a-z\d_.\-]*$/
1521 ),
1522 Properties: {
1523 /**
1524 * Standard Properties
1525 */
1526 accessKey: null,
1527 accept: null,
1528 action: null,
1529 ajaxify: MUST_USE_ATTRIBUTE,
1530 allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
1531 allowTransparency: MUST_USE_ATTRIBUTE,
1532 alt: null,
1533 autoComplete: null,
1534 autoFocus: HAS_BOOLEAN_VALUE,
1535 autoPlay: HAS_BOOLEAN_VALUE,
1536 cellPadding: null,
1537 cellSpacing: null,
1538 checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1539 className: MUST_USE_PROPERTY,
1540 colSpan: null,
1541 contentEditable: null,
1542 contextMenu: MUST_USE_ATTRIBUTE,
1543 controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1544 data: null, // For `<object />` acts as `src`.
1545 dateTime: MUST_USE_ATTRIBUTE,
1546 dir: null,
1547 disabled: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1548 draggable: null,
1549 encType: null,
1550 frameBorder: MUST_USE_ATTRIBUTE,
1551 height: MUST_USE_ATTRIBUTE,
1552 hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
1553 href: null,
1554 htmlFor: null,
1555 icon: null,
1556 id: MUST_USE_PROPERTY,
1557 label: null,
1558 lang: null,
1559 list: null,
1560 max: null,
1561 maxLength: MUST_USE_ATTRIBUTE,
1562 method: null,
1563 min: null,
1564 multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1565 name: null,
1566 pattern: null,
1567 poster: null,
1568 preload: null,
1569 placeholder: null,
1570 radioGroup: null,
1571 rel: null,
1572 readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1573 required: HAS_BOOLEAN_VALUE,
1574 role: MUST_USE_ATTRIBUTE,
1575 scrollLeft: MUST_USE_PROPERTY,
1576 scrollTop: MUST_USE_PROPERTY,
1577 selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
1578 size: null,
1579 spellCheck: null,
1580 src: null,
1581 step: null,
1582 style: null,
1583 tabIndex: null,
1584 target: null,
1585 title: null,
1586 type: null,
1587 value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
1588 width: MUST_USE_ATTRIBUTE,
1589 wmode: MUST_USE_ATTRIBUTE,
1590 /**
1591 * SVG Properties
1592 */
1593 cx: MUST_USE_PROPERTY,
1594 cy: MUST_USE_PROPERTY,
1595 d: MUST_USE_PROPERTY,
1596 fill: MUST_USE_PROPERTY,
1597 fx: MUST_USE_PROPERTY,
1598 fy: MUST_USE_PROPERTY,
1599 points: MUST_USE_PROPERTY,
1600 r: MUST_USE_PROPERTY,
1601 stroke: MUST_USE_PROPERTY,
1602 strokeLinecap: MUST_USE_PROPERTY,
1603 strokeWidth: MUST_USE_PROPERTY,
1604 transform: MUST_USE_PROPERTY,
1605 x: MUST_USE_PROPERTY,
1606 x1: MUST_USE_PROPERTY,
1607 x2: MUST_USE_PROPERTY,
1608 version: MUST_USE_PROPERTY,
1609 viewBox: MUST_USE_PROPERTY,
1610 y: MUST_USE_PROPERTY,
1611 y1: MUST_USE_PROPERTY,
1612 y2: MUST_USE_PROPERTY,
1613 spreadMethod: MUST_USE_PROPERTY,
1614 offset: MUST_USE_PROPERTY,
1615 stopColor: MUST_USE_PROPERTY,
1616 stopOpacity: MUST_USE_PROPERTY,
1617 gradientUnits: MUST_USE_PROPERTY,
1618 gradientTransform: MUST_USE_PROPERTY
1619 },
1620 DOMAttributeNames: {
1621 className: 'class',
1622 htmlFor: 'for',
1623 strokeLinecap: 'stroke-linecap',
1624 strokeWidth: 'stroke-width',
1625 stopColor: 'stop-color',
1626 stopOpacity: 'stop-opacity'
1627 },
1628 DOMPropertyNames: {
1629 autoComplete: 'autocomplete',
1630 autoFocus: 'autofocus',
1631 autoPlay: 'autoplay',
1632 encType: 'enctype',
1633 radioGroup: 'radiogroup',
1634 spellCheck: 'spellcheck'
1635 },
1636 DOMMutationMethods: {
1637 /**
1638 * Setting `className` to null may cause it to be set to the string "null".
1639 *
1640 * @param {DOMElement} node
1641 * @param {*} value
1642 */
1643 className: function(node, value) {
1644 node.className = value || '';
1645 }
1646 }
1647};
1648
1649module.exports = DefaultDOMPropertyConfig;
1650
1651},{"./DOMProperty":7}],11:[function(require,module,exports){
1652/**
1653 * Copyright 2013 Facebook, Inc.
1654 *
1655 * Licensed under the Apache License, Version 2.0 (the "License");
1656 * you may not use this file except in compliance with the License.
1657 * You may obtain a copy of the License at
1658 *
1659 * http://www.apache.org/licenses/LICENSE-2.0
1660 *
1661 * Unless required by applicable law or agreed to in writing, software
1662 * distributed under the License is distributed on an "AS IS" BASIS,
1663 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1664 * See the License for the specific language governing permissions and
1665 * limitations under the License.
1666 *
1667 * @providesModule DefaultEventPluginOrder
1668 */
1669
1670"use strict";
1671
1672 var keyOf = require("./keyOf");
1673
1674/**
1675 * Module that is injectable into `EventPluginHub`, that specifies a
1676 * deterministic ordering of `EventPlugin`s. A convenient way to reason about
1677 * plugins, without having to package every one of them. This is better than
1678 * having plugins be ordered in the same order that they are injected because
1679 * that ordering would be influenced by the packaging order.
1680 * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
1681 * preventing default on events is convenient in `SimpleEventPlugin` handlers.
1682 */
1683var DefaultEventPluginOrder = [
1684 keyOf({ResponderEventPlugin: null}),
1685 keyOf({SimpleEventPlugin: null}),
1686 keyOf({TapEventPlugin: null}),
1687 keyOf({EnterLeaveEventPlugin: null}),
1688 keyOf({ChangeEventPlugin: null}),
1689 keyOf({AnalyticsEventPlugin: null}),
1690 keyOf({MobileSafariClickEventPlugin: null})
1691];
1692
1693module.exports = DefaultEventPluginOrder;
1694
1695},{"./keyOf":82}],12:[function(require,module,exports){
1696(function(){/**
1697 * Copyright 2013 Facebook, Inc.
1698 *
1699 * Licensed under the Apache License, Version 2.0 (the "License");
1700 * you may not use this file except in compliance with the License.
1701 * You may obtain a copy of the License at
1702 *
1703 * http://www.apache.org/licenses/LICENSE-2.0
1704 *
1705 * Unless required by applicable law or agreed to in writing, software
1706 * distributed under the License is distributed on an "AS IS" BASIS,
1707 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1708 * See the License for the specific language governing permissions and
1709 * limitations under the License.
1710 *
1711 * @providesModule EnterLeaveEventPlugin
1712 * @typechecks static-only
1713 */
1714
1715"use strict";
1716
1717var EventConstants = require("./EventConstants");
1718var EventPropagators = require("./EventPropagators");
1719var ExecutionEnvironment = require("./ExecutionEnvironment");
1720var SyntheticMouseEvent = require("./SyntheticMouseEvent");
1721
1722var ReactMount = require("./ReactMount");
1723var keyOf = require("./keyOf");
1724
1725var topLevelTypes = EventConstants.topLevelTypes;
1726var getFirstReactDOM = ReactMount.getFirstReactDOM;
1727
1728var eventTypes = {
1729 mouseEnter: {registrationName: keyOf({onMouseEnter: null})},
1730 mouseLeave: {registrationName: keyOf({onMouseLeave: null})}
1731};
1732
1733var EnterLeaveEventPlugin = {
1734
1735 eventTypes: eventTypes,
1736
1737 /**
1738 * For almost every interaction we care about, there will be both a top-level
1739 * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
1740 * we do not extract duplicate events. However, moving the mouse into the
1741 * browser from outside will not fire a `mouseout` event. In this case, we use
1742 * the `mouseover` top-level event.
1743 *
1744 * @param {string} topLevelType Record from `EventConstants`.
1745 * @param {DOMEventTarget} topLevelTarget The listening component root node.
1746 * @param {string} topLevelTargetID ID of `topLevelTarget`.
1747 * @param {object} nativeEvent Native browser event.
1748 * @return {*} An accumulation of synthetic events.
1749 * @see {EventPluginHub.extractEvents}
1750 */
1751 extractEvents: function(
1752 topLevelType,
1753 topLevelTarget,
1754 topLevelTargetID,
1755 nativeEvent) {
1756 if (topLevelType === topLevelTypes.topMouseOver &&
1757 (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
1758 return null;
1759 }
1760 if (topLevelType !== topLevelTypes.topMouseOut &&
1761 topLevelType !== topLevelTypes.topMouseOver) {
1762 // Must not be a mouse in or mouse out - ignoring.
1763 return null;
1764 }
1765
1766 var from, to;
1767 if (topLevelType === topLevelTypes.topMouseOut) {
1768 from = topLevelTarget;
1769 to =
1770 getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
1771 ExecutionEnvironment.global;
1772 } else {
1773 from = ExecutionEnvironment.global;
1774 to = topLevelTarget;
1775 }
1776
1777 if (from === to) {
1778 // Nothing pertains to our managed components.
1779 return null;
1780 }
1781
1782 var fromID = from ? ReactMount.getID(from) : '';
1783 var toID = to ? ReactMount.getID(to) : '';
1784
1785 var leave = SyntheticMouseEvent.getPooled(
1786 eventTypes.mouseLeave,
1787 fromID,
1788 nativeEvent
1789 );
1790 var enter = SyntheticMouseEvent.getPooled(
1791 eventTypes.mouseEnter,
1792 toID,
1793 nativeEvent
1794 );
1795
1796 EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
1797 return [leave, enter];
1798 }
1799
1800};
1801
1802module.exports = EnterLeaveEventPlugin;
1803
1804})()
1805},{"./EventConstants":13,"./EventPropagators":18,"./ExecutionEnvironment":19,"./ReactMount":39,"./SyntheticMouseEvent":54,"./keyOf":82}],13:[function(require,module,exports){
1806/**
1807 * Copyright 2013 Facebook, Inc.
1808 *
1809 * Licensed under the Apache License, Version 2.0 (the "License");
1810 * you may not use this file except in compliance with the License.
1811 * You may obtain a copy of the License at
1812 *
1813 * http://www.apache.org/licenses/LICENSE-2.0
1814 *
1815 * Unless required by applicable law or agreed to in writing, software
1816 * distributed under the License is distributed on an "AS IS" BASIS,
1817 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818 * See the License for the specific language governing permissions and
1819 * limitations under the License.
1820 *
1821 * @providesModule EventConstants
1822 */
1823
1824"use strict";
1825
1826var keyMirror = require("./keyMirror");
1827
1828var PropagationPhases = keyMirror({bubbled: null, captured: null});
1829
1830/**
1831 * Types of raw signals from the browser caught at the top level.
1832 */
1833var topLevelTypes = keyMirror({
1834 topBlur: null,
1835 topChange: null,
1836 topClick: null,
1837 topDOMCharacterDataModified: null,
1838 topDoubleClick: null,
1839 topDrag: null,
1840 topDragEnd: null,
1841 topDragEnter: null,
1842 topDragExit: null,
1843 topDragLeave: null,
1844 topDragOver: null,
1845 topDragStart: null,
1846 topDrop: null,
1847 topFocus: null,
1848 topInput: null,
1849 topKeyDown: null,
1850 topKeyPress: null,
1851 topKeyUp: null,
1852 topMouseDown: null,
1853 topMouseMove: null,
1854 topMouseOut: null,
1855 topMouseOver: null,
1856 topMouseUp: null,
1857 topScroll: null,
1858 topSelectionChange: null,
1859 topSubmit: null,
1860 topTouchCancel: null,
1861 topTouchEnd: null,
1862 topTouchMove: null,
1863 topTouchStart: null,
1864 topWheel: null
1865});
1866
1867var EventConstants = {
1868 topLevelTypes: topLevelTypes,
1869 PropagationPhases: PropagationPhases
1870};
1871
1872module.exports = EventConstants;
1873
1874},{"./keyMirror":81}],14:[function(require,module,exports){
1875/**
1876 * Copyright 2013 Facebook, Inc.
1877 *
1878 * Licensed under the Apache License, Version 2.0 (the "License");
1879 * you may not use this file except in compliance with the License.
1880 * You may obtain a copy of the License at
1881 *
1882 * http://www.apache.org/licenses/LICENSE-2.0
1883 *
1884 * Unless required by applicable law or agreed to in writing, software
1885 * distributed under the License is distributed on an "AS IS" BASIS,
1886 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1887 * See the License for the specific language governing permissions and
1888 * limitations under the License.
1889 *
1890 * @providesModule EventListener
1891 */
1892
1893/**
1894 * Upstream version of event listener. Does not take into account specific
1895 * nature of platform.
1896 */
1897var EventListener = {
1898 /**
1899 * Listens to bubbled events on a DOM node.
1900 *
1901 * @param {Element} el DOM element to register listener on.
1902 * @param {string} handlerBaseName 'click'/'mouseover'
1903 * @param {Function!} cb Callback function
1904 */
1905 listen: function(el, handlerBaseName, cb) {
1906 if (el.addEventListener) {
1907 el.addEventListener(handlerBaseName, cb, false);
1908 } else if (el.attachEvent) {
1909 el.attachEvent('on' + handlerBaseName, cb);
1910 }
1911 },
1912
1913 /**
1914 * Listens to captured events on a DOM node.
1915 *
1916 * @see `EventListener.listen` for params.
1917 * @throws Exception if addEventListener is not supported.
1918 */
1919 capture: function(el, handlerBaseName, cb) {
1920 if (!el.addEventListener) {
1921 if (true) {
1922 console.error(
1923 'You are attempting to use addEventlistener ' +
1924 'in a browser that does not support it support it.' +
1925 'This likely means that you will not receive events that ' +
1926 'your application relies on (such as scroll).');
1927 }
1928 return;
1929 } else {
1930 el.addEventListener(handlerBaseName, cb, true);
1931 }
1932 }
1933};
1934
1935module.exports = EventListener;
1936
1937},{}],15:[function(require,module,exports){
1938/**
1939 * Copyright 2013 Facebook, Inc.
1940 *
1941 * Licensed under the Apache License, Version 2.0 (the "License");
1942 * you may not use this file except in compliance with the License.
1943 * You may obtain a copy of the License at
1944 *
1945 * http://www.apache.org/licenses/LICENSE-2.0
1946 *
1947 * Unless required by applicable law or agreed to in writing, software
1948 * distributed under the License is distributed on an "AS IS" BASIS,
1949 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1950 * See the License for the specific language governing permissions and
1951 * limitations under the License.
1952 *
1953 * @providesModule EventPluginHub
1954 */
1955
1956"use strict";
1957
1958var CallbackRegistry = require("./CallbackRegistry");
1959var EventPluginRegistry = require("./EventPluginRegistry");
1960var EventPluginUtils = require("./EventPluginUtils");
1961var EventPropagators = require("./EventPropagators");
1962var ExecutionEnvironment = require("./ExecutionEnvironment");
1963
1964var accumulate = require("./accumulate");
1965var forEachAccumulated = require("./forEachAccumulated");
1966var invariant = require("./invariant");
1967
1968/**
1969 * Internal queue of events that have accumulated their dispatches and are
1970 * waiting to have their dispatches executed.
1971 */
1972var eventQueue = null;
1973
1974/**
1975 * Dispatches an event and releases it back into the pool, unless persistent.
1976 *
1977 * @param {?object} event Synthetic event to be dispatched.
1978 * @private
1979 */
1980var executeDispatchesAndRelease = function(event) {
1981 if (event) {
1982 var executeDispatch = EventPluginUtils.executeDispatch;
1983 // Plugins can provide custom behavior when dispatching events.
1984 var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
1985 if (PluginModule && PluginModule.executeDispatch) {
1986 executeDispatch = PluginModule.executeDispatch;
1987 }
1988 EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
1989
1990 if (!event.isPersistent()) {
1991 event.constructor.release(event);
1992 }
1993 }
1994};
1995
1996/**
1997 * This is a unified interface for event plugins to be installed and configured.
1998 *
1999 * Event plugins can implement the following properties:
2000 *
2001 * `extractEvents` {function(string, DOMEventTarget, string, object): *}
2002 * Required. When a top-level event is fired, this method is expected to
2003 * extract synthetic events that will in turn be queued and dispatched.
2004 *
2005 * `eventTypes` {object}
2006 * Optional, plugins that fire events must publish a mapping of registration
2007 * names that are used to register listeners. Values of this mapping must
2008 * be objects that contain `registrationName` or `phasedRegistrationNames`.
2009 *
2010 * `executeDispatch` {function(object, function, string)}
2011 * Optional, allows plugins to override how an event gets dispatched. By
2012 * default, the listener is simply invoked.
2013 *
2014 * Each plugin that is injected into `EventsPluginHub` is immediately operable.
2015 *
2016 * @public
2017 */
2018var EventPluginHub = {
2019
2020 /**
2021 * Methods for injecting dependencies.
2022 */
2023 injection: {
2024
2025 /**
2026 * @param {object} InjectedInstanceHandle
2027 * @public
2028 */
2029 injectInstanceHandle: EventPropagators.injection.injectInstanceHandle,
2030
2031 /**
2032 * @param {array} InjectedEventPluginOrder
2033 * @public
2034 */
2035 injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
2036
2037 /**
2038 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
2039 */
2040 injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
2041
2042 },
2043
2044 registrationNames: EventPluginRegistry.registrationNames,
2045
2046 putListener: CallbackRegistry.putListener,
2047
2048 getListener: CallbackRegistry.getListener,
2049
2050 deleteListener: CallbackRegistry.deleteListener,
2051
2052 deleteAllListeners: CallbackRegistry.deleteAllListeners,
2053
2054 /**
2055 * Allows registered plugins an opportunity to extract events from top-level
2056 * native browser events.
2057 *
2058 * @param {string} topLevelType Record from `EventConstants`.
2059 * @param {DOMEventTarget} topLevelTarget The listening component root node.
2060 * @param {string} topLevelTargetID ID of `topLevelTarget`.
2061 * @param {object} nativeEvent Native browser event.
2062 * @return {*} An accumulation of synthetic events.
2063 * @internal
2064 */
2065 extractEvents: function(
2066 topLevelType,
2067 topLevelTarget,
2068 topLevelTargetID,
2069 nativeEvent) {
2070 var events;
2071 var plugins = EventPluginRegistry.plugins;
2072 for (var i = 0, l = plugins.length; i < l; i++) {
2073 // Not every plugin in the ordering may be loaded at runtime.
2074 var possiblePlugin = plugins[i];
2075 if (possiblePlugin) {
2076 var extractedEvents = possiblePlugin.extractEvents(
2077 topLevelType,
2078 topLevelTarget,
2079 topLevelTargetID,
2080 nativeEvent
2081 );
2082 if (extractedEvents) {
2083 events = accumulate(events, extractedEvents);
2084 }
2085 }
2086 }
2087 return events;
2088 },
2089
2090 /**
2091 * Enqueues a synthetic event that should be dispatched when
2092 * `processEventQueue` is invoked.
2093 *
2094 * @param {*} events An accumulation of synthetic events.
2095 * @internal
2096 */
2097 enqueueEvents: function(events) {
2098 if (events) {
2099 eventQueue = accumulate(eventQueue, events);
2100 }
2101 },
2102
2103 /**
2104 * Dispatches all synthetic events on the event queue.
2105 *
2106 * @internal
2107 */
2108 processEventQueue: function() {
2109 // Set `eventQueue` to null before processing it so that we can tell if more
2110 // events get enqueued while processing.
2111 var processingEventQueue = eventQueue;
2112 eventQueue = null;
2113 forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
2114 invariant(
2115 !eventQueue,
2116 'processEventQueue(): Additional events were enqueued while processing ' +
2117 'an event queue. Support for this has not yet been implemented.'
2118 );
2119 }
2120
2121};
2122
2123if (ExecutionEnvironment.canUseDOM) {
2124 window.EventPluginHub = EventPluginHub;
2125}
2126
2127module.exports = EventPluginHub;
2128
2129},{"./CallbackRegistry":4,"./EventPluginRegistry":16,"./EventPluginUtils":17,"./EventPropagators":18,"./ExecutionEnvironment":19,"./accumulate":61,"./forEachAccumulated":70,"./invariant":78}],16:[function(require,module,exports){
2130/**
2131 * Copyright 2013 Facebook, Inc.
2132 *
2133 * Licensed under the Apache License, Version 2.0 (the "License");
2134 * you may not use this file except in compliance with the License.
2135 * You may obtain a copy of the License at
2136 *
2137 * http://www.apache.org/licenses/LICENSE-2.0
2138 *
2139 * Unless required by applicable law or agreed to in writing, software
2140 * distributed under the License is distributed on an "AS IS" BASIS,
2141 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2142 * See the License for the specific language governing permissions and
2143 * limitations under the License.
2144 *
2145 * @providesModule EventPluginRegistry
2146 * @typechecks static-only
2147 */
2148
2149"use strict";
2150
2151var invariant = require("./invariant");
2152
2153/**
2154 * Injectable ordering of event plugins.
2155 */
2156var EventPluginOrder = null;
2157
2158/**
2159 * Injectable mapping from names to event plugin modules.
2160 */
2161var namesToPlugins = {};
2162
2163/**
2164 * Recomputes the plugin list using the injected plugins and plugin ordering.
2165 *
2166 * @private
2167 */
2168function recomputePluginOrdering() {
2169 if (!EventPluginOrder) {
2170 // Wait until an `EventPluginOrder` is injected.
2171 return;
2172 }
2173 for (var pluginName in namesToPlugins) {
2174 var PluginModule = namesToPlugins[pluginName];
2175 var pluginIndex = EventPluginOrder.indexOf(pluginName);
2176 invariant(
2177 pluginIndex > -1,
2178 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
2179 'the plugin ordering, `%s`.',
2180 pluginName
2181 );
2182 if (EventPluginRegistry.plugins[pluginIndex]) {
2183 continue;
2184 }
2185 invariant(
2186 PluginModule.extractEvents,
2187 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
2188 'method, but `%s` does not.',
2189 pluginName
2190 );
2191 EventPluginRegistry.plugins[pluginIndex] = PluginModule;
2192 var publishedEvents = PluginModule.eventTypes;
2193 for (var eventName in publishedEvents) {
2194 invariant(
2195 publishEventForPlugin(publishedEvents[eventName], PluginModule),
2196 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
2197 eventName,
2198 pluginName
2199 );
2200 }
2201 }
2202}
2203
2204/**
2205 * Publishes an event so that it can be dispatched by the supplied plugin.
2206 *
2207 * @param {object} dispatchConfig Dispatch configuration for the event.
2208 * @param {object} PluginModule Plugin publishing the event.
2209 * @return {boolean} True if the event was successfully published.
2210 * @private
2211 */
2212function publishEventForPlugin(dispatchConfig, PluginModule) {
2213 var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
2214 if (phasedRegistrationNames) {
2215 for (var phaseName in phasedRegistrationNames) {
2216 if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
2217 var phasedRegistrationName = phasedRegistrationNames[phaseName];
2218 publishRegistrationName(phasedRegistrationName, PluginModule);
2219 }
2220 }
2221 return true;
2222 } else if (dispatchConfig.registrationName) {
2223 publishRegistrationName(dispatchConfig.registrationName, PluginModule);
2224 return true;
2225 }
2226 return false;
2227}
2228
2229/**
2230 * Publishes a registration name that is used to identify dispatched events and
2231 * can be used with `EventPluginHub.putListener` to register listeners.
2232 *
2233 * @param {string} registrationName Registration name to add.
2234 * @param {object} PluginModule Plugin publishing the event.
2235 * @private
2236 */
2237function publishRegistrationName(registrationName, PluginModule) {
2238 invariant(
2239 !EventPluginRegistry.registrationNames[registrationName],
2240 'EventPluginHub: More than one plugin attempted to publish the same ' +
2241 'registration name, `%s`.',
2242 registrationName
2243 );
2244 EventPluginRegistry.registrationNames[registrationName] = PluginModule;
2245 EventPluginRegistry.registrationNamesKeys.push(registrationName);
2246}
2247
2248/**
2249 * Registers plugins so that they can extract and dispatch events.
2250 *
2251 * @see {EventPluginHub}
2252 */
2253var EventPluginRegistry = {
2254
2255 /**
2256 * Ordered list of injected plugins.
2257 */
2258 plugins: [],
2259
2260 /**
2261 * Mapping from registration names to plugin modules.
2262 */
2263 registrationNames: {},
2264
2265 /**
2266 * The keys of `registrationNames`.
2267 */
2268 registrationNamesKeys: [],
2269
2270 /**
2271 * Injects an ordering of plugins (by plugin name). This allows the ordering
2272 * to be decoupled from injection of the actual plugins so that ordering is
2273 * always deterministic regardless of packaging, on-the-fly injection, etc.
2274 *
2275 * @param {array} InjectedEventPluginOrder
2276 * @internal
2277 * @see {EventPluginHub.injection.injectEventPluginOrder}
2278 */
2279 injectEventPluginOrder: function(InjectedEventPluginOrder) {
2280 invariant(
2281 !EventPluginOrder,
2282 'EventPluginRegistry: Cannot inject event plugin ordering more than once.'
2283 );
2284 // Clone the ordering so it cannot be dynamically mutated.
2285 EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
2286 recomputePluginOrdering();
2287 },
2288
2289 /**
2290 * Injects plugins to be used by `EventPluginHub`. The plugin names must be
2291 * in the ordering injected by `injectEventPluginOrder`.
2292 *
2293 * Plugins can be injected as part of page initialization or on-the-fly.
2294 *
2295 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
2296 * @internal
2297 * @see {EventPluginHub.injection.injectEventPluginsByName}
2298 */
2299 injectEventPluginsByName: function(injectedNamesToPlugins) {
2300 var isOrderingDirty = false;
2301 for (var pluginName in injectedNamesToPlugins) {
2302 if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
2303 continue;
2304 }
2305 var PluginModule = injectedNamesToPlugins[pluginName];
2306 if (namesToPlugins[pluginName] !== PluginModule) {
2307 invariant(
2308 !namesToPlugins[pluginName],
2309 'EventPluginRegistry: Cannot inject two different event plugins ' +
2310 'using the same name, `%s`.',
2311 pluginName
2312 );
2313 namesToPlugins[pluginName] = PluginModule;
2314 isOrderingDirty = true;
2315 }
2316 }
2317 if (isOrderingDirty) {
2318 recomputePluginOrdering();
2319 }
2320 },
2321
2322 /**
2323 * Looks up the plugin for the supplied event.
2324 *
2325 * @param {object} event A synthetic event.
2326 * @return {?object} The plugin that created the supplied event.
2327 * @internal
2328 */
2329 getPluginModuleForEvent: function(event) {
2330 var dispatchConfig = event.dispatchConfig;
2331 if (dispatchConfig.registrationName) {
2332 return EventPluginRegistry.registrationNames[
2333 dispatchConfig.registrationName
2334 ] || null;
2335 }
2336 for (var phase in dispatchConfig.phasedRegistrationNames) {
2337 if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
2338 continue;
2339 }
2340 var PluginModule = EventPluginRegistry.registrationNames[
2341 dispatchConfig.phasedRegistrationNames[phase]
2342 ];
2343 if (PluginModule) {
2344 return PluginModule;
2345 }
2346 }
2347 return null;
2348 },
2349
2350 /**
2351 * Exposed for unit testing.
2352 * @private
2353 */
2354 _resetEventPlugins: function() {
2355 EventPluginOrder = null;
2356 for (var pluginName in namesToPlugins) {
2357 if (namesToPlugins.hasOwnProperty(pluginName)) {
2358 delete namesToPlugins[pluginName];
2359 }
2360 }
2361 EventPluginRegistry.plugins.length = 0;
2362 var registrationNames = EventPluginRegistry.registrationNames;
2363 for (var registrationName in registrationNames) {
2364 if (registrationNames.hasOwnProperty(registrationName)) {
2365 delete registrationNames[registrationName];
2366 }
2367 }
2368 EventPluginRegistry.registrationNamesKeys.length = 0;
2369 }
2370
2371};
2372
2373module.exports = EventPluginRegistry;
2374
2375},{"./invariant":78}],17:[function(require,module,exports){
2376/**
2377 * Copyright 2013 Facebook, Inc.
2378 *
2379 * Licensed under the Apache License, Version 2.0 (the "License");
2380 * you may not use this file except in compliance with the License.
2381 * You may obtain a copy of the License at
2382 *
2383 * http://www.apache.org/licenses/LICENSE-2.0
2384 *
2385 * Unless required by applicable law or agreed to in writing, software
2386 * distributed under the License is distributed on an "AS IS" BASIS,
2387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2388 * See the License for the specific language governing permissions and
2389 * limitations under the License.
2390 *
2391 * @providesModule EventPluginUtils
2392 */
2393
2394"use strict";
2395
2396var EventConstants = require("./EventConstants");
2397
2398var invariant = require("./invariant");
2399
2400var topLevelTypes = EventConstants.topLevelTypes;
2401
2402function isEndish(topLevelType) {
2403 return topLevelType === topLevelTypes.topMouseUp ||
2404 topLevelType === topLevelTypes.topTouchEnd ||
2405 topLevelType === topLevelTypes.topTouchCancel;
2406}
2407
2408function isMoveish(topLevelType) {
2409 return topLevelType === topLevelTypes.topMouseMove ||
2410 topLevelType === topLevelTypes.topTouchMove;
2411}
2412function isStartish(topLevelType) {
2413 return topLevelType === topLevelTypes.topMouseDown ||
2414 topLevelType === topLevelTypes.topTouchStart;
2415}
2416
2417var validateEventDispatches;
2418if (true) {
2419 validateEventDispatches = function(event) {
2420 var dispatchListeners = event._dispatchListeners;
2421 var dispatchIDs = event._dispatchIDs;
2422
2423 var listenersIsArr = Array.isArray(dispatchListeners);
2424 var idsIsArr = Array.isArray(dispatchIDs);
2425 var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
2426 var listenersLen = listenersIsArr ?
2427 dispatchListeners.length :
2428 dispatchListeners ? 1 : 0;
2429
2430 invariant(
2431 idsIsArr === listenersIsArr && IDsLen === listenersLen,
2432 'EventPluginUtils: Invalid `event`.'
2433 );
2434 };
2435}
2436
2437/**
2438 * Invokes `cb(event, listener, id)`. Avoids using call if no scope is
2439 * provided. The `(listener,id)` pair effectively forms the "dispatch" but are
2440 * kept separate to conserve memory.
2441 */
2442function forEachEventDispatch(event, cb) {
2443 var dispatchListeners = event._dispatchListeners;
2444 var dispatchIDs = event._dispatchIDs;
2445 if (true) {
2446 validateEventDispatches(event);
2447 }
2448 if (Array.isArray(dispatchListeners)) {
2449 for (var i = 0; i < dispatchListeners.length; i++) {
2450 if (event.isPropagationStopped()) {
2451 break;
2452 }
2453 // Listeners and IDs are two parallel arrays that are always in sync.
2454 cb(event, dispatchListeners[i], dispatchIDs[i]);
2455 }
2456 } else if (dispatchListeners) {
2457 cb(event, dispatchListeners, dispatchIDs);
2458 }
2459}
2460
2461/**
2462 * Default implementation of PluginModule.executeDispatch().
2463 * @param {SyntheticEvent} SyntheticEvent to handle
2464 * @param {function} Application-level callback
2465 * @param {string} domID DOM id to pass to the callback.
2466 */
2467function executeDispatch(event, listener, domID) {
2468 listener(event, domID);
2469}
2470
2471/**
2472 * Standard/simple iteration through an event's collected dispatches.
2473 */
2474function executeDispatchesInOrder(event, executeDispatch) {
2475 forEachEventDispatch(event, executeDispatch);
2476 event._dispatchListeners = null;
2477 event._dispatchIDs = null;
2478}
2479
2480/**
2481 * Standard/simple iteration through an event's collected dispatches, but stops
2482 * at the first dispatch execution returning true, and returns that id.
2483 *
2484 * @return id of the first dispatch execution who's listener returns true, or
2485 * null if no listener returned true.
2486 */
2487function executeDispatchesInOrderStopAtTrue(event) {
2488 var dispatchListeners = event._dispatchListeners;
2489 var dispatchIDs = event._dispatchIDs;
2490 if (true) {
2491 validateEventDispatches(event);
2492 }
2493 if (Array.isArray(dispatchListeners)) {
2494 for (var i = 0; i < dispatchListeners.length; i++) {
2495 if (event.isPropagationStopped()) {
2496 break;
2497 }
2498 // Listeners and IDs are two parallel arrays that are always in sync.
2499 if (dispatchListeners[i](event, dispatchIDs[i])) {
2500 return dispatchIDs[i];
2501 }
2502 }
2503 } else if (dispatchListeners) {
2504 if (dispatchListeners(event, dispatchIDs)) {
2505 return dispatchIDs;
2506 }
2507 }
2508 return null;
2509}
2510
2511/**
2512 * Execution of a "direct" dispatch - there must be at most one dispatch
2513 * accumulated on the event or it is considered an error. It doesn't really make
2514 * sense for an event with multiple dispatches (bubbled) to keep track of the
2515 * return values at each dispatch execution, but it does tend to make sense when
2516 * dealing with "direct" dispatches.
2517 *
2518 * @return The return value of executing the single dispatch.
2519 */
2520function executeDirectDispatch(event) {
2521 if (true) {
2522 validateEventDispatches(event);
2523 }
2524 var dispatchListener = event._dispatchListeners;
2525 var dispatchID = event._dispatchIDs;
2526 invariant(
2527 !Array.isArray(dispatchListener),
2528 'executeDirectDispatch(...): Invalid `event`.'
2529 );
2530 var res = dispatchListener ?
2531 dispatchListener(event, dispatchID) :
2532 null;
2533 event._dispatchListeners = null;
2534 event._dispatchIDs = null;
2535 return res;
2536}
2537
2538/**
2539 * @param {SyntheticEvent} event
2540 * @return {bool} True iff number of dispatches accumulated is greater than 0.
2541 */
2542function hasDispatches(event) {
2543 return !!event._dispatchListeners;
2544}
2545
2546/**
2547 * General utilities that are useful in creating custom Event Plugins.
2548 */
2549var EventPluginUtils = {
2550 isEndish: isEndish,
2551 isMoveish: isMoveish,
2552 isStartish: isStartish,
2553 executeDispatchesInOrder: executeDispatchesInOrder,
2554 executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
2555 executeDirectDispatch: executeDirectDispatch,
2556 hasDispatches: hasDispatches,
2557 executeDispatch: executeDispatch
2558};
2559
2560module.exports = EventPluginUtils;
2561
2562},{"./EventConstants":13,"./invariant":78}],18:[function(require,module,exports){
2563/**
2564 * Copyright 2013 Facebook, Inc.
2565 *
2566 * Licensed under the Apache License, Version 2.0 (the "License");
2567 * you may not use this file except in compliance with the License.
2568 * You may obtain a copy of the License at
2569 *
2570 * http://www.apache.org/licenses/LICENSE-2.0
2571 *
2572 * Unless required by applicable law or agreed to in writing, software
2573 * distributed under the License is distributed on an "AS IS" BASIS,
2574 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2575 * See the License for the specific language governing permissions and
2576 * limitations under the License.
2577 *
2578 * @providesModule EventPropagators
2579 */
2580
2581"use strict";
2582
2583var CallbackRegistry = require("./CallbackRegistry");
2584var EventConstants = require("./EventConstants");
2585
2586var accumulate = require("./accumulate");
2587var forEachAccumulated = require("./forEachAccumulated");
2588var getListener = CallbackRegistry.getListener;
2589var PropagationPhases = EventConstants.PropagationPhases;
2590
2591/**
2592 * Injected dependencies:
2593 */
2594
2595/**
2596 * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
2597 * hierarchy given ids of the logical DOM elements involved.
2598 */
2599var injection = {
2600 InstanceHandle: null,
2601 injectInstanceHandle: function(InjectedInstanceHandle) {
2602 injection.InstanceHandle = InjectedInstanceHandle;
2603 if (true) {
2604 injection.validate();
2605 }
2606 },
2607 validate: function() {
2608 var invalid = !injection.InstanceHandle||
2609 !injection.InstanceHandle.traverseTwoPhase ||
2610 !injection.InstanceHandle.traverseEnterLeave;
2611 if (invalid) {
2612 throw new Error('InstanceHandle not injected before use!');
2613 }
2614 }
2615};
2616
2617/**
2618 * Some event types have a notion of different registration names for different
2619 * "phases" of propagation. This finds listeners by a given phase.
2620 */
2621function listenerAtPhase(id, event, propagationPhase) {
2622 var registrationName =
2623 event.dispatchConfig.phasedRegistrationNames[propagationPhase];
2624 return getListener(id, registrationName);
2625}
2626
2627/**
2628 * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
2629 * here, allows us to not have to bind or create functions for each event.
2630 * Mutating the event's members allows us to not have to create a wrapping
2631 * "dispatch" object that pairs the event with the listener.
2632 */
2633function accumulateDirectionalDispatches(domID, upwards, event) {
2634 if (true) {
2635 if (!domID) {
2636 throw new Error('Dispatching id must not be null');
2637 }
2638 injection.validate();
2639 }
2640 var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
2641 var listener = listenerAtPhase(domID, event, phase);
2642 if (listener) {
2643 event._dispatchListeners = accumulate(event._dispatchListeners, listener);
2644 event._dispatchIDs = accumulate(event._dispatchIDs, domID);
2645 }
2646}
2647
2648/**
2649 * Collect dispatches (must be entirely collected before dispatching - see unit
2650 * tests). Lazily allocate the array to conserve memory. We must loop through
2651 * each event and perform the traversal for each one. We can not perform a
2652 * single traversal for the entire collection of events because each event may
2653 * have a different target.
2654 */
2655function accumulateTwoPhaseDispatchesSingle(event) {
2656 if (event && event.dispatchConfig.phasedRegistrationNames) {
2657 injection.InstanceHandle.traverseTwoPhase(
2658 event.dispatchMarker,
2659 accumulateDirectionalDispatches,
2660 event
2661 );
2662 }
2663}
2664
2665
2666/**
2667 * Accumulates without regard to direction, does not look for phased
2668 * registration names. Same as `accumulateDirectDispatchesSingle` but without
2669 * requiring that the `dispatchMarker` be the same as the dispatched ID.
2670 */
2671function accumulateDispatches(id, ignoredDirection, event) {
2672 if (event && event.dispatchConfig.registrationName) {
2673 var registrationName = event.dispatchConfig.registrationName;
2674 var listener = getListener(id, registrationName);
2675 if (listener) {
2676 event._dispatchListeners = accumulate(event._dispatchListeners, listener);
2677 event._dispatchIDs = accumulate(event._dispatchIDs, id);
2678 }
2679 }
2680}
2681
2682/**
2683 * Accumulates dispatches on an `SyntheticEvent`, but only for the
2684 * `dispatchMarker`.
2685 * @param {SyntheticEvent} event
2686 */
2687function accumulateDirectDispatchesSingle(event) {
2688 if (event && event.dispatchConfig.registrationName) {
2689 accumulateDispatches(event.dispatchMarker, null, event);
2690 }
2691}
2692
2693function accumulateTwoPhaseDispatches(events) {
2694 if (true) {
2695 injection.validate();
2696 }
2697 forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
2698}
2699
2700function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
2701 if (true) {
2702 injection.validate();
2703 }
2704 injection.InstanceHandle.traverseEnterLeave(
2705 fromID,
2706 toID,
2707 accumulateDispatches,
2708 leave,
2709 enter
2710 );
2711}
2712
2713
2714function accumulateDirectDispatches(events) {
2715 if (true) {
2716 injection.validate();
2717 }
2718 forEachAccumulated(events, accumulateDirectDispatchesSingle);
2719}
2720
2721
2722
2723/**
2724 * A small set of propagation patterns, each of which will accept a small amount
2725 * of information, and generate a set of "dispatch ready event objects" - which
2726 * are sets of events that have already been annotated with a set of dispatched
2727 * listener functions/ids. The API is designed this way to discourage these
2728 * propagation strategies from actually executing the dispatches, since we
2729 * always want to collect the entire set of dispatches before executing event a
2730 * single one.
2731 *
2732 * @constructor EventPropagators
2733 */
2734var EventPropagators = {
2735 accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
2736 accumulateDirectDispatches: accumulateDirectDispatches,
2737 accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches,
2738 injection: injection
2739};
2740
2741module.exports = EventPropagators;
2742
2743},{"./CallbackRegistry":4,"./EventConstants":13,"./accumulate":61,"./forEachAccumulated":70}],19:[function(require,module,exports){
2744(function(){/**
2745 * Copyright 2013 Facebook, Inc.
2746 *
2747 * Licensed under the Apache License, Version 2.0 (the "License");
2748 * you may not use this file except in compliance with the License.
2749 * You may obtain a copy of the License at
2750 *
2751 * http://www.apache.org/licenses/LICENSE-2.0
2752 *
2753 * Unless required by applicable law or agreed to in writing, software
2754 * distributed under the License is distributed on an "AS IS" BASIS,
2755 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2756 * See the License for the specific language governing permissions and
2757 * limitations under the License.
2758 *
2759 * @providesModule ExecutionEnvironment
2760 */
2761
2762/*jslint evil: true */
2763
2764"use strict";
2765
2766var canUseDOM = typeof window !== 'undefined';
2767
2768/**
2769 * Simple, lightweight module assisting with the detection and context of
2770 * Worker. Helps avoid circular dependencies and allows code to reason about
2771 * whether or not they are in a Worker, even if they never include the main
2772 * `ReactWorker` dependency.
2773 */
2774var ExecutionEnvironment = {
2775
2776 canUseDOM: canUseDOM,
2777
2778 canUseWorkers: typeof Worker !== 'undefined',
2779
2780 isInWorker: !canUseDOM, // For now, this is true - might change in the future.
2781
2782 global: new Function('return this;')()
2783
2784};
2785
2786module.exports = ExecutionEnvironment;
2787
2788})()
2789},{}],20:[function(require,module,exports){
2790/**
2791 * Copyright 2013 Facebook, Inc.
2792 *
2793 * Licensed under the Apache License, Version 2.0 (the "License");
2794 * you may not use this file except in compliance with the License.
2795 * You may obtain a copy of the License at
2796 *
2797 * http://www.apache.org/licenses/LICENSE-2.0
2798 *
2799 * Unless required by applicable law or agreed to in writing, software
2800 * distributed under the License is distributed on an "AS IS" BASIS,
2801 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2802 * See the License for the specific language governing permissions and
2803 * limitations under the License.
2804 *
2805 * @providesModule MobileSafariClickEventPlugin
2806 * @typechecks static-only
2807 */
2808
2809"use strict";
2810
2811var EventConstants = require("./EventConstants");
2812
2813var emptyFunction = require("./emptyFunction");
2814
2815var topLevelTypes = EventConstants.topLevelTypes;
2816
2817/**
2818 * Mobile Safari does not fire properly bubble click events on non-interactive
2819 * elements, which means delegated click listeners do not fire. The workaround
2820 * for this bug involves attaching an empty click listener on the target node.
2821 *
2822 * This particular plugin works around the bug by attaching an empty click
2823 * listener on `touchstart` (which does fire on every element).
2824 */
2825var MobileSafariClickEventPlugin = {
2826
2827 eventTypes: null,
2828
2829 /**
2830 * @param {string} topLevelType Record from `EventConstants`.
2831 * @param {DOMEventTarget} topLevelTarget The listening component root node.
2832 * @param {string} topLevelTargetID ID of `topLevelTarget`.
2833 * @param {object} nativeEvent Native browser event.
2834 * @return {*} An accumulation of synthetic events.
2835 * @see {EventPluginHub.extractEvents}
2836 */
2837 extractEvents: function(
2838 topLevelType,
2839 topLevelTarget,
2840 topLevelTargetID,
2841 nativeEvent) {
2842 if (topLevelType === topLevelTypes.topTouchStart) {
2843 var target = nativeEvent.target;
2844 if (target && !target.onclick) {
2845 target.onclick = emptyFunction;
2846 }
2847 }
2848 }
2849
2850};
2851
2852module.exports = MobileSafariClickEventPlugin;
2853
2854},{"./EventConstants":13,"./emptyFunction":66}],21:[function(require,module,exports){
2855/**
2856 * Copyright 2013 Facebook, Inc.
2857 *
2858 * Licensed under the Apache License, Version 2.0 (the "License");
2859 * you may not use this file except in compliance with the License.
2860 * You may obtain a copy of the License at
2861 *
2862 * http://www.apache.org/licenses/LICENSE-2.0
2863 *
2864 * Unless required by applicable law or agreed to in writing, software
2865 * distributed under the License is distributed on an "AS IS" BASIS,
2866 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2867 * See the License for the specific language governing permissions and
2868 * limitations under the License.
2869 *
2870 * @providesModule PooledClass
2871 */
2872
2873"use strict";
2874
2875/**
2876 * Static poolers. Several custom versions for each potential number of
2877 * arguments. A completely generic pooler is easy to implement, but would
2878 * require accessing the `arguments` object. In each of these, `this` refers to
2879 * the Class itself, not an instance. If any others are needed, simply add them
2880 * here, or in their own files.
2881 */
2882var oneArgumentPooler = function(copyFieldsFrom) {
2883 var Klass = this;
2884 if (Klass.instancePool.length) {
2885 var instance = Klass.instancePool.pop();
2886 Klass.call(instance, copyFieldsFrom);
2887 return instance;
2888 } else {
2889 return new Klass(copyFieldsFrom);
2890 }
2891};
2892
2893var twoArgumentPooler = function(a1, a2) {
2894 var Klass = this;
2895 if (Klass.instancePool.length) {
2896 var instance = Klass.instancePool.pop();
2897 Klass.call(instance, a1, a2);
2898 return instance;
2899 } else {
2900 return new Klass(a1, a2);
2901 }
2902};
2903
2904var threeArgumentPooler = function(a1, a2, a3) {
2905 var Klass = this;
2906 if (Klass.instancePool.length) {
2907 var instance = Klass.instancePool.pop();
2908 Klass.call(instance, a1, a2, a3);
2909 return instance;
2910 } else {
2911 return new Klass(a1, a2, a3);
2912 }
2913};
2914
2915var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
2916 var Klass = this;
2917 if (Klass.instancePool.length) {
2918 var instance = Klass.instancePool.pop();
2919 Klass.call(instance, a1, a2, a3, a4, a5);
2920 return instance;
2921 } else {
2922 return new Klass(a1, a2, a3, a4, a5);
2923 }
2924};
2925
2926var standardReleaser = function(instance) {
2927 var Klass = this;
2928 if (instance.destructor) {
2929 instance.destructor();
2930 }
2931 if (Klass.instancePool.length < Klass.poolSize) {
2932 Klass.instancePool.push(instance);
2933 }
2934};
2935
2936var DEFAULT_POOL_SIZE = 10;
2937var DEFAULT_POOLER = oneArgumentPooler;
2938
2939/**
2940 * Augments `CopyConstructor` to be a poolable class, augmenting only the class
2941 * itself (statically) not adding any prototypical fields. Any CopyConstructor
2942 * you give this may have a `poolSize` property, and will look for a
2943 * prototypical `destructor` on instances (optional).
2944 *
2945 * @param {Function} CopyConstructor Constructor that can be used to reset.
2946 * @param {Function} pooler Customizable pooler.
2947 */
2948var addPoolingTo = function(CopyConstructor, pooler) {
2949 var NewKlass = CopyConstructor;
2950 NewKlass.instancePool = [];
2951 NewKlass.getPooled = pooler || DEFAULT_POOLER;
2952 if (!NewKlass.poolSize) {
2953 NewKlass.poolSize = DEFAULT_POOL_SIZE;
2954 }
2955 NewKlass.release = standardReleaser;
2956 return NewKlass;
2957};
2958
2959var PooledClass = {
2960 addPoolingTo: addPoolingTo,
2961 oneArgumentPooler: oneArgumentPooler,
2962 twoArgumentPooler: twoArgumentPooler,
2963 threeArgumentPooler: threeArgumentPooler,
2964 fiveArgumentPooler: fiveArgumentPooler
2965};
2966
2967module.exports = PooledClass;
2968
2969},{}],22:[function(require,module,exports){
2970/**
2971 * Copyright 2013 Facebook, Inc.
2972 *
2973 * Licensed under the Apache License, Version 2.0 (the "License");
2974 * you may not use this file except in compliance with the License.
2975 * You may obtain a copy of the License at
2976 *
2977 * http://www.apache.org/licenses/LICENSE-2.0
2978 *
2979 * Unless required by applicable law or agreed to in writing, software
2980 * distributed under the License is distributed on an "AS IS" BASIS,
2981 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2982 * See the License for the specific language governing permissions and
2983 * limitations under the License.
2984 *
2985 * @providesModule React
2986 */
2987
2988"use strict";
2989
2990var ReactCompositeComponent = require("./ReactCompositeComponent");
2991var ReactComponent = require("./ReactComponent");
2992var ReactDOM = require("./ReactDOM");
2993var ReactMount = require("./ReactMount");
2994var ReactPropTypes = require("./ReactPropTypes");
2995var ReactServerRendering = require("./ReactServerRendering");
2996
2997var ReactDefaultInjection = require("./ReactDefaultInjection");
2998
2999ReactDefaultInjection.inject();
3000
3001var React = {
3002 DOM: ReactDOM,
3003 PropTypes: ReactPropTypes,
3004 initializeTouchEvents: function(shouldUseTouch) {
3005 ReactMount.useTouchEvents = shouldUseTouch;
3006 },
3007 autoBind: ReactCompositeComponent.autoBind,
3008 createClass: ReactCompositeComponent.createClass,
3009 constructAndRenderComponent: ReactMount.constructAndRenderComponent,
3010 constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
3011 renderComponent: ReactMount.renderComponent,
3012 renderComponentToString: ReactServerRendering.renderComponentToString,
3013 unmountAndReleaseReactRootNode: ReactMount.unmountAndReleaseReactRootNode,
3014 isValidComponent: ReactComponent.isValidComponent
3015};
3016
3017module.exports = React;
3018
3019},{"./ReactComponent":23,"./ReactCompositeComponent":24,"./ReactDOM":26,"./ReactDefaultInjection":33,"./ReactMount":39,"./ReactPropTypes":45,"./ReactServerRendering":47}],23:[function(require,module,exports){
3020/**
3021 * Copyright 2013 Facebook, Inc.
3022 *
3023 * Licensed under the Apache License, Version 2.0 (the "License");
3024 * you may not use this file except in compliance with the License.
3025 * You may obtain a copy of the License at
3026 *
3027 * http://www.apache.org/licenses/LICENSE-2.0
3028 *
3029 * Unless required by applicable law or agreed to in writing, software
3030 * distributed under the License is distributed on an "AS IS" BASIS,
3031 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032 * See the License for the specific language governing permissions and
3033 * limitations under the License.
3034 *
3035 * @providesModule ReactComponent
3036 */
3037
3038/*jslint evil: true */
3039
3040"use strict";
3041
3042var getReactRootElementInContainer = require("./getReactRootElementInContainer");
3043var ReactCurrentOwner = require("./ReactCurrentOwner");
3044var ReactDOMIDOperations = require("./ReactDOMIDOperations");
3045var ReactMarkupChecksum = require("./ReactMarkupChecksum");
3046var ReactMount = require("./ReactMount");
3047var ReactOwner = require("./ReactOwner");
3048var ReactReconcileTransaction = require("./ReactReconcileTransaction");
3049var ReactUpdates = require("./ReactUpdates");
3050
3051var invariant = require("./invariant");
3052var keyMirror = require("./keyMirror");
3053var merge = require("./merge");
3054
3055/**
3056 * Prop key that references a component's owner.
3057 * @private
3058 */
3059var OWNER = '{owner}';
3060
3061/**
3062 * Props key that determines if a component's key was already validated.
3063 * @private
3064 */
3065var IS_KEY_VALIDATED = '{is.key.validated}';
3066
3067/**
3068 * Every React component is in one of these life cycles.
3069 */
3070var ComponentLifeCycle = keyMirror({
3071 /**
3072 * Mounted components have a DOM node representation and are capable of
3073 * receiving new props.
3074 */
3075 MOUNTED: null,
3076 /**
3077 * Unmounted components are inactive and cannot receive new props.
3078 */
3079 UNMOUNTED: null
3080});
3081
3082/**
3083 * Warn if there's no key explicitly set on dynamic arrays of children.
3084 * This allows us to keep track of children between updates.
3085 */
3086
3087var ownerHasWarned = {};
3088
3089/**
3090 * Warn if the component doesn't have an explicit key assigned to it.
3091 * This component is in an array. The array could grow and shrink or be
3092 * reordered. All children, that hasn't already been validated, are required to
3093 * have a "key" property assigned to it.
3094 *
3095 * @internal
3096 * @param {ReactComponent} component Component that requires a key.
3097 */
3098function validateExplicitKey(component) {
3099 if (component[IS_KEY_VALIDATED] || component.props.key != null) {
3100 return;
3101 }
3102 component[IS_KEY_VALIDATED] = true;
3103
3104 // We can't provide friendly warnings for top level components.
3105 if (!ReactCurrentOwner.current) {
3106 return;
3107 }
3108
3109 // Name of the component whose render method tried to pass children.
3110 var currentName = ReactCurrentOwner.current.constructor.displayName;
3111 if (ownerHasWarned.hasOwnProperty(currentName)) {
3112 return;
3113 }
3114 ownerHasWarned[currentName] = true;
3115
3116 var message = 'Each child in an array should have a unique "key" prop. ' +
3117 'Check the render method of ' + currentName + '.';
3118 if (!component.isOwnedBy(ReactCurrentOwner.current)) {
3119 // Name of the component that originally created this child.
3120 var childOwnerName =
3121 component.props[OWNER] && component.props[OWNER].constructor.displayName;
3122
3123 // Usually the current owner is the offender, but if it accepts
3124 // children as a property, it may be the creator of the child that's
3125 // responsible for assigning it a key.
3126 message += ' It was passed a child from ' + childOwnerName + '.';
3127 }
3128
3129 console.warn(message);
3130}
3131
3132/**
3133 * Ensure that every component either is passed in a static location or, if
3134 * if it's passed in an array, has an explicit key property defined.
3135 *
3136 * @internal
3137 * @param {*} component Statically passed child of any type.
3138 * @return {boolean}
3139 */
3140function validateChildKeys(component) {
3141 if (Array.isArray(component)) {
3142 for (var i = 0; i < component.length; i++) {
3143 var child = component[i];
3144 if (ReactComponent.isValidComponent(child)) {
3145 validateExplicitKey(child);
3146 }
3147 }
3148 } else if (ReactComponent.isValidComponent(component)) {
3149 // This component was passed in a valid location.
3150 component[IS_KEY_VALIDATED] = true;
3151 }
3152}
3153
3154/**
3155 * Components are the basic units of composition in React.
3156 *
3157 * Every component accepts a set of keyed input parameters known as "props" that
3158 * are initialized by the constructor. Once a component is mounted, the props
3159 * can be mutated using `setProps` or `replaceProps`.
3160 *
3161 * Every component is capable of the following operations:
3162 *
3163 * `mountComponent`
3164 * Initializes the component, renders markup, and registers event listeners.
3165 *
3166 * `receiveProps`
3167 * Updates the rendered DOM nodes given a new set of props.
3168 *
3169 * `unmountComponent`
3170 * Releases any resources allocated by this component.
3171 *
3172 * Components can also be "owned" by other components. Being owned by another
3173 * component means being constructed by that component. This is different from
3174 * being the child of a component, which means having a DOM representation that
3175 * is a child of the DOM representation of that component.
3176 *
3177 * @class ReactComponent
3178 */
3179var ReactComponent = {
3180
3181 /**
3182 * @param {?object} object
3183 * @return {boolean} True if `object` is a valid component.
3184 * @final
3185 */
3186 isValidComponent: function(object) {
3187 return !!(
3188 object &&
3189 typeof object.mountComponentIntoNode === 'function' &&
3190 typeof object.receiveProps === 'function'
3191 );
3192 },
3193
3194 /**
3195 * Generate a key string that identifies a component within a set.
3196 *
3197 * @param {*} component A component that could contain a manual key.
3198 * @param {number} index Index that is used if a manual key is not provided.
3199 * @return {string}
3200 * @internal
3201 */
3202 getKey: function(component, index) {
3203 if (component && component.props && component.props.key != null) {
3204 // Explicit key
3205 return '' + component.props.key;
3206 }
3207 // Implicit key determined by the index in the set
3208 return '' + index;
3209 },
3210
3211 /**
3212 * @internal
3213 */
3214 LifeCycle: ComponentLifeCycle,
3215
3216 /**
3217 * React references `ReactDOMIDOperations` using this property in order to
3218 * allow dependency injection.
3219 *
3220 * @internal
3221 */
3222 DOMIDOperations: ReactDOMIDOperations,
3223
3224 /**
3225 * React references `ReactReconcileTransaction` using this property in order
3226 * to allow dependency injection.
3227 *
3228 * @internal
3229 */
3230 ReactReconcileTransaction: ReactReconcileTransaction,
3231
3232 /**
3233 * @param {object} DOMIDOperations
3234 * @final
3235 */
3236 setDOMOperations: function(DOMIDOperations) {
3237 ReactComponent.DOMIDOperations = DOMIDOperations;
3238 },
3239
3240 /**
3241 * @param {Transaction} ReactReconcileTransaction
3242 * @final
3243 */
3244 setReactReconcileTransaction: function(ReactReconcileTransaction) {
3245 ReactComponent.ReactReconcileTransaction = ReactReconcileTransaction;
3246 },
3247
3248 /**
3249 * Base functionality for every ReactComponent constructor.
3250 *
3251 * @lends {ReactComponent.prototype}
3252 */
3253 Mixin: {
3254
3255 /**
3256 * Checks whether or not this component is mounted.
3257 *
3258 * @return {boolean} True if mounted, false otherwise.
3259 * @final
3260 * @protected
3261 */
3262 isMounted: function() {
3263 return this._lifeCycleState === ComponentLifeCycle.MOUNTED;
3264 },
3265
3266 /**
3267 * Returns the DOM node rendered by this component.
3268 *
3269 * @return {DOMElement} The root node of this component.
3270 * @final
3271 * @protected
3272 */
3273 getDOMNode: function() {
3274 invariant(
3275 this.isMounted(),
3276 'getDOMNode(): A component must be mounted to have a DOM node.'
3277 );
3278 return ReactMount.getNode(this._rootNodeID);
3279 },
3280
3281 /**
3282 * Sets a subset of the props.
3283 *
3284 * @param {object} partialProps Subset of the next props.
3285 * @param {?function} callback Called after props are updated.
3286 * @final
3287 * @public
3288 */
3289 setProps: function(partialProps, callback) {
3290 // Merge with `_pendingProps` if it exists, otherwise with existing props.
3291 this.replaceProps(
3292 merge(this._pendingProps || this.props, partialProps),
3293 callback
3294 );
3295 },
3296
3297 /**
3298 * Replaces all of the props.
3299 *
3300 * @param {object} props New props.
3301 * @param {?function} callback Called after props are updated.
3302 * @final
3303 * @public
3304 */
3305 replaceProps: function(props, callback) {
3306 invariant(
3307 !this.props[OWNER],
3308 'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
3309 'component with an owner. This is an anti-pattern since props will ' +
3310 'get reactively updated when rendered. Instead, change the owner\'s ' +
3311 '`render` method to pass the correct value as props to the component ' +
3312 'where it is created.'
3313 );
3314 this._pendingProps = props;
3315 ReactUpdates.enqueueUpdate(this, callback);
3316 },
3317
3318 /**
3319 * Base constructor for all React component.
3320 *
3321 * Subclasses that override this method should make sure to invoke
3322 * `ReactComponent.Mixin.construct.call(this, ...)`.
3323 *
3324 * @param {?object} initialProps
3325 * @param {*} children
3326 * @internal
3327 */
3328 construct: function(initialProps, children) {
3329 this.props = initialProps || {};
3330 // Record the component responsible for creating this component.
3331 this.props[OWNER] = ReactCurrentOwner.current;
3332 // All components start unmounted.
3333 this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
3334
3335 this._pendingProps = null;
3336 this._pendingCallbacks = null;
3337
3338 // Children can be more than one argument
3339 var childrenLength = arguments.length - 1;
3340 if (childrenLength === 1) {
3341 if (true) {
3342 validateChildKeys(children);
3343 }
3344 this.props.children = children;
3345 } else if (childrenLength > 1) {
3346 var childArray = Array(childrenLength);
3347 for (var i = 0; i < childrenLength; i++) {
3348 if (true) {
3349 validateChildKeys(arguments[i + 1]);
3350 }
3351 childArray[i] = arguments[i + 1];
3352 }
3353 this.props.children = childArray;
3354 }
3355 },
3356
3357 /**
3358 * Initializes the component, renders markup, and registers event listeners.
3359 *
3360 * NOTE: This does not insert any nodes into the DOM.
3361 *
3362 * Subclasses that override this method should make sure to invoke
3363 * `ReactComponent.Mixin.mountComponent.call(this, ...)`.
3364 *
3365 * @param {string} rootID DOM ID of the root node.
3366 * @param {ReactReconcileTransaction} transaction
3367 * @return {?string} Rendered markup to be inserted into the DOM.
3368 * @internal
3369 */
3370 mountComponent: function(rootID, transaction) {
3371 invariant(
3372 !this.isMounted(),
3373 'mountComponent(%s, ...): Can only mount an unmounted component.',
3374 rootID
3375 );
3376 var props = this.props;
3377 if (props.ref != null) {
3378 ReactOwner.addComponentAsRefTo(this, props.ref, props[OWNER]);
3379 }
3380 this._rootNodeID = rootID;
3381 this._lifeCycleState = ComponentLifeCycle.MOUNTED;
3382 // Effectively: return '';
3383 },
3384
3385 /**
3386 * Releases any resources allocated by `mountComponent`.
3387 *
3388 * NOTE: This does not remove any nodes from the DOM.
3389 *
3390 * Subclasses that override this method should make sure to invoke
3391 * `ReactComponent.Mixin.unmountComponent.call(this)`.
3392 *
3393 * @internal
3394 */
3395 unmountComponent: function() {
3396 invariant(
3397 this.isMounted(),
3398 'unmountComponent(): Can only unmount a mounted component.'
3399 );
3400 var props = this.props;
3401 if (props.ref != null) {
3402 ReactOwner.removeComponentAsRefFrom(this, props.ref, props[OWNER]);
3403 }
3404 ReactMount.purgeID(this._rootNodeID);
3405 this._rootNodeID = null;
3406 this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
3407 },
3408
3409 /**
3410 * Updates the rendered DOM nodes given a new set of props.
3411 *
3412 * Subclasses that override this method should make sure to invoke
3413 * `ReactComponent.Mixin.receiveProps.call(this, ...)`.
3414 *
3415 * @param {object} nextProps Next set of properties.
3416 * @param {ReactReconcileTransaction} transaction
3417 * @internal
3418 */
3419 receiveProps: function(nextProps, transaction) {
3420 invariant(
3421 this.isMounted(),
3422 'receiveProps(...): Can only update a mounted component.'
3423 );
3424 this._pendingProps = nextProps;
3425 this._performUpdateIfNecessary(transaction);
3426 },
3427
3428 /**
3429 * Call `_performUpdateIfNecessary` within a new transaction.
3430 *
3431 * @param {ReactReconcileTransaction} transaction
3432 * @internal
3433 */
3434 performUpdateIfNecessary: function() {
3435 var transaction = ReactComponent.ReactReconcileTransaction.getPooled();
3436 transaction.perform(this._performUpdateIfNecessary, this, transaction);
3437 ReactComponent.ReactReconcileTransaction.release(transaction);
3438 },
3439
3440 /**
3441 * If `_pendingProps` is set, update the component.
3442 *
3443 * @param {ReactReconcileTransaction} transaction
3444 * @internal
3445 */
3446 _performUpdateIfNecessary: function(transaction) {
3447 if (this._pendingProps == null) {
3448 return;
3449 }
3450 var prevProps = this.props;
3451 this.props = this._pendingProps;
3452 this._pendingProps = null;
3453 this.updateComponent(transaction, prevProps);
3454 },
3455
3456 /**
3457 * Updates the component's currently mounted representation.
3458 *
3459 * @param {ReactReconcileTransaction} transaction
3460 * @param {object} prevProps
3461 * @internal
3462 */
3463 updateComponent: function(transaction, prevProps) {
3464 var props = this.props;
3465 // If either the owner or a `ref` has changed, make sure the newest owner
3466 // has stored a reference to `this`, and the previous owner (if different)
3467 // has forgotten the reference to `this`.
3468 if (props[OWNER] !== prevProps[OWNER] || props.ref !== prevProps.ref) {
3469 if (prevProps.ref != null) {
3470 ReactOwner.removeComponentAsRefFrom(
3471 this, prevProps.ref, prevProps[OWNER]
3472 );
3473 }
3474 // Correct, even if the owner is the same, and only the ref has changed.
3475 if (props.ref != null) {
3476 ReactOwner.addComponentAsRefTo(this, props.ref, props[OWNER]);
3477 }
3478 }
3479 },
3480
3481 /**
3482 * Mounts this component and inserts it into the DOM.
3483 *
3484 * @param {string} rootID DOM ID of the root node.
3485 * @param {DOMElement} container DOM element to mount into.
3486 * @param {boolean} shouldReuseMarkup If true, do not insert markup
3487 * @final
3488 * @internal
3489 * @see {ReactMount.renderComponent}
3490 */
3491 mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
3492 var transaction = ReactComponent.ReactReconcileTransaction.getPooled();
3493 transaction.perform(
3494 this._mountComponentIntoNode,
3495 this,
3496 rootID,
3497 container,
3498 transaction,
3499 shouldReuseMarkup
3500 );
3501 ReactComponent.ReactReconcileTransaction.release(transaction);
3502 },
3503
3504 /**
3505 * @param {string} rootID DOM ID of the root node.
3506 * @param {DOMElement} container DOM element to mount into.
3507 * @param {ReactReconcileTransaction} transaction
3508 * @param {boolean} shouldReuseMarkup If true, do not insert markup
3509 * @final
3510 * @private
3511 */
3512 _mountComponentIntoNode: function(
3513 rootID,
3514 container,
3515 transaction,
3516 shouldReuseMarkup) {
3517 invariant(
3518 container && container.nodeType === 1,
3519 'mountComponentIntoNode(...): Target container is not a DOM element.'
3520 );
3521 var markup = this.mountComponent(rootID, transaction);
3522
3523 if (shouldReuseMarkup) {
3524 if (ReactMarkupChecksum.canReuseMarkup(
3525 markup,
3526 getReactRootElementInContainer(container))) {
3527 return;
3528 } else {
3529 if (true) {
3530 console.warn(
3531 'React attempted to use reuse markup in a container but the ' +
3532 'checksum was invalid. This generally means that you are using ' +
3533 'server rendering and the markup generated on the server was ' +
3534 'not what the client was expecting. React injected new markup ' +
3535 'to compensate which works but you have lost many of the ' +
3536 'benefits of server rendering. Instead, figure out why the ' +
3537 'markup being generated is different on the client or server.'
3538 );
3539 }
3540 }
3541 }
3542
3543 // Asynchronously inject markup by ensuring that the container is not in
3544 // the document when settings its `innerHTML`.
3545 var parent = container.parentNode;
3546 if (parent) {
3547 var next = container.nextSibling;
3548 parent.removeChild(container);
3549 container.innerHTML = markup;
3550 if (next) {
3551 parent.insertBefore(container, next);
3552 } else {
3553 parent.appendChild(container);
3554 }
3555 } else {
3556 container.innerHTML = markup;
3557 }
3558 },
3559
3560 /**
3561 * Unmounts this component and removes it from the DOM.
3562 *
3563 * @param {DOMElement} container DOM element to unmount from.
3564 * @final
3565 * @internal
3566 * @see {ReactMount.unmountAndReleaseReactRootNode}
3567 */
3568 unmountComponentFromNode: function(container) {
3569 this.unmountComponent();
3570 // http://jsperf.com/emptying-a-node
3571 while (container.lastChild) {
3572 container.removeChild(container.lastChild);
3573 }
3574 },
3575
3576 /**
3577 * Checks if this component is owned by the supplied `owner` component.
3578 *
3579 * @param {ReactComponent} owner Component to check.
3580 * @return {boolean} True if `owners` owns this component.
3581 * @final
3582 * @internal
3583 */
3584 isOwnedBy: function(owner) {
3585 return this.props[OWNER] === owner;
3586 },
3587
3588 /**
3589 * Gets another component, that shares the same owner as this one, by ref.
3590 *
3591 * @param {string} ref of a sibling Component.
3592 * @return {?ReactComponent} the actual sibling Component.
3593 * @final
3594 * @internal
3595 */
3596 getSiblingByRef: function(ref) {
3597 var owner = this.props[OWNER];
3598 if (!owner || !owner.refs) {
3599 return null;
3600 }
3601 return owner.refs[ref];
3602 }
3603
3604 }
3605
3606};
3607
3608module.exports = ReactComponent;
3609
3610},{"./ReactCurrentOwner":25,"./ReactDOMIDOperations":28,"./ReactMarkupChecksum":38,"./ReactMount":39,"./ReactOwner":43,"./ReactReconcileTransaction":46,"./ReactUpdates":49,"./getReactRootElementInContainer":73,"./invariant":78,"./keyMirror":81,"./merge":84}],24:[function(require,module,exports){
3611(function(){/**
3612 * Copyright 2013 Facebook, Inc.
3613 *
3614 * Licensed under the Apache License, Version 2.0 (the "License");
3615 * you may not use this file except in compliance with the License.
3616 * You may obtain a copy of the License at
3617 *
3618 * http://www.apache.org/licenses/LICENSE-2.0
3619 *
3620 * Unless required by applicable law or agreed to in writing, software
3621 * distributed under the License is distributed on an "AS IS" BASIS,
3622 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3623 * See the License for the specific language governing permissions and
3624 * limitations under the License.
3625 *
3626 * @providesModule ReactCompositeComponent
3627 */
3628
3629"use strict";
3630
3631var ReactComponent = require("./ReactComponent");
3632var ReactCurrentOwner = require("./ReactCurrentOwner");
3633var ReactOwner = require("./ReactOwner");
3634var ReactPropTransferer = require("./ReactPropTransferer");
3635var ReactUpdates = require("./ReactUpdates");
3636
3637var invariant = require("./invariant");
3638var keyMirror = require("./keyMirror");
3639var merge = require("./merge");
3640var mixInto = require("./mixInto");
3641
3642/**
3643 * Policies that describe methods in `ReactCompositeComponentInterface`.
3644 */
3645var SpecPolicy = keyMirror({
3646 /**
3647 * These methods may be defined only once by the class specification or mixin.
3648 */
3649 DEFINE_ONCE: null,
3650 /**
3651 * These methods may be defined by both the class specification and mixins.
3652 * Subsequent definitions will be chained. These methods must return void.
3653 */
3654 DEFINE_MANY: null,
3655 /**
3656 * These methods are overriding the base ReactCompositeComponent class.
3657 */
3658 OVERRIDE_BASE: null
3659});
3660
3661/**
3662 * Composite components are higher-level components that compose other composite
3663 * or native components.
3664 *
3665 * To create a new type of `ReactCompositeComponent`, pass a specification of
3666 * your new class to `React.createClass`. The only requirement of your class
3667 * specification is that you implement a `render` method.
3668 *
3669 * var MyComponent = React.createClass({
3670 * render: function() {
3671 * return <div>Hello World</div>;
3672 * }
3673 * });
3674 *
3675 * The class specification supports a specific protocol of methods that have
3676 * special meaning (e.g. `render`). See `ReactCompositeComponentInterface` for
3677 * more the comprehensive protocol. Any other properties and methods in the
3678 * class specification will available on the prototype.
3679 *
3680 * @interface ReactCompositeComponentInterface
3681 * @internal
3682 */
3683var ReactCompositeComponentInterface = {
3684
3685 /**
3686 * An array of Mixin objects to include when defining your component.
3687 *
3688 * @type {array}
3689 * @optional
3690 */
3691 mixins: SpecPolicy.DEFINE_MANY,
3692
3693 /**
3694 * Definition of prop types for this component.
3695 *
3696 * @type {object}
3697 * @optional
3698 */
3699 propTypes: SpecPolicy.DEFINE_ONCE,
3700
3701
3702
3703 // ==== Definition methods ====
3704
3705 /**
3706 * Invoked when the component is mounted. Values in the mapping will be set on
3707 * `this.props` if that prop is not specified (i.e. using an `in` check).
3708 *
3709 * This method is invoked before `getInitialState` and therefore cannot rely
3710 * on `this.state` or use `this.setState`.
3711 *
3712 * @return {object}
3713 * @optional
3714 */
3715 getDefaultProps: SpecPolicy.DEFINE_ONCE,
3716
3717 /**
3718 * Invoked once before the component is mounted. The return value will be used
3719 * as the initial value of `this.state`.
3720 *
3721 * getInitialState: function() {
3722 * return {
3723 * isOn: false,
3724 * fooBaz: new BazFoo()
3725 * }
3726 * }
3727 *
3728 * @return {object}
3729 * @optional
3730 */
3731 getInitialState: SpecPolicy.DEFINE_ONCE,
3732
3733 /**
3734 * Uses props from `this.props` and state from `this.state` to render the
3735 * structure of the component.
3736 *
3737 * No guarantees are made about when or how often this method is invoked, so
3738 * it must not have side effects.
3739 *
3740 * render: function() {
3741 * var name = this.props.name;
3742 * return <div>Hello, {name}!</div>;
3743 * }
3744 *
3745 * @return {ReactComponent}
3746 * @nosideeffects
3747 * @required
3748 */
3749 render: SpecPolicy.DEFINE_ONCE,
3750
3751
3752
3753 // ==== Delegate methods ====
3754
3755 /**
3756 * Invoked when the component is initially created and about to be mounted.
3757 * This may have side effects, but any external subscriptions or data created
3758 * by this method must be cleaned up in `componentWillUnmount`.
3759 *
3760 * @optional
3761 */
3762 componentWillMount: SpecPolicy.DEFINE_MANY,
3763
3764 /**
3765 * Invoked when the component has been mounted and has a DOM representation.
3766 * However, there is no guarantee that the DOM node is in the document.
3767 *
3768 * Use this as an opportunity to operate on the DOM when the component has
3769 * been mounted (initialized and rendered) for the first time.
3770 *
3771 * @param {DOMElement} rootNode DOM element representing the component.
3772 * @optional
3773 */
3774 componentDidMount: SpecPolicy.DEFINE_MANY,
3775
3776 /**
3777 * Invoked before the component receives new props.
3778 *
3779 * Use this as an opportunity to react to a prop transition by updating the
3780 * state using `this.setState`. Current props are accessed via `this.props`.
3781 *
3782 * componentWillReceiveProps: function(nextProps) {
3783 * this.setState({
3784 * likesIncreasing: nextProps.likeCount > this.props.likeCount
3785 * });
3786 * }
3787 *
3788 * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
3789 * transition may cause a state change, but the opposite is not true. If you
3790 * need it, you are probably looking for `componentWillUpdate`.
3791 *
3792 * @param {object} nextProps
3793 * @optional
3794 */
3795 componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
3796
3797 /**
3798 * Invoked while deciding if the component should be updated as a result of
3799 * receiving new props and state.
3800 *
3801 * Use this as an opportunity to `return false` when you're certain that the
3802 * transition to the new props and state will not require a component update.
3803 *
3804 * shouldComponentUpdate: function(nextProps, nextState) {
3805 * return !equal(nextProps, this.props) || !equal(nextState, this.state);
3806 * }
3807 *
3808 * @param {object} nextProps
3809 * @param {?object} nextState
3810 * @return {boolean} True if the component should update.
3811 * @optional
3812 */
3813 shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
3814
3815 /**
3816 * Invoked when the component is about to update due to a transition from
3817 * `this.props` and `this.state` to `nextProps` and `nextState`.
3818 *
3819 * Use this as an opportunity to perform preparation before an update occurs.
3820 *
3821 * NOTE: You **cannot** use `this.setState()` in this method.
3822 *
3823 * @param {object} nextProps
3824 * @param {?object} nextState
3825 * @param {ReactReconcileTransaction} transaction
3826 * @optional
3827 */
3828 componentWillUpdate: SpecPolicy.DEFINE_MANY,
3829
3830 /**
3831 * Invoked when the component's DOM representation has been updated.
3832 *
3833 * Use this as an opportunity to operate on the DOM when the component has
3834 * been updated.
3835 *
3836 * @param {object} prevProps
3837 * @param {?object} prevState
3838 * @param {DOMElement} rootNode DOM element representing the component.
3839 * @optional
3840 */
3841 componentDidUpdate: SpecPolicy.DEFINE_MANY,
3842
3843 /**
3844 * Invoked when the component is about to be removed from its parent and have
3845 * its DOM representation destroyed.
3846 *
3847 * Use this as an opportunity to deallocate any external resources.
3848 *
3849 * NOTE: There is no `componentDidUnmount` since your component will have been
3850 * destroyed by that point.
3851 *
3852 * @optional
3853 */
3854 componentWillUnmount: SpecPolicy.DEFINE_MANY,
3855
3856
3857
3858 // ==== Advanced methods ====
3859
3860 /**
3861 * Updates the component's currently mounted DOM representation.
3862 *
3863 * By default, this implements React's rendering and reconciliation algorithm.
3864 * Sophisticated clients may wish to override this.
3865 *
3866 * @param {ReactReconcileTransaction} transaction
3867 * @internal
3868 * @overridable
3869 */
3870 updateComponent: SpecPolicy.OVERRIDE_BASE
3871
3872};
3873
3874/**
3875 * Mapping from class specification keys to special processing functions.
3876 *
3877 * Although these are declared in the specification when defining classes
3878 * using `React.createClass`, they will not be on the component's prototype.
3879 */
3880var RESERVED_SPEC_KEYS = {
3881 displayName: function(Constructor, displayName) {
3882 Constructor.displayName = displayName;
3883 },
3884 mixins: function(Constructor, mixins) {
3885 if (mixins) {
3886 for (var i = 0; i < mixins.length; i++) {
3887 mixSpecIntoComponent(Constructor, mixins[i]);
3888 }
3889 }
3890 },
3891 propTypes: function(Constructor, propTypes) {
3892 Constructor.propTypes = propTypes;
3893 }
3894};
3895
3896function validateMethodOverride(proto, name) {
3897 var specPolicy = ReactCompositeComponentInterface[name];
3898
3899 // Disallow overriding of base class methods unless explicitly allowed.
3900 if (ReactCompositeComponentMixin.hasOwnProperty(name)) {
3901 invariant(
3902 specPolicy === SpecPolicy.OVERRIDE_BASE,
3903 'ReactCompositeComponentInterface: You are attempting to override ' +
3904 '`%s` from your class specification. Ensure that your method names ' +
3905 'do not overlap with React methods.',
3906 name
3907 );
3908 }
3909
3910 // Disallow defining methods more than once unless explicitly allowed.
3911 if (proto.hasOwnProperty(name)) {
3912 invariant(
3913 specPolicy === SpecPolicy.DEFINE_MANY,
3914 'ReactCompositeComponentInterface: You are attempting to define ' +
3915 '`%s` on your component more than once. This conflict may be due ' +
3916 'to a mixin.',
3917 name
3918 );
3919 }
3920}
3921
3922
3923function validateLifeCycleOnReplaceState(instance) {
3924 var compositeLifeCycleState = instance._compositeLifeCycleState;
3925 invariant(
3926 instance.isMounted() ||
3927 compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
3928 'replaceState(...): Can only update a mounted or mounting component.'
3929 );
3930 invariant(
3931 compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
3932 compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
3933 'replaceState(...): Cannot update while unmounting component or during ' +
3934 'an existing state transition (such as within `render`).'
3935 );
3936}
3937
3938/**
3939 * Custom version of `mixInto` which handles policy validation and reserved
3940 * specification keys when building `ReactCompositeComponent` classses.
3941 */
3942function mixSpecIntoComponent(Constructor, spec) {
3943 var proto = Constructor.prototype;
3944 for (var name in spec) {
3945 var property = spec[name];
3946 if (!spec.hasOwnProperty(name) || !property) {
3947 continue;
3948 }
3949 validateMethodOverride(proto, name);
3950
3951 if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
3952 RESERVED_SPEC_KEYS[name](Constructor, property);
3953 } else {
3954 // Setup methods on prototype:
3955 // The following member methods should not be automatically bound:
3956 // 1. Expected ReactCompositeComponent methods (in the "interface").
3957 // 2. Overridden methods (that were mixed in).
3958 var isCompositeComponentMethod = name in ReactCompositeComponentInterface;
3959 var isInherited = name in proto;
3960 var markedDontBind = property.__reactDontBind;
3961 var isFunction = typeof property === 'function';
3962 var shouldAutoBind =
3963 isFunction &&
3964 !isCompositeComponentMethod &&
3965 !isInherited &&
3966 !markedDontBind;
3967
3968 if (shouldAutoBind) {
3969 if (!proto.__reactAutoBindMap) {
3970 proto.__reactAutoBindMap = {};
3971 }
3972 proto.__reactAutoBindMap[name] = property;
3973 proto[name] = property;
3974 } else {
3975 if (isInherited) {
3976 // For methods which are defined more than once, call the existing
3977 // methods before calling the new property.
3978 proto[name] = createChainedFunction(proto[name], property);
3979 } else {
3980 proto[name] = property;
3981 }
3982 }
3983 }
3984 }
3985}
3986
3987/**
3988 * Creates a function that invokes two functions and ignores their return vales.
3989 *
3990 * @param {function} one Function to invoke first.
3991 * @param {function} two Function to invoke second.
3992 * @return {function} Function that invokes the two argument functions.
3993 * @private
3994 */
3995function createChainedFunction(one, two) {
3996 return function chainedFunction() {
3997 one.apply(this, arguments);
3998 two.apply(this, arguments);
3999 };
4000}
4001
4002/**
4003 * `ReactCompositeComponent` maintains an auxiliary life cycle state in
4004 * `this._compositeLifeCycleState` (which can be null).
4005 *
4006 * This is different from the life cycle state maintained by `ReactComponent` in
4007 * `this._lifeCycleState`. The following diagram shows how the states overlap in
4008 * time. There are times when the CompositeLifeCycle is null - at those times it
4009 * is only meaningful to look at ComponentLifeCycle alone.
4010 *
4011 * Top Row: ReactComponent.ComponentLifeCycle
4012 * Low Row: ReactComponent.CompositeLifeCycle
4013 *
4014 * +-------+------------------------------------------------------+--------+
4015 * | UN | MOUNTED | UN |
4016 * |MOUNTED| | MOUNTED|
4017 * +-------+------------------------------------------------------+--------+
4018 * | ^--------+ +------+ +------+ +------+ +--------^ |
4019 * | | | | | | | | | | | |
4020 * | 0--|MOUNTING|-0-|RECEIV|-0-|RECEIV|-0-|RECEIV|-0-| UN |--->0 |
4021 * | | | |PROPS | | PROPS| | STATE| |MOUNTING| |
4022 * | | | | | | | | | | | |
4023 * | | | | | | | | | | | |
4024 * | +--------+ +------+ +------+ +------+ +--------+ |
4025 * | | | |
4026 * +-------+------------------------------------------------------+--------+
4027 */
4028var CompositeLifeCycle = keyMirror({
4029 /**
4030 * Components in the process of being mounted respond to state changes
4031 * differently.
4032 */
4033 MOUNTING: null,
4034 /**
4035 * Components in the process of being unmounted are guarded against state
4036 * changes.
4037 */
4038 UNMOUNTING: null,
4039 /**
4040 * Components that are mounted and receiving new props respond to state
4041 * changes differently.
4042 */
4043 RECEIVING_PROPS: null,
4044 /**
4045 * Components that are mounted and receiving new state are guarded against
4046 * additional state changes.
4047 */
4048 RECEIVING_STATE: null
4049});
4050
4051/**
4052 * @lends {ReactCompositeComponent.prototype}
4053 */
4054var ReactCompositeComponentMixin = {
4055
4056 /**
4057 * Base constructor for all composite component.
4058 *
4059 * @param {?object} initialProps
4060 * @param {*} children
4061 * @final
4062 * @internal
4063 */
4064 construct: function(initialProps, children) {
4065 // Children can be either an array or more than one argument
4066 ReactComponent.Mixin.construct.apply(this, arguments);
4067 this.state = null;
4068 this._pendingState = null;
4069 this._compositeLifeCycleState = null;
4070 },
4071
4072 /**
4073 * Checks whether or not this composite component is mounted.
4074 * @return {boolean} True if mounted, false otherwise.
4075 * @protected
4076 * @final
4077 */
4078 isMounted: function() {
4079 return ReactComponent.Mixin.isMounted.call(this) &&
4080 this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING;
4081 },
4082
4083 /**
4084 * Initializes the component, renders markup, and registers event listeners.
4085 *
4086 * @param {string} rootID DOM ID of the root node.
4087 * @param {ReactReconcileTransaction} transaction
4088 * @return {?string} Rendered markup to be inserted into the DOM.
4089 * @final
4090 * @internal
4091 */
4092 mountComponent: function(rootID, transaction) {
4093 ReactComponent.Mixin.mountComponent.call(this, rootID, transaction);
4094 this._compositeLifeCycleState = CompositeLifeCycle.MOUNTING;
4095
4096 this._defaultProps = this.getDefaultProps ? this.getDefaultProps() : null;
4097 this._processProps(this.props);
4098
4099 if (this.__reactAutoBindMap) {
4100 this._bindAutoBindMethods();
4101 }
4102
4103 this.state = this.getInitialState ? this.getInitialState() : null;
4104 this._pendingState = null;
4105 this._pendingForceUpdate = false;
4106
4107 if (this.componentWillMount) {
4108 this.componentWillMount();
4109 // When mounting, calls to `setState` by `componentWillMount` will set
4110 // `this._pendingState` without triggering a re-render.
4111 if (this._pendingState) {
4112 this.state = this._pendingState;
4113 this._pendingState = null;
4114 }
4115 }
4116
4117 this._renderedComponent = this._renderValidatedComponent();
4118
4119 // Done with mounting, `setState` will now trigger UI changes.
4120 this._compositeLifeCycleState = null;
4121 var markup = this._renderedComponent.mountComponent(rootID, transaction);
4122 if (this.componentDidMount) {
4123 transaction.getReactOnDOMReady().enqueue(this, this.componentDidMount);
4124 }
4125 return markup;
4126 },
4127
4128 /**
4129 * Releases any resources allocated by `mountComponent`.
4130 *
4131 * @final
4132 * @internal
4133 */
4134 unmountComponent: function() {
4135 this._compositeLifeCycleState = CompositeLifeCycle.UNMOUNTING;
4136 if (this.componentWillUnmount) {
4137 this.componentWillUnmount();
4138 }
4139 this._compositeLifeCycleState = null;
4140
4141 this._defaultProps = null;
4142
4143 ReactComponent.Mixin.unmountComponent.call(this);
4144 this._renderedComponent.unmountComponent();
4145 this._renderedComponent = null;
4146
4147 if (this.refs) {
4148 this.refs = null;
4149 }
4150
4151 // Some existing components rely on this.props even after they've been
4152 // destroyed (in event handlers).
4153 // TODO: this.props = null;
4154 // TODO: this.state = null;
4155 },
4156
4157 /**
4158 * Sets a subset of the state. Always use this or `replaceState` to mutate
4159 * state. You should treat `this.state` as immutable.
4160 *
4161 * There is no guarantee that `this.state` will be immediately updated, so
4162 * accessing `this.state` after calling this method may return the old value.
4163 *
4164 * There is no guarantee that calls to `setState` will run synchronously,
4165 * as they may eventually be batched together. You can provide an optional
4166 * callback that will be executed when the call to setState is actually
4167 * completed.
4168 *
4169 * @param {object} partialState Next partial state to be merged with state.
4170 * @param {?function} callback Called after state is updated.
4171 * @final
4172 * @protected
4173 */
4174 setState: function(partialState, callback) {
4175 // Merge with `_pendingState` if it exists, otherwise with existing state.
4176 this.replaceState(
4177 merge(this._pendingState || this.state, partialState),
4178 callback
4179 );
4180 },
4181
4182 /**
4183 * Replaces all of the state. Always use this or `setState` to mutate state.
4184 * You should treat `this.state` as immutable.
4185 *
4186 * There is no guarantee that `this.state` will be immediately updated, so
4187 * accessing `this.state` after calling this method may return the old value.
4188 *
4189 * @param {object} completeState Next state.
4190 * @param {?function} callback Called after state is updated.
4191 * @final
4192 * @protected
4193 */
4194 replaceState: function(completeState, callback) {
4195 validateLifeCycleOnReplaceState(this);
4196 this._pendingState = completeState;
4197 ReactUpdates.enqueueUpdate(this, callback);
4198 },
4199
4200 /**
4201 * Processes props by setting default values for unspecified props and
4202 * asserting that the props are valid.
4203 *
4204 * @param {object} props
4205 * @private
4206 */
4207 _processProps: function(props) {
4208 var propName;
4209 var defaultProps = this._defaultProps;
4210 for (propName in defaultProps) {
4211 if (!(propName in props)) {
4212 props[propName] = defaultProps[propName];
4213 }
4214 }
4215 var propTypes = this.constructor.propTypes;
4216 if (propTypes) {
4217 var componentName = this.constructor.displayName;
4218 for (propName in propTypes) {
4219 var checkProp = propTypes[propName];
4220 if (checkProp) {
4221 checkProp(props, propName, componentName);
4222 }
4223 }
4224 }
4225 },
4226
4227 performUpdateIfNecessary: function() {
4228 var compositeLifeCycleState = this._compositeLifeCycleState;
4229 // Do not trigger a state transition if we are in the middle of mounting or
4230 // receiving props because both of those will already be doing this.
4231 if (compositeLifeCycleState === CompositeLifeCycle.MOUNTING ||
4232 compositeLifeCycleState === CompositeLifeCycle.RECEIVING_PROPS) {
4233 return;
4234 }
4235 ReactComponent.Mixin.performUpdateIfNecessary.call(this);
4236 },
4237
4238 /**
4239 * If any of `_pendingProps`, `_pendingState`, or `_pendingForceUpdate` is
4240 * set, update the component.
4241 *
4242 * @param {ReactReconcileTransaction} transaction
4243 * @internal
4244 */
4245 _performUpdateIfNecessary: function(transaction) {
4246 if (this._pendingProps == null &&
4247 this._pendingState == null &&
4248 !this._pendingForceUpdate) {
4249 return;
4250 }
4251
4252 var nextProps = this.props;
4253 if (this._pendingProps != null) {
4254 nextProps = this._pendingProps;
4255 this._processProps(nextProps);
4256 this._pendingProps = null;
4257
4258 this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
4259 if (this.componentWillReceiveProps) {
4260 this.componentWillReceiveProps(nextProps, transaction);
4261 }
4262 }
4263
4264 this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_STATE;
4265
4266 var nextState = this._pendingState || this.state;
4267 this._pendingState = null;
4268
4269 if (this._pendingForceUpdate ||
4270 !this.shouldComponentUpdate ||
4271 this.shouldComponentUpdate(nextProps, nextState)) {
4272 this._pendingForceUpdate = false;
4273 // Will set `this.props` and `this.state`.
4274 this._performComponentUpdate(nextProps, nextState, transaction);
4275 } else {
4276 // If it's determined that a component should not update, we still want
4277 // to set props and state.
4278 this.props = nextProps;
4279 this.state = nextState;
4280 }
4281
4282 this._compositeLifeCycleState = null;
4283 },
4284
4285 /**
4286 * Merges new props and state, notifies delegate methods of update and
4287 * performs update.
4288 *
4289 * @param {object} nextProps Next object to set as properties.
4290 * @param {?object} nextState Next object to set as state.
4291 * @param {ReactReconcileTransaction} transaction
4292 * @private
4293 */
4294 _performComponentUpdate: function(nextProps, nextState, transaction) {
4295 var prevProps = this.props;
4296 var prevState = this.state;
4297
4298 if (this.componentWillUpdate) {
4299 this.componentWillUpdate(nextProps, nextState, transaction);
4300 }
4301
4302 this.props = nextProps;
4303 this.state = nextState;
4304
4305 this.updateComponent(transaction, prevProps, prevState);
4306
4307 if (this.componentDidUpdate) {
4308 transaction.getReactOnDOMReady().enqueue(
4309 this,
4310 this.componentDidUpdate.bind(this, prevProps, prevState)
4311 );
4312 }
4313 },
4314
4315 /**
4316 * Updates the component's currently mounted DOM representation.
4317 *
4318 * By default, this implements React's rendering and reconciliation algorithm.
4319 * Sophisticated clients may wish to override this.
4320 *
4321 * @param {ReactReconcileTransaction} transaction
4322 * @param {object} prevProps
4323 * @param {?object} prevState
4324 * @internal
4325 * @overridable
4326 */
4327 updateComponent: function(transaction, prevProps, prevState) {
4328 ReactComponent.Mixin.updateComponent.call(this, transaction, prevProps);
4329 var currentComponent = this._renderedComponent;
4330 var nextComponent = this._renderValidatedComponent();
4331 if (currentComponent.constructor === nextComponent.constructor) {
4332 currentComponent.receiveProps(nextComponent.props, transaction);
4333 } else {
4334 // These two IDs are actually the same! But nothing should rely on that.
4335 var thisID = this._rootNodeID;
4336 var currentComponentID = currentComponent._rootNodeID;
4337 currentComponent.unmountComponent();
4338 var nextMarkup = nextComponent.mountComponent(thisID, transaction);
4339 ReactComponent.DOMIDOperations.dangerouslyReplaceNodeWithMarkupByID(
4340 currentComponentID,
4341 nextMarkup
4342 );
4343 this._renderedComponent = nextComponent;
4344 }
4345 },
4346
4347 /**
4348 * Forces an update. This should only be invoked when it is known with
4349 * certainty that we are **not** in a DOM transaction.
4350 *
4351 * You may want to call this when you know that some deeper aspect of the
4352 * component's state has changed but `setState` was not called.
4353 *
4354 * This will not invoke `shouldUpdateComponent`, but it will invoke
4355 * `componentWillUpdate` and `componentDidUpdate`.
4356 *
4357 * @param {?function} callback Called after update is complete.
4358 * @final
4359 * @protected
4360 */
4361 forceUpdate: function(callback) {
4362 var compositeLifeCycleState = this._compositeLifeCycleState;
4363 invariant(
4364 this.isMounted() ||
4365 compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
4366 'forceUpdate(...): Can only force an update on mounted or mounting ' +
4367 'components.'
4368 );
4369 invariant(
4370 compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
4371 compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
4372 'forceUpdate(...): Cannot force an update while unmounting component ' +
4373 'or during an existing state transition (such as within `render`).'
4374 );
4375 this._pendingForceUpdate = true;
4376 ReactUpdates.enqueueUpdate(this, callback);
4377 },
4378
4379 /**
4380 * @private
4381 */
4382 _renderValidatedComponent: function() {
4383 var renderedComponent;
4384 ReactCurrentOwner.current = this;
4385 try {
4386 renderedComponent = this.render();
4387 } catch (error) {
4388 // IE8 requires `catch` in order to use `finally`.
4389 throw error;
4390 } finally {
4391 ReactCurrentOwner.current = null;
4392 }
4393 invariant(
4394 ReactComponent.isValidComponent(renderedComponent),
4395 '%s.render(): A valid ReactComponent must be returned.',
4396 this.constructor.displayName || 'ReactCompositeComponent'
4397 );
4398 return renderedComponent;
4399 },
4400
4401 /**
4402 * @private
4403 */
4404 _bindAutoBindMethods: function() {
4405 for (var autoBindKey in this.__reactAutoBindMap) {
4406 if (!this.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
4407 continue;
4408 }
4409 var method = this.__reactAutoBindMap[autoBindKey];
4410 this[autoBindKey] = this._bindAutoBindMethod(method);
4411 }
4412 },
4413
4414 /**
4415 * Binds a method to the component.
4416 *
4417 * @param {function} method Method to be bound.
4418 * @private
4419 */
4420 _bindAutoBindMethod: function(method) {
4421 var component = this;
4422 var boundMethod = function() {
4423 return method.apply(component, arguments);
4424 };
4425 if (true) {
4426 var componentName = component.constructor.displayName;
4427 var _bind = boundMethod.bind;
4428 boundMethod.bind = function(newThis) {
4429 // User is trying to bind() an autobound method; we effectively will
4430 // ignore the value of "this" that the user is trying to use, so
4431 // let's warn.
4432 if (newThis !== component) {
4433 console.warn(
4434 'bind(): React component methods may only be bound to the ' +
4435 'component instance. See ' + componentName
4436 );
4437 } else if (arguments.length === 1) {
4438 console.warn(
4439 'bind(): You are binding a component method to the component. ' +
4440 'React does this for you automatically in a high-performance ' +
4441 'way, so you can safely remove this call. See ' + componentName
4442 );
4443 return boundMethod;
4444 }
4445 return _bind.apply(boundMethod, arguments);
4446 };
4447 }
4448 return boundMethod;
4449 }
4450};
4451
4452var ReactCompositeComponentBase = function() {};
4453mixInto(ReactCompositeComponentBase, ReactComponent.Mixin);
4454mixInto(ReactCompositeComponentBase, ReactOwner.Mixin);
4455mixInto(ReactCompositeComponentBase, ReactPropTransferer.Mixin);
4456mixInto(ReactCompositeComponentBase, ReactCompositeComponentMixin);
4457
4458/**
4459 * Module for creating composite components.
4460 *
4461 * @class ReactCompositeComponent
4462 * @extends ReactComponent
4463 * @extends ReactOwner
4464 * @extends ReactPropTransferer
4465 */
4466var ReactCompositeComponent = {
4467
4468 LifeCycle: CompositeLifeCycle,
4469
4470 Base: ReactCompositeComponentBase,
4471
4472 /**
4473 * Creates a composite component class given a class specification.
4474 *
4475 * @param {object} spec Class specification (which must define `render`).
4476 * @return {function} Component constructor function.
4477 * @public
4478 */
4479 createClass: function(spec) {
4480 var Constructor = function() {};
4481 Constructor.prototype = new ReactCompositeComponentBase();
4482 Constructor.prototype.constructor = Constructor;
4483 mixSpecIntoComponent(Constructor, spec);
4484 invariant(
4485 Constructor.prototype.render,
4486 'createClass(...): Class specification must implement a `render` method.'
4487 );
4488 // Reduce time spent doing lookups by setting these on the prototype.
4489 for (var methodName in ReactCompositeComponentInterface) {
4490 if (!Constructor.prototype[methodName]) {
4491 Constructor.prototype[methodName] = null;
4492 }
4493 }
4494
4495 var ConvenienceConstructor = function(props, children) {
4496 var instance = new Constructor();
4497 instance.construct.apply(instance, arguments);
4498 return instance;
4499 };
4500 ConvenienceConstructor.componentConstructor = Constructor;
4501 ConvenienceConstructor.originalSpec = spec;
4502 return ConvenienceConstructor;
4503 },
4504
4505 /**
4506 * TODO: Delete this when all callers have been updated to rely on this
4507 * behavior being the default.
4508 *
4509 * Backwards compatible stub for what is now the default behavior.
4510 * @param {function} method Method to be bound.
4511 * @public
4512 */
4513 autoBind: function(method) {
4514 if (true) {
4515 console.warn(
4516 'React.autoBind() is now deprecated. All React component methods ' +
4517 'are auto bound by default, so React.autoBind() is a no-op. It ' +
4518 'will be removed in the next version of React'
4519 );
4520 }
4521 return method;
4522 }
4523};
4524
4525module.exports = ReactCompositeComponent;
4526
4527})()
4528},{"./ReactComponent":23,"./ReactCurrentOwner":25,"./ReactOwner":43,"./ReactPropTransferer":44,"./ReactUpdates":49,"./invariant":78,"./keyMirror":81,"./merge":84,"./mixInto":87}],25:[function(require,module,exports){
4529/**
4530 * Copyright 2013 Facebook, Inc.
4531 *
4532 * Licensed under the Apache License, Version 2.0 (the "License");
4533 * you may not use this file except in compliance with the License.
4534 * You may obtain a copy of the License at
4535 *
4536 * http://www.apache.org/licenses/LICENSE-2.0
4537 *
4538 * Unless required by applicable law or agreed to in writing, software
4539 * distributed under the License is distributed on an "AS IS" BASIS,
4540 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4541 * See the License for the specific language governing permissions and
4542 * limitations under the License.
4543 *
4544 * @providesModule ReactCurrentOwner
4545 */
4546
4547"use strict";
4548
4549/**
4550 * Keeps track of the current owner.
4551 *
4552 * The current owner is the component who should own any components that are
4553 * currently being constructed.
4554 *
4555 * The depth indicate how many composite components are above this render level.
4556 */
4557var ReactCurrentOwner = {
4558
4559 /**
4560 * @internal
4561 * @type {ReactComponent}
4562 */
4563 current: null
4564
4565};
4566
4567module.exports = ReactCurrentOwner;
4568
4569},{}],26:[function(require,module,exports){
4570/**
4571 * Copyright 2013 Facebook, Inc.
4572 *
4573 * Licensed under the Apache License, Version 2.0 (the "License");
4574 * you may not use this file except in compliance with the License.
4575 * You may obtain a copy of the License at
4576 *
4577 * http://www.apache.org/licenses/LICENSE-2.0
4578 *
4579 * Unless required by applicable law or agreed to in writing, software
4580 * distributed under the License is distributed on an "AS IS" BASIS,
4581 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4582 * See the License for the specific language governing permissions and
4583 * limitations under the License.
4584 *
4585 * @providesModule ReactDOM
4586 * @typechecks static-only
4587 */
4588
4589"use strict";
4590
4591var ReactNativeComponent = require("./ReactNativeComponent");
4592
4593var mergeInto = require("./mergeInto");
4594var objMapKeyVal = require("./objMapKeyVal");
4595
4596/**
4597 * Creates a new React class that is idempotent and capable of containing other
4598 * React components. It accepts event listeners and DOM properties that are
4599 * valid according to `DOMProperty`.
4600 *
4601 * - Event listeners: `onClick`, `onMouseDown`, etc.
4602 * - DOM properties: `className`, `name`, `title`, etc.
4603 *
4604 * The `style` property functions differently from the DOM API. It accepts an
4605 * object mapping of style properties to values.
4606 *
4607 * @param {string} tag Tag name (e.g. `div`).
4608 * @param {boolean} omitClose True if the close tag should be omitted.
4609 * @private
4610 */
4611function createDOMComponentClass(tag, omitClose) {
4612 var Constructor = function() {};
4613 Constructor.prototype = new ReactNativeComponent(tag, omitClose);
4614 Constructor.prototype.constructor = Constructor;
4615
4616 var ConvenienceConstructor = function(props, children) {
4617 var instance = new Constructor();
4618 instance.construct.apply(instance, arguments);
4619 return instance;
4620 };
4621 ConvenienceConstructor.componentConstructor = Constructor;
4622 return ConvenienceConstructor;
4623}
4624
4625/**
4626 * Creates a mapping from supported HTML tags to `ReactNativeComponent` classes.
4627 * This is also accessible via `React.DOM`.
4628 *
4629 * @public
4630 */
4631var ReactDOM = objMapKeyVal({
4632 a: false,
4633 abbr: false,
4634 address: false,
4635 area: false,
4636 article: false,
4637 aside: false,
4638 audio: false,
4639 b: false,
4640 base: false,
4641 bdi: false,
4642 bdo: false,
4643 big: false,
4644 blockquote: false,
4645 body: false,
4646 br: true,
4647 button: false,
4648 canvas: false,
4649 caption: false,
4650 cite: false,
4651 code: false,
4652 col: true,
4653 colgroup: false,
4654 data: false,
4655 datalist: false,
4656 dd: false,
4657 del: false,
4658 details: false,
4659 dfn: false,
4660 div: false,
4661 dl: false,
4662 dt: false,
4663 em: false,
4664 embed: true,
4665 fieldset: false,
4666 figcaption: false,
4667 figure: false,
4668 footer: false,
4669 form: false, // NOTE: Injected, see `ReactDOMForm`.
4670 h1: false,
4671 h2: false,
4672 h3: false,
4673 h4: false,
4674 h5: false,
4675 h6: false,
4676 head: false,
4677 header: false,
4678 hr: true,
4679 html: false,
4680 i: false,
4681 iframe: false,
4682 img: true,
4683 input: true,
4684 ins: false,
4685 kbd: false,
4686 keygen: true,
4687 label: false,
4688 legend: false,
4689 li: false,
4690 link: false,
4691 main: false,
4692 map: false,
4693 mark: false,
4694 menu: false,
4695 menuitem: false, // NOTE: Close tag should be omitted, but causes problems.
4696 meta: true,
4697 meter: false,
4698 nav: false,
4699 noscript: false,
4700 object: false,
4701 ol: false,
4702 optgroup: false,
4703 option: false,
4704 output: false,
4705 p: false,
4706 param: true,
4707 pre: false,
4708 progress: false,
4709 q: false,
4710 rp: false,
4711 rt: false,
4712 ruby: false,
4713 s: false,
4714 samp: false,
4715 script: false,
4716 section: false,
4717 select: false,
4718 small: false,
4719 source: false,
4720 span: false,
4721 strong: false,
4722 style: false,
4723 sub: false,
4724 summary: false,
4725 sup: false,
4726 table: false,
4727 tbody: false,
4728 td: false,
4729 textarea: false, // NOTE: Injected, see `ReactDOMTextarea`.
4730 tfoot: false,
4731 th: false,
4732 thead: false,
4733 time: false,
4734 title: false,
4735 tr: false,
4736 track: true,
4737 u: false,
4738 ul: false,
4739 'var': false,
4740 video: false,
4741 wbr: false,
4742
4743 // SVG
4744 circle: false,
4745 g: false,
4746 line: false,
4747 path: false,
4748 polyline: false,
4749 rect: false,
4750 svg: false,
4751 text: false
4752}, createDOMComponentClass);
4753
4754var injection = {
4755 injectComponentClasses: function(componentClasses) {
4756 mergeInto(ReactDOM, componentClasses);
4757 }
4758};
4759
4760ReactDOM.injection = injection;
4761
4762module.exports = ReactDOM;
4763
4764},{"./ReactNativeComponent":41,"./mergeInto":86,"./objMapKeyVal":88}],27:[function(require,module,exports){
4765/**
4766 * Copyright 2013 Facebook, Inc.
4767 *
4768 * Licensed under the Apache License, Version 2.0 (the "License");
4769 * you may not use this file except in compliance with the License.
4770 * You may obtain a copy of the License at
4771 *
4772 * http://www.apache.org/licenses/LICENSE-2.0
4773 *
4774 * Unless required by applicable law or agreed to in writing, software
4775 * distributed under the License is distributed on an "AS IS" BASIS,
4776 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4777 * See the License for the specific language governing permissions and
4778 * limitations under the License.
4779 *
4780 * @providesModule ReactDOMForm
4781 */
4782
4783"use strict";
4784
4785var ReactCompositeComponent = require("./ReactCompositeComponent");
4786var ReactDOM = require("./ReactDOM");
4787var ReactEventEmitter = require("./ReactEventEmitter");
4788var EventConstants = require("./EventConstants");
4789
4790// Store a reference to the <form> `ReactNativeComponent`.
4791var form = ReactDOM.form;
4792
4793/**
4794 * Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
4795 * to capture it on the <form> element itself. There are lots of hacks we could
4796 * do to accomplish this, but the most reliable is to make <form> a
4797 * composite component and use `componentDidMount` to attach the event handlers.
4798 */
4799var ReactDOMForm = ReactCompositeComponent.createClass({
4800 render: function() {
4801 // TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
4802 // `jshint` fails to parse JSX so in order for linting to work in the open
4803 // source repo, we need to just use `ReactDOM.form`.
4804 return this.transferPropsTo(form(null, this.props.children));
4805 },
4806
4807 componentDidMount: function(node) {
4808 ReactEventEmitter.trapBubbledEvent(
4809 EventConstants.topLevelTypes.topSubmit,
4810 'submit',
4811 node
4812 );
4813 }
4814});
4815
4816module.exports = ReactDOMForm;
4817
4818},{"./EventConstants":13,"./ReactCompositeComponent":24,"./ReactDOM":26,"./ReactEventEmitter":34}],28:[function(require,module,exports){
4819(function(){/**
4820 * Copyright 2013 Facebook, Inc.
4821 *
4822 * Licensed under the Apache License, Version 2.0 (the "License");
4823 * you may not use this file except in compliance with the License.
4824 * You may obtain a copy of the License at
4825 *
4826 * http://www.apache.org/licenses/LICENSE-2.0
4827 *
4828 * Unless required by applicable law or agreed to in writing, software
4829 * distributed under the License is distributed on an "AS IS" BASIS,
4830 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4831 * See the License for the specific language governing permissions and
4832 * limitations under the License.
4833 *
4834 * @providesModule ReactDOMIDOperations
4835 * @typechecks static-only
4836 */
4837
4838/*jslint evil: true */
4839
4840"use strict";
4841
4842var CSSPropertyOperations = require("./CSSPropertyOperations");
4843var DOMChildrenOperations = require("./DOMChildrenOperations");
4844var DOMPropertyOperations = require("./DOMPropertyOperations");
4845var ReactMount = require("./ReactMount");
4846
4847var getTextContentAccessor = require("./getTextContentAccessor");
4848var invariant = require("./invariant");
4849
4850/**
4851 * Errors for properties that should not be updated with `updatePropertyById()`.
4852 *
4853 * @type {object}
4854 * @private
4855 */
4856var INVALID_PROPERTY_ERRORS = {
4857 dangerouslySetInnerHTML:
4858 '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
4859 style: '`style` must be set using `updateStylesByID()`.'
4860};
4861
4862/**
4863 * The DOM property to use when setting text content.
4864 *
4865 * @type {string}
4866 * @private
4867 */
4868var textContentAccessor = getTextContentAccessor() || 'NA';
4869
4870/**
4871 * Operations used to process updates to DOM nodes. This is made injectable via
4872 * `ReactComponent.DOMIDOperations`.
4873 */
4874var ReactDOMIDOperations = {
4875
4876 /**
4877 * Updates a DOM node with new property values. This should only be used to
4878 * update DOM properties in `DOMProperty`.
4879 *
4880 * @param {string} id ID of the node to update.
4881 * @param {string} name A valid property name, see `DOMProperty`.
4882 * @param {*} value New value of the property.
4883 * @internal
4884 */
4885 updatePropertyByID: function(id, name, value) {
4886 var node = ReactMount.getNode(id);
4887 invariant(
4888 !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
4889 'updatePropertyByID(...): %s',
4890 INVALID_PROPERTY_ERRORS[name]
4891 );
4892
4893 // If we're updating to null or undefined, we should remove the property
4894 // from the DOM node instead of inadvertantly setting to a string. This
4895 // brings us in line with the same behavior we have on initial render.
4896 if (value != null) {
4897 DOMPropertyOperations.setValueForProperty(node, name, value);
4898 } else {
4899 DOMPropertyOperations.deleteValueForProperty(node, name);
4900 }
4901 },
4902
4903 /**
4904 * Updates a DOM node to remove a property. This should only be used to remove
4905 * DOM properties in `DOMProperty`.
4906 *
4907 * @param {string} id ID of the node to update.
4908 * @param {string} name A property name to remove, see `DOMProperty`.
4909 * @internal
4910 */
4911 deletePropertyByID: function(id, name, value) {
4912 var node = ReactMount.getNode(id);
4913 invariant(
4914 !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
4915 'updatePropertyByID(...): %s',
4916 INVALID_PROPERTY_ERRORS[name]
4917 );
4918 DOMPropertyOperations.deleteValueForProperty(node, name, value);
4919 },
4920
4921 /**
4922 * This should almost never be used instead of `updatePropertyByID()` due to
4923 * the extra object allocation required by the API. That said, this is useful
4924 * for batching up several operations across worker thread boundaries.
4925 *
4926 * @param {string} id ID of the node to update.
4927 * @param {object} properties A mapping of valid property names.
4928 * @internal
4929 * @see {ReactDOMIDOperations.updatePropertyByID}
4930 */
4931 updatePropertiesByID: function(id, properties) {
4932 for (var name in properties) {
4933 if (!properties.hasOwnProperty(name)) {
4934 continue;
4935 }
4936 ReactDOMIDOperations.updatePropertiesByID(id, name, properties[name]);
4937 }
4938 },
4939
4940 /**
4941 * Updates a DOM node with new style values. If a value is specified as '',
4942 * the corresponding style property will be unset.
4943 *
4944 * @param {string} id ID of the node to update.
4945 * @param {object} styles Mapping from styles to values.
4946 * @internal
4947 */
4948 updateStylesByID: function(id, styles) {
4949 var node = ReactMount.getNode(id);
4950 CSSPropertyOperations.setValueForStyles(node, styles);
4951 },
4952
4953 /**
4954 * Updates a DOM node's innerHTML set by `props.dangerouslySetInnerHTML`.
4955 *
4956 * @param {string} id ID of the node to update.
4957 * @param {object} html An HTML object with the `__html` property.
4958 * @internal
4959 */
4960 updateInnerHTMLByID: function(id, html) {
4961 var node = ReactMount.getNode(id);
4962 // HACK: IE8- normalize whitespace in innerHTML, removing leading spaces.
4963 // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
4964 node.innerHTML = (html && html.__html || '').replace(/^ /g, '&nbsp;');
4965 },
4966
4967 /**
4968 * Updates a DOM node's text content set by `props.content`.
4969 *
4970 * @param {string} id ID of the node to update.
4971 * @param {string} content Text content.
4972 * @internal
4973 */
4974 updateTextContentByID: function(id, content) {
4975 var node = ReactMount.getNode(id);
4976 node[textContentAccessor] = content;
4977 },
4978
4979 /**
4980 * Replaces a DOM node that exists in the document with markup.
4981 *
4982 * @param {string} id ID of child to be replaced.
4983 * @param {string} markup Dangerous markup to inject in place of child.
4984 * @internal
4985 * @see {Danger.dangerouslyReplaceNodeWithMarkup}
4986 */
4987 dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
4988 var node = ReactMount.getNode(id);
4989 DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
4990 },
4991
4992 /**
4993 * TODO: We only actually *need* to purge the cache when we remove elements.
4994 * Detect if any elements were removed instead of blindly purging.
4995 */
4996 manageChildrenByParentID: function(parentID, domOperations) {
4997 var parent = ReactMount.getNode(parentID);
4998 DOMChildrenOperations.manageChildren(parent, domOperations);
4999 }
5000
5001};
5002
5003module.exports = ReactDOMIDOperations;
5004
5005})()
5006},{"./CSSPropertyOperations":3,"./DOMChildrenOperations":6,"./DOMPropertyOperations":8,"./ReactMount":39,"./getTextContentAccessor":74,"./invariant":78}],29:[function(require,module,exports){
5007/**
5008 * Copyright 2013 Facebook, Inc.
5009 *
5010 * Licensed under the Apache License, Version 2.0 (the "License");
5011 * you may not use this file except in compliance with the License.
5012 * You may obtain a copy of the License at
5013 *
5014 * http://www.apache.org/licenses/LICENSE-2.0
5015 *
5016 * Unless required by applicable law or agreed to in writing, software
5017 * distributed under the License is distributed on an "AS IS" BASIS,
5018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5019 * See the License for the specific language governing permissions and
5020 * limitations under the License.
5021 *
5022 * @providesModule ReactDOMInput
5023 */
5024
5025"use strict";
5026
5027var DOMPropertyOperations = require("./DOMPropertyOperations");
5028var ReactCompositeComponent = require("./ReactCompositeComponent");
5029var ReactDOM = require("./ReactDOM");
5030
5031var merge = require("./merge");
5032
5033// Store a reference to the <input> `ReactNativeComponent`.
5034var input = ReactDOM.input;
5035
5036/**
5037 * Implements an <input> native component that allows setting these optional
5038 * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
5039 *
5040 * If `checked` or `value` are not supplied (or null/undefined), user actions
5041 * that affect the checked state or value will trigger updates to the element.
5042 *
5043 * If they are supplied (and not null/undefined), the rendered element will not
5044 * trigger updates to the element. Instead, the props must change in order for
5045 * the rendered element to be updated.
5046 *
5047 * The rendered element will be initialized as unchecked (or `defaultChecked`)
5048 * with an empty value (or `defaultValue`).
5049 *
5050 * @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
5051 */
5052var ReactDOMInput = ReactCompositeComponent.createClass({
5053
5054 getInitialState: function() {
5055 return {
5056 checked: this.props.defaultChecked || false,
5057 value: this.props.defaultValue || ''
5058 };
5059 },
5060
5061 shouldComponentUpdate: function() {
5062 // Defer any updates to this component during the `onChange` handler.
5063 return !this._isChanging;
5064 },
5065
5066 getChecked: function() {
5067 return this.props.checked != null ? this.props.checked : this.state.checked;
5068 },
5069
5070 getValue: function() {
5071 // Cast `this.props.value` to a string so equality checks pass.
5072 return this.props.value != null ? '' + this.props.value : this.state.value;
5073 },
5074
5075 render: function() {
5076 // Clone `this.props` so we don't mutate the input.
5077 var props = merge(this.props);
5078
5079 props.checked = this.getChecked();
5080 props.value = this.getValue();
5081 props.onChange = this.handleChange;
5082
5083 return input(props, this.props.children);
5084 },
5085
5086 componentDidUpdate: function(prevProps, prevState, rootNode) {
5087 if (this.props.checked != null) {
5088 DOMPropertyOperations.setValueForProperty(
5089 rootNode,
5090 'checked',
5091 this.props.checked || false
5092 );
5093 }
5094 if (this.props.value != null) {
5095 // Cast `this.props.value` to a string so falsey values that cast to
5096 // truthy strings are not ignored.
5097 DOMPropertyOperations.setValueForProperty(
5098 rootNode,
5099 'value',
5100 '' + this.props.value || ''
5101 );
5102 }
5103 },
5104
5105 handleChange: function(event) {
5106 var returnValue;
5107 if (this.props.onChange) {
5108 this._isChanging = true;
5109 returnValue = this.props.onChange(event);
5110 this._isChanging = false;
5111 }
5112 this.setState({
5113 checked: event.target.checked,
5114 value: event.target.value
5115 });
5116 return returnValue;
5117 }
5118
5119});
5120
5121module.exports = ReactDOMInput;
5122
5123},{"./DOMPropertyOperations":8,"./ReactCompositeComponent":24,"./ReactDOM":26,"./merge":84}],30:[function(require,module,exports){
5124/**
5125 * Copyright 2013 Facebook, Inc.
5126 *
5127 * Licensed under the Apache License, Version 2.0 (the "License");
5128 * you may not use this file except in compliance with the License.
5129 * You may obtain a copy of the License at
5130 *
5131 * http://www.apache.org/licenses/LICENSE-2.0
5132 *
5133 * Unless required by applicable law or agreed to in writing, software
5134 * distributed under the License is distributed on an "AS IS" BASIS,
5135 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5136 * See the License for the specific language governing permissions and
5137 * limitations under the License.
5138 *
5139 * @providesModule ReactDOMOption
5140 */
5141
5142"use strict";
5143
5144var ReactCompositeComponent = require("./ReactCompositeComponent");
5145var ReactDOM = require("./ReactDOM");
5146
5147// Store a reference to the <option> `ReactNativeComponent`.
5148var option = ReactDOM.option;
5149
5150/**
5151 * Implements an <option> native component that warns when `selected` is set.
5152 */
5153var ReactDOMOption = ReactCompositeComponent.createClass({
5154
5155 componentWillMount: function() {
5156 // TODO (yungsters): Remove support for `selected` in <option>.
5157 if (this.props.selected != null) {
5158 if (true) {
5159 console.warn(
5160 'Use the `defaultValue` or `value` props on <select> instead of ' +
5161 'setting `selected` on <option>.'
5162 );
5163 }
5164 }
5165 },
5166
5167 render: function() {
5168 return option(this.props, this.props.children);
5169 }
5170
5171});
5172
5173module.exports = ReactDOMOption;
5174
5175},{"./ReactCompositeComponent":24,"./ReactDOM":26}],31:[function(require,module,exports){
5176/**
5177 * Copyright 2013 Facebook, Inc.
5178 *
5179 * Licensed under the Apache License, Version 2.0 (the "License");
5180 * you may not use this file except in compliance with the License.
5181 * You may obtain a copy of the License at
5182 *
5183 * http://www.apache.org/licenses/LICENSE-2.0
5184 *
5185 * Unless required by applicable law or agreed to in writing, software
5186 * distributed under the License is distributed on an "AS IS" BASIS,
5187 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5188 * See the License for the specific language governing permissions and
5189 * limitations under the License.
5190 *
5191 * @providesModule ReactDOMSelect
5192 */
5193
5194"use strict";
5195
5196var ReactCompositeComponent = require("./ReactCompositeComponent");
5197var ReactDOM = require("./ReactDOM");
5198
5199var invariant = require("./invariant");
5200var merge = require("./merge");
5201
5202// Store a reference to the <select> `ReactNativeComponent`.
5203var select = ReactDOM.select;
5204
5205/**
5206 * Validation function for `value` and `defaultValue`.
5207 * @private
5208 */
5209function selectValueType(props, propName, componentName) {
5210 if (props[propName] == null) {
5211 return;
5212 }
5213 if (props.multiple) {
5214 invariant(
5215 Array.isArray(props[propName]),
5216 'The `%s` prop supplied to <select> must be an array if `multiple` is ' +
5217 'true.',
5218 propName
5219 );
5220 } else {
5221 invariant(
5222 !Array.isArray(props[propName]),
5223 'The `%s` prop supplied to <select> must be a scalar value if ' +
5224 '`multiple` is false.',
5225 propName
5226 );
5227 }
5228}
5229
5230/**
5231 * If `value` is supplied, updates <option> elements on mount and update.
5232 * @private
5233 */
5234function updateOptions() {
5235 /*jshint validthis:true */
5236 if (this.props.value == null) {
5237 return;
5238 }
5239 var options = this.getDOMNode().options;
5240 var selectedValue = '' + this.props.value;
5241
5242 for (var i = 0, l = options.length; i < l; i++) {
5243 var selected = this.props.multiple ?
5244 selectedValue.indexOf(options[i].value) >= 0 :
5245 selected = options[i].value === selectedValue;
5246
5247 if (selected !== options[i].selected) {
5248 options[i].selected = selected;
5249 }
5250 }
5251}
5252
5253/**
5254 * Implements a <select> native component that allows optionally setting the
5255 * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
5256 * string. If `multiple` is true, the prop must be an array of strings.
5257 *
5258 * If `value` is not supplied (or null/undefined), user actions that change the
5259 * selected option will trigger updates to the rendered options.
5260 *
5261 * If it is supplied (and not null/undefined), the rendered options will not
5262 * update in response to user actions. Instead, the `value` prop must change in
5263 * order for the rendered options to update.
5264 *
5265 * If `defaultValue` is provided, any options with the supplied values will be
5266 * selected.
5267 */
5268var ReactDOMSelect = ReactCompositeComponent.createClass({
5269
5270 propTypes: {
5271 defaultValue: selectValueType,
5272 value: selectValueType
5273 },
5274
5275 getInitialState: function() {
5276 return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
5277 },
5278
5279 componentWillReceiveProps: function(nextProps) {
5280 if (!this.props.multiple && nextProps.multiple) {
5281 this.setState({value: [this.state.value]});
5282 } else if (this.props.multiple && !nextProps.multiple) {
5283 this.setState({value: this.state.value[0]});
5284 }
5285 },
5286
5287 shouldComponentUpdate: function() {
5288 // Defer any updates to this component during the `onChange` handler.
5289 return !this._isChanging;
5290 },
5291
5292 render: function() {
5293 // Clone `this.props` so we don't mutate the input.
5294 var props = merge(this.props);
5295
5296 props.onChange = this.handleChange;
5297 props.value = null;
5298
5299 return select(props, this.props.children);
5300 },
5301
5302 componentDidMount: updateOptions,
5303
5304 componentDidUpdate: updateOptions,
5305
5306 handleChange: function(event) {
5307 var returnValue;
5308 if (this.props.onChange) {
5309 this._isChanging = true;
5310 returnValue = this.props.onChange(event);
5311 this._isChanging = false;
5312 }
5313
5314 var selectedValue;
5315 if (this.props.multiple) {
5316 selectedValue = [];
5317 var options = event.target.options;
5318 for (var i = 0, l = options.length; i < l; i++) {
5319 if (options[i].selected) {
5320 selectedValue.push(options[i].value);
5321 }
5322 }
5323 } else {
5324 selectedValue = event.target.value;
5325 }
5326
5327 this.setState({value: selectedValue});
5328 return returnValue;
5329 }
5330
5331});
5332
5333module.exports = ReactDOMSelect;
5334
5335},{"./ReactCompositeComponent":24,"./ReactDOM":26,"./invariant":78,"./merge":84}],32:[function(require,module,exports){
5336/**
5337 * Copyright 2013 Facebook, Inc.
5338 *
5339 * Licensed under the Apache License, Version 2.0 (the "License");
5340 * you may not use this file except in compliance with the License.
5341 * You may obtain a copy of the License at
5342 *
5343 * http://www.apache.org/licenses/LICENSE-2.0
5344 *
5345 * Unless required by applicable law or agreed to in writing, software
5346 * distributed under the License is distributed on an "AS IS" BASIS,
5347 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5348 * See the License for the specific language governing permissions and
5349 * limitations under the License.
5350 *
5351 * @providesModule ReactDOMTextarea
5352 */
5353
5354"use strict";
5355
5356var DOMPropertyOperations = require("./DOMPropertyOperations");
5357var ReactCompositeComponent = require("./ReactCompositeComponent");
5358var ReactDOM = require("./ReactDOM");
5359
5360var invariant = require("./invariant");
5361var merge = require("./merge");
5362
5363// Store a reference to the <textarea> `ReactNativeComponent`.
5364var textarea = ReactDOM.textarea;
5365
5366// For quickly matching children type, to test if can be treated as content.
5367var CONTENT_TYPES = {'string': true, 'number': true};
5368
5369/**
5370 * Implements a <textarea> native component that allows setting `value`, and
5371 * `defaultValue`. This differs from the traditional DOM API because value is
5372 * usually set as PCDATA children.
5373 *
5374 * If `value` is not supplied (or null/undefined), user actions that affect the
5375 * value will trigger updates to the element.
5376 *
5377 * If `value` is supplied (and not null/undefined), the rendered element will
5378 * not trigger updates to the element. Instead, the `value` prop must change in
5379 * order for the rendered element to be updated.
5380 *
5381 * The rendered element will be initialized with an empty value, the prop
5382 * `defaultValue` if specified, or the children content (deprecated).
5383 */
5384var ReactDOMTextarea = ReactCompositeComponent.createClass({
5385
5386 getInitialState: function() {
5387 var defaultValue = this.props.defaultValue;
5388 // TODO (yungsters): Remove support for children content in <textarea>.
5389 var children = this.props.children;
5390 if (children != null) {
5391 if (true) {
5392 console.warn(
5393 'Use the `defaultValue` or `value` props instead of setting ' +
5394 'children on <textarea>.'
5395 );
5396 }
5397 invariant(
5398 defaultValue == null,
5399 'If you supply `defaultValue` on a <textarea>, do not pass children.'
5400 );
5401 if (Array.isArray(children)) {
5402 invariant(
5403 children.length <= 1,
5404 '<textarea> can only have at most one child.'
5405 );
5406 children = children[0];
5407 }
5408 invariant(
5409 CONTENT_TYPES[typeof children],
5410 'If you specify children to <textarea>, it must be a single string ' +
5411 'or number., not an array or object.'
5412 );
5413 defaultValue = '' + children;
5414 }
5415 defaultValue = defaultValue || '';
5416 return {
5417 // We save the initial value so that `ReactNativeComponent` doesn't update
5418 // `textContent` (unnecessary since we update value).
5419 initialValue: this.props.value != null ? this.props.value : defaultValue,
5420 value: defaultValue
5421 };
5422 },
5423
5424 shouldComponentUpdate: function() {
5425 // Defer any updates to this component during the `onChange` handler.
5426 return !this._isChanging;
5427 },
5428
5429 getValue: function() {
5430 return this.props.value != null ? this.props.value : this.state.value;
5431 },
5432
5433 render: function() {
5434 // Clone `this.props` so we don't mutate the input.
5435 var props = merge(this.props);
5436
5437 invariant(
5438 props.dangerouslySetInnerHTML == null,
5439 '`dangerouslySetInnerHTML` does not make sense on <textarea>.'
5440 );
5441
5442 props.value = this.getValue();
5443 props.onChange = this.handleChange;
5444
5445 // Always set children to the same thing. In IE9, the selection range will
5446 // get reset if `textContent` is mutated.
5447 return textarea(props, this.state.initialValue);
5448 },
5449
5450 componentDidUpdate: function(prevProps, prevState, rootNode) {
5451 if (this.props.value != null) {
5452 DOMPropertyOperations.setValueForProperty(
5453 rootNode,
5454 'value',
5455 this.props.value || ''
5456 );
5457 }
5458 },
5459
5460 handleChange: function(event) {
5461 var returnValue;
5462 if (this.props.onChange) {
5463 this._isChanging = true;
5464 returnValue = this.props.onChange(event);
5465 this._isChanging = false;
5466 }
5467 this.setState({value: event.target.value});
5468 return returnValue;
5469 }
5470
5471});
5472
5473module.exports = ReactDOMTextarea;
5474
5475},{"./DOMPropertyOperations":8,"./ReactCompositeComponent":24,"./ReactDOM":26,"./invariant":78,"./merge":84}],33:[function(require,module,exports){
5476/**
5477 * Copyright 2013 Facebook, Inc.
5478 *
5479 * Licensed under the Apache License, Version 2.0 (the "License");
5480 * you may not use this file except in compliance with the License.
5481 * You may obtain a copy of the License at
5482 *
5483 * http://www.apache.org/licenses/LICENSE-2.0
5484 *
5485 * Unless required by applicable law or agreed to in writing, software
5486 * distributed under the License is distributed on an "AS IS" BASIS,
5487 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5488 * See the License for the specific language governing permissions and
5489 * limitations under the License.
5490 *
5491 * @providesModule ReactDefaultInjection
5492 */
5493
5494"use strict";
5495
5496var ReactDOM = require("./ReactDOM");
5497var ReactDOMForm = require("./ReactDOMForm");
5498var ReactDOMInput = require("./ReactDOMInput");
5499var ReactDOMOption = require("./ReactDOMOption");
5500var ReactDOMSelect = require("./ReactDOMSelect");
5501var ReactDOMTextarea = require("./ReactDOMTextarea");
5502var ReactEventEmitter = require("./ReactEventEmitter");
5503var ReactEventTopLevelCallback = require("./ReactEventTopLevelCallback");
5504
5505var DefaultDOMPropertyConfig = require("./DefaultDOMPropertyConfig");
5506var DOMProperty = require("./DOMProperty");
5507
5508var DefaultEventPluginOrder = require("./DefaultEventPluginOrder");
5509var EnterLeaveEventPlugin = require("./EnterLeaveEventPlugin");
5510var ChangeEventPlugin = require("./ChangeEventPlugin");
5511var EventPluginHub = require("./EventPluginHub");
5512var ReactInstanceHandles = require("./ReactInstanceHandles");
5513var SimpleEventPlugin = require("./SimpleEventPlugin");
5514var MobileSafariClickEventPlugin = require("./MobileSafariClickEventPlugin");
5515
5516function inject() {
5517 ReactEventEmitter.TopLevelCallbackCreator = ReactEventTopLevelCallback;
5518 /**
5519 * Inject module for resolving DOM hierarchy and plugin ordering.
5520 */
5521 EventPluginHub.injection.injectEventPluginOrder(DefaultEventPluginOrder);
5522 EventPluginHub.injection.injectInstanceHandle(ReactInstanceHandles);
5523
5524 /**
5525 * Some important event plugins included by default (without having to require
5526 * them).
5527 */
5528 EventPluginHub.injection.injectEventPluginsByName({
5529 'SimpleEventPlugin': SimpleEventPlugin,
5530 'EnterLeaveEventPlugin': EnterLeaveEventPlugin,
5531 'ChangeEventPlugin': ChangeEventPlugin,
5532 'MobileSafariClickEventPlugin': MobileSafariClickEventPlugin
5533 });
5534
5535 ReactDOM.injection.injectComponentClasses({
5536 form: ReactDOMForm,
5537 input: ReactDOMInput,
5538 option: ReactDOMOption,
5539 select: ReactDOMSelect,
5540 textarea: ReactDOMTextarea
5541 });
5542
5543 DOMProperty.injection.injectDOMPropertyConfig(DefaultDOMPropertyConfig);
5544}
5545
5546module.exports = {
5547 inject: inject
5548};
5549
5550},{"./ChangeEventPlugin":5,"./DOMProperty":7,"./DefaultDOMPropertyConfig":10,"./DefaultEventPluginOrder":11,"./EnterLeaveEventPlugin":12,"./EventPluginHub":15,"./MobileSafariClickEventPlugin":20,"./ReactDOM":26,"./ReactDOMForm":27,"./ReactDOMInput":29,"./ReactDOMOption":30,"./ReactDOMSelect":31,"./ReactDOMTextarea":32,"./ReactEventEmitter":34,"./ReactEventTopLevelCallback":35,"./ReactInstanceHandles":37,"./SimpleEventPlugin":50}],34:[function(require,module,exports){
5551(function(){/**
5552 * Copyright 2013 Facebook, Inc.
5553 *
5554 * Licensed under the Apache License, Version 2.0 (the "License");
5555 * you may not use this file except in compliance with the License.
5556 * You may obtain a copy of the License at
5557 *
5558 * http://www.apache.org/licenses/LICENSE-2.0
5559 *
5560 * Unless required by applicable law or agreed to in writing, software
5561 * distributed under the License is distributed on an "AS IS" BASIS,
5562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5563 * See the License for the specific language governing permissions and
5564 * limitations under the License.
5565 *
5566 * @providesModule ReactEventEmitter
5567 * @typechecks static-only
5568 */
5569
5570"use strict";
5571
5572var EventConstants = require("./EventConstants");
5573var EventListener = require("./EventListener");
5574var EventPluginHub = require("./EventPluginHub");
5575var ExecutionEnvironment = require("./ExecutionEnvironment");
5576var ReactUpdates = require("./ReactUpdates");
5577var ViewportMetrics = require("./ViewportMetrics");
5578
5579var invariant = require("./invariant");
5580var isEventSupported = require("./isEventSupported");
5581
5582/**
5583 * Summary of `ReactEventEmitter` event handling:
5584 *
5585 * - Top-level delegation is used to trap native browser events. We normalize
5586 * and de-duplicate events to account for browser quirks.
5587 *
5588 * - Forward these native events (with the associated top-level type used to
5589 * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
5590 * to extract any synthetic events.
5591 *
5592 * - The `EventPluginHub` will then process each event by annotating them with
5593 * "dispatches", a sequence of listeners and IDs that care about that event.
5594 *
5595 * - The `EventPluginHub` then dispatches the events.
5596 *
5597 * Overview of React and the event system:
5598 *
5599 * .
5600 * +------------+ .
5601 * | DOM | .
5602 * +------------+ . +-----------+
5603 * + . +--------+|SimpleEvent|
5604 * | . | |Plugin |
5605 * +-----|------+ . v +-----------+
5606 * | | | . +--------------+ +------------+
5607 * | +-----------.--->|EventPluginHub| | Event |
5608 * | | . | | +-----------+ | Propagators|
5609 * | ReactEvent | . | | |TapEvent | |------------|
5610 * | Emitter | . | |<---+|Plugin | |other plugin|
5611 * | | . | | +-----------+ | utilities |
5612 * | +-----------.---------+ | +------------+
5613 * | | | . +----|---------+
5614 * +-----|------+ . | ^ +-----------+
5615 * | . | | |Enter/Leave|
5616 * + . | +-------+|Plugin |
5617 * +-------------+ . v +-----------+
5618 * | application | . +----------+
5619 * |-------------| . | callback |
5620 * | | . | registry |
5621 * | | . +----------+
5622 * +-------------+ .
5623 * .
5624 * React Core . General Purpose Event Plugin System
5625 */
5626
5627/**
5628 * Whether or not `ensureListening` has been invoked.
5629 * @type {boolean}
5630 * @private
5631 */
5632var _isListening = false;
5633
5634/**
5635 * Traps top-level events by using event bubbling.
5636 *
5637 * @param {string} topLevelType Record from `EventConstants`.
5638 * @param {string} handlerBaseName Event name (e.g. "click").
5639 * @param {DOMEventTarget} element Element on which to attach listener.
5640 * @internal
5641 */
5642function trapBubbledEvent(topLevelType, handlerBaseName, element) {
5643 EventListener.listen(
5644 element,
5645 handlerBaseName,
5646 ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
5647 topLevelType
5648 )
5649 );
5650}
5651
5652/**
5653 * Traps a top-level event by using event capturing.
5654 *
5655 * @param {string} topLevelType Record from `EventConstants`.
5656 * @param {string} handlerBaseName Event name (e.g. "click").
5657 * @param {DOMEventTarget} element Element on which to attach listener.
5658 * @internal
5659 */
5660function trapCapturedEvent(topLevelType, handlerBaseName, element) {
5661 EventListener.capture(
5662 element,
5663 handlerBaseName,
5664 ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
5665 topLevelType
5666 )
5667 );
5668}
5669
5670/**
5671 * Listens to window scroll and resize events. We cache scroll values so that
5672 * application code can access them without triggering reflows.
5673 *
5674 * NOTE: Scroll events do not bubble.
5675 *
5676 * @private
5677 * @see http://www.quirksmode.org/dom/events/scroll.html
5678 */
5679function registerScrollValueMonitoring() {
5680 var refresh = ViewportMetrics.refreshScrollValues;
5681 EventListener.listen(window, 'scroll', refresh);
5682 EventListener.listen(window, 'resize', refresh);
5683}
5684
5685/**
5686 * We listen for bubbled touch events on the document object.
5687 *
5688 * Firefox v8.01 (and possibly others) exhibited strange behavior when mounting
5689 * `onmousemove` events at some node that was not the document element. The
5690 * symptoms were that if your mouse is not moving over something contained
5691 * within that mount point (for example on the background) the top-level
5692 * listeners for `onmousemove` won't be called. However, if you register the
5693 * `mousemove` on the document object, then it will of course catch all
5694 * `mousemove`s. This along with iOS quirks, justifies restricting top-level
5695 * listeners to the document object only, at least for these movement types of
5696 * events and possibly all events.
5697 *
5698 * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
5699 *
5700 * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
5701 * they bubble to document.
5702 *
5703 * @param {boolean} touchNotMouse Listen to touch events instead of mouse.
5704 * @private
5705 * @see http://www.quirksmode.org/dom/events/keys.html.
5706 */
5707function listenAtTopLevel(touchNotMouse) {
5708 invariant(
5709 !_isListening,
5710 'listenAtTopLevel(...): Cannot setup top-level listener more than once.'
5711 );
5712 var topLevelTypes = EventConstants.topLevelTypes;
5713 var mountAt = document;
5714
5715 registerScrollValueMonitoring();
5716 trapBubbledEvent(topLevelTypes.topMouseOver, 'mouseover', mountAt);
5717 trapBubbledEvent(topLevelTypes.topMouseDown, 'mousedown', mountAt);
5718 trapBubbledEvent(topLevelTypes.topMouseUp, 'mouseup', mountAt);
5719 trapBubbledEvent(topLevelTypes.topMouseMove, 'mousemove', mountAt);
5720 trapBubbledEvent(topLevelTypes.topMouseOut, 'mouseout', mountAt);
5721 trapBubbledEvent(topLevelTypes.topClick, 'click', mountAt);
5722 trapBubbledEvent(topLevelTypes.topDoubleClick, 'dblclick', mountAt);
5723 if (touchNotMouse) {
5724 trapBubbledEvent(topLevelTypes.topTouchStart, 'touchstart', mountAt);
5725 trapBubbledEvent(topLevelTypes.topTouchEnd, 'touchend', mountAt);
5726 trapBubbledEvent(topLevelTypes.topTouchMove, 'touchmove', mountAt);
5727 trapBubbledEvent(topLevelTypes.topTouchCancel, 'touchcancel', mountAt);
5728 }
5729 trapBubbledEvent(topLevelTypes.topKeyUp, 'keyup', mountAt);
5730 trapBubbledEvent(topLevelTypes.topKeyPress, 'keypress', mountAt);
5731 trapBubbledEvent(topLevelTypes.topKeyDown, 'keydown', mountAt);
5732 trapBubbledEvent(topLevelTypes.topInput, 'input', mountAt);
5733 trapBubbledEvent(topLevelTypes.topChange, 'change', mountAt);
5734 trapBubbledEvent(
5735 topLevelTypes.topSelectionChange,
5736 'selectionchange',
5737 mountAt
5738 );
5739 trapBubbledEvent(
5740 topLevelTypes.topDOMCharacterDataModified,
5741 'DOMCharacterDataModified',
5742 mountAt
5743 );
5744
5745 if (isEventSupported('drag')) {
5746 trapBubbledEvent(topLevelTypes.topDrag, 'drag', mountAt);
5747 trapBubbledEvent(topLevelTypes.topDragEnd, 'dragend', mountAt);
5748 trapBubbledEvent(topLevelTypes.topDragEnter, 'dragenter', mountAt);
5749 trapBubbledEvent(topLevelTypes.topDragExit, 'dragexit', mountAt);
5750 trapBubbledEvent(topLevelTypes.topDragLeave, 'dragleave', mountAt);
5751 trapBubbledEvent(topLevelTypes.topDragOver, 'dragover', mountAt);
5752 trapBubbledEvent(topLevelTypes.topDragStart, 'dragstart', mountAt);
5753 trapBubbledEvent(topLevelTypes.topDrop, 'drop', mountAt);
5754 }
5755
5756 if (isEventSupported('wheel')) {
5757 trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt);
5758 } else if (isEventSupported('mousewheel')) {
5759 trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt);
5760 } else {
5761 // Firefox needs to capture a different mouse scroll event.
5762 // @see http://www.quirksmode.org/dom/events/tests/scroll.html
5763 trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt);
5764 }
5765
5766 // IE<9 does not support capturing so just trap the bubbled event there.
5767 if (isEventSupported('scroll', true)) {
5768 trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt);
5769 } else {
5770 trapBubbledEvent(topLevelTypes.topScroll, 'scroll', window);
5771 }
5772
5773 if (isEventSupported('focus', true)) {
5774 trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt);
5775 trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt);
5776 } else if (isEventSupported('focusin')) {
5777 // IE has `focusin` and `focusout` events which bubble.
5778 // @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
5779 trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt);
5780 trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt);
5781 }
5782}
5783
5784/**
5785 * `ReactEventEmitter` is used to attach top-level event listeners. For example:
5786 *
5787 * ReactEventEmitter.putListener('myID', 'onClick', myFunction);
5788 *
5789 * This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
5790 *
5791 * @internal
5792 */
5793var ReactEventEmitter = {
5794
5795 /**
5796 * React references `ReactEventTopLevelCallback` using this property in order
5797 * to allow dependency injection.
5798 */
5799 TopLevelCallbackCreator: null,
5800
5801 /**
5802 * Ensures that top-level event delegation listeners are installed.
5803 *
5804 * There are issues with listening to both touch events and mouse events on
5805 * the top-level, so we make the caller choose which one to listen to. (If
5806 * there's a touch top-level listeners, anchors don't receive clicks for some
5807 * reason, and only in some cases).
5808 *
5809 * @param {boolean} touchNotMouse Listen to touch events instead of mouse.
5810 */
5811 ensureListening: function(touchNotMouse) {
5812 invariant(
5813 ExecutionEnvironment.canUseDOM,
5814 'ensureListening(...): Cannot toggle event listening in a Worker ' +
5815 'thread. This is likely a bug in the framework. Please report ' +
5816 'immediately.'
5817 );
5818 invariant(
5819 ReactEventEmitter.TopLevelCallbackCreator,
5820 'ensureListening(...): Cannot be called without a top level callback ' +
5821 'creator being injected.'
5822 );
5823 if (!_isListening) {
5824 listenAtTopLevel(touchNotMouse);
5825 _isListening = true;
5826 }
5827 },
5828
5829 /**
5830 * Sets whether or not any created callbacks should be enabled.
5831 *
5832 * @param {boolean} enabled True if callbacks should be enabled.
5833 */
5834 setEnabled: function(enabled) {
5835 invariant(
5836 ExecutionEnvironment.canUseDOM,
5837 'setEnabled(...): Cannot toggle event listening in a Worker thread. ' +
5838 'This is likely a bug in the framework. Please report immediately.'
5839 );
5840 if (ReactEventEmitter.TopLevelCallbackCreator) {
5841 ReactEventEmitter.TopLevelCallbackCreator.setEnabled(enabled);
5842 }
5843 },
5844
5845 /**
5846 * @return {boolean} True if callbacks are enabled.
5847 */
5848 isEnabled: function() {
5849 return !!(
5850 ReactEventEmitter.TopLevelCallbackCreator &&
5851 ReactEventEmitter.TopLevelCallbackCreator.isEnabled()
5852 );
5853 },
5854
5855 /**
5856 * Streams a fired top-level event to `EventPluginHub` where plugins have the
5857 * opportunity to create `ReactEvent`s to be dispatched.
5858 *
5859 * @param {string} topLevelType Record from `EventConstants`.
5860 * @param {DOMEventTarget} topLevelTarget The listening component root node.
5861 * @param {string} topLevelTargetID ID of `topLevelTarget`.
5862 * @param {object} nativeEvent Native browser event.
5863 */
5864 handleTopLevel: function(
5865 topLevelType,
5866 topLevelTarget,
5867 topLevelTargetID,
5868 nativeEvent) {
5869 var events = EventPluginHub.extractEvents(
5870 topLevelType,
5871 topLevelTarget,
5872 topLevelTargetID,
5873 nativeEvent
5874 );
5875
5876 // Event queue being processed in the same cycle allows `preventDefault`.
5877 ReactUpdates.batchedUpdates(function() {
5878 EventPluginHub.enqueueEvents(events);
5879 EventPluginHub.processEventQueue();
5880 });
5881 },
5882
5883 registrationNames: EventPluginHub.registrationNames,
5884
5885 putListener: EventPluginHub.putListener,
5886
5887 getListener: EventPluginHub.getListener,
5888
5889 deleteListener: EventPluginHub.deleteListener,
5890
5891 deleteAllListeners: EventPluginHub.deleteAllListeners,
5892
5893 trapBubbledEvent: trapBubbledEvent,
5894
5895 trapCapturedEvent: trapCapturedEvent
5896
5897};
5898
5899module.exports = ReactEventEmitter;
5900
5901})()
5902},{"./EventConstants":13,"./EventListener":14,"./EventPluginHub":15,"./ExecutionEnvironment":19,"./ReactUpdates":49,"./ViewportMetrics":60,"./invariant":78,"./isEventSupported":79}],35:[function(require,module,exports){
5903(function(){/**
5904 * Copyright 2013 Facebook, Inc.
5905 *
5906 * Licensed under the Apache License, Version 2.0 (the "License");
5907 * you may not use this file except in compliance with the License.
5908 * You may obtain a copy of the License at
5909 *
5910 * http://www.apache.org/licenses/LICENSE-2.0
5911 *
5912 * Unless required by applicable law or agreed to in writing, software
5913 * distributed under the License is distributed on an "AS IS" BASIS,
5914 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5915 * See the License for the specific language governing permissions and
5916 * limitations under the License.
5917 *
5918 * @providesModule ReactEventTopLevelCallback
5919 * @typechecks static-only
5920 */
5921
5922"use strict";
5923
5924var ExecutionEnvironment = require("./ExecutionEnvironment");
5925var ReactEventEmitter = require("./ReactEventEmitter");
5926var ReactMount = require("./ReactMount");
5927
5928var getEventTarget = require("./getEventTarget");
5929
5930/**
5931 * @type {boolean}
5932 * @private
5933 */
5934var _topLevelListenersEnabled = true;
5935
5936/**
5937 * Top-level callback creator used to implement event handling using delegation.
5938 * This is used via dependency injection.
5939 */
5940var ReactEventTopLevelCallback = {
5941
5942 /**
5943 * Sets whether or not any created callbacks should be enabled.
5944 *
5945 * @param {boolean} enabled True if callbacks should be enabled.
5946 */
5947 setEnabled: function(enabled) {
5948 _topLevelListenersEnabled = !!enabled;
5949 },
5950
5951 /**
5952 * @return {boolean} True if callbacks are enabled.
5953 */
5954 isEnabled: function() {
5955 return _topLevelListenersEnabled;
5956 },
5957
5958 /**
5959 * Creates a callback for the supplied `topLevelType` that could be added as
5960 * a listener to the document. The callback computes a `topLevelTarget` which
5961 * should be the root node of a mounted React component where the listener
5962 * is attached.
5963 *
5964 * @param {string} topLevelType Record from `EventConstants`.
5965 * @return {function} Callback for handling top-level events.
5966 */
5967 createTopLevelCallback: function(topLevelType) {
5968 return function(nativeEvent) {
5969 if (!_topLevelListenersEnabled) {
5970 return;
5971 }
5972 // TODO: Remove when synthetic events are ready, this is for IE<9.
5973 if (nativeEvent.srcElement &&
5974 nativeEvent.srcElement !== nativeEvent.target) {
5975 nativeEvent.target = nativeEvent.srcElement;
5976 }
5977 var topLevelTarget = ReactMount.getFirstReactDOM(
5978 getEventTarget(nativeEvent)
5979 ) || ExecutionEnvironment.global;
5980 var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
5981 ReactEventEmitter.handleTopLevel(
5982 topLevelType,
5983 topLevelTarget,
5984 topLevelTargetID,
5985 nativeEvent
5986 );
5987 };
5988 }
5989
5990};
5991
5992module.exports = ReactEventTopLevelCallback;
5993
5994})()
5995},{"./ExecutionEnvironment":19,"./ReactEventEmitter":34,"./ReactMount":39,"./getEventTarget":72}],36:[function(require,module,exports){
5996/**
5997 * Copyright 2013 Facebook, Inc.
5998 *
5999 * Licensed under the Apache License, Version 2.0 (the "License");
6000 * you may not use this file except in compliance with the License.
6001 * You may obtain a copy of the License at
6002 *
6003 * http://www.apache.org/licenses/LICENSE-2.0
6004 *
6005 * Unless required by applicable law or agreed to in writing, software
6006 * distributed under the License is distributed on an "AS IS" BASIS,
6007 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6008 * See the License for the specific language governing permissions and
6009 * limitations under the License.
6010 *
6011 * @providesModule ReactInputSelection
6012 */
6013
6014"use strict";
6015
6016// It is not safe to read the document.activeElement property in IE if there's
6017// nothing focused.
6018function getActiveElement() {
6019 try {
6020 return document.activeElement;
6021 } catch (e) {
6022 }
6023}
6024
6025function isInDocument(node) {
6026 return document.documentElement.contains(node);
6027}
6028
6029/**
6030 * @ReactInputSelection: React input selection module. Based on Selection.js,
6031 * but modified to be suitable for react and has a couple of bug fixes (doesn't
6032 * assume buttons have range selections allowed).
6033 * Input selection module for React.
6034 */
6035var ReactInputSelection = {
6036
6037 hasSelectionCapabilities: function(elem) {
6038 return elem && (
6039 (elem.nodeName === 'INPUT' && elem.type === 'text') ||
6040 elem.nodeName === 'TEXTAREA' ||
6041 elem.contentEditable === 'true'
6042 );
6043 },
6044
6045 getSelectionInformation: function() {
6046 var focusedElem = getActiveElement();
6047 return {
6048 focusedElem: focusedElem,
6049 selectionRange:
6050 ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
6051 ReactInputSelection.getSelection(focusedElem) :
6052 null
6053 };
6054 },
6055
6056 /**
6057 * @restoreSelection: If any selection information was potentially lost,
6058 * restore it. This is useful when performing operations that could remove dom
6059 * nodes and place them back in, resulting in focus being lost.
6060 */
6061 restoreSelection: function(priorSelectionInformation) {
6062 var curFocusedElem = getActiveElement();
6063 var priorFocusedElem = priorSelectionInformation.focusedElem;
6064 var priorSelectionRange = priorSelectionInformation.selectionRange;
6065 if (curFocusedElem !== priorFocusedElem &&
6066 isInDocument(priorFocusedElem)) {
6067 if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
6068 ReactInputSelection.setSelection(
6069 priorFocusedElem,
6070 priorSelectionRange
6071 );
6072 }
6073 priorFocusedElem.focus();
6074 }
6075 },
6076
6077 /**
6078 * @getSelection: Gets the selection bounds of a textarea or input.
6079 * -@input: Look up selection bounds of this input or textarea
6080 * -@return {start: selectionStart, end: selectionEnd}
6081 */
6082 getSelection: function(input) {
6083 var range;
6084 if (input.contentEditable === 'true' && window.getSelection) {
6085 range = window.getSelection().getRangeAt(0);
6086 var commonAncestor = range.commonAncestorContainer;
6087 if (commonAncestor && commonAncestor.nodeType === 3) {
6088 commonAncestor = commonAncestor.parentNode;
6089 }
6090 if (commonAncestor !== input) {
6091 return {start: 0, end: 0};
6092 } else {
6093 return {start: range.startOffset, end: range.endOffset};
6094 }
6095 }
6096
6097 if (!document.selection) {
6098 // Mozilla, Safari, etc.
6099 return {start: input.selectionStart, end: input.selectionEnd};
6100 }
6101
6102 range = document.selection.createRange();
6103 if (range.parentElement() !== input) {
6104 // There can only be one selection per document in IE, so if the
6105 // containing element of the document's selection isn't our text field,
6106 // our text field must have no selection.
6107 return {start: 0, end: 0};
6108 }
6109
6110 var length = input.value.length;
6111
6112 if (input.nodeName === 'INPUT') {
6113 return {
6114 start: -range.moveStart('character', -length),
6115 end: -range.moveEnd('character', -length)
6116 };
6117 } else {
6118 var range2 = range.duplicate();
6119 range2.moveToElementText(input);
6120 range2.setEndPoint('StartToEnd', range);
6121 var end = length - range2.text.length;
6122 range2.setEndPoint('StartToStart', range);
6123 return {
6124 start: length - range2.text.length,
6125 end: end
6126 };
6127 }
6128 },
6129
6130 /**
6131 * @setSelection: Sets the selection bounds of a textarea or input and focuses
6132 * the input.
6133 * -@input Set selection bounds of this input or textarea
6134 * -@rangeObj Object of same form that is returned from get*
6135 */
6136 setSelection: function(input, rangeObj) {
6137 var range;
6138 var start = rangeObj.start;
6139 var end = rangeObj.end;
6140 if (typeof end === 'undefined') {
6141 end = start;
6142 }
6143 if (document.selection) {
6144 // IE is inconsistent about character offsets when it comes to carriage
6145 // returns, so we need to manually take them into account
6146 if (input.tagName === 'TEXTAREA') {
6147 var cr_before =
6148 (input.value.slice(0, start).match(/\r/g) || []).length;
6149 var cr_inside =
6150 (input.value.slice(start, end).match(/\r/g) || []).length;
6151 start -= cr_before;
6152 end -= cr_before + cr_inside;
6153 }
6154 range = input.createTextRange();
6155 range.collapse(true);
6156 range.moveStart('character', start);
6157 range.moveEnd('character', end - start);
6158 range.select();
6159 } else {
6160 if (input.contentEditable === 'true') {
6161 if (input.childNodes.length === 1) {
6162 range = document.createRange();
6163 range.setStart(input.childNodes[0], start);
6164 range.setEnd(input.childNodes[0], end);
6165 var sel = window.getSelection();
6166 sel.removeAllRanges();
6167 sel.addRange(range);
6168 }
6169 } else {
6170 input.selectionStart = start;
6171 input.selectionEnd = Math.min(end, input.value.length);
6172 input.focus();
6173 }
6174 }
6175 }
6176
6177};
6178
6179module.exports = ReactInputSelection;
6180
6181},{}],37:[function(require,module,exports){
6182/**
6183 * Copyright 2013 Facebook, Inc.
6184 *
6185 * Licensed under the Apache License, Version 2.0 (the "License");
6186 * you may not use this file except in compliance with the License.
6187 * You may obtain a copy of the License at
6188 *
6189 * http://www.apache.org/licenses/LICENSE-2.0
6190 *
6191 * Unless required by applicable law or agreed to in writing, software
6192 * distributed under the License is distributed on an "AS IS" BASIS,
6193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6194 * See the License for the specific language governing permissions and
6195 * limitations under the License.
6196 *
6197 * @providesModule ReactInstanceHandles
6198 * @typechecks static-only
6199 */
6200
6201"use strict";
6202
6203var invariant = require("./invariant");
6204
6205var SEPARATOR = '.';
6206var SEPARATOR_LENGTH = SEPARATOR.length;
6207
6208/**
6209 * Maximum depth of traversals before we consider the possibility of a bad ID.
6210 */
6211var MAX_TREE_DEPTH = 100;
6212
6213/**
6214 * Size of the reactRoot ID space. We generate random numbers for React root
6215 * IDs and if there's a collision the events and DOM update system will
6216 * get confused. If we assume 100 React components per page, and a user
6217 * loads 1 page per minute 24/7 for 50 years, with a mount point space of
6218 * 9,999,999 the likelihood of never having a collision is 99.997%.
6219 */
6220var GLOBAL_MOUNT_POINT_MAX = 9999999;
6221
6222/**
6223 * Creates a DOM ID prefix to use when mounting React components.
6224 *
6225 * @param {number} index A unique integer
6226 * @return {string} React root ID.
6227 * @internal
6228 */
6229function getReactRootIDString(index) {
6230 return SEPARATOR + 'r[' + index.toString(36) + ']';
6231}
6232
6233/**
6234 * Checks if a character in the supplied ID is a separator or the end.
6235 *
6236 * @param {string} id A React DOM ID.
6237 * @param {number} index Index of the character to check.
6238 * @return {boolean} True if the character is a separator or end of the ID.
6239 * @private
6240 */
6241function isBoundary(id, index) {
6242 return id.charAt(index) === SEPARATOR || index === id.length;
6243}
6244
6245/**
6246 * Checks if the supplied string is a valid React DOM ID.
6247 *
6248 * @param {string} id A React DOM ID, maybe.
6249 * @return {boolean} True if the string is a valid React DOM ID.
6250 * @private
6251 */
6252function isValidID(id) {
6253 return id === '' || (
6254 id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
6255 );
6256}
6257
6258/**
6259 * Checks if the first ID is an ancestor of or equal to the second ID.
6260 *
6261 * @param {string} ancestorID
6262 * @param {string} descendantID
6263 * @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
6264 * @internal
6265 */
6266function isAncestorIDOf(ancestorID, descendantID) {
6267 return (
6268 descendantID.indexOf(ancestorID) === 0 &&
6269 isBoundary(descendantID, ancestorID.length)
6270 );
6271}
6272
6273/**
6274 * Gets the parent ID of the supplied React DOM ID, `id`.
6275 *
6276 * @param {string} id ID of a component.
6277 * @return {string} ID of the parent, or an empty string.
6278 * @private
6279 */
6280function getParentID(id) {
6281 return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
6282}
6283
6284/**
6285 * Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
6286 * supplied `destinationID`. If they are equal, the ID is returned.
6287 *
6288 * @param {string} ancestorID ID of an ancestor node of `destinationID`.
6289 * @param {string} destinationID ID of the destination node.
6290 * @return {string} Next ID on the path from `ancestorID` to `destinationID`.
6291 * @private
6292 */
6293function getNextDescendantID(ancestorID, destinationID) {
6294 invariant(
6295 isValidID(ancestorID) && isValidID(destinationID),
6296 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
6297 ancestorID,
6298 destinationID
6299 );
6300 invariant(
6301 isAncestorIDOf(ancestorID, destinationID),
6302 'getNextDescendantID(...): React has made an invalid assumption about ' +
6303 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
6304 ancestorID,
6305 destinationID
6306 );
6307 if (ancestorID === destinationID) {
6308 return ancestorID;
6309 }
6310 // Skip over the ancestor and the immediate separator. Traverse until we hit
6311 // another separator or we reach the end of `destinationID`.
6312 var start = ancestorID.length + SEPARATOR_LENGTH;
6313 for (var i = start; i < destinationID.length; i++) {
6314 if (isBoundary(destinationID, i)) {
6315 break;
6316 }
6317 }
6318 return destinationID.substr(0, i);
6319}
6320
6321/**
6322 * Gets the nearest common ancestor ID of two IDs.
6323 *
6324 * Using this ID scheme, the nearest common ancestor ID is the longest common
6325 * prefix of the two IDs that immediately preceded a "marker" in both strings.
6326 *
6327 * @param {string} oneID
6328 * @param {string} twoID
6329 * @return {string} Nearest common ancestor ID, or the empty string if none.
6330 * @private
6331 */
6332function getFirstCommonAncestorID(oneID, twoID) {
6333 var minLength = Math.min(oneID.length, twoID.length);
6334 if (minLength === 0) {
6335 return '';
6336 }
6337 var lastCommonMarkerIndex = 0;
6338 // Use `<=` to traverse until the "EOL" of the shorter string.
6339 for (var i = 0; i <= minLength; i++) {
6340 if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
6341 lastCommonMarkerIndex = i;
6342 } else if (oneID.charAt(i) !== twoID.charAt(i)) {
6343 break;
6344 }
6345 }
6346 var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
6347 invariant(
6348 isValidID(longestCommonID),
6349 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
6350 oneID,
6351 twoID,
6352 longestCommonID
6353 );
6354 return longestCommonID;
6355}
6356
6357/**
6358 * Traverses the parent path between two IDs (either up or down). The IDs must
6359 * not be the same, and there must exist a parent path between them.
6360 *
6361 * @param {?string} start ID at which to start traversal.
6362 * @param {?string} stop ID at which to end traversal.
6363 * @param {function} cb Callback to invoke each ID with.
6364 * @param {?boolean} skipFirst Whether or not to skip the first node.
6365 * @param {?boolean} skipLast Whether or not to skip the last node.
6366 * @private
6367 */
6368function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
6369 start = start || '';
6370 stop = stop || '';
6371 invariant(
6372 start !== stop,
6373 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
6374 start
6375 );
6376 var traverseUp = isAncestorIDOf(stop, start);
6377 invariant(
6378 traverseUp || isAncestorIDOf(start, stop),
6379 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
6380 'not have a parent path.',
6381 start,
6382 stop
6383 );
6384 // Traverse from `start` to `stop` one depth at a time.
6385 var depth = 0;
6386 var traverse = traverseUp ? getParentID : getNextDescendantID;
6387 for (var id = start; /* until break */; id = traverse(id, stop)) {
6388 if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
6389 cb(id, traverseUp, arg);
6390 }
6391 if (id === stop) {
6392 // Only break //after// visiting `stop`.
6393 break;
6394 }
6395 invariant(
6396 depth++ < MAX_TREE_DEPTH,
6397 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
6398 'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
6399 start, stop
6400 );
6401 }
6402}
6403
6404/**
6405 * Manages the IDs assigned to DOM representations of React components. This
6406 * uses a specific scheme in order to traverse the DOM efficiently (e.g. in
6407 * order to simulate events).
6408 *
6409 * @internal
6410 */
6411var ReactInstanceHandles = {
6412
6413 separator: SEPARATOR,
6414
6415 createReactRootID: function() {
6416 return getReactRootIDString(
6417 Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX)
6418 );
6419 },
6420
6421 /**
6422 * Gets the DOM ID of the React component that is the root of the tree that
6423 * contains the React component with the supplied DOM ID.
6424 *
6425 * @param {string} id DOM ID of a React component.
6426 * @return {?string} DOM ID of the React component that is the root.
6427 * @internal
6428 */
6429 getReactRootIDFromNodeID: function(id) {
6430 var regexResult = /\.r\[[^\]]+\]/.exec(id);
6431 return regexResult && regexResult[0];
6432 },
6433
6434 /**
6435 * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
6436 * should would receive a `mouseEnter` or `mouseLeave` event.
6437 *
6438 * NOTE: Does not invoke the callback on the nearest common ancestor because
6439 * nothing "entered" or "left" that element.
6440 *
6441 * @param {string} leaveID ID being left.
6442 * @param {string} enterID ID being entered.
6443 * @param {function} cb Callback to invoke on each entered/left ID.
6444 * @param {*} upArg Argument to invoke the callback with on left IDs.
6445 * @param {*} downArg Argument to invoke the callback with on entered IDs.
6446 * @internal
6447 */
6448 traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
6449 var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
6450 if (ancestorID !== leaveID) {
6451 traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
6452 }
6453 if (ancestorID !== enterID) {
6454 traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
6455 }
6456 },
6457
6458 /**
6459 * Simulates the traversal of a two-phase, capture/bubble event dispatch.
6460 *
6461 * NOTE: This traversal happens on IDs without touching the DOM.
6462 *
6463 * @param {string} targetID ID of the target node.
6464 * @param {function} cb Callback to invoke.
6465 * @param {*} arg Argument to invoke the callback with.
6466 * @internal
6467 */
6468 traverseTwoPhase: function(targetID, cb, arg) {
6469 if (targetID) {
6470 traverseParentPath('', targetID, cb, arg, true, false);
6471 traverseParentPath(targetID, '', cb, arg, false, true);
6472 }
6473 },
6474
6475 /**
6476 * Exposed for unit testing.
6477 * @private
6478 */
6479 _getFirstCommonAncestorID: getFirstCommonAncestorID,
6480
6481 /**
6482 * Exposed for unit testing.
6483 * @private
6484 */
6485 _getNextDescendantID: getNextDescendantID,
6486
6487 isAncestorIDOf: isAncestorIDOf,
6488
6489 SEPARATOR: SEPARATOR
6490
6491};
6492
6493module.exports = ReactInstanceHandles;
6494
6495},{"./invariant":78}],38:[function(require,module,exports){
6496/**
6497 * Copyright 2013 Facebook, Inc.
6498 *
6499 * Licensed under the Apache License, Version 2.0 (the "License");
6500 * you may not use this file except in compliance with the License.
6501 * You may obtain a copy of the License at
6502 *
6503 * http://www.apache.org/licenses/LICENSE-2.0
6504 *
6505 * Unless required by applicable law or agreed to in writing, software
6506 * distributed under the License is distributed on an "AS IS" BASIS,
6507 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6508 * See the License for the specific language governing permissions and
6509 * limitations under the License.
6510 *
6511 * @providesModule ReactMarkupChecksum
6512 */
6513
6514"use strict";
6515
6516var adler32 = require("./adler32");
6517
6518var ReactMarkupChecksum = {
6519 CHECKSUM_ATTR_NAME: 'data-react-checksum',
6520
6521 /**
6522 * @param {string} markup Markup string
6523 * @return {string} Markup string with checksum attribute attached
6524 */
6525 addChecksumToMarkup: function(markup) {
6526 var checksum = adler32(markup);
6527 return markup.replace(
6528 '>',
6529 ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
6530 );
6531 },
6532
6533 /**
6534 * @param {string} markup to use
6535 * @param {DOMElement} element root React element
6536 * @returns {boolean} whether or not the markup is the same
6537 */
6538 canReuseMarkup: function(markup, element) {
6539 var existingChecksum = element.getAttribute(
6540 ReactMarkupChecksum.CHECKSUM_ATTR_NAME
6541 );
6542 existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
6543 var markupChecksum = adler32(markup);
6544 return markupChecksum === existingChecksum;
6545 }
6546};
6547
6548module.exports = ReactMarkupChecksum;
6549
6550},{"./adler32":62}],39:[function(require,module,exports){
6551(function(){/**
6552 * Copyright 2013 Facebook, Inc.
6553 *
6554 * Licensed under the Apache License, Version 2.0 (the "License");
6555 * you may not use this file except in compliance with the License.
6556 * You may obtain a copy of the License at
6557 *
6558 * http://www.apache.org/licenses/LICENSE-2.0
6559 *
6560 * Unless required by applicable law or agreed to in writing, software
6561 * distributed under the License is distributed on an "AS IS" BASIS,
6562 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6563 * See the License for the specific language governing permissions and
6564 * limitations under the License.
6565 *
6566 * @providesModule ReactMount
6567 */
6568
6569"use strict";
6570
6571var invariant = require("./invariant");
6572var getReactRootElementInContainer = require("./getReactRootElementInContainer");
6573var ReactEventEmitter = require("./ReactEventEmitter");
6574var ReactInstanceHandles = require("./ReactInstanceHandles");
6575
6576var SEPARATOR = ReactInstanceHandles.SEPARATOR;
6577
6578var ATTR_NAME = 'data-reactid';
6579var nodeCache = {};
6580
6581var $ = require("./$");
6582
6583/** Mapping from reactRootID to React component instance. */
6584var instanceByReactRootID = {};
6585
6586/** Mapping from reactRootID to `container` nodes. */
6587var containersByReactRootID = {};
6588
6589if (true) {
6590 /** __DEV__-only mapping from reactRootID to root elements. */
6591 var rootElementsByReactRootID = {};
6592}
6593
6594/**
6595 * @param {DOMElement} container DOM element that may contain a React component.
6596 * @return {?string} A "reactRoot" ID, if a React component is rendered.
6597 */
6598function getReactRootID(container) {
6599 var rootElement = getReactRootElementInContainer(container);
6600 return rootElement && ReactMount.getID(rootElement);
6601}
6602
6603/**
6604 * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
6605 * element can return its control whose name or ID equals ATTR_NAME. All
6606 * DOM nodes support `getAttributeNode` but this can also get called on
6607 * other objects so just return '' if we're given something other than a
6608 * DOM node (such as window).
6609 *
6610 * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
6611 * @return {string} ID of the supplied `domNode`.
6612 */
6613function getID(node) {
6614 var id = internalGetID(node);
6615 if (id) {
6616 if (nodeCache.hasOwnProperty(id)) {
6617 var cached = nodeCache[id];
6618 if (cached !== node) {
6619 invariant(
6620 !isValid(cached, id),
6621 'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
6622 ATTR_NAME, id
6623 );
6624
6625 nodeCache[id] = node;
6626 }
6627 } else {
6628 nodeCache[id] = node;
6629 }
6630 }
6631
6632 return id;
6633}
6634
6635function internalGetID(node) {
6636 // If node is something like a window, document, or text node, none of
6637 // which support attributes or a .getAttribute method, gracefully return
6638 // the empty string, as if the attribute were missing.
6639 return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
6640}
6641
6642/**
6643 * Sets the React-specific ID of the given node.
6644 *
6645 * @param {DOMElement} node The DOM node whose ID will be set.
6646 * @param {string} id The value of the ID attribute.
6647 */
6648function setID(node, id) {
6649 var oldID = internalGetID(node);
6650 if (oldID !== id) {
6651 delete nodeCache[oldID];
6652 }
6653 node.setAttribute(ATTR_NAME, id);
6654 nodeCache[id] = node;
6655}
6656
6657/**
6658 * Finds the node with the supplied React-generated DOM ID.
6659 *
6660 * @param {string} id A React-generated DOM ID.
6661 * @return {DOMElement} DOM node with the suppled `id`.
6662 * @internal
6663 */
6664function getNode(id) {
6665 if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
6666 nodeCache[id] = ReactMount.findReactNodeByID(id);
6667 }
6668 return nodeCache[id];
6669}
6670
6671/**
6672 * A node is "valid" if it is contained by a currently mounted container.
6673 *
6674 * This means that the node does not have to be contained by a document in
6675 * order to be considered valid.
6676 *
6677 * @param {?DOMElement} node The candidate DOM node.
6678 * @param {string} id The expected ID of the node.
6679 * @return {boolean} Whether the node is contained by a mounted container.
6680 */
6681function isValid(node, id) {
6682 if (node) {
6683 invariant(
6684 internalGetID(node) === id,
6685 'ReactMount: Unexpected modification of `%s`',
6686 ATTR_NAME
6687 );
6688
6689 var container = ReactMount.findReactContainerForID(id);
6690 if (container && contains(container, node)) {
6691 return true;
6692 }
6693 }
6694
6695 return false;
6696}
6697
6698function contains(ancestor, descendant) {
6699 if (ancestor.contains) {
6700 // Supported natively in virtually all browsers, but not in jsdom.
6701 return ancestor.contains(descendant);
6702 }
6703
6704 if (descendant === ancestor) {
6705 return true;
6706 }
6707
6708 if (descendant.nodeType === 3) {
6709 // If descendant is a text node, start from descendant.parentNode
6710 // instead, so that we can assume all ancestors worth considering are
6711 // element nodes with nodeType === 1.
6712 descendant = descendant.parentNode;
6713 }
6714
6715 while (descendant && descendant.nodeType === 1) {
6716 if (descendant === ancestor) {
6717 return true;
6718 }
6719 descendant = descendant.parentNode;
6720 }
6721
6722 return false;
6723}
6724
6725/**
6726 * Causes the cache to forget about one React-specific ID.
6727 *
6728 * @param {string} id The ID to forget.
6729 */
6730function purgeID(id) {
6731 delete nodeCache[id];
6732}
6733
6734/**
6735 * Mounting is the process of initializing a React component by creatings its
6736 * representative DOM elements and inserting them into a supplied `container`.
6737 * Any prior content inside `container` is destroyed in the process.
6738 *
6739 * ReactMount.renderComponent(component, $('container'));
6740 *
6741 * <div id="container"> <-- Supplied `container`.
6742 * <div data-reactid=".r[3]"> <-- Rendered reactRoot of React
6743 * // ... component.
6744 * </div>
6745 * </div>
6746 *
6747 * Inside of `container`, the first element rendered is the "reactRoot".
6748 */
6749var ReactMount = {
6750
6751 /** Time spent generating markup. */
6752 totalInstantiationTime: 0,
6753
6754 /** Time spent inserting markup into the DOM. */
6755 totalInjectionTime: 0,
6756
6757 /** Whether support for touch events should be initialized. */
6758 useTouchEvents: false,
6759
6760 /**
6761 * This is a hook provided to support rendering React components while
6762 * ensuring that the apparent scroll position of its `container` does not
6763 * change.
6764 *
6765 * @param {DOMElement} container The `container` being rendered into.
6766 * @param {function} renderCallback This must be called once to do the render.
6767 */
6768 scrollMonitor: function(container, renderCallback) {
6769 renderCallback();
6770 },
6771
6772 /**
6773 * Ensures that the top-level event delegation listener is set up. This will
6774 * be invoked some time before the first time any React component is rendered.
6775 *
6776 * @private
6777 */
6778 prepareTopLevelEvents: function() {
6779 ReactEventEmitter.ensureListening(ReactMount.useTouchEvents);
6780 },
6781
6782 /**
6783 * Take a component that's already mounted into the DOM and replace its props
6784 * @param {ReactComponent} prevComponent component instance already in the DOM
6785 * @param {ReactComponent} nextComponent component instance to render
6786 * @param {DOMElement} container container to render into
6787 * @param {?function} callback function triggered on completion
6788 */
6789 _updateRootComponent: function(
6790 prevComponent,
6791 nextComponent,
6792 container,
6793 callback) {
6794 var nextProps = nextComponent.props;
6795 ReactMount.scrollMonitor(container, function() {
6796 prevComponent.replaceProps(nextProps, callback);
6797 });
6798
6799 if (true) {
6800 // Record the root element in case it later gets transplanted.
6801 rootElementsByReactRootID[getReactRootID(container)] =
6802 getReactRootElementInContainer(container);
6803 }
6804
6805 return prevComponent;
6806 },
6807
6808 /**
6809 * Register a component into the instance map and start the events system.
6810 * @param {ReactComponent} nextComponent component instance to render
6811 * @param {DOMElement} container container to render into
6812 * @return {string} reactRoot ID prefix
6813 */
6814 _registerComponent: function(nextComponent, container) {
6815 ReactMount.prepareTopLevelEvents();
6816
6817 var reactRootID = ReactMount.registerContainer(container);
6818 instanceByReactRootID[reactRootID] = nextComponent;
6819 return reactRootID;
6820 },
6821
6822 /**
6823 * Render a new component into the DOM.
6824 * @param {ReactComponent} nextComponent component instance to render
6825 * @param {DOMElement} container container to render into
6826 * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
6827 * @return {ReactComponent} nextComponent
6828 */
6829 _renderNewRootComponent: function(
6830 nextComponent,
6831 container,
6832 shouldReuseMarkup) {
6833 var reactRootID = ReactMount._registerComponent(nextComponent, container);
6834 nextComponent.mountComponentIntoNode(
6835 reactRootID,
6836 container,
6837 shouldReuseMarkup
6838 );
6839
6840 if (true) {
6841 // Record the root element in case it later gets transplanted.
6842 rootElementsByReactRootID[reactRootID] =
6843 getReactRootElementInContainer(container);
6844 }
6845
6846 return nextComponent;
6847 },
6848
6849 /**
6850 * Renders a React component into the DOM in the supplied `container`.
6851 *
6852 * If the React component was previously rendered into `container`, this will
6853 * perform an update on it and only mutate the DOM as necessary to reflect the
6854 * latest React component.
6855 *
6856 * @param {ReactComponent} nextComponent Component instance to render.
6857 * @param {DOMElement} container DOM element to render into.
6858 * @param {?function} callback function triggered on completion
6859 * @return {ReactComponent} Component instance rendered in `container`.
6860 */
6861 renderComponent: function(nextComponent, container, callback) {
6862 var registeredComponent = instanceByReactRootID[getReactRootID(container)];
6863
6864 if (registeredComponent) {
6865 if (registeredComponent.constructor === nextComponent.constructor) {
6866 return ReactMount._updateRootComponent(
6867 registeredComponent,
6868 nextComponent,
6869 container,
6870 callback
6871 );
6872 } else {
6873 ReactMount.unmountAndReleaseReactRootNode(container);
6874 }
6875 }
6876
6877 var reactRootElement = getReactRootElementInContainer(container);
6878 var containerHasReactMarkup =
6879 reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
6880
6881 var shouldReuseMarkup = containerHasReactMarkup && !registeredComponent;
6882
6883 var component = ReactMount._renderNewRootComponent(
6884 nextComponent,
6885 container,
6886 shouldReuseMarkup
6887 );
6888 callback && callback();
6889 return component;
6890 },
6891
6892 /**
6893 * Constructs a component instance of `constructor` with `initialProps` and
6894 * renders it into the supplied `container`.
6895 *
6896 * @param {function} constructor React component constructor.
6897 * @param {?object} props Initial props of the component instance.
6898 * @param {DOMElement} container DOM element to render into.
6899 * @return {ReactComponent} Component instance rendered in `container`.
6900 */
6901 constructAndRenderComponent: function(constructor, props, container) {
6902 return ReactMount.renderComponent(constructor(props), container);
6903 },
6904
6905 /**
6906 * Constructs a component instance of `constructor` with `initialProps` and
6907 * renders it into a container node identified by supplied `id`.
6908 *
6909 * @param {function} componentConstructor React component constructor
6910 * @param {?object} props Initial props of the component instance.
6911 * @param {string} id ID of the DOM element to render into.
6912 * @return {ReactComponent} Component instance rendered in the container node.
6913 */
6914 constructAndRenderComponentByID: function(constructor, props, id) {
6915 return ReactMount.constructAndRenderComponent(constructor, props, $(id));
6916 },
6917
6918 /**
6919 * Registers a container node into which React components will be rendered.
6920 * This also creates the "reatRoot" ID that will be assigned to the element
6921 * rendered within.
6922 *
6923 * @param {DOMElement} container DOM element to register as a container.
6924 * @return {string} The "reactRoot" ID of elements rendered within.
6925 */
6926 registerContainer: function(container) {
6927 var reactRootID = getReactRootID(container);
6928 if (reactRootID) {
6929 // If one exists, make sure it is a valid "reactRoot" ID.
6930 reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
6931 }
6932 if (!reactRootID) {
6933 // No valid "reactRoot" ID found, create one.
6934 reactRootID = ReactInstanceHandles.createReactRootID();
6935 }
6936 containersByReactRootID[reactRootID] = container;
6937 return reactRootID;
6938 },
6939
6940 /**
6941 * Unmounts and destroys the React component rendered in the `container`.
6942 *
6943 * @param {DOMElement} container DOM element containing a React component.
6944 * @return {boolean} True if a component was found in and unmounted from
6945 * `container`
6946 */
6947 unmountAndReleaseReactRootNode: function(container) {
6948 var reactRootID = getReactRootID(container);
6949 var component = instanceByReactRootID[reactRootID];
6950 if (!component) {
6951 return false;
6952 }
6953 component.unmountComponentFromNode(container);
6954 delete instanceByReactRootID[reactRootID];
6955 delete containersByReactRootID[reactRootID];
6956 if (true) {
6957 delete rootElementsByReactRootID[reactRootID];
6958 }
6959 return true;
6960 },
6961
6962 /**
6963 * Finds the container DOM element that contains React component to which the
6964 * supplied DOM `id` belongs.
6965 *
6966 * @param {string} id The ID of an element rendered by a React component.
6967 * @return {?DOMElement} DOM element that contains the `id`.
6968 */
6969 findReactContainerForID: function(id) {
6970 var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
6971 var container = containersByReactRootID[reactRootID];
6972
6973 if (true) {
6974 var rootElement = rootElementsByReactRootID[reactRootID];
6975 if (rootElement && rootElement.parentNode !== container) {
6976 invariant(
6977 // Call internalGetID here because getID calls isValid which calls
6978 // findReactContainerForID (this function).
6979 internalGetID(rootElement) === reactRootID,
6980 'ReactMount: Root element ID differed from reactRootID.'
6981 );
6982
6983 var containerChild = container.firstChild;
6984 if (containerChild &&
6985 reactRootID === internalGetID(containerChild)) {
6986 // If the container has a new child with the same ID as the old
6987 // root element, then rootElementsByReactRootID[reactRootID] is
6988 // just stale and needs to be updated. The case that deserves a
6989 // warning is when the container is empty.
6990 rootElementsByReactRootID[reactRootID] = containerChild;
6991 } else {
6992 console.warn(
6993 'ReactMount: Root element has been removed from its original ' +
6994 'container. New container:', rootElement.parentNode
6995 );
6996 }
6997 }
6998 }
6999
7000 return container;
7001 },
7002
7003 /**
7004 * Finds an element rendered by React with the supplied ID.
7005 *
7006 * @param {string} id ID of a DOM node in the React component.
7007 * @return {DOMElement} Root DOM node of the React component.
7008 */
7009 findReactNodeByID: function(id) {
7010 var reactRoot = ReactMount.findReactContainerForID(id);
7011 return ReactMount.findComponentRoot(reactRoot, id);
7012 },
7013
7014 /**
7015 * True if the supplied `node` is rendered by React.
7016 *
7017 * @param {*} node DOM Element to check.
7018 * @return {boolean} True if the DOM Element appears to be rendered by React.
7019 * @internal
7020 */
7021 isRenderedByReact: function(node) {
7022 if (node.nodeType !== 1) {
7023 // Not a DOMElement, therefore not a React component
7024 return false;
7025 }
7026 var id = ReactMount.getID(node);
7027 return id ? id.charAt(0) === SEPARATOR : false;
7028 },
7029
7030 /**
7031 * Traverses up the ancestors of the supplied node to find a node that is a
7032 * DOM representation of a React component.
7033 *
7034 * @param {*} node
7035 * @return {?DOMEventTarget}
7036 * @internal
7037 */
7038 getFirstReactDOM: function(node) {
7039 var current = node;
7040 while (current && current.parentNode !== current) {
7041 if (ReactMount.isRenderedByReact(current)) {
7042 return current;
7043 }
7044 current = current.parentNode;
7045 }
7046 return null;
7047 },
7048
7049 /**
7050 * Finds a node with the supplied `id` inside of the supplied `ancestorNode`.
7051 * Exploits the ID naming scheme to perform the search quickly.
7052 *
7053 * @param {DOMEventTarget} ancestorNode Search from this root.
7054 * @pararm {string} id ID of the DOM representation of the component.
7055 * @return {DOMEventTarget} DOM node with the supplied `id`.
7056 * @internal
7057 */
7058 findComponentRoot: function(ancestorNode, id) {
7059 var firstChildren = [ancestorNode.firstChild];
7060 var childIndex = 0;
7061
7062 while (childIndex < firstChildren.length) {
7063 var child = firstChildren[childIndex++];
7064 while (child) {
7065 var childID = ReactMount.getID(child);
7066 if (childID) {
7067 if (id === childID) {
7068 return child;
7069 } else if (ReactInstanceHandles.isAncestorIDOf(childID, id)) {
7070 // If we find a child whose ID is an ancestor of the given ID,
7071 // then we can be sure that we only want to search the subtree
7072 // rooted at this child, so we can throw out the rest of the
7073 // search state.
7074 firstChildren.length = childIndex = 0;
7075 firstChildren.push(child.firstChild);
7076 break;
7077 } else {
7078 // TODO This should not be necessary if the ID hierarchy is
7079 // correct, but is occasionally necessary if the DOM has been
7080 // modified in unexpected ways.
7081 firstChildren.push(child.firstChild);
7082 }
7083 } else {
7084 // If this child had no ID, then there's a chance that it was
7085 // injected automatically by the browser, as when a `<table>`
7086 // element sprouts an extra `<tbody>` child as a side effect of
7087 // `.innerHTML` parsing. Optimistically continue down this
7088 // branch, but not before examining the other siblings.
7089 firstChildren.push(child.firstChild);
7090 }
7091 child = child.nextSibling;
7092 }
7093 }
7094
7095 if (true) {
7096 console.error(
7097 'Error while invoking `findComponentRoot` with the following ' +
7098 'ancestor node:',
7099 ancestorNode
7100 );
7101 }
7102 invariant(
7103 false,
7104 'findComponentRoot(..., %s): Unable to find element. This probably ' +
7105 'means the DOM was unexpectedly mutated (e.g. by the browser).',
7106 id,
7107 ReactMount.getID(ancestorNode)
7108 );
7109 },
7110
7111
7112 /**
7113 * React ID utilities.
7114 */
7115
7116 ATTR_NAME: ATTR_NAME,
7117
7118 getID: getID,
7119
7120 setID: setID,
7121
7122 getNode: getNode,
7123
7124 purgeID: purgeID,
7125
7126 injection: {}
7127};
7128
7129module.exports = ReactMount;
7130
7131})()
7132},{"./$":1,"./ReactEventEmitter":34,"./ReactInstanceHandles":37,"./getReactRootElementInContainer":73,"./invariant":78}],40:[function(require,module,exports){
7133(function(){/**
7134 * Copyright 2013 Facebook, Inc.
7135 *
7136 * Licensed under the Apache License, Version 2.0 (the "License");
7137 * you may not use this file except in compliance with the License.
7138 * You may obtain a copy of the License at
7139 *
7140 * http://www.apache.org/licenses/LICENSE-2.0
7141 *
7142 * Unless required by applicable law or agreed to in writing, software
7143 * distributed under the License is distributed on an "AS IS" BASIS,
7144 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7145 * See the License for the specific language governing permissions and
7146 * limitations under the License.
7147 *
7148 * @providesModule ReactMultiChild
7149 */
7150
7151"use strict";
7152
7153var ReactComponent = require("./ReactComponent");
7154
7155/**
7156 * Given a `curChild` and `newChild`, determines if `curChild` should be managed
7157 * as it exists, as opposed to being destroyed and/or replaced.
7158 * @param {?ReactComponent} curChild
7159 * @param {?ReactComponent} newChild
7160 * @return {!boolean} Whether or not `curChild` should be updated with
7161 * `newChild`'s props
7162 */
7163function shouldManageExisting(curChild, newChild) {
7164 return curChild && newChild && curChild.constructor === newChild.constructor;
7165}
7166
7167/**
7168 * `ReactMultiChild` provides common functionality for components that have
7169 * multiple children. Standard `ReactCompositeComponent`s do not currently have
7170 * multiple children. `ReactNativeComponent`s do, however. Other specially
7171 * reconciled components will also have multiple children. Contains three
7172 * internally used properties that are used to keep track of state throughout
7173 * the `updateMultiChild` process.
7174 *
7175 * @class ReactMultiChild
7176 */
7177
7178/**
7179 * @lends `ReactMultiChildMixin`.
7180 */
7181var ReactMultiChildMixin = {
7182
7183 enqueueMarkupAt: function(markup, insertAt) {
7184 this.domOperations = this.domOperations || [];
7185 this.domOperations.push({insertMarkup: markup, finalIndex: insertAt});
7186 },
7187
7188 enqueueMove: function(originalIndex, finalIndex) {
7189 this.domOperations = this.domOperations || [];
7190 this.domOperations.push({moveFrom: originalIndex, finalIndex: finalIndex});
7191 },
7192
7193 enqueueUnmountChildByName: function(name, removeChild) {
7194 if (ReactComponent.isValidComponent(removeChild)) {
7195 this.domOperations = this.domOperations || [];
7196 this.domOperations.push({removeAt: removeChild._domIndex});
7197 removeChild.unmountComponent && removeChild.unmountComponent();
7198 delete this._renderedChildren[name];
7199 }
7200 },
7201
7202 /**
7203 * Process any pending DOM operations that have been accumulated when updating
7204 * the UI. By default, we execute the injected `DOMIDOperations` module's
7205 * `manageChildrenByParentID` which does executes the DOM operations without
7206 * any animation. It can be used as a reference implementation for special
7207 * animation based implementations.
7208 *
7209 * @abstract
7210 */
7211 processChildDOMOperationsQueue: function() {
7212 if (this.domOperations) {
7213 ReactComponent.DOMIDOperations
7214 .manageChildrenByParentID(this._rootNodeID, this.domOperations);
7215 this.domOperations = null;
7216 }
7217 },
7218
7219 unmountMultiChild: function() {
7220 var renderedChildren = this._renderedChildren;
7221 for (var name in renderedChildren) {
7222 if (renderedChildren.hasOwnProperty(name) && renderedChildren[name]) {
7223 var renderedChild = renderedChildren[name];
7224 renderedChild.unmountComponent && renderedChild.unmountComponent();
7225 }
7226 }
7227 this._renderedChildren = null;
7228 },
7229
7230 /**
7231 * Generates markup for a component that holds multiple children. #todo: Allow
7232 * all `ReactMultiChildMixin`s to support having arrays of children without a
7233 * container node. This current implementation may assume that children exist
7234 * at domIndices [0, parentNode.length].
7235 *
7236 * Has side effects of (likely) causing events to be registered. Also, every
7237 * component instance may only be rendered once.
7238 *
7239 * @param {?Object} children Flattened children object.
7240 * @return {!String} The rendered markup.
7241 */
7242 mountMultiChild: function(children, transaction) {
7243 var accum = '';
7244 var index = 0;
7245 for (var name in children) {
7246 var child = children[name];
7247 if (children.hasOwnProperty(name) && child) {
7248 accum += child.mountComponent(
7249 this._rootNodeID + '.' + name,
7250 transaction
7251 );
7252 child._domIndex = index;
7253 index++;
7254 }
7255 }
7256 this._renderedChildren = children; // children are in just the right form!
7257 this.domOperations = null;
7258 return accum;
7259 },
7260
7261 /**
7262 * Reconciles new children with old children in three phases.
7263 *
7264 * - Adds new content while updating existing children that should remain.
7265 * - Remove children that are no longer present in the next children.
7266 * - As a very last step, moves existing dom structures around.
7267 * - (Comment 1) `curChildrenDOMIndex` is the largest index of the current
7268 * rendered children that appears in the next children and did not need to
7269 * be "moved".
7270 * - (Comment 2) This is the key insight. If any non-removed child's previous
7271 * index is less than `curChildrenDOMIndex` it must be moved.
7272 *
7273 * @param {?Object} children Flattened children object.
7274 */
7275 updateMultiChild: function(nextChildren, transaction) {
7276 if (!nextChildren && !this._renderedChildren) {
7277 return;
7278 } else if (nextChildren && !this._renderedChildren) {
7279 this._renderedChildren = {}; // lazily allocate backing store with nothing
7280 } else if (!nextChildren && this._renderedChildren) {
7281 nextChildren = {};
7282 }
7283 var rootDomIdDot = this._rootNodeID + '.';
7284 var markupBuffer = null; // Accumulate adjacent new children markup.
7285 var numPendingInsert = 0; // How many root nodes are waiting in markupBuffer
7286 var loopDomIndex = 0; // Index of loop through new children.
7287 var curChildrenDOMIndex = 0; // See (Comment 1)
7288 for (var name in nextChildren) {
7289 if (!nextChildren.hasOwnProperty(name)) {continue;}
7290 var curChild = this._renderedChildren[name];
7291 var nextChild = nextChildren[name];
7292 if (shouldManageExisting(curChild, nextChild)) {
7293 if (markupBuffer) {
7294 this.enqueueMarkupAt(markupBuffer, loopDomIndex - numPendingInsert);
7295 markupBuffer = null;
7296 }
7297 numPendingInsert = 0;
7298 if (curChild._domIndex < curChildrenDOMIndex) { // (Comment 2)
7299 this.enqueueMove(curChild._domIndex, loopDomIndex);
7300 }
7301 curChildrenDOMIndex = Math.max(curChild._domIndex, curChildrenDOMIndex);
7302 curChild.receiveProps(nextChild.props, transaction);
7303 curChild._domIndex = loopDomIndex;
7304 } else {
7305 if (curChild) { // !shouldUpdate && curChild => delete
7306 this.enqueueUnmountChildByName(name, curChild);
7307 curChildrenDOMIndex =
7308 Math.max(curChild._domIndex, curChildrenDOMIndex);
7309 }
7310 if (nextChild) { // !shouldUpdate && nextChild => insert
7311 this._renderedChildren[name] = nextChild;
7312 var nextMarkup =
7313 nextChild.mountComponent(rootDomIdDot + name, transaction);
7314 markupBuffer = markupBuffer ? markupBuffer + nextMarkup : nextMarkup;
7315 numPendingInsert++;
7316 nextChild._domIndex = loopDomIndex;
7317 }
7318 }
7319 loopDomIndex = nextChild ? loopDomIndex + 1 : loopDomIndex;
7320 }
7321 if (markupBuffer) {
7322 this.enqueueMarkupAt(markupBuffer, loopDomIndex - numPendingInsert);
7323 }
7324 for (var childName in this._renderedChildren) { // from other direction
7325 if (!this._renderedChildren.hasOwnProperty(childName)) { continue; }
7326 var child = this._renderedChildren[childName];
7327 if (child && !nextChildren[childName]) {
7328 this.enqueueUnmountChildByName(childName, child);
7329 }
7330 }
7331 this.processChildDOMOperationsQueue();
7332 }
7333};
7334
7335var ReactMultiChild = {
7336 Mixin: ReactMultiChildMixin
7337};
7338
7339module.exports = ReactMultiChild;
7340
7341})()
7342},{"./ReactComponent":23}],41:[function(require,module,exports){
7343/**
7344 * Copyright 2013 Facebook, Inc.
7345 *
7346 * Licensed under the Apache License, Version 2.0 (the "License");
7347 * you may not use this file except in compliance with the License.
7348 * You may obtain a copy of the License at
7349 *
7350 * http://www.apache.org/licenses/LICENSE-2.0
7351 *
7352 * Unless required by applicable law or agreed to in writing, software
7353 * distributed under the License is distributed on an "AS IS" BASIS,
7354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7355 * See the License for the specific language governing permissions and
7356 * limitations under the License.
7357 *
7358 * @providesModule ReactNativeComponent
7359 * @typechecks static-only
7360 */
7361
7362"use strict";
7363
7364var CSSPropertyOperations = require("./CSSPropertyOperations");
7365var DOMProperty = require("./DOMProperty");
7366var DOMPropertyOperations = require("./DOMPropertyOperations");
7367var ReactComponent = require("./ReactComponent");
7368var ReactEventEmitter = require("./ReactEventEmitter");
7369var ReactMultiChild = require("./ReactMultiChild");
7370var ReactMount = require("./ReactMount");
7371
7372var escapeTextForBrowser = require("./escapeTextForBrowser");
7373var flattenChildren = require("./flattenChildren");
7374var invariant = require("./invariant");
7375var keyOf = require("./keyOf");
7376var merge = require("./merge");
7377var mixInto = require("./mixInto");
7378
7379var putListener = ReactEventEmitter.putListener;
7380var deleteListener = ReactEventEmitter.deleteListener;
7381var registrationNames = ReactEventEmitter.registrationNames;
7382
7383// For quickly matching children type, to test if can be treated as content.
7384var CONTENT_TYPES = {'string': true, 'number': true};
7385
7386var DANGEROUSLY_SET_INNER_HTML = keyOf({dangerouslySetInnerHTML: null});
7387var STYLE = keyOf({style: null});
7388
7389/**
7390 * @param {?object} props
7391 */
7392function assertValidProps(props) {
7393 if (!props) {
7394 return;
7395 }
7396 // Note the use of `==` which checks for null or undefined.
7397 invariant(
7398 props.children == null || props.dangerouslySetInnerHTML == null,
7399 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
7400 );
7401 invariant(
7402 props.style == null || typeof props.style === 'object',
7403 'The `style` prop expects a mapping from style properties to values, ' +
7404 'not a string.'
7405 );
7406}
7407
7408/**
7409 * @constructor ReactNativeComponent
7410 * @extends ReactComponent
7411 * @extends ReactMultiChild
7412 */
7413function ReactNativeComponent(tag, omitClose) {
7414 this._tagOpen = '<' + tag;
7415 this._tagClose = omitClose ? '' : '</' + tag + '>';
7416 this.tagName = tag.toUpperCase();
7417}
7418
7419ReactNativeComponent.Mixin = {
7420
7421 /**
7422 * Generates root tag markup then recurses. This method has side effects and
7423 * is not idempotent.
7424 *
7425 * @internal
7426 * @param {string} rootID The root DOM ID for this node.
7427 * @param {ReactReconcileTransaction} transaction
7428 * @return {string} The computed markup.
7429 */
7430 mountComponent: function(rootID, transaction) {
7431 ReactComponent.Mixin.mountComponent.call(this, rootID, transaction);
7432 assertValidProps(this.props);
7433 return (
7434 this._createOpenTagMarkup() +
7435 this._createContentMarkup(transaction) +
7436 this._tagClose
7437 );
7438 },
7439
7440 /**
7441 * Creates markup for the open tag and all attributes.
7442 *
7443 * This method has side effects because events get registered.
7444 *
7445 * Iterating over object properties is faster than iterating over arrays.
7446 * @see http://jsperf.com/obj-vs-arr-iteration
7447 *
7448 * @private
7449 * @return {string} Markup of opening tag.
7450 */
7451 _createOpenTagMarkup: function() {
7452 var props = this.props;
7453 var ret = this._tagOpen;
7454
7455 for (var propKey in props) {
7456 if (!props.hasOwnProperty(propKey)) {
7457 continue;
7458 }
7459 var propValue = props[propKey];
7460 if (propValue == null) {
7461 continue;
7462 }
7463 if (registrationNames[propKey]) {
7464 putListener(this._rootNodeID, propKey, propValue);
7465 } else {
7466 if (propKey === STYLE) {
7467 if (propValue) {
7468 propValue = props.style = merge(props.style);
7469 }
7470 propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
7471 }
7472 var markup =
7473 DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
7474 if (markup) {
7475 ret += ' ' + markup;
7476 }
7477 }
7478 }
7479
7480 var escapedID = escapeTextForBrowser(this._rootNodeID);
7481 return ret + ' ' + ReactMount.ATTR_NAME + '="' + escapedID + '">';
7482 },
7483
7484 /**
7485 * Creates markup for the content between the tags.
7486 *
7487 * @private
7488 * @param {ReactReconcileTransaction} transaction
7489 * @return {string} Content markup.
7490 */
7491 _createContentMarkup: function(transaction) {
7492 // Intentional use of != to avoid catching zero/false.
7493 var innerHTML = this.props.dangerouslySetInnerHTML;
7494 if (innerHTML != null) {
7495 if (innerHTML.__html != null) {
7496 return innerHTML.__html;
7497 }
7498 } else {
7499 var contentToUse =
7500 CONTENT_TYPES[typeof this.props.children] ? this.props.children : null;
7501 var childrenToUse = contentToUse != null ? null : this.props.children;
7502 if (contentToUse != null) {
7503 return escapeTextForBrowser(contentToUse);
7504 } else if (childrenToUse != null) {
7505 return this.mountMultiChild(
7506 flattenChildren(childrenToUse),
7507 transaction
7508 );
7509 }
7510 }
7511 return '';
7512 },
7513
7514 receiveProps: function(nextProps, transaction) {
7515 assertValidProps(nextProps);
7516 ReactComponent.Mixin.receiveProps.call(this, nextProps, transaction);
7517 },
7518
7519 /**
7520 * Updates a native DOM component after it has already been allocated and
7521 * attached to the DOM. Reconciles the root DOM node, then recurses.
7522 *
7523 * @param {ReactReconcileTransaction} transaction
7524 * @param {object} prevProps
7525 * @internal
7526 * @overridable
7527 */
7528 updateComponent: function(transaction, prevProps) {
7529 ReactComponent.Mixin.updateComponent.call(this, transaction, prevProps);
7530 this._updateDOMProperties(prevProps);
7531 this._updateDOMChildren(prevProps, transaction);
7532 },
7533
7534 /**
7535 * Reconciles the properties by detecting differences in property values and
7536 * updating the DOM as necessary. This function is probably the single most
7537 * critical path for performance optimization.
7538 *
7539 * TODO: Benchmark whether checking for changed values in memory actually
7540 * improves performance (especially statically positioned elements).
7541 * TODO: Benchmark the effects of putting this at the top since 99% of props
7542 * do not change for a given reconciliation.
7543 * TODO: Benchmark areas that can be improved with caching.
7544 *
7545 * @private
7546 * @param {object} lastProps
7547 */
7548 _updateDOMProperties: function(lastProps) {
7549 var nextProps = this.props;
7550 var propKey;
7551 var styleName;
7552 var styleUpdates;
7553 for (propKey in lastProps) {
7554 if (nextProps.hasOwnProperty(propKey) ||
7555 !lastProps.hasOwnProperty(propKey)) {
7556 continue;
7557 }
7558 if (propKey === STYLE) {
7559 var lastStyle = lastProps[propKey];
7560 for (styleName in lastStyle) {
7561 if (lastStyle.hasOwnProperty(styleName)) {
7562 styleUpdates = styleUpdates || {};
7563 styleUpdates[styleName] = '';
7564 }
7565 }
7566 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
7567 // http://jsperf.com/emptying-speed
7568 ReactComponent.DOMIDOperations.updateTextContentByID(
7569 this._rootNodeID,
7570 ''
7571 );
7572 } else if (registrationNames[propKey]) {
7573 deleteListener(this._rootNodeID, propKey);
7574 } else {
7575 ReactComponent.DOMIDOperations.deletePropertyByID(
7576 this._rootNodeID,
7577 propKey
7578 );
7579 }
7580 }
7581 for (propKey in nextProps) {
7582 var nextProp = nextProps[propKey];
7583 var lastProp = lastProps[propKey];
7584 if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
7585 continue;
7586 }
7587 if (propKey === STYLE) {
7588 if (nextProp) {
7589 nextProp = nextProps.style = merge(nextProp);
7590 }
7591 if (lastProp) {
7592 // Unset styles on `lastProp` but not on `nextProp`.
7593 for (styleName in lastProp) {
7594 if (lastProp.hasOwnProperty(styleName) &&
7595 !nextProp.hasOwnProperty(styleName)) {
7596 styleUpdates = styleUpdates || {};
7597 styleUpdates[styleName] = '';
7598 }
7599 }
7600 // Update styles that changed since `lastProp`.
7601 for (styleName in nextProp) {
7602 if (nextProp.hasOwnProperty(styleName) &&
7603 lastProp[styleName] !== nextProp[styleName]) {
7604 styleUpdates = styleUpdates || {};
7605 styleUpdates[styleName] = nextProp[styleName];
7606 }
7607 }
7608 } else {
7609 // Relies on `updateStylesByID` not mutating `styleUpdates`.
7610 styleUpdates = nextProp;
7611 }
7612 } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
7613 var lastHtml = lastProp && lastProp.__html;
7614 var nextHtml = nextProp && nextProp.__html;
7615 if (lastHtml !== nextHtml) {
7616 ReactComponent.DOMIDOperations.updateInnerHTMLByID(
7617 this._rootNodeID,
7618 nextProp
7619 );
7620 }
7621 } else if (registrationNames[propKey]) {
7622 putListener(this._rootNodeID, propKey, nextProp);
7623 } else if (
7624 DOMProperty.isStandardName[propKey] ||
7625 DOMProperty.isCustomAttribute(propKey)) {
7626 ReactComponent.DOMIDOperations.updatePropertyByID(
7627 this._rootNodeID,
7628 propKey,
7629 nextProp
7630 );
7631 }
7632 }
7633 if (styleUpdates) {
7634 ReactComponent.DOMIDOperations.updateStylesByID(
7635 this._rootNodeID,
7636 styleUpdates
7637 );
7638 }
7639 },
7640
7641 /**
7642 * Reconciles the children with the various properties that affect the
7643 * children content.
7644 *
7645 * @param {object} lastProps
7646 * @param {ReactReconcileTransaction} transaction
7647 */
7648 _updateDOMChildren: function(lastProps, transaction) {
7649 var nextProps = this.props;
7650
7651 var lastUsedContent =
7652 CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
7653 var contentToUse =
7654 CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
7655
7656 // Note the use of `!=` which checks for null or undefined.
7657
7658 var lastUsedChildren =
7659 lastUsedContent != null ? null : lastProps.children;
7660 var childrenToUse = contentToUse != null ? null : nextProps.children;
7661
7662 if (contentToUse != null) {
7663 var childrenRemoved = lastUsedChildren != null && childrenToUse == null;
7664 if (childrenRemoved) {
7665 this.updateMultiChild(null, transaction);
7666 }
7667 if (lastUsedContent !== contentToUse) {
7668 ReactComponent.DOMIDOperations.updateTextContentByID(
7669 this._rootNodeID,
7670 '' + contentToUse
7671 );
7672 }
7673 } else {
7674 var contentRemoved = lastUsedContent != null && contentToUse == null;
7675 if (contentRemoved) {
7676 ReactComponent.DOMIDOperations.updateTextContentByID(
7677 this._rootNodeID,
7678 ''
7679 );
7680 }
7681 this.updateMultiChild(flattenChildren(nextProps.children), transaction);
7682 }
7683 },
7684
7685 /**
7686 * Destroys all event registrations for this instance. Does not remove from
7687 * the DOM. That must be done by the parent.
7688 *
7689 * @internal
7690 */
7691 unmountComponent: function() {
7692 ReactEventEmitter.deleteAllListeners(this._rootNodeID);
7693 ReactComponent.Mixin.unmountComponent.call(this);
7694 this.unmountMultiChild();
7695 }
7696
7697};
7698
7699mixInto(ReactNativeComponent, ReactComponent.Mixin);
7700mixInto(ReactNativeComponent, ReactNativeComponent.Mixin);
7701mixInto(ReactNativeComponent, ReactMultiChild.Mixin);
7702
7703module.exports = ReactNativeComponent;
7704
7705},{"./CSSPropertyOperations":3,"./DOMProperty":7,"./DOMPropertyOperations":8,"./ReactComponent":23,"./ReactEventEmitter":34,"./ReactMount":39,"./ReactMultiChild":40,"./escapeTextForBrowser":67,"./flattenChildren":69,"./invariant":78,"./keyOf":82,"./merge":84,"./mixInto":87}],42:[function(require,module,exports){
7706/**
7707 * Copyright 2013 Facebook, Inc.
7708 *
7709 * Licensed under the Apache License, Version 2.0 (the "License");
7710 * you may not use this file except in compliance with the License.
7711 * You may obtain a copy of the License at
7712 *
7713 * http://www.apache.org/licenses/LICENSE-2.0
7714 *
7715 * Unless required by applicable law or agreed to in writing, software
7716 * distributed under the License is distributed on an "AS IS" BASIS,
7717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7718 * See the License for the specific language governing permissions and
7719 * limitations under the License.
7720 *
7721 * @providesModule ReactOnDOMReady
7722 */
7723
7724"use strict";
7725
7726var PooledClass = require("./PooledClass");
7727
7728var mixInto = require("./mixInto");
7729
7730/**
7731 * A specialized pseudo-event module to help keep track of components waiting to
7732 * be notified when their DOM representations are available for use.
7733 *
7734 * This implements `PooledClass`, so you should never need to instantiate this.
7735 * Instead, use `ReactOnDOMReady.getPooled()`.
7736 *
7737 * @param {?array<function>} initialCollection
7738 * @class ReactOnDOMReady
7739 * @implements PooledClass
7740 * @internal
7741 */
7742function ReactOnDOMReady(initialCollection) {
7743 this._queue = initialCollection || null;
7744}
7745
7746mixInto(ReactOnDOMReady, {
7747
7748 /**
7749 * Enqueues a callback to be invoked when `notifyAll` is invoked. This is used
7750 * to enqueue calls to `componentDidMount` and `componentDidUpdate`.
7751 *
7752 * @param {ReactComponent} component Component being rendered.
7753 * @param {function(DOMElement)} callback Invoked when `notifyAll` is invoked.
7754 * @internal
7755 */
7756 enqueue: function(component, callback) {
7757 this._queue = this._queue || [];
7758 this._queue.push({component: component, callback: callback});
7759 },
7760
7761 /**
7762 * Invokes all enqueued callbacks and clears the queue. This is invoked after
7763 * the DOM representation of a component has been created or updated.
7764 *
7765 * @internal
7766 */
7767 notifyAll: function() {
7768 var queue = this._queue;
7769 if (queue) {
7770 this._queue = null;
7771 for (var i = 0, l = queue.length; i < l; i++) {
7772 var component = queue[i].component;
7773 var callback = queue[i].callback;
7774 callback.call(component, component.getDOMNode());
7775 }
7776 queue.length = 0;
7777 }
7778 },
7779
7780 /**
7781 * Resets the internal queue.
7782 *
7783 * @internal
7784 */
7785 reset: function() {
7786 this._queue = null;
7787 },
7788
7789 /**
7790 * `PooledClass` looks for this.
7791 */
7792 destructor: function() {
7793 this.reset();
7794 }
7795
7796});
7797
7798PooledClass.addPoolingTo(ReactOnDOMReady);
7799
7800module.exports = ReactOnDOMReady;
7801
7802},{"./PooledClass":21,"./mixInto":87}],43:[function(require,module,exports){
7803/**
7804 * Copyright 2013 Facebook, Inc.
7805 *
7806 * Licensed under the Apache License, Version 2.0 (the "License");
7807 * you may not use this file except in compliance with the License.
7808 * You may obtain a copy of the License at
7809 *
7810 * http://www.apache.org/licenses/LICENSE-2.0
7811 *
7812 * Unless required by applicable law or agreed to in writing, software
7813 * distributed under the License is distributed on an "AS IS" BASIS,
7814 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7815 * See the License for the specific language governing permissions and
7816 * limitations under the License.
7817 *
7818 * @providesModule ReactOwner
7819 */
7820
7821"use strict";
7822
7823var invariant = require("./invariant");
7824
7825/**
7826 * ReactOwners are capable of storing references to owned components.
7827 *
7828 * All components are capable of //being// referenced by owner components, but
7829 * only ReactOwner components are capable of //referencing// owned components.
7830 * The named reference is known as a "ref".
7831 *
7832 * Refs are available when mounted and updated during reconciliation.
7833 *
7834 * var MyComponent = React.createClass({
7835 * render: function() {
7836 * return (
7837 * <div onClick={this.handleClick}>
7838 * <CustomComponent ref="custom" />
7839 * </div>
7840 * );
7841 * },
7842 * handleClick: function() {
7843 * this.refs.custom.handleClick();
7844 * },
7845 * componentDidMount: function() {
7846 * this.refs.custom.initialize();
7847 * }
7848 * });
7849 *
7850 * Refs should rarely be used. When refs are used, they should only be done to
7851 * control data that is not handled by React's data flow.
7852 *
7853 * @class ReactOwner
7854 */
7855var ReactOwner = {
7856
7857 /**
7858 * @param {?object} object
7859 * @return {boolean} True if `object` is a valid owner.
7860 * @final
7861 */
7862 isValidOwner: function(object) {
7863 return !!(
7864 object &&
7865 typeof object.attachRef === 'function' &&
7866 typeof object.detachRef === 'function'
7867 );
7868 },
7869
7870 /**
7871 * Adds a component by ref to an owner component.
7872 *
7873 * @param {ReactComponent} component Component to reference.
7874 * @param {string} ref Name by which to refer to the component.
7875 * @param {ReactOwner} owner Component on which to record the ref.
7876 * @final
7877 * @internal
7878 */
7879 addComponentAsRefTo: function(component, ref, owner) {
7880 invariant(
7881 ReactOwner.isValidOwner(owner),
7882 'addComponentAsRefTo(...): Only a ReactOwner can have refs.'
7883 );
7884 owner.attachRef(ref, component);
7885 },
7886
7887 /**
7888 * Removes a component by ref from an owner component.
7889 *
7890 * @param {ReactComponent} component Component to dereference.
7891 * @param {string} ref Name of the ref to remove.
7892 * @param {ReactOwner} owner Component on which the ref is recorded.
7893 * @final
7894 * @internal
7895 */
7896 removeComponentAsRefFrom: function(component, ref, owner) {
7897 invariant(
7898 ReactOwner.isValidOwner(owner),
7899 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs.'
7900 );
7901 // Check that `component` is still the current ref because we do not want to
7902 // detach the ref if another component stole it.
7903 if (owner.refs[ref] === component) {
7904 owner.detachRef(ref);
7905 }
7906 },
7907
7908 /**
7909 * A ReactComponent must mix this in to have refs.
7910 *
7911 * @lends {ReactOwner.prototype}
7912 */
7913 Mixin: {
7914
7915 /**
7916 * Lazily allocates the refs object and stores `component` as `ref`.
7917 *
7918 * @param {string} ref Reference name.
7919 * @param {component} component Component to store as `ref`.
7920 * @final
7921 * @private
7922 */
7923 attachRef: function(ref, component) {
7924 invariant(
7925 component.isOwnedBy(this),
7926 'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
7927 ref
7928 );
7929 var refs = this.refs || (this.refs = {});
7930 refs[ref] = component;
7931 },
7932
7933 /**
7934 * Detaches a reference name.
7935 *
7936 * @param {string} ref Name to dereference.
7937 * @final
7938 * @private
7939 */
7940 detachRef: function(ref) {
7941 delete this.refs[ref];
7942 }
7943
7944 }
7945
7946};
7947
7948module.exports = ReactOwner;
7949
7950},{"./invariant":78}],44:[function(require,module,exports){
7951/**
7952 * Copyright 2013 Facebook, Inc.
7953 *
7954 * Licensed under the Apache License, Version 2.0 (the "License");
7955 * you may not use this file except in compliance with the License.
7956 * You may obtain a copy of the License at
7957 *
7958 * http://www.apache.org/licenses/LICENSE-2.0
7959 *
7960 * Unless required by applicable law or agreed to in writing, software
7961 * distributed under the License is distributed on an "AS IS" BASIS,
7962 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7963 * See the License for the specific language governing permissions and
7964 * limitations under the License.
7965 *
7966 * @providesModule ReactPropTransferer
7967 */
7968
7969"use strict";
7970
7971var emptyFunction = require("./emptyFunction");
7972var joinClasses = require("./joinClasses");
7973var merge = require("./merge");
7974
7975/**
7976 * Creates a transfer strategy that will merge prop values using the supplied
7977 * `mergeStrategy`. If a prop was previously unset, this just sets it.
7978 *
7979 * @param {function} mergeStrategy
7980 * @return {function}
7981 */
7982function createTransferStrategy(mergeStrategy) {
7983 return function(props, key, value) {
7984 if (!props.hasOwnProperty(key)) {
7985 props[key] = value;
7986 } else {
7987 props[key] = mergeStrategy(props[key], value);
7988 }
7989 };
7990}
7991
7992/**
7993 * Transfer strategies dictate how props are transferred by `transferPropsTo`.
7994 */
7995var TransferStrategies = {
7996 /**
7997 * Never transfer `children`.
7998 */
7999 children: emptyFunction,
8000 /**
8001 * Transfer the `className` prop by merging them.
8002 */
8003 className: createTransferStrategy(joinClasses),
8004 /**
8005 * Never transfer the `ref` prop.
8006 */
8007 ref: emptyFunction,
8008 /**
8009 * Transfer the `style` prop (which is an object) by merging them.
8010 */
8011 style: createTransferStrategy(merge)
8012};
8013
8014/**
8015 * ReactPropTransferer are capable of transferring props to another component
8016 * using a `transferPropsTo` method.
8017 *
8018 * @class ReactPropTransferer
8019 */
8020var ReactPropTransferer = {
8021
8022 TransferStrategies: TransferStrategies,
8023
8024 /**
8025 * @lends {ReactPropTransferer.prototype}
8026 */
8027 Mixin: {
8028
8029 /**
8030 * Transfer props from this component to a target component.
8031 *
8032 * Props that do not have an explicit transfer strategy will be transferred
8033 * only if the target component does not already have the prop set.
8034 *
8035 * This is usually used to pass down props to a returned root component.
8036 *
8037 * @param {ReactComponent} component Component receiving the properties.
8038 * @return {ReactComponent} The supplied `component`.
8039 * @final
8040 * @protected
8041 */
8042 transferPropsTo: function(component) {
8043 var props = {};
8044 for (var thatKey in component.props) {
8045 if (component.props.hasOwnProperty(thatKey)) {
8046 props[thatKey] = component.props[thatKey];
8047 }
8048 }
8049 for (var thisKey in this.props) {
8050 if (!this.props.hasOwnProperty(thisKey)) {
8051 continue;
8052 }
8053 var transferStrategy = TransferStrategies[thisKey];
8054 if (transferStrategy) {
8055 transferStrategy(props, thisKey, this.props[thisKey]);
8056 } else if (!props.hasOwnProperty(thisKey)) {
8057 props[thisKey] = this.props[thisKey];
8058 }
8059 }
8060 component.props = props;
8061 return component;
8062 }
8063
8064 }
8065
8066};
8067
8068module.exports = ReactPropTransferer;
8069
8070},{"./emptyFunction":66,"./joinClasses":80,"./merge":84}],45:[function(require,module,exports){
8071/**
8072 * Copyright 2013 Facebook, Inc.
8073 *
8074 * Licensed under the Apache License, Version 2.0 (the "License");
8075 * you may not use this file except in compliance with the License.
8076 * You may obtain a copy of the License at
8077 *
8078 * http://www.apache.org/licenses/LICENSE-2.0
8079 *
8080 * Unless required by applicable law or agreed to in writing, software
8081 * distributed under the License is distributed on an "AS IS" BASIS,
8082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8083 * See the License for the specific language governing permissions and
8084 * limitations under the License.
8085 *
8086 * @providesModule ReactPropTypes
8087 */
8088
8089"use strict";
8090
8091var createObjectFrom = require("./createObjectFrom");
8092var invariant = require("./invariant");
8093
8094/**
8095 * Collection of methods that allow declaration and validation of props that are
8096 * supplied to React components. Example usage:
8097 *
8098 * var Props = require('ReactPropTypes');
8099 * var MyArticle = React.createClass({
8100 * propTypes: {
8101 * // An optional string prop named "description".
8102 * description: Props.string,
8103 *
8104 * // A required enum prop named "category".
8105 * category: Props.oneOf(['News','Photos']).isRequired,
8106 *
8107 * // A prop named "dialog" that requires an instance of Dialog.
8108 * dialog: Props.instanceOf(Dialog).isRequired
8109 * },
8110 * render: function() { ... }
8111 * });
8112 *
8113 * A more formal specification of how these methods are used:
8114 *
8115 * type := array|bool|object|number|string|oneOf([...])|instanceOf(...)
8116 * decl := ReactPropTypes.{type}(.isRequired)?
8117 *
8118 * Each and every declaration produces a function with the same signature. This
8119 * allows the creation of custom validation functions. For example:
8120 *
8121 * var Props = require('ReactPropTypes');
8122 * var MyLink = React.createClass({
8123 * propTypes: {
8124 * // An optional string or URI prop named "href".
8125 * href: function(props, propName, componentName) {
8126 * var propValue = props[propName];
8127 * invariant(
8128 * propValue == null ||
8129 * typeof propValue === string ||
8130 * propValue instanceof URI,
8131 * 'Invalid `%s` supplied to `%s`, expected string or URI.',
8132 * propName,
8133 * componentName
8134 * );
8135 * }
8136 * },
8137 * render: function() { ... }
8138 * });
8139 *
8140 * @internal
8141 */
8142var Props = {
8143
8144 array: createPrimitiveTypeChecker('array'),
8145 bool: createPrimitiveTypeChecker('boolean'),
8146 func: createPrimitiveTypeChecker('function'),
8147 number: createPrimitiveTypeChecker('number'),
8148 object: createPrimitiveTypeChecker('object'),
8149 string: createPrimitiveTypeChecker('string'),
8150
8151 oneOf: createEnumTypeChecker,
8152
8153 instanceOf: createInstanceTypeChecker
8154
8155};
8156
8157var ANONYMOUS = '<<anonymous>>';
8158
8159function createPrimitiveTypeChecker(expectedType) {
8160 function validatePrimitiveType(propValue, propName, componentName) {
8161 var propType = typeof propValue;
8162 if (propType === 'object' && Array.isArray(propValue)) {
8163 propType = 'array';
8164 }
8165 invariant(
8166 propType === expectedType,
8167 'Invalid prop `%s` of type `%s` supplied to `%s`, expected `%s`.',
8168 propName,
8169 propType,
8170 componentName,
8171 expectedType
8172 );
8173 }
8174 return createChainableTypeChecker(validatePrimitiveType);
8175}
8176
8177function createEnumTypeChecker(expectedValues) {
8178 var expectedEnum = createObjectFrom(expectedValues);
8179 function validateEnumType(propValue, propName, componentName) {
8180 invariant(
8181 expectedEnum[propValue],
8182 'Invalid prop `%s` supplied to `%s`, expected one of %s.',
8183 propName,
8184 componentName,
8185 JSON.stringify(Object.keys(expectedEnum))
8186 );
8187 }
8188 return createChainableTypeChecker(validateEnumType);
8189}
8190
8191function createInstanceTypeChecker(expectedClass) {
8192 function validateInstanceType(propValue, propName, componentName) {
8193 invariant(
8194 propValue instanceof expectedClass,
8195 'Invalid prop `%s` supplied to `%s`, expected instance of `%s`.',
8196 propName,
8197 componentName,
8198 expectedClass.name || ANONYMOUS
8199 );
8200 }
8201 return createChainableTypeChecker(validateInstanceType);
8202}
8203
8204function createChainableTypeChecker(validate) {
8205 function createTypeChecker(isRequired) {
8206 function checkType(props, propName, componentName) {
8207 var propValue = props[propName];
8208 if (propValue != null) {
8209 // Only validate if there is a value to check.
8210 validate(propValue, propName, componentName || ANONYMOUS);
8211 } else {
8212 invariant(
8213 !isRequired,
8214 'Required prop `%s` was not specified in `%s`.',
8215 propName,
8216 componentName || ANONYMOUS
8217 );
8218 }
8219 }
8220 if (!isRequired) {
8221 checkType.isRequired = createTypeChecker(true);
8222 }
8223 return checkType;
8224 }
8225 return createTypeChecker(false);
8226}
8227
8228module.exports = Props;
8229
8230},{"./createObjectFrom":64,"./invariant":78}],46:[function(require,module,exports){
8231/**
8232 * Copyright 2013 Facebook, Inc.
8233 *
8234 * Licensed under the Apache License, Version 2.0 (the "License");
8235 * you may not use this file except in compliance with the License.
8236 * You may obtain a copy of the License at
8237 *
8238 * http://www.apache.org/licenses/LICENSE-2.0
8239 *
8240 * Unless required by applicable law or agreed to in writing, software
8241 * distributed under the License is distributed on an "AS IS" BASIS,
8242 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8243 * See the License for the specific language governing permissions and
8244 * limitations under the License.
8245 *
8246 * @providesModule ReactReconcileTransaction
8247 * @typechecks static-only
8248 */
8249
8250"use strict";
8251
8252var ExecutionEnvironment = require("./ExecutionEnvironment");
8253var PooledClass = require("./PooledClass");
8254var ReactEventEmitter = require("./ReactEventEmitter");
8255var ReactInputSelection = require("./ReactInputSelection");
8256var ReactOnDOMReady = require("./ReactOnDOMReady");
8257var Transaction = require("./Transaction");
8258
8259var mixInto = require("./mixInto");
8260
8261/**
8262 * Ensures that, when possible, the selection range (currently selected text
8263 * input) is not disturbed by performing the transaction.
8264 */
8265var SELECTION_RESTORATION = {
8266 /**
8267 * @return {Selection} Selection information.
8268 */
8269 initialize: ReactInputSelection.getSelectionInformation,
8270 /**
8271 * @param {Selection} sel Selection information returned from `initialize`.
8272 */
8273 close: ReactInputSelection.restoreSelection
8274};
8275
8276/**
8277 * Suppresses events (blur/focus) that could be inadvertently dispatched due to
8278 * high level DOM manipulations (like temporarily removing a text input from the
8279 * DOM).
8280 */
8281var EVENT_SUPPRESSION = {
8282 /**
8283 * @return {boolean} The enabled status of `ReactEventEmitter` before the
8284 * reconciliation.
8285 */
8286 initialize: function() {
8287 var currentlyEnabled = ReactEventEmitter.isEnabled();
8288 ReactEventEmitter.setEnabled(false);
8289 return currentlyEnabled;
8290 },
8291
8292 /**
8293 * @param {boolean} previouslyEnabled Enabled status of `ReactEventEmitter`
8294 * before the reconciliation occured. `close` restores the previous value.
8295 */
8296 close: function(previouslyEnabled) {
8297 ReactEventEmitter.setEnabled(previouslyEnabled);
8298 }
8299};
8300
8301/**
8302 * Provides a `ReactOnDOMReady` queue for collecting `onDOMReady` callbacks
8303 * during the performing of the transaction.
8304 */
8305var ON_DOM_READY_QUEUEING = {
8306 /**
8307 * Initializes the internal `onDOMReady` queue.
8308 */
8309 initialize: function() {
8310 this.reactOnDOMReady.reset();
8311 },
8312
8313 /**
8314 * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
8315 */
8316 close: function() {
8317 this.reactOnDOMReady.notifyAll();
8318 }
8319};
8320
8321/**
8322 * Executed within the scope of the `Transaction` instance. Consider these as
8323 * being member methods, but with an implied ordering while being isolated from
8324 * each other.
8325 */
8326var TRANSACTION_WRAPPERS = [
8327 SELECTION_RESTORATION,
8328 EVENT_SUPPRESSION,
8329 ON_DOM_READY_QUEUEING
8330];
8331
8332/**
8333 * Currently:
8334 * - The order that these are listed in the transaction is critical:
8335 * - Suppresses events.
8336 * - Restores selection range.
8337 *
8338 * Future:
8339 * - Restore document/overflow scroll positions that were unintentionally
8340 * modified via DOM insertions above the top viewport boundary.
8341 * - Implement/integrate with customized constraint based layout system and keep
8342 * track of which dimensions must be remeasured.
8343 *
8344 * @class ReactReconcileTransaction
8345 */
8346function ReactReconcileTransaction() {
8347 this.reinitializeTransaction();
8348 this.reactOnDOMReady = ReactOnDOMReady.getPooled(null);
8349}
8350
8351var Mixin = {
8352 /**
8353 * @see Transaction
8354 * @abstract
8355 * @final
8356 * @return {array<object>} List of operation wrap proceedures.
8357 * TODO: convert to array<TransactionWrapper>
8358 */
8359 getTransactionWrappers: function() {
8360 if (ExecutionEnvironment.canUseDOM) {
8361 return TRANSACTION_WRAPPERS;
8362 } else {
8363 return [];
8364 }
8365 },
8366
8367 /**
8368 * @return {object} The queue to collect `onDOMReady` callbacks with.
8369 * TODO: convert to ReactOnDOMReady
8370 */
8371 getReactOnDOMReady: function() {
8372 return this.reactOnDOMReady;
8373 },
8374
8375 /**
8376 * `PooledClass` looks for this, and will invoke this before allowing this
8377 * instance to be resused.
8378 */
8379 destructor: function() {
8380 ReactOnDOMReady.release(this.reactOnDOMReady);
8381 this.reactOnDOMReady = null;
8382 }
8383};
8384
8385
8386mixInto(ReactReconcileTransaction, Transaction.Mixin);
8387mixInto(ReactReconcileTransaction, Mixin);
8388
8389PooledClass.addPoolingTo(ReactReconcileTransaction);
8390
8391module.exports = ReactReconcileTransaction;
8392
8393},{"./ExecutionEnvironment":19,"./PooledClass":21,"./ReactEventEmitter":34,"./ReactInputSelection":36,"./ReactOnDOMReady":42,"./Transaction":59,"./mixInto":87}],47:[function(require,module,exports){
8394/**
8395 * Copyright 2013 Facebook, Inc.
8396 *
8397 * Licensed under the Apache License, Version 2.0 (the "License");
8398 * you may not use this file except in compliance with the License.
8399 * You may obtain a copy of the License at
8400 *
8401 * http://www.apache.org/licenses/LICENSE-2.0
8402 *
8403 * Unless required by applicable law or agreed to in writing, software
8404 * distributed under the License is distributed on an "AS IS" BASIS,
8405 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8406 * See the License for the specific language governing permissions and
8407 * limitations under the License.
8408 *
8409 * @typechecks static-only
8410 * @providesModule ReactServerRendering
8411 */
8412"use strict";
8413
8414var ReactMarkupChecksum = require("./ReactMarkupChecksum");
8415var ReactReconcileTransaction = require("./ReactReconcileTransaction");
8416var ReactInstanceHandles = require("./ReactInstanceHandles");
8417
8418/**
8419 * @param {object} component
8420 * @param {function} callback
8421 */
8422function renderComponentToString(component, callback) {
8423 // We use a callback API to keep the API async in case in the future we ever
8424 // need it, but in reality this is a synchronous operation.
8425 var id = ReactInstanceHandles.createReactRootID();
8426 var transaction = ReactReconcileTransaction.getPooled();
8427 transaction.reinitializeTransaction();
8428 try {
8429 transaction.perform(function() {
8430 var markup = component.mountComponent(id, transaction);
8431 markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
8432 callback(markup);
8433 }, null);
8434 } finally {
8435 ReactReconcileTransaction.release(transaction);
8436 }
8437}
8438
8439module.exports = {
8440 renderComponentToString: renderComponentToString
8441};
8442
8443},{"./ReactInstanceHandles":37,"./ReactMarkupChecksum":38,"./ReactReconcileTransaction":46}],48:[function(require,module,exports){
8444/**
8445 * Copyright 2013 Facebook, Inc.
8446 *
8447 * Licensed under the Apache License, Version 2.0 (the "License");
8448 * you may not use this file except in compliance with the License.
8449 * You may obtain a copy of the License at
8450 *
8451 * http://www.apache.org/licenses/LICENSE-2.0
8452 *
8453 * Unless required by applicable law or agreed to in writing, software
8454 * distributed under the License is distributed on an "AS IS" BASIS,
8455 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8456 * See the License for the specific language governing permissions and
8457 * limitations under the License.
8458 *
8459 * @providesModule ReactTextComponent
8460 * @typechecks static-only
8461 */
8462
8463"use strict";
8464
8465var ReactComponent = require("./ReactComponent");
8466var ReactMount = require("./ReactMount");
8467
8468var escapeTextForBrowser = require("./escapeTextForBrowser");
8469var mixInto = require("./mixInto");
8470
8471/**
8472 * Text nodes violate a couple assumptions that React makes about components:
8473 *
8474 * - When mounting text into the DOM, adjacent text nodes are merged.
8475 * - Text nodes cannot be assigned a React root ID.
8476 *
8477 * This component is used to wrap strings in elements so that they can undergo
8478 * the same reconciliation that is applied to elements.
8479 *
8480 * TODO: Investigate representing React components in the DOM with text nodes.
8481 *
8482 * @class ReactTextComponent
8483 * @extends ReactComponent
8484 * @internal
8485 */
8486var ReactTextComponent = function(initialText) {
8487 this.construct({text: initialText});
8488};
8489
8490mixInto(ReactTextComponent, ReactComponent.Mixin);
8491mixInto(ReactTextComponent, {
8492
8493 /**
8494 * Creates the markup for this text node. This node is not intended to have
8495 * any features besides containing text content.
8496 *
8497 * @param {string} rootID DOM ID of the root node.
8498 * @return {string} Markup for this text node.
8499 * @internal
8500 */
8501 mountComponent: function(rootID) {
8502 ReactComponent.Mixin.mountComponent.call(this, rootID);
8503 return (
8504 '<span ' + ReactMount.ATTR_NAME + '="' + rootID + '">' +
8505 escapeTextForBrowser(this.props.text) +
8506 '</span>'
8507 );
8508 },
8509
8510 /**
8511 * Updates this component by updating the text content.
8512 *
8513 * @param {object} nextProps Contains the next text content.
8514 * @param {ReactReconcileTransaction} transaction
8515 * @internal
8516 */
8517 receiveProps: function(nextProps, transaction) {
8518 if (nextProps.text !== this.props.text) {
8519 this.props.text = nextProps.text;
8520 ReactComponent.DOMIDOperations.updateTextContentByID(
8521 this._rootNodeID,
8522 nextProps.text
8523 );
8524 }
8525 }
8526
8527});
8528
8529module.exports = ReactTextComponent;
8530
8531},{"./ReactComponent":23,"./ReactMount":39,"./escapeTextForBrowser":67,"./mixInto":87}],49:[function(require,module,exports){
8532/**
8533 * Copyright 2013 Facebook, Inc.
8534 *
8535 * Licensed under the Apache License, Version 2.0 (the "License");
8536 * you may not use this file except in compliance with the License.
8537 * You may obtain a copy of the License at
8538 *
8539 * http://www.apache.org/licenses/LICENSE-2.0
8540 *
8541 * Unless required by applicable law or agreed to in writing, software
8542 * distributed under the License is distributed on an "AS IS" BASIS,
8543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8544 * See the License for the specific language governing permissions and
8545 * limitations under the License.
8546 *
8547 * @providesModule ReactUpdates
8548 */
8549
8550"use strict";
8551
8552var invariant = require("./invariant");
8553
8554var isBatchingUpdates = false;
8555
8556var dirtyComponents = [];
8557
8558/**
8559 * Call the provided function in a context within which calls to `setState` and
8560 * friends are batched such that components aren't updated unnecessarily.
8561 */
8562function batchedUpdates(callback) {
8563 if (isBatchingUpdates) {
8564 // We're already executing in an environment where updates will be batched,
8565 // so this is a no-op.
8566 callback();
8567 return;
8568 }
8569
8570 isBatchingUpdates = true;
8571
8572 try {
8573 callback();
8574 // TODO: Sort components by depth such that parent components update first
8575 for (var i = 0; i < dirtyComponents.length; i++) {
8576 // If a component is unmounted before pending changes apply, ignore them
8577 // TODO: Queue unmounts in the same list to avoid this happening at all
8578 var component = dirtyComponents[i];
8579 if (component.isMounted()) {
8580 // If performUpdateIfNecessary happens to enqueue any new updates, we
8581 // shouldn't execute the callbacks until the next render happens, so
8582 // stash the callbacks first
8583 var callbacks = component._pendingCallbacks;
8584 component._pendingCallbacks = null;
8585 component.performUpdateIfNecessary();
8586 if (callbacks) {
8587 for (var j = 0; j < callbacks.length; j++) {
8588 callbacks[j].call(component);
8589 }
8590 }
8591 }
8592 }
8593 } catch (error) {
8594 // IE8 requires `catch` in order to use `finally`.
8595 throw error;
8596 } finally {
8597 dirtyComponents.length = 0;
8598 isBatchingUpdates = false;
8599 }
8600}
8601
8602/**
8603 * Mark a component as needing a rerender, adding an optional callback to a
8604 * list of functions which will be executed once the rerender occurs.
8605 */
8606function enqueueUpdate(component, callback) {
8607 invariant(
8608 !callback || typeof callback === "function",
8609 'enqueueUpdate(...): You called `setProps`, `replaceProps`, ' +
8610 '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
8611 'isn\'t callable.'
8612 );
8613
8614 if (!isBatchingUpdates) {
8615 component.performUpdateIfNecessary();
8616 callback && callback();
8617 return;
8618 }
8619
8620 dirtyComponents.push(component);
8621
8622 if (callback) {
8623 if (component._pendingCallbacks) {
8624 component._pendingCallbacks.push(callback);
8625 } else {
8626 component._pendingCallbacks = [callback];
8627 }
8628 }
8629}
8630
8631var ReactUpdates = {
8632 batchedUpdates: batchedUpdates,
8633 enqueueUpdate: enqueueUpdate
8634};
8635
8636module.exports = ReactUpdates;
8637
8638},{"./invariant":78}],50:[function(require,module,exports){
8639/**
8640 * Copyright 2013 Facebook, Inc.
8641 *
8642 * Licensed under the Apache License, Version 2.0 (the "License");
8643 * you may not use this file except in compliance with the License.
8644 * You may obtain a copy of the License at
8645 *
8646 * http://www.apache.org/licenses/LICENSE-2.0
8647 *
8648 * Unless required by applicable law or agreed to in writing, software
8649 * distributed under the License is distributed on an "AS IS" BASIS,
8650 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8651 * See the License for the specific language governing permissions and
8652 * limitations under the License.
8653 *
8654 * @providesModule SimpleEventPlugin
8655 */
8656
8657"use strict";
8658
8659var EventConstants = require("./EventConstants");
8660var EventPropagators = require("./EventPropagators");
8661var SyntheticEvent = require("./SyntheticEvent");
8662var SyntheticFocusEvent = require("./SyntheticFocusEvent");
8663var SyntheticKeyboardEvent = require("./SyntheticKeyboardEvent");
8664var SyntheticMouseEvent = require("./SyntheticMouseEvent");
8665var SyntheticMutationEvent = require("./SyntheticMutationEvent");
8666var SyntheticTouchEvent = require("./SyntheticTouchEvent");
8667var SyntheticUIEvent = require("./SyntheticUIEvent");
8668var SyntheticWheelEvent = require("./SyntheticWheelEvent");
8669
8670var invariant = require("./invariant");
8671var keyOf = require("./keyOf");
8672
8673var topLevelTypes = EventConstants.topLevelTypes;
8674
8675var eventTypes = {
8676 blur: {
8677 phasedRegistrationNames: {
8678 bubbled: keyOf({onBlur: true}),
8679 captured: keyOf({onBlurCapture: true})
8680 }
8681 },
8682 click: {
8683 phasedRegistrationNames: {
8684 bubbled: keyOf({onClick: true}),
8685 captured: keyOf({onClickCapture: true})
8686 }
8687 },
8688 doubleClick: {
8689 phasedRegistrationNames: {
8690 bubbled: keyOf({onDoubleClick: true}),
8691 captured: keyOf({onDoubleClickCapture: true})
8692 }
8693 },
8694 drag: {
8695 phasedRegistrationNames: {
8696 bubbled: keyOf({onDrag: true}),
8697 captured: keyOf({onDragCapture: true})
8698 }
8699 },
8700 dragEnd: {
8701 phasedRegistrationNames: {
8702 bubbled: keyOf({onDragEnd: true}),
8703 captured: keyOf({onDragEndCapture: true})
8704 }
8705 },
8706 dragEnter: {
8707 phasedRegistrationNames: {
8708 bubbled: keyOf({onDragEnter: true}),
8709 captured: keyOf({onDragEnterCapture: true})
8710 }
8711 },
8712 dragExit: {
8713 phasedRegistrationNames: {
8714 bubbled: keyOf({onDragExit: true}),
8715 captured: keyOf({onDragExitCapture: true})
8716 }
8717 },
8718 dragLeave: {
8719 phasedRegistrationNames: {
8720 bubbled: keyOf({onDragLeave: true}),
8721 captured: keyOf({onDragLeaveCapture: true})
8722 }
8723 },
8724 dragOver: {
8725 phasedRegistrationNames: {
8726 bubbled: keyOf({onDragOver: true}),
8727 captured: keyOf({onDragOverCapture: true})
8728 }
8729 },
8730 dragStart: {
8731 phasedRegistrationNames: {
8732 bubbled: keyOf({onDragStart: true}),
8733 captured: keyOf({onDragStartCapture: true})
8734 }
8735 },
8736 drop: {
8737 phasedRegistrationNames: {
8738 bubbled: keyOf({onDrop: true}),
8739 captured: keyOf({onDropCapture: true})
8740 }
8741 },
8742 DOMCharacterDataModified: {
8743 phasedRegistrationNames: {
8744 bubbled: keyOf({onDOMCharacterDataModified: true}),
8745 captured: keyOf({onDOMCharacterDataModifiedCapture: true})
8746 }
8747 },
8748 focus: {
8749 phasedRegistrationNames: {
8750 bubbled: keyOf({onFocus: true}),
8751 captured: keyOf({onFocusCapture: true})
8752 }
8753 },
8754 input: {
8755 phasedRegistrationNames: {
8756 bubbled: keyOf({onInput: true}),
8757 captured: keyOf({onInputCapture: true})
8758 }
8759 },
8760 keyDown: {
8761 phasedRegistrationNames: {
8762 bubbled: keyOf({onKeyDown: true}),
8763 captured: keyOf({onKeyDownCapture: true})
8764 }
8765 },
8766 keyPress: {
8767 phasedRegistrationNames: {
8768 bubbled: keyOf({onKeyPress: true}),
8769 captured: keyOf({onKeyPressCapture: true})
8770 }
8771 },
8772 keyUp: {
8773 phasedRegistrationNames: {
8774 bubbled: keyOf({onKeyUp: true}),
8775 captured: keyOf({onKeyUpCapture: true})
8776 }
8777 },
8778 // Note: We do not allow listening to mouseOver events. Instead, use the
8779 // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
8780 mouseDown: {
8781 phasedRegistrationNames: {
8782 bubbled: keyOf({onMouseDown: true}),
8783 captured: keyOf({onMouseDownCapture: true})
8784 }
8785 },
8786 mouseMove: {
8787 phasedRegistrationNames: {
8788 bubbled: keyOf({onMouseMove: true}),
8789 captured: keyOf({onMouseMoveCapture: true})
8790 }
8791 },
8792 mouseUp: {
8793 phasedRegistrationNames: {
8794 bubbled: keyOf({onMouseUp: true}),
8795 captured: keyOf({onMouseUpCapture: true})
8796 }
8797 },
8798 scroll: {
8799 phasedRegistrationNames: {
8800 bubbled: keyOf({onScroll: true}),
8801 captured: keyOf({onScrollCapture: true})
8802 }
8803 },
8804 submit: {
8805 phasedRegistrationNames: {
8806 bubbled: keyOf({onSubmit: true}),
8807 captured: keyOf({onSubmitCapture: true})
8808 }
8809 },
8810 touchCancel: {
8811 phasedRegistrationNames: {
8812 bubbled: keyOf({onTouchCancel: true}),
8813 captured: keyOf({onTouchCancelCapture: true})
8814 }
8815 },
8816 touchEnd: {
8817 phasedRegistrationNames: {
8818 bubbled: keyOf({onTouchEnd: true}),
8819 captured: keyOf({onTouchEndCapture: true})
8820 }
8821 },
8822 touchMove: {
8823 phasedRegistrationNames: {
8824 bubbled: keyOf({onTouchMove: true}),
8825 captured: keyOf({onTouchMoveCapture: true})
8826 }
8827 },
8828 touchStart: {
8829 phasedRegistrationNames: {
8830 bubbled: keyOf({onTouchStart: true}),
8831 captured: keyOf({onTouchStartCapture: true})
8832 }
8833 },
8834 wheel: {
8835 phasedRegistrationNames: {
8836 bubbled: keyOf({onWheel: true}),
8837 captured: keyOf({onWheelCapture: true})
8838 }
8839 }
8840};
8841
8842var topLevelEventsToDispatchConfig = {
8843 topBlur: eventTypes.blur,
8844 topClick: eventTypes.click,
8845 topDoubleClick: eventTypes.doubleClick,
8846 topDOMCharacterDataModified: eventTypes.DOMCharacterDataModified,
8847 topDrag: eventTypes.drag,
8848 topDragEnd: eventTypes.dragEnd,
8849 topDragEnter: eventTypes.dragEnter,
8850 topDragExit: eventTypes.dragExit,
8851 topDragLeave: eventTypes.dragLeave,
8852 topDragOver: eventTypes.dragOver,
8853 topDragStart: eventTypes.dragStart,
8854 topDrop: eventTypes.drop,
8855 topFocus: eventTypes.focus,
8856 topInput: eventTypes.input,
8857 topKeyDown: eventTypes.keyDown,
8858 topKeyPress: eventTypes.keyPress,
8859 topKeyUp: eventTypes.keyUp,
8860 topMouseDown: eventTypes.mouseDown,
8861 topMouseMove: eventTypes.mouseMove,
8862 topMouseUp: eventTypes.mouseUp,
8863 topScroll: eventTypes.scroll,
8864 topSubmit: eventTypes.submit,
8865 topTouchCancel: eventTypes.touchCancel,
8866 topTouchEnd: eventTypes.touchEnd,
8867 topTouchMove: eventTypes.touchMove,
8868 topTouchStart: eventTypes.touchStart,
8869 topWheel: eventTypes.wheel
8870};
8871
8872var SimpleEventPlugin = {
8873
8874 eventTypes: eventTypes,
8875
8876 /**
8877 * Same as the default implementation, except cancels the event when return
8878 * value is false.
8879 *
8880 * @param {object} Event to be dispatched.
8881 * @param {function} Application-level callback.
8882 * @param {string} domID DOM ID to pass to the callback.
8883 */
8884 executeDispatch: function(event, listener, domID) {
8885 var returnValue = listener(event, domID);
8886 if (returnValue === false) {
8887 event.stopPropagation();
8888 event.preventDefault();
8889 }
8890 },
8891
8892 /**
8893 * @param {string} topLevelType Record from `EventConstants`.
8894 * @param {DOMEventTarget} topLevelTarget The listening component root node.
8895 * @param {string} topLevelTargetID ID of `topLevelTarget`.
8896 * @param {object} nativeEvent Native browser event.
8897 * @return {*} An accumulation of synthetic events.
8898 * @see {EventPluginHub.extractEvents}
8899 */
8900 extractEvents: function(
8901 topLevelType,
8902 topLevelTarget,
8903 topLevelTargetID,
8904 nativeEvent) {
8905 var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
8906 if (!dispatchConfig) {
8907 return null;
8908 }
8909 var EventConstructor;
8910 switch(topLevelType) {
8911 case topLevelTypes.topInput:
8912 case topLevelTypes.topSubmit:
8913 // HTML Events
8914 // @see http://www.w3.org/TR/html5/index.html#events-0
8915 EventConstructor = SyntheticEvent;
8916 break;
8917 case topLevelTypes.topKeyDown:
8918 case topLevelTypes.topKeyPress:
8919 case topLevelTypes.topKeyUp:
8920 EventConstructor = SyntheticKeyboardEvent;
8921 break;
8922 case topLevelTypes.topBlur:
8923 case topLevelTypes.topFocus:
8924 EventConstructor = SyntheticFocusEvent;
8925 break;
8926 case topLevelTypes.topClick:
8927 case topLevelTypes.topDoubleClick:
8928 case topLevelTypes.topDrag:
8929 case topLevelTypes.topDragEnd:
8930 case topLevelTypes.topDragEnter:
8931 case topLevelTypes.topDragExit:
8932 case topLevelTypes.topDragLeave:
8933 case topLevelTypes.topDragOver:
8934 case topLevelTypes.topDragStart:
8935 case topLevelTypes.topDrop:
8936 case topLevelTypes.topMouseDown:
8937 case topLevelTypes.topMouseMove:
8938 case topLevelTypes.topMouseUp:
8939 EventConstructor = SyntheticMouseEvent;
8940 break;
8941 case topLevelTypes.topDOMCharacterDataModified:
8942 EventConstructor = SyntheticMutationEvent;
8943 break;
8944 case topLevelTypes.topTouchCancel:
8945 case topLevelTypes.topTouchEnd:
8946 case topLevelTypes.topTouchMove:
8947 case topLevelTypes.topTouchStart:
8948 EventConstructor = SyntheticTouchEvent;
8949 break;
8950 case topLevelTypes.topScroll:
8951 EventConstructor = SyntheticUIEvent;
8952 break;
8953 case topLevelTypes.topWheel:
8954 EventConstructor = SyntheticWheelEvent;
8955 break;
8956 }
8957 invariant(
8958 EventConstructor,
8959 'SimpleEventPlugin: Unhandled event type, `%s`.',
8960 topLevelType
8961 );
8962 var event = EventConstructor.getPooled(
8963 dispatchConfig,
8964 topLevelTargetID,
8965 nativeEvent
8966 );
8967 EventPropagators.accumulateTwoPhaseDispatches(event);
8968 return event;
8969 }
8970
8971};
8972
8973module.exports = SimpleEventPlugin;
8974
8975},{"./EventConstants":13,"./EventPropagators":18,"./SyntheticEvent":51,"./SyntheticFocusEvent":52,"./SyntheticKeyboardEvent":53,"./SyntheticMouseEvent":54,"./SyntheticMutationEvent":55,"./SyntheticTouchEvent":56,"./SyntheticUIEvent":57,"./SyntheticWheelEvent":58,"./invariant":78,"./keyOf":82}],51:[function(require,module,exports){
8976/**
8977 * Copyright 2013 Facebook, Inc.
8978 *
8979 * Licensed under the Apache License, Version 2.0 (the "License");
8980 * you may not use this file except in compliance with the License.
8981 * You may obtain a copy of the License at
8982 *
8983 * http://www.apache.org/licenses/LICENSE-2.0
8984 *
8985 * Unless required by applicable law or agreed to in writing, software
8986 * distributed under the License is distributed on an "AS IS" BASIS,
8987 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8988 * See the License for the specific language governing permissions and
8989 * limitations under the License.
8990 *
8991 * @providesModule SyntheticEvent
8992 * @typechecks static-only
8993 */
8994
8995"use strict";
8996
8997var PooledClass = require("./PooledClass");
8998
8999var emptyFunction = require("./emptyFunction");
9000var getEventTarget = require("./getEventTarget");
9001var merge = require("./merge");
9002var mergeInto = require("./mergeInto");
9003
9004/**
9005 * @interface Event
9006 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9007 */
9008var EventInterface = {
9009 type: null,
9010 target: getEventTarget,
9011 currentTarget: null,
9012 eventPhase: null,
9013 bubbles: null,
9014 cancelable: null,
9015 timeStamp: function(event) {
9016 return event.timeStamp || Date.now();
9017 },
9018 defaultPrevented: null,
9019 isTrusted: null
9020};
9021
9022/**
9023 * Synthetic events are dispatched by event plugins, typically in response to a
9024 * top-level event delegation handler.
9025 *
9026 * These systems should generally use pooling to reduce the frequency of garbage
9027 * collection. The system should check `isPersistent` to determine whether the
9028 * event should be released into the pool after being dispatched. Users that
9029 * need a persisted event should invoke `persist`.
9030 *
9031 * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
9032 * normalizing browser quirks. Subclasses do not necessarily have to implement a
9033 * DOM interface; custom application-specific events can also subclass this.
9034 *
9035 * @param {object} dispatchConfig Configuration used to dispatch this event.
9036 * @param {string} dispatchMarker Marker identifying the event target.
9037 * @param {object} nativeEvent Native browser event.
9038 */
9039function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9040 this.dispatchConfig = dispatchConfig;
9041 this.dispatchMarker = dispatchMarker;
9042 this.nativeEvent = nativeEvent;
9043
9044 var Interface = this.constructor.Interface;
9045 for (var propName in Interface) {
9046 if (!Interface.hasOwnProperty(propName)) {
9047 continue;
9048 }
9049 var normalize = Interface[propName];
9050 if (normalize) {
9051 this[propName] = normalize(nativeEvent);
9052 } else {
9053 this[propName] = nativeEvent[propName];
9054 }
9055 }
9056
9057 if (nativeEvent.defaultPrevented || nativeEvent.returnValue === false) {
9058 this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
9059 } else {
9060 this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
9061 }
9062 this.isPropagationStopped = emptyFunction.thatReturnsFalse;
9063}
9064
9065mergeInto(SyntheticEvent.prototype, {
9066
9067 preventDefault: function() {
9068 this.defaultPrevented = true;
9069 var event = this.nativeEvent;
9070 event.preventDefault ? event.preventDefault() : event.returnValue = false;
9071 this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
9072 },
9073
9074 stopPropagation: function() {
9075 var event = this.nativeEvent;
9076 event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
9077 this.isPropagationStopped = emptyFunction.thatReturnsTrue;
9078 },
9079
9080 /**
9081 * We release all dispatched `SyntheticEvent`s after each event loop, adding
9082 * them back into the pool. This allows a way to hold onto a reference that
9083 * won't be added back into the pool.
9084 */
9085 persist: function() {
9086 this.isPersistent = emptyFunction.thatReturnsTrue;
9087 },
9088
9089 /**
9090 * Checks if this event should be released back into the pool.
9091 *
9092 * @return {boolean} True if this should not be released, false otherwise.
9093 */
9094 isPersistent: emptyFunction.thatReturnsFalse,
9095
9096 /**
9097 * `PooledClass` looks for `destructor` on each instance it releases.
9098 */
9099 destructor: function() {
9100 var Interface = this.constructor.Interface;
9101 for (var propName in Interface) {
9102 this[propName] = null;
9103 }
9104 this.dispatchConfig = null;
9105 this.dispatchMarker = null;
9106 this.nativeEvent = null;
9107 }
9108
9109});
9110
9111SyntheticEvent.Interface = EventInterface;
9112
9113/**
9114 * Helper to reduce boilerplate when creating subclasses.
9115 *
9116 * @param {function} Class
9117 * @param {?object} Interface
9118 */
9119SyntheticEvent.augmentClass = function(Class, Interface) {
9120 var Super = this;
9121
9122 var prototype = Object.create(Super.prototype);
9123 mergeInto(prototype, Class.prototype);
9124 Class.prototype = prototype;
9125 Class.prototype.constructor = Class;
9126
9127 Class.Interface = merge(Super.Interface, Interface);
9128 Class.augmentClass = Super.augmentClass;
9129
9130 PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
9131};
9132
9133PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
9134
9135module.exports = SyntheticEvent;
9136
9137},{"./PooledClass":21,"./emptyFunction":66,"./getEventTarget":72,"./merge":84,"./mergeInto":86}],52:[function(require,module,exports){
9138/**
9139 * Copyright 2013 Facebook, Inc.
9140 *
9141 * Licensed under the Apache License, Version 2.0 (the "License");
9142 * you may not use this file except in compliance with the License.
9143 * You may obtain a copy of the License at
9144 *
9145 * http://www.apache.org/licenses/LICENSE-2.0
9146 *
9147 * Unless required by applicable law or agreed to in writing, software
9148 * distributed under the License is distributed on an "AS IS" BASIS,
9149 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9150 * See the License for the specific language governing permissions and
9151 * limitations under the License.
9152 *
9153 * @providesModule SyntheticFocusEvent
9154 * @typechecks static-only
9155 */
9156
9157"use strict";
9158
9159var SyntheticUIEvent = require("./SyntheticUIEvent");
9160
9161/**
9162 * @interface FocusEvent
9163 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9164 */
9165var FocusEventInterface = {
9166 relatedTarget: null
9167};
9168
9169/**
9170 * @param {object} dispatchConfig Configuration used to dispatch this event.
9171 * @param {string} dispatchMarker Marker identifying the event target.
9172 * @param {object} nativeEvent Native browser event.
9173 * @extends {SyntheticUIEvent}
9174 */
9175function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9176 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9177}
9178
9179SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
9180
9181module.exports = SyntheticFocusEvent;
9182
9183},{"./SyntheticUIEvent":57}],53:[function(require,module,exports){
9184/**
9185 * Copyright 2013 Facebook, Inc.
9186 *
9187 * Licensed under the Apache License, Version 2.0 (the "License");
9188 * you may not use this file except in compliance with the License.
9189 * You may obtain a copy of the License at
9190 *
9191 * http://www.apache.org/licenses/LICENSE-2.0
9192 *
9193 * Unless required by applicable law or agreed to in writing, software
9194 * distributed under the License is distributed on an "AS IS" BASIS,
9195 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9196 * See the License for the specific language governing permissions and
9197 * limitations under the License.
9198 *
9199 * @providesModule SyntheticKeyboardEvent
9200 * @typechecks static-only
9201 */
9202
9203"use strict";
9204
9205var SyntheticUIEvent = require("./SyntheticUIEvent");
9206
9207/**
9208 * @interface KeyboardEvent
9209 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9210 */
9211var KeyboardEventInterface = {
9212 'char': null,
9213 key: null,
9214 location: null,
9215 ctrlKey: null,
9216 shiftKey: null,
9217 altKey: null,
9218 metaKey: null,
9219 repeat: null,
9220 locale: null,
9221 // Legacy Interface
9222 charCode: null,
9223 keyCode: null,
9224 which: null
9225};
9226
9227/**
9228 * @param {object} dispatchConfig Configuration used to dispatch this event.
9229 * @param {string} dispatchMarker Marker identifying the event target.
9230 * @param {object} nativeEvent Native browser event.
9231 * @extends {SyntheticUIEvent}
9232 */
9233function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9234 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9235}
9236
9237SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
9238
9239module.exports = SyntheticKeyboardEvent;
9240
9241},{"./SyntheticUIEvent":57}],54:[function(require,module,exports){
9242/**
9243 * Copyright 2013 Facebook, Inc.
9244 *
9245 * Licensed under the Apache License, Version 2.0 (the "License");
9246 * you may not use this file except in compliance with the License.
9247 * You may obtain a copy of the License at
9248 *
9249 * http://www.apache.org/licenses/LICENSE-2.0
9250 *
9251 * Unless required by applicable law or agreed to in writing, software
9252 * distributed under the License is distributed on an "AS IS" BASIS,
9253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9254 * See the License for the specific language governing permissions and
9255 * limitations under the License.
9256 *
9257 * @providesModule SyntheticMouseEvent
9258 * @typechecks static-only
9259 */
9260
9261"use strict";
9262
9263var SyntheticUIEvent = require("./SyntheticUIEvent");
9264var ViewportMetrics = require("./ViewportMetrics");
9265
9266/**
9267 * @interface MouseEvent
9268 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9269 */
9270var MouseEventInterface = {
9271 screenX: null,
9272 screenY: null,
9273 clientX: null,
9274 clientY: null,
9275 ctrlKey: null,
9276 shiftKey: null,
9277 altKey: null,
9278 metaKey: null,
9279 button: function(event) {
9280 // Webkit, Firefox, IE9+
9281 // which: 1 2 3
9282 // button: 0 1 2 (standard)
9283 var button = event.button;
9284 if ('which' in event) {
9285 return button;
9286 }
9287 // IE<9
9288 // which: undefined
9289 // button: 0 0 0
9290 // button: 1 4 2 (onmouseup)
9291 return button === 2 ? 2 : button === 4 ? 1 : 0;
9292 },
9293 buttons: null,
9294 relatedTarget: function(event) {
9295 return event.relatedTarget || (
9296 event.fromElement === event.srcElement ?
9297 event.toElement :
9298 event.fromElement
9299 );
9300 },
9301 // "Proprietary" Interface.
9302 pageX: function(event) {
9303 return 'pageX' in event ?
9304 event.pageX :
9305 event.clientX + ViewportMetrics.currentScrollLeft;
9306 },
9307 pageY: function(event) {
9308 return 'pageY' in event ?
9309 event.pageY :
9310 event.clientY + ViewportMetrics.currentScrollTop;
9311 }
9312};
9313
9314/**
9315 * @param {object} dispatchConfig Configuration used to dispatch this event.
9316 * @param {string} dispatchMarker Marker identifying the event target.
9317 * @param {object} nativeEvent Native browser event.
9318 * @extends {SyntheticUIEvent}
9319 */
9320function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9321 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9322}
9323
9324SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
9325
9326module.exports = SyntheticMouseEvent;
9327
9328},{"./SyntheticUIEvent":57,"./ViewportMetrics":60}],55:[function(require,module,exports){
9329/**
9330 * Copyright 2013 Facebook, Inc.
9331 *
9332 * Licensed under the Apache License, Version 2.0 (the "License");
9333 * you may not use this file except in compliance with the License.
9334 * You may obtain a copy of the License at
9335 *
9336 * http://www.apache.org/licenses/LICENSE-2.0
9337 *
9338 * Unless required by applicable law or agreed to in writing, software
9339 * distributed under the License is distributed on an "AS IS" BASIS,
9340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9341 * See the License for the specific language governing permissions and
9342 * limitations under the License.
9343 *
9344 * @providesModule SyntheticMutationEvent
9345 * @typechecks static-only
9346 */
9347
9348"use strict";
9349
9350var SyntheticEvent = require("./SyntheticEvent");
9351
9352/**
9353 * @interface MutationEvent
9354 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9355 */
9356var MutationEventInterface = {
9357 relatedNode: null,
9358 prevValue: null,
9359 newValue: null,
9360 attrName: null,
9361 attrChange: null
9362};
9363
9364/**
9365 * @param {object} dispatchConfig Configuration used to dispatch this event.
9366 * @param {string} dispatchMarker Marker identifying the event target.
9367 * @param {object} nativeEvent Native browser event.
9368 * @extends {SyntheticEvent}
9369 */
9370function SyntheticMutationEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9371 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9372}
9373
9374SyntheticEvent.augmentClass(SyntheticMutationEvent, MutationEventInterface);
9375
9376module.exports = SyntheticMutationEvent;
9377
9378},{"./SyntheticEvent":51}],56:[function(require,module,exports){
9379/**
9380 * Copyright 2013 Facebook, Inc.
9381 *
9382 * Licensed under the Apache License, Version 2.0 (the "License");
9383 * you may not use this file except in compliance with the License.
9384 * You may obtain a copy of the License at
9385 *
9386 * http://www.apache.org/licenses/LICENSE-2.0
9387 *
9388 * Unless required by applicable law or agreed to in writing, software
9389 * distributed under the License is distributed on an "AS IS" BASIS,
9390 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9391 * See the License for the specific language governing permissions and
9392 * limitations under the License.
9393 *
9394 * @providesModule SyntheticTouchEvent
9395 * @typechecks static-only
9396 */
9397
9398"use strict";
9399
9400var SyntheticUIEvent = require("./SyntheticUIEvent");
9401
9402/**
9403 * @interface TouchEvent
9404 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9405 */
9406var TouchEventInterface = {
9407 touches: null,
9408 targetTouches: null,
9409 changedTouches: null,
9410 altKey: null,
9411 metaKey: null,
9412 ctrlKey: null,
9413 shiftKey: null
9414};
9415
9416/**
9417 * @param {object} dispatchConfig Configuration used to dispatch this event.
9418 * @param {string} dispatchMarker Marker identifying the event target.
9419 * @param {object} nativeEvent Native browser event.
9420 * @extends {SyntheticUIEvent}
9421 */
9422function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9423 SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9424}
9425
9426SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
9427
9428module.exports = SyntheticTouchEvent;
9429
9430},{"./SyntheticUIEvent":57}],57:[function(require,module,exports){
9431/**
9432 * Copyright 2013 Facebook, Inc.
9433 *
9434 * Licensed under the Apache License, Version 2.0 (the "License");
9435 * you may not use this file except in compliance with the License.
9436 * You may obtain a copy of the License at
9437 *
9438 * http://www.apache.org/licenses/LICENSE-2.0
9439 *
9440 * Unless required by applicable law or agreed to in writing, software
9441 * distributed under the License is distributed on an "AS IS" BASIS,
9442 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9443 * See the License for the specific language governing permissions and
9444 * limitations under the License.
9445 *
9446 * @providesModule SyntheticUIEvent
9447 * @typechecks static-only
9448 */
9449
9450"use strict";
9451
9452var SyntheticEvent = require("./SyntheticEvent");
9453
9454/**
9455 * @interface UIEvent
9456 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9457 */
9458var UIEventInterface = {
9459 view: null,
9460 detail: null
9461};
9462
9463/**
9464 * @param {object} dispatchConfig Configuration used to dispatch this event.
9465 * @param {string} dispatchMarker Marker identifying the event target.
9466 * @param {object} nativeEvent Native browser event.
9467 * @extends {SyntheticEvent}
9468 */
9469function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9470 SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9471}
9472
9473SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
9474
9475module.exports = SyntheticUIEvent;
9476
9477},{"./SyntheticEvent":51}],58:[function(require,module,exports){
9478/**
9479 * Copyright 2013 Facebook, Inc.
9480 *
9481 * Licensed under the Apache License, Version 2.0 (the "License");
9482 * you may not use this file except in compliance with the License.
9483 * You may obtain a copy of the License at
9484 *
9485 * http://www.apache.org/licenses/LICENSE-2.0
9486 *
9487 * Unless required by applicable law or agreed to in writing, software
9488 * distributed under the License is distributed on an "AS IS" BASIS,
9489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9490 * See the License for the specific language governing permissions and
9491 * limitations under the License.
9492 *
9493 * @providesModule SyntheticWheelEvent
9494 * @typechecks static-only
9495 */
9496
9497"use strict";
9498
9499var SyntheticMouseEvent = require("./SyntheticMouseEvent");
9500
9501/**
9502 * @interface WheelEvent
9503 * @see http://www.w3.org/TR/DOM-Level-3-Events/
9504 */
9505var WheelEventInterface = {
9506 deltaX: function(event) {
9507 // NOTE: IE<9 does not support x-axis delta.
9508 return (
9509 'deltaX' in event ? event.deltaX :
9510 // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
9511 'wheelDeltaX' in event ? -event.wheelDeltaX : 0
9512 );
9513 },
9514 deltaY: function(event) {
9515 return (
9516 // Normalize (up is positive).
9517 'deltaY' in event ? -event.deltaY :
9518 // Fallback to `wheelDeltaY` for Webkit.
9519 'wheelDeltaY' in event ? event.wheelDeltaY :
9520 // Fallback to `wheelDelta` for IE<9.
9521 'wheelDelta' in event ? event.wheelData : 0
9522 );
9523 },
9524 deltaZ: null,
9525 deltaMode: null
9526};
9527
9528/**
9529 * @param {object} dispatchConfig Configuration used to dispatch this event.
9530 * @param {string} dispatchMarker Marker identifying the event target.
9531 * @param {object} nativeEvent Native browser event.
9532 * @extends {SyntheticMouseEvent}
9533 */
9534function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
9535 SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
9536}
9537
9538SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
9539
9540module.exports = SyntheticWheelEvent;
9541
9542},{"./SyntheticMouseEvent":54}],59:[function(require,module,exports){
9543(function(){/**
9544 * Copyright 2013 Facebook, Inc.
9545 *
9546 * Licensed under the Apache License, Version 2.0 (the "License");
9547 * you may not use this file except in compliance with the License.
9548 * You may obtain a copy of the License at
9549 *
9550 * http://www.apache.org/licenses/LICENSE-2.0
9551 *
9552 * Unless required by applicable law or agreed to in writing, software
9553 * distributed under the License is distributed on an "AS IS" BASIS,
9554 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9555 * See the License for the specific language governing permissions and
9556 * limitations under the License.
9557 *
9558 * @providesModule Transaction
9559 */
9560
9561"use strict";
9562
9563var invariant = require("./invariant");
9564
9565/**
9566 * `Transaction` creates a black box that is able to wrap any method such that
9567 * certain invariants are maintained before and after the method is invoked
9568 * (Even if an exception is thrown while invoking the wrapped method). Whoever
9569 * instantiates a transaction can provide enforcers of the invariants at
9570 * creation time. The `Transaction` class itself will supply one additional
9571 * automatic invariant for you - the invariant that any transaction instance
9572 * should not be ran while it is already being ran. You would typically create a
9573 * single instance of a `Transaction` for reuse multiple times, that potentially
9574 * is used to wrap several different methods. Wrappers are extremely simple -
9575 * they only require implementing two methods.
9576 *
9577 * <pre>
9578 * wrappers (injected at creation time)
9579 * + +
9580 * | |
9581 * +-----------------|--------|--------------+
9582 * | v | |
9583 * | +---------------+ | |
9584 * | +--| wrapper1 |---|----+ |
9585 * | | +---------------+ v | |
9586 * | | +-------------+ | |
9587 * | | +----| wrapper2 |--------+ |
9588 * | | | +-------------+ | | |
9589 * | | | | | |
9590 * | v v v v | wrapper
9591 * | +---+ +---+ +---------+ +---+ +---+ | invariants
9592 * perform(anyMethod) | | | | | | | | | | | | maintained
9593 * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
9594 * | | | | | | | | | | | |
9595 * | | | | | | | | | | | |
9596 * | | | | | | | | | | | |
9597 * | +---+ +---+ +---------+ +---+ +---+ |
9598 * | initialize close |
9599 * +-----------------------------------------+
9600 * </pre>
9601 *
9602 * Bonus:
9603 * - Reports timing metrics by method name and wrapper index.
9604 *
9605 * Use cases:
9606 * - Preserving the input selection ranges before/after reconciliation.
9607 * Restoring selection even in the event of an unexpected error.
9608 * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
9609 * while guaranteeing that afterwards, the event system is reactivated.
9610 * - Flushing a queue of collected DOM mutations to the main UI thread after a
9611 * reconciliation takes place in a worker thread.
9612 * - Invoking any collected `componentDidRender` callbacks after rendering new
9613 * content.
9614 * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
9615 * to preserve the `scrollTop` (an automatic scroll aware DOM).
9616 * - (Future use case): Layout calculations before and after DOM upates.
9617 *
9618 * Transactional plugin API:
9619 * - A module that has an `initialize` method that returns any precomputation.
9620 * - and a `close` method that accepts the precomputation. `close` is invoked
9621 * when the wrapped process is completed, or has failed.
9622 *
9623 * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
9624 * that implement `initialize` and `close`.
9625 * @return {Transaction} Single transaction for reuse in thread.
9626 *
9627 * @class Transaction
9628 */
9629var Mixin = {
9630 /**
9631 * Sets up this instance so that it is prepared for collecting metrics. Does
9632 * so such that this setup method may be used on an instance that is already
9633 * initialized, in a way that does not consume additional memory upon reuse.
9634 * That can be useful if you decide to make your subclass of this mixin a
9635 * "PooledClass".
9636 */
9637 reinitializeTransaction: function() {
9638 this.transactionWrappers = this.getTransactionWrappers();
9639 if (!this.wrapperInitData) {
9640 this.wrapperInitData = [];
9641 } else {
9642 this.wrapperInitData.length = 0;
9643 }
9644 if (!this.timingMetrics) {
9645 this.timingMetrics = {};
9646 }
9647 this.timingMetrics.methodInvocationTime = 0;
9648 if (!this.timingMetrics.wrapperInitTimes) {
9649 this.timingMetrics.wrapperInitTimes = [];
9650 } else {
9651 this.timingMetrics.wrapperInitTimes.length = 0;
9652 }
9653 if (!this.timingMetrics.wrapperCloseTimes) {
9654 this.timingMetrics.wrapperCloseTimes = [];
9655 } else {
9656 this.timingMetrics.wrapperCloseTimes.length = 0;
9657 }
9658 this._isInTransaction = false;
9659 },
9660
9661 _isInTransaction: false,
9662
9663 /**
9664 * @abstract
9665 * @return {Array<TransactionWrapper>} Array of transaction wrappers.
9666 */
9667 getTransactionWrappers: null,
9668
9669 isInTransaction: function() {
9670 return !!this._isInTransaction;
9671 },
9672
9673 /**
9674 * Executes the function within a safety window. Use this for the top level
9675 * methods that result in large amounts of computation/mutations that would
9676 * need to be safety checked.
9677 *
9678 * @param {function} method Member of scope to call.
9679 * @param {Object} scope Scope to invoke from.
9680 * @param {Object?=} args... Arguments to pass to the method (optional).
9681 * Helps prevent need to bind in many cases.
9682 * @return Return value from `method`.
9683 */
9684 perform: function(method, scope, a, b, c, d, e, f) {
9685 invariant(
9686 !this.isInTransaction(),
9687 'Transaction.perform(...): Cannot initialize a transaction when there ' +
9688 'is already an outstanding transaction.'
9689 );
9690 var memberStart = Date.now();
9691 var errorToThrow = null;
9692 var ret;
9693 try {
9694 this.initializeAll();
9695 ret = method.call(scope, a, b, c, d, e, f);
9696 } catch (error) {
9697 // IE8 requires `catch` in order to use `finally`.
9698 errorToThrow = error;
9699 } finally {
9700 var memberEnd = Date.now();
9701 this.methodInvocationTime += (memberEnd - memberStart);
9702 try {
9703 this.closeAll();
9704 } catch (closeError) {
9705 // If `method` throws, prefer to show that stack trace over any thrown
9706 // by invoking `closeAll`.
9707 errorToThrow = errorToThrow || closeError;
9708 }
9709 }
9710 if (errorToThrow) {
9711 throw errorToThrow;
9712 }
9713 return ret;
9714 },
9715
9716 initializeAll: function() {
9717 this._isInTransaction = true;
9718 var transactionWrappers = this.transactionWrappers;
9719 var wrapperInitTimes = this.timingMetrics.wrapperInitTimes;
9720 var errorToThrow = null;
9721 for (var i = 0; i < transactionWrappers.length; i++) {
9722 var initStart = Date.now();
9723 var wrapper = transactionWrappers[i];
9724 try {
9725 this.wrapperInitData[i] = wrapper.initialize ?
9726 wrapper.initialize.call(this) :
9727 null;
9728 } catch (initError) {
9729 // Prefer to show the stack trace of the first error.
9730 errorToThrow = errorToThrow || initError;
9731 this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
9732 } finally {
9733 var curInitTime = wrapperInitTimes[i];
9734 var initEnd = Date.now();
9735 wrapperInitTimes[i] = (curInitTime || 0) + (initEnd - initStart);
9736 }
9737 }
9738 if (errorToThrow) {
9739 throw errorToThrow;
9740 }
9741 },
9742
9743 /**
9744 * Invokes each of `this.transactionWrappers.close[i]` functions, passing into
9745 * them the respective return values of `this.transactionWrappers.init[i]`
9746 * (`close`rs that correspond to initializers that failed will not be
9747 * invoked).
9748 */
9749 closeAll: function() {
9750 invariant(
9751 this.isInTransaction(),
9752 'Transaction.closeAll(): Cannot close transaction when none are open.'
9753 );
9754 var transactionWrappers = this.transactionWrappers;
9755 var wrapperCloseTimes = this.timingMetrics.wrapperCloseTimes;
9756 var errorToThrow = null;
9757 for (var i = 0; i < transactionWrappers.length; i++) {
9758 var wrapper = transactionWrappers[i];
9759 var closeStart = Date.now();
9760 var initData = this.wrapperInitData[i];
9761 try {
9762 if (initData !== Transaction.OBSERVED_ERROR) {
9763 wrapper.close && wrapper.close.call(this, initData);
9764 }
9765 } catch (closeError) {
9766 // Prefer to show the stack trace of the first error.
9767 errorToThrow = errorToThrow || closeError;
9768 } finally {
9769 var closeEnd = Date.now();
9770 var curCloseTime = wrapperCloseTimes[i];
9771 wrapperCloseTimes[i] = (curCloseTime || 0) + (closeEnd - closeStart);
9772 }
9773 }
9774 this.wrapperInitData.length = 0;
9775 this._isInTransaction = false;
9776 if (errorToThrow) {
9777 throw errorToThrow;
9778 }
9779 }
9780};
9781
9782var Transaction = {
9783
9784 Mixin: Mixin,
9785
9786 /**
9787 * Token to look for to determine if an error occured.
9788 */
9789 OBSERVED_ERROR: {}
9790
9791};
9792
9793module.exports = Transaction;
9794
9795})()
9796},{"./invariant":78}],60:[function(require,module,exports){
9797/**
9798 * Copyright 2013 Facebook, Inc.
9799 *
9800 * Licensed under the Apache License, Version 2.0 (the "License");
9801 * you may not use this file except in compliance with the License.
9802 * You may obtain a copy of the License at
9803 *
9804 * http://www.apache.org/licenses/LICENSE-2.0
9805 *
9806 * Unless required by applicable law or agreed to in writing, software
9807 * distributed under the License is distributed on an "AS IS" BASIS,
9808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9809 * See the License for the specific language governing permissions and
9810 * limitations under the License.
9811 *
9812 * @providesModule ViewportMetrics
9813 */
9814
9815"use strict";
9816
9817var ViewportMetrics = {
9818
9819 currentScrollLeft: 0,
9820
9821 currentScrollTop: 0,
9822
9823 refreshScrollValues: function() {
9824 ViewportMetrics.currentScrollLeft =
9825 document.body.scrollLeft + document.documentElement.scrollLeft;
9826 ViewportMetrics.currentScrollTop =
9827 document.body.scrollTop + document.documentElement.scrollTop;
9828 }
9829
9830};
9831
9832module.exports = ViewportMetrics;
9833
9834},{}],61:[function(require,module,exports){
9835/**
9836 * Copyright 2013 Facebook, Inc.
9837 *
9838 * Licensed under the Apache License, Version 2.0 (the "License");
9839 * you may not use this file except in compliance with the License.
9840 * You may obtain a copy of the License at
9841 *
9842 * http://www.apache.org/licenses/LICENSE-2.0
9843 *
9844 * Unless required by applicable law or agreed to in writing, software
9845 * distributed under the License is distributed on an "AS IS" BASIS,
9846 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9847 * See the License for the specific language governing permissions and
9848 * limitations under the License.
9849 *
9850 * @providesModule accumulate
9851 */
9852
9853"use strict";
9854
9855var invariant = require("./invariant");
9856
9857/**
9858 * Accumulates items that must not be null or undefined.
9859 *
9860 * This is used to conserve memory by avoiding array allocations.
9861 *
9862 * @return {*|array<*>} An accumulation of items.
9863 */
9864function accumulate(current, next) {
9865 invariant(
9866 next != null,
9867 'accumulate(...): Accumulated items must be not be null or undefined.'
9868 );
9869 if (current == null) {
9870 return next;
9871 } else {
9872 // Both are not empty. Warning: Never call x.concat(y) when you are not
9873 // certain that x is an Array (x could be a string with concat method).
9874 var currentIsArray = Array.isArray(current);
9875 var nextIsArray = Array.isArray(next);
9876 if (currentIsArray) {
9877 return current.concat(next);
9878 } else {
9879 if (nextIsArray) {
9880 return [current].concat(next);
9881 } else {
9882 return [current, next];
9883 }
9884 }
9885 }
9886}
9887
9888module.exports = accumulate;
9889
9890},{"./invariant":78}],62:[function(require,module,exports){
9891/**
9892 * Copyright 2013 Facebook, Inc.
9893 *
9894 * Licensed under the Apache License, Version 2.0 (the "License");
9895 * you may not use this file except in compliance with the License.
9896 * You may obtain a copy of the License at
9897 *
9898 * http://www.apache.org/licenses/LICENSE-2.0
9899 *
9900 * Unless required by applicable law or agreed to in writing, software
9901 * distributed under the License is distributed on an "AS IS" BASIS,
9902 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9903 * See the License for the specific language governing permissions and
9904 * limitations under the License.
9905 *
9906 * @providesModule adler32
9907 */
9908
9909"use strict";
9910
9911var MOD = 65521;
9912
9913// This is a clean-room implementation of adler32 designed for detecting
9914// if markup is not what we expect it to be. It does not need to be
9915// cryptographically strong, only reasonable good at detecting if markup
9916// generated on the server is different than that on the client.
9917function adler32(data) {
9918 var a = 1;
9919 var b = 0;
9920 for (var i = 0; i < data.length; i++) {
9921 a = (a + data.charCodeAt(i)) % MOD;
9922 b = (b + a) % MOD;
9923 }
9924 return a | (b << 16);
9925}
9926
9927module.exports = adler32;
9928
9929},{}],63:[function(require,module,exports){
9930/**
9931 * Copyright 2013 Facebook, Inc.
9932 *
9933 * Licensed under the Apache License, Version 2.0 (the "License");
9934 * you may not use this file except in compliance with the License.
9935 * You may obtain a copy of the License at
9936 *
9937 * http://www.apache.org/licenses/LICENSE-2.0
9938 *
9939 * Unless required by applicable law or agreed to in writing, software
9940 * distributed under the License is distributed on an "AS IS" BASIS,
9941 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9942 * See the License for the specific language governing permissions and
9943 * limitations under the License.
9944 *
9945 * @providesModule copyProperties
9946 */
9947
9948/**
9949 * Copy properties from one or more objects (up to 5) into the first object.
9950 * This is a shallow copy. It mutates the first object and also returns it.
9951 *
9952 * NOTE: `arguments` has a very significant performance penalty, which is why
9953 * we don't support unlimited arguments.
9954 */
9955function copyProperties(obj, a, b, c, d, e, f) {
9956 obj = obj || {};
9957
9958 if (true) {
9959 if (f) {
9960 throw new Error('Too many arguments passed to copyProperties');
9961 }
9962 }
9963
9964 var args = [a, b, c, d, e];
9965 var ii = 0, v;
9966 while (args[ii]) {
9967 v = args[ii++];
9968 for (var k in v) {
9969 obj[k] = v[k];
9970 }
9971
9972 // IE ignores toString in object iteration.. See:
9973 // webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html
9974 if (v.hasOwnProperty && v.hasOwnProperty('toString') &&
9975 (typeof v.toString != 'undefined') && (obj.toString !== v.toString)) {
9976 obj.toString = v.toString;
9977 }
9978 }
9979
9980 return obj;
9981}
9982
9983module.exports = copyProperties;
9984
9985},{}],64:[function(require,module,exports){
9986/**
9987 * Copyright 2013 Facebook, Inc.
9988 *
9989 * Licensed under the Apache License, Version 2.0 (the "License");
9990 * you may not use this file except in compliance with the License.
9991 * You may obtain a copy of the License at
9992 *
9993 * http://www.apache.org/licenses/LICENSE-2.0
9994 *
9995 * Unless required by applicable law or agreed to in writing, software
9996 * distributed under the License is distributed on an "AS IS" BASIS,
9997 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9998 * See the License for the specific language governing permissions and
9999 * limitations under the License.
10000 *
10001 * @providesModule createObjectFrom
10002 */
10003
10004var hasArrayNature = require("./hasArrayNature");
10005
10006/**
10007 * Construct an object from an array of keys
10008 * and optionally specified value or list of values.
10009 *
10010 * >>> createObjectFrom(['a','b','c']);
10011 * {a: true, b: true, c: true}
10012 *
10013 * >>> createObjectFrom(['a','b','c'], false);
10014 * {a: false, b: false, c: false}
10015 *
10016 * >>> createObjectFrom(['a','b','c'], 'monkey');
10017 * {c:'monkey', b:'monkey' c:'monkey'}
10018 *
10019 * >>> createObjectFrom(['a','b','c'], [1,2,3]);
10020 * {a: 1, b: 2, c: 3}
10021 *
10022 * >>> createObjectFrom(['women', 'men'], [true, false]);
10023 * {women: true, men: false}
10024 *
10025 * @param Array list of keys
10026 * @param mixed optional value or value array. defaults true.
10027 * @returns object
10028 */
10029function createObjectFrom(keys, values /* = true */) {
10030 if (true) {
10031 if (!hasArrayNature(keys)) {
10032 throw new TypeError('Must pass an array of keys.');
10033 }
10034 }
10035
10036 var object = {};
10037 var is_array = hasArrayNature(values);
10038 if (typeof values == 'undefined') {
10039 values = true;
10040 }
10041
10042 for (var ii = keys.length; ii--;) {
10043 object[keys[ii]] = is_array ? values[ii] : values;
10044 }
10045 return object;
10046}
10047
10048module.exports = createObjectFrom;
10049
10050},{"./hasArrayNature":75}],65:[function(require,module,exports){
10051/**
10052 * Copyright 2013 Facebook, Inc.
10053 *
10054 * Licensed under the Apache License, Version 2.0 (the "License");
10055 * you may not use this file except in compliance with the License.
10056 * You may obtain a copy of the License at
10057 *
10058 * http://www.apache.org/licenses/LICENSE-2.0
10059 *
10060 * Unless required by applicable law or agreed to in writing, software
10061 * distributed under the License is distributed on an "AS IS" BASIS,
10062 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10063 * See the License for the specific language governing permissions and
10064 * limitations under the License.
10065 *
10066 * @providesModule dangerousStyleValue
10067 * @typechecks static-only
10068 */
10069
10070"use strict";
10071
10072var CSSProperty = require("./CSSProperty");
10073
10074/**
10075 * Convert a value into the proper css writable value. The `styleName` name
10076 * name should be logical (no hyphens), as specified
10077 * in `CSSProperty.isUnitlessNumber`.
10078 *
10079 * @param {string} styleName CSS property name such as `topMargin`.
10080 * @param {*} value CSS property value such as `10px`.
10081 * @return {string} Normalized style value with dimensions applied.
10082 */
10083function dangerousStyleValue(styleName, value) {
10084 // Note that we've removed escapeTextForBrowser() calls here since the
10085 // whole string will be escaped when the attribute is injected into
10086 // the markup. If you provide unsafe user data here they can inject
10087 // arbitrary CSS which may be problematic (I couldn't repro this):
10088 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
10089 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
10090 // This is not an XSS hole but instead a potential CSS injection issue
10091 // which has lead to a greater discussion about how we're going to
10092 // trust URLs moving forward. See #2115901
10093
10094 var isEmpty = value == null || typeof value === 'boolean' || value === '';
10095 if (isEmpty) {
10096 return '';
10097 }
10098
10099 var isNonNumeric = isNaN(value);
10100 if (isNonNumeric || value === 0 || CSSProperty.isUnitlessNumber[styleName]) {
10101 return '' + value; // cast to string
10102 }
10103
10104 return value + 'px';
10105}
10106
10107module.exports = dangerousStyleValue;
10108
10109},{"./CSSProperty":2}],66:[function(require,module,exports){
10110/**
10111 * Copyright 2013 Facebook, Inc.
10112 *
10113 * Licensed under the Apache License, Version 2.0 (the "License");
10114 * you may not use this file except in compliance with the License.
10115 * You may obtain a copy of the License at
10116 *
10117 * http://www.apache.org/licenses/LICENSE-2.0
10118 *
10119 * Unless required by applicable law or agreed to in writing, software
10120 * distributed under the License is distributed on an "AS IS" BASIS,
10121 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10122 * See the License for the specific language governing permissions and
10123 * limitations under the License.
10124 *
10125 * @providesModule emptyFunction
10126 */
10127
10128var copyProperties = require("./copyProperties");
10129
10130function makeEmptyFunction(arg) {
10131 return function() {
10132 return arg;
10133 };
10134}
10135
10136/**
10137 * This function accepts and discards inputs; it has no side effects. This is
10138 * primarily useful idiomatically for overridable function endpoints which
10139 * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
10140 */
10141function emptyFunction() {}
10142
10143copyProperties(emptyFunction, {
10144 thatReturns: makeEmptyFunction,
10145 thatReturnsFalse: makeEmptyFunction(false),
10146 thatReturnsTrue: makeEmptyFunction(true),
10147 thatReturnsNull: makeEmptyFunction(null),
10148 thatReturnsThis: function() { return this; },
10149 thatReturnsArgument: function(arg) { return arg; }
10150});
10151
10152module.exports = emptyFunction;
10153
10154},{"./copyProperties":63}],67:[function(require,module,exports){
10155/**
10156 * Copyright 2013 Facebook, Inc.
10157 *
10158 * Licensed under the Apache License, Version 2.0 (the "License");
10159 * you may not use this file except in compliance with the License.
10160 * You may obtain a copy of the License at
10161 *
10162 * http://www.apache.org/licenses/LICENSE-2.0
10163 *
10164 * Unless required by applicable law or agreed to in writing, software
10165 * distributed under the License is distributed on an "AS IS" BASIS,
10166 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10167 * See the License for the specific language governing permissions and
10168 * limitations under the License.
10169 *
10170 * @providesModule escapeTextForBrowser
10171 * @typechecks static-only
10172 */
10173
10174"use strict";
10175
10176var invariant = require("./invariant");
10177
10178var ESCAPE_LOOKUP = {
10179 "&": "&amp;",
10180 ">": "&gt;",
10181 "<": "&lt;",
10182 "\"": "&quot;",
10183 "'": "&#x27;",
10184 "/": "&#x2f;"
10185};
10186
10187function escaper(match) {
10188 return ESCAPE_LOOKUP[match];
10189}
10190
10191/**
10192 * Escapes text to prevent scripting attacks.
10193 *
10194 * @param {number|string} text Text value to escape.
10195 * @return {string} An escaped string.
10196 */
10197function escapeTextForBrowser(text) {
10198 var type = typeof text;
10199 invariant(
10200 type !== 'object',
10201 'escapeTextForBrowser(...): Attempted to escape an object.'
10202 );
10203 if (text === '') {
10204 return '';
10205 } else {
10206 if (type === 'string') {
10207 return text.replace(/[&><"'\/]/g, escaper);
10208 } else {
10209 return (''+text).replace(/[&><"'\/]/g, escaper);
10210 }
10211 }
10212}
10213
10214module.exports = escapeTextForBrowser;
10215
10216},{"./invariant":78}],68:[function(require,module,exports){
10217/**
10218 * Copyright 2013 Facebook, Inc.
10219 *
10220 * Licensed under the Apache License, Version 2.0 (the "License");
10221 * you may not use this file except in compliance with the License.
10222 * You may obtain a copy of the License at
10223 *
10224 * http://www.apache.org/licenses/LICENSE-2.0
10225 *
10226 * Unless required by applicable law or agreed to in writing, software
10227 * distributed under the License is distributed on an "AS IS" BASIS,
10228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10229 * See the License for the specific language governing permissions and
10230 * limitations under the License.
10231 *
10232 * @providesModule ex
10233 * @typechecks
10234 * @nostacktrace
10235 */
10236
10237/**
10238 * This function transforms error message with arguments into plain text error
10239 * message, so that it can be passed to window.onerror without losing anything.
10240 * It can then be transformed back by `erx()` function.
10241 *
10242 * Usage:
10243 * throw new Error(ex('Error %s from %s', errorCode, userID));
10244 *
10245 * @param {string} errorMessage
10246 */
10247
10248var ex = function(errorMessage/*, arg1, arg2, ...*/) {
10249 var args = Array.prototype.slice.call(arguments).map(function(arg) {
10250 return String(arg);
10251 });
10252 var expectedLength = errorMessage.split('%s').length - 1;
10253
10254 if (expectedLength !== args.length - 1) {
10255 // something wrong with the formatting string
10256 return ex('ex args number mismatch: %s', JSON.stringify(args));
10257 }
10258
10259 return ex._prefix + JSON.stringify(args) + ex._suffix;
10260};
10261
10262ex._prefix = '<![EX[';
10263ex._suffix = ']]>';
10264
10265module.exports = ex;
10266
10267},{}],69:[function(require,module,exports){
10268/**
10269 * Copyright 2013 Facebook, Inc.
10270 *
10271 * Licensed under the Apache License, Version 2.0 (the "License");
10272 * you may not use this file except in compliance with the License.
10273 * You may obtain a copy of the License at
10274 *
10275 * http://www.apache.org/licenses/LICENSE-2.0
10276 *
10277 * Unless required by applicable law or agreed to in writing, software
10278 * distributed under the License is distributed on an "AS IS" BASIS,
10279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10280 * See the License for the specific language governing permissions and
10281 * limitations under the License.
10282 *
10283 * @providesModule flattenChildren
10284 */
10285
10286"use strict";
10287
10288var invariant = require("./invariant");
10289var traverseAllChildren = require("./traverseAllChildren");
10290
10291/**
10292 * @param {function} traverseContext Context passed through traversal.
10293 * @param {?ReactComponent} child React child component.
10294 * @param {!string} name String name of key path to child.
10295 */
10296function flattenSingleChildIntoContext(traverseContext, child, name) {
10297 // We found a component instance.
10298 var result = traverseContext;
10299 invariant(
10300 !result.hasOwnProperty(name),
10301 'flattenChildren(...): Encountered two children with the same key, `%s`. ' +
10302 'Children keys must be unique.',
10303 name
10304 );
10305 result[name] = child;
10306}
10307
10308/**
10309 * Flattens children that are typically specified as `props.children`.
10310 * @return {!object} flattened children keyed by name.
10311 */
10312function flattenChildren(children) {
10313 if (children == null) {
10314 return children;
10315 }
10316 var result = {};
10317 traverseAllChildren(children, flattenSingleChildIntoContext, result);
10318 return result;
10319}
10320
10321module.exports = flattenChildren;
10322
10323},{"./invariant":78,"./traverseAllChildren":90}],70:[function(require,module,exports){
10324/**
10325 * Copyright 2013 Facebook, Inc.
10326 *
10327 * Licensed under the Apache License, Version 2.0 (the "License");
10328 * you may not use this file except in compliance with the License.
10329 * You may obtain a copy of the License at
10330 *
10331 * http://www.apache.org/licenses/LICENSE-2.0
10332 *
10333 * Unless required by applicable law or agreed to in writing, software
10334 * distributed under the License is distributed on an "AS IS" BASIS,
10335 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10336 * See the License for the specific language governing permissions and
10337 * limitations under the License.
10338 *
10339 * @providesModule forEachAccumulated
10340 */
10341
10342"use strict";
10343
10344/**
10345 * @param {array} an "accumulation" of items which is either an Array or
10346 * a single item. Useful when paired with the `accumulate` module. This is a
10347 * simple utility that allows us to reason about a collection of items, but
10348 * handling the case when there is exactly one item (and we do not need to
10349 * allocate an array).
10350 */
10351var forEachAccumulated = function(arr, cb, scope) {
10352 if (Array.isArray(arr)) {
10353 arr.forEach(cb, scope);
10354 } else if (arr) {
10355 cb.call(scope, arr);
10356 }
10357};
10358
10359module.exports = forEachAccumulated;
10360
10361},{}],71:[function(require,module,exports){
10362/**
10363 * Copyright 2013 Facebook, Inc.
10364 *
10365 * Licensed under the Apache License, Version 2.0 (the "License");
10366 * you may not use this file except in compliance with the License.
10367 * You may obtain a copy of the License at
10368 *
10369 * http://www.apache.org/licenses/LICENSE-2.0
10370 *
10371 * Unless required by applicable law or agreed to in writing, software
10372 * distributed under the License is distributed on an "AS IS" BASIS,
10373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10374 * See the License for the specific language governing permissions and
10375 * limitations under the License.
10376 *
10377 * @providesModule ge
10378 */
10379
10380/**
10381 * Find a node by ID. Optionally search a sub-tree outside of the document
10382 *
10383 * Use ge if you're not sure whether or not the element exists. You can test
10384 * for existence yourself in your application code.
10385 *
10386 * If your application code depends on the existence of the element, use $
10387 * instead, which will throw in DEV if the element doesn't exist.
10388 */
10389function ge(arg, root, tag) {
10390 return typeof arg != 'string' ? arg :
10391 !root ? document.getElementById(arg) :
10392 _geFromSubtree(arg, root, tag);
10393}
10394
10395function _geFromSubtree(id, root, tag) {
10396 var elem, children, ii;
10397
10398 if (_getNodeID(root) == id) {
10399 return root;
10400 } else if (root.getElementsByTagName) {
10401 // All Elements implement this, which does an iterative DFS, which is
10402 // faster than recursion and doesn't run into stack depth issues.
10403 children = root.getElementsByTagName(tag || '*');
10404 for (ii = 0; ii < children.length; ii++) {
10405 if (_getNodeID(children[ii]) == id) {
10406 return children[ii];
10407 }
10408 }
10409 } else {
10410 // DocumentFragment does not implement getElementsByTagName, so
10411 // recurse over its children. Its children must be Elements, so
10412 // each child will use the getElementsByTagName case instead.
10413 children = root.childNodes;
10414 for (ii = 0; ii < children.length; ii++) {
10415 elem = _geFromSubtree(id, children[ii]);
10416 if (elem) {
10417 return elem;
10418 }
10419 }
10420 }
10421
10422 return null;
10423}
10424
10425/**
10426 * Return the ID value for a given node. This allows us to avoid issues
10427 * with forms that contain inputs with name="id".
10428 *
10429 * @return string (null if attribute not set)
10430 */
10431function _getNodeID(node) {
10432 // #document and #document-fragment do not have getAttributeNode.
10433 var id = node.getAttributeNode && node.getAttributeNode('id');
10434 return id ? id.value : null;
10435}
10436
10437module.exports = ge;
10438
10439},{}],72:[function(require,module,exports){
10440(function(){/**
10441 * Copyright 2013 Facebook, Inc.
10442 *
10443 * Licensed under the Apache License, Version 2.0 (the "License");
10444 * you may not use this file except in compliance with the License.
10445 * You may obtain a copy of the License at
10446 *
10447 * http://www.apache.org/licenses/LICENSE-2.0
10448 *
10449 * Unless required by applicable law or agreed to in writing, software
10450 * distributed under the License is distributed on an "AS IS" BASIS,
10451 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10452 * See the License for the specific language governing permissions and
10453 * limitations under the License.
10454 *
10455 * @providesModule getEventTarget
10456 * @typechecks static-only
10457 */
10458
10459"use strict";
10460
10461var ExecutionEnvironment = require("./ExecutionEnvironment");
10462
10463/**
10464 * Gets the target node from a native browser event by accounting for
10465 * inconsistencies in browser DOM APIs.
10466 *
10467 * @param {object} nativeEvent Native browser event.
10468 * @return {DOMEventTarget} Target node.
10469 */
10470function getEventTarget(nativeEvent) {
10471 var target =
10472 nativeEvent.target ||
10473 nativeEvent.srcElement ||
10474 ExecutionEnvironment.global;
10475 // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
10476 // @see http://www.quirksmode.org/js/events_properties.html
10477 return target.nodeType === 3 ? target.parentNode : target;
10478}
10479
10480module.exports = getEventTarget;
10481
10482})()
10483},{"./ExecutionEnvironment":19}],73:[function(require,module,exports){
10484/**
10485 * Copyright 2013 Facebook, Inc.
10486 *
10487 * Licensed under the Apache License, Version 2.0 (the "License");
10488 * you may not use this file except in compliance with the License.
10489 * You may obtain a copy of the License at
10490 *
10491 * http://www.apache.org/licenses/LICENSE-2.0
10492 *
10493 * Unless required by applicable law or agreed to in writing, software
10494 * distributed under the License is distributed on an "AS IS" BASIS,
10495 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10496 * See the License for the specific language governing permissions and
10497 * limitations under the License.
10498 *
10499 * @providesModule getReactRootElementInContainer
10500 */
10501
10502"use strict";
10503
10504/**
10505 * @param {DOMElement} container DOM element that may contain a React component
10506 * @return {?*} DOM element that may have the reactRoot ID, or null.
10507 */
10508function getReactRootElementInContainer(container) {
10509 return container && container.firstChild;
10510}
10511
10512module.exports = getReactRootElementInContainer;
10513
10514},{}],74:[function(require,module,exports){
10515/**
10516 * Copyright 2013 Facebook, Inc.
10517 *
10518 * Licensed under the Apache License, Version 2.0 (the "License");
10519 * you may not use this file except in compliance with the License.
10520 * You may obtain a copy of the License at
10521 *
10522 * http://www.apache.org/licenses/LICENSE-2.0
10523 *
10524 * Unless required by applicable law or agreed to in writing, software
10525 * distributed under the License is distributed on an "AS IS" BASIS,
10526 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10527 * See the License for the specific language governing permissions and
10528 * limitations under the License.
10529 *
10530 * @providesModule getTextContentAccessor
10531 */
10532
10533"use strict";
10534
10535var ExecutionEnvironment = require("./ExecutionEnvironment");
10536
10537var contentKey = null;
10538
10539/**
10540 * Gets the key used to access text content on a DOM node.
10541 *
10542 * @return {?string} Key used to access text content.
10543 * @internal
10544 */
10545function getTextContentAccessor() {
10546 if (!contentKey && ExecutionEnvironment.canUseDOM) {
10547 contentKey = 'innerText' in document.createElement('div') ?
10548 'innerText' :
10549 'textContent';
10550 }
10551 return contentKey;
10552}
10553
10554module.exports = getTextContentAccessor;
10555
10556},{"./ExecutionEnvironment":19}],75:[function(require,module,exports){
10557/**
10558 * Copyright 2013 Facebook, Inc.
10559 *
10560 * Licensed under the Apache License, Version 2.0 (the "License");
10561 * you may not use this file except in compliance with the License.
10562 * You may obtain a copy of the License at
10563 *
10564 * http://www.apache.org/licenses/LICENSE-2.0
10565 *
10566 * Unless required by applicable law or agreed to in writing, software
10567 * distributed under the License is distributed on an "AS IS" BASIS,
10568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10569 * See the License for the specific language governing permissions and
10570 * limitations under the License.
10571 *
10572 * @providesModule hasArrayNature
10573 */
10574
10575/**
10576 * Perform a heuristic test to determine if an object is "array-like".
10577 *
10578 * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
10579 * Joshu replied: "Mu."
10580 *
10581 * This function determines if its argument has "array nature": it returns
10582 * true if the argument is an actual array, an `arguments' object, or an
10583 * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
10584 *
10585 * @param obj An object to test.
10586 * @return bool True if the object is array-like.
10587 */
10588function hasArrayNature(obj) {
10589 return (
10590 // not null/false
10591 !!obj &&
10592 // arrays are objects, NodeLists are functions in Safari
10593 (typeof obj == 'object' || typeof obj == 'function') &&
10594 // quacks like an array
10595 ('length' in obj) &&
10596 // not window
10597 !('setInterval' in obj) &&
10598 // no DOM node should be considered an array-like
10599 // a 'select' element has 'length' and 'item' properties
10600 (typeof obj.nodeType != 'number') &&
10601 (
10602 // a real array
10603 (Array.isArray(obj) ||
10604 // arguments
10605 ('callee' in obj) || // HTMLCollection/NodeList
10606 'item' in obj)
10607 )
10608 );
10609}
10610
10611module.exports = hasArrayNature;
10612
10613},{}],76:[function(require,module,exports){
10614/**
10615 * Copyright 2013 Facebook, Inc.
10616 *
10617 * Licensed under the Apache License, Version 2.0 (the "License");
10618 * you may not use this file except in compliance with the License.
10619 * You may obtain a copy of the License at
10620 *
10621 * http://www.apache.org/licenses/LICENSE-2.0
10622 *
10623 * Unless required by applicable law or agreed to in writing, software
10624 * distributed under the License is distributed on an "AS IS" BASIS,
10625 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10626 * See the License for the specific language governing permissions and
10627 * limitations under the License.
10628 *
10629 * @providesModule hyphenate
10630 * @typechecks
10631 */
10632
10633var _uppercasePattern = /([A-Z])/g;
10634
10635/**
10636 * Hyphenates a camelcased string, for example:
10637 *
10638 * > hyphenate('backgroundColor')
10639 * < "background-color"
10640 *
10641 * @param {string} string
10642 * @return {string}
10643 */
10644function hyphenate(string) {
10645 return string.replace(_uppercasePattern, '-$1').toLowerCase();
10646}
10647
10648module.exports = hyphenate;
10649
10650},{}],77:[function(require,module,exports){
10651/**
10652 * Copyright 2013 Facebook, Inc.
10653 *
10654 * Licensed under the Apache License, Version 2.0 (the "License");
10655 * you may not use this file except in compliance with the License.
10656 * You may obtain a copy of the License at
10657 *
10658 * http://www.apache.org/licenses/LICENSE-2.0
10659 *
10660 * Unless required by applicable law or agreed to in writing, software
10661 * distributed under the License is distributed on an "AS IS" BASIS,
10662 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10663 * See the License for the specific language governing permissions and
10664 * limitations under the License.
10665 *
10666 * @providesModule insertNodeAt
10667 */
10668
10669"use strict";
10670
10671/**
10672 * Inserts `node` at a particular child index. Other nodes move to make room.
10673 * @param {!Element} root The parent root node to insert into.
10674 * @param {!node} node The node to insert.
10675 * @param {!number} atIndex The index in `root` that `node` should exist at.
10676 */
10677function insertNodeAt(root, node, atIndex) {
10678 var childNodes = root.childNodes;
10679 // Remove from parent so that if node is already child of root,
10680 // `childNodes[atIndex]` already takes into account the removal.
10681 var curAtIndex = root.childNodes[atIndex];
10682 if (curAtIndex === node) {
10683 return node;
10684 }
10685 if (node.parentNode) {
10686 node.parentNode.removeChild(node);
10687 }
10688 if (atIndex >= childNodes.length) {
10689 root.appendChild(node);
10690 } else {
10691 root.insertBefore(node, childNodes[atIndex]);
10692 }
10693 return node;
10694}
10695
10696module.exports = insertNodeAt;
10697
10698},{}],78:[function(require,module,exports){
10699/**
10700 * Copyright 2013 Facebook, Inc.
10701 *
10702 * Licensed under the Apache License, Version 2.0 (the "License");
10703 * you may not use this file except in compliance with the License.
10704 * You may obtain a copy of the License at
10705 *
10706 * http://www.apache.org/licenses/LICENSE-2.0
10707 *
10708 * Unless required by applicable law or agreed to in writing, software
10709 * distributed under the License is distributed on an "AS IS" BASIS,
10710 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10711 * See the License for the specific language governing permissions and
10712 * limitations under the License.
10713 *
10714 * @providesModule invariant
10715 */
10716
10717/**
10718 * Use invariant() to assert state which your program assumes to be true.
10719 *
10720 * Provide sprintf style format and arguments to provide information about
10721 * what broke and what you were expecting.
10722 *
10723 * The invariant message will be stripped in production, but the invariant
10724 * will remain to ensure logic does not differ in production.
10725 */
10726
10727function invariant(condition) {
10728 if (!condition) {
10729 throw new Error('Invariant Violation');
10730 }
10731}
10732
10733module.exports = invariant;
10734
10735if (true) {
10736 var invariantDev = function(condition, format, a, b, c, d, e, f) {
10737 if (format === undefined) {
10738 throw new Error('invariant requires an error message argument');
10739 }
10740
10741 if (!condition) {
10742 var args = [a, b, c, d, e, f];
10743 var argIndex = 0;
10744 throw new Error(
10745 'Invariant Violation: ' +
10746 format.replace(/%s/g, function() { return args[argIndex++]; })
10747 );
10748 }
10749 };
10750
10751 module.exports = invariantDev;
10752}
10753
10754},{}],79:[function(require,module,exports){
10755/**
10756 * Copyright 2013 Facebook, Inc.
10757 *
10758 * Licensed under the Apache License, Version 2.0 (the "License");
10759 * you may not use this file except in compliance with the License.
10760 * You may obtain a copy of the License at
10761 *
10762 * http://www.apache.org/licenses/LICENSE-2.0
10763 *
10764 * Unless required by applicable law or agreed to in writing, software
10765 * distributed under the License is distributed on an "AS IS" BASIS,
10766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10767 * See the License for the specific language governing permissions and
10768 * limitations under the License.
10769 *
10770 * @providesModule isEventSupported
10771 */
10772
10773"use strict";
10774
10775var ExecutionEnvironment = require("./ExecutionEnvironment");
10776
10777var testNode, useHasFeature;
10778if (ExecutionEnvironment.canUseDOM) {
10779 testNode = document.createElement('div');
10780 useHasFeature =
10781 document.implementation &&
10782 document.implementation.hasFeature &&
10783 // `hasFeature` always returns true in Firefox 19+.
10784 document.implementation.hasFeature('', '') !== true;
10785}
10786
10787/**
10788 * Checks if an event is supported in the current execution environment.
10789 *
10790 * NOTE: This will not work correctly for non-generic events such as `change`,
10791 * `reset`, `load`, `error`, and `select`.
10792 *
10793 * Borrows from Modernizr.
10794 *
10795 * @param {string} eventNameSuffix Event name, e.g. "click".
10796 * @param {?boolean} capture Check if the capture phase is supported.
10797 * @return {boolean} True if the event is supported.
10798 * @internal
10799 * @license Modernizr 3.0.0pre (Custom Build) | MIT
10800 */
10801function isEventSupported(eventNameSuffix, capture) {
10802 if (!testNode || (capture && !testNode.addEventListener)) {
10803 return false;
10804 }
10805 var element = document.createElement('div');
10806
10807 var eventName = 'on' + eventNameSuffix;
10808 var isSupported = eventName in element;
10809
10810 if (!isSupported) {
10811 element.setAttribute(eventName, '');
10812 isSupported = typeof element[eventName] === 'function';
10813 if (typeof element[eventName] !== 'undefined') {
10814 element[eventName] = undefined;
10815 }
10816 element.removeAttribute(eventName);
10817 }
10818
10819 if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
10820 // This is the only way to test support for the `wheel` event in IE9+.
10821 isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
10822 }
10823
10824 element = null;
10825 return isSupported;
10826}
10827
10828module.exports = isEventSupported;
10829
10830},{"./ExecutionEnvironment":19}],80:[function(require,module,exports){
10831/**
10832 * Copyright 2013 Facebook, Inc.
10833 *
10834 * Licensed under the Apache License, Version 2.0 (the "License");
10835 * you may not use this file except in compliance with the License.
10836 * You may obtain a copy of the License at
10837 *
10838 * http://www.apache.org/licenses/LICENSE-2.0
10839 *
10840 * Unless required by applicable law or agreed to in writing, software
10841 * distributed under the License is distributed on an "AS IS" BASIS,
10842 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10843 * See the License for the specific language governing permissions and
10844 * limitations under the License.
10845 *
10846 * @providesModule joinClasses
10847 * @typechecks static-only
10848 */
10849
10850"use strict";
10851
10852/**
10853 * Combines multiple className strings into one.
10854 * http://jsperf.com/joinclasses-args-vs-array
10855 *
10856 * @param {...?string} classes
10857 * @return {string}
10858 */
10859function joinClasses(className/*, ... */) {
10860 if (!className) {
10861 className = '';
10862 }
10863 var nextClass;
10864 var argLength = arguments.length;
10865 if (argLength > 1) {
10866 for (var ii = 1; ii < argLength; ii++) {
10867 nextClass = arguments[ii];
10868 nextClass && (className += ' ' + nextClass);
10869 }
10870 }
10871 return className;
10872}
10873
10874module.exports = joinClasses;
10875
10876},{}],81:[function(require,module,exports){
10877/**
10878 * Copyright 2013 Facebook, Inc.
10879 *
10880 * Licensed under the Apache License, Version 2.0 (the "License");
10881 * you may not use this file except in compliance with the License.
10882 * You may obtain a copy of the License at
10883 *
10884 * http://www.apache.org/licenses/LICENSE-2.0
10885 *
10886 * Unless required by applicable law or agreed to in writing, software
10887 * distributed under the License is distributed on an "AS IS" BASIS,
10888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10889 * See the License for the specific language governing permissions and
10890 * limitations under the License.
10891 *
10892 * @providesModule keyMirror
10893 * @typechecks static-only
10894 */
10895
10896"use strict";
10897
10898var invariant = require("./invariant");
10899
10900/**
10901 * Constructs an enumeration with keys equal to their value.
10902 *
10903 * For example:
10904 *
10905 * var COLORS = keyMirror({blue: null, red: null});
10906 * var myColor = COLORS.blue;
10907 * var isColorValid = !!COLORS[myColor];
10908 *
10909 * The last line could not be performed if the values of the generated enum were
10910 * not equal to their keys.
10911 *
10912 * Input: {key1: val1, key2: val2}
10913 * Output: {key1: key1, key2: key2}
10914 *
10915 * @param {object} obj
10916 * @return {object}
10917 */
10918var keyMirror = function(obj) {
10919 var ret = {};
10920 var key;
10921 invariant(
10922 obj instanceof Object && !Array.isArray(obj),
10923 'keyMirror(...): Argument must be an object.'
10924 );
10925 for (key in obj) {
10926 if (!obj.hasOwnProperty(key)) {
10927 continue;
10928 }
10929 ret[key] = key;
10930 }
10931 return ret;
10932};
10933
10934module.exports = keyMirror;
10935
10936},{"./invariant":78}],82:[function(require,module,exports){
10937/**
10938 * Copyright 2013 Facebook, Inc.
10939 *
10940 * Licensed under the Apache License, Version 2.0 (the "License");
10941 * you may not use this file except in compliance with the License.
10942 * You may obtain a copy of the License at
10943 *
10944 * http://www.apache.org/licenses/LICENSE-2.0
10945 *
10946 * Unless required by applicable law or agreed to in writing, software
10947 * distributed under the License is distributed on an "AS IS" BASIS,
10948 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10949 * See the License for the specific language governing permissions and
10950 * limitations under the License.
10951 *
10952 * @providesModule keyOf
10953 */
10954
10955/**
10956 * Allows extraction of a minified key. Let's the build system minify keys
10957 * without loosing the ability to dynamically use key strings as values
10958 * themselves. Pass in an object with a single key/val pair and it will return
10959 * you the string key of that single record. Suppose you want to grab the
10960 * value for a key 'className' inside of an object. Key/val minification may
10961 * have aliased that key to be 'xa12'. keyOf({className: null}) will return
10962 * 'xa12' in that case. Resolve keys you want to use once at startup time, then
10963 * reuse those resolutions.
10964 */
10965var keyOf = function(oneKeyObj) {
10966 var key;
10967 for (key in oneKeyObj) {
10968 if (!oneKeyObj.hasOwnProperty(key)) {
10969 continue;
10970 }
10971 return key;
10972 }
10973 return null;
10974};
10975
10976
10977module.exports = keyOf;
10978
10979},{}],83:[function(require,module,exports){
10980/**
10981 * Copyright 2013 Facebook, Inc.
10982 *
10983 * Licensed under the Apache License, Version 2.0 (the "License");
10984 * you may not use this file except in compliance with the License.
10985 * You may obtain a copy of the License at
10986 *
10987 * http://www.apache.org/licenses/LICENSE-2.0
10988 *
10989 * Unless required by applicable law or agreed to in writing, software
10990 * distributed under the License is distributed on an "AS IS" BASIS,
10991 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10992 * See the License for the specific language governing permissions and
10993 * limitations under the License.
10994 *
10995 * @providesModule memoizeStringOnly
10996 * @typechecks static-only
10997 */
10998
10999"use strict";
11000
11001/**
11002 * Memoizes the return value of a function that accepts one string argument.
11003 *
11004 * @param {function} callback
11005 * @return {function}
11006 */
11007function memoizeStringOnly(callback) {
11008 var cache = {};
11009 return function(string) {
11010 if (cache.hasOwnProperty(string)) {
11011 return cache[string];
11012 } else {
11013 return cache[string] = callback.call(this, string);
11014 }
11015 };
11016}
11017
11018module.exports = memoizeStringOnly;
11019
11020},{}],84:[function(require,module,exports){
11021/**
11022 * Copyright 2013 Facebook, Inc.
11023 *
11024 * Licensed under the Apache License, Version 2.0 (the "License");
11025 * you may not use this file except in compliance with the License.
11026 * You may obtain a copy of the License at
11027 *
11028 * http://www.apache.org/licenses/LICENSE-2.0
11029 *
11030 * Unless required by applicable law or agreed to in writing, software
11031 * distributed under the License is distributed on an "AS IS" BASIS,
11032 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11033 * See the License for the specific language governing permissions and
11034 * limitations under the License.
11035 *
11036 * @providesModule merge
11037 */
11038
11039"use strict";
11040
11041var mergeInto = require("./mergeInto");
11042
11043/**
11044 * Shallow merges two structures into a return value, without mutating either.
11045 *
11046 * @param {?object} one Optional object with properties to merge from.
11047 * @param {?object} two Optional object with properties to merge from.
11048 * @return {object} The shallow extension of one by two.
11049 */
11050var merge = function(one, two) {
11051 var result = {};
11052 mergeInto(result, one);
11053 mergeInto(result, two);
11054 return result;
11055};
11056
11057module.exports = merge;
11058
11059},{"./mergeInto":86}],85:[function(require,module,exports){
11060/**
11061 * Copyright 2013 Facebook, Inc.
11062 *
11063 * Licensed under the Apache License, Version 2.0 (the "License");
11064 * you may not use this file except in compliance with the License.
11065 * You may obtain a copy of the License at
11066 *
11067 * http://www.apache.org/licenses/LICENSE-2.0
11068 *
11069 * Unless required by applicable law or agreed to in writing, software
11070 * distributed under the License is distributed on an "AS IS" BASIS,
11071 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11072 * See the License for the specific language governing permissions and
11073 * limitations under the License.
11074 *
11075 * @providesModule mergeHelpers
11076 *
11077 * requiresPolyfills: Array.isArray
11078 */
11079
11080"use strict";
11081
11082var invariant = require("./invariant");
11083var keyMirror = require("./keyMirror");
11084
11085/**
11086 * Maximum number of levels to traverse. Will catch circular structures.
11087 * @const
11088 */
11089var MAX_MERGE_DEPTH = 36;
11090
11091/**
11092 * We won't worry about edge cases like new String('x') or new Boolean(true).
11093 * Functions are considered terminals, and arrays are not.
11094 * @param {*} o The item/object/value to test.
11095 * @return {boolean} true iff the argument is a terminal.
11096 */
11097var isTerminal = function(o) {
11098 return typeof o !== 'object' || o === null;
11099};
11100
11101var mergeHelpers = {
11102
11103 MAX_MERGE_DEPTH: MAX_MERGE_DEPTH,
11104
11105 isTerminal: isTerminal,
11106
11107 /**
11108 * Converts null/undefined values into empty object.
11109 *
11110 * @param {?Object=} arg Argument to be normalized (nullable optional)
11111 * @return {!Object}
11112 */
11113 normalizeMergeArg: function(arg) {
11114 return arg === undefined || arg === null ? {} : arg;
11115 },
11116
11117 /**
11118 * If merging Arrays, a merge strategy *must* be supplied. If not, it is
11119 * likely the caller's fault. If this function is ever called with anything
11120 * but `one` and `two` being `Array`s, it is the fault of the merge utilities.
11121 *
11122 * @param {*} one Array to merge into.
11123 * @param {*} two Array to merge from.
11124 */
11125 checkMergeArrayArgs: function(one, two) {
11126 invariant(
11127 Array.isArray(one) && Array.isArray(two),
11128 'Critical assumptions about the merge functions have been violated. ' +
11129 'This is the fault of the merge functions themselves, not necessarily ' +
11130 'the callers.'
11131 );
11132 },
11133
11134 /**
11135 * @param {*} one Object to merge into.
11136 * @param {*} two Object to merge from.
11137 */
11138 checkMergeObjectArgs: function(one, two) {
11139 mergeHelpers.checkMergeObjectArg(one);
11140 mergeHelpers.checkMergeObjectArg(two);
11141 },
11142
11143 /**
11144 * @param {*} arg
11145 */
11146 checkMergeObjectArg: function(arg) {
11147 invariant(
11148 !isTerminal(arg) && !Array.isArray(arg),
11149 'Critical assumptions about the merge functions have been violated. ' +
11150 'This is the fault of the merge functions themselves, not necessarily ' +
11151 'the callers.'
11152 );
11153 },
11154
11155 /**
11156 * Checks that a merge was not given a circular object or an object that had
11157 * too great of depth.
11158 *
11159 * @param {number} Level of recursion to validate against maximum.
11160 */
11161 checkMergeLevel: function(level) {
11162 invariant(
11163 level < MAX_MERGE_DEPTH,
11164 'Maximum deep merge depth exceeded. You may be attempting to merge ' +
11165 'circular structures in an unsupported way.'
11166 );
11167 },
11168
11169 /**
11170 * Checks that the supplied merge strategy is valid.
11171 *
11172 * @param {string} Array merge strategy.
11173 */
11174 checkArrayStrategy: function(strategy) {
11175 invariant(
11176 strategy === undefined || strategy in mergeHelpers.ArrayStrategies,
11177 'You must provide an array strategy to deep merge functions to ' +
11178 'instruct the deep merge how to resolve merging two arrays.'
11179 );
11180 },
11181
11182 /**
11183 * Set of possible behaviors of merge algorithms when encountering two Arrays
11184 * that must be merged together.
11185 * - `clobber`: The left `Array` is ignored.
11186 * - `indexByIndex`: The result is achieved by recursively deep merging at
11187 * each index. (not yet supported.)
11188 */
11189 ArrayStrategies: keyMirror({
11190 Clobber: true,
11191 IndexByIndex: true
11192 })
11193
11194};
11195
11196module.exports = mergeHelpers;
11197
11198},{"./invariant":78,"./keyMirror":81}],86:[function(require,module,exports){
11199/**
11200 * Copyright 2013 Facebook, Inc.
11201 *
11202 * Licensed under the Apache License, Version 2.0 (the "License");
11203 * you may not use this file except in compliance with the License.
11204 * You may obtain a copy of the License at
11205 *
11206 * http://www.apache.org/licenses/LICENSE-2.0
11207 *
11208 * Unless required by applicable law or agreed to in writing, software
11209 * distributed under the License is distributed on an "AS IS" BASIS,
11210 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11211 * See the License for the specific language governing permissions and
11212 * limitations under the License.
11213 *
11214 * @providesModule mergeInto
11215 * @typechecks static-only
11216 */
11217
11218"use strict";
11219
11220var mergeHelpers = require("./mergeHelpers");
11221
11222var checkMergeObjectArg = mergeHelpers.checkMergeObjectArg;
11223
11224/**
11225 * Shallow merges two structures by mutating the first parameter.
11226 *
11227 * @param {object} one Object to be merged into.
11228 * @param {?object} two Optional object with properties to merge from.
11229 */
11230function mergeInto(one, two) {
11231 checkMergeObjectArg(one);
11232 if (two != null) {
11233 checkMergeObjectArg(two);
11234 for (var key in two) {
11235 if (!two.hasOwnProperty(key)) {
11236 continue;
11237 }
11238 one[key] = two[key];
11239 }
11240 }
11241}
11242
11243module.exports = mergeInto;
11244
11245},{"./mergeHelpers":85}],87:[function(require,module,exports){
11246/**
11247 * Copyright 2013 Facebook, Inc.
11248 *
11249 * Licensed under the Apache License, Version 2.0 (the "License");
11250 * you may not use this file except in compliance with the License.
11251 * You may obtain a copy of the License at
11252 *
11253 * http://www.apache.org/licenses/LICENSE-2.0
11254 *
11255 * Unless required by applicable law or agreed to in writing, software
11256 * distributed under the License is distributed on an "AS IS" BASIS,
11257 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11258 * See the License for the specific language governing permissions and
11259 * limitations under the License.
11260 *
11261 * @providesModule mixInto
11262 */
11263
11264"use strict";
11265
11266/**
11267 * Simply copies properties to the prototype.
11268 */
11269var mixInto = function(constructor, methodBag) {
11270 var methodName;
11271 for (methodName in methodBag) {
11272 if (!methodBag.hasOwnProperty(methodName)) {
11273 continue;
11274 }
11275 constructor.prototype[methodName] = methodBag[methodName];
11276 }
11277};
11278
11279module.exports = mixInto;
11280
11281},{}],88:[function(require,module,exports){
11282/**
11283 * Copyright 2013 Facebook, Inc.
11284 *
11285 * Licensed under the Apache License, Version 2.0 (the "License");
11286 * you may not use this file except in compliance with the License.
11287 * You may obtain a copy of the License at
11288 *
11289 * http://www.apache.org/licenses/LICENSE-2.0
11290 *
11291 * Unless required by applicable law or agreed to in writing, software
11292 * distributed under the License is distributed on an "AS IS" BASIS,
11293 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11294 * See the License for the specific language governing permissions and
11295 * limitations under the License.
11296 *
11297 * @providesModule objMapKeyVal
11298 */
11299
11300"use strict";
11301
11302/**
11303 * Behaves the same as `objMap` but invokes func with the key first, and value
11304 * second. Use `objMap` unless you need this special case.
11305 * Invokes func as:
11306 *
11307 * func(key, value, iteration)
11308 *
11309 * @param {?object} obj Object to map keys over
11310 * @param {!function} func Invoked for each key/val pair.
11311 * @param {?*} context
11312 * @return {?object} Result of mapping or null if obj is falsey
11313 */
11314function objMapKeyVal(obj, func, context) {
11315 if (!obj) {
11316 return null;
11317 }
11318 var i = 0;
11319 var ret = {};
11320 for (var key in obj) {
11321 if (obj.hasOwnProperty(key)) {
11322 ret[key] = func.call(context, key, obj[key], i++);
11323 }
11324 }
11325 return ret;
11326}
11327
11328module.exports = objMapKeyVal;
11329
11330},{}],89:[function(require,module,exports){
11331/**
11332 * Copyright 2013 Facebook, Inc.
11333 *
11334 * Licensed under the Apache License, Version 2.0 (the "License");
11335 * you may not use this file except in compliance with the License.
11336 * You may obtain a copy of the License at
11337 *
11338 * http://www.apache.org/licenses/LICENSE-2.0
11339 *
11340 * Unless required by applicable law or agreed to in writing, software
11341 * distributed under the License is distributed on an "AS IS" BASIS,
11342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11343 * See the License for the specific language governing permissions and
11344 * limitations under the License.
11345 *
11346 * @providesModule throwIf
11347 */
11348
11349"use strict";
11350
11351var throwIf = function(condition, err) {
11352 if (condition) {
11353 throw new Error(err);
11354 }
11355};
11356
11357module.exports = throwIf;
11358
11359},{}],90:[function(require,module,exports){
11360(function(){/**
11361 * Copyright 2013 Facebook, Inc.
11362 *
11363 * Licensed under the Apache License, Version 2.0 (the "License");
11364 * you may not use this file except in compliance with the License.
11365 * You may obtain a copy of the License at
11366 *
11367 * http://www.apache.org/licenses/LICENSE-2.0
11368 *
11369 * Unless required by applicable law or agreed to in writing, software
11370 * distributed under the License is distributed on an "AS IS" BASIS,
11371 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11372 * See the License for the specific language governing permissions and
11373 * limitations under the License.
11374 *
11375 * @providesModule traverseAllChildren
11376 */
11377
11378"use strict";
11379
11380var ReactComponent = require("./ReactComponent");
11381var ReactTextComponent = require("./ReactTextComponent");
11382
11383var invariant = require("./invariant");
11384
11385/**
11386 * TODO: Test that:
11387 * 1. `mapChildren` transforms strings and numbers into `ReactTextComponent`.
11388 * 2. it('should fail when supplied duplicate key', function() {
11389 * 3. That a single child and an array with one item have the same key pattern.
11390 * });
11391 */
11392
11393/**
11394 * @param {?*} children Children tree container.
11395 * @param {!string} nameSoFar Name of the key path so far.
11396 * @param {!number} indexSoFar Number of children encountered until this point.
11397 * @param {!function} callback Callback to invoke with each child found.
11398 * @param {?*} traverseContext Used to pass information throughout the traversal
11399 * process.
11400 * @return {!number} The number of children in this subtree.
11401 */
11402var traverseAllChildrenImpl =
11403 function(children, nameSoFar, indexSoFar, callback, traverseContext) {
11404 var subtreeCount = 0; // Count of children found in the current subtree.
11405 if (Array.isArray(children)) {
11406 for (var i = 0; i < children.length; i++) {
11407 var child = children[i];
11408 var nextName = nameSoFar + '[' + ReactComponent.getKey(child, i) + ']';
11409 var nextIndex = indexSoFar + subtreeCount;
11410 subtreeCount += traverseAllChildrenImpl(
11411 child,
11412 nextName,
11413 nextIndex,
11414 callback,
11415 traverseContext
11416 );
11417 }
11418 } else {
11419 var type = typeof children;
11420 var isOnlyChild = nameSoFar === '';
11421 // If it's the only child, treat the name as if it was wrapped in an array
11422 // so that it's consistent if the number of children grows
11423 var storageName = isOnlyChild ?
11424 '[' + ReactComponent.getKey(children, 0) + ']' :
11425 nameSoFar;
11426 if (children === null || children === undefined || type === 'boolean') {
11427 // All of the above are perceived as null.
11428 callback(traverseContext, null, storageName, indexSoFar);
11429 subtreeCount = 1;
11430 } else if (children.mountComponentIntoNode) {
11431 callback(traverseContext, children, storageName, indexSoFar);
11432 subtreeCount = 1;
11433 } else {
11434 if (type === 'object') {
11435 invariant(
11436 children || children.nodeType !== 1,
11437 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
11438 'elements are not valid children of React components.'
11439 );
11440 for (var key in children) {
11441 if (children.hasOwnProperty(key)) {
11442 subtreeCount += traverseAllChildrenImpl(
11443 children[key],
11444 nameSoFar + '{' + key + '}',
11445 indexSoFar + subtreeCount,
11446 callback,
11447 traverseContext
11448 );
11449 }
11450 }
11451 } else if (type === 'string') {
11452 var normalizedText = new ReactTextComponent(children);
11453 callback(traverseContext, normalizedText, storageName, indexSoFar);
11454 subtreeCount += 1;
11455 } else if (type === 'number') {
11456 var normalizedNumber = new ReactTextComponent('' + children);
11457 callback(traverseContext, normalizedNumber, storageName, indexSoFar);
11458 subtreeCount += 1;
11459 }
11460 }
11461 }
11462 return subtreeCount;
11463 };
11464
11465/**
11466 * Traverses children that are typically specified as `props.children`, but
11467 * might also be specified through attributes:
11468 *
11469 * - `traverseAllChildren(this.props.children, ...)`
11470 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
11471 *
11472 * The `traverseContext` is an optional argument that is passed through the
11473 * entire traversal. It can be used to store accumulations or anything else that
11474 * the callback might find relevant.
11475 *
11476 * @param {?*} children Children tree object.
11477 * @param {!function} callback To invoke upon traversing each child.
11478 * @param {?*} traverseContext Context for traversal.
11479 */
11480function traverseAllChildren(children, callback, traverseContext) {
11481 if (children !== null && children !== undefined) {
11482 traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
11483 }
11484}
11485
11486module.exports = traverseAllChildren;
11487
11488})()
11489},{"./ReactComponent":23,"./ReactTextComponent":48,"./invariant":78}]},{},[22])(22)
11490});
11491; \ No newline at end of file