1 |
|
2 |
|
3 |
|
4 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.React=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | "use strict";
|
17 |
|
18 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
19 | var EventPluginUtils = _dereq_("./EventPluginUtils");
|
20 | var ReactChildren = _dereq_("./ReactChildren");
|
21 | var ReactComponent = _dereq_("./ReactComponent");
|
22 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
23 | var ReactContext = _dereq_("./ReactContext");
|
24 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
25 | var ReactElement = _dereq_("./ReactElement");
|
26 | var ReactElementValidator = _dereq_("./ReactElementValidator");
|
27 | var ReactDOM = _dereq_("./ReactDOM");
|
28 | var ReactDOMComponent = _dereq_("./ReactDOMComponent");
|
29 | var ReactDefaultInjection = _dereq_("./ReactDefaultInjection");
|
30 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
31 | var ReactLegacyElement = _dereq_("./ReactLegacyElement");
|
32 | var ReactMount = _dereq_("./ReactMount");
|
33 | var ReactMultiChild = _dereq_("./ReactMultiChild");
|
34 | var ReactPerf = _dereq_("./ReactPerf");
|
35 | var ReactPropTypes = _dereq_("./ReactPropTypes");
|
36 | var ReactServerRendering = _dereq_("./ReactServerRendering");
|
37 | var ReactTextComponent = _dereq_("./ReactTextComponent");
|
38 |
|
39 | var assign = _dereq_("./Object.assign");
|
40 | var deprecated = _dereq_("./deprecated");
|
41 | var onlyChild = _dereq_("./onlyChild");
|
42 |
|
43 | ReactDefaultInjection.inject();
|
44 |
|
45 | var createElement = ReactElement.createElement;
|
46 | var createFactory = ReactElement.createFactory;
|
47 |
|
48 | if ("production" !== "development") {
|
49 | createElement = ReactElementValidator.createElement;
|
50 | createFactory = ReactElementValidator.createFactory;
|
51 | }
|
52 |
|
53 |
|
54 | createElement = ReactLegacyElement.wrapCreateElement(
|
55 | createElement
|
56 | );
|
57 | createFactory = ReactLegacyElement.wrapCreateFactory(
|
58 | createFactory
|
59 | );
|
60 |
|
61 | var render = ReactPerf.measure('React', 'render', ReactMount.render);
|
62 |
|
63 | var React = {
|
64 | Children: {
|
65 | map: ReactChildren.map,
|
66 | forEach: ReactChildren.forEach,
|
67 | count: ReactChildren.count,
|
68 | only: onlyChild
|
69 | },
|
70 | DOM: ReactDOM,
|
71 | PropTypes: ReactPropTypes,
|
72 | initializeTouchEvents: function(shouldUseTouch) {
|
73 | EventPluginUtils.useTouchEvents = shouldUseTouch;
|
74 | },
|
75 | createClass: ReactCompositeComponent.createClass,
|
76 | createElement: createElement,
|
77 | createFactory: createFactory,
|
78 | constructAndRenderComponent: ReactMount.constructAndRenderComponent,
|
79 | constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
|
80 | render: render,
|
81 | renderToString: ReactServerRendering.renderToString,
|
82 | renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
83 | unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
84 | isValidClass: ReactLegacyElement.isValidClass,
|
85 | isValidElement: ReactElement.isValidElement,
|
86 | withContext: ReactContext.withContext,
|
87 |
|
88 |
|
89 | __spread: assign,
|
90 |
|
91 |
|
92 | renderComponent: deprecated(
|
93 | 'React',
|
94 | 'renderComponent',
|
95 | 'render',
|
96 | this,
|
97 | render
|
98 | ),
|
99 | renderComponentToString: deprecated(
|
100 | 'React',
|
101 | 'renderComponentToString',
|
102 | 'renderToString',
|
103 | this,
|
104 | ReactServerRendering.renderToString
|
105 | ),
|
106 | renderComponentToStaticMarkup: deprecated(
|
107 | 'React',
|
108 | 'renderComponentToStaticMarkup',
|
109 | 'renderToStaticMarkup',
|
110 | this,
|
111 | ReactServerRendering.renderToStaticMarkup
|
112 | ),
|
113 | isValidComponent: deprecated(
|
114 | 'React',
|
115 | 'isValidComponent',
|
116 | 'isValidElement',
|
117 | this,
|
118 | ReactElement.isValidElement
|
119 | )
|
120 | };
|
121 |
|
122 |
|
123 |
|
124 | if (
|
125 | typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
126 | typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
|
127 | __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
|
128 | Component: ReactComponent,
|
129 | CurrentOwner: ReactCurrentOwner,
|
130 | DOMComponent: ReactDOMComponent,
|
131 | DOMPropertyOperations: DOMPropertyOperations,
|
132 | InstanceHandles: ReactInstanceHandles,
|
133 | Mount: ReactMount,
|
134 | MultiChild: ReactMultiChild,
|
135 | TextComponent: ReactTextComponent
|
136 | });
|
137 | }
|
138 |
|
139 | if ("production" !== "development") {
|
140 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
141 | if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
|
142 |
|
143 |
|
144 |
|
145 | if (navigator.userAgent.indexOf('Chrome') > -1) {
|
146 | if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
|
147 | console.debug(
|
148 | 'Download the React DevTools for a better development experience: ' +
|
149 | 'http://fb.me/react-devtools'
|
150 | );
|
151 | }
|
152 | }
|
153 |
|
154 | var expectedFeatures = [
|
155 |
|
156 | Array.isArray,
|
157 | Array.prototype.every,
|
158 | Array.prototype.forEach,
|
159 | Array.prototype.indexOf,
|
160 | Array.prototype.map,
|
161 | Date.now,
|
162 | Function.prototype.bind,
|
163 | Object.keys,
|
164 | String.prototype.split,
|
165 | String.prototype.trim,
|
166 |
|
167 |
|
168 | Object.create,
|
169 | Object.freeze
|
170 | ];
|
171 |
|
172 | for (var i = 0; i < expectedFeatures.length; i++) {
|
173 | if (!expectedFeatures[i]) {
|
174 | console.error(
|
175 | 'One or more ES5 shim/shams expected by React are not available: ' +
|
176 | 'http://fb.me/react-warning-polyfills'
|
177 | );
|
178 | break;
|
179 | }
|
180 | }
|
181 | }
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 | React.version = '0.12.2';
|
187 |
|
188 | module.exports = React;
|
189 |
|
190 | },{"./DOMPropertyOperations":12,"./EventPluginUtils":20,"./ExecutionEnvironment":22,"./Object.assign":27,"./ReactChildren":31,"./ReactComponent":32,"./ReactCompositeComponent":34,"./ReactContext":35,"./ReactCurrentOwner":36,"./ReactDOM":37,"./ReactDOMComponent":39,"./ReactDefaultInjection":49,"./ReactElement":52,"./ReactElementValidator":53,"./ReactInstanceHandles":60,"./ReactLegacyElement":61,"./ReactMount":63,"./ReactMultiChild":64,"./ReactPerf":68,"./ReactPropTypes":72,"./ReactServerRendering":76,"./ReactTextComponent":78,"./deprecated":106,"./onlyChild":137}],2:[function(_dereq_,module,exports){
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 | "use strict";
|
204 |
|
205 | var focusNode = _dereq_("./focusNode");
|
206 |
|
207 | var AutoFocusMixin = {
|
208 | componentDidMount: function() {
|
209 | if (this.props.autoFocus) {
|
210 | focusNode(this.getDOMNode());
|
211 | }
|
212 | }
|
213 | };
|
214 |
|
215 | module.exports = AutoFocusMixin;
|
216 |
|
217 | },{"./focusNode":111}],3:[function(_dereq_,module,exports){
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | "use strict";
|
231 |
|
232 | var EventConstants = _dereq_("./EventConstants");
|
233 | var EventPropagators = _dereq_("./EventPropagators");
|
234 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
235 | var SyntheticInputEvent = _dereq_("./SyntheticInputEvent");
|
236 |
|
237 | var keyOf = _dereq_("./keyOf");
|
238 |
|
239 | var canUseTextInputEvent = (
|
240 | ExecutionEnvironment.canUseDOM &&
|
241 | 'TextEvent' in window &&
|
242 | !('documentMode' in document || isPresto())
|
243 | );
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | function isPresto() {
|
250 | var opera = window.opera;
|
251 | return (
|
252 | typeof opera === 'object' &&
|
253 | typeof opera.version === 'function' &&
|
254 | parseInt(opera.version(), 10) <= 12
|
255 | );
|
256 | }
|
257 |
|
258 | var SPACEBAR_CODE = 32;
|
259 | var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
260 |
|
261 | var topLevelTypes = EventConstants.topLevelTypes;
|
262 |
|
263 |
|
264 | var eventTypes = {
|
265 | beforeInput: {
|
266 | phasedRegistrationNames: {
|
267 | bubbled: keyOf({onBeforeInput: null}),
|
268 | captured: keyOf({onBeforeInputCapture: null})
|
269 | },
|
270 | dependencies: [
|
271 | topLevelTypes.topCompositionEnd,
|
272 | topLevelTypes.topKeyPress,
|
273 | topLevelTypes.topTextInput,
|
274 | topLevelTypes.topPaste
|
275 | ]
|
276 | }
|
277 | };
|
278 |
|
279 |
|
280 | var fallbackChars = null;
|
281 |
|
282 |
|
283 | var hasSpaceKeypress = false;
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | function isKeypressCommand(nativeEvent) {
|
291 | return (
|
292 | (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
|
293 |
|
294 | !(nativeEvent.ctrlKey && nativeEvent.altKey)
|
295 | );
|
296 | }
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | var BeforeInputEventPlugin = {
|
313 |
|
314 | eventTypes: eventTypes,
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | extractEvents: function(
|
325 | topLevelType,
|
326 | topLevelTarget,
|
327 | topLevelTargetID,
|
328 | nativeEvent) {
|
329 |
|
330 | var chars;
|
331 |
|
332 | if (canUseTextInputEvent) {
|
333 | switch (topLevelType) {
|
334 | case topLevelTypes.topKeyPress:
|
335 | |
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 | var which = nativeEvent.which;
|
350 | if (which !== SPACEBAR_CODE) {
|
351 | return;
|
352 | }
|
353 |
|
354 | hasSpaceKeypress = true;
|
355 | chars = SPACEBAR_CHAR;
|
356 | break;
|
357 |
|
358 | case topLevelTypes.topTextInput:
|
359 |
|
360 | chars = nativeEvent.data;
|
361 |
|
362 |
|
363 |
|
364 |
|
365 | if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
366 | return;
|
367 | }
|
368 |
|
369 |
|
370 | break;
|
371 |
|
372 | default:
|
373 |
|
374 | return;
|
375 | }
|
376 | } else {
|
377 | switch (topLevelType) {
|
378 | case topLevelTypes.topPaste:
|
379 |
|
380 |
|
381 | fallbackChars = null;
|
382 | break;
|
383 | case topLevelTypes.topKeyPress:
|
384 | |
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 | if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
|
401 | fallbackChars = String.fromCharCode(nativeEvent.which);
|
402 | }
|
403 | break;
|
404 | case topLevelTypes.topCompositionEnd:
|
405 | fallbackChars = nativeEvent.data;
|
406 | break;
|
407 | }
|
408 |
|
409 |
|
410 |
|
411 | if (fallbackChars === null) {
|
412 | return;
|
413 | }
|
414 |
|
415 | chars = fallbackChars;
|
416 | }
|
417 |
|
418 |
|
419 |
|
420 | if (!chars) {
|
421 | return;
|
422 | }
|
423 |
|
424 | var event = SyntheticInputEvent.getPooled(
|
425 | eventTypes.beforeInput,
|
426 | topLevelTargetID,
|
427 | nativeEvent
|
428 | );
|
429 |
|
430 | event.data = chars;
|
431 | fallbackChars = null;
|
432 | EventPropagators.accumulateTwoPhaseDispatches(event);
|
433 | return event;
|
434 | }
|
435 | };
|
436 |
|
437 | module.exports = BeforeInputEventPlugin;
|
438 |
|
439 | },{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./SyntheticInputEvent":89,"./keyOf":133}],4:[function(_dereq_,module,exports){
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 | "use strict";
|
452 |
|
453 |
|
454 |
|
455 |
|
456 | var isUnitlessNumber = {
|
457 | columnCount: true,
|
458 | flex: true,
|
459 | flexGrow: true,
|
460 | flexShrink: true,
|
461 | fontWeight: true,
|
462 | lineClamp: true,
|
463 | lineHeight: true,
|
464 | opacity: true,
|
465 | order: true,
|
466 | orphans: true,
|
467 | widows: true,
|
468 | zIndex: true,
|
469 | zoom: true,
|
470 |
|
471 |
|
472 | fillOpacity: true,
|
473 | strokeOpacity: true
|
474 | };
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 | function prefixKey(prefix, key) {
|
483 | return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
484 | }
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
491 |
|
492 |
|
493 |
|
494 | Object.keys(isUnitlessNumber).forEach(function(prop) {
|
495 | prefixes.forEach(function(prefix) {
|
496 | isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
497 | });
|
498 | });
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 | var shorthandPropertyExpansions = {
|
510 | background: {
|
511 | backgroundImage: true,
|
512 | backgroundPosition: true,
|
513 | backgroundRepeat: true,
|
514 | backgroundColor: true
|
515 | },
|
516 | border: {
|
517 | borderWidth: true,
|
518 | borderStyle: true,
|
519 | borderColor: true
|
520 | },
|
521 | borderBottom: {
|
522 | borderBottomWidth: true,
|
523 | borderBottomStyle: true,
|
524 | borderBottomColor: true
|
525 | },
|
526 | borderLeft: {
|
527 | borderLeftWidth: true,
|
528 | borderLeftStyle: true,
|
529 | borderLeftColor: true
|
530 | },
|
531 | borderRight: {
|
532 | borderRightWidth: true,
|
533 | borderRightStyle: true,
|
534 | borderRightColor: true
|
535 | },
|
536 | borderTop: {
|
537 | borderTopWidth: true,
|
538 | borderTopStyle: true,
|
539 | borderTopColor: true
|
540 | },
|
541 | font: {
|
542 | fontStyle: true,
|
543 | fontVariant: true,
|
544 | fontWeight: true,
|
545 | fontSize: true,
|
546 | lineHeight: true,
|
547 | fontFamily: true
|
548 | }
|
549 | };
|
550 |
|
551 | var CSSProperty = {
|
552 | isUnitlessNumber: isUnitlessNumber,
|
553 | shorthandPropertyExpansions: shorthandPropertyExpansions
|
554 | };
|
555 |
|
556 | module.exports = CSSProperty;
|
557 |
|
558 | },{}],5:[function(_dereq_,module,exports){
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 | "use strict";
|
572 |
|
573 | var CSSProperty = _dereq_("./CSSProperty");
|
574 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
575 |
|
576 | var camelizeStyleName = _dereq_("./camelizeStyleName");
|
577 | var dangerousStyleValue = _dereq_("./dangerousStyleValue");
|
578 | var hyphenateStyleName = _dereq_("./hyphenateStyleName");
|
579 | var memoizeStringOnly = _dereq_("./memoizeStringOnly");
|
580 | var warning = _dereq_("./warning");
|
581 |
|
582 | var processStyleName = memoizeStringOnly(function(styleName) {
|
583 | return hyphenateStyleName(styleName);
|
584 | });
|
585 |
|
586 | var styleFloatAccessor = 'cssFloat';
|
587 | if (ExecutionEnvironment.canUseDOM) {
|
588 |
|
589 | if (document.documentElement.style.cssFloat === undefined) {
|
590 | styleFloatAccessor = 'styleFloat';
|
591 | }
|
592 | }
|
593 |
|
594 | if ("production" !== "development") {
|
595 | var warnedStyleNames = {};
|
596 |
|
597 | var warnHyphenatedStyleName = function(name) {
|
598 | if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
599 | return;
|
600 | }
|
601 |
|
602 | warnedStyleNames[name] = true;
|
603 | ("production" !== "development" ? warning(
|
604 | false,
|
605 | 'Unsupported style property ' + name + '. Did you mean ' +
|
606 | camelizeStyleName(name) + '?'
|
607 | ) : null);
|
608 | };
|
609 | }
|
610 |
|
611 |
|
612 |
|
613 |
|
614 | var CSSPropertyOperations = {
|
615 |
|
616 | |
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | createMarkupForStyles: function(styles) {
|
629 | var serialized = '';
|
630 | for (var styleName in styles) {
|
631 | if (!styles.hasOwnProperty(styleName)) {
|
632 | continue;
|
633 | }
|
634 | if ("production" !== "development") {
|
635 | if (styleName.indexOf('-') > -1) {
|
636 | warnHyphenatedStyleName(styleName);
|
637 | }
|
638 | }
|
639 | var styleValue = styles[styleName];
|
640 | if (styleValue != null) {
|
641 | serialized += processStyleName(styleName) + ':';
|
642 | serialized += dangerousStyleValue(styleName, styleValue) + ';';
|
643 | }
|
644 | }
|
645 | return serialized || null;
|
646 | },
|
647 |
|
648 | |
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 | setValueForStyles: function(node, styles) {
|
656 | var style = node.style;
|
657 | for (var styleName in styles) {
|
658 | if (!styles.hasOwnProperty(styleName)) {
|
659 | continue;
|
660 | }
|
661 | if ("production" !== "development") {
|
662 | if (styleName.indexOf('-') > -1) {
|
663 | warnHyphenatedStyleName(styleName);
|
664 | }
|
665 | }
|
666 | var styleValue = dangerousStyleValue(styleName, styles[styleName]);
|
667 | if (styleName === 'float') {
|
668 | styleName = styleFloatAccessor;
|
669 | }
|
670 | if (styleValue) {
|
671 | style[styleName] = styleValue;
|
672 | } else {
|
673 | var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
|
674 | if (expansion) {
|
675 |
|
676 |
|
677 | for (var individualStyleName in expansion) {
|
678 | style[individualStyleName] = '';
|
679 | }
|
680 | } else {
|
681 | style[styleName] = '';
|
682 | }
|
683 | }
|
684 | }
|
685 | }
|
686 |
|
687 | };
|
688 |
|
689 | module.exports = CSSPropertyOperations;
|
690 |
|
691 | },{"./CSSProperty":4,"./ExecutionEnvironment":22,"./camelizeStyleName":100,"./dangerousStyleValue":105,"./hyphenateStyleName":124,"./memoizeStringOnly":135,"./warning":145}],6:[function(_dereq_,module,exports){
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 | "use strict";
|
704 |
|
705 | var PooledClass = _dereq_("./PooledClass");
|
706 |
|
707 | var assign = _dereq_("./Object.assign");
|
708 | var invariant = _dereq_("./invariant");
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | function CallbackQueue() {
|
722 | this._callbacks = null;
|
723 | this._contexts = null;
|
724 | }
|
725 |
|
726 | assign(CallbackQueue.prototype, {
|
727 |
|
728 | |
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 | enqueue: function(callback, context) {
|
736 | this._callbacks = this._callbacks || [];
|
737 | this._contexts = this._contexts || [];
|
738 | this._callbacks.push(callback);
|
739 | this._contexts.push(context);
|
740 | },
|
741 |
|
742 | |
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 | notifyAll: function() {
|
749 | var callbacks = this._callbacks;
|
750 | var contexts = this._contexts;
|
751 | if (callbacks) {
|
752 | ("production" !== "development" ? invariant(
|
753 | callbacks.length === contexts.length,
|
754 | "Mismatched list of contexts in callback queue"
|
755 | ) : invariant(callbacks.length === contexts.length));
|
756 | this._callbacks = null;
|
757 | this._contexts = null;
|
758 | for (var i = 0, l = callbacks.length; i < l; i++) {
|
759 | callbacks[i].call(contexts[i]);
|
760 | }
|
761 | callbacks.length = 0;
|
762 | contexts.length = 0;
|
763 | }
|
764 | },
|
765 |
|
766 | |
767 |
|
768 |
|
769 |
|
770 |
|
771 | reset: function() {
|
772 | this._callbacks = null;
|
773 | this._contexts = null;
|
774 | },
|
775 |
|
776 | |
777 |
|
778 |
|
779 | destructor: function() {
|
780 | this.reset();
|
781 | }
|
782 |
|
783 | });
|
784 |
|
785 | PooledClass.addPoolingTo(CallbackQueue);
|
786 |
|
787 | module.exports = CallbackQueue;
|
788 |
|
789 | },{"./Object.assign":27,"./PooledClass":28,"./invariant":126}],7:[function(_dereq_,module,exports){
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | "use strict";
|
802 |
|
803 | var EventConstants = _dereq_("./EventConstants");
|
804 | var EventPluginHub = _dereq_("./EventPluginHub");
|
805 | var EventPropagators = _dereq_("./EventPropagators");
|
806 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
807 | var ReactUpdates = _dereq_("./ReactUpdates");
|
808 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
809 |
|
810 | var isEventSupported = _dereq_("./isEventSupported");
|
811 | var isTextInputElement = _dereq_("./isTextInputElement");
|
812 | var keyOf = _dereq_("./keyOf");
|
813 |
|
814 | var topLevelTypes = EventConstants.topLevelTypes;
|
815 |
|
816 | var eventTypes = {
|
817 | change: {
|
818 | phasedRegistrationNames: {
|
819 | bubbled: keyOf({onChange: null}),
|
820 | captured: keyOf({onChangeCapture: null})
|
821 | },
|
822 | dependencies: [
|
823 | topLevelTypes.topBlur,
|
824 | topLevelTypes.topChange,
|
825 | topLevelTypes.topClick,
|
826 | topLevelTypes.topFocus,
|
827 | topLevelTypes.topInput,
|
828 | topLevelTypes.topKeyDown,
|
829 | topLevelTypes.topKeyUp,
|
830 | topLevelTypes.topSelectionChange
|
831 | ]
|
832 | }
|
833 | };
|
834 |
|
835 |
|
836 |
|
837 |
|
838 | var activeElement = null;
|
839 | var activeElementID = null;
|
840 | var activeElementValue = null;
|
841 | var activeElementValueProp = null;
|
842 |
|
843 |
|
844 |
|
845 |
|
846 | function shouldUseChangeEvent(elem) {
|
847 | return (
|
848 | elem.nodeName === 'SELECT' ||
|
849 | (elem.nodeName === 'INPUT' && elem.type === 'file')
|
850 | );
|
851 | }
|
852 |
|
853 | var doesChangeEventBubble = false;
|
854 | if (ExecutionEnvironment.canUseDOM) {
|
855 |
|
856 | doesChangeEventBubble = isEventSupported('change') && (
|
857 | !('documentMode' in document) || document.documentMode > 8
|
858 | );
|
859 | }
|
860 |
|
861 | function manualDispatchChangeEvent(nativeEvent) {
|
862 | var event = SyntheticEvent.getPooled(
|
863 | eventTypes.change,
|
864 | activeElementID,
|
865 | nativeEvent
|
866 | );
|
867 | EventPropagators.accumulateTwoPhaseDispatches(event);
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 | ReactUpdates.batchedUpdates(runEventInBatch, event);
|
881 | }
|
882 |
|
883 | function runEventInBatch(event) {
|
884 | EventPluginHub.enqueueEvents(event);
|
885 | EventPluginHub.processEventQueue();
|
886 | }
|
887 |
|
888 | function startWatchingForChangeEventIE8(target, targetID) {
|
889 | activeElement = target;
|
890 | activeElementID = targetID;
|
891 | activeElement.attachEvent('onchange', manualDispatchChangeEvent);
|
892 | }
|
893 |
|
894 | function stopWatchingForChangeEventIE8() {
|
895 | if (!activeElement) {
|
896 | return;
|
897 | }
|
898 | activeElement.detachEvent('onchange', manualDispatchChangeEvent);
|
899 | activeElement = null;
|
900 | activeElementID = null;
|
901 | }
|
902 |
|
903 | function getTargetIDForChangeEvent(
|
904 | topLevelType,
|
905 | topLevelTarget,
|
906 | topLevelTargetID) {
|
907 | if (topLevelType === topLevelTypes.topChange) {
|
908 | return topLevelTargetID;
|
909 | }
|
910 | }
|
911 | function handleEventsForChangeEventIE8(
|
912 | topLevelType,
|
913 | topLevelTarget,
|
914 | topLevelTargetID) {
|
915 | if (topLevelType === topLevelTypes.topFocus) {
|
916 |
|
917 |
|
918 | stopWatchingForChangeEventIE8();
|
919 | startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
|
920 | } else if (topLevelType === topLevelTypes.topBlur) {
|
921 | stopWatchingForChangeEventIE8();
|
922 | }
|
923 | }
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 | var isInputEventSupported = false;
|
930 | if (ExecutionEnvironment.canUseDOM) {
|
931 |
|
932 |
|
933 | isInputEventSupported = isEventSupported('input') && (
|
934 | !('documentMode' in document) || document.documentMode > 9
|
935 | );
|
936 | }
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | var newValueProp = {
|
943 | get: function() {
|
944 | return activeElementValueProp.get.call(this);
|
945 | },
|
946 | set: function(val) {
|
947 |
|
948 | activeElementValue = '' + val;
|
949 | activeElementValueProp.set.call(this, val);
|
950 | }
|
951 | };
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 | function startWatchingForValueChange(target, targetID) {
|
959 | activeElement = target;
|
960 | activeElementID = targetID;
|
961 | activeElementValue = target.value;
|
962 | activeElementValueProp = Object.getOwnPropertyDescriptor(
|
963 | target.constructor.prototype,
|
964 | 'value'
|
965 | );
|
966 |
|
967 | Object.defineProperty(activeElement, 'value', newValueProp);
|
968 | activeElement.attachEvent('onpropertychange', handlePropertyChange);
|
969 | }
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | function stopWatchingForValueChange() {
|
976 | if (!activeElement) {
|
977 | return;
|
978 | }
|
979 |
|
980 |
|
981 | delete activeElement.value;
|
982 | activeElement.detachEvent('onpropertychange', handlePropertyChange);
|
983 |
|
984 | activeElement = null;
|
985 | activeElementID = null;
|
986 | activeElementValue = null;
|
987 | activeElementValueProp = null;
|
988 | }
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 | function handlePropertyChange(nativeEvent) {
|
995 | if (nativeEvent.propertyName !== 'value') {
|
996 | return;
|
997 | }
|
998 | var value = nativeEvent.srcElement.value;
|
999 | if (value === activeElementValue) {
|
1000 | return;
|
1001 | }
|
1002 | activeElementValue = value;
|
1003 |
|
1004 | manualDispatchChangeEvent(nativeEvent);
|
1005 | }
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 | function getTargetIDForInputEvent(
|
1011 | topLevelType,
|
1012 | topLevelTarget,
|
1013 | topLevelTargetID) {
|
1014 | if (topLevelType === topLevelTypes.topInput) {
|
1015 |
|
1016 |
|
1017 | return topLevelTargetID;
|
1018 | }
|
1019 | }
|
1020 |
|
1021 |
|
1022 | function handleEventsForInputEventIE(
|
1023 | topLevelType,
|
1024 | topLevelTarget,
|
1025 | topLevelTargetID) {
|
1026 | if (topLevelType === topLevelTypes.topFocus) {
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 | stopWatchingForValueChange();
|
1041 | startWatchingForValueChange(topLevelTarget, topLevelTargetID);
|
1042 | } else if (topLevelType === topLevelTypes.topBlur) {
|
1043 | stopWatchingForValueChange();
|
1044 | }
|
1045 | }
|
1046 |
|
1047 |
|
1048 | function getTargetIDForInputEventIE(
|
1049 | topLevelType,
|
1050 | topLevelTarget,
|
1051 | topLevelTargetID) {
|
1052 | if (topLevelType === topLevelTypes.topSelectionChange ||
|
1053 | topLevelType === topLevelTypes.topKeyUp ||
|
1054 | topLevelType === topLevelTypes.topKeyDown) {
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | if (activeElement && activeElement.value !== activeElementValue) {
|
1066 | activeElementValue = activeElement.value;
|
1067 | return activeElementID;
|
1068 | }
|
1069 | }
|
1070 | }
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 | function shouldUseClickEvent(elem) {
|
1077 |
|
1078 |
|
1079 |
|
1080 | return (
|
1081 | elem.nodeName === 'INPUT' &&
|
1082 | (elem.type === 'checkbox' || elem.type === 'radio')
|
1083 | );
|
1084 | }
|
1085 |
|
1086 | function getTargetIDForClickEvent(
|
1087 | topLevelType,
|
1088 | topLevelTarget,
|
1089 | topLevelTargetID) {
|
1090 | if (topLevelType === topLevelTypes.topClick) {
|
1091 | return topLevelTargetID;
|
1092 | }
|
1093 | }
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 | var ChangeEventPlugin = {
|
1106 |
|
1107 | eventTypes: eventTypes,
|
1108 |
|
1109 | |
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 | extractEvents: function(
|
1118 | topLevelType,
|
1119 | topLevelTarget,
|
1120 | topLevelTargetID,
|
1121 | nativeEvent) {
|
1122 |
|
1123 | var getTargetIDFunc, handleEventFunc;
|
1124 | if (shouldUseChangeEvent(topLevelTarget)) {
|
1125 | if (doesChangeEventBubble) {
|
1126 | getTargetIDFunc = getTargetIDForChangeEvent;
|
1127 | } else {
|
1128 | handleEventFunc = handleEventsForChangeEventIE8;
|
1129 | }
|
1130 | } else if (isTextInputElement(topLevelTarget)) {
|
1131 | if (isInputEventSupported) {
|
1132 | getTargetIDFunc = getTargetIDForInputEvent;
|
1133 | } else {
|
1134 | getTargetIDFunc = getTargetIDForInputEventIE;
|
1135 | handleEventFunc = handleEventsForInputEventIE;
|
1136 | }
|
1137 | } else if (shouldUseClickEvent(topLevelTarget)) {
|
1138 | getTargetIDFunc = getTargetIDForClickEvent;
|
1139 | }
|
1140 |
|
1141 | if (getTargetIDFunc) {
|
1142 | var targetID = getTargetIDFunc(
|
1143 | topLevelType,
|
1144 | topLevelTarget,
|
1145 | topLevelTargetID
|
1146 | );
|
1147 | if (targetID) {
|
1148 | var event = SyntheticEvent.getPooled(
|
1149 | eventTypes.change,
|
1150 | targetID,
|
1151 | nativeEvent
|
1152 | );
|
1153 | EventPropagators.accumulateTwoPhaseDispatches(event);
|
1154 | return event;
|
1155 | }
|
1156 | }
|
1157 |
|
1158 | if (handleEventFunc) {
|
1159 | handleEventFunc(
|
1160 | topLevelType,
|
1161 | topLevelTarget,
|
1162 | topLevelTargetID
|
1163 | );
|
1164 | }
|
1165 | }
|
1166 |
|
1167 | };
|
1168 |
|
1169 | module.exports = ChangeEventPlugin;
|
1170 |
|
1171 | },{"./EventConstants":16,"./EventPluginHub":18,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactUpdates":79,"./SyntheticEvent":87,"./isEventSupported":127,"./isTextInputElement":129,"./keyOf":133}],8:[function(_dereq_,module,exports){
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 | "use strict";
|
1185 |
|
1186 | var nextReactRootIndex = 0;
|
1187 |
|
1188 | var ClientReactRootIndex = {
|
1189 | createReactRootIndex: function() {
|
1190 | return nextReactRootIndex++;
|
1191 | }
|
1192 | };
|
1193 |
|
1194 | module.exports = ClientReactRootIndex;
|
1195 |
|
1196 | },{}],9:[function(_dereq_,module,exports){
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 | "use strict";
|
1210 |
|
1211 | var EventConstants = _dereq_("./EventConstants");
|
1212 | var EventPropagators = _dereq_("./EventPropagators");
|
1213 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
1214 | var ReactInputSelection = _dereq_("./ReactInputSelection");
|
1215 | var SyntheticCompositionEvent = _dereq_("./SyntheticCompositionEvent");
|
1216 |
|
1217 | var getTextContentAccessor = _dereq_("./getTextContentAccessor");
|
1218 | var keyOf = _dereq_("./keyOf");
|
1219 |
|
1220 | var END_KEYCODES = [9, 13, 27, 32];
|
1221 | var START_KEYCODE = 229;
|
1222 |
|
1223 | var useCompositionEvent = (
|
1224 | ExecutionEnvironment.canUseDOM &&
|
1225 | 'CompositionEvent' in window
|
1226 | );
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 | var useFallbackData = (
|
1235 | !useCompositionEvent ||
|
1236 | (
|
1237 | 'documentMode' in document &&
|
1238 | document.documentMode > 8 &&
|
1239 | document.documentMode <= 11
|
1240 | )
|
1241 | );
|
1242 |
|
1243 | var topLevelTypes = EventConstants.topLevelTypes;
|
1244 | var currentComposition = null;
|
1245 |
|
1246 |
|
1247 | var eventTypes = {
|
1248 | compositionEnd: {
|
1249 | phasedRegistrationNames: {
|
1250 | bubbled: keyOf({onCompositionEnd: null}),
|
1251 | captured: keyOf({onCompositionEndCapture: null})
|
1252 | },
|
1253 | dependencies: [
|
1254 | topLevelTypes.topBlur,
|
1255 | topLevelTypes.topCompositionEnd,
|
1256 | topLevelTypes.topKeyDown,
|
1257 | topLevelTypes.topKeyPress,
|
1258 | topLevelTypes.topKeyUp,
|
1259 | topLevelTypes.topMouseDown
|
1260 | ]
|
1261 | },
|
1262 | compositionStart: {
|
1263 | phasedRegistrationNames: {
|
1264 | bubbled: keyOf({onCompositionStart: null}),
|
1265 | captured: keyOf({onCompositionStartCapture: null})
|
1266 | },
|
1267 | dependencies: [
|
1268 | topLevelTypes.topBlur,
|
1269 | topLevelTypes.topCompositionStart,
|
1270 | topLevelTypes.topKeyDown,
|
1271 | topLevelTypes.topKeyPress,
|
1272 | topLevelTypes.topKeyUp,
|
1273 | topLevelTypes.topMouseDown
|
1274 | ]
|
1275 | },
|
1276 | compositionUpdate: {
|
1277 | phasedRegistrationNames: {
|
1278 | bubbled: keyOf({onCompositionUpdate: null}),
|
1279 | captured: keyOf({onCompositionUpdateCapture: null})
|
1280 | },
|
1281 | dependencies: [
|
1282 | topLevelTypes.topBlur,
|
1283 | topLevelTypes.topCompositionUpdate,
|
1284 | topLevelTypes.topKeyDown,
|
1285 | topLevelTypes.topKeyPress,
|
1286 | topLevelTypes.topKeyUp,
|
1287 | topLevelTypes.topMouseDown
|
1288 | ]
|
1289 | }
|
1290 | };
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 | function getCompositionEventType(topLevelType) {
|
1299 | switch (topLevelType) {
|
1300 | case topLevelTypes.topCompositionStart:
|
1301 | return eventTypes.compositionStart;
|
1302 | case topLevelTypes.topCompositionEnd:
|
1303 | return eventTypes.compositionEnd;
|
1304 | case topLevelTypes.topCompositionUpdate:
|
1305 | return eventTypes.compositionUpdate;
|
1306 | }
|
1307 | }
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | function isFallbackStart(topLevelType, nativeEvent) {
|
1318 | return (
|
1319 | topLevelType === topLevelTypes.topKeyDown &&
|
1320 | nativeEvent.keyCode === START_KEYCODE
|
1321 | );
|
1322 | }
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 | function isFallbackEnd(topLevelType, nativeEvent) {
|
1332 | switch (topLevelType) {
|
1333 | case topLevelTypes.topKeyUp:
|
1334 |
|
1335 | return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
|
1336 | case topLevelTypes.topKeyDown:
|
1337 |
|
1338 |
|
1339 | return (nativeEvent.keyCode !== START_KEYCODE);
|
1340 | case topLevelTypes.topKeyPress:
|
1341 | case topLevelTypes.topMouseDown:
|
1342 | case topLevelTypes.topBlur:
|
1343 |
|
1344 | return true;
|
1345 | default:
|
1346 | return false;
|
1347 | }
|
1348 | }
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 | function FallbackCompositionState(root) {
|
1357 | this.root = root;
|
1358 | this.startSelection = ReactInputSelection.getSelection(root);
|
1359 | this.startValue = this.getText();
|
1360 | }
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 | FallbackCompositionState.prototype.getText = function() {
|
1368 | return this.root.value || this.root[getTextContentAccessor()];
|
1369 | };
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 | FallbackCompositionState.prototype.getData = function() {
|
1377 | var endValue = this.getText();
|
1378 | var prefixLength = this.startSelection.start;
|
1379 | var suffixLength = this.startValue.length - this.startSelection.end;
|
1380 |
|
1381 | return endValue.substr(
|
1382 | prefixLength,
|
1383 | endValue.length - suffixLength - prefixLength
|
1384 | );
|
1385 | };
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 | var CompositionEventPlugin = {
|
1393 |
|
1394 | eventTypes: eventTypes,
|
1395 |
|
1396 | |
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 | extractEvents: function(
|
1405 | topLevelType,
|
1406 | topLevelTarget,
|
1407 | topLevelTargetID,
|
1408 | nativeEvent) {
|
1409 |
|
1410 | var eventType;
|
1411 | var data;
|
1412 |
|
1413 | if (useCompositionEvent) {
|
1414 | eventType = getCompositionEventType(topLevelType);
|
1415 | } else if (!currentComposition) {
|
1416 | if (isFallbackStart(topLevelType, nativeEvent)) {
|
1417 | eventType = eventTypes.compositionStart;
|
1418 | }
|
1419 | } else if (isFallbackEnd(topLevelType, nativeEvent)) {
|
1420 | eventType = eventTypes.compositionEnd;
|
1421 | }
|
1422 |
|
1423 | if (useFallbackData) {
|
1424 |
|
1425 |
|
1426 | if (!currentComposition && eventType === eventTypes.compositionStart) {
|
1427 | currentComposition = new FallbackCompositionState(topLevelTarget);
|
1428 | } else if (eventType === eventTypes.compositionEnd) {
|
1429 | if (currentComposition) {
|
1430 | data = currentComposition.getData();
|
1431 | currentComposition = null;
|
1432 | }
|
1433 | }
|
1434 | }
|
1435 |
|
1436 | if (eventType) {
|
1437 | var event = SyntheticCompositionEvent.getPooled(
|
1438 | eventType,
|
1439 | topLevelTargetID,
|
1440 | nativeEvent
|
1441 | );
|
1442 | if (data) {
|
1443 |
|
1444 |
|
1445 | event.data = data;
|
1446 | }
|
1447 | EventPropagators.accumulateTwoPhaseDispatches(event);
|
1448 | return event;
|
1449 | }
|
1450 | }
|
1451 | };
|
1452 |
|
1453 | module.exports = CompositionEventPlugin;
|
1454 |
|
1455 | },{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactInputSelection":59,"./SyntheticCompositionEvent":85,"./getTextContentAccessor":121,"./keyOf":133}],10:[function(_dereq_,module,exports){
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 | "use strict";
|
1469 |
|
1470 | var Danger = _dereq_("./Danger");
|
1471 | var ReactMultiChildUpdateTypes = _dereq_("./ReactMultiChildUpdateTypes");
|
1472 |
|
1473 | var getTextContentAccessor = _dereq_("./getTextContentAccessor");
|
1474 | var invariant = _dereq_("./invariant");
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 | var textContentAccessor = getTextContentAccessor();
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 | function insertChildAt(parentNode, childNode, index) {
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 | parentNode.insertBefore(
|
1498 | childNode,
|
1499 | parentNode.childNodes[index] || null
|
1500 | );
|
1501 | }
|
1502 |
|
1503 | var updateTextContent;
|
1504 | if (textContentAccessor === 'textContent') {
|
1505 | |
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 | updateTextContent = function(node, text) {
|
1512 | node.textContent = text;
|
1513 | };
|
1514 | } else {
|
1515 | |
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 | updateTextContent = function(node, text) {
|
1522 |
|
1523 |
|
1524 | while (node.firstChild) {
|
1525 | node.removeChild(node.firstChild);
|
1526 | }
|
1527 | if (text) {
|
1528 | var doc = node.ownerDocument || document;
|
1529 | node.appendChild(doc.createTextNode(text));
|
1530 | }
|
1531 | };
|
1532 | }
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 | var DOMChildrenOperations = {
|
1538 |
|
1539 | dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
|
1540 |
|
1541 | updateTextContent: updateTextContent,
|
1542 |
|
1543 | |
1544 |
|
1545 |
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 | processUpdates: function(updates, markupList) {
|
1552 | var update;
|
1553 |
|
1554 | var initialChildren = null;
|
1555 |
|
1556 | var updatedChildren = null;
|
1557 |
|
1558 | for (var i = 0; update = updates[i]; i++) {
|
1559 | if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
|
1560 | update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
|
1561 | var updatedIndex = update.fromIndex;
|
1562 | var updatedChild = update.parentNode.childNodes[updatedIndex];
|
1563 | var parentID = update.parentID;
|
1564 |
|
1565 | ("production" !== "development" ? invariant(
|
1566 | updatedChild,
|
1567 | 'processUpdates(): Unable to find child %s of element. This ' +
|
1568 | 'probably means the DOM was unexpectedly mutated (e.g., by the ' +
|
1569 | 'browser), usually due to forgetting a <tbody> when using tables, ' +
|
1570 | 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements '+
|
1571 | 'in an <svg> parent. Try inspecting the child nodes of the element ' +
|
1572 | 'with React ID `%s`.',
|
1573 | updatedIndex,
|
1574 | parentID
|
1575 | ) : invariant(updatedChild));
|
1576 |
|
1577 | initialChildren = initialChildren || {};
|
1578 | initialChildren[parentID] = initialChildren[parentID] || [];
|
1579 | initialChildren[parentID][updatedIndex] = updatedChild;
|
1580 |
|
1581 | updatedChildren = updatedChildren || [];
|
1582 | updatedChildren.push(updatedChild);
|
1583 | }
|
1584 | }
|
1585 |
|
1586 | var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
|
1587 |
|
1588 |
|
1589 | if (updatedChildren) {
|
1590 | for (var j = 0; j < updatedChildren.length; j++) {
|
1591 | updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
|
1592 | }
|
1593 | }
|
1594 |
|
1595 | for (var k = 0; update = updates[k]; k++) {
|
1596 | switch (update.type) {
|
1597 | case ReactMultiChildUpdateTypes.INSERT_MARKUP:
|
1598 | insertChildAt(
|
1599 | update.parentNode,
|
1600 | renderedMarkup[update.markupIndex],
|
1601 | update.toIndex
|
1602 | );
|
1603 | break;
|
1604 | case ReactMultiChildUpdateTypes.MOVE_EXISTING:
|
1605 | insertChildAt(
|
1606 | update.parentNode,
|
1607 | initialChildren[update.parentID][update.fromIndex],
|
1608 | update.toIndex
|
1609 | );
|
1610 | break;
|
1611 | case ReactMultiChildUpdateTypes.TEXT_CONTENT:
|
1612 | updateTextContent(
|
1613 | update.parentNode,
|
1614 | update.textContent
|
1615 | );
|
1616 | break;
|
1617 | case ReactMultiChildUpdateTypes.REMOVE_NODE:
|
1618 |
|
1619 | break;
|
1620 | }
|
1621 | }
|
1622 | }
|
1623 |
|
1624 | };
|
1625 |
|
1626 | module.exports = DOMChildrenOperations;
|
1627 |
|
1628 | },{"./Danger":13,"./ReactMultiChildUpdateTypes":65,"./getTextContentAccessor":121,"./invariant":126}],11:[function(_dereq_,module,exports){
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 | "use strict";
|
1644 |
|
1645 | var invariant = _dereq_("./invariant");
|
1646 |
|
1647 | function checkMask(value, bitmask) {
|
1648 | return (value & bitmask) === bitmask;
|
1649 | }
|
1650 |
|
1651 | var DOMPropertyInjection = {
|
1652 | |
1653 |
|
1654 |
|
1655 |
|
1656 | MUST_USE_ATTRIBUTE: 0x1,
|
1657 | MUST_USE_PROPERTY: 0x2,
|
1658 | HAS_SIDE_EFFECTS: 0x4,
|
1659 | HAS_BOOLEAN_VALUE: 0x8,
|
1660 | HAS_NUMERIC_VALUE: 0x10,
|
1661 | HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
|
1662 | HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
|
1663 |
|
1664 | |
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 |
|
1686 |
|
1687 |
|
1688 |
|
1689 | injectDOMPropertyConfig: function(domPropertyConfig) {
|
1690 | var Properties = domPropertyConfig.Properties || {};
|
1691 | var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
|
1692 | var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
|
1693 | var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
|
1694 |
|
1695 | if (domPropertyConfig.isCustomAttribute) {
|
1696 | DOMProperty._isCustomAttributeFunctions.push(
|
1697 | domPropertyConfig.isCustomAttribute
|
1698 | );
|
1699 | }
|
1700 |
|
1701 | for (var propName in Properties) {
|
1702 | ("production" !== "development" ? invariant(
|
1703 | !DOMProperty.isStandardName.hasOwnProperty(propName),
|
1704 | 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
|
1705 | '\'%s\' which has already been injected. You may be accidentally ' +
|
1706 | 'injecting the same DOM property config twice, or you may be ' +
|
1707 | 'injecting two configs that have conflicting property names.',
|
1708 | propName
|
1709 | ) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
|
1710 |
|
1711 | DOMProperty.isStandardName[propName] = true;
|
1712 |
|
1713 | var lowerCased = propName.toLowerCase();
|
1714 | DOMProperty.getPossibleStandardName[lowerCased] = propName;
|
1715 |
|
1716 | if (DOMAttributeNames.hasOwnProperty(propName)) {
|
1717 | var attributeName = DOMAttributeNames[propName];
|
1718 | DOMProperty.getPossibleStandardName[attributeName] = propName;
|
1719 | DOMProperty.getAttributeName[propName] = attributeName;
|
1720 | } else {
|
1721 | DOMProperty.getAttributeName[propName] = lowerCased;
|
1722 | }
|
1723 |
|
1724 | DOMProperty.getPropertyName[propName] =
|
1725 | DOMPropertyNames.hasOwnProperty(propName) ?
|
1726 | DOMPropertyNames[propName] :
|
1727 | propName;
|
1728 |
|
1729 | if (DOMMutationMethods.hasOwnProperty(propName)) {
|
1730 | DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
|
1731 | } else {
|
1732 | DOMProperty.getMutationMethod[propName] = null;
|
1733 | }
|
1734 |
|
1735 | var propConfig = Properties[propName];
|
1736 | DOMProperty.mustUseAttribute[propName] =
|
1737 | checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
|
1738 | DOMProperty.mustUseProperty[propName] =
|
1739 | checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
|
1740 | DOMProperty.hasSideEffects[propName] =
|
1741 | checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
|
1742 | DOMProperty.hasBooleanValue[propName] =
|
1743 | checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
|
1744 | DOMProperty.hasNumericValue[propName] =
|
1745 | checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
|
1746 | DOMProperty.hasPositiveNumericValue[propName] =
|
1747 | checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
|
1748 | DOMProperty.hasOverloadedBooleanValue[propName] =
|
1749 | checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
|
1750 |
|
1751 | ("production" !== "development" ? invariant(
|
1752 | !DOMProperty.mustUseAttribute[propName] ||
|
1753 | !DOMProperty.mustUseProperty[propName],
|
1754 | 'DOMProperty: Cannot require using both attribute and property: %s',
|
1755 | propName
|
1756 | ) : invariant(!DOMProperty.mustUseAttribute[propName] ||
|
1757 | !DOMProperty.mustUseProperty[propName]));
|
1758 | ("production" !== "development" ? invariant(
|
1759 | DOMProperty.mustUseProperty[propName] ||
|
1760 | !DOMProperty.hasSideEffects[propName],
|
1761 | 'DOMProperty: Properties that have side effects must use property: %s',
|
1762 | propName
|
1763 | ) : invariant(DOMProperty.mustUseProperty[propName] ||
|
1764 | !DOMProperty.hasSideEffects[propName]));
|
1765 | ("production" !== "development" ? invariant(
|
1766 | !!DOMProperty.hasBooleanValue[propName] +
|
1767 | !!DOMProperty.hasNumericValue[propName] +
|
1768 | !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
|
1769 | 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
|
1770 | 'numeric value, but not a combination: %s',
|
1771 | propName
|
1772 | ) : invariant(!!DOMProperty.hasBooleanValue[propName] +
|
1773 | !!DOMProperty.hasNumericValue[propName] +
|
1774 | !!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
|
1775 | }
|
1776 | }
|
1777 | };
|
1778 | var defaultValueCache = {};
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 | var DOMProperty = {
|
1794 |
|
1795 | ID_ATTRIBUTE_NAME: 'data-reactid',
|
1796 |
|
1797 | |
1798 |
|
1799 |
|
1800 |
|
1801 | isStandardName: {},
|
1802 |
|
1803 | |
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 | getPossibleStandardName: {},
|
1809 |
|
1810 | |
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 | getAttributeName: {},
|
1816 |
|
1817 | |
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 | getPropertyName: {},
|
1823 |
|
1824 | |
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 | getMutationMethod: {},
|
1830 |
|
1831 | |
1832 |
|
1833 |
|
1834 |
|
1835 | mustUseAttribute: {},
|
1836 |
|
1837 | |
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 | mustUseProperty: {},
|
1843 |
|
1844 | |
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 | hasSideEffects: {},
|
1851 |
|
1852 | |
1853 |
|
1854 |
|
1855 |
|
1856 | hasBooleanValue: {},
|
1857 |
|
1858 | |
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 | hasNumericValue: {},
|
1864 |
|
1865 | |
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 | hasPositiveNumericValue: {},
|
1871 |
|
1872 | |
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 | hasOverloadedBooleanValue: {},
|
1879 |
|
1880 | |
1881 |
|
1882 |
|
1883 | _isCustomAttributeFunctions: [],
|
1884 |
|
1885 | |
1886 |
|
1887 |
|
1888 |
|
1889 | isCustomAttribute: function(attributeName) {
|
1890 | for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
|
1891 | var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
|
1892 | if (isCustomAttributeFn(attributeName)) {
|
1893 | return true;
|
1894 | }
|
1895 | }
|
1896 | return false;
|
1897 | },
|
1898 |
|
1899 | |
1900 |
|
1901 |
|
1902 |
|
1903 |
|
1904 |
|
1905 |
|
1906 |
|
1907 | getDefaultValueForProperty: function(nodeName, prop) {
|
1908 | var nodeDefaults = defaultValueCache[nodeName];
|
1909 | var testElement;
|
1910 | if (!nodeDefaults) {
|
1911 | defaultValueCache[nodeName] = nodeDefaults = {};
|
1912 | }
|
1913 | if (!(prop in nodeDefaults)) {
|
1914 | testElement = document.createElement(nodeName);
|
1915 | nodeDefaults[prop] = testElement[prop];
|
1916 | }
|
1917 | return nodeDefaults[prop];
|
1918 | },
|
1919 |
|
1920 | injection: DOMPropertyInjection
|
1921 | };
|
1922 |
|
1923 | module.exports = DOMProperty;
|
1924 |
|
1925 | },{"./invariant":126}],12:[function(_dereq_,module,exports){
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 | "use strict";
|
1939 |
|
1940 | var DOMProperty = _dereq_("./DOMProperty");
|
1941 |
|
1942 | var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
|
1943 | var memoizeStringOnly = _dereq_("./memoizeStringOnly");
|
1944 | var warning = _dereq_("./warning");
|
1945 |
|
1946 | function shouldIgnoreValue(name, value) {
|
1947 | return value == null ||
|
1948 | (DOMProperty.hasBooleanValue[name] && !value) ||
|
1949 | (DOMProperty.hasNumericValue[name] && isNaN(value)) ||
|
1950 | (DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
|
1951 | (DOMProperty.hasOverloadedBooleanValue[name] && value === false);
|
1952 | }
|
1953 |
|
1954 | var processAttributeNameAndPrefix = memoizeStringOnly(function(name) {
|
1955 | return escapeTextForBrowser(name) + '="';
|
1956 | });
|
1957 |
|
1958 | if ("production" !== "development") {
|
1959 | var reactProps = {
|
1960 | children: true,
|
1961 | dangerouslySetInnerHTML: true,
|
1962 | key: true,
|
1963 | ref: true
|
1964 | };
|
1965 | var warnedProperties = {};
|
1966 |
|
1967 | var warnUnknownProperty = function(name) {
|
1968 | if (reactProps.hasOwnProperty(name) && reactProps[name] ||
|
1969 | warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
1970 | return;
|
1971 | }
|
1972 |
|
1973 | warnedProperties[name] = true;
|
1974 | var lowerCasedName = name.toLowerCase();
|
1975 |
|
1976 |
|
1977 | var standardName = (
|
1978 | DOMProperty.isCustomAttribute(lowerCasedName) ?
|
1979 | lowerCasedName :
|
1980 | DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
|
1981 | DOMProperty.getPossibleStandardName[lowerCasedName] :
|
1982 | null
|
1983 | );
|
1984 |
|
1985 |
|
1986 |
|
1987 | ("production" !== "development" ? warning(
|
1988 | standardName == null,
|
1989 | 'Unknown DOM property ' + name + '. Did you mean ' + standardName + '?'
|
1990 | ) : null);
|
1991 |
|
1992 | };
|
1993 | }
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 | var DOMPropertyOperations = {
|
1999 |
|
2000 | |
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 | createMarkupForID: function(id) {
|
2007 | return processAttributeNameAndPrefix(DOMProperty.ID_ATTRIBUTE_NAME) +
|
2008 | escapeTextForBrowser(id) + '"';
|
2009 | },
|
2010 |
|
2011 | |
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 | createMarkupForProperty: function(name, value) {
|
2019 | if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
2020 | DOMProperty.isStandardName[name]) {
|
2021 | if (shouldIgnoreValue(name, value)) {
|
2022 | return '';
|
2023 | }
|
2024 | var attributeName = DOMProperty.getAttributeName[name];
|
2025 | if (DOMProperty.hasBooleanValue[name] ||
|
2026 | (DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
|
2027 | return escapeTextForBrowser(attributeName);
|
2028 | }
|
2029 | return processAttributeNameAndPrefix(attributeName) +
|
2030 | escapeTextForBrowser(value) + '"';
|
2031 | } else if (DOMProperty.isCustomAttribute(name)) {
|
2032 | if (value == null) {
|
2033 | return '';
|
2034 | }
|
2035 | return processAttributeNameAndPrefix(name) +
|
2036 | escapeTextForBrowser(value) + '"';
|
2037 | } else if ("production" !== "development") {
|
2038 | warnUnknownProperty(name);
|
2039 | }
|
2040 | return null;
|
2041 | },
|
2042 |
|
2043 | |
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 | setValueForProperty: function(node, name, value) {
|
2051 | if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
2052 | DOMProperty.isStandardName[name]) {
|
2053 | var mutationMethod = DOMProperty.getMutationMethod[name];
|
2054 | if (mutationMethod) {
|
2055 | mutationMethod(node, value);
|
2056 | } else if (shouldIgnoreValue(name, value)) {
|
2057 | this.deleteValueForProperty(node, name);
|
2058 | } else if (DOMProperty.mustUseAttribute[name]) {
|
2059 |
|
2060 |
|
2061 | node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
|
2062 | } else {
|
2063 | var propName = DOMProperty.getPropertyName[name];
|
2064 |
|
2065 |
|
2066 | if (!DOMProperty.hasSideEffects[name] ||
|
2067 | ('' + node[propName]) !== ('' + value)) {
|
2068 |
|
2069 |
|
2070 | node[propName] = value;
|
2071 | }
|
2072 | }
|
2073 | } else if (DOMProperty.isCustomAttribute(name)) {
|
2074 | if (value == null) {
|
2075 | node.removeAttribute(name);
|
2076 | } else {
|
2077 | node.setAttribute(name, '' + value);
|
2078 | }
|
2079 | } else if ("production" !== "development") {
|
2080 | warnUnknownProperty(name);
|
2081 | }
|
2082 | },
|
2083 |
|
2084 | |
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 | deleteValueForProperty: function(node, name) {
|
2091 | if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
2092 | DOMProperty.isStandardName[name]) {
|
2093 | var mutationMethod = DOMProperty.getMutationMethod[name];
|
2094 | if (mutationMethod) {
|
2095 | mutationMethod(node, undefined);
|
2096 | } else if (DOMProperty.mustUseAttribute[name]) {
|
2097 | node.removeAttribute(DOMProperty.getAttributeName[name]);
|
2098 | } else {
|
2099 | var propName = DOMProperty.getPropertyName[name];
|
2100 | var defaultValue = DOMProperty.getDefaultValueForProperty(
|
2101 | node.nodeName,
|
2102 | propName
|
2103 | );
|
2104 | if (!DOMProperty.hasSideEffects[name] ||
|
2105 | ('' + node[propName]) !== defaultValue) {
|
2106 | node[propName] = defaultValue;
|
2107 | }
|
2108 | }
|
2109 | } else if (DOMProperty.isCustomAttribute(name)) {
|
2110 | node.removeAttribute(name);
|
2111 | } else if ("production" !== "development") {
|
2112 | warnUnknownProperty(name);
|
2113 | }
|
2114 | }
|
2115 |
|
2116 | };
|
2117 |
|
2118 | module.exports = DOMPropertyOperations;
|
2119 |
|
2120 | },{"./DOMProperty":11,"./escapeTextForBrowser":109,"./memoizeStringOnly":135,"./warning":145}],13:[function(_dereq_,module,exports){
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 | "use strict";
|
2136 |
|
2137 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
2138 |
|
2139 | var createNodesFromMarkup = _dereq_("./createNodesFromMarkup");
|
2140 | var emptyFunction = _dereq_("./emptyFunction");
|
2141 | var getMarkupWrap = _dereq_("./getMarkupWrap");
|
2142 | var invariant = _dereq_("./invariant");
|
2143 |
|
2144 | var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
|
2145 | var RESULT_INDEX_ATTR = 'data-danger-index';
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 |
|
2157 |
|
2158 | function getNodeName(markup) {
|
2159 | return markup.substring(1, markup.indexOf(' '));
|
2160 | }
|
2161 |
|
2162 | var Danger = {
|
2163 |
|
2164 | |
2165 |
|
2166 |
|
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 |
|
2173 | dangerouslyRenderMarkup: function(markupList) {
|
2174 | ("production" !== "development" ? invariant(
|
2175 | ExecutionEnvironment.canUseDOM,
|
2176 | 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
|
2177 | 'thread. Make sure `window` and `document` are available globally ' +
|
2178 | 'before requiring React when unit testing or use ' +
|
2179 | 'React.renderToString for server rendering.'
|
2180 | ) : invariant(ExecutionEnvironment.canUseDOM));
|
2181 | var nodeName;
|
2182 | var markupByNodeName = {};
|
2183 |
|
2184 | for (var i = 0; i < markupList.length; i++) {
|
2185 | ("production" !== "development" ? invariant(
|
2186 | markupList[i],
|
2187 | 'dangerouslyRenderMarkup(...): Missing markup.'
|
2188 | ) : invariant(markupList[i]));
|
2189 | nodeName = getNodeName(markupList[i]);
|
2190 | nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
2191 | markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
2192 | markupByNodeName[nodeName][i] = markupList[i];
|
2193 | }
|
2194 | var resultList = [];
|
2195 | var resultListAssignmentCount = 0;
|
2196 | for (nodeName in markupByNodeName) {
|
2197 | if (!markupByNodeName.hasOwnProperty(nodeName)) {
|
2198 | continue;
|
2199 | }
|
2200 | var markupListByNodeName = markupByNodeName[nodeName];
|
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 | for (var resultIndex in markupListByNodeName) {
|
2206 | if (markupListByNodeName.hasOwnProperty(resultIndex)) {
|
2207 | var markup = markupListByNodeName[resultIndex];
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 | markupListByNodeName[resultIndex] = markup.replace(
|
2213 | OPEN_TAG_NAME_EXP,
|
2214 |
|
2215 | '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
|
2216 | );
|
2217 | }
|
2218 | }
|
2219 |
|
2220 |
|
2221 | var renderNodes = createNodesFromMarkup(
|
2222 | markupListByNodeName.join(''),
|
2223 | emptyFunction
|
2224 | );
|
2225 |
|
2226 | for (i = 0; i < renderNodes.length; ++i) {
|
2227 | var renderNode = renderNodes[i];
|
2228 | if (renderNode.hasAttribute &&
|
2229 | renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
2230 |
|
2231 | resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
2232 | renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
2233 |
|
2234 | ("production" !== "development" ? invariant(
|
2235 | !resultList.hasOwnProperty(resultIndex),
|
2236 | 'Danger: Assigning to an already-occupied result index.'
|
2237 | ) : invariant(!resultList.hasOwnProperty(resultIndex)));
|
2238 |
|
2239 | resultList[resultIndex] = renderNode;
|
2240 |
|
2241 |
|
2242 |
|
2243 | resultListAssignmentCount += 1;
|
2244 |
|
2245 | } else if ("production" !== "development") {
|
2246 | console.error(
|
2247 | "Danger: Discarding unexpected node:",
|
2248 | renderNode
|
2249 | );
|
2250 | }
|
2251 | }
|
2252 | }
|
2253 |
|
2254 |
|
2255 |
|
2256 | ("production" !== "development" ? invariant(
|
2257 | resultListAssignmentCount === resultList.length,
|
2258 | 'Danger: Did not assign to every index of resultList.'
|
2259 | ) : invariant(resultListAssignmentCount === resultList.length));
|
2260 |
|
2261 | ("production" !== "development" ? invariant(
|
2262 | resultList.length === markupList.length,
|
2263 | 'Danger: Expected markup to render %s nodes, but rendered %s.',
|
2264 | markupList.length,
|
2265 | resultList.length
|
2266 | ) : invariant(resultList.length === markupList.length));
|
2267 |
|
2268 | return resultList;
|
2269 | },
|
2270 |
|
2271 | |
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 | dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
|
2280 | ("production" !== "development" ? invariant(
|
2281 | ExecutionEnvironment.canUseDOM,
|
2282 | 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
|
2283 | 'worker thread. Make sure `window` and `document` are available ' +
|
2284 | 'globally before requiring React when unit testing or use ' +
|
2285 | 'React.renderToString for server rendering.'
|
2286 | ) : invariant(ExecutionEnvironment.canUseDOM));
|
2287 | ("production" !== "development" ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
|
2288 | ("production" !== "development" ? invariant(
|
2289 | oldChild.tagName.toLowerCase() !== 'html',
|
2290 | 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
|
2291 | '<html> node. This is because browser quirks make this unreliable ' +
|
2292 | 'and/or slow. If you want to render to the root you must use ' +
|
2293 | 'server rendering. See renderComponentToString().'
|
2294 | ) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
|
2295 |
|
2296 | var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
2297 | oldChild.parentNode.replaceChild(newChild, oldChild);
|
2298 | }
|
2299 |
|
2300 | };
|
2301 |
|
2302 | module.exports = Danger;
|
2303 |
|
2304 | },{"./ExecutionEnvironment":22,"./createNodesFromMarkup":104,"./emptyFunction":107,"./getMarkupWrap":118,"./invariant":126}],14:[function(_dereq_,module,exports){
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 |
|
2314 |
|
2315 |
|
2316 | "use strict";
|
2317 |
|
2318 | var keyOf = _dereq_("./keyOf");
|
2319 |
|
2320 |
|
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 | var DefaultEventPluginOrder = [
|
2330 | keyOf({ResponderEventPlugin: null}),
|
2331 | keyOf({SimpleEventPlugin: null}),
|
2332 | keyOf({TapEventPlugin: null}),
|
2333 | keyOf({EnterLeaveEventPlugin: null}),
|
2334 | keyOf({ChangeEventPlugin: null}),
|
2335 | keyOf({SelectEventPlugin: null}),
|
2336 | keyOf({CompositionEventPlugin: null}),
|
2337 | keyOf({BeforeInputEventPlugin: null}),
|
2338 | keyOf({AnalyticsEventPlugin: null}),
|
2339 | keyOf({MobileSafariClickEventPlugin: null})
|
2340 | ];
|
2341 |
|
2342 | module.exports = DefaultEventPluginOrder;
|
2343 |
|
2344 | },{"./keyOf":133}],15:[function(_dereq_,module,exports){
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 |
|
2357 | "use strict";
|
2358 |
|
2359 | var EventConstants = _dereq_("./EventConstants");
|
2360 | var EventPropagators = _dereq_("./EventPropagators");
|
2361 | var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
|
2362 |
|
2363 | var ReactMount = _dereq_("./ReactMount");
|
2364 | var keyOf = _dereq_("./keyOf");
|
2365 |
|
2366 | var topLevelTypes = EventConstants.topLevelTypes;
|
2367 | var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
2368 |
|
2369 | var eventTypes = {
|
2370 | mouseEnter: {
|
2371 | registrationName: keyOf({onMouseEnter: null}),
|
2372 | dependencies: [
|
2373 | topLevelTypes.topMouseOut,
|
2374 | topLevelTypes.topMouseOver
|
2375 | ]
|
2376 | },
|
2377 | mouseLeave: {
|
2378 | registrationName: keyOf({onMouseLeave: null}),
|
2379 | dependencies: [
|
2380 | topLevelTypes.topMouseOut,
|
2381 | topLevelTypes.topMouseOver
|
2382 | ]
|
2383 | }
|
2384 | };
|
2385 |
|
2386 | var extractedEvents = [null, null];
|
2387 |
|
2388 | var EnterLeaveEventPlugin = {
|
2389 |
|
2390 | eventTypes: eventTypes,
|
2391 |
|
2392 | |
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 |
|
2398 |
|
2399 |
|
2400 |
|
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 | extractEvents: function(
|
2407 | topLevelType,
|
2408 | topLevelTarget,
|
2409 | topLevelTargetID,
|
2410 | nativeEvent) {
|
2411 | if (topLevelType === topLevelTypes.topMouseOver &&
|
2412 | (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
2413 | return null;
|
2414 | }
|
2415 | if (topLevelType !== topLevelTypes.topMouseOut &&
|
2416 | topLevelType !== topLevelTypes.topMouseOver) {
|
2417 |
|
2418 | return null;
|
2419 | }
|
2420 |
|
2421 | var win;
|
2422 | if (topLevelTarget.window === topLevelTarget) {
|
2423 |
|
2424 | win = topLevelTarget;
|
2425 | } else {
|
2426 |
|
2427 | var doc = topLevelTarget.ownerDocument;
|
2428 | if (doc) {
|
2429 | win = doc.defaultView || doc.parentWindow;
|
2430 | } else {
|
2431 | win = window;
|
2432 | }
|
2433 | }
|
2434 |
|
2435 | var from, to;
|
2436 | if (topLevelType === topLevelTypes.topMouseOut) {
|
2437 | from = topLevelTarget;
|
2438 | to =
|
2439 | getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
|
2440 | win;
|
2441 | } else {
|
2442 | from = win;
|
2443 | to = topLevelTarget;
|
2444 | }
|
2445 |
|
2446 | if (from === to) {
|
2447 |
|
2448 | return null;
|
2449 | }
|
2450 |
|
2451 | var fromID = from ? ReactMount.getID(from) : '';
|
2452 | var toID = to ? ReactMount.getID(to) : '';
|
2453 |
|
2454 | var leave = SyntheticMouseEvent.getPooled(
|
2455 | eventTypes.mouseLeave,
|
2456 | fromID,
|
2457 | nativeEvent
|
2458 | );
|
2459 | leave.type = 'mouseleave';
|
2460 | leave.target = from;
|
2461 | leave.relatedTarget = to;
|
2462 |
|
2463 | var enter = SyntheticMouseEvent.getPooled(
|
2464 | eventTypes.mouseEnter,
|
2465 | toID,
|
2466 | nativeEvent
|
2467 | );
|
2468 | enter.type = 'mouseenter';
|
2469 | enter.target = to;
|
2470 | enter.relatedTarget = from;
|
2471 |
|
2472 | EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
|
2473 |
|
2474 | extractedEvents[0] = leave;
|
2475 | extractedEvents[1] = enter;
|
2476 |
|
2477 | return extractedEvents;
|
2478 | }
|
2479 |
|
2480 | };
|
2481 |
|
2482 | module.exports = EnterLeaveEventPlugin;
|
2483 |
|
2484 | },{"./EventConstants":16,"./EventPropagators":21,"./ReactMount":63,"./SyntheticMouseEvent":91,"./keyOf":133}],16:[function(_dereq_,module,exports){
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 |
|
2494 |
|
2495 |
|
2496 | "use strict";
|
2497 |
|
2498 | var keyMirror = _dereq_("./keyMirror");
|
2499 |
|
2500 | var PropagationPhases = keyMirror({bubbled: null, captured: null});
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 | var topLevelTypes = keyMirror({
|
2506 | topBlur: null,
|
2507 | topChange: null,
|
2508 | topClick: null,
|
2509 | topCompositionEnd: null,
|
2510 | topCompositionStart: null,
|
2511 | topCompositionUpdate: null,
|
2512 | topContextMenu: null,
|
2513 | topCopy: null,
|
2514 | topCut: null,
|
2515 | topDoubleClick: null,
|
2516 | topDrag: null,
|
2517 | topDragEnd: null,
|
2518 | topDragEnter: null,
|
2519 | topDragExit: null,
|
2520 | topDragLeave: null,
|
2521 | topDragOver: null,
|
2522 | topDragStart: null,
|
2523 | topDrop: null,
|
2524 | topError: null,
|
2525 | topFocus: null,
|
2526 | topInput: null,
|
2527 | topKeyDown: null,
|
2528 | topKeyPress: null,
|
2529 | topKeyUp: null,
|
2530 | topLoad: null,
|
2531 | topMouseDown: null,
|
2532 | topMouseMove: null,
|
2533 | topMouseOut: null,
|
2534 | topMouseOver: null,
|
2535 | topMouseUp: null,
|
2536 | topPaste: null,
|
2537 | topReset: null,
|
2538 | topScroll: null,
|
2539 | topSelectionChange: null,
|
2540 | topSubmit: null,
|
2541 | topTextInput: null,
|
2542 | topTouchCancel: null,
|
2543 | topTouchEnd: null,
|
2544 | topTouchMove: null,
|
2545 | topTouchStart: null,
|
2546 | topWheel: null
|
2547 | });
|
2548 |
|
2549 | var EventConstants = {
|
2550 | topLevelTypes: topLevelTypes,
|
2551 | PropagationPhases: PropagationPhases
|
2552 | };
|
2553 |
|
2554 | module.exports = EventConstants;
|
2555 |
|
2556 | },{"./keyMirror":132}],17:[function(_dereq_,module,exports){
|
2557 |
|
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 |
|
2563 |
|
2564 |
|
2565 |
|
2566 |
|
2567 |
|
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 | var emptyFunction = _dereq_("./emptyFunction");
|
2577 |
|
2578 |
|
2579 |
|
2580 |
|
2581 |
|
2582 | var EventListener = {
|
2583 | |
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 |
|
2591 | listen: function(target, eventType, callback) {
|
2592 | if (target.addEventListener) {
|
2593 | target.addEventListener(eventType, callback, false);
|
2594 | return {
|
2595 | remove: function() {
|
2596 | target.removeEventListener(eventType, callback, false);
|
2597 | }
|
2598 | };
|
2599 | } else if (target.attachEvent) {
|
2600 | target.attachEvent('on' + eventType, callback);
|
2601 | return {
|
2602 | remove: function() {
|
2603 | target.detachEvent('on' + eventType, callback);
|
2604 | }
|
2605 | };
|
2606 | }
|
2607 | },
|
2608 |
|
2609 | |
2610 |
|
2611 |
|
2612 |
|
2613 |
|
2614 |
|
2615 |
|
2616 |
|
2617 | capture: function(target, eventType, callback) {
|
2618 | if (!target.addEventListener) {
|
2619 | if ("production" !== "development") {
|
2620 | console.error(
|
2621 | 'Attempted to listen to events during the capture phase on a ' +
|
2622 | 'browser that does not support the capture phase. Your application ' +
|
2623 | 'will not receive some events.'
|
2624 | );
|
2625 | }
|
2626 | return {
|
2627 | remove: emptyFunction
|
2628 | };
|
2629 | } else {
|
2630 | target.addEventListener(eventType, callback, true);
|
2631 | return {
|
2632 | remove: function() {
|
2633 | target.removeEventListener(eventType, callback, true);
|
2634 | }
|
2635 | };
|
2636 | }
|
2637 | },
|
2638 |
|
2639 | registerDefault: function() {}
|
2640 | };
|
2641 |
|
2642 | module.exports = EventListener;
|
2643 |
|
2644 | },{"./emptyFunction":107}],18:[function(_dereq_,module,exports){
|
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 |
|
2651 |
|
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 | "use strict";
|
2657 |
|
2658 | var EventPluginRegistry = _dereq_("./EventPluginRegistry");
|
2659 | var EventPluginUtils = _dereq_("./EventPluginUtils");
|
2660 |
|
2661 | var accumulateInto = _dereq_("./accumulateInto");
|
2662 | var forEachAccumulated = _dereq_("./forEachAccumulated");
|
2663 | var invariant = _dereq_("./invariant");
|
2664 |
|
2665 |
|
2666 |
|
2667 |
|
2668 | var listenerBank = {};
|
2669 |
|
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 | var eventQueue = null;
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 | var executeDispatchesAndRelease = function(event) {
|
2683 | if (event) {
|
2684 | var executeDispatch = EventPluginUtils.executeDispatch;
|
2685 |
|
2686 | var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
|
2687 | if (PluginModule && PluginModule.executeDispatch) {
|
2688 | executeDispatch = PluginModule.executeDispatch;
|
2689 | }
|
2690 | EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
|
2691 |
|
2692 | if (!event.isPersistent()) {
|
2693 | event.constructor.release(event);
|
2694 | }
|
2695 | }
|
2696 | };
|
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 |
|
2702 | var InstanceHandle = null;
|
2703 |
|
2704 | function validateInstanceHandle() {
|
2705 | var invalid = !InstanceHandle||
|
2706 | !InstanceHandle.traverseTwoPhase ||
|
2707 | !InstanceHandle.traverseEnterLeave;
|
2708 | if (invalid) {
|
2709 | throw new Error('InstanceHandle not injected before use!');
|
2710 | }
|
2711 | }
|
2712 |
|
2713 |
|
2714 |
|
2715 |
|
2716 |
|
2717 |
|
2718 |
|
2719 |
|
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 |
|
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 | var EventPluginHub = {
|
2736 |
|
2737 | |
2738 |
|
2739 |
|
2740 | injection: {
|
2741 |
|
2742 | |
2743 |
|
2744 |
|
2745 |
|
2746 | injectMount: EventPluginUtils.injection.injectMount,
|
2747 |
|
2748 | |
2749 |
|
2750 |
|
2751 |
|
2752 | injectInstanceHandle: function(InjectedInstanceHandle) {
|
2753 | InstanceHandle = InjectedInstanceHandle;
|
2754 | if ("production" !== "development") {
|
2755 | validateInstanceHandle();
|
2756 | }
|
2757 | },
|
2758 |
|
2759 | getInstanceHandle: function() {
|
2760 | if ("production" !== "development") {
|
2761 | validateInstanceHandle();
|
2762 | }
|
2763 | return InstanceHandle;
|
2764 | },
|
2765 |
|
2766 | |
2767 |
|
2768 |
|
2769 |
|
2770 | injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
|
2771 |
|
2772 | |
2773 |
|
2774 |
|
2775 | injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
|
2776 |
|
2777 | },
|
2778 |
|
2779 | eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
2780 |
|
2781 | registrationNameModules: EventPluginRegistry.registrationNameModules,
|
2782 |
|
2783 | |
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 | putListener: function(id, registrationName, listener) {
|
2791 | ("production" !== "development" ? invariant(
|
2792 | !listener || typeof listener === 'function',
|
2793 | 'Expected %s listener to be a function, instead got type %s',
|
2794 | registrationName, typeof listener
|
2795 | ) : invariant(!listener || typeof listener === 'function'));
|
2796 |
|
2797 | var bankForRegistrationName =
|
2798 | listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
2799 | bankForRegistrationName[id] = listener;
|
2800 | },
|
2801 |
|
2802 | |
2803 |
|
2804 |
|
2805 |
|
2806 |
|
2807 | getListener: function(id, registrationName) {
|
2808 | var bankForRegistrationName = listenerBank[registrationName];
|
2809 | return bankForRegistrationName && bankForRegistrationName[id];
|
2810 | },
|
2811 |
|
2812 | |
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 |
|
2818 | deleteListener: function(id, registrationName) {
|
2819 | var bankForRegistrationName = listenerBank[registrationName];
|
2820 | if (bankForRegistrationName) {
|
2821 | delete bankForRegistrationName[id];
|
2822 | }
|
2823 | },
|
2824 |
|
2825 | |
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 | deleteAllListeners: function(id) {
|
2831 | for (var registrationName in listenerBank) {
|
2832 | delete listenerBank[registrationName][id];
|
2833 | }
|
2834 | },
|
2835 |
|
2836 | |
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 | extractEvents: function(
|
2848 | topLevelType,
|
2849 | topLevelTarget,
|
2850 | topLevelTargetID,
|
2851 | nativeEvent) {
|
2852 | var events;
|
2853 | var plugins = EventPluginRegistry.plugins;
|
2854 | for (var i = 0, l = plugins.length; i < l; i++) {
|
2855 |
|
2856 | var possiblePlugin = plugins[i];
|
2857 | if (possiblePlugin) {
|
2858 | var extractedEvents = possiblePlugin.extractEvents(
|
2859 | topLevelType,
|
2860 | topLevelTarget,
|
2861 | topLevelTargetID,
|
2862 | nativeEvent
|
2863 | );
|
2864 | if (extractedEvents) {
|
2865 | events = accumulateInto(events, extractedEvents);
|
2866 | }
|
2867 | }
|
2868 | }
|
2869 | return events;
|
2870 | },
|
2871 |
|
2872 | |
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 | enqueueEvents: function(events) {
|
2880 | if (events) {
|
2881 | eventQueue = accumulateInto(eventQueue, events);
|
2882 | }
|
2883 | },
|
2884 |
|
2885 | |
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 | processEventQueue: function() {
|
2891 |
|
2892 |
|
2893 | var processingEventQueue = eventQueue;
|
2894 | eventQueue = null;
|
2895 | forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
|
2896 | ("production" !== "development" ? invariant(
|
2897 | !eventQueue,
|
2898 | 'processEventQueue(): Additional events were enqueued while processing ' +
|
2899 | 'an event queue. Support for this has not yet been implemented.'
|
2900 | ) : invariant(!eventQueue));
|
2901 | },
|
2902 |
|
2903 | |
2904 |
|
2905 |
|
2906 | __purge: function() {
|
2907 | listenerBank = {};
|
2908 | },
|
2909 |
|
2910 | __getListenerBank: function() {
|
2911 | return listenerBank;
|
2912 | }
|
2913 |
|
2914 | };
|
2915 |
|
2916 | module.exports = EventPluginHub;
|
2917 |
|
2918 | },{"./EventPluginRegistry":19,"./EventPluginUtils":20,"./accumulateInto":97,"./forEachAccumulated":112,"./invariant":126}],19:[function(_dereq_,module,exports){
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 |
|
2931 | "use strict";
|
2932 |
|
2933 | var invariant = _dereq_("./invariant");
|
2934 |
|
2935 |
|
2936 |
|
2937 |
|
2938 | var EventPluginOrder = null;
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 | var namesToPlugins = {};
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 | function recomputePluginOrdering() {
|
2951 | if (!EventPluginOrder) {
|
2952 |
|
2953 | return;
|
2954 | }
|
2955 | for (var pluginName in namesToPlugins) {
|
2956 | var PluginModule = namesToPlugins[pluginName];
|
2957 | var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
2958 | ("production" !== "development" ? invariant(
|
2959 | pluginIndex > -1,
|
2960 | 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
|
2961 | 'the plugin ordering, `%s`.',
|
2962 | pluginName
|
2963 | ) : invariant(pluginIndex > -1));
|
2964 | if (EventPluginRegistry.plugins[pluginIndex]) {
|
2965 | continue;
|
2966 | }
|
2967 | ("production" !== "development" ? invariant(
|
2968 | PluginModule.extractEvents,
|
2969 | 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
|
2970 | 'method, but `%s` does not.',
|
2971 | pluginName
|
2972 | ) : invariant(PluginModule.extractEvents));
|
2973 | EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
2974 | var publishedEvents = PluginModule.eventTypes;
|
2975 | for (var eventName in publishedEvents) {
|
2976 | ("production" !== "development" ? invariant(
|
2977 | publishEventForPlugin(
|
2978 | publishedEvents[eventName],
|
2979 | PluginModule,
|
2980 | eventName
|
2981 | ),
|
2982 | 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
|
2983 | eventName,
|
2984 | pluginName
|
2985 | ) : invariant(publishEventForPlugin(
|
2986 | publishedEvents[eventName],
|
2987 | PluginModule,
|
2988 | eventName
|
2989 | )));
|
2990 | }
|
2991 | }
|
2992 | }
|
2993 |
|
2994 |
|
2995 |
|
2996 |
|
2997 |
|
2998 |
|
2999 |
|
3000 |
|
3001 |
|
3002 | function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
3003 | ("production" !== "development" ? invariant(
|
3004 | !EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
|
3005 | 'EventPluginHub: More than one plugin attempted to publish the same ' +
|
3006 | 'event name, `%s`.',
|
3007 | eventName
|
3008 | ) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
|
3009 | EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
3010 |
|
3011 | var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
3012 | if (phasedRegistrationNames) {
|
3013 | for (var phaseName in phasedRegistrationNames) {
|
3014 | if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
|
3015 | var phasedRegistrationName = phasedRegistrationNames[phaseName];
|
3016 | publishRegistrationName(
|
3017 | phasedRegistrationName,
|
3018 | PluginModule,
|
3019 | eventName
|
3020 | );
|
3021 | }
|
3022 | }
|
3023 | return true;
|
3024 | } else if (dispatchConfig.registrationName) {
|
3025 | publishRegistrationName(
|
3026 | dispatchConfig.registrationName,
|
3027 | PluginModule,
|
3028 | eventName
|
3029 | );
|
3030 | return true;
|
3031 | }
|
3032 | return false;
|
3033 | }
|
3034 |
|
3035 |
|
3036 |
|
3037 |
|
3038 |
|
3039 |
|
3040 |
|
3041 |
|
3042 |
|
3043 | function publishRegistrationName(registrationName, PluginModule, eventName) {
|
3044 | ("production" !== "development" ? invariant(
|
3045 | !EventPluginRegistry.registrationNameModules[registrationName],
|
3046 | 'EventPluginHub: More than one plugin attempted to publish the same ' +
|
3047 | 'registration name, `%s`.',
|
3048 | registrationName
|
3049 | ) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
|
3050 | EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
3051 | EventPluginRegistry.registrationNameDependencies[registrationName] =
|
3052 | PluginModule.eventTypes[eventName].dependencies;
|
3053 | }
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 | var EventPluginRegistry = {
|
3061 |
|
3062 | |
3063 |
|
3064 |
|
3065 | plugins: [],
|
3066 |
|
3067 | |
3068 |
|
3069 |
|
3070 | eventNameDispatchConfigs: {},
|
3071 |
|
3072 | |
3073 |
|
3074 |
|
3075 | registrationNameModules: {},
|
3076 |
|
3077 | |
3078 |
|
3079 |
|
3080 | registrationNameDependencies: {},
|
3081 |
|
3082 | |
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 | injectEventPluginOrder: function(InjectedEventPluginOrder) {
|
3092 | ("production" !== "development" ? invariant(
|
3093 | !EventPluginOrder,
|
3094 | 'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
|
3095 | 'once. You are likely trying to load more than one copy of React.'
|
3096 | ) : invariant(!EventPluginOrder));
|
3097 |
|
3098 | EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
3099 | recomputePluginOrdering();
|
3100 | },
|
3101 |
|
3102 | |
3103 |
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 | injectEventPluginsByName: function(injectedNamesToPlugins) {
|
3113 | var isOrderingDirty = false;
|
3114 | for (var pluginName in injectedNamesToPlugins) {
|
3115 | if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
|
3116 | continue;
|
3117 | }
|
3118 | var PluginModule = injectedNamesToPlugins[pluginName];
|
3119 | if (!namesToPlugins.hasOwnProperty(pluginName) ||
|
3120 | namesToPlugins[pluginName] !== PluginModule) {
|
3121 | ("production" !== "development" ? invariant(
|
3122 | !namesToPlugins[pluginName],
|
3123 | 'EventPluginRegistry: Cannot inject two different event plugins ' +
|
3124 | 'using the same name, `%s`.',
|
3125 | pluginName
|
3126 | ) : invariant(!namesToPlugins[pluginName]));
|
3127 | namesToPlugins[pluginName] = PluginModule;
|
3128 | isOrderingDirty = true;
|
3129 | }
|
3130 | }
|
3131 | if (isOrderingDirty) {
|
3132 | recomputePluginOrdering();
|
3133 | }
|
3134 | },
|
3135 |
|
3136 | |
3137 |
|
3138 |
|
3139 |
|
3140 |
|
3141 |
|
3142 |
|
3143 | getPluginModuleForEvent: function(event) {
|
3144 | var dispatchConfig = event.dispatchConfig;
|
3145 | if (dispatchConfig.registrationName) {
|
3146 | return EventPluginRegistry.registrationNameModules[
|
3147 | dispatchConfig.registrationName
|
3148 | ] || null;
|
3149 | }
|
3150 | for (var phase in dispatchConfig.phasedRegistrationNames) {
|
3151 | if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
|
3152 | continue;
|
3153 | }
|
3154 | var PluginModule = EventPluginRegistry.registrationNameModules[
|
3155 | dispatchConfig.phasedRegistrationNames[phase]
|
3156 | ];
|
3157 | if (PluginModule) {
|
3158 | return PluginModule;
|
3159 | }
|
3160 | }
|
3161 | return null;
|
3162 | },
|
3163 |
|
3164 | |
3165 |
|
3166 |
|
3167 |
|
3168 | _resetEventPlugins: function() {
|
3169 | EventPluginOrder = null;
|
3170 | for (var pluginName in namesToPlugins) {
|
3171 | if (namesToPlugins.hasOwnProperty(pluginName)) {
|
3172 | delete namesToPlugins[pluginName];
|
3173 | }
|
3174 | }
|
3175 | EventPluginRegistry.plugins.length = 0;
|
3176 |
|
3177 | var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
|
3178 | for (var eventName in eventNameDispatchConfigs) {
|
3179 | if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
|
3180 | delete eventNameDispatchConfigs[eventName];
|
3181 | }
|
3182 | }
|
3183 |
|
3184 | var registrationNameModules = EventPluginRegistry.registrationNameModules;
|
3185 | for (var registrationName in registrationNameModules) {
|
3186 | if (registrationNameModules.hasOwnProperty(registrationName)) {
|
3187 | delete registrationNameModules[registrationName];
|
3188 | }
|
3189 | }
|
3190 | }
|
3191 |
|
3192 | };
|
3193 |
|
3194 | module.exports = EventPluginRegistry;
|
3195 |
|
3196 | },{"./invariant":126}],20:[function(_dereq_,module,exports){
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 |
|
3202 |
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 | "use strict";
|
3209 |
|
3210 | var EventConstants = _dereq_("./EventConstants");
|
3211 |
|
3212 | var invariant = _dereq_("./invariant");
|
3213 |
|
3214 |
|
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 | var injection = {
|
3223 | Mount: null,
|
3224 | injectMount: function(InjectedMount) {
|
3225 | injection.Mount = InjectedMount;
|
3226 | if ("production" !== "development") {
|
3227 | ("production" !== "development" ? invariant(
|
3228 | InjectedMount && InjectedMount.getNode,
|
3229 | 'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
|
3230 | 'is missing getNode.'
|
3231 | ) : invariant(InjectedMount && InjectedMount.getNode));
|
3232 | }
|
3233 | }
|
3234 | };
|
3235 |
|
3236 | var topLevelTypes = EventConstants.topLevelTypes;
|
3237 |
|
3238 | function isEndish(topLevelType) {
|
3239 | return topLevelType === topLevelTypes.topMouseUp ||
|
3240 | topLevelType === topLevelTypes.topTouchEnd ||
|
3241 | topLevelType === topLevelTypes.topTouchCancel;
|
3242 | }
|
3243 |
|
3244 | function isMoveish(topLevelType) {
|
3245 | return topLevelType === topLevelTypes.topMouseMove ||
|
3246 | topLevelType === topLevelTypes.topTouchMove;
|
3247 | }
|
3248 | function isStartish(topLevelType) {
|
3249 | return topLevelType === topLevelTypes.topMouseDown ||
|
3250 | topLevelType === topLevelTypes.topTouchStart;
|
3251 | }
|
3252 |
|
3253 |
|
3254 | var validateEventDispatches;
|
3255 | if ("production" !== "development") {
|
3256 | validateEventDispatches = function(event) {
|
3257 | var dispatchListeners = event._dispatchListeners;
|
3258 | var dispatchIDs = event._dispatchIDs;
|
3259 |
|
3260 | var listenersIsArr = Array.isArray(dispatchListeners);
|
3261 | var idsIsArr = Array.isArray(dispatchIDs);
|
3262 | var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
|
3263 | var listenersLen = listenersIsArr ?
|
3264 | dispatchListeners.length :
|
3265 | dispatchListeners ? 1 : 0;
|
3266 |
|
3267 | ("production" !== "development" ? invariant(
|
3268 | idsIsArr === listenersIsArr && IDsLen === listenersLen,
|
3269 | 'EventPluginUtils: Invalid `event`.'
|
3270 | ) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
|
3271 | };
|
3272 | }
|
3273 |
|
3274 |
|
3275 |
|
3276 |
|
3277 |
|
3278 |
|
3279 | function forEachEventDispatch(event, cb) {
|
3280 | var dispatchListeners = event._dispatchListeners;
|
3281 | var dispatchIDs = event._dispatchIDs;
|
3282 | if ("production" !== "development") {
|
3283 | validateEventDispatches(event);
|
3284 | }
|
3285 | if (Array.isArray(dispatchListeners)) {
|
3286 | for (var i = 0; i < dispatchListeners.length; i++) {
|
3287 | if (event.isPropagationStopped()) {
|
3288 | break;
|
3289 | }
|
3290 |
|
3291 | cb(event, dispatchListeners[i], dispatchIDs[i]);
|
3292 | }
|
3293 | } else if (dispatchListeners) {
|
3294 | cb(event, dispatchListeners, dispatchIDs);
|
3295 | }
|
3296 | }
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 |
|
3304 | function executeDispatch(event, listener, domID) {
|
3305 | event.currentTarget = injection.Mount.getNode(domID);
|
3306 | var returnValue = listener(event, domID);
|
3307 | event.currentTarget = null;
|
3308 | return returnValue;
|
3309 | }
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 | function executeDispatchesInOrder(event, executeDispatch) {
|
3315 | forEachEventDispatch(event, executeDispatch);
|
3316 | event._dispatchListeners = null;
|
3317 | event._dispatchIDs = null;
|
3318 | }
|
3319 |
|
3320 |
|
3321 |
|
3322 |
|
3323 |
|
3324 |
|
3325 |
|
3326 |
|
3327 | function executeDispatchesInOrderStopAtTrueImpl(event) {
|
3328 | var dispatchListeners = event._dispatchListeners;
|
3329 | var dispatchIDs = event._dispatchIDs;
|
3330 | if ("production" !== "development") {
|
3331 | validateEventDispatches(event);
|
3332 | }
|
3333 | if (Array.isArray(dispatchListeners)) {
|
3334 | for (var i = 0; i < dispatchListeners.length; i++) {
|
3335 | if (event.isPropagationStopped()) {
|
3336 | break;
|
3337 | }
|
3338 |
|
3339 | if (dispatchListeners[i](event, dispatchIDs[i])) {
|
3340 | return dispatchIDs[i];
|
3341 | }
|
3342 | }
|
3343 | } else if (dispatchListeners) {
|
3344 | if (dispatchListeners(event, dispatchIDs)) {
|
3345 | return dispatchIDs;
|
3346 | }
|
3347 | }
|
3348 | return null;
|
3349 | }
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 | function executeDispatchesInOrderStopAtTrue(event) {
|
3355 | var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
3356 | event._dispatchIDs = null;
|
3357 | event._dispatchListeners = null;
|
3358 | return ret;
|
3359 | }
|
3360 |
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 |
|
3367 |
|
3368 |
|
3369 |
|
3370 | function executeDirectDispatch(event) {
|
3371 | if ("production" !== "development") {
|
3372 | validateEventDispatches(event);
|
3373 | }
|
3374 | var dispatchListener = event._dispatchListeners;
|
3375 | var dispatchID = event._dispatchIDs;
|
3376 | ("production" !== "development" ? invariant(
|
3377 | !Array.isArray(dispatchListener),
|
3378 | 'executeDirectDispatch(...): Invalid `event`.'
|
3379 | ) : invariant(!Array.isArray(dispatchListener)));
|
3380 | var res = dispatchListener ?
|
3381 | dispatchListener(event, dispatchID) :
|
3382 | null;
|
3383 | event._dispatchListeners = null;
|
3384 | event._dispatchIDs = null;
|
3385 | return res;
|
3386 | }
|
3387 |
|
3388 |
|
3389 |
|
3390 |
|
3391 |
|
3392 | function hasDispatches(event) {
|
3393 | return !!event._dispatchListeners;
|
3394 | }
|
3395 |
|
3396 |
|
3397 |
|
3398 |
|
3399 | var EventPluginUtils = {
|
3400 | isEndish: isEndish,
|
3401 | isMoveish: isMoveish,
|
3402 | isStartish: isStartish,
|
3403 |
|
3404 | executeDirectDispatch: executeDirectDispatch,
|
3405 | executeDispatch: executeDispatch,
|
3406 | executeDispatchesInOrder: executeDispatchesInOrder,
|
3407 | executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
|
3408 | hasDispatches: hasDispatches,
|
3409 | injection: injection,
|
3410 | useTouchEvents: false
|
3411 | };
|
3412 |
|
3413 | module.exports = EventPluginUtils;
|
3414 |
|
3415 | },{"./EventConstants":16,"./invariant":126}],21:[function(_dereq_,module,exports){
|
3416 |
|
3417 |
|
3418 |
|
3419 |
|
3420 |
|
3421 |
|
3422 |
|
3423 |
|
3424 |
|
3425 |
|
3426 |
|
3427 | "use strict";
|
3428 |
|
3429 | var EventConstants = _dereq_("./EventConstants");
|
3430 | var EventPluginHub = _dereq_("./EventPluginHub");
|
3431 |
|
3432 | var accumulateInto = _dereq_("./accumulateInto");
|
3433 | var forEachAccumulated = _dereq_("./forEachAccumulated");
|
3434 |
|
3435 | var PropagationPhases = EventConstants.PropagationPhases;
|
3436 | var getListener = EventPluginHub.getListener;
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 | function listenerAtPhase(id, event, propagationPhase) {
|
3443 | var registrationName =
|
3444 | event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
3445 | return getListener(id, registrationName);
|
3446 | }
|
3447 |
|
3448 |
|
3449 |
|
3450 |
|
3451 |
|
3452 |
|
3453 |
|
3454 | function accumulateDirectionalDispatches(domID, upwards, event) {
|
3455 | if ("production" !== "development") {
|
3456 | if (!domID) {
|
3457 | throw new Error('Dispatching id must not be null');
|
3458 | }
|
3459 | }
|
3460 | var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
|
3461 | var listener = listenerAtPhase(domID, event, phase);
|
3462 | if (listener) {
|
3463 | event._dispatchListeners =
|
3464 | accumulateInto(event._dispatchListeners, listener);
|
3465 | event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
|
3466 | }
|
3467 | }
|
3468 |
|
3469 |
|
3470 |
|
3471 |
|
3472 |
|
3473 |
|
3474 |
|
3475 |
|
3476 | function accumulateTwoPhaseDispatchesSingle(event) {
|
3477 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
3478 | EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
|
3479 | event.dispatchMarker,
|
3480 | accumulateDirectionalDispatches,
|
3481 | event
|
3482 | );
|
3483 | }
|
3484 | }
|
3485 |
|
3486 |
|
3487 |
|
3488 |
|
3489 |
|
3490 |
|
3491 |
|
3492 | function accumulateDispatches(id, ignoredDirection, event) {
|
3493 | if (event && event.dispatchConfig.registrationName) {
|
3494 | var registrationName = event.dispatchConfig.registrationName;
|
3495 | var listener = getListener(id, registrationName);
|
3496 | if (listener) {
|
3497 | event._dispatchListeners =
|
3498 | accumulateInto(event._dispatchListeners, listener);
|
3499 | event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
|
3500 | }
|
3501 | }
|
3502 | }
|
3503 |
|
3504 |
|
3505 |
|
3506 |
|
3507 |
|
3508 |
|
3509 | function accumulateDirectDispatchesSingle(event) {
|
3510 | if (event && event.dispatchConfig.registrationName) {
|
3511 | accumulateDispatches(event.dispatchMarker, null, event);
|
3512 | }
|
3513 | }
|
3514 |
|
3515 | function accumulateTwoPhaseDispatches(events) {
|
3516 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
3517 | }
|
3518 |
|
3519 | function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
|
3520 | EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
|
3521 | fromID,
|
3522 | toID,
|
3523 | accumulateDispatches,
|
3524 | leave,
|
3525 | enter
|
3526 | );
|
3527 | }
|
3528 |
|
3529 |
|
3530 | function accumulateDirectDispatches(events) {
|
3531 | forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
3532 | }
|
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 |
|
3540 |
|
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 |
|
3546 |
|
3547 | var EventPropagators = {
|
3548 | accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
|
3549 | accumulateDirectDispatches: accumulateDirectDispatches,
|
3550 | accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
|
3551 | };
|
3552 |
|
3553 | module.exports = EventPropagators;
|
3554 |
|
3555 | },{"./EventConstants":16,"./EventPluginHub":18,"./accumulateInto":97,"./forEachAccumulated":112}],22:[function(_dereq_,module,exports){
|
3556 |
|
3557 |
|
3558 |
|
3559 |
|
3560 |
|
3561 |
|
3562 |
|
3563 |
|
3564 |
|
3565 |
|
3566 |
|
3567 |
|
3568 |
|
3569 | "use strict";
|
3570 |
|
3571 | var canUseDOM = !!(
|
3572 | typeof window !== 'undefined' &&
|
3573 | window.document &&
|
3574 | window.document.createElement
|
3575 | );
|
3576 |
|
3577 |
|
3578 |
|
3579 |
|
3580 |
|
3581 |
|
3582 |
|
3583 | var ExecutionEnvironment = {
|
3584 |
|
3585 | canUseDOM: canUseDOM,
|
3586 |
|
3587 | canUseWorkers: typeof Worker !== 'undefined',
|
3588 |
|
3589 | canUseEventListeners:
|
3590 | canUseDOM && !!(window.addEventListener || window.attachEvent),
|
3591 |
|
3592 | canUseViewport: canUseDOM && !!window.screen,
|
3593 |
|
3594 | isInWorker: !canUseDOM
|
3595 |
|
3596 | };
|
3597 |
|
3598 | module.exports = ExecutionEnvironment;
|
3599 |
|
3600 | },{}],23:[function(_dereq_,module,exports){
|
3601 |
|
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 |
|
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 |
|
3614 | "use strict";
|
3615 |
|
3616 | var DOMProperty = _dereq_("./DOMProperty");
|
3617 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
3618 |
|
3619 | var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
3620 | var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
|
3621 | var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
|
3622 | var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
|
3623 | var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
|
3624 | var HAS_POSITIVE_NUMERIC_VALUE =
|
3625 | DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
|
3626 | var HAS_OVERLOADED_BOOLEAN_VALUE =
|
3627 | DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
|
3628 |
|
3629 | var hasSVG;
|
3630 | if (ExecutionEnvironment.canUseDOM) {
|
3631 | var implementation = document.implementation;
|
3632 | hasSVG = (
|
3633 | implementation &&
|
3634 | implementation.hasFeature &&
|
3635 | implementation.hasFeature(
|
3636 | 'http://www.w3.org/TR/SVG11/feature#BasicStructure',
|
3637 | '1.1'
|
3638 | )
|
3639 | );
|
3640 | }
|
3641 |
|
3642 |
|
3643 | var HTMLDOMPropertyConfig = {
|
3644 | isCustomAttribute: RegExp.prototype.test.bind(
|
3645 | /^(data|aria)-[a-z_][a-z\d_.\-]*$/
|
3646 | ),
|
3647 | Properties: {
|
3648 | |
3649 |
|
3650 |
|
3651 | accept: null,
|
3652 | acceptCharset: null,
|
3653 | accessKey: null,
|
3654 | action: null,
|
3655 | allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
3656 | allowTransparency: MUST_USE_ATTRIBUTE,
|
3657 | alt: null,
|
3658 | async: HAS_BOOLEAN_VALUE,
|
3659 | autoComplete: null,
|
3660 |
|
3661 |
|
3662 | autoPlay: HAS_BOOLEAN_VALUE,
|
3663 | cellPadding: null,
|
3664 | cellSpacing: null,
|
3665 | charSet: MUST_USE_ATTRIBUTE,
|
3666 | checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3667 | classID: MUST_USE_ATTRIBUTE,
|
3668 |
|
3669 |
|
3670 |
|
3671 |
|
3672 |
|
3673 | className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
|
3674 | cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
3675 | colSpan: null,
|
3676 | content: null,
|
3677 | contentEditable: null,
|
3678 | contextMenu: MUST_USE_ATTRIBUTE,
|
3679 | controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3680 | coords: null,
|
3681 | crossOrigin: null,
|
3682 | data: null,
|
3683 | dateTime: MUST_USE_ATTRIBUTE,
|
3684 | defer: HAS_BOOLEAN_VALUE,
|
3685 | dir: null,
|
3686 | disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
3687 | download: HAS_OVERLOADED_BOOLEAN_VALUE,
|
3688 | draggable: null,
|
3689 | encType: null,
|
3690 | form: MUST_USE_ATTRIBUTE,
|
3691 | formAction: MUST_USE_ATTRIBUTE,
|
3692 | formEncType: MUST_USE_ATTRIBUTE,
|
3693 | formMethod: MUST_USE_ATTRIBUTE,
|
3694 | formNoValidate: HAS_BOOLEAN_VALUE,
|
3695 | formTarget: MUST_USE_ATTRIBUTE,
|
3696 | frameBorder: MUST_USE_ATTRIBUTE,
|
3697 | height: MUST_USE_ATTRIBUTE,
|
3698 | hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
3699 | href: null,
|
3700 | hrefLang: null,
|
3701 | htmlFor: null,
|
3702 | httpEquiv: null,
|
3703 | icon: null,
|
3704 | id: MUST_USE_PROPERTY,
|
3705 | label: null,
|
3706 | lang: null,
|
3707 | list: MUST_USE_ATTRIBUTE,
|
3708 | loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3709 | manifest: MUST_USE_ATTRIBUTE,
|
3710 | marginHeight: null,
|
3711 | marginWidth: null,
|
3712 | max: null,
|
3713 | maxLength: MUST_USE_ATTRIBUTE,
|
3714 | media: MUST_USE_ATTRIBUTE,
|
3715 | mediaGroup: null,
|
3716 | method: null,
|
3717 | min: null,
|
3718 | multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3719 | muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3720 | name: null,
|
3721 | noValidate: HAS_BOOLEAN_VALUE,
|
3722 | open: null,
|
3723 | pattern: null,
|
3724 | placeholder: null,
|
3725 | poster: null,
|
3726 | preload: null,
|
3727 | radioGroup: null,
|
3728 | readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3729 | rel: null,
|
3730 | required: HAS_BOOLEAN_VALUE,
|
3731 | role: MUST_USE_ATTRIBUTE,
|
3732 | rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
3733 | rowSpan: null,
|
3734 | sandbox: null,
|
3735 | scope: null,
|
3736 | scrolling: null,
|
3737 | seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
3738 | selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
3739 | shape: null,
|
3740 | size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
|
3741 | sizes: MUST_USE_ATTRIBUTE,
|
3742 | span: HAS_POSITIVE_NUMERIC_VALUE,
|
3743 | spellCheck: null,
|
3744 | src: null,
|
3745 | srcDoc: MUST_USE_PROPERTY,
|
3746 | srcSet: MUST_USE_ATTRIBUTE,
|
3747 | start: HAS_NUMERIC_VALUE,
|
3748 | step: null,
|
3749 | style: null,
|
3750 | tabIndex: null,
|
3751 | target: null,
|
3752 | title: null,
|
3753 | type: null,
|
3754 | useMap: null,
|
3755 | value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
|
3756 | width: MUST_USE_ATTRIBUTE,
|
3757 | wmode: MUST_USE_ATTRIBUTE,
|
3758 |
|
3759 | |
3760 |
|
3761 |
|
3762 | autoCapitalize: null,
|
3763 | autoCorrect: null,
|
3764 | itemProp: MUST_USE_ATTRIBUTE,
|
3765 | itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
|
3766 | itemType: MUST_USE_ATTRIBUTE,
|
3767 | property: null
|
3768 | },
|
3769 | DOMAttributeNames: {
|
3770 | acceptCharset: 'accept-charset',
|
3771 | className: 'class',
|
3772 | htmlFor: 'for',
|
3773 | httpEquiv: 'http-equiv'
|
3774 | },
|
3775 | DOMPropertyNames: {
|
3776 | autoCapitalize: 'autocapitalize',
|
3777 | autoComplete: 'autocomplete',
|
3778 | autoCorrect: 'autocorrect',
|
3779 | autoFocus: 'autofocus',
|
3780 | autoPlay: 'autoplay',
|
3781 | encType: 'enctype',
|
3782 | hrefLang: 'hreflang',
|
3783 | radioGroup: 'radiogroup',
|
3784 | spellCheck: 'spellcheck',
|
3785 | srcDoc: 'srcdoc',
|
3786 | srcSet: 'srcset'
|
3787 | }
|
3788 | };
|
3789 |
|
3790 | module.exports = HTMLDOMPropertyConfig;
|
3791 |
|
3792 | },{"./DOMProperty":11,"./ExecutionEnvironment":22}],24:[function(_dereq_,module,exports){
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 |
|
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 |
|
3804 |
|
3805 | "use strict";
|
3806 |
|
3807 | var ReactPropTypes = _dereq_("./ReactPropTypes");
|
3808 |
|
3809 | var invariant = _dereq_("./invariant");
|
3810 |
|
3811 | var hasReadOnlyValue = {
|
3812 | 'button': true,
|
3813 | 'checkbox': true,
|
3814 | 'image': true,
|
3815 | 'hidden': true,
|
3816 | 'radio': true,
|
3817 | 'reset': true,
|
3818 | 'submit': true
|
3819 | };
|
3820 |
|
3821 | function _assertSingleLink(input) {
|
3822 | ("production" !== "development" ? invariant(
|
3823 | input.props.checkedLink == null || input.props.valueLink == null,
|
3824 | 'Cannot provide a checkedLink and a valueLink. If you want to use ' +
|
3825 | 'checkedLink, you probably don\'t want to use valueLink and vice versa.'
|
3826 | ) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
|
3827 | }
|
3828 | function _assertValueLink(input) {
|
3829 | _assertSingleLink(input);
|
3830 | ("production" !== "development" ? invariant(
|
3831 | input.props.value == null && input.props.onChange == null,
|
3832 | 'Cannot provide a valueLink and a value or onChange event. If you want ' +
|
3833 | 'to use value or onChange, you probably don\'t want to use valueLink.'
|
3834 | ) : invariant(input.props.value == null && input.props.onChange == null));
|
3835 | }
|
3836 |
|
3837 | function _assertCheckedLink(input) {
|
3838 | _assertSingleLink(input);
|
3839 | ("production" !== "development" ? invariant(
|
3840 | input.props.checked == null && input.props.onChange == null,
|
3841 | 'Cannot provide a checkedLink and a checked property or onChange event. ' +
|
3842 | 'If you want to use checked or onChange, you probably don\'t want to ' +
|
3843 | 'use checkedLink'
|
3844 | ) : invariant(input.props.checked == null && input.props.onChange == null));
|
3845 | }
|
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 | function _handleLinkedValueChange(e) {
|
3851 |
|
3852 | this.props.valueLink.requestChange(e.target.value);
|
3853 | }
|
3854 |
|
3855 |
|
3856 |
|
3857 |
|
3858 | function _handleLinkedCheckChange(e) {
|
3859 |
|
3860 | this.props.checkedLink.requestChange(e.target.checked);
|
3861 | }
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 | var LinkedValueUtils = {
|
3868 | Mixin: {
|
3869 | propTypes: {
|
3870 | value: function(props, propName, componentName) {
|
3871 | if (!props[propName] ||
|
3872 | hasReadOnlyValue[props.type] ||
|
3873 | props.onChange ||
|
3874 | props.readOnly ||
|
3875 | props.disabled) {
|
3876 | return;
|
3877 | }
|
3878 | return new Error(
|
3879 | 'You provided a `value` prop to a form field without an ' +
|
3880 | '`onChange` handler. This will render a read-only field. If ' +
|
3881 | 'the field should be mutable use `defaultValue`. Otherwise, ' +
|
3882 | 'set either `onChange` or `readOnly`.'
|
3883 | );
|
3884 | },
|
3885 | checked: function(props, propName, componentName) {
|
3886 | if (!props[propName] ||
|
3887 | props.onChange ||
|
3888 | props.readOnly ||
|
3889 | props.disabled) {
|
3890 | return;
|
3891 | }
|
3892 | return new Error(
|
3893 | 'You provided a `checked` prop to a form field without an ' +
|
3894 | '`onChange` handler. This will render a read-only field. If ' +
|
3895 | 'the field should be mutable use `defaultChecked`. Otherwise, ' +
|
3896 | 'set either `onChange` or `readOnly`.'
|
3897 | );
|
3898 | },
|
3899 | onChange: ReactPropTypes.func
|
3900 | }
|
3901 | },
|
3902 |
|
3903 | |
3904 |
|
3905 |
|
3906 |
|
3907 | getValue: function(input) {
|
3908 | if (input.props.valueLink) {
|
3909 | _assertValueLink(input);
|
3910 | return input.props.valueLink.value;
|
3911 | }
|
3912 | return input.props.value;
|
3913 | },
|
3914 |
|
3915 | |
3916 |
|
3917 |
|
3918 |
|
3919 |
|
3920 | getChecked: function(input) {
|
3921 | if (input.props.checkedLink) {
|
3922 | _assertCheckedLink(input);
|
3923 | return input.props.checkedLink.value;
|
3924 | }
|
3925 | return input.props.checked;
|
3926 | },
|
3927 |
|
3928 | |
3929 |
|
3930 |
|
3931 |
|
3932 | getOnChange: function(input) {
|
3933 | if (input.props.valueLink) {
|
3934 | _assertValueLink(input);
|
3935 | return _handleLinkedValueChange;
|
3936 | } else if (input.props.checkedLink) {
|
3937 | _assertCheckedLink(input);
|
3938 | return _handleLinkedCheckChange;
|
3939 | }
|
3940 | return input.props.onChange;
|
3941 | }
|
3942 | };
|
3943 |
|
3944 | module.exports = LinkedValueUtils;
|
3945 |
|
3946 | },{"./ReactPropTypes":72,"./invariant":126}],25:[function(_dereq_,module,exports){
|
3947 |
|
3948 |
|
3949 |
|
3950 |
|
3951 |
|
3952 |
|
3953 |
|
3954 |
|
3955 |
|
3956 |
|
3957 |
|
3958 | "use strict";
|
3959 |
|
3960 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
3961 |
|
3962 | var accumulateInto = _dereq_("./accumulateInto");
|
3963 | var forEachAccumulated = _dereq_("./forEachAccumulated");
|
3964 | var invariant = _dereq_("./invariant");
|
3965 |
|
3966 | function remove(event) {
|
3967 | event.remove();
|
3968 | }
|
3969 |
|
3970 | var LocalEventTrapMixin = {
|
3971 | trapBubbledEvent:function(topLevelType, handlerBaseName) {
|
3972 | ("production" !== "development" ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
|
3973 | var listener = ReactBrowserEventEmitter.trapBubbledEvent(
|
3974 | topLevelType,
|
3975 | handlerBaseName,
|
3976 | this.getDOMNode()
|
3977 | );
|
3978 | this._localEventListeners =
|
3979 | accumulateInto(this._localEventListeners, listener);
|
3980 | },
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 | componentWillUnmount:function() {
|
3986 | if (this._localEventListeners) {
|
3987 | forEachAccumulated(this._localEventListeners, remove);
|
3988 | }
|
3989 | }
|
3990 | };
|
3991 |
|
3992 | module.exports = LocalEventTrapMixin;
|
3993 |
|
3994 | },{"./ReactBrowserEventEmitter":30,"./accumulateInto":97,"./forEachAccumulated":112,"./invariant":126}],26:[function(_dereq_,module,exports){
|
3995 |
|
3996 |
|
3997 |
|
3998 |
|
3999 |
|
4000 |
|
4001 |
|
4002 |
|
4003 |
|
4004 |
|
4005 |
|
4006 |
|
4007 | "use strict";
|
4008 |
|
4009 | var EventConstants = _dereq_("./EventConstants");
|
4010 |
|
4011 | var emptyFunction = _dereq_("./emptyFunction");
|
4012 |
|
4013 | var topLevelTypes = EventConstants.topLevelTypes;
|
4014 |
|
4015 |
|
4016 |
|
4017 |
|
4018 |
|
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 | var MobileSafariClickEventPlugin = {
|
4024 |
|
4025 | eventTypes: null,
|
4026 |
|
4027 | |
4028 |
|
4029 |
|
4030 |
|
4031 |
|
4032 |
|
4033 |
|
4034 |
|
4035 | extractEvents: function(
|
4036 | topLevelType,
|
4037 | topLevelTarget,
|
4038 | topLevelTargetID,
|
4039 | nativeEvent) {
|
4040 | if (topLevelType === topLevelTypes.topTouchStart) {
|
4041 | var target = nativeEvent.target;
|
4042 | if (target && !target.onclick) {
|
4043 | target.onclick = emptyFunction;
|
4044 | }
|
4045 | }
|
4046 | }
|
4047 |
|
4048 | };
|
4049 |
|
4050 | module.exports = MobileSafariClickEventPlugin;
|
4051 |
|
4052 | },{"./EventConstants":16,"./emptyFunction":107}],27:[function(_dereq_,module,exports){
|
4053 |
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 |
|
4061 |
|
4062 |
|
4063 |
|
4064 |
|
4065 |
|
4066 | function assign(target, sources) {
|
4067 | if (target == null) {
|
4068 | throw new TypeError('Object.assign target cannot be null or undefined');
|
4069 | }
|
4070 |
|
4071 | var to = Object(target);
|
4072 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
4073 |
|
4074 | for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
|
4075 | var nextSource = arguments[nextIndex];
|
4076 | if (nextSource == null) {
|
4077 | continue;
|
4078 | }
|
4079 |
|
4080 | var from = Object(nextSource);
|
4081 |
|
4082 |
|
4083 |
|
4084 |
|
4085 |
|
4086 |
|
4087 | for (var key in from) {
|
4088 | if (hasOwnProperty.call(from, key)) {
|
4089 | to[key] = from[key];
|
4090 | }
|
4091 | }
|
4092 | }
|
4093 |
|
4094 | return to;
|
4095 | };
|
4096 |
|
4097 | module.exports = assign;
|
4098 |
|
4099 | },{}],28:[function(_dereq_,module,exports){
|
4100 |
|
4101 |
|
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 |
|
4109 |
|
4110 |
|
4111 | "use strict";
|
4112 |
|
4113 | var invariant = _dereq_("./invariant");
|
4114 |
|
4115 |
|
4116 |
|
4117 |
|
4118 |
|
4119 |
|
4120 |
|
4121 |
|
4122 | var oneArgumentPooler = function(copyFieldsFrom) {
|
4123 | var Klass = this;
|
4124 | if (Klass.instancePool.length) {
|
4125 | var instance = Klass.instancePool.pop();
|
4126 | Klass.call(instance, copyFieldsFrom);
|
4127 | return instance;
|
4128 | } else {
|
4129 | return new Klass(copyFieldsFrom);
|
4130 | }
|
4131 | };
|
4132 |
|
4133 | var twoArgumentPooler = function(a1, a2) {
|
4134 | var Klass = this;
|
4135 | if (Klass.instancePool.length) {
|
4136 | var instance = Klass.instancePool.pop();
|
4137 | Klass.call(instance, a1, a2);
|
4138 | return instance;
|
4139 | } else {
|
4140 | return new Klass(a1, a2);
|
4141 | }
|
4142 | };
|
4143 |
|
4144 | var threeArgumentPooler = function(a1, a2, a3) {
|
4145 | var Klass = this;
|
4146 | if (Klass.instancePool.length) {
|
4147 | var instance = Klass.instancePool.pop();
|
4148 | Klass.call(instance, a1, a2, a3);
|
4149 | return instance;
|
4150 | } else {
|
4151 | return new Klass(a1, a2, a3);
|
4152 | }
|
4153 | };
|
4154 |
|
4155 | var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
|
4156 | var Klass = this;
|
4157 | if (Klass.instancePool.length) {
|
4158 | var instance = Klass.instancePool.pop();
|
4159 | Klass.call(instance, a1, a2, a3, a4, a5);
|
4160 | return instance;
|
4161 | } else {
|
4162 | return new Klass(a1, a2, a3, a4, a5);
|
4163 | }
|
4164 | };
|
4165 |
|
4166 | var standardReleaser = function(instance) {
|
4167 | var Klass = this;
|
4168 | ("production" !== "development" ? invariant(
|
4169 | instance instanceof Klass,
|
4170 | 'Trying to release an instance into a pool of a different type.'
|
4171 | ) : invariant(instance instanceof Klass));
|
4172 | if (instance.destructor) {
|
4173 | instance.destructor();
|
4174 | }
|
4175 | if (Klass.instancePool.length < Klass.poolSize) {
|
4176 | Klass.instancePool.push(instance);
|
4177 | }
|
4178 | };
|
4179 |
|
4180 | var DEFAULT_POOL_SIZE = 10;
|
4181 | var DEFAULT_POOLER = oneArgumentPooler;
|
4182 |
|
4183 |
|
4184 |
|
4185 |
|
4186 |
|
4187 |
|
4188 |
|
4189 |
|
4190 |
|
4191 |
|
4192 | var addPoolingTo = function(CopyConstructor, pooler) {
|
4193 | var NewKlass = CopyConstructor;
|
4194 | NewKlass.instancePool = [];
|
4195 | NewKlass.getPooled = pooler || DEFAULT_POOLER;
|
4196 | if (!NewKlass.poolSize) {
|
4197 | NewKlass.poolSize = DEFAULT_POOL_SIZE;
|
4198 | }
|
4199 | NewKlass.release = standardReleaser;
|
4200 | return NewKlass;
|
4201 | };
|
4202 |
|
4203 | var PooledClass = {
|
4204 | addPoolingTo: addPoolingTo,
|
4205 | oneArgumentPooler: oneArgumentPooler,
|
4206 | twoArgumentPooler: twoArgumentPooler,
|
4207 | threeArgumentPooler: threeArgumentPooler,
|
4208 | fiveArgumentPooler: fiveArgumentPooler
|
4209 | };
|
4210 |
|
4211 | module.exports = PooledClass;
|
4212 |
|
4213 | },{"./invariant":126}],29:[function(_dereq_,module,exports){
|
4214 |
|
4215 |
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 | "use strict";
|
4226 |
|
4227 | var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
|
4228 | var ReactMount = _dereq_("./ReactMount");
|
4229 |
|
4230 | var invariant = _dereq_("./invariant");
|
4231 |
|
4232 | var ReactBrowserComponentMixin = {
|
4233 | |
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 |
|
4239 |
|
4240 | getDOMNode: function() {
|
4241 | ("production" !== "development" ? invariant(
|
4242 | this.isMounted(),
|
4243 | 'getDOMNode(): A component must be mounted to have a DOM node.'
|
4244 | ) : invariant(this.isMounted()));
|
4245 | if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
|
4246 | return null;
|
4247 | }
|
4248 | return ReactMount.getNode(this._rootNodeID);
|
4249 | }
|
4250 | };
|
4251 |
|
4252 | module.exports = ReactBrowserComponentMixin;
|
4253 |
|
4254 | },{"./ReactEmptyComponent":54,"./ReactMount":63,"./invariant":126}],30:[function(_dereq_,module,exports){
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 | "use strict";
|
4268 |
|
4269 | var EventConstants = _dereq_("./EventConstants");
|
4270 | var EventPluginHub = _dereq_("./EventPluginHub");
|
4271 | var EventPluginRegistry = _dereq_("./EventPluginRegistry");
|
4272 | var ReactEventEmitterMixin = _dereq_("./ReactEventEmitterMixin");
|
4273 | var ViewportMetrics = _dereq_("./ViewportMetrics");
|
4274 |
|
4275 | var assign = _dereq_("./Object.assign");
|
4276 | var isEventSupported = _dereq_("./isEventSupported");
|
4277 |
|
4278 |
|
4279 |
|
4280 |
|
4281 |
|
4282 |
|
4283 |
|
4284 |
|
4285 |
|
4286 |
|
4287 |
|
4288 |
|
4289 |
|
4290 |
|
4291 |
|
4292 |
|
4293 |
|
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 |
|
4312 |
|
4313 |
|
4314 |
|
4315 |
|
4316 |
|
4317 |
|
4318 |
|
4319 |
|
4320 |
|
4321 |
|
4322 |
|
4323 |
|
4324 |
|
4325 |
|
4326 |
|
4327 |
|
4328 |
|
4329 |
|
4330 |
|
4331 |
|
4332 |
|
4333 | var alreadyListeningTo = {};
|
4334 | var isMonitoringScrollValue = false;
|
4335 | var reactTopListenersCounter = 0;
|
4336 |
|
4337 |
|
4338 |
|
4339 |
|
4340 | var topEventMapping = {
|
4341 | topBlur: 'blur',
|
4342 | topChange: 'change',
|
4343 | topClick: 'click',
|
4344 | topCompositionEnd: 'compositionend',
|
4345 | topCompositionStart: 'compositionstart',
|
4346 | topCompositionUpdate: 'compositionupdate',
|
4347 | topContextMenu: 'contextmenu',
|
4348 | topCopy: 'copy',
|
4349 | topCut: 'cut',
|
4350 | topDoubleClick: 'dblclick',
|
4351 | topDrag: 'drag',
|
4352 | topDragEnd: 'dragend',
|
4353 | topDragEnter: 'dragenter',
|
4354 | topDragExit: 'dragexit',
|
4355 | topDragLeave: 'dragleave',
|
4356 | topDragOver: 'dragover',
|
4357 | topDragStart: 'dragstart',
|
4358 | topDrop: 'drop',
|
4359 | topFocus: 'focus',
|
4360 | topInput: 'input',
|
4361 | topKeyDown: 'keydown',
|
4362 | topKeyPress: 'keypress',
|
4363 | topKeyUp: 'keyup',
|
4364 | topMouseDown: 'mousedown',
|
4365 | topMouseMove: 'mousemove',
|
4366 | topMouseOut: 'mouseout',
|
4367 | topMouseOver: 'mouseover',
|
4368 | topMouseUp: 'mouseup',
|
4369 | topPaste: 'paste',
|
4370 | topScroll: 'scroll',
|
4371 | topSelectionChange: 'selectionchange',
|
4372 | topTextInput: 'textInput',
|
4373 | topTouchCancel: 'touchcancel',
|
4374 | topTouchEnd: 'touchend',
|
4375 | topTouchMove: 'touchmove',
|
4376 | topTouchStart: 'touchstart',
|
4377 | topWheel: 'wheel'
|
4378 | };
|
4379 |
|
4380 |
|
4381 |
|
4382 |
|
4383 | var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2);
|
4384 |
|
4385 | function getListeningForDocument(mountAt) {
|
4386 |
|
4387 |
|
4388 | if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
|
4389 | mountAt[topListenersIDKey] = reactTopListenersCounter++;
|
4390 | alreadyListeningTo[mountAt[topListenersIDKey]] = {};
|
4391 | }
|
4392 | return alreadyListeningTo[mountAt[topListenersIDKey]];
|
4393 | }
|
4394 |
|
4395 |
|
4396 |
|
4397 |
|
4398 |
|
4399 |
|
4400 |
|
4401 |
|
4402 |
|
4403 |
|
4404 |
|
4405 | var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
4406 |
|
4407 | |
4408 |
|
4409 |
|
4410 | ReactEventListener: null,
|
4411 |
|
4412 | injection: {
|
4413 | |
4414 |
|
4415 |
|
4416 | injectReactEventListener: function(ReactEventListener) {
|
4417 | ReactEventListener.setHandleTopLevel(
|
4418 | ReactBrowserEventEmitter.handleTopLevel
|
4419 | );
|
4420 | ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
|
4421 | }
|
4422 | },
|
4423 |
|
4424 | |
4425 |
|
4426 |
|
4427 |
|
4428 |
|
4429 | setEnabled: function(enabled) {
|
4430 | if (ReactBrowserEventEmitter.ReactEventListener) {
|
4431 | ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
|
4432 | }
|
4433 | },
|
4434 |
|
4435 | |
4436 |
|
4437 |
|
4438 | isEnabled: function() {
|
4439 | return !!(
|
4440 | ReactBrowserEventEmitter.ReactEventListener &&
|
4441 | ReactBrowserEventEmitter.ReactEventListener.isEnabled()
|
4442 | );
|
4443 | },
|
4444 |
|
4445 | |
4446 |
|
4447 |
|
4448 |
|
4449 |
|
4450 |
|
4451 |
|
4452 |
|
4453 |
|
4454 |
|
4455 |
|
4456 |
|
4457 |
|
4458 |
|
4459 |
|
4460 |
|
4461 |
|
4462 |
|
4463 |
|
4464 |
|
4465 |
|
4466 | listenTo: function(registrationName, contentDocumentHandle) {
|
4467 | var mountAt = contentDocumentHandle;
|
4468 | var isListening = getListeningForDocument(mountAt);
|
4469 | var dependencies = EventPluginRegistry.
|
4470 | registrationNameDependencies[registrationName];
|
4471 |
|
4472 | var topLevelTypes = EventConstants.topLevelTypes;
|
4473 | for (var i = 0, l = dependencies.length; i < l; i++) {
|
4474 | var dependency = dependencies[i];
|
4475 | if (!(
|
4476 | isListening.hasOwnProperty(dependency) &&
|
4477 | isListening[dependency]
|
4478 | )) {
|
4479 | if (dependency === topLevelTypes.topWheel) {
|
4480 | if (isEventSupported('wheel')) {
|
4481 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4482 | topLevelTypes.topWheel,
|
4483 | 'wheel',
|
4484 | mountAt
|
4485 | );
|
4486 | } else if (isEventSupported('mousewheel')) {
|
4487 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4488 | topLevelTypes.topWheel,
|
4489 | 'mousewheel',
|
4490 | mountAt
|
4491 | );
|
4492 | } else {
|
4493 |
|
4494 |
|
4495 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4496 | topLevelTypes.topWheel,
|
4497 | 'DOMMouseScroll',
|
4498 | mountAt
|
4499 | );
|
4500 | }
|
4501 | } else if (dependency === topLevelTypes.topScroll) {
|
4502 |
|
4503 | if (isEventSupported('scroll', true)) {
|
4504 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
4505 | topLevelTypes.topScroll,
|
4506 | 'scroll',
|
4507 | mountAt
|
4508 | );
|
4509 | } else {
|
4510 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4511 | topLevelTypes.topScroll,
|
4512 | 'scroll',
|
4513 | ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
|
4514 | );
|
4515 | }
|
4516 | } else if (dependency === topLevelTypes.topFocus ||
|
4517 | dependency === topLevelTypes.topBlur) {
|
4518 |
|
4519 | if (isEventSupported('focus', true)) {
|
4520 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
4521 | topLevelTypes.topFocus,
|
4522 | 'focus',
|
4523 | mountAt
|
4524 | );
|
4525 | ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
4526 | topLevelTypes.topBlur,
|
4527 | 'blur',
|
4528 | mountAt
|
4529 | );
|
4530 | } else if (isEventSupported('focusin')) {
|
4531 |
|
4532 |
|
4533 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4534 | topLevelTypes.topFocus,
|
4535 | 'focusin',
|
4536 | mountAt
|
4537 | );
|
4538 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4539 | topLevelTypes.topBlur,
|
4540 | 'focusout',
|
4541 | mountAt
|
4542 | );
|
4543 | }
|
4544 |
|
4545 |
|
4546 | isListening[topLevelTypes.topBlur] = true;
|
4547 | isListening[topLevelTypes.topFocus] = true;
|
4548 | } else if (topEventMapping.hasOwnProperty(dependency)) {
|
4549 | ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4550 | dependency,
|
4551 | topEventMapping[dependency],
|
4552 | mountAt
|
4553 | );
|
4554 | }
|
4555 |
|
4556 | isListening[dependency] = true;
|
4557 | }
|
4558 | }
|
4559 | },
|
4560 |
|
4561 | trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
|
4562 | return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
4563 | topLevelType,
|
4564 | handlerBaseName,
|
4565 | handle
|
4566 | );
|
4567 | },
|
4568 |
|
4569 | trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
|
4570 | return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
4571 | topLevelType,
|
4572 | handlerBaseName,
|
4573 | handle
|
4574 | );
|
4575 | },
|
4576 |
|
4577 | |
4578 |
|
4579 |
|
4580 |
|
4581 |
|
4582 |
|
4583 |
|
4584 |
|
4585 | ensureScrollValueMonitoring: function(){
|
4586 | if (!isMonitoringScrollValue) {
|
4587 | var refresh = ViewportMetrics.refreshScrollValues;
|
4588 | ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
|
4589 | isMonitoringScrollValue = true;
|
4590 | }
|
4591 | },
|
4592 |
|
4593 | eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
|
4594 |
|
4595 | registrationNameModules: EventPluginHub.registrationNameModules,
|
4596 |
|
4597 | putListener: EventPluginHub.putListener,
|
4598 |
|
4599 | getListener: EventPluginHub.getListener,
|
4600 |
|
4601 | deleteListener: EventPluginHub.deleteListener,
|
4602 |
|
4603 | deleteAllListeners: EventPluginHub.deleteAllListeners
|
4604 |
|
4605 | });
|
4606 |
|
4607 | module.exports = ReactBrowserEventEmitter;
|
4608 |
|
4609 | },{"./EventConstants":16,"./EventPluginHub":18,"./EventPluginRegistry":19,"./Object.assign":27,"./ReactEventEmitterMixin":56,"./ViewportMetrics":96,"./isEventSupported":127}],31:[function(_dereq_,module,exports){
|
4610 |
|
4611 |
|
4612 |
|
4613 |
|
4614 |
|
4615 |
|
4616 |
|
4617 |
|
4618 |
|
4619 |
|
4620 |
|
4621 | "use strict";
|
4622 |
|
4623 | var PooledClass = _dereq_("./PooledClass");
|
4624 |
|
4625 | var traverseAllChildren = _dereq_("./traverseAllChildren");
|
4626 | var warning = _dereq_("./warning");
|
4627 |
|
4628 | var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
4629 | var threeArgumentPooler = PooledClass.threeArgumentPooler;
|
4630 |
|
4631 |
|
4632 |
|
4633 |
|
4634 |
|
4635 |
|
4636 |
|
4637 |
|
4638 |
|
4639 | function ForEachBookKeeping(forEachFunction, forEachContext) {
|
4640 | this.forEachFunction = forEachFunction;
|
4641 | this.forEachContext = forEachContext;
|
4642 | }
|
4643 | PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
4644 |
|
4645 | function forEachSingleChild(traverseContext, child, name, i) {
|
4646 | var forEachBookKeeping = traverseContext;
|
4647 | forEachBookKeeping.forEachFunction.call(
|
4648 | forEachBookKeeping.forEachContext, child, i);
|
4649 | }
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 |
|
4659 |
|
4660 |
|
4661 | function forEachChildren(children, forEachFunc, forEachContext) {
|
4662 | if (children == null) {
|
4663 | return children;
|
4664 | }
|
4665 |
|
4666 | var traverseContext =
|
4667 | ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
4668 | traverseAllChildren(children, forEachSingleChild, traverseContext);
|
4669 | ForEachBookKeeping.release(traverseContext);
|
4670 | }
|
4671 |
|
4672 |
|
4673 |
|
4674 |
|
4675 |
|
4676 |
|
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 | function MapBookKeeping(mapResult, mapFunction, mapContext) {
|
4682 | this.mapResult = mapResult;
|
4683 | this.mapFunction = mapFunction;
|
4684 | this.mapContext = mapContext;
|
4685 | }
|
4686 | PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
|
4687 |
|
4688 | function mapSingleChildIntoContext(traverseContext, child, name, i) {
|
4689 | var mapBookKeeping = traverseContext;
|
4690 | var mapResult = mapBookKeeping.mapResult;
|
4691 |
|
4692 | var keyUnique = !mapResult.hasOwnProperty(name);
|
4693 | ("production" !== "development" ? warning(
|
4694 | keyUnique,
|
4695 | 'ReactChildren.map(...): Encountered two children with the same key, ' +
|
4696 | '`%s`. Child keys must be unique; when two children share a key, only ' +
|
4697 | 'the first child will be used.',
|
4698 | name
|
4699 | ) : null);
|
4700 |
|
4701 | if (keyUnique) {
|
4702 | var mappedChild =
|
4703 | mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
|
4704 | mapResult[name] = mappedChild;
|
4705 | }
|
4706 | }
|
4707 |
|
4708 |
|
4709 |
|
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 |
|
4717 |
|
4718 |
|
4719 |
|
4720 |
|
4721 |
|
4722 | function mapChildren(children, func, context) {
|
4723 | if (children == null) {
|
4724 | return children;
|
4725 | }
|
4726 |
|
4727 | var mapResult = {};
|
4728 | var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
|
4729 | traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
4730 | MapBookKeeping.release(traverseContext);
|
4731 | return mapResult;
|
4732 | }
|
4733 |
|
4734 | function forEachSingleChildDummy(traverseContext, child, name, i) {
|
4735 | return null;
|
4736 | }
|
4737 |
|
4738 |
|
4739 |
|
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 | function countChildren(children, context) {
|
4746 | return traverseAllChildren(children, forEachSingleChildDummy, null);
|
4747 | }
|
4748 |
|
4749 | var ReactChildren = {
|
4750 | forEach: forEachChildren,
|
4751 | map: mapChildren,
|
4752 | count: countChildren
|
4753 | };
|
4754 |
|
4755 | module.exports = ReactChildren;
|
4756 |
|
4757 | },{"./PooledClass":28,"./traverseAllChildren":144,"./warning":145}],32:[function(_dereq_,module,exports){
|
4758 |
|
4759 |
|
4760 |
|
4761 |
|
4762 |
|
4763 |
|
4764 |
|
4765 |
|
4766 |
|
4767 |
|
4768 |
|
4769 | "use strict";
|
4770 |
|
4771 | var ReactElement = _dereq_("./ReactElement");
|
4772 | var ReactOwner = _dereq_("./ReactOwner");
|
4773 | var ReactUpdates = _dereq_("./ReactUpdates");
|
4774 |
|
4775 | var assign = _dereq_("./Object.assign");
|
4776 | var invariant = _dereq_("./invariant");
|
4777 | var keyMirror = _dereq_("./keyMirror");
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 | var ComponentLifeCycle = keyMirror({
|
4783 | |
4784 |
|
4785 |
|
4786 |
|
4787 | MOUNTED: null,
|
4788 | |
4789 |
|
4790 |
|
4791 | UNMOUNTED: null
|
4792 | });
|
4793 |
|
4794 | var injected = false;
|
4795 |
|
4796 |
|
4797 |
|
4798 |
|
4799 |
|
4800 |
|
4801 |
|
4802 |
|
4803 | var unmountIDFromEnvironment = null;
|
4804 |
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 |
|
4813 |
|
4814 | var mountImageIntoNode = null;
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 |
|
4820 |
|
4821 |
|
4822 |
|
4823 |
|
4824 |
|
4825 |
|
4826 |
|
4827 |
|
4828 |
|
4829 |
|
4830 |
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 |
|
4840 |
|
4841 | var ReactComponent = {
|
4842 |
|
4843 | injection: {
|
4844 | injectEnvironment: function(ReactComponentEnvironment) {
|
4845 | ("production" !== "development" ? invariant(
|
4846 | !injected,
|
4847 | 'ReactComponent: injectEnvironment() can only be called once.'
|
4848 | ) : invariant(!injected));
|
4849 | mountImageIntoNode = ReactComponentEnvironment.mountImageIntoNode;
|
4850 | unmountIDFromEnvironment =
|
4851 | ReactComponentEnvironment.unmountIDFromEnvironment;
|
4852 | ReactComponent.BackendIDOperations =
|
4853 | ReactComponentEnvironment.BackendIDOperations;
|
4854 | injected = true;
|
4855 | }
|
4856 | },
|
4857 |
|
4858 | |
4859 |
|
4860 |
|
4861 | LifeCycle: ComponentLifeCycle,
|
4862 |
|
4863 | |
4864 |
|
4865 |
|
4866 |
|
4867 |
|
4868 |
|
4869 |
|
4870 | BackendIDOperations: null,
|
4871 |
|
4872 | |
4873 |
|
4874 |
|
4875 |
|
4876 |
|
4877 |
|
4878 | Mixin: {
|
4879 |
|
4880 | |
4881 |
|
4882 |
|
4883 |
|
4884 |
|
4885 |
|
4886 |
|
4887 | isMounted: function() {
|
4888 | return this._lifeCycleState === ComponentLifeCycle.MOUNTED;
|
4889 | },
|
4890 |
|
4891 | |
4892 |
|
4893 |
|
4894 |
|
4895 |
|
4896 |
|
4897 |
|
4898 |
|
4899 | setProps: function(partialProps, callback) {
|
4900 |
|
4901 |
|
4902 | var element = this._pendingElement || this._currentElement;
|
4903 | this.replaceProps(
|
4904 | assign({}, element.props, partialProps),
|
4905 | callback
|
4906 | );
|
4907 | },
|
4908 |
|
4909 | |
4910 |
|
4911 |
|
4912 |
|
4913 |
|
4914 |
|
4915 |
|
4916 |
|
4917 | replaceProps: function(props, callback) {
|
4918 | ("production" !== "development" ? invariant(
|
4919 | this.isMounted(),
|
4920 | 'replaceProps(...): Can only update a mounted component.'
|
4921 | ) : invariant(this.isMounted()));
|
4922 | ("production" !== "development" ? invariant(
|
4923 | this._mountDepth === 0,
|
4924 | 'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
|
4925 | 'component with a parent. This is an anti-pattern since props will ' +
|
4926 | 'get reactively updated when rendered. Instead, change the owner\'s ' +
|
4927 | '`render` method to pass the correct value as props to the component ' +
|
4928 | 'where it is created.'
|
4929 | ) : invariant(this._mountDepth === 0));
|
4930 |
|
4931 |
|
4932 | this._pendingElement = ReactElement.cloneAndReplaceProps(
|
4933 | this._pendingElement || this._currentElement,
|
4934 | props
|
4935 | );
|
4936 | ReactUpdates.enqueueUpdate(this, callback);
|
4937 | },
|
4938 |
|
4939 | |
4940 |
|
4941 |
|
4942 |
|
4943 |
|
4944 |
|
4945 |
|
4946 |
|
4947 | _setPropsInternal: function(partialProps, callback) {
|
4948 |
|
4949 |
|
4950 | var element = this._pendingElement || this._currentElement;
|
4951 | this._pendingElement = ReactElement.cloneAndReplaceProps(
|
4952 | element,
|
4953 | assign({}, element.props, partialProps)
|
4954 | );
|
4955 | ReactUpdates.enqueueUpdate(this, callback);
|
4956 | },
|
4957 |
|
4958 | |
4959 |
|
4960 |
|
4961 |
|
4962 |
|
4963 |
|
4964 |
|
4965 |
|
4966 |
|
4967 | construct: function(element) {
|
4968 |
|
4969 |
|
4970 |
|
4971 | this.props = element.props;
|
4972 |
|
4973 |
|
4974 |
|
4975 |
|
4976 | this._owner = element._owner;
|
4977 |
|
4978 |
|
4979 | this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
|
4980 |
|
4981 |
|
4982 | this._pendingCallbacks = null;
|
4983 |
|
4984 |
|
4985 |
|
4986 | this._currentElement = element;
|
4987 | this._pendingElement = null;
|
4988 | },
|
4989 |
|
4990 | |
4991 |
|
4992 |
|
4993 |
|
4994 |
|
4995 |
|
4996 |
|
4997 |
|
4998 |
|
4999 |
|
5000 |
|
5001 |
|
5002 |
|
5003 |
|
5004 | mountComponent: function(rootID, transaction, mountDepth) {
|
5005 | ("production" !== "development" ? invariant(
|
5006 | !this.isMounted(),
|
5007 | 'mountComponent(%s, ...): Can only mount an unmounted component. ' +
|
5008 | 'Make sure to avoid storing components between renders or reusing a ' +
|
5009 | 'single component instance in multiple places.',
|
5010 | rootID
|
5011 | ) : invariant(!this.isMounted()));
|
5012 | var ref = this._currentElement.ref;
|
5013 | if (ref != null) {
|
5014 | var owner = this._currentElement._owner;
|
5015 | ReactOwner.addComponentAsRefTo(this, ref, owner);
|
5016 | }
|
5017 | this._rootNodeID = rootID;
|
5018 | this._lifeCycleState = ComponentLifeCycle.MOUNTED;
|
5019 | this._mountDepth = mountDepth;
|
5020 |
|
5021 | },
|
5022 |
|
5023 | |
5024 |
|
5025 |
|
5026 |
|
5027 |
|
5028 |
|
5029 |
|
5030 |
|
5031 |
|
5032 |
|
5033 | unmountComponent: function() {
|
5034 | ("production" !== "development" ? invariant(
|
5035 | this.isMounted(),
|
5036 | 'unmountComponent(): Can only unmount a mounted component.'
|
5037 | ) : invariant(this.isMounted()));
|
5038 | var ref = this._currentElement.ref;
|
5039 | if (ref != null) {
|
5040 | ReactOwner.removeComponentAsRefFrom(this, ref, this._owner);
|
5041 | }
|
5042 | unmountIDFromEnvironment(this._rootNodeID);
|
5043 | this._rootNodeID = null;
|
5044 | this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
|
5045 | },
|
5046 |
|
5047 | |
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 | receiveComponent: function(nextElement, transaction) {
|
5059 | ("production" !== "development" ? invariant(
|
5060 | this.isMounted(),
|
5061 | 'receiveComponent(...): Can only update a mounted component.'
|
5062 | ) : invariant(this.isMounted()));
|
5063 | this._pendingElement = nextElement;
|
5064 | this.performUpdateIfNecessary(transaction);
|
5065 | },
|
5066 |
|
5067 | |
5068 |
|
5069 |
|
5070 |
|
5071 |
|
5072 |
|
5073 | performUpdateIfNecessary: function(transaction) {
|
5074 | if (this._pendingElement == null) {
|
5075 | return;
|
5076 | }
|
5077 | var prevElement = this._currentElement;
|
5078 | var nextElement = this._pendingElement;
|
5079 | this._currentElement = nextElement;
|
5080 | this.props = nextElement.props;
|
5081 | this._owner = nextElement._owner;
|
5082 | this._pendingElement = null;
|
5083 | this.updateComponent(transaction, prevElement);
|
5084 | },
|
5085 |
|
5086 | |
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 | updateComponent: function(transaction, prevElement) {
|
5094 | var nextElement = this._currentElement;
|
5095 |
|
5096 |
|
5097 |
|
5098 |
|
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 |
|
5106 |
|
5107 |
|
5108 | if (nextElement._owner !== prevElement._owner ||
|
5109 | nextElement.ref !== prevElement.ref) {
|
5110 | if (prevElement.ref != null) {
|
5111 | ReactOwner.removeComponentAsRefFrom(
|
5112 | this, prevElement.ref, prevElement._owner
|
5113 | );
|
5114 | }
|
5115 |
|
5116 | if (nextElement.ref != null) {
|
5117 | ReactOwner.addComponentAsRefTo(
|
5118 | this,
|
5119 | nextElement.ref,
|
5120 | nextElement._owner
|
5121 | );
|
5122 | }
|
5123 | }
|
5124 | },
|
5125 |
|
5126 | |
5127 |
|
5128 |
|
5129 |
|
5130 |
|
5131 |
|
5132 |
|
5133 |
|
5134 |
|
5135 |
|
5136 | mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
|
5137 | var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
|
5138 | transaction.perform(
|
5139 | this._mountComponentIntoNode,
|
5140 | this,
|
5141 | rootID,
|
5142 | container,
|
5143 | transaction,
|
5144 | shouldReuseMarkup
|
5145 | );
|
5146 | ReactUpdates.ReactReconcileTransaction.release(transaction);
|
5147 | },
|
5148 |
|
5149 | |
5150 |
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 |
|
5156 |
|
5157 | _mountComponentIntoNode: function(
|
5158 | rootID,
|
5159 | container,
|
5160 | transaction,
|
5161 | shouldReuseMarkup) {
|
5162 | var markup = this.mountComponent(rootID, transaction, 0);
|
5163 | mountImageIntoNode(markup, container, shouldReuseMarkup);
|
5164 | },
|
5165 |
|
5166 | |
5167 |
|
5168 |
|
5169 |
|
5170 |
|
5171 |
|
5172 |
|
5173 |
|
5174 | isOwnedBy: function(owner) {
|
5175 | return this._owner === owner;
|
5176 | },
|
5177 |
|
5178 | |
5179 |
|
5180 |
|
5181 |
|
5182 |
|
5183 |
|
5184 |
|
5185 |
|
5186 | getSiblingByRef: function(ref) {
|
5187 | var owner = this._owner;
|
5188 | if (!owner || !owner.refs) {
|
5189 | return null;
|
5190 | }
|
5191 | return owner.refs[ref];
|
5192 | }
|
5193 | }
|
5194 | };
|
5195 |
|
5196 | module.exports = ReactComponent;
|
5197 |
|
5198 | },{"./Object.assign":27,"./ReactElement":52,"./ReactOwner":67,"./ReactUpdates":79,"./invariant":126,"./keyMirror":132}],33:[function(_dereq_,module,exports){
|
5199 |
|
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 |
|
5209 |
|
5210 |
|
5211 |
|
5212 | "use strict";
|
5213 |
|
5214 | var ReactDOMIDOperations = _dereq_("./ReactDOMIDOperations");
|
5215 | var ReactMarkupChecksum = _dereq_("./ReactMarkupChecksum");
|
5216 | var ReactMount = _dereq_("./ReactMount");
|
5217 | var ReactPerf = _dereq_("./ReactPerf");
|
5218 | var ReactReconcileTransaction = _dereq_("./ReactReconcileTransaction");
|
5219 |
|
5220 | var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer");
|
5221 | var invariant = _dereq_("./invariant");
|
5222 | var setInnerHTML = _dereq_("./setInnerHTML");
|
5223 |
|
5224 |
|
5225 | var ELEMENT_NODE_TYPE = 1;
|
5226 | var DOC_NODE_TYPE = 9;
|
5227 |
|
5228 |
|
5229 |
|
5230 |
|
5231 |
|
5232 |
|
5233 | var ReactComponentBrowserEnvironment = {
|
5234 | ReactReconcileTransaction: ReactReconcileTransaction,
|
5235 |
|
5236 | BackendIDOperations: ReactDOMIDOperations,
|
5237 |
|
5238 | |
5239 |
|
5240 |
|
5241 |
|
5242 |
|
5243 |
|
5244 |
|
5245 | unmountIDFromEnvironment: function(rootNodeID) {
|
5246 | ReactMount.purgeID(rootNodeID);
|
5247 | },
|
5248 |
|
5249 | |
5250 |
|
5251 |
|
5252 |
|
5253 |
|
5254 |
|
5255 | mountImageIntoNode: ReactPerf.measure(
|
5256 | 'ReactComponentBrowserEnvironment',
|
5257 | 'mountImageIntoNode',
|
5258 | function(markup, container, shouldReuseMarkup) {
|
5259 | ("production" !== "development" ? invariant(
|
5260 | container && (
|
5261 | container.nodeType === ELEMENT_NODE_TYPE ||
|
5262 | container.nodeType === DOC_NODE_TYPE
|
5263 | ),
|
5264 | 'mountComponentIntoNode(...): Target container is not valid.'
|
5265 | ) : invariant(container && (
|
5266 | container.nodeType === ELEMENT_NODE_TYPE ||
|
5267 | container.nodeType === DOC_NODE_TYPE
|
5268 | )));
|
5269 |
|
5270 | if (shouldReuseMarkup) {
|
5271 | if (ReactMarkupChecksum.canReuseMarkup(
|
5272 | markup,
|
5273 | getReactRootElementInContainer(container))) {
|
5274 | return;
|
5275 | } else {
|
5276 | ("production" !== "development" ? invariant(
|
5277 | container.nodeType !== DOC_NODE_TYPE,
|
5278 | 'You\'re trying to render a component to the document using ' +
|
5279 | 'server rendering but the checksum was invalid. This usually ' +
|
5280 | 'means you rendered a different component type or props on ' +
|
5281 | 'the client from the one on the server, or your render() ' +
|
5282 | 'methods are impure. React cannot handle this case due to ' +
|
5283 | 'cross-browser quirks by rendering at the document root. You ' +
|
5284 | 'should look for environment dependent code in your components ' +
|
5285 | 'and ensure the props are the same client and server side.'
|
5286 | ) : invariant(container.nodeType !== DOC_NODE_TYPE));
|
5287 |
|
5288 | if ("production" !== "development") {
|
5289 | console.warn(
|
5290 | 'React attempted to use reuse markup in a container but the ' +
|
5291 | 'checksum was invalid. This generally means that you are ' +
|
5292 | 'using server rendering and the markup generated on the ' +
|
5293 | 'server was not what the client was expecting. React injected ' +
|
5294 | 'new markup to compensate which works but you have lost many ' +
|
5295 | 'of the benefits of server rendering. Instead, figure out ' +
|
5296 | 'why the markup being generated is different on the client ' +
|
5297 | 'or server.'
|
5298 | );
|
5299 | }
|
5300 | }
|
5301 | }
|
5302 |
|
5303 | ("production" !== "development" ? invariant(
|
5304 | container.nodeType !== DOC_NODE_TYPE,
|
5305 | 'You\'re trying to render a component to the document but ' +
|
5306 | 'you didn\'t use server rendering. We can\'t do this ' +
|
5307 | 'without using server rendering due to cross-browser quirks. ' +
|
5308 | 'See renderComponentToString() for server rendering.'
|
5309 | ) : invariant(container.nodeType !== DOC_NODE_TYPE));
|
5310 |
|
5311 | setInnerHTML(container, markup);
|
5312 | }
|
5313 | )
|
5314 | };
|
5315 |
|
5316 | module.exports = ReactComponentBrowserEnvironment;
|
5317 |
|
5318 | },{"./ReactDOMIDOperations":41,"./ReactMarkupChecksum":62,"./ReactMount":63,"./ReactPerf":68,"./ReactReconcileTransaction":74,"./getReactRootElementInContainer":120,"./invariant":126,"./setInnerHTML":140}],34:[function(_dereq_,module,exports){
|
5319 |
|
5320 |
|
5321 |
|
5322 |
|
5323 |
|
5324 |
|
5325 |
|
5326 |
|
5327 |
|
5328 |
|
5329 |
|
5330 | "use strict";
|
5331 |
|
5332 | var ReactComponent = _dereq_("./ReactComponent");
|
5333 | var ReactContext = _dereq_("./ReactContext");
|
5334 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
5335 | var ReactElement = _dereq_("./ReactElement");
|
5336 | var ReactElementValidator = _dereq_("./ReactElementValidator");
|
5337 | var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
|
5338 | var ReactErrorUtils = _dereq_("./ReactErrorUtils");
|
5339 | var ReactLegacyElement = _dereq_("./ReactLegacyElement");
|
5340 | var ReactOwner = _dereq_("./ReactOwner");
|
5341 | var ReactPerf = _dereq_("./ReactPerf");
|
5342 | var ReactPropTransferer = _dereq_("./ReactPropTransferer");
|
5343 | var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
|
5344 | var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
|
5345 | var ReactUpdates = _dereq_("./ReactUpdates");
|
5346 |
|
5347 | var assign = _dereq_("./Object.assign");
|
5348 | var instantiateReactComponent = _dereq_("./instantiateReactComponent");
|
5349 | var invariant = _dereq_("./invariant");
|
5350 | var keyMirror = _dereq_("./keyMirror");
|
5351 | var keyOf = _dereq_("./keyOf");
|
5352 | var monitorCodeUse = _dereq_("./monitorCodeUse");
|
5353 | var mapObject = _dereq_("./mapObject");
|
5354 | var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
|
5355 | var warning = _dereq_("./warning");
|
5356 |
|
5357 | var MIXINS_KEY = keyOf({mixins: null});
|
5358 |
|
5359 |
|
5360 |
|
5361 |
|
5362 | var SpecPolicy = keyMirror({
|
5363 | |
5364 |
|
5365 |
|
5366 | DEFINE_ONCE: null,
|
5367 | |
5368 |
|
5369 |
|
5370 |
|
5371 | DEFINE_MANY: null,
|
5372 | |
5373 |
|
5374 |
|
5375 | OVERRIDE_BASE: null,
|
5376 | |
5377 |
|
5378 |
|
5379 |
|
5380 |
|
5381 | DEFINE_MANY_MERGED: null
|
5382 | });
|
5383 |
|
5384 |
|
5385 | var injectedMixins = [];
|
5386 |
|
5387 |
|
5388 |
|
5389 |
|
5390 |
|
5391 |
|
5392 |
|
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 |
|
5398 |
|
5399 |
|
5400 |
|
5401 |
|
5402 |
|
5403 |
|
5404 |
|
5405 |
|
5406 |
|
5407 |
|
5408 |
|
5409 | var ReactCompositeComponentInterface = {
|
5410 |
|
5411 | |
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 |
|
5417 | mixins: SpecPolicy.DEFINE_MANY,
|
5418 |
|
5419 | |
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 |
|
5426 | statics: SpecPolicy.DEFINE_MANY,
|
5427 |
|
5428 | |
5429 |
|
5430 |
|
5431 |
|
5432 |
|
5433 |
|
5434 | propTypes: SpecPolicy.DEFINE_MANY,
|
5435 |
|
5436 | |
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 |
|
5442 | contextTypes: SpecPolicy.DEFINE_MANY,
|
5443 |
|
5444 | |
5445 |
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 | childContextTypes: SpecPolicy.DEFINE_MANY,
|
5451 |
|
5452 |
|
5453 |
|
5454 | |
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 |
|
5461 |
|
5462 |
|
5463 |
|
5464 | getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
|
5465 |
|
5466 | |
5467 |
|
5468 |
|
5469 |
|
5470 |
|
5471 |
|
5472 |
|
5473 |
|
5474 |
|
5475 |
|
5476 |
|
5477 |
|
5478 |
|
5479 |
|
5480 | getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
|
5481 |
|
5482 | |
5483 |
|
5484 |
|
5485 |
|
5486 | getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
|
5487 |
|
5488 | |
5489 |
|
5490 |
|
5491 |
|
5492 |
|
5493 |
|
5494 |
|
5495 |
|
5496 |
|
5497 |
|
5498 |
|
5499 |
|
5500 |
|
5501 |
|
5502 |
|
5503 |
|
5504 | render: SpecPolicy.DEFINE_ONCE,
|
5505 |
|
5506 |
|
5507 |
|
5508 |
|
5509 |
|
5510 | |
5511 |
|
5512 |
|
5513 |
|
5514 |
|
5515 |
|
5516 |
|
5517 | componentWillMount: SpecPolicy.DEFINE_MANY,
|
5518 |
|
5519 | |
5520 |
|
5521 |
|
5522 |
|
5523 |
|
5524 |
|
5525 |
|
5526 |
|
5527 |
|
5528 |
|
5529 | componentDidMount: SpecPolicy.DEFINE_MANY,
|
5530 |
|
5531 | |
5532 |
|
5533 |
|
5534 |
|
5535 |
|
5536 |
|
5537 |
|
5538 |
|
5539 |
|
5540 |
|
5541 |
|
5542 |
|
5543 |
|
5544 |
|
5545 |
|
5546 |
|
5547 |
|
5548 |
|
5549 |
|
5550 | componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
|
5551 |
|
5552 | |
5553 |
|
5554 |
|
5555 |
|
5556 |
|
5557 |
|
5558 |
|
5559 |
|
5560 |
|
5561 |
|
5562 |
|
5563 |
|
5564 |
|
5565 |
|
5566 |
|
5567 |
|
5568 |
|
5569 |
|
5570 |
|
5571 |
|
5572 | shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
|
5573 |
|
5574 | |
5575 |
|
5576 |
|
5577 |
|
5578 |
|
5579 |
|
5580 |
|
5581 |
|
5582 |
|
5583 |
|
5584 |
|
5585 |
|
5586 |
|
5587 |
|
5588 |
|
5589 | componentWillUpdate: SpecPolicy.DEFINE_MANY,
|
5590 |
|
5591 | |
5592 |
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 |
|
5598 |
|
5599 |
|
5600 |
|
5601 |
|
5602 |
|
5603 | componentDidUpdate: SpecPolicy.DEFINE_MANY,
|
5604 |
|
5605 | |
5606 |
|
5607 |
|
5608 |
|
5609 |
|
5610 |
|
5611 |
|
5612 |
|
5613 |
|
5614 |
|
5615 |
|
5616 | componentWillUnmount: SpecPolicy.DEFINE_MANY,
|
5617 |
|
5618 |
|
5619 |
|
5620 |
|
5621 |
|
5622 | |
5623 |
|
5624 |
|
5625 |
|
5626 |
|
5627 |
|
5628 |
|
5629 |
|
5630 |
|
5631 |
|
5632 | updateComponent: SpecPolicy.OVERRIDE_BASE
|
5633 |
|
5634 | };
|
5635 |
|
5636 |
|
5637 |
|
5638 |
|
5639 |
|
5640 |
|
5641 |
|
5642 |
|
5643 |
|
5644 |
|
5645 | var RESERVED_SPEC_KEYS = {
|
5646 | displayName: function(Constructor, displayName) {
|
5647 | Constructor.displayName = displayName;
|
5648 | },
|
5649 | mixins: function(Constructor, mixins) {
|
5650 | if (mixins) {
|
5651 | for (var i = 0; i < mixins.length; i++) {
|
5652 | mixSpecIntoComponent(Constructor, mixins[i]);
|
5653 | }
|
5654 | }
|
5655 | },
|
5656 | childContextTypes: function(Constructor, childContextTypes) {
|
5657 | validateTypeDef(
|
5658 | Constructor,
|
5659 | childContextTypes,
|
5660 | ReactPropTypeLocations.childContext
|
5661 | );
|
5662 | Constructor.childContextTypes = assign(
|
5663 | {},
|
5664 | Constructor.childContextTypes,
|
5665 | childContextTypes
|
5666 | );
|
5667 | },
|
5668 | contextTypes: function(Constructor, contextTypes) {
|
5669 | validateTypeDef(
|
5670 | Constructor,
|
5671 | contextTypes,
|
5672 | ReactPropTypeLocations.context
|
5673 | );
|
5674 | Constructor.contextTypes = assign(
|
5675 | {},
|
5676 | Constructor.contextTypes,
|
5677 | contextTypes
|
5678 | );
|
5679 | },
|
5680 | |
5681 |
|
5682 |
|
5683 |
|
5684 | getDefaultProps: function(Constructor, getDefaultProps) {
|
5685 | if (Constructor.getDefaultProps) {
|
5686 | Constructor.getDefaultProps = createMergedResultFunction(
|
5687 | Constructor.getDefaultProps,
|
5688 | getDefaultProps
|
5689 | );
|
5690 | } else {
|
5691 | Constructor.getDefaultProps = getDefaultProps;
|
5692 | }
|
5693 | },
|
5694 | propTypes: function(Constructor, propTypes) {
|
5695 | validateTypeDef(
|
5696 | Constructor,
|
5697 | propTypes,
|
5698 | ReactPropTypeLocations.prop
|
5699 | );
|
5700 | Constructor.propTypes = assign(
|
5701 | {},
|
5702 | Constructor.propTypes,
|
5703 | propTypes
|
5704 | );
|
5705 | },
|
5706 | statics: function(Constructor, statics) {
|
5707 | mixStaticSpecIntoComponent(Constructor, statics);
|
5708 | }
|
5709 | };
|
5710 |
|
5711 | function getDeclarationErrorAddendum(component) {
|
5712 | var owner = component._owner || null;
|
5713 | if (owner && owner.constructor && owner.constructor.displayName) {
|
5714 | return ' Check the render method of `' + owner.constructor.displayName +
|
5715 | '`.';
|
5716 | }
|
5717 | return '';
|
5718 | }
|
5719 |
|
5720 | function validateTypeDef(Constructor, typeDef, location) {
|
5721 | for (var propName in typeDef) {
|
5722 | if (typeDef.hasOwnProperty(propName)) {
|
5723 | ("production" !== "development" ? invariant(
|
5724 | typeof typeDef[propName] == 'function',
|
5725 | '%s: %s type `%s` is invalid; it must be a function, usually from ' +
|
5726 | 'React.PropTypes.',
|
5727 | Constructor.displayName || 'ReactCompositeComponent',
|
5728 | ReactPropTypeLocationNames[location],
|
5729 | propName
|
5730 | ) : invariant(typeof typeDef[propName] == 'function'));
|
5731 | }
|
5732 | }
|
5733 | }
|
5734 |
|
5735 | function validateMethodOverride(proto, name) {
|
5736 | var specPolicy = ReactCompositeComponentInterface.hasOwnProperty(name) ?
|
5737 | ReactCompositeComponentInterface[name] :
|
5738 | null;
|
5739 |
|
5740 |
|
5741 | if (ReactCompositeComponentMixin.hasOwnProperty(name)) {
|
5742 | ("production" !== "development" ? invariant(
|
5743 | specPolicy === SpecPolicy.OVERRIDE_BASE,
|
5744 | 'ReactCompositeComponentInterface: You are attempting to override ' +
|
5745 | '`%s` from your class specification. Ensure that your method names ' +
|
5746 | 'do not overlap with React methods.',
|
5747 | name
|
5748 | ) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
|
5749 | }
|
5750 |
|
5751 |
|
5752 | if (proto.hasOwnProperty(name)) {
|
5753 | ("production" !== "development" ? invariant(
|
5754 | specPolicy === SpecPolicy.DEFINE_MANY ||
|
5755 | specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
|
5756 | 'ReactCompositeComponentInterface: You are attempting to define ' +
|
5757 | '`%s` on your component more than once. This conflict may be due ' +
|
5758 | 'to a mixin.',
|
5759 | name
|
5760 | ) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
|
5761 | specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
|
5762 | }
|
5763 | }
|
5764 |
|
5765 | function validateLifeCycleOnReplaceState(instance) {
|
5766 | var compositeLifeCycleState = instance._compositeLifeCycleState;
|
5767 | ("production" !== "development" ? invariant(
|
5768 | instance.isMounted() ||
|
5769 | compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
|
5770 | 'replaceState(...): Can only update a mounted or mounting component.'
|
5771 | ) : invariant(instance.isMounted() ||
|
5772 | compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
|
5773 | ("production" !== "development" ? invariant(
|
5774 | ReactCurrentOwner.current == null,
|
5775 | 'replaceState(...): Cannot update during an existing state transition ' +
|
5776 | '(such as within `render`). Render methods should be a pure function ' +
|
5777 | 'of props and state.'
|
5778 | ) : invariant(ReactCurrentOwner.current == null));
|
5779 | ("production" !== "development" ? invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
|
5780 | 'replaceState(...): Cannot update while unmounting component. This ' +
|
5781 | 'usually means you called setState() on an unmounted component.'
|
5782 | ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
|
5783 | }
|
5784 |
|
5785 |
|
5786 |
|
5787 |
|
5788 |
|
5789 | function mixSpecIntoComponent(Constructor, spec) {
|
5790 | if (!spec) {
|
5791 | return;
|
5792 | }
|
5793 |
|
5794 | ("production" !== "development" ? invariant(
|
5795 | !ReactLegacyElement.isValidFactory(spec),
|
5796 | 'ReactCompositeComponent: You\'re attempting to ' +
|
5797 | 'use a component class as a mixin. Instead, just use a regular object.'
|
5798 | ) : invariant(!ReactLegacyElement.isValidFactory(spec)));
|
5799 | ("production" !== "development" ? invariant(
|
5800 | !ReactElement.isValidElement(spec),
|
5801 | 'ReactCompositeComponent: You\'re attempting to ' +
|
5802 | 'use a component as a mixin. Instead, just use a regular object.'
|
5803 | ) : invariant(!ReactElement.isValidElement(spec)));
|
5804 |
|
5805 | var proto = Constructor.prototype;
|
5806 |
|
5807 |
|
5808 |
|
5809 |
|
5810 | if (spec.hasOwnProperty(MIXINS_KEY)) {
|
5811 | RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
|
5812 | }
|
5813 |
|
5814 | for (var name in spec) {
|
5815 | if (!spec.hasOwnProperty(name)) {
|
5816 | continue;
|
5817 | }
|
5818 |
|
5819 | if (name === MIXINS_KEY) {
|
5820 |
|
5821 | continue;
|
5822 | }
|
5823 |
|
5824 | var property = spec[name];
|
5825 | validateMethodOverride(proto, name);
|
5826 |
|
5827 | if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
|
5828 | RESERVED_SPEC_KEYS[name](Constructor, property);
|
5829 | } else {
|
5830 |
|
5831 |
|
5832 |
|
5833 |
|
5834 | var isCompositeComponentMethod =
|
5835 | ReactCompositeComponentInterface.hasOwnProperty(name);
|
5836 | var isAlreadyDefined = proto.hasOwnProperty(name);
|
5837 | var markedDontBind = property && property.__reactDontBind;
|
5838 | var isFunction = typeof property === 'function';
|
5839 | var shouldAutoBind =
|
5840 | isFunction &&
|
5841 | !isCompositeComponentMethod &&
|
5842 | !isAlreadyDefined &&
|
5843 | !markedDontBind;
|
5844 |
|
5845 | if (shouldAutoBind) {
|
5846 | if (!proto.__reactAutoBindMap) {
|
5847 | proto.__reactAutoBindMap = {};
|
5848 | }
|
5849 | proto.__reactAutoBindMap[name] = property;
|
5850 | proto[name] = property;
|
5851 | } else {
|
5852 | if (isAlreadyDefined) {
|
5853 | var specPolicy = ReactCompositeComponentInterface[name];
|
5854 |
|
5855 |
|
5856 | ("production" !== "development" ? invariant(
|
5857 | isCompositeComponentMethod && (
|
5858 | specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
|
5859 | specPolicy === SpecPolicy.DEFINE_MANY
|
5860 | ),
|
5861 | 'ReactCompositeComponent: Unexpected spec policy %s for key %s ' +
|
5862 | 'when mixing in component specs.',
|
5863 | specPolicy,
|
5864 | name
|
5865 | ) : invariant(isCompositeComponentMethod && (
|
5866 | specPolicy === SpecPolicy.DEFINE_MANY_MERGED ||
|
5867 | specPolicy === SpecPolicy.DEFINE_MANY
|
5868 | )));
|
5869 |
|
5870 |
|
5871 |
|
5872 | if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
|
5873 | proto[name] = createMergedResultFunction(proto[name], property);
|
5874 | } else if (specPolicy === SpecPolicy.DEFINE_MANY) {
|
5875 | proto[name] = createChainedFunction(proto[name], property);
|
5876 | }
|
5877 | } else {
|
5878 | proto[name] = property;
|
5879 | if ("production" !== "development") {
|
5880 |
|
5881 |
|
5882 | if (typeof property === 'function' && spec.displayName) {
|
5883 | proto[name].displayName = spec.displayName + '_' + name;
|
5884 | }
|
5885 | }
|
5886 | }
|
5887 | }
|
5888 | }
|
5889 | }
|
5890 | }
|
5891 |
|
5892 | function mixStaticSpecIntoComponent(Constructor, statics) {
|
5893 | if (!statics) {
|
5894 | return;
|
5895 | }
|
5896 | for (var name in statics) {
|
5897 | var property = statics[name];
|
5898 | if (!statics.hasOwnProperty(name)) {
|
5899 | continue;
|
5900 | }
|
5901 |
|
5902 | var isReserved = name in RESERVED_SPEC_KEYS;
|
5903 | ("production" !== "development" ? invariant(
|
5904 | !isReserved,
|
5905 | 'ReactCompositeComponent: You are attempting to define a reserved ' +
|
5906 | 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
|
5907 | 'as an instance property instead; it will still be accessible on the ' +
|
5908 | 'constructor.',
|
5909 | name
|
5910 | ) : invariant(!isReserved));
|
5911 |
|
5912 | var isInherited = name in Constructor;
|
5913 | ("production" !== "development" ? invariant(
|
5914 | !isInherited,
|
5915 | 'ReactCompositeComponent: You are attempting to define ' +
|
5916 | '`%s` on your component more than once. This conflict may be ' +
|
5917 | 'due to a mixin.',
|
5918 | name
|
5919 | ) : invariant(!isInherited));
|
5920 | Constructor[name] = property;
|
5921 | }
|
5922 | }
|
5923 |
|
5924 |
|
5925 |
|
5926 |
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 | function mergeObjectsWithNoDuplicateKeys(one, two) {
|
5932 | ("production" !== "development" ? invariant(
|
5933 | one && two && typeof one === 'object' && typeof two === 'object',
|
5934 | 'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects'
|
5935 | ) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
|
5936 |
|
5937 | mapObject(two, function(value, key) {
|
5938 | ("production" !== "development" ? invariant(
|
5939 | one[key] === undefined,
|
5940 | 'mergeObjectsWithNoDuplicateKeys(): ' +
|
5941 | 'Tried to merge two objects with the same key: `%s`. This conflict ' +
|
5942 | 'may be due to a mixin; in particular, this may be caused by two ' +
|
5943 | 'getInitialState() or getDefaultProps() methods returning objects ' +
|
5944 | 'with clashing keys.',
|
5945 | key
|
5946 | ) : invariant(one[key] === undefined));
|
5947 | one[key] = value;
|
5948 | });
|
5949 | return one;
|
5950 | }
|
5951 |
|
5952 |
|
5953 |
|
5954 |
|
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 | function createMergedResultFunction(one, two) {
|
5961 | return function mergedResult() {
|
5962 | var a = one.apply(this, arguments);
|
5963 | var b = two.apply(this, arguments);
|
5964 | if (a == null) {
|
5965 | return b;
|
5966 | } else if (b == null) {
|
5967 | return a;
|
5968 | }
|
5969 | return mergeObjectsWithNoDuplicateKeys(a, b);
|
5970 | };
|
5971 | }
|
5972 |
|
5973 |
|
5974 |
|
5975 |
|
5976 |
|
5977 |
|
5978 |
|
5979 |
|
5980 |
|
5981 | function createChainedFunction(one, two) {
|
5982 | return function chainedFunction() {
|
5983 | one.apply(this, arguments);
|
5984 | two.apply(this, arguments);
|
5985 | };
|
5986 | }
|
5987 |
|
5988 |
|
5989 |
|
5990 |
|
5991 |
|
5992 |
|
5993 |
|
5994 |
|
5995 |
|
5996 |
|
5997 |
|
5998 |
|
5999 |
|
6000 |
|
6001 |
|
6002 |
|
6003 |
|
6004 |
|
6005 |
|
6006 |
|
6007 |
|
6008 |
|
6009 |
|
6010 |
|
6011 |
|
6012 |
|
6013 |
|
6014 | var CompositeLifeCycle = keyMirror({
|
6015 | |
6016 |
|
6017 |
|
6018 |
|
6019 | MOUNTING: null,
|
6020 | |
6021 |
|
6022 |
|
6023 |
|
6024 | UNMOUNTING: null,
|
6025 | |
6026 |
|
6027 |
|
6028 |
|
6029 | RECEIVING_PROPS: null
|
6030 | });
|
6031 |
|
6032 |
|
6033 |
|
6034 |
|
6035 | var ReactCompositeComponentMixin = {
|
6036 |
|
6037 | |
6038 |
|
6039 |
|
6040 |
|
6041 |
|
6042 |
|
6043 |
|
6044 | construct: function(element) {
|
6045 |
|
6046 | ReactComponent.Mixin.construct.apply(this, arguments);
|
6047 | ReactOwner.Mixin.construct.apply(this, arguments);
|
6048 |
|
6049 | this.state = null;
|
6050 | this._pendingState = null;
|
6051 |
|
6052 |
|
6053 |
|
6054 | this.context = null;
|
6055 |
|
6056 | this._compositeLifeCycleState = null;
|
6057 | },
|
6058 |
|
6059 | |
6060 |
|
6061 |
|
6062 |
|
6063 |
|
6064 |
|
6065 | isMounted: function() {
|
6066 | return ReactComponent.Mixin.isMounted.call(this) &&
|
6067 | this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING;
|
6068 | },
|
6069 |
|
6070 | |
6071 |
|
6072 |
|
6073 |
|
6074 |
|
6075 |
|
6076 |
|
6077 |
|
6078 |
|
6079 |
|
6080 | mountComponent: ReactPerf.measure(
|
6081 | 'ReactCompositeComponent',
|
6082 | 'mountComponent',
|
6083 | function(rootID, transaction, mountDepth) {
|
6084 | ReactComponent.Mixin.mountComponent.call(
|
6085 | this,
|
6086 | rootID,
|
6087 | transaction,
|
6088 | mountDepth
|
6089 | );
|
6090 | this._compositeLifeCycleState = CompositeLifeCycle.MOUNTING;
|
6091 |
|
6092 | if (this.__reactAutoBindMap) {
|
6093 | this._bindAutoBindMethods();
|
6094 | }
|
6095 |
|
6096 | this.context = this._processContext(this._currentElement._context);
|
6097 | this.props = this._processProps(this.props);
|
6098 |
|
6099 | this.state = this.getInitialState ? this.getInitialState() : null;
|
6100 | ("production" !== "development" ? invariant(
|
6101 | typeof this.state === 'object' && !Array.isArray(this.state),
|
6102 | '%s.getInitialState(): must return an object or null',
|
6103 | this.constructor.displayName || 'ReactCompositeComponent'
|
6104 | ) : invariant(typeof this.state === 'object' && !Array.isArray(this.state)));
|
6105 |
|
6106 | this._pendingState = null;
|
6107 | this._pendingForceUpdate = false;
|
6108 |
|
6109 | if (this.componentWillMount) {
|
6110 | this.componentWillMount();
|
6111 |
|
6112 |
|
6113 | if (this._pendingState) {
|
6114 | this.state = this._pendingState;
|
6115 | this._pendingState = null;
|
6116 | }
|
6117 | }
|
6118 |
|
6119 | this._renderedComponent = instantiateReactComponent(
|
6120 | this._renderValidatedComponent(),
|
6121 | this._currentElement.type
|
6122 | );
|
6123 |
|
6124 |
|
6125 | this._compositeLifeCycleState = null;
|
6126 | var markup = this._renderedComponent.mountComponent(
|
6127 | rootID,
|
6128 | transaction,
|
6129 | mountDepth + 1
|
6130 | );
|
6131 | if (this.componentDidMount) {
|
6132 | transaction.getReactMountReady().enqueue(this.componentDidMount, this);
|
6133 | }
|
6134 | return markup;
|
6135 | }
|
6136 | ),
|
6137 |
|
6138 | |
6139 |
|
6140 |
|
6141 |
|
6142 |
|
6143 |
|
6144 | unmountComponent: function() {
|
6145 | this._compositeLifeCycleState = CompositeLifeCycle.UNMOUNTING;
|
6146 | if (this.componentWillUnmount) {
|
6147 | this.componentWillUnmount();
|
6148 | }
|
6149 | this._compositeLifeCycleState = null;
|
6150 |
|
6151 | this._renderedComponent.unmountComponent();
|
6152 | this._renderedComponent = null;
|
6153 |
|
6154 | ReactComponent.Mixin.unmountComponent.call(this);
|
6155 |
|
6156 |
|
6157 |
|
6158 |
|
6159 |
|
6160 | },
|
6161 |
|
6162 | |
6163 |
|
6164 |
|
6165 |
|
6166 |
|
6167 |
|
6168 |
|
6169 |
|
6170 |
|
6171 |
|
6172 |
|
6173 |
|
6174 |
|
6175 |
|
6176 |
|
6177 |
|
6178 |
|
6179 | setState: function(partialState, callback) {
|
6180 | ("production" !== "development" ? invariant(
|
6181 | typeof partialState === 'object' || partialState == null,
|
6182 | 'setState(...): takes an object of state variables to update.'
|
6183 | ) : invariant(typeof partialState === 'object' || partialState == null));
|
6184 | if ("production" !== "development"){
|
6185 | ("production" !== "development" ? warning(
|
6186 | partialState != null,
|
6187 | 'setState(...): You passed an undefined or null state object; ' +
|
6188 | 'instead, use forceUpdate().'
|
6189 | ) : null);
|
6190 | }
|
6191 |
|
6192 | this.replaceState(
|
6193 | assign({}, this._pendingState || this.state, partialState),
|
6194 | callback
|
6195 | );
|
6196 | },
|
6197 |
|
6198 | |
6199 |
|
6200 |
|
6201 |
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 |
|
6207 |
|
6208 |
|
6209 |
|
6210 | replaceState: function(completeState, callback) {
|
6211 | validateLifeCycleOnReplaceState(this);
|
6212 | this._pendingState = completeState;
|
6213 | if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) {
|
6214 |
|
6215 |
|
6216 |
|
6217 |
|
6218 |
|
6219 |
|
6220 | ReactUpdates.enqueueUpdate(this, callback);
|
6221 | }
|
6222 | },
|
6223 |
|
6224 | |
6225 |
|
6226 |
|
6227 |
|
6228 |
|
6229 |
|
6230 |
|
6231 |
|
6232 | _processContext: function(context) {
|
6233 | var maskedContext = null;
|
6234 | var contextTypes = this.constructor.contextTypes;
|
6235 | if (contextTypes) {
|
6236 | maskedContext = {};
|
6237 | for (var contextName in contextTypes) {
|
6238 | maskedContext[contextName] = context[contextName];
|
6239 | }
|
6240 | if ("production" !== "development") {
|
6241 | this._checkPropTypes(
|
6242 | contextTypes,
|
6243 | maskedContext,
|
6244 | ReactPropTypeLocations.context
|
6245 | );
|
6246 | }
|
6247 | }
|
6248 | return maskedContext;
|
6249 | },
|
6250 |
|
6251 | |
6252 |
|
6253 |
|
6254 |
|
6255 |
|
6256 | _processChildContext: function(currentContext) {
|
6257 | var childContext = this.getChildContext && this.getChildContext();
|
6258 | var displayName = this.constructor.displayName || 'ReactCompositeComponent';
|
6259 | if (childContext) {
|
6260 | ("production" !== "development" ? invariant(
|
6261 | typeof this.constructor.childContextTypes === 'object',
|
6262 | '%s.getChildContext(): childContextTypes must be defined in order to ' +
|
6263 | 'use getChildContext().',
|
6264 | displayName
|
6265 | ) : invariant(typeof this.constructor.childContextTypes === 'object'));
|
6266 | if ("production" !== "development") {
|
6267 | this._checkPropTypes(
|
6268 | this.constructor.childContextTypes,
|
6269 | childContext,
|
6270 | ReactPropTypeLocations.childContext
|
6271 | );
|
6272 | }
|
6273 | for (var name in childContext) {
|
6274 | ("production" !== "development" ? invariant(
|
6275 | name in this.constructor.childContextTypes,
|
6276 | '%s.getChildContext(): key "%s" is not defined in childContextTypes.',
|
6277 | displayName,
|
6278 | name
|
6279 | ) : invariant(name in this.constructor.childContextTypes));
|
6280 | }
|
6281 | return assign({}, currentContext, childContext);
|
6282 | }
|
6283 | return currentContext;
|
6284 | },
|
6285 |
|
6286 | |
6287 |
|
6288 |
|
6289 |
|
6290 |
|
6291 |
|
6292 |
|
6293 |
|
6294 |
|
6295 | _processProps: function(newProps) {
|
6296 | if ("production" !== "development") {
|
6297 | var propTypes = this.constructor.propTypes;
|
6298 | if (propTypes) {
|
6299 | this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
|
6300 | }
|
6301 | }
|
6302 | return newProps;
|
6303 | },
|
6304 |
|
6305 | |
6306 |
|
6307 |
|
6308 |
|
6309 |
|
6310 |
|
6311 |
|
6312 |
|
6313 | _checkPropTypes: function(propTypes, props, location) {
|
6314 |
|
6315 |
|
6316 | var componentName = this.constructor.displayName;
|
6317 | for (var propName in propTypes) {
|
6318 | if (propTypes.hasOwnProperty(propName)) {
|
6319 | var error =
|
6320 | propTypes[propName](props, propName, componentName, location);
|
6321 | if (error instanceof Error) {
|
6322 |
|
6323 |
|
6324 |
|
6325 | var addendum = getDeclarationErrorAddendum(this);
|
6326 | ("production" !== "development" ? warning(false, error.message + addendum) : null);
|
6327 | }
|
6328 | }
|
6329 | }
|
6330 | },
|
6331 |
|
6332 | |
6333 |
|
6334 |
|
6335 |
|
6336 |
|
6337 |
|
6338 |
|
6339 | performUpdateIfNecessary: function(transaction) {
|
6340 | var compositeLifeCycleState = this._compositeLifeCycleState;
|
6341 |
|
6342 |
|
6343 | if (compositeLifeCycleState === CompositeLifeCycle.MOUNTING ||
|
6344 | compositeLifeCycleState === CompositeLifeCycle.RECEIVING_PROPS) {
|
6345 | return;
|
6346 | }
|
6347 |
|
6348 | if (this._pendingElement == null &&
|
6349 | this._pendingState == null &&
|
6350 | !this._pendingForceUpdate) {
|
6351 | return;
|
6352 | }
|
6353 |
|
6354 | var nextContext = this.context;
|
6355 | var nextProps = this.props;
|
6356 | var nextElement = this._currentElement;
|
6357 | if (this._pendingElement != null) {
|
6358 | nextElement = this._pendingElement;
|
6359 | nextContext = this._processContext(nextElement._context);
|
6360 | nextProps = this._processProps(nextElement.props);
|
6361 | this._pendingElement = null;
|
6362 |
|
6363 | this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
|
6364 | if (this.componentWillReceiveProps) {
|
6365 | this.componentWillReceiveProps(nextProps, nextContext);
|
6366 | }
|
6367 | }
|
6368 |
|
6369 | this._compositeLifeCycleState = null;
|
6370 |
|
6371 | var nextState = this._pendingState || this.state;
|
6372 | this._pendingState = null;
|
6373 |
|
6374 | var shouldUpdate =
|
6375 | this._pendingForceUpdate ||
|
6376 | !this.shouldComponentUpdate ||
|
6377 | this.shouldComponentUpdate(nextProps, nextState, nextContext);
|
6378 |
|
6379 | if ("production" !== "development") {
|
6380 | if (typeof shouldUpdate === "undefined") {
|
6381 | console.warn(
|
6382 | (this.constructor.displayName || 'ReactCompositeComponent') +
|
6383 | '.shouldComponentUpdate(): Returned undefined instead of a ' +
|
6384 | 'boolean value. Make sure to return true or false.'
|
6385 | );
|
6386 | }
|
6387 | }
|
6388 |
|
6389 | if (shouldUpdate) {
|
6390 | this._pendingForceUpdate = false;
|
6391 |
|
6392 | this._performComponentUpdate(
|
6393 | nextElement,
|
6394 | nextProps,
|
6395 | nextState,
|
6396 | nextContext,
|
6397 | transaction
|
6398 | );
|
6399 | } else {
|
6400 |
|
6401 |
|
6402 | this._currentElement = nextElement;
|
6403 | this.props = nextProps;
|
6404 | this.state = nextState;
|
6405 | this.context = nextContext;
|
6406 |
|
6407 |
|
6408 |
|
6409 | this._owner = nextElement._owner;
|
6410 | }
|
6411 | },
|
6412 |
|
6413 | |
6414 |
|
6415 |
|
6416 |
|
6417 |
|
6418 |
|
6419 |
|
6420 |
|
6421 |
|
6422 |
|
6423 |
|
6424 | _performComponentUpdate: function(
|
6425 | nextElement,
|
6426 | nextProps,
|
6427 | nextState,
|
6428 | nextContext,
|
6429 | transaction
|
6430 | ) {
|
6431 | var prevElement = this._currentElement;
|
6432 | var prevProps = this.props;
|
6433 | var prevState = this.state;
|
6434 | var prevContext = this.context;
|
6435 |
|
6436 | if (this.componentWillUpdate) {
|
6437 | this.componentWillUpdate(nextProps, nextState, nextContext);
|
6438 | }
|
6439 |
|
6440 | this._currentElement = nextElement;
|
6441 | this.props = nextProps;
|
6442 | this.state = nextState;
|
6443 | this.context = nextContext;
|
6444 |
|
6445 |
|
6446 |
|
6447 | this._owner = nextElement._owner;
|
6448 |
|
6449 | this.updateComponent(
|
6450 | transaction,
|
6451 | prevElement
|
6452 | );
|
6453 |
|
6454 | if (this.componentDidUpdate) {
|
6455 | transaction.getReactMountReady().enqueue(
|
6456 | this.componentDidUpdate.bind(this, prevProps, prevState, prevContext),
|
6457 | this
|
6458 | );
|
6459 | }
|
6460 | },
|
6461 |
|
6462 | receiveComponent: function(nextElement, transaction) {
|
6463 | if (nextElement === this._currentElement &&
|
6464 | nextElement._owner != null) {
|
6465 |
|
6466 |
|
6467 |
|
6468 |
|
6469 |
|
6470 |
|
6471 |
|
6472 | return;
|
6473 | }
|
6474 |
|
6475 | ReactComponent.Mixin.receiveComponent.call(
|
6476 | this,
|
6477 | nextElement,
|
6478 | transaction
|
6479 | );
|
6480 | },
|
6481 |
|
6482 | |
6483 |
|
6484 |
|
6485 |
|
6486 |
|
6487 |
|
6488 |
|
6489 |
|
6490 |
|
6491 |
|
6492 |
|
6493 | updateComponent: ReactPerf.measure(
|
6494 | 'ReactCompositeComponent',
|
6495 | 'updateComponent',
|
6496 | function(transaction, prevParentElement) {
|
6497 | ReactComponent.Mixin.updateComponent.call(
|
6498 | this,
|
6499 | transaction,
|
6500 | prevParentElement
|
6501 | );
|
6502 |
|
6503 | var prevComponentInstance = this._renderedComponent;
|
6504 | var prevElement = prevComponentInstance._currentElement;
|
6505 | var nextElement = this._renderValidatedComponent();
|
6506 | if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
6507 | prevComponentInstance.receiveComponent(nextElement, transaction);
|
6508 | } else {
|
6509 |
|
6510 | var thisID = this._rootNodeID;
|
6511 | var prevComponentID = prevComponentInstance._rootNodeID;
|
6512 | prevComponentInstance.unmountComponent();
|
6513 | this._renderedComponent = instantiateReactComponent(
|
6514 | nextElement,
|
6515 | this._currentElement.type
|
6516 | );
|
6517 | var nextMarkup = this._renderedComponent.mountComponent(
|
6518 | thisID,
|
6519 | transaction,
|
6520 | this._mountDepth + 1
|
6521 | );
|
6522 | ReactComponent.BackendIDOperations.dangerouslyReplaceNodeWithMarkupByID(
|
6523 | prevComponentID,
|
6524 | nextMarkup
|
6525 | );
|
6526 | }
|
6527 | }
|
6528 | ),
|
6529 |
|
6530 | |
6531 |
|
6532 |
|
6533 |
|
6534 |
|
6535 |
|
6536 |
|
6537 |
|
6538 |
|
6539 |
|
6540 |
|
6541 |
|
6542 |
|
6543 |
|
6544 | forceUpdate: function(callback) {
|
6545 | var compositeLifeCycleState = this._compositeLifeCycleState;
|
6546 | ("production" !== "development" ? invariant(
|
6547 | this.isMounted() ||
|
6548 | compositeLifeCycleState === CompositeLifeCycle.MOUNTING,
|
6549 | 'forceUpdate(...): Can only force an update on mounted or mounting ' +
|
6550 | 'components.'
|
6551 | ) : invariant(this.isMounted() ||
|
6552 | compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
|
6553 | ("production" !== "development" ? invariant(
|
6554 | compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
|
6555 | ReactCurrentOwner.current == null,
|
6556 | 'forceUpdate(...): Cannot force an update while unmounting component ' +
|
6557 | 'or within a `render` function.'
|
6558 | ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
|
6559 | ReactCurrentOwner.current == null));
|
6560 | this._pendingForceUpdate = true;
|
6561 | ReactUpdates.enqueueUpdate(this, callback);
|
6562 | },
|
6563 |
|
6564 | |
6565 |
|
6566 |
|
6567 | _renderValidatedComponent: ReactPerf.measure(
|
6568 | 'ReactCompositeComponent',
|
6569 | '_renderValidatedComponent',
|
6570 | function() {
|
6571 | var renderedComponent;
|
6572 | var previousContext = ReactContext.current;
|
6573 | ReactContext.current = this._processChildContext(
|
6574 | this._currentElement._context
|
6575 | );
|
6576 | ReactCurrentOwner.current = this;
|
6577 | try {
|
6578 | renderedComponent = this.render();
|
6579 | if (renderedComponent === null || renderedComponent === false) {
|
6580 | renderedComponent = ReactEmptyComponent.getEmptyComponent();
|
6581 | ReactEmptyComponent.registerNullComponentID(this._rootNodeID);
|
6582 | } else {
|
6583 | ReactEmptyComponent.deregisterNullComponentID(this._rootNodeID);
|
6584 | }
|
6585 | } finally {
|
6586 | ReactContext.current = previousContext;
|
6587 | ReactCurrentOwner.current = null;
|
6588 | }
|
6589 | ("production" !== "development" ? invariant(
|
6590 | ReactElement.isValidElement(renderedComponent),
|
6591 | '%s.render(): A valid ReactComponent must be returned. You may have ' +
|
6592 | 'returned undefined, an array or some other invalid object.',
|
6593 | this.constructor.displayName || 'ReactCompositeComponent'
|
6594 | ) : invariant(ReactElement.isValidElement(renderedComponent)));
|
6595 | return renderedComponent;
|
6596 | }
|
6597 | ),
|
6598 |
|
6599 | |
6600 |
|
6601 |
|
6602 | _bindAutoBindMethods: function() {
|
6603 | for (var autoBindKey in this.__reactAutoBindMap) {
|
6604 | if (!this.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
|
6605 | continue;
|
6606 | }
|
6607 | var method = this.__reactAutoBindMap[autoBindKey];
|
6608 | this[autoBindKey] = this._bindAutoBindMethod(ReactErrorUtils.guard(
|
6609 | method,
|
6610 | this.constructor.displayName + '.' + autoBindKey
|
6611 | ));
|
6612 | }
|
6613 | },
|
6614 |
|
6615 | |
6616 |
|
6617 |
|
6618 |
|
6619 |
|
6620 |
|
6621 | _bindAutoBindMethod: function(method) {
|
6622 | var component = this;
|
6623 | var boundMethod = method.bind(component);
|
6624 | if ("production" !== "development") {
|
6625 | boundMethod.__reactBoundContext = component;
|
6626 | boundMethod.__reactBoundMethod = method;
|
6627 | boundMethod.__reactBoundArguments = null;
|
6628 | var componentName = component.constructor.displayName;
|
6629 | var _bind = boundMethod.bind;
|
6630 | boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
6631 |
|
6632 |
|
6633 |
|
6634 | if (newThis !== component && newThis !== null) {
|
6635 | monitorCodeUse('react_bind_warning', { component: componentName });
|
6636 | console.warn(
|
6637 | 'bind(): React component methods may only be bound to the ' +
|
6638 | 'component instance. See ' + componentName
|
6639 | );
|
6640 | } else if (!args.length) {
|
6641 | monitorCodeUse('react_bind_warning', { component: componentName });
|
6642 | console.warn(
|
6643 | 'bind(): You are binding a component method to the component. ' +
|
6644 | 'React does this for you automatically in a high-performance ' +
|
6645 | 'way, so you can safely remove this call. See ' + componentName
|
6646 | );
|
6647 | return boundMethod;
|
6648 | }
|
6649 | var reboundMethod = _bind.apply(boundMethod, arguments);
|
6650 | reboundMethod.__reactBoundContext = component;
|
6651 | reboundMethod.__reactBoundMethod = method;
|
6652 | reboundMethod.__reactBoundArguments = args;
|
6653 | return reboundMethod;
|
6654 | };
|
6655 | }
|
6656 | return boundMethod;
|
6657 | }
|
6658 | };
|
6659 |
|
6660 | var ReactCompositeComponentBase = function() {};
|
6661 | assign(
|
6662 | ReactCompositeComponentBase.prototype,
|
6663 | ReactComponent.Mixin,
|
6664 | ReactOwner.Mixin,
|
6665 | ReactPropTransferer.Mixin,
|
6666 | ReactCompositeComponentMixin
|
6667 | );
|
6668 |
|
6669 |
|
6670 |
|
6671 |
|
6672 |
|
6673 |
|
6674 |
|
6675 |
|
6676 |
|
6677 | var ReactCompositeComponent = {
|
6678 |
|
6679 | LifeCycle: CompositeLifeCycle,
|
6680 |
|
6681 | Base: ReactCompositeComponentBase,
|
6682 |
|
6683 | |
6684 |
|
6685 |
|
6686 |
|
6687 |
|
6688 |
|
6689 |
|
6690 | createClass: function(spec) {
|
6691 | var Constructor = function(props) {
|
6692 |
|
6693 |
|
6694 |
|
6695 | };
|
6696 | Constructor.prototype = new ReactCompositeComponentBase();
|
6697 | Constructor.prototype.constructor = Constructor;
|
6698 |
|
6699 | injectedMixins.forEach(
|
6700 | mixSpecIntoComponent.bind(null, Constructor)
|
6701 | );
|
6702 |
|
6703 | mixSpecIntoComponent(Constructor, spec);
|
6704 |
|
6705 |
|
6706 | if (Constructor.getDefaultProps) {
|
6707 | Constructor.defaultProps = Constructor.getDefaultProps();
|
6708 | }
|
6709 |
|
6710 | ("production" !== "development" ? invariant(
|
6711 | Constructor.prototype.render,
|
6712 | 'createClass(...): Class specification must implement a `render` method.'
|
6713 | ) : invariant(Constructor.prototype.render));
|
6714 |
|
6715 | if ("production" !== "development") {
|
6716 | if (Constructor.prototype.componentShouldUpdate) {
|
6717 | monitorCodeUse(
|
6718 | 'react_component_should_update_warning',
|
6719 | { component: spec.displayName }
|
6720 | );
|
6721 | console.warn(
|
6722 | (spec.displayName || 'A component') + ' has a method called ' +
|
6723 | 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
6724 | 'The name is phrased as a question because the function is ' +
|
6725 | 'expected to return a value.'
|
6726 | );
|
6727 | }
|
6728 | }
|
6729 |
|
6730 |
|
6731 | for (var methodName in ReactCompositeComponentInterface) {
|
6732 | if (!Constructor.prototype[methodName]) {
|
6733 | Constructor.prototype[methodName] = null;
|
6734 | }
|
6735 | }
|
6736 |
|
6737 | if ("production" !== "development") {
|
6738 | return ReactLegacyElement.wrapFactory(
|
6739 | ReactElementValidator.createFactory(Constructor)
|
6740 | );
|
6741 | }
|
6742 | return ReactLegacyElement.wrapFactory(
|
6743 | ReactElement.createFactory(Constructor)
|
6744 | );
|
6745 | },
|
6746 |
|
6747 | injection: {
|
6748 | injectMixin: function(mixin) {
|
6749 | injectedMixins.push(mixin);
|
6750 | }
|
6751 | }
|
6752 | };
|
6753 |
|
6754 | module.exports = ReactCompositeComponent;
|
6755 |
|
6756 | },{"./Object.assign":27,"./ReactComponent":32,"./ReactContext":35,"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactElementValidator":53,"./ReactEmptyComponent":54,"./ReactErrorUtils":55,"./ReactLegacyElement":61,"./ReactOwner":67,"./ReactPerf":68,"./ReactPropTransferer":69,"./ReactPropTypeLocationNames":70,"./ReactPropTypeLocations":71,"./ReactUpdates":79,"./instantiateReactComponent":125,"./invariant":126,"./keyMirror":132,"./keyOf":133,"./mapObject":134,"./monitorCodeUse":136,"./shouldUpdateReactComponent":142,"./warning":145}],35:[function(_dereq_,module,exports){
|
6757 |
|
6758 |
|
6759 |
|
6760 |
|
6761 |
|
6762 |
|
6763 |
|
6764 |
|
6765 |
|
6766 |
|
6767 |
|
6768 | "use strict";
|
6769 |
|
6770 | var assign = _dereq_("./Object.assign");
|
6771 |
|
6772 |
|
6773 |
|
6774 |
|
6775 |
|
6776 |
|
6777 |
|
6778 | var ReactContext = {
|
6779 |
|
6780 | |
6781 |
|
6782 |
|
6783 |
|
6784 | current: {},
|
6785 |
|
6786 | |
6787 |
|
6788 |
|
6789 |
|
6790 |
|
6791 |
|
6792 |
|
6793 |
|
6794 |
|
6795 |
|
6796 |
|
6797 |
|
6798 |
|
6799 |
|
6800 |
|
6801 |
|
6802 | withContext: function(newContext, scopedCallback) {
|
6803 | var result;
|
6804 | var previousContext = ReactContext.current;
|
6805 | ReactContext.current = assign({}, previousContext, newContext);
|
6806 | try {
|
6807 | result = scopedCallback();
|
6808 | } finally {
|
6809 | ReactContext.current = previousContext;
|
6810 | }
|
6811 | return result;
|
6812 | }
|
6813 |
|
6814 | };
|
6815 |
|
6816 | module.exports = ReactContext;
|
6817 |
|
6818 | },{"./Object.assign":27}],36:[function(_dereq_,module,exports){
|
6819 |
|
6820 |
|
6821 |
|
6822 |
|
6823 |
|
6824 |
|
6825 |
|
6826 |
|
6827 |
|
6828 |
|
6829 |
|
6830 | "use strict";
|
6831 |
|
6832 |
|
6833 |
|
6834 |
|
6835 |
|
6836 |
|
6837 |
|
6838 |
|
6839 |
|
6840 | var ReactCurrentOwner = {
|
6841 |
|
6842 | |
6843 |
|
6844 |
|
6845 |
|
6846 | current: null
|
6847 |
|
6848 | };
|
6849 |
|
6850 | module.exports = ReactCurrentOwner;
|
6851 |
|
6852 | },{}],37:[function(_dereq_,module,exports){
|
6853 |
|
6854 |
|
6855 |
|
6856 |
|
6857 |
|
6858 |
|
6859 |
|
6860 |
|
6861 |
|
6862 |
|
6863 |
|
6864 |
|
6865 | "use strict";
|
6866 |
|
6867 | var ReactElement = _dereq_("./ReactElement");
|
6868 | var ReactElementValidator = _dereq_("./ReactElementValidator");
|
6869 | var ReactLegacyElement = _dereq_("./ReactLegacyElement");
|
6870 |
|
6871 | var mapObject = _dereq_("./mapObject");
|
6872 |
|
6873 |
|
6874 |
|
6875 |
|
6876 |
|
6877 |
|
6878 |
|
6879 | function createDOMFactory(tag) {
|
6880 | if ("production" !== "development") {
|
6881 | return ReactLegacyElement.markNonLegacyFactory(
|
6882 | ReactElementValidator.createFactory(tag)
|
6883 | );
|
6884 | }
|
6885 | return ReactLegacyElement.markNonLegacyFactory(
|
6886 | ReactElement.createFactory(tag)
|
6887 | );
|
6888 | }
|
6889 |
|
6890 |
|
6891 |
|
6892 |
|
6893 |
|
6894 |
|
6895 |
|
6896 | var ReactDOM = mapObject({
|
6897 | a: 'a',
|
6898 | abbr: 'abbr',
|
6899 | address: 'address',
|
6900 | area: 'area',
|
6901 | article: 'article',
|
6902 | aside: 'aside',
|
6903 | audio: 'audio',
|
6904 | b: 'b',
|
6905 | base: 'base',
|
6906 | bdi: 'bdi',
|
6907 | bdo: 'bdo',
|
6908 | big: 'big',
|
6909 | blockquote: 'blockquote',
|
6910 | body: 'body',
|
6911 | br: 'br',
|
6912 | button: 'button',
|
6913 | canvas: 'canvas',
|
6914 | caption: 'caption',
|
6915 | cite: 'cite',
|
6916 | code: 'code',
|
6917 | col: 'col',
|
6918 | colgroup: 'colgroup',
|
6919 | data: 'data',
|
6920 | datalist: 'datalist',
|
6921 | dd: 'dd',
|
6922 | del: 'del',
|
6923 | details: 'details',
|
6924 | dfn: 'dfn',
|
6925 | dialog: 'dialog',
|
6926 | div: 'div',
|
6927 | dl: 'dl',
|
6928 | dt: 'dt',
|
6929 | em: 'em',
|
6930 | embed: 'embed',
|
6931 | fieldset: 'fieldset',
|
6932 | figcaption: 'figcaption',
|
6933 | figure: 'figure',
|
6934 | footer: 'footer',
|
6935 | form: 'form',
|
6936 | h1: 'h1',
|
6937 | h2: 'h2',
|
6938 | h3: 'h3',
|
6939 | h4: 'h4',
|
6940 | h5: 'h5',
|
6941 | h6: 'h6',
|
6942 | head: 'head',
|
6943 | header: 'header',
|
6944 | hr: 'hr',
|
6945 | html: 'html',
|
6946 | i: 'i',
|
6947 | iframe: 'iframe',
|
6948 | img: 'img',
|
6949 | input: 'input',
|
6950 | ins: 'ins',
|
6951 | kbd: 'kbd',
|
6952 | keygen: 'keygen',
|
6953 | label: 'label',
|
6954 | legend: 'legend',
|
6955 | li: 'li',
|
6956 | link: 'link',
|
6957 | main: 'main',
|
6958 | map: 'map',
|
6959 | mark: 'mark',
|
6960 | menu: 'menu',
|
6961 | menuitem: 'menuitem',
|
6962 | meta: 'meta',
|
6963 | meter: 'meter',
|
6964 | nav: 'nav',
|
6965 | noscript: 'noscript',
|
6966 | object: 'object',
|
6967 | ol: 'ol',
|
6968 | optgroup: 'optgroup',
|
6969 | option: 'option',
|
6970 | output: 'output',
|
6971 | p: 'p',
|
6972 | param: 'param',
|
6973 | picture: 'picture',
|
6974 | pre: 'pre',
|
6975 | progress: 'progress',
|
6976 | q: 'q',
|
6977 | rp: 'rp',
|
6978 | rt: 'rt',
|
6979 | ruby: 'ruby',
|
6980 | s: 's',
|
6981 | samp: 'samp',
|
6982 | script: 'script',
|
6983 | section: 'section',
|
6984 | select: 'select',
|
6985 | small: 'small',
|
6986 | source: 'source',
|
6987 | span: 'span',
|
6988 | strong: 'strong',
|
6989 | style: 'style',
|
6990 | sub: 'sub',
|
6991 | summary: 'summary',
|
6992 | sup: 'sup',
|
6993 | table: 'table',
|
6994 | tbody: 'tbody',
|
6995 | td: 'td',
|
6996 | textarea: 'textarea',
|
6997 | tfoot: 'tfoot',
|
6998 | th: 'th',
|
6999 | thead: 'thead',
|
7000 | time: 'time',
|
7001 | title: 'title',
|
7002 | tr: 'tr',
|
7003 | track: 'track',
|
7004 | u: 'u',
|
7005 | ul: 'ul',
|
7006 | 'var': 'var',
|
7007 | video: 'video',
|
7008 | wbr: 'wbr',
|
7009 |
|
7010 |
|
7011 | circle: 'circle',
|
7012 | defs: 'defs',
|
7013 | ellipse: 'ellipse',
|
7014 | g: 'g',
|
7015 | line: 'line',
|
7016 | linearGradient: 'linearGradient',
|
7017 | mask: 'mask',
|
7018 | path: 'path',
|
7019 | pattern: 'pattern',
|
7020 | polygon: 'polygon',
|
7021 | polyline: 'polyline',
|
7022 | radialGradient: 'radialGradient',
|
7023 | rect: 'rect',
|
7024 | stop: 'stop',
|
7025 | svg: 'svg',
|
7026 | text: 'text',
|
7027 | tspan: 'tspan',
|
7028 | feColorMatrix: 'feColorMatrix',
|
7029 | feGaussianBlur: 'feGaussianBlur',
|
7030 | feOffset: 'feOffset',
|
7031 | feFlood: 'feFlood',
|
7032 | feComposite: 'feComposite',
|
7033 | feMerge: 'feMerge',
|
7034 | feMergeNode: 'feMergeNode',
|
7035 | filter: 'filter',
|
7036 | image: 'image',
|
7037 | clipPath: 'clipPath',
|
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 | }, createDOMFactory);
|
7043 |
|
7044 | module.exports = ReactDOM;
|
7045 |
|
7046 | },{"./ReactElement":52,"./ReactElementValidator":53,"./ReactLegacyElement":61,"./mapObject":134}],38:[function(_dereq_,module,exports){
|
7047 |
|
7048 |
|
7049 |
|
7050 |
|
7051 |
|
7052 |
|
7053 |
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 | "use strict";
|
7059 |
|
7060 | var AutoFocusMixin = _dereq_("./AutoFocusMixin");
|
7061 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
7062 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
7063 | var ReactElement = _dereq_("./ReactElement");
|
7064 | var ReactDOM = _dereq_("./ReactDOM");
|
7065 |
|
7066 | var keyMirror = _dereq_("./keyMirror");
|
7067 |
|
7068 |
|
7069 | var button = ReactElement.createFactory(ReactDOM.button.type);
|
7070 |
|
7071 | var mouseListenerNames = keyMirror({
|
7072 | onClick: true,
|
7073 | onDoubleClick: true,
|
7074 | onMouseDown: true,
|
7075 | onMouseMove: true,
|
7076 | onMouseUp: true,
|
7077 | onClickCapture: true,
|
7078 | onDoubleClickCapture: true,
|
7079 | onMouseDownCapture: true,
|
7080 | onMouseMoveCapture: true,
|
7081 | onMouseUpCapture: true
|
7082 | });
|
7083 |
|
7084 |
|
7085 |
|
7086 |
|
7087 |
|
7088 | var ReactDOMButton = ReactCompositeComponent.createClass({
|
7089 | displayName: 'ReactDOMButton',
|
7090 |
|
7091 | mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
|
7092 |
|
7093 | render: function() {
|
7094 | var props = {};
|
7095 |
|
7096 |
|
7097 | for (var key in this.props) {
|
7098 | if (this.props.hasOwnProperty(key) &&
|
7099 | (!this.props.disabled || !mouseListenerNames[key])) {
|
7100 | props[key] = this.props[key];
|
7101 | }
|
7102 | }
|
7103 |
|
7104 | return button(props, this.props.children);
|
7105 | }
|
7106 |
|
7107 | });
|
7108 |
|
7109 | module.exports = ReactDOMButton;
|
7110 |
|
7111 | },{"./AutoFocusMixin":2,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./keyMirror":132}],39:[function(_dereq_,module,exports){
|
7112 |
|
7113 |
|
7114 |
|
7115 |
|
7116 |
|
7117 |
|
7118 |
|
7119 |
|
7120 |
|
7121 |
|
7122 |
|
7123 |
|
7124 | "use strict";
|
7125 |
|
7126 | var CSSPropertyOperations = _dereq_("./CSSPropertyOperations");
|
7127 | var DOMProperty = _dereq_("./DOMProperty");
|
7128 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
7129 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
7130 | var ReactComponent = _dereq_("./ReactComponent");
|
7131 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
7132 | var ReactMount = _dereq_("./ReactMount");
|
7133 | var ReactMultiChild = _dereq_("./ReactMultiChild");
|
7134 | var ReactPerf = _dereq_("./ReactPerf");
|
7135 |
|
7136 | var assign = _dereq_("./Object.assign");
|
7137 | var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
|
7138 | var invariant = _dereq_("./invariant");
|
7139 | var isEventSupported = _dereq_("./isEventSupported");
|
7140 | var keyOf = _dereq_("./keyOf");
|
7141 | var monitorCodeUse = _dereq_("./monitorCodeUse");
|
7142 |
|
7143 | var deleteListener = ReactBrowserEventEmitter.deleteListener;
|
7144 | var listenTo = ReactBrowserEventEmitter.listenTo;
|
7145 | var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
|
7146 |
|
7147 |
|
7148 | var CONTENT_TYPES = {'string': true, 'number': true};
|
7149 |
|
7150 | var STYLE = keyOf({style: null});
|
7151 |
|
7152 | var ELEMENT_NODE_TYPE = 1;
|
7153 |
|
7154 |
|
7155 |
|
7156 |
|
7157 | function assertValidProps(props) {
|
7158 | if (!props) {
|
7159 | return;
|
7160 | }
|
7161 |
|
7162 | ("production" !== "development" ? invariant(
|
7163 | props.children == null || props.dangerouslySetInnerHTML == null,
|
7164 | 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
|
7165 | ) : invariant(props.children == null || props.dangerouslySetInnerHTML == null));
|
7166 | if ("production" !== "development") {
|
7167 | if (props.contentEditable && props.children != null) {
|
7168 | console.warn(
|
7169 | 'A component is `contentEditable` and contains `children` managed by ' +
|
7170 | 'React. It is now your responsibility to guarantee that none of those '+
|
7171 | 'nodes are unexpectedly modified or duplicated. This is probably not ' +
|
7172 | 'intentional.'
|
7173 | );
|
7174 | }
|
7175 | }
|
7176 | ("production" !== "development" ? invariant(
|
7177 | props.style == null || typeof props.style === 'object',
|
7178 | 'The `style` prop expects a mapping from style properties to values, ' +
|
7179 | 'not a string.'
|
7180 | ) : invariant(props.style == null || typeof props.style === 'object'));
|
7181 | }
|
7182 |
|
7183 | function putListener(id, registrationName, listener, transaction) {
|
7184 | if ("production" !== "development") {
|
7185 |
|
7186 |
|
7187 | if (registrationName === 'onScroll' &&
|
7188 | !isEventSupported('scroll', true)) {
|
7189 | monitorCodeUse('react_no_scroll_event');
|
7190 | console.warn('This browser doesn\'t support the `onScroll` event');
|
7191 | }
|
7192 | }
|
7193 | var container = ReactMount.findReactContainerForID(id);
|
7194 | if (container) {
|
7195 | var doc = container.nodeType === ELEMENT_NODE_TYPE ?
|
7196 | container.ownerDocument :
|
7197 | container;
|
7198 | listenTo(registrationName, doc);
|
7199 | }
|
7200 | transaction.getPutListenerQueue().enqueuePutListener(
|
7201 | id,
|
7202 | registrationName,
|
7203 | listener
|
7204 | );
|
7205 | }
|
7206 |
|
7207 |
|
7208 |
|
7209 |
|
7210 | var omittedCloseTags = {
|
7211 | 'area': true,
|
7212 | 'base': true,
|
7213 | 'br': true,
|
7214 | 'col': true,
|
7215 | 'embed': true,
|
7216 | 'hr': true,
|
7217 | 'img': true,
|
7218 | 'input': true,
|
7219 | 'keygen': true,
|
7220 | 'link': true,
|
7221 | 'meta': true,
|
7222 | 'param': true,
|
7223 | 'source': true,
|
7224 | 'track': true,
|
7225 | 'wbr': true
|
7226 |
|
7227 | };
|
7228 |
|
7229 |
|
7230 |
|
7231 |
|
7232 |
|
7233 | var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/;
|
7234 | var validatedTagCache = {};
|
7235 | var hasOwnProperty = {}.hasOwnProperty;
|
7236 |
|
7237 | function validateDangerousTag(tag) {
|
7238 | if (!hasOwnProperty.call(validatedTagCache, tag)) {
|
7239 | ("production" !== "development" ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
|
7240 | validatedTagCache[tag] = true;
|
7241 | }
|
7242 | }
|
7243 |
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 |
|
7251 |
|
7252 |
|
7253 |
|
7254 |
|
7255 |
|
7256 |
|
7257 |
|
7258 |
|
7259 | function ReactDOMComponent(tag) {
|
7260 | validateDangerousTag(tag);
|
7261 | this._tag = tag;
|
7262 | this.tagName = tag.toUpperCase();
|
7263 | }
|
7264 |
|
7265 | ReactDOMComponent.displayName = 'ReactDOMComponent';
|
7266 |
|
7267 | ReactDOMComponent.Mixin = {
|
7268 |
|
7269 | |
7270 |
|
7271 |
|
7272 |
|
7273 |
|
7274 |
|
7275 |
|
7276 |
|
7277 |
|
7278 |
|
7279 | mountComponent: ReactPerf.measure(
|
7280 | 'ReactDOMComponent',
|
7281 | 'mountComponent',
|
7282 | function(rootID, transaction, mountDepth) {
|
7283 | ReactComponent.Mixin.mountComponent.call(
|
7284 | this,
|
7285 | rootID,
|
7286 | transaction,
|
7287 | mountDepth
|
7288 | );
|
7289 | assertValidProps(this.props);
|
7290 | var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
|
7291 | return (
|
7292 | this._createOpenTagMarkupAndPutListeners(transaction) +
|
7293 | this._createContentMarkup(transaction) +
|
7294 | closeTag
|
7295 | );
|
7296 | }
|
7297 | ),
|
7298 |
|
7299 | |
7300 |
|
7301 |
|
7302 |
|
7303 |
|
7304 |
|
7305 |
|
7306 |
|
7307 |
|
7308 |
|
7309 |
|
7310 |
|
7311 | _createOpenTagMarkupAndPutListeners: function(transaction) {
|
7312 | var props = this.props;
|
7313 | var ret = '<' + this._tag;
|
7314 |
|
7315 | for (var propKey in props) {
|
7316 | if (!props.hasOwnProperty(propKey)) {
|
7317 | continue;
|
7318 | }
|
7319 | var propValue = props[propKey];
|
7320 | if (propValue == null) {
|
7321 | continue;
|
7322 | }
|
7323 | if (registrationNameModules.hasOwnProperty(propKey)) {
|
7324 | putListener(this._rootNodeID, propKey, propValue, transaction);
|
7325 | } else {
|
7326 | if (propKey === STYLE) {
|
7327 | if (propValue) {
|
7328 | propValue = props.style = assign({}, props.style);
|
7329 | }
|
7330 | propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
|
7331 | }
|
7332 | var markup =
|
7333 | DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
|
7334 | if (markup) {
|
7335 | ret += ' ' + markup;
|
7336 | }
|
7337 | }
|
7338 | }
|
7339 |
|
7340 |
|
7341 |
|
7342 | if (transaction.renderToStaticMarkup) {
|
7343 | return ret + '>';
|
7344 | }
|
7345 |
|
7346 | var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
|
7347 | return ret + ' ' + markupForID + '>';
|
7348 | },
|
7349 |
|
7350 | |
7351 |
|
7352 |
|
7353 |
|
7354 |
|
7355 |
|
7356 |
|
7357 | _createContentMarkup: function(transaction) {
|
7358 |
|
7359 | var innerHTML = this.props.dangerouslySetInnerHTML;
|
7360 | if (innerHTML != null) {
|
7361 | if (innerHTML.__html != null) {
|
7362 | return innerHTML.__html;
|
7363 | }
|
7364 | } else {
|
7365 | var contentToUse =
|
7366 | CONTENT_TYPES[typeof this.props.children] ? this.props.children : null;
|
7367 | var childrenToUse = contentToUse != null ? null : this.props.children;
|
7368 | if (contentToUse != null) {
|
7369 | return escapeTextForBrowser(contentToUse);
|
7370 | } else if (childrenToUse != null) {
|
7371 | var mountImages = this.mountChildren(
|
7372 | childrenToUse,
|
7373 | transaction
|
7374 | );
|
7375 | return mountImages.join('');
|
7376 | }
|
7377 | }
|
7378 | return '';
|
7379 | },
|
7380 |
|
7381 | receiveComponent: function(nextElement, transaction) {
|
7382 | if (nextElement === this._currentElement &&
|
7383 | nextElement._owner != null) {
|
7384 |
|
7385 |
|
7386 |
|
7387 |
|
7388 |
|
7389 |
|
7390 |
|
7391 | return;
|
7392 | }
|
7393 |
|
7394 | ReactComponent.Mixin.receiveComponent.call(
|
7395 | this,
|
7396 | nextElement,
|
7397 | transaction
|
7398 | );
|
7399 | },
|
7400 |
|
7401 | |
7402 |
|
7403 |
|
7404 |
|
7405 |
|
7406 |
|
7407 |
|
7408 |
|
7409 |
|
7410 | updateComponent: ReactPerf.measure(
|
7411 | 'ReactDOMComponent',
|
7412 | 'updateComponent',
|
7413 | function(transaction, prevElement) {
|
7414 | assertValidProps(this._currentElement.props);
|
7415 | ReactComponent.Mixin.updateComponent.call(
|
7416 | this,
|
7417 | transaction,
|
7418 | prevElement
|
7419 | );
|
7420 | this._updateDOMProperties(prevElement.props, transaction);
|
7421 | this._updateDOMChildren(prevElement.props, transaction);
|
7422 | }
|
7423 | ),
|
7424 |
|
7425 | |
7426 |
|
7427 |
|
7428 |
|
7429 |
|
7430 |
|
7431 |
|
7432 |
|
7433 |
|
7434 |
|
7435 |
|
7436 |
|
7437 |
|
7438 |
|
7439 |
|
7440 | _updateDOMProperties: function(lastProps, transaction) {
|
7441 | var nextProps = this.props;
|
7442 | var propKey;
|
7443 | var styleName;
|
7444 | var styleUpdates;
|
7445 | for (propKey in lastProps) {
|
7446 | if (nextProps.hasOwnProperty(propKey) ||
|
7447 | !lastProps.hasOwnProperty(propKey)) {
|
7448 | continue;
|
7449 | }
|
7450 | if (propKey === STYLE) {
|
7451 | var lastStyle = lastProps[propKey];
|
7452 | for (styleName in lastStyle) {
|
7453 | if (lastStyle.hasOwnProperty(styleName)) {
|
7454 | styleUpdates = styleUpdates || {};
|
7455 | styleUpdates[styleName] = '';
|
7456 | }
|
7457 | }
|
7458 | } else if (registrationNameModules.hasOwnProperty(propKey)) {
|
7459 | deleteListener(this._rootNodeID, propKey);
|
7460 | } else if (
|
7461 | DOMProperty.isStandardName[propKey] ||
|
7462 | DOMProperty.isCustomAttribute(propKey)) {
|
7463 | ReactComponent.BackendIDOperations.deletePropertyByID(
|
7464 | this._rootNodeID,
|
7465 | propKey
|
7466 | );
|
7467 | }
|
7468 | }
|
7469 | for (propKey in nextProps) {
|
7470 | var nextProp = nextProps[propKey];
|
7471 | var lastProp = lastProps[propKey];
|
7472 | if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
7473 | continue;
|
7474 | }
|
7475 | if (propKey === STYLE) {
|
7476 | if (nextProp) {
|
7477 | nextProp = nextProps.style = assign({}, nextProp);
|
7478 | }
|
7479 | if (lastProp) {
|
7480 |
|
7481 | for (styleName in lastProp) {
|
7482 | if (lastProp.hasOwnProperty(styleName) &&
|
7483 | (!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
7484 | styleUpdates = styleUpdates || {};
|
7485 | styleUpdates[styleName] = '';
|
7486 | }
|
7487 | }
|
7488 |
|
7489 | for (styleName in nextProp) {
|
7490 | if (nextProp.hasOwnProperty(styleName) &&
|
7491 | lastProp[styleName] !== nextProp[styleName]) {
|
7492 | styleUpdates = styleUpdates || {};
|
7493 | styleUpdates[styleName] = nextProp[styleName];
|
7494 | }
|
7495 | }
|
7496 | } else {
|
7497 |
|
7498 | styleUpdates = nextProp;
|
7499 | }
|
7500 | } else if (registrationNameModules.hasOwnProperty(propKey)) {
|
7501 | putListener(this._rootNodeID, propKey, nextProp, transaction);
|
7502 | } else if (
|
7503 | DOMProperty.isStandardName[propKey] ||
|
7504 | DOMProperty.isCustomAttribute(propKey)) {
|
7505 | ReactComponent.BackendIDOperations.updatePropertyByID(
|
7506 | this._rootNodeID,
|
7507 | propKey,
|
7508 | nextProp
|
7509 | );
|
7510 | }
|
7511 | }
|
7512 | if (styleUpdates) {
|
7513 | ReactComponent.BackendIDOperations.updateStylesByID(
|
7514 | this._rootNodeID,
|
7515 | styleUpdates
|
7516 | );
|
7517 | }
|
7518 | },
|
7519 |
|
7520 | |
7521 |
|
7522 |
|
7523 |
|
7524 |
|
7525 |
|
7526 |
|
7527 | _updateDOMChildren: function(lastProps, transaction) {
|
7528 | var nextProps = this.props;
|
7529 |
|
7530 | var lastContent =
|
7531 | CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
|
7532 | var nextContent =
|
7533 | CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
|
7534 |
|
7535 | var lastHtml =
|
7536 | lastProps.dangerouslySetInnerHTML &&
|
7537 | lastProps.dangerouslySetInnerHTML.__html;
|
7538 | var nextHtml =
|
7539 | nextProps.dangerouslySetInnerHTML &&
|
7540 | nextProps.dangerouslySetInnerHTML.__html;
|
7541 |
|
7542 |
|
7543 | var lastChildren = lastContent != null ? null : lastProps.children;
|
7544 | var nextChildren = nextContent != null ? null : nextProps.children;
|
7545 |
|
7546 |
|
7547 |
|
7548 | var lastHasContentOrHtml = lastContent != null || lastHtml != null;
|
7549 | var nextHasContentOrHtml = nextContent != null || nextHtml != null;
|
7550 | if (lastChildren != null && nextChildren == null) {
|
7551 | this.updateChildren(null, transaction);
|
7552 | } else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
|
7553 | this.updateTextContent('');
|
7554 | }
|
7555 |
|
7556 | if (nextContent != null) {
|
7557 | if (lastContent !== nextContent) {
|
7558 | this.updateTextContent('' + nextContent);
|
7559 | }
|
7560 | } else if (nextHtml != null) {
|
7561 | if (lastHtml !== nextHtml) {
|
7562 | ReactComponent.BackendIDOperations.updateInnerHTMLByID(
|
7563 | this._rootNodeID,
|
7564 | nextHtml
|
7565 | );
|
7566 | }
|
7567 | } else if (nextChildren != null) {
|
7568 | this.updateChildren(nextChildren, transaction);
|
7569 | }
|
7570 | },
|
7571 |
|
7572 | |
7573 |
|
7574 |
|
7575 |
|
7576 |
|
7577 |
|
7578 | unmountComponent: function() {
|
7579 | this.unmountChildren();
|
7580 | ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
7581 | ReactComponent.Mixin.unmountComponent.call(this);
|
7582 | }
|
7583 |
|
7584 | };
|
7585 |
|
7586 | assign(
|
7587 | ReactDOMComponent.prototype,
|
7588 | ReactComponent.Mixin,
|
7589 | ReactDOMComponent.Mixin,
|
7590 | ReactMultiChild.Mixin,
|
7591 | ReactBrowserComponentMixin
|
7592 | );
|
7593 |
|
7594 | module.exports = ReactDOMComponent;
|
7595 |
|
7596 | },{"./CSSPropertyOperations":5,"./DOMProperty":11,"./DOMPropertyOperations":12,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactBrowserEventEmitter":30,"./ReactComponent":32,"./ReactMount":63,"./ReactMultiChild":64,"./ReactPerf":68,"./escapeTextForBrowser":109,"./invariant":126,"./isEventSupported":127,"./keyOf":133,"./monitorCodeUse":136}],40:[function(_dereq_,module,exports){
|
7597 |
|
7598 |
|
7599 |
|
7600 |
|
7601 |
|
7602 |
|
7603 |
|
7604 |
|
7605 |
|
7606 |
|
7607 |
|
7608 | "use strict";
|
7609 |
|
7610 | var EventConstants = _dereq_("./EventConstants");
|
7611 | var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
|
7612 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
7613 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
7614 | var ReactElement = _dereq_("./ReactElement");
|
7615 | var ReactDOM = _dereq_("./ReactDOM");
|
7616 |
|
7617 |
|
7618 | var form = ReactElement.createFactory(ReactDOM.form.type);
|
7619 |
|
7620 |
|
7621 |
|
7622 |
|
7623 |
|
7624 |
|
7625 |
|
7626 | var ReactDOMForm = ReactCompositeComponent.createClass({
|
7627 | displayName: 'ReactDOMForm',
|
7628 |
|
7629 | mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
7630 |
|
7631 | render: function() {
|
7632 |
|
7633 |
|
7634 |
|
7635 | return form(this.props);
|
7636 | },
|
7637 |
|
7638 | componentDidMount: function() {
|
7639 | this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
|
7640 | this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
|
7641 | }
|
7642 | });
|
7643 |
|
7644 | module.exports = ReactDOMForm;
|
7645 |
|
7646 | },{"./EventConstants":16,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52}],41:[function(_dereq_,module,exports){
|
7647 |
|
7648 |
|
7649 |
|
7650 |
|
7651 |
|
7652 |
|
7653 |
|
7654 |
|
7655 |
|
7656 |
|
7657 |
|
7658 |
|
7659 |
|
7660 |
|
7661 | "use strict";
|
7662 |
|
7663 | var CSSPropertyOperations = _dereq_("./CSSPropertyOperations");
|
7664 | var DOMChildrenOperations = _dereq_("./DOMChildrenOperations");
|
7665 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
7666 | var ReactMount = _dereq_("./ReactMount");
|
7667 | var ReactPerf = _dereq_("./ReactPerf");
|
7668 |
|
7669 | var invariant = _dereq_("./invariant");
|
7670 | var setInnerHTML = _dereq_("./setInnerHTML");
|
7671 |
|
7672 |
|
7673 |
|
7674 |
|
7675 |
|
7676 |
|
7677 |
|
7678 | var INVALID_PROPERTY_ERRORS = {
|
7679 | dangerouslySetInnerHTML:
|
7680 | '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
|
7681 | style: '`style` must be set using `updateStylesByID()`.'
|
7682 | };
|
7683 |
|
7684 |
|
7685 |
|
7686 |
|
7687 |
|
7688 | var ReactDOMIDOperations = {
|
7689 |
|
7690 | |
7691 |
|
7692 |
|
7693 |
|
7694 |
|
7695 |
|
7696 |
|
7697 |
|
7698 |
|
7699 | updatePropertyByID: ReactPerf.measure(
|
7700 | 'ReactDOMIDOperations',
|
7701 | 'updatePropertyByID',
|
7702 | function(id, name, value) {
|
7703 | var node = ReactMount.getNode(id);
|
7704 | ("production" !== "development" ? invariant(
|
7705 | !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
7706 | 'updatePropertyByID(...): %s',
|
7707 | INVALID_PROPERTY_ERRORS[name]
|
7708 | ) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
7709 |
|
7710 |
|
7711 |
|
7712 |
|
7713 | if (value != null) {
|
7714 | DOMPropertyOperations.setValueForProperty(node, name, value);
|
7715 | } else {
|
7716 | DOMPropertyOperations.deleteValueForProperty(node, name);
|
7717 | }
|
7718 | }
|
7719 | ),
|
7720 |
|
7721 | |
7722 |
|
7723 |
|
7724 |
|
7725 |
|
7726 |
|
7727 |
|
7728 |
|
7729 | deletePropertyByID: ReactPerf.measure(
|
7730 | 'ReactDOMIDOperations',
|
7731 | 'deletePropertyByID',
|
7732 | function(id, name, value) {
|
7733 | var node = ReactMount.getNode(id);
|
7734 | ("production" !== "development" ? invariant(
|
7735 | !INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
|
7736 | 'updatePropertyByID(...): %s',
|
7737 | INVALID_PROPERTY_ERRORS[name]
|
7738 | ) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
|
7739 | DOMPropertyOperations.deleteValueForProperty(node, name, value);
|
7740 | }
|
7741 | ),
|
7742 |
|
7743 | |
7744 |
|
7745 |
|
7746 |
|
7747 |
|
7748 |
|
7749 |
|
7750 |
|
7751 | updateStylesByID: ReactPerf.measure(
|
7752 | 'ReactDOMIDOperations',
|
7753 | 'updateStylesByID',
|
7754 | function(id, styles) {
|
7755 | var node = ReactMount.getNode(id);
|
7756 | CSSPropertyOperations.setValueForStyles(node, styles);
|
7757 | }
|
7758 | ),
|
7759 |
|
7760 | |
7761 |
|
7762 |
|
7763 |
|
7764 |
|
7765 |
|
7766 |
|
7767 | updateInnerHTMLByID: ReactPerf.measure(
|
7768 | 'ReactDOMIDOperations',
|
7769 | 'updateInnerHTMLByID',
|
7770 | function(id, html) {
|
7771 | var node = ReactMount.getNode(id);
|
7772 | setInnerHTML(node, html);
|
7773 | }
|
7774 | ),
|
7775 |
|
7776 | |
7777 |
|
7778 |
|
7779 |
|
7780 |
|
7781 |
|
7782 |
|
7783 | updateTextContentByID: ReactPerf.measure(
|
7784 | 'ReactDOMIDOperations',
|
7785 | 'updateTextContentByID',
|
7786 | function(id, content) {
|
7787 | var node = ReactMount.getNode(id);
|
7788 | DOMChildrenOperations.updateTextContent(node, content);
|
7789 | }
|
7790 | ),
|
7791 |
|
7792 | |
7793 |
|
7794 |
|
7795 |
|
7796 |
|
7797 |
|
7798 |
|
7799 |
|
7800 | dangerouslyReplaceNodeWithMarkupByID: ReactPerf.measure(
|
7801 | 'ReactDOMIDOperations',
|
7802 | 'dangerouslyReplaceNodeWithMarkupByID',
|
7803 | function(id, markup) {
|
7804 | var node = ReactMount.getNode(id);
|
7805 | DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
|
7806 | }
|
7807 | ),
|
7808 |
|
7809 | |
7810 |
|
7811 |
|
7812 |
|
7813 |
|
7814 |
|
7815 |
|
7816 | dangerouslyProcessChildrenUpdates: ReactPerf.measure(
|
7817 | 'ReactDOMIDOperations',
|
7818 | 'dangerouslyProcessChildrenUpdates',
|
7819 | function(updates, markup) {
|
7820 | for (var i = 0; i < updates.length; i++) {
|
7821 | updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
|
7822 | }
|
7823 | DOMChildrenOperations.processUpdates(updates, markup);
|
7824 | }
|
7825 | )
|
7826 | };
|
7827 |
|
7828 | module.exports = ReactDOMIDOperations;
|
7829 |
|
7830 | },{"./CSSPropertyOperations":5,"./DOMChildrenOperations":10,"./DOMPropertyOperations":12,"./ReactMount":63,"./ReactPerf":68,"./invariant":126,"./setInnerHTML":140}],42:[function(_dereq_,module,exports){
|
7831 |
|
7832 |
|
7833 |
|
7834 |
|
7835 |
|
7836 |
|
7837 |
|
7838 |
|
7839 |
|
7840 |
|
7841 |
|
7842 | "use strict";
|
7843 |
|
7844 | var EventConstants = _dereq_("./EventConstants");
|
7845 | var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
|
7846 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
7847 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
7848 | var ReactElement = _dereq_("./ReactElement");
|
7849 | var ReactDOM = _dereq_("./ReactDOM");
|
7850 |
|
7851 |
|
7852 | var img = ReactElement.createFactory(ReactDOM.img.type);
|
7853 |
|
7854 |
|
7855 |
|
7856 |
|
7857 |
|
7858 |
|
7859 |
|
7860 | var ReactDOMImg = ReactCompositeComponent.createClass({
|
7861 | displayName: 'ReactDOMImg',
|
7862 | tagName: 'IMG',
|
7863 |
|
7864 | mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
|
7865 |
|
7866 | render: function() {
|
7867 | return img(this.props);
|
7868 | },
|
7869 |
|
7870 | componentDidMount: function() {
|
7871 | this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
|
7872 | this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
|
7873 | }
|
7874 | });
|
7875 |
|
7876 | module.exports = ReactDOMImg;
|
7877 |
|
7878 | },{"./EventConstants":16,"./LocalEventTrapMixin":25,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52}],43:[function(_dereq_,module,exports){
|
7879 |
|
7880 |
|
7881 |
|
7882 |
|
7883 |
|
7884 |
|
7885 |
|
7886 |
|
7887 |
|
7888 |
|
7889 |
|
7890 | "use strict";
|
7891 |
|
7892 | var AutoFocusMixin = _dereq_("./AutoFocusMixin");
|
7893 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
7894 | var LinkedValueUtils = _dereq_("./LinkedValueUtils");
|
7895 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
7896 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
7897 | var ReactElement = _dereq_("./ReactElement");
|
7898 | var ReactDOM = _dereq_("./ReactDOM");
|
7899 | var ReactMount = _dereq_("./ReactMount");
|
7900 | var ReactUpdates = _dereq_("./ReactUpdates");
|
7901 |
|
7902 | var assign = _dereq_("./Object.assign");
|
7903 | var invariant = _dereq_("./invariant");
|
7904 |
|
7905 |
|
7906 | var input = ReactElement.createFactory(ReactDOM.input.type);
|
7907 |
|
7908 | var instancesByReactID = {};
|
7909 |
|
7910 | function forceUpdateIfMounted() {
|
7911 |
|
7912 | if (this.isMounted()) {
|
7913 | this.forceUpdate();
|
7914 | }
|
7915 | }
|
7916 |
|
7917 |
|
7918 |
|
7919 |
|
7920 |
|
7921 |
|
7922 |
|
7923 |
|
7924 |
|
7925 |
|
7926 |
|
7927 |
|
7928 |
|
7929 |
|
7930 |
|
7931 |
|
7932 |
|
7933 | var ReactDOMInput = ReactCompositeComponent.createClass({
|
7934 | displayName: 'ReactDOMInput',
|
7935 |
|
7936 | mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
7937 |
|
7938 | getInitialState: function() {
|
7939 | var defaultValue = this.props.defaultValue;
|
7940 | return {
|
7941 | initialChecked: this.props.defaultChecked || false,
|
7942 | initialValue: defaultValue != null ? defaultValue : null
|
7943 | };
|
7944 | },
|
7945 |
|
7946 | render: function() {
|
7947 |
|
7948 | var props = assign({}, this.props);
|
7949 |
|
7950 | props.defaultChecked = null;
|
7951 | props.defaultValue = null;
|
7952 |
|
7953 | var value = LinkedValueUtils.getValue(this);
|
7954 | props.value = value != null ? value : this.state.initialValue;
|
7955 |
|
7956 | var checked = LinkedValueUtils.getChecked(this);
|
7957 | props.checked = checked != null ? checked : this.state.initialChecked;
|
7958 |
|
7959 | props.onChange = this._handleChange;
|
7960 |
|
7961 | return input(props, this.props.children);
|
7962 | },
|
7963 |
|
7964 | componentDidMount: function() {
|
7965 | var id = ReactMount.getID(this.getDOMNode());
|
7966 | instancesByReactID[id] = this;
|
7967 | },
|
7968 |
|
7969 | componentWillUnmount: function() {
|
7970 | var rootNode = this.getDOMNode();
|
7971 | var id = ReactMount.getID(rootNode);
|
7972 | delete instancesByReactID[id];
|
7973 | },
|
7974 |
|
7975 | componentDidUpdate: function(prevProps, prevState, prevContext) {
|
7976 | var rootNode = this.getDOMNode();
|
7977 | if (this.props.checked != null) {
|
7978 | DOMPropertyOperations.setValueForProperty(
|
7979 | rootNode,
|
7980 | 'checked',
|
7981 | this.props.checked || false
|
7982 | );
|
7983 | }
|
7984 |
|
7985 | var value = LinkedValueUtils.getValue(this);
|
7986 | if (value != null) {
|
7987 |
|
7988 |
|
7989 | DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
|
7990 | }
|
7991 | },
|
7992 |
|
7993 | _handleChange: function(event) {
|
7994 | var returnValue;
|
7995 | var onChange = LinkedValueUtils.getOnChange(this);
|
7996 | if (onChange) {
|
7997 | returnValue = onChange.call(this, event);
|
7998 | }
|
7999 |
|
8000 |
|
8001 |
|
8002 | ReactUpdates.asap(forceUpdateIfMounted, this);
|
8003 |
|
8004 | var name = this.props.name;
|
8005 | if (this.props.type === 'radio' && name != null) {
|
8006 | var rootNode = this.getDOMNode();
|
8007 | var queryRoot = rootNode;
|
8008 |
|
8009 | while (queryRoot.parentNode) {
|
8010 | queryRoot = queryRoot.parentNode;
|
8011 | }
|
8012 |
|
8013 |
|
8014 |
|
8015 |
|
8016 |
|
8017 |
|
8018 |
|
8019 | var group = queryRoot.querySelectorAll(
|
8020 | 'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
|
8021 |
|
8022 | for (var i = 0, groupLen = group.length; i < groupLen; i++) {
|
8023 | var otherNode = group[i];
|
8024 | if (otherNode === rootNode ||
|
8025 | otherNode.form !== rootNode.form) {
|
8026 | continue;
|
8027 | }
|
8028 | var otherID = ReactMount.getID(otherNode);
|
8029 | ("production" !== "development" ? invariant(
|
8030 | otherID,
|
8031 | 'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
|
8032 | 'same `name` is not supported.'
|
8033 | ) : invariant(otherID));
|
8034 | var otherInstance = instancesByReactID[otherID];
|
8035 | ("production" !== "development" ? invariant(
|
8036 | otherInstance,
|
8037 | 'ReactDOMInput: Unknown radio button ID %s.',
|
8038 | otherID
|
8039 | ) : invariant(otherInstance));
|
8040 |
|
8041 |
|
8042 |
|
8043 | ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
|
8044 | }
|
8045 | }
|
8046 |
|
8047 | return returnValue;
|
8048 | }
|
8049 |
|
8050 | });
|
8051 |
|
8052 | module.exports = ReactDOMInput;
|
8053 |
|
8054 | },{"./AutoFocusMixin":2,"./DOMPropertyOperations":12,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactMount":63,"./ReactUpdates":79,"./invariant":126}],44:[function(_dereq_,module,exports){
|
8055 |
|
8056 |
|
8057 |
|
8058 |
|
8059 |
|
8060 |
|
8061 |
|
8062 |
|
8063 |
|
8064 |
|
8065 |
|
8066 | "use strict";
|
8067 |
|
8068 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
8069 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
8070 | var ReactElement = _dereq_("./ReactElement");
|
8071 | var ReactDOM = _dereq_("./ReactDOM");
|
8072 |
|
8073 | var warning = _dereq_("./warning");
|
8074 |
|
8075 |
|
8076 | var option = ReactElement.createFactory(ReactDOM.option.type);
|
8077 |
|
8078 |
|
8079 |
|
8080 |
|
8081 | var ReactDOMOption = ReactCompositeComponent.createClass({
|
8082 | displayName: 'ReactDOMOption',
|
8083 |
|
8084 | mixins: [ReactBrowserComponentMixin],
|
8085 |
|
8086 | componentWillMount: function() {
|
8087 |
|
8088 | if ("production" !== "development") {
|
8089 | ("production" !== "development" ? warning(
|
8090 | this.props.selected == null,
|
8091 | 'Use the `defaultValue` or `value` props on <select> instead of ' +
|
8092 | 'setting `selected` on <option>.'
|
8093 | ) : null);
|
8094 | }
|
8095 | },
|
8096 |
|
8097 | render: function() {
|
8098 | return option(this.props, this.props.children);
|
8099 | }
|
8100 |
|
8101 | });
|
8102 |
|
8103 | module.exports = ReactDOMOption;
|
8104 |
|
8105 | },{"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./warning":145}],45:[function(_dereq_,module,exports){
|
8106 |
|
8107 |
|
8108 |
|
8109 |
|
8110 |
|
8111 |
|
8112 |
|
8113 |
|
8114 |
|
8115 |
|
8116 |
|
8117 | "use strict";
|
8118 |
|
8119 | var AutoFocusMixin = _dereq_("./AutoFocusMixin");
|
8120 | var LinkedValueUtils = _dereq_("./LinkedValueUtils");
|
8121 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
8122 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
8123 | var ReactElement = _dereq_("./ReactElement");
|
8124 | var ReactDOM = _dereq_("./ReactDOM");
|
8125 | var ReactUpdates = _dereq_("./ReactUpdates");
|
8126 |
|
8127 | var assign = _dereq_("./Object.assign");
|
8128 |
|
8129 |
|
8130 | var select = ReactElement.createFactory(ReactDOM.select.type);
|
8131 |
|
8132 | function updateWithPendingValueIfMounted() {
|
8133 |
|
8134 | if (this.isMounted()) {
|
8135 | this.setState({value: this._pendingValue});
|
8136 | this._pendingValue = 0;
|
8137 | }
|
8138 | }
|
8139 |
|
8140 |
|
8141 |
|
8142 |
|
8143 |
|
8144 | function selectValueType(props, propName, componentName) {
|
8145 | if (props[propName] == null) {
|
8146 | return;
|
8147 | }
|
8148 | if (props.multiple) {
|
8149 | if (!Array.isArray(props[propName])) {
|
8150 | return new Error(
|
8151 | ("The `" + propName + "` prop supplied to <select> must be an array if ") +
|
8152 | ("`multiple` is true.")
|
8153 | );
|
8154 | }
|
8155 | } else {
|
8156 | if (Array.isArray(props[propName])) {
|
8157 | return new Error(
|
8158 | ("The `" + propName + "` prop supplied to <select> must be a scalar ") +
|
8159 | ("value if `multiple` is false.")
|
8160 | );
|
8161 | }
|
8162 | }
|
8163 | }
|
8164 |
|
8165 |
|
8166 |
|
8167 |
|
8168 |
|
8169 |
|
8170 |
|
8171 |
|
8172 | function updateOptions(component, propValue) {
|
8173 | var multiple = component.props.multiple;
|
8174 | var value = propValue != null ? propValue : component.state.value;
|
8175 | var options = component.getDOMNode().options;
|
8176 | var selectedValue, i, l;
|
8177 | if (multiple) {
|
8178 | selectedValue = {};
|
8179 | for (i = 0, l = value.length; i < l; ++i) {
|
8180 | selectedValue['' + value[i]] = true;
|
8181 | }
|
8182 | } else {
|
8183 | selectedValue = '' + value;
|
8184 | }
|
8185 | for (i = 0, l = options.length; i < l; i++) {
|
8186 | var selected = multiple ?
|
8187 | selectedValue.hasOwnProperty(options[i].value) :
|
8188 | options[i].value === selectedValue;
|
8189 |
|
8190 | if (selected !== options[i].selected) {
|
8191 | options[i].selected = selected;
|
8192 | }
|
8193 | }
|
8194 | }
|
8195 |
|
8196 |
|
8197 |
|
8198 |
|
8199 |
|
8200 |
|
8201 |
|
8202 |
|
8203 |
|
8204 |
|
8205 |
|
8206 |
|
8207 |
|
8208 |
|
8209 |
|
8210 |
|
8211 | var ReactDOMSelect = ReactCompositeComponent.createClass({
|
8212 | displayName: 'ReactDOMSelect',
|
8213 |
|
8214 | mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
8215 |
|
8216 | propTypes: {
|
8217 | defaultValue: selectValueType,
|
8218 | value: selectValueType
|
8219 | },
|
8220 |
|
8221 | getInitialState: function() {
|
8222 | return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
|
8223 | },
|
8224 |
|
8225 | componentWillMount: function() {
|
8226 | this._pendingValue = null;
|
8227 | },
|
8228 |
|
8229 | componentWillReceiveProps: function(nextProps) {
|
8230 | if (!this.props.multiple && nextProps.multiple) {
|
8231 | this.setState({value: [this.state.value]});
|
8232 | } else if (this.props.multiple && !nextProps.multiple) {
|
8233 | this.setState({value: this.state.value[0]});
|
8234 | }
|
8235 | },
|
8236 |
|
8237 | render: function() {
|
8238 |
|
8239 | var props = assign({}, this.props);
|
8240 |
|
8241 | props.onChange = this._handleChange;
|
8242 | props.value = null;
|
8243 |
|
8244 | return select(props, this.props.children);
|
8245 | },
|
8246 |
|
8247 | componentDidMount: function() {
|
8248 | updateOptions(this, LinkedValueUtils.getValue(this));
|
8249 | },
|
8250 |
|
8251 | componentDidUpdate: function(prevProps) {
|
8252 | var value = LinkedValueUtils.getValue(this);
|
8253 | var prevMultiple = !!prevProps.multiple;
|
8254 | var multiple = !!this.props.multiple;
|
8255 | if (value != null || prevMultiple !== multiple) {
|
8256 | updateOptions(this, value);
|
8257 | }
|
8258 | },
|
8259 |
|
8260 | _handleChange: function(event) {
|
8261 | var returnValue;
|
8262 | var onChange = LinkedValueUtils.getOnChange(this);
|
8263 | if (onChange) {
|
8264 | returnValue = onChange.call(this, event);
|
8265 | }
|
8266 |
|
8267 | var selectedValue;
|
8268 | if (this.props.multiple) {
|
8269 | selectedValue = [];
|
8270 | var options = event.target.options;
|
8271 | for (var i = 0, l = options.length; i < l; i++) {
|
8272 | if (options[i].selected) {
|
8273 | selectedValue.push(options[i].value);
|
8274 | }
|
8275 | }
|
8276 | } else {
|
8277 | selectedValue = event.target.value;
|
8278 | }
|
8279 |
|
8280 | this._pendingValue = selectedValue;
|
8281 | ReactUpdates.asap(updateWithPendingValueIfMounted, this);
|
8282 | return returnValue;
|
8283 | }
|
8284 |
|
8285 | });
|
8286 |
|
8287 | module.exports = ReactDOMSelect;
|
8288 |
|
8289 | },{"./AutoFocusMixin":2,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactUpdates":79}],46:[function(_dereq_,module,exports){
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 |
|
8295 |
|
8296 |
|
8297 |
|
8298 |
|
8299 |
|
8300 |
|
8301 | "use strict";
|
8302 |
|
8303 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
8304 |
|
8305 | var getNodeForCharacterOffset = _dereq_("./getNodeForCharacterOffset");
|
8306 | var getTextContentAccessor = _dereq_("./getTextContentAccessor");
|
8307 |
|
8308 |
|
8309 |
|
8310 |
|
8311 |
|
8312 |
|
8313 | function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
|
8314 | return anchorNode === focusNode && anchorOffset === focusOffset;
|
8315 | }
|
8316 |
|
8317 |
|
8318 |
|
8319 |
|
8320 |
|
8321 |
|
8322 |
|
8323 |
|
8324 |
|
8325 |
|
8326 |
|
8327 |
|
8328 |
|
8329 |
|
8330 |
|
8331 | function getIEOffsets(node) {
|
8332 | var selection = document.selection;
|
8333 | var selectedRange = selection.createRange();
|
8334 | var selectedLength = selectedRange.text.length;
|
8335 |
|
8336 |
|
8337 | var fromStart = selectedRange.duplicate();
|
8338 | fromStart.moveToElementText(node);
|
8339 | fromStart.setEndPoint('EndToStart', selectedRange);
|
8340 |
|
8341 | var startOffset = fromStart.text.length;
|
8342 | var endOffset = startOffset + selectedLength;
|
8343 |
|
8344 | return {
|
8345 | start: startOffset,
|
8346 | end: endOffset
|
8347 | };
|
8348 | }
|
8349 |
|
8350 |
|
8351 |
|
8352 |
|
8353 |
|
8354 | function getModernOffsets(node) {
|
8355 | var selection = window.getSelection && window.getSelection();
|
8356 |
|
8357 | if (!selection || selection.rangeCount === 0) {
|
8358 | return null;
|
8359 | }
|
8360 |
|
8361 | var anchorNode = selection.anchorNode;
|
8362 | var anchorOffset = selection.anchorOffset;
|
8363 | var focusNode = selection.focusNode;
|
8364 | var focusOffset = selection.focusOffset;
|
8365 |
|
8366 | var currentRange = selection.getRangeAt(0);
|
8367 |
|
8368 |
|
8369 |
|
8370 |
|
8371 | var isSelectionCollapsed = isCollapsed(
|
8372 | selection.anchorNode,
|
8373 | selection.anchorOffset,
|
8374 | selection.focusNode,
|
8375 | selection.focusOffset
|
8376 | );
|
8377 |
|
8378 | var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
|
8379 |
|
8380 | var tempRange = currentRange.cloneRange();
|
8381 | tempRange.selectNodeContents(node);
|
8382 | tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
|
8383 |
|
8384 | var isTempRangeCollapsed = isCollapsed(
|
8385 | tempRange.startContainer,
|
8386 | tempRange.startOffset,
|
8387 | tempRange.endContainer,
|
8388 | tempRange.endOffset
|
8389 | );
|
8390 |
|
8391 | var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
|
8392 | var end = start + rangeLength;
|
8393 |
|
8394 |
|
8395 | var detectionRange = document.createRange();
|
8396 | detectionRange.setStart(anchorNode, anchorOffset);
|
8397 | detectionRange.setEnd(focusNode, focusOffset);
|
8398 | var isBackward = detectionRange.collapsed;
|
8399 |
|
8400 | return {
|
8401 | start: isBackward ? end : start,
|
8402 | end: isBackward ? start : end
|
8403 | };
|
8404 | }
|
8405 |
|
8406 |
|
8407 |
|
8408 |
|
8409 |
|
8410 | function setIEOffsets(node, offsets) {
|
8411 | var range = document.selection.createRange().duplicate();
|
8412 | var start, end;
|
8413 |
|
8414 | if (typeof offsets.end === 'undefined') {
|
8415 | start = offsets.start;
|
8416 | end = start;
|
8417 | } else if (offsets.start > offsets.end) {
|
8418 | start = offsets.end;
|
8419 | end = offsets.start;
|
8420 | } else {
|
8421 | start = offsets.start;
|
8422 | end = offsets.end;
|
8423 | }
|
8424 |
|
8425 | range.moveToElementText(node);
|
8426 | range.moveStart('character', start);
|
8427 | range.setEndPoint('EndToStart', range);
|
8428 | range.moveEnd('character', end - start);
|
8429 | range.select();
|
8430 | }
|
8431 |
|
8432 |
|
8433 |
|
8434 |
|
8435 |
|
8436 |
|
8437 |
|
8438 |
|
8439 |
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 | function setModernOffsets(node, offsets) {
|
8445 | if (!window.getSelection) {
|
8446 | return;
|
8447 | }
|
8448 |
|
8449 | var selection = window.getSelection();
|
8450 | var length = node[getTextContentAccessor()].length;
|
8451 | var start = Math.min(offsets.start, length);
|
8452 | var end = typeof offsets.end === 'undefined' ?
|
8453 | start : Math.min(offsets.end, length);
|
8454 |
|
8455 |
|
8456 |
|
8457 | if (!selection.extend && start > end) {
|
8458 | var temp = end;
|
8459 | end = start;
|
8460 | start = temp;
|
8461 | }
|
8462 |
|
8463 | var startMarker = getNodeForCharacterOffset(node, start);
|
8464 | var endMarker = getNodeForCharacterOffset(node, end);
|
8465 |
|
8466 | if (startMarker && endMarker) {
|
8467 | var range = document.createRange();
|
8468 | range.setStart(startMarker.node, startMarker.offset);
|
8469 | selection.removeAllRanges();
|
8470 |
|
8471 | if (start > end) {
|
8472 | selection.addRange(range);
|
8473 | selection.extend(endMarker.node, endMarker.offset);
|
8474 | } else {
|
8475 | range.setEnd(endMarker.node, endMarker.offset);
|
8476 | selection.addRange(range);
|
8477 | }
|
8478 | }
|
8479 | }
|
8480 |
|
8481 | var useIEOffsets = ExecutionEnvironment.canUseDOM && document.selection;
|
8482 |
|
8483 | var ReactDOMSelection = {
|
8484 | |
8485 |
|
8486 |
|
8487 | getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
|
8488 |
|
8489 | |
8490 |
|
8491 |
|
8492 |
|
8493 | setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
|
8494 | };
|
8495 |
|
8496 | module.exports = ReactDOMSelection;
|
8497 |
|
8498 | },{"./ExecutionEnvironment":22,"./getNodeForCharacterOffset":119,"./getTextContentAccessor":121}],47:[function(_dereq_,module,exports){
|
8499 |
|
8500 |
|
8501 |
|
8502 |
|
8503 |
|
8504 |
|
8505 |
|
8506 |
|
8507 |
|
8508 |
|
8509 |
|
8510 | "use strict";
|
8511 |
|
8512 | var AutoFocusMixin = _dereq_("./AutoFocusMixin");
|
8513 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
8514 | var LinkedValueUtils = _dereq_("./LinkedValueUtils");
|
8515 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
8516 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
8517 | var ReactElement = _dereq_("./ReactElement");
|
8518 | var ReactDOM = _dereq_("./ReactDOM");
|
8519 | var ReactUpdates = _dereq_("./ReactUpdates");
|
8520 |
|
8521 | var assign = _dereq_("./Object.assign");
|
8522 | var invariant = _dereq_("./invariant");
|
8523 |
|
8524 | var warning = _dereq_("./warning");
|
8525 |
|
8526 |
|
8527 | var textarea = ReactElement.createFactory(ReactDOM.textarea.type);
|
8528 |
|
8529 | function forceUpdateIfMounted() {
|
8530 |
|
8531 | if (this.isMounted()) {
|
8532 | this.forceUpdate();
|
8533 | }
|
8534 | }
|
8535 |
|
8536 |
|
8537 |
|
8538 |
|
8539 |
|
8540 |
|
8541 |
|
8542 |
|
8543 |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 |
|
8550 |
|
8551 | var ReactDOMTextarea = ReactCompositeComponent.createClass({
|
8552 | displayName: 'ReactDOMTextarea',
|
8553 |
|
8554 | mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
|
8555 |
|
8556 | getInitialState: function() {
|
8557 | var defaultValue = this.props.defaultValue;
|
8558 |
|
8559 | var children = this.props.children;
|
8560 | if (children != null) {
|
8561 | if ("production" !== "development") {
|
8562 | ("production" !== "development" ? warning(
|
8563 | false,
|
8564 | 'Use the `defaultValue` or `value` props instead of setting ' +
|
8565 | 'children on <textarea>.'
|
8566 | ) : null);
|
8567 | }
|
8568 | ("production" !== "development" ? invariant(
|
8569 | defaultValue == null,
|
8570 | 'If you supply `defaultValue` on a <textarea>, do not pass children.'
|
8571 | ) : invariant(defaultValue == null));
|
8572 | if (Array.isArray(children)) {
|
8573 | ("production" !== "development" ? invariant(
|
8574 | children.length <= 1,
|
8575 | '<textarea> can only have at most one child.'
|
8576 | ) : invariant(children.length <= 1));
|
8577 | children = children[0];
|
8578 | }
|
8579 |
|
8580 | defaultValue = '' + children;
|
8581 | }
|
8582 | if (defaultValue == null) {
|
8583 | defaultValue = '';
|
8584 | }
|
8585 | var value = LinkedValueUtils.getValue(this);
|
8586 | return {
|
8587 |
|
8588 |
|
8589 |
|
8590 |
|
8591 | initialValue: '' + (value != null ? value : defaultValue)
|
8592 | };
|
8593 | },
|
8594 |
|
8595 | render: function() {
|
8596 |
|
8597 | var props = assign({}, this.props);
|
8598 |
|
8599 | ("production" !== "development" ? invariant(
|
8600 | props.dangerouslySetInnerHTML == null,
|
8601 | '`dangerouslySetInnerHTML` does not make sense on <textarea>.'
|
8602 | ) : invariant(props.dangerouslySetInnerHTML == null));
|
8603 |
|
8604 | props.defaultValue = null;
|
8605 | props.value = null;
|
8606 | props.onChange = this._handleChange;
|
8607 |
|
8608 |
|
8609 |
|
8610 | return textarea(props, this.state.initialValue);
|
8611 | },
|
8612 |
|
8613 | componentDidUpdate: function(prevProps, prevState, prevContext) {
|
8614 | var value = LinkedValueUtils.getValue(this);
|
8615 | if (value != null) {
|
8616 | var rootNode = this.getDOMNode();
|
8617 |
|
8618 |
|
8619 | DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
|
8620 | }
|
8621 | },
|
8622 |
|
8623 | _handleChange: function(event) {
|
8624 | var returnValue;
|
8625 | var onChange = LinkedValueUtils.getOnChange(this);
|
8626 | if (onChange) {
|
8627 | returnValue = onChange.call(this, event);
|
8628 | }
|
8629 | ReactUpdates.asap(forceUpdateIfMounted, this);
|
8630 | return returnValue;
|
8631 | }
|
8632 |
|
8633 | });
|
8634 |
|
8635 | module.exports = ReactDOMTextarea;
|
8636 |
|
8637 | },{"./AutoFocusMixin":2,"./DOMPropertyOperations":12,"./LinkedValueUtils":24,"./Object.assign":27,"./ReactBrowserComponentMixin":29,"./ReactCompositeComponent":34,"./ReactDOM":37,"./ReactElement":52,"./ReactUpdates":79,"./invariant":126,"./warning":145}],48:[function(_dereq_,module,exports){
|
8638 |
|
8639 |
|
8640 |
|
8641 |
|
8642 |
|
8643 |
|
8644 |
|
8645 |
|
8646 |
|
8647 |
|
8648 |
|
8649 | "use strict";
|
8650 |
|
8651 | var ReactUpdates = _dereq_("./ReactUpdates");
|
8652 | var Transaction = _dereq_("./Transaction");
|
8653 |
|
8654 | var assign = _dereq_("./Object.assign");
|
8655 | var emptyFunction = _dereq_("./emptyFunction");
|
8656 |
|
8657 | var RESET_BATCHED_UPDATES = {
|
8658 | initialize: emptyFunction,
|
8659 | close: function() {
|
8660 | ReactDefaultBatchingStrategy.isBatchingUpdates = false;
|
8661 | }
|
8662 | };
|
8663 |
|
8664 | var FLUSH_BATCHED_UPDATES = {
|
8665 | initialize: emptyFunction,
|
8666 | close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
|
8667 | };
|
8668 |
|
8669 | var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
|
8670 |
|
8671 | function ReactDefaultBatchingStrategyTransaction() {
|
8672 | this.reinitializeTransaction();
|
8673 | }
|
8674 |
|
8675 | assign(
|
8676 | ReactDefaultBatchingStrategyTransaction.prototype,
|
8677 | Transaction.Mixin,
|
8678 | {
|
8679 | getTransactionWrappers: function() {
|
8680 | return TRANSACTION_WRAPPERS;
|
8681 | }
|
8682 | }
|
8683 | );
|
8684 |
|
8685 | var transaction = new ReactDefaultBatchingStrategyTransaction();
|
8686 |
|
8687 | var ReactDefaultBatchingStrategy = {
|
8688 | isBatchingUpdates: false,
|
8689 |
|
8690 | |
8691 |
|
8692 |
|
8693 |
|
8694 | batchedUpdates: function(callback, a, b) {
|
8695 | var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
|
8696 |
|
8697 | ReactDefaultBatchingStrategy.isBatchingUpdates = true;
|
8698 |
|
8699 |
|
8700 | if (alreadyBatchingUpdates) {
|
8701 | callback(a, b);
|
8702 | } else {
|
8703 | transaction.perform(callback, null, a, b);
|
8704 | }
|
8705 | }
|
8706 | };
|
8707 |
|
8708 | module.exports = ReactDefaultBatchingStrategy;
|
8709 |
|
8710 | },{"./Object.assign":27,"./ReactUpdates":79,"./Transaction":95,"./emptyFunction":107}],49:[function(_dereq_,module,exports){
|
8711 |
|
8712 |
|
8713 |
|
8714 |
|
8715 |
|
8716 |
|
8717 |
|
8718 |
|
8719 |
|
8720 |
|
8721 |
|
8722 | "use strict";
|
8723 |
|
8724 | var BeforeInputEventPlugin = _dereq_("./BeforeInputEventPlugin");
|
8725 | var ChangeEventPlugin = _dereq_("./ChangeEventPlugin");
|
8726 | var ClientReactRootIndex = _dereq_("./ClientReactRootIndex");
|
8727 | var CompositionEventPlugin = _dereq_("./CompositionEventPlugin");
|
8728 | var DefaultEventPluginOrder = _dereq_("./DefaultEventPluginOrder");
|
8729 | var EnterLeaveEventPlugin = _dereq_("./EnterLeaveEventPlugin");
|
8730 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
8731 | var HTMLDOMPropertyConfig = _dereq_("./HTMLDOMPropertyConfig");
|
8732 | var MobileSafariClickEventPlugin = _dereq_("./MobileSafariClickEventPlugin");
|
8733 | var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
|
8734 | var ReactComponentBrowserEnvironment =
|
8735 | _dereq_("./ReactComponentBrowserEnvironment");
|
8736 | var ReactDefaultBatchingStrategy = _dereq_("./ReactDefaultBatchingStrategy");
|
8737 | var ReactDOMComponent = _dereq_("./ReactDOMComponent");
|
8738 | var ReactDOMButton = _dereq_("./ReactDOMButton");
|
8739 | var ReactDOMForm = _dereq_("./ReactDOMForm");
|
8740 | var ReactDOMImg = _dereq_("./ReactDOMImg");
|
8741 | var ReactDOMInput = _dereq_("./ReactDOMInput");
|
8742 | var ReactDOMOption = _dereq_("./ReactDOMOption");
|
8743 | var ReactDOMSelect = _dereq_("./ReactDOMSelect");
|
8744 | var ReactDOMTextarea = _dereq_("./ReactDOMTextarea");
|
8745 | var ReactEventListener = _dereq_("./ReactEventListener");
|
8746 | var ReactInjection = _dereq_("./ReactInjection");
|
8747 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
8748 | var ReactMount = _dereq_("./ReactMount");
|
8749 | var SelectEventPlugin = _dereq_("./SelectEventPlugin");
|
8750 | var ServerReactRootIndex = _dereq_("./ServerReactRootIndex");
|
8751 | var SimpleEventPlugin = _dereq_("./SimpleEventPlugin");
|
8752 | var SVGDOMPropertyConfig = _dereq_("./SVGDOMPropertyConfig");
|
8753 |
|
8754 | var createFullPageComponent = _dereq_("./createFullPageComponent");
|
8755 |
|
8756 | function inject() {
|
8757 | ReactInjection.EventEmitter.injectReactEventListener(
|
8758 | ReactEventListener
|
8759 | );
|
8760 |
|
8761 | |
8762 |
|
8763 |
|
8764 | ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
|
8765 | ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
|
8766 | ReactInjection.EventPluginHub.injectMount(ReactMount);
|
8767 |
|
8768 | |
8769 |
|
8770 |
|
8771 |
|
8772 | ReactInjection.EventPluginHub.injectEventPluginsByName({
|
8773 | SimpleEventPlugin: SimpleEventPlugin,
|
8774 | EnterLeaveEventPlugin: EnterLeaveEventPlugin,
|
8775 | ChangeEventPlugin: ChangeEventPlugin,
|
8776 | CompositionEventPlugin: CompositionEventPlugin,
|
8777 | MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
|
8778 | SelectEventPlugin: SelectEventPlugin,
|
8779 | BeforeInputEventPlugin: BeforeInputEventPlugin
|
8780 | });
|
8781 |
|
8782 | ReactInjection.NativeComponent.injectGenericComponentClass(
|
8783 | ReactDOMComponent
|
8784 | );
|
8785 |
|
8786 | ReactInjection.NativeComponent.injectComponentClasses({
|
8787 | 'button': ReactDOMButton,
|
8788 | 'form': ReactDOMForm,
|
8789 | 'img': ReactDOMImg,
|
8790 | 'input': ReactDOMInput,
|
8791 | 'option': ReactDOMOption,
|
8792 | 'select': ReactDOMSelect,
|
8793 | 'textarea': ReactDOMTextarea,
|
8794 |
|
8795 | 'html': createFullPageComponent('html'),
|
8796 | 'head': createFullPageComponent('head'),
|
8797 | 'body': createFullPageComponent('body')
|
8798 | });
|
8799 |
|
8800 |
|
8801 |
|
8802 | ReactInjection.CompositeComponent.injectMixin(ReactBrowserComponentMixin);
|
8803 |
|
8804 | ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
8805 | ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
8806 |
|
8807 | ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
|
8808 |
|
8809 | ReactInjection.Updates.injectReconcileTransaction(
|
8810 | ReactComponentBrowserEnvironment.ReactReconcileTransaction
|
8811 | );
|
8812 | ReactInjection.Updates.injectBatchingStrategy(
|
8813 | ReactDefaultBatchingStrategy
|
8814 | );
|
8815 |
|
8816 | ReactInjection.RootIndex.injectCreateReactRootIndex(
|
8817 | ExecutionEnvironment.canUseDOM ?
|
8818 | ClientReactRootIndex.createReactRootIndex :
|
8819 | ServerReactRootIndex.createReactRootIndex
|
8820 | );
|
8821 |
|
8822 | ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
8823 |
|
8824 | if ("production" !== "development") {
|
8825 | var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
|
8826 | if ((/[?&]react_perf\b/).test(url)) {
|
8827 | var ReactDefaultPerf = _dereq_("./ReactDefaultPerf");
|
8828 | ReactDefaultPerf.start();
|
8829 | }
|
8830 | }
|
8831 | }
|
8832 |
|
8833 | module.exports = {
|
8834 | inject: inject
|
8835 | };
|
8836 |
|
8837 | },{"./BeforeInputEventPlugin":3,"./ChangeEventPlugin":7,"./ClientReactRootIndex":8,"./CompositionEventPlugin":9,"./DefaultEventPluginOrder":14,"./EnterLeaveEventPlugin":15,"./ExecutionEnvironment":22,"./HTMLDOMPropertyConfig":23,"./MobileSafariClickEventPlugin":26,"./ReactBrowserComponentMixin":29,"./ReactComponentBrowserEnvironment":33,"./ReactDOMButton":38,"./ReactDOMComponent":39,"./ReactDOMForm":40,"./ReactDOMImg":42,"./ReactDOMInput":43,"./ReactDOMOption":44,"./ReactDOMSelect":45,"./ReactDOMTextarea":47,"./ReactDefaultBatchingStrategy":48,"./ReactDefaultPerf":50,"./ReactEventListener":57,"./ReactInjection":58,"./ReactInstanceHandles":60,"./ReactMount":63,"./SVGDOMPropertyConfig":80,"./SelectEventPlugin":81,"./ServerReactRootIndex":82,"./SimpleEventPlugin":83,"./createFullPageComponent":103}],50:[function(_dereq_,module,exports){
|
8838 |
|
8839 |
|
8840 |
|
8841 |
|
8842 |
|
8843 |
|
8844 |
|
8845 |
|
8846 |
|
8847 |
|
8848 |
|
8849 |
|
8850 | "use strict";
|
8851 |
|
8852 | var DOMProperty = _dereq_("./DOMProperty");
|
8853 | var ReactDefaultPerfAnalysis = _dereq_("./ReactDefaultPerfAnalysis");
|
8854 | var ReactMount = _dereq_("./ReactMount");
|
8855 | var ReactPerf = _dereq_("./ReactPerf");
|
8856 |
|
8857 | var performanceNow = _dereq_("./performanceNow");
|
8858 |
|
8859 | function roundFloat(val) {
|
8860 | return Math.floor(val * 100) / 100;
|
8861 | }
|
8862 |
|
8863 | function addValue(obj, key, val) {
|
8864 | obj[key] = (obj[key] || 0) + val;
|
8865 | }
|
8866 |
|
8867 | var ReactDefaultPerf = {
|
8868 | _allMeasurements: [],
|
8869 | _mountStack: [0],
|
8870 | _injected: false,
|
8871 |
|
8872 | start: function() {
|
8873 | if (!ReactDefaultPerf._injected) {
|
8874 | ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
|
8875 | }
|
8876 |
|
8877 | ReactDefaultPerf._allMeasurements.length = 0;
|
8878 | ReactPerf.enableMeasure = true;
|
8879 | },
|
8880 |
|
8881 | stop: function() {
|
8882 | ReactPerf.enableMeasure = false;
|
8883 | },
|
8884 |
|
8885 | getLastMeasurements: function() {
|
8886 | return ReactDefaultPerf._allMeasurements;
|
8887 | },
|
8888 |
|
8889 | printExclusive: function(measurements) {
|
8890 | measurements = measurements || ReactDefaultPerf._allMeasurements;
|
8891 | var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
|
8892 | console.table(summary.map(function(item) {
|
8893 | return {
|
8894 | 'Component class name': item.componentName,
|
8895 | 'Total inclusive time (ms)': roundFloat(item.inclusive),
|
8896 | 'Exclusive mount time (ms)': roundFloat(item.exclusive),
|
8897 | 'Exclusive render time (ms)': roundFloat(item.render),
|
8898 | 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
|
8899 | 'Render time per instance (ms)': roundFloat(item.render / item.count),
|
8900 | 'Instances': item.count
|
8901 | };
|
8902 | }));
|
8903 |
|
8904 |
|
8905 | },
|
8906 |
|
8907 | printInclusive: function(measurements) {
|
8908 | measurements = measurements || ReactDefaultPerf._allMeasurements;
|
8909 | var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
|
8910 | console.table(summary.map(function(item) {
|
8911 | return {
|
8912 | 'Owner > component': item.componentName,
|
8913 | 'Inclusive time (ms)': roundFloat(item.time),
|
8914 | 'Instances': item.count
|
8915 | };
|
8916 | }));
|
8917 | console.log(
|
8918 | 'Total time:',
|
8919 | ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
8920 | );
|
8921 | },
|
8922 |
|
8923 | getMeasurementsSummaryMap: function(measurements) {
|
8924 | var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
|
8925 | measurements,
|
8926 | true
|
8927 | );
|
8928 | return summary.map(function(item) {
|
8929 | return {
|
8930 | 'Owner > component': item.componentName,
|
8931 | 'Wasted time (ms)': item.time,
|
8932 | 'Instances': item.count
|
8933 | };
|
8934 | });
|
8935 | },
|
8936 |
|
8937 | printWasted: function(measurements) {
|
8938 | measurements = measurements || ReactDefaultPerf._allMeasurements;
|
8939 | console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
|
8940 | console.log(
|
8941 | 'Total time:',
|
8942 | ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
8943 | );
|
8944 | },
|
8945 |
|
8946 | printDOM: function(measurements) {
|
8947 | measurements = measurements || ReactDefaultPerf._allMeasurements;
|
8948 | var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
|
8949 | console.table(summary.map(function(item) {
|
8950 | var result = {};
|
8951 | result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
|
8952 | result['type'] = item.type;
|
8953 | result['args'] = JSON.stringify(item.args);
|
8954 | return result;
|
8955 | }));
|
8956 | console.log(
|
8957 | 'Total time:',
|
8958 | ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
|
8959 | );
|
8960 | },
|
8961 |
|
8962 | _recordWrite: function(id, fnName, totalTime, args) {
|
8963 |
|
8964 | var writes =
|
8965 | ReactDefaultPerf
|
8966 | ._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
|
8967 | .writes;
|
8968 | writes[id] = writes[id] || [];
|
8969 | writes[id].push({
|
8970 | type: fnName,
|
8971 | time: totalTime,
|
8972 | args: args
|
8973 | });
|
8974 | },
|
8975 |
|
8976 | measure: function(moduleName, fnName, func) {
|
8977 | return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
8978 | var totalTime;
|
8979 | var rv;
|
8980 | var start;
|
8981 |
|
8982 | if (fnName === '_renderNewRootComponent' ||
|
8983 | fnName === 'flushBatchedUpdates') {
|
8984 |
|
8985 |
|
8986 |
|
8987 |
|
8988 | ReactDefaultPerf._allMeasurements.push({
|
8989 | exclusive: {},
|
8990 | inclusive: {},
|
8991 | render: {},
|
8992 | counts: {},
|
8993 | writes: {},
|
8994 | displayNames: {},
|
8995 | totalTime: 0
|
8996 | });
|
8997 | start = performanceNow();
|
8998 | rv = func.apply(this, args);
|
8999 | ReactDefaultPerf._allMeasurements[
|
9000 | ReactDefaultPerf._allMeasurements.length - 1
|
9001 | ].totalTime = performanceNow() - start;
|
9002 | return rv;
|
9003 | } else if (moduleName === 'ReactDOMIDOperations' ||
|
9004 | moduleName === 'ReactComponentBrowserEnvironment') {
|
9005 | start = performanceNow();
|
9006 | rv = func.apply(this, args);
|
9007 | totalTime = performanceNow() - start;
|
9008 |
|
9009 | if (fnName === 'mountImageIntoNode') {
|
9010 | var mountID = ReactMount.getID(args[1]);
|
9011 | ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
|
9012 | } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
|
9013 |
|
9014 | args[0].forEach(function(update) {
|
9015 | var writeArgs = {};
|
9016 | if (update.fromIndex !== null) {
|
9017 | writeArgs.fromIndex = update.fromIndex;
|
9018 | }
|
9019 | if (update.toIndex !== null) {
|
9020 | writeArgs.toIndex = update.toIndex;
|
9021 | }
|
9022 | if (update.textContent !== null) {
|
9023 | writeArgs.textContent = update.textContent;
|
9024 | }
|
9025 | if (update.markupIndex !== null) {
|
9026 | writeArgs.markup = args[1][update.markupIndex];
|
9027 | }
|
9028 | ReactDefaultPerf._recordWrite(
|
9029 | update.parentID,
|
9030 | update.type,
|
9031 | totalTime,
|
9032 | writeArgs
|
9033 | );
|
9034 | });
|
9035 | } else {
|
9036 |
|
9037 | ReactDefaultPerf._recordWrite(
|
9038 | args[0],
|
9039 | fnName,
|
9040 | totalTime,
|
9041 | Array.prototype.slice.call(args, 1)
|
9042 | );
|
9043 | }
|
9044 | return rv;
|
9045 | } else if (moduleName === 'ReactCompositeComponent' && (
|
9046 | fnName === 'mountComponent' ||
|
9047 | fnName === 'updateComponent' ||
|
9048 | fnName === '_renderValidatedComponent')) {
|
9049 |
|
9050 | var rootNodeID = fnName === 'mountComponent' ?
|
9051 | args[0] :
|
9052 | this._rootNodeID;
|
9053 | var isRender = fnName === '_renderValidatedComponent';
|
9054 | var isMount = fnName === 'mountComponent';
|
9055 |
|
9056 | var mountStack = ReactDefaultPerf._mountStack;
|
9057 | var entry = ReactDefaultPerf._allMeasurements[
|
9058 | ReactDefaultPerf._allMeasurements.length - 1
|
9059 | ];
|
9060 |
|
9061 | if (isRender) {
|
9062 | addValue(entry.counts, rootNodeID, 1);
|
9063 | } else if (isMount) {
|
9064 | mountStack.push(0);
|
9065 | }
|
9066 |
|
9067 | start = performanceNow();
|
9068 | rv = func.apply(this, args);
|
9069 | totalTime = performanceNow() - start;
|
9070 |
|
9071 | if (isRender) {
|
9072 | addValue(entry.render, rootNodeID, totalTime);
|
9073 | } else if (isMount) {
|
9074 | var subMountTime = mountStack.pop();
|
9075 | mountStack[mountStack.length - 1] += totalTime;
|
9076 | addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
|
9077 | addValue(entry.inclusive, rootNodeID, totalTime);
|
9078 | } else {
|
9079 | addValue(entry.inclusive, rootNodeID, totalTime);
|
9080 | }
|
9081 |
|
9082 | entry.displayNames[rootNodeID] = {
|
9083 | current: this.constructor.displayName,
|
9084 | owner: this._owner ? this._owner.constructor.displayName : '<root>'
|
9085 | };
|
9086 |
|
9087 | return rv;
|
9088 | } else {
|
9089 | return func.apply(this, args);
|
9090 | }
|
9091 | };
|
9092 | }
|
9093 | };
|
9094 |
|
9095 | module.exports = ReactDefaultPerf;
|
9096 |
|
9097 | },{"./DOMProperty":11,"./ReactDefaultPerfAnalysis":51,"./ReactMount":63,"./ReactPerf":68,"./performanceNow":139}],51:[function(_dereq_,module,exports){
|
9098 |
|
9099 |
|
9100 |
|
9101 |
|
9102 |
|
9103 |
|
9104 |
|
9105 |
|
9106 |
|
9107 |
|
9108 |
|
9109 | var assign = _dereq_("./Object.assign");
|
9110 |
|
9111 |
|
9112 | var DONT_CARE_THRESHOLD = 1.2;
|
9113 | var DOM_OPERATION_TYPES = {
|
9114 | 'mountImageIntoNode': 'set innerHTML',
|
9115 | INSERT_MARKUP: 'set innerHTML',
|
9116 | MOVE_EXISTING: 'move',
|
9117 | REMOVE_NODE: 'remove',
|
9118 | TEXT_CONTENT: 'set textContent',
|
9119 | 'updatePropertyByID': 'update attribute',
|
9120 | 'deletePropertyByID': 'delete attribute',
|
9121 | 'updateStylesByID': 'update styles',
|
9122 | 'updateInnerHTMLByID': 'set innerHTML',
|
9123 | 'dangerouslyReplaceNodeWithMarkupByID': 'replace'
|
9124 | };
|
9125 |
|
9126 | function getTotalTime(measurements) {
|
9127 |
|
9128 |
|
9129 |
|
9130 |
|
9131 | var totalTime = 0;
|
9132 | for (var i = 0; i < measurements.length; i++) {
|
9133 | var measurement = measurements[i];
|
9134 | totalTime += measurement.totalTime;
|
9135 | }
|
9136 | return totalTime;
|
9137 | }
|
9138 |
|
9139 | function getDOMSummary(measurements) {
|
9140 | var items = [];
|
9141 | for (var i = 0; i < measurements.length; i++) {
|
9142 | var measurement = measurements[i];
|
9143 | var id;
|
9144 |
|
9145 | for (id in measurement.writes) {
|
9146 | measurement.writes[id].forEach(function(write) {
|
9147 | items.push({
|
9148 | id: id,
|
9149 | type: DOM_OPERATION_TYPES[write.type] || write.type,
|
9150 | args: write.args
|
9151 | });
|
9152 | });
|
9153 | }
|
9154 | }
|
9155 | return items;
|
9156 | }
|
9157 |
|
9158 | function getExclusiveSummary(measurements) {
|
9159 | var candidates = {};
|
9160 | var displayName;
|
9161 |
|
9162 | for (var i = 0; i < measurements.length; i++) {
|
9163 | var measurement = measurements[i];
|
9164 | var allIDs = assign(
|
9165 | {},
|
9166 | measurement.exclusive,
|
9167 | measurement.inclusive
|
9168 | );
|
9169 |
|
9170 | for (var id in allIDs) {
|
9171 | displayName = measurement.displayNames[id].current;
|
9172 |
|
9173 | candidates[displayName] = candidates[displayName] || {
|
9174 | componentName: displayName,
|
9175 | inclusive: 0,
|
9176 | exclusive: 0,
|
9177 | render: 0,
|
9178 | count: 0
|
9179 | };
|
9180 | if (measurement.render[id]) {
|
9181 | candidates[displayName].render += measurement.render[id];
|
9182 | }
|
9183 | if (measurement.exclusive[id]) {
|
9184 | candidates[displayName].exclusive += measurement.exclusive[id];
|
9185 | }
|
9186 | if (measurement.inclusive[id]) {
|
9187 | candidates[displayName].inclusive += measurement.inclusive[id];
|
9188 | }
|
9189 | if (measurement.counts[id]) {
|
9190 | candidates[displayName].count += measurement.counts[id];
|
9191 | }
|
9192 | }
|
9193 | }
|
9194 |
|
9195 |
|
9196 | var arr = [];
|
9197 | for (displayName in candidates) {
|
9198 | if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
|
9199 | arr.push(candidates[displayName]);
|
9200 | }
|
9201 | }
|
9202 |
|
9203 | arr.sort(function(a, b) {
|
9204 | return b.exclusive - a.exclusive;
|
9205 | });
|
9206 |
|
9207 | return arr;
|
9208 | }
|
9209 |
|
9210 | function getInclusiveSummary(measurements, onlyClean) {
|
9211 | var candidates = {};
|
9212 | var inclusiveKey;
|
9213 |
|
9214 | for (var i = 0; i < measurements.length; i++) {
|
9215 | var measurement = measurements[i];
|
9216 | var allIDs = assign(
|
9217 | {},
|
9218 | measurement.exclusive,
|
9219 | measurement.inclusive
|
9220 | );
|
9221 | var cleanComponents;
|
9222 |
|
9223 | if (onlyClean) {
|
9224 | cleanComponents = getUnchangedComponents(measurement);
|
9225 | }
|
9226 |
|
9227 | for (var id in allIDs) {
|
9228 | if (onlyClean && !cleanComponents[id]) {
|
9229 | continue;
|
9230 | }
|
9231 |
|
9232 | var displayName = measurement.displayNames[id];
|
9233 |
|
9234 |
|
9235 |
|
9236 |
|
9237 | inclusiveKey = displayName.owner + ' > ' + displayName.current;
|
9238 |
|
9239 | candidates[inclusiveKey] = candidates[inclusiveKey] || {
|
9240 | componentName: inclusiveKey,
|
9241 | time: 0,
|
9242 | count: 0
|
9243 | };
|
9244 |
|
9245 | if (measurement.inclusive[id]) {
|
9246 | candidates[inclusiveKey].time += measurement.inclusive[id];
|
9247 | }
|
9248 | if (measurement.counts[id]) {
|
9249 | candidates[inclusiveKey].count += measurement.counts[id];
|
9250 | }
|
9251 | }
|
9252 | }
|
9253 |
|
9254 |
|
9255 | var arr = [];
|
9256 | for (inclusiveKey in candidates) {
|
9257 | if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
|
9258 | arr.push(candidates[inclusiveKey]);
|
9259 | }
|
9260 | }
|
9261 |
|
9262 | arr.sort(function(a, b) {
|
9263 | return b.time - a.time;
|
9264 | });
|
9265 |
|
9266 | return arr;
|
9267 | }
|
9268 |
|
9269 | function getUnchangedComponents(measurement) {
|
9270 |
|
9271 |
|
9272 |
|
9273 | var cleanComponents = {};
|
9274 | var dirtyLeafIDs = Object.keys(measurement.writes);
|
9275 | var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
|
9276 |
|
9277 | for (var id in allIDs) {
|
9278 | var isDirty = false;
|
9279 |
|
9280 |
|
9281 | for (var i = 0; i < dirtyLeafIDs.length; i++) {
|
9282 | if (dirtyLeafIDs[i].indexOf(id) === 0) {
|
9283 | isDirty = true;
|
9284 | break;
|
9285 | }
|
9286 | }
|
9287 | if (!isDirty && measurement.counts[id] > 0) {
|
9288 | cleanComponents[id] = true;
|
9289 | }
|
9290 | }
|
9291 | return cleanComponents;
|
9292 | }
|
9293 |
|
9294 | var ReactDefaultPerfAnalysis = {
|
9295 | getExclusiveSummary: getExclusiveSummary,
|
9296 | getInclusiveSummary: getInclusiveSummary,
|
9297 | getDOMSummary: getDOMSummary,
|
9298 | getTotalTime: getTotalTime
|
9299 | };
|
9300 |
|
9301 | module.exports = ReactDefaultPerfAnalysis;
|
9302 |
|
9303 | },{"./Object.assign":27}],52:[function(_dereq_,module,exports){
|
9304 |
|
9305 |
|
9306 |
|
9307 |
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 |
|
9315 | "use strict";
|
9316 |
|
9317 | var ReactContext = _dereq_("./ReactContext");
|
9318 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
9319 |
|
9320 | var warning = _dereq_("./warning");
|
9321 |
|
9322 | var RESERVED_PROPS = {
|
9323 | key: true,
|
9324 | ref: true
|
9325 | };
|
9326 |
|
9327 |
|
9328 |
|
9329 |
|
9330 |
|
9331 |
|
9332 |
|
9333 |
|
9334 | function defineWarningProperty(object, key) {
|
9335 | Object.defineProperty(object, key, {
|
9336 |
|
9337 | configurable: false,
|
9338 | enumerable: true,
|
9339 |
|
9340 | get: function() {
|
9341 | if (!this._store) {
|
9342 | return null;
|
9343 | }
|
9344 | return this._store[key];
|
9345 | },
|
9346 |
|
9347 | set: function(value) {
|
9348 | ("production" !== "development" ? warning(
|
9349 | false,
|
9350 | 'Don\'t set the ' + key + ' property of the component. ' +
|
9351 | 'Mutate the existing props object instead.'
|
9352 | ) : null);
|
9353 | this._store[key] = value;
|
9354 | }
|
9355 |
|
9356 | });
|
9357 | }
|
9358 |
|
9359 |
|
9360 |
|
9361 |
|
9362 | var useMutationMembrane = false;
|
9363 |
|
9364 |
|
9365 |
|
9366 |
|
9367 |
|
9368 |
|
9369 |
|
9370 | function defineMutationMembrane(prototype) {
|
9371 | try {
|
9372 | var pseudoFrozenProperties = {
|
9373 | props: true
|
9374 | };
|
9375 | for (var key in pseudoFrozenProperties) {
|
9376 | defineWarningProperty(prototype, key);
|
9377 | }
|
9378 | useMutationMembrane = true;
|
9379 | } catch (x) {
|
9380 |
|
9381 | }
|
9382 | }
|
9383 |
|
9384 |
|
9385 |
|
9386 |
|
9387 |
|
9388 |
|
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 | var ReactElement = function(type, key, ref, owner, context, props) {
|
9395 |
|
9396 | this.type = type;
|
9397 | this.key = key;
|
9398 | this.ref = ref;
|
9399 |
|
9400 |
|
9401 | this._owner = owner;
|
9402 |
|
9403 |
|
9404 |
|
9405 | this._context = context;
|
9406 |
|
9407 | if ("production" !== "development") {
|
9408 |
|
9409 |
|
9410 |
|
9411 |
|
9412 | this._store = { validated: false, props: props };
|
9413 |
|
9414 |
|
9415 |
|
9416 |
|
9417 | if (useMutationMembrane) {
|
9418 | Object.freeze(this);
|
9419 | return;
|
9420 | }
|
9421 | }
|
9422 |
|
9423 | this.props = props;
|
9424 | };
|
9425 |
|
9426 |
|
9427 |
|
9428 | ReactElement.prototype = {
|
9429 | _isReactElement: true
|
9430 | };
|
9431 |
|
9432 | if ("production" !== "development") {
|
9433 | defineMutationMembrane(ReactElement.prototype);
|
9434 | }
|
9435 |
|
9436 | ReactElement.createElement = function(type, config, children) {
|
9437 | var propName;
|
9438 |
|
9439 |
|
9440 | var props = {};
|
9441 |
|
9442 | var key = null;
|
9443 | var ref = null;
|
9444 |
|
9445 | if (config != null) {
|
9446 | ref = config.ref === undefined ? null : config.ref;
|
9447 | if ("production" !== "development") {
|
9448 | ("production" !== "development" ? warning(
|
9449 | config.key !== null,
|
9450 | 'createElement(...): Encountered component with a `key` of null. In ' +
|
9451 | 'a future version, this will be treated as equivalent to the string ' +
|
9452 | '\'null\'; instead, provide an explicit key or use undefined.'
|
9453 | ) : null);
|
9454 | }
|
9455 |
|
9456 | key = config.key == null ? null : '' + config.key;
|
9457 |
|
9458 | for (propName in config) {
|
9459 | if (config.hasOwnProperty(propName) &&
|
9460 | !RESERVED_PROPS.hasOwnProperty(propName)) {
|
9461 | props[propName] = config[propName];
|
9462 | }
|
9463 | }
|
9464 | }
|
9465 |
|
9466 |
|
9467 |
|
9468 | var childrenLength = arguments.length - 2;
|
9469 | if (childrenLength === 1) {
|
9470 | props.children = children;
|
9471 | } else if (childrenLength > 1) {
|
9472 | var childArray = Array(childrenLength);
|
9473 | for (var i = 0; i < childrenLength; i++) {
|
9474 | childArray[i] = arguments[i + 2];
|
9475 | }
|
9476 | props.children = childArray;
|
9477 | }
|
9478 |
|
9479 |
|
9480 | if (type && type.defaultProps) {
|
9481 | var defaultProps = type.defaultProps;
|
9482 | for (propName in defaultProps) {
|
9483 | if (typeof props[propName] === 'undefined') {
|
9484 | props[propName] = defaultProps[propName];
|
9485 | }
|
9486 | }
|
9487 | }
|
9488 |
|
9489 | return new ReactElement(
|
9490 | type,
|
9491 | key,
|
9492 | ref,
|
9493 | ReactCurrentOwner.current,
|
9494 | ReactContext.current,
|
9495 | props
|
9496 | );
|
9497 | };
|
9498 |
|
9499 | ReactElement.createFactory = function(type) {
|
9500 | var factory = ReactElement.createElement.bind(null, type);
|
9501 |
|
9502 |
|
9503 |
|
9504 |
|
9505 | factory.type = type;
|
9506 | return factory;
|
9507 | };
|
9508 |
|
9509 | ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
|
9510 | var newElement = new ReactElement(
|
9511 | oldElement.type,
|
9512 | oldElement.key,
|
9513 | oldElement.ref,
|
9514 | oldElement._owner,
|
9515 | oldElement._context,
|
9516 | newProps
|
9517 | );
|
9518 |
|
9519 | if ("production" !== "development") {
|
9520 |
|
9521 | newElement._store.validated = oldElement._store.validated;
|
9522 | }
|
9523 | return newElement;
|
9524 | };
|
9525 |
|
9526 |
|
9527 |
|
9528 |
|
9529 |
|
9530 |
|
9531 | ReactElement.isValidElement = function(object) {
|
9532 |
|
9533 |
|
9534 |
|
9535 |
|
9536 | var isElement = !!(object && object._isReactElement);
|
9537 |
|
9538 |
|
9539 |
|
9540 |
|
9541 |
|
9542 | return isElement;
|
9543 | };
|
9544 |
|
9545 | module.exports = ReactElement;
|
9546 |
|
9547 | },{"./ReactContext":35,"./ReactCurrentOwner":36,"./warning":145}],53:[function(_dereq_,module,exports){
|
9548 |
|
9549 |
|
9550 |
|
9551 |
|
9552 |
|
9553 |
|
9554 |
|
9555 |
|
9556 |
|
9557 |
|
9558 |
|
9559 |
|
9560 |
|
9561 |
|
9562 |
|
9563 |
|
9564 |
|
9565 |
|
9566 | "use strict";
|
9567 |
|
9568 | var ReactElement = _dereq_("./ReactElement");
|
9569 | var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
|
9570 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
9571 |
|
9572 | var monitorCodeUse = _dereq_("./monitorCodeUse");
|
9573 | var warning = _dereq_("./warning");
|
9574 |
|
9575 |
|
9576 |
|
9577 |
|
9578 |
|
9579 |
|
9580 | var ownerHasKeyUseWarning = {
|
9581 | 'react_key_warning': {},
|
9582 | 'react_numeric_key_warning': {}
|
9583 | };
|
9584 | var ownerHasMonitoredObjectMap = {};
|
9585 |
|
9586 | var loggedTypeFailures = {};
|
9587 |
|
9588 | var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
9589 |
|
9590 |
|
9591 |
|
9592 |
|
9593 |
|
9594 |
|
9595 |
|
9596 | function getCurrentOwnerDisplayName() {
|
9597 | var current = ReactCurrentOwner.current;
|
9598 | return current && current.constructor.displayName || undefined;
|
9599 | }
|
9600 |
|
9601 |
|
9602 |
|
9603 |
|
9604 |
|
9605 |
|
9606 |
|
9607 |
|
9608 |
|
9609 |
|
9610 |
|
9611 | function validateExplicitKey(component, parentType) {
|
9612 | if (component._store.validated || component.key != null) {
|
9613 | return;
|
9614 | }
|
9615 | component._store.validated = true;
|
9616 |
|
9617 | warnAndMonitorForKeyUse(
|
9618 | 'react_key_warning',
|
9619 | 'Each child in an array should have a unique "key" prop.',
|
9620 | component,
|
9621 | parentType
|
9622 | );
|
9623 | }
|
9624 |
|
9625 |
|
9626 |
|
9627 |
|
9628 |
|
9629 |
|
9630 |
|
9631 |
|
9632 |
|
9633 |
|
9634 | function validatePropertyKey(name, component, parentType) {
|
9635 | if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
9636 | return;
|
9637 | }
|
9638 | warnAndMonitorForKeyUse(
|
9639 | 'react_numeric_key_warning',
|
9640 | 'Child objects should have non-numeric keys so ordering is preserved.',
|
9641 | component,
|
9642 | parentType
|
9643 | );
|
9644 | }
|
9645 |
|
9646 |
|
9647 |
|
9648 |
|
9649 |
|
9650 |
|
9651 |
|
9652 |
|
9653 |
|
9654 |
|
9655 | function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
|
9656 | var ownerName = getCurrentOwnerDisplayName();
|
9657 | var parentName = parentType.displayName;
|
9658 |
|
9659 | var useName = ownerName || parentName;
|
9660 | var memoizer = ownerHasKeyUseWarning[warningID];
|
9661 | if (memoizer.hasOwnProperty(useName)) {
|
9662 | return;
|
9663 | }
|
9664 | memoizer[useName] = true;
|
9665 |
|
9666 | message += ownerName ?
|
9667 | (" Check the render method of " + ownerName + ".") :
|
9668 | (" Check the renderComponent call using <" + parentName + ">.");
|
9669 |
|
9670 |
|
9671 |
|
9672 |
|
9673 | var childOwnerName = null;
|
9674 | if (component._owner && component._owner !== ReactCurrentOwner.current) {
|
9675 |
|
9676 | childOwnerName = component._owner.constructor.displayName;
|
9677 |
|
9678 | message += (" It was passed a child from " + childOwnerName + ".");
|
9679 | }
|
9680 |
|
9681 | message += ' See http://fb.me/react-warning-keys for more information.';
|
9682 | monitorCodeUse(warningID, {
|
9683 | component: useName,
|
9684 | componentOwner: childOwnerName
|
9685 | });
|
9686 | console.warn(message);
|
9687 | }
|
9688 |
|
9689 |
|
9690 |
|
9691 |
|
9692 |
|
9693 |
|
9694 |
|
9695 | function monitorUseOfObjectMap() {
|
9696 | var currentName = getCurrentOwnerDisplayName() || '';
|
9697 | if (ownerHasMonitoredObjectMap.hasOwnProperty(currentName)) {
|
9698 | return;
|
9699 | }
|
9700 | ownerHasMonitoredObjectMap[currentName] = true;
|
9701 | monitorCodeUse('react_object_map_children');
|
9702 | }
|
9703 |
|
9704 |
|
9705 |
|
9706 |
|
9707 |
|
9708 |
|
9709 |
|
9710 |
|
9711 |
|
9712 |
|
9713 |
|
9714 | function validateChildKeys(component, parentType) {
|
9715 | if (Array.isArray(component)) {
|
9716 | for (var i = 0; i < component.length; i++) {
|
9717 | var child = component[i];
|
9718 | if (ReactElement.isValidElement(child)) {
|
9719 | validateExplicitKey(child, parentType);
|
9720 | }
|
9721 | }
|
9722 | } else if (ReactElement.isValidElement(component)) {
|
9723 |
|
9724 | component._store.validated = true;
|
9725 | } else if (component && typeof component === 'object') {
|
9726 | monitorUseOfObjectMap();
|
9727 | for (var name in component) {
|
9728 | validatePropertyKey(name, component[name], parentType);
|
9729 | }
|
9730 | }
|
9731 | }
|
9732 |
|
9733 |
|
9734 |
|
9735 |
|
9736 |
|
9737 |
|
9738 |
|
9739 |
|
9740 |
|
9741 |
|
9742 | function checkPropTypes(componentName, propTypes, props, location) {
|
9743 | for (var propName in propTypes) {
|
9744 | if (propTypes.hasOwnProperty(propName)) {
|
9745 | var error;
|
9746 |
|
9747 |
|
9748 |
|
9749 | try {
|
9750 | error = propTypes[propName](props, propName, componentName, location);
|
9751 | } catch (ex) {
|
9752 | error = ex;
|
9753 | }
|
9754 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
9755 |
|
9756 |
|
9757 | loggedTypeFailures[error.message] = true;
|
9758 |
|
9759 | monitorCodeUse(
|
9760 | 'react_failed_descriptor_type_check',
|
9761 | { message: error.message }
|
9762 | );
|
9763 | }
|
9764 | }
|
9765 | }
|
9766 | }
|
9767 |
|
9768 | var ReactElementValidator = {
|
9769 |
|
9770 | createElement: function(type, props, children) {
|
9771 |
|
9772 |
|
9773 | ("production" !== "development" ? warning(
|
9774 | type != null,
|
9775 | 'React.createElement: type should not be null or undefined. It should ' +
|
9776 | 'be a string (for DOM elements) or a ReactClass (for composite ' +
|
9777 | 'components).'
|
9778 | ) : null);
|
9779 |
|
9780 | var element = ReactElement.createElement.apply(this, arguments);
|
9781 |
|
9782 |
|
9783 |
|
9784 | if (element == null) {
|
9785 | return element;
|
9786 | }
|
9787 |
|
9788 | for (var i = 2; i < arguments.length; i++) {
|
9789 | validateChildKeys(arguments[i], type);
|
9790 | }
|
9791 |
|
9792 | if (type) {
|
9793 | var name = type.displayName;
|
9794 | if (type.propTypes) {
|
9795 | checkPropTypes(
|
9796 | name,
|
9797 | type.propTypes,
|
9798 | element.props,
|
9799 | ReactPropTypeLocations.prop
|
9800 | );
|
9801 | }
|
9802 | if (type.contextTypes) {
|
9803 | checkPropTypes(
|
9804 | name,
|
9805 | type.contextTypes,
|
9806 | element._context,
|
9807 | ReactPropTypeLocations.context
|
9808 | );
|
9809 | }
|
9810 | }
|
9811 | return element;
|
9812 | },
|
9813 |
|
9814 | createFactory: function(type) {
|
9815 | var validatedFactory = ReactElementValidator.createElement.bind(
|
9816 | null,
|
9817 | type
|
9818 | );
|
9819 | validatedFactory.type = type;
|
9820 | return validatedFactory;
|
9821 | }
|
9822 |
|
9823 | };
|
9824 |
|
9825 | module.exports = ReactElementValidator;
|
9826 |
|
9827 | },{"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactPropTypeLocations":71,"./monitorCodeUse":136,"./warning":145}],54:[function(_dereq_,module,exports){
|
9828 |
|
9829 |
|
9830 |
|
9831 |
|
9832 |
|
9833 |
|
9834 |
|
9835 |
|
9836 |
|
9837 |
|
9838 |
|
9839 | "use strict";
|
9840 |
|
9841 | var ReactElement = _dereq_("./ReactElement");
|
9842 |
|
9843 | var invariant = _dereq_("./invariant");
|
9844 |
|
9845 | var component;
|
9846 |
|
9847 |
|
9848 | var nullComponentIdsRegistry = {};
|
9849 |
|
9850 | var ReactEmptyComponentInjection = {
|
9851 | injectEmptyComponent: function(emptyComponent) {
|
9852 | component = ReactElement.createFactory(emptyComponent);
|
9853 | }
|
9854 | };
|
9855 |
|
9856 |
|
9857 |
|
9858 |
|
9859 | function getEmptyComponent() {
|
9860 | ("production" !== "development" ? invariant(
|
9861 | component,
|
9862 | 'Trying to return null from a render, but no null placeholder component ' +
|
9863 | 'was injected.'
|
9864 | ) : invariant(component));
|
9865 | return component();
|
9866 | }
|
9867 |
|
9868 |
|
9869 |
|
9870 |
|
9871 |
|
9872 | function registerNullComponentID(id) {
|
9873 | nullComponentIdsRegistry[id] = true;
|
9874 | }
|
9875 |
|
9876 |
|
9877 |
|
9878 |
|
9879 |
|
9880 | function deregisterNullComponentID(id) {
|
9881 | delete nullComponentIdsRegistry[id];
|
9882 | }
|
9883 |
|
9884 |
|
9885 |
|
9886 |
|
9887 |
|
9888 | function isNullComponentID(id) {
|
9889 | return nullComponentIdsRegistry[id];
|
9890 | }
|
9891 |
|
9892 | var ReactEmptyComponent = {
|
9893 | deregisterNullComponentID: deregisterNullComponentID,
|
9894 | getEmptyComponent: getEmptyComponent,
|
9895 | injection: ReactEmptyComponentInjection,
|
9896 | isNullComponentID: isNullComponentID,
|
9897 | registerNullComponentID: registerNullComponentID
|
9898 | };
|
9899 |
|
9900 | module.exports = ReactEmptyComponent;
|
9901 |
|
9902 | },{"./ReactElement":52,"./invariant":126}],55:[function(_dereq_,module,exports){
|
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 |
|
9908 |
|
9909 |
|
9910 |
|
9911 |
|
9912 |
|
9913 |
|
9914 |
|
9915 | "use strict";
|
9916 |
|
9917 | var ReactErrorUtils = {
|
9918 | |
9919 |
|
9920 |
|
9921 |
|
9922 |
|
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 | guard: function(func, name) {
|
9928 | return func;
|
9929 | }
|
9930 | };
|
9931 |
|
9932 | module.exports = ReactErrorUtils;
|
9933 |
|
9934 | },{}],56:[function(_dereq_,module,exports){
|
9935 |
|
9936 |
|
9937 |
|
9938 |
|
9939 |
|
9940 |
|
9941 |
|
9942 |
|
9943 |
|
9944 |
|
9945 |
|
9946 | "use strict";
|
9947 |
|
9948 | var EventPluginHub = _dereq_("./EventPluginHub");
|
9949 |
|
9950 | function runEventQueueInBatch(events) {
|
9951 | EventPluginHub.enqueueEvents(events);
|
9952 | EventPluginHub.processEventQueue();
|
9953 | }
|
9954 |
|
9955 | var ReactEventEmitterMixin = {
|
9956 |
|
9957 | |
9958 |
|
9959 |
|
9960 |
|
9961 |
|
9962 |
|
9963 |
|
9964 |
|
9965 |
|
9966 | handleTopLevel: function(
|
9967 | topLevelType,
|
9968 | topLevelTarget,
|
9969 | topLevelTargetID,
|
9970 | nativeEvent) {
|
9971 | var events = EventPluginHub.extractEvents(
|
9972 | topLevelType,
|
9973 | topLevelTarget,
|
9974 | topLevelTargetID,
|
9975 | nativeEvent
|
9976 | );
|
9977 |
|
9978 | runEventQueueInBatch(events);
|
9979 | }
|
9980 | };
|
9981 |
|
9982 | module.exports = ReactEventEmitterMixin;
|
9983 |
|
9984 | },{"./EventPluginHub":18}],57:[function(_dereq_,module,exports){
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 |
|
9995 |
|
9996 |
|
9997 | "use strict";
|
9998 |
|
9999 | var EventListener = _dereq_("./EventListener");
|
10000 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
10001 | var PooledClass = _dereq_("./PooledClass");
|
10002 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
10003 | var ReactMount = _dereq_("./ReactMount");
|
10004 | var ReactUpdates = _dereq_("./ReactUpdates");
|
10005 |
|
10006 | var assign = _dereq_("./Object.assign");
|
10007 | var getEventTarget = _dereq_("./getEventTarget");
|
10008 | var getUnboundedScrollPosition = _dereq_("./getUnboundedScrollPosition");
|
10009 |
|
10010 |
|
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 |
|
10016 |
|
10017 | function findParent(node) {
|
10018 |
|
10019 |
|
10020 |
|
10021 | var nodeID = ReactMount.getID(node);
|
10022 | var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
|
10023 | var container = ReactMount.findReactContainerForID(rootID);
|
10024 | var parent = ReactMount.getFirstReactDOM(container);
|
10025 | return parent;
|
10026 | }
|
10027 |
|
10028 |
|
10029 | function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
|
10030 | this.topLevelType = topLevelType;
|
10031 | this.nativeEvent = nativeEvent;
|
10032 | this.ancestors = [];
|
10033 | }
|
10034 | assign(TopLevelCallbackBookKeeping.prototype, {
|
10035 | destructor: function() {
|
10036 | this.topLevelType = null;
|
10037 | this.nativeEvent = null;
|
10038 | this.ancestors.length = 0;
|
10039 | }
|
10040 | });
|
10041 | PooledClass.addPoolingTo(
|
10042 | TopLevelCallbackBookKeeping,
|
10043 | PooledClass.twoArgumentPooler
|
10044 | );
|
10045 |
|
10046 | function handleTopLevelImpl(bookKeeping) {
|
10047 | var topLevelTarget = ReactMount.getFirstReactDOM(
|
10048 | getEventTarget(bookKeeping.nativeEvent)
|
10049 | ) || window;
|
10050 |
|
10051 |
|
10052 |
|
10053 |
|
10054 |
|
10055 | var ancestor = topLevelTarget;
|
10056 | while (ancestor) {
|
10057 | bookKeeping.ancestors.push(ancestor);
|
10058 | ancestor = findParent(ancestor);
|
10059 | }
|
10060 |
|
10061 | for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
|
10062 | topLevelTarget = bookKeeping.ancestors[i];
|
10063 | var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
|
10064 | ReactEventListener._handleTopLevel(
|
10065 | bookKeeping.topLevelType,
|
10066 | topLevelTarget,
|
10067 | topLevelTargetID,
|
10068 | bookKeeping.nativeEvent
|
10069 | );
|
10070 | }
|
10071 | }
|
10072 |
|
10073 | function scrollValueMonitor(cb) {
|
10074 | var scrollPosition = getUnboundedScrollPosition(window);
|
10075 | cb(scrollPosition);
|
10076 | }
|
10077 |
|
10078 | var ReactEventListener = {
|
10079 | _enabled: true,
|
10080 | _handleTopLevel: null,
|
10081 |
|
10082 | WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
|
10083 |
|
10084 | setHandleTopLevel: function(handleTopLevel) {
|
10085 | ReactEventListener._handleTopLevel = handleTopLevel;
|
10086 | },
|
10087 |
|
10088 | setEnabled: function(enabled) {
|
10089 | ReactEventListener._enabled = !!enabled;
|
10090 | },
|
10091 |
|
10092 | isEnabled: function() {
|
10093 | return ReactEventListener._enabled;
|
10094 | },
|
10095 |
|
10096 |
|
10097 | |
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 |
|
10103 |
|
10104 |
|
10105 |
|
10106 |
|
10107 | trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
|
10108 | var element = handle;
|
10109 | if (!element) {
|
10110 | return;
|
10111 | }
|
10112 | return EventListener.listen(
|
10113 | element,
|
10114 | handlerBaseName,
|
10115 | ReactEventListener.dispatchEvent.bind(null, topLevelType)
|
10116 | );
|
10117 | },
|
10118 |
|
10119 | |
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 | trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
|
10130 | var element = handle;
|
10131 | if (!element) {
|
10132 | return;
|
10133 | }
|
10134 | return EventListener.capture(
|
10135 | element,
|
10136 | handlerBaseName,
|
10137 | ReactEventListener.dispatchEvent.bind(null, topLevelType)
|
10138 | );
|
10139 | },
|
10140 |
|
10141 | monitorScrollValue: function(refresh) {
|
10142 | var callback = scrollValueMonitor.bind(null, refresh);
|
10143 | EventListener.listen(window, 'scroll', callback);
|
10144 | EventListener.listen(window, 'resize', callback);
|
10145 | },
|
10146 |
|
10147 | dispatchEvent: function(topLevelType, nativeEvent) {
|
10148 | if (!ReactEventListener._enabled) {
|
10149 | return;
|
10150 | }
|
10151 |
|
10152 | var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
|
10153 | topLevelType,
|
10154 | nativeEvent
|
10155 | );
|
10156 | try {
|
10157 |
|
10158 |
|
10159 | ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
|
10160 | } finally {
|
10161 | TopLevelCallbackBookKeeping.release(bookKeeping);
|
10162 | }
|
10163 | }
|
10164 | };
|
10165 |
|
10166 | module.exports = ReactEventListener;
|
10167 |
|
10168 | },{"./EventListener":17,"./ExecutionEnvironment":22,"./Object.assign":27,"./PooledClass":28,"./ReactInstanceHandles":60,"./ReactMount":63,"./ReactUpdates":79,"./getEventTarget":117,"./getUnboundedScrollPosition":122}],58:[function(_dereq_,module,exports){
|
10169 |
|
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 |
|
10177 |
|
10178 |
|
10179 |
|
10180 | "use strict";
|
10181 |
|
10182 | var DOMProperty = _dereq_("./DOMProperty");
|
10183 | var EventPluginHub = _dereq_("./EventPluginHub");
|
10184 | var ReactComponent = _dereq_("./ReactComponent");
|
10185 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
10186 | var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
|
10187 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
10188 | var ReactNativeComponent = _dereq_("./ReactNativeComponent");
|
10189 | var ReactPerf = _dereq_("./ReactPerf");
|
10190 | var ReactRootIndex = _dereq_("./ReactRootIndex");
|
10191 | var ReactUpdates = _dereq_("./ReactUpdates");
|
10192 |
|
10193 | var ReactInjection = {
|
10194 | Component: ReactComponent.injection,
|
10195 | CompositeComponent: ReactCompositeComponent.injection,
|
10196 | DOMProperty: DOMProperty.injection,
|
10197 | EmptyComponent: ReactEmptyComponent.injection,
|
10198 | EventPluginHub: EventPluginHub.injection,
|
10199 | EventEmitter: ReactBrowserEventEmitter.injection,
|
10200 | NativeComponent: ReactNativeComponent.injection,
|
10201 | Perf: ReactPerf.injection,
|
10202 | RootIndex: ReactRootIndex.injection,
|
10203 | Updates: ReactUpdates.injection
|
10204 | };
|
10205 |
|
10206 | module.exports = ReactInjection;
|
10207 |
|
10208 | },{"./DOMProperty":11,"./EventPluginHub":18,"./ReactBrowserEventEmitter":30,"./ReactComponent":32,"./ReactCompositeComponent":34,"./ReactEmptyComponent":54,"./ReactNativeComponent":66,"./ReactPerf":68,"./ReactRootIndex":75,"./ReactUpdates":79}],59:[function(_dereq_,module,exports){
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 |
|
10214 |
|
10215 |
|
10216 |
|
10217 |
|
10218 |
|
10219 |
|
10220 | "use strict";
|
10221 |
|
10222 | var ReactDOMSelection = _dereq_("./ReactDOMSelection");
|
10223 |
|
10224 | var containsNode = _dereq_("./containsNode");
|
10225 | var focusNode = _dereq_("./focusNode");
|
10226 | var getActiveElement = _dereq_("./getActiveElement");
|
10227 |
|
10228 | function isInDocument(node) {
|
10229 | return containsNode(document.documentElement, node);
|
10230 | }
|
10231 |
|
10232 |
|
10233 |
|
10234 |
|
10235 |
|
10236 |
|
10237 |
|
10238 | var ReactInputSelection = {
|
10239 |
|
10240 | hasSelectionCapabilities: function(elem) {
|
10241 | return elem && (
|
10242 | (elem.nodeName === 'INPUT' && elem.type === 'text') ||
|
10243 | elem.nodeName === 'TEXTAREA' ||
|
10244 | elem.contentEditable === 'true'
|
10245 | );
|
10246 | },
|
10247 |
|
10248 | getSelectionInformation: function() {
|
10249 | var focusedElem = getActiveElement();
|
10250 | return {
|
10251 | focusedElem: focusedElem,
|
10252 | selectionRange:
|
10253 | ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
|
10254 | ReactInputSelection.getSelection(focusedElem) :
|
10255 | null
|
10256 | };
|
10257 | },
|
10258 |
|
10259 | |
10260 |
|
10261 |
|
10262 |
|
10263 |
|
10264 | restoreSelection: function(priorSelectionInformation) {
|
10265 | var curFocusedElem = getActiveElement();
|
10266 | var priorFocusedElem = priorSelectionInformation.focusedElem;
|
10267 | var priorSelectionRange = priorSelectionInformation.selectionRange;
|
10268 | if (curFocusedElem !== priorFocusedElem &&
|
10269 | isInDocument(priorFocusedElem)) {
|
10270 | if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
|
10271 | ReactInputSelection.setSelection(
|
10272 | priorFocusedElem,
|
10273 | priorSelectionRange
|
10274 | );
|
10275 | }
|
10276 | focusNode(priorFocusedElem);
|
10277 | }
|
10278 | },
|
10279 |
|
10280 | |
10281 |
|
10282 |
|
10283 |
|
10284 |
|
10285 |
|
10286 | getSelection: function(input) {
|
10287 | var selection;
|
10288 |
|
10289 | if ('selectionStart' in input) {
|
10290 |
|
10291 | selection = {
|
10292 | start: input.selectionStart,
|
10293 | end: input.selectionEnd
|
10294 | };
|
10295 | } else if (document.selection && input.nodeName === 'INPUT') {
|
10296 |
|
10297 | var range = document.selection.createRange();
|
10298 |
|
10299 |
|
10300 | if (range.parentElement() === input) {
|
10301 | selection = {
|
10302 | start: -range.moveStart('character', -input.value.length),
|
10303 | end: -range.moveEnd('character', -input.value.length)
|
10304 | };
|
10305 | }
|
10306 | } else {
|
10307 |
|
10308 | selection = ReactDOMSelection.getOffsets(input);
|
10309 | }
|
10310 |
|
10311 | return selection || {start: 0, end: 0};
|
10312 | },
|
10313 |
|
10314 | |
10315 |
|
10316 |
|
10317 |
|
10318 |
|
10319 |
|
10320 | setSelection: function(input, offsets) {
|
10321 | var start = offsets.start;
|
10322 | var end = offsets.end;
|
10323 | if (typeof end === 'undefined') {
|
10324 | end = start;
|
10325 | }
|
10326 |
|
10327 | if ('selectionStart' in input) {
|
10328 | input.selectionStart = start;
|
10329 | input.selectionEnd = Math.min(end, input.value.length);
|
10330 | } else if (document.selection && input.nodeName === 'INPUT') {
|
10331 | var range = input.createTextRange();
|
10332 | range.collapse(true);
|
10333 | range.moveStart('character', start);
|
10334 | range.moveEnd('character', end - start);
|
10335 | range.select();
|
10336 | } else {
|
10337 | ReactDOMSelection.setOffsets(input, offsets);
|
10338 | }
|
10339 | }
|
10340 | };
|
10341 |
|
10342 | module.exports = ReactInputSelection;
|
10343 |
|
10344 | },{"./ReactDOMSelection":46,"./containsNode":101,"./focusNode":111,"./getActiveElement":113}],60:[function(_dereq_,module,exports){
|
10345 |
|
10346 |
|
10347 |
|
10348 |
|
10349 |
|
10350 |
|
10351 |
|
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 |
|
10357 | "use strict";
|
10358 |
|
10359 | var ReactRootIndex = _dereq_("./ReactRootIndex");
|
10360 |
|
10361 | var invariant = _dereq_("./invariant");
|
10362 |
|
10363 | var SEPARATOR = '.';
|
10364 | var SEPARATOR_LENGTH = SEPARATOR.length;
|
10365 |
|
10366 |
|
10367 |
|
10368 |
|
10369 | var MAX_TREE_DEPTH = 100;
|
10370 |
|
10371 |
|
10372 |
|
10373 |
|
10374 |
|
10375 |
|
10376 |
|
10377 |
|
10378 | function getReactRootIDString(index) {
|
10379 | return SEPARATOR + index.toString(36);
|
10380 | }
|
10381 |
|
10382 |
|
10383 |
|
10384 |
|
10385 |
|
10386 |
|
10387 |
|
10388 |
|
10389 |
|
10390 | function isBoundary(id, index) {
|
10391 | return id.charAt(index) === SEPARATOR || index === id.length;
|
10392 | }
|
10393 |
|
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 |
|
10399 |
|
10400 |
|
10401 | function isValidID(id) {
|
10402 | return id === '' || (
|
10403 | id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
|
10404 | );
|
10405 | }
|
10406 |
|
10407 |
|
10408 |
|
10409 |
|
10410 |
|
10411 |
|
10412 |
|
10413 |
|
10414 |
|
10415 | function isAncestorIDOf(ancestorID, descendantID) {
|
10416 | return (
|
10417 | descendantID.indexOf(ancestorID) === 0 &&
|
10418 | isBoundary(descendantID, ancestorID.length)
|
10419 | );
|
10420 | }
|
10421 |
|
10422 |
|
10423 |
|
10424 |
|
10425 |
|
10426 |
|
10427 |
|
10428 |
|
10429 | function getParentID(id) {
|
10430 | return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
|
10431 | }
|
10432 |
|
10433 |
|
10434 |
|
10435 |
|
10436 |
|
10437 |
|
10438 |
|
10439 |
|
10440 |
|
10441 |
|
10442 | function getNextDescendantID(ancestorID, destinationID) {
|
10443 | ("production" !== "development" ? invariant(
|
10444 | isValidID(ancestorID) && isValidID(destinationID),
|
10445 | 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
|
10446 | ancestorID,
|
10447 | destinationID
|
10448 | ) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
|
10449 | ("production" !== "development" ? invariant(
|
10450 | isAncestorIDOf(ancestorID, destinationID),
|
10451 | 'getNextDescendantID(...): React has made an invalid assumption about ' +
|
10452 | 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
|
10453 | ancestorID,
|
10454 | destinationID
|
10455 | ) : invariant(isAncestorIDOf(ancestorID, destinationID)));
|
10456 | if (ancestorID === destinationID) {
|
10457 | return ancestorID;
|
10458 | }
|
10459 |
|
10460 |
|
10461 | var start = ancestorID.length + SEPARATOR_LENGTH;
|
10462 | for (var i = start; i < destinationID.length; i++) {
|
10463 | if (isBoundary(destinationID, i)) {
|
10464 | break;
|
10465 | }
|
10466 | }
|
10467 | return destinationID.substr(0, i);
|
10468 | }
|
10469 |
|
10470 |
|
10471 |
|
10472 |
|
10473 |
|
10474 |
|
10475 |
|
10476 |
|
10477 |
|
10478 |
|
10479 |
|
10480 |
|
10481 | function getFirstCommonAncestorID(oneID, twoID) {
|
10482 | var minLength = Math.min(oneID.length, twoID.length);
|
10483 | if (minLength === 0) {
|
10484 | return '';
|
10485 | }
|
10486 | var lastCommonMarkerIndex = 0;
|
10487 |
|
10488 | for (var i = 0; i <= minLength; i++) {
|
10489 | if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
|
10490 | lastCommonMarkerIndex = i;
|
10491 | } else if (oneID.charAt(i) !== twoID.charAt(i)) {
|
10492 | break;
|
10493 | }
|
10494 | }
|
10495 | var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
|
10496 | ("production" !== "development" ? invariant(
|
10497 | isValidID(longestCommonID),
|
10498 | 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
|
10499 | oneID,
|
10500 | twoID,
|
10501 | longestCommonID
|
10502 | ) : invariant(isValidID(longestCommonID)));
|
10503 | return longestCommonID;
|
10504 | }
|
10505 |
|
10506 |
|
10507 |
|
10508 |
|
10509 |
|
10510 |
|
10511 |
|
10512 |
|
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 |
|
10518 | function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
|
10519 | start = start || '';
|
10520 | stop = stop || '';
|
10521 | ("production" !== "development" ? invariant(
|
10522 | start !== stop,
|
10523 | 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
|
10524 | start
|
10525 | ) : invariant(start !== stop));
|
10526 | var traverseUp = isAncestorIDOf(stop, start);
|
10527 | ("production" !== "development" ? invariant(
|
10528 | traverseUp || isAncestorIDOf(start, stop),
|
10529 | 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
|
10530 | 'not have a parent path.',
|
10531 | start,
|
10532 | stop
|
10533 | ) : invariant(traverseUp || isAncestorIDOf(start, stop)));
|
10534 |
|
10535 | var depth = 0;
|
10536 | var traverse = traverseUp ? getParentID : getNextDescendantID;
|
10537 | for (var id = start; ; id = traverse(id, stop)) {
|
10538 | var ret;
|
10539 | if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
|
10540 | ret = cb(id, traverseUp, arg);
|
10541 | }
|
10542 | if (ret === false || id === stop) {
|
10543 |
|
10544 | break;
|
10545 | }
|
10546 | ("production" !== "development" ? invariant(
|
10547 | depth++ < MAX_TREE_DEPTH,
|
10548 | 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
|
10549 | 'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
|
10550 | start, stop
|
10551 | ) : invariant(depth++ < MAX_TREE_DEPTH));
|
10552 | }
|
10553 | }
|
10554 |
|
10555 | /**
|
10556 | * Manages the IDs assigned to DOM representations of React components. This
|
10557 | * uses a specific scheme in order to traverse the DOM efficiently (e.g. in
|
10558 | * order to simulate events).
|
10559 | *
|
10560 | * @internal
|
10561 | */
|
10562 | var ReactInstanceHandles = {
|
10563 |
|
10564 | /**
|
10565 | * Constructs a React root ID
|
10566 | * @return {string} A React root ID.
|
10567 | */
|
10568 | createReactRootID: function() {
|
10569 | return getReactRootIDString(ReactRootIndex.createReactRootIndex());
|
10570 | },
|
10571 |
|
10572 | /**
|
10573 | * Constructs a React ID by joining a root ID with a name.
|
10574 | *
|
10575 | * @param {string} rootID Root ID of a parent component.
|
10576 | * @param {string} name A component's name (as flattened children).
|
10577 | * @return {string} A React ID.
|
10578 | * @internal
|
10579 | */
|
10580 | createReactID: function(rootID, name) {
|
10581 | return rootID + name;
|
10582 | },
|
10583 |
|
10584 | /**
|
10585 | * Gets the DOM ID of the React component that is the root of the tree that
|
10586 | * contains the React component with the supplied DOM ID.
|
10587 | *
|
10588 | * @param {string} id DOM ID of a React component.
|
10589 | * @return {?string} DOM ID of the React component that is the root.
|
10590 | * @internal
|
10591 | */
|
10592 | getReactRootIDFromNodeID: function(id) {
|
10593 | if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
|
10594 | var index = id.indexOf(SEPARATOR, 1);
|
10595 | return index > -1 ? id.substr(0, index) : id;
|
10596 | }
|
10597 | return null;
|
10598 | },
|
10599 |
|
10600 | /**
|
10601 | * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
|
10602 | * should would receive a `mouseEnter` or `mouseLeave` event.
|
10603 | *
|
10604 | * NOTE: Does not invoke the callback on the nearest common ancestor because
|
10605 | * nothing "entered" or "left" that element.
|
10606 | *
|
10607 | * @param {string} leaveID ID being left.
|
10608 | * @param {string} enterID ID being entered.
|
10609 | * @param {function} cb Callback to invoke on each entered/left ID.
|
10610 | * @param {*} upArg Argument to invoke the callback with on left IDs.
|
10611 | * @param {*} downArg Argument to invoke the callback with on entered IDs.
|
10612 | * @internal
|
10613 | */
|
10614 | traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
|
10615 | var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
|
10616 | if (ancestorID !== leaveID) {
|
10617 | traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
|
10618 | }
|
10619 | if (ancestorID !== enterID) {
|
10620 | traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
|
10621 | }
|
10622 | },
|
10623 |
|
10624 | /**
|
10625 | * Simulates the traversal of a two-phase, capture/bubble event dispatch.
|
10626 | *
|
10627 | * NOTE: This traversal happens on IDs without touching the DOM.
|
10628 | *
|
10629 | * @param {string} targetID ID of the target node.
|
10630 | * @param {function} cb Callback to invoke.
|
10631 | * @param {*} arg Argument to invoke the callback with.
|
10632 | * @internal
|
10633 | */
|
10634 | traverseTwoPhase: function(targetID, cb, arg) {
|
10635 | if (targetID) {
|
10636 | traverseParentPath('', targetID, cb, arg, true, false);
|
10637 | traverseParentPath(targetID, '', cb, arg, false, true);
|
10638 | }
|
10639 | },
|
10640 |
|
10641 | /**
|
10642 | * Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
|
10643 | * example, passing `.0.$row-0.1` would result in `cb` getting called
|
10644 | * with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
|
10645 | *
|
10646 | * NOTE: This traversal happens on IDs without touching the DOM.
|
10647 | *
|
10648 | * @param {string} targetID ID of the target node.
|
10649 | * @param {function} cb Callback to invoke.
|
10650 | * @param {*} arg Argument to invoke the callback with.
|
10651 | * @internal
|
10652 | */
|
10653 | traverseAncestors: function(targetID, cb, arg) {
|
10654 | traverseParentPath('', targetID, cb, arg, true, false);
|
10655 | },
|
10656 |
|
10657 | /**
|
10658 | * Exposed for unit testing.
|
10659 | * @private
|
10660 | */
|
10661 | _getFirstCommonAncestorID: getFirstCommonAncestorID,
|
10662 |
|
10663 | /**
|
10664 | * Exposed for unit testing.
|
10665 | * @private
|
10666 | */
|
10667 | _getNextDescendantID: getNextDescendantID,
|
10668 |
|
10669 | isAncestorIDOf: isAncestorIDOf,
|
10670 |
|
10671 | SEPARATOR: SEPARATOR
|
10672 |
|
10673 | };
|
10674 |
|
10675 | module.exports = ReactInstanceHandles;
|
10676 |
|
10677 | },{"./ReactRootIndex":75,"./invariant":126}],61:[function(_dereq_,module,exports){
|
10678 | /**
|
10679 | * Copyright 2014, Facebook, Inc.
|
10680 | * All rights reserved.
|
10681 | *
|
10682 | * This source code is licensed under the BSD-style license found in the
|
10683 | * LICENSE file in the root directory of this source tree. An additional grant
|
10684 | * of patent rights can be found in the PATENTS file in the same directory.
|
10685 | *
|
10686 | * @providesModule ReactLegacyElement
|
10687 | */
|
10688 |
|
10689 | "use strict";
|
10690 |
|
10691 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
10692 |
|
10693 | var invariant = _dereq_("./invariant");
|
10694 | var monitorCodeUse = _dereq_("./monitorCodeUse");
|
10695 | var warning = _dereq_("./warning");
|
10696 |
|
10697 | var legacyFactoryLogs = {};
|
10698 | function warnForLegacyFactoryCall() {
|
10699 | if (!ReactLegacyElementFactory._isLegacyCallWarningEnabled) {
|
10700 | return;
|
10701 | }
|
10702 | var owner = ReactCurrentOwner.current;
|
10703 | var name = owner && owner.constructor ? owner.constructor.displayName : '';
|
10704 | if (!name) {
|
10705 | name = 'Something';
|
10706 | }
|
10707 | if (legacyFactoryLogs.hasOwnProperty(name)) {
|
10708 | return;
|
10709 | }
|
10710 | legacyFactoryLogs[name] = true;
|
10711 | ("production" !== "development" ? warning(
|
10712 | false,
|
10713 | name + ' is calling a React component directly. ' +
|
10714 | 'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
|
10715 | ) : null);
|
10716 | monitorCodeUse('react_legacy_factory_call', { version: 3, name: name });
|
10717 | }
|
10718 |
|
10719 | function warnForPlainFunctionType(type) {
|
10720 | var isReactClass =
|
10721 | type.prototype &&
|
10722 | typeof type.prototype.mountComponent === 'function' &&
|
10723 | typeof type.prototype.receiveComponent === 'function';
|
10724 | if (isReactClass) {
|
10725 | ("production" !== "development" ? warning(
|
10726 | false,
|
10727 | 'Did not expect to get a React class here. Use `Component` instead ' +
|
10728 | 'of `Component.type` or `this.constructor`.'
|
10729 | ) : null);
|
10730 | } else {
|
10731 | if (!type._reactWarnedForThisType) {
|
10732 | try {
|
10733 | type._reactWarnedForThisType = true;
|
10734 | } catch (x) {
|
10735 | // just incase this is a frozen object or some special object
|
10736 | }
|
10737 | monitorCodeUse(
|
10738 | 'react_non_component_in_jsx',
|
10739 | { version: 3, name: type.name }
|
10740 | );
|
10741 | }
|
10742 | ("production" !== "development" ? warning(
|
10743 | false,
|
10744 | 'This JSX uses a plain function. Only React components are ' +
|
10745 | 'valid in React\'s JSX transform.'
|
10746 | ) : null);
|
10747 | }
|
10748 | }
|
10749 |
|
10750 | function warnForNonLegacyFactory(type) {
|
10751 | ("production" !== "development" ? warning(
|
10752 | false,
|
10753 | 'Do not pass React.DOM.' + type.type + ' to JSX or createFactory. ' +
|
10754 | 'Use the string "' + type.type + '" instead.'
|
10755 | ) : null);
|
10756 | }
|
10757 |
|
10758 | /**
|
10759 | * Transfer static properties from the source to the target. Functions are
|
10760 | * rebound to have this reflect the original source.
|
10761 | */
|
10762 | function proxyStaticMethods(target, source) {
|
10763 | if (typeof source !== 'function') {
|
10764 | return;
|
10765 | }
|
10766 | for (var key in source) {
|
10767 | if (source.hasOwnProperty(key)) {
|
10768 | var value = source[key];
|
10769 | if (typeof value === 'function') {
|
10770 | var bound = value.bind(source);
|
10771 | // Copy any properties defined on the function, such as `isRequired` on
|
10772 | // a PropTypes validator.
|
10773 | for (var k in value) {
|
10774 | if (value.hasOwnProperty(k)) {
|
10775 | bound[k] = value[k];
|
10776 | }
|
10777 | }
|
10778 | target[key] = bound;
|
10779 | } else {
|
10780 | target[key] = value;
|
10781 | }
|
10782 | }
|
10783 | }
|
10784 | }
|
10785 |
|
10786 | // We use an object instead of a boolean because booleans are ignored by our
|
10787 | // mocking libraries when these factories gets mocked.
|
10788 | var LEGACY_MARKER = {};
|
10789 | var NON_LEGACY_MARKER = {};
|
10790 |
|
10791 | var ReactLegacyElementFactory = {};
|
10792 |
|
10793 | ReactLegacyElementFactory.wrapCreateFactory = function(createFactory) {
|
10794 | var legacyCreateFactory = function(type) {
|
10795 | if (typeof type !== 'function') {
|
10796 | // Non-function types cannot be legacy factories
|
10797 | return createFactory(type);
|
10798 | }
|
10799 |
|
10800 | if (type.isReactNonLegacyFactory) {
|
10801 | // This is probably a factory created by ReactDOM we unwrap it to get to
|
10802 | // the underlying string type. It shouldn't have been passed here so we
|
10803 | // warn.
|
10804 | if ("production" !== "development") {
|
10805 | warnForNonLegacyFactory(type);
|
10806 | }
|
10807 | return createFactory(type.type);
|
10808 | }
|
10809 |
|
10810 | if (type.isReactLegacyFactory) {
|
10811 | // This is probably a legacy factory created by ReactCompositeComponent.
|
10812 | // We unwrap it to get to the underlying class.
|
10813 | return createFactory(type.type);
|
10814 | }
|
10815 |
|
10816 | if ("production" !== "development") {
|
10817 | warnForPlainFunctionType(type);
|
10818 | }
|
10819 |
|
10820 | // Unless it's a legacy factory, then this is probably a plain function,
|
10821 | // that is expecting to be invoked by JSX. We can just return it as is.
|
10822 | return type;
|
10823 | };
|
10824 | return legacyCreateFactory;
|
10825 | };
|
10826 |
|
10827 | ReactLegacyElementFactory.wrapCreateElement = function(createElement) {
|
10828 | var legacyCreateElement = function(type, props, children) {
|
10829 | if (typeof type !== 'function') {
|
10830 | // Non-function types cannot be legacy factories
|
10831 | return createElement.apply(this, arguments);
|
10832 | }
|
10833 |
|
10834 | var args;
|
10835 |
|
10836 | if (type.isReactNonLegacyFactory) {
|
10837 | // This is probably a factory created by ReactDOM we unwrap it to get to
|
10838 | // the underlying string type. It shouldn't have been passed here so we
|
10839 | // warn.
|
10840 | if ("production" !== "development") {
|
10841 | warnForNonLegacyFactory(type);
|
10842 | }
|
10843 | args = Array.prototype.slice.call(arguments, 0);
|
10844 | args[0] = type.type;
|
10845 | return createElement.apply(this, args);
|
10846 | }
|
10847 |
|
10848 | if (type.isReactLegacyFactory) {
|
10849 | // This is probably a legacy factory created by ReactCompositeComponent.
|
10850 | // We unwrap it to get to the underlying class.
|
10851 | if (type._isMockFunction) {
|
10852 | // If this is a mock function, people will expect it to be called. We
|
10853 | // will actually call the original mock factory function instead. This
|
10854 | // future proofs unit testing that assume that these are classes.
|
10855 | type.type._mockedReactClassConstructor = type;
|
10856 | }
|
10857 | args = Array.prototype.slice.call(arguments, 0);
|
10858 | args[0] = type.type;
|
10859 | return createElement.apply(this, args);
|
10860 | }
|
10861 |
|
10862 | if ("production" !== "development") {
|
10863 | warnForPlainFunctionType(type);
|
10864 | }
|
10865 |
|
10866 | // This is being called with a plain function we should invoke it
|
10867 | // immediately as if this was used with legacy JSX.
|
10868 | return type.apply(null, Array.prototype.slice.call(arguments, 1));
|
10869 | };
|
10870 | return legacyCreateElement;
|
10871 | };
|
10872 |
|
10873 | ReactLegacyElementFactory.wrapFactory = function(factory) {
|
10874 | ("production" !== "development" ? invariant(
|
10875 | typeof factory === 'function',
|
10876 | 'This is suppose to accept a element factory'
|
10877 | ) : invariant(typeof factory === 'function'));
|
10878 | var legacyElementFactory = function(config, children) {
|
10879 | // This factory should not be called when JSX is used. Use JSX instead.
|
10880 | if ("production" !== "development") {
|
10881 | warnForLegacyFactoryCall();
|
10882 | }
|
10883 | return factory.apply(this, arguments);
|
10884 | };
|
10885 | proxyStaticMethods(legacyElementFactory, factory.type);
|
10886 | legacyElementFactory.isReactLegacyFactory = LEGACY_MARKER;
|
10887 | legacyElementFactory.type = factory.type;
|
10888 | return legacyElementFactory;
|
10889 | };
|
10890 |
|
10891 | // This is used to mark a factory that will remain. E.g. we're allowed to call
|
10892 | // it as a function. However, you're not suppose to pass it to createElement
|
10893 | // or createFactory, so it will warn you if you do.
|
10894 | ReactLegacyElementFactory.markNonLegacyFactory = function(factory) {
|
10895 | factory.isReactNonLegacyFactory = NON_LEGACY_MARKER;
|
10896 | return factory;
|
10897 | };
|
10898 |
|
10899 | // Checks if a factory function is actually a legacy factory pretending to
|
10900 | // be a class.
|
10901 | ReactLegacyElementFactory.isValidFactory = function(factory) {
|
10902 | // TODO: This will be removed and moved into a class validator or something.
|
10903 | return typeof factory === 'function' &&
|
10904 | factory.isReactLegacyFactory === LEGACY_MARKER;
|
10905 | };
|
10906 |
|
10907 | ReactLegacyElementFactory.isValidClass = function(factory) {
|
10908 | if ("production" !== "development") {
|
10909 | ("production" !== "development" ? warning(
|
10910 | false,
|
10911 | 'isValidClass is deprecated and will be removed in a future release. ' +
|
10912 | 'Use a more specific validator instead.'
|
10913 | ) : null);
|
10914 | }
|
10915 | return ReactLegacyElementFactory.isValidFactory(factory);
|
10916 | };
|
10917 |
|
10918 | ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
|
10919 |
|
10920 | module.exports = ReactLegacyElementFactory;
|
10921 |
|
10922 | },{"./ReactCurrentOwner":36,"./invariant":126,"./monitorCodeUse":136,"./warning":145}],62:[function(_dereq_,module,exports){
|
10923 | /**
|
10924 | * Copyright 2013-2014, Facebook, Inc.
|
10925 | * All rights reserved.
|
10926 | *
|
10927 | * This source code is licensed under the BSD-style license found in the
|
10928 | * LICENSE file in the root directory of this source tree. An additional grant
|
10929 | * of patent rights can be found in the PATENTS file in the same directory.
|
10930 | *
|
10931 | * @providesModule ReactMarkupChecksum
|
10932 | */
|
10933 |
|
10934 | "use strict";
|
10935 |
|
10936 | var adler32 = _dereq_("./adler32");
|
10937 |
|
10938 | var ReactMarkupChecksum = {
|
10939 | CHECKSUM_ATTR_NAME: 'data-react-checksum',
|
10940 |
|
10941 | /**
|
10942 | * @param {string} markup Markup string
|
10943 | * @return {string} Markup string with checksum attribute attached
|
10944 | */
|
10945 | addChecksumToMarkup: function(markup) {
|
10946 | var checksum = adler32(markup);
|
10947 | return markup.replace(
|
10948 | '>',
|
10949 | ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
|
10950 | );
|
10951 | },
|
10952 |
|
10953 | /**
|
10954 | * @param {string} markup to use
|
10955 | * @param {DOMElement} element root React element
|
10956 | * @returns {boolean} whether or not the markup is the same
|
10957 | */
|
10958 | canReuseMarkup: function(markup, element) {
|
10959 | var existingChecksum = element.getAttribute(
|
10960 | ReactMarkupChecksum.CHECKSUM_ATTR_NAME
|
10961 | );
|
10962 | existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
|
10963 | var markupChecksum = adler32(markup);
|
10964 | return markupChecksum === existingChecksum;
|
10965 | }
|
10966 | };
|
10967 |
|
10968 | module.exports = ReactMarkupChecksum;
|
10969 |
|
10970 | },{"./adler32":98}],63:[function(_dereq_,module,exports){
|
10971 | /**
|
10972 | * Copyright 2013-2014, Facebook, Inc.
|
10973 | * All rights reserved.
|
10974 | *
|
10975 | * This source code is licensed under the BSD-style license found in the
|
10976 | * LICENSE file in the root directory of this source tree. An additional grant
|
10977 | * of patent rights can be found in the PATENTS file in the same directory.
|
10978 | *
|
10979 | * @providesModule ReactMount
|
10980 | */
|
10981 |
|
10982 | "use strict";
|
10983 |
|
10984 | var DOMProperty = _dereq_("./DOMProperty");
|
10985 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
10986 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
10987 | var ReactElement = _dereq_("./ReactElement");
|
10988 | var ReactLegacyElement = _dereq_("./ReactLegacyElement");
|
10989 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
10990 | var ReactPerf = _dereq_("./ReactPerf");
|
10991 |
|
10992 | var containsNode = _dereq_("./containsNode");
|
10993 | var deprecated = _dereq_("./deprecated");
|
10994 | var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer");
|
10995 | var instantiateReactComponent = _dereq_("./instantiateReactComponent");
|
10996 | var invariant = _dereq_("./invariant");
|
10997 | var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
|
10998 | var warning = _dereq_("./warning");
|
10999 |
|
11000 | var createElement = ReactLegacyElement.wrapCreateElement(
|
11001 | ReactElement.createElement
|
11002 | );
|
11003 |
|
11004 | var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
11005 |
|
11006 | var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
|
11007 | var nodeCache = {};
|
11008 |
|
11009 | var ELEMENT_NODE_TYPE = 1;
|
11010 | var DOC_NODE_TYPE = 9;
|
11011 |
|
11012 | /** Mapping from reactRootID to React component instance. */
|
11013 | var instancesByReactRootID = {};
|
11014 |
|
11015 | /** Mapping from reactRootID to `container` nodes. */
|
11016 | var containersByReactRootID = {};
|
11017 |
|
11018 | if ("production" !== "development") {
|
11019 | /** __DEV__-only mapping from reactRootID to root elements. */
|
11020 | var rootElementsByReactRootID = {};
|
11021 | }
|
11022 |
|
11023 | // Used to store breadth-first search state in findComponentRoot.
|
11024 | var findComponentRootReusableArray = [];
|
11025 |
|
11026 | /**
|
11027 | * @param {DOMElement} container DOM element that may contain a React component.
|
11028 | * @return {?string} A "reactRoot" ID, if a React component is rendered.
|
11029 | */
|
11030 | function getReactRootID(container) {
|
11031 | var rootElement = getReactRootElementInContainer(container);
|
11032 | return rootElement && ReactMount.getID(rootElement);
|
11033 | }
|
11034 |
|
11035 | /**
|
11036 | * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
|
11037 | * element can return its control whose name or ID equals ATTR_NAME. All
|
11038 | * DOM nodes support `getAttributeNode` but this can also get called on
|
11039 | * other objects so just return '' if we're given something other than a
|
11040 | * DOM node (such as window).
|
11041 | *
|
11042 | * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
|
11043 | * @return {string} ID of the supplied `domNode`.
|
11044 | */
|
11045 | function getID(node) {
|
11046 | var id = internalGetID(node);
|
11047 | if (id) {
|
11048 | if (nodeCache.hasOwnProperty(id)) {
|
11049 | var cached = nodeCache[id];
|
11050 | if (cached !== node) {
|
11051 | ("production" !== "development" ? invariant(
|
11052 | !isValid(cached, id),
|
11053 | 'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
|
11054 | ATTR_NAME, id
|
11055 | ) : invariant(!isValid(cached, id)));
|
11056 |
|
11057 | nodeCache[id] = node;
|
11058 | }
|
11059 | } else {
|
11060 | nodeCache[id] = node;
|
11061 | }
|
11062 | }
|
11063 |
|
11064 | return id;
|
11065 | }
|
11066 |
|
11067 | function internalGetID(node) {
|
11068 | // If node is something like a window, document, or text node, none of
|
11069 | // which support attributes or a .getAttribute method, gracefully return
|
11070 | // the empty string, as if the attribute were missing.
|
11071 | return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
|
11072 | }
|
11073 |
|
11074 | /**
|
11075 | * Sets the React-specific ID of the given node.
|
11076 | *
|
11077 | * @param {DOMElement} node The DOM node whose ID will be set.
|
11078 | * @param {string} id The value of the ID attribute.
|
11079 | */
|
11080 | function setID(node, id) {
|
11081 | var oldID = internalGetID(node);
|
11082 | if (oldID !== id) {
|
11083 | delete nodeCache[oldID];
|
11084 | }
|
11085 | node.setAttribute(ATTR_NAME, id);
|
11086 | nodeCache[id] = node;
|
11087 | }
|
11088 |
|
11089 | /**
|
11090 | * Finds the node with the supplied React-generated DOM ID.
|
11091 | *
|
11092 | * @param {string} id A React-generated DOM ID.
|
11093 | * @return {DOMElement} DOM node with the suppled `id`.
|
11094 | * @internal
|
11095 | */
|
11096 | function getNode(id) {
|
11097 | if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
|
11098 | nodeCache[id] = ReactMount.findReactNodeByID(id);
|
11099 | }
|
11100 | return nodeCache[id];
|
11101 | }
|
11102 |
|
11103 | /**
|
11104 | * A node is "valid" if it is contained by a currently mounted container.
|
11105 | *
|
11106 | * This means that the node does not have to be contained by a document in
|
11107 | * order to be considered valid.
|
11108 | *
|
11109 | * @param {?DOMElement} node The candidate DOM node.
|
11110 | * @param {string} id The expected ID of the node.
|
11111 | * @return {boolean} Whether the node is contained by a mounted container.
|
11112 | */
|
11113 | function isValid(node, id) {
|
11114 | if (node) {
|
11115 | ("production" !== "development" ? invariant(
|
11116 | internalGetID(node) === id,
|
11117 | 'ReactMount: Unexpected modification of `%s`',
|
11118 | ATTR_NAME
|
11119 | ) : invariant(internalGetID(node) === id));
|
11120 |
|
11121 | var container = ReactMount.findReactContainerForID(id);
|
11122 | if (container && containsNode(container, node)) {
|
11123 | return true;
|
11124 | }
|
11125 | }
|
11126 |
|
11127 | return false;
|
11128 | }
|
11129 |
|
11130 | /**
|
11131 | * Causes the cache to forget about one React-specific ID.
|
11132 | *
|
11133 | * @param {string} id The ID to forget.
|
11134 | */
|
11135 | function purgeID(id) {
|
11136 | delete nodeCache[id];
|
11137 | }
|
11138 |
|
11139 | var deepestNodeSoFar = null;
|
11140 | function findDeepestCachedAncestorImpl(ancestorID) {
|
11141 | var ancestor = nodeCache[ancestorID];
|
11142 | if (ancestor && isValid(ancestor, ancestorID)) {
|
11143 | deepestNodeSoFar = ancestor;
|
11144 | } else {
|
11145 | // This node isn't populated in the cache, so presumably none of its
|
11146 | // descendants are. Break out of the loop.
|
11147 | return false;
|
11148 | }
|
11149 | }
|
11150 |
|
11151 | /**
|
11152 | * Return the deepest cached node whose ID is a prefix of `targetID`.
|
11153 | */
|
11154 | function findDeepestCachedAncestor(targetID) {
|
11155 | deepestNodeSoFar = null;
|
11156 | ReactInstanceHandles.traverseAncestors(
|
11157 | targetID,
|
11158 | findDeepestCachedAncestorImpl
|
11159 | );
|
11160 |
|
11161 | var foundNode = deepestNodeSoFar;
|
11162 | deepestNodeSoFar = null;
|
11163 | return foundNode;
|
11164 | }
|
11165 |
|
11166 | /**
|
11167 | * Mounting is the process of initializing a React component by creatings its
|
11168 | * representative DOM elements and inserting them into a supplied `container`.
|
11169 | * Any prior content inside `container` is destroyed in the process.
|
11170 | *
|
11171 | * ReactMount.render(
|
11172 | * component,
|
11173 | * document.getElementById('container')
|
11174 | * );
|
11175 | *
|
11176 | * <div id="container"> <-- Supplied `container`.
|
11177 | * <div data-reactid=".3"> <-- Rendered reactRoot of React
|
11178 | * // ... component.
|
11179 | * </div>
|
11180 | * </div>
|
11181 | *
|
11182 | * Inside of `container`, the first element rendered is the "reactRoot".
|
11183 | */
|
11184 | var ReactMount = {
|
11185 | /** Exposed for debugging purposes **/
|
11186 | _instancesByReactRootID: instancesByReactRootID,
|
11187 |
|
11188 | /**
|
11189 | * This is a hook provided to support rendering React components while
|
11190 | * ensuring that the apparent scroll position of its `container` does not
|
11191 | * change.
|
11192 | *
|
11193 | * @param {DOMElement} container The `container` being rendered into.
|
11194 | * @param {function} renderCallback This must be called once to do the render.
|
11195 | */
|
11196 | scrollMonitor: function(container, renderCallback) {
|
11197 | renderCallback();
|
11198 | },
|
11199 |
|
11200 | /**
|
11201 | * Take a component that's already mounted into the DOM and replace its props
|
11202 | * @param {ReactComponent} prevComponent component instance already in the DOM
|
11203 | * @param {ReactComponent} nextComponent component instance to render
|
11204 | * @param {DOMElement} container container to render into
|
11205 | * @param {?function} callback function triggered on completion
|
11206 | */
|
11207 | _updateRootComponent: function(
|
11208 | prevComponent,
|
11209 | nextComponent,
|
11210 | container,
|
11211 | callback) {
|
11212 | var nextProps = nextComponent.props;
|
11213 | ReactMount.scrollMonitor(container, function() {
|
11214 | prevComponent.replaceProps(nextProps, callback);
|
11215 | });
|
11216 |
|
11217 | if ("production" !== "development") {
|
11218 | // Record the root element in case it later gets transplanted.
|
11219 | rootElementsByReactRootID[getReactRootID(container)] =
|
11220 | getReactRootElementInContainer(container);
|
11221 | }
|
11222 |
|
11223 | return prevComponent;
|
11224 | },
|
11225 |
|
11226 | /**
|
11227 | * Register a component into the instance map and starts scroll value
|
11228 | * monitoring
|
11229 | * @param {ReactComponent} nextComponent component instance to render
|
11230 | * @param {DOMElement} container container to render into
|
11231 | * @return {string} reactRoot ID prefix
|
11232 | */
|
11233 | _registerComponent: function(nextComponent, container) {
|
11234 | ("production" !== "development" ? invariant(
|
11235 | container && (
|
11236 | container.nodeType === ELEMENT_NODE_TYPE ||
|
11237 | container.nodeType === DOC_NODE_TYPE
|
11238 | ),
|
11239 | '_registerComponent(...): Target container is not a DOM element.'
|
11240 | ) : invariant(container && (
|
11241 | container.nodeType === ELEMENT_NODE_TYPE ||
|
11242 | container.nodeType === DOC_NODE_TYPE
|
11243 | )));
|
11244 |
|
11245 | ReactBrowserEventEmitter.ensureScrollValueMonitoring();
|
11246 |
|
11247 | var reactRootID = ReactMount.registerContainer(container);
|
11248 | instancesByReactRootID[reactRootID] = nextComponent;
|
11249 | return reactRootID;
|
11250 | },
|
11251 |
|
11252 | /**
|
11253 | * Render a new component into the DOM.
|
11254 | * @param {ReactComponent} nextComponent component instance to render
|
11255 | * @param {DOMElement} container container to render into
|
11256 | * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
|
11257 | * @return {ReactComponent} nextComponent
|
11258 | */
|
11259 | _renderNewRootComponent: ReactPerf.measure(
|
11260 | 'ReactMount',
|
11261 | '_renderNewRootComponent',
|
11262 | function(
|
11263 | nextComponent,
|
11264 | container,
|
11265 | shouldReuseMarkup) {
|
11266 | // Various parts of our code (such as ReactCompositeComponent's
|
11267 | // _renderValidatedComponent) assume that calls to render aren't nested;
|
11268 | // verify that that's the case.
|
11269 | ("production" !== "development" ? warning(
|
11270 | ReactCurrentOwner.current == null,
|
11271 | '_renderNewRootComponent(): Render methods should be a pure function ' +
|
11272 | 'of props and state; triggering nested component updates from ' +
|
11273 | 'render is not allowed. If necessary, trigger nested updates in ' +
|
11274 | 'componentDidUpdate.'
|
11275 | ) : null);
|
11276 |
|
11277 | var componentInstance = instantiateReactComponent(nextComponent, null);
|
11278 | var reactRootID = ReactMount._registerComponent(
|
11279 | componentInstance,
|
11280 | container
|
11281 | );
|
11282 | componentInstance.mountComponentIntoNode(
|
11283 | reactRootID,
|
11284 | container,
|
11285 | shouldReuseMarkup
|
11286 | );
|
11287 |
|
11288 | if ("production" !== "development") {
|
11289 | // Record the root element in case it later gets transplanted.
|
11290 | rootElementsByReactRootID[reactRootID] =
|
11291 | getReactRootElementInContainer(container);
|
11292 | }
|
11293 |
|
11294 | return componentInstance;
|
11295 | }
|
11296 | ),
|
11297 |
|
11298 | /**
|
11299 | * Renders a React component into the DOM in the supplied `container`.
|
11300 | *
|
11301 | * If the React component was previously rendered into `container`, this will
|
11302 | * perform an update on it and only mutate the DOM as necessary to reflect the
|
11303 | * latest React component.
|
11304 | *
|
11305 | * @param {ReactElement} nextElement Component element to render.
|
11306 | * @param {DOMElement} container DOM element to render into.
|
11307 | * @param {?function} callback function triggered on completion
|
11308 | * @return {ReactComponent} Component instance rendered in `container`.
|
11309 | */
|
11310 | render: function(nextElement, container, callback) {
|
11311 | ("production" !== "development" ? invariant(
|
11312 | ReactElement.isValidElement(nextElement),
|
11313 | 'renderComponent(): Invalid component element.%s',
|
11314 | (
|
11315 | typeof nextElement === 'string' ?
|
11316 | ' Instead of passing an element string, make sure to instantiate ' +
|
11317 | 'it by passing it to React.createElement.' :
|
11318 | ReactLegacyElement.isValidFactory(nextElement) ?
|
11319 | ' Instead of passing a component class, make sure to instantiate ' +
|
11320 | 'it by passing it to React.createElement.' :
|
11321 | // Check if it quacks like a element
|
11322 | typeof nextElement.props !== "undefined" ?
|
11323 | ' This may be caused by unintentionally loading two independent ' +
|
11324 | 'copies of React.' :
|
11325 | ''
|
11326 | )
|
11327 | ) : invariant(ReactElement.isValidElement(nextElement)));
|
11328 |
|
11329 | var prevComponent = instancesByReactRootID[getReactRootID(container)];
|
11330 |
|
11331 | if (prevComponent) {
|
11332 | var prevElement = prevComponent._currentElement;
|
11333 | if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
11334 | return ReactMount._updateRootComponent(
|
11335 | prevComponent,
|
11336 | nextElement,
|
11337 | container,
|
11338 | callback
|
11339 | );
|
11340 | } else {
|
11341 | ReactMount.unmountComponentAtNode(container);
|
11342 | }
|
11343 | }
|
11344 |
|
11345 | var reactRootElement = getReactRootElementInContainer(container);
|
11346 | var containerHasReactMarkup =
|
11347 | reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
|
11348 |
|
11349 | var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
|
11350 |
|
11351 | var component = ReactMount._renderNewRootComponent(
|
11352 | nextElement,
|
11353 | container,
|
11354 | shouldReuseMarkup
|
11355 | );
|
11356 | callback && callback.call(component);
|
11357 | return component;
|
11358 | },
|
11359 |
|
11360 | /**
|
11361 | * Constructs a component instance of `constructor` with `initialProps` and
|
11362 | * renders it into the supplied `container`.
|
11363 | *
|
11364 | * @param {function} constructor React component constructor.
|
11365 | * @param {?object} props Initial props of the component instance.
|
11366 | * @param {DOMElement} container DOM element to render into.
|
11367 | * @return {ReactComponent} Component instance rendered in `container`.
|
11368 | */
|
11369 | constructAndRenderComponent: function(constructor, props, container) {
|
11370 | var element = createElement(constructor, props);
|
11371 | return ReactMount.render(element, container);
|
11372 | },
|
11373 |
|
11374 | /**
|
11375 | * Constructs a component instance of `constructor` with `initialProps` and
|
11376 | * renders it into a container node identified by supplied `id`.
|
11377 | *
|
11378 | * @param {function} componentConstructor React component constructor
|
11379 | * @param {?object} props Initial props of the component instance.
|
11380 | * @param {string} id ID of the DOM element to render into.
|
11381 | * @return {ReactComponent} Component instance rendered in the container node.
|
11382 | */
|
11383 | constructAndRenderComponentByID: function(constructor, props, id) {
|
11384 | var domNode = document.getElementById(id);
|
11385 | ("production" !== "development" ? invariant(
|
11386 | domNode,
|
11387 | 'Tried to get element with id of "%s" but it is not present on the page.',
|
11388 | id
|
11389 | ) : invariant(domNode));
|
11390 | return ReactMount.constructAndRenderComponent(constructor, props, domNode);
|
11391 | },
|
11392 |
|
11393 | /**
|
11394 | * Registers a container node into which React components will be rendered.
|
11395 | * This also creates the "reactRoot" ID that will be assigned to the element
|
11396 | * rendered within.
|
11397 | *
|
11398 | * @param {DOMElement} container DOM element to register as a container.
|
11399 | * @return {string} The "reactRoot" ID of elements rendered within.
|
11400 | */
|
11401 | registerContainer: function(container) {
|
11402 | var reactRootID = getReactRootID(container);
|
11403 | if (reactRootID) {
|
11404 | // If one exists, make sure it is a valid "reactRoot" ID.
|
11405 | reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
|
11406 | }
|
11407 | if (!reactRootID) {
|
11408 | // No valid "reactRoot" ID found, create one.
|
11409 | reactRootID = ReactInstanceHandles.createReactRootID();
|
11410 | }
|
11411 | containersByReactRootID[reactRootID] = container;
|
11412 | return reactRootID;
|
11413 | },
|
11414 |
|
11415 | /**
|
11416 | * Unmounts and destroys the React component rendered in the `container`.
|
11417 | *
|
11418 | * @param {DOMElement} container DOM element containing a React component.
|
11419 | * @return {boolean} True if a component was found in and unmounted from
|
11420 | * `container`
|
11421 | */
|
11422 | unmountComponentAtNode: function(container) {
|
11423 | // Various parts of our code (such as ReactCompositeComponent's
|
11424 | // _renderValidatedComponent) assume that calls to render aren't nested;
|
11425 | // verify that that's the case. (Strictly speaking, unmounting won't cause a
|
11426 | // render but we still don't expect to be in a render call here.)
|
11427 | ("production" !== "development" ? warning(
|
11428 | ReactCurrentOwner.current == null,
|
11429 | 'unmountComponentAtNode(): Render methods should be a pure function of ' +
|
11430 | 'props and state; triggering nested component updates from render is ' +
|
11431 | 'not allowed. If necessary, trigger nested updates in ' +
|
11432 | 'componentDidUpdate.'
|
11433 | ) : null);
|
11434 |
|
11435 | var reactRootID = getReactRootID(container);
|
11436 | var component = instancesByReactRootID[reactRootID];
|
11437 | if (!component) {
|
11438 | return false;
|
11439 | }
|
11440 | ReactMount.unmountComponentFromNode(component, container);
|
11441 | delete instancesByReactRootID[reactRootID];
|
11442 | delete containersByReactRootID[reactRootID];
|
11443 | if ("production" !== "development") {
|
11444 | delete rootElementsByReactRootID[reactRootID];
|
11445 | }
|
11446 | return true;
|
11447 | },
|
11448 |
|
11449 | /**
|
11450 | * Unmounts a component and removes it from the DOM.
|
11451 | *
|
11452 | * @param {ReactComponent} instance React component instance.
|
11453 | * @param {DOMElement} container DOM element to unmount from.
|
11454 | * @final
|
11455 | * @internal
|
11456 | * @see {ReactMount.unmountComponentAtNode}
|
11457 | */
|
11458 | unmountComponentFromNode: function(instance, container) {
|
11459 | instance.unmountComponent();
|
11460 |
|
11461 | if (container.nodeType === DOC_NODE_TYPE) {
|
11462 | container = container.documentElement;
|
11463 | }
|
11464 |
|
11465 | // http://jsperf.com/emptying-a-node
|
11466 | while (container.lastChild) {
|
11467 | container.removeChild(container.lastChild);
|
11468 | }
|
11469 | },
|
11470 |
|
11471 | /**
|
11472 | * Finds the container DOM element that contains React component to which the
|
11473 | * supplied DOM `id` belongs.
|
11474 | *
|
11475 | * @param {string} id The ID of an element rendered by a React component.
|
11476 | * @return {?DOMElement} DOM element that contains the `id`.
|
11477 | */
|
11478 | findReactContainerForID: function(id) {
|
11479 | var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
|
11480 | var container = containersByReactRootID[reactRootID];
|
11481 |
|
11482 | if ("production" !== "development") {
|
11483 | var rootElement = rootElementsByReactRootID[reactRootID];
|
11484 | if (rootElement && rootElement.parentNode !== container) {
|
11485 | ("production" !== "development" ? invariant(
|
11486 | // Call internalGetID here because getID calls isValid which calls
|
11487 | // findReactContainerForID (this function).
|
11488 | internalGetID(rootElement) === reactRootID,
|
11489 | 'ReactMount: Root element ID differed from reactRootID.'
|
11490 | ) : invariant(// Call internalGetID here because getID calls isValid which calls
|
11491 | // findReactContainerForID (this function).
|
11492 | internalGetID(rootElement) === reactRootID));
|
11493 |
|
11494 | var containerChild = container.firstChild;
|
11495 | if (containerChild &&
|
11496 | reactRootID === internalGetID(containerChild)) {
|
11497 | // If the container has a new child with the same ID as the old
|
11498 | // root element, then rootElementsByReactRootID[reactRootID] is
|
11499 | // just stale and needs to be updated. The case that deserves a
|
11500 | // warning is when the container is empty.
|
11501 | rootElementsByReactRootID[reactRootID] = containerChild;
|
11502 | } else {
|
11503 | console.warn(
|
11504 | 'ReactMount: Root element has been removed from its original ' +
|
11505 | 'container. New container:', rootElement.parentNode
|
11506 | );
|
11507 | }
|
11508 | }
|
11509 | }
|
11510 |
|
11511 | return container;
|
11512 | },
|
11513 |
|
11514 | /**
|
11515 | * Finds an element rendered by React with the supplied ID.
|
11516 | *
|
11517 | * @param {string} id ID of a DOM node in the React component.
|
11518 | * @return {DOMElement} Root DOM node of the React component.
|
11519 | */
|
11520 | findReactNodeByID: function(id) {
|
11521 | var reactRoot = ReactMount.findReactContainerForID(id);
|
11522 | return ReactMount.findComponentRoot(reactRoot, id);
|
11523 | },
|
11524 |
|
11525 | /**
|
11526 | * True if the supplied `node` is rendered by React.
|
11527 | *
|
11528 | * @param {*} node DOM Element to check.
|
11529 | * @return {boolean} True if the DOM Element appears to be rendered by React.
|
11530 | * @internal
|
11531 | */
|
11532 | isRenderedByReact: function(node) {
|
11533 | if (node.nodeType !== 1) {
|
11534 | // Not a DOMElement, therefore not a React component
|
11535 | return false;
|
11536 | }
|
11537 | var id = ReactMount.getID(node);
|
11538 | return id ? id.charAt(0) === SEPARATOR : false;
|
11539 | },
|
11540 |
|
11541 | /**
|
11542 | * Traverses up the ancestors of the supplied node to find a node that is a
|
11543 | * DOM representation of a React component.
|
11544 | *
|
11545 | * @param {*} node
|
11546 | * @return {?DOMEventTarget}
|
11547 | * @internal
|
11548 | */
|
11549 | getFirstReactDOM: function(node) {
|
11550 | var current = node;
|
11551 | while (current && current.parentNode !== current) {
|
11552 | if (ReactMount.isRenderedByReact(current)) {
|
11553 | return current;
|
11554 | }
|
11555 | current = current.parentNode;
|
11556 | }
|
11557 | return null;
|
11558 | },
|
11559 |
|
11560 | /**
|
11561 | * Finds a node with the supplied `targetID` inside of the supplied
|
11562 | * `ancestorNode`. Exploits the ID naming scheme to perform the search
|
11563 | * quickly.
|
11564 | *
|
11565 | * @param {DOMEventTarget} ancestorNode Search from this root.
|
11566 | * @pararm {string} targetID ID of the DOM representation of the component.
|
11567 | * @return {DOMEventTarget} DOM node with the supplied `targetID`.
|
11568 | * @internal
|
11569 | */
|
11570 | findComponentRoot: function(ancestorNode, targetID) {
|
11571 | var firstChildren = findComponentRootReusableArray;
|
11572 | var childIndex = 0;
|
11573 |
|
11574 | var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
|
11575 |
|
11576 | firstChildren[0] = deepestAncestor.firstChild;
|
11577 | firstChildren.length = 1;
|
11578 |
|
11579 | while (childIndex < firstChildren.length) {
|
11580 | var child = firstChildren[childIndex++];
|
11581 | var targetChild;
|
11582 |
|
11583 | while (child) {
|
11584 | var childID = ReactMount.getID(child);
|
11585 | if (childID) {
|
11586 | // Even if we find the node we're looking for, we finish looping
|
11587 | // through its siblings to ensure they're cached so that we don't have
|
11588 | // to revisit this node again. Otherwise, we make n^2 calls to getID
|
11589 | // when visiting the many children of a single node in order.
|
11590 |
|
11591 | if (targetID === childID) {
|
11592 | targetChild = child;
|
11593 | } else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
|
11594 | // If we find a child whose ID is an ancestor of the given ID,
|
11595 | // then we can be sure that we only want to search the subtree
|
11596 | // rooted at this child, so we can throw out the rest of the
|
11597 | // search state.
|
11598 | firstChildren.length = childIndex = 0;
|
11599 | firstChildren.push(child.firstChild);
|
11600 | }
|
11601 |
|
11602 | } else {
|
11603 | // If this child had no ID, then there's a chance that it was
|
11604 | // injected automatically by the browser, as when a `<table>`
|
11605 | // element sprouts an extra `<tbody>` child as a side effect of
|
11606 | // `.innerHTML` parsing. Optimistically continue down this
|
11607 | // branch, but not before examining the other siblings.
|
11608 | firstChildren.push(child.firstChild);
|
11609 | }
|
11610 |
|
11611 | child = child.nextSibling;
|
11612 | }
|
11613 |
|
11614 | if (targetChild) {
|
11615 | // Emptying firstChildren/findComponentRootReusableArray is
|
11616 | // not necessary for correctness, but it helps the GC reclaim
|
11617 | // any nodes that were left at the end of the search.
|
11618 | firstChildren.length = 0;
|
11619 |
|
11620 | return targetChild;
|
11621 | }
|
11622 | }
|
11623 |
|
11624 | firstChildren.length = 0;
|
11625 |
|
11626 | ("production" !== "development" ? invariant(
|
11627 | false,
|
11628 | 'findComponentRoot(..., %s): Unable to find element. This probably ' +
|
11629 | 'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
|
11630 | 'usually due to forgetting a <tbody> when using tables, nesting tags ' +
|
11631 | 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
|
11632 | 'parent. ' +
|
11633 | 'Try inspecting the child nodes of the element with React ID `%s`.',
|
11634 | targetID,
|
11635 | ReactMount.getID(ancestorNode)
|
11636 | ) : invariant(false));
|
11637 | },
|
11638 |
|
11639 |
|
11640 | /**
|
11641 | * React ID utilities.
|
11642 | */
|
11643 |
|
11644 | getReactRootID: getReactRootID,
|
11645 |
|
11646 | getID: getID,
|
11647 |
|
11648 | setID: setID,
|
11649 |
|
11650 | getNode: getNode,
|
11651 |
|
11652 | purgeID: purgeID
|
11653 | };
|
11654 |
|
11655 | // Deprecations (remove for 0.13)
|
11656 | ReactMount.renderComponent = deprecated(
|
11657 | 'ReactMount',
|
11658 | 'renderComponent',
|
11659 | 'render',
|
11660 | this,
|
11661 | ReactMount.render
|
11662 | );
|
11663 |
|
11664 | module.exports = ReactMount;
|
11665 |
|
11666 | },{"./DOMProperty":11,"./ReactBrowserEventEmitter":30,"./ReactCurrentOwner":36,"./ReactElement":52,"./ReactInstanceHandles":60,"./ReactLegacyElement":61,"./ReactPerf":68,"./containsNode":101,"./deprecated":106,"./getReactRootElementInContainer":120,"./instantiateReactComponent":125,"./invariant":126,"./shouldUpdateReactComponent":142,"./warning":145}],64:[function(_dereq_,module,exports){
|
11667 | /**
|
11668 | * Copyright 2013-2014, Facebook, Inc.
|
11669 | * All rights reserved.
|
11670 | *
|
11671 | * This source code is licensed under the BSD-style license found in the
|
11672 | * LICENSE file in the root directory of this source tree. An additional grant
|
11673 | * of patent rights can be found in the PATENTS file in the same directory.
|
11674 | *
|
11675 | * @providesModule ReactMultiChild
|
11676 | * @typechecks static-only
|
11677 | */
|
11678 |
|
11679 | "use strict";
|
11680 |
|
11681 | var ReactComponent = _dereq_("./ReactComponent");
|
11682 | var ReactMultiChildUpdateTypes = _dereq_("./ReactMultiChildUpdateTypes");
|
11683 |
|
11684 | var flattenChildren = _dereq_("./flattenChildren");
|
11685 | var instantiateReactComponent = _dereq_("./instantiateReactComponent");
|
11686 | var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
|
11687 |
|
11688 | /**
|
11689 | * Updating children of a component may trigger recursive updates. The depth is
|
11690 | * used to batch recursive updates to render markup more efficiently.
|
11691 | *
|
11692 | * @type {number}
|
11693 | * @private
|
11694 | */
|
11695 | var updateDepth = 0;
|
11696 |
|
11697 | /**
|
11698 | * Queue of update configuration objects.
|
11699 | *
|
11700 | * Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
|
11701 | *
|
11702 | * @type {array<object>}
|
11703 | * @private
|
11704 | */
|
11705 | var updateQueue = [];
|
11706 |
|
11707 | /**
|
11708 | * Queue of markup to be rendered.
|
11709 | *
|
11710 | * @type {array<string>}
|
11711 | * @private
|
11712 | */
|
11713 | var markupQueue = [];
|
11714 |
|
11715 | /**
|
11716 | * Enqueues markup to be rendered and inserted at a supplied index.
|
11717 | *
|
11718 | * @param {string} parentID ID of the parent component.
|
11719 | * @param {string} markup Markup that renders into an element.
|
11720 | * @param {number} toIndex Destination index.
|
11721 | * @private
|
11722 | */
|
11723 | function enqueueMarkup(parentID, markup, toIndex) {
|
11724 | // NOTE: Null values reduce hidden classes.
|
11725 | updateQueue.push({
|
11726 | parentID: parentID,
|
11727 | parentNode: null,
|
11728 | type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
|
11729 | markupIndex: markupQueue.push(markup) - 1,
|
11730 | textContent: null,
|
11731 | fromIndex: null,
|
11732 | toIndex: toIndex
|
11733 | });
|
11734 | }
|
11735 |
|
11736 | /**
|
11737 | * Enqueues moving an existing element to another index.
|
11738 | *
|
11739 | * @param {string} parentID ID of the parent component.
|
11740 | * @param {number} fromIndex Source index of the existing element.
|
11741 | * @param {number} toIndex Destination index of the element.
|
11742 | * @private
|
11743 | */
|
11744 | function enqueueMove(parentID, fromIndex, toIndex) {
|
11745 | // NOTE: Null values reduce hidden classes.
|
11746 | updateQueue.push({
|
11747 | parentID: parentID,
|
11748 | parentNode: null,
|
11749 | type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
|
11750 | markupIndex: null,
|
11751 | textContent: null,
|
11752 | fromIndex: fromIndex,
|
11753 | toIndex: toIndex
|
11754 | });
|
11755 | }
|
11756 |
|
11757 | /**
|
11758 | * Enqueues removing an element at an index.
|
11759 | *
|
11760 | * @param {string} parentID ID of the parent component.
|
11761 | * @param {number} fromIndex Index of the element to remove.
|
11762 | * @private
|
11763 | */
|
11764 | function enqueueRemove(parentID, fromIndex) {
|
11765 | // NOTE: Null values reduce hidden classes.
|
11766 | updateQueue.push({
|
11767 | parentID: parentID,
|
11768 | parentNode: null,
|
11769 | type: ReactMultiChildUpdateTypes.REMOVE_NODE,
|
11770 | markupIndex: null,
|
11771 | textContent: null,
|
11772 | fromIndex: fromIndex,
|
11773 | toIndex: null
|
11774 | });
|
11775 | }
|
11776 |
|
11777 | /**
|
11778 | * Enqueues setting the text content.
|
11779 | *
|
11780 | * @param {string} parentID ID of the parent component.
|
11781 | * @param {string} textContent Text content to set.
|
11782 | * @private
|
11783 | */
|
11784 | function enqueueTextContent(parentID, textContent) {
|
11785 | // NOTE: Null values reduce hidden classes.
|
11786 | updateQueue.push({
|
11787 | parentID: parentID,
|
11788 | parentNode: null,
|
11789 | type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
|
11790 | markupIndex: null,
|
11791 | textContent: textContent,
|
11792 | fromIndex: null,
|
11793 | toIndex: null
|
11794 | });
|
11795 | }
|
11796 |
|
11797 | /**
|
11798 | * Processes any enqueued updates.
|
11799 | *
|
11800 | * @private
|
11801 | */
|
11802 | function processQueue() {
|
11803 | if (updateQueue.length) {
|
11804 | ReactComponent.BackendIDOperations.dangerouslyProcessChildrenUpdates(
|
11805 | updateQueue,
|
11806 | markupQueue
|
11807 | );
|
11808 | clearQueue();
|
11809 | }
|
11810 | }
|
11811 |
|
11812 | /**
|
11813 | * Clears any enqueued updates.
|
11814 | *
|
11815 | * @private
|
11816 | */
|
11817 | function clearQueue() {
|
11818 | updateQueue.length = 0;
|
11819 | markupQueue.length = 0;
|
11820 | }
|
11821 |
|
11822 | /**
|
11823 | * ReactMultiChild are capable of reconciling multiple children.
|
11824 | *
|
11825 | * @class ReactMultiChild
|
11826 | * @internal
|
11827 | */
|
11828 | var ReactMultiChild = {
|
11829 |
|
11830 | /**
|
11831 | * Provides common functionality for components that must reconcile multiple
|
11832 | * children. This is used by `ReactDOMComponent` to mount, update, and
|
11833 | * unmount child components.
|
11834 | *
|
11835 | * @lends {ReactMultiChild.prototype}
|
11836 | */
|
11837 | Mixin: {
|
11838 |
|
11839 | /**
|
11840 | * Generates a "mount image" for each of the supplied children. In the case
|
11841 | * of `ReactDOMComponent`, a mount image is a string of markup.
|
11842 | *
|
11843 | * @param {?object} nestedChildren Nested child maps.
|
11844 | * @return {array} An array of mounted representations.
|
11845 | * @internal
|
11846 | */
|
11847 | mountChildren: function(nestedChildren, transaction) {
|
11848 | var children = flattenChildren(nestedChildren);
|
11849 | var mountImages = [];
|
11850 | var index = 0;
|
11851 | this._renderedChildren = children;
|
11852 | for (var name in children) {
|
11853 | var child = children[name];
|
11854 | if (children.hasOwnProperty(name)) {
|
11855 | // The rendered children must be turned into instances as they're
|
11856 | // mounted.
|
11857 | var childInstance = instantiateReactComponent(child, null);
|
11858 | children[name] = childInstance;
|
11859 | // Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
11860 | var rootID = this._rootNodeID + name;
|
11861 | var mountImage = childInstance.mountComponent(
|
11862 | rootID,
|
11863 | transaction,
|
11864 | this._mountDepth + 1
|
11865 | );
|
11866 | childInstance._mountIndex = index;
|
11867 | mountImages.push(mountImage);
|
11868 | index++;
|
11869 | }
|
11870 | }
|
11871 | return mountImages;
|
11872 | },
|
11873 |
|
11874 | /**
|
11875 | * Replaces any rendered children with a text content string.
|
11876 | *
|
11877 | * @param {string} nextContent String of content.
|
11878 | * @internal
|
11879 | */
|
11880 | updateTextContent: function(nextContent) {
|
11881 | updateDepth++;
|
11882 | var errorThrown = true;
|
11883 | try {
|
11884 | var prevChildren = this._renderedChildren;
|
11885 | // Remove any rendered children.
|
11886 | for (var name in prevChildren) {
|
11887 | if (prevChildren.hasOwnProperty(name)) {
|
11888 | this._unmountChildByName(prevChildren[name], name);
|
11889 | }
|
11890 | }
|
11891 | // Set new text content.
|
11892 | this.setTextContent(nextContent);
|
11893 | errorThrown = false;
|
11894 | } finally {
|
11895 | updateDepth--;
|
11896 | if (!updateDepth) {
|
11897 | errorThrown ? clearQueue() : processQueue();
|
11898 | }
|
11899 | }
|
11900 | },
|
11901 |
|
11902 | /**
|
11903 | * Updates the rendered children with new children.
|
11904 | *
|
11905 | * @param {?object} nextNestedChildren Nested child maps.
|
11906 | * @param {ReactReconcileTransaction} transaction
|
11907 | * @internal
|
11908 | */
|
11909 | updateChildren: function(nextNestedChildren, transaction) {
|
11910 | updateDepth++;
|
11911 | var errorThrown = true;
|
11912 | try {
|
11913 | this._updateChildren(nextNestedChildren, transaction);
|
11914 | errorThrown = false;
|
11915 | } finally {
|
11916 | updateDepth--;
|
11917 | if (!updateDepth) {
|
11918 | errorThrown ? clearQueue() : processQueue();
|
11919 | }
|
11920 | }
|
11921 | },
|
11922 |
|
11923 | /**
|
11924 | * Improve performance by isolating this hot code path from the try/catch
|
11925 | * block in `updateChildren`.
|
11926 | *
|
11927 | * @param {?object} nextNestedChildren Nested child maps.
|
11928 | * @param {ReactReconcileTransaction} transaction
|
11929 | * @final
|
11930 | * @protected
|
11931 | */
|
11932 | _updateChildren: function(nextNestedChildren, transaction) {
|
11933 | var nextChildren = flattenChildren(nextNestedChildren);
|
11934 | var prevChildren = this._renderedChildren;
|
11935 | if (!nextChildren && !prevChildren) {
|
11936 | return;
|
11937 | }
|
11938 | var name;
|
11939 | // `nextIndex` will increment for each child in `nextChildren`, but
|
11940 | // `lastIndex` will be the last index visited in `prevChildren`.
|
11941 | var lastIndex = 0;
|
11942 | var nextIndex = 0;
|
11943 | for (name in nextChildren) {
|
11944 | if (!nextChildren.hasOwnProperty(name)) {
|
11945 | continue;
|
11946 | }
|
11947 | var prevChild = prevChildren && prevChildren[name];
|
11948 | var prevElement = prevChild && prevChild._currentElement;
|
11949 | var nextElement = nextChildren[name];
|
11950 | if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
11951 | this.moveChild(prevChild, nextIndex, lastIndex);
|
11952 | lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
11953 | prevChild.receiveComponent(nextElement, transaction);
|
11954 | prevChild._mountIndex = nextIndex;
|
11955 | } else {
|
11956 | if (prevChild) {
|
11957 | // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
|
11958 | lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
11959 | this._unmountChildByName(prevChild, name);
|
11960 | }
|
11961 | // The child must be instantiated before it's mounted.
|
11962 | var nextChildInstance = instantiateReactComponent(
|
11963 | nextElement,
|
11964 | null
|
11965 | );
|
11966 | this._mountChildByNameAtIndex(
|
11967 | nextChildInstance, name, nextIndex, transaction
|
11968 | );
|
11969 | }
|
11970 | nextIndex++;
|
11971 | }
|
11972 | // Remove children that are no longer present.
|
11973 | for (name in prevChildren) {
|
11974 | if (prevChildren.hasOwnProperty(name) &&
|
11975 | !(nextChildren && nextChildren[name])) {
|
11976 | this._unmountChildByName(prevChildren[name], name);
|
11977 | }
|
11978 | }
|
11979 | },
|
11980 |
|
11981 | /**
|
11982 | * Unmounts all rendered children. This should be used to clean up children
|
11983 | * when this component is unmounted.
|
11984 | *
|
11985 | * @internal
|
11986 | */
|
11987 | unmountChildren: function() {
|
11988 | var renderedChildren = this._renderedChildren;
|
11989 | for (var name in renderedChildren) {
|
11990 | var renderedChild = renderedChildren[name];
|
11991 | // TODO: When is this not true?
|
11992 | if (renderedChild.unmountComponent) {
|
11993 | renderedChild.unmountComponent();
|
11994 | }
|
11995 | }
|
11996 | this._renderedChildren = null;
|
11997 | },
|
11998 |
|
11999 | /**
|
12000 | * Moves a child component to the supplied index.
|
12001 | *
|
12002 | * @param {ReactComponent} child Component to move.
|
12003 | * @param {number} toIndex Destination index of the element.
|
12004 | * @param {number} lastIndex Last index visited of the siblings of `child`.
|
12005 | * @protected
|
12006 | */
|
12007 | moveChild: function(child, toIndex, lastIndex) {
|
12008 | // If the index of `child` is less than `lastIndex`, then it needs to
|
12009 | // be moved. Otherwise, we do not need to move it because a child will be
|
12010 | // inserted or moved before `child`.
|
12011 | if (child._mountIndex < lastIndex) {
|
12012 | enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
|
12013 | }
|
12014 | },
|
12015 |
|
12016 | /**
|
12017 | * Creates a child component.
|
12018 | *
|
12019 | * @param {ReactComponent} child Component to create.
|
12020 | * @param {string} mountImage Markup to insert.
|
12021 | * @protected
|
12022 | */
|
12023 | createChild: function(child, mountImage) {
|
12024 | enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
|
12025 | },
|
12026 |
|
12027 | /**
|
12028 | * Removes a child component.
|
12029 | *
|
12030 | * @param {ReactComponent} child Child to remove.
|
12031 | * @protected
|
12032 | */
|
12033 | removeChild: function(child) {
|
12034 | enqueueRemove(this._rootNodeID, child._mountIndex);
|
12035 | },
|
12036 |
|
12037 | /**
|
12038 | * Sets this text content string.
|
12039 | *
|
12040 | * @param {string} textContent Text content to set.
|
12041 | * @protected
|
12042 | */
|
12043 | setTextContent: function(textContent) {
|
12044 | enqueueTextContent(this._rootNodeID, textContent);
|
12045 | },
|
12046 |
|
12047 | /**
|
12048 | * Mounts a child with the supplied name.
|
12049 | *
|
12050 | * NOTE: This is part of `updateChildren` and is here for readability.
|
12051 | *
|
12052 | * @param {ReactComponent} child Component to mount.
|
12053 | * @param {string} name Name of the child.
|
12054 | * @param {number} index Index at which to insert the child.
|
12055 | * @param {ReactReconcileTransaction} transaction
|
12056 | * @private
|
12057 | */
|
12058 | _mountChildByNameAtIndex: function(child, name, index, transaction) {
|
12059 | // Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
12060 | var rootID = this._rootNodeID + name;
|
12061 | var mountImage = child.mountComponent(
|
12062 | rootID,
|
12063 | transaction,
|
12064 | this._mountDepth + 1
|
12065 | );
|
12066 | child._mountIndex = index;
|
12067 | this.createChild(child, mountImage);
|
12068 | this._renderedChildren = this._renderedChildren || {};
|
12069 | this._renderedChildren[name] = child;
|
12070 | },
|
12071 |
|
12072 | /**
|
12073 | * Unmounts a rendered child by name.
|
12074 | *
|
12075 | * NOTE: This is part of `updateChildren` and is here for readability.
|
12076 | *
|
12077 | * @param {ReactComponent} child Component to unmount.
|
12078 | * @param {string} name Name of the child in `this._renderedChildren`.
|
12079 | * @private
|
12080 | */
|
12081 | _unmountChildByName: function(child, name) {
|
12082 | this.removeChild(child);
|
12083 | child._mountIndex = null;
|
12084 | child.unmountComponent();
|
12085 | delete this._renderedChildren[name];
|
12086 | }
|
12087 |
|
12088 | }
|
12089 |
|
12090 | };
|
12091 |
|
12092 | module.exports = ReactMultiChild;
|
12093 |
|
12094 | },{"./ReactComponent":32,"./ReactMultiChildUpdateTypes":65,"./flattenChildren":110,"./instantiateReactComponent":125,"./shouldUpdateReactComponent":142}],65:[function(_dereq_,module,exports){
|
12095 | /**
|
12096 | * Copyright 2013-2014, Facebook, Inc.
|
12097 | * All rights reserved.
|
12098 | *
|
12099 | * This source code is licensed under the BSD-style license found in the
|
12100 | * LICENSE file in the root directory of this source tree. An additional grant
|
12101 | * of patent rights can be found in the PATENTS file in the same directory.
|
12102 | *
|
12103 | * @providesModule ReactMultiChildUpdateTypes
|
12104 | */
|
12105 |
|
12106 | "use strict";
|
12107 |
|
12108 | var keyMirror = _dereq_("./keyMirror");
|
12109 |
|
12110 | /**
|
12111 | * When a component's children are updated, a series of update configuration
|
12112 | * objects are created in order to batch and serialize the required changes.
|
12113 | *
|
12114 | * Enumerates all the possible types of update configurations.
|
12115 | *
|
12116 | * @internal
|
12117 | */
|
12118 | var ReactMultiChildUpdateTypes = keyMirror({
|
12119 | INSERT_MARKUP: null,
|
12120 | MOVE_EXISTING: null,
|
12121 | REMOVE_NODE: null,
|
12122 | TEXT_CONTENT: null
|
12123 | });
|
12124 |
|
12125 | module.exports = ReactMultiChildUpdateTypes;
|
12126 |
|
12127 | },{"./keyMirror":132}],66:[function(_dereq_,module,exports){
|
12128 | /**
|
12129 | * Copyright 2014, Facebook, Inc.
|
12130 | * All rights reserved.
|
12131 | *
|
12132 | * This source code is licensed under the BSD-style license found in the
|
12133 | * LICENSE file in the root directory of this source tree. An additional grant
|
12134 | * of patent rights can be found in the PATENTS file in the same directory.
|
12135 | *
|
12136 | * @providesModule ReactNativeComponent
|
12137 | */
|
12138 |
|
12139 | "use strict";
|
12140 |
|
12141 | var assign = _dereq_("./Object.assign");
|
12142 | var invariant = _dereq_("./invariant");
|
12143 |
|
12144 | var genericComponentClass = null;
|
12145 | // This registry keeps track of wrapper classes around native tags
|
12146 | var tagToComponentClass = {};
|
12147 |
|
12148 | var ReactNativeComponentInjection = {
|
12149 | // This accepts a class that receives the tag string. This is a catch all
|
12150 | // that can render any kind of tag.
|
12151 | injectGenericComponentClass: function(componentClass) {
|
12152 | genericComponentClass = componentClass;
|
12153 | },
|
12154 | // This accepts a keyed object with classes as values. Each key represents a
|
12155 | // tag. That particular tag will use this class instead of the generic one.
|
12156 | injectComponentClasses: function(componentClasses) {
|
12157 | assign(tagToComponentClass, componentClasses);
|
12158 | }
|
12159 | };
|
12160 |
|
12161 | /**
|
12162 | * Create an internal class for a specific tag.
|
12163 | *
|
12164 | * @param {string} tag The tag for which to create an internal instance.
|
12165 | * @param {any} props The props passed to the instance constructor.
|
12166 | * @return {ReactComponent} component The injected empty component.
|
12167 | */
|
12168 | function createInstanceForTag(tag, props, parentType) {
|
12169 | var componentClass = tagToComponentClass[tag];
|
12170 | if (componentClass == null) {
|
12171 | ("production" !== "development" ? invariant(
|
12172 | genericComponentClass,
|
12173 | 'There is no registered component for the tag %s',
|
12174 | tag
|
12175 | ) : invariant(genericComponentClass));
|
12176 | return new genericComponentClass(tag, props);
|
12177 | }
|
12178 | if (parentType === tag) {
|
12179 | // Avoid recursion
|
12180 | ("production" !== "development" ? invariant(
|
12181 | genericComponentClass,
|
12182 | 'There is no registered component for the tag %s',
|
12183 | tag
|
12184 | ) : invariant(genericComponentClass));
|
12185 | return new genericComponentClass(tag, props);
|
12186 | }
|
12187 | // Unwrap legacy factories
|
12188 | return new componentClass.type(props);
|
12189 | }
|
12190 |
|
12191 | var ReactNativeComponent = {
|
12192 | createInstanceForTag: createInstanceForTag,
|
12193 | injection: ReactNativeComponentInjection
|
12194 | };
|
12195 |
|
12196 | module.exports = ReactNativeComponent;
|
12197 |
|
12198 | },{"./Object.assign":27,"./invariant":126}],67:[function(_dereq_,module,exports){
|
12199 | /**
|
12200 | * Copyright 2013-2014, Facebook, Inc.
|
12201 | * All rights reserved.
|
12202 | *
|
12203 | * This source code is licensed under the BSD-style license found in the
|
12204 | * LICENSE file in the root directory of this source tree. An additional grant
|
12205 | * of patent rights can be found in the PATENTS file in the same directory.
|
12206 | *
|
12207 | * @providesModule ReactOwner
|
12208 | */
|
12209 |
|
12210 | "use strict";
|
12211 |
|
12212 | var emptyObject = _dereq_("./emptyObject");
|
12213 | var invariant = _dereq_("./invariant");
|
12214 |
|
12215 | /**
|
12216 | * ReactOwners are capable of storing references to owned components.
|
12217 | *
|
12218 | * All components are capable of //being// referenced by owner components, but
|
12219 | * only ReactOwner components are capable of //referencing// owned components.
|
12220 | * The named reference is known as a "ref".
|
12221 | *
|
12222 | * Refs are available when mounted and updated during reconciliation.
|
12223 | *
|
12224 | * var MyComponent = React.createClass({
|
12225 | * render: function() {
|
12226 | * return (
|
12227 | * <div onClick={this.handleClick}>
|
12228 | * <CustomComponent ref="custom" />
|
12229 | * </div>
|
12230 | * );
|
12231 | * },
|
12232 | * handleClick: function() {
|
12233 | * this.refs.custom.handleClick();
|
12234 | * },
|
12235 | * componentDidMount: function() {
|
12236 | * this.refs.custom.initialize();
|
12237 | * }
|
12238 | * });
|
12239 | *
|
12240 | * Refs should rarely be used. When refs are used, they should only be done to
|
12241 | * control data that is not handled by React's data flow.
|
12242 | *
|
12243 | * @class ReactOwner
|
12244 | */
|
12245 | var ReactOwner = {
|
12246 |
|
12247 | /**
|
12248 | * @param {?object} object
|
12249 | * @return {boolean} True if `object` is a valid owner.
|
12250 | * @final
|
12251 | */
|
12252 | isValidOwner: function(object) {
|
12253 | return !!(
|
12254 | object &&
|
12255 | typeof object.attachRef === 'function' &&
|
12256 | typeof object.detachRef === 'function'
|
12257 | );
|
12258 | },
|
12259 |
|
12260 | /**
|
12261 | * Adds a component by ref to an owner component.
|
12262 | *
|
12263 | * @param {ReactComponent} component Component to reference.
|
12264 | * @param {string} ref Name by which to refer to the component.
|
12265 | * @param {ReactOwner} owner Component on which to record the ref.
|
12266 | * @final
|
12267 | * @internal
|
12268 | */
|
12269 | addComponentAsRefTo: function(component, ref, owner) {
|
12270 | ("production" !== "development" ? invariant(
|
12271 | ReactOwner.isValidOwner(owner),
|
12272 | 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
|
12273 | 'usually means that you\'re trying to add a ref to a component that ' +
|
12274 | 'doesn\'t have an owner (that is, was not created inside of another ' +
|
12275 | 'component\'s `render` method). Try rendering this component inside of ' +
|
12276 | 'a new top-level component which will hold the ref.'
|
12277 | ) : invariant(ReactOwner.isValidOwner(owner)));
|
12278 | owner.attachRef(ref, component);
|
12279 | },
|
12280 |
|
12281 | /**
|
12282 | * Removes a component by ref from an owner component.
|
12283 | *
|
12284 | * @param {ReactComponent} component Component to dereference.
|
12285 | * @param {string} ref Name of the ref to remove.
|
12286 | * @param {ReactOwner} owner Component on which the ref is recorded.
|
12287 | * @final
|
12288 | * @internal
|
12289 | */
|
12290 | removeComponentAsRefFrom: function(component, ref, owner) {
|
12291 | ("production" !== "development" ? invariant(
|
12292 | ReactOwner.isValidOwner(owner),
|
12293 | 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
|
12294 | 'usually means that you\'re trying to remove a ref to a component that ' +
|
12295 | 'doesn\'t have an owner (that is, was not created inside of another ' +
|
12296 | 'component\'s `render` method). Try rendering this component inside of ' +
|
12297 | 'a new top-level component which will hold the ref.'
|
12298 | ) : invariant(ReactOwner.isValidOwner(owner)));
|
12299 | // Check that `component` is still the current ref because we do not want to
|
12300 | // detach the ref if another component stole it.
|
12301 | if (owner.refs[ref] === component) {
|
12302 | owner.detachRef(ref);
|
12303 | }
|
12304 | },
|
12305 |
|
12306 | /**
|
12307 | * A ReactComponent must mix this in to have refs.
|
12308 | *
|
12309 | * @lends {ReactOwner.prototype}
|
12310 | */
|
12311 | Mixin: {
|
12312 |
|
12313 | construct: function() {
|
12314 | this.refs = emptyObject;
|
12315 | },
|
12316 |
|
12317 | /**
|
12318 | * Lazily allocates the refs object and stores `component` as `ref`.
|
12319 | *
|
12320 | * @param {string} ref Reference name.
|
12321 | * @param {component} component Component to store as `ref`.
|
12322 | * @final
|
12323 | * @private
|
12324 | */
|
12325 | attachRef: function(ref, component) {
|
12326 | ("production" !== "development" ? invariant(
|
12327 | component.isOwnedBy(this),
|
12328 | 'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
|
12329 | ref
|
12330 | ) : invariant(component.isOwnedBy(this)));
|
12331 | var refs = this.refs === emptyObject ? (this.refs = {}) : this.refs;
|
12332 | refs[ref] = component;
|
12333 | },
|
12334 |
|
12335 | /**
|
12336 | * Detaches a reference name.
|
12337 | *
|
12338 | * @param {string} ref Name to dereference.
|
12339 | * @final
|
12340 | * @private
|
12341 | */
|
12342 | detachRef: function(ref) {
|
12343 | delete this.refs[ref];
|
12344 | }
|
12345 |
|
12346 | }
|
12347 |
|
12348 | };
|
12349 |
|
12350 | module.exports = ReactOwner;
|
12351 |
|
12352 | },{"./emptyObject":108,"./invariant":126}],68:[function(_dereq_,module,exports){
|
12353 | /**
|
12354 | * Copyright 2013-2014, Facebook, Inc.
|
12355 | * All rights reserved.
|
12356 | *
|
12357 | * This source code is licensed under the BSD-style license found in the
|
12358 | * LICENSE file in the root directory of this source tree. An additional grant
|
12359 | * of patent rights can be found in the PATENTS file in the same directory.
|
12360 | *
|
12361 | * @providesModule ReactPerf
|
12362 | * @typechecks static-only
|
12363 | */
|
12364 |
|
12365 | "use strict";
|
12366 |
|
12367 | /**
|
12368 | * ReactPerf is a general AOP system designed to measure performance. This
|
12369 | * module only has the hooks: see ReactDefaultPerf for the analysis tool.
|
12370 | */
|
12371 | var ReactPerf = {
|
12372 | /**
|
12373 | * Boolean to enable/disable measurement. Set to false by default to prevent
|
12374 | * accidental logging and perf loss.
|
12375 | */
|
12376 | enableMeasure: false,
|
12377 |
|
12378 | /**
|
12379 | * Holds onto the measure function in use. By default, don't measure
|
12380 | * anything, but we'll override this if we inject a measure function.
|
12381 | */
|
12382 | storedMeasure: _noMeasure,
|
12383 |
|
12384 | /**
|
12385 | * Use this to wrap methods you want to measure. Zero overhead in production.
|
12386 | *
|
12387 | * @param {string} objName
|
12388 | * @param {string} fnName
|
12389 | * @param {function} func
|
12390 | * @return {function}
|
12391 | */
|
12392 | measure: function(objName, fnName, func) {
|
12393 | if ("production" !== "development") {
|
12394 | var measuredFunc = null;
|
12395 | var wrapper = function() {
|
12396 | if (ReactPerf.enableMeasure) {
|
12397 | if (!measuredFunc) {
|
12398 | measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
|
12399 | }
|
12400 | return measuredFunc.apply(this, arguments);
|
12401 | }
|
12402 | return func.apply(this, arguments);
|
12403 | };
|
12404 | wrapper.displayName = objName + '_' + fnName;
|
12405 | return wrapper;
|
12406 | }
|
12407 | return func;
|
12408 | },
|
12409 |
|
12410 | injection: {
|
12411 | /**
|
12412 | * @param {function} measure
|
12413 | */
|
12414 | injectMeasure: function(measure) {
|
12415 | ReactPerf.storedMeasure = measure;
|
12416 | }
|
12417 | }
|
12418 | };
|
12419 |
|
12420 | /**
|
12421 | * Simply passes through the measured function, without measuring it.
|
12422 | *
|
12423 | * @param {string} objName
|
12424 | * @param {string} fnName
|
12425 | * @param {function} func
|
12426 | * @return {function}
|
12427 | */
|
12428 | function _noMeasure(objName, fnName, func) {
|
12429 | return func;
|
12430 | }
|
12431 |
|
12432 | module.exports = ReactPerf;
|
12433 |
|
12434 | },{}],69:[function(_dereq_,module,exports){
|
12435 | /**
|
12436 | * Copyright 2013-2014, Facebook, Inc.
|
12437 | * All rights reserved.
|
12438 | *
|
12439 | * This source code is licensed under the BSD-style license found in the
|
12440 | * LICENSE file in the root directory of this source tree. An additional grant
|
12441 | * of patent rights can be found in the PATENTS file in the same directory.
|
12442 | *
|
12443 | * @providesModule ReactPropTransferer
|
12444 | */
|
12445 |
|
12446 | "use strict";
|
12447 |
|
12448 | var assign = _dereq_("./Object.assign");
|
12449 | var emptyFunction = _dereq_("./emptyFunction");
|
12450 | var invariant = _dereq_("./invariant");
|
12451 | var joinClasses = _dereq_("./joinClasses");
|
12452 | var warning = _dereq_("./warning");
|
12453 |
|
12454 | var didWarn = false;
|
12455 |
|
12456 | /**
|
12457 | * Creates a transfer strategy that will merge prop values using the supplied
|
12458 | * `mergeStrategy`. If a prop was previously unset, this just sets it.
|
12459 | *
|
12460 | * @param {function} mergeStrategy
|
12461 | * @return {function}
|
12462 | */
|
12463 | function createTransferStrategy(mergeStrategy) {
|
12464 | return function(props, key, value) {
|
12465 | if (!props.hasOwnProperty(key)) {
|
12466 | props[key] = value;
|
12467 | } else {
|
12468 | props[key] = mergeStrategy(props[key], value);
|
12469 | }
|
12470 | };
|
12471 | }
|
12472 |
|
12473 | var transferStrategyMerge = createTransferStrategy(function(a, b) {
|
12474 | // `merge` overrides the first object's (`props[key]` above) keys using the
|
12475 | // second object's (`value`) keys. An object's style's existing `propA` would
|
12476 | // get overridden. Flip the order here.
|
12477 | return assign({}, b, a);
|
12478 | });
|
12479 |
|
12480 | /**
|
12481 | * Transfer strategies dictate how props are transferred by `transferPropsTo`.
|
12482 | * NOTE: if you add any more exceptions to this list you should be sure to
|
12483 | * update `cloneWithProps()` accordingly.
|
12484 | */
|
12485 | var TransferStrategies = {
|
12486 | /**
|
12487 | * Never transfer `children`.
|
12488 | */
|
12489 | children: emptyFunction,
|
12490 | /**
|
12491 | * Transfer the `className` prop by merging them.
|
12492 | */
|
12493 | className: createTransferStrategy(joinClasses),
|
12494 | /**
|
12495 | * Transfer the `style` prop (which is an object) by merging them.
|
12496 | */
|
12497 | style: transferStrategyMerge
|
12498 | };
|
12499 |
|
12500 | /**
|
12501 | * Mutates the first argument by transferring the properties from the second
|
12502 | * argument.
|
12503 | *
|
12504 | * @param {object} props
|
12505 | * @param {object} newProps
|
12506 | * @return {object}
|
12507 | */
|
12508 | function transferInto(props, newProps) {
|
12509 | for (var thisKey in newProps) {
|
12510 | if (!newProps.hasOwnProperty(thisKey)) {
|
12511 | continue;
|
12512 | }
|
12513 |
|
12514 | var transferStrategy = TransferStrategies[thisKey];
|
12515 |
|
12516 | if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
|
12517 | transferStrategy(props, thisKey, newProps[thisKey]);
|
12518 | } else if (!props.hasOwnProperty(thisKey)) {
|
12519 | props[thisKey] = newProps[thisKey];
|
12520 | }
|
12521 | }
|
12522 | return props;
|
12523 | }
|
12524 |
|
12525 | /**
|
12526 | * ReactPropTransferer are capable of transferring props to another component
|
12527 | * using a `transferPropsTo` method.
|
12528 | *
|
12529 | * @class ReactPropTransferer
|
12530 | */
|
12531 | var ReactPropTransferer = {
|
12532 |
|
12533 | TransferStrategies: TransferStrategies,
|
12534 |
|
12535 | /**
|
12536 | * Merge two props objects using TransferStrategies.
|
12537 | *
|
12538 | * @param {object} oldProps original props (they take precedence)
|
12539 | * @param {object} newProps new props to merge in
|
12540 | * @return {object} a new object containing both sets of props merged.
|
12541 | */
|
12542 | mergeProps: function(oldProps, newProps) {
|
12543 | return transferInto(assign({}, oldProps), newProps);
|
12544 | },
|
12545 |
|
12546 | /**
|
12547 | * @lends {ReactPropTransferer.prototype}
|
12548 | */
|
12549 | Mixin: {
|
12550 |
|
12551 | /**
|
12552 | * Transfer props from this component to a target component.
|
12553 | *
|
12554 | * Props that do not have an explicit transfer strategy will be transferred
|
12555 | * only if the target component does not already have the prop set.
|
12556 | *
|
12557 | * This is usually used to pass down props to a returned root component.
|
12558 | *
|
12559 | * @param {ReactElement} element Component receiving the properties.
|
12560 | * @return {ReactElement} The supplied `component`.
|
12561 | * @final
|
12562 | * @protected
|
12563 | */
|
12564 | transferPropsTo: function(element) {
|
12565 | ("production" !== "development" ? invariant(
|
12566 | element._owner === this,
|
12567 | '%s: You can\'t call transferPropsTo() on a component that you ' +
|
12568 | 'don\'t own, %s. This usually means you are calling ' +
|
12569 | 'transferPropsTo() on a component passed in as props or children.',
|
12570 | this.constructor.displayName,
|
12571 | typeof element.type === 'string' ?
|
12572 | element.type :
|
12573 | element.type.displayName
|
12574 | ) : invariant(element._owner === this));
|
12575 |
|
12576 | if ("production" !== "development") {
|
12577 | if (!didWarn) {
|
12578 | didWarn = true;
|
12579 | ("production" !== "development" ? warning(
|
12580 | false,
|
12581 | 'transferPropsTo is deprecated. ' +
|
12582 | 'See http://fb.me/react-transferpropsto for more information.'
|
12583 | ) : null);
|
12584 | }
|
12585 | }
|
12586 |
|
12587 | // Because elements are immutable we have to merge into the existing
|
12588 | // props object rather than clone it.
|
12589 | transferInto(element.props, this.props);
|
12590 |
|
12591 | return element;
|
12592 | }
|
12593 |
|
12594 | }
|
12595 | };
|
12596 |
|
12597 | module.exports = ReactPropTransferer;
|
12598 |
|
12599 | },{"./Object.assign":27,"./emptyFunction":107,"./invariant":126,"./joinClasses":131,"./warning":145}],70:[function(_dereq_,module,exports){
|
12600 | /**
|
12601 | * Copyright 2013-2014, Facebook, Inc.
|
12602 | * All rights reserved.
|
12603 | *
|
12604 | * This source code is licensed under the BSD-style license found in the
|
12605 | * LICENSE file in the root directory of this source tree. An additional grant
|
12606 | * of patent rights can be found in the PATENTS file in the same directory.
|
12607 | *
|
12608 | * @providesModule ReactPropTypeLocationNames
|
12609 | */
|
12610 |
|
12611 | "use strict";
|
12612 |
|
12613 | var ReactPropTypeLocationNames = {};
|
12614 |
|
12615 | if ("production" !== "development") {
|
12616 | ReactPropTypeLocationNames = {
|
12617 | prop: 'prop',
|
12618 | context: 'context',
|
12619 | childContext: 'child context'
|
12620 | };
|
12621 | }
|
12622 |
|
12623 | module.exports = ReactPropTypeLocationNames;
|
12624 |
|
12625 | },{}],71:[function(_dereq_,module,exports){
|
12626 | /**
|
12627 | * Copyright 2013-2014, Facebook, Inc.
|
12628 | * All rights reserved.
|
12629 | *
|
12630 | * This source code is licensed under the BSD-style license found in the
|
12631 | * LICENSE file in the root directory of this source tree. An additional grant
|
12632 | * of patent rights can be found in the PATENTS file in the same directory.
|
12633 | *
|
12634 | * @providesModule ReactPropTypeLocations
|
12635 | */
|
12636 |
|
12637 | "use strict";
|
12638 |
|
12639 | var keyMirror = _dereq_("./keyMirror");
|
12640 |
|
12641 | var ReactPropTypeLocations = keyMirror({
|
12642 | prop: null,
|
12643 | context: null,
|
12644 | childContext: null
|
12645 | });
|
12646 |
|
12647 | module.exports = ReactPropTypeLocations;
|
12648 |
|
12649 | },{"./keyMirror":132}],72:[function(_dereq_,module,exports){
|
12650 | /**
|
12651 | * Copyright 2013-2014, Facebook, Inc.
|
12652 | * All rights reserved.
|
12653 | *
|
12654 | * This source code is licensed under the BSD-style license found in the
|
12655 | * LICENSE file in the root directory of this source tree. An additional grant
|
12656 | * of patent rights can be found in the PATENTS file in the same directory.
|
12657 | *
|
12658 | * @providesModule ReactPropTypes
|
12659 | */
|
12660 |
|
12661 | "use strict";
|
12662 |
|
12663 | var ReactElement = _dereq_("./ReactElement");
|
12664 | var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
|
12665 |
|
12666 | var deprecated = _dereq_("./deprecated");
|
12667 | var emptyFunction = _dereq_("./emptyFunction");
|
12668 |
|
12669 | /**
|
12670 | * Collection of methods that allow declaration and validation of props that are
|
12671 | * supplied to React components. Example usage:
|
12672 | *
|
12673 | * var Props = require('ReactPropTypes');
|
12674 | * var MyArticle = React.createClass({
|
12675 | * propTypes: {
|
12676 | * // An optional string prop named "description".
|
12677 | * description: Props.string,
|
12678 | *
|
12679 | * // A required enum prop named "category".
|
12680 | * category: Props.oneOf(['News','Photos']).isRequired,
|
12681 | *
|
12682 | * // A prop named "dialog" that requires an instance of Dialog.
|
12683 | * dialog: Props.instanceOf(Dialog).isRequired
|
12684 | * },
|
12685 | * render: function() { ... }
|
12686 | * });
|
12687 | *
|
12688 | * A more formal specification of how these methods are used:
|
12689 | *
|
12690 | * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
12691 | * decl := ReactPropTypes.{type}(.isRequired)?
|
12692 | *
|
12693 | * Each and every declaration produces a function with the same signature. This
|
12694 | * allows the creation of custom validation functions. For example:
|
12695 | *
|
12696 | * var MyLink = React.createClass({
|
12697 | * propTypes: {
|
12698 | * // An optional string or URI prop named "href".
|
12699 | * href: function(props, propName, componentName) {
|
12700 | * var propValue = props[propName];
|
12701 | * if (propValue != null && typeof propValue !== 'string' &&
|
12702 | * !(propValue instanceof URI)) {
|
12703 | * return new Error(
|
12704 | * 'Expected a string or an URI for ' + propName + ' in ' +
|
12705 | * componentName
|
12706 | * );
|
12707 | * }
|
12708 | * }
|
12709 | * },
|
12710 | * render: function() {...}
|
12711 | * });
|
12712 | *
|
12713 | * @internal
|
12714 | */
|
12715 |
|
12716 | var ANONYMOUS = '<<anonymous>>';
|
12717 |
|
12718 | var elementTypeChecker = createElementTypeChecker();
|
12719 | var nodeTypeChecker = createNodeChecker();
|
12720 |
|
12721 | var ReactPropTypes = {
|
12722 | array: createPrimitiveTypeChecker('array'),
|
12723 | bool: createPrimitiveTypeChecker('boolean'),
|
12724 | func: createPrimitiveTypeChecker('function'),
|
12725 | number: createPrimitiveTypeChecker('number'),
|
12726 | object: createPrimitiveTypeChecker('object'),
|
12727 | string: createPrimitiveTypeChecker('string'),
|
12728 |
|
12729 | any: createAnyTypeChecker(),
|
12730 | arrayOf: createArrayOfTypeChecker,
|
12731 | element: elementTypeChecker,
|
12732 | instanceOf: createInstanceTypeChecker,
|
12733 | node: nodeTypeChecker,
|
12734 | objectOf: createObjectOfTypeChecker,
|
12735 | oneOf: createEnumTypeChecker,
|
12736 | oneOfType: createUnionTypeChecker,
|
12737 | shape: createShapeTypeChecker,
|
12738 |
|
12739 | component: deprecated(
|
12740 | 'React.PropTypes',
|
12741 | 'component',
|
12742 | 'element',
|
12743 | this,
|
12744 | elementTypeChecker
|
12745 | ),
|
12746 | renderable: deprecated(
|
12747 | 'React.PropTypes',
|
12748 | 'renderable',
|
12749 | 'node',
|
12750 | this,
|
12751 | nodeTypeChecker
|
12752 | )
|
12753 | };
|
12754 |
|
12755 | function createChainableTypeChecker(validate) {
|
12756 | function checkType(isRequired, props, propName, componentName, location) {
|
12757 | componentName = componentName || ANONYMOUS;
|
12758 | if (props[propName] == null) {
|
12759 | var locationName = ReactPropTypeLocationNames[location];
|
12760 | if (isRequired) {
|
12761 | return new Error(
|
12762 | ("Required " + locationName + " `" + propName + "` was not specified in ")+
|
12763 | ("`" + componentName + "`.")
|
12764 | );
|
12765 | }
|
12766 | } else {
|
12767 | return validate(props, propName, componentName, location);
|
12768 | }
|
12769 | }
|
12770 |
|
12771 | var chainedCheckType = checkType.bind(null, false);
|
12772 | chainedCheckType.isRequired = checkType.bind(null, true);
|
12773 |
|
12774 | return chainedCheckType;
|
12775 | }
|
12776 |
|
12777 | function createPrimitiveTypeChecker(expectedType) {
|
12778 | function validate(props, propName, componentName, location) {
|
12779 | var propValue = props[propName];
|
12780 | var propType = getPropType(propValue);
|
12781 | if (propType !== expectedType) {
|
12782 | var locationName = ReactPropTypeLocationNames[location];
|
12783 | // `propValue` being instance of, say, date/regexp, pass the 'object'
|
12784 | // check, but we can offer a more precise error message here rather than
|
12785 | // 'of type `object`'.
|
12786 | var preciseType = getPreciseType(propValue);
|
12787 |
|
12788 | return new Error(
|
12789 | ("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
|
12790 | ("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
|
12791 | );
|
12792 | }
|
12793 | }
|
12794 | return createChainableTypeChecker(validate);
|
12795 | }
|
12796 |
|
12797 | function createAnyTypeChecker() {
|
12798 | return createChainableTypeChecker(emptyFunction.thatReturns());
|
12799 | }
|
12800 |
|
12801 | function createArrayOfTypeChecker(typeChecker) {
|
12802 | function validate(props, propName, componentName, location) {
|
12803 | var propValue = props[propName];
|
12804 | if (!Array.isArray(propValue)) {
|
12805 | var locationName = ReactPropTypeLocationNames[location];
|
12806 | var propType = getPropType(propValue);
|
12807 | return new Error(
|
12808 | ("Invalid " + locationName + " `" + propName + "` of type ") +
|
12809 | ("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
|
12810 | );
|
12811 | }
|
12812 | for (var i = 0; i < propValue.length; i++) {
|
12813 | var error = typeChecker(propValue, i, componentName, location);
|
12814 | if (error instanceof Error) {
|
12815 | return error;
|
12816 | }
|
12817 | }
|
12818 | }
|
12819 | return createChainableTypeChecker(validate);
|
12820 | }
|
12821 |
|
12822 | function createElementTypeChecker() {
|
12823 | function validate(props, propName, componentName, location) {
|
12824 | if (!ReactElement.isValidElement(props[propName])) {
|
12825 | var locationName = ReactPropTypeLocationNames[location];
|
12826 | return new Error(
|
12827 | ("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
12828 | ("`" + componentName + "`, expected a ReactElement.")
|
12829 | );
|
12830 | }
|
12831 | }
|
12832 | return createChainableTypeChecker(validate);
|
12833 | }
|
12834 |
|
12835 | function createInstanceTypeChecker(expectedClass) {
|
12836 | function validate(props, propName, componentName, location) {
|
12837 | if (!(props[propName] instanceof expectedClass)) {
|
12838 | var locationName = ReactPropTypeLocationNames[location];
|
12839 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
12840 | return new Error(
|
12841 | ("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
12842 | ("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
|
12843 | );
|
12844 | }
|
12845 | }
|
12846 | return createChainableTypeChecker(validate);
|
12847 | }
|
12848 |
|
12849 | function createEnumTypeChecker(expectedValues) {
|
12850 | function validate(props, propName, componentName, location) {
|
12851 | var propValue = props[propName];
|
12852 | for (var i = 0; i < expectedValues.length; i++) {
|
12853 | if (propValue === expectedValues[i]) {
|
12854 | return;
|
12855 | }
|
12856 | }
|
12857 |
|
12858 | var locationName = ReactPropTypeLocationNames[location];
|
12859 | var valuesString = JSON.stringify(expectedValues);
|
12860 | return new Error(
|
12861 | ("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
|
12862 | ("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
|
12863 | );
|
12864 | }
|
12865 | return createChainableTypeChecker(validate);
|
12866 | }
|
12867 |
|
12868 | function createObjectOfTypeChecker(typeChecker) {
|
12869 | function validate(props, propName, componentName, location) {
|
12870 | var propValue = props[propName];
|
12871 | var propType = getPropType(propValue);
|
12872 | if (propType !== 'object') {
|
12873 | var locationName = ReactPropTypeLocationNames[location];
|
12874 | return new Error(
|
12875 | ("Invalid " + locationName + " `" + propName + "` of type ") +
|
12876 | ("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
|
12877 | );
|
12878 | }
|
12879 | for (var key in propValue) {
|
12880 | if (propValue.hasOwnProperty(key)) {
|
12881 | var error = typeChecker(propValue, key, componentName, location);
|
12882 | if (error instanceof Error) {
|
12883 | return error;
|
12884 | }
|
12885 | }
|
12886 | }
|
12887 | }
|
12888 | return createChainableTypeChecker(validate);
|
12889 | }
|
12890 |
|
12891 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
12892 | function validate(props, propName, componentName, location) {
|
12893 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
12894 | var checker = arrayOfTypeCheckers[i];
|
12895 | if (checker(props, propName, componentName, location) == null) {
|
12896 | return;
|
12897 | }
|
12898 | }
|
12899 |
|
12900 | var locationName = ReactPropTypeLocationNames[location];
|
12901 | return new Error(
|
12902 | ("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
12903 | ("`" + componentName + "`.")
|
12904 | );
|
12905 | }
|
12906 | return createChainableTypeChecker(validate);
|
12907 | }
|
12908 |
|
12909 | function createNodeChecker() {
|
12910 | function validate(props, propName, componentName, location) {
|
12911 | if (!isNode(props[propName])) {
|
12912 | var locationName = ReactPropTypeLocationNames[location];
|
12913 | return new Error(
|
12914 | ("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
12915 | ("`" + componentName + "`, expected a ReactNode.")
|
12916 | );
|
12917 | }
|
12918 | }
|
12919 | return createChainableTypeChecker(validate);
|
12920 | }
|
12921 |
|
12922 | function createShapeTypeChecker(shapeTypes) {
|
12923 | function validate(props, propName, componentName, location) {
|
12924 | var propValue = props[propName];
|
12925 | var propType = getPropType(propValue);
|
12926 | if (propType !== 'object') {
|
12927 | var locationName = ReactPropTypeLocationNames[location];
|
12928 | return new Error(
|
12929 | ("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
|
12930 | ("supplied to `" + componentName + "`, expected `object`.")
|
12931 | );
|
12932 | }
|
12933 | for (var key in shapeTypes) {
|
12934 | var checker = shapeTypes[key];
|
12935 | if (!checker) {
|
12936 | continue;
|
12937 | }
|
12938 | var error = checker(propValue, key, componentName, location);
|
12939 | if (error) {
|
12940 | return error;
|
12941 | }
|
12942 | }
|
12943 | }
|
12944 | return createChainableTypeChecker(validate, 'expected `object`');
|
12945 | }
|
12946 |
|
12947 | function isNode(propValue) {
|
12948 | switch(typeof propValue) {
|
12949 | case 'number':
|
12950 | case 'string':
|
12951 | return true;
|
12952 | case 'boolean':
|
12953 | return !propValue;
|
12954 | case 'object':
|
12955 | if (Array.isArray(propValue)) {
|
12956 | return propValue.every(isNode);
|
12957 | }
|
12958 | if (ReactElement.isValidElement(propValue)) {
|
12959 | return true;
|
12960 | }
|
12961 | for (var k in propValue) {
|
12962 | if (!isNode(propValue[k])) {
|
12963 | return false;
|
12964 | }
|
12965 | }
|
12966 | return true;
|
12967 | default:
|
12968 | return false;
|
12969 | }
|
12970 | }
|
12971 |
|
12972 | // Equivalent of `typeof` but with special handling for array and regexp.
|
12973 | function getPropType(propValue) {
|
12974 | var propType = typeof propValue;
|
12975 | if (Array.isArray(propValue)) {
|
12976 | return 'array';
|
12977 | }
|
12978 | if (propValue instanceof RegExp) {
|
12979 | // Old webkits (at least until Android 4.0) return 'function' rather than
|
12980 | // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
12981 | // passes PropTypes.object.
|
12982 | return 'object';
|
12983 | }
|
12984 | return propType;
|
12985 | }
|
12986 |
|
12987 | // This handles more types than `getPropType`. Only used for error messages.
|
12988 | // See `createPrimitiveTypeChecker`.
|
12989 | function getPreciseType(propValue) {
|
12990 | var propType = getPropType(propValue);
|
12991 | if (propType === 'object') {
|
12992 | if (propValue instanceof Date) {
|
12993 | return 'date';
|
12994 | } else if (propValue instanceof RegExp) {
|
12995 | return 'regexp';
|
12996 | }
|
12997 | }
|
12998 | return propType;
|
12999 | }
|
13000 |
|
13001 | module.exports = ReactPropTypes;
|
13002 |
|
13003 | },{"./ReactElement":52,"./ReactPropTypeLocationNames":70,"./deprecated":106,"./emptyFunction":107}],73:[function(_dereq_,module,exports){
|
13004 | /**
|
13005 | * Copyright 2013-2014, Facebook, Inc.
|
13006 | * All rights reserved.
|
13007 | *
|
13008 | * This source code is licensed under the BSD-style license found in the
|
13009 | * LICENSE file in the root directory of this source tree. An additional grant
|
13010 | * of patent rights can be found in the PATENTS file in the same directory.
|
13011 | *
|
13012 | * @providesModule ReactPutListenerQueue
|
13013 | */
|
13014 |
|
13015 | "use strict";
|
13016 |
|
13017 | var PooledClass = _dereq_("./PooledClass");
|
13018 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
13019 |
|
13020 | var assign = _dereq_("./Object.assign");
|
13021 |
|
13022 | function ReactPutListenerQueue() {
|
13023 | this.listenersToPut = [];
|
13024 | }
|
13025 |
|
13026 | assign(ReactPutListenerQueue.prototype, {
|
13027 | enqueuePutListener: function(rootNodeID, propKey, propValue) {
|
13028 | this.listenersToPut.push({
|
13029 | rootNodeID: rootNodeID,
|
13030 | propKey: propKey,
|
13031 | propValue: propValue
|
13032 | });
|
13033 | },
|
13034 |
|
13035 | putListeners: function() {
|
13036 | for (var i = 0; i < this.listenersToPut.length; i++) {
|
13037 | var listenerToPut = this.listenersToPut[i];
|
13038 | ReactBrowserEventEmitter.putListener(
|
13039 | listenerToPut.rootNodeID,
|
13040 | listenerToPut.propKey,
|
13041 | listenerToPut.propValue
|
13042 | );
|
13043 | }
|
13044 | },
|
13045 |
|
13046 | reset: function() {
|
13047 | this.listenersToPut.length = 0;
|
13048 | },
|
13049 |
|
13050 | destructor: function() {
|
13051 | this.reset();
|
13052 | }
|
13053 | });
|
13054 |
|
13055 | PooledClass.addPoolingTo(ReactPutListenerQueue);
|
13056 |
|
13057 | module.exports = ReactPutListenerQueue;
|
13058 |
|
13059 | },{"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":30}],74:[function(_dereq_,module,exports){
|
13060 | /**
|
13061 | * Copyright 2013-2014, Facebook, Inc.
|
13062 | * All rights reserved.
|
13063 | *
|
13064 | * This source code is licensed under the BSD-style license found in the
|
13065 | * LICENSE file in the root directory of this source tree. An additional grant
|
13066 | * of patent rights can be found in the PATENTS file in the same directory.
|
13067 | *
|
13068 | * @providesModule ReactReconcileTransaction
|
13069 | * @typechecks static-only
|
13070 | */
|
13071 |
|
13072 | "use strict";
|
13073 |
|
13074 | var CallbackQueue = _dereq_("./CallbackQueue");
|
13075 | var PooledClass = _dereq_("./PooledClass");
|
13076 | var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
|
13077 | var ReactInputSelection = _dereq_("./ReactInputSelection");
|
13078 | var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
|
13079 | var Transaction = _dereq_("./Transaction");
|
13080 |
|
13081 | var assign = _dereq_("./Object.assign");
|
13082 |
|
13083 | /**
|
13084 | * Ensures that, when possible, the selection range (currently selected text
|
13085 | * input) is not disturbed by performing the transaction.
|
13086 | */
|
13087 | var SELECTION_RESTORATION = {
|
13088 | /**
|
13089 | * @return {Selection} Selection information.
|
13090 | */
|
13091 | initialize: ReactInputSelection.getSelectionInformation,
|
13092 | /**
|
13093 | * @param {Selection} sel Selection information returned from `initialize`.
|
13094 | */
|
13095 | close: ReactInputSelection.restoreSelection
|
13096 | };
|
13097 |
|
13098 | /**
|
13099 | * Suppresses events (blur/focus) that could be inadvertently dispatched due to
|
13100 | * high level DOM manipulations (like temporarily removing a text input from the
|
13101 | * DOM).
|
13102 | */
|
13103 | var EVENT_SUPPRESSION = {
|
13104 | /**
|
13105 | * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
|
13106 | * the reconciliation.
|
13107 | */
|
13108 | initialize: function() {
|
13109 | var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
|
13110 | ReactBrowserEventEmitter.setEnabled(false);
|
13111 | return currentlyEnabled;
|
13112 | },
|
13113 |
|
13114 | /**
|
13115 | * @param {boolean} previouslyEnabled Enabled status of
|
13116 | * `ReactBrowserEventEmitter` before the reconciliation occured. `close`
|
13117 | * restores the previous value.
|
13118 | */
|
13119 | close: function(previouslyEnabled) {
|
13120 | ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
|
13121 | }
|
13122 | };
|
13123 |
|
13124 | /**
|
13125 | * Provides a queue for collecting `componentDidMount` and
|
13126 | * `componentDidUpdate` callbacks during the the transaction.
|
13127 | */
|
13128 | var ON_DOM_READY_QUEUEING = {
|
13129 | /**
|
13130 | * Initializes the internal `onDOMReady` queue.
|
13131 | */
|
13132 | initialize: function() {
|
13133 | this.reactMountReady.reset();
|
13134 | },
|
13135 |
|
13136 | /**
|
13137 | * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
|
13138 | */
|
13139 | close: function() {
|
13140 | this.reactMountReady.notifyAll();
|
13141 | }
|
13142 | };
|
13143 |
|
13144 | var PUT_LISTENER_QUEUEING = {
|
13145 | initialize: function() {
|
13146 | this.putListenerQueue.reset();
|
13147 | },
|
13148 |
|
13149 | close: function() {
|
13150 | this.putListenerQueue.putListeners();
|
13151 | }
|
13152 | };
|
13153 |
|
13154 | /**
|
13155 | * Executed within the scope of the `Transaction` instance. Consider these as
|
13156 | * being member methods, but with an implied ordering while being isolated from
|
13157 | * each other.
|
13158 | */
|
13159 | var TRANSACTION_WRAPPERS = [
|
13160 | PUT_LISTENER_QUEUEING,
|
13161 | SELECTION_RESTORATION,
|
13162 | EVENT_SUPPRESSION,
|
13163 | ON_DOM_READY_QUEUEING
|
13164 | ];
|
13165 |
|
13166 | /**
|
13167 | * Currently:
|
13168 | * - The order that these are listed in the transaction is critical:
|
13169 | * - Suppresses events.
|
13170 | * - Restores selection range.
|
13171 | *
|
13172 | * Future:
|
13173 | * - Restore document/overflow scroll positions that were unintentionally
|
13174 | * modified via DOM insertions above the top viewport boundary.
|
13175 | * - Implement/integrate with customized constraint based layout system and keep
|
13176 | * track of which dimensions must be remeasured.
|
13177 | *
|
13178 | * @class ReactReconcileTransaction
|
13179 | */
|
13180 | function ReactReconcileTransaction() {
|
13181 | this.reinitializeTransaction();
|
13182 | // Only server-side rendering really needs this option (see
|
13183 | // `ReactServerRendering`), but server-side uses
|
13184 | // `ReactServerRenderingTransaction` instead. This option is here so that it's
|
13185 | // accessible and defaults to false when `ReactDOMComponent` and
|
13186 | // `ReactTextComponent` checks it in `mountComponent`.`
|
13187 | this.renderToStaticMarkup = false;
|
13188 | this.reactMountReady = CallbackQueue.getPooled(null);
|
13189 | this.putListenerQueue = ReactPutListenerQueue.getPooled();
|
13190 | }
|
13191 |
|
13192 | var Mixin = {
|
13193 | /**
|
13194 | * @see Transaction
|
13195 | * @abstract
|
13196 | * @final
|
13197 | * @return {array<object>} List of operation wrap proceedures.
|
13198 | * TODO: convert to array<TransactionWrapper>
|
13199 | */
|
13200 | getTransactionWrappers: function() {
|
13201 | return TRANSACTION_WRAPPERS;
|
13202 | },
|
13203 |
|
13204 | /**
|
13205 | * @return {object} The queue to collect `onDOMReady` callbacks with.
|
13206 | */
|
13207 | getReactMountReady: function() {
|
13208 | return this.reactMountReady;
|
13209 | },
|
13210 |
|
13211 | getPutListenerQueue: function() {
|
13212 | return this.putListenerQueue;
|
13213 | },
|
13214 |
|
13215 | /**
|
13216 | * `PooledClass` looks for this, and will invoke this before allowing this
|
13217 | * instance to be resused.
|
13218 | */
|
13219 | destructor: function() {
|
13220 | CallbackQueue.release(this.reactMountReady);
|
13221 | this.reactMountReady = null;
|
13222 |
|
13223 | ReactPutListenerQueue.release(this.putListenerQueue);
|
13224 | this.putListenerQueue = null;
|
13225 | }
|
13226 | };
|
13227 |
|
13228 |
|
13229 | assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
13230 |
|
13231 | PooledClass.addPoolingTo(ReactReconcileTransaction);
|
13232 |
|
13233 | module.exports = ReactReconcileTransaction;
|
13234 |
|
13235 | },{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactBrowserEventEmitter":30,"./ReactInputSelection":59,"./ReactPutListenerQueue":73,"./Transaction":95}],75:[function(_dereq_,module,exports){
|
13236 | /**
|
13237 | * Copyright 2013-2014, Facebook, Inc.
|
13238 | * All rights reserved.
|
13239 | *
|
13240 | * This source code is licensed under the BSD-style license found in the
|
13241 | * LICENSE file in the root directory of this source tree. An additional grant
|
13242 | * of patent rights can be found in the PATENTS file in the same directory.
|
13243 | *
|
13244 | * @providesModule ReactRootIndex
|
13245 | * @typechecks
|
13246 | */
|
13247 |
|
13248 | "use strict";
|
13249 |
|
13250 | var ReactRootIndexInjection = {
|
13251 | /**
|
13252 | * @param {function} _createReactRootIndex
|
13253 | */
|
13254 | injectCreateReactRootIndex: function(_createReactRootIndex) {
|
13255 | ReactRootIndex.createReactRootIndex = _createReactRootIndex;
|
13256 | }
|
13257 | };
|
13258 |
|
13259 | var ReactRootIndex = {
|
13260 | createReactRootIndex: null,
|
13261 | injection: ReactRootIndexInjection
|
13262 | };
|
13263 |
|
13264 | module.exports = ReactRootIndex;
|
13265 |
|
13266 | },{}],76:[function(_dereq_,module,exports){
|
13267 | /**
|
13268 | * Copyright 2013-2014, Facebook, Inc.
|
13269 | * All rights reserved.
|
13270 | *
|
13271 | * This source code is licensed under the BSD-style license found in the
|
13272 | * LICENSE file in the root directory of this source tree. An additional grant
|
13273 | * of patent rights can be found in the PATENTS file in the same directory.
|
13274 | *
|
13275 | * @typechecks static-only
|
13276 | * @providesModule ReactServerRendering
|
13277 | */
|
13278 | "use strict";
|
13279 |
|
13280 | var ReactElement = _dereq_("./ReactElement");
|
13281 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
13282 | var ReactMarkupChecksum = _dereq_("./ReactMarkupChecksum");
|
13283 | var ReactServerRenderingTransaction =
|
13284 | _dereq_("./ReactServerRenderingTransaction");
|
13285 |
|
13286 | var instantiateReactComponent = _dereq_("./instantiateReactComponent");
|
13287 | var invariant = _dereq_("./invariant");
|
13288 |
|
13289 | /**
|
13290 | * @param {ReactElement} element
|
13291 | * @return {string} the HTML markup
|
13292 | */
|
13293 | function renderToString(element) {
|
13294 | ("production" !== "development" ? invariant(
|
13295 | ReactElement.isValidElement(element),
|
13296 | 'renderToString(): You must pass a valid ReactElement.'
|
13297 | ) : invariant(ReactElement.isValidElement(element)));
|
13298 |
|
13299 | var transaction;
|
13300 | try {
|
13301 | var id = ReactInstanceHandles.createReactRootID();
|
13302 | transaction = ReactServerRenderingTransaction.getPooled(false);
|
13303 |
|
13304 | return transaction.perform(function() {
|
13305 | var componentInstance = instantiateReactComponent(element, null);
|
13306 | var markup = componentInstance.mountComponent(id, transaction, 0);
|
13307 | return ReactMarkupChecksum.addChecksumToMarkup(markup);
|
13308 | }, null);
|
13309 | } finally {
|
13310 | ReactServerRenderingTransaction.release(transaction);
|
13311 | }
|
13312 | }
|
13313 |
|
13314 | /**
|
13315 | * @param {ReactElement} element
|
13316 | * @return {string} the HTML markup, without the extra React ID and checksum
|
13317 | * (for generating static pages)
|
13318 | */
|
13319 | function renderToStaticMarkup(element) {
|
13320 | ("production" !== "development" ? invariant(
|
13321 | ReactElement.isValidElement(element),
|
13322 | 'renderToStaticMarkup(): You must pass a valid ReactElement.'
|
13323 | ) : invariant(ReactElement.isValidElement(element)));
|
13324 |
|
13325 | var transaction;
|
13326 | try {
|
13327 | var id = ReactInstanceHandles.createReactRootID();
|
13328 | transaction = ReactServerRenderingTransaction.getPooled(true);
|
13329 |
|
13330 | return transaction.perform(function() {
|
13331 | var componentInstance = instantiateReactComponent(element, null);
|
13332 | return componentInstance.mountComponent(id, transaction, 0);
|
13333 | }, null);
|
13334 | } finally {
|
13335 | ReactServerRenderingTransaction.release(transaction);
|
13336 | }
|
13337 | }
|
13338 |
|
13339 | module.exports = {
|
13340 | renderToString: renderToString,
|
13341 | renderToStaticMarkup: renderToStaticMarkup
|
13342 | };
|
13343 |
|
13344 | },{"./ReactElement":52,"./ReactInstanceHandles":60,"./ReactMarkupChecksum":62,"./ReactServerRenderingTransaction":77,"./instantiateReactComponent":125,"./invariant":126}],77:[function(_dereq_,module,exports){
|
13345 | /**
|
13346 | * Copyright 2014, Facebook, Inc.
|
13347 | * All rights reserved.
|
13348 | *
|
13349 | * This source code is licensed under the BSD-style license found in the
|
13350 | * LICENSE file in the root directory of this source tree. An additional grant
|
13351 | * of patent rights can be found in the PATENTS file in the same directory.
|
13352 | *
|
13353 | * @providesModule ReactServerRenderingTransaction
|
13354 | * @typechecks
|
13355 | */
|
13356 |
|
13357 | "use strict";
|
13358 |
|
13359 | var PooledClass = _dereq_("./PooledClass");
|
13360 | var CallbackQueue = _dereq_("./CallbackQueue");
|
13361 | var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
|
13362 | var Transaction = _dereq_("./Transaction");
|
13363 |
|
13364 | var assign = _dereq_("./Object.assign");
|
13365 | var emptyFunction = _dereq_("./emptyFunction");
|
13366 |
|
13367 | /**
|
13368 | * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
|
13369 | * during the performing of the transaction.
|
13370 | */
|
13371 | var ON_DOM_READY_QUEUEING = {
|
13372 | /**
|
13373 | * Initializes the internal `onDOMReady` queue.
|
13374 | */
|
13375 | initialize: function() {
|
13376 | this.reactMountReady.reset();
|
13377 | },
|
13378 |
|
13379 | close: emptyFunction
|
13380 | };
|
13381 |
|
13382 | var PUT_LISTENER_QUEUEING = {
|
13383 | initialize: function() {
|
13384 | this.putListenerQueue.reset();
|
13385 | },
|
13386 |
|
13387 | close: emptyFunction
|
13388 | };
|
13389 |
|
13390 | /**
|
13391 | * Executed within the scope of the `Transaction` instance. Consider these as
|
13392 | * being member methods, but with an implied ordering while being isolated from
|
13393 | * each other.
|
13394 | */
|
13395 | var TRANSACTION_WRAPPERS = [
|
13396 | PUT_LISTENER_QUEUEING,
|
13397 | ON_DOM_READY_QUEUEING
|
13398 | ];
|
13399 |
|
13400 | /**
|
13401 | * @class ReactServerRenderingTransaction
|
13402 | * @param {boolean} renderToStaticMarkup
|
13403 | */
|
13404 | function ReactServerRenderingTransaction(renderToStaticMarkup) {
|
13405 | this.reinitializeTransaction();
|
13406 | this.renderToStaticMarkup = renderToStaticMarkup;
|
13407 | this.reactMountReady = CallbackQueue.getPooled(null);
|
13408 | this.putListenerQueue = ReactPutListenerQueue.getPooled();
|
13409 | }
|
13410 |
|
13411 | var Mixin = {
|
13412 | /**
|
13413 | * @see Transaction
|
13414 | * @abstract
|
13415 | * @final
|
13416 | * @return {array} Empty list of operation wrap proceedures.
|
13417 | */
|
13418 | getTransactionWrappers: function() {
|
13419 | return TRANSACTION_WRAPPERS;
|
13420 | },
|
13421 |
|
13422 | /**
|
13423 | * @return {object} The queue to collect `onDOMReady` callbacks with.
|
13424 | */
|
13425 | getReactMountReady: function() {
|
13426 | return this.reactMountReady;
|
13427 | },
|
13428 |
|
13429 | getPutListenerQueue: function() {
|
13430 | return this.putListenerQueue;
|
13431 | },
|
13432 |
|
13433 | /**
|
13434 | * `PooledClass` looks for this, and will invoke this before allowing this
|
13435 | * instance to be resused.
|
13436 | */
|
13437 | destructor: function() {
|
13438 | CallbackQueue.release(this.reactMountReady);
|
13439 | this.reactMountReady = null;
|
13440 |
|
13441 | ReactPutListenerQueue.release(this.putListenerQueue);
|
13442 | this.putListenerQueue = null;
|
13443 | }
|
13444 | };
|
13445 |
|
13446 |
|
13447 | assign(
|
13448 | ReactServerRenderingTransaction.prototype,
|
13449 | Transaction.Mixin,
|
13450 | Mixin
|
13451 | );
|
13452 |
|
13453 | PooledClass.addPoolingTo(ReactServerRenderingTransaction);
|
13454 |
|
13455 | module.exports = ReactServerRenderingTransaction;
|
13456 |
|
13457 | },{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactPutListenerQueue":73,"./Transaction":95,"./emptyFunction":107}],78:[function(_dereq_,module,exports){
|
13458 | /**
|
13459 | * Copyright 2013-2014, Facebook, Inc.
|
13460 | * All rights reserved.
|
13461 | *
|
13462 | * This source code is licensed under the BSD-style license found in the
|
13463 | * LICENSE file in the root directory of this source tree. An additional grant
|
13464 | * of patent rights can be found in the PATENTS file in the same directory.
|
13465 | *
|
13466 | * @providesModule ReactTextComponent
|
13467 | * @typechecks static-only
|
13468 | */
|
13469 |
|
13470 | "use strict";
|
13471 |
|
13472 | var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
|
13473 | var ReactComponent = _dereq_("./ReactComponent");
|
13474 | var ReactElement = _dereq_("./ReactElement");
|
13475 |
|
13476 | var assign = _dereq_("./Object.assign");
|
13477 | var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
|
13478 |
|
13479 | /**
|
13480 | * Text nodes violate a couple assumptions that React makes about components:
|
13481 | *
|
13482 | * - When mounting text into the DOM, adjacent text nodes are merged.
|
13483 | * - Text nodes cannot be assigned a React root ID.
|
13484 | *
|
13485 | * This component is used to wrap strings in elements so that they can undergo
|
13486 | * the same reconciliation that is applied to elements.
|
13487 | *
|
13488 | * TODO: Investigate representing React components in the DOM with text nodes.
|
13489 | *
|
13490 | * @class ReactTextComponent
|
13491 | * @extends ReactComponent
|
13492 | * @internal
|
13493 | */
|
13494 | var ReactTextComponent = function(props) {
|
13495 | // This constructor and it's argument is currently used by mocks.
|
13496 | };
|
13497 |
|
13498 | assign(ReactTextComponent.prototype, ReactComponent.Mixin, {
|
13499 |
|
13500 | /**
|
13501 | * Creates the markup for this text node. This node is not intended to have
|
13502 | * any features besides containing text content.
|
13503 | *
|
13504 | * @param {string} rootID DOM ID of the root node.
|
13505 | * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
13506 | * @param {number} mountDepth number of components in the owner hierarchy
|
13507 | * @return {string} Markup for this text node.
|
13508 | * @internal
|
13509 | */
|
13510 | mountComponent: function(rootID, transaction, mountDepth) {
|
13511 | ReactComponent.Mixin.mountComponent.call(
|
13512 | this,
|
13513 | rootID,
|
13514 | transaction,
|
13515 | mountDepth
|
13516 | );
|
13517 |
|
13518 | var escapedText = escapeTextForBrowser(this.props);
|
13519 |
|
13520 | if (transaction.renderToStaticMarkup) {
|
13521 | // Normally we'd wrap this in a `span` for the reasons stated above, but
|
13522 | // since this is a situation where React won't take over (static pages),
|
13523 | // we can simply return the text as it is.
|
13524 | return escapedText;
|
13525 | }
|
13526 |
|
13527 | return (
|
13528 | '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
|
13529 | escapedText +
|
13530 | '</span>'
|
13531 | );
|
13532 | },
|
13533 |
|
13534 | /**
|
13535 | * Updates this component by updating the text content.
|
13536 | *
|
13537 | * @param {object} nextComponent Contains the next text content.
|
13538 | * @param {ReactReconcileTransaction} transaction
|
13539 | * @internal
|
13540 | */
|
13541 | receiveComponent: function(nextComponent, transaction) {
|
13542 | var nextProps = nextComponent.props;
|
13543 | if (nextProps !== this.props) {
|
13544 | this.props = nextProps;
|
13545 | ReactComponent.BackendIDOperations.updateTextContentByID(
|
13546 | this._rootNodeID,
|
13547 | nextProps
|
13548 | );
|
13549 | }
|
13550 | }
|
13551 |
|
13552 | });
|
13553 |
|
13554 | var ReactTextComponentFactory = function(text) {
|
13555 | // Bypass validation and configuration
|
13556 | return new ReactElement(ReactTextComponent, null, null, null, null, text);
|
13557 | };
|
13558 |
|
13559 | ReactTextComponentFactory.type = ReactTextComponent;
|
13560 |
|
13561 | module.exports = ReactTextComponentFactory;
|
13562 |
|
13563 | },{"./DOMPropertyOperations":12,"./Object.assign":27,"./ReactComponent":32,"./ReactElement":52,"./escapeTextForBrowser":109}],79:[function(_dereq_,module,exports){
|
13564 | /**
|
13565 | * Copyright 2013-2014, Facebook, Inc.
|
13566 | * All rights reserved.
|
13567 | *
|
13568 | * This source code is licensed under the BSD-style license found in the
|
13569 | * LICENSE file in the root directory of this source tree. An additional grant
|
13570 | * of patent rights can be found in the PATENTS file in the same directory.
|
13571 | *
|
13572 | * @providesModule ReactUpdates
|
13573 | */
|
13574 |
|
13575 | "use strict";
|
13576 |
|
13577 | var CallbackQueue = _dereq_("./CallbackQueue");
|
13578 | var PooledClass = _dereq_("./PooledClass");
|
13579 | var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
|
13580 | var ReactPerf = _dereq_("./ReactPerf");
|
13581 | var Transaction = _dereq_("./Transaction");
|
13582 |
|
13583 | var assign = _dereq_("./Object.assign");
|
13584 | var invariant = _dereq_("./invariant");
|
13585 | var warning = _dereq_("./warning");
|
13586 |
|
13587 | var dirtyComponents = [];
|
13588 | var asapCallbackQueue = CallbackQueue.getPooled();
|
13589 | var asapEnqueued = false;
|
13590 |
|
13591 | var batchingStrategy = null;
|
13592 |
|
13593 | function ensureInjected() {
|
13594 | ("production" !== "development" ? invariant(
|
13595 | ReactUpdates.ReactReconcileTransaction && batchingStrategy,
|
13596 | 'ReactUpdates: must inject a reconcile transaction class and batching ' +
|
13597 | 'strategy'
|
13598 | ) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
|
13599 | }
|
13600 |
|
13601 | var NESTED_UPDATES = {
|
13602 | initialize: function() {
|
13603 | this.dirtyComponentsLength = dirtyComponents.length;
|
13604 | },
|
13605 | close: function() {
|
13606 | if (this.dirtyComponentsLength !== dirtyComponents.length) {
|
13607 | // Additional updates were enqueued by componentDidUpdate handlers or
|
13608 | // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
|
13609 | // these new updates so that if A's componentDidUpdate calls setState on
|
13610 | // B, B will update before the callback A's updater provided when calling
|
13611 | // setState.
|
13612 | dirtyComponents.splice(0, this.dirtyComponentsLength);
|
13613 | flushBatchedUpdates();
|
13614 | } else {
|
13615 | dirtyComponents.length = 0;
|
13616 | }
|
13617 | }
|
13618 | };
|
13619 |
|
13620 | var UPDATE_QUEUEING = {
|
13621 | initialize: function() {
|
13622 | this.callbackQueue.reset();
|
13623 | },
|
13624 | close: function() {
|
13625 | this.callbackQueue.notifyAll();
|
13626 | }
|
13627 | };
|
13628 |
|
13629 | var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
|
13630 |
|
13631 | function ReactUpdatesFlushTransaction() {
|
13632 | this.reinitializeTransaction();
|
13633 | this.dirtyComponentsLength = null;
|
13634 | this.callbackQueue = CallbackQueue.getPooled();
|
13635 | this.reconcileTransaction =
|
13636 | ReactUpdates.ReactReconcileTransaction.getPooled();
|
13637 | }
|
13638 |
|
13639 | assign(
|
13640 | ReactUpdatesFlushTransaction.prototype,
|
13641 | Transaction.Mixin, {
|
13642 | getTransactionWrappers: function() {
|
13643 | return TRANSACTION_WRAPPERS;
|
13644 | },
|
13645 |
|
13646 | destructor: function() {
|
13647 | this.dirtyComponentsLength = null;
|
13648 | CallbackQueue.release(this.callbackQueue);
|
13649 | this.callbackQueue = null;
|
13650 | ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
|
13651 | this.reconcileTransaction = null;
|
13652 | },
|
13653 |
|
13654 | perform: function(method, scope, a) {
|
13655 | // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
|
13656 | // with this transaction's wrappers around it.
|
13657 | return Transaction.Mixin.perform.call(
|
13658 | this,
|
13659 | this.reconcileTransaction.perform,
|
13660 | this.reconcileTransaction,
|
13661 | method,
|
13662 | scope,
|
13663 | a
|
13664 | );
|
13665 | }
|
13666 | });
|
13667 |
|
13668 | PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
|
13669 |
|
13670 | function batchedUpdates(callback, a, b) {
|
13671 | ensureInjected();
|
13672 | batchingStrategy.batchedUpdates(callback, a, b);
|
13673 | }
|
13674 |
|
13675 | /**
|
13676 | * Array comparator for ReactComponents by owner depth
|
13677 | *
|
13678 | * @param {ReactComponent} c1 first component you're comparing
|
13679 | * @param {ReactComponent} c2 second component you're comparing
|
13680 | * @return {number} Return value usable by Array.prototype.sort().
|
13681 | */
|
13682 | function mountDepthComparator(c1, c2) {
|
13683 | return c1._mountDepth - c2._mountDepth;
|
13684 | }
|
13685 |
|
13686 | function runBatchedUpdates(transaction) {
|
13687 | var len = transaction.dirtyComponentsLength;
|
13688 | ("production" !== "development" ? invariant(
|
13689 | len === dirtyComponents.length,
|
13690 | 'Expected flush transaction\'s stored dirty-components length (%s) to ' +
|
13691 | 'match dirty-components array length (%s).',
|
13692 | len,
|
13693 | dirtyComponents.length
|
13694 | ) : invariant(len === dirtyComponents.length));
|
13695 |
|
13696 | // Since reconciling a component higher in the owner hierarchy usually (not
|
13697 | // always -- see shouldComponentUpdate()) will reconcile children, reconcile
|
13698 | // them before their children by sorting the array.
|
13699 | dirtyComponents.sort(mountDepthComparator);
|
13700 |
|
13701 | for (var i = 0; i < len; i++) {
|
13702 | // If a component is unmounted before pending changes apply, ignore them
|
13703 | // TODO: Queue unmounts in the same list to avoid this happening at all
|
13704 | var component = dirtyComponents[i];
|
13705 | if (component.isMounted()) {
|
13706 | // If performUpdateIfNecessary happens to enqueue any new updates, we
|
13707 | // shouldn't execute the callbacks until the next render happens, so
|
13708 | // stash the callbacks first
|
13709 | var callbacks = component._pendingCallbacks;
|
13710 | component._pendingCallbacks = null;
|
13711 | component.performUpdateIfNecessary(transaction.reconcileTransaction);
|
13712 |
|
13713 | if (callbacks) {
|
13714 | for (var j = 0; j < callbacks.length; j++) {
|
13715 | transaction.callbackQueue.enqueue(
|
13716 | callbacks[j],
|
13717 | component
|
13718 | );
|
13719 | }
|
13720 | }
|
13721 | }
|
13722 | }
|
13723 | }
|
13724 |
|
13725 | var flushBatchedUpdates = ReactPerf.measure(
|
13726 | 'ReactUpdates',
|
13727 | 'flushBatchedUpdates',
|
13728 | function() {
|
13729 | // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
|
13730 | // array and perform any updates enqueued by mount-ready handlers (i.e.,
|
13731 | // componentDidUpdate) but we need to check here too in order to catch
|
13732 | // updates enqueued by setState callbacks and asap calls.
|
13733 | while (dirtyComponents.length || asapEnqueued) {
|
13734 | if (dirtyComponents.length) {
|
13735 | var transaction = ReactUpdatesFlushTransaction.getPooled();
|
13736 | transaction.perform(runBatchedUpdates, null, transaction);
|
13737 | ReactUpdatesFlushTransaction.release(transaction);
|
13738 | }
|
13739 |
|
13740 | if (asapEnqueued) {
|
13741 | asapEnqueued = false;
|
13742 | var queue = asapCallbackQueue;
|
13743 | asapCallbackQueue = CallbackQueue.getPooled();
|
13744 | queue.notifyAll();
|
13745 | CallbackQueue.release(queue);
|
13746 | }
|
13747 | }
|
13748 | }
|
13749 | );
|
13750 |
|
13751 | /**
|
13752 | * Mark a component as needing a rerender, adding an optional callback to a
|
13753 | * list of functions which will be executed once the rerender occurs.
|
13754 | */
|
13755 | function enqueueUpdate(component, callback) {
|
13756 | ("production" !== "development" ? invariant(
|
13757 | !callback || typeof callback === "function",
|
13758 | 'enqueueUpdate(...): You called `setProps`, `replaceProps`, ' +
|
13759 | '`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
|
13760 | 'isn\'t callable.'
|
13761 | ) : invariant(!callback || typeof callback === "function"));
|
13762 | ensureInjected();
|
13763 |
|
13764 | // Various parts of our code (such as ReactCompositeComponent's
|
13765 | // _renderValidatedComponent) assume that calls to render aren't nested;
|
13766 | // verify that that's the case. (This is called by each top-level update
|
13767 | // function, like setProps, setState, forceUpdate, etc.; creation and
|
13768 | // destruction of top-level components is guarded in ReactMount.)
|
13769 | ("production" !== "development" ? warning(
|
13770 | ReactCurrentOwner.current == null,
|
13771 | 'enqueueUpdate(): Render methods should be a pure function of props ' +
|
13772 | 'and state; triggering nested component updates from render is not ' +
|
13773 | 'allowed. If necessary, trigger nested updates in ' +
|
13774 | 'componentDidUpdate.'
|
13775 | ) : null);
|
13776 |
|
13777 | if (!batchingStrategy.isBatchingUpdates) {
|
13778 | batchingStrategy.batchedUpdates(enqueueUpdate, component, callback);
|
13779 | return;
|
13780 | }
|
13781 |
|
13782 | dirtyComponents.push(component);
|
13783 |
|
13784 | if (callback) {
|
13785 | if (component._pendingCallbacks) {
|
13786 | component._pendingCallbacks.push(callback);
|
13787 | } else {
|
13788 | component._pendingCallbacks = [callback];
|
13789 | }
|
13790 | }
|
13791 | }
|
13792 |
|
13793 | /**
|
13794 | * Enqueue a callback to be run at the end of the current batching cycle. Throws
|
13795 | * if no updates are currently being performed.
|
13796 | */
|
13797 | function asap(callback, context) {
|
13798 | ("production" !== "development" ? invariant(
|
13799 | batchingStrategy.isBatchingUpdates,
|
13800 | 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
|
13801 | 'updates are not being batched.'
|
13802 | ) : invariant(batchingStrategy.isBatchingUpdates));
|
13803 | asapCallbackQueue.enqueue(callback, context);
|
13804 | asapEnqueued = true;
|
13805 | }
|
13806 |
|
13807 | var ReactUpdatesInjection = {
|
13808 | injectReconcileTransaction: function(ReconcileTransaction) {
|
13809 | ("production" !== "development" ? invariant(
|
13810 | ReconcileTransaction,
|
13811 | 'ReactUpdates: must provide a reconcile transaction class'
|
13812 | ) : invariant(ReconcileTransaction));
|
13813 | ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
|
13814 | },
|
13815 |
|
13816 | injectBatchingStrategy: function(_batchingStrategy) {
|
13817 | ("production" !== "development" ? invariant(
|
13818 | _batchingStrategy,
|
13819 | 'ReactUpdates: must provide a batching strategy'
|
13820 | ) : invariant(_batchingStrategy));
|
13821 | ("production" !== "development" ? invariant(
|
13822 | typeof _batchingStrategy.batchedUpdates === 'function',
|
13823 | 'ReactUpdates: must provide a batchedUpdates() function'
|
13824 | ) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
|
13825 | ("production" !== "development" ? invariant(
|
13826 | typeof _batchingStrategy.isBatchingUpdates === 'boolean',
|
13827 | 'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
|
13828 | ) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
|
13829 | batchingStrategy = _batchingStrategy;
|
13830 | }
|
13831 | };
|
13832 |
|
13833 | var ReactUpdates = {
|
13834 | /**
|
13835 | * React references `ReactReconcileTransaction` using this property in order
|
13836 | * to allow dependency injection.
|
13837 | *
|
13838 | * @internal
|
13839 | */
|
13840 | ReactReconcileTransaction: null,
|
13841 |
|
13842 | batchedUpdates: batchedUpdates,
|
13843 | enqueueUpdate: enqueueUpdate,
|
13844 | flushBatchedUpdates: flushBatchedUpdates,
|
13845 | injection: ReactUpdatesInjection,
|
13846 | asap: asap
|
13847 | };
|
13848 |
|
13849 | module.exports = ReactUpdates;
|
13850 |
|
13851 | },{"./CallbackQueue":6,"./Object.assign":27,"./PooledClass":28,"./ReactCurrentOwner":36,"./ReactPerf":68,"./Transaction":95,"./invariant":126,"./warning":145}],80:[function(_dereq_,module,exports){
|
13852 | /**
|
13853 | * Copyright 2013-2014, Facebook, Inc.
|
13854 | * All rights reserved.
|
13855 | *
|
13856 | * This source code is licensed under the BSD-style license found in the
|
13857 | * LICENSE file in the root directory of this source tree. An additional grant
|
13858 | * of patent rights can be found in the PATENTS file in the same directory.
|
13859 | *
|
13860 | * @providesModule SVGDOMPropertyConfig
|
13861 | */
|
13862 |
|
13863 | /*jslint bitwise: true*/
|
13864 |
|
13865 | "use strict";
|
13866 |
|
13867 | var DOMProperty = _dereq_("./DOMProperty");
|
13868 |
|
13869 | var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
|
13870 |
|
13871 | var SVGDOMPropertyConfig = {
|
13872 | Properties: {
|
13873 | clipPath: MUST_USE_ATTRIBUTE,
|
13874 | cx: MUST_USE_ATTRIBUTE,
|
13875 | cy: MUST_USE_ATTRIBUTE,
|
13876 | d: MUST_USE_ATTRIBUTE,
|
13877 | dx: MUST_USE_ATTRIBUTE,
|
13878 | dy: MUST_USE_ATTRIBUTE,
|
13879 | fill: MUST_USE_ATTRIBUTE,
|
13880 | fillOpacity: MUST_USE_ATTRIBUTE,
|
13881 | filter: MUST_USE_ATTRIBUTE,
|
13882 | fontFamily: MUST_USE_ATTRIBUTE,
|
13883 | fontSize: MUST_USE_ATTRIBUTE,
|
13884 | fontWeight: MUST_USE_ATTRIBUTE,
|
13885 | fx: MUST_USE_ATTRIBUTE,
|
13886 | fy: MUST_USE_ATTRIBUTE,
|
13887 | gradientTransform: MUST_USE_ATTRIBUTE,
|
13888 | gradientUnits: MUST_USE_ATTRIBUTE,
|
13889 | k2: MUST_USE_ATTRIBUTE,
|
13890 | k3: MUST_USE_ATTRIBUTE,
|
13891 | in: MUST_USE_ATTRIBUTE,
|
13892 | in2: MUST_USE_ATTRIBUTE,
|
13893 | operator: MUST_USE_ATTRIBUTE,
|
13894 | floodColor: MUST_USE_ATTRIBUTE,
|
13895 | floodOpacity: MUST_USE_ATTRIBUTE,
|
13896 | stdDeviation: MUST_USE_ATTRIBUTE,
|
13897 | result: MUST_USE_ATTRIBUTE,
|
13898 | out: MUST_USE_ATTRIBUTE,
|
13899 | markerEnd: MUST_USE_ATTRIBUTE,
|
13900 | markerMid: MUST_USE_ATTRIBUTE,
|
13901 | markerStart: MUST_USE_ATTRIBUTE,
|
13902 | mask: MUST_USE_ATTRIBUTE,
|
13903 | offset: MUST_USE_ATTRIBUTE,
|
13904 | opacity: MUST_USE_ATTRIBUTE,
|
13905 | patternContentUnits: MUST_USE_ATTRIBUTE,
|
13906 | patternUnits: MUST_USE_ATTRIBUTE,
|
13907 | points: MUST_USE_ATTRIBUTE,
|
13908 | preserveAspectRatio: MUST_USE_ATTRIBUTE,
|
13909 | r: MUST_USE_ATTRIBUTE,
|
13910 | rx: MUST_USE_ATTRIBUTE,
|
13911 | ry: MUST_USE_ATTRIBUTE,
|
13912 | spreadMethod: MUST_USE_ATTRIBUTE,
|
13913 | stopColor: MUST_USE_ATTRIBUTE,
|
13914 | stopOpacity: MUST_USE_ATTRIBUTE,
|
13915 | stroke: MUST_USE_ATTRIBUTE,
|
13916 | strokeDasharray: MUST_USE_ATTRIBUTE,
|
13917 | strokeLinecap: MUST_USE_ATTRIBUTE,
|
13918 | strokeOpacity: MUST_USE_ATTRIBUTE,
|
13919 | strokeWidth: MUST_USE_ATTRIBUTE,
|
13920 | textAnchor: MUST_USE_ATTRIBUTE,
|
13921 | transform: MUST_USE_ATTRIBUTE,
|
13922 | values: MUST_USE_ATTRIBUTE,
|
13923 | version: MUST_USE_ATTRIBUTE,
|
13924 | viewBox: MUST_USE_ATTRIBUTE,
|
13925 | 'xlink:href': MUST_USE_ATTRIBUTE,
|
13926 | x0: MUST_USE_ATTRIBUTE,
|
13927 | y0: MUST_USE_ATTRIBUTE,
|
13928 | x1: MUST_USE_ATTRIBUTE,
|
13929 | x2: MUST_USE_ATTRIBUTE,
|
13930 | x: MUST_USE_ATTRIBUTE,
|
13931 | y1: MUST_USE_ATTRIBUTE,
|
13932 | y2: MUST_USE_ATTRIBUTE,
|
13933 | y: MUST_USE_ATTRIBUTE
|
13934 | },
|
13935 | DOMAttributeNames: {
|
13936 | fillOpacity: 'fill-opacity',
|
13937 | fontFamily: 'font-family',
|
13938 | fontSize: 'font-size',
|
13939 | gradientTransform: 'gradientTransform',
|
13940 | gradientUnits: 'gradientUnits',
|
13941 | markerEnd: 'marker-end',
|
13942 | markerMid: 'marker-mid',
|
13943 | markerStart: 'marker-start',
|
13944 | patternContentUnits: 'patternContentUnits',
|
13945 | patternUnits: 'patternUnits',
|
13946 | preserveAspectRatio: 'preserveAspectRatio',
|
13947 | spreadMethod: 'spreadMethod',
|
13948 | stopColor: 'stop-color',
|
13949 | stopOpacity: 'stop-opacity',
|
13950 | strokeDasharray: 'stroke-dasharray',
|
13951 | strokeLinecap: 'stroke-linecap',
|
13952 | strokeOpacity: 'stroke-opacity',
|
13953 | strokeWidth: 'stroke-width',
|
13954 | textAnchor: 'text-anchor',
|
13955 | viewBox: 'viewBox'
|
13956 | }
|
13957 | };
|
13958 |
|
13959 | module.exports = SVGDOMPropertyConfig;
|
13960 |
|
13961 | },{"./DOMProperty":11}],81:[function(_dereq_,module,exports){
|
13962 | /**
|
13963 | * Copyright 2013-2014, Facebook, Inc.
|
13964 | * All rights reserved.
|
13965 | *
|
13966 | * This source code is licensed under the BSD-style license found in the
|
13967 | * LICENSE file in the root directory of this source tree. An additional grant
|
13968 | * of patent rights can be found in the PATENTS file in the same directory.
|
13969 | *
|
13970 | * @providesModule SelectEventPlugin
|
13971 | */
|
13972 |
|
13973 | "use strict";
|
13974 |
|
13975 | var EventConstants = _dereq_("./EventConstants");
|
13976 | var EventPropagators = _dereq_("./EventPropagators");
|
13977 | var ReactInputSelection = _dereq_("./ReactInputSelection");
|
13978 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
13979 |
|
13980 | var getActiveElement = _dereq_("./getActiveElement");
|
13981 | var isTextInputElement = _dereq_("./isTextInputElement");
|
13982 | var keyOf = _dereq_("./keyOf");
|
13983 | var shallowEqual = _dereq_("./shallowEqual");
|
13984 |
|
13985 | var topLevelTypes = EventConstants.topLevelTypes;
|
13986 |
|
13987 | var eventTypes = {
|
13988 | select: {
|
13989 | phasedRegistrationNames: {
|
13990 | bubbled: keyOf({onSelect: null}),
|
13991 | captured: keyOf({onSelectCapture: null})
|
13992 | },
|
13993 | dependencies: [
|
13994 | topLevelTypes.topBlur,
|
13995 | topLevelTypes.topContextMenu,
|
13996 | topLevelTypes.topFocus,
|
13997 | topLevelTypes.topKeyDown,
|
13998 | topLevelTypes.topMouseDown,
|
13999 | topLevelTypes.topMouseUp,
|
14000 | topLevelTypes.topSelectionChange
|
14001 | ]
|
14002 | }
|
14003 | };
|
14004 |
|
14005 | var activeElement = null;
|
14006 | var activeElementID = null;
|
14007 | var lastSelection = null;
|
14008 | var mouseDown = false;
|
14009 |
|
14010 | /**
|
14011 | * Get an object which is a unique representation of the current selection.
|
14012 | *
|
14013 | * The return value will not be consistent across nodes or browsers, but
|
14014 | * two identical selections on the same node will return identical objects.
|
14015 | *
|
14016 | * @param {DOMElement} node
|
14017 | * @param {object}
|
14018 | */
|
14019 | function getSelection(node) {
|
14020 | if ('selectionStart' in node &&
|
14021 | ReactInputSelection.hasSelectionCapabilities(node)) {
|
14022 | return {
|
14023 | start: node.selectionStart,
|
14024 | end: node.selectionEnd
|
14025 | };
|
14026 | } else if (window.getSelection) {
|
14027 | var selection = window.getSelection();
|
14028 | return {
|
14029 | anchorNode: selection.anchorNode,
|
14030 | anchorOffset: selection.anchorOffset,
|
14031 | focusNode: selection.focusNode,
|
14032 | focusOffset: selection.focusOffset
|
14033 | };
|
14034 | } else if (document.selection) {
|
14035 | var range = document.selection.createRange();
|
14036 | return {
|
14037 | parentElement: range.parentElement(),
|
14038 | text: range.text,
|
14039 | top: range.boundingTop,
|
14040 | left: range.boundingLeft
|
14041 | };
|
14042 | }
|
14043 | }
|
14044 |
|
14045 | /**
|
14046 | * Poll selection to see whether it's changed.
|
14047 | *
|
14048 | * @param {object} nativeEvent
|
14049 | * @return {?SyntheticEvent}
|
14050 | */
|
14051 | function constructSelectEvent(nativeEvent) {
|
14052 | // Ensure we have the right element, and that the user is not dragging a
|
14053 | // selection (this matches native `select` event behavior). In HTML5, select
|
14054 | // fires only on input and textarea thus if there's no focused element we
|
14055 | // won't dispatch.
|
14056 | if (mouseDown ||
|
14057 | activeElement == null ||
|
14058 | activeElement != getActiveElement()) {
|
14059 | return;
|
14060 | }
|
14061 |
|
14062 | // Only fire when selection has actually changed.
|
14063 | var currentSelection = getSelection(activeElement);
|
14064 | if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
14065 | lastSelection = currentSelection;
|
14066 |
|
14067 | var syntheticEvent = SyntheticEvent.getPooled(
|
14068 | eventTypes.select,
|
14069 | activeElementID,
|
14070 | nativeEvent
|
14071 | );
|
14072 |
|
14073 | syntheticEvent.type = 'select';
|
14074 | syntheticEvent.target = activeElement;
|
14075 |
|
14076 | EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
|
14077 |
|
14078 | return syntheticEvent;
|
14079 | }
|
14080 | }
|
14081 |
|
14082 | /**
|
14083 | * This plugin creates an `onSelect` event that normalizes select events
|
14084 | * across form elements.
|
14085 | *
|
14086 | * Supported elements are:
|
14087 | * - input (see `isTextInputElement`)
|
14088 | * - textarea
|
14089 | * - contentEditable
|
14090 | *
|
14091 | * This differs from native browser implementations in the following ways:
|
14092 | * - Fires on contentEditable fields as well as inputs.
|
14093 | * - Fires for collapsed selection.
|
14094 | * - Fires after user input.
|
14095 | */
|
14096 | var SelectEventPlugin = {
|
14097 |
|
14098 | eventTypes: eventTypes,
|
14099 |
|
14100 | /**
|
14101 | * @param {string} topLevelType Record from `EventConstants`.
|
14102 | * @param {DOMEventTarget} topLevelTarget The listening component root node.
|
14103 | * @param {string} topLevelTargetID ID of `topLevelTarget`.
|
14104 | * @param {object} nativeEvent Native browser event.
|
14105 | * @return {*} An accumulation of synthetic events.
|
14106 | * @see {EventPluginHub.extractEvents}
|
14107 | */
|
14108 | extractEvents: function(
|
14109 | topLevelType,
|
14110 | topLevelTarget,
|
14111 | topLevelTargetID,
|
14112 | nativeEvent) {
|
14113 |
|
14114 | switch (topLevelType) {
|
14115 | // Track the input node that has focus.
|
14116 | case topLevelTypes.topFocus:
|
14117 | if (isTextInputElement(topLevelTarget) ||
|
14118 | topLevelTarget.contentEditable === 'true') {
|
14119 | activeElement = topLevelTarget;
|
14120 | activeElementID = topLevelTargetID;
|
14121 | lastSelection = null;
|
14122 | }
|
14123 | break;
|
14124 | case topLevelTypes.topBlur:
|
14125 | activeElement = null;
|
14126 | activeElementID = null;
|
14127 | lastSelection = null;
|
14128 | break;
|
14129 |
|
14130 | // Don't fire the event while the user is dragging. This matches the
|
14131 | // semantics of the native select event.
|
14132 | case topLevelTypes.topMouseDown:
|
14133 | mouseDown = true;
|
14134 | break;
|
14135 | case topLevelTypes.topContextMenu:
|
14136 | case topLevelTypes.topMouseUp:
|
14137 | mouseDown = false;
|
14138 | return constructSelectEvent(nativeEvent);
|
14139 |
|
14140 | // Chrome and IE fire non-standard event when selection is changed (and
|
14141 | // sometimes when it hasn't).
|
14142 | // Firefox doesn't support selectionchange, so check selection status
|
14143 | // after each key entry. The selection changes after keydown and before
|
14144 | // keyup, but we check on keydown as well in the case of holding down a
|
14145 | // key, when multiple keydown events are fired but only one keyup is.
|
14146 | case topLevelTypes.topSelectionChange:
|
14147 | case topLevelTypes.topKeyDown:
|
14148 | case topLevelTypes.topKeyUp:
|
14149 | return constructSelectEvent(nativeEvent);
|
14150 | }
|
14151 | }
|
14152 | };
|
14153 |
|
14154 | module.exports = SelectEventPlugin;
|
14155 |
|
14156 | },{"./EventConstants":16,"./EventPropagators":21,"./ReactInputSelection":59,"./SyntheticEvent":87,"./getActiveElement":113,"./isTextInputElement":129,"./keyOf":133,"./shallowEqual":141}],82:[function(_dereq_,module,exports){
|
14157 | /**
|
14158 | * Copyright 2013-2014, Facebook, Inc.
|
14159 | * All rights reserved.
|
14160 | *
|
14161 | * This source code is licensed under the BSD-style license found in the
|
14162 | * LICENSE file in the root directory of this source tree. An additional grant
|
14163 | * of patent rights can be found in the PATENTS file in the same directory.
|
14164 | *
|
14165 | * @providesModule ServerReactRootIndex
|
14166 | * @typechecks
|
14167 | */
|
14168 |
|
14169 | "use strict";
|
14170 |
|
14171 | /**
|
14172 | * Size of the reactRoot ID space. We generate random numbers for React root
|
14173 | * IDs and if there's a collision the events and DOM update system will
|
14174 | * get confused. In the future we need a way to generate GUIDs but for
|
14175 | * now this will work on a smaller scale.
|
14176 | */
|
14177 | var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
|
14178 |
|
14179 | var ServerReactRootIndex = {
|
14180 | createReactRootIndex: function() {
|
14181 | return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
|
14182 | }
|
14183 | };
|
14184 |
|
14185 | module.exports = ServerReactRootIndex;
|
14186 |
|
14187 | },{}],83:[function(_dereq_,module,exports){
|
14188 | /**
|
14189 | * Copyright 2013-2014, Facebook, Inc.
|
14190 | * All rights reserved.
|
14191 | *
|
14192 | * This source code is licensed under the BSD-style license found in the
|
14193 | * LICENSE file in the root directory of this source tree. An additional grant
|
14194 | * of patent rights can be found in the PATENTS file in the same directory.
|
14195 | *
|
14196 | * @providesModule SimpleEventPlugin
|
14197 | */
|
14198 |
|
14199 | "use strict";
|
14200 |
|
14201 | var EventConstants = _dereq_("./EventConstants");
|
14202 | var EventPluginUtils = _dereq_("./EventPluginUtils");
|
14203 | var EventPropagators = _dereq_("./EventPropagators");
|
14204 | var SyntheticClipboardEvent = _dereq_("./SyntheticClipboardEvent");
|
14205 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
14206 | var SyntheticFocusEvent = _dereq_("./SyntheticFocusEvent");
|
14207 | var SyntheticKeyboardEvent = _dereq_("./SyntheticKeyboardEvent");
|
14208 | var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
|
14209 | var SyntheticDragEvent = _dereq_("./SyntheticDragEvent");
|
14210 | var SyntheticTouchEvent = _dereq_("./SyntheticTouchEvent");
|
14211 | var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
|
14212 | var SyntheticWheelEvent = _dereq_("./SyntheticWheelEvent");
|
14213 |
|
14214 | var getEventCharCode = _dereq_("./getEventCharCode");
|
14215 |
|
14216 | var invariant = _dereq_("./invariant");
|
14217 | var keyOf = _dereq_("./keyOf");
|
14218 | var warning = _dereq_("./warning");
|
14219 |
|
14220 | var topLevelTypes = EventConstants.topLevelTypes;
|
14221 |
|
14222 | var eventTypes = {
|
14223 | blur: {
|
14224 | phasedRegistrationNames: {
|
14225 | bubbled: keyOf({onBlur: true}),
|
14226 | captured: keyOf({onBlurCapture: true})
|
14227 | }
|
14228 | },
|
14229 | click: {
|
14230 | phasedRegistrationNames: {
|
14231 | bubbled: keyOf({onClick: true}),
|
14232 | captured: keyOf({onClickCapture: true})
|
14233 | }
|
14234 | },
|
14235 | contextMenu: {
|
14236 | phasedRegistrationNames: {
|
14237 | bubbled: keyOf({onContextMenu: true}),
|
14238 | captured: keyOf({onContextMenuCapture: true})
|
14239 | }
|
14240 | },
|
14241 | copy: {
|
14242 | phasedRegistrationNames: {
|
14243 | bubbled: keyOf({onCopy: true}),
|
14244 | captured: keyOf({onCopyCapture: true})
|
14245 | }
|
14246 | },
|
14247 | cut: {
|
14248 | phasedRegistrationNames: {
|
14249 | bubbled: keyOf({onCut: true}),
|
14250 | captured: keyOf({onCutCapture: true})
|
14251 | }
|
14252 | },
|
14253 | doubleClick: {
|
14254 | phasedRegistrationNames: {
|
14255 | bubbled: keyOf({onDoubleClick: true}),
|
14256 | captured: keyOf({onDoubleClickCapture: true})
|
14257 | }
|
14258 | },
|
14259 | drag: {
|
14260 | phasedRegistrationNames: {
|
14261 | bubbled: keyOf({onDrag: true}),
|
14262 | captured: keyOf({onDragCapture: true})
|
14263 | }
|
14264 | },
|
14265 | dragEnd: {
|
14266 | phasedRegistrationNames: {
|
14267 | bubbled: keyOf({onDragEnd: true}),
|
14268 | captured: keyOf({onDragEndCapture: true})
|
14269 | }
|
14270 | },
|
14271 | dragEnter: {
|
14272 | phasedRegistrationNames: {
|
14273 | bubbled: keyOf({onDragEnter: true}),
|
14274 | captured: keyOf({onDragEnterCapture: true})
|
14275 | }
|
14276 | },
|
14277 | dragExit: {
|
14278 | phasedRegistrationNames: {
|
14279 | bubbled: keyOf({onDragExit: true}),
|
14280 | captured: keyOf({onDragExitCapture: true})
|
14281 | }
|
14282 | },
|
14283 | dragLeave: {
|
14284 | phasedRegistrationNames: {
|
14285 | bubbled: keyOf({onDragLeave: true}),
|
14286 | captured: keyOf({onDragLeaveCapture: true})
|
14287 | }
|
14288 | },
|
14289 | dragOver: {
|
14290 | phasedRegistrationNames: {
|
14291 | bubbled: keyOf({onDragOver: true}),
|
14292 | captured: keyOf({onDragOverCapture: true})
|
14293 | }
|
14294 | },
|
14295 | dragStart: {
|
14296 | phasedRegistrationNames: {
|
14297 | bubbled: keyOf({onDragStart: true}),
|
14298 | captured: keyOf({onDragStartCapture: true})
|
14299 | }
|
14300 | },
|
14301 | drop: {
|
14302 | phasedRegistrationNames: {
|
14303 | bubbled: keyOf({onDrop: true}),
|
14304 | captured: keyOf({onDropCapture: true})
|
14305 | }
|
14306 | },
|
14307 | focus: {
|
14308 | phasedRegistrationNames: {
|
14309 | bubbled: keyOf({onFocus: true}),
|
14310 | captured: keyOf({onFocusCapture: true})
|
14311 | }
|
14312 | },
|
14313 | input: {
|
14314 | phasedRegistrationNames: {
|
14315 | bubbled: keyOf({onInput: true}),
|
14316 | captured: keyOf({onInputCapture: true})
|
14317 | }
|
14318 | },
|
14319 | keyDown: {
|
14320 | phasedRegistrationNames: {
|
14321 | bubbled: keyOf({onKeyDown: true}),
|
14322 | captured: keyOf({onKeyDownCapture: true})
|
14323 | }
|
14324 | },
|
14325 | keyPress: {
|
14326 | phasedRegistrationNames: {
|
14327 | bubbled: keyOf({onKeyPress: true}),
|
14328 | captured: keyOf({onKeyPressCapture: true})
|
14329 | }
|
14330 | },
|
14331 | keyUp: {
|
14332 | phasedRegistrationNames: {
|
14333 | bubbled: keyOf({onKeyUp: true}),
|
14334 | captured: keyOf({onKeyUpCapture: true})
|
14335 | }
|
14336 | },
|
14337 | load: {
|
14338 | phasedRegistrationNames: {
|
14339 | bubbled: keyOf({onLoad: true}),
|
14340 | captured: keyOf({onLoadCapture: true})
|
14341 | }
|
14342 | },
|
14343 | error: {
|
14344 | phasedRegistrationNames: {
|
14345 | bubbled: keyOf({onError: true}),
|
14346 | captured: keyOf({onErrorCapture: true})
|
14347 | }
|
14348 | },
|
14349 | // Note: We do not allow listening to mouseOver events. Instead, use the
|
14350 | // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
|
14351 | mouseDown: {
|
14352 | phasedRegistrationNames: {
|
14353 | bubbled: keyOf({onMouseDown: true}),
|
14354 | captured: keyOf({onMouseDownCapture: true})
|
14355 | }
|
14356 | },
|
14357 | mouseMove: {
|
14358 | phasedRegistrationNames: {
|
14359 | bubbled: keyOf({onMouseMove: true}),
|
14360 | captured: keyOf({onMouseMoveCapture: true})
|
14361 | }
|
14362 | },
|
14363 | mouseOut: {
|
14364 | phasedRegistrationNames: {
|
14365 | bubbled: keyOf({onMouseOut: true}),
|
14366 | captured: keyOf({onMouseOutCapture: true})
|
14367 | }
|
14368 | },
|
14369 | mouseOver: {
|
14370 | phasedRegistrationNames: {
|
14371 | bubbled: keyOf({onMouseOver: true}),
|
14372 | captured: keyOf({onMouseOverCapture: true})
|
14373 | }
|
14374 | },
|
14375 | mouseUp: {
|
14376 | phasedRegistrationNames: {
|
14377 | bubbled: keyOf({onMouseUp: true}),
|
14378 | captured: keyOf({onMouseUpCapture: true})
|
14379 | }
|
14380 | },
|
14381 | paste: {
|
14382 | phasedRegistrationNames: {
|
14383 | bubbled: keyOf({onPaste: true}),
|
14384 | captured: keyOf({onPasteCapture: true})
|
14385 | }
|
14386 | },
|
14387 | reset: {
|
14388 | phasedRegistrationNames: {
|
14389 | bubbled: keyOf({onReset: true}),
|
14390 | captured: keyOf({onResetCapture: true})
|
14391 | }
|
14392 | },
|
14393 | scroll: {
|
14394 | phasedRegistrationNames: {
|
14395 | bubbled: keyOf({onScroll: true}),
|
14396 | captured: keyOf({onScrollCapture: true})
|
14397 | }
|
14398 | },
|
14399 | submit: {
|
14400 | phasedRegistrationNames: {
|
14401 | bubbled: keyOf({onSubmit: true}),
|
14402 | captured: keyOf({onSubmitCapture: true})
|
14403 | }
|
14404 | },
|
14405 | touchCancel: {
|
14406 | phasedRegistrationNames: {
|
14407 | bubbled: keyOf({onTouchCancel: true}),
|
14408 | captured: keyOf({onTouchCancelCapture: true})
|
14409 | }
|
14410 | },
|
14411 | touchEnd: {
|
14412 | phasedRegistrationNames: {
|
14413 | bubbled: keyOf({onTouchEnd: true}),
|
14414 | captured: keyOf({onTouchEndCapture: true})
|
14415 | }
|
14416 | },
|
14417 | touchMove: {
|
14418 | phasedRegistrationNames: {
|
14419 | bubbled: keyOf({onTouchMove: true}),
|
14420 | captured: keyOf({onTouchMoveCapture: true})
|
14421 | }
|
14422 | },
|
14423 | touchStart: {
|
14424 | phasedRegistrationNames: {
|
14425 | bubbled: keyOf({onTouchStart: true}),
|
14426 | captured: keyOf({onTouchStartCapture: true})
|
14427 | }
|
14428 | },
|
14429 | wheel: {
|
14430 | phasedRegistrationNames: {
|
14431 | bubbled: keyOf({onWheel: true}),
|
14432 | captured: keyOf({onWheelCapture: true})
|
14433 | }
|
14434 | }
|
14435 | };
|
14436 |
|
14437 | var topLevelEventsToDispatchConfig = {
|
14438 | topBlur: eventTypes.blur,
|
14439 | topClick: eventTypes.click,
|
14440 | topContextMenu: eventTypes.contextMenu,
|
14441 | topCopy: eventTypes.copy,
|
14442 | topCut: eventTypes.cut,
|
14443 | topDoubleClick: eventTypes.doubleClick,
|
14444 | topDrag: eventTypes.drag,
|
14445 | topDragEnd: eventTypes.dragEnd,
|
14446 | topDragEnter: eventTypes.dragEnter,
|
14447 | topDragExit: eventTypes.dragExit,
|
14448 | topDragLeave: eventTypes.dragLeave,
|
14449 | topDragOver: eventTypes.dragOver,
|
14450 | topDragStart: eventTypes.dragStart,
|
14451 | topDrop: eventTypes.drop,
|
14452 | topError: eventTypes.error,
|
14453 | topFocus: eventTypes.focus,
|
14454 | topInput: eventTypes.input,
|
14455 | topKeyDown: eventTypes.keyDown,
|
14456 | topKeyPress: eventTypes.keyPress,
|
14457 | topKeyUp: eventTypes.keyUp,
|
14458 | topLoad: eventTypes.load,
|
14459 | topMouseDown: eventTypes.mouseDown,
|
14460 | topMouseMove: eventTypes.mouseMove,
|
14461 | topMouseOut: eventTypes.mouseOut,
|
14462 | topMouseOver: eventTypes.mouseOver,
|
14463 | topMouseUp: eventTypes.mouseUp,
|
14464 | topPaste: eventTypes.paste,
|
14465 | topReset: eventTypes.reset,
|
14466 | topScroll: eventTypes.scroll,
|
14467 | topSubmit: eventTypes.submit,
|
14468 | topTouchCancel: eventTypes.touchCancel,
|
14469 | topTouchEnd: eventTypes.touchEnd,
|
14470 | topTouchMove: eventTypes.touchMove,
|
14471 | topTouchStart: eventTypes.touchStart,
|
14472 | topWheel: eventTypes.wheel
|
14473 | };
|
14474 |
|
14475 | for (var topLevelType in topLevelEventsToDispatchConfig) {
|
14476 | topLevelEventsToDispatchConfig[topLevelType].dependencies = [topLevelType];
|
14477 | }
|
14478 |
|
14479 | var SimpleEventPlugin = {
|
14480 |
|
14481 | eventTypes: eventTypes,
|
14482 |
|
14483 | /**
|
14484 | * Same as the default implementation, except cancels the event when return
|
14485 | * value is false. This behavior will be disabled in a future release.
|
14486 | *
|
14487 | * @param {object} Event to be dispatched.
|
14488 | * @param {function} Application-level callback.
|
14489 | * @param {string} domID DOM ID to pass to the callback.
|
14490 | */
|
14491 | executeDispatch: function(event, listener, domID) {
|
14492 | var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
|
14493 |
|
14494 | ("production" !== "development" ? warning(
|
14495 | typeof returnValue !== 'boolean',
|
14496 | 'Returning `false` from an event handler is deprecated and will be ' +
|
14497 | 'ignored in a future release. Instead, manually call ' +
|
14498 | 'e.stopPropagation() or e.preventDefault(), as appropriate.'
|
14499 | ) : null);
|
14500 |
|
14501 | if (returnValue === false) {
|
14502 | event.stopPropagation();
|
14503 | event.preventDefault();
|
14504 | }
|
14505 | },
|
14506 |
|
14507 | /**
|
14508 | * @param {string} topLevelType Record from `EventConstants`.
|
14509 | * @param {DOMEventTarget} topLevelTarget The listening component root node.
|
14510 | * @param {string} topLevelTargetID ID of `topLevelTarget`.
|
14511 | * @param {object} nativeEvent Native browser event.
|
14512 | * @return {*} An accumulation of synthetic events.
|
14513 | * @see {EventPluginHub.extractEvents}
|
14514 | */
|
14515 | extractEvents: function(
|
14516 | topLevelType,
|
14517 | topLevelTarget,
|
14518 | topLevelTargetID,
|
14519 | nativeEvent) {
|
14520 | var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
|
14521 | if (!dispatchConfig) {
|
14522 | return null;
|
14523 | }
|
14524 | var EventConstructor;
|
14525 | switch (topLevelType) {
|
14526 | case topLevelTypes.topInput:
|
14527 | case topLevelTypes.topLoad:
|
14528 | case topLevelTypes.topError:
|
14529 | case topLevelTypes.topReset:
|
14530 | case topLevelTypes.topSubmit:
|
14531 | // HTML Events
|
14532 | // @see http://www.w3.org/TR/html5/index.html#events-0
|
14533 | EventConstructor = SyntheticEvent;
|
14534 | break;
|
14535 | case topLevelTypes.topKeyPress:
|
14536 | // FireFox creates a keypress event for function keys too. This removes
|
14537 | // the unwanted keypress events. Enter is however both printable and
|
14538 | // non-printable. One would expect Tab to be as well (but it isn't).
|
14539 | if (getEventCharCode(nativeEvent) === 0) {
|
14540 | return null;
|
14541 | }
|
14542 | /* falls through */
|
14543 | case topLevelTypes.topKeyDown:
|
14544 | case topLevelTypes.topKeyUp:
|
14545 | EventConstructor = SyntheticKeyboardEvent;
|
14546 | break;
|
14547 | case topLevelTypes.topBlur:
|
14548 | case topLevelTypes.topFocus:
|
14549 | EventConstructor = SyntheticFocusEvent;
|
14550 | break;
|
14551 | case topLevelTypes.topClick:
|
14552 | // Firefox creates a click event on right mouse clicks. This removes the
|
14553 | // unwanted click events.
|
14554 | if (nativeEvent.button === 2) {
|
14555 | return null;
|
14556 | }
|
14557 | /* falls through */
|
14558 | case topLevelTypes.topContextMenu:
|
14559 | case topLevelTypes.topDoubleClick:
|
14560 | case topLevelTypes.topMouseDown:
|
14561 | case topLevelTypes.topMouseMove:
|
14562 | case topLevelTypes.topMouseOut:
|
14563 | case topLevelTypes.topMouseOver:
|
14564 | case topLevelTypes.topMouseUp:
|
14565 | EventConstructor = SyntheticMouseEvent;
|
14566 | break;
|
14567 | case topLevelTypes.topDrag:
|
14568 | case topLevelTypes.topDragEnd:
|
14569 | case topLevelTypes.topDragEnter:
|
14570 | case topLevelTypes.topDragExit:
|
14571 | case topLevelTypes.topDragLeave:
|
14572 | case topLevelTypes.topDragOver:
|
14573 | case topLevelTypes.topDragStart:
|
14574 | case topLevelTypes.topDrop:
|
14575 | EventConstructor = SyntheticDragEvent;
|
14576 | break;
|
14577 | case topLevelTypes.topTouchCancel:
|
14578 | case topLevelTypes.topTouchEnd:
|
14579 | case topLevelTypes.topTouchMove:
|
14580 | case topLevelTypes.topTouchStart:
|
14581 | EventConstructor = SyntheticTouchEvent;
|
14582 | break;
|
14583 | case topLevelTypes.topScroll:
|
14584 | EventConstructor = SyntheticUIEvent;
|
14585 | break;
|
14586 | case topLevelTypes.topWheel:
|
14587 | EventConstructor = SyntheticWheelEvent;
|
14588 | break;
|
14589 | case topLevelTypes.topCopy:
|
14590 | case topLevelTypes.topCut:
|
14591 | case topLevelTypes.topPaste:
|
14592 | EventConstructor = SyntheticClipboardEvent;
|
14593 | break;
|
14594 | }
|
14595 | ("production" !== "development" ? invariant(
|
14596 | EventConstructor,
|
14597 | 'SimpleEventPlugin: Unhandled event type, `%s`.',
|
14598 | topLevelType
|
14599 | ) : invariant(EventConstructor));
|
14600 | var event = EventConstructor.getPooled(
|
14601 | dispatchConfig,
|
14602 | topLevelTargetID,
|
14603 | nativeEvent
|
14604 | );
|
14605 | EventPropagators.accumulateTwoPhaseDispatches(event);
|
14606 | return event;
|
14607 | }
|
14608 |
|
14609 | };
|
14610 |
|
14611 | module.exports = SimpleEventPlugin;
|
14612 |
|
14613 | },{"./EventConstants":16,"./EventPluginUtils":20,"./EventPropagators":21,"./SyntheticClipboardEvent":84,"./SyntheticDragEvent":86,"./SyntheticEvent":87,"./SyntheticFocusEvent":88,"./SyntheticKeyboardEvent":90,"./SyntheticMouseEvent":91,"./SyntheticTouchEvent":92,"./SyntheticUIEvent":93,"./SyntheticWheelEvent":94,"./getEventCharCode":114,"./invariant":126,"./keyOf":133,"./warning":145}],84:[function(_dereq_,module,exports){
|
14614 | /**
|
14615 | * Copyright 2013-2014, Facebook, Inc.
|
14616 | * All rights reserved.
|
14617 | *
|
14618 | * This source code is licensed under the BSD-style license found in the
|
14619 | * LICENSE file in the root directory of this source tree. An additional grant
|
14620 | * of patent rights can be found in the PATENTS file in the same directory.
|
14621 | *
|
14622 | * @providesModule SyntheticClipboardEvent
|
14623 | * @typechecks static-only
|
14624 | */
|
14625 |
|
14626 | "use strict";
|
14627 |
|
14628 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
14629 |
|
14630 | /**
|
14631 | * @interface Event
|
14632 | * @see http://www.w3.org/TR/clipboard-apis/
|
14633 | */
|
14634 | var ClipboardEventInterface = {
|
14635 | clipboardData: function(event) {
|
14636 | return (
|
14637 | 'clipboardData' in event ?
|
14638 | event.clipboardData :
|
14639 | window.clipboardData
|
14640 | );
|
14641 | }
|
14642 | };
|
14643 |
|
14644 | /**
|
14645 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14646 | * @param {string} dispatchMarker Marker identifying the event target.
|
14647 | * @param {object} nativeEvent Native browser event.
|
14648 | * @extends {SyntheticUIEvent}
|
14649 | */
|
14650 | function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
14651 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
14652 | }
|
14653 |
|
14654 | SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
|
14655 |
|
14656 | module.exports = SyntheticClipboardEvent;
|
14657 |
|
14658 |
|
14659 | },{"./SyntheticEvent":87}],85:[function(_dereq_,module,exports){
|
14660 | /**
|
14661 | * Copyright 2013-2014, Facebook, Inc.
|
14662 | * All rights reserved.
|
14663 | *
|
14664 | * This source code is licensed under the BSD-style license found in the
|
14665 | * LICENSE file in the root directory of this source tree. An additional grant
|
14666 | * of patent rights can be found in the PATENTS file in the same directory.
|
14667 | *
|
14668 | * @providesModule SyntheticCompositionEvent
|
14669 | * @typechecks static-only
|
14670 | */
|
14671 |
|
14672 | "use strict";
|
14673 |
|
14674 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
14675 |
|
14676 | /**
|
14677 | * @interface Event
|
14678 | * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
|
14679 | */
|
14680 | var CompositionEventInterface = {
|
14681 | data: null
|
14682 | };
|
14683 |
|
14684 | /**
|
14685 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14686 | * @param {string} dispatchMarker Marker identifying the event target.
|
14687 | * @param {object} nativeEvent Native browser event.
|
14688 | * @extends {SyntheticUIEvent}
|
14689 | */
|
14690 | function SyntheticCompositionEvent(
|
14691 | dispatchConfig,
|
14692 | dispatchMarker,
|
14693 | nativeEvent) {
|
14694 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
14695 | }
|
14696 |
|
14697 | SyntheticEvent.augmentClass(
|
14698 | SyntheticCompositionEvent,
|
14699 | CompositionEventInterface
|
14700 | );
|
14701 |
|
14702 | module.exports = SyntheticCompositionEvent;
|
14703 |
|
14704 |
|
14705 | },{"./SyntheticEvent":87}],86:[function(_dereq_,module,exports){
|
14706 | /**
|
14707 | * Copyright 2013-2014, Facebook, Inc.
|
14708 | * All rights reserved.
|
14709 | *
|
14710 | * This source code is licensed under the BSD-style license found in the
|
14711 | * LICENSE file in the root directory of this source tree. An additional grant
|
14712 | * of patent rights can be found in the PATENTS file in the same directory.
|
14713 | *
|
14714 | * @providesModule SyntheticDragEvent
|
14715 | * @typechecks static-only
|
14716 | */
|
14717 |
|
14718 | "use strict";
|
14719 |
|
14720 | var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
|
14721 |
|
14722 | /**
|
14723 | * @interface DragEvent
|
14724 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
14725 | */
|
14726 | var DragEventInterface = {
|
14727 | dataTransfer: null
|
14728 | };
|
14729 |
|
14730 | /**
|
14731 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14732 | * @param {string} dispatchMarker Marker identifying the event target.
|
14733 | * @param {object} nativeEvent Native browser event.
|
14734 | * @extends {SyntheticUIEvent}
|
14735 | */
|
14736 | function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
14737 | SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
14738 | }
|
14739 |
|
14740 | SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
|
14741 |
|
14742 | module.exports = SyntheticDragEvent;
|
14743 |
|
14744 | },{"./SyntheticMouseEvent":91}],87:[function(_dereq_,module,exports){
|
14745 | /**
|
14746 | * Copyright 2013-2014, Facebook, Inc.
|
14747 | * All rights reserved.
|
14748 | *
|
14749 | * This source code is licensed under the BSD-style license found in the
|
14750 | * LICENSE file in the root directory of this source tree. An additional grant
|
14751 | * of patent rights can be found in the PATENTS file in the same directory.
|
14752 | *
|
14753 | * @providesModule SyntheticEvent
|
14754 | * @typechecks static-only
|
14755 | */
|
14756 |
|
14757 | "use strict";
|
14758 |
|
14759 | var PooledClass = _dereq_("./PooledClass");
|
14760 |
|
14761 | var assign = _dereq_("./Object.assign");
|
14762 | var emptyFunction = _dereq_("./emptyFunction");
|
14763 | var getEventTarget = _dereq_("./getEventTarget");
|
14764 |
|
14765 | /**
|
14766 | * @interface Event
|
14767 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
14768 | */
|
14769 | var EventInterface = {
|
14770 | type: null,
|
14771 | target: getEventTarget,
|
14772 | // currentTarget is set when dispatching; no use in copying it here
|
14773 | currentTarget: emptyFunction.thatReturnsNull,
|
14774 | eventPhase: null,
|
14775 | bubbles: null,
|
14776 | cancelable: null,
|
14777 | timeStamp: function(event) {
|
14778 | return event.timeStamp || Date.now();
|
14779 | },
|
14780 | defaultPrevented: null,
|
14781 | isTrusted: null
|
14782 | };
|
14783 |
|
14784 | /**
|
14785 | * Synthetic events are dispatched by event plugins, typically in response to a
|
14786 | * top-level event delegation handler.
|
14787 | *
|
14788 | * These systems should generally use pooling to reduce the frequency of garbage
|
14789 | * collection. The system should check `isPersistent` to determine whether the
|
14790 | * event should be released into the pool after being dispatched. Users that
|
14791 | * need a persisted event should invoke `persist`.
|
14792 | *
|
14793 | * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
|
14794 | * normalizing browser quirks. Subclasses do not necessarily have to implement a
|
14795 | * DOM interface; custom application-specific events can also subclass this.
|
14796 | *
|
14797 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14798 | * @param {string} dispatchMarker Marker identifying the event target.
|
14799 | * @param {object} nativeEvent Native browser event.
|
14800 | */
|
14801 | function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
14802 | this.dispatchConfig = dispatchConfig;
|
14803 | this.dispatchMarker = dispatchMarker;
|
14804 | this.nativeEvent = nativeEvent;
|
14805 |
|
14806 | var Interface = this.constructor.Interface;
|
14807 | for (var propName in Interface) {
|
14808 | if (!Interface.hasOwnProperty(propName)) {
|
14809 | continue;
|
14810 | }
|
14811 | var normalize = Interface[propName];
|
14812 | if (normalize) {
|
14813 | this[propName] = normalize(nativeEvent);
|
14814 | } else {
|
14815 | this[propName] = nativeEvent[propName];
|
14816 | }
|
14817 | }
|
14818 |
|
14819 | var defaultPrevented = nativeEvent.defaultPrevented != null ?
|
14820 | nativeEvent.defaultPrevented :
|
14821 | nativeEvent.returnValue === false;
|
14822 | if (defaultPrevented) {
|
14823 | this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
|
14824 | } else {
|
14825 | this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
|
14826 | }
|
14827 | this.isPropagationStopped = emptyFunction.thatReturnsFalse;
|
14828 | }
|
14829 |
|
14830 | assign(SyntheticEvent.prototype, {
|
14831 |
|
14832 | preventDefault: function() {
|
14833 | this.defaultPrevented = true;
|
14834 | var event = this.nativeEvent;
|
14835 | event.preventDefault ? event.preventDefault() : event.returnValue = false;
|
14836 | this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
|
14837 | },
|
14838 |
|
14839 | stopPropagation: function() {
|
14840 | var event = this.nativeEvent;
|
14841 | event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
|
14842 | this.isPropagationStopped = emptyFunction.thatReturnsTrue;
|
14843 | },
|
14844 |
|
14845 | /**
|
14846 | * We release all dispatched `SyntheticEvent`s after each event loop, adding
|
14847 | * them back into the pool. This allows a way to hold onto a reference that
|
14848 | * won't be added back into the pool.
|
14849 | */
|
14850 | persist: function() {
|
14851 | this.isPersistent = emptyFunction.thatReturnsTrue;
|
14852 | },
|
14853 |
|
14854 | /**
|
14855 | * Checks if this event should be released back into the pool.
|
14856 | *
|
14857 | * @return {boolean} True if this should not be released, false otherwise.
|
14858 | */
|
14859 | isPersistent: emptyFunction.thatReturnsFalse,
|
14860 |
|
14861 | /**
|
14862 | * `PooledClass` looks for `destructor` on each instance it releases.
|
14863 | */
|
14864 | destructor: function() {
|
14865 | var Interface = this.constructor.Interface;
|
14866 | for (var propName in Interface) {
|
14867 | this[propName] = null;
|
14868 | }
|
14869 | this.dispatchConfig = null;
|
14870 | this.dispatchMarker = null;
|
14871 | this.nativeEvent = null;
|
14872 | }
|
14873 |
|
14874 | });
|
14875 |
|
14876 | SyntheticEvent.Interface = EventInterface;
|
14877 |
|
14878 | /**
|
14879 | * Helper to reduce boilerplate when creating subclasses.
|
14880 | *
|
14881 | * @param {function} Class
|
14882 | * @param {?object} Interface
|
14883 | */
|
14884 | SyntheticEvent.augmentClass = function(Class, Interface) {
|
14885 | var Super = this;
|
14886 |
|
14887 | var prototype = Object.create(Super.prototype);
|
14888 | assign(prototype, Class.prototype);
|
14889 | Class.prototype = prototype;
|
14890 | Class.prototype.constructor = Class;
|
14891 |
|
14892 | Class.Interface = assign({}, Super.Interface, Interface);
|
14893 | Class.augmentClass = Super.augmentClass;
|
14894 |
|
14895 | PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
|
14896 | };
|
14897 |
|
14898 | PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
|
14899 |
|
14900 | module.exports = SyntheticEvent;
|
14901 |
|
14902 | },{"./Object.assign":27,"./PooledClass":28,"./emptyFunction":107,"./getEventTarget":117}],88:[function(_dereq_,module,exports){
|
14903 | /**
|
14904 | * Copyright 2013-2014, Facebook, Inc.
|
14905 | * All rights reserved.
|
14906 | *
|
14907 | * This source code is licensed under the BSD-style license found in the
|
14908 | * LICENSE file in the root directory of this source tree. An additional grant
|
14909 | * of patent rights can be found in the PATENTS file in the same directory.
|
14910 | *
|
14911 | * @providesModule SyntheticFocusEvent
|
14912 | * @typechecks static-only
|
14913 | */
|
14914 |
|
14915 | "use strict";
|
14916 |
|
14917 | var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
|
14918 |
|
14919 | /**
|
14920 | * @interface FocusEvent
|
14921 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
14922 | */
|
14923 | var FocusEventInterface = {
|
14924 | relatedTarget: null
|
14925 | };
|
14926 |
|
14927 | /**
|
14928 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14929 | * @param {string} dispatchMarker Marker identifying the event target.
|
14930 | * @param {object} nativeEvent Native browser event.
|
14931 | * @extends {SyntheticUIEvent}
|
14932 | */
|
14933 | function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
14934 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
14935 | }
|
14936 |
|
14937 | SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
|
14938 |
|
14939 | module.exports = SyntheticFocusEvent;
|
14940 |
|
14941 | },{"./SyntheticUIEvent":93}],89:[function(_dereq_,module,exports){
|
14942 | /**
|
14943 | * Copyright 2013 Facebook, Inc.
|
14944 | * All rights reserved.
|
14945 | *
|
14946 | * This source code is licensed under the BSD-style license found in the
|
14947 | * LICENSE file in the root directory of this source tree. An additional grant
|
14948 | * of patent rights can be found in the PATENTS file in the same directory.
|
14949 | *
|
14950 | * @providesModule SyntheticInputEvent
|
14951 | * @typechecks static-only
|
14952 | */
|
14953 |
|
14954 | "use strict";
|
14955 |
|
14956 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
14957 |
|
14958 | /**
|
14959 | * @interface Event
|
14960 | * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
|
14961 | * /#events-inputevents
|
14962 | */
|
14963 | var InputEventInterface = {
|
14964 | data: null
|
14965 | };
|
14966 |
|
14967 | /**
|
14968 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
14969 | * @param {string} dispatchMarker Marker identifying the event target.
|
14970 | * @param {object} nativeEvent Native browser event.
|
14971 | * @extends {SyntheticUIEvent}
|
14972 | */
|
14973 | function SyntheticInputEvent(
|
14974 | dispatchConfig,
|
14975 | dispatchMarker,
|
14976 | nativeEvent) {
|
14977 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
14978 | }
|
14979 |
|
14980 | SyntheticEvent.augmentClass(
|
14981 | SyntheticInputEvent,
|
14982 | InputEventInterface
|
14983 | );
|
14984 |
|
14985 | module.exports = SyntheticInputEvent;
|
14986 |
|
14987 |
|
14988 | },{"./SyntheticEvent":87}],90:[function(_dereq_,module,exports){
|
14989 | /**
|
14990 | * Copyright 2013-2014, Facebook, Inc.
|
14991 | * All rights reserved.
|
14992 | *
|
14993 | * This source code is licensed under the BSD-style license found in the
|
14994 | * LICENSE file in the root directory of this source tree. An additional grant
|
14995 | * of patent rights can be found in the PATENTS file in the same directory.
|
14996 | *
|
14997 | * @providesModule SyntheticKeyboardEvent
|
14998 | * @typechecks static-only
|
14999 | */
|
15000 |
|
15001 | "use strict";
|
15002 |
|
15003 | var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
|
15004 |
|
15005 | var getEventCharCode = _dereq_("./getEventCharCode");
|
15006 | var getEventKey = _dereq_("./getEventKey");
|
15007 | var getEventModifierState = _dereq_("./getEventModifierState");
|
15008 |
|
15009 | /**
|
15010 | * @interface KeyboardEvent
|
15011 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
15012 | */
|
15013 | var KeyboardEventInterface = {
|
15014 | key: getEventKey,
|
15015 | location: null,
|
15016 | ctrlKey: null,
|
15017 | shiftKey: null,
|
15018 | altKey: null,
|
15019 | metaKey: null,
|
15020 | repeat: null,
|
15021 | locale: null,
|
15022 | getModifierState: getEventModifierState,
|
15023 | // Legacy Interface
|
15024 | charCode: function(event) {
|
15025 | // `charCode` is the result of a KeyPress event and represents the value of
|
15026 | // the actual printable character.
|
15027 |
|
15028 | // KeyPress is deprecated, but its replacement is not yet final and not
|
15029 | // implemented in any major browser. Only KeyPress has charCode.
|
15030 | if (event.type === 'keypress') {
|
15031 | return getEventCharCode(event);
|
15032 | }
|
15033 | return 0;
|
15034 | },
|
15035 | keyCode: function(event) {
|
15036 | // `keyCode` is the result of a KeyDown/Up event and represents the value of
|
15037 | // physical keyboard key.
|
15038 |
|
15039 | // The actual meaning of the value depends on the users' keyboard layout
|
15040 | // which cannot be detected. Assuming that it is a US keyboard layout
|
15041 | // provides a surprisingly accurate mapping for US and European users.
|
15042 | // Due to this, it is left to the user to implement at this time.
|
15043 | if (event.type === 'keydown' || event.type === 'keyup') {
|
15044 | return event.keyCode;
|
15045 | }
|
15046 | return 0;
|
15047 | },
|
15048 | which: function(event) {
|
15049 | // `which` is an alias for either `keyCode` or `charCode` depending on the
|
15050 | // type of the event.
|
15051 | if (event.type === 'keypress') {
|
15052 | return getEventCharCode(event);
|
15053 | }
|
15054 | if (event.type === 'keydown' || event.type === 'keyup') {
|
15055 | return event.keyCode;
|
15056 | }
|
15057 | return 0;
|
15058 | }
|
15059 | };
|
15060 |
|
15061 | /**
|
15062 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
15063 | * @param {string} dispatchMarker Marker identifying the event target.
|
15064 | * @param {object} nativeEvent Native browser event.
|
15065 | * @extends {SyntheticUIEvent}
|
15066 | */
|
15067 | function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
15068 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
15069 | }
|
15070 |
|
15071 | SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
|
15072 |
|
15073 | module.exports = SyntheticKeyboardEvent;
|
15074 |
|
15075 | },{"./SyntheticUIEvent":93,"./getEventCharCode":114,"./getEventKey":115,"./getEventModifierState":116}],91:[function(_dereq_,module,exports){
|
15076 | /**
|
15077 | * Copyright 2013-2014, Facebook, Inc.
|
15078 | * All rights reserved.
|
15079 | *
|
15080 | * This source code is licensed under the BSD-style license found in the
|
15081 | * LICENSE file in the root directory of this source tree. An additional grant
|
15082 | * of patent rights can be found in the PATENTS file in the same directory.
|
15083 | *
|
15084 | * @providesModule SyntheticMouseEvent
|
15085 | * @typechecks static-only
|
15086 | */
|
15087 |
|
15088 | "use strict";
|
15089 |
|
15090 | var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
|
15091 | var ViewportMetrics = _dereq_("./ViewportMetrics");
|
15092 |
|
15093 | var getEventModifierState = _dereq_("./getEventModifierState");
|
15094 |
|
15095 | /**
|
15096 | * @interface MouseEvent
|
15097 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
15098 | */
|
15099 | var MouseEventInterface = {
|
15100 | screenX: null,
|
15101 | screenY: null,
|
15102 | clientX: null,
|
15103 | clientY: null,
|
15104 | ctrlKey: null,
|
15105 | shiftKey: null,
|
15106 | altKey: null,
|
15107 | metaKey: null,
|
15108 | getModifierState: getEventModifierState,
|
15109 | button: function(event) {
|
15110 | // Webkit, Firefox, IE9+
|
15111 | // which: 1 2 3
|
15112 | // button: 0 1 2 (standard)
|
15113 | var button = event.button;
|
15114 | if ('which' in event) {
|
15115 | return button;
|
15116 | }
|
15117 | // IE<9
|
15118 | // which: undefined
|
15119 | // button: 0 0 0
|
15120 | // button: 1 4 2 (onmouseup)
|
15121 | return button === 2 ? 2 : button === 4 ? 1 : 0;
|
15122 | },
|
15123 | buttons: null,
|
15124 | relatedTarget: function(event) {
|
15125 | return event.relatedTarget || (
|
15126 | event.fromElement === event.srcElement ?
|
15127 | event.toElement :
|
15128 | event.fromElement
|
15129 | );
|
15130 | },
|
15131 | // "Proprietary" Interface.
|
15132 | pageX: function(event) {
|
15133 | return 'pageX' in event ?
|
15134 | event.pageX :
|
15135 | event.clientX + ViewportMetrics.currentScrollLeft;
|
15136 | },
|
15137 | pageY: function(event) {
|
15138 | return 'pageY' in event ?
|
15139 | event.pageY :
|
15140 | event.clientY + ViewportMetrics.currentScrollTop;
|
15141 | }
|
15142 | };
|
15143 |
|
15144 | /**
|
15145 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
15146 | * @param {string} dispatchMarker Marker identifying the event target.
|
15147 | * @param {object} nativeEvent Native browser event.
|
15148 | * @extends {SyntheticUIEvent}
|
15149 | */
|
15150 | function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
15151 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
15152 | }
|
15153 |
|
15154 | SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
|
15155 |
|
15156 | module.exports = SyntheticMouseEvent;
|
15157 |
|
15158 | },{"./SyntheticUIEvent":93,"./ViewportMetrics":96,"./getEventModifierState":116}],92:[function(_dereq_,module,exports){
|
15159 | /**
|
15160 | * Copyright 2013-2014, Facebook, Inc.
|
15161 | * All rights reserved.
|
15162 | *
|
15163 | * This source code is licensed under the BSD-style license found in the
|
15164 | * LICENSE file in the root directory of this source tree. An additional grant
|
15165 | * of patent rights can be found in the PATENTS file in the same directory.
|
15166 | *
|
15167 | * @providesModule SyntheticTouchEvent
|
15168 | * @typechecks static-only
|
15169 | */
|
15170 |
|
15171 | "use strict";
|
15172 |
|
15173 | var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
|
15174 |
|
15175 | var getEventModifierState = _dereq_("./getEventModifierState");
|
15176 |
|
15177 | /**
|
15178 | * @interface TouchEvent
|
15179 | * @see http://www.w3.org/TR/touch-events/
|
15180 | */
|
15181 | var TouchEventInterface = {
|
15182 | touches: null,
|
15183 | targetTouches: null,
|
15184 | changedTouches: null,
|
15185 | altKey: null,
|
15186 | metaKey: null,
|
15187 | ctrlKey: null,
|
15188 | shiftKey: null,
|
15189 | getModifierState: getEventModifierState
|
15190 | };
|
15191 |
|
15192 | /**
|
15193 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
15194 | * @param {string} dispatchMarker Marker identifying the event target.
|
15195 | * @param {object} nativeEvent Native browser event.
|
15196 | * @extends {SyntheticUIEvent}
|
15197 | */
|
15198 | function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
15199 | SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
15200 | }
|
15201 |
|
15202 | SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
|
15203 |
|
15204 | module.exports = SyntheticTouchEvent;
|
15205 |
|
15206 | },{"./SyntheticUIEvent":93,"./getEventModifierState":116}],93:[function(_dereq_,module,exports){
|
15207 | /**
|
15208 | * Copyright 2013-2014, Facebook, Inc.
|
15209 | * All rights reserved.
|
15210 | *
|
15211 | * This source code is licensed under the BSD-style license found in the
|
15212 | * LICENSE file in the root directory of this source tree. An additional grant
|
15213 | * of patent rights can be found in the PATENTS file in the same directory.
|
15214 | *
|
15215 | * @providesModule SyntheticUIEvent
|
15216 | * @typechecks static-only
|
15217 | */
|
15218 |
|
15219 | "use strict";
|
15220 |
|
15221 | var SyntheticEvent = _dereq_("./SyntheticEvent");
|
15222 |
|
15223 | var getEventTarget = _dereq_("./getEventTarget");
|
15224 |
|
15225 | /**
|
15226 | * @interface UIEvent
|
15227 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
15228 | */
|
15229 | var UIEventInterface = {
|
15230 | view: function(event) {
|
15231 | if (event.view) {
|
15232 | return event.view;
|
15233 | }
|
15234 |
|
15235 | var target = getEventTarget(event);
|
15236 | if (target != null && target.window === target) {
|
15237 | // target is a window object
|
15238 | return target;
|
15239 | }
|
15240 |
|
15241 | var doc = target.ownerDocument;
|
15242 | // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
15243 | if (doc) {
|
15244 | return doc.defaultView || doc.parentWindow;
|
15245 | } else {
|
15246 | return window;
|
15247 | }
|
15248 | },
|
15249 | detail: function(event) {
|
15250 | return event.detail || 0;
|
15251 | }
|
15252 | };
|
15253 |
|
15254 | /**
|
15255 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
15256 | * @param {string} dispatchMarker Marker identifying the event target.
|
15257 | * @param {object} nativeEvent Native browser event.
|
15258 | * @extends {SyntheticEvent}
|
15259 | */
|
15260 | function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
15261 | SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
15262 | }
|
15263 |
|
15264 | SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
|
15265 |
|
15266 | module.exports = SyntheticUIEvent;
|
15267 |
|
15268 | },{"./SyntheticEvent":87,"./getEventTarget":117}],94:[function(_dereq_,module,exports){
|
15269 | /**
|
15270 | * Copyright 2013-2014, Facebook, Inc.
|
15271 | * All rights reserved.
|
15272 | *
|
15273 | * This source code is licensed under the BSD-style license found in the
|
15274 | * LICENSE file in the root directory of this source tree. An additional grant
|
15275 | * of patent rights can be found in the PATENTS file in the same directory.
|
15276 | *
|
15277 | * @providesModule SyntheticWheelEvent
|
15278 | * @typechecks static-only
|
15279 | */
|
15280 |
|
15281 | "use strict";
|
15282 |
|
15283 | var SyntheticMouseEvent = _dereq_("./SyntheticMouseEvent");
|
15284 |
|
15285 | /**
|
15286 | * @interface WheelEvent
|
15287 | * @see http://www.w3.org/TR/DOM-Level-3-Events/
|
15288 | */
|
15289 | var WheelEventInterface = {
|
15290 | deltaX: function(event) {
|
15291 | return (
|
15292 | 'deltaX' in event ? event.deltaX :
|
15293 | // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
|
15294 | 'wheelDeltaX' in event ? -event.wheelDeltaX : 0
|
15295 | );
|
15296 | },
|
15297 | deltaY: function(event) {
|
15298 | return (
|
15299 | 'deltaY' in event ? event.deltaY :
|
15300 | // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
|
15301 | 'wheelDeltaY' in event ? -event.wheelDeltaY :
|
15302 | // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
|
15303 | 'wheelDelta' in event ? -event.wheelDelta : 0
|
15304 | );
|
15305 | },
|
15306 | deltaZ: null,
|
15307 |
|
15308 | // Browsers without "deltaMode" is reporting in raw wheel delta where one
|
15309 | // notch on the scroll is always +/- 120, roughly equivalent to pixels.
|
15310 | // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
|
15311 | // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
|
15312 | deltaMode: null
|
15313 | };
|
15314 |
|
15315 | /**
|
15316 | * @param {object} dispatchConfig Configuration used to dispatch this event.
|
15317 | * @param {string} dispatchMarker Marker identifying the event target.
|
15318 | * @param {object} nativeEvent Native browser event.
|
15319 | * @extends {SyntheticMouseEvent}
|
15320 | */
|
15321 | function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
|
15322 | SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
|
15323 | }
|
15324 |
|
15325 | SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
|
15326 |
|
15327 | module.exports = SyntheticWheelEvent;
|
15328 |
|
15329 | },{"./SyntheticMouseEvent":91}],95:[function(_dereq_,module,exports){
|
15330 | /**
|
15331 | * Copyright 2013-2014, Facebook, Inc.
|
15332 | * All rights reserved.
|
15333 | *
|
15334 | * This source code is licensed under the BSD-style license found in the
|
15335 | * LICENSE file in the root directory of this source tree. An additional grant
|
15336 | * of patent rights can be found in the PATENTS file in the same directory.
|
15337 | *
|
15338 | * @providesModule Transaction
|
15339 | */
|
15340 |
|
15341 | "use strict";
|
15342 |
|
15343 | var invariant = _dereq_("./invariant");
|
15344 |
|
15345 | /**
|
15346 | * `Transaction` creates a black box that is able to wrap any method such that
|
15347 | * certain invariants are maintained before and after the method is invoked
|
15348 | * (Even if an exception is thrown while invoking the wrapped method). Whoever
|
15349 | * instantiates a transaction can provide enforcers of the invariants at
|
15350 | * creation time. The `Transaction` class itself will supply one additional
|
15351 | * automatic invariant for you - the invariant that any transaction instance
|
15352 | * should not be run while it is already being run. You would typically create a
|
15353 | * single instance of a `Transaction` for reuse multiple times, that potentially
|
15354 | * is used to wrap several different methods. Wrappers are extremely simple -
|
15355 | * they only require implementing two methods.
|
15356 | *
|
15357 | * <pre>
|
15358 | * wrappers (injected at creation time)
|
15359 | * + +
|
15360 | * | |
|
15361 | * +-----------------|--------|--------------+
|
15362 | * | v | |
|
15363 | * | +---------------+ | |
|
15364 | * | +--| wrapper1 |---|----+ |
|
15365 | * | | +---------------+ v | |
|
15366 | * | | +-------------+ | |
|
15367 | * | | +----| wrapper2 |--------+ |
|
15368 | * | | | +-------------+ | | |
|
15369 | * | | | | | |
|
15370 | * | v v v v | wrapper
|
15371 | * | +---+ +---+ +---------+ +---+ +---+ | invariants
|
15372 | * perform(anyMethod) | | | | | | | | | | | | maintained
|
15373 | * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
|
15374 | * | | | | | | | | | | | |
|
15375 | * | | | | | | | | | | | |
|
15376 | * | | | | | | | | | | | |
|
15377 | * | +---+ +---+ +---------+ +---+ +---+ |
|
15378 | * | initialize close |
|
15379 | * +-----------------------------------------+
|
15380 | * </pre>
|
15381 | *
|
15382 | * Use cases:
|
15383 | * - Preserving the input selection ranges before/after reconciliation.
|
15384 | * Restoring selection even in the event of an unexpected error.
|
15385 | * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
|
15386 | * while guaranteeing that afterwards, the event system is reactivated.
|
15387 | * - Flushing a queue of collected DOM mutations to the main UI thread after a
|
15388 | * reconciliation takes place in a worker thread.
|
15389 | * - Invoking any collected `componentDidUpdate` callbacks after rendering new
|
15390 | * content.
|
15391 | * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
|
15392 | * to preserve the `scrollTop` (an automatic scroll aware DOM).
|
15393 | * - (Future use case): Layout calculations before and after DOM upates.
|
15394 | *
|
15395 | * Transactional plugin API:
|
15396 | * - A module that has an `initialize` method that returns any precomputation.
|
15397 | * - and a `close` method that accepts the precomputation. `close` is invoked
|
15398 | * when the wrapped process is completed, or has failed.
|
15399 | *
|
15400 | * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
|
15401 | * that implement `initialize` and `close`.
|
15402 | * @return {Transaction} Single transaction for reuse in thread.
|
15403 | *
|
15404 | * @class Transaction
|
15405 | */
|
15406 | var Mixin = {
|
15407 | /**
|
15408 | * Sets up this instance so that it is prepared for collecting metrics. Does
|
15409 | * so such that this setup method may be used on an instance that is already
|
15410 | * initialized, in a way that does not consume additional memory upon reuse.
|
15411 | * That can be useful if you decide to make your subclass of this mixin a
|
15412 | * "PooledClass".
|
15413 | */
|
15414 | reinitializeTransaction: function() {
|
15415 | this.transactionWrappers = this.getTransactionWrappers();
|
15416 | if (!this.wrapperInitData) {
|
15417 | this.wrapperInitData = [];
|
15418 | } else {
|
15419 | this.wrapperInitData.length = 0;
|
15420 | }
|
15421 | this._isInTransaction = false;
|
15422 | },
|
15423 |
|
15424 | _isInTransaction: false,
|
15425 |
|
15426 | /**
|
15427 | * @abstract
|
15428 | * @return {Array<TransactionWrapper>} Array of transaction wrappers.
|
15429 | */
|
15430 | getTransactionWrappers: null,
|
15431 |
|
15432 | isInTransaction: function() {
|
15433 | return !!this._isInTransaction;
|
15434 | },
|
15435 |
|
15436 | /**
|
15437 | * Executes the function within a safety window. Use this for the top level
|
15438 | * methods that result in large amounts of computation/mutations that would
|
15439 | * need to be safety checked.
|
15440 | *
|
15441 | * @param {function} method Member of scope to call.
|
15442 | * @param {Object} scope Scope to invoke from.
|
15443 | * @param {Object?=} args... Arguments to pass to the method (optional).
|
15444 | * Helps prevent need to bind in many cases.
|
15445 | * @return Return value from `method`.
|
15446 | */
|
15447 | perform: function(method, scope, a, b, c, d, e, f) {
|
15448 | ("production" !== "development" ? invariant(
|
15449 | !this.isInTransaction(),
|
15450 | 'Transaction.perform(...): Cannot initialize a transaction when there ' +
|
15451 | 'is already an outstanding transaction.'
|
15452 | ) : invariant(!this.isInTransaction()));
|
15453 | var errorThrown;
|
15454 | var ret;
|
15455 | try {
|
15456 | this._isInTransaction = true;
|
15457 | // Catching errors makes debugging more difficult, so we start with
|
15458 | // errorThrown set to true before setting it to false after calling
|
15459 | // close -- if it's still set to true in the finally block, it means
|
15460 | // one of these calls threw.
|
15461 | errorThrown = true;
|
15462 | this.initializeAll(0);
|
15463 | ret = method.call(scope, a, b, c, d, e, f);
|
15464 | errorThrown = false;
|
15465 | } finally {
|
15466 | try {
|
15467 | if (errorThrown) {
|
15468 | // If `method` throws, prefer to show that stack trace over any thrown
|
15469 | // by invoking `closeAll`.
|
15470 | try {
|
15471 | this.closeAll(0);
|
15472 | } catch (err) {
|
15473 | }
|
15474 | } else {
|
15475 | // Since `method` didn't throw, we don't want to silence the exception
|
15476 | // here.
|
15477 | this.closeAll(0);
|
15478 | }
|
15479 | } finally {
|
15480 | this._isInTransaction = false;
|
15481 | }
|
15482 | }
|
15483 | return ret;
|
15484 | },
|
15485 |
|
15486 | initializeAll: function(startIndex) {
|
15487 | var transactionWrappers = this.transactionWrappers;
|
15488 | for (var i = startIndex; i < transactionWrappers.length; i++) {
|
15489 | var wrapper = transactionWrappers[i];
|
15490 | try {
|
15491 | // Catching errors makes debugging more difficult, so we start with the
|
15492 | // OBSERVED_ERROR state before overwriting it with the real return value
|
15493 | // of initialize -- if it's still set to OBSERVED_ERROR in the finally
|
15494 | // block, it means wrapper.initialize threw.
|
15495 | this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
|
15496 | this.wrapperInitData[i] = wrapper.initialize ?
|
15497 | wrapper.initialize.call(this) :
|
15498 | null;
|
15499 | } finally {
|
15500 | if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
|
15501 | // The initializer for wrapper i threw an error; initialize the
|
15502 | // remaining wrappers but silence any exceptions from them to ensure
|
15503 | // that the first error is the one to bubble up.
|
15504 | try {
|
15505 | this.initializeAll(i + 1);
|
15506 | } catch (err) {
|
15507 | }
|
15508 | }
|
15509 | }
|
15510 | }
|
15511 | },
|
15512 |
|
15513 | /**
|
15514 | * Invokes each of `this.transactionWrappers.close[i]` functions, passing into
|
15515 | * them the respective return values of `this.transactionWrappers.init[i]`
|
15516 | * (`close`rs that correspond to initializers that failed will not be
|
15517 | * invoked).
|
15518 | */
|
15519 | closeAll: function(startIndex) {
|
15520 | ("production" !== "development" ? invariant(
|
15521 | this.isInTransaction(),
|
15522 | 'Transaction.closeAll(): Cannot close transaction when none are open.'
|
15523 | ) : invariant(this.isInTransaction()));
|
15524 | var transactionWrappers = this.transactionWrappers;
|
15525 | for (var i = startIndex; i < transactionWrappers.length; i++) {
|
15526 | var wrapper = transactionWrappers[i];
|
15527 | var initData = this.wrapperInitData[i];
|
15528 | var errorThrown;
|
15529 | try {
|
15530 | // Catching errors makes debugging more difficult, so we start with
|
15531 | // errorThrown set to true before setting it to false after calling
|
15532 | // close -- if it's still set to true in the finally block, it means
|
15533 | // wrapper.close threw.
|
15534 | errorThrown = true;
|
15535 | if (initData !== Transaction.OBSERVED_ERROR) {
|
15536 | wrapper.close && wrapper.close.call(this, initData);
|
15537 | }
|
15538 | errorThrown = false;
|
15539 | } finally {
|
15540 | if (errorThrown) {
|
15541 | // The closer for wrapper i threw an error; close the remaining
|
15542 | // wrappers but silence any exceptions from them to ensure that the
|
15543 | // first error is the one to bubble up.
|
15544 | try {
|
15545 | this.closeAll(i + 1);
|
15546 | } catch (e) {
|
15547 | }
|
15548 | }
|
15549 | }
|
15550 | }
|
15551 | this.wrapperInitData.length = 0;
|
15552 | }
|
15553 | };
|
15554 |
|
15555 | var Transaction = {
|
15556 |
|
15557 | Mixin: Mixin,
|
15558 |
|
15559 | /**
|
15560 | * Token to look for to determine if an error occured.
|
15561 | */
|
15562 | OBSERVED_ERROR: {}
|
15563 |
|
15564 | };
|
15565 |
|
15566 | module.exports = Transaction;
|
15567 |
|
15568 | },{"./invariant":126}],96:[function(_dereq_,module,exports){
|
15569 | /**
|
15570 | * Copyright 2013-2014, Facebook, Inc.
|
15571 | * All rights reserved.
|
15572 | *
|
15573 | * This source code is licensed under the BSD-style license found in the
|
15574 | * LICENSE file in the root directory of this source tree. An additional grant
|
15575 | * of patent rights can be found in the PATENTS file in the same directory.
|
15576 | *
|
15577 | * @providesModule ViewportMetrics
|
15578 | */
|
15579 |
|
15580 | "use strict";
|
15581 |
|
15582 | var getUnboundedScrollPosition = _dereq_("./getUnboundedScrollPosition");
|
15583 |
|
15584 | var ViewportMetrics = {
|
15585 |
|
15586 | currentScrollLeft: 0,
|
15587 |
|
15588 | currentScrollTop: 0,
|
15589 |
|
15590 | refreshScrollValues: function() {
|
15591 | var scrollPosition = getUnboundedScrollPosition(window);
|
15592 | ViewportMetrics.currentScrollLeft = scrollPosition.x;
|
15593 | ViewportMetrics.currentScrollTop = scrollPosition.y;
|
15594 | }
|
15595 |
|
15596 | };
|
15597 |
|
15598 | module.exports = ViewportMetrics;
|
15599 |
|
15600 | },{"./getUnboundedScrollPosition":122}],97:[function(_dereq_,module,exports){
|
15601 | /**
|
15602 | * Copyright 2014, Facebook, Inc.
|
15603 | * All rights reserved.
|
15604 | *
|
15605 | * This source code is licensed under the BSD-style license found in the
|
15606 | * LICENSE file in the root directory of this source tree. An additional grant
|
15607 | * of patent rights can be found in the PATENTS file in the same directory.
|
15608 | *
|
15609 | * @providesModule accumulateInto
|
15610 | */
|
15611 |
|
15612 | "use strict";
|
15613 |
|
15614 | var invariant = _dereq_("./invariant");
|
15615 |
|
15616 | /**
|
15617 | *
|
15618 | * Accumulates items that must not be null or undefined into the first one. This
|
15619 | * is used to conserve memory by avoiding array allocations, and thus sacrifices
|
15620 | * API cleanness. Since `current` can be null before being passed in and not
|
15621 | * null after this function, make sure to assign it back to `current`:
|
15622 | *
|
15623 | * `a = accumulateInto(a, b);`
|
15624 | *
|
15625 | * This API should be sparingly used. Try `accumulate` for something cleaner.
|
15626 | *
|
15627 | * @return {*|array<*>} An accumulation of items.
|
15628 | */
|
15629 |
|
15630 | function accumulateInto(current, next) {
|
15631 | ("production" !== "development" ? invariant(
|
15632 | next != null,
|
15633 | 'accumulateInto(...): Accumulated items must not be null or undefined.'
|
15634 | ) : invariant(next != null));
|
15635 | if (current == null) {
|
15636 | return next;
|
15637 | }
|
15638 |
|
15639 | // Both are not empty. Warning: Never call x.concat(y) when you are not
|
15640 | // certain that x is an Array (x could be a string with concat method).
|
15641 | var currentIsArray = Array.isArray(current);
|
15642 | var nextIsArray = Array.isArray(next);
|
15643 |
|
15644 | if (currentIsArray && nextIsArray) {
|
15645 | current.push.apply(current, next);
|
15646 | return current;
|
15647 | }
|
15648 |
|
15649 | if (currentIsArray) {
|
15650 | current.push(next);
|
15651 | return current;
|
15652 | }
|
15653 |
|
15654 | if (nextIsArray) {
|
15655 | // A bit too dangerous to mutate `next`.
|
15656 | return [current].concat(next);
|
15657 | }
|
15658 |
|
15659 | return [current, next];
|
15660 | }
|
15661 |
|
15662 | module.exports = accumulateInto;
|
15663 |
|
15664 | },{"./invariant":126}],98:[function(_dereq_,module,exports){
|
15665 | /**
|
15666 | * Copyright 2013-2014, Facebook, Inc.
|
15667 | * All rights reserved.
|
15668 | *
|
15669 | * This source code is licensed under the BSD-style license found in the
|
15670 | * LICENSE file in the root directory of this source tree. An additional grant
|
15671 | * of patent rights can be found in the PATENTS file in the same directory.
|
15672 | *
|
15673 | * @providesModule adler32
|
15674 | */
|
15675 |
|
15676 | /* jslint bitwise:true */
|
15677 |
|
15678 | "use strict";
|
15679 |
|
15680 | var MOD = 65521;
|
15681 |
|
15682 | // This is a clean-room implementation of adler32 designed for detecting
|
15683 | // if markup is not what we expect it to be. It does not need to be
|
15684 | // cryptographically strong, only reasonably good at detecting if markup
|
15685 | // generated on the server is different than that on the client.
|
15686 | function adler32(data) {
|
15687 | var a = 1;
|
15688 | var b = 0;
|
15689 | for (var i = 0; i < data.length; i++) {
|
15690 | a = (a + data.charCodeAt(i)) % MOD;
|
15691 | b = (b + a) % MOD;
|
15692 | }
|
15693 | return a | (b << 16);
|
15694 | }
|
15695 |
|
15696 | module.exports = adler32;
|
15697 |
|
15698 | },{}],99:[function(_dereq_,module,exports){
|
15699 | /**
|
15700 | * Copyright 2013-2014, Facebook, Inc.
|
15701 | * All rights reserved.
|
15702 | *
|
15703 | * This source code is licensed under the BSD-style license found in the
|
15704 | * LICENSE file in the root directory of this source tree. An additional grant
|
15705 | * of patent rights can be found in the PATENTS file in the same directory.
|
15706 | *
|
15707 | * @providesModule camelize
|
15708 | * @typechecks
|
15709 | */
|
15710 |
|
15711 | var _hyphenPattern = /-(.)/g;
|
15712 |
|
15713 | /**
|
15714 | * Camelcases a hyphenated string, for example:
|
15715 | *
|
15716 | * > camelize('background-color')
|
15717 | * < "backgroundColor"
|
15718 | *
|
15719 | * @param {string} string
|
15720 | * @return {string}
|
15721 | */
|
15722 | function camelize(string) {
|
15723 | return string.replace(_hyphenPattern, function(_, character) {
|
15724 | return character.toUpperCase();
|
15725 | });
|
15726 | }
|
15727 |
|
15728 | module.exports = camelize;
|
15729 |
|
15730 | },{}],100:[function(_dereq_,module,exports){
|
15731 | /**
|
15732 | * Copyright 2014, Facebook, Inc.
|
15733 | * All rights reserved.
|
15734 | *
|
15735 | * This source code is licensed under the BSD-style license found in the
|
15736 | * LICENSE file in the root directory of this source tree. An additional grant
|
15737 | * of patent rights can be found in the PATENTS file in the same directory.
|
15738 | *
|
15739 | * @providesModule camelizeStyleName
|
15740 | * @typechecks
|
15741 | */
|
15742 |
|
15743 | "use strict";
|
15744 |
|
15745 | var camelize = _dereq_("./camelize");
|
15746 |
|
15747 | var msPattern = /^-ms-/;
|
15748 |
|
15749 | /**
|
15750 | * Camelcases a hyphenated CSS property name, for example:
|
15751 | *
|
15752 | * > camelizeStyleName('background-color')
|
15753 | * < "backgroundColor"
|
15754 | * > camelizeStyleName('-moz-transition')
|
15755 | * < "MozTransition"
|
15756 | * > camelizeStyleName('-ms-transition')
|
15757 | * < "msTransition"
|
15758 | *
|
15759 | * As Andi Smith suggests
|
15760 | * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
|
15761 | * is converted to lowercase `ms`.
|
15762 | *
|
15763 | * @param {string} string
|
15764 | * @return {string}
|
15765 | */
|
15766 | function camelizeStyleName(string) {
|
15767 | return camelize(string.replace(msPattern, 'ms-'));
|
15768 | }
|
15769 |
|
15770 | module.exports = camelizeStyleName;
|
15771 |
|
15772 | },{"./camelize":99}],101:[function(_dereq_,module,exports){
|
15773 | /**
|
15774 | * Copyright 2013-2014, Facebook, Inc.
|
15775 | * All rights reserved.
|
15776 | *
|
15777 | * This source code is licensed under the BSD-style license found in the
|
15778 | * LICENSE file in the root directory of this source tree. An additional grant
|
15779 | * of patent rights can be found in the PATENTS file in the same directory.
|
15780 | *
|
15781 | * @providesModule containsNode
|
15782 | * @typechecks
|
15783 | */
|
15784 |
|
15785 | var isTextNode = _dereq_("./isTextNode");
|
15786 |
|
15787 | /*jslint bitwise:true */
|
15788 |
|
15789 | /**
|
15790 | * Checks if a given DOM node contains or is another DOM node.
|
15791 | *
|
15792 | * @param {?DOMNode} outerNode Outer DOM node.
|
15793 | * @param {?DOMNode} innerNode Inner DOM node.
|
15794 | * @return {boolean} True if `outerNode` contains or is `innerNode`.
|
15795 | */
|
15796 | function containsNode(outerNode, innerNode) {
|
15797 | if (!outerNode || !innerNode) {
|
15798 | return false;
|
15799 | } else if (outerNode === innerNode) {
|
15800 | return true;
|
15801 | } else if (isTextNode(outerNode)) {
|
15802 | return false;
|
15803 | } else if (isTextNode(innerNode)) {
|
15804 | return containsNode(outerNode, innerNode.parentNode);
|
15805 | } else if (outerNode.contains) {
|
15806 | return outerNode.contains(innerNode);
|
15807 | } else if (outerNode.compareDocumentPosition) {
|
15808 | return !!(outerNode.compareDocumentPosition(innerNode) & 16);
|
15809 | } else {
|
15810 | return false;
|
15811 | }
|
15812 | }
|
15813 |
|
15814 | module.exports = containsNode;
|
15815 |
|
15816 | },{"./isTextNode":130}],102:[function(_dereq_,module,exports){
|
15817 | /**
|
15818 | * Copyright 2013-2014, Facebook, Inc.
|
15819 | * All rights reserved.
|
15820 | *
|
15821 | * This source code is licensed under the BSD-style license found in the
|
15822 | * LICENSE file in the root directory of this source tree. An additional grant
|
15823 | * of patent rights can be found in the PATENTS file in the same directory.
|
15824 | *
|
15825 | * @providesModule createArrayFrom
|
15826 | * @typechecks
|
15827 | */
|
15828 |
|
15829 | var toArray = _dereq_("./toArray");
|
15830 |
|
15831 | /**
|
15832 | * Perform a heuristic test to determine if an object is "array-like".
|
15833 | *
|
15834 | * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
|
15835 | * Joshu replied: "Mu."
|
15836 | *
|
15837 | * This function determines if its argument has "array nature": it returns
|
15838 | * true if the argument is an actual array, an `arguments' object, or an
|
15839 | * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
|
15840 | *
|
15841 | * It will return false for other array-like objects like Filelist.
|
15842 | *
|
15843 | * @param {*} obj
|
15844 | * @return {boolean}
|
15845 | */
|
15846 | function hasArrayNature(obj) {
|
15847 | return (
|
15848 | // not null/false
|
15849 | !!obj &&
|
15850 | // arrays are objects, NodeLists are functions in Safari
|
15851 | (typeof obj == 'object' || typeof obj == 'function') &&
|
15852 | // quacks like an array
|
15853 | ('length' in obj) &&
|
15854 | // not window
|
15855 | !('setInterval' in obj) &&
|
15856 | // no DOM node should be considered an array-like
|
15857 | // a 'select' element has 'length' and 'item' properties on IE8
|
15858 | (typeof obj.nodeType != 'number') &&
|
15859 | (
|
15860 | // a real array
|
15861 | (// HTMLCollection/NodeList
|
15862 | (Array.isArray(obj) ||
|
15863 | // arguments
|
15864 | ('callee' in obj) || 'item' in obj))
|
15865 | )
|
15866 | );
|
15867 | }
|
15868 |
|
15869 | /**
|
15870 | * Ensure that the argument is an array by wrapping it in an array if it is not.
|
15871 | * Creates a copy of the argument if it is already an array.
|
15872 | *
|
15873 | * This is mostly useful idiomatically:
|
15874 | *
|
15875 | * var createArrayFrom = require('createArrayFrom');
|
15876 | *
|
15877 | * function takesOneOrMoreThings(things) {
|
15878 | * things = createArrayFrom(things);
|
15879 | * ...
|
15880 | * }
|
15881 | *
|
15882 | * This allows you to treat `things' as an array, but accept scalars in the API.
|
15883 | *
|
15884 | * If you need to convert an array-like object, like `arguments`, into an array
|
15885 | * use toArray instead.
|
15886 | *
|
15887 | * @param {*} obj
|
15888 | * @return {array}
|
15889 | */
|
15890 | function createArrayFrom(obj) {
|
15891 | if (!hasArrayNature(obj)) {
|
15892 | return [obj];
|
15893 | } else if (Array.isArray(obj)) {
|
15894 | return obj.slice();
|
15895 | } else {
|
15896 | return toArray(obj);
|
15897 | }
|
15898 | }
|
15899 |
|
15900 | module.exports = createArrayFrom;
|
15901 |
|
15902 | },{"./toArray":143}],103:[function(_dereq_,module,exports){
|
15903 | /**
|
15904 | * Copyright 2013-2014, Facebook, Inc.
|
15905 | * All rights reserved.
|
15906 | *
|
15907 | * This source code is licensed under the BSD-style license found in the
|
15908 | * LICENSE file in the root directory of this source tree. An additional grant
|
15909 | * of patent rights can be found in the PATENTS file in the same directory.
|
15910 | *
|
15911 | * @providesModule createFullPageComponent
|
15912 | * @typechecks
|
15913 | */
|
15914 |
|
15915 | "use strict";
|
15916 |
|
15917 | // Defeat circular references by requiring this directly.
|
15918 | var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
|
15919 | var ReactElement = _dereq_("./ReactElement");
|
15920 |
|
15921 | var invariant = _dereq_("./invariant");
|
15922 |
|
15923 | /**
|
15924 | * Create a component that will throw an exception when unmounted.
|
15925 | *
|
15926 | * Components like <html> <head> and <body> can't be removed or added
|
15927 | * easily in a cross-browser way, however it's valuable to be able to
|
15928 | * take advantage of React's reconciliation for styling and <title>
|
15929 | * management. So we just document it and throw in dangerous cases.
|
15930 | *
|
15931 | * @param {string} tag The tag to wrap
|
15932 | * @return {function} convenience constructor of new component
|
15933 | */
|
15934 | function createFullPageComponent(tag) {
|
15935 | var elementFactory = ReactElement.createFactory(tag);
|
15936 |
|
15937 | var FullPageComponent = ReactCompositeComponent.createClass({
|
15938 | displayName: 'ReactFullPageComponent' + tag,
|
15939 |
|
15940 | componentWillUnmount: function() {
|
15941 | ("production" !== "development" ? invariant(
|
15942 | false,
|
15943 | '%s tried to unmount. Because of cross-browser quirks it is ' +
|
15944 | 'impossible to unmount some top-level components (eg <html>, <head>, ' +
|
15945 | 'and <body>) reliably and efficiently. To fix this, have a single ' +
|
15946 | 'top-level component that never unmounts render these elements.',
|
15947 | this.constructor.displayName
|
15948 | ) : invariant(false));
|
15949 | },
|
15950 |
|
15951 | render: function() {
|
15952 | return elementFactory(this.props);
|
15953 | }
|
15954 | });
|
15955 |
|
15956 | return FullPageComponent;
|
15957 | }
|
15958 |
|
15959 | module.exports = createFullPageComponent;
|
15960 |
|
15961 | },{"./ReactCompositeComponent":34,"./ReactElement":52,"./invariant":126}],104:[function(_dereq_,module,exports){
|
15962 | /**
|
15963 | * Copyright 2013-2014, Facebook, Inc.
|
15964 | * All rights reserved.
|
15965 | *
|
15966 | * This source code is licensed under the BSD-style license found in the
|
15967 | * LICENSE file in the root directory of this source tree. An additional grant
|
15968 | * of patent rights can be found in the PATENTS file in the same directory.
|
15969 | *
|
15970 | * @providesModule createNodesFromMarkup
|
15971 | * @typechecks
|
15972 | */
|
15973 |
|
15974 | /*jslint evil: true, sub: true */
|
15975 |
|
15976 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
15977 |
|
15978 | var createArrayFrom = _dereq_("./createArrayFrom");
|
15979 | var getMarkupWrap = _dereq_("./getMarkupWrap");
|
15980 | var invariant = _dereq_("./invariant");
|
15981 |
|
15982 | /**
|
15983 | * Dummy container used to render all markup.
|
15984 | */
|
15985 | var dummyNode =
|
15986 | ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
15987 |
|
15988 | /**
|
15989 | * Pattern used by `getNodeName`.
|
15990 | */
|
15991 | var nodeNamePattern = /^\s*<(\w+)/;
|
15992 |
|
15993 | /**
|
15994 | * Extracts the `nodeName` of the first element in a string of markup.
|
15995 | *
|
15996 | * @param {string} markup String of markup.
|
15997 | * @return {?string} Node name of the supplied markup.
|
15998 | */
|
15999 | function getNodeName(markup) {
|
16000 | var nodeNameMatch = markup.match(nodeNamePattern);
|
16001 | return nodeNameMatch && nodeNameMatch[1].toLowerCase();
|
16002 | }
|
16003 |
|
16004 | /**
|
16005 | * Creates an array containing the nodes rendered from the supplied markup. The
|
16006 | * optionally supplied `handleScript` function will be invoked once for each
|
16007 | * <script> element that is rendered. If no `handleScript` function is supplied,
|
16008 | * an exception is thrown if any <script> elements are rendered.
|
16009 | *
|
16010 | * @param {string} markup A string of valid HTML markup.
|
16011 | * @param {?function} handleScript Invoked once for each rendered <script>.
|
16012 | * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
|
16013 | */
|
16014 | function createNodesFromMarkup(markup, handleScript) {
|
16015 | var node = dummyNode;
|
16016 | ("production" !== "development" ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
|
16017 | var nodeName = getNodeName(markup);
|
16018 |
|
16019 | var wrap = nodeName && getMarkupWrap(nodeName);
|
16020 | if (wrap) {
|
16021 | node.innerHTML = wrap[1] + markup + wrap[2];
|
16022 |
|
16023 | var wrapDepth = wrap[0];
|
16024 | while (wrapDepth--) {
|
16025 | node = node.lastChild;
|
16026 | }
|
16027 | } else {
|
16028 | node.innerHTML = markup;
|
16029 | }
|
16030 |
|
16031 | var scripts = node.getElementsByTagName('script');
|
16032 | if (scripts.length) {
|
16033 | ("production" !== "development" ? invariant(
|
16034 | handleScript,
|
16035 | 'createNodesFromMarkup(...): Unexpected <script> element rendered.'
|
16036 | ) : invariant(handleScript));
|
16037 | createArrayFrom(scripts).forEach(handleScript);
|
16038 | }
|
16039 |
|
16040 | var nodes = createArrayFrom(node.childNodes);
|
16041 | while (node.lastChild) {
|
16042 | node.removeChild(node.lastChild);
|
16043 | }
|
16044 | return nodes;
|
16045 | }
|
16046 |
|
16047 | module.exports = createNodesFromMarkup;
|
16048 |
|
16049 | },{"./ExecutionEnvironment":22,"./createArrayFrom":102,"./getMarkupWrap":118,"./invariant":126}],105:[function(_dereq_,module,exports){
|
16050 | /**
|
16051 | * Copyright 2013-2014, Facebook, Inc.
|
16052 | * All rights reserved.
|
16053 | *
|
16054 | * This source code is licensed under the BSD-style license found in the
|
16055 | * LICENSE file in the root directory of this source tree. An additional grant
|
16056 | * of patent rights can be found in the PATENTS file in the same directory.
|
16057 | *
|
16058 | * @providesModule dangerousStyleValue
|
16059 | * @typechecks static-only
|
16060 | */
|
16061 |
|
16062 | "use strict";
|
16063 |
|
16064 | var CSSProperty = _dereq_("./CSSProperty");
|
16065 |
|
16066 | var isUnitlessNumber = CSSProperty.isUnitlessNumber;
|
16067 |
|
16068 | /**
|
16069 | * Convert a value into the proper css writable value. The style name `name`
|
16070 | * should be logical (no hyphens), as specified
|
16071 | * in `CSSProperty.isUnitlessNumber`.
|
16072 | *
|
16073 | * @param {string} name CSS property name such as `topMargin`.
|
16074 | * @param {*} value CSS property value such as `10px`.
|
16075 | * @return {string} Normalized style value with dimensions applied.
|
16076 | */
|
16077 | function dangerousStyleValue(name, value) {
|
16078 | // Note that we've removed escapeTextForBrowser() calls here since the
|
16079 | // whole string will be escaped when the attribute is injected into
|
16080 | // the markup. If you provide unsafe user data here they can inject
|
16081 | // arbitrary CSS which may be problematic (I couldn't repro this):
|
16082 | // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
|
16083 | // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
|
16084 | // This is not an XSS hole but instead a potential CSS injection issue
|
16085 | // which has lead to a greater discussion about how we're going to
|
16086 | // trust URLs moving forward. See #2115901
|
16087 |
|
16088 | var isEmpty = value == null || typeof value === 'boolean' || value === '';
|
16089 | if (isEmpty) {
|
16090 | return '';
|
16091 | }
|
16092 |
|
16093 | var isNonNumeric = isNaN(value);
|
16094 | if (isNonNumeric || value === 0 ||
|
16095 | isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
|
16096 | return '' + value; // cast to string
|
16097 | }
|
16098 |
|
16099 | if (typeof value === 'string') {
|
16100 | value = value.trim();
|
16101 | }
|
16102 | return value + 'px';
|
16103 | }
|
16104 |
|
16105 | module.exports = dangerousStyleValue;
|
16106 |
|
16107 | },{"./CSSProperty":4}],106:[function(_dereq_,module,exports){
|
16108 | /**
|
16109 | * Copyright 2013-2014, Facebook, Inc.
|
16110 | * All rights reserved.
|
16111 | *
|
16112 | * This source code is licensed under the BSD-style license found in the
|
16113 | * LICENSE file in the root directory of this source tree. An additional grant
|
16114 | * of patent rights can be found in the PATENTS file in the same directory.
|
16115 | *
|
16116 | * @providesModule deprecated
|
16117 | */
|
16118 |
|
16119 | var assign = _dereq_("./Object.assign");
|
16120 | var warning = _dereq_("./warning");
|
16121 |
|
16122 | /**
|
16123 | * This will log a single deprecation notice per function and forward the call
|
16124 | * on to the new API.
|
16125 | *
|
16126 | * @param {string} namespace The namespace of the call, eg 'React'
|
16127 | * @param {string} oldName The old function name, eg 'renderComponent'
|
16128 | * @param {string} newName The new function name, eg 'render'
|
16129 | * @param {*} ctx The context this forwarded call should run in
|
16130 | * @param {function} fn The function to forward on to
|
16131 | * @return {*} Will be the value as returned from `fn`
|
16132 | */
|
16133 | function deprecated(namespace, oldName, newName, ctx, fn) {
|
16134 | var warned = false;
|
16135 | if ("production" !== "development") {
|
16136 | var newFn = function() {
|
16137 | ("production" !== "development" ? warning(
|
16138 | warned,
|
16139 | (namespace + "." + oldName + " will be deprecated in a future version. ") +
|
16140 | ("Use " + namespace + "." + newName + " instead.")
|
16141 | ) : null);
|
16142 | warned = true;
|
16143 | return fn.apply(ctx, arguments);
|
16144 | };
|
16145 | newFn.displayName = (namespace + "_" + oldName);
|
16146 | // We need to make sure all properties of the original fn are copied over.
|
16147 | // In particular, this is needed to support PropTypes
|
16148 | return assign(newFn, fn);
|
16149 | }
|
16150 |
|
16151 | return fn;
|
16152 | }
|
16153 |
|
16154 | module.exports = deprecated;
|
16155 |
|
16156 | },{"./Object.assign":27,"./warning":145}],107:[function(_dereq_,module,exports){
|
16157 | /**
|
16158 | * Copyright 2013-2014, Facebook, Inc.
|
16159 | * All rights reserved.
|
16160 | *
|
16161 | * This source code is licensed under the BSD-style license found in the
|
16162 | * LICENSE file in the root directory of this source tree. An additional grant
|
16163 | * of patent rights can be found in the PATENTS file in the same directory.
|
16164 | *
|
16165 | * @providesModule emptyFunction
|
16166 | */
|
16167 |
|
16168 | function makeEmptyFunction(arg) {
|
16169 | return function() {
|
16170 | return arg;
|
16171 | };
|
16172 | }
|
16173 |
|
16174 | /**
|
16175 | * This function accepts and discards inputs; it has no side effects. This is
|
16176 | * primarily useful idiomatically for overridable function endpoints which
|
16177 | * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
16178 | */
|
16179 | function emptyFunction() {}
|
16180 |
|
16181 | emptyFunction.thatReturns = makeEmptyFunction;
|
16182 | emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
16183 | emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
16184 | emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
16185 | emptyFunction.thatReturnsThis = function() { return this; };
|
16186 | emptyFunction.thatReturnsArgument = function(arg) { return arg; };
|
16187 |
|
16188 | module.exports = emptyFunction;
|
16189 |
|
16190 | },{}],108:[function(_dereq_,module,exports){
|
16191 | /**
|
16192 | * Copyright 2013-2014, Facebook, Inc.
|
16193 | * All rights reserved.
|
16194 | *
|
16195 | * This source code is licensed under the BSD-style license found in the
|
16196 | * LICENSE file in the root directory of this source tree. An additional grant
|
16197 | * of patent rights can be found in the PATENTS file in the same directory.
|
16198 | *
|
16199 | * @providesModule emptyObject
|
16200 | */
|
16201 |
|
16202 | "use strict";
|
16203 |
|
16204 | var emptyObject = {};
|
16205 |
|
16206 | if ("production" !== "development") {
|
16207 | Object.freeze(emptyObject);
|
16208 | }
|
16209 |
|
16210 | module.exports = emptyObject;
|
16211 |
|
16212 | },{}],109:[function(_dereq_,module,exports){
|
16213 | /**
|
16214 | * Copyright 2013-2014, Facebook, Inc.
|
16215 | * All rights reserved.
|
16216 | *
|
16217 | * This source code is licensed under the BSD-style license found in the
|
16218 | * LICENSE file in the root directory of this source tree. An additional grant
|
16219 | * of patent rights can be found in the PATENTS file in the same directory.
|
16220 | *
|
16221 | * @providesModule escapeTextForBrowser
|
16222 | * @typechecks static-only
|
16223 | */
|
16224 |
|
16225 | "use strict";
|
16226 |
|
16227 | var ESCAPE_LOOKUP = {
|
16228 | "&": "&",
|
16229 | ">": ">",
|
16230 | "<": "<",
|
16231 | "\"": """,
|
16232 | "'": "'"
|
16233 | };
|
16234 |
|
16235 | var ESCAPE_REGEX = /[&><"']/g;
|
16236 |
|
16237 | function escaper(match) {
|
16238 | return ESCAPE_LOOKUP[match];
|
16239 | }
|
16240 |
|
16241 | /**
|
16242 | * Escapes text to prevent scripting attacks.
|
16243 | *
|
16244 | * @param {*} text Text value to escape.
|
16245 | * @return {string} An escaped string.
|
16246 | */
|
16247 | function escapeTextForBrowser(text) {
|
16248 | return ('' + text).replace(ESCAPE_REGEX, escaper);
|
16249 | }
|
16250 |
|
16251 | module.exports = escapeTextForBrowser;
|
16252 |
|
16253 | },{}],110:[function(_dereq_,module,exports){
|
16254 | /**
|
16255 | * Copyright 2013-2014, Facebook, Inc.
|
16256 | * All rights reserved.
|
16257 | *
|
16258 | * This source code is licensed under the BSD-style license found in the
|
16259 | * LICENSE file in the root directory of this source tree. An additional grant
|
16260 | * of patent rights can be found in the PATENTS file in the same directory.
|
16261 | *
|
16262 | * @providesModule flattenChildren
|
16263 | */
|
16264 |
|
16265 | "use strict";
|
16266 |
|
16267 | var ReactTextComponent = _dereq_("./ReactTextComponent");
|
16268 |
|
16269 | var traverseAllChildren = _dereq_("./traverseAllChildren");
|
16270 | var warning = _dereq_("./warning");
|
16271 |
|
16272 | /**
|
16273 | * @param {function} traverseContext Context passed through traversal.
|
16274 | * @param {?ReactComponent} child React child component.
|
16275 | * @param {!string} name String name of key path to child.
|
16276 | */
|
16277 | function flattenSingleChildIntoContext(traverseContext, child, name) {
|
16278 | // We found a component instance.
|
16279 | var result = traverseContext;
|
16280 | var keyUnique = !result.hasOwnProperty(name);
|
16281 | ("production" !== "development" ? warning(
|
16282 | keyUnique,
|
16283 | 'flattenChildren(...): Encountered two children with the same key, ' +
|
16284 | '`%s`. Child keys must be unique; when two children share a key, only ' +
|
16285 | 'the first child will be used.',
|
16286 | name
|
16287 | ) : null);
|
16288 | if (keyUnique && child != null) {
|
16289 | var type = typeof child;
|
16290 | var normalizedValue;
|
16291 |
|
16292 | if (type === 'string') {
|
16293 | normalizedValue = ReactTextComponent(child);
|
16294 | } else if (type === 'number') {
|
16295 | normalizedValue = ReactTextComponent('' + child);
|
16296 | } else {
|
16297 | normalizedValue = child;
|
16298 | }
|
16299 |
|
16300 | result[name] = normalizedValue;
|
16301 | }
|
16302 | }
|
16303 |
|
16304 | /**
|
16305 | * Flattens children that are typically specified as `props.children`. Any null
|
16306 | * children will not be included in the resulting object.
|
16307 | * @return {!object} flattened children keyed by name.
|
16308 | */
|
16309 | function flattenChildren(children) {
|
16310 | if (children == null) {
|
16311 | return children;
|
16312 | }
|
16313 | var result = {};
|
16314 | traverseAllChildren(children, flattenSingleChildIntoContext, result);
|
16315 | return result;
|
16316 | }
|
16317 |
|
16318 | module.exports = flattenChildren;
|
16319 |
|
16320 | },{"./ReactTextComponent":78,"./traverseAllChildren":144,"./warning":145}],111:[function(_dereq_,module,exports){
|
16321 | /**
|
16322 | * Copyright 2014, Facebook, Inc.
|
16323 | * All rights reserved.
|
16324 | *
|
16325 | * This source code is licensed under the BSD-style license found in the
|
16326 | * LICENSE file in the root directory of this source tree. An additional grant
|
16327 | * of patent rights can be found in the PATENTS file in the same directory.
|
16328 | *
|
16329 | * @providesModule focusNode
|
16330 | */
|
16331 |
|
16332 | "use strict";
|
16333 |
|
16334 | /**
|
16335 | * @param {DOMElement} node input/textarea to focus
|
16336 | */
|
16337 | function focusNode(node) {
|
16338 | // IE8 can throw "Can't move focus to the control because it is invisible,
|
16339 | // not enabled, or of a type that does not accept the focus." for all kinds of
|
16340 | // reasons that are too expensive and fragile to test.
|
16341 | try {
|
16342 | node.focus();
|
16343 | } catch(e) {
|
16344 | }
|
16345 | }
|
16346 |
|
16347 | module.exports = focusNode;
|
16348 |
|
16349 | },{}],112:[function(_dereq_,module,exports){
|
16350 | /**
|
16351 | * Copyright 2013-2014, Facebook, Inc.
|
16352 | * All rights reserved.
|
16353 | *
|
16354 | * This source code is licensed under the BSD-style license found in the
|
16355 | * LICENSE file in the root directory of this source tree. An additional grant
|
16356 | * of patent rights can be found in the PATENTS file in the same directory.
|
16357 | *
|
16358 | * @providesModule forEachAccumulated
|
16359 | */
|
16360 |
|
16361 | "use strict";
|
16362 |
|
16363 | /**
|
16364 | * @param {array} an "accumulation" of items which is either an Array or
|
16365 | * a single item. Useful when paired with the `accumulate` module. This is a
|
16366 | * simple utility that allows us to reason about a collection of items, but
|
16367 | * handling the case when there is exactly one item (and we do not need to
|
16368 | * allocate an array).
|
16369 | */
|
16370 | var forEachAccumulated = function(arr, cb, scope) {
|
16371 | if (Array.isArray(arr)) {
|
16372 | arr.forEach(cb, scope);
|
16373 | } else if (arr) {
|
16374 | cb.call(scope, arr);
|
16375 | }
|
16376 | };
|
16377 |
|
16378 | module.exports = forEachAccumulated;
|
16379 |
|
16380 | },{}],113:[function(_dereq_,module,exports){
|
16381 | /**
|
16382 | * Copyright 2013-2014, Facebook, Inc.
|
16383 | * All rights reserved.
|
16384 | *
|
16385 | * This source code is licensed under the BSD-style license found in the
|
16386 | * LICENSE file in the root directory of this source tree. An additional grant
|
16387 | * of patent rights can be found in the PATENTS file in the same directory.
|
16388 | *
|
16389 | * @providesModule getActiveElement
|
16390 | * @typechecks
|
16391 | */
|
16392 |
|
16393 | /**
|
16394 | * Same as document.activeElement but wraps in a try-catch block. In IE it is
|
16395 | * not safe to call document.activeElement if there is nothing focused.
|
16396 | *
|
16397 | * The activeElement will be null only if the document body is not yet defined.
|
16398 | */
|
16399 | function getActiveElement() /*?DOMElement*/ {
|
16400 | try {
|
16401 | return document.activeElement || document.body;
|
16402 | } catch (e) {
|
16403 | return document.body;
|
16404 | }
|
16405 | }
|
16406 |
|
16407 | module.exports = getActiveElement;
|
16408 |
|
16409 | },{}],114:[function(_dereq_,module,exports){
|
16410 | /**
|
16411 | * Copyright 2013-2014, Facebook, Inc.
|
16412 | * All rights reserved.
|
16413 | *
|
16414 | * This source code is licensed under the BSD-style license found in the
|
16415 | * LICENSE file in the root directory of this source tree. An additional grant
|
16416 | * of patent rights can be found in the PATENTS file in the same directory.
|
16417 | *
|
16418 | * @providesModule getEventCharCode
|
16419 | * @typechecks static-only
|
16420 | */
|
16421 |
|
16422 | "use strict";
|
16423 |
|
16424 | /**
|
16425 | * `charCode` represents the actual "character code" and is safe to use with
|
16426 | * `String.fromCharCode`. As such, only keys that correspond to printable
|
16427 | * characters produce a valid `charCode`, the only exception to this is Enter.
|
16428 | * The Tab-key is considered non-printable and does not have a `charCode`,
|
16429 | * presumably because it does not produce a tab-character in browsers.
|
16430 | *
|
16431 | * @param {object} nativeEvent Native browser event.
|
16432 | * @return {string} Normalized `charCode` property.
|
16433 | */
|
16434 | function getEventCharCode(nativeEvent) {
|
16435 | var charCode;
|
16436 | var keyCode = nativeEvent.keyCode;
|
16437 |
|
16438 | if ('charCode' in nativeEvent) {
|
16439 | charCode = nativeEvent.charCode;
|
16440 |
|
16441 | // FF does not set `charCode` for the Enter-key, check against `keyCode`.
|
16442 | if (charCode === 0 && keyCode === 13) {
|
16443 | charCode = 13;
|
16444 | }
|
16445 | } else {
|
16446 | // IE8 does not implement `charCode`, but `keyCode` has the correct value.
|
16447 | charCode = keyCode;
|
16448 | }
|
16449 |
|
16450 | // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
|
16451 | // Must not discard the (non-)printable Enter-key.
|
16452 | if (charCode >= 32 || charCode === 13) {
|
16453 | return charCode;
|
16454 | }
|
16455 |
|
16456 | return 0;
|
16457 | }
|
16458 |
|
16459 | module.exports = getEventCharCode;
|
16460 |
|
16461 | },{}],115:[function(_dereq_,module,exports){
|
16462 | /**
|
16463 | * Copyright 2013-2014, Facebook, Inc.
|
16464 | * All rights reserved.
|
16465 | *
|
16466 | * This source code is licensed under the BSD-style license found in the
|
16467 | * LICENSE file in the root directory of this source tree. An additional grant
|
16468 | * of patent rights can be found in the PATENTS file in the same directory.
|
16469 | *
|
16470 | * @providesModule getEventKey
|
16471 | * @typechecks static-only
|
16472 | */
|
16473 |
|
16474 | "use strict";
|
16475 |
|
16476 | var getEventCharCode = _dereq_("./getEventCharCode");
|
16477 |
|
16478 | /**
|
16479 | * Normalization of deprecated HTML5 `key` values
|
16480 | * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
16481 | */
|
16482 | var normalizeKey = {
|
16483 | 'Esc': 'Escape',
|
16484 | 'Spacebar': ' ',
|
16485 | 'Left': 'ArrowLeft',
|
16486 | 'Up': 'ArrowUp',
|
16487 | 'Right': 'ArrowRight',
|
16488 | 'Down': 'ArrowDown',
|
16489 | 'Del': 'Delete',
|
16490 | 'Win': 'OS',
|
16491 | 'Menu': 'ContextMenu',
|
16492 | 'Apps': 'ContextMenu',
|
16493 | 'Scroll': 'ScrollLock',
|
16494 | 'MozPrintableKey': 'Unidentified'
|
16495 | };
|
16496 |
|
16497 | /**
|
16498 | * Translation from legacy `keyCode` to HTML5 `key`
|
16499 | * Only special keys supported, all others depend on keyboard layout or browser
|
16500 | * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
|
16501 | */
|
16502 | var translateToKey = {
|
16503 | 8: 'Backspace',
|
16504 | 9: 'Tab',
|
16505 | 12: 'Clear',
|
16506 | 13: 'Enter',
|
16507 | 16: 'Shift',
|
16508 | 17: 'Control',
|
16509 | 18: 'Alt',
|
16510 | 19: 'Pause',
|
16511 | 20: 'CapsLock',
|
16512 | 27: 'Escape',
|
16513 | 32: ' ',
|
16514 | 33: 'PageUp',
|
16515 | 34: 'PageDown',
|
16516 | 35: 'End',
|
16517 | 36: 'Home',
|
16518 | 37: 'ArrowLeft',
|
16519 | 38: 'ArrowUp',
|
16520 | 39: 'ArrowRight',
|
16521 | 40: 'ArrowDown',
|
16522 | 45: 'Insert',
|
16523 | 46: 'Delete',
|
16524 | 112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
|
16525 | 118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
|
16526 | 144: 'NumLock',
|
16527 | 145: 'ScrollLock',
|
16528 | 224: 'Meta'
|
16529 | };
|
16530 |
|
16531 | /**
|
16532 | * @param {object} nativeEvent Native browser event.
|
16533 | * @return {string} Normalized `key` property.
|
16534 | */
|
16535 | function getEventKey(nativeEvent) {
|
16536 | if (nativeEvent.key) {
|
16537 | // Normalize inconsistent values reported by browsers due to
|
16538 | // implementations of a working draft specification.
|
16539 |
|
16540 | // FireFox implements `key` but returns `MozPrintableKey` for all
|
16541 | // printable characters (normalized to `Unidentified`), ignore it.
|
16542 | var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
|
16543 | if (key !== 'Unidentified') {
|
16544 | return key;
|
16545 | }
|
16546 | }
|
16547 |
|
16548 | // Browser does not implement `key`, polyfill as much of it as we can.
|
16549 | if (nativeEvent.type === 'keypress') {
|
16550 | var charCode = getEventCharCode(nativeEvent);
|
16551 |
|
16552 | // The enter-key is technically both printable and non-printable and can
|
16553 | // thus be captured by `keypress`, no other non-printable key should.
|
16554 | return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
|
16555 | }
|
16556 | if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
|
16557 | // While user keyboard layout determines the actual meaning of each
|
16558 | // `keyCode` value, almost all function keys have a universal value.
|
16559 | return translateToKey[nativeEvent.keyCode] || 'Unidentified';
|
16560 | }
|
16561 | return '';
|
16562 | }
|
16563 |
|
16564 | module.exports = getEventKey;
|
16565 |
|
16566 | },{"./getEventCharCode":114}],116:[function(_dereq_,module,exports){
|
16567 | /**
|
16568 | * Copyright 2013 Facebook, Inc.
|
16569 | * All rights reserved.
|
16570 | *
|
16571 | * This source code is licensed under the BSD-style license found in the
|
16572 | * LICENSE file in the root directory of this source tree. An additional grant
|
16573 | * of patent rights can be found in the PATENTS file in the same directory.
|
16574 | *
|
16575 | * @providesModule getEventModifierState
|
16576 | * @typechecks static-only
|
16577 | */
|
16578 |
|
16579 | "use strict";
|
16580 |
|
16581 | /**
|
16582 | * Translation from modifier key to the associated property in the event.
|
16583 | * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
|
16584 | */
|
16585 |
|
16586 | var modifierKeyToProp = {
|
16587 | 'Alt': 'altKey',
|
16588 | 'Control': 'ctrlKey',
|
16589 | 'Meta': 'metaKey',
|
16590 | 'Shift': 'shiftKey'
|
16591 | };
|
16592 |
|
16593 | // IE8 does not implement getModifierState so we simply map it to the only
|
16594 | // modifier keys exposed by the event itself, does not support Lock-keys.
|
16595 | // Currently, all major browsers except Chrome seems to support Lock-keys.
|
16596 | function modifierStateGetter(keyArg) {
|
16597 | /*jshint validthis:true */
|
16598 | var syntheticEvent = this;
|
16599 | var nativeEvent = syntheticEvent.nativeEvent;
|
16600 | if (nativeEvent.getModifierState) {
|
16601 | return nativeEvent.getModifierState(keyArg);
|
16602 | }
|
16603 | var keyProp = modifierKeyToProp[keyArg];
|
16604 | return keyProp ? !!nativeEvent[keyProp] : false;
|
16605 | }
|
16606 |
|
16607 | function getEventModifierState(nativeEvent) {
|
16608 | return modifierStateGetter;
|
16609 | }
|
16610 |
|
16611 | module.exports = getEventModifierState;
|
16612 |
|
16613 | },{}],117:[function(_dereq_,module,exports){
|
16614 | /**
|
16615 | * Copyright 2013-2014, Facebook, Inc.
|
16616 | * All rights reserved.
|
16617 | *
|
16618 | * This source code is licensed under the BSD-style license found in the
|
16619 | * LICENSE file in the root directory of this source tree. An additional grant
|
16620 | * of patent rights can be found in the PATENTS file in the same directory.
|
16621 | *
|
16622 | * @providesModule getEventTarget
|
16623 | * @typechecks static-only
|
16624 | */
|
16625 |
|
16626 | "use strict";
|
16627 |
|
16628 | /**
|
16629 | * Gets the target node from a native browser event by accounting for
|
16630 | * inconsistencies in browser DOM APIs.
|
16631 | *
|
16632 | * @param {object} nativeEvent Native browser event.
|
16633 | * @return {DOMEventTarget} Target node.
|
16634 | */
|
16635 | function getEventTarget(nativeEvent) {
|
16636 | var target = nativeEvent.target || nativeEvent.srcElement || window;
|
16637 | // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
|
16638 | // @see http://www.quirksmode.org/js/events_properties.html
|
16639 | return target.nodeType === 3 ? target.parentNode : target;
|
16640 | }
|
16641 |
|
16642 | module.exports = getEventTarget;
|
16643 |
|
16644 | },{}],118:[function(_dereq_,module,exports){
|
16645 | /**
|
16646 | * Copyright 2013-2014, Facebook, Inc.
|
16647 | * All rights reserved.
|
16648 | *
|
16649 | * This source code is licensed under the BSD-style license found in the
|
16650 | * LICENSE file in the root directory of this source tree. An additional grant
|
16651 | * of patent rights can be found in the PATENTS file in the same directory.
|
16652 | *
|
16653 | * @providesModule getMarkupWrap
|
16654 | */
|
16655 |
|
16656 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
16657 |
|
16658 | var invariant = _dereq_("./invariant");
|
16659 |
|
16660 | /**
|
16661 | * Dummy container used to detect which wraps are necessary.
|
16662 | */
|
16663 | var dummyNode =
|
16664 | ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
|
16665 |
|
16666 | /**
|
16667 | * Some browsers cannot use `innerHTML` to render certain elements standalone,
|
16668 | * so we wrap them, render the wrapped nodes, then extract the desired node.
|
16669 | *
|
16670 | * In IE8, certain elements cannot render alone, so wrap all elements ('*').
|
16671 | */
|
16672 | var shouldWrap = {
|
16673 | // Force wrapping for SVG elements because if they get created inside a <div>,
|
16674 | // they will be initialized in the wrong namespace (and will not display).
|
16675 | 'circle': true,
|
16676 | 'defs': true,
|
16677 | 'ellipse': true,
|
16678 | 'g': true,
|
16679 | 'line': true,
|
16680 | 'linearGradient': true,
|
16681 | 'path': true,
|
16682 | 'polygon': true,
|
16683 | 'polyline': true,
|
16684 | 'radialGradient': true,
|
16685 | 'rect': true,
|
16686 | 'stop': true,
|
16687 | 'text': true
|
16688 | };
|
16689 |
|
16690 | var selectWrap = [1, '<select multiple="true">', '</select>'];
|
16691 | var tableWrap = [1, '<table>', '</table>'];
|
16692 | var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
|
16693 |
|
16694 | var svgWrap = [1, '<svg>', '</svg>'];
|
16695 |
|
16696 | var markupWrap = {
|
16697 | '*': [1, '?<div>', '</div>'],
|
16698 |
|
16699 | 'area': [1, '<map>', '</map>'],
|
16700 | 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
|
16701 | 'legend': [1, '<fieldset>', '</fieldset>'],
|
16702 | 'param': [1, '<object>', '</object>'],
|
16703 | 'tr': [2, '<table><tbody>', '</tbody></table>'],
|
16704 |
|
16705 | 'optgroup': selectWrap,
|
16706 | 'option': selectWrap,
|
16707 |
|
16708 | 'caption': tableWrap,
|
16709 | 'colgroup': tableWrap,
|
16710 | 'tbody': tableWrap,
|
16711 | 'tfoot': tableWrap,
|
16712 | 'thead': tableWrap,
|
16713 |
|
16714 | 'td': trWrap,
|
16715 | 'th': trWrap,
|
16716 |
|
16717 | 'circle': svgWrap,
|
16718 | 'defs': svgWrap,
|
16719 | 'ellipse': svgWrap,
|
16720 | 'g': svgWrap,
|
16721 | 'line': svgWrap,
|
16722 | 'linearGradient': svgWrap,
|
16723 | 'path': svgWrap,
|
16724 | 'polygon': svgWrap,
|
16725 | 'polyline': svgWrap,
|
16726 | 'radialGradient': svgWrap,
|
16727 | 'rect': svgWrap,
|
16728 | 'stop': svgWrap,
|
16729 | 'text': svgWrap
|
16730 | };
|
16731 |
|
16732 | /**
|
16733 | * Gets the markup wrap configuration for the supplied `nodeName`.
|
16734 | *
|
16735 | * NOTE: This lazily detects which wraps are necessary for the current browser.
|
16736 | *
|
16737 | * @param {string} nodeName Lowercase `nodeName`.
|
16738 | * @return {?array} Markup wrap configuration, if applicable.
|
16739 | */
|
16740 | function getMarkupWrap(nodeName) {
|
16741 | ("production" !== "development" ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
|
16742 | if (!markupWrap.hasOwnProperty(nodeName)) {
|
16743 | nodeName = '*';
|
16744 | }
|
16745 | if (!shouldWrap.hasOwnProperty(nodeName)) {
|
16746 | if (nodeName === '*') {
|
16747 | dummyNode.innerHTML = '<link />';
|
16748 | } else {
|
16749 | dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
|
16750 | }
|
16751 | shouldWrap[nodeName] = !dummyNode.firstChild;
|
16752 | }
|
16753 | return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
|
16754 | }
|
16755 |
|
16756 |
|
16757 | module.exports = getMarkupWrap;
|
16758 |
|
16759 | },{"./ExecutionEnvironment":22,"./invariant":126}],119:[function(_dereq_,module,exports){
|
16760 | /**
|
16761 | * Copyright 2013-2014, Facebook, Inc.
|
16762 | * All rights reserved.
|
16763 | *
|
16764 | * This source code is licensed under the BSD-style license found in the
|
16765 | * LICENSE file in the root directory of this source tree. An additional grant
|
16766 | * of patent rights can be found in the PATENTS file in the same directory.
|
16767 | *
|
16768 | * @providesModule getNodeForCharacterOffset
|
16769 | */
|
16770 |
|
16771 | "use strict";
|
16772 |
|
16773 | /**
|
16774 | * Given any node return the first leaf node without children.
|
16775 | *
|
16776 | * @param {DOMElement|DOMTextNode} node
|
16777 | * @return {DOMElement|DOMTextNode}
|
16778 | */
|
16779 | function getLeafNode(node) {
|
16780 | while (node && node.firstChild) {
|
16781 | node = node.firstChild;
|
16782 | }
|
16783 | return node;
|
16784 | }
|
16785 |
|
16786 | /**
|
16787 | * Get the next sibling within a container. This will walk up the
|
16788 | * DOM if a node's siblings have been exhausted.
|
16789 | *
|
16790 | * @param {DOMElement|DOMTextNode} node
|
16791 | * @return {?DOMElement|DOMTextNode}
|
16792 | */
|
16793 | function getSiblingNode(node) {
|
16794 | while (node) {
|
16795 | if (node.nextSibling) {
|
16796 | return node.nextSibling;
|
16797 | }
|
16798 | node = node.parentNode;
|
16799 | }
|
16800 | }
|
16801 |
|
16802 | /**
|
16803 | * Get object describing the nodes which contain characters at offset.
|
16804 | *
|
16805 | * @param {DOMElement|DOMTextNode} root
|
16806 | * @param {number} offset
|
16807 | * @return {?object}
|
16808 | */
|
16809 | function getNodeForCharacterOffset(root, offset) {
|
16810 | var node = getLeafNode(root);
|
16811 | var nodeStart = 0;
|
16812 | var nodeEnd = 0;
|
16813 |
|
16814 | while (node) {
|
16815 | if (node.nodeType == 3) {
|
16816 | nodeEnd = nodeStart + node.textContent.length;
|
16817 |
|
16818 | if (nodeStart <= offset && nodeEnd >= offset) {
|
16819 | return {
|
16820 | node: node,
|
16821 | offset: offset - nodeStart
|
16822 | };
|
16823 | }
|
16824 |
|
16825 | nodeStart = nodeEnd;
|
16826 | }
|
16827 |
|
16828 | node = getLeafNode(getSiblingNode(node));
|
16829 | }
|
16830 | }
|
16831 |
|
16832 | module.exports = getNodeForCharacterOffset;
|
16833 |
|
16834 | },{}],120:[function(_dereq_,module,exports){
|
16835 | /**
|
16836 | * Copyright 2013-2014, Facebook, Inc.
|
16837 | * All rights reserved.
|
16838 | *
|
16839 | * This source code is licensed under the BSD-style license found in the
|
16840 | * LICENSE file in the root directory of this source tree. An additional grant
|
16841 | * of patent rights can be found in the PATENTS file in the same directory.
|
16842 | *
|
16843 | * @providesModule getReactRootElementInContainer
|
16844 | */
|
16845 |
|
16846 | "use strict";
|
16847 |
|
16848 | var DOC_NODE_TYPE = 9;
|
16849 |
|
16850 | /**
|
16851 | * @param {DOMElement|DOMDocument} container DOM element that may contain
|
16852 | * a React component
|
16853 | * @return {?*} DOM element that may have the reactRoot ID, or null.
|
16854 | */
|
16855 | function getReactRootElementInContainer(container) {
|
16856 | if (!container) {
|
16857 | return null;
|
16858 | }
|
16859 |
|
16860 | if (container.nodeType === DOC_NODE_TYPE) {
|
16861 | return container.documentElement;
|
16862 | } else {
|
16863 | return container.firstChild;
|
16864 | }
|
16865 | }
|
16866 |
|
16867 | module.exports = getReactRootElementInContainer;
|
16868 |
|
16869 | },{}],121:[function(_dereq_,module,exports){
|
16870 | /**
|
16871 | * Copyright 2013-2014, Facebook, Inc.
|
16872 | * All rights reserved.
|
16873 | *
|
16874 | * This source code is licensed under the BSD-style license found in the
|
16875 | * LICENSE file in the root directory of this source tree. An additional grant
|
16876 | * of patent rights can be found in the PATENTS file in the same directory.
|
16877 | *
|
16878 | * @providesModule getTextContentAccessor
|
16879 | */
|
16880 |
|
16881 | "use strict";
|
16882 |
|
16883 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
16884 |
|
16885 | var contentKey = null;
|
16886 |
|
16887 | /**
|
16888 | * Gets the key used to access text content on a DOM node.
|
16889 | *
|
16890 | * @return {?string} Key used to access text content.
|
16891 | * @internal
|
16892 | */
|
16893 | function getTextContentAccessor() {
|
16894 | if (!contentKey && ExecutionEnvironment.canUseDOM) {
|
16895 | // Prefer textContent to innerText because many browsers support both but
|
16896 | // SVG <text> elements don't support innerText even when <div> does.
|
16897 | contentKey = 'textContent' in document.documentElement ?
|
16898 | 'textContent' :
|
16899 | 'innerText';
|
16900 | }
|
16901 | return contentKey;
|
16902 | }
|
16903 |
|
16904 | module.exports = getTextContentAccessor;
|
16905 |
|
16906 | },{"./ExecutionEnvironment":22}],122:[function(_dereq_,module,exports){
|
16907 | /**
|
16908 | * Copyright 2013-2014, Facebook, Inc.
|
16909 | * All rights reserved.
|
16910 | *
|
16911 | * This source code is licensed under the BSD-style license found in the
|
16912 | * LICENSE file in the root directory of this source tree. An additional grant
|
16913 | * of patent rights can be found in the PATENTS file in the same directory.
|
16914 | *
|
16915 | * @providesModule getUnboundedScrollPosition
|
16916 | * @typechecks
|
16917 | */
|
16918 |
|
16919 | "use strict";
|
16920 |
|
16921 | /**
|
16922 | * Gets the scroll position of the supplied element or window.
|
16923 | *
|
16924 | * The return values are unbounded, unlike `getScrollPosition`. This means they
|
16925 | * may be negative or exceed the element boundaries (which is possible using
|
16926 | * inertial scrolling).
|
16927 | *
|
16928 | * @param {DOMWindow|DOMElement} scrollable
|
16929 | * @return {object} Map with `x` and `y` keys.
|
16930 | */
|
16931 | function getUnboundedScrollPosition(scrollable) {
|
16932 | if (scrollable === window) {
|
16933 | return {
|
16934 | x: window.pageXOffset || document.documentElement.scrollLeft,
|
16935 | y: window.pageYOffset || document.documentElement.scrollTop
|
16936 | };
|
16937 | }
|
16938 | return {
|
16939 | x: scrollable.scrollLeft,
|
16940 | y: scrollable.scrollTop
|
16941 | };
|
16942 | }
|
16943 |
|
16944 | module.exports = getUnboundedScrollPosition;
|
16945 |
|
16946 | },{}],123:[function(_dereq_,module,exports){
|
16947 | /**
|
16948 | * Copyright 2013-2014, Facebook, Inc.
|
16949 | * All rights reserved.
|
16950 | *
|
16951 | * This source code is licensed under the BSD-style license found in the
|
16952 | * LICENSE file in the root directory of this source tree. An additional grant
|
16953 | * of patent rights can be found in the PATENTS file in the same directory.
|
16954 | *
|
16955 | * @providesModule hyphenate
|
16956 | * @typechecks
|
16957 | */
|
16958 |
|
16959 | var _uppercasePattern = /([A-Z])/g;
|
16960 |
|
16961 | /**
|
16962 | * Hyphenates a camelcased string, for example:
|
16963 | *
|
16964 | * > hyphenate('backgroundColor')
|
16965 | * < "background-color"
|
16966 | *
|
16967 | * For CSS style names, use `hyphenateStyleName` instead which works properly
|
16968 | * with all vendor prefixes, including `ms`.
|
16969 | *
|
16970 | * @param {string} string
|
16971 | * @return {string}
|
16972 | */
|
16973 | function hyphenate(string) {
|
16974 | return string.replace(_uppercasePattern, '-$1').toLowerCase();
|
16975 | }
|
16976 |
|
16977 | module.exports = hyphenate;
|
16978 |
|
16979 | },{}],124:[function(_dereq_,module,exports){
|
16980 | /**
|
16981 | * Copyright 2013-2014, Facebook, Inc.
|
16982 | * All rights reserved.
|
16983 | *
|
16984 | * This source code is licensed under the BSD-style license found in the
|
16985 | * LICENSE file in the root directory of this source tree. An additional grant
|
16986 | * of patent rights can be found in the PATENTS file in the same directory.
|
16987 | *
|
16988 | * @providesModule hyphenateStyleName
|
16989 | * @typechecks
|
16990 | */
|
16991 |
|
16992 | "use strict";
|
16993 |
|
16994 | var hyphenate = _dereq_("./hyphenate");
|
16995 |
|
16996 | var msPattern = /^ms-/;
|
16997 |
|
16998 | /**
|
16999 | * Hyphenates a camelcased CSS property name, for example:
|
17000 | *
|
17001 | * > hyphenateStyleName('backgroundColor')
|
17002 | * < "background-color"
|
17003 | * > hyphenateStyleName('MozTransition')
|
17004 | * < "-moz-transition"
|
17005 | * > hyphenateStyleName('msTransition')
|
17006 | * < "-ms-transition"
|
17007 | *
|
17008 | * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
17009 | * is converted to `-ms-`.
|
17010 | *
|
17011 | * @param {string} string
|
17012 | * @return {string}
|
17013 | */
|
17014 | function hyphenateStyleName(string) {
|
17015 | return hyphenate(string).replace(msPattern, '-ms-');
|
17016 | }
|
17017 |
|
17018 | module.exports = hyphenateStyleName;
|
17019 |
|
17020 | },{"./hyphenate":123}],125:[function(_dereq_,module,exports){
|
17021 | /**
|
17022 | * Copyright 2013-2014, Facebook, Inc.
|
17023 | * All rights reserved.
|
17024 | *
|
17025 | * This source code is licensed under the BSD-style license found in the
|
17026 | * LICENSE file in the root directory of this source tree. An additional grant
|
17027 | * of patent rights can be found in the PATENTS file in the same directory.
|
17028 | *
|
17029 | * @providesModule instantiateReactComponent
|
17030 | * @typechecks static-only
|
17031 | */
|
17032 |
|
17033 | "use strict";
|
17034 |
|
17035 | var warning = _dereq_("./warning");
|
17036 |
|
17037 | var ReactElement = _dereq_("./ReactElement");
|
17038 | var ReactLegacyElement = _dereq_("./ReactLegacyElement");
|
17039 | var ReactNativeComponent = _dereq_("./ReactNativeComponent");
|
17040 | var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
|
17041 |
|
17042 | /**
|
17043 | * Given an `element` create an instance that will actually be mounted.
|
17044 | *
|
17045 | * @param {object} element
|
17046 | * @param {*} parentCompositeType The composite type that resolved this.
|
17047 | * @return {object} A new instance of the element's constructor.
|
17048 | * @protected
|
17049 | */
|
17050 | function instantiateReactComponent(element, parentCompositeType) {
|
17051 | var instance;
|
17052 |
|
17053 | if ("production" !== "development") {
|
17054 | ("production" !== "development" ? warning(
|
17055 | element && (typeof element.type === 'function' ||
|
17056 | typeof element.type === 'string'),
|
17057 | 'Only functions or strings can be mounted as React components.'
|
17058 | ) : null);
|
17059 |
|
17060 | // Resolve mock instances
|
17061 | if (element.type._mockedReactClassConstructor) {
|
17062 | // If this is a mocked class, we treat the legacy factory as if it was the
|
17063 | // class constructor for future proofing unit tests. Because this might
|
17064 | // be mocked as a legacy factory, we ignore any warnings triggerd by
|
17065 | // this temporary hack.
|
17066 | ReactLegacyElement._isLegacyCallWarningEnabled = false;
|
17067 | try {
|
17068 | instance = new element.type._mockedReactClassConstructor(
|
17069 | element.props
|
17070 | );
|
17071 | } finally {
|
17072 | ReactLegacyElement._isLegacyCallWarningEnabled = true;
|
17073 | }
|
17074 |
|
17075 | // If the mock implementation was a legacy factory, then it returns a
|
17076 | // element. We need to turn this into a real component instance.
|
17077 | if (ReactElement.isValidElement(instance)) {
|
17078 | instance = new instance.type(instance.props);
|
17079 | }
|
17080 |
|
17081 | var render = instance.render;
|
17082 | if (!render) {
|
17083 | // For auto-mocked factories, the prototype isn't shimmed and therefore
|
17084 | // there is no render function on the instance. We replace the whole
|
17085 | // component with an empty component instance instead.
|
17086 | element = ReactEmptyComponent.getEmptyComponent();
|
17087 | } else {
|
17088 | if (render._isMockFunction && !render._getMockImplementation()) {
|
17089 | // Auto-mocked components may have a prototype with a mocked render
|
17090 | // function. For those, we'll need to mock the result of the render
|
17091 | // since we consider undefined to be invalid results from render.
|
17092 | render.mockImplementation(
|
17093 | ReactEmptyComponent.getEmptyComponent
|
17094 | );
|
17095 | }
|
17096 | instance.construct(element);
|
17097 | return instance;
|
17098 | }
|
17099 | }
|
17100 | }
|
17101 |
|
17102 | // Special case string values
|
17103 | if (typeof element.type === 'string') {
|
17104 | instance = ReactNativeComponent.createInstanceForTag(
|
17105 | element.type,
|
17106 | element.props,
|
17107 | parentCompositeType
|
17108 | );
|
17109 | } else {
|
17110 | // Normal case for non-mocks and non-strings
|
17111 | instance = new element.type(element.props);
|
17112 | }
|
17113 |
|
17114 | if ("production" !== "development") {
|
17115 | ("production" !== "development" ? warning(
|
17116 | typeof instance.construct === 'function' &&
|
17117 | typeof instance.mountComponent === 'function' &&
|
17118 | typeof instance.receiveComponent === 'function',
|
17119 | 'Only React Components can be mounted.'
|
17120 | ) : null);
|
17121 | }
|
17122 |
|
17123 | // This actually sets up the internal instance. This will become decoupled
|
17124 | // from the public instance in a future diff.
|
17125 | instance.construct(element);
|
17126 |
|
17127 | return instance;
|
17128 | }
|
17129 |
|
17130 | module.exports = instantiateReactComponent;
|
17131 |
|
17132 | },{"./ReactElement":52,"./ReactEmptyComponent":54,"./ReactLegacyElement":61,"./ReactNativeComponent":66,"./warning":145}],126:[function(_dereq_,module,exports){
|
17133 | /**
|
17134 | * Copyright 2013-2014, Facebook, Inc.
|
17135 | * All rights reserved.
|
17136 | *
|
17137 | * This source code is licensed under the BSD-style license found in the
|
17138 | * LICENSE file in the root directory of this source tree. An additional grant
|
17139 | * of patent rights can be found in the PATENTS file in the same directory.
|
17140 | *
|
17141 | * @providesModule invariant
|
17142 | */
|
17143 |
|
17144 | "use strict";
|
17145 |
|
17146 | /**
|
17147 | * Use invariant() to assert state which your program assumes to be true.
|
17148 | *
|
17149 | * Provide sprintf-style format (only %s is supported) and arguments
|
17150 | * to provide information about what broke and what you were
|
17151 | * expecting.
|
17152 | *
|
17153 | * The invariant message will be stripped in production, but the invariant
|
17154 | * will remain to ensure logic does not differ in production.
|
17155 | */
|
17156 |
|
17157 | var invariant = function(condition, format, a, b, c, d, e, f) {
|
17158 | if ("production" !== "development") {
|
17159 | if (format === undefined) {
|
17160 | throw new Error('invariant requires an error message argument');
|
17161 | }
|
17162 | }
|
17163 |
|
17164 | if (!condition) {
|
17165 | var error;
|
17166 | if (format === undefined) {
|
17167 | error = new Error(
|
17168 | 'Minified exception occurred; use the non-minified dev environment ' +
|
17169 | 'for the full error message and additional helpful warnings.'
|
17170 | );
|
17171 | } else {
|
17172 | var args = [a, b, c, d, e, f];
|
17173 | var argIndex = 0;
|
17174 | error = new Error(
|
17175 | 'Invariant Violation: ' +
|
17176 | format.replace(/%s/g, function() { return args[argIndex++]; })
|
17177 | );
|
17178 | }
|
17179 |
|
17180 | error.framesToPop = 1; // we don't care about invariant's own frame
|
17181 | throw error;
|
17182 | }
|
17183 | };
|
17184 |
|
17185 | module.exports = invariant;
|
17186 |
|
17187 | },{}],127:[function(_dereq_,module,exports){
|
17188 | /**
|
17189 | * Copyright 2013-2014, Facebook, Inc.
|
17190 | * All rights reserved.
|
17191 | *
|
17192 | * This source code is licensed under the BSD-style license found in the
|
17193 | * LICENSE file in the root directory of this source tree. An additional grant
|
17194 | * of patent rights can be found in the PATENTS file in the same directory.
|
17195 | *
|
17196 | * @providesModule isEventSupported
|
17197 | */
|
17198 |
|
17199 | "use strict";
|
17200 |
|
17201 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
17202 |
|
17203 | var useHasFeature;
|
17204 | if (ExecutionEnvironment.canUseDOM) {
|
17205 | useHasFeature =
|
17206 | document.implementation &&
|
17207 | document.implementation.hasFeature &&
|
17208 | // always returns true in newer browsers as per the standard.
|
17209 | // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
17210 | document.implementation.hasFeature('', '') !== true;
|
17211 | }
|
17212 |
|
17213 | /**
|
17214 | * Checks if an event is supported in the current execution environment.
|
17215 | *
|
17216 | * NOTE: This will not work correctly for non-generic events such as `change`,
|
17217 | * `reset`, `load`, `error`, and `select`.
|
17218 | *
|
17219 | * Borrows from Modernizr.
|
17220 | *
|
17221 | * @param {string} eventNameSuffix Event name, e.g. "click".
|
17222 | * @param {?boolean} capture Check if the capture phase is supported.
|
17223 | * @return {boolean} True if the event is supported.
|
17224 | * @internal
|
17225 | * @license Modernizr 3.0.0pre (Custom Build) | MIT
|
17226 | */
|
17227 | function isEventSupported(eventNameSuffix, capture) {
|
17228 | if (!ExecutionEnvironment.canUseDOM ||
|
17229 | capture && !('addEventListener' in document)) {
|
17230 | return false;
|
17231 | }
|
17232 |
|
17233 | var eventName = 'on' + eventNameSuffix;
|
17234 | var isSupported = eventName in document;
|
17235 |
|
17236 | if (!isSupported) {
|
17237 | var element = document.createElement('div');
|
17238 | element.setAttribute(eventName, 'return;');
|
17239 | isSupported = typeof element[eventName] === 'function';
|
17240 | }
|
17241 |
|
17242 | if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
|
17243 | // This is the only way to test support for the `wheel` event in IE9+.
|
17244 | isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
17245 | }
|
17246 |
|
17247 | return isSupported;
|
17248 | }
|
17249 |
|
17250 | module.exports = isEventSupported;
|
17251 |
|
17252 | },{"./ExecutionEnvironment":22}],128:[function(_dereq_,module,exports){
|
17253 | /**
|
17254 | * Copyright 2013-2014, Facebook, Inc.
|
17255 | * All rights reserved.
|
17256 | *
|
17257 | * This source code is licensed under the BSD-style license found in the
|
17258 | * LICENSE file in the root directory of this source tree. An additional grant
|
17259 | * of patent rights can be found in the PATENTS file in the same directory.
|
17260 | *
|
17261 | * @providesModule isNode
|
17262 | * @typechecks
|
17263 | */
|
17264 |
|
17265 | /**
|
17266 | * @param {*} object The object to check.
|
17267 | * @return {boolean} Whether or not the object is a DOM node.
|
17268 | */
|
17269 | function isNode(object) {
|
17270 | return !!(object && (
|
17271 | typeof Node === 'function' ? object instanceof Node :
|
17272 | typeof object === 'object' &&
|
17273 | typeof object.nodeType === 'number' &&
|
17274 | typeof object.nodeName === 'string'
|
17275 | ));
|
17276 | }
|
17277 |
|
17278 | module.exports = isNode;
|
17279 |
|
17280 | },{}],129:[function(_dereq_,module,exports){
|
17281 | /**
|
17282 | * Copyright 2013-2014, Facebook, Inc.
|
17283 | * All rights reserved.
|
17284 | *
|
17285 | * This source code is licensed under the BSD-style license found in the
|
17286 | * LICENSE file in the root directory of this source tree. An additional grant
|
17287 | * of patent rights can be found in the PATENTS file in the same directory.
|
17288 | *
|
17289 | * @providesModule isTextInputElement
|
17290 | */
|
17291 |
|
17292 | "use strict";
|
17293 |
|
17294 | /**
|
17295 | * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
|
17296 | */
|
17297 | var supportedInputTypes = {
|
17298 | 'color': true,
|
17299 | 'date': true,
|
17300 | 'datetime': true,
|
17301 | 'datetime-local': true,
|
17302 | 'email': true,
|
17303 | 'month': true,
|
17304 | 'number': true,
|
17305 | 'password': true,
|
17306 | 'range': true,
|
17307 | 'search': true,
|
17308 | 'tel': true,
|
17309 | 'text': true,
|
17310 | 'time': true,
|
17311 | 'url': true,
|
17312 | 'week': true
|
17313 | };
|
17314 |
|
17315 | function isTextInputElement(elem) {
|
17316 | return elem && (
|
17317 | (elem.nodeName === 'INPUT' && supportedInputTypes[elem.type]) ||
|
17318 | elem.nodeName === 'TEXTAREA'
|
17319 | );
|
17320 | }
|
17321 |
|
17322 | module.exports = isTextInputElement;
|
17323 |
|
17324 | },{}],130:[function(_dereq_,module,exports){
|
17325 | /**
|
17326 | * Copyright 2013-2014, Facebook, Inc.
|
17327 | * All rights reserved.
|
17328 | *
|
17329 | * This source code is licensed under the BSD-style license found in the
|
17330 | * LICENSE file in the root directory of this source tree. An additional grant
|
17331 | * of patent rights can be found in the PATENTS file in the same directory.
|
17332 | *
|
17333 | * @providesModule isTextNode
|
17334 | * @typechecks
|
17335 | */
|
17336 |
|
17337 | var isNode = _dereq_("./isNode");
|
17338 |
|
17339 | /**
|
17340 | * @param {*} object The object to check.
|
17341 | * @return {boolean} Whether or not the object is a DOM text node.
|
17342 | */
|
17343 | function isTextNode(object) {
|
17344 | return isNode(object) && object.nodeType == 3;
|
17345 | }
|
17346 |
|
17347 | module.exports = isTextNode;
|
17348 |
|
17349 | },{"./isNode":128}],131:[function(_dereq_,module,exports){
|
17350 | /**
|
17351 | * Copyright 2013-2014, Facebook, Inc.
|
17352 | * All rights reserved.
|
17353 | *
|
17354 | * This source code is licensed under the BSD-style license found in the
|
17355 | * LICENSE file in the root directory of this source tree. An additional grant
|
17356 | * of patent rights can be found in the PATENTS file in the same directory.
|
17357 | *
|
17358 | * @providesModule joinClasses
|
17359 | * @typechecks static-only
|
17360 | */
|
17361 |
|
17362 | "use strict";
|
17363 |
|
17364 | /**
|
17365 | * Combines multiple className strings into one.
|
17366 | * http://jsperf.com/joinclasses-args-vs-array
|
17367 | *
|
17368 | * @param {...?string} classes
|
17369 | * @return {string}
|
17370 | */
|
17371 | function joinClasses(className/*, ... */) {
|
17372 | if (!className) {
|
17373 | className = '';
|
17374 | }
|
17375 | var nextClass;
|
17376 | var argLength = arguments.length;
|
17377 | if (argLength > 1) {
|
17378 | for (var ii = 1; ii < argLength; ii++) {
|
17379 | nextClass = arguments[ii];
|
17380 | if (nextClass) {
|
17381 | className = (className ? className + ' ' : '') + nextClass;
|
17382 | }
|
17383 | }
|
17384 | }
|
17385 | return className;
|
17386 | }
|
17387 |
|
17388 | module.exports = joinClasses;
|
17389 |
|
17390 | },{}],132:[function(_dereq_,module,exports){
|
17391 | /**
|
17392 | * Copyright 2013-2014, Facebook, Inc.
|
17393 | * All rights reserved.
|
17394 | *
|
17395 | * This source code is licensed under the BSD-style license found in the
|
17396 | * LICENSE file in the root directory of this source tree. An additional grant
|
17397 | * of patent rights can be found in the PATENTS file in the same directory.
|
17398 | *
|
17399 | * @providesModule keyMirror
|
17400 | * @typechecks static-only
|
17401 | */
|
17402 |
|
17403 | "use strict";
|
17404 |
|
17405 | var invariant = _dereq_("./invariant");
|
17406 |
|
17407 | /**
|
17408 | * Constructs an enumeration with keys equal to their value.
|
17409 | *
|
17410 | * For example:
|
17411 | *
|
17412 | * var COLORS = keyMirror({blue: null, red: null});
|
17413 | * var myColor = COLORS.blue;
|
17414 | * var isColorValid = !!COLORS[myColor];
|
17415 | *
|
17416 | * The last line could not be performed if the values of the generated enum were
|
17417 | * not equal to their keys.
|
17418 | *
|
17419 | * Input: {key1: val1, key2: val2}
|
17420 | * Output: {key1: key1, key2: key2}
|
17421 | *
|
17422 | * @param {object} obj
|
17423 | * @return {object}
|
17424 | */
|
17425 | var keyMirror = function(obj) {
|
17426 | var ret = {};
|
17427 | var key;
|
17428 | ("production" !== "development" ? invariant(
|
17429 | obj instanceof Object && !Array.isArray(obj),
|
17430 | 'keyMirror(...): Argument must be an object.'
|
17431 | ) : invariant(obj instanceof Object && !Array.isArray(obj)));
|
17432 | for (key in obj) {
|
17433 | if (!obj.hasOwnProperty(key)) {
|
17434 | continue;
|
17435 | }
|
17436 | ret[key] = key;
|
17437 | }
|
17438 | return ret;
|
17439 | };
|
17440 |
|
17441 | module.exports = keyMirror;
|
17442 |
|
17443 | },{"./invariant":126}],133:[function(_dereq_,module,exports){
|
17444 | /**
|
17445 | * Copyright 2013-2014, Facebook, Inc.
|
17446 | * All rights reserved.
|
17447 | *
|
17448 | * This source code is licensed under the BSD-style license found in the
|
17449 | * LICENSE file in the root directory of this source tree. An additional grant
|
17450 | * of patent rights can be found in the PATENTS file in the same directory.
|
17451 | *
|
17452 | * @providesModule keyOf
|
17453 | */
|
17454 |
|
17455 | /**
|
17456 | * Allows extraction of a minified key. Let's the build system minify keys
|
17457 | * without loosing the ability to dynamically use key strings as values
|
17458 | * themselves. Pass in an object with a single key/val pair and it will return
|
17459 | * you the string key of that single record. Suppose you want to grab the
|
17460 | * value for a key 'className' inside of an object. Key/val minification may
|
17461 | * have aliased that key to be 'xa12'. keyOf({className: null}) will return
|
17462 | * 'xa12' in that case. Resolve keys you want to use once at startup time, then
|
17463 | * reuse those resolutions.
|
17464 | */
|
17465 | var keyOf = function(oneKeyObj) {
|
17466 | var key;
|
17467 | for (key in oneKeyObj) {
|
17468 | if (!oneKeyObj.hasOwnProperty(key)) {
|
17469 | continue;
|
17470 | }
|
17471 | return key;
|
17472 | }
|
17473 | return null;
|
17474 | };
|
17475 |
|
17476 |
|
17477 | module.exports = keyOf;
|
17478 |
|
17479 | },{}],134:[function(_dereq_,module,exports){
|
17480 | /**
|
17481 | * Copyright 2013-2014, Facebook, Inc.
|
17482 | * All rights reserved.
|
17483 | *
|
17484 | * This source code is licensed under the BSD-style license found in the
|
17485 | * LICENSE file in the root directory of this source tree. An additional grant
|
17486 | * of patent rights can be found in the PATENTS file in the same directory.
|
17487 | *
|
17488 | * @providesModule mapObject
|
17489 | */
|
17490 |
|
17491 | 'use strict';
|
17492 |
|
17493 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
17494 |
|
17495 | /**
|
17496 | * Executes the provided `callback` once for each enumerable own property in the
|
17497 | * object and constructs a new object from the results. The `callback` is
|
17498 | * invoked with three arguments:
|
17499 | *
|
17500 | * - the property value
|
17501 | * - the property name
|
17502 | * - the object being traversed
|
17503 | *
|
17504 | * Properties that are added after the call to `mapObject` will not be visited
|
17505 | * by `callback`. If the values of existing properties are changed, the value
|
17506 | * passed to `callback` will be the value at the time `mapObject` visits them.
|
17507 | * Properties that are deleted before being visited are not visited.
|
17508 | *
|
17509 | * @grep function objectMap()
|
17510 | * @grep function objMap()
|
17511 | *
|
17512 | * @param {?object} object
|
17513 | * @param {function} callback
|
17514 | * @param {*} context
|
17515 | * @return {?object}
|
17516 | */
|
17517 | function mapObject(object, callback, context) {
|
17518 | if (!object) {
|
17519 | return null;
|
17520 | }
|
17521 | var result = {};
|
17522 | for (var name in object) {
|
17523 | if (hasOwnProperty.call(object, name)) {
|
17524 | result[name] = callback.call(context, object[name], name, object);
|
17525 | }
|
17526 | }
|
17527 | return result;
|
17528 | }
|
17529 |
|
17530 | module.exports = mapObject;
|
17531 |
|
17532 | },{}],135:[function(_dereq_,module,exports){
|
17533 | /**
|
17534 | * Copyright 2013-2014, Facebook, Inc.
|
17535 | * All rights reserved.
|
17536 | *
|
17537 | * This source code is licensed under the BSD-style license found in the
|
17538 | * LICENSE file in the root directory of this source tree. An additional grant
|
17539 | * of patent rights can be found in the PATENTS file in the same directory.
|
17540 | *
|
17541 | * @providesModule memoizeStringOnly
|
17542 | * @typechecks static-only
|
17543 | */
|
17544 |
|
17545 | "use strict";
|
17546 |
|
17547 | /**
|
17548 | * Memoizes the return value of a function that accepts one string argument.
|
17549 | *
|
17550 | * @param {function} callback
|
17551 | * @return {function}
|
17552 | */
|
17553 | function memoizeStringOnly(callback) {
|
17554 | var cache = {};
|
17555 | return function(string) {
|
17556 | if (cache.hasOwnProperty(string)) {
|
17557 | return cache[string];
|
17558 | } else {
|
17559 | return cache[string] = callback.call(this, string);
|
17560 | }
|
17561 | };
|
17562 | }
|
17563 |
|
17564 | module.exports = memoizeStringOnly;
|
17565 |
|
17566 | },{}],136:[function(_dereq_,module,exports){
|
17567 | /**
|
17568 | * Copyright 2014, Facebook, Inc.
|
17569 | * All rights reserved.
|
17570 | *
|
17571 | * This source code is licensed under the BSD-style license found in the
|
17572 | * LICENSE file in the root directory of this source tree. An additional grant
|
17573 | * of patent rights can be found in the PATENTS file in the same directory.
|
17574 | *
|
17575 | * @providesModule monitorCodeUse
|
17576 | */
|
17577 |
|
17578 | "use strict";
|
17579 |
|
17580 | var invariant = _dereq_("./invariant");
|
17581 |
|
17582 | /**
|
17583 | * Provides open-source compatible instrumentation for monitoring certain API
|
17584 | * uses before we're ready to issue a warning or refactor. It accepts an event
|
17585 | * name which may only contain the characters [a-z0-9_] and an optional data
|
17586 | * object with further information.
|
17587 | */
|
17588 |
|
17589 | function monitorCodeUse(eventName, data) {
|
17590 | ("production" !== "development" ? invariant(
|
17591 | eventName && !/[^a-z0-9_]/.test(eventName),
|
17592 | 'You must provide an eventName using only the characters [a-z0-9_]'
|
17593 | ) : invariant(eventName && !/[^a-z0-9_]/.test(eventName)));
|
17594 | }
|
17595 |
|
17596 | module.exports = monitorCodeUse;
|
17597 |
|
17598 | },{"./invariant":126}],137:[function(_dereq_,module,exports){
|
17599 | /**
|
17600 | * Copyright 2013-2014, Facebook, Inc.
|
17601 | * All rights reserved.
|
17602 | *
|
17603 | * This source code is licensed under the BSD-style license found in the
|
17604 | * LICENSE file in the root directory of this source tree. An additional grant
|
17605 | * of patent rights can be found in the PATENTS file in the same directory.
|
17606 | *
|
17607 | * @providesModule onlyChild
|
17608 | */
|
17609 | "use strict";
|
17610 |
|
17611 | var ReactElement = _dereq_("./ReactElement");
|
17612 |
|
17613 | var invariant = _dereq_("./invariant");
|
17614 |
|
17615 | /**
|
17616 | * Returns the first child in a collection of children and verifies that there
|
17617 | * is only one child in the collection. The current implementation of this
|
17618 | * function assumes that a single child gets passed without a wrapper, but the
|
17619 | * purpose of this helper function is to abstract away the particular structure
|
17620 | * of children.
|
17621 | *
|
17622 | * @param {?object} children Child collection structure.
|
17623 | * @return {ReactComponent} The first and only `ReactComponent` contained in the
|
17624 | * structure.
|
17625 | */
|
17626 | function onlyChild(children) {
|
17627 | ("production" !== "development" ? invariant(
|
17628 | ReactElement.isValidElement(children),
|
17629 | 'onlyChild must be passed a children with exactly one child.'
|
17630 | ) : invariant(ReactElement.isValidElement(children)));
|
17631 | return children;
|
17632 | }
|
17633 |
|
17634 | module.exports = onlyChild;
|
17635 |
|
17636 | },{"./ReactElement":52,"./invariant":126}],138:[function(_dereq_,module,exports){
|
17637 | /**
|
17638 | * Copyright 2013-2014, Facebook, Inc.
|
17639 | * All rights reserved.
|
17640 | *
|
17641 | * This source code is licensed under the BSD-style license found in the
|
17642 | * LICENSE file in the root directory of this source tree. An additional grant
|
17643 | * of patent rights can be found in the PATENTS file in the same directory.
|
17644 | *
|
17645 | * @providesModule performance
|
17646 | * @typechecks
|
17647 | */
|
17648 |
|
17649 | "use strict";
|
17650 |
|
17651 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
17652 |
|
17653 | var performance;
|
17654 |
|
17655 | if (ExecutionEnvironment.canUseDOM) {
|
17656 | performance =
|
17657 | window.performance ||
|
17658 | window.msPerformance ||
|
17659 | window.webkitPerformance;
|
17660 | }
|
17661 |
|
17662 | module.exports = performance || {};
|
17663 |
|
17664 | },{"./ExecutionEnvironment":22}],139:[function(_dereq_,module,exports){
|
17665 | /**
|
17666 | * Copyright 2013-2014, Facebook, Inc.
|
17667 | * All rights reserved.
|
17668 | *
|
17669 | * This source code is licensed under the BSD-style license found in the
|
17670 | * LICENSE file in the root directory of this source tree. An additional grant
|
17671 | * of patent rights can be found in the PATENTS file in the same directory.
|
17672 | *
|
17673 | * @providesModule performanceNow
|
17674 | * @typechecks
|
17675 | */
|
17676 |
|
17677 | var performance = _dereq_("./performance");
|
17678 |
|
17679 | /**
|
17680 | * Detect if we can use `window.performance.now()` and gracefully fallback to
|
17681 | * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
|
17682 | * because of Facebook's testing infrastructure.
|
17683 | */
|
17684 | if (!performance || !performance.now) {
|
17685 | performance = Date;
|
17686 | }
|
17687 |
|
17688 | var performanceNow = performance.now.bind(performance);
|
17689 |
|
17690 | module.exports = performanceNow;
|
17691 |
|
17692 | },{"./performance":138}],140:[function(_dereq_,module,exports){
|
17693 | /**
|
17694 | * Copyright 2013-2014, Facebook, Inc.
|
17695 | * All rights reserved.
|
17696 | *
|
17697 | * This source code is licensed under the BSD-style license found in the
|
17698 | * LICENSE file in the root directory of this source tree. An additional grant
|
17699 | * of patent rights can be found in the PATENTS file in the same directory.
|
17700 | *
|
17701 | * @providesModule setInnerHTML
|
17702 | */
|
17703 |
|
17704 | "use strict";
|
17705 |
|
17706 | var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
|
17707 |
|
17708 | var WHITESPACE_TEST = /^[ \r\n\t\f]/;
|
17709 | var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
17710 |
|
17711 | /**
|
17712 | * Set the innerHTML property of a node, ensuring that whitespace is preserved
|
17713 | * even in IE8.
|
17714 | *
|
17715 | * @param {DOMElement} node
|
17716 | * @param {string} html
|
17717 | * @internal
|
17718 | */
|
17719 | var setInnerHTML = function(node, html) {
|
17720 | node.innerHTML = html;
|
17721 | };
|
17722 |
|
17723 | if (ExecutionEnvironment.canUseDOM) {
|
17724 | // IE8: When updating a just created node with innerHTML only leading
|
17725 | // whitespace is removed. When updating an existing node with innerHTML
|
17726 | // whitespace in root TextNodes is also collapsed.
|
17727 | // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
|
17728 |
|
17729 | // Feature detection; only IE8 is known to behave improperly like this.
|
17730 | var testElement = document.createElement('div');
|
17731 | testElement.innerHTML = ' ';
|
17732 | if (testElement.innerHTML === '') {
|
17733 | setInnerHTML = function(node, html) {
|
17734 | // Magic theory: IE8 supposedly differentiates between added and updated
|
17735 | // nodes when processing innerHTML, innerHTML on updated nodes suffers
|
17736 | // from worse whitespace behavior. Re-adding a node like this triggers
|
17737 | // the initial and more favorable whitespace behavior.
|
17738 | // TODO: What to do on a detached node?
|
17739 | if (node.parentNode) {
|
17740 | node.parentNode.replaceChild(node, node);
|
17741 | }
|
17742 |
|
17743 | // We also implement a workaround for non-visible tags disappearing into
|
17744 | // thin air on IE8, this only happens if there is no visible text
|
17745 | // in-front of the non-visible tags. Piggyback on the whitespace fix
|
17746 | // and simply check if any non-visible tags appear in the source.
|
17747 | if (WHITESPACE_TEST.test(html) ||
|
17748 | html[0] === '<' && NONVISIBLE_TEST.test(html)) {
|
17749 | // Recover leading whitespace by temporarily prepending any character.
|
17750 | // \uFEFF has the potential advantage of being zero-width/invisible.
|
17751 | node.innerHTML = '\uFEFF' + html;
|
17752 |
|
17753 | // deleteData leaves an empty `TextNode` which offsets the index of all
|
17754 | // children. Definitely want to avoid this.
|
17755 | var textNode = node.firstChild;
|
17756 | if (textNode.data.length === 1) {
|
17757 | node.removeChild(textNode);
|
17758 | } else {
|
17759 | textNode.deleteData(0, 1);
|
17760 | }
|
17761 | } else {
|
17762 | node.innerHTML = html;
|
17763 | }
|
17764 | };
|
17765 | }
|
17766 | }
|
17767 |
|
17768 | module.exports = setInnerHTML;
|
17769 |
|
17770 | },{"./ExecutionEnvironment":22}],141:[function(_dereq_,module,exports){
|
17771 | /**
|
17772 | * Copyright 2013-2014, Facebook, Inc.
|
17773 | * All rights reserved.
|
17774 | *
|
17775 | * This source code is licensed under the BSD-style license found in the
|
17776 | * LICENSE file in the root directory of this source tree. An additional grant
|
17777 | * of patent rights can be found in the PATENTS file in the same directory.
|
17778 | *
|
17779 | * @providesModule shallowEqual
|
17780 | */
|
17781 |
|
17782 | "use strict";
|
17783 |
|
17784 | /**
|
17785 | * Performs equality by iterating through keys on an object and returning
|
17786 | * false when any key has values which are not strictly equal between
|
17787 | * objA and objB. Returns true when the values of all keys are strictly equal.
|
17788 | *
|
17789 | * @return {boolean}
|
17790 | */
|
17791 | function shallowEqual(objA, objB) {
|
17792 | if (objA === objB) {
|
17793 | return true;
|
17794 | }
|
17795 | var key;
|
17796 | // Test for A's keys different from B.
|
17797 | for (key in objA) {
|
17798 | if (objA.hasOwnProperty(key) &&
|
17799 | (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
|
17800 | return false;
|
17801 | }
|
17802 | }
|
17803 | // Test for B's keys missing from A.
|
17804 | for (key in objB) {
|
17805 | if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
|
17806 | return false;
|
17807 | }
|
17808 | }
|
17809 | return true;
|
17810 | }
|
17811 |
|
17812 | module.exports = shallowEqual;
|
17813 |
|
17814 | },{}],142:[function(_dereq_,module,exports){
|
17815 | /**
|
17816 | * Copyright 2013-2014, Facebook, Inc.
|
17817 | * All rights reserved.
|
17818 | *
|
17819 | * This source code is licensed under the BSD-style license found in the
|
17820 | * LICENSE file in the root directory of this source tree. An additional grant
|
17821 | * of patent rights can be found in the PATENTS file in the same directory.
|
17822 | *
|
17823 | * @providesModule shouldUpdateReactComponent
|
17824 | * @typechecks static-only
|
17825 | */
|
17826 |
|
17827 | "use strict";
|
17828 |
|
17829 | /**
|
17830 | * Given a `prevElement` and `nextElement`, determines if the existing
|
17831 | * instance should be updated as opposed to being destroyed or replaced by a new
|
17832 | * instance. Both arguments are elements. This ensures that this logic can
|
17833 | * operate on stateless trees without any backing instance.
|
17834 | *
|
17835 | * @param {?object} prevElement
|
17836 | * @param {?object} nextElement
|
17837 | * @return {boolean} True if the existing instance should be updated.
|
17838 | * @protected
|
17839 | */
|
17840 | function shouldUpdateReactComponent(prevElement, nextElement) {
|
17841 | if (prevElement && nextElement &&
|
17842 | prevElement.type === nextElement.type &&
|
17843 | prevElement.key === nextElement.key &&
|
17844 | prevElement._owner === nextElement._owner) {
|
17845 | return true;
|
17846 | }
|
17847 | return false;
|
17848 | }
|
17849 |
|
17850 | module.exports = shouldUpdateReactComponent;
|
17851 |
|
17852 | },{}],143:[function(_dereq_,module,exports){
|
17853 | /**
|
17854 | * Copyright 2014, Facebook, Inc.
|
17855 | * All rights reserved.
|
17856 | *
|
17857 | * This source code is licensed under the BSD-style license found in the
|
17858 | * LICENSE file in the root directory of this source tree. An additional grant
|
17859 | * of patent rights can be found in the PATENTS file in the same directory.
|
17860 | *
|
17861 | * @providesModule toArray
|
17862 | * @typechecks
|
17863 | */
|
17864 |
|
17865 | var invariant = _dereq_("./invariant");
|
17866 |
|
17867 | /**
|
17868 | * Convert array-like objects to arrays.
|
17869 | *
|
17870 | * This API assumes the caller knows the contents of the data type. For less
|
17871 | * well defined inputs use createArrayFrom.
|
17872 | *
|
17873 | * @param {object|function|filelist} obj
|
17874 | * @return {array}
|
17875 | */
|
17876 | function toArray(obj) {
|
17877 | var length = obj.length;
|
17878 |
|
17879 | // Some browse builtin objects can report typeof 'function' (e.g. NodeList in
|
17880 | // old versions of Safari).
|
17881 | ("production" !== "development" ? invariant(
|
17882 | !Array.isArray(obj) &&
|
17883 | (typeof obj === 'object' || typeof obj === 'function'),
|
17884 | 'toArray: Array-like object expected'
|
17885 | ) : invariant(!Array.isArray(obj) &&
|
17886 | (typeof obj === 'object' || typeof obj === 'function')));
|
17887 |
|
17888 | ("production" !== "development" ? invariant(
|
17889 | typeof length === 'number',
|
17890 | 'toArray: Object needs a length property'
|
17891 | ) : invariant(typeof length === 'number'));
|
17892 |
|
17893 | ("production" !== "development" ? invariant(
|
17894 | length === 0 ||
|
17895 | (length - 1) in obj,
|
17896 | 'toArray: Object should have keys for indices'
|
17897 | ) : invariant(length === 0 ||
|
17898 | (length - 1) in obj));
|
17899 |
|
17900 | // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
|
17901 | // without method will throw during the slice call and skip straight to the
|
17902 | // fallback.
|
17903 | if (obj.hasOwnProperty) {
|
17904 | try {
|
17905 | return Array.prototype.slice.call(obj);
|
17906 | } catch (e) {
|
17907 | // IE < 9 does not support Array#slice on collections objects
|
17908 | }
|
17909 | }
|
17910 |
|
17911 | // Fall back to copying key by key. This assumes all keys have a value,
|
17912 | // so will not preserve sparsely populated inputs.
|
17913 | var ret = Array(length);
|
17914 | for (var ii = 0; ii < length; ii++) {
|
17915 | ret[ii] = obj[ii];
|
17916 | }
|
17917 | return ret;
|
17918 | }
|
17919 |
|
17920 | module.exports = toArray;
|
17921 |
|
17922 | },{"./invariant":126}],144:[function(_dereq_,module,exports){
|
17923 | /**
|
17924 | * Copyright 2013-2014, Facebook, Inc.
|
17925 | * All rights reserved.
|
17926 | *
|
17927 | * This source code is licensed under the BSD-style license found in the
|
17928 | * LICENSE file in the root directory of this source tree. An additional grant
|
17929 | * of patent rights can be found in the PATENTS file in the same directory.
|
17930 | *
|
17931 | * @providesModule traverseAllChildren
|
17932 | */
|
17933 |
|
17934 | "use strict";
|
17935 |
|
17936 | var ReactElement = _dereq_("./ReactElement");
|
17937 | var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
|
17938 |
|
17939 | var invariant = _dereq_("./invariant");
|
17940 |
|
17941 | var SEPARATOR = ReactInstanceHandles.SEPARATOR;
|
17942 | var SUBSEPARATOR = ':';
|
17943 |
|
17944 | /**
|
17945 | * TODO: Test that:
|
17946 | * 1. `mapChildren` transforms strings and numbers into `ReactTextComponent`.
|
17947 | * 2. it('should fail when supplied duplicate key', function() {
|
17948 | * 3. That a single child and an array with one item have the same key pattern.
|
17949 | * });
|
17950 | */
|
17951 |
|
17952 | var userProvidedKeyEscaperLookup = {
|
17953 | '=': '=0',
|
17954 | '.': '=1',
|
17955 | ':': '=2'
|
17956 | };
|
17957 |
|
17958 | var userProvidedKeyEscapeRegex = /[=.:]/g;
|
17959 |
|
17960 | function userProvidedKeyEscaper(match) {
|
17961 | return userProvidedKeyEscaperLookup[match];
|
17962 | }
|
17963 |
|
17964 | /**
|
17965 | * Generate a key string that identifies a component within a set.
|
17966 | *
|
17967 | * @param {*} component A component that could contain a manual key.
|
17968 | * @param {number} index Index that is used if a manual key is not provided.
|
17969 | * @return {string}
|
17970 | */
|
17971 | function getComponentKey(component, index) {
|
17972 | if (component && component.key != null) {
|
17973 | // Explicit key
|
17974 | return wrapUserProvidedKey(component.key);
|
17975 | }
|
17976 | // Implicit key determined by the index in the set
|
17977 | return index.toString(36);
|
17978 | }
|
17979 |
|
17980 | /**
|
17981 | * Escape a component key so that it is safe to use in a reactid.
|
17982 | *
|
17983 | * @param {*} key Component key to be escaped.
|
17984 | * @return {string} An escaped string.
|
17985 | */
|
17986 | function escapeUserProvidedKey(text) {
|
17987 | return ('' + text).replace(
|
17988 | userProvidedKeyEscapeRegex,
|
17989 | userProvidedKeyEscaper
|
17990 | );
|
17991 | }
|
17992 |
|
17993 | /**
|
17994 | * Wrap a `key` value explicitly provided by the user to distinguish it from
|
17995 | * implicitly-generated keys generated by a component's index in its parent.
|
17996 | *
|
17997 | * @param {string} key Value of a user-provided `key` attribute
|
17998 | * @return {string}
|
17999 | */
|
18000 | function wrapUserProvidedKey(key) {
|
18001 | return '$' + escapeUserProvidedKey(key);
|
18002 | }
|
18003 |
|
18004 | /**
|
18005 | * @param {?*} children Children tree container.
|
18006 | * @param {!string} nameSoFar Name of the key path so far.
|
18007 | * @param {!number} indexSoFar Number of children encountered until this point.
|
18008 | * @param {!function} callback Callback to invoke with each child found.
|
18009 | * @param {?*} traverseContext Used to pass information throughout the traversal
|
18010 | * process.
|
18011 | * @return {!number} The number of children in this subtree.
|
18012 | */
|
18013 | var traverseAllChildrenImpl =
|
18014 | function(children, nameSoFar, indexSoFar, callback, traverseContext) {
|
18015 | var nextName, nextIndex;
|
18016 | var subtreeCount = 0; // Count of children found in the current subtree.
|
18017 | if (Array.isArray(children)) {
|
18018 | for (var i = 0; i < children.length; i++) {
|
18019 | var child = children[i];
|
18020 | nextName = (
|
18021 | nameSoFar +
|
18022 | (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
|
18023 | getComponentKey(child, i)
|
18024 | );
|
18025 | nextIndex = indexSoFar + subtreeCount;
|
18026 | subtreeCount += traverseAllChildrenImpl(
|
18027 | child,
|
18028 | nextName,
|
18029 | nextIndex,
|
18030 | callback,
|
18031 | traverseContext
|
18032 | );
|
18033 | }
|
18034 | } else {
|
18035 | var type = typeof children;
|
18036 | var isOnlyChild = nameSoFar === '';
|
18037 | // If it's the only child, treat the name as if it was wrapped in an array
|
18038 | // so that it's consistent if the number of children grows
|
18039 | var storageName =
|
18040 | isOnlyChild ? SEPARATOR + getComponentKey(children, 0) : nameSoFar;
|
18041 | if (children == null || type === 'boolean') {
|
18042 | // All of the above are perceived as null.
|
18043 | callback(traverseContext, null, storageName, indexSoFar);
|
18044 | subtreeCount = 1;
|
18045 | } else if (type === 'string' || type === 'number' ||
|
18046 | ReactElement.isValidElement(children)) {
|
18047 | callback(traverseContext, children, storageName, indexSoFar);
|
18048 | subtreeCount = 1;
|
18049 | } else if (type === 'object') {
|
18050 | ("production" !== "development" ? invariant(
|
18051 | !children || children.nodeType !== 1,
|
18052 | 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
|
18053 | 'elements are not valid children of React components.'
|
18054 | ) : invariant(!children || children.nodeType !== 1));
|
18055 | for (var key in children) {
|
18056 | if (children.hasOwnProperty(key)) {
|
18057 | nextName = (
|
18058 | nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
|
18059 | wrapUserProvidedKey(key) + SUBSEPARATOR +
|
18060 | getComponentKey(children[key], 0)
|
18061 | );
|
18062 | nextIndex = indexSoFar + subtreeCount;
|
18063 | subtreeCount += traverseAllChildrenImpl(
|
18064 | children[key],
|
18065 | nextName,
|
18066 | nextIndex,
|
18067 | callback,
|
18068 | traverseContext
|
18069 | );
|
18070 | }
|
18071 | }
|
18072 | }
|
18073 | }
|
18074 | return subtreeCount;
|
18075 | };
|
18076 |
|
18077 | /**
|
18078 | * Traverses children that are typically specified as `props.children`, but
|
18079 | * might also be specified through attributes:
|
18080 | *
|
18081 | * - `traverseAllChildren(this.props.children, ...)`
|
18082 | * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
|
18083 | *
|
18084 | * The `traverseContext` is an optional argument that is passed through the
|
18085 | * entire traversal. It can be used to store accumulations or anything else that
|
18086 | * the callback might find relevant.
|
18087 | *
|
18088 | * @param {?*} children Children tree object.
|
18089 | * @param {!function} callback To invoke upon traversing each child.
|
18090 | * @param {?*} traverseContext Context for traversal.
|
18091 | * @return {!number} The number of children in this subtree.
|
18092 | */
|
18093 | function traverseAllChildren(children, callback, traverseContext) {
|
18094 | if (children == null) {
|
18095 | return 0;
|
18096 | }
|
18097 |
|
18098 | return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
|
18099 | }
|
18100 |
|
18101 | module.exports = traverseAllChildren;
|
18102 |
|
18103 | },{"./ReactElement":52,"./ReactInstanceHandles":60,"./invariant":126}],145:[function(_dereq_,module,exports){
|
18104 | /**
|
18105 | * Copyright 2014, Facebook, Inc.
|
18106 | * All rights reserved.
|
18107 | *
|
18108 | * This source code is licensed under the BSD-style license found in the
|
18109 | * LICENSE file in the root directory of this source tree. An additional grant
|
18110 | * of patent rights can be found in the PATENTS file in the same directory.
|
18111 | *
|
18112 | * @providesModule warning
|
18113 | */
|
18114 |
|
18115 | "use strict";
|
18116 |
|
18117 | var emptyFunction = _dereq_("./emptyFunction");
|
18118 |
|
18119 | /**
|
18120 | * Similar to invariant but only logs a warning if the condition is not met.
|
18121 | * This can be used to log issues in development environments in critical
|
18122 | * paths. Removing the logging code for production environments will keep the
|
18123 | * same logic and follow the same code paths.
|
18124 | */
|
18125 |
|
18126 | var warning = emptyFunction;
|
18127 |
|
18128 | if ("production" !== "development") {
|
18129 | warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
|
18130 | if (format === undefined) {
|
18131 | throw new Error(
|
18132 | '`warning(condition, format, ...args)` requires a warning ' +
|
18133 | 'message argument'
|
18134 | );
|
18135 | }
|
18136 |
|
18137 | if (!condition) {
|
18138 | var argIndex = 0;
|
18139 | console.warn('Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];}));
|
18140 | }
|
18141 | };
|
18142 | }
|
18143 |
|
18144 | module.exports = warning;
|
18145 |
|
18146 | },{"./emptyFunction":107}]},{},[1])(1)
|
18147 | }); |
\ | No newline at end of file |