Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 50994
1
/**
2
* React v0.13.3
3
*/
4
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.React = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
5
/**
6
* Copyright 2013-2015, Facebook, Inc.
7
* All rights reserved.
8
*
9
* This source code is licensed under the BSD-style license found in the
10
* LICENSE file in the root directory of this source tree. An additional grant
11
* of patent rights can be found in the PATENTS file in the same directory.
12
*
13
* @providesModule React
14
*/
15
16
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
17
18
'use strict';
19
20
var EventPluginUtils = _dereq_(19);
21
var ReactChildren = _dereq_(32);
22
var ReactComponent = _dereq_(34);
23
var ReactClass = _dereq_(33);
24
var ReactContext = _dereq_(38);
25
var ReactCurrentOwner = _dereq_(39);
26
var ReactElement = _dereq_(57);
27
var ReactElementValidator = _dereq_(58);
28
var ReactDOM = _dereq_(40);
29
var ReactDOMTextComponent = _dereq_(51);
30
var ReactDefaultInjection = _dereq_(54);
31
var ReactInstanceHandles = _dereq_(66);
32
var ReactMount = _dereq_(70);
33
var ReactPerf = _dereq_(75);
34
var ReactPropTypes = _dereq_(78);
35
var ReactReconciler = _dereq_(81);
36
var ReactServerRendering = _dereq_(84);
37
38
var assign = _dereq_(27);
39
var findDOMNode = _dereq_(117);
40
var onlyChild = _dereq_(144);
41
42
ReactDefaultInjection.inject();
43
44
var createElement = ReactElement.createElement;
45
var createFactory = ReactElement.createFactory;
46
var cloneElement = ReactElement.cloneElement;
47
48
if ("production" !== "development") {
49
createElement = ReactElementValidator.createElement;
50
createFactory = ReactElementValidator.createFactory;
51
cloneElement = ReactElementValidator.cloneElement;
52
}
53
54
var render = ReactPerf.measure('React', 'render', ReactMount.render);
55
56
var React = {
57
Children: {
58
map: ReactChildren.map,
59
forEach: ReactChildren.forEach,
60
count: ReactChildren.count,
61
only: onlyChild
62
},
63
Component: ReactComponent,
64
DOM: ReactDOM,
65
PropTypes: ReactPropTypes,
66
initializeTouchEvents: function(shouldUseTouch) {
67
EventPluginUtils.useTouchEvents = shouldUseTouch;
68
},
69
createClass: ReactClass.createClass,
70
createElement: createElement,
71
cloneElement: cloneElement,
72
createFactory: createFactory,
73
createMixin: function(mixin) {
74
// Currently a noop. Will be used to validate and trace mixins.
75
return mixin;
76
},
77
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
78
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
79
findDOMNode: findDOMNode,
80
render: render,
81
renderToString: ReactServerRendering.renderToString,
82
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
83
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
84
isValidElement: ReactElement.isValidElement,
85
withContext: ReactContext.withContext,
86
87
// Hook for JSX spread, don't use this for anything else.
88
__spread: assign
89
};
90
91
// Inject the runtime into a devtools global hook regardless of browser.
92
// Allows for debugging when the hook is injected on the page.
93
if (
94
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
95
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
96
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
97
CurrentOwner: ReactCurrentOwner,
98
InstanceHandles: ReactInstanceHandles,
99
Mount: ReactMount,
100
Reconciler: ReactReconciler,
101
TextComponent: ReactDOMTextComponent
102
});
103
}
104
105
if ("production" !== "development") {
106
var ExecutionEnvironment = _dereq_(21);
107
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
108
109
// If we're in Chrome, look for the devtools marker and provide a download
110
// link if not installed.
111
if (navigator.userAgent.indexOf('Chrome') > -1) {
112
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
113
console.debug(
114
'Download the React DevTools for a better development experience: ' +
115
'https://fb.me/react-devtools'
116
);
117
}
118
}
119
120
var expectedFeatures = [
121
// shims
122
Array.isArray,
123
Array.prototype.every,
124
Array.prototype.forEach,
125
Array.prototype.indexOf,
126
Array.prototype.map,
127
Date.now,
128
Function.prototype.bind,
129
Object.keys,
130
String.prototype.split,
131
String.prototype.trim,
132
133
// shams
134
Object.create,
135
Object.freeze
136
];
137
138
for (var i = 0; i < expectedFeatures.length; i++) {
139
if (!expectedFeatures[i]) {
140
console.error(
141
'One or more ES5 shim/shams expected by React are not available: ' +
142
'https://fb.me/react-warning-polyfills'
143
);
144
break;
145
}
146
}
147
}
148
}
149
150
React.version = '0.13.3';
151
152
module.exports = React;
153
154
},{"117":117,"144":144,"19":19,"21":21,"27":27,"32":32,"33":33,"34":34,"38":38,"39":39,"40":40,"51":51,"54":54,"57":57,"58":58,"66":66,"70":70,"75":75,"78":78,"81":81,"84":84}],2:[function(_dereq_,module,exports){
155
/**
156
* Copyright 2013-2015, Facebook, Inc.
157
* All rights reserved.
158
*
159
* This source code is licensed under the BSD-style license found in the
160
* LICENSE file in the root directory of this source tree. An additional grant
161
* of patent rights can be found in the PATENTS file in the same directory.
162
*
163
* @providesModule AutoFocusMixin
164
* @typechecks static-only
165
*/
166
167
'use strict';
168
169
var focusNode = _dereq_(119);
170
171
var AutoFocusMixin = {
172
componentDidMount: function() {
173
if (this.props.autoFocus) {
174
focusNode(this.getDOMNode());
175
}
176
}
177
};
178
179
module.exports = AutoFocusMixin;
180
181
},{"119":119}],3:[function(_dereq_,module,exports){
182
/**
183
* Copyright 2013-2015 Facebook, Inc.
184
* All rights reserved.
185
*
186
* This source code is licensed under the BSD-style license found in the
187
* LICENSE file in the root directory of this source tree. An additional grant
188
* of patent rights can be found in the PATENTS file in the same directory.
189
*
190
* @providesModule BeforeInputEventPlugin
191
* @typechecks static-only
192
*/
193
194
'use strict';
195
196
var EventConstants = _dereq_(15);
197
var EventPropagators = _dereq_(20);
198
var ExecutionEnvironment = _dereq_(21);
199
var FallbackCompositionState = _dereq_(22);
200
var SyntheticCompositionEvent = _dereq_(93);
201
var SyntheticInputEvent = _dereq_(97);
202
203
var keyOf = _dereq_(141);
204
205
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
206
var START_KEYCODE = 229;
207
208
var canUseCompositionEvent = (
209
ExecutionEnvironment.canUseDOM &&
210
'CompositionEvent' in window
211
);
212
213
var documentMode = null;
214
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
215
documentMode = document.documentMode;
216
}
217
218
// Webkit offers a very useful `textInput` event that can be used to
219
// directly represent `beforeInput`. The IE `textinput` event is not as
220
// useful, so we don't use it.
221
var canUseTextInputEvent = (
222
ExecutionEnvironment.canUseDOM &&
223
'TextEvent' in window &&
224
!documentMode &&
225
!isPresto()
226
);
227
228
// In IE9+, we have access to composition events, but the data supplied
229
// by the native compositionend event may be incorrect. Japanese ideographic
230
// spaces, for instance (\u3000) are not recorded correctly.
231
var useFallbackCompositionData = (
232
ExecutionEnvironment.canUseDOM &&
233
(
234
(!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11)
235
)
236
);
237
238
/**
239
* Opera <= 12 includes TextEvent in window, but does not fire
240
* text input events. Rely on keypress instead.
241
*/
242
function isPresto() {
243
var opera = window.opera;
244
return (
245
typeof opera === 'object' &&
246
typeof opera.version === 'function' &&
247
parseInt(opera.version(), 10) <= 12
248
);
249
}
250
251
var SPACEBAR_CODE = 32;
252
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
253
254
var topLevelTypes = EventConstants.topLevelTypes;
255
256
// Events and their corresponding property names.
257
var eventTypes = {
258
beforeInput: {
259
phasedRegistrationNames: {
260
bubbled: keyOf({onBeforeInput: null}),
261
captured: keyOf({onBeforeInputCapture: null})
262
},
263
dependencies: [
264
topLevelTypes.topCompositionEnd,
265
topLevelTypes.topKeyPress,
266
topLevelTypes.topTextInput,
267
topLevelTypes.topPaste
268
]
269
},
270
compositionEnd: {
271
phasedRegistrationNames: {
272
bubbled: keyOf({onCompositionEnd: null}),
273
captured: keyOf({onCompositionEndCapture: null})
274
},
275
dependencies: [
276
topLevelTypes.topBlur,
277
topLevelTypes.topCompositionEnd,
278
topLevelTypes.topKeyDown,
279
topLevelTypes.topKeyPress,
280
topLevelTypes.topKeyUp,
281
topLevelTypes.topMouseDown
282
]
283
},
284
compositionStart: {
285
phasedRegistrationNames: {
286
bubbled: keyOf({onCompositionStart: null}),
287
captured: keyOf({onCompositionStartCapture: null})
288
},
289
dependencies: [
290
topLevelTypes.topBlur,
291
topLevelTypes.topCompositionStart,
292
topLevelTypes.topKeyDown,
293
topLevelTypes.topKeyPress,
294
topLevelTypes.topKeyUp,
295
topLevelTypes.topMouseDown
296
]
297
},
298
compositionUpdate: {
299
phasedRegistrationNames: {
300
bubbled: keyOf({onCompositionUpdate: null}),
301
captured: keyOf({onCompositionUpdateCapture: null})
302
},
303
dependencies: [
304
topLevelTypes.topBlur,
305
topLevelTypes.topCompositionUpdate,
306
topLevelTypes.topKeyDown,
307
topLevelTypes.topKeyPress,
308
topLevelTypes.topKeyUp,
309
topLevelTypes.topMouseDown
310
]
311
}
312
};
313
314
// Track whether we've ever handled a keypress on the space key.
315
var hasSpaceKeypress = false;
316
317
/**
318
* Return whether a native keypress event is assumed to be a command.
319
* This is required because Firefox fires `keypress` events for key commands
320
* (cut, copy, select-all, etc.) even though no character is inserted.
321
*/
322
function isKeypressCommand(nativeEvent) {
323
return (
324
(nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
325
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
326
!(nativeEvent.ctrlKey && nativeEvent.altKey)
327
);
328
}
329
330
331
/**
332
* Translate native top level events into event types.
333
*
334
* @param {string} topLevelType
335
* @return {object}
336
*/
337
function getCompositionEventType(topLevelType) {
338
switch (topLevelType) {
339
case topLevelTypes.topCompositionStart:
340
return eventTypes.compositionStart;
341
case topLevelTypes.topCompositionEnd:
342
return eventTypes.compositionEnd;
343
case topLevelTypes.topCompositionUpdate:
344
return eventTypes.compositionUpdate;
345
}
346
}
347
348
/**
349
* Does our fallback best-guess model think this event signifies that
350
* composition has begun?
351
*
352
* @param {string} topLevelType
353
* @param {object} nativeEvent
354
* @return {boolean}
355
*/
356
function isFallbackCompositionStart(topLevelType, nativeEvent) {
357
return (
358
topLevelType === topLevelTypes.topKeyDown &&
359
nativeEvent.keyCode === START_KEYCODE
360
);
361
}
362
363
/**
364
* Does our fallback mode think that this event is the end of composition?
365
*
366
* @param {string} topLevelType
367
* @param {object} nativeEvent
368
* @return {boolean}
369
*/
370
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
371
switch (topLevelType) {
372
case topLevelTypes.topKeyUp:
373
// Command keys insert or clear IME input.
374
return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
375
case topLevelTypes.topKeyDown:
376
// Expect IME keyCode on each keydown. If we get any other
377
// code we must have exited earlier.
378
return (nativeEvent.keyCode !== START_KEYCODE);
379
case topLevelTypes.topKeyPress:
380
case topLevelTypes.topMouseDown:
381
case topLevelTypes.topBlur:
382
// Events are not possible without cancelling IME.
383
return true;
384
default:
385
return false;
386
}
387
}
388
389
/**
390
* Google Input Tools provides composition data via a CustomEvent,
391
* with the `data` property populated in the `detail` object. If this
392
* is available on the event object, use it. If not, this is a plain
393
* composition event and we have nothing special to extract.
394
*
395
* @param {object} nativeEvent
396
* @return {?string}
397
*/
398
function getDataFromCustomEvent(nativeEvent) {
399
var detail = nativeEvent.detail;
400
if (typeof detail === 'object' && 'data' in detail) {
401
return detail.data;
402
}
403
return null;
404
}
405
406
// Track the current IME composition fallback object, if any.
407
var currentComposition = null;
408
409
/**
410
* @param {string} topLevelType Record from `EventConstants`.
411
* @param {DOMEventTarget} topLevelTarget The listening component root node.
412
* @param {string} topLevelTargetID ID of `topLevelTarget`.
413
* @param {object} nativeEvent Native browser event.
414
* @return {?object} A SyntheticCompositionEvent.
415
*/
416
function extractCompositionEvent(
417
topLevelType,
418
topLevelTarget,
419
topLevelTargetID,
420
nativeEvent
421
) {
422
var eventType;
423
var fallbackData;
424
425
if (canUseCompositionEvent) {
426
eventType = getCompositionEventType(topLevelType);
427
} else if (!currentComposition) {
428
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
429
eventType = eventTypes.compositionStart;
430
}
431
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
432
eventType = eventTypes.compositionEnd;
433
}
434
435
if (!eventType) {
436
return null;
437
}
438
439
if (useFallbackCompositionData) {
440
// The current composition is stored statically and must not be
441
// overwritten while composition continues.
442
if (!currentComposition && eventType === eventTypes.compositionStart) {
443
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
444
} else if (eventType === eventTypes.compositionEnd) {
445
if (currentComposition) {
446
fallbackData = currentComposition.getData();
447
}
448
}
449
}
450
451
var event = SyntheticCompositionEvent.getPooled(
452
eventType,
453
topLevelTargetID,
454
nativeEvent
455
);
456
457
if (fallbackData) {
458
// Inject data generated from fallback path into the synthetic event.
459
// This matches the property of native CompositionEventInterface.
460
event.data = fallbackData;
461
} else {
462
var customData = getDataFromCustomEvent(nativeEvent);
463
if (customData !== null) {
464
event.data = customData;
465
}
466
}
467
468
EventPropagators.accumulateTwoPhaseDispatches(event);
469
return event;
470
}
471
472
/**
473
* @param {string} topLevelType Record from `EventConstants`.
474
* @param {object} nativeEvent Native browser event.
475
* @return {?string} The string corresponding to this `beforeInput` event.
476
*/
477
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
478
switch (topLevelType) {
479
case topLevelTypes.topCompositionEnd:
480
return getDataFromCustomEvent(nativeEvent);
481
case topLevelTypes.topKeyPress:
482
/**
483
* If native `textInput` events are available, our goal is to make
484
* use of them. However, there is a special case: the spacebar key.
485
* In Webkit, preventing default on a spacebar `textInput` event
486
* cancels character insertion, but it *also* causes the browser
487
* to fall back to its default spacebar behavior of scrolling the
488
* page.
489
*
490
* Tracking at:
491
* https://code.google.com/p/chromium/issues/detail?id=355103
492
*
493
* To avoid this issue, use the keypress event as if no `textInput`
494
* event is available.
495
*/
496
var which = nativeEvent.which;
497
if (which !== SPACEBAR_CODE) {
498
return null;
499
}
500
501
hasSpaceKeypress = true;
502
return SPACEBAR_CHAR;
503
504
case topLevelTypes.topTextInput:
505
// Record the characters to be added to the DOM.
506
var chars = nativeEvent.data;
507
508
// If it's a spacebar character, assume that we have already handled
509
// it at the keypress level and bail immediately. Android Chrome
510
// doesn't give us keycodes, so we need to blacklist it.
511
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
512
return null;
513
}
514
515
return chars;
516
517
default:
518
// For other native event types, do nothing.
519
return null;
520
}
521
}
522
523
/**
524
* For browsers that do not provide the `textInput` event, extract the
525
* appropriate string to use for SyntheticInputEvent.
526
*
527
* @param {string} topLevelType Record from `EventConstants`.
528
* @param {object} nativeEvent Native browser event.
529
* @return {?string} The fallback string for this `beforeInput` event.
530
*/
531
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
532
// If we are currently composing (IME) and using a fallback to do so,
533
// try to extract the composed characters from the fallback object.
534
if (currentComposition) {
535
if (
536
topLevelType === topLevelTypes.topCompositionEnd ||
537
isFallbackCompositionEnd(topLevelType, nativeEvent)
538
) {
539
var chars = currentComposition.getData();
540
FallbackCompositionState.release(currentComposition);
541
currentComposition = null;
542
return chars;
543
}
544
return null;
545
}
546
547
switch (topLevelType) {
548
case topLevelTypes.topPaste:
549
// If a paste event occurs after a keypress, throw out the input
550
// chars. Paste events should not lead to BeforeInput events.
551
return null;
552
case topLevelTypes.topKeyPress:
553
/**
554
* As of v27, Firefox may fire keypress events even when no character
555
* will be inserted. A few possibilities:
556
*
557
* - `which` is `0`. Arrow keys, Esc key, etc.
558
*
559
* - `which` is the pressed key code, but no char is available.
560
* Ex: 'AltGr + d` in Polish. There is no modified character for
561
* this key combination and no character is inserted into the
562
* document, but FF fires the keypress for char code `100` anyway.
563
* No `input` event will occur.
564
*
565
* - `which` is the pressed key code, but a command combination is
566
* being used. Ex: `Cmd+C`. No character is inserted, and no
567
* `input` event will occur.
568
*/
569
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
570
return String.fromCharCode(nativeEvent.which);
571
}
572
return null;
573
case topLevelTypes.topCompositionEnd:
574
return useFallbackCompositionData ? null : nativeEvent.data;
575
default:
576
return null;
577
}
578
}
579
580
/**
581
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
582
* `textInput` or fallback behavior.
583
*
584
* @param {string} topLevelType Record from `EventConstants`.
585
* @param {DOMEventTarget} topLevelTarget The listening component root node.
586
* @param {string} topLevelTargetID ID of `topLevelTarget`.
587
* @param {object} nativeEvent Native browser event.
588
* @return {?object} A SyntheticInputEvent.
589
*/
590
function extractBeforeInputEvent(
591
topLevelType,
592
topLevelTarget,
593
topLevelTargetID,
594
nativeEvent
595
) {
596
var chars;
597
598
if (canUseTextInputEvent) {
599
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
600
} else {
601
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
602
}
603
604
// If no characters are being inserted, no BeforeInput event should
605
// be fired.
606
if (!chars) {
607
return null;
608
}
609
610
var event = SyntheticInputEvent.getPooled(
611
eventTypes.beforeInput,
612
topLevelTargetID,
613
nativeEvent
614
);
615
616
event.data = chars;
617
EventPropagators.accumulateTwoPhaseDispatches(event);
618
return event;
619
}
620
621
/**
622
* Create an `onBeforeInput` event to match
623
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
624
*
625
* This event plugin is based on the native `textInput` event
626
* available in Chrome, Safari, Opera, and IE. This event fires after
627
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
628
*
629
* `beforeInput` is spec'd but not implemented in any browsers, and
630
* the `input` event does not provide any useful information about what has
631
* actually been added, contrary to the spec. Thus, `textInput` is the best
632
* available event to identify the characters that have actually been inserted
633
* into the target node.
634
*
635
* This plugin is also responsible for emitting `composition` events, thus
636
* allowing us to share composition fallback code for both `beforeInput` and
637
* `composition` event types.
638
*/
639
var BeforeInputEventPlugin = {
640
641
eventTypes: eventTypes,
642
643
/**
644
* @param {string} topLevelType Record from `EventConstants`.
645
* @param {DOMEventTarget} topLevelTarget The listening component root node.
646
* @param {string} topLevelTargetID ID of `topLevelTarget`.
647
* @param {object} nativeEvent Native browser event.
648
* @return {*} An accumulation of synthetic events.
649
* @see {EventPluginHub.extractEvents}
650
*/
651
extractEvents: function(
652
topLevelType,
653
topLevelTarget,
654
topLevelTargetID,
655
nativeEvent
656
) {
657
return [
658
extractCompositionEvent(
659
topLevelType,
660
topLevelTarget,
661
topLevelTargetID,
662
nativeEvent
663
),
664
extractBeforeInputEvent(
665
topLevelType,
666
topLevelTarget,
667
topLevelTargetID,
668
nativeEvent
669
)
670
];
671
}
672
};
673
674
module.exports = BeforeInputEventPlugin;
675
676
},{"141":141,"15":15,"20":20,"21":21,"22":22,"93":93,"97":97}],4:[function(_dereq_,module,exports){
677
/**
678
* Copyright 2013-2015, Facebook, Inc.
679
* All rights reserved.
680
*
681
* This source code is licensed under the BSD-style license found in the
682
* LICENSE file in the root directory of this source tree. An additional grant
683
* of patent rights can be found in the PATENTS file in the same directory.
684
*
685
* @providesModule CSSProperty
686
*/
687
688
'use strict';
689
690
/**
691
* CSS properties which accept numbers but are not in units of "px".
692
*/
693
var isUnitlessNumber = {
694
boxFlex: true,
695
boxFlexGroup: true,
696
columnCount: true,
697
flex: true,
698
flexGrow: true,
699
flexPositive: true,
700
flexShrink: true,
701
flexNegative: true,
702
fontWeight: true,
703
lineClamp: true,
704
lineHeight: true,
705
opacity: true,
706
order: true,
707
orphans: true,
708
widows: true,
709
zIndex: true,
710
zoom: true,
711
712
// SVG-related properties
713
fillOpacity: true,
714
strokeDashoffset: true,
715
strokeOpacity: true,
716
strokeWidth: true
717
};
718
719
/**
720
* @param {string} prefix vendor-specific prefix, eg: Webkit
721
* @param {string} key style name, eg: transitionDuration
722
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
723
* WebkitTransitionDuration
724
*/
725
function prefixKey(prefix, key) {
726
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
727
}
728
729
/**
730
* Support style names that may come passed in prefixed by adding permutations
731
* of vendor prefixes.
732
*/
733
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
734
735
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
736
// infinite loop, because it iterates over the newly added props too.
737
Object.keys(isUnitlessNumber).forEach(function(prop) {
738
prefixes.forEach(function(prefix) {
739
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
740
});
741
});
742
743
/**
744
* Most style properties can be unset by doing .style[prop] = '' but IE8
745
* doesn't like doing that with shorthand properties so for the properties that
746
* IE8 breaks on, which are listed here, we instead unset each of the
747
* individual properties. See http://bugs.jquery.com/ticket/12385.
748
* The 4-value 'clock' properties like margin, padding, border-width seem to
749
* behave without any problems. Curiously, list-style works too without any
750
* special prodding.
751
*/
752
var shorthandPropertyExpansions = {
753
background: {
754
backgroundImage: true,
755
backgroundPosition: true,
756
backgroundRepeat: true,
757
backgroundColor: true
758
},
759
border: {
760
borderWidth: true,
761
borderStyle: true,
762
borderColor: true
763
},
764
borderBottom: {
765
borderBottomWidth: true,
766
borderBottomStyle: true,
767
borderBottomColor: true
768
},
769
borderLeft: {
770
borderLeftWidth: true,
771
borderLeftStyle: true,
772
borderLeftColor: true
773
},
774
borderRight: {
775
borderRightWidth: true,
776
borderRightStyle: true,
777
borderRightColor: true
778
},
779
borderTop: {
780
borderTopWidth: true,
781
borderTopStyle: true,
782
borderTopColor: true
783
},
784
font: {
785
fontStyle: true,
786
fontVariant: true,
787
fontWeight: true,
788
fontSize: true,
789
lineHeight: true,
790
fontFamily: true
791
}
792
};
793
794
var CSSProperty = {
795
isUnitlessNumber: isUnitlessNumber,
796
shorthandPropertyExpansions: shorthandPropertyExpansions
797
};
798
799
module.exports = CSSProperty;
800
801
},{}],5:[function(_dereq_,module,exports){
802
/**
803
* Copyright 2013-2015, Facebook, Inc.
804
* All rights reserved.
805
*
806
* This source code is licensed under the BSD-style license found in the
807
* LICENSE file in the root directory of this source tree. An additional grant
808
* of patent rights can be found in the PATENTS file in the same directory.
809
*
810
* @providesModule CSSPropertyOperations
811
* @typechecks static-only
812
*/
813
814
'use strict';
815
816
var CSSProperty = _dereq_(4);
817
var ExecutionEnvironment = _dereq_(21);
818
819
var camelizeStyleName = _dereq_(108);
820
var dangerousStyleValue = _dereq_(113);
821
var hyphenateStyleName = _dereq_(133);
822
var memoizeStringOnly = _dereq_(143);
823
var warning = _dereq_(154);
824
825
var processStyleName = memoizeStringOnly(function(styleName) {
826
return hyphenateStyleName(styleName);
827
});
828
829
var styleFloatAccessor = 'cssFloat';
830
if (ExecutionEnvironment.canUseDOM) {
831
// IE8 only supports accessing cssFloat (standard) as styleFloat
832
if (document.documentElement.style.cssFloat === undefined) {
833
styleFloatAccessor = 'styleFloat';
834
}
835
}
836
837
if ("production" !== "development") {
838
// 'msTransform' is correct, but the other prefixes should be capitalized
839
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
840
841
// style values shouldn't contain a semicolon
842
var badStyleValueWithSemicolonPattern = /;\s*$/;
843
844
var warnedStyleNames = {};
845
var warnedStyleValues = {};
846
847
var warnHyphenatedStyleName = function(name) {
848
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
849
return;
850
}
851
852
warnedStyleNames[name] = true;
853
("production" !== "development" ? warning(
854
false,
855
'Unsupported style property %s. Did you mean %s?',
856
name,
857
camelizeStyleName(name)
858
) : null);
859
};
860
861
var warnBadVendoredStyleName = function(name) {
862
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
863
return;
864
}
865
866
warnedStyleNames[name] = true;
867
("production" !== "development" ? warning(
868
false,
869
'Unsupported vendor-prefixed style property %s. Did you mean %s?',
870
name,
871
name.charAt(0).toUpperCase() + name.slice(1)
872
) : null);
873
};
874
875
var warnStyleValueWithSemicolon = function(name, value) {
876
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
877
return;
878
}
879
880
warnedStyleValues[value] = true;
881
("production" !== "development" ? warning(
882
false,
883
'Style property values shouldn\'t contain a semicolon. ' +
884
'Try "%s: %s" instead.',
885
name,
886
value.replace(badStyleValueWithSemicolonPattern, '')
887
) : null);
888
};
889
890
/**
891
* @param {string} name
892
* @param {*} value
893
*/
894
var warnValidStyle = function(name, value) {
895
if (name.indexOf('-') > -1) {
896
warnHyphenatedStyleName(name);
897
} else if (badVendoredStyleNamePattern.test(name)) {
898
warnBadVendoredStyleName(name);
899
} else if (badStyleValueWithSemicolonPattern.test(value)) {
900
warnStyleValueWithSemicolon(name, value);
901
}
902
};
903
}
904
905
/**
906
* Operations for dealing with CSS properties.
907
*/
908
var CSSPropertyOperations = {
909
910
/**
911
* Serializes a mapping of style properties for use as inline styles:
912
*
913
* > createMarkupForStyles({width: '200px', height: 0})
914
* "width:200px;height:0;"
915
*
916
* Undefined values are ignored so that declarative programming is easier.
917
* The result should be HTML-escaped before insertion into the DOM.
918
*
919
* @param {object} styles
920
* @return {?string}
921
*/
922
createMarkupForStyles: function(styles) {
923
var serialized = '';
924
for (var styleName in styles) {
925
if (!styles.hasOwnProperty(styleName)) {
926
continue;
927
}
928
var styleValue = styles[styleName];
929
if ("production" !== "development") {
930
warnValidStyle(styleName, styleValue);
931
}
932
if (styleValue != null) {
933
serialized += processStyleName(styleName) + ':';
934
serialized += dangerousStyleValue(styleName, styleValue) + ';';
935
}
936
}
937
return serialized || null;
938
},
939
940
/**
941
* Sets the value for multiple styles on a node. If a value is specified as
942
* '' (empty string), the corresponding style property will be unset.
943
*
944
* @param {DOMElement} node
945
* @param {object} styles
946
*/
947
setValueForStyles: function(node, styles) {
948
var style = node.style;
949
for (var styleName in styles) {
950
if (!styles.hasOwnProperty(styleName)) {
951
continue;
952
}
953
if ("production" !== "development") {
954
warnValidStyle(styleName, styles[styleName]);
955
}
956
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
957
if (styleName === 'float') {
958
styleName = styleFloatAccessor;
959
}
960
if (styleValue) {
961
style[styleName] = styleValue;
962
} else {
963
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
964
if (expansion) {
965
// Shorthand property that IE8 won't like unsetting, so unset each
966
// component to placate it
967
for (var individualStyleName in expansion) {
968
style[individualStyleName] = '';
969
}
970
} else {
971
style[styleName] = '';
972
}
973
}
974
}
975
}
976
977
};
978
979
module.exports = CSSPropertyOperations;
980
981
},{"108":108,"113":113,"133":133,"143":143,"154":154,"21":21,"4":4}],6:[function(_dereq_,module,exports){
982
/**
983
* Copyright 2013-2015, Facebook, Inc.
984
* All rights reserved.
985
*
986
* This source code is licensed under the BSD-style license found in the
987
* LICENSE file in the root directory of this source tree. An additional grant
988
* of patent rights can be found in the PATENTS file in the same directory.
989
*
990
* @providesModule CallbackQueue
991
*/
992
993
'use strict';
994
995
var PooledClass = _dereq_(28);
996
997
var assign = _dereq_(27);
998
var invariant = _dereq_(135);
999
1000
/**
1001
* A specialized pseudo-event module to help keep track of components waiting to
1002
* be notified when their DOM representations are available for use.
1003
*
1004
* This implements `PooledClass`, so you should never need to instantiate this.
1005
* Instead, use `CallbackQueue.getPooled()`.
1006
*
1007
* @class ReactMountReady
1008
* @implements PooledClass
1009
* @internal
1010
*/
1011
function CallbackQueue() {
1012
this._callbacks = null;
1013
this._contexts = null;
1014
}
1015
1016
assign(CallbackQueue.prototype, {
1017
1018
/**
1019
* Enqueues a callback to be invoked when `notifyAll` is invoked.
1020
*
1021
* @param {function} callback Invoked when `notifyAll` is invoked.
1022
* @param {?object} context Context to call `callback` with.
1023
* @internal
1024
*/
1025
enqueue: function(callback, context) {
1026
this._callbacks = this._callbacks || [];
1027
this._contexts = this._contexts || [];
1028
this._callbacks.push(callback);
1029
this._contexts.push(context);
1030
},
1031
1032
/**
1033
* Invokes all enqueued callbacks and clears the queue. This is invoked after
1034
* the DOM representation of a component has been created or updated.
1035
*
1036
* @internal
1037
*/
1038
notifyAll: function() {
1039
var callbacks = this._callbacks;
1040
var contexts = this._contexts;
1041
if (callbacks) {
1042
("production" !== "development" ? invariant(
1043
callbacks.length === contexts.length,
1044
'Mismatched list of contexts in callback queue'
1045
) : invariant(callbacks.length === contexts.length));
1046
this._callbacks = null;
1047
this._contexts = null;
1048
for (var i = 0, l = callbacks.length; i < l; i++) {
1049
callbacks[i].call(contexts[i]);
1050
}
1051
callbacks.length = 0;
1052
contexts.length = 0;
1053
}
1054
},
1055
1056
/**
1057
* Resets the internal queue.
1058
*
1059
* @internal
1060
*/
1061
reset: function() {
1062
this._callbacks = null;
1063
this._contexts = null;
1064
},
1065
1066
/**
1067
* `PooledClass` looks for this.
1068
*/
1069
destructor: function() {
1070
this.reset();
1071
}
1072
1073
});
1074
1075
PooledClass.addPoolingTo(CallbackQueue);
1076
1077
module.exports = CallbackQueue;
1078
1079
},{"135":135,"27":27,"28":28}],7:[function(_dereq_,module,exports){
1080
/**
1081
* Copyright 2013-2015, Facebook, Inc.
1082
* All rights reserved.
1083
*
1084
* This source code is licensed under the BSD-style license found in the
1085
* LICENSE file in the root directory of this source tree. An additional grant
1086
* of patent rights can be found in the PATENTS file in the same directory.
1087
*
1088
* @providesModule ChangeEventPlugin
1089
*/
1090
1091
'use strict';
1092
1093
var EventConstants = _dereq_(15);
1094
var EventPluginHub = _dereq_(17);
1095
var EventPropagators = _dereq_(20);
1096
var ExecutionEnvironment = _dereq_(21);
1097
var ReactUpdates = _dereq_(87);
1098
var SyntheticEvent = _dereq_(95);
1099
1100
var isEventSupported = _dereq_(136);
1101
var isTextInputElement = _dereq_(138);
1102
var keyOf = _dereq_(141);
1103
1104
var topLevelTypes = EventConstants.topLevelTypes;
1105
1106
var eventTypes = {
1107
change: {
1108
phasedRegistrationNames: {
1109
bubbled: keyOf({onChange: null}),
1110
captured: keyOf({onChangeCapture: null})
1111
},
1112
dependencies: [
1113
topLevelTypes.topBlur,
1114
topLevelTypes.topChange,
1115
topLevelTypes.topClick,
1116
topLevelTypes.topFocus,
1117
topLevelTypes.topInput,
1118
topLevelTypes.topKeyDown,
1119
topLevelTypes.topKeyUp,
1120
topLevelTypes.topSelectionChange
1121
]
1122
}
1123
};
1124
1125
/**
1126
* For IE shims
1127
*/
1128
var activeElement = null;
1129
var activeElementID = null;
1130
var activeElementValue = null;
1131
var activeElementValueProp = null;
1132
1133
/**
1134
* SECTION: handle `change` event
1135
*/
1136
function shouldUseChangeEvent(elem) {
1137
return (
1138
elem.nodeName === 'SELECT' ||
1139
(elem.nodeName === 'INPUT' && elem.type === 'file')
1140
);
1141
}
1142
1143
var doesChangeEventBubble = false;
1144
if (ExecutionEnvironment.canUseDOM) {
1145
// See `handleChange` comment below
1146
doesChangeEventBubble = isEventSupported('change') && (
1147
(!('documentMode' in document) || document.documentMode > 8)
1148
);
1149
}
1150
1151
function manualDispatchChangeEvent(nativeEvent) {
1152
var event = SyntheticEvent.getPooled(
1153
eventTypes.change,
1154
activeElementID,
1155
nativeEvent
1156
);
1157
EventPropagators.accumulateTwoPhaseDispatches(event);
1158
1159
// If change and propertychange bubbled, we'd just bind to it like all the
1160
// other events and have it go through ReactBrowserEventEmitter. Since it
1161
// doesn't, we manually listen for the events and so we have to enqueue and
1162
// process the abstract event manually.
1163
//
1164
// Batching is necessary here in order to ensure that all event handlers run
1165
// before the next rerender (including event handlers attached to ancestor
1166
// elements instead of directly on the input). Without this, controlled
1167
// components don't work properly in conjunction with event bubbling because
1168
// the component is rerendered and the value reverted before all the event
1169
// handlers can run. See https://github.com/facebook/react/issues/708.
1170
ReactUpdates.batchedUpdates(runEventInBatch, event);
1171
}
1172
1173
function runEventInBatch(event) {
1174
EventPluginHub.enqueueEvents(event);
1175
EventPluginHub.processEventQueue();
1176
}
1177
1178
function startWatchingForChangeEventIE8(target, targetID) {
1179
activeElement = target;
1180
activeElementID = targetID;
1181
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
1182
}
1183
1184
function stopWatchingForChangeEventIE8() {
1185
if (!activeElement) {
1186
return;
1187
}
1188
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
1189
activeElement = null;
1190
activeElementID = null;
1191
}
1192
1193
function getTargetIDForChangeEvent(
1194
topLevelType,
1195
topLevelTarget,
1196
topLevelTargetID) {
1197
if (topLevelType === topLevelTypes.topChange) {
1198
return topLevelTargetID;
1199
}
1200
}
1201
function handleEventsForChangeEventIE8(
1202
topLevelType,
1203
topLevelTarget,
1204
topLevelTargetID) {
1205
if (topLevelType === topLevelTypes.topFocus) {
1206
// stopWatching() should be a noop here but we call it just in case we
1207
// missed a blur event somehow.
1208
stopWatchingForChangeEventIE8();
1209
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
1210
} else if (topLevelType === topLevelTypes.topBlur) {
1211
stopWatchingForChangeEventIE8();
1212
}
1213
}
1214
1215
1216
/**
1217
* SECTION: handle `input` event
1218
*/
1219
var isInputEventSupported = false;
1220
if (ExecutionEnvironment.canUseDOM) {
1221
// IE9 claims to support the input event but fails to trigger it when
1222
// deleting text, so we ignore its input events
1223
isInputEventSupported = isEventSupported('input') && (
1224
(!('documentMode' in document) || document.documentMode > 9)
1225
);
1226
}
1227
1228
/**
1229
* (For old IE.) Replacement getter/setter for the `value` property that gets
1230
* set on the active element.
1231
*/
1232
var newValueProp = {
1233
get: function() {
1234
return activeElementValueProp.get.call(this);
1235
},
1236
set: function(val) {
1237
// Cast to a string so we can do equality checks.
1238
activeElementValue = '' + val;
1239
activeElementValueProp.set.call(this, val);
1240
}
1241
};
1242
1243
/**
1244
* (For old IE.) Starts tracking propertychange events on the passed-in element
1245
* and override the value property so that we can distinguish user events from
1246
* value changes in JS.
1247
*/
1248
function startWatchingForValueChange(target, targetID) {
1249
activeElement = target;
1250
activeElementID = targetID;
1251
activeElementValue = target.value;
1252
activeElementValueProp = Object.getOwnPropertyDescriptor(
1253
target.constructor.prototype,
1254
'value'
1255
);
1256
1257
Object.defineProperty(activeElement, 'value', newValueProp);
1258
activeElement.attachEvent('onpropertychange', handlePropertyChange);
1259
}
1260
1261
/**
1262
* (For old IE.) Removes the event listeners from the currently-tracked element,
1263
* if any exists.
1264
*/
1265
function stopWatchingForValueChange() {
1266
if (!activeElement) {
1267
return;
1268
}
1269
1270
// delete restores the original property definition
1271
delete activeElement.value;
1272
activeElement.detachEvent('onpropertychange', handlePropertyChange);
1273
1274
activeElement = null;
1275
activeElementID = null;
1276
activeElementValue = null;
1277
activeElementValueProp = null;
1278
}
1279
1280
/**
1281
* (For old IE.) Handles a propertychange event, sending a `change` event if
1282
* the value of the active element has changed.
1283
*/
1284
function handlePropertyChange(nativeEvent) {
1285
if (nativeEvent.propertyName !== 'value') {
1286
return;
1287
}
1288
var value = nativeEvent.srcElement.value;
1289
if (value === activeElementValue) {
1290
return;
1291
}
1292
activeElementValue = value;
1293
1294
manualDispatchChangeEvent(nativeEvent);
1295
}
1296
1297
/**
1298
* If a `change` event should be fired, returns the target's ID.
1299
*/
1300
function getTargetIDForInputEvent(
1301
topLevelType,
1302
topLevelTarget,
1303
topLevelTargetID) {
1304
if (topLevelType === topLevelTypes.topInput) {
1305
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
1306
// what we want so fall through here and trigger an abstract event
1307
return topLevelTargetID;
1308
}
1309
}
1310
1311
// For IE8 and IE9.
1312
function handleEventsForInputEventIE(
1313
topLevelType,
1314
topLevelTarget,
1315
topLevelTargetID) {
1316
if (topLevelType === topLevelTypes.topFocus) {
1317
// In IE8, we can capture almost all .value changes by adding a
1318
// propertychange handler and looking for events with propertyName
1319
// equal to 'value'
1320
// In IE9, propertychange fires for most input events but is buggy and
1321
// doesn't fire when text is deleted, but conveniently, selectionchange
1322
// appears to fire in all of the remaining cases so we catch those and
1323
// forward the event if the value has changed
1324
// In either case, we don't want to call the event handler if the value
1325
// is changed from JS so we redefine a setter for `.value` that updates
1326
// our activeElementValue variable, allowing us to ignore those changes
1327
//
1328
// stopWatching() should be a noop here but we call it just in case we
1329
// missed a blur event somehow.
1330
stopWatchingForValueChange();
1331
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
1332
} else if (topLevelType === topLevelTypes.topBlur) {
1333
stopWatchingForValueChange();
1334
}
1335
}
1336
1337
// For IE8 and IE9.
1338
function getTargetIDForInputEventIE(
1339
topLevelType,
1340
topLevelTarget,
1341
topLevelTargetID) {
1342
if (topLevelType === topLevelTypes.topSelectionChange ||
1343
topLevelType === topLevelTypes.topKeyUp ||
1344
topLevelType === topLevelTypes.topKeyDown) {
1345
// On the selectionchange event, the target is just document which isn't
1346
// helpful for us so just check activeElement instead.
1347
//
1348
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
1349
// propertychange on the first input event after setting `value` from a
1350
// script and fires only keydown, keypress, keyup. Catching keyup usually
1351
// gets it and catching keydown lets us fire an event for the first
1352
// keystroke if user does a key repeat (it'll be a little delayed: right
1353
// before the second keystroke). Other input methods (e.g., paste) seem to
1354
// fire selectionchange normally.
1355
if (activeElement && activeElement.value !== activeElementValue) {
1356
activeElementValue = activeElement.value;
1357
return activeElementID;
1358
}
1359
}
1360
}
1361
1362
1363
/**
1364
* SECTION: handle `click` event
1365
*/
1366
function shouldUseClickEvent(elem) {
1367
// Use the `click` event to detect changes to checkbox and radio inputs.
1368
// This approach works across all browsers, whereas `change` does not fire
1369
// until `blur` in IE8.
1370
return (
1371
elem.nodeName === 'INPUT' &&
1372
(elem.type === 'checkbox' || elem.type === 'radio')
1373
);
1374
}
1375
1376
function getTargetIDForClickEvent(
1377
topLevelType,
1378
topLevelTarget,
1379
topLevelTargetID) {
1380
if (topLevelType === topLevelTypes.topClick) {
1381
return topLevelTargetID;
1382
}
1383
}
1384
1385
/**
1386
* This plugin creates an `onChange` event that normalizes change events
1387
* across form elements. This event fires at a time when it's possible to
1388
* change the element's value without seeing a flicker.
1389
*
1390
* Supported elements are:
1391
* - input (see `isTextInputElement`)
1392
* - textarea
1393
* - select
1394
*/
1395
var ChangeEventPlugin = {
1396
1397
eventTypes: eventTypes,
1398
1399
/**
1400
* @param {string} topLevelType Record from `EventConstants`.
1401
* @param {DOMEventTarget} topLevelTarget The listening component root node.
1402
* @param {string} topLevelTargetID ID of `topLevelTarget`.
1403
* @param {object} nativeEvent Native browser event.
1404
* @return {*} An accumulation of synthetic events.
1405
* @see {EventPluginHub.extractEvents}
1406
*/
1407
extractEvents: function(
1408
topLevelType,
1409
topLevelTarget,
1410
topLevelTargetID,
1411
nativeEvent) {
1412
1413
var getTargetIDFunc, handleEventFunc;
1414
if (shouldUseChangeEvent(topLevelTarget)) {
1415
if (doesChangeEventBubble) {
1416
getTargetIDFunc = getTargetIDForChangeEvent;
1417
} else {
1418
handleEventFunc = handleEventsForChangeEventIE8;
1419
}
1420
} else if (isTextInputElement(topLevelTarget)) {
1421
if (isInputEventSupported) {
1422
getTargetIDFunc = getTargetIDForInputEvent;
1423
} else {
1424
getTargetIDFunc = getTargetIDForInputEventIE;
1425
handleEventFunc = handleEventsForInputEventIE;
1426
}
1427
} else if (shouldUseClickEvent(topLevelTarget)) {
1428
getTargetIDFunc = getTargetIDForClickEvent;
1429
}
1430
1431
if (getTargetIDFunc) {
1432
var targetID = getTargetIDFunc(
1433
topLevelType,
1434
topLevelTarget,
1435
topLevelTargetID
1436
);
1437
if (targetID) {
1438
var event = SyntheticEvent.getPooled(
1439
eventTypes.change,
1440
targetID,
1441
nativeEvent
1442
);
1443
EventPropagators.accumulateTwoPhaseDispatches(event);
1444
return event;
1445
}
1446
}
1447
1448
if (handleEventFunc) {
1449
handleEventFunc(
1450
topLevelType,
1451
topLevelTarget,
1452
topLevelTargetID
1453
);
1454
}
1455
}
1456
1457
};
1458
1459
module.exports = ChangeEventPlugin;
1460
1461
},{"136":136,"138":138,"141":141,"15":15,"17":17,"20":20,"21":21,"87":87,"95":95}],8:[function(_dereq_,module,exports){
1462
/**
1463
* Copyright 2013-2015, Facebook, Inc.
1464
* All rights reserved.
1465
*
1466
* This source code is licensed under the BSD-style license found in the
1467
* LICENSE file in the root directory of this source tree. An additional grant
1468
* of patent rights can be found in the PATENTS file in the same directory.
1469
*
1470
* @providesModule ClientReactRootIndex
1471
* @typechecks
1472
*/
1473
1474
'use strict';
1475
1476
var nextReactRootIndex = 0;
1477
1478
var ClientReactRootIndex = {
1479
createReactRootIndex: function() {
1480
return nextReactRootIndex++;
1481
}
1482
};
1483
1484
module.exports = ClientReactRootIndex;
1485
1486
},{}],9:[function(_dereq_,module,exports){
1487
/**
1488
* Copyright 2013-2015, Facebook, Inc.
1489
* All rights reserved.
1490
*
1491
* This source code is licensed under the BSD-style license found in the
1492
* LICENSE file in the root directory of this source tree. An additional grant
1493
* of patent rights can be found in the PATENTS file in the same directory.
1494
*
1495
* @providesModule DOMChildrenOperations
1496
* @typechecks static-only
1497
*/
1498
1499
'use strict';
1500
1501
var Danger = _dereq_(12);
1502
var ReactMultiChildUpdateTypes = _dereq_(72);
1503
1504
var setTextContent = _dereq_(149);
1505
var invariant = _dereq_(135);
1506
1507
/**
1508
* Inserts `childNode` as a child of `parentNode` at the `index`.
1509
*
1510
* @param {DOMElement} parentNode Parent node in which to insert.
1511
* @param {DOMElement} childNode Child node to insert.
1512
* @param {number} index Index at which to insert the child.
1513
* @internal
1514
*/
1515
function insertChildAt(parentNode, childNode, index) {
1516
// By exploiting arrays returning `undefined` for an undefined index, we can
1517
// rely exclusively on `insertBefore(node, null)` instead of also using
1518
// `appendChild(node)`. However, using `undefined` is not allowed by all
1519
// browsers so we must replace it with `null`.
1520
parentNode.insertBefore(
1521
childNode,
1522
parentNode.childNodes[index] || null
1523
);
1524
}
1525
1526
/**
1527
* Operations for updating with DOM children.
1528
*/
1529
var DOMChildrenOperations = {
1530
1531
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
1532
1533
updateTextContent: setTextContent,
1534
1535
/**
1536
* Updates a component's children by processing a series of updates. The
1537
* update configurations are each expected to have a `parentNode` property.
1538
*
1539
* @param {array<object>} updates List of update configurations.
1540
* @param {array<string>} markupList List of markup strings.
1541
* @internal
1542
*/
1543
processUpdates: function(updates, markupList) {
1544
var update;
1545
// Mapping from parent IDs to initial child orderings.
1546
var initialChildren = null;
1547
// List of children that will be moved or removed.
1548
var updatedChildren = null;
1549
1550
for (var i = 0; i < updates.length; i++) {
1551
update = updates[i];
1552
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
1553
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
1554
var updatedIndex = update.fromIndex;
1555
var updatedChild = update.parentNode.childNodes[updatedIndex];
1556
var parentID = update.parentID;
1557
1558
("production" !== "development" ? invariant(
1559
updatedChild,
1560
'processUpdates(): Unable to find child %s of element. This ' +
1561
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
1562
'browser), usually due to forgetting a <tbody> when using tables, ' +
1563
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
1564
'in an <svg> parent. Try inspecting the child nodes of the element ' +
1565
'with React ID `%s`.',
1566
updatedIndex,
1567
parentID
1568
) : invariant(updatedChild));
1569
1570
initialChildren = initialChildren || {};
1571
initialChildren[parentID] = initialChildren[parentID] || [];
1572
initialChildren[parentID][updatedIndex] = updatedChild;
1573
1574
updatedChildren = updatedChildren || [];
1575
updatedChildren.push(updatedChild);
1576
}
1577
}
1578
1579
var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
1580
1581
// Remove updated children first so that `toIndex` is consistent.
1582
if (updatedChildren) {
1583
for (var j = 0; j < updatedChildren.length; j++) {
1584
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
1585
}
1586
}
1587
1588
for (var k = 0; k < updates.length; k++) {
1589
update = updates[k];
1590
switch (update.type) {
1591
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
1592
insertChildAt(
1593
update.parentNode,
1594
renderedMarkup[update.markupIndex],
1595
update.toIndex
1596
);
1597
break;
1598
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
1599
insertChildAt(
1600
update.parentNode,
1601
initialChildren[update.parentID][update.fromIndex],
1602
update.toIndex
1603
);
1604
break;
1605
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
1606
setTextContent(
1607
update.parentNode,
1608
update.textContent
1609
);
1610
break;
1611
case ReactMultiChildUpdateTypes.REMOVE_NODE:
1612
// Already removed by the for-loop above.
1613
break;
1614
}
1615
}
1616
}
1617
1618
};
1619
1620
module.exports = DOMChildrenOperations;
1621
1622
},{"12":12,"135":135,"149":149,"72":72}],10:[function(_dereq_,module,exports){
1623
/**
1624
* Copyright 2013-2015, Facebook, Inc.
1625
* All rights reserved.
1626
*
1627
* This source code is licensed under the BSD-style license found in the
1628
* LICENSE file in the root directory of this source tree. An additional grant
1629
* of patent rights can be found in the PATENTS file in the same directory.
1630
*
1631
* @providesModule DOMProperty
1632
* @typechecks static-only
1633
*/
1634
1635
/*jslint bitwise: true */
1636
1637
'use strict';
1638
1639
var invariant = _dereq_(135);
1640
1641
function checkMask(value, bitmask) {
1642
return (value & bitmask) === bitmask;
1643
}
1644
1645
var DOMPropertyInjection = {
1646
/**
1647
* Mapping from normalized, camelcased property names to a configuration that
1648
* specifies how the associated DOM property should be accessed or rendered.
1649
*/
1650
MUST_USE_ATTRIBUTE: 0x1,
1651
MUST_USE_PROPERTY: 0x2,
1652
HAS_SIDE_EFFECTS: 0x4,
1653
HAS_BOOLEAN_VALUE: 0x8,
1654
HAS_NUMERIC_VALUE: 0x10,
1655
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
1656
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
1657
1658
/**
1659
* Inject some specialized knowledge about the DOM. This takes a config object
1660
* with the following properties:
1661
*
1662
* isCustomAttribute: function that given an attribute name will return true
1663
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
1664
* attributes where it's impossible to enumerate all of the possible
1665
* attribute names,
1666
*
1667
* Properties: object mapping DOM property name to one of the
1668
* DOMPropertyInjection constants or null. If your attribute isn't in here,
1669
* it won't get written to the DOM.
1670
*
1671
* DOMAttributeNames: object mapping React attribute name to the DOM
1672
* attribute name. Attribute names not specified use the **lowercase**
1673
* normalized name.
1674
*
1675
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
1676
* Property names not specified use the normalized name.
1677
*
1678
* DOMMutationMethods: Properties that require special mutation methods. If
1679
* `value` is undefined, the mutation method should unset the property.
1680
*
1681
* @param {object} domPropertyConfig the config as described above.
1682
*/
1683
injectDOMPropertyConfig: function(domPropertyConfig) {
1684
var Properties = domPropertyConfig.Properties || {};
1685
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
1686
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
1687
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
1688
1689
if (domPropertyConfig.isCustomAttribute) {
1690
DOMProperty._isCustomAttributeFunctions.push(
1691
domPropertyConfig.isCustomAttribute
1692
);
1693
}
1694
1695
for (var propName in Properties) {
1696
("production" !== "development" ? invariant(
1697
!DOMProperty.isStandardName.hasOwnProperty(propName),
1698
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
1699
'\'%s\' which has already been injected. You may be accidentally ' +
1700
'injecting the same DOM property config twice, or you may be ' +
1701
'injecting two configs that have conflicting property names.',
1702
propName
1703
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
1704
1705
DOMProperty.isStandardName[propName] = true;
1706
1707
var lowerCased = propName.toLowerCase();
1708
DOMProperty.getPossibleStandardName[lowerCased] = propName;
1709
1710
if (DOMAttributeNames.hasOwnProperty(propName)) {
1711
var attributeName = DOMAttributeNames[propName];
1712
DOMProperty.getPossibleStandardName[attributeName] = propName;
1713
DOMProperty.getAttributeName[propName] = attributeName;
1714
} else {
1715
DOMProperty.getAttributeName[propName] = lowerCased;
1716
}
1717
1718
DOMProperty.getPropertyName[propName] =
1719
DOMPropertyNames.hasOwnProperty(propName) ?
1720
DOMPropertyNames[propName] :
1721
propName;
1722
1723
if (DOMMutationMethods.hasOwnProperty(propName)) {
1724
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
1725
} else {
1726
DOMProperty.getMutationMethod[propName] = null;
1727
}
1728
1729
var propConfig = Properties[propName];
1730
DOMProperty.mustUseAttribute[propName] =
1731
checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
1732
DOMProperty.mustUseProperty[propName] =
1733
checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
1734
DOMProperty.hasSideEffects[propName] =
1735
checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
1736
DOMProperty.hasBooleanValue[propName] =
1737
checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
1738
DOMProperty.hasNumericValue[propName] =
1739
checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
1740
DOMProperty.hasPositiveNumericValue[propName] =
1741
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
1742
DOMProperty.hasOverloadedBooleanValue[propName] =
1743
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
1744
1745
("production" !== "development" ? invariant(
1746
!DOMProperty.mustUseAttribute[propName] ||
1747
!DOMProperty.mustUseProperty[propName],
1748
'DOMProperty: Cannot require using both attribute and property: %s',
1749
propName
1750
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
1751
!DOMProperty.mustUseProperty[propName]));
1752
("production" !== "development" ? invariant(
1753
DOMProperty.mustUseProperty[propName] ||
1754
!DOMProperty.hasSideEffects[propName],
1755
'DOMProperty: Properties that have side effects must use property: %s',
1756
propName
1757
) : invariant(DOMProperty.mustUseProperty[propName] ||
1758
!DOMProperty.hasSideEffects[propName]));
1759
("production" !== "development" ? invariant(
1760
!!DOMProperty.hasBooleanValue[propName] +
1761
!!DOMProperty.hasNumericValue[propName] +
1762
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
1763
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
1764
'numeric value, but not a combination: %s',
1765
propName
1766
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
1767
!!DOMProperty.hasNumericValue[propName] +
1768
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
1769
}
1770
}
1771
};
1772
var defaultValueCache = {};
1773
1774
/**
1775
* DOMProperty exports lookup objects that can be used like functions:
1776
*
1777
* > DOMProperty.isValid['id']
1778
* true
1779
* > DOMProperty.isValid['foobar']
1780
* undefined
1781
*
1782
* Although this may be confusing, it performs better in general.
1783
*
1784
* @see http://jsperf.com/key-exists
1785
* @see http://jsperf.com/key-missing
1786
*/
1787
var DOMProperty = {
1788
1789
ID_ATTRIBUTE_NAME: 'data-reactid',
1790
1791
/**
1792
* Checks whether a property name is a standard property.
1793
* @type {Object}
1794
*/
1795
isStandardName: {},
1796
1797
/**
1798
* Mapping from lowercase property names to the properly cased version, used
1799
* to warn in the case of missing properties.
1800
* @type {Object}
1801
*/
1802
getPossibleStandardName: {},
1803
1804
/**
1805
* Mapping from normalized names to attribute names that differ. Attribute
1806
* names are used when rendering markup or with `*Attribute()`.
1807
* @type {Object}
1808
*/
1809
getAttributeName: {},
1810
1811
/**
1812
* Mapping from normalized names to properties on DOM node instances.
1813
* (This includes properties that mutate due to external factors.)
1814
* @type {Object}
1815
*/
1816
getPropertyName: {},
1817
1818
/**
1819
* Mapping from normalized names to mutation methods. This will only exist if
1820
* mutation cannot be set simply by the property or `setAttribute()`.
1821
* @type {Object}
1822
*/
1823
getMutationMethod: {},
1824
1825
/**
1826
* Whether the property must be accessed and mutated as an object property.
1827
* @type {Object}
1828
*/
1829
mustUseAttribute: {},
1830
1831
/**
1832
* Whether the property must be accessed and mutated using `*Attribute()`.
1833
* (This includes anything that fails `<propName> in <element>`.)
1834
* @type {Object}
1835
*/
1836
mustUseProperty: {},
1837
1838
/**
1839
* Whether or not setting a value causes side effects such as triggering
1840
* resources to be loaded or text selection changes. We must ensure that
1841
* the value is only set if it has changed.
1842
* @type {Object}
1843
*/
1844
hasSideEffects: {},
1845
1846
/**
1847
* Whether the property should be removed when set to a falsey value.
1848
* @type {Object}
1849
*/
1850
hasBooleanValue: {},
1851
1852
/**
1853
* Whether the property must be numeric or parse as a
1854
* numeric and should be removed when set to a falsey value.
1855
* @type {Object}
1856
*/
1857
hasNumericValue: {},
1858
1859
/**
1860
* Whether the property must be positive numeric or parse as a positive
1861
* numeric and should be removed when set to a falsey value.
1862
* @type {Object}
1863
*/
1864
hasPositiveNumericValue: {},
1865
1866
/**
1867
* Whether the property can be used as a flag as well as with a value. Removed
1868
* when strictly equal to false; present without a value when strictly equal
1869
* to true; present with a value otherwise.
1870
* @type {Object}
1871
*/
1872
hasOverloadedBooleanValue: {},
1873
1874
/**
1875
* All of the isCustomAttribute() functions that have been injected.
1876
*/
1877
_isCustomAttributeFunctions: [],
1878
1879
/**
1880
* Checks whether a property name is a custom attribute.
1881
* @method
1882
*/
1883
isCustomAttribute: function(attributeName) {
1884
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
1885
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
1886
if (isCustomAttributeFn(attributeName)) {
1887
return true;
1888
}
1889
}
1890
return false;
1891
},
1892
1893
/**
1894
* Returns the default property value for a DOM property (i.e., not an
1895
* attribute). Most default values are '' or false, but not all. Worse yet,
1896
* some (in particular, `type`) vary depending on the type of element.
1897
*
1898
* TODO: Is it better to grab all the possible properties when creating an
1899
* element to avoid having to create the same element twice?
1900
*/
1901
getDefaultValueForProperty: function(nodeName, prop) {
1902
var nodeDefaults = defaultValueCache[nodeName];
1903
var testElement;
1904
if (!nodeDefaults) {
1905
defaultValueCache[nodeName] = nodeDefaults = {};
1906
}
1907
if (!(prop in nodeDefaults)) {
1908
testElement = document.createElement(nodeName);
1909
nodeDefaults[prop] = testElement[prop];
1910
}
1911
return nodeDefaults[prop];
1912
},
1913
1914
injection: DOMPropertyInjection
1915
};
1916
1917
module.exports = DOMProperty;
1918
1919
},{"135":135}],11:[function(_dereq_,module,exports){
1920
/**
1921
* Copyright 2013-2015, Facebook, Inc.
1922
* All rights reserved.
1923
*
1924
* This source code is licensed under the BSD-style license found in the
1925
* LICENSE file in the root directory of this source tree. An additional grant
1926
* of patent rights can be found in the PATENTS file in the same directory.
1927
*
1928
* @providesModule DOMPropertyOperations
1929
* @typechecks static-only
1930
*/
1931
1932
'use strict';
1933
1934
var DOMProperty = _dereq_(10);
1935
1936
var quoteAttributeValueForBrowser = _dereq_(147);
1937
var warning = _dereq_(154);
1938
1939
function shouldIgnoreValue(name, value) {
1940
return value == null ||
1941
(DOMProperty.hasBooleanValue[name] && !value) ||
1942
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
1943
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
1944
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
1945
}
1946
1947
if ("production" !== "development") {
1948
var reactProps = {
1949
children: true,
1950
dangerouslySetInnerHTML: true,
1951
key: true,
1952
ref: true
1953
};
1954
var warnedProperties = {};
1955
1956
var warnUnknownProperty = function(name) {
1957
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
1958
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
1959
return;
1960
}
1961
1962
warnedProperties[name] = true;
1963
var lowerCasedName = name.toLowerCase();
1964
1965
// data-* attributes should be lowercase; suggest the lowercase version
1966
var standardName = (
1967
DOMProperty.isCustomAttribute(lowerCasedName) ?
1968
lowerCasedName :
1969
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
1970
DOMProperty.getPossibleStandardName[lowerCasedName] :
1971
null
1972
);
1973
1974
// For now, only warn when we have a suggested correction. This prevents
1975
// logging too much when using transferPropsTo.
1976
("production" !== "development" ? warning(
1977
standardName == null,
1978
'Unknown DOM property %s. Did you mean %s?',
1979
name,
1980
standardName
1981
) : null);
1982
1983
};
1984
}
1985
1986
/**
1987
* Operations for dealing with DOM properties.
1988
*/
1989
var DOMPropertyOperations = {
1990
1991
/**
1992
* Creates markup for the ID property.
1993
*
1994
* @param {string} id Unescaped ID.
1995
* @return {string} Markup string.
1996
*/
1997
createMarkupForID: function(id) {
1998
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
1999
quoteAttributeValueForBrowser(id);
2000
},
2001
2002
/**
2003
* Creates markup for a property.
2004
*
2005
* @param {string} name
2006
* @param {*} value
2007
* @return {?string} Markup string, or null if the property was invalid.
2008
*/
2009
createMarkupForProperty: function(name, value) {
2010
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2011
DOMProperty.isStandardName[name]) {
2012
if (shouldIgnoreValue(name, value)) {
2013
return '';
2014
}
2015
var attributeName = DOMProperty.getAttributeName[name];
2016
if (DOMProperty.hasBooleanValue[name] ||
2017
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
2018
return attributeName;
2019
}
2020
return attributeName + '=' + quoteAttributeValueForBrowser(value);
2021
} else if (DOMProperty.isCustomAttribute(name)) {
2022
if (value == null) {
2023
return '';
2024
}
2025
return name + '=' + quoteAttributeValueForBrowser(value);
2026
} else if ("production" !== "development") {
2027
warnUnknownProperty(name);
2028
}
2029
return null;
2030
},
2031
2032
/**
2033
* Sets the value for a property on a node.
2034
*
2035
* @param {DOMElement} node
2036
* @param {string} name
2037
* @param {*} value
2038
*/
2039
setValueForProperty: function(node, name, value) {
2040
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2041
DOMProperty.isStandardName[name]) {
2042
var mutationMethod = DOMProperty.getMutationMethod[name];
2043
if (mutationMethod) {
2044
mutationMethod(node, value);
2045
} else if (shouldIgnoreValue(name, value)) {
2046
this.deleteValueForProperty(node, name);
2047
} else if (DOMProperty.mustUseAttribute[name]) {
2048
// `setAttribute` with objects becomes only `[object]` in IE8/9,
2049
// ('' + value) makes it output the correct toString()-value.
2050
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
2051
} else {
2052
var propName = DOMProperty.getPropertyName[name];
2053
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
2054
// property type before comparing; only `value` does and is string.
2055
if (!DOMProperty.hasSideEffects[name] ||
2056
('' + node[propName]) !== ('' + value)) {
2057
// Contrary to `setAttribute`, object properties are properly
2058
// `toString`ed by IE8/9.
2059
node[propName] = value;
2060
}
2061
}
2062
} else if (DOMProperty.isCustomAttribute(name)) {
2063
if (value == null) {
2064
node.removeAttribute(name);
2065
} else {
2066
node.setAttribute(name, '' + value);
2067
}
2068
} else if ("production" !== "development") {
2069
warnUnknownProperty(name);
2070
}
2071
},
2072
2073
/**
2074
* Deletes the value for a property on a node.
2075
*
2076
* @param {DOMElement} node
2077
* @param {string} name
2078
*/
2079
deleteValueForProperty: function(node, name) {
2080
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2081
DOMProperty.isStandardName[name]) {
2082
var mutationMethod = DOMProperty.getMutationMethod[name];
2083
if (mutationMethod) {
2084
mutationMethod(node, undefined);
2085
} else if (DOMProperty.mustUseAttribute[name]) {
2086
node.removeAttribute(DOMProperty.getAttributeName[name]);
2087
} else {
2088
var propName = DOMProperty.getPropertyName[name];
2089
var defaultValue = DOMProperty.getDefaultValueForProperty(
2090
node.nodeName,
2091
propName
2092
);
2093
if (!DOMProperty.hasSideEffects[name] ||
2094
('' + node[propName]) !== defaultValue) {
2095
node[propName] = defaultValue;
2096
}
2097
}
2098
} else if (DOMProperty.isCustomAttribute(name)) {
2099
node.removeAttribute(name);
2100
} else if ("production" !== "development") {
2101
warnUnknownProperty(name);
2102
}
2103
}
2104
2105
};
2106
2107
module.exports = DOMPropertyOperations;
2108
2109
},{"10":10,"147":147,"154":154}],12:[function(_dereq_,module,exports){
2110
/**
2111
* Copyright 2013-2015, Facebook, Inc.
2112
* All rights reserved.
2113
*
2114
* This source code is licensed under the BSD-style license found in the
2115
* LICENSE file in the root directory of this source tree. An additional grant
2116
* of patent rights can be found in the PATENTS file in the same directory.
2117
*
2118
* @providesModule Danger
2119
* @typechecks static-only
2120
*/
2121
2122
/*jslint evil: true, sub: true */
2123
2124
'use strict';
2125
2126
var ExecutionEnvironment = _dereq_(21);
2127
2128
var createNodesFromMarkup = _dereq_(112);
2129
var emptyFunction = _dereq_(114);
2130
var getMarkupWrap = _dereq_(127);
2131
var invariant = _dereq_(135);
2132
2133
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
2134
var RESULT_INDEX_ATTR = 'data-danger-index';
2135
2136
/**
2137
* Extracts the `nodeName` from a string of markup.
2138
*
2139
* NOTE: Extracting the `nodeName` does not require a regular expression match
2140
* because we make assumptions about React-generated markup (i.e. there are no
2141
* spaces surrounding the opening tag and there is at least one attribute).
2142
*
2143
* @param {string} markup String of markup.
2144
* @return {string} Node name of the supplied markup.
2145
* @see http://jsperf.com/extract-nodename
2146
*/
2147
function getNodeName(markup) {
2148
return markup.substring(1, markup.indexOf(' '));
2149
}
2150
2151
var Danger = {
2152
2153
/**
2154
* Renders markup into an array of nodes. The markup is expected to render
2155
* into a list of root nodes. Also, the length of `resultList` and
2156
* `markupList` should be the same.
2157
*
2158
* @param {array<string>} markupList List of markup strings to render.
2159
* @return {array<DOMElement>} List of rendered nodes.
2160
* @internal
2161
*/
2162
dangerouslyRenderMarkup: function(markupList) {
2163
("production" !== "development" ? invariant(
2164
ExecutionEnvironment.canUseDOM,
2165
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
2166
'thread. Make sure `window` and `document` are available globally ' +
2167
'before requiring React when unit testing or use ' +
2168
'React.renderToString for server rendering.'
2169
) : invariant(ExecutionEnvironment.canUseDOM));
2170
var nodeName;
2171
var markupByNodeName = {};
2172
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
2173
for (var i = 0; i < markupList.length; i++) {
2174
("production" !== "development" ? invariant(
2175
markupList[i],
2176
'dangerouslyRenderMarkup(...): Missing markup.'
2177
) : invariant(markupList[i]));
2178
nodeName = getNodeName(markupList[i]);
2179
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
2180
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
2181
markupByNodeName[nodeName][i] = markupList[i];
2182
}
2183
var resultList = [];
2184
var resultListAssignmentCount = 0;
2185
for (nodeName in markupByNodeName) {
2186
if (!markupByNodeName.hasOwnProperty(nodeName)) {
2187
continue;
2188
}
2189
var markupListByNodeName = markupByNodeName[nodeName];
2190
2191
// This for-in loop skips the holes of the sparse array. The order of
2192
// iteration should follow the order of assignment, which happens to match
2193
// numerical index order, but we don't rely on that.
2194
var resultIndex;
2195
for (resultIndex in markupListByNodeName) {
2196
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
2197
var markup = markupListByNodeName[resultIndex];
2198
2199
// Push the requested markup with an additional RESULT_INDEX_ATTR
2200
// attribute. If the markup does not start with a < character, it
2201
// will be discarded below (with an appropriate console.error).
2202
markupListByNodeName[resultIndex] = markup.replace(
2203
OPEN_TAG_NAME_EXP,
2204
// This index will be parsed back out below.
2205
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
2206
);
2207
}
2208
}
2209
2210
// Render each group of markup with similar wrapping `nodeName`.
2211
var renderNodes = createNodesFromMarkup(
2212
markupListByNodeName.join(''),
2213
emptyFunction // Do nothing special with <script> tags.
2214
);
2215
2216
for (var j = 0; j < renderNodes.length; ++j) {
2217
var renderNode = renderNodes[j];
2218
if (renderNode.hasAttribute &&
2219
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
2220
2221
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
2222
renderNode.removeAttribute(RESULT_INDEX_ATTR);
2223
2224
("production" !== "development" ? invariant(
2225
!resultList.hasOwnProperty(resultIndex),
2226
'Danger: Assigning to an already-occupied result index.'
2227
) : invariant(!resultList.hasOwnProperty(resultIndex)));
2228
2229
resultList[resultIndex] = renderNode;
2230
2231
// This should match resultList.length and markupList.length when
2232
// we're done.
2233
resultListAssignmentCount += 1;
2234
2235
} else if ("production" !== "development") {
2236
console.error(
2237
'Danger: Discarding unexpected node:',
2238
renderNode
2239
);
2240
}
2241
}
2242
}
2243
2244
// Although resultList was populated out of order, it should now be a dense
2245
// array.
2246
("production" !== "development" ? invariant(
2247
resultListAssignmentCount === resultList.length,
2248
'Danger: Did not assign to every index of resultList.'
2249
) : invariant(resultListAssignmentCount === resultList.length));
2250
2251
("production" !== "development" ? invariant(
2252
resultList.length === markupList.length,
2253
'Danger: Expected markup to render %s nodes, but rendered %s.',
2254
markupList.length,
2255
resultList.length
2256
) : invariant(resultList.length === markupList.length));
2257
2258
return resultList;
2259
},
2260
2261
/**
2262
* Replaces a node with a string of markup at its current position within its
2263
* parent. The markup must render into a single root node.
2264
*
2265
* @param {DOMElement} oldChild Child node to replace.
2266
* @param {string} markup Markup to render in place of the child node.
2267
* @internal
2268
*/
2269
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
2270
("production" !== "development" ? invariant(
2271
ExecutionEnvironment.canUseDOM,
2272
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
2273
'worker thread. Make sure `window` and `document` are available ' +
2274
'globally before requiring React when unit testing or use ' +
2275
'React.renderToString for server rendering.'
2276
) : invariant(ExecutionEnvironment.canUseDOM));
2277
("production" !== "development" ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
2278
("production" !== "development" ? invariant(
2279
oldChild.tagName.toLowerCase() !== 'html',
2280
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
2281
'<html> node. This is because browser quirks make this unreliable ' +
2282
'and/or slow. If you want to render to the root you must use ' +
2283
'server rendering. See React.renderToString().'
2284
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
2285
2286
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
2287
oldChild.parentNode.replaceChild(newChild, oldChild);
2288
}
2289
2290
};
2291
2292
module.exports = Danger;
2293
2294
},{"112":112,"114":114,"127":127,"135":135,"21":21}],13:[function(_dereq_,module,exports){
2295
/**
2296
* Copyright 2013-2015, Facebook, Inc.
2297
* All rights reserved.
2298
*
2299
* This source code is licensed under the BSD-style license found in the
2300
* LICENSE file in the root directory of this source tree. An additional grant
2301
* of patent rights can be found in the PATENTS file in the same directory.
2302
*
2303
* @providesModule DefaultEventPluginOrder
2304
*/
2305
2306
'use strict';
2307
2308
var keyOf = _dereq_(141);
2309
2310
/**
2311
* Module that is injectable into `EventPluginHub`, that specifies a
2312
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
2313
* plugins, without having to package every one of them. This is better than
2314
* having plugins be ordered in the same order that they are injected because
2315
* that ordering would be influenced by the packaging order.
2316
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
2317
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
2318
*/
2319
var DefaultEventPluginOrder = [
2320
keyOf({ResponderEventPlugin: null}),
2321
keyOf({SimpleEventPlugin: null}),
2322
keyOf({TapEventPlugin: null}),
2323
keyOf({EnterLeaveEventPlugin: null}),
2324
keyOf({ChangeEventPlugin: null}),
2325
keyOf({SelectEventPlugin: null}),
2326
keyOf({BeforeInputEventPlugin: null}),
2327
keyOf({AnalyticsEventPlugin: null}),
2328
keyOf({MobileSafariClickEventPlugin: null})
2329
];
2330
2331
module.exports = DefaultEventPluginOrder;
2332
2333
},{"141":141}],14:[function(_dereq_,module,exports){
2334
/**
2335
* Copyright 2013-2015, Facebook, Inc.
2336
* All rights reserved.
2337
*
2338
* This source code is licensed under the BSD-style license found in the
2339
* LICENSE file in the root directory of this source tree. An additional grant
2340
* of patent rights can be found in the PATENTS file in the same directory.
2341
*
2342
* @providesModule EnterLeaveEventPlugin
2343
* @typechecks static-only
2344
*/
2345
2346
'use strict';
2347
2348
var EventConstants = _dereq_(15);
2349
var EventPropagators = _dereq_(20);
2350
var SyntheticMouseEvent = _dereq_(99);
2351
2352
var ReactMount = _dereq_(70);
2353
var keyOf = _dereq_(141);
2354
2355
var topLevelTypes = EventConstants.topLevelTypes;
2356
var getFirstReactDOM = ReactMount.getFirstReactDOM;
2357
2358
var eventTypes = {
2359
mouseEnter: {
2360
registrationName: keyOf({onMouseEnter: null}),
2361
dependencies: [
2362
topLevelTypes.topMouseOut,
2363
topLevelTypes.topMouseOver
2364
]
2365
},
2366
mouseLeave: {
2367
registrationName: keyOf({onMouseLeave: null}),
2368
dependencies: [
2369
topLevelTypes.topMouseOut,
2370
topLevelTypes.topMouseOver
2371
]
2372
}
2373
};
2374
2375
var extractedEvents = [null, null];
2376
2377
var EnterLeaveEventPlugin = {
2378
2379
eventTypes: eventTypes,
2380
2381
/**
2382
* For almost every interaction we care about, there will be both a top-level
2383
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
2384
* we do not extract duplicate events. However, moving the mouse into the
2385
* browser from outside will not fire a `mouseout` event. In this case, we use
2386
* the `mouseover` top-level event.
2387
*
2388
* @param {string} topLevelType Record from `EventConstants`.
2389
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2390
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2391
* @param {object} nativeEvent Native browser event.
2392
* @return {*} An accumulation of synthetic events.
2393
* @see {EventPluginHub.extractEvents}
2394
*/
2395
extractEvents: function(
2396
topLevelType,
2397
topLevelTarget,
2398
topLevelTargetID,
2399
nativeEvent) {
2400
if (topLevelType === topLevelTypes.topMouseOver &&
2401
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
2402
return null;
2403
}
2404
if (topLevelType !== topLevelTypes.topMouseOut &&
2405
topLevelType !== topLevelTypes.topMouseOver) {
2406
// Must not be a mouse in or mouse out - ignoring.
2407
return null;
2408
}
2409
2410
var win;
2411
if (topLevelTarget.window === topLevelTarget) {
2412
// `topLevelTarget` is probably a window object.
2413
win = topLevelTarget;
2414
} else {
2415
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
2416
var doc = topLevelTarget.ownerDocument;
2417
if (doc) {
2418
win = doc.defaultView || doc.parentWindow;
2419
} else {
2420
win = window;
2421
}
2422
}
2423
2424
var from, to;
2425
if (topLevelType === topLevelTypes.topMouseOut) {
2426
from = topLevelTarget;
2427
to =
2428
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
2429
win;
2430
} else {
2431
from = win;
2432
to = topLevelTarget;
2433
}
2434
2435
if (from === to) {
2436
// Nothing pertains to our managed components.
2437
return null;
2438
}
2439
2440
var fromID = from ? ReactMount.getID(from) : '';
2441
var toID = to ? ReactMount.getID(to) : '';
2442
2443
var leave = SyntheticMouseEvent.getPooled(
2444
eventTypes.mouseLeave,
2445
fromID,
2446
nativeEvent
2447
);
2448
leave.type = 'mouseleave';
2449
leave.target = from;
2450
leave.relatedTarget = to;
2451
2452
var enter = SyntheticMouseEvent.getPooled(
2453
eventTypes.mouseEnter,
2454
toID,
2455
nativeEvent
2456
);
2457
enter.type = 'mouseenter';
2458
enter.target = to;
2459
enter.relatedTarget = from;
2460
2461
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
2462
2463
extractedEvents[0] = leave;
2464
extractedEvents[1] = enter;
2465
2466
return extractedEvents;
2467
}
2468
2469
};
2470
2471
module.exports = EnterLeaveEventPlugin;
2472
2473
},{"141":141,"15":15,"20":20,"70":70,"99":99}],15:[function(_dereq_,module,exports){
2474
/**
2475
* Copyright 2013-2015, Facebook, Inc.
2476
* All rights reserved.
2477
*
2478
* This source code is licensed under the BSD-style license found in the
2479
* LICENSE file in the root directory of this source tree. An additional grant
2480
* of patent rights can be found in the PATENTS file in the same directory.
2481
*
2482
* @providesModule EventConstants
2483
*/
2484
2485
'use strict';
2486
2487
var keyMirror = _dereq_(140);
2488
2489
var PropagationPhases = keyMirror({bubbled: null, captured: null});
2490
2491
/**
2492
* Types of raw signals from the browser caught at the top level.
2493
*/
2494
var topLevelTypes = keyMirror({
2495
topBlur: null,
2496
topChange: null,
2497
topClick: null,
2498
topCompositionEnd: null,
2499
topCompositionStart: null,
2500
topCompositionUpdate: null,
2501
topContextMenu: null,
2502
topCopy: null,
2503
topCut: null,
2504
topDoubleClick: null,
2505
topDrag: null,
2506
topDragEnd: null,
2507
topDragEnter: null,
2508
topDragExit: null,
2509
topDragLeave: null,
2510
topDragOver: null,
2511
topDragStart: null,
2512
topDrop: null,
2513
topError: null,
2514
topFocus: null,
2515
topInput: null,
2516
topKeyDown: null,
2517
topKeyPress: null,
2518
topKeyUp: null,
2519
topLoad: null,
2520
topMouseDown: null,
2521
topMouseMove: null,
2522
topMouseOut: null,
2523
topMouseOver: null,
2524
topMouseUp: null,
2525
topPaste: null,
2526
topReset: null,
2527
topScroll: null,
2528
topSelectionChange: null,
2529
topSubmit: null,
2530
topTextInput: null,
2531
topTouchCancel: null,
2532
topTouchEnd: null,
2533
topTouchMove: null,
2534
topTouchStart: null,
2535
topWheel: null
2536
});
2537
2538
var EventConstants = {
2539
topLevelTypes: topLevelTypes,
2540
PropagationPhases: PropagationPhases
2541
};
2542
2543
module.exports = EventConstants;
2544
2545
},{"140":140}],16:[function(_dereq_,module,exports){
2546
/**
2547
* Copyright 2013-2015, Facebook, Inc.
2548
*
2549
* Licensed under the Apache License, Version 2.0 (the "License");
2550
* you may not use this file except in compliance with the License.
2551
* You may obtain a copy of the License at
2552
*
2553
* http://www.apache.org/licenses/LICENSE-2.0
2554
*
2555
* Unless required by applicable law or agreed to in writing, software
2556
* distributed under the License is distributed on an "AS IS" BASIS,
2557
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2558
* See the License for the specific language governing permissions and
2559
* limitations under the License.
2560
*
2561
* @providesModule EventListener
2562
* @typechecks
2563
*/
2564
2565
var emptyFunction = _dereq_(114);
2566
2567
/**
2568
* Upstream version of event listener. Does not take into account specific
2569
* nature of platform.
2570
*/
2571
var EventListener = {
2572
/**
2573
* Listen to DOM events during the bubble phase.
2574
*
2575
* @param {DOMEventTarget} target DOM element to register listener on.
2576
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2577
* @param {function} callback Callback function.
2578
* @return {object} Object with a `remove` method.
2579
*/
2580
listen: function(target, eventType, callback) {
2581
if (target.addEventListener) {
2582
target.addEventListener(eventType, callback, false);
2583
return {
2584
remove: function() {
2585
target.removeEventListener(eventType, callback, false);
2586
}
2587
};
2588
} else if (target.attachEvent) {
2589
target.attachEvent('on' + eventType, callback);
2590
return {
2591
remove: function() {
2592
target.detachEvent('on' + eventType, callback);
2593
}
2594
};
2595
}
2596
},
2597
2598
/**
2599
* Listen to DOM events during the capture phase.
2600
*
2601
* @param {DOMEventTarget} target DOM element to register listener on.
2602
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2603
* @param {function} callback Callback function.
2604
* @return {object} Object with a `remove` method.
2605
*/
2606
capture: function(target, eventType, callback) {
2607
if (!target.addEventListener) {
2608
if ("production" !== "development") {
2609
console.error(
2610
'Attempted to listen to events during the capture phase on a ' +
2611
'browser that does not support the capture phase. Your application ' +
2612
'will not receive some events.'
2613
);
2614
}
2615
return {
2616
remove: emptyFunction
2617
};
2618
} else {
2619
target.addEventListener(eventType, callback, true);
2620
return {
2621
remove: function() {
2622
target.removeEventListener(eventType, callback, true);
2623
}
2624
};
2625
}
2626
},
2627
2628
registerDefault: function() {}
2629
};
2630
2631
module.exports = EventListener;
2632
2633
},{"114":114}],17:[function(_dereq_,module,exports){
2634
/**
2635
* Copyright 2013-2015, Facebook, Inc.
2636
* All rights reserved.
2637
*
2638
* This source code is licensed under the BSD-style license found in the
2639
* LICENSE file in the root directory of this source tree. An additional grant
2640
* of patent rights can be found in the PATENTS file in the same directory.
2641
*
2642
* @providesModule EventPluginHub
2643
*/
2644
2645
'use strict';
2646
2647
var EventPluginRegistry = _dereq_(18);
2648
var EventPluginUtils = _dereq_(19);
2649
2650
var accumulateInto = _dereq_(105);
2651
var forEachAccumulated = _dereq_(120);
2652
var invariant = _dereq_(135);
2653
2654
/**
2655
* Internal store for event listeners
2656
*/
2657
var listenerBank = {};
2658
2659
/**
2660
* Internal queue of events that have accumulated their dispatches and are
2661
* waiting to have their dispatches executed.
2662
*/
2663
var eventQueue = null;
2664
2665
/**
2666
* Dispatches an event and releases it back into the pool, unless persistent.
2667
*
2668
* @param {?object} event Synthetic event to be dispatched.
2669
* @private
2670
*/
2671
var executeDispatchesAndRelease = function(event) {
2672
if (event) {
2673
var executeDispatch = EventPluginUtils.executeDispatch;
2674
// Plugins can provide custom behavior when dispatching events.
2675
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
2676
if (PluginModule && PluginModule.executeDispatch) {
2677
executeDispatch = PluginModule.executeDispatch;
2678
}
2679
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
2680
2681
if (!event.isPersistent()) {
2682
event.constructor.release(event);
2683
}
2684
}
2685
};
2686
2687
/**
2688
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
2689
* hierarchy given ids of the logical DOM elements involved.
2690
*/
2691
var InstanceHandle = null;
2692
2693
function validateInstanceHandle() {
2694
var valid =
2695
InstanceHandle &&
2696
InstanceHandle.traverseTwoPhase &&
2697
InstanceHandle.traverseEnterLeave;
2698
("production" !== "development" ? invariant(
2699
valid,
2700
'InstanceHandle not injected before use!'
2701
) : invariant(valid));
2702
}
2703
2704
/**
2705
* This is a unified interface for event plugins to be installed and configured.
2706
*
2707
* Event plugins can implement the following properties:
2708
*
2709
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
2710
* Required. When a top-level event is fired, this method is expected to
2711
* extract synthetic events that will in turn be queued and dispatched.
2712
*
2713
* `eventTypes` {object}
2714
* Optional, plugins that fire events must publish a mapping of registration
2715
* names that are used to register listeners. Values of this mapping must
2716
* be objects that contain `registrationName` or `phasedRegistrationNames`.
2717
*
2718
* `executeDispatch` {function(object, function, string)}
2719
* Optional, allows plugins to override how an event gets dispatched. By
2720
* default, the listener is simply invoked.
2721
*
2722
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
2723
*
2724
* @public
2725
*/
2726
var EventPluginHub = {
2727
2728
/**
2729
* Methods for injecting dependencies.
2730
*/
2731
injection: {
2732
2733
/**
2734
* @param {object} InjectedMount
2735
* @public
2736
*/
2737
injectMount: EventPluginUtils.injection.injectMount,
2738
2739
/**
2740
* @param {object} InjectedInstanceHandle
2741
* @public
2742
*/
2743
injectInstanceHandle: function(InjectedInstanceHandle) {
2744
InstanceHandle = InjectedInstanceHandle;
2745
if ("production" !== "development") {
2746
validateInstanceHandle();
2747
}
2748
},
2749
2750
getInstanceHandle: function() {
2751
if ("production" !== "development") {
2752
validateInstanceHandle();
2753
}
2754
return InstanceHandle;
2755
},
2756
2757
/**
2758
* @param {array} InjectedEventPluginOrder
2759
* @public
2760
*/
2761
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
2762
2763
/**
2764
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
2765
*/
2766
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
2767
2768
},
2769
2770
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
2771
2772
registrationNameModules: EventPluginRegistry.registrationNameModules,
2773
2774
/**
2775
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
2776
*
2777
* @param {string} id ID of the DOM element.
2778
* @param {string} registrationName Name of listener (e.g. `onClick`).
2779
* @param {?function} listener The callback to store.
2780
*/
2781
putListener: function(id, registrationName, listener) {
2782
("production" !== "development" ? invariant(
2783
!listener || typeof listener === 'function',
2784
'Expected %s listener to be a function, instead got type %s',
2785
registrationName, typeof listener
2786
) : invariant(!listener || typeof listener === 'function'));
2787
2788
var bankForRegistrationName =
2789
listenerBank[registrationName] || (listenerBank[registrationName] = {});
2790
bankForRegistrationName[id] = listener;
2791
},
2792
2793
/**
2794
* @param {string} id ID of the DOM element.
2795
* @param {string} registrationName Name of listener (e.g. `onClick`).
2796
* @return {?function} The stored callback.
2797
*/
2798
getListener: function(id, registrationName) {
2799
var bankForRegistrationName = listenerBank[registrationName];
2800
return bankForRegistrationName && bankForRegistrationName[id];
2801
},
2802
2803
/**
2804
* Deletes a listener from the registration bank.
2805
*
2806
* @param {string} id ID of the DOM element.
2807
* @param {string} registrationName Name of listener (e.g. `onClick`).
2808
*/
2809
deleteListener: function(id, registrationName) {
2810
var bankForRegistrationName = listenerBank[registrationName];
2811
if (bankForRegistrationName) {
2812
delete bankForRegistrationName[id];
2813
}
2814
},
2815
2816
/**
2817
* Deletes all listeners for the DOM element with the supplied ID.
2818
*
2819
* @param {string} id ID of the DOM element.
2820
*/
2821
deleteAllListeners: function(id) {
2822
for (var registrationName in listenerBank) {
2823
delete listenerBank[registrationName][id];
2824
}
2825
},
2826
2827
/**
2828
* Allows registered plugins an opportunity to extract events from top-level
2829
* native browser events.
2830
*
2831
* @param {string} topLevelType Record from `EventConstants`.
2832
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2833
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2834
* @param {object} nativeEvent Native browser event.
2835
* @return {*} An accumulation of synthetic events.
2836
* @internal
2837
*/
2838
extractEvents: function(
2839
topLevelType,
2840
topLevelTarget,
2841
topLevelTargetID,
2842
nativeEvent) {
2843
var events;
2844
var plugins = EventPluginRegistry.plugins;
2845
for (var i = 0, l = plugins.length; i < l; i++) {
2846
// Not every plugin in the ordering may be loaded at runtime.
2847
var possiblePlugin = plugins[i];
2848
if (possiblePlugin) {
2849
var extractedEvents = possiblePlugin.extractEvents(
2850
topLevelType,
2851
topLevelTarget,
2852
topLevelTargetID,
2853
nativeEvent
2854
);
2855
if (extractedEvents) {
2856
events = accumulateInto(events, extractedEvents);
2857
}
2858
}
2859
}
2860
return events;
2861
},
2862
2863
/**
2864
* Enqueues a synthetic event that should be dispatched when
2865
* `processEventQueue` is invoked.
2866
*
2867
* @param {*} events An accumulation of synthetic events.
2868
* @internal
2869
*/
2870
enqueueEvents: function(events) {
2871
if (events) {
2872
eventQueue = accumulateInto(eventQueue, events);
2873
}
2874
},
2875
2876
/**
2877
* Dispatches all synthetic events on the event queue.
2878
*
2879
* @internal
2880
*/
2881
processEventQueue: function() {
2882
// Set `eventQueue` to null before processing it so that we can tell if more
2883
// events get enqueued while processing.
2884
var processingEventQueue = eventQueue;
2885
eventQueue = null;
2886
forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
2887
("production" !== "development" ? invariant(
2888
!eventQueue,
2889
'processEventQueue(): Additional events were enqueued while processing ' +
2890
'an event queue. Support for this has not yet been implemented.'
2891
) : invariant(!eventQueue));
2892
},
2893
2894
/**
2895
* These are needed for tests only. Do not use!
2896
*/
2897
__purge: function() {
2898
listenerBank = {};
2899
},
2900
2901
__getListenerBank: function() {
2902
return listenerBank;
2903
}
2904
2905
};
2906
2907
module.exports = EventPluginHub;
2908
2909
},{"105":105,"120":120,"135":135,"18":18,"19":19}],18:[function(_dereq_,module,exports){
2910
/**
2911
* Copyright 2013-2015, Facebook, Inc.
2912
* All rights reserved.
2913
*
2914
* This source code is licensed under the BSD-style license found in the
2915
* LICENSE file in the root directory of this source tree. An additional grant
2916
* of patent rights can be found in the PATENTS file in the same directory.
2917
*
2918
* @providesModule EventPluginRegistry
2919
* @typechecks static-only
2920
*/
2921
2922
'use strict';
2923
2924
var invariant = _dereq_(135);
2925
2926
/**
2927
* Injectable ordering of event plugins.
2928
*/
2929
var EventPluginOrder = null;
2930
2931
/**
2932
* Injectable mapping from names to event plugin modules.
2933
*/
2934
var namesToPlugins = {};
2935
2936
/**
2937
* Recomputes the plugin list using the injected plugins and plugin ordering.
2938
*
2939
* @private
2940
*/
2941
function recomputePluginOrdering() {
2942
if (!EventPluginOrder) {
2943
// Wait until an `EventPluginOrder` is injected.
2944
return;
2945
}
2946
for (var pluginName in namesToPlugins) {
2947
var PluginModule = namesToPlugins[pluginName];
2948
var pluginIndex = EventPluginOrder.indexOf(pluginName);
2949
("production" !== "development" ? invariant(
2950
pluginIndex > -1,
2951
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
2952
'the plugin ordering, `%s`.',
2953
pluginName
2954
) : invariant(pluginIndex > -1));
2955
if (EventPluginRegistry.plugins[pluginIndex]) {
2956
continue;
2957
}
2958
("production" !== "development" ? invariant(
2959
PluginModule.extractEvents,
2960
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
2961
'method, but `%s` does not.',
2962
pluginName
2963
) : invariant(PluginModule.extractEvents));
2964
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
2965
var publishedEvents = PluginModule.eventTypes;
2966
for (var eventName in publishedEvents) {
2967
("production" !== "development" ? invariant(
2968
publishEventForPlugin(
2969
publishedEvents[eventName],
2970
PluginModule,
2971
eventName
2972
),
2973
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
2974
eventName,
2975
pluginName
2976
) : invariant(publishEventForPlugin(
2977
publishedEvents[eventName],
2978
PluginModule,
2979
eventName
2980
)));
2981
}
2982
}
2983
}
2984
2985
/**
2986
* Publishes an event so that it can be dispatched by the supplied plugin.
2987
*
2988
* @param {object} dispatchConfig Dispatch configuration for the event.
2989
* @param {object} PluginModule Plugin publishing the event.
2990
* @return {boolean} True if the event was successfully published.
2991
* @private
2992
*/
2993
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
2994
("production" !== "development" ? invariant(
2995
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
2996
'EventPluginHub: More than one plugin attempted to publish the same ' +
2997
'event name, `%s`.',
2998
eventName
2999
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
3000
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
3001
3002
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
3003
if (phasedRegistrationNames) {
3004
for (var phaseName in phasedRegistrationNames) {
3005
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
3006
var phasedRegistrationName = phasedRegistrationNames[phaseName];
3007
publishRegistrationName(
3008
phasedRegistrationName,
3009
PluginModule,
3010
eventName
3011
);
3012
}
3013
}
3014
return true;
3015
} else if (dispatchConfig.registrationName) {
3016
publishRegistrationName(
3017
dispatchConfig.registrationName,
3018
PluginModule,
3019
eventName
3020
);
3021
return true;
3022
}
3023
return false;
3024
}
3025
3026
/**
3027
* Publishes a registration name that is used to identify dispatched events and
3028
* can be used with `EventPluginHub.putListener` to register listeners.
3029
*
3030
* @param {string} registrationName Registration name to add.
3031
* @param {object} PluginModule Plugin publishing the event.
3032
* @private
3033
*/
3034
function publishRegistrationName(registrationName, PluginModule, eventName) {
3035
("production" !== "development" ? invariant(
3036
!EventPluginRegistry.registrationNameModules[registrationName],
3037
'EventPluginHub: More than one plugin attempted to publish the same ' +
3038
'registration name, `%s`.',
3039
registrationName
3040
) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
3041
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
3042
EventPluginRegistry.registrationNameDependencies[registrationName] =
3043
PluginModule.eventTypes[eventName].dependencies;
3044
}
3045
3046
/**
3047
* Registers plugins so that they can extract and dispatch events.
3048
*
3049
* @see {EventPluginHub}
3050
*/
3051
var EventPluginRegistry = {
3052
3053
/**
3054
* Ordered list of injected plugins.
3055
*/
3056
plugins: [],
3057
3058
/**
3059
* Mapping from event name to dispatch config
3060
*/
3061
eventNameDispatchConfigs: {},
3062
3063
/**
3064
* Mapping from registration name to plugin module
3065
*/
3066
registrationNameModules: {},
3067
3068
/**
3069
* Mapping from registration name to event name
3070
*/
3071
registrationNameDependencies: {},
3072
3073
/**
3074
* Injects an ordering of plugins (by plugin name). This allows the ordering
3075
* to be decoupled from injection of the actual plugins so that ordering is
3076
* always deterministic regardless of packaging, on-the-fly injection, etc.
3077
*
3078
* @param {array} InjectedEventPluginOrder
3079
* @internal
3080
* @see {EventPluginHub.injection.injectEventPluginOrder}
3081
*/
3082
injectEventPluginOrder: function(InjectedEventPluginOrder) {
3083
("production" !== "development" ? invariant(
3084
!EventPluginOrder,
3085
'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
3086
'once. You are likely trying to load more than one copy of React.'
3087
) : invariant(!EventPluginOrder));
3088
// Clone the ordering so it cannot be dynamically mutated.
3089
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
3090
recomputePluginOrdering();
3091
},
3092
3093
/**
3094
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
3095
* in the ordering injected by `injectEventPluginOrder`.
3096
*
3097
* Plugins can be injected as part of page initialization or on-the-fly.
3098
*
3099
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
3100
* @internal
3101
* @see {EventPluginHub.injection.injectEventPluginsByName}
3102
*/
3103
injectEventPluginsByName: function(injectedNamesToPlugins) {
3104
var isOrderingDirty = false;
3105
for (var pluginName in injectedNamesToPlugins) {
3106
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
3107
continue;
3108
}
3109
var PluginModule = injectedNamesToPlugins[pluginName];
3110
if (!namesToPlugins.hasOwnProperty(pluginName) ||
3111
namesToPlugins[pluginName] !== PluginModule) {
3112
("production" !== "development" ? invariant(
3113
!namesToPlugins[pluginName],
3114
'EventPluginRegistry: Cannot inject two different event plugins ' +
3115
'using the same name, `%s`.',
3116
pluginName
3117
) : invariant(!namesToPlugins[pluginName]));
3118
namesToPlugins[pluginName] = PluginModule;
3119
isOrderingDirty = true;
3120
}
3121
}
3122
if (isOrderingDirty) {
3123
recomputePluginOrdering();
3124
}
3125
},
3126
3127
/**
3128
* Looks up the plugin for the supplied event.
3129
*
3130
* @param {object} event A synthetic event.
3131
* @return {?object} The plugin that created the supplied event.
3132
* @internal
3133
*/
3134
getPluginModuleForEvent: function(event) {
3135
var dispatchConfig = event.dispatchConfig;
3136
if (dispatchConfig.registrationName) {
3137
return EventPluginRegistry.registrationNameModules[
3138
dispatchConfig.registrationName
3139
] || null;
3140
}
3141
for (var phase in dispatchConfig.phasedRegistrationNames) {
3142
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
3143
continue;
3144
}
3145
var PluginModule = EventPluginRegistry.registrationNameModules[
3146
dispatchConfig.phasedRegistrationNames[phase]
3147
];
3148
if (PluginModule) {
3149
return PluginModule;
3150
}
3151
}
3152
return null;
3153
},
3154
3155
/**
3156
* Exposed for unit testing.
3157
* @private
3158
*/
3159
_resetEventPlugins: function() {
3160
EventPluginOrder = null;
3161
for (var pluginName in namesToPlugins) {
3162
if (namesToPlugins.hasOwnProperty(pluginName)) {
3163
delete namesToPlugins[pluginName];
3164
}
3165
}
3166
EventPluginRegistry.plugins.length = 0;
3167
3168
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
3169
for (var eventName in eventNameDispatchConfigs) {
3170
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
3171
delete eventNameDispatchConfigs[eventName];
3172
}
3173
}
3174
3175
var registrationNameModules = EventPluginRegistry.registrationNameModules;
3176
for (var registrationName in registrationNameModules) {
3177
if (registrationNameModules.hasOwnProperty(registrationName)) {
3178
delete registrationNameModules[registrationName];
3179
}
3180
}
3181
}
3182
3183
};
3184
3185
module.exports = EventPluginRegistry;
3186
3187
},{"135":135}],19:[function(_dereq_,module,exports){
3188
/**
3189
* Copyright 2013-2015, Facebook, Inc.
3190
* All rights reserved.
3191
*
3192
* This source code is licensed under the BSD-style license found in the
3193
* LICENSE file in the root directory of this source tree. An additional grant
3194
* of patent rights can be found in the PATENTS file in the same directory.
3195
*
3196
* @providesModule EventPluginUtils
3197
*/
3198
3199
'use strict';
3200
3201
var EventConstants = _dereq_(15);
3202
3203
var invariant = _dereq_(135);
3204
3205
/**
3206
* Injected dependencies:
3207
*/
3208
3209
/**
3210
* - `Mount`: [required] Module that can convert between React dom IDs and
3211
* actual node references.
3212
*/
3213
var injection = {
3214
Mount: null,
3215
injectMount: function(InjectedMount) {
3216
injection.Mount = InjectedMount;
3217
if ("production" !== "development") {
3218
("production" !== "development" ? invariant(
3219
InjectedMount && InjectedMount.getNode,
3220
'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
3221
'is missing getNode.'
3222
) : invariant(InjectedMount && InjectedMount.getNode));
3223
}
3224
}
3225
};
3226
3227
var topLevelTypes = EventConstants.topLevelTypes;
3228
3229
function isEndish(topLevelType) {
3230
return topLevelType === topLevelTypes.topMouseUp ||
3231
topLevelType === topLevelTypes.topTouchEnd ||
3232
topLevelType === topLevelTypes.topTouchCancel;
3233
}
3234
3235
function isMoveish(topLevelType) {
3236
return topLevelType === topLevelTypes.topMouseMove ||
3237
topLevelType === topLevelTypes.topTouchMove;
3238
}
3239
function isStartish(topLevelType) {
3240
return topLevelType === topLevelTypes.topMouseDown ||
3241
topLevelType === topLevelTypes.topTouchStart;
3242
}
3243
3244
3245
var validateEventDispatches;
3246
if ("production" !== "development") {
3247
validateEventDispatches = function(event) {
3248
var dispatchListeners = event._dispatchListeners;
3249
var dispatchIDs = event._dispatchIDs;
3250
3251
var listenersIsArr = Array.isArray(dispatchListeners);
3252
var idsIsArr = Array.isArray(dispatchIDs);
3253
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
3254
var listenersLen = listenersIsArr ?
3255
dispatchListeners.length :
3256
dispatchListeners ? 1 : 0;
3257
3258
("production" !== "development" ? invariant(
3259
idsIsArr === listenersIsArr && IDsLen === listenersLen,
3260
'EventPluginUtils: Invalid `event`.'
3261
) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
3262
};
3263
}
3264
3265
/**
3266
* Invokes `cb(event, listener, id)`. Avoids using call if no scope is
3267
* provided. The `(listener,id)` pair effectively forms the "dispatch" but are
3268
* kept separate to conserve memory.
3269
*/
3270
function forEachEventDispatch(event, cb) {
3271
var dispatchListeners = event._dispatchListeners;
3272
var dispatchIDs = event._dispatchIDs;
3273
if ("production" !== "development") {
3274
validateEventDispatches(event);
3275
}
3276
if (Array.isArray(dispatchListeners)) {
3277
for (var i = 0; i < dispatchListeners.length; i++) {
3278
if (event.isPropagationStopped()) {
3279
break;
3280
}
3281
// Listeners and IDs are two parallel arrays that are always in sync.
3282
cb(event, dispatchListeners[i], dispatchIDs[i]);
3283
}
3284
} else if (dispatchListeners) {
3285
cb(event, dispatchListeners, dispatchIDs);
3286
}
3287
}
3288
3289
/**
3290
* Default implementation of PluginModule.executeDispatch().
3291
* @param {SyntheticEvent} SyntheticEvent to handle
3292
* @param {function} Application-level callback
3293
* @param {string} domID DOM id to pass to the callback.
3294
*/
3295
function executeDispatch(event, listener, domID) {
3296
event.currentTarget = injection.Mount.getNode(domID);
3297
var returnValue = listener(event, domID);
3298
event.currentTarget = null;
3299
return returnValue;
3300
}
3301
3302
/**
3303
* Standard/simple iteration through an event's collected dispatches.
3304
*/
3305
function executeDispatchesInOrder(event, cb) {
3306
forEachEventDispatch(event, cb);
3307
event._dispatchListeners = null;
3308
event._dispatchIDs = null;
3309
}
3310
3311
/**
3312
* Standard/simple iteration through an event's collected dispatches, but stops
3313
* at the first dispatch execution returning true, and returns that id.
3314
*
3315
* @return id of the first dispatch execution who's listener returns true, or
3316
* null if no listener returned true.
3317
*/
3318
function executeDispatchesInOrderStopAtTrueImpl(event) {
3319
var dispatchListeners = event._dispatchListeners;
3320
var dispatchIDs = event._dispatchIDs;
3321
if ("production" !== "development") {
3322
validateEventDispatches(event);
3323
}
3324
if (Array.isArray(dispatchListeners)) {
3325
for (var i = 0; i < dispatchListeners.length; i++) {
3326
if (event.isPropagationStopped()) {
3327
break;
3328
}
3329
// Listeners and IDs are two parallel arrays that are always in sync.
3330
if (dispatchListeners[i](event, dispatchIDs[i])) {
3331
return dispatchIDs[i];
3332
}
3333
}
3334
} else if (dispatchListeners) {
3335
if (dispatchListeners(event, dispatchIDs)) {
3336
return dispatchIDs;
3337
}
3338
}
3339
return null;
3340
}
3341
3342
/**
3343
* @see executeDispatchesInOrderStopAtTrueImpl
3344
*/
3345
function executeDispatchesInOrderStopAtTrue(event) {
3346
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
3347
event._dispatchIDs = null;
3348
event._dispatchListeners = null;
3349
return ret;
3350
}
3351
3352
/**
3353
* Execution of a "direct" dispatch - there must be at most one dispatch
3354
* accumulated on the event or it is considered an error. It doesn't really make
3355
* sense for an event with multiple dispatches (bubbled) to keep track of the
3356
* return values at each dispatch execution, but it does tend to make sense when
3357
* dealing with "direct" dispatches.
3358
*
3359
* @return The return value of executing the single dispatch.
3360
*/
3361
function executeDirectDispatch(event) {
3362
if ("production" !== "development") {
3363
validateEventDispatches(event);
3364
}
3365
var dispatchListener = event._dispatchListeners;
3366
var dispatchID = event._dispatchIDs;
3367
("production" !== "development" ? invariant(
3368
!Array.isArray(dispatchListener),
3369
'executeDirectDispatch(...): Invalid `event`.'
3370
) : invariant(!Array.isArray(dispatchListener)));
3371
var res = dispatchListener ?
3372
dispatchListener(event, dispatchID) :
3373
null;
3374
event._dispatchListeners = null;
3375
event._dispatchIDs = null;
3376
return res;
3377
}
3378
3379
/**
3380
* @param {SyntheticEvent} event
3381
* @return {bool} True iff number of dispatches accumulated is greater than 0.
3382
*/
3383
function hasDispatches(event) {
3384
return !!event._dispatchListeners;
3385
}
3386
3387
/**
3388
* General utilities that are useful in creating custom Event Plugins.
3389
*/
3390
var EventPluginUtils = {
3391
isEndish: isEndish,
3392
isMoveish: isMoveish,
3393
isStartish: isStartish,
3394
3395
executeDirectDispatch: executeDirectDispatch,
3396
executeDispatch: executeDispatch,
3397
executeDispatchesInOrder: executeDispatchesInOrder,
3398
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
3399
hasDispatches: hasDispatches,
3400
injection: injection,
3401
useTouchEvents: false
3402
};
3403
3404
module.exports = EventPluginUtils;
3405
3406
},{"135":135,"15":15}],20:[function(_dereq_,module,exports){
3407
/**
3408
* Copyright 2013-2015, Facebook, Inc.
3409
* All rights reserved.
3410
*
3411
* This source code is licensed under the BSD-style license found in the
3412
* LICENSE file in the root directory of this source tree. An additional grant
3413
* of patent rights can be found in the PATENTS file in the same directory.
3414
*
3415
* @providesModule EventPropagators
3416
*/
3417
3418
'use strict';
3419
3420
var EventConstants = _dereq_(15);
3421
var EventPluginHub = _dereq_(17);
3422
3423
var accumulateInto = _dereq_(105);
3424
var forEachAccumulated = _dereq_(120);
3425
3426
var PropagationPhases = EventConstants.PropagationPhases;
3427
var getListener = EventPluginHub.getListener;
3428
3429
/**
3430
* Some event types have a notion of different registration names for different
3431
* "phases" of propagation. This finds listeners by a given phase.
3432
*/
3433
function listenerAtPhase(id, event, propagationPhase) {
3434
var registrationName =
3435
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
3436
return getListener(id, registrationName);
3437
}
3438
3439
/**
3440
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
3441
* here, allows us to not have to bind or create functions for each event.
3442
* Mutating the event's members allows us to not have to create a wrapping
3443
* "dispatch" object that pairs the event with the listener.
3444
*/
3445
function accumulateDirectionalDispatches(domID, upwards, event) {
3446
if ("production" !== "development") {
3447
if (!domID) {
3448
throw new Error('Dispatching id must not be null');
3449
}
3450
}
3451
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
3452
var listener = listenerAtPhase(domID, event, phase);
3453
if (listener) {
3454
event._dispatchListeners =
3455
accumulateInto(event._dispatchListeners, listener);
3456
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
3457
}
3458
}
3459
3460
/**
3461
* Collect dispatches (must be entirely collected before dispatching - see unit
3462
* tests). Lazily allocate the array to conserve memory. We must loop through
3463
* each event and perform the traversal for each one. We can not perform a
3464
* single traversal for the entire collection of events because each event may
3465
* have a different target.
3466
*/
3467
function accumulateTwoPhaseDispatchesSingle(event) {
3468
if (event && event.dispatchConfig.phasedRegistrationNames) {
3469
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
3470
event.dispatchMarker,
3471
accumulateDirectionalDispatches,
3472
event
3473
);
3474
}
3475
}
3476
3477
3478
/**
3479
* Accumulates without regard to direction, does not look for phased
3480
* registration names. Same as `accumulateDirectDispatchesSingle` but without
3481
* requiring that the `dispatchMarker` be the same as the dispatched ID.
3482
*/
3483
function accumulateDispatches(id, ignoredDirection, event) {
3484
if (event && event.dispatchConfig.registrationName) {
3485
var registrationName = event.dispatchConfig.registrationName;
3486
var listener = getListener(id, registrationName);
3487
if (listener) {
3488
event._dispatchListeners =
3489
accumulateInto(event._dispatchListeners, listener);
3490
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
3491
}
3492
}
3493
}
3494
3495
/**
3496
* Accumulates dispatches on an `SyntheticEvent`, but only for the
3497
* `dispatchMarker`.
3498
* @param {SyntheticEvent} event
3499
*/
3500
function accumulateDirectDispatchesSingle(event) {
3501
if (event && event.dispatchConfig.registrationName) {
3502
accumulateDispatches(event.dispatchMarker, null, event);
3503
}
3504
}
3505
3506
function accumulateTwoPhaseDispatches(events) {
3507
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
3508
}
3509
3510
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
3511
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
3512
fromID,
3513
toID,
3514
accumulateDispatches,
3515
leave,
3516
enter
3517
);
3518
}
3519
3520
3521
function accumulateDirectDispatches(events) {
3522
forEachAccumulated(events, accumulateDirectDispatchesSingle);
3523
}
3524
3525
3526
3527
/**
3528
* A small set of propagation patterns, each of which will accept a small amount
3529
* of information, and generate a set of "dispatch ready event objects" - which
3530
* are sets of events that have already been annotated with a set of dispatched
3531
* listener functions/ids. The API is designed this way to discourage these
3532
* propagation strategies from actually executing the dispatches, since we
3533
* always want to collect the entire set of dispatches before executing event a
3534
* single one.
3535
*
3536
* @constructor EventPropagators
3537
*/
3538
var EventPropagators = {
3539
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
3540
accumulateDirectDispatches: accumulateDirectDispatches,
3541
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
3542
};
3543
3544
module.exports = EventPropagators;
3545
3546
},{"105":105,"120":120,"15":15,"17":17}],21:[function(_dereq_,module,exports){
3547
/**
3548
* Copyright 2013-2015, Facebook, Inc.
3549
* All rights reserved.
3550
*
3551
* This source code is licensed under the BSD-style license found in the
3552
* LICENSE file in the root directory of this source tree. An additional grant
3553
* of patent rights can be found in the PATENTS file in the same directory.
3554
*
3555
* @providesModule ExecutionEnvironment
3556
*/
3557
3558
/*jslint evil: true */
3559
3560
"use strict";
3561
3562
var canUseDOM = !!(
3563
(typeof window !== 'undefined' &&
3564
window.document && window.document.createElement)
3565
);
3566
3567
/**
3568
* Simple, lightweight module assisting with the detection and context of
3569
* Worker. Helps avoid circular dependencies and allows code to reason about
3570
* whether or not they are in a Worker, even if they never include the main
3571
* `ReactWorker` dependency.
3572
*/
3573
var ExecutionEnvironment = {
3574
3575
canUseDOM: canUseDOM,
3576
3577
canUseWorkers: typeof Worker !== 'undefined',
3578
3579
canUseEventListeners:
3580
canUseDOM && !!(window.addEventListener || window.attachEvent),
3581
3582
canUseViewport: canUseDOM && !!window.screen,
3583
3584
isInWorker: !canUseDOM // For now, this is true - might change in the future.
3585
3586
};
3587
3588
module.exports = ExecutionEnvironment;
3589
3590
},{}],22:[function(_dereq_,module,exports){
3591
/**
3592
* Copyright 2013-2015, Facebook, Inc.
3593
* All rights reserved.
3594
*
3595
* This source code is licensed under the BSD-style license found in the
3596
* LICENSE file in the root directory of this source tree. An additional grant
3597
* of patent rights can be found in the PATENTS file in the same directory.
3598
*
3599
* @providesModule FallbackCompositionState
3600
* @typechecks static-only
3601
*/
3602
3603
'use strict';
3604
3605
var PooledClass = _dereq_(28);
3606
3607
var assign = _dereq_(27);
3608
var getTextContentAccessor = _dereq_(130);
3609
3610
/**
3611
* This helper class stores information about text content of a target node,
3612
* allowing comparison of content before and after a given event.
3613
*
3614
* Identify the node where selection currently begins, then observe
3615
* both its text content and its current position in the DOM. Since the
3616
* browser may natively replace the target node during composition, we can
3617
* use its position to find its replacement.
3618
*
3619
* @param {DOMEventTarget} root
3620
*/
3621
function FallbackCompositionState(root) {
3622
this._root = root;
3623
this._startText = this.getText();
3624
this._fallbackText = null;
3625
}
3626
3627
assign(FallbackCompositionState.prototype, {
3628
/**
3629
* Get current text of input.
3630
*
3631
* @return {string}
3632
*/
3633
getText: function() {
3634
if ('value' in this._root) {
3635
return this._root.value;
3636
}
3637
return this._root[getTextContentAccessor()];
3638
},
3639
3640
/**
3641
* Determine the differing substring between the initially stored
3642
* text content and the current content.
3643
*
3644
* @return {string}
3645
*/
3646
getData: function() {
3647
if (this._fallbackText) {
3648
return this._fallbackText;
3649
}
3650
3651
var start;
3652
var startValue = this._startText;
3653
var startLength = startValue.length;
3654
var end;
3655
var endValue = this.getText();
3656
var endLength = endValue.length;
3657
3658
for (start = 0; start < startLength; start++) {
3659
if (startValue[start] !== endValue[start]) {
3660
break;
3661
}
3662
}
3663
3664
var minEnd = startLength - start;
3665
for (end = 1; end <= minEnd; end++) {
3666
if (startValue[startLength - end] !== endValue[endLength - end]) {
3667
break;
3668
}
3669
}
3670
3671
var sliceTail = end > 1 ? 1 - end : undefined;
3672
this._fallbackText = endValue.slice(start, sliceTail);
3673
return this._fallbackText;
3674
}
3675
});
3676
3677
PooledClass.addPoolingTo(FallbackCompositionState);
3678
3679
module.exports = FallbackCompositionState;
3680
3681
},{"130":130,"27":27,"28":28}],23:[function(_dereq_,module,exports){
3682
/**
3683
* Copyright 2013-2015, Facebook, Inc.
3684
* All rights reserved.
3685
*
3686
* This source code is licensed under the BSD-style license found in the
3687
* LICENSE file in the root directory of this source tree. An additional grant
3688
* of patent rights can be found in the PATENTS file in the same directory.
3689
*
3690
* @providesModule HTMLDOMPropertyConfig
3691
*/
3692
3693
/*jslint bitwise: true*/
3694
3695
'use strict';
3696
3697
var DOMProperty = _dereq_(10);
3698
var ExecutionEnvironment = _dereq_(21);
3699
3700
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
3701
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
3702
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
3703
var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
3704
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
3705
var HAS_POSITIVE_NUMERIC_VALUE =
3706
DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
3707
var HAS_OVERLOADED_BOOLEAN_VALUE =
3708
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
3709
3710
var hasSVG;
3711
if (ExecutionEnvironment.canUseDOM) {
3712
var implementation = document.implementation;
3713
hasSVG = (
3714
implementation &&
3715
implementation.hasFeature &&
3716
implementation.hasFeature(
3717
'http://www.w3.org/TR/SVG11/feature#BasicStructure',
3718
'1.1'
3719
)
3720
);
3721
}
3722
3723
3724
var HTMLDOMPropertyConfig = {
3725
isCustomAttribute: RegExp.prototype.test.bind(
3726
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
3727
),
3728
Properties: {
3729
/**
3730
* Standard Properties
3731
*/
3732
accept: null,
3733
acceptCharset: null,
3734
accessKey: null,
3735
action: null,
3736
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3737
allowTransparency: MUST_USE_ATTRIBUTE,
3738
alt: null,
3739
async: HAS_BOOLEAN_VALUE,
3740
autoComplete: null,
3741
// autoFocus is polyfilled/normalized by AutoFocusMixin
3742
// autoFocus: HAS_BOOLEAN_VALUE,
3743
autoPlay: HAS_BOOLEAN_VALUE,
3744
cellPadding: null,
3745
cellSpacing: null,
3746
charSet: MUST_USE_ATTRIBUTE,
3747
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3748
classID: MUST_USE_ATTRIBUTE,
3749
// To set className on SVG elements, it's necessary to use .setAttribute;
3750
// this works on HTML elements too in all browsers except IE8. Conveniently,
3751
// IE8 doesn't support SVG and so we can simply use the attribute in
3752
// browsers that support SVG and the property in browsers that don't,
3753
// regardless of whether the element is HTML or SVG.
3754
className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
3755
cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3756
colSpan: null,
3757
content: null,
3758
contentEditable: null,
3759
contextMenu: MUST_USE_ATTRIBUTE,
3760
controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3761
coords: null,
3762
crossOrigin: null,
3763
data: null, // For `<object />` acts as `src`.
3764
dateTime: MUST_USE_ATTRIBUTE,
3765
defer: HAS_BOOLEAN_VALUE,
3766
dir: null,
3767
disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3768
download: HAS_OVERLOADED_BOOLEAN_VALUE,
3769
draggable: null,
3770
encType: null,
3771
form: MUST_USE_ATTRIBUTE,
3772
formAction: MUST_USE_ATTRIBUTE,
3773
formEncType: MUST_USE_ATTRIBUTE,
3774
formMethod: MUST_USE_ATTRIBUTE,
3775
formNoValidate: HAS_BOOLEAN_VALUE,
3776
formTarget: MUST_USE_ATTRIBUTE,
3777
frameBorder: MUST_USE_ATTRIBUTE,
3778
headers: null,
3779
height: MUST_USE_ATTRIBUTE,
3780
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3781
high: null,
3782
href: null,
3783
hrefLang: null,
3784
htmlFor: null,
3785
httpEquiv: null,
3786
icon: null,
3787
id: MUST_USE_PROPERTY,
3788
label: null,
3789
lang: null,
3790
list: MUST_USE_ATTRIBUTE,
3791
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3792
low: null,
3793
manifest: MUST_USE_ATTRIBUTE,
3794
marginHeight: null,
3795
marginWidth: null,
3796
max: null,
3797
maxLength: MUST_USE_ATTRIBUTE,
3798
media: MUST_USE_ATTRIBUTE,
3799
mediaGroup: null,
3800
method: null,
3801
min: null,
3802
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3803
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3804
name: null,
3805
noValidate: HAS_BOOLEAN_VALUE,
3806
open: HAS_BOOLEAN_VALUE,
3807
optimum: null,
3808
pattern: null,
3809
placeholder: null,
3810
poster: null,
3811
preload: null,
3812
radioGroup: null,
3813
readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3814
rel: null,
3815
required: HAS_BOOLEAN_VALUE,
3816
role: MUST_USE_ATTRIBUTE,
3817
rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3818
rowSpan: null,
3819
sandbox: null,
3820
scope: null,
3821
scoped: HAS_BOOLEAN_VALUE,
3822
scrolling: null,
3823
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3824
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3825
shape: null,
3826
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3827
sizes: MUST_USE_ATTRIBUTE,
3828
span: HAS_POSITIVE_NUMERIC_VALUE,
3829
spellCheck: null,
3830
src: null,
3831
srcDoc: MUST_USE_PROPERTY,
3832
srcSet: MUST_USE_ATTRIBUTE,
3833
start: HAS_NUMERIC_VALUE,
3834
step: null,
3835
style: null,
3836
tabIndex: null,
3837
target: null,
3838
title: null,
3839
type: null,
3840
useMap: null,
3841
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
3842
width: MUST_USE_ATTRIBUTE,
3843
wmode: MUST_USE_ATTRIBUTE,
3844
3845
/**
3846
* Non-standard Properties
3847
*/
3848
// autoCapitalize and autoCorrect are supported in Mobile Safari for
3849
// keyboard hints.
3850
autoCapitalize: null,
3851
autoCorrect: null,
3852
// itemProp, itemScope, itemType are for
3853
// Microdata support. See http://schema.org/docs/gs.html
3854
itemProp: MUST_USE_ATTRIBUTE,
3855
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3856
itemType: MUST_USE_ATTRIBUTE,
3857
// itemID and itemRef are for Microdata support as well but
3858
// only specified in the the WHATWG spec document. See
3859
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
3860
itemID: MUST_USE_ATTRIBUTE,
3861
itemRef: MUST_USE_ATTRIBUTE,
3862
// property is supported for OpenGraph in meta tags.
3863
property: null,
3864
// IE-only attribute that controls focus behavior
3865
unselectable: MUST_USE_ATTRIBUTE
3866
},
3867
DOMAttributeNames: {
3868
acceptCharset: 'accept-charset',
3869
className: 'class',
3870
htmlFor: 'for',
3871
httpEquiv: 'http-equiv'
3872
},
3873
DOMPropertyNames: {
3874
autoCapitalize: 'autocapitalize',
3875
autoComplete: 'autocomplete',
3876
autoCorrect: 'autocorrect',
3877
autoFocus: 'autofocus',
3878
autoPlay: 'autoplay',
3879
// `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
3880
// http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
3881
encType: 'encoding',
3882
hrefLang: 'hreflang',
3883
radioGroup: 'radiogroup',
3884
spellCheck: 'spellcheck',
3885
srcDoc: 'srcdoc',
3886
srcSet: 'srcset'
3887
}
3888
};
3889
3890
module.exports = HTMLDOMPropertyConfig;
3891
3892
},{"10":10,"21":21}],24:[function(_dereq_,module,exports){
3893
/**
3894
* Copyright 2013-2015, Facebook, Inc.
3895
* All rights reserved.
3896
*
3897
* This source code is licensed under the BSD-style license found in the
3898
* LICENSE file in the root directory of this source tree. An additional grant
3899
* of patent rights can be found in the PATENTS file in the same directory.
3900
*
3901
* @providesModule LinkedValueUtils
3902
* @typechecks static-only
3903
*/
3904
3905
'use strict';
3906
3907
var ReactPropTypes = _dereq_(78);
3908
3909
var invariant = _dereq_(135);
3910
3911
var hasReadOnlyValue = {
3912
'button': true,
3913
'checkbox': true,
3914
'image': true,
3915
'hidden': true,
3916
'radio': true,
3917
'reset': true,
3918
'submit': true
3919
};
3920
3921
function _assertSingleLink(input) {
3922
("production" !== "development" ? invariant(
3923
input.props.checkedLink == null || input.props.valueLink == null,
3924
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
3925
'checkedLink, you probably don\'t want to use valueLink and vice versa.'
3926
) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
3927
}
3928
function _assertValueLink(input) {
3929
_assertSingleLink(input);
3930
("production" !== "development" ? invariant(
3931
input.props.value == null && input.props.onChange == null,
3932
'Cannot provide a valueLink and a value or onChange event. If you want ' +
3933
'to use value or onChange, you probably don\'t want to use valueLink.'
3934
) : invariant(input.props.value == null && input.props.onChange == null));
3935
}
3936
3937
function _assertCheckedLink(input) {
3938
_assertSingleLink(input);
3939
("production" !== "development" ? invariant(
3940
input.props.checked == null && input.props.onChange == null,
3941
'Cannot provide a checkedLink and a checked property or onChange event. ' +
3942
'If you want to use checked or onChange, you probably don\'t want to ' +
3943
'use checkedLink'
3944
) : invariant(input.props.checked == null && input.props.onChange == null));
3945
}
3946
3947
/**
3948
* @param {SyntheticEvent} e change event to handle
3949
*/
3950
function _handleLinkedValueChange(e) {
3951
/*jshint validthis:true */
3952
this.props.valueLink.requestChange(e.target.value);
3953
}
3954
3955
/**
3956
* @param {SyntheticEvent} e change event to handle
3957
*/
3958
function _handleLinkedCheckChange(e) {
3959
/*jshint validthis:true */
3960
this.props.checkedLink.requestChange(e.target.checked);
3961
}
3962
3963
/**
3964
* Provide a linked `value` attribute for controlled forms. You should not use
3965
* this outside of the ReactDOM controlled form components.
3966
*/
3967
var LinkedValueUtils = {
3968
Mixin: {
3969
propTypes: {
3970
value: function(props, propName, componentName) {
3971
if (!props[propName] ||
3972
hasReadOnlyValue[props.type] ||
3973
props.onChange ||
3974
props.readOnly ||
3975
props.disabled) {
3976
return null;
3977
}
3978
return new Error(
3979
'You provided a `value` prop to a form field without an ' +
3980
'`onChange` handler. This will render a read-only field. If ' +
3981
'the field should be mutable use `defaultValue`. Otherwise, ' +
3982
'set either `onChange` or `readOnly`.'
3983
);
3984
},
3985
checked: function(props, propName, componentName) {
3986
if (!props[propName] ||
3987
props.onChange ||
3988
props.readOnly ||
3989
props.disabled) {
3990
return null;
3991
}
3992
return new Error(
3993
'You provided a `checked` prop to a form field without an ' +
3994
'`onChange` handler. This will render a read-only field. If ' +
3995
'the field should be mutable use `defaultChecked`. Otherwise, ' +
3996
'set either `onChange` or `readOnly`.'
3997
);
3998
},
3999
onChange: ReactPropTypes.func
4000
}
4001
},
4002
4003
/**
4004
* @param {ReactComponent} input Form component
4005
* @return {*} current value of the input either from value prop or link.
4006
*/
4007
getValue: function(input) {
4008
if (input.props.valueLink) {
4009
_assertValueLink(input);
4010
return input.props.valueLink.value;
4011
}
4012
return input.props.value;
4013
},
4014
4015
/**
4016
* @param {ReactComponent} input Form component
4017
* @return {*} current checked status of the input either from checked prop
4018
* or link.
4019
*/
4020
getChecked: function(input) {
4021
if (input.props.checkedLink) {
4022
_assertCheckedLink(input);
4023
return input.props.checkedLink.value;
4024
}
4025
return input.props.checked;
4026
},
4027
4028
/**
4029
* @param {ReactComponent} input Form component
4030
* @return {function} change callback either from onChange prop or link.
4031
*/
4032
getOnChange: function(input) {
4033
if (input.props.valueLink) {
4034
_assertValueLink(input);
4035
return _handleLinkedValueChange;
4036
} else if (input.props.checkedLink) {
4037
_assertCheckedLink(input);
4038
return _handleLinkedCheckChange;
4039
}
4040
return input.props.onChange;
4041
}
4042
};
4043
4044
module.exports = LinkedValueUtils;
4045
4046
},{"135":135,"78":78}],25:[function(_dereq_,module,exports){
4047
/**
4048
* Copyright 2014-2015, Facebook, Inc.
4049
* All rights reserved.
4050
*
4051
* This source code is licensed under the BSD-style license found in the
4052
* LICENSE file in the root directory of this source tree. An additional grant
4053
* of patent rights can be found in the PATENTS file in the same directory.
4054
*
4055
* @providesModule LocalEventTrapMixin
4056
*/
4057
4058
'use strict';
4059
4060
var ReactBrowserEventEmitter = _dereq_(30);
4061
4062
var accumulateInto = _dereq_(105);
4063
var forEachAccumulated = _dereq_(120);
4064
var invariant = _dereq_(135);
4065
4066
function remove(event) {
4067
event.remove();
4068
}
4069
4070
var LocalEventTrapMixin = {
4071
trapBubbledEvent:function(topLevelType, handlerBaseName) {
4072
("production" !== "development" ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
4073
// If a component renders to null or if another component fatals and causes
4074
// the state of the tree to be corrupted, `node` here can be null.
4075
var node = this.getDOMNode();
4076
("production" !== "development" ? invariant(
4077
node,
4078
'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
4079
) : invariant(node));
4080
var listener = ReactBrowserEventEmitter.trapBubbledEvent(
4081
topLevelType,
4082
handlerBaseName,
4083
node
4084
);
4085
this._localEventListeners =
4086
accumulateInto(this._localEventListeners, listener);
4087
},
4088
4089
// trapCapturedEvent would look nearly identical. We don't implement that
4090
// method because it isn't currently needed.
4091
4092
componentWillUnmount:function() {
4093
if (this._localEventListeners) {
4094
forEachAccumulated(this._localEventListeners, remove);
4095
}
4096
}
4097
};
4098
4099
module.exports = LocalEventTrapMixin;
4100
4101
},{"105":105,"120":120,"135":135,"30":30}],26:[function(_dereq_,module,exports){
4102
/**
4103
* Copyright 2013-2015, Facebook, Inc.
4104
* All rights reserved.
4105
*
4106
* This source code is licensed under the BSD-style license found in the
4107
* LICENSE file in the root directory of this source tree. An additional grant
4108
* of patent rights can be found in the PATENTS file in the same directory.
4109
*
4110
* @providesModule MobileSafariClickEventPlugin
4111
* @typechecks static-only
4112
*/
4113
4114
'use strict';
4115
4116
var EventConstants = _dereq_(15);
4117
4118
var emptyFunction = _dereq_(114);
4119
4120
var topLevelTypes = EventConstants.topLevelTypes;
4121
4122
/**
4123
* Mobile Safari does not fire properly bubble click events on non-interactive
4124
* elements, which means delegated click listeners do not fire. The workaround
4125
* for this bug involves attaching an empty click listener on the target node.
4126
*
4127
* This particular plugin works around the bug by attaching an empty click
4128
* listener on `touchstart` (which does fire on every element).
4129
*/
4130
var MobileSafariClickEventPlugin = {
4131
4132
eventTypes: null,
4133
4134
/**
4135
* @param {string} topLevelType Record from `EventConstants`.
4136
* @param {DOMEventTarget} topLevelTarget The listening component root node.
4137
* @param {string} topLevelTargetID ID of `topLevelTarget`.
4138
* @param {object} nativeEvent Native browser event.
4139
* @return {*} An accumulation of synthetic events.
4140
* @see {EventPluginHub.extractEvents}
4141
*/
4142
extractEvents: function(
4143
topLevelType,
4144
topLevelTarget,
4145
topLevelTargetID,
4146
nativeEvent) {
4147
if (topLevelType === topLevelTypes.topTouchStart) {
4148
var target = nativeEvent.target;
4149
if (target && !target.onclick) {
4150
target.onclick = emptyFunction;
4151
}
4152
}
4153
}
4154
4155
};
4156
4157
module.exports = MobileSafariClickEventPlugin;
4158
4159
},{"114":114,"15":15}],27:[function(_dereq_,module,exports){
4160
/**
4161
* Copyright 2014-2015, Facebook, Inc.
4162
* All rights reserved.
4163
*
4164
* This source code is licensed under the BSD-style license found in the
4165
* LICENSE file in the root directory of this source tree. An additional grant
4166
* of patent rights can be found in the PATENTS file in the same directory.
4167
*
4168
* @providesModule Object.assign
4169
*/
4170
4171
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
4172
4173
'use strict';
4174
4175
function assign(target, sources) {
4176
if (target == null) {
4177
throw new TypeError('Object.assign target cannot be null or undefined');
4178
}
4179
4180
var to = Object(target);
4181
var hasOwnProperty = Object.prototype.hasOwnProperty;
4182
4183
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
4184
var nextSource = arguments[nextIndex];
4185
if (nextSource == null) {
4186
continue;
4187
}
4188
4189
var from = Object(nextSource);
4190
4191
// We don't currently support accessors nor proxies. Therefore this
4192
// copy cannot throw. If we ever supported this then we must handle
4193
// exceptions and side-effects. We don't support symbols so they won't
4194
// be transferred.
4195
4196
for (var key in from) {
4197
if (hasOwnProperty.call(from, key)) {
4198
to[key] = from[key];
4199
}
4200
}
4201
}
4202
4203
return to;
4204
}
4205
4206
module.exports = assign;
4207
4208
},{}],28:[function(_dereq_,module,exports){
4209
/**
4210
* Copyright 2013-2015, Facebook, Inc.
4211
* All rights reserved.
4212
*
4213
* This source code is licensed under the BSD-style license found in the
4214
* LICENSE file in the root directory of this source tree. An additional grant
4215
* of patent rights can be found in the PATENTS file in the same directory.
4216
*
4217
* @providesModule PooledClass
4218
*/
4219
4220
'use strict';
4221
4222
var invariant = _dereq_(135);
4223
4224
/**
4225
* Static poolers. Several custom versions for each potential number of
4226
* arguments. A completely generic pooler is easy to implement, but would
4227
* require accessing the `arguments` object. In each of these, `this` refers to
4228
* the Class itself, not an instance. If any others are needed, simply add them
4229
* here, or in their own files.
4230
*/
4231
var oneArgumentPooler = function(copyFieldsFrom) {
4232
var Klass = this;
4233
if (Klass.instancePool.length) {
4234
var instance = Klass.instancePool.pop();
4235
Klass.call(instance, copyFieldsFrom);
4236
return instance;
4237
} else {
4238
return new Klass(copyFieldsFrom);
4239
}
4240
};
4241
4242
var twoArgumentPooler = function(a1, a2) {
4243
var Klass = this;
4244
if (Klass.instancePool.length) {
4245
var instance = Klass.instancePool.pop();
4246
Klass.call(instance, a1, a2);
4247
return instance;
4248
} else {
4249
return new Klass(a1, a2);
4250
}
4251
};
4252
4253
var threeArgumentPooler = function(a1, a2, a3) {
4254
var Klass = this;
4255
if (Klass.instancePool.length) {
4256
var instance = Klass.instancePool.pop();
4257
Klass.call(instance, a1, a2, a3);
4258
return instance;
4259
} else {
4260
return new Klass(a1, a2, a3);
4261
}
4262
};
4263
4264
var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
4265
var Klass = this;
4266
if (Klass.instancePool.length) {
4267
var instance = Klass.instancePool.pop();
4268
Klass.call(instance, a1, a2, a3, a4, a5);
4269
return instance;
4270
} else {
4271
return new Klass(a1, a2, a3, a4, a5);
4272
}
4273
};
4274
4275
var standardReleaser = function(instance) {
4276
var Klass = this;
4277
("production" !== "development" ? invariant(
4278
instance instanceof Klass,
4279
'Trying to release an instance into a pool of a different type.'
4280
) : invariant(instance instanceof Klass));
4281
if (instance.destructor) {
4282
instance.destructor();
4283
}
4284
if (Klass.instancePool.length < Klass.poolSize) {
4285
Klass.instancePool.push(instance);
4286
}
4287
};
4288
4289
var DEFAULT_POOL_SIZE = 10;
4290
var DEFAULT_POOLER = oneArgumentPooler;
4291
4292
/**
4293
* Augments `CopyConstructor` to be a poolable class, augmenting only the class
4294
* itself (statically) not adding any prototypical fields. Any CopyConstructor
4295
* you give this may have a `poolSize` property, and will look for a
4296
* prototypical `destructor` on instances (optional).
4297
*
4298
* @param {Function} CopyConstructor Constructor that can be used to reset.
4299
* @param {Function} pooler Customizable pooler.
4300
*/
4301
var addPoolingTo = function(CopyConstructor, pooler) {
4302
var NewKlass = CopyConstructor;
4303
NewKlass.instancePool = [];
4304
NewKlass.getPooled = pooler || DEFAULT_POOLER;
4305
if (!NewKlass.poolSize) {
4306
NewKlass.poolSize = DEFAULT_POOL_SIZE;
4307
}
4308
NewKlass.release = standardReleaser;
4309
return NewKlass;
4310
};
4311
4312
var PooledClass = {
4313
addPoolingTo: addPoolingTo,
4314
oneArgumentPooler: oneArgumentPooler,
4315
twoArgumentPooler: twoArgumentPooler,
4316
threeArgumentPooler: threeArgumentPooler,
4317
fiveArgumentPooler: fiveArgumentPooler
4318
};
4319
4320
module.exports = PooledClass;
4321
4322
},{"135":135}],29:[function(_dereq_,module,exports){
4323
/**
4324
* Copyright 2013-2015, Facebook, Inc.
4325
* All rights reserved.
4326
*
4327
* This source code is licensed under the BSD-style license found in the
4328
* LICENSE file in the root directory of this source tree. An additional grant
4329
* of patent rights can be found in the PATENTS file in the same directory.
4330
*
4331
* @providesModule ReactBrowserComponentMixin
4332
*/
4333
4334
'use strict';
4335
4336
var findDOMNode = _dereq_(117);
4337
4338
var ReactBrowserComponentMixin = {
4339
/**
4340
* Returns the DOM node rendered by this component.
4341
*
4342
* @return {DOMElement} The root node of this component.
4343
* @final
4344
* @protected
4345
*/
4346
getDOMNode: function() {
4347
return findDOMNode(this);
4348
}
4349
};
4350
4351
module.exports = ReactBrowserComponentMixin;
4352
4353
},{"117":117}],30:[function(_dereq_,module,exports){
4354
/**
4355
* Copyright 2013-2015, Facebook, Inc.
4356
* All rights reserved.
4357
*
4358
* This source code is licensed under the BSD-style license found in the
4359
* LICENSE file in the root directory of this source tree. An additional grant
4360
* of patent rights can be found in the PATENTS file in the same directory.
4361
*
4362
* @providesModule ReactBrowserEventEmitter
4363
* @typechecks static-only
4364
*/
4365
4366
'use strict';
4367
4368
var EventConstants = _dereq_(15);
4369
var EventPluginHub = _dereq_(17);
4370
var EventPluginRegistry = _dereq_(18);
4371
var ReactEventEmitterMixin = _dereq_(61);
4372
var ViewportMetrics = _dereq_(104);
4373
4374
var assign = _dereq_(27);
4375
var isEventSupported = _dereq_(136);
4376
4377
/**
4378
* Summary of `ReactBrowserEventEmitter` event handling:
4379
*
4380
* - Top-level delegation is used to trap most native browser events. This
4381
* may only occur in the main thread and is the responsibility of
4382
* ReactEventListener, which is injected and can therefore support pluggable
4383
* event sources. This is the only work that occurs in the main thread.
4384
*
4385
* - We normalize and de-duplicate events to account for browser quirks. This
4386
* may be done in the worker thread.
4387
*
4388
* - Forward these native events (with the associated top-level type used to
4389
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
4390
* to extract any synthetic events.
4391
*
4392
* - The `EventPluginHub` will then process each event by annotating them with
4393
* "dispatches", a sequence of listeners and IDs that care about that event.
4394
*
4395
* - The `EventPluginHub` then dispatches the events.
4396
*
4397
* Overview of React and the event system:
4398
*
4399
* +------------+ .
4400
* | DOM | .
4401
* +------------+ .
4402
* | .
4403
* v .
4404
* +------------+ .
4405
* | ReactEvent | .
4406
* | Listener | .
4407
* +------------+ . +-----------+
4408
* | . +--------+|SimpleEvent|
4409
* | . | |Plugin |
4410
* +-----|------+ . v +-----------+
4411
* | | | . +--------------+ +------------+
4412
* | +-----------.--->|EventPluginHub| | Event |
4413
* | | . | | +-----------+ | Propagators|
4414
* | ReactEvent | . | | |TapEvent | |------------|
4415
* | Emitter | . | |<---+|Plugin | |other plugin|
4416
* | | . | | +-----------+ | utilities |
4417
* | +-----------.--->| | +------------+
4418
* | | | . +--------------+
4419
* +-----|------+ . ^ +-----------+
4420
* | . | |Enter/Leave|
4421
* + . +-------+|Plugin |
4422
* +-------------+ . +-----------+
4423
* | application | .
4424
* |-------------| .
4425
* | | .
4426
* | | .
4427
* +-------------+ .
4428
* .
4429
* React Core . General Purpose Event Plugin System
4430
*/
4431
4432
var alreadyListeningTo = {};
4433
var isMonitoringScrollValue = false;
4434
var reactTopListenersCounter = 0;
4435
4436
// For events like 'submit' which don't consistently bubble (which we trap at a
4437
// lower node than `document`), binding at `document` would cause duplicate
4438
// events so we don't include them here
4439
var topEventMapping = {
4440
topBlur: 'blur',
4441
topChange: 'change',
4442
topClick: 'click',
4443
topCompositionEnd: 'compositionend',
4444
topCompositionStart: 'compositionstart',
4445
topCompositionUpdate: 'compositionupdate',
4446
topContextMenu: 'contextmenu',
4447
topCopy: 'copy',
4448
topCut: 'cut',
4449
topDoubleClick: 'dblclick',
4450
topDrag: 'drag',
4451
topDragEnd: 'dragend',
4452
topDragEnter: 'dragenter',
4453
topDragExit: 'dragexit',
4454
topDragLeave: 'dragleave',
4455
topDragOver: 'dragover',
4456
topDragStart: 'dragstart',
4457
topDrop: 'drop',
4458
topFocus: 'focus',
4459
topInput: 'input',
4460
topKeyDown: 'keydown',
4461
topKeyPress: 'keypress',
4462
topKeyUp: 'keyup',
4463
topMouseDown: 'mousedown',
4464
topMouseMove: 'mousemove',
4465
topMouseOut: 'mouseout',
4466
topMouseOver: 'mouseover',
4467
topMouseUp: 'mouseup',
4468
topPaste: 'paste',
4469
topScroll: 'scroll',
4470
topSelectionChange: 'selectionchange',
4471
topTextInput: 'textInput',
4472
topTouchCancel: 'touchcancel',
4473
topTouchEnd: 'touchend',
4474
topTouchMove: 'touchmove',
4475
topTouchStart: 'touchstart',
4476
topWheel: 'wheel'
4477
};
4478
4479
/**
4480
* To ensure no conflicts with other potential React instances on the page
4481
*/
4482
var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2);
4483
4484
function getListeningForDocument(mountAt) {
4485
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
4486
// directly.
4487
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
4488
mountAt[topListenersIDKey] = reactTopListenersCounter++;
4489
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
4490
}
4491
return alreadyListeningTo[mountAt[topListenersIDKey]];
4492
}
4493
4494
/**
4495
* `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
4496
* example:
4497
*
4498
* ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
4499
*
4500
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
4501
*
4502
* @internal
4503
*/
4504
var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
4505
4506
/**
4507
* Injectable event backend
4508
*/
4509
ReactEventListener: null,
4510
4511
injection: {
4512
/**
4513
* @param {object} ReactEventListener
4514
*/
4515
injectReactEventListener: function(ReactEventListener) {
4516
ReactEventListener.setHandleTopLevel(
4517
ReactBrowserEventEmitter.handleTopLevel
4518
);
4519
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
4520
}
4521
},
4522
4523
/**
4524
* Sets whether or not any created callbacks should be enabled.
4525
*
4526
* @param {boolean} enabled True if callbacks should be enabled.
4527
*/
4528
setEnabled: function(enabled) {
4529
if (ReactBrowserEventEmitter.ReactEventListener) {
4530
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
4531
}
4532
},
4533
4534
/**
4535
* @return {boolean} True if callbacks are enabled.
4536
*/
4537
isEnabled: function() {
4538
return !!(
4539
(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled())
4540
);
4541
},
4542
4543
/**
4544
* We listen for bubbled touch events on the document object.
4545
*
4546
* Firefox v8.01 (and possibly others) exhibited strange behavior when
4547
* mounting `onmousemove` events at some node that was not the document
4548
* element. The symptoms were that if your mouse is not moving over something
4549
* contained within that mount point (for example on the background) the
4550
* top-level listeners for `onmousemove` won't be called. However, if you
4551
* register the `mousemove` on the document object, then it will of course
4552
* catch all `mousemove`s. This along with iOS quirks, justifies restricting
4553
* top-level listeners to the document object only, at least for these
4554
* movement types of events and possibly all events.
4555
*
4556
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
4557
*
4558
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
4559
* they bubble to document.
4560
*
4561
* @param {string} registrationName Name of listener (e.g. `onClick`).
4562
* @param {object} contentDocumentHandle Document which owns the container
4563
*/
4564
listenTo: function(registrationName, contentDocumentHandle) {
4565
var mountAt = contentDocumentHandle;
4566
var isListening = getListeningForDocument(mountAt);
4567
var dependencies = EventPluginRegistry.
4568
registrationNameDependencies[registrationName];
4569
4570
var topLevelTypes = EventConstants.topLevelTypes;
4571
for (var i = 0, l = dependencies.length; i < l; i++) {
4572
var dependency = dependencies[i];
4573
if (!(
4574
(isListening.hasOwnProperty(dependency) && isListening[dependency])
4575
)) {
4576
if (dependency === topLevelTypes.topWheel) {
4577
if (isEventSupported('wheel')) {
4578
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4579
topLevelTypes.topWheel,
4580
'wheel',
4581
mountAt
4582
);
4583
} else if (isEventSupported('mousewheel')) {
4584
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4585
topLevelTypes.topWheel,
4586
'mousewheel',
4587
mountAt
4588
);
4589
} else {
4590
// Firefox needs to capture a different mouse scroll event.
4591
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
4592
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4593
topLevelTypes.topWheel,
4594
'DOMMouseScroll',
4595
mountAt
4596
);
4597
}
4598
} else if (dependency === topLevelTypes.topScroll) {
4599
4600
if (isEventSupported('scroll', true)) {
4601
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4602
topLevelTypes.topScroll,
4603
'scroll',
4604
mountAt
4605
);
4606
} else {
4607
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4608
topLevelTypes.topScroll,
4609
'scroll',
4610
ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
4611
);
4612
}
4613
} else if (dependency === topLevelTypes.topFocus ||
4614
dependency === topLevelTypes.topBlur) {
4615
4616
if (isEventSupported('focus', true)) {
4617
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4618
topLevelTypes.topFocus,
4619
'focus',
4620
mountAt
4621
);
4622
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4623
topLevelTypes.topBlur,
4624
'blur',
4625
mountAt
4626
);
4627
} else if (isEventSupported('focusin')) {
4628
// IE has `focusin` and `focusout` events which bubble.
4629
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
4630
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4631
topLevelTypes.topFocus,
4632
'focusin',
4633
mountAt
4634
);
4635
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4636
topLevelTypes.topBlur,
4637
'focusout',
4638
mountAt
4639
);
4640
}
4641
4642
// to make sure blur and focus event listeners are only attached once
4643
isListening[topLevelTypes.topBlur] = true;
4644
isListening[topLevelTypes.topFocus] = true;
4645
} else if (topEventMapping.hasOwnProperty(dependency)) {
4646
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4647
dependency,
4648
topEventMapping[dependency],
4649
mountAt
4650
);
4651
}
4652
4653
isListening[dependency] = true;
4654
}
4655
}
4656
},
4657
4658
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
4659
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4660
topLevelType,
4661
handlerBaseName,
4662
handle
4663
);
4664
},
4665
4666
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
4667
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4668
topLevelType,
4669
handlerBaseName,
4670
handle
4671
);
4672
},
4673
4674
/**
4675
* Listens to window scroll and resize events. We cache scroll values so that
4676
* application code can access them without triggering reflows.
4677
*
4678
* NOTE: Scroll events do not bubble.
4679
*
4680
* @see http://www.quirksmode.org/dom/events/scroll.html
4681
*/
4682
ensureScrollValueMonitoring: function() {
4683
if (!isMonitoringScrollValue) {
4684
var refresh = ViewportMetrics.refreshScrollValues;
4685
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
4686
isMonitoringScrollValue = true;
4687
}
4688
},
4689
4690
eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
4691
4692
registrationNameModules: EventPluginHub.registrationNameModules,
4693
4694
putListener: EventPluginHub.putListener,
4695
4696
getListener: EventPluginHub.getListener,
4697
4698
deleteListener: EventPluginHub.deleteListener,
4699
4700
deleteAllListeners: EventPluginHub.deleteAllListeners
4701
4702
});
4703
4704
module.exports = ReactBrowserEventEmitter;
4705
4706
},{"104":104,"136":136,"15":15,"17":17,"18":18,"27":27,"61":61}],31:[function(_dereq_,module,exports){
4707
/**
4708
* Copyright 2014-2015, Facebook, Inc.
4709
* All rights reserved.
4710
*
4711
* This source code is licensed under the BSD-style license found in the
4712
* LICENSE file in the root directory of this source tree. An additional grant
4713
* of patent rights can be found in the PATENTS file in the same directory.
4714
*
4715
* @providesModule ReactChildReconciler
4716
* @typechecks static-only
4717
*/
4718
4719
'use strict';
4720
4721
var ReactReconciler = _dereq_(81);
4722
4723
var flattenChildren = _dereq_(118);
4724
var instantiateReactComponent = _dereq_(134);
4725
var shouldUpdateReactComponent = _dereq_(151);
4726
4727
/**
4728
* ReactChildReconciler provides helpers for initializing or updating a set of
4729
* children. Its output is suitable for passing it onto ReactMultiChild which
4730
* does diffed reordering and insertion.
4731
*/
4732
var ReactChildReconciler = {
4733
4734
/**
4735
* Generates a "mount image" for each of the supplied children. In the case
4736
* of `ReactDOMComponent`, a mount image is a string of markup.
4737
*
4738
* @param {?object} nestedChildNodes Nested child maps.
4739
* @return {?object} A set of child instances.
4740
* @internal
4741
*/
4742
instantiateChildren: function(nestedChildNodes, transaction, context) {
4743
var children = flattenChildren(nestedChildNodes);
4744
for (var name in children) {
4745
if (children.hasOwnProperty(name)) {
4746
var child = children[name];
4747
// The rendered children must be turned into instances as they're
4748
// mounted.
4749
var childInstance = instantiateReactComponent(child, null);
4750
children[name] = childInstance;
4751
}
4752
}
4753
return children;
4754
},
4755
4756
/**
4757
* Updates the rendered children and returns a new set of children.
4758
*
4759
* @param {?object} prevChildren Previously initialized set of children.
4760
* @param {?object} nextNestedChildNodes Nested child maps.
4761
* @param {ReactReconcileTransaction} transaction
4762
* @param {object} context
4763
* @return {?object} A new set of child instances.
4764
* @internal
4765
*/
4766
updateChildren: function(
4767
prevChildren,
4768
nextNestedChildNodes,
4769
transaction,
4770
context) {
4771
// We currently don't have a way to track moves here but if we use iterators
4772
// instead of for..in we can zip the iterators and check if an item has
4773
// moved.
4774
// TODO: If nothing has changed, return the prevChildren object so that we
4775
// can quickly bailout if nothing has changed.
4776
var nextChildren = flattenChildren(nextNestedChildNodes);
4777
if (!nextChildren && !prevChildren) {
4778
return null;
4779
}
4780
var name;
4781
for (name in nextChildren) {
4782
if (!nextChildren.hasOwnProperty(name)) {
4783
continue;
4784
}
4785
var prevChild = prevChildren && prevChildren[name];
4786
var prevElement = prevChild && prevChild._currentElement;
4787
var nextElement = nextChildren[name];
4788
if (shouldUpdateReactComponent(prevElement, nextElement)) {
4789
ReactReconciler.receiveComponent(
4790
prevChild, nextElement, transaction, context
4791
);
4792
nextChildren[name] = prevChild;
4793
} else {
4794
if (prevChild) {
4795
ReactReconciler.unmountComponent(prevChild, name);
4796
}
4797
// The child must be instantiated before it's mounted.
4798
var nextChildInstance = instantiateReactComponent(
4799
nextElement,
4800
null
4801
);
4802
nextChildren[name] = nextChildInstance;
4803
}
4804
}
4805
// Unmount children that are no longer present.
4806
for (name in prevChildren) {
4807
if (prevChildren.hasOwnProperty(name) &&
4808
!(nextChildren && nextChildren.hasOwnProperty(name))) {
4809
ReactReconciler.unmountComponent(prevChildren[name]);
4810
}
4811
}
4812
return nextChildren;
4813
},
4814
4815
/**
4816
* Unmounts all rendered children. This should be used to clean up children
4817
* when this component is unmounted.
4818
*
4819
* @param {?object} renderedChildren Previously initialized set of children.
4820
* @internal
4821
*/
4822
unmountChildren: function(renderedChildren) {
4823
for (var name in renderedChildren) {
4824
var renderedChild = renderedChildren[name];
4825
ReactReconciler.unmountComponent(renderedChild);
4826
}
4827
}
4828
4829
};
4830
4831
module.exports = ReactChildReconciler;
4832
4833
},{"118":118,"134":134,"151":151,"81":81}],32:[function(_dereq_,module,exports){
4834
/**
4835
* Copyright 2013-2015, Facebook, Inc.
4836
* All rights reserved.
4837
*
4838
* This source code is licensed under the BSD-style license found in the
4839
* LICENSE file in the root directory of this source tree. An additional grant
4840
* of patent rights can be found in the PATENTS file in the same directory.
4841
*
4842
* @providesModule ReactChildren
4843
*/
4844
4845
'use strict';
4846
4847
var PooledClass = _dereq_(28);
4848
var ReactFragment = _dereq_(63);
4849
4850
var traverseAllChildren = _dereq_(153);
4851
var warning = _dereq_(154);
4852
4853
var twoArgumentPooler = PooledClass.twoArgumentPooler;
4854
var threeArgumentPooler = PooledClass.threeArgumentPooler;
4855
4856
/**
4857
* PooledClass representing the bookkeeping associated with performing a child
4858
* traversal. Allows avoiding binding callbacks.
4859
*
4860
* @constructor ForEachBookKeeping
4861
* @param {!function} forEachFunction Function to perform traversal with.
4862
* @param {?*} forEachContext Context to perform context with.
4863
*/
4864
function ForEachBookKeeping(forEachFunction, forEachContext) {
4865
this.forEachFunction = forEachFunction;
4866
this.forEachContext = forEachContext;
4867
}
4868
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
4869
4870
function forEachSingleChild(traverseContext, child, name, i) {
4871
var forEachBookKeeping = traverseContext;
4872
forEachBookKeeping.forEachFunction.call(
4873
forEachBookKeeping.forEachContext, child, i);
4874
}
4875
4876
/**
4877
* Iterates through children that are typically specified as `props.children`.
4878
*
4879
* The provided forEachFunc(child, index) will be called for each
4880
* leaf child.
4881
*
4882
* @param {?*} children Children tree container.
4883
* @param {function(*, int)} forEachFunc.
4884
* @param {*} forEachContext Context for forEachContext.
4885
*/
4886
function forEachChildren(children, forEachFunc, forEachContext) {
4887
if (children == null) {
4888
return children;
4889
}
4890
4891
var traverseContext =
4892
ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
4893
traverseAllChildren(children, forEachSingleChild, traverseContext);
4894
ForEachBookKeeping.release(traverseContext);
4895
}
4896
4897
/**
4898
* PooledClass representing the bookkeeping associated with performing a child
4899
* mapping. Allows avoiding binding callbacks.
4900
*
4901
* @constructor MapBookKeeping
4902
* @param {!*} mapResult Object containing the ordered map of results.
4903
* @param {!function} mapFunction Function to perform mapping with.
4904
* @param {?*} mapContext Context to perform mapping with.
4905
*/
4906
function MapBookKeeping(mapResult, mapFunction, mapContext) {
4907
this.mapResult = mapResult;
4908
this.mapFunction = mapFunction;
4909
this.mapContext = mapContext;
4910
}
4911
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
4912
4913
function mapSingleChildIntoContext(traverseContext, child, name, i) {
4914
var mapBookKeeping = traverseContext;
4915
var mapResult = mapBookKeeping.mapResult;
4916
4917
var keyUnique = !mapResult.hasOwnProperty(name);
4918
if ("production" !== "development") {
4919
("production" !== "development" ? warning(
4920
keyUnique,
4921
'ReactChildren.map(...): Encountered two children with the same key, ' +
4922
'`%s`. Child keys must be unique; when two children share a key, only ' +
4923
'the first child will be used.',
4924
name
4925
) : null);
4926
}
4927
4928
if (keyUnique) {
4929
var mappedChild =
4930
mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
4931
mapResult[name] = mappedChild;
4932
}
4933
}
4934
4935
/**
4936
* Maps children that are typically specified as `props.children`.
4937
*
4938
* The provided mapFunction(child, key, index) will be called for each
4939
* leaf child.
4940
*
4941
* TODO: This may likely break any calls to `ReactChildren.map` that were
4942
* previously relying on the fact that we guarded against null children.
4943
*
4944
* @param {?*} children Children tree container.
4945
* @param {function(*, int)} mapFunction.
4946
* @param {*} mapContext Context for mapFunction.
4947
* @return {object} Object containing the ordered map of results.
4948
*/
4949
function mapChildren(children, func, context) {
4950
if (children == null) {
4951
return children;
4952
}
4953
4954
var mapResult = {};
4955
var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
4956
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
4957
MapBookKeeping.release(traverseContext);
4958
return ReactFragment.create(mapResult);
4959
}
4960
4961
function forEachSingleChildDummy(traverseContext, child, name, i) {
4962
return null;
4963
}
4964
4965
/**
4966
* Count the number of children that are typically specified as
4967
* `props.children`.
4968
*
4969
* @param {?*} children Children tree container.
4970
* @return {number} The number of children.
4971
*/
4972
function countChildren(children, context) {
4973
return traverseAllChildren(children, forEachSingleChildDummy, null);
4974
}
4975
4976
var ReactChildren = {
4977
forEach: forEachChildren,
4978
map: mapChildren,
4979
count: countChildren
4980
};
4981
4982
module.exports = ReactChildren;
4983
4984
},{"153":153,"154":154,"28":28,"63":63}],33:[function(_dereq_,module,exports){
4985
/**
4986
* Copyright 2013-2015, Facebook, Inc.
4987
* All rights reserved.
4988
*
4989
* This source code is licensed under the BSD-style license found in the
4990
* LICENSE file in the root directory of this source tree. An additional grant
4991
* of patent rights can be found in the PATENTS file in the same directory.
4992
*
4993
* @providesModule ReactClass
4994
*/
4995
4996
'use strict';
4997
4998
var ReactComponent = _dereq_(34);
4999
var ReactCurrentOwner = _dereq_(39);
5000
var ReactElement = _dereq_(57);
5001
var ReactErrorUtils = _dereq_(60);
5002
var ReactInstanceMap = _dereq_(67);
5003
var ReactLifeCycle = _dereq_(68);
5004
var ReactPropTypeLocations = _dereq_(77);
5005
var ReactPropTypeLocationNames = _dereq_(76);
5006
var ReactUpdateQueue = _dereq_(86);
5007
5008
var assign = _dereq_(27);
5009
var invariant = _dereq_(135);
5010
var keyMirror = _dereq_(140);
5011
var keyOf = _dereq_(141);
5012
var warning = _dereq_(154);
5013
5014
var MIXINS_KEY = keyOf({mixins: null});
5015
5016
/**
5017
* Policies that describe methods in `ReactClassInterface`.
5018
*/
5019
var SpecPolicy = keyMirror({
5020
/**
5021
* These methods may be defined only once by the class specification or mixin.
5022
*/
5023
DEFINE_ONCE: null,
5024
/**
5025
* These methods may be defined by both the class specification and mixins.
5026
* Subsequent definitions will be chained. These methods must return void.
5027
*/
5028
DEFINE_MANY: null,
5029
/**
5030
* These methods are overriding the base class.
5031
*/
5032
OVERRIDE_BASE: null,
5033
/**
5034
* These methods are similar to DEFINE_MANY, except we assume they return
5035
* objects. We try to merge the keys of the return values of all the mixed in
5036
* functions. If there is a key conflict we throw.
5037
*/
5038
DEFINE_MANY_MERGED: null
5039
});
5040
5041
5042
var injectedMixins = [];
5043
5044
/**
5045
* Composite components are higher-level components that compose other composite
5046
* or native components.
5047
*
5048
* To create a new type of `ReactClass`, pass a specification of
5049
* your new class to `React.createClass`. The only requirement of your class
5050
* specification is that you implement a `render` method.
5051
*
5052
* var MyComponent = React.createClass({
5053
* render: function() {
5054
* return <div>Hello World</div>;
5055
* }
5056
* });
5057
*
5058
* The class specification supports a specific protocol of methods that have
5059
* special meaning (e.g. `render`). See `ReactClassInterface` for
5060
* more the comprehensive protocol. Any other properties and methods in the
5061
* class specification will available on the prototype.
5062
*
5063
* @interface ReactClassInterface
5064
* @internal
5065
*/
5066
var ReactClassInterface = {
5067
5068
/**
5069
* An array of Mixin objects to include when defining your component.
5070
*
5071
* @type {array}
5072
* @optional
5073
*/
5074
mixins: SpecPolicy.DEFINE_MANY,
5075
5076
/**
5077
* An object containing properties and methods that should be defined on
5078
* the component's constructor instead of its prototype (static methods).
5079
*
5080
* @type {object}
5081
* @optional
5082
*/
5083
statics: SpecPolicy.DEFINE_MANY,
5084
5085
/**
5086
* Definition of prop types for this component.
5087
*
5088
* @type {object}
5089
* @optional
5090
*/
5091
propTypes: SpecPolicy.DEFINE_MANY,
5092
5093
/**
5094
* Definition of context types for this component.
5095
*
5096
* @type {object}
5097
* @optional
5098
*/
5099
contextTypes: SpecPolicy.DEFINE_MANY,
5100
5101
/**
5102
* Definition of context types this component sets for its children.
5103
*
5104
* @type {object}
5105
* @optional
5106
*/
5107
childContextTypes: SpecPolicy.DEFINE_MANY,
5108
5109
// ==== Definition methods ====
5110
5111
/**
5112
* Invoked when the component is mounted. Values in the mapping will be set on
5113
* `this.props` if that prop is not specified (i.e. using an `in` check).
5114
*
5115
* This method is invoked before `getInitialState` and therefore cannot rely
5116
* on `this.state` or use `this.setState`.
5117
*
5118
* @return {object}
5119
* @optional
5120
*/
5121
getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
5122
5123
/**
5124
* Invoked once before the component is mounted. The return value will be used
5125
* as the initial value of `this.state`.
5126
*
5127
* getInitialState: function() {
5128
* return {
5129
* isOn: false,
5130
* fooBaz: new BazFoo()
5131
* }
5132
* }
5133
*
5134
* @return {object}
5135
* @optional
5136
*/
5137
getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
5138
5139
/**
5140
* @return {object}
5141
* @optional
5142
*/
5143
getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
5144
5145
/**
5146
* Uses props from `this.props` and state from `this.state` to render the
5147
* structure of the component.
5148
*
5149
* No guarantees are made about when or how often this method is invoked, so
5150
* it must not have side effects.
5151
*
5152
* render: function() {
5153
* var name = this.props.name;
5154
* return <div>Hello, {name}!</div>;
5155
* }
5156
*
5157
* @return {ReactComponent}
5158
* @nosideeffects
5159
* @required
5160
*/
5161
render: SpecPolicy.DEFINE_ONCE,
5162
5163
5164
5165
// ==== Delegate methods ====
5166
5167
/**
5168
* Invoked when the component is initially created and about to be mounted.
5169
* This may have side effects, but any external subscriptions or data created
5170
* by this method must be cleaned up in `componentWillUnmount`.
5171
*
5172
* @optional
5173
*/
5174
componentWillMount: SpecPolicy.DEFINE_MANY,
5175
5176
/**
5177
* Invoked when the component has been mounted and has a DOM representation.
5178
* However, there is no guarantee that the DOM node is in the document.
5179
*
5180
* Use this as an opportunity to operate on the DOM when the component has
5181
* been mounted (initialized and rendered) for the first time.
5182
*
5183
* @param {DOMElement} rootNode DOM element representing the component.
5184
* @optional
5185
*/
5186
componentDidMount: SpecPolicy.DEFINE_MANY,
5187
5188
/**
5189
* Invoked before the component receives new props.
5190
*
5191
* Use this as an opportunity to react to a prop transition by updating the
5192
* state using `this.setState`. Current props are accessed via `this.props`.
5193
*
5194
* componentWillReceiveProps: function(nextProps, nextContext) {
5195
* this.setState({
5196
* likesIncreasing: nextProps.likeCount > this.props.likeCount
5197
* });
5198
* }
5199
*
5200
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
5201
* transition may cause a state change, but the opposite is not true. If you
5202
* need it, you are probably looking for `componentWillUpdate`.
5203
*
5204
* @param {object} nextProps
5205
* @optional
5206
*/
5207
componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
5208
5209
/**
5210
* Invoked while deciding if the component should be updated as a result of
5211
* receiving new props, state and/or context.
5212
*
5213
* Use this as an opportunity to `return false` when you're certain that the
5214
* transition to the new props/state/context will not require a component
5215
* update.
5216
*
5217
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
5218
* return !equal(nextProps, this.props) ||
5219
* !equal(nextState, this.state) ||
5220
* !equal(nextContext, this.context);
5221
* }
5222
*
5223
* @param {object} nextProps
5224
* @param {?object} nextState
5225
* @param {?object} nextContext
5226
* @return {boolean} True if the component should update.
5227
* @optional
5228
*/
5229
shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
5230
5231
/**
5232
* Invoked when the component is about to update due to a transition from
5233
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
5234
* and `nextContext`.
5235
*
5236
* Use this as an opportunity to perform preparation before an update occurs.
5237
*
5238
* NOTE: You **cannot** use `this.setState()` in this method.
5239
*
5240
* @param {object} nextProps
5241
* @param {?object} nextState
5242
* @param {?object} nextContext
5243
* @param {ReactReconcileTransaction} transaction
5244
* @optional
5245
*/
5246
componentWillUpdate: SpecPolicy.DEFINE_MANY,
5247
5248
/**
5249
* Invoked when the component's DOM representation has been updated.
5250
*
5251
* Use this as an opportunity to operate on the DOM when the component has
5252
* been updated.
5253
*
5254
* @param {object} prevProps
5255
* @param {?object} prevState
5256
* @param {?object} prevContext
5257
* @param {DOMElement} rootNode DOM element representing the component.
5258
* @optional
5259
*/
5260
componentDidUpdate: SpecPolicy.DEFINE_MANY,
5261
5262
/**
5263
* Invoked when the component is about to be removed from its parent and have
5264
* its DOM representation destroyed.
5265
*
5266
* Use this as an opportunity to deallocate any external resources.
5267
*
5268
* NOTE: There is no `componentDidUnmount` since your component will have been
5269
* destroyed by that point.
5270
*
5271
* @optional
5272
*/
5273
componentWillUnmount: SpecPolicy.DEFINE_MANY,
5274
5275
5276
5277
// ==== Advanced methods ====
5278
5279
/**
5280
* Updates the component's currently mounted DOM representation.
5281
*
5282
* By default, this implements React's rendering and reconciliation algorithm.
5283
* Sophisticated clients may wish to override this.
5284
*
5285
* @param {ReactReconcileTransaction} transaction
5286
* @internal
5287
* @overridable
5288
*/
5289
updateComponent: SpecPolicy.OVERRIDE_BASE
5290
5291
};
5292
5293
/**
5294
* Mapping from class specification keys to special processing functions.
5295
*
5296
* Although these are declared like instance properties in the specification
5297
* when defining classes using `React.createClass`, they are actually static
5298
* and are accessible on the constructor instead of the prototype. Despite
5299
* being static, they must be defined outside of the "statics" key under
5300
* which all other static methods are defined.
5301
*/
5302
var RESERVED_SPEC_KEYS = {
5303
displayName: function(Constructor, displayName) {
5304
Constructor.displayName = displayName;
5305
},
5306
mixins: function(Constructor, mixins) {
5307
if (mixins) {
5308
for (var i = 0; i < mixins.length; i++) {
5309
mixSpecIntoComponent(Constructor, mixins[i]);
5310
}
5311
}
5312
},
5313
childContextTypes: function(Constructor, childContextTypes) {
5314
if ("production" !== "development") {
5315
validateTypeDef(
5316
Constructor,
5317
childContextTypes,
5318
ReactPropTypeLocations.childContext
5319
);
5320
}
5321
Constructor.childContextTypes = assign(
5322
{},
5323
Constructor.childContextTypes,
5324
childContextTypes
5325
);
5326
},
5327
contextTypes: function(Constructor, contextTypes) {
5328
if ("production" !== "development") {
5329
validateTypeDef(
5330
Constructor,
5331
contextTypes,
5332
ReactPropTypeLocations.context
5333
);
5334
}
5335
Constructor.contextTypes = assign(
5336
{},
5337
Constructor.contextTypes,
5338
contextTypes
5339
);
5340
},
5341
/**
5342
* Special case getDefaultProps which should move into statics but requires
5343
* automatic merging.
5344
*/
5345
getDefaultProps: function(Constructor, getDefaultProps) {
5346
if (Constructor.getDefaultProps) {
5347
Constructor.getDefaultProps = createMergedResultFunction(
5348
Constructor.getDefaultProps,
5349
getDefaultProps
5350
);
5351
} else {
5352
Constructor.getDefaultProps = getDefaultProps;
5353
}
5354
},
5355
propTypes: function(Constructor, propTypes) {
5356
if ("production" !== "development") {
5357
validateTypeDef(
5358
Constructor,
5359
propTypes,
5360
ReactPropTypeLocations.prop
5361
);
5362
}
5363
Constructor.propTypes = assign(
5364
{},
5365
Constructor.propTypes,
5366
propTypes
5367
);
5368
},
5369
statics: function(Constructor, statics) {
5370
mixStaticSpecIntoComponent(Constructor, statics);
5371
}
5372
};
5373
5374
function validateTypeDef(Constructor, typeDef, location) {
5375
for (var propName in typeDef) {
5376
if (typeDef.hasOwnProperty(propName)) {
5377
// use a warning instead of an invariant so components
5378
// don't show up in prod but not in __DEV__
5379
("production" !== "development" ? warning(
5380
typeof typeDef[propName] === 'function',
5381
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
5382
'React.PropTypes.',
5383
Constructor.displayName || 'ReactClass',
5384
ReactPropTypeLocationNames[location],
5385
propName
5386
) : null);
5387
}
5388
}
5389
}
5390
5391
function validateMethodOverride(proto, name) {
5392
var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
5393
ReactClassInterface[name] :
5394
null;
5395
5396
// Disallow overriding of base class methods unless explicitly allowed.
5397
if (ReactClassMixin.hasOwnProperty(name)) {
5398
("production" !== "development" ? invariant(
5399
specPolicy === SpecPolicy.OVERRIDE_BASE,
5400
'ReactClassInterface: You are attempting to override ' +
5401
'`%s` from your class specification. Ensure that your method names ' +
5402
'do not overlap with React methods.',
5403
name
5404
) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
5405
}
5406
5407
// Disallow defining methods more than once unless explicitly allowed.
5408
if (proto.hasOwnProperty(name)) {
5409
("production" !== "development" ? invariant(
5410
specPolicy === SpecPolicy.DEFINE_MANY ||
5411
specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
5412
'ReactClassInterface: You are attempting to define ' +
5413
'`%s` on your component more than once. This conflict may be due ' +
5414
'to a mixin.',
5415
name
5416
) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
5417
specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
5418
}
5419
}
5420
5421
/**
5422
* Mixin helper which handles policy validation and reserved
5423
* specification keys when building React classses.
5424
*/
5425
function mixSpecIntoComponent(Constructor, spec) {
5426
if (!spec) {
5427
return;
5428
}
5429
5430
("production" !== "development" ? invariant(
5431
typeof spec !== 'function',
5432
'ReactClass: You\'re attempting to ' +
5433
'use a component class as a mixin. Instead, just use a regular object.'
5434
) : invariant(typeof spec !== 'function'));
5435
("production" !== "development" ? invariant(
5436
!ReactElement.isValidElement(spec),
5437
'ReactClass: You\'re attempting to ' +
5438
'use a component as a mixin. Instead, just use a regular object.'
5439
) : invariant(!ReactElement.isValidElement(spec)));
5440
5441
var proto = Constructor.prototype;
5442
5443
// By handling mixins before any other properties, we ensure the same
5444
// chaining order is applied to methods with DEFINE_MANY policy, whether
5445
// mixins are listed before or after these methods in the spec.
5446
if (spec.hasOwnProperty(MIXINS_KEY)) {
5447
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
5448
}
5449
5450
for (var name in spec) {
5451
if (!spec.hasOwnProperty(name)) {
5452
continue;
5453
}
5454
5455
if (name === MIXINS_KEY) {
5456
// We have already handled mixins in a special case above
5457
continue;
5458
}
5459
5460
var property = spec[name];
5461
validateMethodOverride(proto, name);
5462
5463
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
5464
RESERVED_SPEC_KEYS[name](Constructor, property);
5465
} else {
5466
// Setup methods on prototype:
5467
// The following member methods should not be automatically bound:
5468
// 1. Expected ReactClass methods (in the "interface").
5469
// 2. Overridden methods (that were mixed in).
5470
var isReactClassMethod =
5471
ReactClassInterface.hasOwnProperty(name);
5472
var isAlreadyDefined = proto.hasOwnProperty(name);
5473
var markedDontBind = property && property.__reactDontBind;
5474
var isFunction = typeof property === 'function';
5475
var shouldAutoBind =
5476
isFunction &&
5477
!isReactClassMethod &&
5478
!isAlreadyDefined &&
5479
!markedDontBind;
5480
5481
if (shouldAutoBind) {
5482
if (!proto.__reactAutoBindMap) {
5483
proto.__reactAutoBindMap = {};
5484
}
5485
proto.__reactAutoBindMap[name] = property;
5486
proto[name] = property;
5487
} else {
5488
if (isAlreadyDefined) {
5489
var specPolicy = ReactClassInterface[name];
5490
5491
// These cases should already be caught by validateMethodOverride
5492
("production" !== "development" ? invariant(
5493
isReactClassMethod && (
5494
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
5495
),
5496
'ReactClass: Unexpected spec policy %s for key %s ' +
5497
'when mixing in component specs.',
5498
specPolicy,
5499
name
5500
) : invariant(isReactClassMethod && (
5501
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
5502
)));
5503
5504
// For methods which are defined more than once, call the existing
5505
// methods before calling the new property, merging if appropriate.
5506
if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
5507
proto[name] = createMergedResultFunction(proto[name], property);
5508
} else if (specPolicy === SpecPolicy.DEFINE_MANY) {
5509
proto[name] = createChainedFunction(proto[name], property);
5510
}
5511
} else {
5512
proto[name] = property;
5513
if ("production" !== "development") {
5514
// Add verbose displayName to the function, which helps when looking
5515
// at profiling tools.
5516
if (typeof property === 'function' && spec.displayName) {
5517
proto[name].displayName = spec.displayName + '_' + name;
5518
}
5519
}
5520
}
5521
}
5522
}
5523
}
5524
}
5525
5526
function mixStaticSpecIntoComponent(Constructor, statics) {
5527
if (!statics) {
5528
return;
5529
}
5530
for (var name in statics) {
5531
var property = statics[name];
5532
if (!statics.hasOwnProperty(name)) {
5533
continue;
5534
}
5535
5536
var isReserved = name in RESERVED_SPEC_KEYS;
5537
("production" !== "development" ? invariant(
5538
!isReserved,
5539
'ReactClass: You are attempting to define a reserved ' +
5540
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
5541
'as an instance property instead; it will still be accessible on the ' +
5542
'constructor.',
5543
name
5544
) : invariant(!isReserved));
5545
5546
var isInherited = name in Constructor;
5547
("production" !== "development" ? invariant(
5548
!isInherited,
5549
'ReactClass: You are attempting to define ' +
5550
'`%s` on your component more than once. This conflict may be ' +
5551
'due to a mixin.',
5552
name
5553
) : invariant(!isInherited));
5554
Constructor[name] = property;
5555
}
5556
}
5557
5558
/**
5559
* Merge two objects, but throw if both contain the same key.
5560
*
5561
* @param {object} one The first object, which is mutated.
5562
* @param {object} two The second object
5563
* @return {object} one after it has been mutated to contain everything in two.
5564
*/
5565
function mergeIntoWithNoDuplicateKeys(one, two) {
5566
("production" !== "development" ? invariant(
5567
one && two && typeof one === 'object' && typeof two === 'object',
5568
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
5569
) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
5570
5571
for (var key in two) {
5572
if (two.hasOwnProperty(key)) {
5573
("production" !== "development" ? invariant(
5574
one[key] === undefined,
5575
'mergeIntoWithNoDuplicateKeys(): ' +
5576
'Tried to merge two objects with the same key: `%s`. This conflict ' +
5577
'may be due to a mixin; in particular, this may be caused by two ' +
5578
'getInitialState() or getDefaultProps() methods returning objects ' +
5579
'with clashing keys.',
5580
key
5581
) : invariant(one[key] === undefined));
5582
one[key] = two[key];
5583
}
5584
}
5585
return one;
5586
}
5587
5588
/**
5589
* Creates a function that invokes two functions and merges their return values.
5590
*
5591
* @param {function} one Function to invoke first.
5592
* @param {function} two Function to invoke second.
5593
* @return {function} Function that invokes the two argument functions.
5594
* @private
5595
*/
5596
function createMergedResultFunction(one, two) {
5597
return function mergedResult() {
5598
var a = one.apply(this, arguments);
5599
var b = two.apply(this, arguments);
5600
if (a == null) {
5601
return b;
5602
} else if (b == null) {
5603
return a;
5604
}
5605
var c = {};
5606
mergeIntoWithNoDuplicateKeys(c, a);
5607
mergeIntoWithNoDuplicateKeys(c, b);
5608
return c;
5609
};
5610
}
5611
5612
/**
5613
* Creates a function that invokes two functions and ignores their return vales.
5614
*
5615
* @param {function} one Function to invoke first.
5616
* @param {function} two Function to invoke second.
5617
* @return {function} Function that invokes the two argument functions.
5618
* @private
5619
*/
5620
function createChainedFunction(one, two) {
5621
return function chainedFunction() {
5622
one.apply(this, arguments);
5623
two.apply(this, arguments);
5624
};
5625
}
5626
5627
/**
5628
* Binds a method to the component.
5629
*
5630
* @param {object} component Component whose method is going to be bound.
5631
* @param {function} method Method to be bound.
5632
* @return {function} The bound method.
5633
*/
5634
function bindAutoBindMethod(component, method) {
5635
var boundMethod = method.bind(component);
5636
if ("production" !== "development") {
5637
boundMethod.__reactBoundContext = component;
5638
boundMethod.__reactBoundMethod = method;
5639
boundMethod.__reactBoundArguments = null;
5640
var componentName = component.constructor.displayName;
5641
var _bind = boundMethod.bind;
5642
/* eslint-disable block-scoped-var, no-undef */
5643
boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
5644
// User is trying to bind() an autobound method; we effectively will
5645
// ignore the value of "this" that the user is trying to use, so
5646
// let's warn.
5647
if (newThis !== component && newThis !== null) {
5648
("production" !== "development" ? warning(
5649
false,
5650
'bind(): React component methods may only be bound to the ' +
5651
'component instance. See %s',
5652
componentName
5653
) : null);
5654
} else if (!args.length) {
5655
("production" !== "development" ? warning(
5656
false,
5657
'bind(): You are binding a component method to the component. ' +
5658
'React does this for you automatically in a high-performance ' +
5659
'way, so you can safely remove this call. See %s',
5660
componentName
5661
) : null);
5662
return boundMethod;
5663
}
5664
var reboundMethod = _bind.apply(boundMethod, arguments);
5665
reboundMethod.__reactBoundContext = component;
5666
reboundMethod.__reactBoundMethod = method;
5667
reboundMethod.__reactBoundArguments = args;
5668
return reboundMethod;
5669
/* eslint-enable */
5670
};
5671
}
5672
return boundMethod;
5673
}
5674
5675
/**
5676
* Binds all auto-bound methods in a component.
5677
*
5678
* @param {object} component Component whose method is going to be bound.
5679
*/
5680
function bindAutoBindMethods(component) {
5681
for (var autoBindKey in component.__reactAutoBindMap) {
5682
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
5683
var method = component.__reactAutoBindMap[autoBindKey];
5684
component[autoBindKey] = bindAutoBindMethod(
5685
component,
5686
ReactErrorUtils.guard(
5687
method,
5688
component.constructor.displayName + '.' + autoBindKey
5689
)
5690
);
5691
}
5692
}
5693
}
5694
5695
var typeDeprecationDescriptor = {
5696
enumerable: false,
5697
get: function() {
5698
var displayName = this.displayName || this.name || 'Component';
5699
("production" !== "development" ? warning(
5700
false,
5701
'%s.type is deprecated. Use %s directly to access the class.',
5702
displayName,
5703
displayName
5704
) : null);
5705
Object.defineProperty(this, 'type', {
5706
value: this
5707
});
5708
return this;
5709
}
5710
};
5711
5712
/**
5713
* Add more to the ReactClass base class. These are all legacy features and
5714
* therefore not already part of the modern ReactComponent.
5715
*/
5716
var ReactClassMixin = {
5717
5718
/**
5719
* TODO: This will be deprecated because state should always keep a consistent
5720
* type signature and the only use case for this, is to avoid that.
5721
*/
5722
replaceState: function(newState, callback) {
5723
ReactUpdateQueue.enqueueReplaceState(this, newState);
5724
if (callback) {
5725
ReactUpdateQueue.enqueueCallback(this, callback);
5726
}
5727
},
5728
5729
/**
5730
* Checks whether or not this composite component is mounted.
5731
* @return {boolean} True if mounted, false otherwise.
5732
* @protected
5733
* @final
5734
*/
5735
isMounted: function() {
5736
if ("production" !== "development") {
5737
var owner = ReactCurrentOwner.current;
5738
if (owner !== null) {
5739
("production" !== "development" ? warning(
5740
owner._warnedAboutRefsInRender,
5741
'%s is accessing isMounted inside its render() function. ' +
5742
'render() should be a pure function of props and state. It should ' +
5743
'never access something that requires stale data from the previous ' +
5744
'render, such as refs. Move this logic to componentDidMount and ' +
5745
'componentDidUpdate instead.',
5746
owner.getName() || 'A component'
5747
) : null);
5748
owner._warnedAboutRefsInRender = true;
5749
}
5750
}
5751
var internalInstance = ReactInstanceMap.get(this);
5752
return (
5753
internalInstance &&
5754
internalInstance !== ReactLifeCycle.currentlyMountingInstance
5755
);
5756
},
5757
5758
/**
5759
* Sets a subset of the props.
5760
*
5761
* @param {object} partialProps Subset of the next props.
5762
* @param {?function} callback Called after props are updated.
5763
* @final
5764
* @public
5765
* @deprecated
5766
*/
5767
setProps: function(partialProps, callback) {
5768
ReactUpdateQueue.enqueueSetProps(this, partialProps);
5769
if (callback) {
5770
ReactUpdateQueue.enqueueCallback(this, callback);
5771
}
5772
},
5773
5774
/**
5775
* Replace all the props.
5776
*
5777
* @param {object} newProps Subset of the next props.
5778
* @param {?function} callback Called after props are updated.
5779
* @final
5780
* @public
5781
* @deprecated
5782
*/
5783
replaceProps: function(newProps, callback) {
5784
ReactUpdateQueue.enqueueReplaceProps(this, newProps);
5785
if (callback) {
5786
ReactUpdateQueue.enqueueCallback(this, callback);
5787
}
5788
}
5789
};
5790
5791
var ReactClassComponent = function() {};
5792
assign(
5793
ReactClassComponent.prototype,
5794
ReactComponent.prototype,
5795
ReactClassMixin
5796
);
5797
5798
/**
5799
* Module for creating composite components.
5800
*
5801
* @class ReactClass
5802
*/
5803
var ReactClass = {
5804
5805
/**
5806
* Creates a composite component class given a class specification.
5807
*
5808
* @param {object} spec Class specification (which must define `render`).
5809
* @return {function} Component constructor function.
5810
* @public
5811
*/
5812
createClass: function(spec) {
5813
var Constructor = function(props, context) {
5814
// This constructor is overridden by mocks. The argument is used
5815
// by mocks to assert on what gets mounted.
5816
5817
if ("production" !== "development") {
5818
("production" !== "development" ? warning(
5819
this instanceof Constructor,
5820
'Something is calling a React component directly. Use a factory or ' +
5821
'JSX instead. See: https://fb.me/react-legacyfactory'
5822
) : null);
5823
}
5824
5825
// Wire up auto-binding
5826
if (this.__reactAutoBindMap) {
5827
bindAutoBindMethods(this);
5828
}
5829
5830
this.props = props;
5831
this.context = context;
5832
this.state = null;
5833
5834
// ReactClasses doesn't have constructors. Instead, they use the
5835
// getInitialState and componentWillMount methods for initialization.
5836
5837
var initialState = this.getInitialState ? this.getInitialState() : null;
5838
if ("production" !== "development") {
5839
// We allow auto-mocks to proceed as if they're returning null.
5840
if (typeof initialState === 'undefined' &&
5841
this.getInitialState._isMockFunction) {
5842
// This is probably bad practice. Consider warning here and
5843
// deprecating this convenience.
5844
initialState = null;
5845
}
5846
}
5847
("production" !== "development" ? invariant(
5848
typeof initialState === 'object' && !Array.isArray(initialState),
5849
'%s.getInitialState(): must return an object or null',
5850
Constructor.displayName || 'ReactCompositeComponent'
5851
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
5852
5853
this.state = initialState;
5854
};
5855
Constructor.prototype = new ReactClassComponent();
5856
Constructor.prototype.constructor = Constructor;
5857
5858
injectedMixins.forEach(
5859
mixSpecIntoComponent.bind(null, Constructor)
5860
);
5861
5862
mixSpecIntoComponent(Constructor, spec);
5863
5864
// Initialize the defaultProps property after all mixins have been merged
5865
if (Constructor.getDefaultProps) {
5866
Constructor.defaultProps = Constructor.getDefaultProps();
5867
}
5868
5869
if ("production" !== "development") {
5870
// This is a tag to indicate that the use of these method names is ok,
5871
// since it's used with createClass. If it's not, then it's likely a
5872
// mistake so we'll warn you to use the static property, property
5873
// initializer or constructor respectively.
5874
if (Constructor.getDefaultProps) {
5875
Constructor.getDefaultProps.isReactClassApproved = {};
5876
}
5877
if (Constructor.prototype.getInitialState) {
5878
Constructor.prototype.getInitialState.isReactClassApproved = {};
5879
}
5880
}
5881
5882
("production" !== "development" ? invariant(
5883
Constructor.prototype.render,
5884
'createClass(...): Class specification must implement a `render` method.'
5885
) : invariant(Constructor.prototype.render));
5886
5887
if ("production" !== "development") {
5888
("production" !== "development" ? warning(
5889
!Constructor.prototype.componentShouldUpdate,
5890
'%s has a method called ' +
5891
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
5892
'The name is phrased as a question because the function is ' +
5893
'expected to return a value.',
5894
spec.displayName || 'A component'
5895
) : null);
5896
}
5897
5898
// Reduce time spent doing lookups by setting these on the prototype.
5899
for (var methodName in ReactClassInterface) {
5900
if (!Constructor.prototype[methodName]) {
5901
Constructor.prototype[methodName] = null;
5902
}
5903
}
5904
5905
// Legacy hook
5906
Constructor.type = Constructor;
5907
if ("production" !== "development") {
5908
try {
5909
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
5910
} catch (x) {
5911
// IE will fail on defineProperty (es5-shim/sham too)
5912
}
5913
}
5914
5915
return Constructor;
5916
},
5917
5918
injection: {
5919
injectMixin: function(mixin) {
5920
injectedMixins.push(mixin);
5921
}
5922
}
5923
5924
};
5925
5926
module.exports = ReactClass;
5927
5928
},{"135":135,"140":140,"141":141,"154":154,"27":27,"34":34,"39":39,"57":57,"60":60,"67":67,"68":68,"76":76,"77":77,"86":86}],34:[function(_dereq_,module,exports){
5929
/**
5930
* Copyright 2013-2015, Facebook, Inc.
5931
* All rights reserved.
5932
*
5933
* This source code is licensed under the BSD-style license found in the
5934
* LICENSE file in the root directory of this source tree. An additional grant
5935
* of patent rights can be found in the PATENTS file in the same directory.
5936
*
5937
* @providesModule ReactComponent
5938
*/
5939
5940
'use strict';
5941
5942
var ReactUpdateQueue = _dereq_(86);
5943
5944
var invariant = _dereq_(135);
5945
var warning = _dereq_(154);
5946
5947
/**
5948
* Base class helpers for the updating state of a component.
5949
*/
5950
function ReactComponent(props, context) {
5951
this.props = props;
5952
this.context = context;
5953
}
5954
5955
/**
5956
* Sets a subset of the state. Always use this to mutate
5957
* state. You should treat `this.state` as immutable.
5958
*
5959
* There is no guarantee that `this.state` will be immediately updated, so
5960
* accessing `this.state` after calling this method may return the old value.
5961
*
5962
* There is no guarantee that calls to `setState` will run synchronously,
5963
* as they may eventually be batched together. You can provide an optional
5964
* callback that will be executed when the call to setState is actually
5965
* completed.
5966
*
5967
* When a function is provided to setState, it will be called at some point in
5968
* the future (not synchronously). It will be called with the up to date
5969
* component arguments (state, props, context). These values can be different
5970
* from this.* because your function may be called after receiveProps but before
5971
* shouldComponentUpdate, and this new state, props, and context will not yet be
5972
* assigned to this.
5973
*
5974
* @param {object|function} partialState Next partial state or function to
5975
* produce next partial state to be merged with current state.
5976
* @param {?function} callback Called after state is updated.
5977
* @final
5978
* @protected
5979
*/
5980
ReactComponent.prototype.setState = function(partialState, callback) {
5981
("production" !== "development" ? invariant(
5982
typeof partialState === 'object' ||
5983
typeof partialState === 'function' ||
5984
partialState == null,
5985
'setState(...): takes an object of state variables to update or a ' +
5986
'function which returns an object of state variables.'
5987
) : invariant(typeof partialState === 'object' ||
5988
typeof partialState === 'function' ||
5989
partialState == null));
5990
if ("production" !== "development") {
5991
("production" !== "development" ? warning(
5992
partialState != null,
5993
'setState(...): You passed an undefined or null state object; ' +
5994
'instead, use forceUpdate().'
5995
) : null);
5996
}
5997
ReactUpdateQueue.enqueueSetState(this, partialState);
5998
if (callback) {
5999
ReactUpdateQueue.enqueueCallback(this, callback);
6000
}
6001
};
6002
6003
/**
6004
* Forces an update. This should only be invoked when it is known with
6005
* certainty that we are **not** in a DOM transaction.
6006
*
6007
* You may want to call this when you know that some deeper aspect of the
6008
* component's state has changed but `setState` was not called.
6009
*
6010
* This will not invoke `shouldComponentUpdate`, but it will invoke
6011
* `componentWillUpdate` and `componentDidUpdate`.
6012
*
6013
* @param {?function} callback Called after update is complete.
6014
* @final
6015
* @protected
6016
*/
6017
ReactComponent.prototype.forceUpdate = function(callback) {
6018
ReactUpdateQueue.enqueueForceUpdate(this);
6019
if (callback) {
6020
ReactUpdateQueue.enqueueCallback(this, callback);
6021
}
6022
};
6023
6024
/**
6025
* Deprecated APIs. These APIs used to exist on classic React classes but since
6026
* we would like to deprecate them, we're not going to move them over to this
6027
* modern base class. Instead, we define a getter that warns if it's accessed.
6028
*/
6029
if ("production" !== "development") {
6030
var deprecatedAPIs = {
6031
getDOMNode: [
6032
'getDOMNode',
6033
'Use React.findDOMNode(component) instead.'
6034
],
6035
isMounted: [
6036
'isMounted',
6037
'Instead, make sure to clean up subscriptions and pending requests in ' +
6038
'componentWillUnmount to prevent memory leaks.'
6039
],
6040
replaceProps: [
6041
'replaceProps',
6042
'Instead call React.render again at the top level.'
6043
],
6044
replaceState: [
6045
'replaceState',
6046
'Refactor your code to use setState instead (see ' +
6047
'https://github.com/facebook/react/issues/3236).'
6048
],
6049
setProps: [
6050
'setProps',
6051
'Instead call React.render again at the top level.'
6052
]
6053
};
6054
var defineDeprecationWarning = function(methodName, info) {
6055
try {
6056
Object.defineProperty(ReactComponent.prototype, methodName, {
6057
get: function() {
6058
("production" !== "development" ? warning(
6059
false,
6060
'%s(...) is deprecated in plain JavaScript React classes. %s',
6061
info[0],
6062
info[1]
6063
) : null);
6064
return undefined;
6065
}
6066
});
6067
} catch (x) {
6068
// IE will fail on defineProperty (es5-shim/sham too)
6069
}
6070
};
6071
for (var fnName in deprecatedAPIs) {
6072
if (deprecatedAPIs.hasOwnProperty(fnName)) {
6073
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
6074
}
6075
}
6076
}
6077
6078
module.exports = ReactComponent;
6079
6080
},{"135":135,"154":154,"86":86}],35:[function(_dereq_,module,exports){
6081
/**
6082
* Copyright 2013-2015, Facebook, Inc.
6083
* All rights reserved.
6084
*
6085
* This source code is licensed under the BSD-style license found in the
6086
* LICENSE file in the root directory of this source tree. An additional grant
6087
* of patent rights can be found in the PATENTS file in the same directory.
6088
*
6089
* @providesModule ReactComponentBrowserEnvironment
6090
*/
6091
6092
/*jslint evil: true */
6093
6094
'use strict';
6095
6096
var ReactDOMIDOperations = _dereq_(44);
6097
var ReactMount = _dereq_(70);
6098
6099
/**
6100
* Abstracts away all functionality of the reconciler that requires knowledge of
6101
* the browser context. TODO: These callers should be refactored to avoid the
6102
* need for this injection.
6103
*/
6104
var ReactComponentBrowserEnvironment = {
6105
6106
processChildrenUpdates:
6107
ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
6108
6109
replaceNodeWithMarkupByID:
6110
ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
6111
6112
/**
6113
* If a particular environment requires that some resources be cleaned up,
6114
* specify this in the injected Mixin. In the DOM, we would likely want to
6115
* purge any cached node ID lookups.
6116
*
6117
* @private
6118
*/
6119
unmountIDFromEnvironment: function(rootNodeID) {
6120
ReactMount.purgeID(rootNodeID);
6121
}
6122
6123
};
6124
6125
module.exports = ReactComponentBrowserEnvironment;
6126
6127
},{"44":44,"70":70}],36:[function(_dereq_,module,exports){
6128
/**
6129
* Copyright 2014-2015, Facebook, Inc.
6130
* All rights reserved.
6131
*
6132
* This source code is licensed under the BSD-style license found in the
6133
* LICENSE file in the root directory of this source tree. An additional grant
6134
* of patent rights can be found in the PATENTS file in the same directory.
6135
*
6136
* @providesModule ReactComponentEnvironment
6137
*/
6138
6139
'use strict';
6140
6141
var invariant = _dereq_(135);
6142
6143
var injected = false;
6144
6145
var ReactComponentEnvironment = {
6146
6147
/**
6148
* Optionally injectable environment dependent cleanup hook. (server vs.
6149
* browser etc). Example: A browser system caches DOM nodes based on component
6150
* ID and must remove that cache entry when this instance is unmounted.
6151
*/
6152
unmountIDFromEnvironment: null,
6153
6154
/**
6155
* Optionally injectable hook for swapping out mount images in the middle of
6156
* the tree.
6157
*/
6158
replaceNodeWithMarkupByID: null,
6159
6160
/**
6161
* Optionally injectable hook for processing a queue of child updates. Will
6162
* later move into MultiChildComponents.
6163
*/
6164
processChildrenUpdates: null,
6165
6166
injection: {
6167
injectEnvironment: function(environment) {
6168
("production" !== "development" ? invariant(
6169
!injected,
6170
'ReactCompositeComponent: injectEnvironment() can only be called once.'
6171
) : invariant(!injected));
6172
ReactComponentEnvironment.unmountIDFromEnvironment =
6173
environment.unmountIDFromEnvironment;
6174
ReactComponentEnvironment.replaceNodeWithMarkupByID =
6175
environment.replaceNodeWithMarkupByID;
6176
ReactComponentEnvironment.processChildrenUpdates =
6177
environment.processChildrenUpdates;
6178
injected = true;
6179
}
6180
}
6181
6182
};
6183
6184
module.exports = ReactComponentEnvironment;
6185
6186
},{"135":135}],37:[function(_dereq_,module,exports){
6187
/**
6188
* Copyright 2013-2015, Facebook, Inc.
6189
* All rights reserved.
6190
*
6191
* This source code is licensed under the BSD-style license found in the
6192
* LICENSE file in the root directory of this source tree. An additional grant
6193
* of patent rights can be found in the PATENTS file in the same directory.
6194
*
6195
* @providesModule ReactCompositeComponent
6196
*/
6197
6198
'use strict';
6199
6200
var ReactComponentEnvironment = _dereq_(36);
6201
var ReactContext = _dereq_(38);
6202
var ReactCurrentOwner = _dereq_(39);
6203
var ReactElement = _dereq_(57);
6204
var ReactElementValidator = _dereq_(58);
6205
var ReactInstanceMap = _dereq_(67);
6206
var ReactLifeCycle = _dereq_(68);
6207
var ReactNativeComponent = _dereq_(73);
6208
var ReactPerf = _dereq_(75);
6209
var ReactPropTypeLocations = _dereq_(77);
6210
var ReactPropTypeLocationNames = _dereq_(76);
6211
var ReactReconciler = _dereq_(81);
6212
var ReactUpdates = _dereq_(87);
6213
6214
var assign = _dereq_(27);
6215
var emptyObject = _dereq_(115);
6216
var invariant = _dereq_(135);
6217
var shouldUpdateReactComponent = _dereq_(151);
6218
var warning = _dereq_(154);
6219
6220
function getDeclarationErrorAddendum(component) {
6221
var owner = component._currentElement._owner || null;
6222
if (owner) {
6223
var name = owner.getName();
6224
if (name) {
6225
return ' Check the render method of `' + name + '`.';
6226
}
6227
}
6228
return '';
6229
}
6230
6231
/**
6232
* ------------------ The Life-Cycle of a Composite Component ------------------
6233
*
6234
* - constructor: Initialization of state. The instance is now retained.
6235
* - componentWillMount
6236
* - render
6237
* - [children's constructors]
6238
* - [children's componentWillMount and render]
6239
* - [children's componentDidMount]
6240
* - componentDidMount
6241
*
6242
* Update Phases:
6243
* - componentWillReceiveProps (only called if parent updated)
6244
* - shouldComponentUpdate
6245
* - componentWillUpdate
6246
* - render
6247
* - [children's constructors or receive props phases]
6248
* - componentDidUpdate
6249
*
6250
* - componentWillUnmount
6251
* - [children's componentWillUnmount]
6252
* - [children destroyed]
6253
* - (destroyed): The instance is now blank, released by React and ready for GC.
6254
*
6255
* -----------------------------------------------------------------------------
6256
*/
6257
6258
/**
6259
* An incrementing ID assigned to each component when it is mounted. This is
6260
* used to enforce the order in which `ReactUpdates` updates dirty components.
6261
*
6262
* @private
6263
*/
6264
var nextMountID = 1;
6265
6266
/**
6267
* @lends {ReactCompositeComponent.prototype}
6268
*/
6269
var ReactCompositeComponentMixin = {
6270
6271
/**
6272
* Base constructor for all composite component.
6273
*
6274
* @param {ReactElement} element
6275
* @final
6276
* @internal
6277
*/
6278
construct: function(element) {
6279
this._currentElement = element;
6280
this._rootNodeID = null;
6281
this._instance = null;
6282
6283
// See ReactUpdateQueue
6284
this._pendingElement = null;
6285
this._pendingStateQueue = null;
6286
this._pendingReplaceState = false;
6287
this._pendingForceUpdate = false;
6288
6289
this._renderedComponent = null;
6290
6291
this._context = null;
6292
this._mountOrder = 0;
6293
this._isTopLevel = false;
6294
6295
// See ReactUpdates and ReactUpdateQueue.
6296
this._pendingCallbacks = null;
6297
},
6298
6299
/**
6300
* Initializes the component, renders markup, and registers event listeners.
6301
*
6302
* @param {string} rootID DOM ID of the root node.
6303
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
6304
* @return {?string} Rendered markup to be inserted into the DOM.
6305
* @final
6306
* @internal
6307
*/
6308
mountComponent: function(rootID, transaction, context) {
6309
this._context = context;
6310
this._mountOrder = nextMountID++;
6311
this._rootNodeID = rootID;
6312
6313
var publicProps = this._processProps(this._currentElement.props);
6314
var publicContext = this._processContext(this._currentElement._context);
6315
6316
var Component = ReactNativeComponent.getComponentClassForElement(
6317
this._currentElement
6318
);
6319
6320
// Initialize the public class
6321
var inst = new Component(publicProps, publicContext);
6322
6323
if ("production" !== "development") {
6324
// This will throw later in _renderValidatedComponent, but add an early
6325
// warning now to help debugging
6326
("production" !== "development" ? warning(
6327
inst.render != null,
6328
'%s(...): No `render` method found on the returned component ' +
6329
'instance: you may have forgotten to define `render` in your ' +
6330
'component or you may have accidentally tried to render an element ' +
6331
'whose type is a function that isn\'t a React component.',
6332
Component.displayName || Component.name || 'Component'
6333
) : null);
6334
}
6335
6336
// These should be set up in the constructor, but as a convenience for
6337
// simpler class abstractions, we set them up after the fact.
6338
inst.props = publicProps;
6339
inst.context = publicContext;
6340
inst.refs = emptyObject;
6341
6342
this._instance = inst;
6343
6344
// Store a reference from the instance back to the internal representation
6345
ReactInstanceMap.set(inst, this);
6346
6347
if ("production" !== "development") {
6348
this._warnIfContextsDiffer(this._currentElement._context, context);
6349
}
6350
6351
if ("production" !== "development") {
6352
// Since plain JS classes are defined without any special initialization
6353
// logic, we can not catch common errors early. Therefore, we have to
6354
// catch them here, at initialization time, instead.
6355
("production" !== "development" ? warning(
6356
!inst.getInitialState ||
6357
inst.getInitialState.isReactClassApproved,
6358
'getInitialState was defined on %s, a plain JavaScript class. ' +
6359
'This is only supported for classes created using React.createClass. ' +
6360
'Did you mean to define a state property instead?',
6361
this.getName() || 'a component'
6362
) : null);
6363
("production" !== "development" ? warning(
6364
!inst.getDefaultProps ||
6365
inst.getDefaultProps.isReactClassApproved,
6366
'getDefaultProps was defined on %s, a plain JavaScript class. ' +
6367
'This is only supported for classes created using React.createClass. ' +
6368
'Use a static property to define defaultProps instead.',
6369
this.getName() || 'a component'
6370
) : null);
6371
("production" !== "development" ? warning(
6372
!inst.propTypes,
6373
'propTypes was defined as an instance property on %s. Use a static ' +
6374
'property to define propTypes instead.',
6375
this.getName() || 'a component'
6376
) : null);
6377
("production" !== "development" ? warning(
6378
!inst.contextTypes,
6379
'contextTypes was defined as an instance property on %s. Use a ' +
6380
'static property to define contextTypes instead.',
6381
this.getName() || 'a component'
6382
) : null);
6383
("production" !== "development" ? warning(
6384
typeof inst.componentShouldUpdate !== 'function',
6385
'%s has a method called ' +
6386
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
6387
'The name is phrased as a question because the function is ' +
6388
'expected to return a value.',
6389
(this.getName() || 'A component')
6390
) : null);
6391
}
6392
6393
var initialState = inst.state;
6394
if (initialState === undefined) {
6395
inst.state = initialState = null;
6396
}
6397
("production" !== "development" ? invariant(
6398
typeof initialState === 'object' && !Array.isArray(initialState),
6399
'%s.state: must be set to an object or null',
6400
this.getName() || 'ReactCompositeComponent'
6401
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
6402
6403
this._pendingStateQueue = null;
6404
this._pendingReplaceState = false;
6405
this._pendingForceUpdate = false;
6406
6407
var childContext;
6408
var renderedElement;
6409
6410
var previouslyMounting = ReactLifeCycle.currentlyMountingInstance;
6411
ReactLifeCycle.currentlyMountingInstance = this;
6412
try {
6413
if (inst.componentWillMount) {
6414
inst.componentWillMount();
6415
// When mounting, calls to `setState` by `componentWillMount` will set
6416
// `this._pendingStateQueue` without triggering a re-render.
6417
if (this._pendingStateQueue) {
6418
inst.state = this._processPendingState(inst.props, inst.context);
6419
}
6420
}
6421
6422
childContext = this._getValidatedChildContext(context);
6423
renderedElement = this._renderValidatedComponent(childContext);
6424
} finally {
6425
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
6426
}
6427
6428
this._renderedComponent = this._instantiateReactComponent(
6429
renderedElement,
6430
this._currentElement.type // The wrapping type
6431
);
6432
6433
var markup = ReactReconciler.mountComponent(
6434
this._renderedComponent,
6435
rootID,
6436
transaction,
6437
this._mergeChildContext(context, childContext)
6438
);
6439
if (inst.componentDidMount) {
6440
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
6441
}
6442
6443
return markup;
6444
},
6445
6446
/**
6447
* Releases any resources allocated by `mountComponent`.
6448
*
6449
* @final
6450
* @internal
6451
*/
6452
unmountComponent: function() {
6453
var inst = this._instance;
6454
6455
if (inst.componentWillUnmount) {
6456
var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
6457
ReactLifeCycle.currentlyUnmountingInstance = this;
6458
try {
6459
inst.componentWillUnmount();
6460
} finally {
6461
ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
6462
}
6463
}
6464
6465
ReactReconciler.unmountComponent(this._renderedComponent);
6466
this._renderedComponent = null;
6467
6468
// Reset pending fields
6469
this._pendingStateQueue = null;
6470
this._pendingReplaceState = false;
6471
this._pendingForceUpdate = false;
6472
this._pendingCallbacks = null;
6473
this._pendingElement = null;
6474
6475
// These fields do not really need to be reset since this object is no
6476
// longer accessible.
6477
this._context = null;
6478
this._rootNodeID = null;
6479
6480
// Delete the reference from the instance to this internal representation
6481
// which allow the internals to be properly cleaned up even if the user
6482
// leaks a reference to the public instance.
6483
ReactInstanceMap.remove(inst);
6484
6485
// Some existing components rely on inst.props even after they've been
6486
// destroyed (in event handlers).
6487
// TODO: inst.props = null;
6488
// TODO: inst.state = null;
6489
// TODO: inst.context = null;
6490
},
6491
6492
/**
6493
* Schedule a partial update to the props. Only used for internal testing.
6494
*
6495
* @param {object} partialProps Subset of the next props.
6496
* @param {?function} callback Called after props are updated.
6497
* @final
6498
* @internal
6499
*/
6500
_setPropsInternal: function(partialProps, callback) {
6501
// This is a deoptimized path. We optimize for always having an element.
6502
// This creates an extra internal element.
6503
var element = this._pendingElement || this._currentElement;
6504
this._pendingElement = ReactElement.cloneAndReplaceProps(
6505
element,
6506
assign({}, element.props, partialProps)
6507
);
6508
ReactUpdates.enqueueUpdate(this, callback);
6509
},
6510
6511
/**
6512
* Filters the context object to only contain keys specified in
6513
* `contextTypes`
6514
*
6515
* @param {object} context
6516
* @return {?object}
6517
* @private
6518
*/
6519
_maskContext: function(context) {
6520
var maskedContext = null;
6521
// This really should be getting the component class for the element,
6522
// but we know that we're not going to need it for built-ins.
6523
if (typeof this._currentElement.type === 'string') {
6524
return emptyObject;
6525
}
6526
var contextTypes = this._currentElement.type.contextTypes;
6527
if (!contextTypes) {
6528
return emptyObject;
6529
}
6530
maskedContext = {};
6531
for (var contextName in contextTypes) {
6532
maskedContext[contextName] = context[contextName];
6533
}
6534
return maskedContext;
6535
},
6536
6537
/**
6538
* Filters the context object to only contain keys specified in
6539
* `contextTypes`, and asserts that they are valid.
6540
*
6541
* @param {object} context
6542
* @return {?object}
6543
* @private
6544
*/
6545
_processContext: function(context) {
6546
var maskedContext = this._maskContext(context);
6547
if ("production" !== "development") {
6548
var Component = ReactNativeComponent.getComponentClassForElement(
6549
this._currentElement
6550
);
6551
if (Component.contextTypes) {
6552
this._checkPropTypes(
6553
Component.contextTypes,
6554
maskedContext,
6555
ReactPropTypeLocations.context
6556
);
6557
}
6558
}
6559
return maskedContext;
6560
},
6561
6562
/**
6563
* @param {object} currentContext
6564
* @return {object}
6565
* @private
6566
*/
6567
_getValidatedChildContext: function(currentContext) {
6568
var inst = this._instance;
6569
var childContext = inst.getChildContext && inst.getChildContext();
6570
if (childContext) {
6571
("production" !== "development" ? invariant(
6572
typeof inst.constructor.childContextTypes === 'object',
6573
'%s.getChildContext(): childContextTypes must be defined in order to ' +
6574
'use getChildContext().',
6575
this.getName() || 'ReactCompositeComponent'
6576
) : invariant(typeof inst.constructor.childContextTypes === 'object'));
6577
if ("production" !== "development") {
6578
this._checkPropTypes(
6579
inst.constructor.childContextTypes,
6580
childContext,
6581
ReactPropTypeLocations.childContext
6582
);
6583
}
6584
for (var name in childContext) {
6585
("production" !== "development" ? invariant(
6586
name in inst.constructor.childContextTypes,
6587
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
6588
this.getName() || 'ReactCompositeComponent',
6589
name
6590
) : invariant(name in inst.constructor.childContextTypes));
6591
}
6592
return childContext;
6593
}
6594
return null;
6595
},
6596
6597
_mergeChildContext: function(currentContext, childContext) {
6598
if (childContext) {
6599
return assign({}, currentContext, childContext);
6600
}
6601
return currentContext;
6602
},
6603
6604
/**
6605
* Processes props by setting default values for unspecified props and
6606
* asserting that the props are valid. Does not mutate its argument; returns
6607
* a new props object with defaults merged in.
6608
*
6609
* @param {object} newProps
6610
* @return {object}
6611
* @private
6612
*/
6613
_processProps: function(newProps) {
6614
if ("production" !== "development") {
6615
var Component = ReactNativeComponent.getComponentClassForElement(
6616
this._currentElement
6617
);
6618
if (Component.propTypes) {
6619
this._checkPropTypes(
6620
Component.propTypes,
6621
newProps,
6622
ReactPropTypeLocations.prop
6623
);
6624
}
6625
}
6626
return newProps;
6627
},
6628
6629
/**
6630
* Assert that the props are valid
6631
*
6632
* @param {object} propTypes Map of prop name to a ReactPropType
6633
* @param {object} props
6634
* @param {string} location e.g. "prop", "context", "child context"
6635
* @private
6636
*/
6637
_checkPropTypes: function(propTypes, props, location) {
6638
// TODO: Stop validating prop types here and only use the element
6639
// validation.
6640
var componentName = this.getName();
6641
for (var propName in propTypes) {
6642
if (propTypes.hasOwnProperty(propName)) {
6643
var error;
6644
try {
6645
// This is intentionally an invariant that gets caught. It's the same
6646
// behavior as without this statement except with a better message.
6647
("production" !== "development" ? invariant(
6648
typeof propTypes[propName] === 'function',
6649
'%s: %s type `%s` is invalid; it must be a function, usually ' +
6650
'from React.PropTypes.',
6651
componentName || 'React class',
6652
ReactPropTypeLocationNames[location],
6653
propName
6654
) : invariant(typeof propTypes[propName] === 'function'));
6655
error = propTypes[propName](props, propName, componentName, location);
6656
} catch (ex) {
6657
error = ex;
6658
}
6659
if (error instanceof Error) {
6660
// We may want to extend this logic for similar errors in
6661
// React.render calls, so I'm abstracting it away into
6662
// a function to minimize refactoring in the future
6663
var addendum = getDeclarationErrorAddendum(this);
6664
6665
if (location === ReactPropTypeLocations.prop) {
6666
// Preface gives us something to blacklist in warning module
6667
("production" !== "development" ? warning(
6668
false,
6669
'Failed Composite propType: %s%s',
6670
error.message,
6671
addendum
6672
) : null);
6673
} else {
6674
("production" !== "development" ? warning(
6675
false,
6676
'Failed Context Types: %s%s',
6677
error.message,
6678
addendum
6679
) : null);
6680
}
6681
}
6682
}
6683
}
6684
},
6685
6686
receiveComponent: function(nextElement, transaction, nextContext) {
6687
var prevElement = this._currentElement;
6688
var prevContext = this._context;
6689
6690
this._pendingElement = null;
6691
6692
this.updateComponent(
6693
transaction,
6694
prevElement,
6695
nextElement,
6696
prevContext,
6697
nextContext
6698
);
6699
},
6700
6701
/**
6702
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
6703
* is set, update the component.
6704
*
6705
* @param {ReactReconcileTransaction} transaction
6706
* @internal
6707
*/
6708
performUpdateIfNecessary: function(transaction) {
6709
if (this._pendingElement != null) {
6710
ReactReconciler.receiveComponent(
6711
this,
6712
this._pendingElement || this._currentElement,
6713
transaction,
6714
this._context
6715
);
6716
}
6717
6718
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
6719
if ("production" !== "development") {
6720
ReactElementValidator.checkAndWarnForMutatedProps(
6721
this._currentElement
6722
);
6723
}
6724
6725
this.updateComponent(
6726
transaction,
6727
this._currentElement,
6728
this._currentElement,
6729
this._context,
6730
this._context
6731
);
6732
}
6733
},
6734
6735
/**
6736
* Compare two contexts, warning if they are different
6737
* TODO: Remove this check when owner-context is removed
6738
*/
6739
_warnIfContextsDiffer: function(ownerBasedContext, parentBasedContext) {
6740
ownerBasedContext = this._maskContext(ownerBasedContext);
6741
parentBasedContext = this._maskContext(parentBasedContext);
6742
var parentKeys = Object.keys(parentBasedContext).sort();
6743
var displayName = this.getName() || 'ReactCompositeComponent';
6744
for (var i = 0; i < parentKeys.length; i++) {
6745
var key = parentKeys[i];
6746
("production" !== "development" ? warning(
6747
ownerBasedContext[key] === parentBasedContext[key],
6748
'owner-based and parent-based contexts differ ' +
6749
'(values: `%s` vs `%s`) for key (%s) while mounting %s ' +
6750
'(see: http://fb.me/react-context-by-parent)',
6751
ownerBasedContext[key],
6752
parentBasedContext[key],
6753
key,
6754
displayName
6755
) : null);
6756
}
6757
},
6758
6759
/**
6760
* Perform an update to a mounted component. The componentWillReceiveProps and
6761
* shouldComponentUpdate methods are called, then (assuming the update isn't
6762
* skipped) the remaining update lifecycle methods are called and the DOM
6763
* representation is updated.
6764
*
6765
* By default, this implements React's rendering and reconciliation algorithm.
6766
* Sophisticated clients may wish to override this.
6767
*
6768
* @param {ReactReconcileTransaction} transaction
6769
* @param {ReactElement} prevParentElement
6770
* @param {ReactElement} nextParentElement
6771
* @internal
6772
* @overridable
6773
*/
6774
updateComponent: function(
6775
transaction,
6776
prevParentElement,
6777
nextParentElement,
6778
prevUnmaskedContext,
6779
nextUnmaskedContext
6780
) {
6781
var inst = this._instance;
6782
6783
var nextContext = inst.context;
6784
var nextProps = inst.props;
6785
6786
// Distinguish between a props update versus a simple state update
6787
if (prevParentElement !== nextParentElement) {
6788
nextContext = this._processContext(nextParentElement._context);
6789
nextProps = this._processProps(nextParentElement.props);
6790
6791
if ("production" !== "development") {
6792
if (nextUnmaskedContext != null) {
6793
this._warnIfContextsDiffer(
6794
nextParentElement._context,
6795
nextUnmaskedContext
6796
);
6797
}
6798
}
6799
6800
// An update here will schedule an update but immediately set
6801
// _pendingStateQueue which will ensure that any state updates gets
6802
// immediately reconciled instead of waiting for the next batch.
6803
6804
if (inst.componentWillReceiveProps) {
6805
inst.componentWillReceiveProps(nextProps, nextContext);
6806
}
6807
}
6808
6809
var nextState = this._processPendingState(nextProps, nextContext);
6810
6811
var shouldUpdate =
6812
this._pendingForceUpdate ||
6813
!inst.shouldComponentUpdate ||
6814
inst.shouldComponentUpdate(nextProps, nextState, nextContext);
6815
6816
if ("production" !== "development") {
6817
("production" !== "development" ? warning(
6818
typeof shouldUpdate !== 'undefined',
6819
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
6820
'boolean value. Make sure to return true or false.',
6821
this.getName() || 'ReactCompositeComponent'
6822
) : null);
6823
}
6824
6825
if (shouldUpdate) {
6826
this._pendingForceUpdate = false;
6827
// Will set `this.props`, `this.state` and `this.context`.
6828
this._performComponentUpdate(
6829
nextParentElement,
6830
nextProps,
6831
nextState,
6832
nextContext,
6833
transaction,
6834
nextUnmaskedContext
6835
);
6836
} else {
6837
// If it's determined that a component should not update, we still want
6838
// to set props and state but we shortcut the rest of the update.
6839
this._currentElement = nextParentElement;
6840
this._context = nextUnmaskedContext;
6841
inst.props = nextProps;
6842
inst.state = nextState;
6843
inst.context = nextContext;
6844
}
6845
},
6846
6847
_processPendingState: function(props, context) {
6848
var inst = this._instance;
6849
var queue = this._pendingStateQueue;
6850
var replace = this._pendingReplaceState;
6851
this._pendingReplaceState = false;
6852
this._pendingStateQueue = null;
6853
6854
if (!queue) {
6855
return inst.state;
6856
}
6857
6858
if (replace && queue.length === 1) {
6859
return queue[0];
6860
}
6861
6862
var nextState = assign({}, replace ? queue[0] : inst.state);
6863
for (var i = replace ? 1 : 0; i < queue.length; i++) {
6864
var partial = queue[i];
6865
assign(
6866
nextState,
6867
typeof partial === 'function' ?
6868
partial.call(inst, nextState, props, context) :
6869
partial
6870
);
6871
}
6872
6873
return nextState;
6874
},
6875
6876
/**
6877
* Merges new props and state, notifies delegate methods of update and
6878
* performs update.
6879
*
6880
* @param {ReactElement} nextElement Next element
6881
* @param {object} nextProps Next public object to set as properties.
6882
* @param {?object} nextState Next object to set as state.
6883
* @param {?object} nextContext Next public object to set as context.
6884
* @param {ReactReconcileTransaction} transaction
6885
* @param {?object} unmaskedContext
6886
* @private
6887
*/
6888
_performComponentUpdate: function(
6889
nextElement,
6890
nextProps,
6891
nextState,
6892
nextContext,
6893
transaction,
6894
unmaskedContext
6895
) {
6896
var inst = this._instance;
6897
6898
var prevProps = inst.props;
6899
var prevState = inst.state;
6900
var prevContext = inst.context;
6901
6902
if (inst.componentWillUpdate) {
6903
inst.componentWillUpdate(nextProps, nextState, nextContext);
6904
}
6905
6906
this._currentElement = nextElement;
6907
this._context = unmaskedContext;
6908
inst.props = nextProps;
6909
inst.state = nextState;
6910
inst.context = nextContext;
6911
6912
this._updateRenderedComponent(transaction, unmaskedContext);
6913
6914
if (inst.componentDidUpdate) {
6915
transaction.getReactMountReady().enqueue(
6916
inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext),
6917
inst
6918
);
6919
}
6920
},
6921
6922
/**
6923
* Call the component's `render` method and update the DOM accordingly.
6924
*
6925
* @param {ReactReconcileTransaction} transaction
6926
* @internal
6927
*/
6928
_updateRenderedComponent: function(transaction, context) {
6929
var prevComponentInstance = this._renderedComponent;
6930
var prevRenderedElement = prevComponentInstance._currentElement;
6931
var childContext = this._getValidatedChildContext();
6932
var nextRenderedElement = this._renderValidatedComponent(childContext);
6933
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
6934
ReactReconciler.receiveComponent(
6935
prevComponentInstance,
6936
nextRenderedElement,
6937
transaction,
6938
this._mergeChildContext(context, childContext)
6939
);
6940
} else {
6941
// These two IDs are actually the same! But nothing should rely on that.
6942
var thisID = this._rootNodeID;
6943
var prevComponentID = prevComponentInstance._rootNodeID;
6944
ReactReconciler.unmountComponent(prevComponentInstance);
6945
6946
this._renderedComponent = this._instantiateReactComponent(
6947
nextRenderedElement,
6948
this._currentElement.type
6949
);
6950
var nextMarkup = ReactReconciler.mountComponent(
6951
this._renderedComponent,
6952
thisID,
6953
transaction,
6954
this._mergeChildContext(context, childContext)
6955
);
6956
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
6957
}
6958
},
6959
6960
/**
6961
* @protected
6962
*/
6963
_replaceNodeWithMarkupByID: function(prevComponentID, nextMarkup) {
6964
ReactComponentEnvironment.replaceNodeWithMarkupByID(
6965
prevComponentID,
6966
nextMarkup
6967
);
6968
},
6969
6970
/**
6971
* @protected
6972
*/
6973
_renderValidatedComponentWithoutOwnerOrContext: function() {
6974
var inst = this._instance;
6975
var renderedComponent = inst.render();
6976
if ("production" !== "development") {
6977
// We allow auto-mocks to proceed as if they're returning null.
6978
if (typeof renderedComponent === 'undefined' &&
6979
inst.render._isMockFunction) {
6980
// This is probably bad practice. Consider warning here and
6981
// deprecating this convenience.
6982
renderedComponent = null;
6983
}
6984
}
6985
6986
return renderedComponent;
6987
},
6988
6989
/**
6990
* @private
6991
*/
6992
_renderValidatedComponent: function(childContext) {
6993
var renderedComponent;
6994
var previousContext = ReactContext.current;
6995
ReactContext.current = this._mergeChildContext(
6996
this._currentElement._context,
6997
childContext
6998
);
6999
ReactCurrentOwner.current = this;
7000
try {
7001
renderedComponent =
7002
this._renderValidatedComponentWithoutOwnerOrContext();
7003
} finally {
7004
ReactContext.current = previousContext;
7005
ReactCurrentOwner.current = null;
7006
}
7007
("production" !== "development" ? invariant(
7008
// TODO: An `isValidNode` function would probably be more appropriate
7009
renderedComponent === null || renderedComponent === false ||
7010
ReactElement.isValidElement(renderedComponent),
7011
'%s.render(): A valid ReactComponent must be returned. You may have ' +
7012
'returned undefined, an array or some other invalid object.',
7013
this.getName() || 'ReactCompositeComponent'
7014
) : invariant(// TODO: An `isValidNode` function would probably be more appropriate
7015
renderedComponent === null || renderedComponent === false ||
7016
ReactElement.isValidElement(renderedComponent)));
7017
return renderedComponent;
7018
},
7019
7020
/**
7021
* Lazily allocates the refs object and stores `component` as `ref`.
7022
*
7023
* @param {string} ref Reference name.
7024
* @param {component} component Component to store as `ref`.
7025
* @final
7026
* @private
7027
*/
7028
attachRef: function(ref, component) {
7029
var inst = this.getPublicInstance();
7030
var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
7031
refs[ref] = component.getPublicInstance();
7032
},
7033
7034
/**
7035
* Detaches a reference name.
7036
*
7037
* @param {string} ref Name to dereference.
7038
* @final
7039
* @private
7040
*/
7041
detachRef: function(ref) {
7042
var refs = this.getPublicInstance().refs;
7043
delete refs[ref];
7044
},
7045
7046
/**
7047
* Get a text description of the component that can be used to identify it
7048
* in error messages.
7049
* @return {string} The name or null.
7050
* @internal
7051
*/
7052
getName: function() {
7053
var type = this._currentElement.type;
7054
var constructor = this._instance && this._instance.constructor;
7055
return (
7056
type.displayName || (constructor && constructor.displayName) ||
7057
type.name || (constructor && constructor.name) ||
7058
null
7059
);
7060
},
7061
7062
/**
7063
* Get the publicly accessible representation of this component - i.e. what
7064
* is exposed by refs and returned by React.render. Can be null for stateless
7065
* components.
7066
*
7067
* @return {ReactComponent} the public component instance.
7068
* @internal
7069
*/
7070
getPublicInstance: function() {
7071
return this._instance;
7072
},
7073
7074
// Stub
7075
_instantiateReactComponent: null
7076
7077
};
7078
7079
ReactPerf.measureMethods(
7080
ReactCompositeComponentMixin,
7081
'ReactCompositeComponent',
7082
{
7083
mountComponent: 'mountComponent',
7084
updateComponent: 'updateComponent',
7085
_renderValidatedComponent: '_renderValidatedComponent'
7086
}
7087
);
7088
7089
var ReactCompositeComponent = {
7090
7091
Mixin: ReactCompositeComponentMixin
7092
7093
};
7094
7095
module.exports = ReactCompositeComponent;
7096
7097
},{"115":115,"135":135,"151":151,"154":154,"27":27,"36":36,"38":38,"39":39,"57":57,"58":58,"67":67,"68":68,"73":73,"75":75,"76":76,"77":77,"81":81,"87":87}],38:[function(_dereq_,module,exports){
7098
/**
7099
* Copyright 2013-2015, Facebook, Inc.
7100
* All rights reserved.
7101
*
7102
* This source code is licensed under the BSD-style license found in the
7103
* LICENSE file in the root directory of this source tree. An additional grant
7104
* of patent rights can be found in the PATENTS file in the same directory.
7105
*
7106
* @providesModule ReactContext
7107
*/
7108
7109
'use strict';
7110
7111
var assign = _dereq_(27);
7112
var emptyObject = _dereq_(115);
7113
var warning = _dereq_(154);
7114
7115
var didWarn = false;
7116
7117
/**
7118
* Keeps track of the current context.
7119
*
7120
* The context is automatically passed down the component ownership hierarchy
7121
* and is accessible via `this.context` on ReactCompositeComponents.
7122
*/
7123
var ReactContext = {
7124
7125
/**
7126
* @internal
7127
* @type {object}
7128
*/
7129
current: emptyObject,
7130
7131
/**
7132
* Temporarily extends the current context while executing scopedCallback.
7133
*
7134
* A typical use case might look like
7135
*
7136
* render: function() {
7137
* var children = ReactContext.withContext({foo: 'foo'}, () => (
7138
*
7139
* ));
7140
* return <div>{children}</div>;
7141
* }
7142
*
7143
* @param {object} newContext New context to merge into the existing context
7144
* @param {function} scopedCallback Callback to run with the new context
7145
* @return {ReactComponent|array<ReactComponent>}
7146
*/
7147
withContext: function(newContext, scopedCallback) {
7148
if ("production" !== "development") {
7149
("production" !== "development" ? warning(
7150
didWarn,
7151
'withContext is deprecated and will be removed in a future version. ' +
7152
'Use a wrapper component with getChildContext instead.'
7153
) : null);
7154
7155
didWarn = true;
7156
}
7157
7158
var result;
7159
var previousContext = ReactContext.current;
7160
ReactContext.current = assign({}, previousContext, newContext);
7161
try {
7162
result = scopedCallback();
7163
} finally {
7164
ReactContext.current = previousContext;
7165
}
7166
return result;
7167
}
7168
7169
};
7170
7171
module.exports = ReactContext;
7172
7173
},{"115":115,"154":154,"27":27}],39:[function(_dereq_,module,exports){
7174
/**
7175
* Copyright 2013-2015, Facebook, Inc.
7176
* All rights reserved.
7177
*
7178
* This source code is licensed under the BSD-style license found in the
7179
* LICENSE file in the root directory of this source tree. An additional grant
7180
* of patent rights can be found in the PATENTS file in the same directory.
7181
*
7182
* @providesModule ReactCurrentOwner
7183
*/
7184
7185
'use strict';
7186
7187
/**
7188
* Keeps track of the current owner.
7189
*
7190
* The current owner is the component who should own any components that are
7191
* currently being constructed.
7192
*
7193
* The depth indicate how many composite components are above this render level.
7194
*/
7195
var ReactCurrentOwner = {
7196
7197
/**
7198
* @internal
7199
* @type {ReactComponent}
7200
*/
7201
current: null
7202
7203
};
7204
7205
module.exports = ReactCurrentOwner;
7206
7207
},{}],40:[function(_dereq_,module,exports){
7208
/**
7209
* Copyright 2013-2015, Facebook, Inc.
7210
* All rights reserved.
7211
*
7212
* This source code is licensed under the BSD-style license found in the
7213
* LICENSE file in the root directory of this source tree. An additional grant
7214
* of patent rights can be found in the PATENTS file in the same directory.
7215
*
7216
* @providesModule ReactDOM
7217
* @typechecks static-only
7218
*/
7219
7220
'use strict';
7221
7222
var ReactElement = _dereq_(57);
7223
var ReactElementValidator = _dereq_(58);
7224
7225
var mapObject = _dereq_(142);
7226
7227
/**
7228
* Create a factory that creates HTML tag elements.
7229
*
7230
* @param {string} tag Tag name (e.g. `div`).
7231
* @private
7232
*/
7233
function createDOMFactory(tag) {
7234
if ("production" !== "development") {
7235
return ReactElementValidator.createFactory(tag);
7236
}
7237
return ReactElement.createFactory(tag);
7238
}
7239
7240
/**
7241
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
7242
* This is also accessible via `React.DOM`.
7243
*
7244
* @public
7245
*/
7246
var ReactDOM = mapObject({
7247
a: 'a',
7248
abbr: 'abbr',
7249
address: 'address',
7250
area: 'area',
7251
article: 'article',
7252
aside: 'aside',
7253
audio: 'audio',
7254
b: 'b',
7255
base: 'base',
7256
bdi: 'bdi',
7257
bdo: 'bdo',
7258
big: 'big',
7259
blockquote: 'blockquote',
7260
body: 'body',
7261
br: 'br',
7262
button: 'button',
7263
canvas: 'canvas',
7264
caption: 'caption',
7265
cite: 'cite',
7266
code: 'code',
7267
col: 'col',
7268
colgroup: 'colgroup',
7269
data: 'data',
7270
datalist: 'datalist',
7271
dd: 'dd',
7272
del: 'del',
7273
details: 'details',
7274
dfn: 'dfn',
7275
dialog: 'dialog',
7276
div: 'div',
7277
dl: 'dl',
7278
dt: 'dt',
7279
em: 'em',
7280
embed: 'embed',
7281
fieldset: 'fieldset',
7282
figcaption: 'figcaption',
7283
figure: 'figure',
7284
footer: 'footer',
7285
form: 'form',
7286
h1: 'h1',
7287
h2: 'h2',
7288
h3: 'h3',
7289
h4: 'h4',
7290
h5: 'h5',
7291
h6: 'h6',
7292
head: 'head',
7293
header: 'header',
7294
hr: 'hr',
7295
html: 'html',
7296
i: 'i',
7297
iframe: 'iframe',
7298
img: 'img',
7299
input: 'input',
7300
ins: 'ins',
7301
kbd: 'kbd',
7302
keygen: 'keygen',
7303
label: 'label',
7304
legend: 'legend',
7305
li: 'li',
7306
link: 'link',
7307
main: 'main',
7308
map: 'map',
7309
mark: 'mark',
7310
menu: 'menu',
7311
menuitem: 'menuitem',
7312
meta: 'meta',
7313
meter: 'meter',
7314
nav: 'nav',
7315
noscript: 'noscript',
7316
object: 'object',
7317
ol: 'ol',
7318
optgroup: 'optgroup',
7319
option: 'option',
7320
output: 'output',
7321
p: 'p',
7322
param: 'param',
7323
picture: 'picture',
7324
pre: 'pre',
7325
progress: 'progress',
7326
q: 'q',
7327
rp: 'rp',
7328
rt: 'rt',
7329
ruby: 'ruby',
7330
s: 's',
7331
samp: 'samp',
7332
script: 'script',
7333
section: 'section',
7334
select: 'select',
7335
small: 'small',
7336
source: 'source',
7337
span: 'span',
7338
strong: 'strong',
7339
style: 'style',
7340
sub: 'sub',
7341
summary: 'summary',
7342
sup: 'sup',
7343
table: 'table',
7344
tbody: 'tbody',
7345
td: 'td',
7346
textarea: 'textarea',
7347
tfoot: 'tfoot',
7348
th: 'th',
7349
thead: 'thead',
7350
time: 'time',
7351
title: 'title',
7352
tr: 'tr',
7353
track: 'track',
7354
u: 'u',
7355
ul: 'ul',
7356
'var': 'var',
7357
video: 'video',
7358
wbr: 'wbr',
7359
7360
// SVG
7361
circle: 'circle',
7362
clipPath: 'clipPath',
7363
defs: 'defs',
7364
ellipse: 'ellipse',
7365
g: 'g',
7366
line: 'line',
7367
linearGradient: 'linearGradient',
7368
mask: 'mask',
7369
path: 'path',
7370
pattern: 'pattern',
7371
polygon: 'polygon',
7372
polyline: 'polyline',
7373
radialGradient: 'radialGradient',
7374
rect: 'rect',
7375
stop: 'stop',
7376
svg: 'svg',
7377
text: 'text',
7378
tspan: 'tspan'
7379
7380
}, createDOMFactory);
7381
7382
module.exports = ReactDOM;
7383
7384
},{"142":142,"57":57,"58":58}],41:[function(_dereq_,module,exports){
7385
/**
7386
* Copyright 2013-2015, Facebook, Inc.
7387
* All rights reserved.
7388
*
7389
* This source code is licensed under the BSD-style license found in the
7390
* LICENSE file in the root directory of this source tree. An additional grant
7391
* of patent rights can be found in the PATENTS file in the same directory.
7392
*
7393
* @providesModule ReactDOMButton
7394
*/
7395
7396
'use strict';
7397
7398
var AutoFocusMixin = _dereq_(2);
7399
var ReactBrowserComponentMixin = _dereq_(29);
7400
var ReactClass = _dereq_(33);
7401
var ReactElement = _dereq_(57);
7402
7403
var keyMirror = _dereq_(140);
7404
7405
var button = ReactElement.createFactory('button');
7406
7407
var mouseListenerNames = keyMirror({
7408
onClick: true,
7409
onDoubleClick: true,
7410
onMouseDown: true,
7411
onMouseMove: true,
7412
onMouseUp: true,
7413
onClickCapture: true,
7414
onDoubleClickCapture: true,
7415
onMouseDownCapture: true,
7416
onMouseMoveCapture: true,
7417
onMouseUpCapture: true
7418
});
7419
7420
/**
7421
* Implements a <button> native component that does not receive mouse events
7422
* when `disabled` is set.
7423
*/
7424
var ReactDOMButton = ReactClass.createClass({
7425
displayName: 'ReactDOMButton',
7426
tagName: 'BUTTON',
7427
7428
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
7429
7430
render: function() {
7431
var props = {};
7432
7433
// Copy the props; except the mouse listeners if we're disabled
7434
for (var key in this.props) {
7435
if (this.props.hasOwnProperty(key) &&
7436
(!this.props.disabled || !mouseListenerNames[key])) {
7437
props[key] = this.props[key];
7438
}
7439
}
7440
7441
return button(props, this.props.children);
7442
}
7443
7444
});
7445
7446
module.exports = ReactDOMButton;
7447
7448
},{"140":140,"2":2,"29":29,"33":33,"57":57}],42:[function(_dereq_,module,exports){
7449
/**
7450
* Copyright 2013-2015, Facebook, Inc.
7451
* All rights reserved.
7452
*
7453
* This source code is licensed under the BSD-style license found in the
7454
* LICENSE file in the root directory of this source tree. An additional grant
7455
* of patent rights can be found in the PATENTS file in the same directory.
7456
*
7457
* @providesModule ReactDOMComponent
7458
* @typechecks static-only
7459
*/
7460
7461
/* global hasOwnProperty:true */
7462
7463
'use strict';
7464
7465
var CSSPropertyOperations = _dereq_(5);
7466
var DOMProperty = _dereq_(10);
7467
var DOMPropertyOperations = _dereq_(11);
7468
var ReactBrowserEventEmitter = _dereq_(30);
7469
var ReactComponentBrowserEnvironment =
7470
_dereq_(35);
7471
var ReactMount = _dereq_(70);
7472
var ReactMultiChild = _dereq_(71);
7473
var ReactPerf = _dereq_(75);
7474
7475
var assign = _dereq_(27);
7476
var escapeTextContentForBrowser = _dereq_(116);
7477
var invariant = _dereq_(135);
7478
var isEventSupported = _dereq_(136);
7479
var keyOf = _dereq_(141);
7480
var warning = _dereq_(154);
7481
7482
var deleteListener = ReactBrowserEventEmitter.deleteListener;
7483
var listenTo = ReactBrowserEventEmitter.listenTo;
7484
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
7485
7486
// For quickly matching children type, to test if can be treated as content.
7487
var CONTENT_TYPES = {'string': true, 'number': true};
7488
7489
var STYLE = keyOf({style: null});
7490
7491
var ELEMENT_NODE_TYPE = 1;
7492
7493
/**
7494
* Optionally injectable operations for mutating the DOM
7495
*/
7496
var BackendIDOperations = null;
7497
7498
/**
7499
* @param {?object} props
7500
*/
7501
function assertValidProps(props) {
7502
if (!props) {
7503
return;
7504
}
7505
// Note the use of `==` which checks for null or undefined.
7506
if (props.dangerouslySetInnerHTML != null) {
7507
("production" !== "development" ? invariant(
7508
props.children == null,
7509
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
7510
) : invariant(props.children == null));
7511
("production" !== "development" ? invariant(
7512
typeof props.dangerouslySetInnerHTML === 'object' &&
7513
'__html' in props.dangerouslySetInnerHTML,
7514
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
7515
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' +
7516
'for more information.'
7517
) : invariant(typeof props.dangerouslySetInnerHTML === 'object' &&
7518
'__html' in props.dangerouslySetInnerHTML));
7519
}
7520
if ("production" !== "development") {
7521
("production" !== "development" ? warning(
7522
props.innerHTML == null,
7523
'Directly setting property `innerHTML` is not permitted. ' +
7524
'For more information, lookup documentation on `dangerouslySetInnerHTML`.'
7525
) : null);
7526
("production" !== "development" ? warning(
7527
!props.contentEditable || props.children == null,
7528
'A component is `contentEditable` and contains `children` managed by ' +
7529
'React. It is now your responsibility to guarantee that none of ' +
7530
'those nodes are unexpectedly modified or duplicated. This is ' +
7531
'probably not intentional.'
7532
) : null);
7533
}
7534
("production" !== "development" ? invariant(
7535
props.style == null || typeof props.style === 'object',
7536
'The `style` prop expects a mapping from style properties to values, ' +
7537
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
7538
'using JSX.'
7539
) : invariant(props.style == null || typeof props.style === 'object'));
7540
}
7541
7542
function putListener(id, registrationName, listener, transaction) {
7543
if ("production" !== "development") {
7544
// IE8 has no API for event capturing and the `onScroll` event doesn't
7545
// bubble.
7546
("production" !== "development" ? warning(
7547
registrationName !== 'onScroll' || isEventSupported('scroll', true),
7548
'This browser doesn\'t support the `onScroll` event'
7549
) : null);
7550
}
7551
var container = ReactMount.findReactContainerForID(id);
7552
if (container) {
7553
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
7554
container.ownerDocument :
7555
container;
7556
listenTo(registrationName, doc);
7557
}
7558
transaction.getPutListenerQueue().enqueuePutListener(
7559
id,
7560
registrationName,
7561
listener
7562
);
7563
}
7564
7565
// For HTML, certain tags should omit their close tag. We keep a whitelist for
7566
// those special cased tags.
7567
7568
var omittedCloseTags = {
7569
'area': true,
7570
'base': true,
7571
'br': true,
7572
'col': true,
7573
'embed': true,
7574
'hr': true,
7575
'img': true,
7576
'input': true,
7577
'keygen': true,
7578
'link': true,
7579
'meta': true,
7580
'param': true,
7581
'source': true,
7582
'track': true,
7583
'wbr': true
7584
// NOTE: menuitem's close tag should be omitted, but that causes problems.
7585
};
7586
7587
// We accept any tag to be rendered but since this gets injected into abitrary
7588
// HTML, we want to make sure that it's a safe tag.
7589
// http://www.w3.org/TR/REC-xml/#NT-Name
7590
7591
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
7592
var validatedTagCache = {};
7593
var hasOwnProperty = {}.hasOwnProperty;
7594
7595
function validateDangerousTag(tag) {
7596
if (!hasOwnProperty.call(validatedTagCache, tag)) {
7597
("production" !== "development" ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
7598
validatedTagCache[tag] = true;
7599
}
7600
}
7601
7602
/**
7603
* Creates a new React class that is idempotent and capable of containing other
7604
* React components. It accepts event listeners and DOM properties that are
7605
* valid according to `DOMProperty`.
7606
*
7607
* - Event listeners: `onClick`, `onMouseDown`, etc.
7608
* - DOM properties: `className`, `name`, `title`, etc.
7609
*
7610
* The `style` property functions differently from the DOM API. It accepts an
7611
* object mapping of style properties to values.
7612
*
7613
* @constructor ReactDOMComponent
7614
* @extends ReactMultiChild
7615
*/
7616
function ReactDOMComponent(tag) {
7617
validateDangerousTag(tag);
7618
this._tag = tag;
7619
this._renderedChildren = null;
7620
this._previousStyleCopy = null;
7621
this._rootNodeID = null;
7622
}
7623
7624
ReactDOMComponent.displayName = 'ReactDOMComponent';
7625
7626
ReactDOMComponent.Mixin = {
7627
7628
construct: function(element) {
7629
this._currentElement = element;
7630
},
7631
7632
/**
7633
* Generates root tag markup then recurses. This method has side effects and
7634
* is not idempotent.
7635
*
7636
* @internal
7637
* @param {string} rootID The root DOM ID for this node.
7638
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7639
* @return {string} The computed markup.
7640
*/
7641
mountComponent: function(rootID, transaction, context) {
7642
this._rootNodeID = rootID;
7643
assertValidProps(this._currentElement.props);
7644
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
7645
return (
7646
this._createOpenTagMarkupAndPutListeners(transaction) +
7647
this._createContentMarkup(transaction, context) +
7648
closeTag
7649
);
7650
},
7651
7652
/**
7653
* Creates markup for the open tag and all attributes.
7654
*
7655
* This method has side effects because events get registered.
7656
*
7657
* Iterating over object properties is faster than iterating over arrays.
7658
* @see http://jsperf.com/obj-vs-arr-iteration
7659
*
7660
* @private
7661
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7662
* @return {string} Markup of opening tag.
7663
*/
7664
_createOpenTagMarkupAndPutListeners: function(transaction) {
7665
var props = this._currentElement.props;
7666
var ret = '<' + this._tag;
7667
7668
for (var propKey in props) {
7669
if (!props.hasOwnProperty(propKey)) {
7670
continue;
7671
}
7672
var propValue = props[propKey];
7673
if (propValue == null) {
7674
continue;
7675
}
7676
if (registrationNameModules.hasOwnProperty(propKey)) {
7677
putListener(this._rootNodeID, propKey, propValue, transaction);
7678
} else {
7679
if (propKey === STYLE) {
7680
if (propValue) {
7681
propValue = this._previousStyleCopy = assign({}, props.style);
7682
}
7683
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
7684
}
7685
var markup =
7686
DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
7687
if (markup) {
7688
ret += ' ' + markup;
7689
}
7690
}
7691
}
7692
7693
// For static pages, no need to put React ID and checksum. Saves lots of
7694
// bytes.
7695
if (transaction.renderToStaticMarkup) {
7696
return ret + '>';
7697
}
7698
7699
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
7700
return ret + ' ' + markupForID + '>';
7701
},
7702
7703
/**
7704
* Creates markup for the content between the tags.
7705
*
7706
* @private
7707
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
7708
* @param {object} context
7709
* @return {string} Content markup.
7710
*/
7711
_createContentMarkup: function(transaction, context) {
7712
var prefix = '';
7713
if (this._tag === 'listing' ||
7714
this._tag === 'pre' ||
7715
this._tag === 'textarea') {
7716
// Add an initial newline because browsers ignore the first newline in
7717
// a <listing>, <pre>, or <textarea> as an "authoring convenience" -- see
7718
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody.
7719
prefix = '\n';
7720
}
7721
7722
var props = this._currentElement.props;
7723
7724
// Intentional use of != to avoid catching zero/false.
7725
var innerHTML = props.dangerouslySetInnerHTML;
7726
if (innerHTML != null) {
7727
if (innerHTML.__html != null) {
7728
return prefix + innerHTML.__html;
7729
}
7730
} else {
7731
var contentToUse =
7732
CONTENT_TYPES[typeof props.children] ? props.children : null;
7733
var childrenToUse = contentToUse != null ? null : props.children;
7734
if (contentToUse != null) {
7735
return prefix + escapeTextContentForBrowser(contentToUse);
7736
} else if (childrenToUse != null) {
7737
var mountImages = this.mountChildren(
7738
childrenToUse,
7739
transaction,
7740
context
7741
);
7742
return prefix + mountImages.join('');
7743
}
7744
}
7745
return prefix;
7746
},
7747
7748
receiveComponent: function(nextElement, transaction, context) {
7749
var prevElement = this._currentElement;
7750
this._currentElement = nextElement;
7751
this.updateComponent(transaction, prevElement, nextElement, context);
7752
},
7753
7754
/**
7755
* Updates a native DOM component after it has already been allocated and
7756
* attached to the DOM. Reconciles the root DOM node, then recurses.
7757
*
7758
* @param {ReactReconcileTransaction} transaction
7759
* @param {ReactElement} prevElement
7760
* @param {ReactElement} nextElement
7761
* @internal
7762
* @overridable
7763
*/
7764
updateComponent: function(transaction, prevElement, nextElement, context) {
7765
assertValidProps(this._currentElement.props);
7766
this._updateDOMProperties(prevElement.props, transaction);
7767
this._updateDOMChildren(prevElement.props, transaction, context);
7768
},
7769
7770
/**
7771
* Reconciles the properties by detecting differences in property values and
7772
* updating the DOM as necessary. This function is probably the single most
7773
* critical path for performance optimization.
7774
*
7775
* TODO: Benchmark whether checking for changed values in memory actually
7776
* improves performance (especially statically positioned elements).
7777
* TODO: Benchmark the effects of putting this at the top since 99% of props
7778
* do not change for a given reconciliation.
7779
* TODO: Benchmark areas that can be improved with caching.
7780
*
7781
* @private
7782
* @param {object} lastProps
7783
* @param {ReactReconcileTransaction} transaction
7784
*/
7785
_updateDOMProperties: function(lastProps, transaction) {
7786
var nextProps = this._currentElement.props;
7787
var propKey;
7788
var styleName;
7789
var styleUpdates;
7790
for (propKey in lastProps) {
7791
if (nextProps.hasOwnProperty(propKey) ||
7792
!lastProps.hasOwnProperty(propKey)) {
7793
continue;
7794
}
7795
if (propKey === STYLE) {
7796
var lastStyle = this._previousStyleCopy;
7797
for (styleName in lastStyle) {
7798
if (lastStyle.hasOwnProperty(styleName)) {
7799
styleUpdates = styleUpdates || {};
7800
styleUpdates[styleName] = '';
7801
}
7802
}
7803
this._previousStyleCopy = null;
7804
} else if (registrationNameModules.hasOwnProperty(propKey)) {
7805
deleteListener(this._rootNodeID, propKey);
7806
} else if (
7807
DOMProperty.isStandardName[propKey] ||
7808
DOMProperty.isCustomAttribute(propKey)) {
7809
BackendIDOperations.deletePropertyByID(
7810
this._rootNodeID,
7811
propKey
7812
);
7813
}
7814
}
7815
for (propKey in nextProps) {
7816
var nextProp = nextProps[propKey];
7817
var lastProp = propKey === STYLE ?
7818
this._previousStyleCopy :
7819
lastProps[propKey];
7820
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
7821
continue;
7822
}
7823
if (propKey === STYLE) {
7824
if (nextProp) {
7825
nextProp = this._previousStyleCopy = assign({}, nextProp);
7826
} else {
7827
this._previousStyleCopy = null;
7828
}
7829
if (lastProp) {
7830
// Unset styles on `lastProp` but not on `nextProp`.
7831
for (styleName in lastProp) {
7832
if (lastProp.hasOwnProperty(styleName) &&
7833
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
7834
styleUpdates = styleUpdates || {};
7835
styleUpdates[styleName] = '';
7836
}
7837
}
7838
// Update styles that changed since `lastProp`.
7839
for (styleName in nextProp) {
7840
if (nextProp.hasOwnProperty(styleName) &&
7841
lastProp[styleName] !== nextProp[styleName]) {
7842
styleUpdates = styleUpdates || {};
7843
styleUpdates[styleName] = nextProp[styleName];
7844
}
7845
}
7846
} else {
7847
// Relies on `updateStylesByID` not mutating `styleUpdates`.
7848
styleUpdates = nextProp;
7849
}
7850
} else if (registrationNameModules.hasOwnProperty(propKey)) {
7851
putListener(this._rootNodeID, propKey, nextProp, transaction);
7852
} else if (
7853
DOMProperty.isStandardName[propKey] ||
7854
DOMProperty.isCustomAttribute(propKey)) {
7855
BackendIDOperations.updatePropertyByID(
7856
this._rootNodeID,
7857
propKey,
7858
nextProp
7859
);
7860
}
7861
}
7862
if (styleUpdates) {
7863
BackendIDOperations.updateStylesByID(
7864
this._rootNodeID,
7865
styleUpdates
7866
);
7867
}
7868
},
7869
7870
/**
7871
* Reconciles the children with the various properties that affect the
7872
* children content.
7873
*
7874
* @param {object} lastProps
7875
* @param {ReactReconcileTransaction} transaction
7876
*/
7877
_updateDOMChildren: function(lastProps, transaction, context) {
7878
var nextProps = this._currentElement.props;
7879
7880
var lastContent =
7881
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
7882
var nextContent =
7883
CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
7884
7885
var lastHtml =
7886
lastProps.dangerouslySetInnerHTML &&
7887
lastProps.dangerouslySetInnerHTML.__html;
7888
var nextHtml =
7889
nextProps.dangerouslySetInnerHTML &&
7890
nextProps.dangerouslySetInnerHTML.__html;
7891
7892
// Note the use of `!=` which checks for null or undefined.
7893
var lastChildren = lastContent != null ? null : lastProps.children;
7894
var nextChildren = nextContent != null ? null : nextProps.children;
7895
7896
// If we're switching from children to content/html or vice versa, remove
7897
// the old content
7898
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
7899
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
7900
if (lastChildren != null && nextChildren == null) {
7901
this.updateChildren(null, transaction, context);
7902
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
7903
this.updateTextContent('');
7904
}
7905
7906
if (nextContent != null) {
7907
if (lastContent !== nextContent) {
7908
this.updateTextContent('' + nextContent);
7909
}
7910
} else if (nextHtml != null) {
7911
if (lastHtml !== nextHtml) {
7912
BackendIDOperations.updateInnerHTMLByID(
7913
this._rootNodeID,
7914
nextHtml
7915
);
7916
}
7917
} else if (nextChildren != null) {
7918
this.updateChildren(nextChildren, transaction, context);
7919
}
7920
},
7921
7922
/**
7923
* Destroys all event registrations for this instance. Does not remove from
7924
* the DOM. That must be done by the parent.
7925
*
7926
* @internal
7927
*/
7928
unmountComponent: function() {
7929
this.unmountChildren();
7930
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
7931
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
7932
this._rootNodeID = null;
7933
}
7934
7935
};
7936
7937
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
7938
mountComponent: 'mountComponent',
7939
updateComponent: 'updateComponent'
7940
});
7941
7942
assign(
7943
ReactDOMComponent.prototype,
7944
ReactDOMComponent.Mixin,
7945
ReactMultiChild.Mixin
7946
);
7947
7948
ReactDOMComponent.injection = {
7949
injectIDOperations: function(IDOperations) {
7950
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
7951
}
7952
};
7953
7954
module.exports = ReactDOMComponent;
7955
7956
},{"10":10,"11":11,"116":116,"135":135,"136":136,"141":141,"154":154,"27":27,"30":30,"35":35,"5":5,"70":70,"71":71,"75":75}],43:[function(_dereq_,module,exports){
7957
/**
7958
* Copyright 2013-2015, Facebook, Inc.
7959
* All rights reserved.
7960
*
7961
* This source code is licensed under the BSD-style license found in the
7962
* LICENSE file in the root directory of this source tree. An additional grant
7963
* of patent rights can be found in the PATENTS file in the same directory.
7964
*
7965
* @providesModule ReactDOMForm
7966
*/
7967
7968
'use strict';
7969
7970
var EventConstants = _dereq_(15);
7971
var LocalEventTrapMixin = _dereq_(25);
7972
var ReactBrowserComponentMixin = _dereq_(29);
7973
var ReactClass = _dereq_(33);
7974
var ReactElement = _dereq_(57);
7975
7976
var form = ReactElement.createFactory('form');
7977
7978
/**
7979
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
7980
* to capture it on the <form> element itself. There are lots of hacks we could
7981
* do to accomplish this, but the most reliable is to make <form> a
7982
* composite component and use `componentDidMount` to attach the event handlers.
7983
*/
7984
var ReactDOMForm = ReactClass.createClass({
7985
displayName: 'ReactDOMForm',
7986
tagName: 'FORM',
7987
7988
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
7989
7990
render: function() {
7991
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
7992
// `jshint` fails to parse JSX so in order for linting to work in the open
7993
// source repo, we need to just use `ReactDOM.form`.
7994
return form(this.props);
7995
},
7996
7997
componentDidMount: function() {
7998
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
7999
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
8000
}
8001
});
8002
8003
module.exports = ReactDOMForm;
8004
8005
},{"15":15,"25":25,"29":29,"33":33,"57":57}],44:[function(_dereq_,module,exports){
8006
/**
8007
* Copyright 2013-2015, Facebook, Inc.
8008
* All rights reserved.
8009
*
8010
* This source code is licensed under the BSD-style license found in the
8011
* LICENSE file in the root directory of this source tree. An additional grant
8012
* of patent rights can be found in the PATENTS file in the same directory.
8013
*
8014
* @providesModule ReactDOMIDOperations
8015
* @typechecks static-only
8016
*/
8017
8018
/*jslint evil: true */
8019
8020
'use strict';
8021
8022
var CSSPropertyOperations = _dereq_(5);
8023
var DOMChildrenOperations = _dereq_(9);
8024
var DOMPropertyOperations = _dereq_(11);
8025
var ReactMount = _dereq_(70);
8026
var ReactPerf = _dereq_(75);
8027
8028
var invariant = _dereq_(135);
8029
var setInnerHTML = _dereq_(148);
8030
8031
/**
8032
* Errors for properties that should not be updated with `updatePropertyById()`.
8033
*
8034
* @type {object}
8035
* @private
8036
*/
8037
var INVALID_PROPERTY_ERRORS = {
8038
dangerouslySetInnerHTML:
8039
'`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
8040
style: '`style` must be set using `updateStylesByID()`.'
8041
};
8042
8043
/**
8044
* Operations used to process updates to DOM nodes. This is made injectable via
8045
* `ReactDOMComponent.BackendIDOperations`.
8046
*/
8047
var ReactDOMIDOperations = {
8048
8049
/**
8050
* Updates a DOM node with new property values. This should only be used to
8051
* update DOM properties in `DOMProperty`.
8052
*
8053
* @param {string} id ID of the node to update.
8054
* @param {string} name A valid property name, see `DOMProperty`.
8055
* @param {*} value New value of the property.
8056
* @internal
8057
*/
8058
updatePropertyByID: function(id, name, value) {
8059
var node = ReactMount.getNode(id);
8060
("production" !== "development" ? invariant(
8061
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
8062
'updatePropertyByID(...): %s',
8063
INVALID_PROPERTY_ERRORS[name]
8064
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
8065
8066
// If we're updating to null or undefined, we should remove the property
8067
// from the DOM node instead of inadvertantly setting to a string. This
8068
// brings us in line with the same behavior we have on initial render.
8069
if (value != null) {
8070
DOMPropertyOperations.setValueForProperty(node, name, value);
8071
} else {
8072
DOMPropertyOperations.deleteValueForProperty(node, name);
8073
}
8074
},
8075
8076
/**
8077
* Updates a DOM node to remove a property. This should only be used to remove
8078
* DOM properties in `DOMProperty`.
8079
*
8080
* @param {string} id ID of the node to update.
8081
* @param {string} name A property name to remove, see `DOMProperty`.
8082
* @internal
8083
*/
8084
deletePropertyByID: function(id, name, value) {
8085
var node = ReactMount.getNode(id);
8086
("production" !== "development" ? invariant(
8087
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
8088
'updatePropertyByID(...): %s',
8089
INVALID_PROPERTY_ERRORS[name]
8090
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
8091
DOMPropertyOperations.deleteValueForProperty(node, name, value);
8092
},
8093
8094
/**
8095
* Updates a DOM node with new style values. If a value is specified as '',
8096
* the corresponding style property will be unset.
8097
*
8098
* @param {string} id ID of the node to update.
8099
* @param {object} styles Mapping from styles to values.
8100
* @internal
8101
*/
8102
updateStylesByID: function(id, styles) {
8103
var node = ReactMount.getNode(id);
8104
CSSPropertyOperations.setValueForStyles(node, styles);
8105
},
8106
8107
/**
8108
* Updates a DOM node's innerHTML.
8109
*
8110
* @param {string} id ID of the node to update.
8111
* @param {string} html An HTML string.
8112
* @internal
8113
*/
8114
updateInnerHTMLByID: function(id, html) {
8115
var node = ReactMount.getNode(id);
8116
setInnerHTML(node, html);
8117
},
8118
8119
/**
8120
* Updates a DOM node's text content set by `props.content`.
8121
*
8122
* @param {string} id ID of the node to update.
8123
* @param {string} content Text content.
8124
* @internal
8125
*/
8126
updateTextContentByID: function(id, content) {
8127
var node = ReactMount.getNode(id);
8128
DOMChildrenOperations.updateTextContent(node, content);
8129
},
8130
8131
/**
8132
* Replaces a DOM node that exists in the document with markup.
8133
*
8134
* @param {string} id ID of child to be replaced.
8135
* @param {string} markup Dangerous markup to inject in place of child.
8136
* @internal
8137
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
8138
*/
8139
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
8140
var node = ReactMount.getNode(id);
8141
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
8142
},
8143
8144
/**
8145
* Updates a component's children by processing a series of updates.
8146
*
8147
* @param {array<object>} updates List of update configurations.
8148
* @param {array<string>} markup List of markup strings.
8149
* @internal
8150
*/
8151
dangerouslyProcessChildrenUpdates: function(updates, markup) {
8152
for (var i = 0; i < updates.length; i++) {
8153
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
8154
}
8155
DOMChildrenOperations.processUpdates(updates, markup);
8156
}
8157
};
8158
8159
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
8160
updatePropertyByID: 'updatePropertyByID',
8161
deletePropertyByID: 'deletePropertyByID',
8162
updateStylesByID: 'updateStylesByID',
8163
updateInnerHTMLByID: 'updateInnerHTMLByID',
8164
updateTextContentByID: 'updateTextContentByID',
8165
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
8166
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
8167
});
8168
8169
module.exports = ReactDOMIDOperations;
8170
8171
},{"11":11,"135":135,"148":148,"5":5,"70":70,"75":75,"9":9}],45:[function(_dereq_,module,exports){
8172
/**
8173
* Copyright 2013-2015, Facebook, Inc.
8174
* All rights reserved.
8175
*
8176
* This source code is licensed under the BSD-style license found in the
8177
* LICENSE file in the root directory of this source tree. An additional grant
8178
* of patent rights can be found in the PATENTS file in the same directory.
8179
*
8180
* @providesModule ReactDOMIframe
8181
*/
8182
8183
'use strict';
8184
8185
var EventConstants = _dereq_(15);
8186
var LocalEventTrapMixin = _dereq_(25);
8187
var ReactBrowserComponentMixin = _dereq_(29);
8188
var ReactClass = _dereq_(33);
8189
var ReactElement = _dereq_(57);
8190
8191
var iframe = ReactElement.createFactory('iframe');
8192
8193
/**
8194
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
8195
* capture it on the <iframe> element itself. There are lots of hacks we could
8196
* do to accomplish this, but the most reliable is to make <iframe> a composite
8197
* component and use `componentDidMount` to attach the event handlers.
8198
*/
8199
var ReactDOMIframe = ReactClass.createClass({
8200
displayName: 'ReactDOMIframe',
8201
tagName: 'IFRAME',
8202
8203
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
8204
8205
render: function() {
8206
return iframe(this.props);
8207
},
8208
8209
componentDidMount: function() {
8210
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
8211
}
8212
});
8213
8214
module.exports = ReactDOMIframe;
8215
8216
},{"15":15,"25":25,"29":29,"33":33,"57":57}],46:[function(_dereq_,module,exports){
8217
/**
8218
* Copyright 2013-2015, Facebook, Inc.
8219
* All rights reserved.
8220
*
8221
* This source code is licensed under the BSD-style license found in the
8222
* LICENSE file in the root directory of this source tree. An additional grant
8223
* of patent rights can be found in the PATENTS file in the same directory.
8224
*
8225
* @providesModule ReactDOMImg
8226
*/
8227
8228
'use strict';
8229
8230
var EventConstants = _dereq_(15);
8231
var LocalEventTrapMixin = _dereq_(25);
8232
var ReactBrowserComponentMixin = _dereq_(29);
8233
var ReactClass = _dereq_(33);
8234
var ReactElement = _dereq_(57);
8235
8236
var img = ReactElement.createFactory('img');
8237
8238
/**
8239
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
8240
* capture it on the <img> element itself. There are lots of hacks we could do
8241
* to accomplish this, but the most reliable is to make <img> a composite
8242
* component and use `componentDidMount` to attach the event handlers.
8243
*/
8244
var ReactDOMImg = ReactClass.createClass({
8245
displayName: 'ReactDOMImg',
8246
tagName: 'IMG',
8247
8248
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
8249
8250
render: function() {
8251
return img(this.props);
8252
},
8253
8254
componentDidMount: function() {
8255
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
8256
this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
8257
}
8258
});
8259
8260
module.exports = ReactDOMImg;
8261
8262
},{"15":15,"25":25,"29":29,"33":33,"57":57}],47:[function(_dereq_,module,exports){
8263
/**
8264
* Copyright 2013-2015, Facebook, Inc.
8265
* All rights reserved.
8266
*
8267
* This source code is licensed under the BSD-style license found in the
8268
* LICENSE file in the root directory of this source tree. An additional grant
8269
* of patent rights can be found in the PATENTS file in the same directory.
8270
*
8271
* @providesModule ReactDOMInput
8272
*/
8273
8274
'use strict';
8275
8276
var AutoFocusMixin = _dereq_(2);
8277
var DOMPropertyOperations = _dereq_(11);
8278
var LinkedValueUtils = _dereq_(24);
8279
var ReactBrowserComponentMixin = _dereq_(29);
8280
var ReactClass = _dereq_(33);
8281
var ReactElement = _dereq_(57);
8282
var ReactMount = _dereq_(70);
8283
var ReactUpdates = _dereq_(87);
8284
8285
var assign = _dereq_(27);
8286
var invariant = _dereq_(135);
8287
8288
var input = ReactElement.createFactory('input');
8289
8290
var instancesByReactID = {};
8291
8292
function forceUpdateIfMounted() {
8293
/*jshint validthis:true */
8294
if (this.isMounted()) {
8295
this.forceUpdate();
8296
}
8297
}
8298
8299
/**
8300
* Implements an <input> native component that allows setting these optional
8301
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
8302
*
8303
* If `checked` or `value` are not supplied (or null/undefined), user actions
8304
* that affect the checked state or value will trigger updates to the element.
8305
*
8306
* If they are supplied (and not null/undefined), the rendered element will not
8307
* trigger updates to the element. Instead, the props must change in order for
8308
* the rendered element to be updated.
8309
*
8310
* The rendered element will be initialized as unchecked (or `defaultChecked`)
8311
* with an empty value (or `defaultValue`).
8312
*
8313
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
8314
*/
8315
var ReactDOMInput = ReactClass.createClass({
8316
displayName: 'ReactDOMInput',
8317
tagName: 'INPUT',
8318
8319
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
8320
8321
getInitialState: function() {
8322
var defaultValue = this.props.defaultValue;
8323
return {
8324
initialChecked: this.props.defaultChecked || false,
8325
initialValue: defaultValue != null ? defaultValue : null
8326
};
8327
},
8328
8329
render: function() {
8330
// Clone `this.props` so we don't mutate the input.
8331
var props = assign({}, this.props);
8332
8333
props.defaultChecked = null;
8334
props.defaultValue = null;
8335
8336
var value = LinkedValueUtils.getValue(this);
8337
props.value = value != null ? value : this.state.initialValue;
8338
8339
var checked = LinkedValueUtils.getChecked(this);
8340
props.checked = checked != null ? checked : this.state.initialChecked;
8341
8342
props.onChange = this._handleChange;
8343
8344
return input(props, this.props.children);
8345
},
8346
8347
componentDidMount: function() {
8348
var id = ReactMount.getID(this.getDOMNode());
8349
instancesByReactID[id] = this;
8350
},
8351
8352
componentWillUnmount: function() {
8353
var rootNode = this.getDOMNode();
8354
var id = ReactMount.getID(rootNode);
8355
delete instancesByReactID[id];
8356
},
8357
8358
componentDidUpdate: function(prevProps, prevState, prevContext) {
8359
var rootNode = this.getDOMNode();
8360
if (this.props.checked != null) {
8361
DOMPropertyOperations.setValueForProperty(
8362
rootNode,
8363
'checked',
8364
this.props.checked || false
8365
);
8366
}
8367
8368
var value = LinkedValueUtils.getValue(this);
8369
if (value != null) {
8370
// Cast `value` to a string to ensure the value is set correctly. While
8371
// browsers typically do this as necessary, jsdom doesn't.
8372
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
8373
}
8374
},
8375
8376
_handleChange: function(event) {
8377
var returnValue;
8378
var onChange = LinkedValueUtils.getOnChange(this);
8379
if (onChange) {
8380
returnValue = onChange.call(this, event);
8381
}
8382
// Here we use asap to wait until all updates have propagated, which
8383
// is important when using controlled components within layers:
8384
// https://github.com/facebook/react/issues/1698
8385
ReactUpdates.asap(forceUpdateIfMounted, this);
8386
8387
var name = this.props.name;
8388
if (this.props.type === 'radio' && name != null) {
8389
var rootNode = this.getDOMNode();
8390
var queryRoot = rootNode;
8391
8392
while (queryRoot.parentNode) {
8393
queryRoot = queryRoot.parentNode;
8394
}
8395
8396
// If `rootNode.form` was non-null, then we could try `form.elements`,
8397
// but that sometimes behaves strangely in IE8. We could also try using
8398
// `form.getElementsByName`, but that will only return direct children
8399
// and won't include inputs that use the HTML5 `form=` attribute. Since
8400
// the input might not even be in a form, let's just use the global
8401
// `querySelectorAll` to ensure we don't miss anything.
8402
var group = queryRoot.querySelectorAll(
8403
'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
8404
8405
for (var i = 0, groupLen = group.length; i < groupLen; i++) {
8406
var otherNode = group[i];
8407
if (otherNode === rootNode ||
8408
otherNode.form !== rootNode.form) {
8409
continue;
8410
}
8411
var otherID = ReactMount.getID(otherNode);
8412
("production" !== "development" ? invariant(
8413
otherID,
8414
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
8415
'same `name` is not supported.'
8416
) : invariant(otherID));
8417
var otherInstance = instancesByReactID[otherID];
8418
("production" !== "development" ? invariant(
8419
otherInstance,
8420
'ReactDOMInput: Unknown radio button ID %s.',
8421
otherID
8422
) : invariant(otherInstance));
8423
// If this is a controlled radio button group, forcing the input that
8424
// was previously checked to update will cause it to be come re-checked
8425
// as appropriate.
8426
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
8427
}
8428
}
8429
8430
return returnValue;
8431
}
8432
8433
});
8434
8435
module.exports = ReactDOMInput;
8436
8437
},{"11":11,"135":135,"2":2,"24":24,"27":27,"29":29,"33":33,"57":57,"70":70,"87":87}],48:[function(_dereq_,module,exports){
8438
/**
8439
* Copyright 2013-2015, Facebook, Inc.
8440
* All rights reserved.
8441
*
8442
* This source code is licensed under the BSD-style license found in the
8443
* LICENSE file in the root directory of this source tree. An additional grant
8444
* of patent rights can be found in the PATENTS file in the same directory.
8445
*
8446
* @providesModule ReactDOMOption
8447
*/
8448
8449
'use strict';
8450
8451
var ReactBrowserComponentMixin = _dereq_(29);
8452
var ReactClass = _dereq_(33);
8453
var ReactElement = _dereq_(57);
8454
8455
var warning = _dereq_(154);
8456
8457
var option = ReactElement.createFactory('option');
8458
8459
/**
8460
* Implements an <option> native component that warns when `selected` is set.
8461
*/
8462
var ReactDOMOption = ReactClass.createClass({
8463
displayName: 'ReactDOMOption',
8464
tagName: 'OPTION',
8465
8466
mixins: [ReactBrowserComponentMixin],
8467
8468
componentWillMount: function() {
8469
// TODO (yungsters): Remove support for `selected` in <option>.
8470
if ("production" !== "development") {
8471
("production" !== "development" ? warning(
8472
this.props.selected == null,
8473
'Use the `defaultValue` or `value` props on <select> instead of ' +
8474
'setting `selected` on <option>.'
8475
) : null);
8476
}
8477
},
8478
8479
render: function() {
8480
return option(this.props, this.props.children);
8481
}
8482
8483
});
8484
8485
module.exports = ReactDOMOption;
8486
8487
},{"154":154,"29":29,"33":33,"57":57}],49:[function(_dereq_,module,exports){
8488
/**
8489
* Copyright 2013-2015, Facebook, Inc.
8490
* All rights reserved.
8491
*
8492
* This source code is licensed under the BSD-style license found in the
8493
* LICENSE file in the root directory of this source tree. An additional grant
8494
* of patent rights can be found in the PATENTS file in the same directory.
8495
*
8496
* @providesModule ReactDOMSelect
8497
*/
8498
8499
'use strict';
8500
8501
var AutoFocusMixin = _dereq_(2);
8502
var LinkedValueUtils = _dereq_(24);
8503
var ReactBrowserComponentMixin = _dereq_(29);
8504
var ReactClass = _dereq_(33);
8505
var ReactElement = _dereq_(57);
8506
var ReactUpdates = _dereq_(87);
8507
8508
var assign = _dereq_(27);
8509
8510
var select = ReactElement.createFactory('select');
8511
8512
function updateOptionsIfPendingUpdateAndMounted() {
8513
/*jshint validthis:true */
8514
if (this._pendingUpdate) {
8515
this._pendingUpdate = false;
8516
var value = LinkedValueUtils.getValue(this);
8517
if (value != null && this.isMounted()) {
8518
updateOptions(this, value);
8519
}
8520
}
8521
}
8522
8523
/**
8524
* Validation function for `value` and `defaultValue`.
8525
* @private
8526
*/
8527
function selectValueType(props, propName, componentName) {
8528
if (props[propName] == null) {
8529
return null;
8530
}
8531
if (props.multiple) {
8532
if (!Array.isArray(props[propName])) {
8533
return new Error(
8534
("The `" + propName + "` prop supplied to <select> must be an array if ") +
8535
("`multiple` is true.")
8536
);
8537
}
8538
} else {
8539
if (Array.isArray(props[propName])) {
8540
return new Error(
8541
("The `" + propName + "` prop supplied to <select> must be a scalar ") +
8542
("value if `multiple` is false.")
8543
);
8544
}
8545
}
8546
}
8547
8548
/**
8549
* @param {ReactComponent} component Instance of ReactDOMSelect
8550
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
8551
* @private
8552
*/
8553
function updateOptions(component, propValue) {
8554
var selectedValue, i, l;
8555
var options = component.getDOMNode().options;
8556
8557
if (component.props.multiple) {
8558
selectedValue = {};
8559
for (i = 0, l = propValue.length; i < l; i++) {
8560
selectedValue['' + propValue[i]] = true;
8561
}
8562
for (i = 0, l = options.length; i < l; i++) {
8563
var selected = selectedValue.hasOwnProperty(options[i].value);
8564
if (options[i].selected !== selected) {
8565
options[i].selected = selected;
8566
}
8567
}
8568
} else {
8569
// Do not set `select.value` as exact behavior isn't consistent across all
8570
// browsers for all cases.
8571
selectedValue = '' + propValue;
8572
for (i = 0, l = options.length; i < l; i++) {
8573
if (options[i].value === selectedValue) {
8574
options[i].selected = true;
8575
return;
8576
}
8577
}
8578
if (options.length) {
8579
options[0].selected = true;
8580
}
8581
}
8582
}
8583
8584
/**
8585
* Implements a <select> native component that allows optionally setting the
8586
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
8587
* stringable. If `multiple` is true, the prop must be an array of stringables.
8588
*
8589
* If `value` is not supplied (or null/undefined), user actions that change the
8590
* selected option will trigger updates to the rendered options.
8591
*
8592
* If it is supplied (and not null/undefined), the rendered options will not
8593
* update in response to user actions. Instead, the `value` prop must change in
8594
* order for the rendered options to update.
8595
*
8596
* If `defaultValue` is provided, any options with the supplied values will be
8597
* selected.
8598
*/
8599
var ReactDOMSelect = ReactClass.createClass({
8600
displayName: 'ReactDOMSelect',
8601
tagName: 'SELECT',
8602
8603
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
8604
8605
propTypes: {
8606
defaultValue: selectValueType,
8607
value: selectValueType
8608
},
8609
8610
render: function() {
8611
// Clone `this.props` so we don't mutate the input.
8612
var props = assign({}, this.props);
8613
8614
props.onChange = this._handleChange;
8615
props.value = null;
8616
8617
return select(props, this.props.children);
8618
},
8619
8620
componentWillMount: function() {
8621
this._pendingUpdate = false;
8622
},
8623
8624
componentDidMount: function() {
8625
var value = LinkedValueUtils.getValue(this);
8626
if (value != null) {
8627
updateOptions(this, value);
8628
} else if (this.props.defaultValue != null) {
8629
updateOptions(this, this.props.defaultValue);
8630
}
8631
},
8632
8633
componentDidUpdate: function(prevProps) {
8634
var value = LinkedValueUtils.getValue(this);
8635
if (value != null) {
8636
this._pendingUpdate = false;
8637
updateOptions(this, value);
8638
} else if (!prevProps.multiple !== !this.props.multiple) {
8639
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
8640
if (this.props.defaultValue != null) {
8641
updateOptions(this, this.props.defaultValue);
8642
} else {
8643
// Revert the select back to its default unselected state.
8644
updateOptions(this, this.props.multiple ? [] : '');
8645
}
8646
}
8647
},
8648
8649
_handleChange: function(event) {
8650
var returnValue;
8651
var onChange = LinkedValueUtils.getOnChange(this);
8652
if (onChange) {
8653
returnValue = onChange.call(this, event);
8654
}
8655
8656
this._pendingUpdate = true;
8657
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
8658
return returnValue;
8659
}
8660
8661
});
8662
8663
module.exports = ReactDOMSelect;
8664
8665
},{"2":2,"24":24,"27":27,"29":29,"33":33,"57":57,"87":87}],50:[function(_dereq_,module,exports){
8666
/**
8667
* Copyright 2013-2015, Facebook, Inc.
8668
* All rights reserved.
8669
*
8670
* This source code is licensed under the BSD-style license found in the
8671
* LICENSE file in the root directory of this source tree. An additional grant
8672
* of patent rights can be found in the PATENTS file in the same directory.
8673
*
8674
* @providesModule ReactDOMSelection
8675
*/
8676
8677
'use strict';
8678
8679
var ExecutionEnvironment = _dereq_(21);
8680
8681
var getNodeForCharacterOffset = _dereq_(128);
8682
var getTextContentAccessor = _dereq_(130);
8683
8684
/**
8685
* While `isCollapsed` is available on the Selection object and `collapsed`
8686
* is available on the Range object, IE11 sometimes gets them wrong.
8687
* If the anchor/focus nodes and offsets are the same, the range is collapsed.
8688
*/
8689
function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
8690
return anchorNode === focusNode && anchorOffset === focusOffset;
8691
}
8692
8693
/**
8694
* Get the appropriate anchor and focus node/offset pairs for IE.
8695
*
8696
* The catch here is that IE's selection API doesn't provide information
8697
* about whether the selection is forward or backward, so we have to
8698
* behave as though it's always forward.
8699
*
8700
* IE text differs from modern selection in that it behaves as though
8701
* block elements end with a new line. This means character offsets will
8702
* differ between the two APIs.
8703
*
8704
* @param {DOMElement} node
8705
* @return {object}
8706
*/
8707
function getIEOffsets(node) {
8708
var selection = document.selection;
8709
var selectedRange = selection.createRange();
8710
var selectedLength = selectedRange.text.length;
8711
8712
// Duplicate selection so we can move range without breaking user selection.
8713
var fromStart = selectedRange.duplicate();
8714
fromStart.moveToElementText(node);
8715
fromStart.setEndPoint('EndToStart', selectedRange);
8716
8717
var startOffset = fromStart.text.length;
8718
var endOffset = startOffset + selectedLength;
8719
8720
return {
8721
start: startOffset,
8722
end: endOffset
8723
};
8724
}
8725
8726
/**
8727
* @param {DOMElement} node
8728
* @return {?object}
8729
*/
8730
function getModernOffsets(node) {
8731
var selection = window.getSelection && window.getSelection();
8732
8733
if (!selection || selection.rangeCount === 0) {
8734
return null;
8735
}
8736
8737
var anchorNode = selection.anchorNode;
8738
var anchorOffset = selection.anchorOffset;
8739
var focusNode = selection.focusNode;
8740
var focusOffset = selection.focusOffset;
8741
8742
var currentRange = selection.getRangeAt(0);
8743
8744
// If the node and offset values are the same, the selection is collapsed.
8745
// `Selection.isCollapsed` is available natively, but IE sometimes gets
8746
// this value wrong.
8747
var isSelectionCollapsed = isCollapsed(
8748
selection.anchorNode,
8749
selection.anchorOffset,
8750
selection.focusNode,
8751
selection.focusOffset
8752
);
8753
8754
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
8755
8756
var tempRange = currentRange.cloneRange();
8757
tempRange.selectNodeContents(node);
8758
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
8759
8760
var isTempRangeCollapsed = isCollapsed(
8761
tempRange.startContainer,
8762
tempRange.startOffset,
8763
tempRange.endContainer,
8764
tempRange.endOffset
8765
);
8766
8767
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
8768
var end = start + rangeLength;
8769
8770
// Detect whether the selection is backward.
8771
var detectionRange = document.createRange();
8772
detectionRange.setStart(anchorNode, anchorOffset);
8773
detectionRange.setEnd(focusNode, focusOffset);
8774
var isBackward = detectionRange.collapsed;
8775
8776
return {
8777
start: isBackward ? end : start,
8778
end: isBackward ? start : end
8779
};
8780
}
8781
8782
/**
8783
* @param {DOMElement|DOMTextNode} node
8784
* @param {object} offsets
8785
*/
8786
function setIEOffsets(node, offsets) {
8787
var range = document.selection.createRange().duplicate();
8788
var start, end;
8789
8790
if (typeof offsets.end === 'undefined') {
8791
start = offsets.start;
8792
end = start;
8793
} else if (offsets.start > offsets.end) {
8794
start = offsets.end;
8795
end = offsets.start;
8796
} else {
8797
start = offsets.start;
8798
end = offsets.end;
8799
}
8800
8801
range.moveToElementText(node);
8802
range.moveStart('character', start);
8803
range.setEndPoint('EndToStart', range);
8804
range.moveEnd('character', end - start);
8805
range.select();
8806
}
8807
8808
/**
8809
* In modern non-IE browsers, we can support both forward and backward
8810
* selections.
8811
*
8812
* Note: IE10+ supports the Selection object, but it does not support
8813
* the `extend` method, which means that even in modern IE, it's not possible
8814
* to programatically create a backward selection. Thus, for all IE
8815
* versions, we use the old IE API to create our selections.
8816
*
8817
* @param {DOMElement|DOMTextNode} node
8818
* @param {object} offsets
8819
*/
8820
function setModernOffsets(node, offsets) {
8821
if (!window.getSelection) {
8822
return;
8823
}
8824
8825
var selection = window.getSelection();
8826
var length = node[getTextContentAccessor()].length;
8827
var start = Math.min(offsets.start, length);
8828
var end = typeof offsets.end === 'undefined' ?
8829
start : Math.min(offsets.end, length);
8830
8831
// IE 11 uses modern selection, but doesn't support the extend method.
8832
// Flip backward selections, so we can set with a single range.
8833
if (!selection.extend && start > end) {
8834
var temp = end;
8835
end = start;
8836
start = temp;
8837
}
8838
8839
var startMarker = getNodeForCharacterOffset(node, start);
8840
var endMarker = getNodeForCharacterOffset(node, end);
8841
8842
if (startMarker && endMarker) {
8843
var range = document.createRange();
8844
range.setStart(startMarker.node, startMarker.offset);
8845
selection.removeAllRanges();
8846
8847
if (start > end) {
8848
selection.addRange(range);
8849
selection.extend(endMarker.node, endMarker.offset);
8850
} else {
8851
range.setEnd(endMarker.node, endMarker.offset);
8852
selection.addRange(range);
8853
}
8854
}
8855
}
8856
8857
var useIEOffsets = (
8858
ExecutionEnvironment.canUseDOM &&
8859
'selection' in document &&
8860
!('getSelection' in window)
8861
);
8862
8863
var ReactDOMSelection = {
8864
/**
8865
* @param {DOMElement} node
8866
*/
8867
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
8868
8869
/**
8870
* @param {DOMElement|DOMTextNode} node
8871
* @param {object} offsets
8872
*/
8873
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
8874
};
8875
8876
module.exports = ReactDOMSelection;
8877
8878
},{"128":128,"130":130,"21":21}],51:[function(_dereq_,module,exports){
8879
/**
8880
* Copyright 2013-2015, Facebook, Inc.
8881
* All rights reserved.
8882
*
8883
* This source code is licensed under the BSD-style license found in the
8884
* LICENSE file in the root directory of this source tree. An additional grant
8885
* of patent rights can be found in the PATENTS file in the same directory.
8886
*
8887
* @providesModule ReactDOMTextComponent
8888
* @typechecks static-only
8889
*/
8890
8891
'use strict';
8892
8893
var DOMPropertyOperations = _dereq_(11);
8894
var ReactComponentBrowserEnvironment =
8895
_dereq_(35);
8896
var ReactDOMComponent = _dereq_(42);
8897
8898
var assign = _dereq_(27);
8899
var escapeTextContentForBrowser = _dereq_(116);
8900
8901
/**
8902
* Text nodes violate a couple assumptions that React makes about components:
8903
*
8904
* - When mounting text into the DOM, adjacent text nodes are merged.
8905
* - Text nodes cannot be assigned a React root ID.
8906
*
8907
* This component is used to wrap strings in elements so that they can undergo
8908
* the same reconciliation that is applied to elements.
8909
*
8910
* TODO: Investigate representing React components in the DOM with text nodes.
8911
*
8912
* @class ReactDOMTextComponent
8913
* @extends ReactComponent
8914
* @internal
8915
*/
8916
var ReactDOMTextComponent = function(props) {
8917
// This constructor and its argument is currently used by mocks.
8918
};
8919
8920
assign(ReactDOMTextComponent.prototype, {
8921
8922
/**
8923
* @param {ReactText} text
8924
* @internal
8925
*/
8926
construct: function(text) {
8927
// TODO: This is really a ReactText (ReactNode), not a ReactElement
8928
this._currentElement = text;
8929
this._stringText = '' + text;
8930
8931
// Properties
8932
this._rootNodeID = null;
8933
this._mountIndex = 0;
8934
},
8935
8936
/**
8937
* Creates the markup for this text node. This node is not intended to have
8938
* any features besides containing text content.
8939
*
8940
* @param {string} rootID DOM ID of the root node.
8941
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
8942
* @return {string} Markup for this text node.
8943
* @internal
8944
*/
8945
mountComponent: function(rootID, transaction, context) {
8946
this._rootNodeID = rootID;
8947
var escapedText = escapeTextContentForBrowser(this._stringText);
8948
8949
if (transaction.renderToStaticMarkup) {
8950
// Normally we'd wrap this in a `span` for the reasons stated above, but
8951
// since this is a situation where React won't take over (static pages),
8952
// we can simply return the text as it is.
8953
return escapedText;
8954
}
8955
8956
return (
8957
'<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
8958
escapedText +
8959
'</span>'
8960
);
8961
},
8962
8963
/**
8964
* Updates this component by updating the text content.
8965
*
8966
* @param {ReactText} nextText The next text content
8967
* @param {ReactReconcileTransaction} transaction
8968
* @internal
8969
*/
8970
receiveComponent: function(nextText, transaction) {
8971
if (nextText !== this._currentElement) {
8972
this._currentElement = nextText;
8973
var nextStringText = '' + nextText;
8974
if (nextStringText !== this._stringText) {
8975
// TODO: Save this as pending props and use performUpdateIfNecessary
8976
// and/or updateComponent to do the actual update for consistency with
8977
// other component types?
8978
this._stringText = nextStringText;
8979
ReactDOMComponent.BackendIDOperations.updateTextContentByID(
8980
this._rootNodeID,
8981
nextStringText
8982
);
8983
}
8984
}
8985
},
8986
8987
unmountComponent: function() {
8988
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
8989
}
8990
8991
});
8992
8993
module.exports = ReactDOMTextComponent;
8994
8995
},{"11":11,"116":116,"27":27,"35":35,"42":42}],52:[function(_dereq_,module,exports){
8996
/**
8997
* Copyright 2013-2015, Facebook, Inc.
8998
* All rights reserved.
8999
*
9000
* This source code is licensed under the BSD-style license found in the
9001
* LICENSE file in the root directory of this source tree. An additional grant
9002
* of patent rights can be found in the PATENTS file in the same directory.
9003
*
9004
* @providesModule ReactDOMTextarea
9005
*/
9006
9007
'use strict';
9008
9009
var AutoFocusMixin = _dereq_(2);
9010
var DOMPropertyOperations = _dereq_(11);
9011
var LinkedValueUtils = _dereq_(24);
9012
var ReactBrowserComponentMixin = _dereq_(29);
9013
var ReactClass = _dereq_(33);
9014
var ReactElement = _dereq_(57);
9015
var ReactUpdates = _dereq_(87);
9016
9017
var assign = _dereq_(27);
9018
var invariant = _dereq_(135);
9019
9020
var warning = _dereq_(154);
9021
9022
var textarea = ReactElement.createFactory('textarea');
9023
9024
function forceUpdateIfMounted() {
9025
/*jshint validthis:true */
9026
if (this.isMounted()) {
9027
this.forceUpdate();
9028
}
9029
}
9030
9031
/**
9032
* Implements a <textarea> native component that allows setting `value`, and
9033
* `defaultValue`. This differs from the traditional DOM API because value is
9034
* usually set as PCDATA children.
9035
*
9036
* If `value` is not supplied (or null/undefined), user actions that affect the
9037
* value will trigger updates to the element.
9038
*
9039
* If `value` is supplied (and not null/undefined), the rendered element will
9040
* not trigger updates to the element. Instead, the `value` prop must change in
9041
* order for the rendered element to be updated.
9042
*
9043
* The rendered element will be initialized with an empty value, the prop
9044
* `defaultValue` if specified, or the children content (deprecated).
9045
*/
9046
var ReactDOMTextarea = ReactClass.createClass({
9047
displayName: 'ReactDOMTextarea',
9048
tagName: 'TEXTAREA',
9049
9050
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
9051
9052
getInitialState: function() {
9053
var defaultValue = this.props.defaultValue;
9054
// TODO (yungsters): Remove support for children content in <textarea>.
9055
var children = this.props.children;
9056
if (children != null) {
9057
if ("production" !== "development") {
9058
("production" !== "development" ? warning(
9059
false,
9060
'Use the `defaultValue` or `value` props instead of setting ' +
9061
'children on <textarea>.'
9062
) : null);
9063
}
9064
("production" !== "development" ? invariant(
9065
defaultValue == null,
9066
'If you supply `defaultValue` on a <textarea>, do not pass children.'
9067
) : invariant(defaultValue == null));
9068
if (Array.isArray(children)) {
9069
("production" !== "development" ? invariant(
9070
children.length <= 1,
9071
'<textarea> can only have at most one child.'
9072
) : invariant(children.length <= 1));
9073
children = children[0];
9074
}
9075
9076
defaultValue = '' + children;
9077
}
9078
if (defaultValue == null) {
9079
defaultValue = '';
9080
}
9081
var value = LinkedValueUtils.getValue(this);
9082
return {
9083
// We save the initial value so that `ReactDOMComponent` doesn't update
9084
// `textContent` (unnecessary since we update value).
9085
// The initial value can be a boolean or object so that's why it's
9086
// forced to be a string.
9087
initialValue: '' + (value != null ? value : defaultValue)
9088
};
9089
},
9090
9091
render: function() {
9092
// Clone `this.props` so we don't mutate the input.
9093
var props = assign({}, this.props);
9094
9095
("production" !== "development" ? invariant(
9096
props.dangerouslySetInnerHTML == null,
9097
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
9098
) : invariant(props.dangerouslySetInnerHTML == null));
9099
9100
props.defaultValue = null;
9101
props.value = null;
9102
props.onChange = this._handleChange;
9103
9104
// Always set children to the same thing. In IE9, the selection range will
9105
// get reset if `textContent` is mutated.
9106
return textarea(props, this.state.initialValue);
9107
},
9108
9109
componentDidUpdate: function(prevProps, prevState, prevContext) {
9110
var value = LinkedValueUtils.getValue(this);
9111
if (value != null) {
9112
var rootNode = this.getDOMNode();
9113
// Cast `value` to a string to ensure the value is set correctly. While
9114
// browsers typically do this as necessary, jsdom doesn't.
9115
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
9116
}
9117
},
9118
9119
_handleChange: function(event) {
9120
var returnValue;
9121
var onChange = LinkedValueUtils.getOnChange(this);
9122
if (onChange) {
9123
returnValue = onChange.call(this, event);
9124
}
9125
ReactUpdates.asap(forceUpdateIfMounted, this);
9126
return returnValue;
9127
}
9128
9129
});
9130
9131
module.exports = ReactDOMTextarea;
9132
9133
},{"11":11,"135":135,"154":154,"2":2,"24":24,"27":27,"29":29,"33":33,"57":57,"87":87}],53:[function(_dereq_,module,exports){
9134
/**
9135
* Copyright 2013-2015, Facebook, Inc.
9136
* All rights reserved.
9137
*
9138
* This source code is licensed under the BSD-style license found in the
9139
* LICENSE file in the root directory of this source tree. An additional grant
9140
* of patent rights can be found in the PATENTS file in the same directory.
9141
*
9142
* @providesModule ReactDefaultBatchingStrategy
9143
*/
9144
9145
'use strict';
9146
9147
var ReactUpdates = _dereq_(87);
9148
var Transaction = _dereq_(103);
9149
9150
var assign = _dereq_(27);
9151
var emptyFunction = _dereq_(114);
9152
9153
var RESET_BATCHED_UPDATES = {
9154
initialize: emptyFunction,
9155
close: function() {
9156
ReactDefaultBatchingStrategy.isBatchingUpdates = false;
9157
}
9158
};
9159
9160
var FLUSH_BATCHED_UPDATES = {
9161
initialize: emptyFunction,
9162
close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
9163
};
9164
9165
var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
9166
9167
function ReactDefaultBatchingStrategyTransaction() {
9168
this.reinitializeTransaction();
9169
}
9170
9171
assign(
9172
ReactDefaultBatchingStrategyTransaction.prototype,
9173
Transaction.Mixin,
9174
{
9175
getTransactionWrappers: function() {
9176
return TRANSACTION_WRAPPERS;
9177
}
9178
}
9179
);
9180
9181
var transaction = new ReactDefaultBatchingStrategyTransaction();
9182
9183
var ReactDefaultBatchingStrategy = {
9184
isBatchingUpdates: false,
9185
9186
/**
9187
* Call the provided function in a context within which calls to `setState`
9188
* and friends are batched such that components aren't updated unnecessarily.
9189
*/
9190
batchedUpdates: function(callback, a, b, c, d) {
9191
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
9192
9193
ReactDefaultBatchingStrategy.isBatchingUpdates = true;
9194
9195
// The code is written this way to avoid extra allocations
9196
if (alreadyBatchingUpdates) {
9197
callback(a, b, c, d);
9198
} else {
9199
transaction.perform(callback, null, a, b, c, d);
9200
}
9201
}
9202
};
9203
9204
module.exports = ReactDefaultBatchingStrategy;
9205
9206
},{"103":103,"114":114,"27":27,"87":87}],54:[function(_dereq_,module,exports){
9207
/**
9208
* Copyright 2013-2015, Facebook, Inc.
9209
* All rights reserved.
9210
*
9211
* This source code is licensed under the BSD-style license found in the
9212
* LICENSE file in the root directory of this source tree. An additional grant
9213
* of patent rights can be found in the PATENTS file in the same directory.
9214
*
9215
* @providesModule ReactDefaultInjection
9216
*/
9217
9218
'use strict';
9219
9220
var BeforeInputEventPlugin = _dereq_(3);
9221
var ChangeEventPlugin = _dereq_(7);
9222
var ClientReactRootIndex = _dereq_(8);
9223
var DefaultEventPluginOrder = _dereq_(13);
9224
var EnterLeaveEventPlugin = _dereq_(14);
9225
var ExecutionEnvironment = _dereq_(21);
9226
var HTMLDOMPropertyConfig = _dereq_(23);
9227
var MobileSafariClickEventPlugin = _dereq_(26);
9228
var ReactBrowserComponentMixin = _dereq_(29);
9229
var ReactClass = _dereq_(33);
9230
var ReactComponentBrowserEnvironment =
9231
_dereq_(35);
9232
var ReactDefaultBatchingStrategy = _dereq_(53);
9233
var ReactDOMComponent = _dereq_(42);
9234
var ReactDOMButton = _dereq_(41);
9235
var ReactDOMForm = _dereq_(43);
9236
var ReactDOMImg = _dereq_(46);
9237
var ReactDOMIDOperations = _dereq_(44);
9238
var ReactDOMIframe = _dereq_(45);
9239
var ReactDOMInput = _dereq_(47);
9240
var ReactDOMOption = _dereq_(48);
9241
var ReactDOMSelect = _dereq_(49);
9242
var ReactDOMTextarea = _dereq_(52);
9243
var ReactDOMTextComponent = _dereq_(51);
9244
var ReactElement = _dereq_(57);
9245
var ReactEventListener = _dereq_(62);
9246
var ReactInjection = _dereq_(64);
9247
var ReactInstanceHandles = _dereq_(66);
9248
var ReactMount = _dereq_(70);
9249
var ReactReconcileTransaction = _dereq_(80);
9250
var SelectEventPlugin = _dereq_(89);
9251
var ServerReactRootIndex = _dereq_(90);
9252
var SimpleEventPlugin = _dereq_(91);
9253
var SVGDOMPropertyConfig = _dereq_(88);
9254
9255
var createFullPageComponent = _dereq_(111);
9256
9257
function autoGenerateWrapperClass(type) {
9258
return ReactClass.createClass({
9259
tagName: type.toUpperCase(),
9260
render: function() {
9261
return new ReactElement(
9262
type,
9263
null,
9264
null,
9265
null,
9266
null,
9267
this.props
9268
);
9269
}
9270
});
9271
}
9272
9273
function inject() {
9274
ReactInjection.EventEmitter.injectReactEventListener(
9275
ReactEventListener
9276
);
9277
9278
/**
9279
* Inject modules for resolving DOM hierarchy and plugin ordering.
9280
*/
9281
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
9282
ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
9283
ReactInjection.EventPluginHub.injectMount(ReactMount);
9284
9285
/**
9286
* Some important event plugins included by default (without having to require
9287
* them).
9288
*/
9289
ReactInjection.EventPluginHub.injectEventPluginsByName({
9290
SimpleEventPlugin: SimpleEventPlugin,
9291
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
9292
ChangeEventPlugin: ChangeEventPlugin,
9293
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
9294
SelectEventPlugin: SelectEventPlugin,
9295
BeforeInputEventPlugin: BeforeInputEventPlugin
9296
});
9297
9298
ReactInjection.NativeComponent.injectGenericComponentClass(
9299
ReactDOMComponent
9300
);
9301
9302
ReactInjection.NativeComponent.injectTextComponentClass(
9303
ReactDOMTextComponent
9304
);
9305
9306
ReactInjection.NativeComponent.injectAutoWrapper(
9307
autoGenerateWrapperClass
9308
);
9309
9310
// This needs to happen before createFullPageComponent() otherwise the mixin
9311
// won't be included.
9312
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
9313
9314
ReactInjection.NativeComponent.injectComponentClasses({
9315
'button': ReactDOMButton,
9316
'form': ReactDOMForm,
9317
'iframe': ReactDOMIframe,
9318
'img': ReactDOMImg,
9319
'input': ReactDOMInput,
9320
'option': ReactDOMOption,
9321
'select': ReactDOMSelect,
9322
'textarea': ReactDOMTextarea,
9323
9324
'html': createFullPageComponent('html'),
9325
'head': createFullPageComponent('head'),
9326
'body': createFullPageComponent('body')
9327
});
9328
9329
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
9330
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
9331
9332
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
9333
9334
ReactInjection.Updates.injectReconcileTransaction(
9335
ReactReconcileTransaction
9336
);
9337
ReactInjection.Updates.injectBatchingStrategy(
9338
ReactDefaultBatchingStrategy
9339
);
9340
9341
ReactInjection.RootIndex.injectCreateReactRootIndex(
9342
ExecutionEnvironment.canUseDOM ?
9343
ClientReactRootIndex.createReactRootIndex :
9344
ServerReactRootIndex.createReactRootIndex
9345
);
9346
9347
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
9348
ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
9349
9350
if ("production" !== "development") {
9351
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
9352
if ((/[?&]react_perf\b/).test(url)) {
9353
var ReactDefaultPerf = _dereq_(55);
9354
ReactDefaultPerf.start();
9355
}
9356
}
9357
}
9358
9359
module.exports = {
9360
inject: inject
9361
};
9362
9363
},{"111":111,"13":13,"14":14,"21":21,"23":23,"26":26,"29":29,"3":3,"33":33,"35":35,"41":41,"42":42,"43":43,"44":44,"45":45,"46":46,"47":47,"48":48,"49":49,"51":51,"52":52,"53":53,"55":55,"57":57,"62":62,"64":64,"66":66,"7":7,"70":70,"8":8,"80":80,"88":88,"89":89,"90":90,"91":91}],55:[function(_dereq_,module,exports){
9364
/**
9365
* Copyright 2013-2015, Facebook, Inc.
9366
* All rights reserved.
9367
*
9368
* This source code is licensed under the BSD-style license found in the
9369
* LICENSE file in the root directory of this source tree. An additional grant
9370
* of patent rights can be found in the PATENTS file in the same directory.
9371
*
9372
* @providesModule ReactDefaultPerf
9373
* @typechecks static-only
9374
*/
9375
9376
'use strict';
9377
9378
var DOMProperty = _dereq_(10);
9379
var ReactDefaultPerfAnalysis = _dereq_(56);
9380
var ReactMount = _dereq_(70);
9381
var ReactPerf = _dereq_(75);
9382
9383
var performanceNow = _dereq_(146);
9384
9385
function roundFloat(val) {
9386
return Math.floor(val * 100) / 100;
9387
}
9388
9389
function addValue(obj, key, val) {
9390
obj[key] = (obj[key] || 0) + val;
9391
}
9392
9393
var ReactDefaultPerf = {
9394
_allMeasurements: [], // last item in the list is the current one
9395
_mountStack: [0],
9396
_injected: false,
9397
9398
start: function() {
9399
if (!ReactDefaultPerf._injected) {
9400
ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
9401
}
9402
9403
ReactDefaultPerf._allMeasurements.length = 0;
9404
ReactPerf.enableMeasure = true;
9405
},
9406
9407
stop: function() {
9408
ReactPerf.enableMeasure = false;
9409
},
9410
9411
getLastMeasurements: function() {
9412
return ReactDefaultPerf._allMeasurements;
9413
},
9414
9415
printExclusive: function(measurements) {
9416
measurements = measurements || ReactDefaultPerf._allMeasurements;
9417
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
9418
console.table(summary.map(function(item) {
9419
return {
9420
'Component class name': item.componentName,
9421
'Total inclusive time (ms)': roundFloat(item.inclusive),
9422
'Exclusive mount time (ms)': roundFloat(item.exclusive),
9423
'Exclusive render time (ms)': roundFloat(item.render),
9424
'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
9425
'Render time per instance (ms)': roundFloat(item.render / item.count),
9426
'Instances': item.count
9427
};
9428
}));
9429
// TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
9430
// number.
9431
},
9432
9433
printInclusive: function(measurements) {
9434
measurements = measurements || ReactDefaultPerf._allMeasurements;
9435
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
9436
console.table(summary.map(function(item) {
9437
return {
9438
'Owner > component': item.componentName,
9439
'Inclusive time (ms)': roundFloat(item.time),
9440
'Instances': item.count
9441
};
9442
}));
9443
console.log(
9444
'Total time:',
9445
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9446
);
9447
},
9448
9449
getMeasurementsSummaryMap: function(measurements) {
9450
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
9451
measurements,
9452
true
9453
);
9454
return summary.map(function(item) {
9455
return {
9456
'Owner > component': item.componentName,
9457
'Wasted time (ms)': item.time,
9458
'Instances': item.count
9459
};
9460
});
9461
},
9462
9463
printWasted: function(measurements) {
9464
measurements = measurements || ReactDefaultPerf._allMeasurements;
9465
console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
9466
console.log(
9467
'Total time:',
9468
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9469
);
9470
},
9471
9472
printDOM: function(measurements) {
9473
measurements = measurements || ReactDefaultPerf._allMeasurements;
9474
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
9475
console.table(summary.map(function(item) {
9476
var result = {};
9477
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
9478
result['type'] = item.type;
9479
result['args'] = JSON.stringify(item.args);
9480
return result;
9481
}));
9482
console.log(
9483
'Total time:',
9484
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9485
);
9486
},
9487
9488
_recordWrite: function(id, fnName, totalTime, args) {
9489
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
9490
var writes =
9491
ReactDefaultPerf
9492
._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
9493
.writes;
9494
writes[id] = writes[id] || [];
9495
writes[id].push({
9496
type: fnName,
9497
time: totalTime,
9498
args: args
9499
});
9500
},
9501
9502
measure: function(moduleName, fnName, func) {
9503
return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
9504
var totalTime;
9505
var rv;
9506
var start;
9507
9508
if (fnName === '_renderNewRootComponent' ||
9509
fnName === 'flushBatchedUpdates') {
9510
// A "measurement" is a set of metrics recorded for each flush. We want
9511
// to group the metrics for a given flush together so we can look at the
9512
// components that rendered and the DOM operations that actually
9513
// happened to determine the amount of "wasted work" performed.
9514
ReactDefaultPerf._allMeasurements.push({
9515
exclusive: {},
9516
inclusive: {},
9517
render: {},
9518
counts: {},
9519
writes: {},
9520
displayNames: {},
9521
totalTime: 0
9522
});
9523
start = performanceNow();
9524
rv = func.apply(this, args);
9525
ReactDefaultPerf._allMeasurements[
9526
ReactDefaultPerf._allMeasurements.length - 1
9527
].totalTime = performanceNow() - start;
9528
return rv;
9529
} else if (fnName === '_mountImageIntoNode' ||
9530
moduleName === 'ReactDOMIDOperations') {
9531
start = performanceNow();
9532
rv = func.apply(this, args);
9533
totalTime = performanceNow() - start;
9534
9535
if (fnName === '_mountImageIntoNode') {
9536
var mountID = ReactMount.getID(args[1]);
9537
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
9538
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
9539
// special format
9540
args[0].forEach(function(update) {
9541
var writeArgs = {};
9542
if (update.fromIndex !== null) {
9543
writeArgs.fromIndex = update.fromIndex;
9544
}
9545
if (update.toIndex !== null) {
9546
writeArgs.toIndex = update.toIndex;
9547
}
9548
if (update.textContent !== null) {
9549
writeArgs.textContent = update.textContent;
9550
}
9551
if (update.markupIndex !== null) {
9552
writeArgs.markup = args[1][update.markupIndex];
9553
}
9554
ReactDefaultPerf._recordWrite(
9555
update.parentID,
9556
update.type,
9557
totalTime,
9558
writeArgs
9559
);
9560
});
9561
} else {
9562
// basic format
9563
ReactDefaultPerf._recordWrite(
9564
args[0],
9565
fnName,
9566
totalTime,
9567
Array.prototype.slice.call(args, 1)
9568
);
9569
}
9570
return rv;
9571
} else if (moduleName === 'ReactCompositeComponent' && (
9572
(// TODO: receiveComponent()?
9573
(fnName === 'mountComponent' ||
9574
fnName === 'updateComponent' || fnName === '_renderValidatedComponent')))) {
9575
9576
if (typeof this._currentElement.type === 'string') {
9577
return func.apply(this, args);
9578
}
9579
9580
var rootNodeID = fnName === 'mountComponent' ?
9581
args[0] :
9582
this._rootNodeID;
9583
var isRender = fnName === '_renderValidatedComponent';
9584
var isMount = fnName === 'mountComponent';
9585
9586
var mountStack = ReactDefaultPerf._mountStack;
9587
var entry = ReactDefaultPerf._allMeasurements[
9588
ReactDefaultPerf._allMeasurements.length - 1
9589
];
9590
9591
if (isRender) {
9592
addValue(entry.counts, rootNodeID, 1);
9593
} else if (isMount) {
9594
mountStack.push(0);
9595
}
9596
9597
start = performanceNow();
9598
rv = func.apply(this, args);
9599
totalTime = performanceNow() - start;
9600
9601
if (isRender) {
9602
addValue(entry.render, rootNodeID, totalTime);
9603
} else if (isMount) {
9604
var subMountTime = mountStack.pop();
9605
mountStack[mountStack.length - 1] += totalTime;
9606
addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
9607
addValue(entry.inclusive, rootNodeID, totalTime);
9608
} else {
9609
addValue(entry.inclusive, rootNodeID, totalTime);
9610
}
9611
9612
entry.displayNames[rootNodeID] = {
9613
current: this.getName(),
9614
owner: this._currentElement._owner ?
9615
this._currentElement._owner.getName() :
9616
'<root>'
9617
};
9618
9619
return rv;
9620
} else {
9621
return func.apply(this, args);
9622
}
9623
};
9624
}
9625
};
9626
9627
module.exports = ReactDefaultPerf;
9628
9629
},{"10":10,"146":146,"56":56,"70":70,"75":75}],56:[function(_dereq_,module,exports){
9630
/**
9631
* Copyright 2013-2015, Facebook, Inc.
9632
* All rights reserved.
9633
*
9634
* This source code is licensed under the BSD-style license found in the
9635
* LICENSE file in the root directory of this source tree. An additional grant
9636
* of patent rights can be found in the PATENTS file in the same directory.
9637
*
9638
* @providesModule ReactDefaultPerfAnalysis
9639
*/
9640
9641
var assign = _dereq_(27);
9642
9643
// Don't try to save users less than 1.2ms (a number I made up)
9644
var DONT_CARE_THRESHOLD = 1.2;
9645
var DOM_OPERATION_TYPES = {
9646
'_mountImageIntoNode': 'set innerHTML',
9647
INSERT_MARKUP: 'set innerHTML',
9648
MOVE_EXISTING: 'move',
9649
REMOVE_NODE: 'remove',
9650
TEXT_CONTENT: 'set textContent',
9651
'updatePropertyByID': 'update attribute',
9652
'deletePropertyByID': 'delete attribute',
9653
'updateStylesByID': 'update styles',
9654
'updateInnerHTMLByID': 'set innerHTML',
9655
'dangerouslyReplaceNodeWithMarkupByID': 'replace'
9656
};
9657
9658
function getTotalTime(measurements) {
9659
// TODO: return number of DOM ops? could be misleading.
9660
// TODO: measure dropped frames after reconcile?
9661
// TODO: log total time of each reconcile and the top-level component
9662
// class that triggered it.
9663
var totalTime = 0;
9664
for (var i = 0; i < measurements.length; i++) {
9665
var measurement = measurements[i];
9666
totalTime += measurement.totalTime;
9667
}
9668
return totalTime;
9669
}
9670
9671
function getDOMSummary(measurements) {
9672
var items = [];
9673
for (var i = 0; i < measurements.length; i++) {
9674
var measurement = measurements[i];
9675
var id;
9676
9677
for (id in measurement.writes) {
9678
measurement.writes[id].forEach(function(write) {
9679
items.push({
9680
id: id,
9681
type: DOM_OPERATION_TYPES[write.type] || write.type,
9682
args: write.args
9683
});
9684
});
9685
}
9686
}
9687
return items;
9688
}
9689
9690
function getExclusiveSummary(measurements) {
9691
var candidates = {};
9692
var displayName;
9693
9694
for (var i = 0; i < measurements.length; i++) {
9695
var measurement = measurements[i];
9696
var allIDs = assign(
9697
{},
9698
measurement.exclusive,
9699
measurement.inclusive
9700
);
9701
9702
for (var id in allIDs) {
9703
displayName = measurement.displayNames[id].current;
9704
9705
candidates[displayName] = candidates[displayName] || {
9706
componentName: displayName,
9707
inclusive: 0,
9708
exclusive: 0,
9709
render: 0,
9710
count: 0
9711
};
9712
if (measurement.render[id]) {
9713
candidates[displayName].render += measurement.render[id];
9714
}
9715
if (measurement.exclusive[id]) {
9716
candidates[displayName].exclusive += measurement.exclusive[id];
9717
}
9718
if (measurement.inclusive[id]) {
9719
candidates[displayName].inclusive += measurement.inclusive[id];
9720
}
9721
if (measurement.counts[id]) {
9722
candidates[displayName].count += measurement.counts[id];
9723
}
9724
}
9725
}
9726
9727
// Now make a sorted array with the results.
9728
var arr = [];
9729
for (displayName in candidates) {
9730
if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
9731
arr.push(candidates[displayName]);
9732
}
9733
}
9734
9735
arr.sort(function(a, b) {
9736
return b.exclusive - a.exclusive;
9737
});
9738
9739
return arr;
9740
}
9741
9742
function getInclusiveSummary(measurements, onlyClean) {
9743
var candidates = {};
9744
var inclusiveKey;
9745
9746
for (var i = 0; i < measurements.length; i++) {
9747
var measurement = measurements[i];
9748
var allIDs = assign(
9749
{},
9750
measurement.exclusive,
9751
measurement.inclusive
9752
);
9753
var cleanComponents;
9754
9755
if (onlyClean) {
9756
cleanComponents = getUnchangedComponents(measurement);
9757
}
9758
9759
for (var id in allIDs) {
9760
if (onlyClean && !cleanComponents[id]) {
9761
continue;
9762
}
9763
9764
var displayName = measurement.displayNames[id];
9765
9766
// Inclusive time is not useful for many components without knowing where
9767
// they are instantiated. So we aggregate inclusive time with both the
9768
// owner and current displayName as the key.
9769
inclusiveKey = displayName.owner + ' > ' + displayName.current;
9770
9771
candidates[inclusiveKey] = candidates[inclusiveKey] || {
9772
componentName: inclusiveKey,
9773
time: 0,
9774
count: 0
9775
};
9776
9777
if (measurement.inclusive[id]) {
9778
candidates[inclusiveKey].time += measurement.inclusive[id];
9779
}
9780
if (measurement.counts[id]) {
9781
candidates[inclusiveKey].count += measurement.counts[id];
9782
}
9783
}
9784
}
9785
9786
// Now make a sorted array with the results.
9787
var arr = [];
9788
for (inclusiveKey in candidates) {
9789
if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
9790
arr.push(candidates[inclusiveKey]);
9791
}
9792
}
9793
9794
arr.sort(function(a, b) {
9795
return b.time - a.time;
9796
});
9797
9798
return arr;
9799
}
9800
9801
function getUnchangedComponents(measurement) {
9802
// For a given reconcile, look at which components did not actually
9803
// render anything to the DOM and return a mapping of their ID to
9804
// the amount of time it took to render the entire subtree.
9805
var cleanComponents = {};
9806
var dirtyLeafIDs = Object.keys(measurement.writes);
9807
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
9808
9809
for (var id in allIDs) {
9810
var isDirty = false;
9811
// For each component that rendered, see if a component that triggered
9812
// a DOM op is in its subtree.
9813
for (var i = 0; i < dirtyLeafIDs.length; i++) {
9814
if (dirtyLeafIDs[i].indexOf(id) === 0) {
9815
isDirty = true;
9816
break;
9817
}
9818
}
9819
if (!isDirty && measurement.counts[id] > 0) {
9820
cleanComponents[id] = true;
9821
}
9822
}
9823
return cleanComponents;
9824
}
9825
9826
var ReactDefaultPerfAnalysis = {
9827
getExclusiveSummary: getExclusiveSummary,
9828
getInclusiveSummary: getInclusiveSummary,
9829
getDOMSummary: getDOMSummary,
9830
getTotalTime: getTotalTime
9831
};
9832
9833
module.exports = ReactDefaultPerfAnalysis;
9834
9835
},{"27":27}],57:[function(_dereq_,module,exports){
9836
/**
9837
* Copyright 2014-2015, Facebook, Inc.
9838
* All rights reserved.
9839
*
9840
* This source code is licensed under the BSD-style license found in the
9841
* LICENSE file in the root directory of this source tree. An additional grant
9842
* of patent rights can be found in the PATENTS file in the same directory.
9843
*
9844
* @providesModule ReactElement
9845
*/
9846
9847
'use strict';
9848
9849
var ReactContext = _dereq_(38);
9850
var ReactCurrentOwner = _dereq_(39);
9851
9852
var assign = _dereq_(27);
9853
var warning = _dereq_(154);
9854
9855
var RESERVED_PROPS = {
9856
key: true,
9857
ref: true
9858
};
9859
9860
/**
9861
* Warn for mutations.
9862
*
9863
* @internal
9864
* @param {object} object
9865
* @param {string} key
9866
*/
9867
function defineWarningProperty(object, key) {
9868
Object.defineProperty(object, key, {
9869
9870
configurable: false,
9871
enumerable: true,
9872
9873
get: function() {
9874
if (!this._store) {
9875
return null;
9876
}
9877
return this._store[key];
9878
},
9879
9880
set: function(value) {
9881
("production" !== "development" ? warning(
9882
false,
9883
'Don\'t set the %s property of the React element. Instead, ' +
9884
'specify the correct value when initially creating the element.',
9885
key
9886
) : null);
9887
this._store[key] = value;
9888
}
9889
9890
});
9891
}
9892
9893
/**
9894
* This is updated to true if the membrane is successfully created.
9895
*/
9896
var useMutationMembrane = false;
9897
9898
/**
9899
* Warn for mutations.
9900
*
9901
* @internal
9902
* @param {object} element
9903
*/
9904
function defineMutationMembrane(prototype) {
9905
try {
9906
var pseudoFrozenProperties = {
9907
props: true
9908
};
9909
for (var key in pseudoFrozenProperties) {
9910
defineWarningProperty(prototype, key);
9911
}
9912
useMutationMembrane = true;
9913
} catch (x) {
9914
// IE will fail on defineProperty
9915
}
9916
}
9917
9918
/**
9919
* Base constructor for all React elements. This is only used to make this
9920
* work with a dynamic instanceof check. Nothing should live on this prototype.
9921
*
9922
* @param {*} type
9923
* @param {string|object} ref
9924
* @param {*} key
9925
* @param {*} props
9926
* @internal
9927
*/
9928
var ReactElement = function(type, key, ref, owner, context, props) {
9929
// Built-in properties that belong on the element
9930
this.type = type;
9931
this.key = key;
9932
this.ref = ref;
9933
9934
// Record the component responsible for creating this element.
9935
this._owner = owner;
9936
9937
// TODO: Deprecate withContext, and then the context becomes accessible
9938
// through the owner.
9939
this._context = context;
9940
9941
if ("production" !== "development") {
9942
// The validation flag and props are currently mutative. We put them on
9943
// an external backing store so that we can freeze the whole object.
9944
// This can be replaced with a WeakMap once they are implemented in
9945
// commonly used development environments.
9946
this._store = {props: props, originalProps: assign({}, props)};
9947
9948
// To make comparing ReactElements easier for testing purposes, we make
9949
// the validation flag non-enumerable (where possible, which should
9950
// include every environment we run tests in), so the test framework
9951
// ignores it.
9952
try {
9953
Object.defineProperty(this._store, 'validated', {
9954
configurable: false,
9955
enumerable: false,
9956
writable: true
9957
});
9958
} catch (x) {
9959
}
9960
this._store.validated = false;
9961
9962
// We're not allowed to set props directly on the object so we early
9963
// return and rely on the prototype membrane to forward to the backing
9964
// store.
9965
if (useMutationMembrane) {
9966
Object.freeze(this);
9967
return;
9968
}
9969
}
9970
9971
this.props = props;
9972
};
9973
9974
// We intentionally don't expose the function on the constructor property.
9975
// ReactElement should be indistinguishable from a plain object.
9976
ReactElement.prototype = {
9977
_isReactElement: true
9978
};
9979
9980
if ("production" !== "development") {
9981
defineMutationMembrane(ReactElement.prototype);
9982
}
9983
9984
ReactElement.createElement = function(type, config, children) {
9985
var propName;
9986
9987
// Reserved names are extracted
9988
var props = {};
9989
9990
var key = null;
9991
var ref = null;
9992
9993
if (config != null) {
9994
ref = config.ref === undefined ? null : config.ref;
9995
key = config.key === undefined ? null : '' + config.key;
9996
// Remaining properties are added to a new props object
9997
for (propName in config) {
9998
if (config.hasOwnProperty(propName) &&
9999
!RESERVED_PROPS.hasOwnProperty(propName)) {
10000
props[propName] = config[propName];
10001
}
10002
}
10003
}
10004
10005
// Children can be more than one argument, and those are transferred onto
10006
// the newly allocated props object.
10007
var childrenLength = arguments.length - 2;
10008
if (childrenLength === 1) {
10009
props.children = children;
10010
} else if (childrenLength > 1) {
10011
var childArray = Array(childrenLength);
10012
for (var i = 0; i < childrenLength; i++) {
10013
childArray[i] = arguments[i + 2];
10014
}
10015
props.children = childArray;
10016
}
10017
10018
// Resolve default props
10019
if (type && type.defaultProps) {
10020
var defaultProps = type.defaultProps;
10021
for (propName in defaultProps) {
10022
if (typeof props[propName] === 'undefined') {
10023
props[propName] = defaultProps[propName];
10024
}
10025
}
10026
}
10027
10028
return new ReactElement(
10029
type,
10030
key,
10031
ref,
10032
ReactCurrentOwner.current,
10033
ReactContext.current,
10034
props
10035
);
10036
};
10037
10038
ReactElement.createFactory = function(type) {
10039
var factory = ReactElement.createElement.bind(null, type);
10040
// Expose the type on the factory and the prototype so that it can be
10041
// easily accessed on elements. E.g. <Foo />.type === Foo.type.
10042
// This should not be named `constructor` since this may not be the function
10043
// that created the element, and it may not even be a constructor.
10044
// Legacy hook TODO: Warn if this is accessed
10045
factory.type = type;
10046
return factory;
10047
};
10048
10049
ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
10050
var newElement = new ReactElement(
10051
oldElement.type,
10052
oldElement.key,
10053
oldElement.ref,
10054
oldElement._owner,
10055
oldElement._context,
10056
newProps
10057
);
10058
10059
if ("production" !== "development") {
10060
// If the key on the original is valid, then the clone is valid
10061
newElement._store.validated = oldElement._store.validated;
10062
}
10063
return newElement;
10064
};
10065
10066
ReactElement.cloneElement = function(element, config, children) {
10067
var propName;
10068
10069
// Original props are copied
10070
var props = assign({}, element.props);
10071
10072
// Reserved names are extracted
10073
var key = element.key;
10074
var ref = element.ref;
10075
10076
// Owner will be preserved, unless ref is overridden
10077
var owner = element._owner;
10078
10079
if (config != null) {
10080
if (config.ref !== undefined) {
10081
// Silently steal the ref from the parent.
10082
ref = config.ref;
10083
owner = ReactCurrentOwner.current;
10084
}
10085
if (config.key !== undefined) {
10086
key = '' + config.key;
10087
}
10088
// Remaining properties override existing props
10089
for (propName in config) {
10090
if (config.hasOwnProperty(propName) &&
10091
!RESERVED_PROPS.hasOwnProperty(propName)) {
10092
props[propName] = config[propName];
10093
}
10094
}
10095
}
10096
10097
// Children can be more than one argument, and those are transferred onto
10098
// the newly allocated props object.
10099
var childrenLength = arguments.length - 2;
10100
if (childrenLength === 1) {
10101
props.children = children;
10102
} else if (childrenLength > 1) {
10103
var childArray = Array(childrenLength);
10104
for (var i = 0; i < childrenLength; i++) {
10105
childArray[i] = arguments[i + 2];
10106
}
10107
props.children = childArray;
10108
}
10109
10110
return new ReactElement(
10111
element.type,
10112
key,
10113
ref,
10114
owner,
10115
element._context,
10116
props
10117
);
10118
};
10119
10120
/**
10121
* @param {?object} object
10122
* @return {boolean} True if `object` is a valid component.
10123
* @final
10124
*/
10125
ReactElement.isValidElement = function(object) {
10126
// ReactTestUtils is often used outside of beforeEach where as React is
10127
// within it. This leads to two different instances of React on the same
10128
// page. To identify a element from a different React instance we use
10129
// a flag instead of an instanceof check.
10130
var isElement = !!(object && object._isReactElement);
10131
// if (isElement && !(object instanceof ReactElement)) {
10132
// This is an indicator that you're using multiple versions of React at the
10133
// same time. This will screw with ownership and stuff. Fix it, please.
10134
// TODO: We could possibly warn here.
10135
// }
10136
return isElement;
10137
};
10138
10139
module.exports = ReactElement;
10140
10141
},{"154":154,"27":27,"38":38,"39":39}],58:[function(_dereq_,module,exports){
10142
/**
10143
* Copyright 2014-2015, Facebook, Inc.
10144
* All rights reserved.
10145
*
10146
* This source code is licensed under the BSD-style license found in the
10147
* LICENSE file in the root directory of this source tree. An additional grant
10148
* of patent rights can be found in the PATENTS file in the same directory.
10149
*
10150
* @providesModule ReactElementValidator
10151
*/
10152
10153
/**
10154
* ReactElementValidator provides a wrapper around a element factory
10155
* which validates the props passed to the element. This is intended to be
10156
* used only in DEV and could be replaced by a static type checker for languages
10157
* that support it.
10158
*/
10159
10160
'use strict';
10161
10162
var ReactElement = _dereq_(57);
10163
var ReactFragment = _dereq_(63);
10164
var ReactPropTypeLocations = _dereq_(77);
10165
var ReactPropTypeLocationNames = _dereq_(76);
10166
var ReactCurrentOwner = _dereq_(39);
10167
var ReactNativeComponent = _dereq_(73);
10168
10169
var getIteratorFn = _dereq_(126);
10170
var invariant = _dereq_(135);
10171
var warning = _dereq_(154);
10172
10173
function getDeclarationErrorAddendum() {
10174
if (ReactCurrentOwner.current) {
10175
var name = ReactCurrentOwner.current.getName();
10176
if (name) {
10177
return ' Check the render method of `' + name + '`.';
10178
}
10179
}
10180
return '';
10181
}
10182
10183
/**
10184
* Warn if there's no key explicitly set on dynamic arrays of children or
10185
* object keys are not valid. This allows us to keep track of children between
10186
* updates.
10187
*/
10188
var ownerHasKeyUseWarning = {};
10189
10190
var loggedTypeFailures = {};
10191
10192
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
10193
10194
/**
10195
* Gets the instance's name for use in warnings.
10196
*
10197
* @internal
10198
* @return {?string} Display name or undefined
10199
*/
10200
function getName(instance) {
10201
var publicInstance = instance && instance.getPublicInstance();
10202
if (!publicInstance) {
10203
return undefined;
10204
}
10205
var constructor = publicInstance.constructor;
10206
if (!constructor) {
10207
return undefined;
10208
}
10209
return constructor.displayName || constructor.name || undefined;
10210
}
10211
10212
/**
10213
* Gets the current owner's displayName for use in warnings.
10214
*
10215
* @internal
10216
* @return {?string} Display name or undefined
10217
*/
10218
function getCurrentOwnerDisplayName() {
10219
var current = ReactCurrentOwner.current;
10220
return (
10221
current && getName(current) || undefined
10222
);
10223
}
10224
10225
/**
10226
* Warn if the element doesn't have an explicit key assigned to it.
10227
* This element is in an array. The array could grow and shrink or be
10228
* reordered. All children that haven't already been validated are required to
10229
* have a "key" property assigned to it.
10230
*
10231
* @internal
10232
* @param {ReactElement} element Element that requires a key.
10233
* @param {*} parentType element's parent's type.
10234
*/
10235
function validateExplicitKey(element, parentType) {
10236
if (element._store.validated || element.key != null) {
10237
return;
10238
}
10239
element._store.validated = true;
10240
10241
warnAndMonitorForKeyUse(
10242
'Each child in an array or iterator should have a unique "key" prop.',
10243
element,
10244
parentType
10245
);
10246
}
10247
10248
/**
10249
* Warn if the key is being defined as an object property but has an incorrect
10250
* value.
10251
*
10252
* @internal
10253
* @param {string} name Property name of the key.
10254
* @param {ReactElement} element Component that requires a key.
10255
* @param {*} parentType element's parent's type.
10256
*/
10257
function validatePropertyKey(name, element, parentType) {
10258
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
10259
return;
10260
}
10261
warnAndMonitorForKeyUse(
10262
'Child objects should have non-numeric keys so ordering is preserved.',
10263
element,
10264
parentType
10265
);
10266
}
10267
10268
/**
10269
* Shared warning and monitoring code for the key warnings.
10270
*
10271
* @internal
10272
* @param {string} message The base warning that gets output.
10273
* @param {ReactElement} element Component that requires a key.
10274
* @param {*} parentType element's parent's type.
10275
*/
10276
function warnAndMonitorForKeyUse(message, element, parentType) {
10277
var ownerName = getCurrentOwnerDisplayName();
10278
var parentName = typeof parentType === 'string' ?
10279
parentType : parentType.displayName || parentType.name;
10280
10281
var useName = ownerName || parentName;
10282
var memoizer = ownerHasKeyUseWarning[message] || (
10283
(ownerHasKeyUseWarning[message] = {})
10284
);
10285
if (memoizer.hasOwnProperty(useName)) {
10286
return;
10287
}
10288
memoizer[useName] = true;
10289
10290
var parentOrOwnerAddendum =
10291
ownerName ? (" Check the render method of " + ownerName + ".") :
10292
parentName ? (" Check the React.render call using <" + parentName + ">.") :
10293
'';
10294
10295
// Usually the current owner is the offender, but if it accepts children as a
10296
// property, it may be the creator of the child that's responsible for
10297
// assigning it a key.
10298
var childOwnerAddendum = '';
10299
if (element &&
10300
element._owner &&
10301
element._owner !== ReactCurrentOwner.current) {
10302
// Name of the component that originally created this child.
10303
var childOwnerName = getName(element._owner);
10304
10305
childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
10306
}
10307
10308
("production" !== "development" ? warning(
10309
false,
10310
message + '%s%s See https://fb.me/react-warning-keys for more information.',
10311
parentOrOwnerAddendum,
10312
childOwnerAddendum
10313
) : null);
10314
}
10315
10316
/**
10317
* Ensure that every element either is passed in a static location, in an
10318
* array with an explicit keys property defined, or in an object literal
10319
* with valid key property.
10320
*
10321
* @internal
10322
* @param {ReactNode} node Statically passed child of any type.
10323
* @param {*} parentType node's parent's type.
10324
*/
10325
function validateChildKeys(node, parentType) {
10326
if (Array.isArray(node)) {
10327
for (var i = 0; i < node.length; i++) {
10328
var child = node[i];
10329
if (ReactElement.isValidElement(child)) {
10330
validateExplicitKey(child, parentType);
10331
}
10332
}
10333
} else if (ReactElement.isValidElement(node)) {
10334
// This element was passed in a valid location.
10335
node._store.validated = true;
10336
} else if (node) {
10337
var iteratorFn = getIteratorFn(node);
10338
// Entry iterators provide implicit keys.
10339
if (iteratorFn) {
10340
if (iteratorFn !== node.entries) {
10341
var iterator = iteratorFn.call(node);
10342
var step;
10343
while (!(step = iterator.next()).done) {
10344
if (ReactElement.isValidElement(step.value)) {
10345
validateExplicitKey(step.value, parentType);
10346
}
10347
}
10348
}
10349
} else if (typeof node === 'object') {
10350
var fragment = ReactFragment.extractIfFragment(node);
10351
for (var key in fragment) {
10352
if (fragment.hasOwnProperty(key)) {
10353
validatePropertyKey(key, fragment[key], parentType);
10354
}
10355
}
10356
}
10357
}
10358
}
10359
10360
/**
10361
* Assert that the props are valid
10362
*
10363
* @param {string} componentName Name of the component for error messages.
10364
* @param {object} propTypes Map of prop name to a ReactPropType
10365
* @param {object} props
10366
* @param {string} location e.g. "prop", "context", "child context"
10367
* @private
10368
*/
10369
function checkPropTypes(componentName, propTypes, props, location) {
10370
for (var propName in propTypes) {
10371
if (propTypes.hasOwnProperty(propName)) {
10372
var error;
10373
// Prop type validation may throw. In case they do, we don't want to
10374
// fail the render phase where it didn't fail before. So we log it.
10375
// After these have been cleaned up, we'll let them throw.
10376
try {
10377
// This is intentionally an invariant that gets caught. It's the same
10378
// behavior as without this statement except with a better message.
10379
("production" !== "development" ? invariant(
10380
typeof propTypes[propName] === 'function',
10381
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
10382
'React.PropTypes.',
10383
componentName || 'React class',
10384
ReactPropTypeLocationNames[location],
10385
propName
10386
) : invariant(typeof propTypes[propName] === 'function'));
10387
error = propTypes[propName](props, propName, componentName, location);
10388
} catch (ex) {
10389
error = ex;
10390
}
10391
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
10392
// Only monitor this failure once because there tends to be a lot of the
10393
// same error.
10394
loggedTypeFailures[error.message] = true;
10395
10396
var addendum = getDeclarationErrorAddendum(this);
10397
("production" !== "development" ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
10398
}
10399
}
10400
}
10401
}
10402
10403
var warnedPropsMutations = {};
10404
10405
/**
10406
* Warn about mutating props when setting `propName` on `element`.
10407
*
10408
* @param {string} propName The string key within props that was set
10409
* @param {ReactElement} element
10410
*/
10411
function warnForPropsMutation(propName, element) {
10412
var type = element.type;
10413
var elementName = typeof type === 'string' ? type : type.displayName;
10414
var ownerName = element._owner ?
10415
element._owner.getPublicInstance().constructor.displayName : null;
10416
10417
var warningKey = propName + '|' + elementName + '|' + ownerName;
10418
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
10419
return;
10420
}
10421
warnedPropsMutations[warningKey] = true;
10422
10423
var elementInfo = '';
10424
if (elementName) {
10425
elementInfo = ' <' + elementName + ' />';
10426
}
10427
var ownerInfo = '';
10428
if (ownerName) {
10429
ownerInfo = ' The element was created by ' + ownerName + '.';
10430
}
10431
10432
("production" !== "development" ? warning(
10433
false,
10434
'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
10435
'correct value when initially creating the element or use ' +
10436
'React.cloneElement to make a new element with updated props.%s',
10437
propName,
10438
elementInfo,
10439
ownerInfo
10440
) : null);
10441
}
10442
10443
// Inline Object.is polyfill
10444
function is(a, b) {
10445
if (a !== a) {
10446
// NaN
10447
return b !== b;
10448
}
10449
if (a === 0 && b === 0) {
10450
// +-0
10451
return 1 / a === 1 / b;
10452
}
10453
return a === b;
10454
}
10455
10456
/**
10457
* Given an element, check if its props have been mutated since element
10458
* creation (or the last call to this function). In particular, check if any
10459
* new props have been added, which we can't directly catch by defining warning
10460
* properties on the props object.
10461
*
10462
* @param {ReactElement} element
10463
*/
10464
function checkAndWarnForMutatedProps(element) {
10465
if (!element._store) {
10466
// Element was created using `new ReactElement` directly or with
10467
// `ReactElement.createElement`; skip mutation checking
10468
return;
10469
}
10470
10471
var originalProps = element._store.originalProps;
10472
var props = element.props;
10473
10474
for (var propName in props) {
10475
if (props.hasOwnProperty(propName)) {
10476
if (!originalProps.hasOwnProperty(propName) ||
10477
!is(originalProps[propName], props[propName])) {
10478
warnForPropsMutation(propName, element);
10479
10480
// Copy over the new value so that the two props objects match again
10481
originalProps[propName] = props[propName];
10482
}
10483
}
10484
}
10485
}
10486
10487
/**
10488
* Given an element, validate that its props follow the propTypes definition,
10489
* provided by the type.
10490
*
10491
* @param {ReactElement} element
10492
*/
10493
function validatePropTypes(element) {
10494
if (element.type == null) {
10495
// This has already warned. Don't throw.
10496
return;
10497
}
10498
// Extract the component class from the element. Converts string types
10499
// to a composite class which may have propTypes.
10500
// TODO: Validating a string's propTypes is not decoupled from the
10501
// rendering target which is problematic.
10502
var componentClass = ReactNativeComponent.getComponentClassForElement(
10503
element
10504
);
10505
var name = componentClass.displayName || componentClass.name;
10506
if (componentClass.propTypes) {
10507
checkPropTypes(
10508
name,
10509
componentClass.propTypes,
10510
element.props,
10511
ReactPropTypeLocations.prop
10512
);
10513
}
10514
if (typeof componentClass.getDefaultProps === 'function') {
10515
("production" !== "development" ? warning(
10516
componentClass.getDefaultProps.isReactClassApproved,
10517
'getDefaultProps is only used on classic React.createClass ' +
10518
'definitions. Use a static property named `defaultProps` instead.'
10519
) : null);
10520
}
10521
}
10522
10523
var ReactElementValidator = {
10524
10525
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
10526
10527
createElement: function(type, props, children) {
10528
// We warn in this case but don't throw. We expect the element creation to
10529
// succeed and there will likely be errors in render.
10530
("production" !== "development" ? warning(
10531
type != null,
10532
'React.createElement: type should not be null or undefined. It should ' +
10533
'be a string (for DOM elements) or a ReactClass (for composite ' +
10534
'components).'
10535
) : null);
10536
10537
var element = ReactElement.createElement.apply(this, arguments);
10538
10539
// The result can be nullish if a mock or a custom function is used.
10540
// TODO: Drop this when these are no longer allowed as the type argument.
10541
if (element == null) {
10542
return element;
10543
}
10544
10545
for (var i = 2; i < arguments.length; i++) {
10546
validateChildKeys(arguments[i], type);
10547
}
10548
10549
validatePropTypes(element);
10550
10551
return element;
10552
},
10553
10554
createFactory: function(type) {
10555
var validatedFactory = ReactElementValidator.createElement.bind(
10556
null,
10557
type
10558
);
10559
// Legacy hook TODO: Warn if this is accessed
10560
validatedFactory.type = type;
10561
10562
if ("production" !== "development") {
10563
try {
10564
Object.defineProperty(
10565
validatedFactory,
10566
'type',
10567
{
10568
enumerable: false,
10569
get: function() {
10570
("production" !== "development" ? warning(
10571
false,
10572
'Factory.type is deprecated. Access the class directly ' +
10573
'before passing it to createFactory.'
10574
) : null);
10575
Object.defineProperty(this, 'type', {
10576
value: type
10577
});
10578
return type;
10579
}
10580
}
10581
);
10582
} catch (x) {
10583
// IE will fail on defineProperty (es5-shim/sham too)
10584
}
10585
}
10586
10587
10588
return validatedFactory;
10589
},
10590
10591
cloneElement: function(element, props, children) {
10592
var newElement = ReactElement.cloneElement.apply(this, arguments);
10593
for (var i = 2; i < arguments.length; i++) {
10594
validateChildKeys(arguments[i], newElement.type);
10595
}
10596
validatePropTypes(newElement);
10597
return newElement;
10598
}
10599
10600
};
10601
10602
module.exports = ReactElementValidator;
10603
10604
},{"126":126,"135":135,"154":154,"39":39,"57":57,"63":63,"73":73,"76":76,"77":77}],59:[function(_dereq_,module,exports){
10605
/**
10606
* Copyright 2014-2015, Facebook, Inc.
10607
* All rights reserved.
10608
*
10609
* This source code is licensed under the BSD-style license found in the
10610
* LICENSE file in the root directory of this source tree. An additional grant
10611
* of patent rights can be found in the PATENTS file in the same directory.
10612
*
10613
* @providesModule ReactEmptyComponent
10614
*/
10615
10616
'use strict';
10617
10618
var ReactElement = _dereq_(57);
10619
var ReactInstanceMap = _dereq_(67);
10620
10621
var invariant = _dereq_(135);
10622
10623
var component;
10624
// This registry keeps track of the React IDs of the components that rendered to
10625
// `null` (in reality a placeholder such as `noscript`)
10626
var nullComponentIDsRegistry = {};
10627
10628
var ReactEmptyComponentInjection = {
10629
injectEmptyComponent: function(emptyComponent) {
10630
component = ReactElement.createFactory(emptyComponent);
10631
}
10632
};
10633
10634
var ReactEmptyComponentType = function() {};
10635
ReactEmptyComponentType.prototype.componentDidMount = function() {
10636
var internalInstance = ReactInstanceMap.get(this);
10637
// TODO: Make sure we run these methods in the correct order, we shouldn't
10638
// need this check. We're going to assume if we're here it means we ran
10639
// componentWillUnmount already so there is no internal instance (it gets
10640
// removed as part of the unmounting process).
10641
if (!internalInstance) {
10642
return;
10643
}
10644
registerNullComponentID(internalInstance._rootNodeID);
10645
};
10646
ReactEmptyComponentType.prototype.componentWillUnmount = function() {
10647
var internalInstance = ReactInstanceMap.get(this);
10648
// TODO: Get rid of this check. See TODO in componentDidMount.
10649
if (!internalInstance) {
10650
return;
10651
}
10652
deregisterNullComponentID(internalInstance._rootNodeID);
10653
};
10654
ReactEmptyComponentType.prototype.render = function() {
10655
("production" !== "development" ? invariant(
10656
component,
10657
'Trying to return null from a render, but no null placeholder component ' +
10658
'was injected.'
10659
) : invariant(component));
10660
return component();
10661
};
10662
10663
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
10664
10665
/**
10666
* Mark the component as having rendered to null.
10667
* @param {string} id Component's `_rootNodeID`.
10668
*/
10669
function registerNullComponentID(id) {
10670
nullComponentIDsRegistry[id] = true;
10671
}
10672
10673
/**
10674
* Unmark the component as having rendered to null: it renders to something now.
10675
* @param {string} id Component's `_rootNodeID`.
10676
*/
10677
function deregisterNullComponentID(id) {
10678
delete nullComponentIDsRegistry[id];
10679
}
10680
10681
/**
10682
* @param {string} id Component's `_rootNodeID`.
10683
* @return {boolean} True if the component is rendered to null.
10684
*/
10685
function isNullComponentID(id) {
10686
return !!nullComponentIDsRegistry[id];
10687
}
10688
10689
var ReactEmptyComponent = {
10690
emptyElement: emptyElement,
10691
injection: ReactEmptyComponentInjection,
10692
isNullComponentID: isNullComponentID
10693
};
10694
10695
module.exports = ReactEmptyComponent;
10696
10697
},{"135":135,"57":57,"67":67}],60:[function(_dereq_,module,exports){
10698
/**
10699
* Copyright 2013-2015, Facebook, Inc.
10700
* All rights reserved.
10701
*
10702
* This source code is licensed under the BSD-style license found in the
10703
* LICENSE file in the root directory of this source tree. An additional grant
10704
* of patent rights can be found in the PATENTS file in the same directory.
10705
*
10706
* @providesModule ReactErrorUtils
10707
* @typechecks
10708
*/
10709
10710
"use strict";
10711
10712
var ReactErrorUtils = {
10713
/**
10714
* Creates a guarded version of a function. This is supposed to make debugging
10715
* of event handlers easier. To aid debugging with the browser's debugger,
10716
* this currently simply returns the original function.
10717
*
10718
* @param {function} func Function to be executed
10719
* @param {string} name The name of the guard
10720
* @return {function}
10721
*/
10722
guard: function(func, name) {
10723
return func;
10724
}
10725
};
10726
10727
module.exports = ReactErrorUtils;
10728
10729
},{}],61:[function(_dereq_,module,exports){
10730
/**
10731
* Copyright 2013-2015, Facebook, Inc.
10732
* All rights reserved.
10733
*
10734
* This source code is licensed under the BSD-style license found in the
10735
* LICENSE file in the root directory of this source tree. An additional grant
10736
* of patent rights can be found in the PATENTS file in the same directory.
10737
*
10738
* @providesModule ReactEventEmitterMixin
10739
*/
10740
10741
'use strict';
10742
10743
var EventPluginHub = _dereq_(17);
10744
10745
function runEventQueueInBatch(events) {
10746
EventPluginHub.enqueueEvents(events);
10747
EventPluginHub.processEventQueue();
10748
}
10749
10750
var ReactEventEmitterMixin = {
10751
10752
/**
10753
* Streams a fired top-level event to `EventPluginHub` where plugins have the
10754
* opportunity to create `ReactEvent`s to be dispatched.
10755
*
10756
* @param {string} topLevelType Record from `EventConstants`.
10757
* @param {object} topLevelTarget The listening component root node.
10758
* @param {string} topLevelTargetID ID of `topLevelTarget`.
10759
* @param {object} nativeEvent Native environment event.
10760
*/
10761
handleTopLevel: function(
10762
topLevelType,
10763
topLevelTarget,
10764
topLevelTargetID,
10765
nativeEvent) {
10766
var events = EventPluginHub.extractEvents(
10767
topLevelType,
10768
topLevelTarget,
10769
topLevelTargetID,
10770
nativeEvent
10771
);
10772
10773
runEventQueueInBatch(events);
10774
}
10775
};
10776
10777
module.exports = ReactEventEmitterMixin;
10778
10779
},{"17":17}],62:[function(_dereq_,module,exports){
10780
/**
10781
* Copyright 2013-2015, Facebook, Inc.
10782
* All rights reserved.
10783
*
10784
* This source code is licensed under the BSD-style license found in the
10785
* LICENSE file in the root directory of this source tree. An additional grant
10786
* of patent rights can be found in the PATENTS file in the same directory.
10787
*
10788
* @providesModule ReactEventListener
10789
* @typechecks static-only
10790
*/
10791
10792
'use strict';
10793
10794
var EventListener = _dereq_(16);
10795
var ExecutionEnvironment = _dereq_(21);
10796
var PooledClass = _dereq_(28);
10797
var ReactInstanceHandles = _dereq_(66);
10798
var ReactMount = _dereq_(70);
10799
var ReactUpdates = _dereq_(87);
10800
10801
var assign = _dereq_(27);
10802
var getEventTarget = _dereq_(125);
10803
var getUnboundedScrollPosition = _dereq_(131);
10804
10805
/**
10806
* Finds the parent React component of `node`.
10807
*
10808
* @param {*} node
10809
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
10810
* is not nested.
10811
*/
10812
function findParent(node) {
10813
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
10814
// traversal, but caching is difficult to do correctly without using a
10815
// mutation observer to listen for all DOM changes.
10816
var nodeID = ReactMount.getID(node);
10817
var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
10818
var container = ReactMount.findReactContainerForID(rootID);
10819
var parent = ReactMount.getFirstReactDOM(container);
10820
return parent;
10821
}
10822
10823
// Used to store ancestor hierarchy in top level callback
10824
function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
10825
this.topLevelType = topLevelType;
10826
this.nativeEvent = nativeEvent;
10827
this.ancestors = [];
10828
}
10829
assign(TopLevelCallbackBookKeeping.prototype, {
10830
destructor: function() {
10831
this.topLevelType = null;
10832
this.nativeEvent = null;
10833
this.ancestors.length = 0;
10834
}
10835
});
10836
PooledClass.addPoolingTo(
10837
TopLevelCallbackBookKeeping,
10838
PooledClass.twoArgumentPooler
10839
);
10840
10841
function handleTopLevelImpl(bookKeeping) {
10842
var topLevelTarget = ReactMount.getFirstReactDOM(
10843
getEventTarget(bookKeeping.nativeEvent)
10844
) || window;
10845
10846
// Loop through the hierarchy, in case there's any nested components.
10847
// It's important that we build the array of ancestors before calling any
10848
// event handlers, because event handlers can modify the DOM, leading to
10849
// inconsistencies with ReactMount's node cache. See #1105.
10850
var ancestor = topLevelTarget;
10851
while (ancestor) {
10852
bookKeeping.ancestors.push(ancestor);
10853
ancestor = findParent(ancestor);
10854
}
10855
10856
for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
10857
topLevelTarget = bookKeeping.ancestors[i];
10858
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
10859
ReactEventListener._handleTopLevel(
10860
bookKeeping.topLevelType,
10861
topLevelTarget,
10862
topLevelTargetID,
10863
bookKeeping.nativeEvent
10864
);
10865
}
10866
}
10867
10868
function scrollValueMonitor(cb) {
10869
var scrollPosition = getUnboundedScrollPosition(window);
10870
cb(scrollPosition);
10871
}
10872
10873
var ReactEventListener = {
10874
_enabled: true,
10875
_handleTopLevel: null,
10876
10877
WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
10878
10879
setHandleTopLevel: function(handleTopLevel) {
10880
ReactEventListener._handleTopLevel = handleTopLevel;
10881
},
10882
10883
setEnabled: function(enabled) {
10884
ReactEventListener._enabled = !!enabled;
10885
},
10886
10887
isEnabled: function() {
10888
return ReactEventListener._enabled;
10889
},
10890
10891
10892
/**
10893
* Traps top-level events by using event bubbling.
10894
*
10895
* @param {string} topLevelType Record from `EventConstants`.
10896
* @param {string} handlerBaseName Event name (e.g. "click").
10897
* @param {object} handle Element on which to attach listener.
10898
* @return {object} An object with a remove function which will forcefully
10899
* remove the listener.
10900
* @internal
10901
*/
10902
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
10903
var element = handle;
10904
if (!element) {
10905
return null;
10906
}
10907
return EventListener.listen(
10908
element,
10909
handlerBaseName,
10910
ReactEventListener.dispatchEvent.bind(null, topLevelType)
10911
);
10912
},
10913
10914
/**
10915
* Traps a top-level event by using event capturing.
10916
*
10917
* @param {string} topLevelType Record from `EventConstants`.
10918
* @param {string} handlerBaseName Event name (e.g. "click").
10919
* @param {object} handle Element on which to attach listener.
10920
* @return {object} An object with a remove function which will forcefully
10921
* remove the listener.
10922
* @internal
10923
*/
10924
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
10925
var element = handle;
10926
if (!element) {
10927
return null;
10928
}
10929
return EventListener.capture(
10930
element,
10931
handlerBaseName,
10932
ReactEventListener.dispatchEvent.bind(null, topLevelType)
10933
);
10934
},
10935
10936
monitorScrollValue: function(refresh) {
10937
var callback = scrollValueMonitor.bind(null, refresh);
10938
EventListener.listen(window, 'scroll', callback);
10939
},
10940
10941
dispatchEvent: function(topLevelType, nativeEvent) {
10942
if (!ReactEventListener._enabled) {
10943
return;
10944
}
10945
10946
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
10947
topLevelType,
10948
nativeEvent
10949
);
10950
try {
10951
// Event queue being processed in the same cycle allows
10952
// `preventDefault`.
10953
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
10954
} finally {
10955
TopLevelCallbackBookKeeping.release(bookKeeping);
10956
}
10957
}
10958
};
10959
10960
module.exports = ReactEventListener;
10961
10962
},{"125":125,"131":131,"16":16,"21":21,"27":27,"28":28,"66":66,"70":70,"87":87}],63:[function(_dereq_,module,exports){
10963
/**
10964
* Copyright 2015, Facebook, Inc.
10965
* All rights reserved.
10966
*
10967
* This source code is licensed under the BSD-style license found in the
10968
* LICENSE file in the root directory of this source tree. An additional grant
10969
* of patent rights can be found in the PATENTS file in the same directory.
10970
*
10971
* @providesModule ReactFragment
10972
*/
10973
10974
'use strict';
10975
10976
var ReactElement = _dereq_(57);
10977
10978
var warning = _dereq_(154);
10979
10980
/**
10981
* We used to allow keyed objects to serve as a collection of ReactElements,
10982
* or nested sets. This allowed us a way to explicitly key a set a fragment of
10983
* components. This is now being replaced with an opaque data structure.
10984
* The upgrade path is to call React.addons.createFragment({ key: value }) to
10985
* create a keyed fragment. The resulting data structure is opaque, for now.
10986
*/
10987
10988
if ("production" !== "development") {
10989
var fragmentKey = '_reactFragment';
10990
var didWarnKey = '_reactDidWarn';
10991
var canWarnForReactFragment = false;
10992
10993
try {
10994
// Feature test. Don't even try to issue this warning if we can't use
10995
// enumerable: false.
10996
10997
var dummy = function() {
10998
return 1;
10999
};
11000
11001
Object.defineProperty(
11002
{},
11003
fragmentKey,
11004
{enumerable: false, value: true}
11005
);
11006
11007
Object.defineProperty(
11008
{},
11009
'key',
11010
{enumerable: true, get: dummy}
11011
);
11012
11013
canWarnForReactFragment = true;
11014
} catch (x) { }
11015
11016
var proxyPropertyAccessWithWarning = function(obj, key) {
11017
Object.defineProperty(obj, key, {
11018
enumerable: true,
11019
get: function() {
11020
("production" !== "development" ? warning(
11021
this[didWarnKey],
11022
'A ReactFragment is an opaque type. Accessing any of its ' +
11023
'properties is deprecated. Pass it to one of the React.Children ' +
11024
'helpers.'
11025
) : null);
11026
this[didWarnKey] = true;
11027
return this[fragmentKey][key];
11028
},
11029
set: function(value) {
11030
("production" !== "development" ? warning(
11031
this[didWarnKey],
11032
'A ReactFragment is an immutable opaque type. Mutating its ' +
11033
'properties is deprecated.'
11034
) : null);
11035
this[didWarnKey] = true;
11036
this[fragmentKey][key] = value;
11037
}
11038
});
11039
};
11040
11041
var issuedWarnings = {};
11042
11043
var didWarnForFragment = function(fragment) {
11044
// We use the keys and the type of the value as a heuristic to dedupe the
11045
// warning to avoid spamming too much.
11046
var fragmentCacheKey = '';
11047
for (var key in fragment) {
11048
fragmentCacheKey += key + ':' + (typeof fragment[key]) + ',';
11049
}
11050
var alreadyWarnedOnce = !!issuedWarnings[fragmentCacheKey];
11051
issuedWarnings[fragmentCacheKey] = true;
11052
return alreadyWarnedOnce;
11053
};
11054
}
11055
11056
var ReactFragment = {
11057
// Wrap a keyed object in an opaque proxy that warns you if you access any
11058
// of its properties.
11059
create: function(object) {
11060
if ("production" !== "development") {
11061
if (typeof object !== 'object' || !object || Array.isArray(object)) {
11062
("production" !== "development" ? warning(
11063
false,
11064
'React.addons.createFragment only accepts a single object.',
11065
object
11066
) : null);
11067
return object;
11068
}
11069
if (ReactElement.isValidElement(object)) {
11070
("production" !== "development" ? warning(
11071
false,
11072
'React.addons.createFragment does not accept a ReactElement ' +
11073
'without a wrapper object.'
11074
) : null);
11075
return object;
11076
}
11077
if (canWarnForReactFragment) {
11078
var proxy = {};
11079
Object.defineProperty(proxy, fragmentKey, {
11080
enumerable: false,
11081
value: object
11082
});
11083
Object.defineProperty(proxy, didWarnKey, {
11084
writable: true,
11085
enumerable: false,
11086
value: false
11087
});
11088
for (var key in object) {
11089
proxyPropertyAccessWithWarning(proxy, key);
11090
}
11091
Object.preventExtensions(proxy);
11092
return proxy;
11093
}
11094
}
11095
return object;
11096
},
11097
// Extract the original keyed object from the fragment opaque type. Warn if
11098
// a plain object is passed here.
11099
extract: function(fragment) {
11100
if ("production" !== "development") {
11101
if (canWarnForReactFragment) {
11102
if (!fragment[fragmentKey]) {
11103
("production" !== "development" ? warning(
11104
didWarnForFragment(fragment),
11105
'Any use of a keyed object should be wrapped in ' +
11106
'React.addons.createFragment(object) before being passed as a ' +
11107
'child.'
11108
) : null);
11109
return fragment;
11110
}
11111
return fragment[fragmentKey];
11112
}
11113
}
11114
return fragment;
11115
},
11116
// Check if this is a fragment and if so, extract the keyed object. If it
11117
// is a fragment-like object, warn that it should be wrapped. Ignore if we
11118
// can't determine what kind of object this is.
11119
extractIfFragment: function(fragment) {
11120
if ("production" !== "development") {
11121
if (canWarnForReactFragment) {
11122
// If it is the opaque type, return the keyed object.
11123
if (fragment[fragmentKey]) {
11124
return fragment[fragmentKey];
11125
}
11126
// Otherwise, check each property if it has an element, if it does
11127
// it is probably meant as a fragment, so we can warn early. Defer,
11128
// the warning to extract.
11129
for (var key in fragment) {
11130
if (fragment.hasOwnProperty(key) &&
11131
ReactElement.isValidElement(fragment[key])) {
11132
// This looks like a fragment object, we should provide an
11133
// early warning.
11134
return ReactFragment.extract(fragment);
11135
}
11136
}
11137
}
11138
}
11139
return fragment;
11140
}
11141
};
11142
11143
module.exports = ReactFragment;
11144
11145
},{"154":154,"57":57}],64:[function(_dereq_,module,exports){
11146
/**
11147
* Copyright 2013-2015, Facebook, Inc.
11148
* All rights reserved.
11149
*
11150
* This source code is licensed under the BSD-style license found in the
11151
* LICENSE file in the root directory of this source tree. An additional grant
11152
* of patent rights can be found in the PATENTS file in the same directory.
11153
*
11154
* @providesModule ReactInjection
11155
*/
11156
11157
'use strict';
11158
11159
var DOMProperty = _dereq_(10);
11160
var EventPluginHub = _dereq_(17);
11161
var ReactComponentEnvironment = _dereq_(36);
11162
var ReactClass = _dereq_(33);
11163
var ReactEmptyComponent = _dereq_(59);
11164
var ReactBrowserEventEmitter = _dereq_(30);
11165
var ReactNativeComponent = _dereq_(73);
11166
var ReactDOMComponent = _dereq_(42);
11167
var ReactPerf = _dereq_(75);
11168
var ReactRootIndex = _dereq_(83);
11169
var ReactUpdates = _dereq_(87);
11170
11171
var ReactInjection = {
11172
Component: ReactComponentEnvironment.injection,
11173
Class: ReactClass.injection,
11174
DOMComponent: ReactDOMComponent.injection,
11175
DOMProperty: DOMProperty.injection,
11176
EmptyComponent: ReactEmptyComponent.injection,
11177
EventPluginHub: EventPluginHub.injection,
11178
EventEmitter: ReactBrowserEventEmitter.injection,
11179
NativeComponent: ReactNativeComponent.injection,
11180
Perf: ReactPerf.injection,
11181
RootIndex: ReactRootIndex.injection,
11182
Updates: ReactUpdates.injection
11183
};
11184
11185
module.exports = ReactInjection;
11186
11187
},{"10":10,"17":17,"30":30,"33":33,"36":36,"42":42,"59":59,"73":73,"75":75,"83":83,"87":87}],65:[function(_dereq_,module,exports){
11188
/**
11189
* Copyright 2013-2015, Facebook, Inc.
11190
* All rights reserved.
11191
*
11192
* This source code is licensed under the BSD-style license found in the
11193
* LICENSE file in the root directory of this source tree. An additional grant
11194
* of patent rights can be found in the PATENTS file in the same directory.
11195
*
11196
* @providesModule ReactInputSelection
11197
*/
11198
11199
'use strict';
11200
11201
var ReactDOMSelection = _dereq_(50);
11202
11203
var containsNode = _dereq_(109);
11204
var focusNode = _dereq_(119);
11205
var getActiveElement = _dereq_(121);
11206
11207
function isInDocument(node) {
11208
return containsNode(document.documentElement, node);
11209
}
11210
11211
/**
11212
* @ReactInputSelection: React input selection module. Based on Selection.js,
11213
* but modified to be suitable for react and has a couple of bug fixes (doesn't
11214
* assume buttons have range selections allowed).
11215
* Input selection module for React.
11216
*/
11217
var ReactInputSelection = {
11218
11219
hasSelectionCapabilities: function(elem) {
11220
return elem && (
11221
((elem.nodeName === 'INPUT' && elem.type === 'text') ||
11222
elem.nodeName === 'TEXTAREA' || elem.contentEditable === 'true')
11223
);
11224
},
11225
11226
getSelectionInformation: function() {
11227
var focusedElem = getActiveElement();
11228
return {
11229
focusedElem: focusedElem,
11230
selectionRange:
11231
ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
11232
ReactInputSelection.getSelection(focusedElem) :
11233
null
11234
};
11235
},
11236
11237
/**
11238
* @restoreSelection: If any selection information was potentially lost,
11239
* restore it. This is useful when performing operations that could remove dom
11240
* nodes and place them back in, resulting in focus being lost.
11241
*/
11242
restoreSelection: function(priorSelectionInformation) {
11243
var curFocusedElem = getActiveElement();
11244
var priorFocusedElem = priorSelectionInformation.focusedElem;
11245
var priorSelectionRange = priorSelectionInformation.selectionRange;
11246
if (curFocusedElem !== priorFocusedElem &&
11247
isInDocument(priorFocusedElem)) {
11248
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
11249
ReactInputSelection.setSelection(
11250
priorFocusedElem,
11251
priorSelectionRange
11252
);
11253
}
11254
focusNode(priorFocusedElem);
11255
}
11256
},
11257
11258
/**
11259
* @getSelection: Gets the selection bounds of a focused textarea, input or
11260
* contentEditable node.
11261
* -@input: Look up selection bounds of this input
11262
* -@return {start: selectionStart, end: selectionEnd}
11263
*/
11264
getSelection: function(input) {
11265
var selection;
11266
11267
if ('selectionStart' in input) {
11268
// Modern browser with input or textarea.
11269
selection = {
11270
start: input.selectionStart,
11271
end: input.selectionEnd
11272
};
11273
} else if (document.selection && input.nodeName === 'INPUT') {
11274
// IE8 input.
11275
var range = document.selection.createRange();
11276
// There can only be one selection per document in IE, so it must
11277
// be in our element.
11278
if (range.parentElement() === input) {
11279
selection = {
11280
start: -range.moveStart('character', -input.value.length),
11281
end: -range.moveEnd('character', -input.value.length)
11282
};
11283
}
11284
} else {
11285
// Content editable or old IE textarea.
11286
selection = ReactDOMSelection.getOffsets(input);
11287
}
11288
11289
return selection || {start: 0, end: 0};
11290
},
11291
11292
/**
11293
* @setSelection: Sets the selection bounds of a textarea or input and focuses
11294
* the input.
11295
* -@input Set selection bounds of this input or textarea
11296
* -@offsets Object of same form that is returned from get*
11297
*/
11298
setSelection: function(input, offsets) {
11299
var start = offsets.start;
11300
var end = offsets.end;
11301
if (typeof end === 'undefined') {
11302
end = start;
11303
}
11304
11305
if ('selectionStart' in input) {
11306
input.selectionStart = start;
11307
input.selectionEnd = Math.min(end, input.value.length);
11308
} else if (document.selection && input.nodeName === 'INPUT') {
11309
var range = input.createTextRange();
11310
range.collapse(true);
11311
range.moveStart('character', start);
11312
range.moveEnd('character', end - start);
11313
range.select();
11314
} else {
11315
ReactDOMSelection.setOffsets(input, offsets);
11316
}
11317
}
11318
};
11319
11320
module.exports = ReactInputSelection;
11321
11322
},{"109":109,"119":119,"121":121,"50":50}],66:[function(_dereq_,module,exports){
11323
/**
11324
* Copyright 2013-2015, Facebook, Inc.
11325
* All rights reserved.
11326
*
11327
* This source code is licensed under the BSD-style license found in the
11328
* LICENSE file in the root directory of this source tree. An additional grant
11329
* of patent rights can be found in the PATENTS file in the same directory.
11330
*
11331
* @providesModule ReactInstanceHandles
11332
* @typechecks static-only
11333
*/
11334
11335
'use strict';
11336
11337
var ReactRootIndex = _dereq_(83);
11338
11339
var invariant = _dereq_(135);
11340
11341
var SEPARATOR = '.';
11342
var SEPARATOR_LENGTH = SEPARATOR.length;
11343
11344
/**
11345
* Maximum depth of traversals before we consider the possibility of a bad ID.
11346
*/
11347
var MAX_TREE_DEPTH = 100;
11348
11349
/**
11350
* Creates a DOM ID prefix to use when mounting React components.
11351
*
11352
* @param {number} index A unique integer
11353
* @return {string} React root ID.
11354
* @internal
11355
*/
11356
function getReactRootIDString(index) {
11357
return SEPARATOR + index.toString(36);
11358
}
11359
11360
/**
11361
* Checks if a character in the supplied ID is a separator or the end.
11362
*
11363
* @param {string} id A React DOM ID.
11364
* @param {number} index Index of the character to check.
11365
* @return {boolean} True if the character is a separator or end of the ID.
11366
* @private
11367
*/
11368
function isBoundary(id, index) {
11369
return id.charAt(index) === SEPARATOR || index === id.length;
11370
}
11371
11372
/**
11373
* Checks if the supplied string is a valid React DOM ID.
11374
*
11375
* @param {string} id A React DOM ID, maybe.
11376
* @return {boolean} True if the string is a valid React DOM ID.
11377
* @private
11378
*/
11379
function isValidID(id) {
11380
return id === '' || (
11381
id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
11382
);
11383
}
11384
11385
/**
11386
* Checks if the first ID is an ancestor of or equal to the second ID.
11387
*
11388
* @param {string} ancestorID
11389
* @param {string} descendantID
11390
* @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
11391
* @internal
11392
*/
11393
function isAncestorIDOf(ancestorID, descendantID) {
11394
return (
11395
descendantID.indexOf(ancestorID) === 0 &&
11396
isBoundary(descendantID, ancestorID.length)
11397
);
11398
}
11399
11400
/**
11401
* Gets the parent ID of the supplied React DOM ID, `id`.
11402
*
11403
* @param {string} id ID of a component.
11404
* @return {string} ID of the parent, or an empty string.
11405
* @private
11406
*/
11407
function getParentID(id) {
11408
return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
11409
}
11410
11411
/**
11412
* Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
11413
* supplied `destinationID`. If they are equal, the ID is returned.
11414
*
11415
* @param {string} ancestorID ID of an ancestor node of `destinationID`.
11416
* @param {string} destinationID ID of the destination node.
11417
* @return {string} Next ID on the path from `ancestorID` to `destinationID`.
11418
* @private
11419
*/
11420
function getNextDescendantID(ancestorID, destinationID) {
11421
("production" !== "development" ? invariant(
11422
isValidID(ancestorID) && isValidID(destinationID),
11423
'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
11424
ancestorID,
11425
destinationID
11426
) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
11427
("production" !== "development" ? invariant(
11428
isAncestorIDOf(ancestorID, destinationID),
11429
'getNextDescendantID(...): React has made an invalid assumption about ' +
11430
'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
11431
ancestorID,
11432
destinationID
11433
) : invariant(isAncestorIDOf(ancestorID, destinationID)));
11434
if (ancestorID === destinationID) {
11435
return ancestorID;
11436
}
11437
// Skip over the ancestor and the immediate separator. Traverse until we hit
11438
// another separator or we reach the end of `destinationID`.
11439
var start = ancestorID.length + SEPARATOR_LENGTH;
11440
var i;
11441
for (i = start; i < destinationID.length; i++) {
11442
if (isBoundary(destinationID, i)) {
11443
break;
11444
}
11445
}
11446
return destinationID.substr(0, i);
11447
}
11448
11449
/**
11450
* Gets the nearest common ancestor ID of two IDs.
11451
*
11452
* Using this ID scheme, the nearest common ancestor ID is the longest common
11453
* prefix of the two IDs that immediately preceded a "marker" in both strings.
11454
*
11455
* @param {string} oneID
11456
* @param {string} twoID
11457
* @return {string} Nearest common ancestor ID, or the empty string if none.
11458
* @private
11459
*/
11460
function getFirstCommonAncestorID(oneID, twoID) {
11461
var minLength = Math.min(oneID.length, twoID.length);
11462
if (minLength === 0) {
11463
return '';
11464
}
11465
var lastCommonMarkerIndex = 0;
11466
// Use `<=` to traverse until the "EOL" of the shorter string.
11467
for (var i = 0; i <= minLength; i++) {
11468
if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
11469
lastCommonMarkerIndex = i;
11470
} else if (oneID.charAt(i) !== twoID.charAt(i)) {
11471
break;
11472
}
11473
}
11474
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
11475
("production" !== "development" ? invariant(
11476
isValidID(longestCommonID),
11477
'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
11478
oneID,
11479
twoID,
11480
longestCommonID
11481
) : invariant(isValidID(longestCommonID)));
11482
return longestCommonID;
11483
}
11484
11485
/**
11486
* Traverses the parent path between two IDs (either up or down). The IDs must
11487
* not be the same, and there must exist a parent path between them. If the
11488
* callback returns `false`, traversal is stopped.
11489
*
11490
* @param {?string} start ID at which to start traversal.
11491
* @param {?string} stop ID at which to end traversal.
11492
* @param {function} cb Callback to invoke each ID with.
11493
* @param {?boolean} skipFirst Whether or not to skip the first node.
11494
* @param {?boolean} skipLast Whether or not to skip the last node.
11495
* @private
11496
*/
11497
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
11498
start = start || '';
11499
stop = stop || '';
11500
("production" !== "development" ? invariant(
11501
start !== stop,
11502
'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
11503
start
11504
) : invariant(start !== stop));
11505
var traverseUp = isAncestorIDOf(stop, start);
11506
("production" !== "development" ? invariant(
11507
traverseUp || isAncestorIDOf(start, stop),
11508
'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
11509
'not have a parent path.',
11510
start,
11511
stop
11512
) : invariant(traverseUp || isAncestorIDOf(start, stop)));
11513
// Traverse from `start` to `stop` one depth at a time.
11514
var depth = 0;
11515
var traverse = traverseUp ? getParentID : getNextDescendantID;
11516
for (var id = start; /* until break */; id = traverse(id, stop)) {
11517
var ret;
11518
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
11519
ret = cb(id, traverseUp, arg);
11520
}
11521
if (ret === false || id === stop) {
11522
// Only break //after// visiting `stop`.
11523
break;
11524
}
11525
("production" !== "development" ? invariant(
11526
depth++ < MAX_TREE_DEPTH,
11527
'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
11528
'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
11529
start, stop
11530
) : invariant(depth++ < MAX_TREE_DEPTH));
11531
}
11532
}
11533
11534
/**
11535
* Manages the IDs assigned to DOM representations of React components. This
11536
* uses a specific scheme in order to traverse the DOM efficiently (e.g. in
11537
* order to simulate events).
11538
*
11539
* @internal
11540
*/
11541
var ReactInstanceHandles = {
11542
11543
/**
11544
* Constructs a React root ID
11545
* @return {string} A React root ID.
11546
*/
11547
createReactRootID: function() {
11548
return getReactRootIDString(ReactRootIndex.createReactRootIndex());
11549
},
11550
11551
/**
11552
* Constructs a React ID by joining a root ID with a name.
11553
*
11554
* @param {string} rootID Root ID of a parent component.
11555
* @param {string} name A component's name (as flattened children).
11556
* @return {string} A React ID.
11557
* @internal
11558
*/
11559
createReactID: function(rootID, name) {
11560
return rootID + name;
11561
},
11562
11563
/**
11564
* Gets the DOM ID of the React component that is the root of the tree that
11565
* contains the React component with the supplied DOM ID.
11566
*
11567
* @param {string} id DOM ID of a React component.
11568
* @return {?string} DOM ID of the React component that is the root.
11569
* @internal
11570
*/
11571
getReactRootIDFromNodeID: function(id) {
11572
if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
11573
var index = id.indexOf(SEPARATOR, 1);
11574
return index > -1 ? id.substr(0, index) : id;
11575
}
11576
return null;
11577
},
11578
11579
/**
11580
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
11581
* should would receive a `mouseEnter` or `mouseLeave` event.
11582
*
11583
* NOTE: Does not invoke the callback on the nearest common ancestor because
11584
* nothing "entered" or "left" that element.
11585
*
11586
* @param {string} leaveID ID being left.
11587
* @param {string} enterID ID being entered.
11588
* @param {function} cb Callback to invoke on each entered/left ID.
11589
* @param {*} upArg Argument to invoke the callback with on left IDs.
11590
* @param {*} downArg Argument to invoke the callback with on entered IDs.
11591
* @internal
11592
*/
11593
traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
11594
var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
11595
if (ancestorID !== leaveID) {
11596
traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
11597
}
11598
if (ancestorID !== enterID) {
11599
traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
11600
}
11601
},
11602
11603
/**
11604
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
11605
*
11606
* NOTE: This traversal happens on IDs without touching the DOM.
11607
*
11608
* @param {string} targetID ID of the target node.
11609
* @param {function} cb Callback to invoke.
11610
* @param {*} arg Argument to invoke the callback with.
11611
* @internal
11612
*/
11613
traverseTwoPhase: function(targetID, cb, arg) {
11614
if (targetID) {
11615
traverseParentPath('', targetID, cb, arg, true, false);
11616
traverseParentPath(targetID, '', cb, arg, false, true);
11617
}
11618
},
11619
11620
/**
11621
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
11622
* example, passing `.0.$row-0.1` would result in `cb` getting called
11623
* with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
11624
*
11625
* NOTE: This traversal happens on IDs without touching the DOM.
11626
*
11627
* @param {string} targetID ID of the target node.
11628
* @param {function} cb Callback to invoke.
11629
* @param {*} arg Argument to invoke the callback with.
11630
* @internal
11631
*/
11632
traverseAncestors: function(targetID, cb, arg) {
11633
traverseParentPath('', targetID, cb, arg, true, false);
11634
},
11635
11636
/**
11637
* Exposed for unit testing.
11638
* @private
11639
*/
11640
_getFirstCommonAncestorID: getFirstCommonAncestorID,
11641
11642
/**
11643
* Exposed for unit testing.
11644
* @private
11645
*/
11646
_getNextDescendantID: getNextDescendantID,
11647
11648
isAncestorIDOf: isAncestorIDOf,
11649
11650
SEPARATOR: SEPARATOR
11651
11652
};
11653
11654
module.exports = ReactInstanceHandles;
11655
11656
},{"135":135,"83":83}],67:[function(_dereq_,module,exports){
11657
/**
11658
* Copyright 2013-2015, Facebook, Inc.
11659
* All rights reserved.
11660
*
11661
* This source code is licensed under the BSD-style license found in the
11662
* LICENSE file in the root directory of this source tree. An additional grant
11663
* of patent rights can be found in the PATENTS file in the same directory.
11664
*
11665
* @providesModule ReactInstanceMap
11666
*/
11667
11668
'use strict';
11669
11670
/**
11671
* `ReactInstanceMap` maintains a mapping from a public facing stateful
11672
* instance (key) and the internal representation (value). This allows public
11673
* methods to accept the user facing instance as an argument and map them back
11674
* to internal methods.
11675
*/
11676
11677
// TODO: Replace this with ES6: var ReactInstanceMap = new Map();
11678
var ReactInstanceMap = {
11679
11680
/**
11681
* This API should be called `delete` but we'd have to make sure to always
11682
* transform these to strings for IE support. When this transform is fully
11683
* supported we can rename it.
11684
*/
11685
remove: function(key) {
11686
key._reactInternalInstance = undefined;
11687
},
11688
11689
get: function(key) {
11690
return key._reactInternalInstance;
11691
},
11692
11693
has: function(key) {
11694
return key._reactInternalInstance !== undefined;
11695
},
11696
11697
set: function(key, value) {
11698
key._reactInternalInstance = value;
11699
}
11700
11701
};
11702
11703
module.exports = ReactInstanceMap;
11704
11705
},{}],68:[function(_dereq_,module,exports){
11706
/**
11707
* Copyright 2015, Facebook, Inc.
11708
* All rights reserved.
11709
*
11710
* This source code is licensed under the BSD-style license found in the
11711
* LICENSE file in the root directory of this source tree. An additional grant
11712
* of patent rights can be found in the PATENTS file in the same directory.
11713
*
11714
* @providesModule ReactLifeCycle
11715
*/
11716
11717
'use strict';
11718
11719
/**
11720
* This module manages the bookkeeping when a component is in the process
11721
* of being mounted or being unmounted. This is used as a way to enforce
11722
* invariants (or warnings) when it is not recommended to call
11723
* setState/forceUpdate.
11724
*
11725
* currentlyMountingInstance: During the construction phase, it is not possible
11726
* to trigger an update since the instance is not fully mounted yet. However, we
11727
* currently allow this as a convenience for mutating the initial state.
11728
*
11729
* currentlyUnmountingInstance: During the unmounting phase, the instance is
11730
* still mounted and can therefore schedule an update. However, this is not
11731
* recommended and probably an error since it's about to be unmounted.
11732
* Therefore we still want to trigger in an error for that case.
11733
*/
11734
11735
var ReactLifeCycle = {
11736
currentlyMountingInstance: null,
11737
currentlyUnmountingInstance: null
11738
};
11739
11740
module.exports = ReactLifeCycle;
11741
11742
},{}],69:[function(_dereq_,module,exports){
11743
/**
11744
* Copyright 2013-2015, Facebook, Inc.
11745
* All rights reserved.
11746
*
11747
* This source code is licensed under the BSD-style license found in the
11748
* LICENSE file in the root directory of this source tree. An additional grant
11749
* of patent rights can be found in the PATENTS file in the same directory.
11750
*
11751
* @providesModule ReactMarkupChecksum
11752
*/
11753
11754
'use strict';
11755
11756
var adler32 = _dereq_(106);
11757
11758
var ReactMarkupChecksum = {
11759
CHECKSUM_ATTR_NAME: 'data-react-checksum',
11760
11761
/**
11762
* @param {string} markup Markup string
11763
* @return {string} Markup string with checksum attribute attached
11764
*/
11765
addChecksumToMarkup: function(markup) {
11766
var checksum = adler32(markup);
11767
return markup.replace(
11768
'>',
11769
' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
11770
);
11771
},
11772
11773
/**
11774
* @param {string} markup to use
11775
* @param {DOMElement} element root React element
11776
* @returns {boolean} whether or not the markup is the same
11777
*/
11778
canReuseMarkup: function(markup, element) {
11779
var existingChecksum = element.getAttribute(
11780
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
11781
);
11782
existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
11783
var markupChecksum = adler32(markup);
11784
return markupChecksum === existingChecksum;
11785
}
11786
};
11787
11788
module.exports = ReactMarkupChecksum;
11789
11790
},{"106":106}],70:[function(_dereq_,module,exports){
11791
/**
11792
* Copyright 2013-2015, Facebook, Inc.
11793
* All rights reserved.
11794
*
11795
* This source code is licensed under the BSD-style license found in the
11796
* LICENSE file in the root directory of this source tree. An additional grant
11797
* of patent rights can be found in the PATENTS file in the same directory.
11798
*
11799
* @providesModule ReactMount
11800
*/
11801
11802
'use strict';
11803
11804
var DOMProperty = _dereq_(10);
11805
var ReactBrowserEventEmitter = _dereq_(30);
11806
var ReactCurrentOwner = _dereq_(39);
11807
var ReactElement = _dereq_(57);
11808
var ReactElementValidator = _dereq_(58);
11809
var ReactEmptyComponent = _dereq_(59);
11810
var ReactInstanceHandles = _dereq_(66);
11811
var ReactInstanceMap = _dereq_(67);
11812
var ReactMarkupChecksum = _dereq_(69);
11813
var ReactPerf = _dereq_(75);
11814
var ReactReconciler = _dereq_(81);
11815
var ReactUpdateQueue = _dereq_(86);
11816
var ReactUpdates = _dereq_(87);
11817
11818
var emptyObject = _dereq_(115);
11819
var containsNode = _dereq_(109);
11820
var getReactRootElementInContainer = _dereq_(129);
11821
var instantiateReactComponent = _dereq_(134);
11822
var invariant = _dereq_(135);
11823
var setInnerHTML = _dereq_(148);
11824
var shouldUpdateReactComponent = _dereq_(151);
11825
var warning = _dereq_(154);
11826
11827
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
11828
11829
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
11830
var nodeCache = {};
11831
11832
var ELEMENT_NODE_TYPE = 1;
11833
var DOC_NODE_TYPE = 9;
11834
11835
/** Mapping from reactRootID to React component instance. */
11836
var instancesByReactRootID = {};
11837
11838
/** Mapping from reactRootID to `container` nodes. */
11839
var containersByReactRootID = {};
11840
11841
if ("production" !== "development") {
11842
/** __DEV__-only mapping from reactRootID to root elements. */
11843
var rootElementsByReactRootID = {};
11844
}
11845
11846
// Used to store breadth-first search state in findComponentRoot.
11847
var findComponentRootReusableArray = [];
11848
11849
/**
11850
* Finds the index of the first character
11851
* that's not common between the two given strings.
11852
*
11853
* @return {number} the index of the character where the strings diverge
11854
*/
11855
function firstDifferenceIndex(string1, string2) {
11856
var minLen = Math.min(string1.length, string2.length);
11857
for (var i = 0; i < minLen; i++) {
11858
if (string1.charAt(i) !== string2.charAt(i)) {
11859
return i;
11860
}
11861
}
11862
return string1.length === string2.length ? -1 : minLen;
11863
}
11864
11865
/**
11866
* @param {DOMElement} container DOM element that may contain a React component.
11867
* @return {?string} A "reactRoot" ID, if a React component is rendered.
11868
*/
11869
function getReactRootID(container) {
11870
var rootElement = getReactRootElementInContainer(container);
11871
return rootElement && ReactMount.getID(rootElement);
11872
}
11873
11874
/**
11875
* Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
11876
* element can return its control whose name or ID equals ATTR_NAME. All
11877
* DOM nodes support `getAttributeNode` but this can also get called on
11878
* other objects so just return '' if we're given something other than a
11879
* DOM node (such as window).
11880
*
11881
* @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
11882
* @return {string} ID of the supplied `domNode`.
11883
*/
11884
function getID(node) {
11885
var id = internalGetID(node);
11886
if (id) {
11887
if (nodeCache.hasOwnProperty(id)) {
11888
var cached = nodeCache[id];
11889
if (cached !== node) {
11890
("production" !== "development" ? invariant(
11891
!isValid(cached, id),
11892
'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
11893
ATTR_NAME, id
11894
) : invariant(!isValid(cached, id)));
11895
11896
nodeCache[id] = node;
11897
}
11898
} else {
11899
nodeCache[id] = node;
11900
}
11901
}
11902
11903
return id;
11904
}
11905
11906
function internalGetID(node) {
11907
// If node is something like a window, document, or text node, none of
11908
// which support attributes or a .getAttribute method, gracefully return
11909
// the empty string, as if the attribute were missing.
11910
return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
11911
}
11912
11913
/**
11914
* Sets the React-specific ID of the given node.
11915
*
11916
* @param {DOMElement} node The DOM node whose ID will be set.
11917
* @param {string} id The value of the ID attribute.
11918
*/
11919
function setID(node, id) {
11920
var oldID = internalGetID(node);
11921
if (oldID !== id) {
11922
delete nodeCache[oldID];
11923
}
11924
node.setAttribute(ATTR_NAME, id);
11925
nodeCache[id] = node;
11926
}
11927
11928
/**
11929
* Finds the node with the supplied React-generated DOM ID.
11930
*
11931
* @param {string} id A React-generated DOM ID.
11932
* @return {DOMElement} DOM node with the suppled `id`.
11933
* @internal
11934
*/
11935
function getNode(id) {
11936
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
11937
nodeCache[id] = ReactMount.findReactNodeByID(id);
11938
}
11939
return nodeCache[id];
11940
}
11941
11942
/**
11943
* Finds the node with the supplied public React instance.
11944
*
11945
* @param {*} instance A public React instance.
11946
* @return {?DOMElement} DOM node with the suppled `id`.
11947
* @internal
11948
*/
11949
function getNodeFromInstance(instance) {
11950
var id = ReactInstanceMap.get(instance)._rootNodeID;
11951
if (ReactEmptyComponent.isNullComponentID(id)) {
11952
return null;
11953
}
11954
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
11955
nodeCache[id] = ReactMount.findReactNodeByID(id);
11956
}
11957
return nodeCache[id];
11958
}
11959
11960
/**
11961
* A node is "valid" if it is contained by a currently mounted container.
11962
*
11963
* This means that the node does not have to be contained by a document in
11964
* order to be considered valid.
11965
*
11966
* @param {?DOMElement} node The candidate DOM node.
11967
* @param {string} id The expected ID of the node.
11968
* @return {boolean} Whether the node is contained by a mounted container.
11969
*/
11970
function isValid(node, id) {
11971
if (node) {
11972
("production" !== "development" ? invariant(
11973
internalGetID(node) === id,
11974
'ReactMount: Unexpected modification of `%s`',
11975
ATTR_NAME
11976
) : invariant(internalGetID(node) === id));
11977
11978
var container = ReactMount.findReactContainerForID(id);
11979
if (container && containsNode(container, node)) {
11980
return true;
11981
}
11982
}
11983
11984
return false;
11985
}
11986
11987
/**
11988
* Causes the cache to forget about one React-specific ID.
11989
*
11990
* @param {string} id The ID to forget.
11991
*/
11992
function purgeID(id) {
11993
delete nodeCache[id];
11994
}
11995
11996
var deepestNodeSoFar = null;
11997
function findDeepestCachedAncestorImpl(ancestorID) {
11998
var ancestor = nodeCache[ancestorID];
11999
if (ancestor && isValid(ancestor, ancestorID)) {
12000
deepestNodeSoFar = ancestor;
12001
} else {
12002
// This node isn't populated in the cache, so presumably none of its
12003
// descendants are. Break out of the loop.
12004
return false;
12005
}
12006
}
12007
12008
/**
12009
* Return the deepest cached node whose ID is a prefix of `targetID`.
12010
*/
12011
function findDeepestCachedAncestor(targetID) {
12012
deepestNodeSoFar = null;
12013
ReactInstanceHandles.traverseAncestors(
12014
targetID,
12015
findDeepestCachedAncestorImpl
12016
);
12017
12018
var foundNode = deepestNodeSoFar;
12019
deepestNodeSoFar = null;
12020
return foundNode;
12021
}
12022
12023
/**
12024
* Mounts this component and inserts it into the DOM.
12025
*
12026
* @param {ReactComponent} componentInstance The instance to mount.
12027
* @param {string} rootID DOM ID of the root node.
12028
* @param {DOMElement} container DOM element to mount into.
12029
* @param {ReactReconcileTransaction} transaction
12030
* @param {boolean} shouldReuseMarkup If true, do not insert markup
12031
*/
12032
function mountComponentIntoNode(
12033
componentInstance,
12034
rootID,
12035
container,
12036
transaction,
12037
shouldReuseMarkup) {
12038
var markup = ReactReconciler.mountComponent(
12039
componentInstance, rootID, transaction, emptyObject
12040
);
12041
componentInstance._isTopLevel = true;
12042
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
12043
}
12044
12045
/**
12046
* Batched mount.
12047
*
12048
* @param {ReactComponent} componentInstance The instance to mount.
12049
* @param {string} rootID DOM ID of the root node.
12050
* @param {DOMElement} container DOM element to mount into.
12051
* @param {boolean} shouldReuseMarkup If true, do not insert markup
12052
*/
12053
function batchedMountComponentIntoNode(
12054
componentInstance,
12055
rootID,
12056
container,
12057
shouldReuseMarkup) {
12058
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
12059
transaction.perform(
12060
mountComponentIntoNode,
12061
null,
12062
componentInstance,
12063
rootID,
12064
container,
12065
transaction,
12066
shouldReuseMarkup
12067
);
12068
ReactUpdates.ReactReconcileTransaction.release(transaction);
12069
}
12070
12071
/**
12072
* Mounting is the process of initializing a React component by creating its
12073
* representative DOM elements and inserting them into a supplied `container`.
12074
* Any prior content inside `container` is destroyed in the process.
12075
*
12076
* ReactMount.render(
12077
* component,
12078
* document.getElementById('container')
12079
* );
12080
*
12081
* <div id="container"> <-- Supplied `container`.
12082
* <div data-reactid=".3"> <-- Rendered reactRoot of React
12083
* // ... component.
12084
* </div>
12085
* </div>
12086
*
12087
* Inside of `container`, the first element rendered is the "reactRoot".
12088
*/
12089
var ReactMount = {
12090
/** Exposed for debugging purposes **/
12091
_instancesByReactRootID: instancesByReactRootID,
12092
12093
/**
12094
* This is a hook provided to support rendering React components while
12095
* ensuring that the apparent scroll position of its `container` does not
12096
* change.
12097
*
12098
* @param {DOMElement} container The `container` being rendered into.
12099
* @param {function} renderCallback This must be called once to do the render.
12100
*/
12101
scrollMonitor: function(container, renderCallback) {
12102
renderCallback();
12103
},
12104
12105
/**
12106
* Take a component that's already mounted into the DOM and replace its props
12107
* @param {ReactComponent} prevComponent component instance already in the DOM
12108
* @param {ReactElement} nextElement component instance to render
12109
* @param {DOMElement} container container to render into
12110
* @param {?function} callback function triggered on completion
12111
*/
12112
_updateRootComponent: function(
12113
prevComponent,
12114
nextElement,
12115
container,
12116
callback) {
12117
if ("production" !== "development") {
12118
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
12119
}
12120
12121
ReactMount.scrollMonitor(container, function() {
12122
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
12123
if (callback) {
12124
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
12125
}
12126
});
12127
12128
if ("production" !== "development") {
12129
// Record the root element in case it later gets transplanted.
12130
rootElementsByReactRootID[getReactRootID(container)] =
12131
getReactRootElementInContainer(container);
12132
}
12133
12134
return prevComponent;
12135
},
12136
12137
/**
12138
* Register a component into the instance map and starts scroll value
12139
* monitoring
12140
* @param {ReactComponent} nextComponent component instance to render
12141
* @param {DOMElement} container container to render into
12142
* @return {string} reactRoot ID prefix
12143
*/
12144
_registerComponent: function(nextComponent, container) {
12145
("production" !== "development" ? invariant(
12146
container && (
12147
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12148
),
12149
'_registerComponent(...): Target container is not a DOM element.'
12150
) : invariant(container && (
12151
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12152
)));
12153
12154
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
12155
12156
var reactRootID = ReactMount.registerContainer(container);
12157
instancesByReactRootID[reactRootID] = nextComponent;
12158
return reactRootID;
12159
},
12160
12161
/**
12162
* Render a new component into the DOM.
12163
* @param {ReactElement} nextElement element to render
12164
* @param {DOMElement} container container to render into
12165
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion
12166
* @return {ReactComponent} nextComponent
12167
*/
12168
_renderNewRootComponent: function(
12169
nextElement,
12170
container,
12171
shouldReuseMarkup
12172
) {
12173
// Various parts of our code (such as ReactCompositeComponent's
12174
// _renderValidatedComponent) assume that calls to render aren't nested;
12175
// verify that that's the case.
12176
("production" !== "development" ? warning(
12177
ReactCurrentOwner.current == null,
12178
'_renderNewRootComponent(): Render methods should be a pure function ' +
12179
'of props and state; triggering nested component updates from ' +
12180
'render is not allowed. If necessary, trigger nested updates in ' +
12181
'componentDidUpdate.'
12182
) : null);
12183
12184
var componentInstance = instantiateReactComponent(nextElement, null);
12185
var reactRootID = ReactMount._registerComponent(
12186
componentInstance,
12187
container
12188
);
12189
12190
// The initial render is synchronous but any updates that happen during
12191
// rendering, in componentWillMount or componentDidMount, will be batched
12192
// according to the current batching strategy.
12193
12194
ReactUpdates.batchedUpdates(
12195
batchedMountComponentIntoNode,
12196
componentInstance,
12197
reactRootID,
12198
container,
12199
shouldReuseMarkup
12200
);
12201
12202
if ("production" !== "development") {
12203
// Record the root element in case it later gets transplanted.
12204
rootElementsByReactRootID[reactRootID] =
12205
getReactRootElementInContainer(container);
12206
}
12207
12208
return componentInstance;
12209
},
12210
12211
/**
12212
* Renders a React component into the DOM in the supplied `container`.
12213
*
12214
* If the React component was previously rendered into `container`, this will
12215
* perform an update on it and only mutate the DOM as necessary to reflect the
12216
* latest React component.
12217
*
12218
* @param {ReactElement} nextElement Component element to render.
12219
* @param {DOMElement} container DOM element to render into.
12220
* @param {?function} callback function triggered on completion
12221
* @return {ReactComponent} Component instance rendered in `container`.
12222
*/
12223
render: function(nextElement, container, callback) {
12224
("production" !== "development" ? invariant(
12225
ReactElement.isValidElement(nextElement),
12226
'React.render(): Invalid component element.%s',
12227
(
12228
typeof nextElement === 'string' ?
12229
' Instead of passing an element string, make sure to instantiate ' +
12230
'it by passing it to React.createElement.' :
12231
typeof nextElement === 'function' ?
12232
' Instead of passing a component class, make sure to instantiate ' +
12233
'it by passing it to React.createElement.' :
12234
// Check if it quacks like an element
12235
nextElement != null && nextElement.props !== undefined ?
12236
' This may be caused by unintentionally loading two independent ' +
12237
'copies of React.' :
12238
''
12239
)
12240
) : invariant(ReactElement.isValidElement(nextElement)));
12241
12242
var prevComponent = instancesByReactRootID[getReactRootID(container)];
12243
12244
if (prevComponent) {
12245
var prevElement = prevComponent._currentElement;
12246
if (shouldUpdateReactComponent(prevElement, nextElement)) {
12247
return ReactMount._updateRootComponent(
12248
prevComponent,
12249
nextElement,
12250
container,
12251
callback
12252
).getPublicInstance();
12253
} else {
12254
ReactMount.unmountComponentAtNode(container);
12255
}
12256
}
12257
12258
var reactRootElement = getReactRootElementInContainer(container);
12259
var containerHasReactMarkup =
12260
reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
12261
12262
if ("production" !== "development") {
12263
if (!containerHasReactMarkup || reactRootElement.nextSibling) {
12264
var rootElementSibling = reactRootElement;
12265
while (rootElementSibling) {
12266
if (ReactMount.isRenderedByReact(rootElementSibling)) {
12267
("production" !== "development" ? warning(
12268
false,
12269
'render(): Target node has markup rendered by React, but there ' +
12270
'are unrelated nodes as well. This is most commonly caused by ' +
12271
'white-space inserted around server-rendered markup.'
12272
) : null);
12273
break;
12274
}
12275
12276
rootElementSibling = rootElementSibling.nextSibling;
12277
}
12278
}
12279
}
12280
12281
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
12282
12283
var component = ReactMount._renderNewRootComponent(
12284
nextElement,
12285
container,
12286
shouldReuseMarkup
12287
).getPublicInstance();
12288
if (callback) {
12289
callback.call(component);
12290
}
12291
return component;
12292
},
12293
12294
/**
12295
* Constructs a component instance of `constructor` with `initialProps` and
12296
* renders it into the supplied `container`.
12297
*
12298
* @param {function} constructor React component constructor.
12299
* @param {?object} props Initial props of the component instance.
12300
* @param {DOMElement} container DOM element to render into.
12301
* @return {ReactComponent} Component instance rendered in `container`.
12302
*/
12303
constructAndRenderComponent: function(constructor, props, container) {
12304
var element = ReactElement.createElement(constructor, props);
12305
return ReactMount.render(element, container);
12306
},
12307
12308
/**
12309
* Constructs a component instance of `constructor` with `initialProps` and
12310
* renders it into a container node identified by supplied `id`.
12311
*
12312
* @param {function} componentConstructor React component constructor
12313
* @param {?object} props Initial props of the component instance.
12314
* @param {string} id ID of the DOM element to render into.
12315
* @return {ReactComponent} Component instance rendered in the container node.
12316
*/
12317
constructAndRenderComponentByID: function(constructor, props, id) {
12318
var domNode = document.getElementById(id);
12319
("production" !== "development" ? invariant(
12320
domNode,
12321
'Tried to get element with id of "%s" but it is not present on the page.',
12322
id
12323
) : invariant(domNode));
12324
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
12325
},
12326
12327
/**
12328
* Registers a container node into which React components will be rendered.
12329
* This also creates the "reactRoot" ID that will be assigned to the element
12330
* rendered within.
12331
*
12332
* @param {DOMElement} container DOM element to register as a container.
12333
* @return {string} The "reactRoot" ID of elements rendered within.
12334
*/
12335
registerContainer: function(container) {
12336
var reactRootID = getReactRootID(container);
12337
if (reactRootID) {
12338
// If one exists, make sure it is a valid "reactRoot" ID.
12339
reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
12340
}
12341
if (!reactRootID) {
12342
// No valid "reactRoot" ID found, create one.
12343
reactRootID = ReactInstanceHandles.createReactRootID();
12344
}
12345
containersByReactRootID[reactRootID] = container;
12346
return reactRootID;
12347
},
12348
12349
/**
12350
* Unmounts and destroys the React component rendered in the `container`.
12351
*
12352
* @param {DOMElement} container DOM element containing a React component.
12353
* @return {boolean} True if a component was found in and unmounted from
12354
* `container`
12355
*/
12356
unmountComponentAtNode: function(container) {
12357
// Various parts of our code (such as ReactCompositeComponent's
12358
// _renderValidatedComponent) assume that calls to render aren't nested;
12359
// verify that that's the case. (Strictly speaking, unmounting won't cause a
12360
// render but we still don't expect to be in a render call here.)
12361
("production" !== "development" ? warning(
12362
ReactCurrentOwner.current == null,
12363
'unmountComponentAtNode(): Render methods should be a pure function of ' +
12364
'props and state; triggering nested component updates from render is ' +
12365
'not allowed. If necessary, trigger nested updates in ' +
12366
'componentDidUpdate.'
12367
) : null);
12368
12369
("production" !== "development" ? invariant(
12370
container && (
12371
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12372
),
12373
'unmountComponentAtNode(...): Target container is not a DOM element.'
12374
) : invariant(container && (
12375
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12376
)));
12377
12378
var reactRootID = getReactRootID(container);
12379
var component = instancesByReactRootID[reactRootID];
12380
if (!component) {
12381
return false;
12382
}
12383
ReactMount.unmountComponentFromNode(component, container);
12384
delete instancesByReactRootID[reactRootID];
12385
delete containersByReactRootID[reactRootID];
12386
if ("production" !== "development") {
12387
delete rootElementsByReactRootID[reactRootID];
12388
}
12389
return true;
12390
},
12391
12392
/**
12393
* Unmounts a component and removes it from the DOM.
12394
*
12395
* @param {ReactComponent} instance React component instance.
12396
* @param {DOMElement} container DOM element to unmount from.
12397
* @final
12398
* @internal
12399
* @see {ReactMount.unmountComponentAtNode}
12400
*/
12401
unmountComponentFromNode: function(instance, container) {
12402
ReactReconciler.unmountComponent(instance);
12403
12404
if (container.nodeType === DOC_NODE_TYPE) {
12405
container = container.documentElement;
12406
}
12407
12408
// http://jsperf.com/emptying-a-node
12409
while (container.lastChild) {
12410
container.removeChild(container.lastChild);
12411
}
12412
},
12413
12414
/**
12415
* Finds the container DOM element that contains React component to which the
12416
* supplied DOM `id` belongs.
12417
*
12418
* @param {string} id The ID of an element rendered by a React component.
12419
* @return {?DOMElement} DOM element that contains the `id`.
12420
*/
12421
findReactContainerForID: function(id) {
12422
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
12423
var container = containersByReactRootID[reactRootID];
12424
12425
if ("production" !== "development") {
12426
var rootElement = rootElementsByReactRootID[reactRootID];
12427
if (rootElement && rootElement.parentNode !== container) {
12428
("production" !== "development" ? invariant(
12429
// Call internalGetID here because getID calls isValid which calls
12430
// findReactContainerForID (this function).
12431
internalGetID(rootElement) === reactRootID,
12432
'ReactMount: Root element ID differed from reactRootID.'
12433
) : invariant(// Call internalGetID here because getID calls isValid which calls
12434
// findReactContainerForID (this function).
12435
internalGetID(rootElement) === reactRootID));
12436
12437
var containerChild = container.firstChild;
12438
if (containerChild &&
12439
reactRootID === internalGetID(containerChild)) {
12440
// If the container has a new child with the same ID as the old
12441
// root element, then rootElementsByReactRootID[reactRootID] is
12442
// just stale and needs to be updated. The case that deserves a
12443
// warning is when the container is empty.
12444
rootElementsByReactRootID[reactRootID] = containerChild;
12445
} else {
12446
("production" !== "development" ? warning(
12447
false,
12448
'ReactMount: Root element has been removed from its original ' +
12449
'container. New container:', rootElement.parentNode
12450
) : null);
12451
}
12452
}
12453
}
12454
12455
return container;
12456
},
12457
12458
/**
12459
* Finds an element rendered by React with the supplied ID.
12460
*
12461
* @param {string} id ID of a DOM node in the React component.
12462
* @return {DOMElement} Root DOM node of the React component.
12463
*/
12464
findReactNodeByID: function(id) {
12465
var reactRoot = ReactMount.findReactContainerForID(id);
12466
return ReactMount.findComponentRoot(reactRoot, id);
12467
},
12468
12469
/**
12470
* True if the supplied `node` is rendered by React.
12471
*
12472
* @param {*} node DOM Element to check.
12473
* @return {boolean} True if the DOM Element appears to be rendered by React.
12474
* @internal
12475
*/
12476
isRenderedByReact: function(node) {
12477
if (node.nodeType !== 1) {
12478
// Not a DOMElement, therefore not a React component
12479
return false;
12480
}
12481
var id = ReactMount.getID(node);
12482
return id ? id.charAt(0) === SEPARATOR : false;
12483
},
12484
12485
/**
12486
* Traverses up the ancestors of the supplied node to find a node that is a
12487
* DOM representation of a React component.
12488
*
12489
* @param {*} node
12490
* @return {?DOMEventTarget}
12491
* @internal
12492
*/
12493
getFirstReactDOM: function(node) {
12494
var current = node;
12495
while (current && current.parentNode !== current) {
12496
if (ReactMount.isRenderedByReact(current)) {
12497
return current;
12498
}
12499
current = current.parentNode;
12500
}
12501
return null;
12502
},
12503
12504
/**
12505
* Finds a node with the supplied `targetID` inside of the supplied
12506
* `ancestorNode`. Exploits the ID naming scheme to perform the search
12507
* quickly.
12508
*
12509
* @param {DOMEventTarget} ancestorNode Search from this root.
12510
* @pararm {string} targetID ID of the DOM representation of the component.
12511
* @return {DOMEventTarget} DOM node with the supplied `targetID`.
12512
* @internal
12513
*/
12514
findComponentRoot: function(ancestorNode, targetID) {
12515
var firstChildren = findComponentRootReusableArray;
12516
var childIndex = 0;
12517
12518
var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
12519
12520
firstChildren[0] = deepestAncestor.firstChild;
12521
firstChildren.length = 1;
12522
12523
while (childIndex < firstChildren.length) {
12524
var child = firstChildren[childIndex++];
12525
var targetChild;
12526
12527
while (child) {
12528
var childID = ReactMount.getID(child);
12529
if (childID) {
12530
// Even if we find the node we're looking for, we finish looping
12531
// through its siblings to ensure they're cached so that we don't have
12532
// to revisit this node again. Otherwise, we make n^2 calls to getID
12533
// when visiting the many children of a single node in order.
12534
12535
if (targetID === childID) {
12536
targetChild = child;
12537
} else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
12538
// If we find a child whose ID is an ancestor of the given ID,
12539
// then we can be sure that we only want to search the subtree
12540
// rooted at this child, so we can throw out the rest of the
12541
// search state.
12542
firstChildren.length = childIndex = 0;
12543
firstChildren.push(child.firstChild);
12544
}
12545
12546
} else {
12547
// If this child had no ID, then there's a chance that it was
12548
// injected automatically by the browser, as when a `<table>`
12549
// element sprouts an extra `<tbody>` child as a side effect of
12550
// `.innerHTML` parsing. Optimistically continue down this
12551
// branch, but not before examining the other siblings.
12552
firstChildren.push(child.firstChild);
12553
}
12554
12555
child = child.nextSibling;
12556
}
12557
12558
if (targetChild) {
12559
// Emptying firstChildren/findComponentRootReusableArray is
12560
// not necessary for correctness, but it helps the GC reclaim
12561
// any nodes that were left at the end of the search.
12562
firstChildren.length = 0;
12563
12564
return targetChild;
12565
}
12566
}
12567
12568
firstChildren.length = 0;
12569
12570
("production" !== "development" ? invariant(
12571
false,
12572
'findComponentRoot(..., %s): Unable to find element. This probably ' +
12573
'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
12574
'usually due to forgetting a <tbody> when using tables, nesting tags ' +
12575
'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
12576
'parent. ' +
12577
'Try inspecting the child nodes of the element with React ID `%s`.',
12578
targetID,
12579
ReactMount.getID(ancestorNode)
12580
) : invariant(false));
12581
},
12582
12583
_mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
12584
("production" !== "development" ? invariant(
12585
container && (
12586
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12587
),
12588
'mountComponentIntoNode(...): Target container is not valid.'
12589
) : invariant(container && (
12590
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12591
)));
12592
12593
if (shouldReuseMarkup) {
12594
var rootElement = getReactRootElementInContainer(container);
12595
if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
12596
return;
12597
} else {
12598
var checksum = rootElement.getAttribute(
12599
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
12600
);
12601
rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
12602
12603
var rootMarkup = rootElement.outerHTML;
12604
rootElement.setAttribute(
12605
ReactMarkupChecksum.CHECKSUM_ATTR_NAME,
12606
checksum
12607
);
12608
12609
var diffIndex = firstDifferenceIndex(markup, rootMarkup);
12610
var difference = ' (client) ' +
12611
markup.substring(diffIndex - 20, diffIndex + 20) +
12612
'\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
12613
12614
("production" !== "development" ? invariant(
12615
container.nodeType !== DOC_NODE_TYPE,
12616
'You\'re trying to render a component to the document using ' +
12617
'server rendering but the checksum was invalid. This usually ' +
12618
'means you rendered a different component type or props on ' +
12619
'the client from the one on the server, or your render() ' +
12620
'methods are impure. React cannot handle this case due to ' +
12621
'cross-browser quirks by rendering at the document root. You ' +
12622
'should look for environment dependent code in your components ' +
12623
'and ensure the props are the same client and server side:\n%s',
12624
difference
12625
) : invariant(container.nodeType !== DOC_NODE_TYPE));
12626
12627
if ("production" !== "development") {
12628
("production" !== "development" ? warning(
12629
false,
12630
'React attempted to reuse markup in a container but the ' +
12631
'checksum was invalid. This generally means that you are ' +
12632
'using server rendering and the markup generated on the ' +
12633
'server was not what the client was expecting. React injected ' +
12634
'new markup to compensate which works but you have lost many ' +
12635
'of the benefits of server rendering. Instead, figure out ' +
12636
'why the markup being generated is different on the client ' +
12637
'or server:\n%s',
12638
difference
12639
) : null);
12640
}
12641
}
12642
}
12643
12644
("production" !== "development" ? invariant(
12645
container.nodeType !== DOC_NODE_TYPE,
12646
'You\'re trying to render a component to the document but ' +
12647
'you didn\'t use server rendering. We can\'t do this ' +
12648
'without using server rendering due to cross-browser quirks. ' +
12649
'See React.renderToString() for server rendering.'
12650
) : invariant(container.nodeType !== DOC_NODE_TYPE));
12651
12652
setInnerHTML(container, markup);
12653
},
12654
12655
/**
12656
* React ID utilities.
12657
*/
12658
12659
getReactRootID: getReactRootID,
12660
12661
getID: getID,
12662
12663
setID: setID,
12664
12665
getNode: getNode,
12666
12667
getNodeFromInstance: getNodeFromInstance,
12668
12669
purgeID: purgeID
12670
};
12671
12672
ReactPerf.measureMethods(ReactMount, 'ReactMount', {
12673
_renderNewRootComponent: '_renderNewRootComponent',
12674
_mountImageIntoNode: '_mountImageIntoNode'
12675
});
12676
12677
module.exports = ReactMount;
12678
12679
},{"10":10,"109":109,"115":115,"129":129,"134":134,"135":135,"148":148,"151":151,"154":154,"30":30,"39":39,"57":57,"58":58,"59":59,"66":66,"67":67,"69":69,"75":75,"81":81,"86":86,"87":87}],71:[function(_dereq_,module,exports){
12680
/**
12681
* Copyright 2013-2015, Facebook, Inc.
12682
* All rights reserved.
12683
*
12684
* This source code is licensed under the BSD-style license found in the
12685
* LICENSE file in the root directory of this source tree. An additional grant
12686
* of patent rights can be found in the PATENTS file in the same directory.
12687
*
12688
* @providesModule ReactMultiChild
12689
* @typechecks static-only
12690
*/
12691
12692
'use strict';
12693
12694
var ReactComponentEnvironment = _dereq_(36);
12695
var ReactMultiChildUpdateTypes = _dereq_(72);
12696
12697
var ReactReconciler = _dereq_(81);
12698
var ReactChildReconciler = _dereq_(31);
12699
12700
/**
12701
* Updating children of a component may trigger recursive updates. The depth is
12702
* used to batch recursive updates to render markup more efficiently.
12703
*
12704
* @type {number}
12705
* @private
12706
*/
12707
var updateDepth = 0;
12708
12709
/**
12710
* Queue of update configuration objects.
12711
*
12712
* Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
12713
*
12714
* @type {array<object>}
12715
* @private
12716
*/
12717
var updateQueue = [];
12718
12719
/**
12720
* Queue of markup to be rendered.
12721
*
12722
* @type {array<string>}
12723
* @private
12724
*/
12725
var markupQueue = [];
12726
12727
/**
12728
* Enqueues markup to be rendered and inserted at a supplied index.
12729
*
12730
* @param {string} parentID ID of the parent component.
12731
* @param {string} markup Markup that renders into an element.
12732
* @param {number} toIndex Destination index.
12733
* @private
12734
*/
12735
function enqueueMarkup(parentID, markup, toIndex) {
12736
// NOTE: Null values reduce hidden classes.
12737
updateQueue.push({
12738
parentID: parentID,
12739
parentNode: null,
12740
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
12741
markupIndex: markupQueue.push(markup) - 1,
12742
textContent: null,
12743
fromIndex: null,
12744
toIndex: toIndex
12745
});
12746
}
12747
12748
/**
12749
* Enqueues moving an existing element to another index.
12750
*
12751
* @param {string} parentID ID of the parent component.
12752
* @param {number} fromIndex Source index of the existing element.
12753
* @param {number} toIndex Destination index of the element.
12754
* @private
12755
*/
12756
function enqueueMove(parentID, fromIndex, toIndex) {
12757
// NOTE: Null values reduce hidden classes.
12758
updateQueue.push({
12759
parentID: parentID,
12760
parentNode: null,
12761
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
12762
markupIndex: null,
12763
textContent: null,
12764
fromIndex: fromIndex,
12765
toIndex: toIndex
12766
});
12767
}
12768
12769
/**
12770
* Enqueues removing an element at an index.
12771
*
12772
* @param {string} parentID ID of the parent component.
12773
* @param {number} fromIndex Index of the element to remove.
12774
* @private
12775
*/
12776
function enqueueRemove(parentID, fromIndex) {
12777
// NOTE: Null values reduce hidden classes.
12778
updateQueue.push({
12779
parentID: parentID,
12780
parentNode: null,
12781
type: ReactMultiChildUpdateTypes.REMOVE_NODE,
12782
markupIndex: null,
12783
textContent: null,
12784
fromIndex: fromIndex,
12785
toIndex: null
12786
});
12787
}
12788
12789
/**
12790
* Enqueues setting the text content.
12791
*
12792
* @param {string} parentID ID of the parent component.
12793
* @param {string} textContent Text content to set.
12794
* @private
12795
*/
12796
function enqueueTextContent(parentID, textContent) {
12797
// NOTE: Null values reduce hidden classes.
12798
updateQueue.push({
12799
parentID: parentID,
12800
parentNode: null,
12801
type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
12802
markupIndex: null,
12803
textContent: textContent,
12804
fromIndex: null,
12805
toIndex: null
12806
});
12807
}
12808
12809
/**
12810
* Processes any enqueued updates.
12811
*
12812
* @private
12813
*/
12814
function processQueue() {
12815
if (updateQueue.length) {
12816
ReactComponentEnvironment.processChildrenUpdates(
12817
updateQueue,
12818
markupQueue
12819
);
12820
clearQueue();
12821
}
12822
}
12823
12824
/**
12825
* Clears any enqueued updates.
12826
*
12827
* @private
12828
*/
12829
function clearQueue() {
12830
updateQueue.length = 0;
12831
markupQueue.length = 0;
12832
}
12833
12834
/**
12835
* ReactMultiChild are capable of reconciling multiple children.
12836
*
12837
* @class ReactMultiChild
12838
* @internal
12839
*/
12840
var ReactMultiChild = {
12841
12842
/**
12843
* Provides common functionality for components that must reconcile multiple
12844
* children. This is used by `ReactDOMComponent` to mount, update, and
12845
* unmount child components.
12846
*
12847
* @lends {ReactMultiChild.prototype}
12848
*/
12849
Mixin: {
12850
12851
/**
12852
* Generates a "mount image" for each of the supplied children. In the case
12853
* of `ReactDOMComponent`, a mount image is a string of markup.
12854
*
12855
* @param {?object} nestedChildren Nested child maps.
12856
* @return {array} An array of mounted representations.
12857
* @internal
12858
*/
12859
mountChildren: function(nestedChildren, transaction, context) {
12860
var children = ReactChildReconciler.instantiateChildren(
12861
nestedChildren, transaction, context
12862
);
12863
this._renderedChildren = children;
12864
var mountImages = [];
12865
var index = 0;
12866
for (var name in children) {
12867
if (children.hasOwnProperty(name)) {
12868
var child = children[name];
12869
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
12870
var rootID = this._rootNodeID + name;
12871
var mountImage = ReactReconciler.mountComponent(
12872
child,
12873
rootID,
12874
transaction,
12875
context
12876
);
12877
child._mountIndex = index;
12878
mountImages.push(mountImage);
12879
index++;
12880
}
12881
}
12882
return mountImages;
12883
},
12884
12885
/**
12886
* Replaces any rendered children with a text content string.
12887
*
12888
* @param {string} nextContent String of content.
12889
* @internal
12890
*/
12891
updateTextContent: function(nextContent) {
12892
updateDepth++;
12893
var errorThrown = true;
12894
try {
12895
var prevChildren = this._renderedChildren;
12896
// Remove any rendered children.
12897
ReactChildReconciler.unmountChildren(prevChildren);
12898
// TODO: The setTextContent operation should be enough
12899
for (var name in prevChildren) {
12900
if (prevChildren.hasOwnProperty(name)) {
12901
this._unmountChildByName(prevChildren[name], name);
12902
}
12903
}
12904
// Set new text content.
12905
this.setTextContent(nextContent);
12906
errorThrown = false;
12907
} finally {
12908
updateDepth--;
12909
if (!updateDepth) {
12910
if (errorThrown) {
12911
clearQueue();
12912
} else {
12913
processQueue();
12914
}
12915
}
12916
}
12917
},
12918
12919
/**
12920
* Updates the rendered children with new children.
12921
*
12922
* @param {?object} nextNestedChildren Nested child maps.
12923
* @param {ReactReconcileTransaction} transaction
12924
* @internal
12925
*/
12926
updateChildren: function(nextNestedChildren, transaction, context) {
12927
updateDepth++;
12928
var errorThrown = true;
12929
try {
12930
this._updateChildren(nextNestedChildren, transaction, context);
12931
errorThrown = false;
12932
} finally {
12933
updateDepth--;
12934
if (!updateDepth) {
12935
if (errorThrown) {
12936
clearQueue();
12937
} else {
12938
processQueue();
12939
}
12940
}
12941
12942
}
12943
},
12944
12945
/**
12946
* Improve performance by isolating this hot code path from the try/catch
12947
* block in `updateChildren`.
12948
*
12949
* @param {?object} nextNestedChildren Nested child maps.
12950
* @param {ReactReconcileTransaction} transaction
12951
* @final
12952
* @protected
12953
*/
12954
_updateChildren: function(nextNestedChildren, transaction, context) {
12955
var prevChildren = this._renderedChildren;
12956
var nextChildren = ReactChildReconciler.updateChildren(
12957
prevChildren, nextNestedChildren, transaction, context
12958
);
12959
this._renderedChildren = nextChildren;
12960
if (!nextChildren && !prevChildren) {
12961
return;
12962
}
12963
var name;
12964
// `nextIndex` will increment for each child in `nextChildren`, but
12965
// `lastIndex` will be the last index visited in `prevChildren`.
12966
var lastIndex = 0;
12967
var nextIndex = 0;
12968
for (name in nextChildren) {
12969
if (!nextChildren.hasOwnProperty(name)) {
12970
continue;
12971
}
12972
var prevChild = prevChildren && prevChildren[name];
12973
var nextChild = nextChildren[name];
12974
if (prevChild === nextChild) {
12975
this.moveChild(prevChild, nextIndex, lastIndex);
12976
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
12977
prevChild._mountIndex = nextIndex;
12978
} else {
12979
if (prevChild) {
12980
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
12981
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
12982
this._unmountChildByName(prevChild, name);
12983
}
12984
// The child must be instantiated before it's mounted.
12985
this._mountChildByNameAtIndex(
12986
nextChild, name, nextIndex, transaction, context
12987
);
12988
}
12989
nextIndex++;
12990
}
12991
// Remove children that are no longer present.
12992
for (name in prevChildren) {
12993
if (prevChildren.hasOwnProperty(name) &&
12994
!(nextChildren && nextChildren.hasOwnProperty(name))) {
12995
this._unmountChildByName(prevChildren[name], name);
12996
}
12997
}
12998
},
12999
13000
/**
13001
* Unmounts all rendered children. This should be used to clean up children
13002
* when this component is unmounted.
13003
*
13004
* @internal
13005
*/
13006
unmountChildren: function() {
13007
var renderedChildren = this._renderedChildren;
13008
ReactChildReconciler.unmountChildren(renderedChildren);
13009
this._renderedChildren = null;
13010
},
13011
13012
/**
13013
* Moves a child component to the supplied index.
13014
*
13015
* @param {ReactComponent} child Component to move.
13016
* @param {number} toIndex Destination index of the element.
13017
* @param {number} lastIndex Last index visited of the siblings of `child`.
13018
* @protected
13019
*/
13020
moveChild: function(child, toIndex, lastIndex) {
13021
// If the index of `child` is less than `lastIndex`, then it needs to
13022
// be moved. Otherwise, we do not need to move it because a child will be
13023
// inserted or moved before `child`.
13024
if (child._mountIndex < lastIndex) {
13025
enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
13026
}
13027
},
13028
13029
/**
13030
* Creates a child component.
13031
*
13032
* @param {ReactComponent} child Component to create.
13033
* @param {string} mountImage Markup to insert.
13034
* @protected
13035
*/
13036
createChild: function(child, mountImage) {
13037
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
13038
},
13039
13040
/**
13041
* Removes a child component.
13042
*
13043
* @param {ReactComponent} child Child to remove.
13044
* @protected
13045
*/
13046
removeChild: function(child) {
13047
enqueueRemove(this._rootNodeID, child._mountIndex);
13048
},
13049
13050
/**
13051
* Sets this text content string.
13052
*
13053
* @param {string} textContent Text content to set.
13054
* @protected
13055
*/
13056
setTextContent: function(textContent) {
13057
enqueueTextContent(this._rootNodeID, textContent);
13058
},
13059
13060
/**
13061
* Mounts a child with the supplied name.
13062
*
13063
* NOTE: This is part of `updateChildren` and is here for readability.
13064
*
13065
* @param {ReactComponent} child Component to mount.
13066
* @param {string} name Name of the child.
13067
* @param {number} index Index at which to insert the child.
13068
* @param {ReactReconcileTransaction} transaction
13069
* @private
13070
*/
13071
_mountChildByNameAtIndex: function(
13072
child,
13073
name,
13074
index,
13075
transaction,
13076
context) {
13077
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
13078
var rootID = this._rootNodeID + name;
13079
var mountImage = ReactReconciler.mountComponent(
13080
child,
13081
rootID,
13082
transaction,
13083
context
13084
);
13085
child._mountIndex = index;
13086
this.createChild(child, mountImage);
13087
},
13088
13089
/**
13090
* Unmounts a rendered child by name.
13091
*
13092
* NOTE: This is part of `updateChildren` and is here for readability.
13093
*
13094
* @param {ReactComponent} child Component to unmount.
13095
* @param {string} name Name of the child in `this._renderedChildren`.
13096
* @private
13097
*/
13098
_unmountChildByName: function(child, name) {
13099
this.removeChild(child);
13100
child._mountIndex = null;
13101
}
13102
13103
}
13104
13105
};
13106
13107
module.exports = ReactMultiChild;
13108
13109
},{"31":31,"36":36,"72":72,"81":81}],72:[function(_dereq_,module,exports){
13110
/**
13111
* Copyright 2013-2015, Facebook, Inc.
13112
* All rights reserved.
13113
*
13114
* This source code is licensed under the BSD-style license found in the
13115
* LICENSE file in the root directory of this source tree. An additional grant
13116
* of patent rights can be found in the PATENTS file in the same directory.
13117
*
13118
* @providesModule ReactMultiChildUpdateTypes
13119
*/
13120
13121
'use strict';
13122
13123
var keyMirror = _dereq_(140);
13124
13125
/**
13126
* When a component's children are updated, a series of update configuration
13127
* objects are created in order to batch and serialize the required changes.
13128
*
13129
* Enumerates all the possible types of update configurations.
13130
*
13131
* @internal
13132
*/
13133
var ReactMultiChildUpdateTypes = keyMirror({
13134
INSERT_MARKUP: null,
13135
MOVE_EXISTING: null,
13136
REMOVE_NODE: null,
13137
TEXT_CONTENT: null
13138
});
13139
13140
module.exports = ReactMultiChildUpdateTypes;
13141
13142
},{"140":140}],73:[function(_dereq_,module,exports){
13143
/**
13144
* Copyright 2014-2015, Facebook, Inc.
13145
* All rights reserved.
13146
*
13147
* This source code is licensed under the BSD-style license found in the
13148
* LICENSE file in the root directory of this source tree. An additional grant
13149
* of patent rights can be found in the PATENTS file in the same directory.
13150
*
13151
* @providesModule ReactNativeComponent
13152
*/
13153
13154
'use strict';
13155
13156
var assign = _dereq_(27);
13157
var invariant = _dereq_(135);
13158
13159
var autoGenerateWrapperClass = null;
13160
var genericComponentClass = null;
13161
// This registry keeps track of wrapper classes around native tags
13162
var tagToComponentClass = {};
13163
var textComponentClass = null;
13164
13165
var ReactNativeComponentInjection = {
13166
// This accepts a class that receives the tag string. This is a catch all
13167
// that can render any kind of tag.
13168
injectGenericComponentClass: function(componentClass) {
13169
genericComponentClass = componentClass;
13170
},
13171
// This accepts a text component class that takes the text string to be
13172
// rendered as props.
13173
injectTextComponentClass: function(componentClass) {
13174
textComponentClass = componentClass;
13175
},
13176
// This accepts a keyed object with classes as values. Each key represents a
13177
// tag. That particular tag will use this class instead of the generic one.
13178
injectComponentClasses: function(componentClasses) {
13179
assign(tagToComponentClass, componentClasses);
13180
},
13181
// Temporary hack since we expect DOM refs to behave like composites,
13182
// for this release.
13183
injectAutoWrapper: function(wrapperFactory) {
13184
autoGenerateWrapperClass = wrapperFactory;
13185
}
13186
};
13187
13188
/**
13189
* Get a composite component wrapper class for a specific tag.
13190
*
13191
* @param {ReactElement} element The tag for which to get the class.
13192
* @return {function} The React class constructor function.
13193
*/
13194
function getComponentClassForElement(element) {
13195
if (typeof element.type === 'function') {
13196
return element.type;
13197
}
13198
var tag = element.type;
13199
var componentClass = tagToComponentClass[tag];
13200
if (componentClass == null) {
13201
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
13202
}
13203
return componentClass;
13204
}
13205
13206
/**
13207
* Get a native internal component class for a specific tag.
13208
*
13209
* @param {ReactElement} element The element to create.
13210
* @return {function} The internal class constructor function.
13211
*/
13212
function createInternalComponent(element) {
13213
("production" !== "development" ? invariant(
13214
genericComponentClass,
13215
'There is no registered component for the tag %s',
13216
element.type
13217
) : invariant(genericComponentClass));
13218
return new genericComponentClass(element.type, element.props);
13219
}
13220
13221
/**
13222
* @param {ReactText} text
13223
* @return {ReactComponent}
13224
*/
13225
function createInstanceForText(text) {
13226
return new textComponentClass(text);
13227
}
13228
13229
/**
13230
* @param {ReactComponent} component
13231
* @return {boolean}
13232
*/
13233
function isTextComponent(component) {
13234
return component instanceof textComponentClass;
13235
}
13236
13237
var ReactNativeComponent = {
13238
getComponentClassForElement: getComponentClassForElement,
13239
createInternalComponent: createInternalComponent,
13240
createInstanceForText: createInstanceForText,
13241
isTextComponent: isTextComponent,
13242
injection: ReactNativeComponentInjection
13243
};
13244
13245
module.exports = ReactNativeComponent;
13246
13247
},{"135":135,"27":27}],74:[function(_dereq_,module,exports){
13248
/**
13249
* Copyright 2013-2015, Facebook, Inc.
13250
* All rights reserved.
13251
*
13252
* This source code is licensed under the BSD-style license found in the
13253
* LICENSE file in the root directory of this source tree. An additional grant
13254
* of patent rights can be found in the PATENTS file in the same directory.
13255
*
13256
* @providesModule ReactOwner
13257
*/
13258
13259
'use strict';
13260
13261
var invariant = _dereq_(135);
13262
13263
/**
13264
* ReactOwners are capable of storing references to owned components.
13265
*
13266
* All components are capable of //being// referenced by owner components, but
13267
* only ReactOwner components are capable of //referencing// owned components.
13268
* The named reference is known as a "ref".
13269
*
13270
* Refs are available when mounted and updated during reconciliation.
13271
*
13272
* var MyComponent = React.createClass({
13273
* render: function() {
13274
* return (
13275
* <div onClick={this.handleClick}>
13276
* <CustomComponent ref="custom" />
13277
* </div>
13278
* );
13279
* },
13280
* handleClick: function() {
13281
* this.refs.custom.handleClick();
13282
* },
13283
* componentDidMount: function() {
13284
* this.refs.custom.initialize();
13285
* }
13286
* });
13287
*
13288
* Refs should rarely be used. When refs are used, they should only be done to
13289
* control data that is not handled by React's data flow.
13290
*
13291
* @class ReactOwner
13292
*/
13293
var ReactOwner = {
13294
13295
/**
13296
* @param {?object} object
13297
* @return {boolean} True if `object` is a valid owner.
13298
* @final
13299
*/
13300
isValidOwner: function(object) {
13301
return !!(
13302
(object &&
13303
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
13304
);
13305
},
13306
13307
/**
13308
* Adds a component by ref to an owner component.
13309
*
13310
* @param {ReactComponent} component Component to reference.
13311
* @param {string} ref Name by which to refer to the component.
13312
* @param {ReactOwner} owner Component on which to record the ref.
13313
* @final
13314
* @internal
13315
*/
13316
addComponentAsRefTo: function(component, ref, owner) {
13317
("production" !== "development" ? invariant(
13318
ReactOwner.isValidOwner(owner),
13319
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
13320
'usually means that you\'re trying to add a ref to a component that ' +
13321
'doesn\'t have an owner (that is, was not created inside of another ' +
13322
'component\'s `render` method). Try rendering this component inside of ' +
13323
'a new top-level component which will hold the ref.'
13324
) : invariant(ReactOwner.isValidOwner(owner)));
13325
owner.attachRef(ref, component);
13326
},
13327
13328
/**
13329
* Removes a component by ref from an owner component.
13330
*
13331
* @param {ReactComponent} component Component to dereference.
13332
* @param {string} ref Name of the ref to remove.
13333
* @param {ReactOwner} owner Component on which the ref is recorded.
13334
* @final
13335
* @internal
13336
*/
13337
removeComponentAsRefFrom: function(component, ref, owner) {
13338
("production" !== "development" ? invariant(
13339
ReactOwner.isValidOwner(owner),
13340
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
13341
'usually means that you\'re trying to remove a ref to a component that ' +
13342
'doesn\'t have an owner (that is, was not created inside of another ' +
13343
'component\'s `render` method). Try rendering this component inside of ' +
13344
'a new top-level component which will hold the ref.'
13345
) : invariant(ReactOwner.isValidOwner(owner)));
13346
// Check that `component` is still the current ref because we do not want to
13347
// detach the ref if another component stole it.
13348
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
13349
owner.detachRef(ref);
13350
}
13351
}
13352
13353
};
13354
13355
module.exports = ReactOwner;
13356
13357
},{"135":135}],75:[function(_dereq_,module,exports){
13358
/**
13359
* Copyright 2013-2015, Facebook, Inc.
13360
* All rights reserved.
13361
*
13362
* This source code is licensed under the BSD-style license found in the
13363
* LICENSE file in the root directory of this source tree. An additional grant
13364
* of patent rights can be found in the PATENTS file in the same directory.
13365
*
13366
* @providesModule ReactPerf
13367
* @typechecks static-only
13368
*/
13369
13370
'use strict';
13371
13372
/**
13373
* ReactPerf is a general AOP system designed to measure performance. This
13374
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
13375
*/
13376
var ReactPerf = {
13377
/**
13378
* Boolean to enable/disable measurement. Set to false by default to prevent
13379
* accidental logging and perf loss.
13380
*/
13381
enableMeasure: false,
13382
13383
/**
13384
* Holds onto the measure function in use. By default, don't measure
13385
* anything, but we'll override this if we inject a measure function.
13386
*/
13387
storedMeasure: _noMeasure,
13388
13389
/**
13390
* @param {object} object
13391
* @param {string} objectName
13392
* @param {object<string>} methodNames
13393
*/
13394
measureMethods: function(object, objectName, methodNames) {
13395
if ("production" !== "development") {
13396
for (var key in methodNames) {
13397
if (!methodNames.hasOwnProperty(key)) {
13398
continue;
13399
}
13400
object[key] = ReactPerf.measure(
13401
objectName,
13402
methodNames[key],
13403
object[key]
13404
);
13405
}
13406
}
13407
},
13408
13409
/**
13410
* Use this to wrap methods you want to measure. Zero overhead in production.
13411
*
13412
* @param {string} objName
13413
* @param {string} fnName
13414
* @param {function} func
13415
* @return {function}
13416
*/
13417
measure: function(objName, fnName, func) {
13418
if ("production" !== "development") {
13419
var measuredFunc = null;
13420
var wrapper = function() {
13421
if (ReactPerf.enableMeasure) {
13422
if (!measuredFunc) {
13423
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
13424
}
13425
return measuredFunc.apply(this, arguments);
13426
}
13427
return func.apply(this, arguments);
13428
};
13429
wrapper.displayName = objName + '_' + fnName;
13430
return wrapper;
13431
}
13432
return func;
13433
},
13434
13435
injection: {
13436
/**
13437
* @param {function} measure
13438
*/
13439
injectMeasure: function(measure) {
13440
ReactPerf.storedMeasure = measure;
13441
}
13442
}
13443
};
13444
13445
/**
13446
* Simply passes through the measured function, without measuring it.
13447
*
13448
* @param {string} objName
13449
* @param {string} fnName
13450
* @param {function} func
13451
* @return {function}
13452
*/
13453
function _noMeasure(objName, fnName, func) {
13454
return func;
13455
}
13456
13457
module.exports = ReactPerf;
13458
13459
},{}],76:[function(_dereq_,module,exports){
13460
/**
13461
* Copyright 2013-2015, Facebook, Inc.
13462
* All rights reserved.
13463
*
13464
* This source code is licensed under the BSD-style license found in the
13465
* LICENSE file in the root directory of this source tree. An additional grant
13466
* of patent rights can be found in the PATENTS file in the same directory.
13467
*
13468
* @providesModule ReactPropTypeLocationNames
13469
*/
13470
13471
'use strict';
13472
13473
var ReactPropTypeLocationNames = {};
13474
13475
if ("production" !== "development") {
13476
ReactPropTypeLocationNames = {
13477
prop: 'prop',
13478
context: 'context',
13479
childContext: 'child context'
13480
};
13481
}
13482
13483
module.exports = ReactPropTypeLocationNames;
13484
13485
},{}],77:[function(_dereq_,module,exports){
13486
/**
13487
* Copyright 2013-2015, Facebook, Inc.
13488
* All rights reserved.
13489
*
13490
* This source code is licensed under the BSD-style license found in the
13491
* LICENSE file in the root directory of this source tree. An additional grant
13492
* of patent rights can be found in the PATENTS file in the same directory.
13493
*
13494
* @providesModule ReactPropTypeLocations
13495
*/
13496
13497
'use strict';
13498
13499
var keyMirror = _dereq_(140);
13500
13501
var ReactPropTypeLocations = keyMirror({
13502
prop: null,
13503
context: null,
13504
childContext: null
13505
});
13506
13507
module.exports = ReactPropTypeLocations;
13508
13509
},{"140":140}],78:[function(_dereq_,module,exports){
13510
/**
13511
* Copyright 2013-2015, Facebook, Inc.
13512
* All rights reserved.
13513
*
13514
* This source code is licensed under the BSD-style license found in the
13515
* LICENSE file in the root directory of this source tree. An additional grant
13516
* of patent rights can be found in the PATENTS file in the same directory.
13517
*
13518
* @providesModule ReactPropTypes
13519
*/
13520
13521
'use strict';
13522
13523
var ReactElement = _dereq_(57);
13524
var ReactFragment = _dereq_(63);
13525
var ReactPropTypeLocationNames = _dereq_(76);
13526
13527
var emptyFunction = _dereq_(114);
13528
13529
/**
13530
* Collection of methods that allow declaration and validation of props that are
13531
* supplied to React components. Example usage:
13532
*
13533
* var Props = require('ReactPropTypes');
13534
* var MyArticle = React.createClass({
13535
* propTypes: {
13536
* // An optional string prop named "description".
13537
* description: Props.string,
13538
*
13539
* // A required enum prop named "category".
13540
* category: Props.oneOf(['News','Photos']).isRequired,
13541
*
13542
* // A prop named "dialog" that requires an instance of Dialog.
13543
* dialog: Props.instanceOf(Dialog).isRequired
13544
* },
13545
* render: function() { ... }
13546
* });
13547
*
13548
* A more formal specification of how these methods are used:
13549
*
13550
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
13551
* decl := ReactPropTypes.{type}(.isRequired)?
13552
*
13553
* Each and every declaration produces a function with the same signature. This
13554
* allows the creation of custom validation functions. For example:
13555
*
13556
* var MyLink = React.createClass({
13557
* propTypes: {
13558
* // An optional string or URI prop named "href".
13559
* href: function(props, propName, componentName) {
13560
* var propValue = props[propName];
13561
* if (propValue != null && typeof propValue !== 'string' &&
13562
* !(propValue instanceof URI)) {
13563
* return new Error(
13564
* 'Expected a string or an URI for ' + propName + ' in ' +
13565
* componentName
13566
* );
13567
* }
13568
* }
13569
* },
13570
* render: function() {...}
13571
* });
13572
*
13573
* @internal
13574
*/
13575
13576
var ANONYMOUS = '<<anonymous>>';
13577
13578
var elementTypeChecker = createElementTypeChecker();
13579
var nodeTypeChecker = createNodeChecker();
13580
13581
var ReactPropTypes = {
13582
array: createPrimitiveTypeChecker('array'),
13583
bool: createPrimitiveTypeChecker('boolean'),
13584
func: createPrimitiveTypeChecker('function'),
13585
number: createPrimitiveTypeChecker('number'),
13586
object: createPrimitiveTypeChecker('object'),
13587
string: createPrimitiveTypeChecker('string'),
13588
13589
any: createAnyTypeChecker(),
13590
arrayOf: createArrayOfTypeChecker,
13591
element: elementTypeChecker,
13592
instanceOf: createInstanceTypeChecker,
13593
node: nodeTypeChecker,
13594
objectOf: createObjectOfTypeChecker,
13595
oneOf: createEnumTypeChecker,
13596
oneOfType: createUnionTypeChecker,
13597
shape: createShapeTypeChecker
13598
};
13599
13600
function createChainableTypeChecker(validate) {
13601
function checkType(isRequired, props, propName, componentName, location) {
13602
componentName = componentName || ANONYMOUS;
13603
if (props[propName] == null) {
13604
var locationName = ReactPropTypeLocationNames[location];
13605
if (isRequired) {
13606
return new Error(
13607
("Required " + locationName + " `" + propName + "` was not specified in ") +
13608
("`" + componentName + "`.")
13609
);
13610
}
13611
return null;
13612
} else {
13613
return validate(props, propName, componentName, location);
13614
}
13615
}
13616
13617
var chainedCheckType = checkType.bind(null, false);
13618
chainedCheckType.isRequired = checkType.bind(null, true);
13619
13620
return chainedCheckType;
13621
}
13622
13623
function createPrimitiveTypeChecker(expectedType) {
13624
function validate(props, propName, componentName, location) {
13625
var propValue = props[propName];
13626
var propType = getPropType(propValue);
13627
if (propType !== expectedType) {
13628
var locationName = ReactPropTypeLocationNames[location];
13629
// `propValue` being instance of, say, date/regexp, pass the 'object'
13630
// check, but we can offer a more precise error message here rather than
13631
// 'of type `object`'.
13632
var preciseType = getPreciseType(propValue);
13633
13634
return new Error(
13635
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
13636
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
13637
);
13638
}
13639
return null;
13640
}
13641
return createChainableTypeChecker(validate);
13642
}
13643
13644
function createAnyTypeChecker() {
13645
return createChainableTypeChecker(emptyFunction.thatReturns(null));
13646
}
13647
13648
function createArrayOfTypeChecker(typeChecker) {
13649
function validate(props, propName, componentName, location) {
13650
var propValue = props[propName];
13651
if (!Array.isArray(propValue)) {
13652
var locationName = ReactPropTypeLocationNames[location];
13653
var propType = getPropType(propValue);
13654
return new Error(
13655
("Invalid " + locationName + " `" + propName + "` of type ") +
13656
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
13657
);
13658
}
13659
for (var i = 0; i < propValue.length; i++) {
13660
var error = typeChecker(propValue, i, componentName, location);
13661
if (error instanceof Error) {
13662
return error;
13663
}
13664
}
13665
return null;
13666
}
13667
return createChainableTypeChecker(validate);
13668
}
13669
13670
function createElementTypeChecker() {
13671
function validate(props, propName, componentName, location) {
13672
if (!ReactElement.isValidElement(props[propName])) {
13673
var locationName = ReactPropTypeLocationNames[location];
13674
return new Error(
13675
("Invalid " + locationName + " `" + propName + "` supplied to ") +
13676
("`" + componentName + "`, expected a ReactElement.")
13677
);
13678
}
13679
return null;
13680
}
13681
return createChainableTypeChecker(validate);
13682
}
13683
13684
function createInstanceTypeChecker(expectedClass) {
13685
function validate(props, propName, componentName, location) {
13686
if (!(props[propName] instanceof expectedClass)) {
13687
var locationName = ReactPropTypeLocationNames[location];
13688
var expectedClassName = expectedClass.name || ANONYMOUS;
13689
return new Error(
13690
("Invalid " + locationName + " `" + propName + "` supplied to ") +
13691
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
13692
);
13693
}
13694
return null;
13695
}
13696
return createChainableTypeChecker(validate);
13697
}
13698
13699
function createEnumTypeChecker(expectedValues) {
13700
function validate(props, propName, componentName, location) {
13701
var propValue = props[propName];
13702
for (var i = 0; i < expectedValues.length; i++) {
13703
if (propValue === expectedValues[i]) {
13704
return null;
13705
}
13706
}
13707
13708
var locationName = ReactPropTypeLocationNames[location];
13709
var valuesString = JSON.stringify(expectedValues);
13710
return new Error(
13711
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
13712
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
13713
);
13714
}
13715
return createChainableTypeChecker(validate);
13716
}
13717
13718
function createObjectOfTypeChecker(typeChecker) {
13719
function validate(props, propName, componentName, location) {
13720
var propValue = props[propName];
13721
var propType = getPropType(propValue);
13722
if (propType !== 'object') {
13723
var locationName = ReactPropTypeLocationNames[location];
13724
return new Error(
13725
("Invalid " + locationName + " `" + propName + "` of type ") +
13726
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
13727
);
13728
}
13729
for (var key in propValue) {
13730
if (propValue.hasOwnProperty(key)) {
13731
var error = typeChecker(propValue, key, componentName, location);
13732
if (error instanceof Error) {
13733
return error;
13734
}
13735
}
13736
}
13737
return null;
13738
}
13739
return createChainableTypeChecker(validate);
13740
}
13741
13742
function createUnionTypeChecker(arrayOfTypeCheckers) {
13743
function validate(props, propName, componentName, location) {
13744
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
13745
var checker = arrayOfTypeCheckers[i];
13746
if (checker(props, propName, componentName, location) == null) {
13747
return null;
13748
}
13749
}
13750
13751
var locationName = ReactPropTypeLocationNames[location];
13752
return new Error(
13753
("Invalid " + locationName + " `" + propName + "` supplied to ") +
13754
("`" + componentName + "`.")
13755
);
13756
}
13757
return createChainableTypeChecker(validate);
13758
}
13759
13760
function createNodeChecker() {
13761
function validate(props, propName, componentName, location) {
13762
if (!isNode(props[propName])) {
13763
var locationName = ReactPropTypeLocationNames[location];
13764
return new Error(
13765
("Invalid " + locationName + " `" + propName + "` supplied to ") +
13766
("`" + componentName + "`, expected a ReactNode.")
13767
);
13768
}
13769
return null;
13770
}
13771
return createChainableTypeChecker(validate);
13772
}
13773
13774
function createShapeTypeChecker(shapeTypes) {
13775
function validate(props, propName, componentName, location) {
13776
var propValue = props[propName];
13777
var propType = getPropType(propValue);
13778
if (propType !== 'object') {
13779
var locationName = ReactPropTypeLocationNames[location];
13780
return new Error(
13781
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
13782
("supplied to `" + componentName + "`, expected `object`.")
13783
);
13784
}
13785
for (var key in shapeTypes) {
13786
var checker = shapeTypes[key];
13787
if (!checker) {
13788
continue;
13789
}
13790
var error = checker(propValue, key, componentName, location);
13791
if (error) {
13792
return error;
13793
}
13794
}
13795
return null;
13796
}
13797
return createChainableTypeChecker(validate);
13798
}
13799
13800
function isNode(propValue) {
13801
switch (typeof propValue) {
13802
case 'number':
13803
case 'string':
13804
case 'undefined':
13805
return true;
13806
case 'boolean':
13807
return !propValue;
13808
case 'object':
13809
if (Array.isArray(propValue)) {
13810
return propValue.every(isNode);
13811
}
13812
if (propValue === null || ReactElement.isValidElement(propValue)) {
13813
return true;
13814
}
13815
propValue = ReactFragment.extractIfFragment(propValue);
13816
for (var k in propValue) {
13817
if (!isNode(propValue[k])) {
13818
return false;
13819
}
13820
}
13821
return true;
13822
default:
13823
return false;
13824
}
13825
}
13826
13827
// Equivalent of `typeof` but with special handling for array and regexp.
13828
function getPropType(propValue) {
13829
var propType = typeof propValue;
13830
if (Array.isArray(propValue)) {
13831
return 'array';
13832
}
13833
if (propValue instanceof RegExp) {
13834
// Old webkits (at least until Android 4.0) return 'function' rather than
13835
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
13836
// passes PropTypes.object.
13837
return 'object';
13838
}
13839
return propType;
13840
}
13841
13842
// This handles more types than `getPropType`. Only used for error messages.
13843
// See `createPrimitiveTypeChecker`.
13844
function getPreciseType(propValue) {
13845
var propType = getPropType(propValue);
13846
if (propType === 'object') {
13847
if (propValue instanceof Date) {
13848
return 'date';
13849
} else if (propValue instanceof RegExp) {
13850
return 'regexp';
13851
}
13852
}
13853
return propType;
13854
}
13855
13856
module.exports = ReactPropTypes;
13857
13858
},{"114":114,"57":57,"63":63,"76":76}],79:[function(_dereq_,module,exports){
13859
/**
13860
* Copyright 2013-2015, Facebook, Inc.
13861
* All rights reserved.
13862
*
13863
* This source code is licensed under the BSD-style license found in the
13864
* LICENSE file in the root directory of this source tree. An additional grant
13865
* of patent rights can be found in the PATENTS file in the same directory.
13866
*
13867
* @providesModule ReactPutListenerQueue
13868
*/
13869
13870
'use strict';
13871
13872
var PooledClass = _dereq_(28);
13873
var ReactBrowserEventEmitter = _dereq_(30);
13874
13875
var assign = _dereq_(27);
13876
13877
function ReactPutListenerQueue() {
13878
this.listenersToPut = [];
13879
}
13880
13881
assign(ReactPutListenerQueue.prototype, {
13882
enqueuePutListener: function(rootNodeID, propKey, propValue) {
13883
this.listenersToPut.push({
13884
rootNodeID: rootNodeID,
13885
propKey: propKey,
13886
propValue: propValue
13887
});
13888
},
13889
13890
putListeners: function() {
13891
for (var i = 0; i < this.listenersToPut.length; i++) {
13892
var listenerToPut = this.listenersToPut[i];
13893
ReactBrowserEventEmitter.putListener(
13894
listenerToPut.rootNodeID,
13895
listenerToPut.propKey,
13896
listenerToPut.propValue
13897
);
13898
}
13899
},
13900
13901
reset: function() {
13902
this.listenersToPut.length = 0;
13903
},
13904
13905
destructor: function() {
13906
this.reset();
13907
}
13908
});
13909
13910
PooledClass.addPoolingTo(ReactPutListenerQueue);
13911
13912
module.exports = ReactPutListenerQueue;
13913
13914
},{"27":27,"28":28,"30":30}],80:[function(_dereq_,module,exports){
13915
/**
13916
* Copyright 2013-2015, Facebook, Inc.
13917
* All rights reserved.
13918
*
13919
* This source code is licensed under the BSD-style license found in the
13920
* LICENSE file in the root directory of this source tree. An additional grant
13921
* of patent rights can be found in the PATENTS file in the same directory.
13922
*
13923
* @providesModule ReactReconcileTransaction
13924
* @typechecks static-only
13925
*/
13926
13927
'use strict';
13928
13929
var CallbackQueue = _dereq_(6);
13930
var PooledClass = _dereq_(28);
13931
var ReactBrowserEventEmitter = _dereq_(30);
13932
var ReactInputSelection = _dereq_(65);
13933
var ReactPutListenerQueue = _dereq_(79);
13934
var Transaction = _dereq_(103);
13935
13936
var assign = _dereq_(27);
13937
13938
/**
13939
* Ensures that, when possible, the selection range (currently selected text
13940
* input) is not disturbed by performing the transaction.
13941
*/
13942
var SELECTION_RESTORATION = {
13943
/**
13944
* @return {Selection} Selection information.
13945
*/
13946
initialize: ReactInputSelection.getSelectionInformation,
13947
/**
13948
* @param {Selection} sel Selection information returned from `initialize`.
13949
*/
13950
close: ReactInputSelection.restoreSelection
13951
};
13952
13953
/**
13954
* Suppresses events (blur/focus) that could be inadvertently dispatched due to
13955
* high level DOM manipulations (like temporarily removing a text input from the
13956
* DOM).
13957
*/
13958
var EVENT_SUPPRESSION = {
13959
/**
13960
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
13961
* the reconciliation.
13962
*/
13963
initialize: function() {
13964
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
13965
ReactBrowserEventEmitter.setEnabled(false);
13966
return currentlyEnabled;
13967
},
13968
13969
/**
13970
* @param {boolean} previouslyEnabled Enabled status of
13971
* `ReactBrowserEventEmitter` before the reconciliation occured. `close`
13972
* restores the previous value.
13973
*/
13974
close: function(previouslyEnabled) {
13975
ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
13976
}
13977
};
13978
13979
/**
13980
* Provides a queue for collecting `componentDidMount` and
13981
* `componentDidUpdate` callbacks during the the transaction.
13982
*/
13983
var ON_DOM_READY_QUEUEING = {
13984
/**
13985
* Initializes the internal `onDOMReady` queue.
13986
*/
13987
initialize: function() {
13988
this.reactMountReady.reset();
13989
},
13990
13991
/**
13992
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
13993
*/
13994
close: function() {
13995
this.reactMountReady.notifyAll();
13996
}
13997
};
13998
13999
var PUT_LISTENER_QUEUEING = {
14000
initialize: function() {
14001
this.putListenerQueue.reset();
14002
},
14003
14004
close: function() {
14005
this.putListenerQueue.putListeners();
14006
}
14007
};
14008
14009
/**
14010
* Executed within the scope of the `Transaction` instance. Consider these as
14011
* being member methods, but with an implied ordering while being isolated from
14012
* each other.
14013
*/
14014
var TRANSACTION_WRAPPERS = [
14015
PUT_LISTENER_QUEUEING,
14016
SELECTION_RESTORATION,
14017
EVENT_SUPPRESSION,
14018
ON_DOM_READY_QUEUEING
14019
];
14020
14021
/**
14022
* Currently:
14023
* - The order that these are listed in the transaction is critical:
14024
* - Suppresses events.
14025
* - Restores selection range.
14026
*
14027
* Future:
14028
* - Restore document/overflow scroll positions that were unintentionally
14029
* modified via DOM insertions above the top viewport boundary.
14030
* - Implement/integrate with customized constraint based layout system and keep
14031
* track of which dimensions must be remeasured.
14032
*
14033
* @class ReactReconcileTransaction
14034
*/
14035
function ReactReconcileTransaction() {
14036
this.reinitializeTransaction();
14037
// Only server-side rendering really needs this option (see
14038
// `ReactServerRendering`), but server-side uses
14039
// `ReactServerRenderingTransaction` instead. This option is here so that it's
14040
// accessible and defaults to false when `ReactDOMComponent` and
14041
// `ReactTextComponent` checks it in `mountComponent`.`
14042
this.renderToStaticMarkup = false;
14043
this.reactMountReady = CallbackQueue.getPooled(null);
14044
this.putListenerQueue = ReactPutListenerQueue.getPooled();
14045
}
14046
14047
var Mixin = {
14048
/**
14049
* @see Transaction
14050
* @abstract
14051
* @final
14052
* @return {array<object>} List of operation wrap proceedures.
14053
* TODO: convert to array<TransactionWrapper>
14054
*/
14055
getTransactionWrappers: function() {
14056
return TRANSACTION_WRAPPERS;
14057
},
14058
14059
/**
14060
* @return {object} The queue to collect `onDOMReady` callbacks with.
14061
*/
14062
getReactMountReady: function() {
14063
return this.reactMountReady;
14064
},
14065
14066
getPutListenerQueue: function() {
14067
return this.putListenerQueue;
14068
},
14069
14070
/**
14071
* `PooledClass` looks for this, and will invoke this before allowing this
14072
* instance to be resused.
14073
*/
14074
destructor: function() {
14075
CallbackQueue.release(this.reactMountReady);
14076
this.reactMountReady = null;
14077
14078
ReactPutListenerQueue.release(this.putListenerQueue);
14079
this.putListenerQueue = null;
14080
}
14081
};
14082
14083
14084
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
14085
14086
PooledClass.addPoolingTo(ReactReconcileTransaction);
14087
14088
module.exports = ReactReconcileTransaction;
14089
14090
},{"103":103,"27":27,"28":28,"30":30,"6":6,"65":65,"79":79}],81:[function(_dereq_,module,exports){
14091
/**
14092
* Copyright 2013-2015, Facebook, Inc.
14093
* All rights reserved.
14094
*
14095
* This source code is licensed under the BSD-style license found in the
14096
* LICENSE file in the root directory of this source tree. An additional grant
14097
* of patent rights can be found in the PATENTS file in the same directory.
14098
*
14099
* @providesModule ReactReconciler
14100
*/
14101
14102
'use strict';
14103
14104
var ReactRef = _dereq_(82);
14105
var ReactElementValidator = _dereq_(58);
14106
14107
/**
14108
* Helper to call ReactRef.attachRefs with this composite component, split out
14109
* to avoid allocations in the transaction mount-ready queue.
14110
*/
14111
function attachRefs() {
14112
ReactRef.attachRefs(this, this._currentElement);
14113
}
14114
14115
var ReactReconciler = {
14116
14117
/**
14118
* Initializes the component, renders markup, and registers event listeners.
14119
*
14120
* @param {ReactComponent} internalInstance
14121
* @param {string} rootID DOM ID of the root node.
14122
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
14123
* @return {?string} Rendered markup to be inserted into the DOM.
14124
* @final
14125
* @internal
14126
*/
14127
mountComponent: function(internalInstance, rootID, transaction, context) {
14128
var markup = internalInstance.mountComponent(rootID, transaction, context);
14129
if ("production" !== "development") {
14130
ReactElementValidator.checkAndWarnForMutatedProps(
14131
internalInstance._currentElement
14132
);
14133
}
14134
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
14135
return markup;
14136
},
14137
14138
/**
14139
* Releases any resources allocated by `mountComponent`.
14140
*
14141
* @final
14142
* @internal
14143
*/
14144
unmountComponent: function(internalInstance) {
14145
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
14146
internalInstance.unmountComponent();
14147
},
14148
14149
/**
14150
* Update a component using a new element.
14151
*
14152
* @param {ReactComponent} internalInstance
14153
* @param {ReactElement} nextElement
14154
* @param {ReactReconcileTransaction} transaction
14155
* @param {object} context
14156
* @internal
14157
*/
14158
receiveComponent: function(
14159
internalInstance, nextElement, transaction, context
14160
) {
14161
var prevElement = internalInstance._currentElement;
14162
14163
if (nextElement === prevElement && nextElement._owner != null) {
14164
// Since elements are immutable after the owner is rendered,
14165
// we can do a cheap identity compare here to determine if this is a
14166
// superfluous reconcile. It's possible for state to be mutable but such
14167
// change should trigger an update of the owner which would recreate
14168
// the element. We explicitly check for the existence of an owner since
14169
// it's possible for an element created outside a composite to be
14170
// deeply mutated and reused.
14171
return;
14172
}
14173
14174
if ("production" !== "development") {
14175
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
14176
}
14177
14178
var refsChanged = ReactRef.shouldUpdateRefs(
14179
prevElement,
14180
nextElement
14181
);
14182
14183
if (refsChanged) {
14184
ReactRef.detachRefs(internalInstance, prevElement);
14185
}
14186
14187
internalInstance.receiveComponent(nextElement, transaction, context);
14188
14189
if (refsChanged) {
14190
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
14191
}
14192
},
14193
14194
/**
14195
* Flush any dirty changes in a component.
14196
*
14197
* @param {ReactComponent} internalInstance
14198
* @param {ReactReconcileTransaction} transaction
14199
* @internal
14200
*/
14201
performUpdateIfNecessary: function(
14202
internalInstance,
14203
transaction
14204
) {
14205
internalInstance.performUpdateIfNecessary(transaction);
14206
}
14207
14208
};
14209
14210
module.exports = ReactReconciler;
14211
14212
},{"58":58,"82":82}],82:[function(_dereq_,module,exports){
14213
/**
14214
* Copyright 2013-2015, Facebook, Inc.
14215
* All rights reserved.
14216
*
14217
* This source code is licensed under the BSD-style license found in the
14218
* LICENSE file in the root directory of this source tree. An additional grant
14219
* of patent rights can be found in the PATENTS file in the same directory.
14220
*
14221
* @providesModule ReactRef
14222
*/
14223
14224
'use strict';
14225
14226
var ReactOwner = _dereq_(74);
14227
14228
var ReactRef = {};
14229
14230
function attachRef(ref, component, owner) {
14231
if (typeof ref === 'function') {
14232
ref(component.getPublicInstance());
14233
} else {
14234
// Legacy ref
14235
ReactOwner.addComponentAsRefTo(component, ref, owner);
14236
}
14237
}
14238
14239
function detachRef(ref, component, owner) {
14240
if (typeof ref === 'function') {
14241
ref(null);
14242
} else {
14243
// Legacy ref
14244
ReactOwner.removeComponentAsRefFrom(component, ref, owner);
14245
}
14246
}
14247
14248
ReactRef.attachRefs = function(instance, element) {
14249
var ref = element.ref;
14250
if (ref != null) {
14251
attachRef(ref, instance, element._owner);
14252
}
14253
};
14254
14255
ReactRef.shouldUpdateRefs = function(prevElement, nextElement) {
14256
// If either the owner or a `ref` has changed, make sure the newest owner
14257
// has stored a reference to `this`, and the previous owner (if different)
14258
// has forgotten the reference to `this`. We use the element instead
14259
// of the public this.props because the post processing cannot determine
14260
// a ref. The ref conceptually lives on the element.
14261
14262
// TODO: Should this even be possible? The owner cannot change because
14263
// it's forbidden by shouldUpdateReactComponent. The ref can change
14264
// if you swap the keys of but not the refs. Reconsider where this check
14265
// is made. It probably belongs where the key checking and
14266
// instantiateReactComponent is done.
14267
14268
return (
14269
nextElement._owner !== prevElement._owner ||
14270
nextElement.ref !== prevElement.ref
14271
);
14272
};
14273
14274
ReactRef.detachRefs = function(instance, element) {
14275
var ref = element.ref;
14276
if (ref != null) {
14277
detachRef(ref, instance, element._owner);
14278
}
14279
};
14280
14281
module.exports = ReactRef;
14282
14283
},{"74":74}],83:[function(_dereq_,module,exports){
14284
/**
14285
* Copyright 2013-2015, Facebook, Inc.
14286
* All rights reserved.
14287
*
14288
* This source code is licensed under the BSD-style license found in the
14289
* LICENSE file in the root directory of this source tree. An additional grant
14290
* of patent rights can be found in the PATENTS file in the same directory.
14291
*
14292
* @providesModule ReactRootIndex
14293
* @typechecks
14294
*/
14295
14296
'use strict';
14297
14298
var ReactRootIndexInjection = {
14299
/**
14300
* @param {function} _createReactRootIndex
14301
*/
14302
injectCreateReactRootIndex: function(_createReactRootIndex) {
14303
ReactRootIndex.createReactRootIndex = _createReactRootIndex;
14304
}
14305
};
14306
14307
var ReactRootIndex = {
14308
createReactRootIndex: null,
14309
injection: ReactRootIndexInjection
14310
};
14311
14312
module.exports = ReactRootIndex;
14313
14314
},{}],84:[function(_dereq_,module,exports){
14315
/**
14316
* Copyright 2013-2015, Facebook, Inc.
14317
* All rights reserved.
14318
*
14319
* This source code is licensed under the BSD-style license found in the
14320
* LICENSE file in the root directory of this source tree. An additional grant
14321
* of patent rights can be found in the PATENTS file in the same directory.
14322
*
14323
* @typechecks static-only
14324
* @providesModule ReactServerRendering
14325
*/
14326
'use strict';
14327
14328
var ReactElement = _dereq_(57);
14329
var ReactInstanceHandles = _dereq_(66);
14330
var ReactMarkupChecksum = _dereq_(69);
14331
var ReactServerRenderingTransaction =
14332
_dereq_(85);
14333
14334
var emptyObject = _dereq_(115);
14335
var instantiateReactComponent = _dereq_(134);
14336
var invariant = _dereq_(135);
14337
14338
/**
14339
* @param {ReactElement} element
14340
* @return {string} the HTML markup
14341
*/
14342
function renderToString(element) {
14343
("production" !== "development" ? invariant(
14344
ReactElement.isValidElement(element),
14345
'renderToString(): You must pass a valid ReactElement.'
14346
) : invariant(ReactElement.isValidElement(element)));
14347
14348
var transaction;
14349
try {
14350
var id = ReactInstanceHandles.createReactRootID();
14351
transaction = ReactServerRenderingTransaction.getPooled(false);
14352
14353
return transaction.perform(function() {
14354
var componentInstance = instantiateReactComponent(element, null);
14355
var markup =
14356
componentInstance.mountComponent(id, transaction, emptyObject);
14357
return ReactMarkupChecksum.addChecksumToMarkup(markup);
14358
}, null);
14359
} finally {
14360
ReactServerRenderingTransaction.release(transaction);
14361
}
14362
}
14363
14364
/**
14365
* @param {ReactElement} element
14366
* @return {string} the HTML markup, without the extra React ID and checksum
14367
* (for generating static pages)
14368
*/
14369
function renderToStaticMarkup(element) {
14370
("production" !== "development" ? invariant(
14371
ReactElement.isValidElement(element),
14372
'renderToStaticMarkup(): You must pass a valid ReactElement.'
14373
) : invariant(ReactElement.isValidElement(element)));
14374
14375
var transaction;
14376
try {
14377
var id = ReactInstanceHandles.createReactRootID();
14378
transaction = ReactServerRenderingTransaction.getPooled(true);
14379
14380
return transaction.perform(function() {
14381
var componentInstance = instantiateReactComponent(element, null);
14382
return componentInstance.mountComponent(id, transaction, emptyObject);
14383
}, null);
14384
} finally {
14385
ReactServerRenderingTransaction.release(transaction);
14386
}
14387
}
14388
14389
module.exports = {
14390
renderToString: renderToString,
14391
renderToStaticMarkup: renderToStaticMarkup
14392
};
14393
14394
},{"115":115,"134":134,"135":135,"57":57,"66":66,"69":69,"85":85}],85:[function(_dereq_,module,exports){
14395
/**
14396
* Copyright 2014-2015, Facebook, Inc.
14397
* All rights reserved.
14398
*
14399
* This source code is licensed under the BSD-style license found in the
14400
* LICENSE file in the root directory of this source tree. An additional grant
14401
* of patent rights can be found in the PATENTS file in the same directory.
14402
*
14403
* @providesModule ReactServerRenderingTransaction
14404
* @typechecks
14405
*/
14406
14407
'use strict';
14408
14409
var PooledClass = _dereq_(28);
14410
var CallbackQueue = _dereq_(6);
14411
var ReactPutListenerQueue = _dereq_(79);
14412
var Transaction = _dereq_(103);
14413
14414
var assign = _dereq_(27);
14415
var emptyFunction = _dereq_(114);
14416
14417
/**
14418
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
14419
* during the performing of the transaction.
14420
*/
14421
var ON_DOM_READY_QUEUEING = {
14422
/**
14423
* Initializes the internal `onDOMReady` queue.
14424
*/
14425
initialize: function() {
14426
this.reactMountReady.reset();
14427
},
14428
14429
close: emptyFunction
14430
};
14431
14432
var PUT_LISTENER_QUEUEING = {
14433
initialize: function() {
14434
this.putListenerQueue.reset();
14435
},
14436
14437
close: emptyFunction
14438
};
14439
14440
/**
14441
* Executed within the scope of the `Transaction` instance. Consider these as
14442
* being member methods, but with an implied ordering while being isolated from
14443
* each other.
14444
*/
14445
var TRANSACTION_WRAPPERS = [
14446
PUT_LISTENER_QUEUEING,
14447
ON_DOM_READY_QUEUEING
14448
];
14449
14450
/**
14451
* @class ReactServerRenderingTransaction
14452
* @param {boolean} renderToStaticMarkup
14453
*/
14454
function ReactServerRenderingTransaction(renderToStaticMarkup) {
14455
this.reinitializeTransaction();
14456
this.renderToStaticMarkup = renderToStaticMarkup;
14457
this.reactMountReady = CallbackQueue.getPooled(null);
14458
this.putListenerQueue = ReactPutListenerQueue.getPooled();
14459
}
14460
14461
var Mixin = {
14462
/**
14463
* @see Transaction
14464
* @abstract
14465
* @final
14466
* @return {array} Empty list of operation wrap proceedures.
14467
*/
14468
getTransactionWrappers: function() {
14469
return TRANSACTION_WRAPPERS;
14470
},
14471
14472
/**
14473
* @return {object} The queue to collect `onDOMReady` callbacks with.
14474
*/
14475
getReactMountReady: function() {
14476
return this.reactMountReady;
14477
},
14478
14479
getPutListenerQueue: function() {
14480
return this.putListenerQueue;
14481
},
14482
14483
/**
14484
* `PooledClass` looks for this, and will invoke this before allowing this
14485
* instance to be resused.
14486
*/
14487
destructor: function() {
14488
CallbackQueue.release(this.reactMountReady);
14489
this.reactMountReady = null;
14490
14491
ReactPutListenerQueue.release(this.putListenerQueue);
14492
this.putListenerQueue = null;
14493
}
14494
};
14495
14496
14497
assign(
14498
ReactServerRenderingTransaction.prototype,
14499
Transaction.Mixin,
14500
Mixin
14501
);
14502
14503
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
14504
14505
module.exports = ReactServerRenderingTransaction;
14506
14507
},{"103":103,"114":114,"27":27,"28":28,"6":6,"79":79}],86:[function(_dereq_,module,exports){
14508
/**
14509
* Copyright 2015, Facebook, Inc.
14510
* All rights reserved.
14511
*
14512
* This source code is licensed under the BSD-style license found in the
14513
* LICENSE file in the root directory of this source tree. An additional grant
14514
* of patent rights can be found in the PATENTS file in the same directory.
14515
*
14516
* @providesModule ReactUpdateQueue
14517
*/
14518
14519
'use strict';
14520
14521
var ReactLifeCycle = _dereq_(68);
14522
var ReactCurrentOwner = _dereq_(39);
14523
var ReactElement = _dereq_(57);
14524
var ReactInstanceMap = _dereq_(67);
14525
var ReactUpdates = _dereq_(87);
14526
14527
var assign = _dereq_(27);
14528
var invariant = _dereq_(135);
14529
var warning = _dereq_(154);
14530
14531
function enqueueUpdate(internalInstance) {
14532
if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
14533
// If we're in a componentWillMount handler, don't enqueue a rerender
14534
// because ReactUpdates assumes we're in a browser context (which is
14535
// wrong for server rendering) and we're about to do a render anyway.
14536
// See bug in #1740.
14537
ReactUpdates.enqueueUpdate(internalInstance);
14538
}
14539
}
14540
14541
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
14542
("production" !== "development" ? invariant(
14543
ReactCurrentOwner.current == null,
14544
'%s(...): Cannot update during an existing state transition ' +
14545
'(such as within `render`). Render methods should be a pure function ' +
14546
'of props and state.',
14547
callerName
14548
) : invariant(ReactCurrentOwner.current == null));
14549
14550
var internalInstance = ReactInstanceMap.get(publicInstance);
14551
if (!internalInstance) {
14552
if ("production" !== "development") {
14553
// Only warn when we have a callerName. Otherwise we should be silent.
14554
// We're probably calling from enqueueCallback. We don't want to warn
14555
// there because we already warned for the corresponding lifecycle method.
14556
("production" !== "development" ? warning(
14557
!callerName,
14558
'%s(...): Can only update a mounted or mounting component. ' +
14559
'This usually means you called %s() on an unmounted ' +
14560
'component. This is a no-op.',
14561
callerName,
14562
callerName
14563
) : null);
14564
}
14565
return null;
14566
}
14567
14568
if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
14569
return null;
14570
}
14571
14572
return internalInstance;
14573
}
14574
14575
/**
14576
* ReactUpdateQueue allows for state updates to be scheduled into a later
14577
* reconciliation step.
14578
*/
14579
var ReactUpdateQueue = {
14580
14581
/**
14582
* Enqueue a callback that will be executed after all the pending updates
14583
* have processed.
14584
*
14585
* @param {ReactClass} publicInstance The instance to use as `this` context.
14586
* @param {?function} callback Called after state is updated.
14587
* @internal
14588
*/
14589
enqueueCallback: function(publicInstance, callback) {
14590
("production" !== "development" ? invariant(
14591
typeof callback === 'function',
14592
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
14593
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
14594
'isn\'t callable.'
14595
) : invariant(typeof callback === 'function'));
14596
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
14597
14598
// Previously we would throw an error if we didn't have an internal
14599
// instance. Since we want to make it a no-op instead, we mirror the same
14600
// behavior we have in other enqueue* methods.
14601
// We also need to ignore callbacks in componentWillMount. See
14602
// enqueueUpdates.
14603
if (!internalInstance ||
14604
internalInstance === ReactLifeCycle.currentlyMountingInstance) {
14605
return null;
14606
}
14607
14608
if (internalInstance._pendingCallbacks) {
14609
internalInstance._pendingCallbacks.push(callback);
14610
} else {
14611
internalInstance._pendingCallbacks = [callback];
14612
}
14613
// TODO: The callback here is ignored when setState is called from
14614
// componentWillMount. Either fix it or disallow doing so completely in
14615
// favor of getInitialState. Alternatively, we can disallow
14616
// componentWillMount during server-side rendering.
14617
enqueueUpdate(internalInstance);
14618
},
14619
14620
enqueueCallbackInternal: function(internalInstance, callback) {
14621
("production" !== "development" ? invariant(
14622
typeof callback === 'function',
14623
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
14624
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
14625
'isn\'t callable.'
14626
) : invariant(typeof callback === 'function'));
14627
if (internalInstance._pendingCallbacks) {
14628
internalInstance._pendingCallbacks.push(callback);
14629
} else {
14630
internalInstance._pendingCallbacks = [callback];
14631
}
14632
enqueueUpdate(internalInstance);
14633
},
14634
14635
/**
14636
* Forces an update. This should only be invoked when it is known with
14637
* certainty that we are **not** in a DOM transaction.
14638
*
14639
* You may want to call this when you know that some deeper aspect of the
14640
* component's state has changed but `setState` was not called.
14641
*
14642
* This will not invoke `shouldUpdateComponent`, but it will invoke
14643
* `componentWillUpdate` and `componentDidUpdate`.
14644
*
14645
* @param {ReactClass} publicInstance The instance that should rerender.
14646
* @internal
14647
*/
14648
enqueueForceUpdate: function(publicInstance) {
14649
var internalInstance = getInternalInstanceReadyForUpdate(
14650
publicInstance,
14651
'forceUpdate'
14652
);
14653
14654
if (!internalInstance) {
14655
return;
14656
}
14657
14658
internalInstance._pendingForceUpdate = true;
14659
14660
enqueueUpdate(internalInstance);
14661
},
14662
14663
/**
14664
* Replaces all of the state. Always use this or `setState` to mutate state.
14665
* You should treat `this.state` as immutable.
14666
*
14667
* There is no guarantee that `this.state` will be immediately updated, so
14668
* accessing `this.state` after calling this method may return the old value.
14669
*
14670
* @param {ReactClass} publicInstance The instance that should rerender.
14671
* @param {object} completeState Next state.
14672
* @internal
14673
*/
14674
enqueueReplaceState: function(publicInstance, completeState) {
14675
var internalInstance = getInternalInstanceReadyForUpdate(
14676
publicInstance,
14677
'replaceState'
14678
);
14679
14680
if (!internalInstance) {
14681
return;
14682
}
14683
14684
internalInstance._pendingStateQueue = [completeState];
14685
internalInstance._pendingReplaceState = true;
14686
14687
enqueueUpdate(internalInstance);
14688
},
14689
14690
/**
14691
* Sets a subset of the state. This only exists because _pendingState is
14692
* internal. This provides a merging strategy that is not available to deep
14693
* properties which is confusing. TODO: Expose pendingState or don't use it
14694
* during the merge.
14695
*
14696
* @param {ReactClass} publicInstance The instance that should rerender.
14697
* @param {object} partialState Next partial state to be merged with state.
14698
* @internal
14699
*/
14700
enqueueSetState: function(publicInstance, partialState) {
14701
var internalInstance = getInternalInstanceReadyForUpdate(
14702
publicInstance,
14703
'setState'
14704
);
14705
14706
if (!internalInstance) {
14707
return;
14708
}
14709
14710
var queue =
14711
internalInstance._pendingStateQueue ||
14712
(internalInstance._pendingStateQueue = []);
14713
queue.push(partialState);
14714
14715
enqueueUpdate(internalInstance);
14716
},
14717
14718
/**
14719
* Sets a subset of the props.
14720
*
14721
* @param {ReactClass} publicInstance The instance that should rerender.
14722
* @param {object} partialProps Subset of the next props.
14723
* @internal
14724
*/
14725
enqueueSetProps: function(publicInstance, partialProps) {
14726
var internalInstance = getInternalInstanceReadyForUpdate(
14727
publicInstance,
14728
'setProps'
14729
);
14730
14731
if (!internalInstance) {
14732
return;
14733
}
14734
14735
("production" !== "development" ? invariant(
14736
internalInstance._isTopLevel,
14737
'setProps(...): You called `setProps` on a ' +
14738
'component with a parent. This is an anti-pattern since props will ' +
14739
'get reactively updated when rendered. Instead, change the owner\'s ' +
14740
'`render` method to pass the correct value as props to the component ' +
14741
'where it is created.'
14742
) : invariant(internalInstance._isTopLevel));
14743
14744
// Merge with the pending element if it exists, otherwise with existing
14745
// element props.
14746
var element = internalInstance._pendingElement ||
14747
internalInstance._currentElement;
14748
var props = assign({}, element.props, partialProps);
14749
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
14750
element,
14751
props
14752
);
14753
14754
enqueueUpdate(internalInstance);
14755
},
14756
14757
/**
14758
* Replaces all of the props.
14759
*
14760
* @param {ReactClass} publicInstance The instance that should rerender.
14761
* @param {object} props New props.
14762
* @internal
14763
*/
14764
enqueueReplaceProps: function(publicInstance, props) {
14765
var internalInstance = getInternalInstanceReadyForUpdate(
14766
publicInstance,
14767
'replaceProps'
14768
);
14769
14770
if (!internalInstance) {
14771
return;
14772
}
14773
14774
("production" !== "development" ? invariant(
14775
internalInstance._isTopLevel,
14776
'replaceProps(...): You called `replaceProps` on a ' +
14777
'component with a parent. This is an anti-pattern since props will ' +
14778
'get reactively updated when rendered. Instead, change the owner\'s ' +
14779
'`render` method to pass the correct value as props to the component ' +
14780
'where it is created.'
14781
) : invariant(internalInstance._isTopLevel));
14782
14783
// Merge with the pending element if it exists, otherwise with existing
14784
// element props.
14785
var element = internalInstance._pendingElement ||
14786
internalInstance._currentElement;
14787
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
14788
element,
14789
props
14790
);
14791
14792
enqueueUpdate(internalInstance);
14793
},
14794
14795
enqueueElementInternal: function(internalInstance, newElement) {
14796
internalInstance._pendingElement = newElement;
14797
enqueueUpdate(internalInstance);
14798
}
14799
14800
};
14801
14802
module.exports = ReactUpdateQueue;
14803
14804
},{"135":135,"154":154,"27":27,"39":39,"57":57,"67":67,"68":68,"87":87}],87:[function(_dereq_,module,exports){
14805
/**
14806
* Copyright 2013-2015, Facebook, Inc.
14807
* All rights reserved.
14808
*
14809
* This source code is licensed under the BSD-style license found in the
14810
* LICENSE file in the root directory of this source tree. An additional grant
14811
* of patent rights can be found in the PATENTS file in the same directory.
14812
*
14813
* @providesModule ReactUpdates
14814
*/
14815
14816
'use strict';
14817
14818
var CallbackQueue = _dereq_(6);
14819
var PooledClass = _dereq_(28);
14820
var ReactCurrentOwner = _dereq_(39);
14821
var ReactPerf = _dereq_(75);
14822
var ReactReconciler = _dereq_(81);
14823
var Transaction = _dereq_(103);
14824
14825
var assign = _dereq_(27);
14826
var invariant = _dereq_(135);
14827
var warning = _dereq_(154);
14828
14829
var dirtyComponents = [];
14830
var asapCallbackQueue = CallbackQueue.getPooled();
14831
var asapEnqueued = false;
14832
14833
var batchingStrategy = null;
14834
14835
function ensureInjected() {
14836
("production" !== "development" ? invariant(
14837
ReactUpdates.ReactReconcileTransaction && batchingStrategy,
14838
'ReactUpdates: must inject a reconcile transaction class and batching ' +
14839
'strategy'
14840
) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
14841
}
14842
14843
var NESTED_UPDATES = {
14844
initialize: function() {
14845
this.dirtyComponentsLength = dirtyComponents.length;
14846
},
14847
close: function() {
14848
if (this.dirtyComponentsLength !== dirtyComponents.length) {
14849
// Additional updates were enqueued by componentDidUpdate handlers or
14850
// similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
14851
// these new updates so that if A's componentDidUpdate calls setState on
14852
// B, B will update before the callback A's updater provided when calling
14853
// setState.
14854
dirtyComponents.splice(0, this.dirtyComponentsLength);
14855
flushBatchedUpdates();
14856
} else {
14857
dirtyComponents.length = 0;
14858
}
14859
}
14860
};
14861
14862
var UPDATE_QUEUEING = {
14863
initialize: function() {
14864
this.callbackQueue.reset();
14865
},
14866
close: function() {
14867
this.callbackQueue.notifyAll();
14868
}
14869
};
14870
14871
var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
14872
14873
function ReactUpdatesFlushTransaction() {
14874
this.reinitializeTransaction();
14875
this.dirtyComponentsLength = null;
14876
this.callbackQueue = CallbackQueue.getPooled();
14877
this.reconcileTransaction =
14878
ReactUpdates.ReactReconcileTransaction.getPooled();
14879
}
14880
14881
assign(
14882
ReactUpdatesFlushTransaction.prototype,
14883
Transaction.Mixin, {
14884
getTransactionWrappers: function() {
14885
return TRANSACTION_WRAPPERS;
14886
},
14887
14888
destructor: function() {
14889
this.dirtyComponentsLength = null;
14890
CallbackQueue.release(this.callbackQueue);
14891
this.callbackQueue = null;
14892
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
14893
this.reconcileTransaction = null;
14894
},
14895
14896
perform: function(method, scope, a) {
14897
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
14898
// with this transaction's wrappers around it.
14899
return Transaction.Mixin.perform.call(
14900
this,
14901
this.reconcileTransaction.perform,
14902
this.reconcileTransaction,
14903
method,
14904
scope,
14905
a
14906
);
14907
}
14908
});
14909
14910
PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
14911
14912
function batchedUpdates(callback, a, b, c, d) {
14913
ensureInjected();
14914
batchingStrategy.batchedUpdates(callback, a, b, c, d);
14915
}
14916
14917
/**
14918
* Array comparator for ReactComponents by mount ordering.
14919
*
14920
* @param {ReactComponent} c1 first component you're comparing
14921
* @param {ReactComponent} c2 second component you're comparing
14922
* @return {number} Return value usable by Array.prototype.sort().
14923
*/
14924
function mountOrderComparator(c1, c2) {
14925
return c1._mountOrder - c2._mountOrder;
14926
}
14927
14928
function runBatchedUpdates(transaction) {
14929
var len = transaction.dirtyComponentsLength;
14930
("production" !== "development" ? invariant(
14931
len === dirtyComponents.length,
14932
'Expected flush transaction\'s stored dirty-components length (%s) to ' +
14933
'match dirty-components array length (%s).',
14934
len,
14935
dirtyComponents.length
14936
) : invariant(len === dirtyComponents.length));
14937
14938
// Since reconciling a component higher in the owner hierarchy usually (not
14939
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
14940
// them before their children by sorting the array.
14941
dirtyComponents.sort(mountOrderComparator);
14942
14943
for (var i = 0; i < len; i++) {
14944
// If a component is unmounted before pending changes apply, it will still
14945
// be here, but we assume that it has cleared its _pendingCallbacks and
14946
// that performUpdateIfNecessary is a noop.
14947
var component = dirtyComponents[i];
14948
14949
// If performUpdateIfNecessary happens to enqueue any new updates, we
14950
// shouldn't execute the callbacks until the next render happens, so
14951
// stash the callbacks first
14952
var callbacks = component._pendingCallbacks;
14953
component._pendingCallbacks = null;
14954
14955
ReactReconciler.performUpdateIfNecessary(
14956
component,
14957
transaction.reconcileTransaction
14958
);
14959
14960
if (callbacks) {
14961
for (var j = 0; j < callbacks.length; j++) {
14962
transaction.callbackQueue.enqueue(
14963
callbacks[j],
14964
component.getPublicInstance()
14965
);
14966
}
14967
}
14968
}
14969
}
14970
14971
var flushBatchedUpdates = function() {
14972
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
14973
// array and perform any updates enqueued by mount-ready handlers (i.e.,
14974
// componentDidUpdate) but we need to check here too in order to catch
14975
// updates enqueued by setState callbacks and asap calls.
14976
while (dirtyComponents.length || asapEnqueued) {
14977
if (dirtyComponents.length) {
14978
var transaction = ReactUpdatesFlushTransaction.getPooled();
14979
transaction.perform(runBatchedUpdates, null, transaction);
14980
ReactUpdatesFlushTransaction.release(transaction);
14981
}
14982
14983
if (asapEnqueued) {
14984
asapEnqueued = false;
14985
var queue = asapCallbackQueue;
14986
asapCallbackQueue = CallbackQueue.getPooled();
14987
queue.notifyAll();
14988
CallbackQueue.release(queue);
14989
}
14990
}
14991
};
14992
flushBatchedUpdates = ReactPerf.measure(
14993
'ReactUpdates',
14994
'flushBatchedUpdates',
14995
flushBatchedUpdates
14996
);
14997
14998
/**
14999
* Mark a component as needing a rerender, adding an optional callback to a
15000
* list of functions which will be executed once the rerender occurs.
15001
*/
15002
function enqueueUpdate(component) {
15003
ensureInjected();
15004
15005
// Various parts of our code (such as ReactCompositeComponent's
15006
// _renderValidatedComponent) assume that calls to render aren't nested;
15007
// verify that that's the case. (This is called by each top-level update
15008
// function, like setProps, setState, forceUpdate, etc.; creation and
15009
// destruction of top-level components is guarded in ReactMount.)
15010
("production" !== "development" ? warning(
15011
ReactCurrentOwner.current == null,
15012
'enqueueUpdate(): Render methods should be a pure function of props ' +
15013
'and state; triggering nested component updates from render is not ' +
15014
'allowed. If necessary, trigger nested updates in ' +
15015
'componentDidUpdate.'
15016
) : null);
15017
15018
if (!batchingStrategy.isBatchingUpdates) {
15019
batchingStrategy.batchedUpdates(enqueueUpdate, component);
15020
return;
15021
}
15022
15023
dirtyComponents.push(component);
15024
}
15025
15026
/**
15027
* Enqueue a callback to be run at the end of the current batching cycle. Throws
15028
* if no updates are currently being performed.
15029
*/
15030
function asap(callback, context) {
15031
("production" !== "development" ? invariant(
15032
batchingStrategy.isBatchingUpdates,
15033
'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
15034
'updates are not being batched.'
15035
) : invariant(batchingStrategy.isBatchingUpdates));
15036
asapCallbackQueue.enqueue(callback, context);
15037
asapEnqueued = true;
15038
}
15039
15040
var ReactUpdatesInjection = {
15041
injectReconcileTransaction: function(ReconcileTransaction) {
15042
("production" !== "development" ? invariant(
15043
ReconcileTransaction,
15044
'ReactUpdates: must provide a reconcile transaction class'
15045
) : invariant(ReconcileTransaction));
15046
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
15047
},
15048
15049
injectBatchingStrategy: function(_batchingStrategy) {
15050
("production" !== "development" ? invariant(
15051
_batchingStrategy,
15052
'ReactUpdates: must provide a batching strategy'
15053
) : invariant(_batchingStrategy));
15054
("production" !== "development" ? invariant(
15055
typeof _batchingStrategy.batchedUpdates === 'function',
15056
'ReactUpdates: must provide a batchedUpdates() function'
15057
) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
15058
("production" !== "development" ? invariant(
15059
typeof _batchingStrategy.isBatchingUpdates === 'boolean',
15060
'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
15061
) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
15062
batchingStrategy = _batchingStrategy;
15063
}
15064
};
15065
15066
var ReactUpdates = {
15067
/**
15068
* React references `ReactReconcileTransaction` using this property in order
15069
* to allow dependency injection.
15070
*
15071
* @internal
15072
*/
15073
ReactReconcileTransaction: null,
15074
15075
batchedUpdates: batchedUpdates,
15076
enqueueUpdate: enqueueUpdate,
15077
flushBatchedUpdates: flushBatchedUpdates,
15078
injection: ReactUpdatesInjection,
15079
asap: asap
15080
};
15081
15082
module.exports = ReactUpdates;
15083
15084
},{"103":103,"135":135,"154":154,"27":27,"28":28,"39":39,"6":6,"75":75,"81":81}],88:[function(_dereq_,module,exports){
15085
/**
15086
* Copyright 2013-2015, Facebook, Inc.
15087
* All rights reserved.
15088
*
15089
* This source code is licensed under the BSD-style license found in the
15090
* LICENSE file in the root directory of this source tree. An additional grant
15091
* of patent rights can be found in the PATENTS file in the same directory.
15092
*
15093
* @providesModule SVGDOMPropertyConfig
15094
*/
15095
15096
/*jslint bitwise: true*/
15097
15098
'use strict';
15099
15100
var DOMProperty = _dereq_(10);
15101
15102
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
15103
15104
var SVGDOMPropertyConfig = {
15105
Properties: {
15106
clipPath: MUST_USE_ATTRIBUTE,
15107
cx: MUST_USE_ATTRIBUTE,
15108
cy: MUST_USE_ATTRIBUTE,
15109
d: MUST_USE_ATTRIBUTE,
15110
dx: MUST_USE_ATTRIBUTE,
15111
dy: MUST_USE_ATTRIBUTE,
15112
fill: MUST_USE_ATTRIBUTE,
15113
fillOpacity: MUST_USE_ATTRIBUTE,
15114
fontFamily: MUST_USE_ATTRIBUTE,
15115
fontSize: MUST_USE_ATTRIBUTE,
15116
fx: MUST_USE_ATTRIBUTE,
15117
fy: MUST_USE_ATTRIBUTE,
15118
gradientTransform: MUST_USE_ATTRIBUTE,
15119
gradientUnits: MUST_USE_ATTRIBUTE,
15120
markerEnd: MUST_USE_ATTRIBUTE,
15121
markerMid: MUST_USE_ATTRIBUTE,
15122
markerStart: MUST_USE_ATTRIBUTE,
15123
offset: MUST_USE_ATTRIBUTE,
15124
opacity: MUST_USE_ATTRIBUTE,
15125
patternContentUnits: MUST_USE_ATTRIBUTE,
15126
patternUnits: MUST_USE_ATTRIBUTE,
15127
points: MUST_USE_ATTRIBUTE,
15128
preserveAspectRatio: MUST_USE_ATTRIBUTE,
15129
r: MUST_USE_ATTRIBUTE,
15130
rx: MUST_USE_ATTRIBUTE,
15131
ry: MUST_USE_ATTRIBUTE,
15132
spreadMethod: MUST_USE_ATTRIBUTE,
15133
stopColor: MUST_USE_ATTRIBUTE,
15134
stopOpacity: MUST_USE_ATTRIBUTE,
15135
stroke: MUST_USE_ATTRIBUTE,
15136
strokeDasharray: MUST_USE_ATTRIBUTE,
15137
strokeLinecap: MUST_USE_ATTRIBUTE,
15138
strokeOpacity: MUST_USE_ATTRIBUTE,
15139
strokeWidth: MUST_USE_ATTRIBUTE,
15140
textAnchor: MUST_USE_ATTRIBUTE,
15141
transform: MUST_USE_ATTRIBUTE,
15142
version: MUST_USE_ATTRIBUTE,
15143
viewBox: MUST_USE_ATTRIBUTE,
15144
x1: MUST_USE_ATTRIBUTE,
15145
x2: MUST_USE_ATTRIBUTE,
15146
x: MUST_USE_ATTRIBUTE,
15147
y1: MUST_USE_ATTRIBUTE,
15148
y2: MUST_USE_ATTRIBUTE,
15149
y: MUST_USE_ATTRIBUTE
15150
},
15151
DOMAttributeNames: {
15152
clipPath: 'clip-path',
15153
fillOpacity: 'fill-opacity',
15154
fontFamily: 'font-family',
15155
fontSize: 'font-size',
15156
gradientTransform: 'gradientTransform',
15157
gradientUnits: 'gradientUnits',
15158
markerEnd: 'marker-end',
15159
markerMid: 'marker-mid',
15160
markerStart: 'marker-start',
15161
patternContentUnits: 'patternContentUnits',
15162
patternUnits: 'patternUnits',
15163
preserveAspectRatio: 'preserveAspectRatio',
15164
spreadMethod: 'spreadMethod',
15165
stopColor: 'stop-color',
15166
stopOpacity: 'stop-opacity',
15167
strokeDasharray: 'stroke-dasharray',
15168
strokeLinecap: 'stroke-linecap',
15169
strokeOpacity: 'stroke-opacity',
15170
strokeWidth: 'stroke-width',
15171
textAnchor: 'text-anchor',
15172
viewBox: 'viewBox'
15173
}
15174
};
15175
15176
module.exports = SVGDOMPropertyConfig;
15177
15178
},{"10":10}],89:[function(_dereq_,module,exports){
15179
/**
15180
* Copyright 2013-2015, Facebook, Inc.
15181
* All rights reserved.
15182
*
15183
* This source code is licensed under the BSD-style license found in the
15184
* LICENSE file in the root directory of this source tree. An additional grant
15185
* of patent rights can be found in the PATENTS file in the same directory.
15186
*
15187
* @providesModule SelectEventPlugin
15188
*/
15189
15190
'use strict';
15191
15192
var EventConstants = _dereq_(15);
15193
var EventPropagators = _dereq_(20);
15194
var ReactInputSelection = _dereq_(65);
15195
var SyntheticEvent = _dereq_(95);
15196
15197
var getActiveElement = _dereq_(121);
15198
var isTextInputElement = _dereq_(138);
15199
var keyOf = _dereq_(141);
15200
var shallowEqual = _dereq_(150);
15201
15202
var topLevelTypes = EventConstants.topLevelTypes;
15203
15204
var eventTypes = {
15205
select: {
15206
phasedRegistrationNames: {
15207
bubbled: keyOf({onSelect: null}),
15208
captured: keyOf({onSelectCapture: null})
15209
},
15210
dependencies: [
15211
topLevelTypes.topBlur,
15212
topLevelTypes.topContextMenu,
15213
topLevelTypes.topFocus,
15214
topLevelTypes.topKeyDown,
15215
topLevelTypes.topMouseDown,
15216
topLevelTypes.topMouseUp,
15217
topLevelTypes.topSelectionChange
15218
]
15219
}
15220
};
15221
15222
var activeElement = null;
15223
var activeElementID = null;
15224
var lastSelection = null;
15225
var mouseDown = false;
15226
15227
/**
15228
* Get an object which is a unique representation of the current selection.
15229
*
15230
* The return value will not be consistent across nodes or browsers, but
15231
* two identical selections on the same node will return identical objects.
15232
*
15233
* @param {DOMElement} node
15234
* @param {object}
15235
*/
15236
function getSelection(node) {
15237
if ('selectionStart' in node &&
15238
ReactInputSelection.hasSelectionCapabilities(node)) {
15239
return {
15240
start: node.selectionStart,
15241
end: node.selectionEnd
15242
};
15243
} else if (window.getSelection) {
15244
var selection = window.getSelection();
15245
return {
15246
anchorNode: selection.anchorNode,
15247
anchorOffset: selection.anchorOffset,
15248
focusNode: selection.focusNode,
15249
focusOffset: selection.focusOffset
15250
};
15251
} else if (document.selection) {
15252
var range = document.selection.createRange();
15253
return {
15254
parentElement: range.parentElement(),
15255
text: range.text,
15256
top: range.boundingTop,
15257
left: range.boundingLeft
15258
};
15259
}
15260
}
15261
15262
/**
15263
* Poll selection to see whether it's changed.
15264
*
15265
* @param {object} nativeEvent
15266
* @return {?SyntheticEvent}
15267
*/
15268
function constructSelectEvent(nativeEvent) {
15269
// Ensure we have the right element, and that the user is not dragging a
15270
// selection (this matches native `select` event behavior). In HTML5, select
15271
// fires only on input and textarea thus if there's no focused element we
15272
// won't dispatch.
15273
if (mouseDown ||
15274
activeElement == null ||
15275
activeElement !== getActiveElement()) {
15276
return null;
15277
}
15278
15279
// Only fire when selection has actually changed.
15280
var currentSelection = getSelection(activeElement);
15281
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
15282
lastSelection = currentSelection;
15283
15284
var syntheticEvent = SyntheticEvent.getPooled(
15285
eventTypes.select,
15286
activeElementID,
15287
nativeEvent
15288
);
15289
15290
syntheticEvent.type = 'select';
15291
syntheticEvent.target = activeElement;
15292
15293
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
15294
15295
return syntheticEvent;
15296
}
15297
}
15298
15299
/**
15300
* This plugin creates an `onSelect` event that normalizes select events
15301
* across form elements.
15302
*
15303
* Supported elements are:
15304
* - input (see `isTextInputElement`)
15305
* - textarea
15306
* - contentEditable
15307
*
15308
* This differs from native browser implementations in the following ways:
15309
* - Fires on contentEditable fields as well as inputs.
15310
* - Fires for collapsed selection.
15311
* - Fires after user input.
15312
*/
15313
var SelectEventPlugin = {
15314
15315
eventTypes: eventTypes,
15316
15317
/**
15318
* @param {string} topLevelType Record from `EventConstants`.
15319
* @param {DOMEventTarget} topLevelTarget The listening component root node.
15320
* @param {string} topLevelTargetID ID of `topLevelTarget`.
15321
* @param {object} nativeEvent Native browser event.
15322
* @return {*} An accumulation of synthetic events.
15323
* @see {EventPluginHub.extractEvents}
15324
*/
15325
extractEvents: function(
15326
topLevelType,
15327
topLevelTarget,
15328
topLevelTargetID,
15329
nativeEvent) {
15330
15331
switch (topLevelType) {
15332
// Track the input node that has focus.
15333
case topLevelTypes.topFocus:
15334
if (isTextInputElement(topLevelTarget) ||
15335
topLevelTarget.contentEditable === 'true') {
15336
activeElement = topLevelTarget;
15337
activeElementID = topLevelTargetID;
15338
lastSelection = null;
15339
}
15340
break;
15341
case topLevelTypes.topBlur:
15342
activeElement = null;
15343
activeElementID = null;
15344
lastSelection = null;
15345
break;
15346
15347
// Don't fire the event while the user is dragging. This matches the
15348
// semantics of the native select event.
15349
case topLevelTypes.topMouseDown:
15350
mouseDown = true;
15351
break;
15352
case topLevelTypes.topContextMenu:
15353
case topLevelTypes.topMouseUp:
15354
mouseDown = false;
15355
return constructSelectEvent(nativeEvent);
15356
15357
// Chrome and IE fire non-standard event when selection is changed (and
15358
// sometimes when it hasn't).
15359
// Firefox doesn't support selectionchange, so check selection status
15360
// after each key entry. The selection changes after keydown and before
15361
// keyup, but we check on keydown as well in the case of holding down a
15362
// key, when multiple keydown events are fired but only one keyup is.
15363
case topLevelTypes.topSelectionChange:
15364
case topLevelTypes.topKeyDown:
15365
case topLevelTypes.topKeyUp:
15366
return constructSelectEvent(nativeEvent);
15367
}
15368
}
15369
};
15370
15371
module.exports = SelectEventPlugin;
15372
15373
},{"121":121,"138":138,"141":141,"15":15,"150":150,"20":20,"65":65,"95":95}],90:[function(_dereq_,module,exports){
15374
/**
15375
* Copyright 2013-2015, Facebook, Inc.
15376
* All rights reserved.
15377
*
15378
* This source code is licensed under the BSD-style license found in the
15379
* LICENSE file in the root directory of this source tree. An additional grant
15380
* of patent rights can be found in the PATENTS file in the same directory.
15381
*
15382
* @providesModule ServerReactRootIndex
15383
* @typechecks
15384
*/
15385
15386
'use strict';
15387
15388
/**
15389
* Size of the reactRoot ID space. We generate random numbers for React root
15390
* IDs and if there's a collision the events and DOM update system will
15391
* get confused. In the future we need a way to generate GUIDs but for
15392
* now this will work on a smaller scale.
15393
*/
15394
var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
15395
15396
var ServerReactRootIndex = {
15397
createReactRootIndex: function() {
15398
return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
15399
}
15400
};
15401
15402
module.exports = ServerReactRootIndex;
15403
15404
},{}],91:[function(_dereq_,module,exports){
15405
/**
15406
* Copyright 2013-2015, Facebook, Inc.
15407
* All rights reserved.
15408
*
15409
* This source code is licensed under the BSD-style license found in the
15410
* LICENSE file in the root directory of this source tree. An additional grant
15411
* of patent rights can be found in the PATENTS file in the same directory.
15412
*
15413
* @providesModule SimpleEventPlugin
15414
*/
15415
15416
'use strict';
15417
15418
var EventConstants = _dereq_(15);
15419
var EventPluginUtils = _dereq_(19);
15420
var EventPropagators = _dereq_(20);
15421
var SyntheticClipboardEvent = _dereq_(92);
15422
var SyntheticEvent = _dereq_(95);
15423
var SyntheticFocusEvent = _dereq_(96);
15424
var SyntheticKeyboardEvent = _dereq_(98);
15425
var SyntheticMouseEvent = _dereq_(99);
15426
var SyntheticDragEvent = _dereq_(94);
15427
var SyntheticTouchEvent = _dereq_(100);
15428
var SyntheticUIEvent = _dereq_(101);
15429
var SyntheticWheelEvent = _dereq_(102);
15430
15431
var getEventCharCode = _dereq_(122);
15432
15433
var invariant = _dereq_(135);
15434
var keyOf = _dereq_(141);
15435
var warning = _dereq_(154);
15436
15437
var topLevelTypes = EventConstants.topLevelTypes;
15438
15439
var eventTypes = {
15440
blur: {
15441
phasedRegistrationNames: {
15442
bubbled: keyOf({onBlur: true}),
15443
captured: keyOf({onBlurCapture: true})
15444
}
15445
},
15446
click: {
15447
phasedRegistrationNames: {
15448
bubbled: keyOf({onClick: true}),
15449
captured: keyOf({onClickCapture: true})
15450
}
15451
},
15452
contextMenu: {
15453
phasedRegistrationNames: {
15454
bubbled: keyOf({onContextMenu: true}),
15455
captured: keyOf({onContextMenuCapture: true})
15456
}
15457
},
15458
copy: {
15459
phasedRegistrationNames: {
15460
bubbled: keyOf({onCopy: true}),
15461
captured: keyOf({onCopyCapture: true})
15462
}
15463
},
15464
cut: {
15465
phasedRegistrationNames: {
15466
bubbled: keyOf({onCut: true}),
15467
captured: keyOf({onCutCapture: true})
15468
}
15469
},
15470
doubleClick: {
15471
phasedRegistrationNames: {
15472
bubbled: keyOf({onDoubleClick: true}),
15473
captured: keyOf({onDoubleClickCapture: true})
15474
}
15475
},
15476
drag: {
15477
phasedRegistrationNames: {
15478
bubbled: keyOf({onDrag: true}),
15479
captured: keyOf({onDragCapture: true})
15480
}
15481
},
15482
dragEnd: {
15483
phasedRegistrationNames: {
15484
bubbled: keyOf({onDragEnd: true}),
15485
captured: keyOf({onDragEndCapture: true})
15486
}
15487
},
15488
dragEnter: {
15489
phasedRegistrationNames: {
15490
bubbled: keyOf({onDragEnter: true}),
15491
captured: keyOf({onDragEnterCapture: true})
15492
}
15493
},
15494
dragExit: {
15495
phasedRegistrationNames: {
15496
bubbled: keyOf({onDragExit: true}),
15497
captured: keyOf({onDragExitCapture: true})
15498
}
15499
},
15500
dragLeave: {
15501
phasedRegistrationNames: {
15502
bubbled: keyOf({onDragLeave: true}),
15503
captured: keyOf({onDragLeaveCapture: true})
15504
}
15505
},
15506
dragOver: {
15507
phasedRegistrationNames: {
15508
bubbled: keyOf({onDragOver: true}),
15509
captured: keyOf({onDragOverCapture: true})
15510
}
15511
},
15512
dragStart: {
15513
phasedRegistrationNames: {
15514
bubbled: keyOf({onDragStart: true}),
15515
captured: keyOf({onDragStartCapture: true})
15516
}
15517
},
15518
drop: {
15519
phasedRegistrationNames: {
15520
bubbled: keyOf({onDrop: true}),
15521
captured: keyOf({onDropCapture: true})
15522
}
15523
},
15524
focus: {
15525
phasedRegistrationNames: {
15526
bubbled: keyOf({onFocus: true}),
15527
captured: keyOf({onFocusCapture: true})
15528
}
15529
},
15530
input: {
15531
phasedRegistrationNames: {
15532
bubbled: keyOf({onInput: true}),
15533
captured: keyOf({onInputCapture: true})
15534
}
15535
},
15536
keyDown: {
15537
phasedRegistrationNames: {
15538
bubbled: keyOf({onKeyDown: true}),
15539
captured: keyOf({onKeyDownCapture: true})
15540
}
15541
},
15542
keyPress: {
15543
phasedRegistrationNames: {
15544
bubbled: keyOf({onKeyPress: true}),
15545
captured: keyOf({onKeyPressCapture: true})
15546
}
15547
},
15548
keyUp: {
15549
phasedRegistrationNames: {
15550
bubbled: keyOf({onKeyUp: true}),
15551
captured: keyOf({onKeyUpCapture: true})
15552
}
15553
},
15554
load: {
15555
phasedRegistrationNames: {
15556
bubbled: keyOf({onLoad: true}),
15557
captured: keyOf({onLoadCapture: true})
15558
}
15559
},
15560
error: {
15561
phasedRegistrationNames: {
15562
bubbled: keyOf({onError: true}),
15563
captured: keyOf({onErrorCapture: true})
15564
}
15565
},
15566
// Note: We do not allow listening to mouseOver events. Instead, use the
15567
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
15568
mouseDown: {
15569
phasedRegistrationNames: {
15570
bubbled: keyOf({onMouseDown: true}),
15571
captured: keyOf({onMouseDownCapture: true})
15572
}
15573
},
15574
mouseMove: {
15575
phasedRegistrationNames: {
15576
bubbled: keyOf({onMouseMove: true}),
15577
captured: keyOf({onMouseMoveCapture: true})
15578
}
15579
},
15580
mouseOut: {
15581
phasedRegistrationNames: {
15582
bubbled: keyOf({onMouseOut: true}),
15583
captured: keyOf({onMouseOutCapture: true})
15584
}
15585
},
15586
mouseOver: {
15587
phasedRegistrationNames: {
15588
bubbled: keyOf({onMouseOver: true}),
15589
captured: keyOf({onMouseOverCapture: true})
15590
}
15591
},
15592
mouseUp: {
15593
phasedRegistrationNames: {
15594
bubbled: keyOf({onMouseUp: true}),
15595
captured: keyOf({onMouseUpCapture: true})
15596
}
15597
},
15598
paste: {
15599
phasedRegistrationNames: {
15600
bubbled: keyOf({onPaste: true}),
15601
captured: keyOf({onPasteCapture: true})
15602
}
15603
},
15604
reset: {
15605
phasedRegistrationNames: {
15606
bubbled: keyOf({onReset: true}),
15607
captured: keyOf({onResetCapture: true})
15608
}
15609
},
15610
scroll: {
15611
phasedRegistrationNames: {
15612
bubbled: keyOf({onScroll: true}),
15613
captured: keyOf({onScrollCapture: true})
15614
}
15615
},
15616
submit: {
15617
phasedRegistrationNames: {
15618
bubbled: keyOf({onSubmit: true}),
15619
captured: keyOf({onSubmitCapture: true})
15620
}
15621
},
15622
touchCancel: {
15623
phasedRegistrationNames: {
15624
bubbled: keyOf({onTouchCancel: true}),
15625
captured: keyOf({onTouchCancelCapture: true})
15626
}
15627
},
15628
touchEnd: {
15629
phasedRegistrationNames: {
15630
bubbled: keyOf({onTouchEnd: true}),
15631
captured: keyOf({onTouchEndCapture: true})
15632
}
15633
},
15634
touchMove: {
15635
phasedRegistrationNames: {
15636
bubbled: keyOf({onTouchMove: true}),
15637
captured: keyOf({onTouchMoveCapture: true})
15638
}
15639
},
15640
touchStart: {
15641
phasedRegistrationNames: {
15642
bubbled: keyOf({onTouchStart: true}),
15643
captured: keyOf({onTouchStartCapture: true})
15644
}
15645
},
15646
wheel: {
15647
phasedRegistrationNames: {
15648
bubbled: keyOf({onWheel: true}),
15649
captured: keyOf({onWheelCapture: true})
15650
}
15651
}
15652
};
15653
15654
var topLevelEventsToDispatchConfig = {
15655
topBlur: eventTypes.blur,
15656
topClick: eventTypes.click,
15657
topContextMenu: eventTypes.contextMenu,
15658
topCopy: eventTypes.copy,
15659
topCut: eventTypes.cut,
15660
topDoubleClick: eventTypes.doubleClick,
15661
topDrag: eventTypes.drag,
15662
topDragEnd: eventTypes.dragEnd,
15663
topDragEnter: eventTypes.dragEnter,
15664
topDragExit: eventTypes.dragExit,
15665
topDragLeave: eventTypes.dragLeave,
15666
topDragOver: eventTypes.dragOver,
15667
topDragStart: eventTypes.dragStart,
15668
topDrop: eventTypes.drop,
15669
topError: eventTypes.error,
15670
topFocus: eventTypes.focus,
15671
topInput: eventTypes.input,
15672
topKeyDown: eventTypes.keyDown,
15673
topKeyPress: eventTypes.keyPress,
15674
topKeyUp: eventTypes.keyUp,
15675
topLoad: eventTypes.load,
15676
topMouseDown: eventTypes.mouseDown,
15677
topMouseMove: eventTypes.mouseMove,
15678
topMouseOut: eventTypes.mouseOut,
15679
topMouseOver: eventTypes.mouseOver,
15680
topMouseUp: eventTypes.mouseUp,
15681
topPaste: eventTypes.paste,
15682
topReset: eventTypes.reset,
15683
topScroll: eventTypes.scroll,
15684
topSubmit: eventTypes.submit,
15685
topTouchCancel: eventTypes.touchCancel,
15686
topTouchEnd: eventTypes.touchEnd,
15687
topTouchMove: eventTypes.touchMove,
15688
topTouchStart: eventTypes.touchStart,
15689
topWheel: eventTypes.wheel
15690
};
15691
15692
for (var type in topLevelEventsToDispatchConfig) {
15693
topLevelEventsToDispatchConfig[type].dependencies = [type];
15694
}
15695
15696
var SimpleEventPlugin = {
15697
15698
eventTypes: eventTypes,
15699
15700
/**
15701
* Same as the default implementation, except cancels the event when return
15702
* value is false. This behavior will be disabled in a future release.
15703
*
15704
* @param {object} Event to be dispatched.
15705
* @param {function} Application-level callback.
15706
* @param {string} domID DOM ID to pass to the callback.
15707
*/
15708
executeDispatch: function(event, listener, domID) {
15709
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
15710
15711
("production" !== "development" ? warning(
15712
typeof returnValue !== 'boolean',
15713
'Returning `false` from an event handler is deprecated and will be ' +
15714
'ignored in a future release. Instead, manually call ' +
15715
'e.stopPropagation() or e.preventDefault(), as appropriate.'
15716
) : null);
15717
15718
if (returnValue === false) {
15719
event.stopPropagation();
15720
event.preventDefault();
15721
}
15722
},
15723
15724
/**
15725
* @param {string} topLevelType Record from `EventConstants`.
15726
* @param {DOMEventTarget} topLevelTarget The listening component root node.
15727
* @param {string} topLevelTargetID ID of `topLevelTarget`.
15728
* @param {object} nativeEvent Native browser event.
15729
* @return {*} An accumulation of synthetic events.
15730
* @see {EventPluginHub.extractEvents}
15731
*/
15732
extractEvents: function(
15733
topLevelType,
15734
topLevelTarget,
15735
topLevelTargetID,
15736
nativeEvent) {
15737
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
15738
if (!dispatchConfig) {
15739
return null;
15740
}
15741
var EventConstructor;
15742
switch (topLevelType) {
15743
case topLevelTypes.topInput:
15744
case topLevelTypes.topLoad:
15745
case topLevelTypes.topError:
15746
case topLevelTypes.topReset:
15747
case topLevelTypes.topSubmit:
15748
// HTML Events
15749
// @see http://www.w3.org/TR/html5/index.html#events-0
15750
EventConstructor = SyntheticEvent;
15751
break;
15752
case topLevelTypes.topKeyPress:
15753
// FireFox creates a keypress event for function keys too. This removes
15754
// the unwanted keypress events. Enter is however both printable and
15755
// non-printable. One would expect Tab to be as well (but it isn't).
15756
if (getEventCharCode(nativeEvent) === 0) {
15757
return null;
15758
}
15759
/* falls through */
15760
case topLevelTypes.topKeyDown:
15761
case topLevelTypes.topKeyUp:
15762
EventConstructor = SyntheticKeyboardEvent;
15763
break;
15764
case topLevelTypes.topBlur:
15765
case topLevelTypes.topFocus:
15766
EventConstructor = SyntheticFocusEvent;
15767
break;
15768
case topLevelTypes.topClick:
15769
// Firefox creates a click event on right mouse clicks. This removes the
15770
// unwanted click events.
15771
if (nativeEvent.button === 2) {
15772
return null;
15773
}
15774
/* falls through */
15775
case topLevelTypes.topContextMenu:
15776
case topLevelTypes.topDoubleClick:
15777
case topLevelTypes.topMouseDown:
15778
case topLevelTypes.topMouseMove:
15779
case topLevelTypes.topMouseOut:
15780
case topLevelTypes.topMouseOver:
15781
case topLevelTypes.topMouseUp:
15782
EventConstructor = SyntheticMouseEvent;
15783
break;
15784
case topLevelTypes.topDrag:
15785
case topLevelTypes.topDragEnd:
15786
case topLevelTypes.topDragEnter:
15787
case topLevelTypes.topDragExit:
15788
case topLevelTypes.topDragLeave:
15789
case topLevelTypes.topDragOver:
15790
case topLevelTypes.topDragStart:
15791
case topLevelTypes.topDrop:
15792
EventConstructor = SyntheticDragEvent;
15793
break;
15794
case topLevelTypes.topTouchCancel:
15795
case topLevelTypes.topTouchEnd:
15796
case topLevelTypes.topTouchMove:
15797
case topLevelTypes.topTouchStart:
15798
EventConstructor = SyntheticTouchEvent;
15799
break;
15800
case topLevelTypes.topScroll:
15801
EventConstructor = SyntheticUIEvent;
15802
break;
15803
case topLevelTypes.topWheel:
15804
EventConstructor = SyntheticWheelEvent;
15805
break;
15806
case topLevelTypes.topCopy:
15807
case topLevelTypes.topCut:
15808
case topLevelTypes.topPaste:
15809
EventConstructor = SyntheticClipboardEvent;
15810
break;
15811
}
15812
("production" !== "development" ? invariant(
15813
EventConstructor,
15814
'SimpleEventPlugin: Unhandled event type, `%s`.',
15815
topLevelType
15816
) : invariant(EventConstructor));
15817
var event = EventConstructor.getPooled(
15818
dispatchConfig,
15819
topLevelTargetID,
15820
nativeEvent
15821
);
15822
EventPropagators.accumulateTwoPhaseDispatches(event);
15823
return event;
15824
}
15825
15826
};
15827
15828
module.exports = SimpleEventPlugin;
15829
15830
},{"100":100,"101":101,"102":102,"122":122,"135":135,"141":141,"15":15,"154":154,"19":19,"20":20,"92":92,"94":94,"95":95,"96":96,"98":98,"99":99}],92:[function(_dereq_,module,exports){
15831
/**
15832
* Copyright 2013-2015, Facebook, Inc.
15833
* All rights reserved.
15834
*
15835
* This source code is licensed under the BSD-style license found in the
15836
* LICENSE file in the root directory of this source tree. An additional grant
15837
* of patent rights can be found in the PATENTS file in the same directory.
15838
*
15839
* @providesModule SyntheticClipboardEvent
15840
* @typechecks static-only
15841
*/
15842
15843
'use strict';
15844
15845
var SyntheticEvent = _dereq_(95);
15846
15847
/**
15848
* @interface Event
15849
* @see http://www.w3.org/TR/clipboard-apis/
15850
*/
15851
var ClipboardEventInterface = {
15852
clipboardData: function(event) {
15853
return (
15854
'clipboardData' in event ?
15855
event.clipboardData :
15856
window.clipboardData
15857
);
15858
}
15859
};
15860
15861
/**
15862
* @param {object} dispatchConfig Configuration used to dispatch this event.
15863
* @param {string} dispatchMarker Marker identifying the event target.
15864
* @param {object} nativeEvent Native browser event.
15865
* @extends {SyntheticUIEvent}
15866
*/
15867
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15868
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15869
}
15870
15871
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
15872
15873
module.exports = SyntheticClipboardEvent;
15874
15875
},{"95":95}],93:[function(_dereq_,module,exports){
15876
/**
15877
* Copyright 2013-2015, Facebook, Inc.
15878
* All rights reserved.
15879
*
15880
* This source code is licensed under the BSD-style license found in the
15881
* LICENSE file in the root directory of this source tree. An additional grant
15882
* of patent rights can be found in the PATENTS file in the same directory.
15883
*
15884
* @providesModule SyntheticCompositionEvent
15885
* @typechecks static-only
15886
*/
15887
15888
'use strict';
15889
15890
var SyntheticEvent = _dereq_(95);
15891
15892
/**
15893
* @interface Event
15894
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
15895
*/
15896
var CompositionEventInterface = {
15897
data: null
15898
};
15899
15900
/**
15901
* @param {object} dispatchConfig Configuration used to dispatch this event.
15902
* @param {string} dispatchMarker Marker identifying the event target.
15903
* @param {object} nativeEvent Native browser event.
15904
* @extends {SyntheticUIEvent}
15905
*/
15906
function SyntheticCompositionEvent(
15907
dispatchConfig,
15908
dispatchMarker,
15909
nativeEvent) {
15910
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15911
}
15912
15913
SyntheticEvent.augmentClass(
15914
SyntheticCompositionEvent,
15915
CompositionEventInterface
15916
);
15917
15918
module.exports = SyntheticCompositionEvent;
15919
15920
},{"95":95}],94:[function(_dereq_,module,exports){
15921
/**
15922
* Copyright 2013-2015, Facebook, Inc.
15923
* All rights reserved.
15924
*
15925
* This source code is licensed under the BSD-style license found in the
15926
* LICENSE file in the root directory of this source tree. An additional grant
15927
* of patent rights can be found in the PATENTS file in the same directory.
15928
*
15929
* @providesModule SyntheticDragEvent
15930
* @typechecks static-only
15931
*/
15932
15933
'use strict';
15934
15935
var SyntheticMouseEvent = _dereq_(99);
15936
15937
/**
15938
* @interface DragEvent
15939
* @see http://www.w3.org/TR/DOM-Level-3-Events/
15940
*/
15941
var DragEventInterface = {
15942
dataTransfer: null
15943
};
15944
15945
/**
15946
* @param {object} dispatchConfig Configuration used to dispatch this event.
15947
* @param {string} dispatchMarker Marker identifying the event target.
15948
* @param {object} nativeEvent Native browser event.
15949
* @extends {SyntheticUIEvent}
15950
*/
15951
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
15952
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
15953
}
15954
15955
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
15956
15957
module.exports = SyntheticDragEvent;
15958
15959
},{"99":99}],95:[function(_dereq_,module,exports){
15960
/**
15961
* Copyright 2013-2015, Facebook, Inc.
15962
* All rights reserved.
15963
*
15964
* This source code is licensed under the BSD-style license found in the
15965
* LICENSE file in the root directory of this source tree. An additional grant
15966
* of patent rights can be found in the PATENTS file in the same directory.
15967
*
15968
* @providesModule SyntheticEvent
15969
* @typechecks static-only
15970
*/
15971
15972
'use strict';
15973
15974
var PooledClass = _dereq_(28);
15975
15976
var assign = _dereq_(27);
15977
var emptyFunction = _dereq_(114);
15978
var getEventTarget = _dereq_(125);
15979
15980
/**
15981
* @interface Event
15982
* @see http://www.w3.org/TR/DOM-Level-3-Events/
15983
*/
15984
var EventInterface = {
15985
type: null,
15986
target: getEventTarget,
15987
// currentTarget is set when dispatching; no use in copying it here
15988
currentTarget: emptyFunction.thatReturnsNull,
15989
eventPhase: null,
15990
bubbles: null,
15991
cancelable: null,
15992
timeStamp: function(event) {
15993
return event.timeStamp || Date.now();
15994
},
15995
defaultPrevented: null,
15996
isTrusted: null
15997
};
15998
15999
/**
16000
* Synthetic events are dispatched by event plugins, typically in response to a
16001
* top-level event delegation handler.
16002
*
16003
* These systems should generally use pooling to reduce the frequency of garbage
16004
* collection. The system should check `isPersistent` to determine whether the
16005
* event should be released into the pool after being dispatched. Users that
16006
* need a persisted event should invoke `persist`.
16007
*
16008
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
16009
* normalizing browser quirks. Subclasses do not necessarily have to implement a
16010
* DOM interface; custom application-specific events can also subclass this.
16011
*
16012
* @param {object} dispatchConfig Configuration used to dispatch this event.
16013
* @param {string} dispatchMarker Marker identifying the event target.
16014
* @param {object} nativeEvent Native browser event.
16015
*/
16016
function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16017
this.dispatchConfig = dispatchConfig;
16018
this.dispatchMarker = dispatchMarker;
16019
this.nativeEvent = nativeEvent;
16020
16021
var Interface = this.constructor.Interface;
16022
for (var propName in Interface) {
16023
if (!Interface.hasOwnProperty(propName)) {
16024
continue;
16025
}
16026
var normalize = Interface[propName];
16027
if (normalize) {
16028
this[propName] = normalize(nativeEvent);
16029
} else {
16030
this[propName] = nativeEvent[propName];
16031
}
16032
}
16033
16034
var defaultPrevented = nativeEvent.defaultPrevented != null ?
16035
nativeEvent.defaultPrevented :
16036
nativeEvent.returnValue === false;
16037
if (defaultPrevented) {
16038
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
16039
} else {
16040
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
16041
}
16042
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
16043
}
16044
16045
assign(SyntheticEvent.prototype, {
16046
16047
preventDefault: function() {
16048
this.defaultPrevented = true;
16049
var event = this.nativeEvent;
16050
if (event.preventDefault) {
16051
event.preventDefault();
16052
} else {
16053
event.returnValue = false;
16054
}
16055
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
16056
},
16057
16058
stopPropagation: function() {
16059
var event = this.nativeEvent;
16060
if (event.stopPropagation) {
16061
event.stopPropagation();
16062
} else {
16063
event.cancelBubble = true;
16064
}
16065
this.isPropagationStopped = emptyFunction.thatReturnsTrue;
16066
},
16067
16068
/**
16069
* We release all dispatched `SyntheticEvent`s after each event loop, adding
16070
* them back into the pool. This allows a way to hold onto a reference that
16071
* won't be added back into the pool.
16072
*/
16073
persist: function() {
16074
this.isPersistent = emptyFunction.thatReturnsTrue;
16075
},
16076
16077
/**
16078
* Checks if this event should be released back into the pool.
16079
*
16080
* @return {boolean} True if this should not be released, false otherwise.
16081
*/
16082
isPersistent: emptyFunction.thatReturnsFalse,
16083
16084
/**
16085
* `PooledClass` looks for `destructor` on each instance it releases.
16086
*/
16087
destructor: function() {
16088
var Interface = this.constructor.Interface;
16089
for (var propName in Interface) {
16090
this[propName] = null;
16091
}
16092
this.dispatchConfig = null;
16093
this.dispatchMarker = null;
16094
this.nativeEvent = null;
16095
}
16096
16097
});
16098
16099
SyntheticEvent.Interface = EventInterface;
16100
16101
/**
16102
* Helper to reduce boilerplate when creating subclasses.
16103
*
16104
* @param {function} Class
16105
* @param {?object} Interface
16106
*/
16107
SyntheticEvent.augmentClass = function(Class, Interface) {
16108
var Super = this;
16109
16110
var prototype = Object.create(Super.prototype);
16111
assign(prototype, Class.prototype);
16112
Class.prototype = prototype;
16113
Class.prototype.constructor = Class;
16114
16115
Class.Interface = assign({}, Super.Interface, Interface);
16116
Class.augmentClass = Super.augmentClass;
16117
16118
PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
16119
};
16120
16121
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
16122
16123
module.exports = SyntheticEvent;
16124
16125
},{"114":114,"125":125,"27":27,"28":28}],96:[function(_dereq_,module,exports){
16126
/**
16127
* Copyright 2013-2015, Facebook, Inc.
16128
* All rights reserved.
16129
*
16130
* This source code is licensed under the BSD-style license found in the
16131
* LICENSE file in the root directory of this source tree. An additional grant
16132
* of patent rights can be found in the PATENTS file in the same directory.
16133
*
16134
* @providesModule SyntheticFocusEvent
16135
* @typechecks static-only
16136
*/
16137
16138
'use strict';
16139
16140
var SyntheticUIEvent = _dereq_(101);
16141
16142
/**
16143
* @interface FocusEvent
16144
* @see http://www.w3.org/TR/DOM-Level-3-Events/
16145
*/
16146
var FocusEventInterface = {
16147
relatedTarget: null
16148
};
16149
16150
/**
16151
* @param {object} dispatchConfig Configuration used to dispatch this event.
16152
* @param {string} dispatchMarker Marker identifying the event target.
16153
* @param {object} nativeEvent Native browser event.
16154
* @extends {SyntheticUIEvent}
16155
*/
16156
function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16157
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16158
}
16159
16160
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
16161
16162
module.exports = SyntheticFocusEvent;
16163
16164
},{"101":101}],97:[function(_dereq_,module,exports){
16165
/**
16166
* Copyright 2013-2015, Facebook, Inc.
16167
* All rights reserved.
16168
*
16169
* This source code is licensed under the BSD-style license found in the
16170
* LICENSE file in the root directory of this source tree. An additional grant
16171
* of patent rights can be found in the PATENTS file in the same directory.
16172
*
16173
* @providesModule SyntheticInputEvent
16174
* @typechecks static-only
16175
*/
16176
16177
'use strict';
16178
16179
var SyntheticEvent = _dereq_(95);
16180
16181
/**
16182
* @interface Event
16183
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
16184
* /#events-inputevents
16185
*/
16186
var InputEventInterface = {
16187
data: null
16188
};
16189
16190
/**
16191
* @param {object} dispatchConfig Configuration used to dispatch this event.
16192
* @param {string} dispatchMarker Marker identifying the event target.
16193
* @param {object} nativeEvent Native browser event.
16194
* @extends {SyntheticUIEvent}
16195
*/
16196
function SyntheticInputEvent(
16197
dispatchConfig,
16198
dispatchMarker,
16199
nativeEvent) {
16200
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16201
}
16202
16203
SyntheticEvent.augmentClass(
16204
SyntheticInputEvent,
16205
InputEventInterface
16206
);
16207
16208
module.exports = SyntheticInputEvent;
16209
16210
},{"95":95}],98:[function(_dereq_,module,exports){
16211
/**
16212
* Copyright 2013-2015, Facebook, Inc.
16213
* All rights reserved.
16214
*
16215
* This source code is licensed under the BSD-style license found in the
16216
* LICENSE file in the root directory of this source tree. An additional grant
16217
* of patent rights can be found in the PATENTS file in the same directory.
16218
*
16219
* @providesModule SyntheticKeyboardEvent
16220
* @typechecks static-only
16221
*/
16222
16223
'use strict';
16224
16225
var SyntheticUIEvent = _dereq_(101);
16226
16227
var getEventCharCode = _dereq_(122);
16228
var getEventKey = _dereq_(123);
16229
var getEventModifierState = _dereq_(124);
16230
16231
/**
16232
* @interface KeyboardEvent
16233
* @see http://www.w3.org/TR/DOM-Level-3-Events/
16234
*/
16235
var KeyboardEventInterface = {
16236
key: getEventKey,
16237
location: null,
16238
ctrlKey: null,
16239
shiftKey: null,
16240
altKey: null,
16241
metaKey: null,
16242
repeat: null,
16243
locale: null,
16244
getModifierState: getEventModifierState,
16245
// Legacy Interface
16246
charCode: function(event) {
16247
// `charCode` is the result of a KeyPress event and represents the value of
16248
// the actual printable character.
16249
16250
// KeyPress is deprecated, but its replacement is not yet final and not
16251
// implemented in any major browser. Only KeyPress has charCode.
16252
if (event.type === 'keypress') {
16253
return getEventCharCode(event);
16254
}
16255
return 0;
16256
},
16257
keyCode: function(event) {
16258
// `keyCode` is the result of a KeyDown/Up event and represents the value of
16259
// physical keyboard key.
16260
16261
// The actual meaning of the value depends on the users' keyboard layout
16262
// which cannot be detected. Assuming that it is a US keyboard layout
16263
// provides a surprisingly accurate mapping for US and European users.
16264
// Due to this, it is left to the user to implement at this time.
16265
if (event.type === 'keydown' || event.type === 'keyup') {
16266
return event.keyCode;
16267
}
16268
return 0;
16269
},
16270
which: function(event) {
16271
// `which` is an alias for either `keyCode` or `charCode` depending on the
16272
// type of the event.
16273
if (event.type === 'keypress') {
16274
return getEventCharCode(event);
16275
}
16276
if (event.type === 'keydown' || event.type === 'keyup') {
16277
return event.keyCode;
16278
}
16279
return 0;
16280
}
16281
};
16282
16283
/**
16284
* @param {object} dispatchConfig Configuration used to dispatch this event.
16285
* @param {string} dispatchMarker Marker identifying the event target.
16286
* @param {object} nativeEvent Native browser event.
16287
* @extends {SyntheticUIEvent}
16288
*/
16289
function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16290
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16291
}
16292
16293
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
16294
16295
module.exports = SyntheticKeyboardEvent;
16296
16297
},{"101":101,"122":122,"123":123,"124":124}],99:[function(_dereq_,module,exports){
16298
/**
16299
* Copyright 2013-2015, Facebook, Inc.
16300
* All rights reserved.
16301
*
16302
* This source code is licensed under the BSD-style license found in the
16303
* LICENSE file in the root directory of this source tree. An additional grant
16304
* of patent rights can be found in the PATENTS file in the same directory.
16305
*
16306
* @providesModule SyntheticMouseEvent
16307
* @typechecks static-only
16308
*/
16309
16310
'use strict';
16311
16312
var SyntheticUIEvent = _dereq_(101);
16313
var ViewportMetrics = _dereq_(104);
16314
16315
var getEventModifierState = _dereq_(124);
16316
16317
/**
16318
* @interface MouseEvent
16319
* @see http://www.w3.org/TR/DOM-Level-3-Events/
16320
*/
16321
var MouseEventInterface = {
16322
screenX: null,
16323
screenY: null,
16324
clientX: null,
16325
clientY: null,
16326
ctrlKey: null,
16327
shiftKey: null,
16328
altKey: null,
16329
metaKey: null,
16330
getModifierState: getEventModifierState,
16331
button: function(event) {
16332
// Webkit, Firefox, IE9+
16333
// which: 1 2 3
16334
// button: 0 1 2 (standard)
16335
var button = event.button;
16336
if ('which' in event) {
16337
return button;
16338
}
16339
// IE<9
16340
// which: undefined
16341
// button: 0 0 0
16342
// button: 1 4 2 (onmouseup)
16343
return button === 2 ? 2 : button === 4 ? 1 : 0;
16344
},
16345
buttons: null,
16346
relatedTarget: function(event) {
16347
return event.relatedTarget || (
16348
((event.fromElement === event.srcElement ? event.toElement : event.fromElement))
16349
);
16350
},
16351
// "Proprietary" Interface.
16352
pageX: function(event) {
16353
return 'pageX' in event ?
16354
event.pageX :
16355
event.clientX + ViewportMetrics.currentScrollLeft;
16356
},
16357
pageY: function(event) {
16358
return 'pageY' in event ?
16359
event.pageY :
16360
event.clientY + ViewportMetrics.currentScrollTop;
16361
}
16362
};
16363
16364
/**
16365
* @param {object} dispatchConfig Configuration used to dispatch this event.
16366
* @param {string} dispatchMarker Marker identifying the event target.
16367
* @param {object} nativeEvent Native browser event.
16368
* @extends {SyntheticUIEvent}
16369
*/
16370
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16371
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16372
}
16373
16374
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
16375
16376
module.exports = SyntheticMouseEvent;
16377
16378
},{"101":101,"104":104,"124":124}],100:[function(_dereq_,module,exports){
16379
/**
16380
* Copyright 2013-2015, Facebook, Inc.
16381
* All rights reserved.
16382
*
16383
* This source code is licensed under the BSD-style license found in the
16384
* LICENSE file in the root directory of this source tree. An additional grant
16385
* of patent rights can be found in the PATENTS file in the same directory.
16386
*
16387
* @providesModule SyntheticTouchEvent
16388
* @typechecks static-only
16389
*/
16390
16391
'use strict';
16392
16393
var SyntheticUIEvent = _dereq_(101);
16394
16395
var getEventModifierState = _dereq_(124);
16396
16397
/**
16398
* @interface TouchEvent
16399
* @see http://www.w3.org/TR/touch-events/
16400
*/
16401
var TouchEventInterface = {
16402
touches: null,
16403
targetTouches: null,
16404
changedTouches: null,
16405
altKey: null,
16406
metaKey: null,
16407
ctrlKey: null,
16408
shiftKey: null,
16409
getModifierState: getEventModifierState
16410
};
16411
16412
/**
16413
* @param {object} dispatchConfig Configuration used to dispatch this event.
16414
* @param {string} dispatchMarker Marker identifying the event target.
16415
* @param {object} nativeEvent Native browser event.
16416
* @extends {SyntheticUIEvent}
16417
*/
16418
function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16419
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16420
}
16421
16422
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
16423
16424
module.exports = SyntheticTouchEvent;
16425
16426
},{"101":101,"124":124}],101:[function(_dereq_,module,exports){
16427
/**
16428
* Copyright 2013-2015, Facebook, Inc.
16429
* All rights reserved.
16430
*
16431
* This source code is licensed under the BSD-style license found in the
16432
* LICENSE file in the root directory of this source tree. An additional grant
16433
* of patent rights can be found in the PATENTS file in the same directory.
16434
*
16435
* @providesModule SyntheticUIEvent
16436
* @typechecks static-only
16437
*/
16438
16439
'use strict';
16440
16441
var SyntheticEvent = _dereq_(95);
16442
16443
var getEventTarget = _dereq_(125);
16444
16445
/**
16446
* @interface UIEvent
16447
* @see http://www.w3.org/TR/DOM-Level-3-Events/
16448
*/
16449
var UIEventInterface = {
16450
view: function(event) {
16451
if (event.view) {
16452
return event.view;
16453
}
16454
16455
var target = getEventTarget(event);
16456
if (target != null && target.window === target) {
16457
// target is a window object
16458
return target;
16459
}
16460
16461
var doc = target.ownerDocument;
16462
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
16463
if (doc) {
16464
return doc.defaultView || doc.parentWindow;
16465
} else {
16466
return window;
16467
}
16468
},
16469
detail: function(event) {
16470
return event.detail || 0;
16471
}
16472
};
16473
16474
/**
16475
* @param {object} dispatchConfig Configuration used to dispatch this event.
16476
* @param {string} dispatchMarker Marker identifying the event target.
16477
* @param {object} nativeEvent Native browser event.
16478
* @extends {SyntheticEvent}
16479
*/
16480
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16481
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16482
}
16483
16484
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
16485
16486
module.exports = SyntheticUIEvent;
16487
16488
},{"125":125,"95":95}],102:[function(_dereq_,module,exports){
16489
/**
16490
* Copyright 2013-2015, Facebook, Inc.
16491
* All rights reserved.
16492
*
16493
* This source code is licensed under the BSD-style license found in the
16494
* LICENSE file in the root directory of this source tree. An additional grant
16495
* of patent rights can be found in the PATENTS file in the same directory.
16496
*
16497
* @providesModule SyntheticWheelEvent
16498
* @typechecks static-only
16499
*/
16500
16501
'use strict';
16502
16503
var SyntheticMouseEvent = _dereq_(99);
16504
16505
/**
16506
* @interface WheelEvent
16507
* @see http://www.w3.org/TR/DOM-Level-3-Events/
16508
*/
16509
var WheelEventInterface = {
16510
deltaX: function(event) {
16511
return (
16512
'deltaX' in event ? event.deltaX :
16513
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
16514
'wheelDeltaX' in event ? -event.wheelDeltaX : 0
16515
);
16516
},
16517
deltaY: function(event) {
16518
return (
16519
'deltaY' in event ? event.deltaY :
16520
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
16521
'wheelDeltaY' in event ? -event.wheelDeltaY :
16522
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
16523
'wheelDelta' in event ? -event.wheelDelta : 0
16524
);
16525
},
16526
deltaZ: null,
16527
16528
// Browsers without "deltaMode" is reporting in raw wheel delta where one
16529
// notch on the scroll is always +/- 120, roughly equivalent to pixels.
16530
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
16531
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
16532
deltaMode: null
16533
};
16534
16535
/**
16536
* @param {object} dispatchConfig Configuration used to dispatch this event.
16537
* @param {string} dispatchMarker Marker identifying the event target.
16538
* @param {object} nativeEvent Native browser event.
16539
* @extends {SyntheticMouseEvent}
16540
*/
16541
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
16542
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
16543
}
16544
16545
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
16546
16547
module.exports = SyntheticWheelEvent;
16548
16549
},{"99":99}],103:[function(_dereq_,module,exports){
16550
/**
16551
* Copyright 2013-2015, Facebook, Inc.
16552
* All rights reserved.
16553
*
16554
* This source code is licensed under the BSD-style license found in the
16555
* LICENSE file in the root directory of this source tree. An additional grant
16556
* of patent rights can be found in the PATENTS file in the same directory.
16557
*
16558
* @providesModule Transaction
16559
*/
16560
16561
'use strict';
16562
16563
var invariant = _dereq_(135);
16564
16565
/**
16566
* `Transaction` creates a black box that is able to wrap any method such that
16567
* certain invariants are maintained before and after the method is invoked
16568
* (Even if an exception is thrown while invoking the wrapped method). Whoever
16569
* instantiates a transaction can provide enforcers of the invariants at
16570
* creation time. The `Transaction` class itself will supply one additional
16571
* automatic invariant for you - the invariant that any transaction instance
16572
* should not be run while it is already being run. You would typically create a
16573
* single instance of a `Transaction` for reuse multiple times, that potentially
16574
* is used to wrap several different methods. Wrappers are extremely simple -
16575
* they only require implementing two methods.
16576
*
16577
* <pre>
16578
* wrappers (injected at creation time)
16579
* + +
16580
* | |
16581
* +-----------------|--------|--------------+
16582
* | v | |
16583
* | +---------------+ | |
16584
* | +--| wrapper1 |---|----+ |
16585
* | | +---------------+ v | |
16586
* | | +-------------+ | |
16587
* | | +----| wrapper2 |--------+ |
16588
* | | | +-------------+ | | |
16589
* | | | | | |
16590
* | v v v v | wrapper
16591
* | +---+ +---+ +---------+ +---+ +---+ | invariants
16592
* perform(anyMethod) | | | | | | | | | | | | maintained
16593
* +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
16594
* | | | | | | | | | | | |
16595
* | | | | | | | | | | | |
16596
* | | | | | | | | | | | |
16597
* | +---+ +---+ +---------+ +---+ +---+ |
16598
* | initialize close |
16599
* +-----------------------------------------+
16600
* </pre>
16601
*
16602
* Use cases:
16603
* - Preserving the input selection ranges before/after reconciliation.
16604
* Restoring selection even in the event of an unexpected error.
16605
* - Deactivating events while rearranging the DOM, preventing blurs/focuses,
16606
* while guaranteeing that afterwards, the event system is reactivated.
16607
* - Flushing a queue of collected DOM mutations to the main UI thread after a
16608
* reconciliation takes place in a worker thread.
16609
* - Invoking any collected `componentDidUpdate` callbacks after rendering new
16610
* content.
16611
* - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
16612
* to preserve the `scrollTop` (an automatic scroll aware DOM).
16613
* - (Future use case): Layout calculations before and after DOM updates.
16614
*
16615
* Transactional plugin API:
16616
* - A module that has an `initialize` method that returns any precomputation.
16617
* - and a `close` method that accepts the precomputation. `close` is invoked
16618
* when the wrapped process is completed, or has failed.
16619
*
16620
* @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
16621
* that implement `initialize` and `close`.
16622
* @return {Transaction} Single transaction for reuse in thread.
16623
*
16624
* @class Transaction
16625
*/
16626
var Mixin = {
16627
/**
16628
* Sets up this instance so that it is prepared for collecting metrics. Does
16629
* so such that this setup method may be used on an instance that is already
16630
* initialized, in a way that does not consume additional memory upon reuse.
16631
* That can be useful if you decide to make your subclass of this mixin a
16632
* "PooledClass".
16633
*/
16634
reinitializeTransaction: function() {
16635
this.transactionWrappers = this.getTransactionWrappers();
16636
if (!this.wrapperInitData) {
16637
this.wrapperInitData = [];
16638
} else {
16639
this.wrapperInitData.length = 0;
16640
}
16641
this._isInTransaction = false;
16642
},
16643
16644
_isInTransaction: false,
16645
16646
/**
16647
* @abstract
16648
* @return {Array<TransactionWrapper>} Array of transaction wrappers.
16649
*/
16650
getTransactionWrappers: null,
16651
16652
isInTransaction: function() {
16653
return !!this._isInTransaction;
16654
},
16655
16656
/**
16657
* Executes the function within a safety window. Use this for the top level
16658
* methods that result in large amounts of computation/mutations that would
16659
* need to be safety checked.
16660
*
16661
* @param {function} method Member of scope to call.
16662
* @param {Object} scope Scope to invoke from.
16663
* @param {Object?=} args... Arguments to pass to the method (optional).
16664
* Helps prevent need to bind in many cases.
16665
* @return Return value from `method`.
16666
*/
16667
perform: function(method, scope, a, b, c, d, e, f) {
16668
("production" !== "development" ? invariant(
16669
!this.isInTransaction(),
16670
'Transaction.perform(...): Cannot initialize a transaction when there ' +
16671
'is already an outstanding transaction.'
16672
) : invariant(!this.isInTransaction()));
16673
var errorThrown;
16674
var ret;
16675
try {
16676
this._isInTransaction = true;
16677
// Catching errors makes debugging more difficult, so we start with
16678
// errorThrown set to true before setting it to false after calling
16679
// close -- if it's still set to true in the finally block, it means
16680
// one of these calls threw.
16681
errorThrown = true;
16682
this.initializeAll(0);
16683
ret = method.call(scope, a, b, c, d, e, f);
16684
errorThrown = false;
16685
} finally {
16686
try {
16687
if (errorThrown) {
16688
// If `method` throws, prefer to show that stack trace over any thrown
16689
// by invoking `closeAll`.
16690
try {
16691
this.closeAll(0);
16692
} catch (err) {
16693
}
16694
} else {
16695
// Since `method` didn't throw, we don't want to silence the exception
16696
// here.
16697
this.closeAll(0);
16698
}
16699
} finally {
16700
this._isInTransaction = false;
16701
}
16702
}
16703
return ret;
16704
},
16705
16706
initializeAll: function(startIndex) {
16707
var transactionWrappers = this.transactionWrappers;
16708
for (var i = startIndex; i < transactionWrappers.length; i++) {
16709
var wrapper = transactionWrappers[i];
16710
try {
16711
// Catching errors makes debugging more difficult, so we start with the
16712
// OBSERVED_ERROR state before overwriting it with the real return value
16713
// of initialize -- if it's still set to OBSERVED_ERROR in the finally
16714
// block, it means wrapper.initialize threw.
16715
this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
16716
this.wrapperInitData[i] = wrapper.initialize ?
16717
wrapper.initialize.call(this) :
16718
null;
16719
} finally {
16720
if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
16721
// The initializer for wrapper i threw an error; initialize the
16722
// remaining wrappers but silence any exceptions from them to ensure
16723
// that the first error is the one to bubble up.
16724
try {
16725
this.initializeAll(i + 1);
16726
} catch (err) {
16727
}
16728
}
16729
}
16730
}
16731
},
16732
16733
/**
16734
* Invokes each of `this.transactionWrappers.close[i]` functions, passing into
16735
* them the respective return values of `this.transactionWrappers.init[i]`
16736
* (`close`rs that correspond to initializers that failed will not be
16737
* invoked).
16738
*/
16739
closeAll: function(startIndex) {
16740
("production" !== "development" ? invariant(
16741
this.isInTransaction(),
16742
'Transaction.closeAll(): Cannot close transaction when none are open.'
16743
) : invariant(this.isInTransaction()));
16744
var transactionWrappers = this.transactionWrappers;
16745
for (var i = startIndex; i < transactionWrappers.length; i++) {
16746
var wrapper = transactionWrappers[i];
16747
var initData = this.wrapperInitData[i];
16748
var errorThrown;
16749
try {
16750
// Catching errors makes debugging more difficult, so we start with
16751
// errorThrown set to true before setting it to false after calling
16752
// close -- if it's still set to true in the finally block, it means
16753
// wrapper.close threw.
16754
errorThrown = true;
16755
if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) {
16756
wrapper.close.call(this, initData);
16757
}
16758
errorThrown = false;
16759
} finally {
16760
if (errorThrown) {
16761
// The closer for wrapper i threw an error; close the remaining
16762
// wrappers but silence any exceptions from them to ensure that the
16763
// first error is the one to bubble up.
16764
try {
16765
this.closeAll(i + 1);
16766
} catch (e) {
16767
}
16768
}
16769
}
16770
}
16771
this.wrapperInitData.length = 0;
16772
}
16773
};
16774
16775
var Transaction = {
16776
16777
Mixin: Mixin,
16778
16779
/**
16780
* Token to look for to determine if an error occured.
16781
*/
16782
OBSERVED_ERROR: {}
16783
16784
};
16785
16786
module.exports = Transaction;
16787
16788
},{"135":135}],104:[function(_dereq_,module,exports){
16789
/**
16790
* Copyright 2013-2015, Facebook, Inc.
16791
* All rights reserved.
16792
*
16793
* This source code is licensed under the BSD-style license found in the
16794
* LICENSE file in the root directory of this source tree. An additional grant
16795
* of patent rights can be found in the PATENTS file in the same directory.
16796
*
16797
* @providesModule ViewportMetrics
16798
*/
16799
16800
'use strict';
16801
16802
var ViewportMetrics = {
16803
16804
currentScrollLeft: 0,
16805
16806
currentScrollTop: 0,
16807
16808
refreshScrollValues: function(scrollPosition) {
16809
ViewportMetrics.currentScrollLeft = scrollPosition.x;
16810
ViewportMetrics.currentScrollTop = scrollPosition.y;
16811
}
16812
16813
};
16814
16815
module.exports = ViewportMetrics;
16816
16817
},{}],105:[function(_dereq_,module,exports){
16818
/**
16819
* Copyright 2014-2015, Facebook, Inc.
16820
* All rights reserved.
16821
*
16822
* This source code is licensed under the BSD-style license found in the
16823
* LICENSE file in the root directory of this source tree. An additional grant
16824
* of patent rights can be found in the PATENTS file in the same directory.
16825
*
16826
* @providesModule accumulateInto
16827
*/
16828
16829
'use strict';
16830
16831
var invariant = _dereq_(135);
16832
16833
/**
16834
*
16835
* Accumulates items that must not be null or undefined into the first one. This
16836
* is used to conserve memory by avoiding array allocations, and thus sacrifices
16837
* API cleanness. Since `current` can be null before being passed in and not
16838
* null after this function, make sure to assign it back to `current`:
16839
*
16840
* `a = accumulateInto(a, b);`
16841
*
16842
* This API should be sparingly used. Try `accumulate` for something cleaner.
16843
*
16844
* @return {*|array<*>} An accumulation of items.
16845
*/
16846
16847
function accumulateInto(current, next) {
16848
("production" !== "development" ? invariant(
16849
next != null,
16850
'accumulateInto(...): Accumulated items must not be null or undefined.'
16851
) : invariant(next != null));
16852
if (current == null) {
16853
return next;
16854
}
16855
16856
// Both are not empty. Warning: Never call x.concat(y) when you are not
16857
// certain that x is an Array (x could be a string with concat method).
16858
var currentIsArray = Array.isArray(current);
16859
var nextIsArray = Array.isArray(next);
16860
16861
if (currentIsArray && nextIsArray) {
16862
current.push.apply(current, next);
16863
return current;
16864
}
16865
16866
if (currentIsArray) {
16867
current.push(next);
16868
return current;
16869
}
16870
16871
if (nextIsArray) {
16872
// A bit too dangerous to mutate `next`.
16873
return [current].concat(next);
16874
}
16875
16876
return [current, next];
16877
}
16878
16879
module.exports = accumulateInto;
16880
16881
},{"135":135}],106:[function(_dereq_,module,exports){
16882
/**
16883
* Copyright 2013-2015, Facebook, Inc.
16884
* All rights reserved.
16885
*
16886
* This source code is licensed under the BSD-style license found in the
16887
* LICENSE file in the root directory of this source tree. An additional grant
16888
* of patent rights can be found in the PATENTS file in the same directory.
16889
*
16890
* @providesModule adler32
16891
*/
16892
16893
/* jslint bitwise:true */
16894
16895
'use strict';
16896
16897
var MOD = 65521;
16898
16899
// This is a clean-room implementation of adler32 designed for detecting
16900
// if markup is not what we expect it to be. It does not need to be
16901
// cryptographically strong, only reasonably good at detecting if markup
16902
// generated on the server is different than that on the client.
16903
function adler32(data) {
16904
var a = 1;
16905
var b = 0;
16906
for (var i = 0; i < data.length; i++) {
16907
a = (a + data.charCodeAt(i)) % MOD;
16908
b = (b + a) % MOD;
16909
}
16910
return a | (b << 16);
16911
}
16912
16913
module.exports = adler32;
16914
16915
},{}],107:[function(_dereq_,module,exports){
16916
/**
16917
* Copyright 2013-2015, Facebook, Inc.
16918
* All rights reserved.
16919
*
16920
* This source code is licensed under the BSD-style license found in the
16921
* LICENSE file in the root directory of this source tree. An additional grant
16922
* of patent rights can be found in the PATENTS file in the same directory.
16923
*
16924
* @providesModule camelize
16925
* @typechecks
16926
*/
16927
16928
var _hyphenPattern = /-(.)/g;
16929
16930
/**
16931
* Camelcases a hyphenated string, for example:
16932
*
16933
* > camelize('background-color')
16934
* < "backgroundColor"
16935
*
16936
* @param {string} string
16937
* @return {string}
16938
*/
16939
function camelize(string) {
16940
return string.replace(_hyphenPattern, function(_, character) {
16941
return character.toUpperCase();
16942
});
16943
}
16944
16945
module.exports = camelize;
16946
16947
},{}],108:[function(_dereq_,module,exports){
16948
/**
16949
* Copyright 2014-2015, Facebook, Inc.
16950
* All rights reserved.
16951
*
16952
* This source code is licensed under the BSD-style license found in the
16953
* LICENSE file in the root directory of this source tree. An additional grant
16954
* of patent rights can be found in the PATENTS file in the same directory.
16955
*
16956
* @providesModule camelizeStyleName
16957
* @typechecks
16958
*/
16959
16960
"use strict";
16961
16962
var camelize = _dereq_(107);
16963
16964
var msPattern = /^-ms-/;
16965
16966
/**
16967
* Camelcases a hyphenated CSS property name, for example:
16968
*
16969
* > camelizeStyleName('background-color')
16970
* < "backgroundColor"
16971
* > camelizeStyleName('-moz-transition')
16972
* < "MozTransition"
16973
* > camelizeStyleName('-ms-transition')
16974
* < "msTransition"
16975
*
16976
* As Andi Smith suggests
16977
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
16978
* is converted to lowercase `ms`.
16979
*
16980
* @param {string} string
16981
* @return {string}
16982
*/
16983
function camelizeStyleName(string) {
16984
return camelize(string.replace(msPattern, 'ms-'));
16985
}
16986
16987
module.exports = camelizeStyleName;
16988
16989
},{"107":107}],109:[function(_dereq_,module,exports){
16990
/**
16991
* Copyright 2013-2015, Facebook, Inc.
16992
* All rights reserved.
16993
*
16994
* This source code is licensed under the BSD-style license found in the
16995
* LICENSE file in the root directory of this source tree. An additional grant
16996
* of patent rights can be found in the PATENTS file in the same directory.
16997
*
16998
* @providesModule containsNode
16999
* @typechecks
17000
*/
17001
17002
var isTextNode = _dereq_(139);
17003
17004
/*jslint bitwise:true */
17005
17006
/**
17007
* Checks if a given DOM node contains or is another DOM node.
17008
*
17009
* @param {?DOMNode} outerNode Outer DOM node.
17010
* @param {?DOMNode} innerNode Inner DOM node.
17011
* @return {boolean} True if `outerNode` contains or is `innerNode`.
17012
*/
17013
function containsNode(outerNode, innerNode) {
17014
if (!outerNode || !innerNode) {
17015
return false;
17016
} else if (outerNode === innerNode) {
17017
return true;
17018
} else if (isTextNode(outerNode)) {
17019
return false;
17020
} else if (isTextNode(innerNode)) {
17021
return containsNode(outerNode, innerNode.parentNode);
17022
} else if (outerNode.contains) {
17023
return outerNode.contains(innerNode);
17024
} else if (outerNode.compareDocumentPosition) {
17025
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
17026
} else {
17027
return false;
17028
}
17029
}
17030
17031
module.exports = containsNode;
17032
17033
},{"139":139}],110:[function(_dereq_,module,exports){
17034
/**
17035
* Copyright 2013-2015, Facebook, Inc.
17036
* All rights reserved.
17037
*
17038
* This source code is licensed under the BSD-style license found in the
17039
* LICENSE file in the root directory of this source tree. An additional grant
17040
* of patent rights can be found in the PATENTS file in the same directory.
17041
*
17042
* @providesModule createArrayFromMixed
17043
* @typechecks
17044
*/
17045
17046
var toArray = _dereq_(152);
17047
17048
/**
17049
* Perform a heuristic test to determine if an object is "array-like".
17050
*
17051
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
17052
* Joshu replied: "Mu."
17053
*
17054
* This function determines if its argument has "array nature": it returns
17055
* true if the argument is an actual array, an `arguments' object, or an
17056
* HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
17057
*
17058
* It will return false for other array-like objects like Filelist.
17059
*
17060
* @param {*} obj
17061
* @return {boolean}
17062
*/
17063
function hasArrayNature(obj) {
17064
return (
17065
// not null/false
17066
!!obj &&
17067
// arrays are objects, NodeLists are functions in Safari
17068
(typeof obj == 'object' || typeof obj == 'function') &&
17069
// quacks like an array
17070
('length' in obj) &&
17071
// not window
17072
!('setInterval' in obj) &&
17073
// no DOM node should be considered an array-like
17074
// a 'select' element has 'length' and 'item' properties on IE8
17075
(typeof obj.nodeType != 'number') &&
17076
(
17077
// a real array
17078
(// HTMLCollection/NodeList
17079
(Array.isArray(obj) ||
17080
// arguments
17081
('callee' in obj) || 'item' in obj))
17082
)
17083
);
17084
}
17085
17086
/**
17087
* Ensure that the argument is an array by wrapping it in an array if it is not.
17088
* Creates a copy of the argument if it is already an array.
17089
*
17090
* This is mostly useful idiomatically:
17091
*
17092
* var createArrayFromMixed = require('createArrayFromMixed');
17093
*
17094
* function takesOneOrMoreThings(things) {
17095
* things = createArrayFromMixed(things);
17096
* ...
17097
* }
17098
*
17099
* This allows you to treat `things' as an array, but accept scalars in the API.
17100
*
17101
* If you need to convert an array-like object, like `arguments`, into an array
17102
* use toArray instead.
17103
*
17104
* @param {*} obj
17105
* @return {array}
17106
*/
17107
function createArrayFromMixed(obj) {
17108
if (!hasArrayNature(obj)) {
17109
return [obj];
17110
} else if (Array.isArray(obj)) {
17111
return obj.slice();
17112
} else {
17113
return toArray(obj);
17114
}
17115
}
17116
17117
module.exports = createArrayFromMixed;
17118
17119
},{"152":152}],111:[function(_dereq_,module,exports){
17120
/**
17121
* Copyright 2013-2015, Facebook, Inc.
17122
* All rights reserved.
17123
*
17124
* This source code is licensed under the BSD-style license found in the
17125
* LICENSE file in the root directory of this source tree. An additional grant
17126
* of patent rights can be found in the PATENTS file in the same directory.
17127
*
17128
* @providesModule createFullPageComponent
17129
* @typechecks
17130
*/
17131
17132
'use strict';
17133
17134
// Defeat circular references by requiring this directly.
17135
var ReactClass = _dereq_(33);
17136
var ReactElement = _dereq_(57);
17137
17138
var invariant = _dereq_(135);
17139
17140
/**
17141
* Create a component that will throw an exception when unmounted.
17142
*
17143
* Components like <html> <head> and <body> can't be removed or added
17144
* easily in a cross-browser way, however it's valuable to be able to
17145
* take advantage of React's reconciliation for styling and <title>
17146
* management. So we just document it and throw in dangerous cases.
17147
*
17148
* @param {string} tag The tag to wrap
17149
* @return {function} convenience constructor of new component
17150
*/
17151
function createFullPageComponent(tag) {
17152
var elementFactory = ReactElement.createFactory(tag);
17153
17154
var FullPageComponent = ReactClass.createClass({
17155
tagName: tag.toUpperCase(),
17156
displayName: 'ReactFullPageComponent' + tag,
17157
17158
componentWillUnmount: function() {
17159
("production" !== "development" ? invariant(
17160
false,
17161
'%s tried to unmount. Because of cross-browser quirks it is ' +
17162
'impossible to unmount some top-level components (eg <html>, <head>, ' +
17163
'and <body>) reliably and efficiently. To fix this, have a single ' +
17164
'top-level component that never unmounts render these elements.',
17165
this.constructor.displayName
17166
) : invariant(false));
17167
},
17168
17169
render: function() {
17170
return elementFactory(this.props);
17171
}
17172
});
17173
17174
return FullPageComponent;
17175
}
17176
17177
module.exports = createFullPageComponent;
17178
17179
},{"135":135,"33":33,"57":57}],112:[function(_dereq_,module,exports){
17180
/**
17181
* Copyright 2013-2015, Facebook, Inc.
17182
* All rights reserved.
17183
*
17184
* This source code is licensed under the BSD-style license found in the
17185
* LICENSE file in the root directory of this source tree. An additional grant
17186
* of patent rights can be found in the PATENTS file in the same directory.
17187
*
17188
* @providesModule createNodesFromMarkup
17189
* @typechecks
17190
*/
17191
17192
/*jslint evil: true, sub: true */
17193
17194
var ExecutionEnvironment = _dereq_(21);
17195
17196
var createArrayFromMixed = _dereq_(110);
17197
var getMarkupWrap = _dereq_(127);
17198
var invariant = _dereq_(135);
17199
17200
/**
17201
* Dummy container used to render all markup.
17202
*/
17203
var dummyNode =
17204
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
17205
17206
/**
17207
* Pattern used by `getNodeName`.
17208
*/
17209
var nodeNamePattern = /^\s*<(\w+)/;
17210
17211
/**
17212
* Extracts the `nodeName` of the first element in a string of markup.
17213
*
17214
* @param {string} markup String of markup.
17215
* @return {?string} Node name of the supplied markup.
17216
*/
17217
function getNodeName(markup) {
17218
var nodeNameMatch = markup.match(nodeNamePattern);
17219
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
17220
}
17221
17222
/**
17223
* Creates an array containing the nodes rendered from the supplied markup. The
17224
* optionally supplied `handleScript` function will be invoked once for each
17225
* <script> element that is rendered. If no `handleScript` function is supplied,
17226
* an exception is thrown if any <script> elements are rendered.
17227
*
17228
* @param {string} markup A string of valid HTML markup.
17229
* @param {?function} handleScript Invoked once for each rendered <script>.
17230
* @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
17231
*/
17232
function createNodesFromMarkup(markup, handleScript) {
17233
var node = dummyNode;
17234
("production" !== "development" ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
17235
var nodeName = getNodeName(markup);
17236
17237
var wrap = nodeName && getMarkupWrap(nodeName);
17238
if (wrap) {
17239
node.innerHTML = wrap[1] + markup + wrap[2];
17240
17241
var wrapDepth = wrap[0];
17242
while (wrapDepth--) {
17243
node = node.lastChild;
17244
}
17245
} else {
17246
node.innerHTML = markup;
17247
}
17248
17249
var scripts = node.getElementsByTagName('script');
17250
if (scripts.length) {
17251
("production" !== "development" ? invariant(
17252
handleScript,
17253
'createNodesFromMarkup(...): Unexpected <script> element rendered.'
17254
) : invariant(handleScript));
17255
createArrayFromMixed(scripts).forEach(handleScript);
17256
}
17257
17258
var nodes = createArrayFromMixed(node.childNodes);
17259
while (node.lastChild) {
17260
node.removeChild(node.lastChild);
17261
}
17262
return nodes;
17263
}
17264
17265
module.exports = createNodesFromMarkup;
17266
17267
},{"110":110,"127":127,"135":135,"21":21}],113:[function(_dereq_,module,exports){
17268
/**
17269
* Copyright 2013-2015, Facebook, Inc.
17270
* All rights reserved.
17271
*
17272
* This source code is licensed under the BSD-style license found in the
17273
* LICENSE file in the root directory of this source tree. An additional grant
17274
* of patent rights can be found in the PATENTS file in the same directory.
17275
*
17276
* @providesModule dangerousStyleValue
17277
* @typechecks static-only
17278
*/
17279
17280
'use strict';
17281
17282
var CSSProperty = _dereq_(4);
17283
17284
var isUnitlessNumber = CSSProperty.isUnitlessNumber;
17285
17286
/**
17287
* Convert a value into the proper css writable value. The style name `name`
17288
* should be logical (no hyphens), as specified
17289
* in `CSSProperty.isUnitlessNumber`.
17290
*
17291
* @param {string} name CSS property name such as `topMargin`.
17292
* @param {*} value CSS property value such as `10px`.
17293
* @return {string} Normalized style value with dimensions applied.
17294
*/
17295
function dangerousStyleValue(name, value) {
17296
// Note that we've removed escapeTextForBrowser() calls here since the
17297
// whole string will be escaped when the attribute is injected into
17298
// the markup. If you provide unsafe user data here they can inject
17299
// arbitrary CSS which may be problematic (I couldn't repro this):
17300
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
17301
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
17302
// This is not an XSS hole but instead a potential CSS injection issue
17303
// which has lead to a greater discussion about how we're going to
17304
// trust URLs moving forward. See #2115901
17305
17306
var isEmpty = value == null || typeof value === 'boolean' || value === '';
17307
if (isEmpty) {
17308
return '';
17309
}
17310
17311
var isNonNumeric = isNaN(value);
17312
if (isNonNumeric || value === 0 ||
17313
isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
17314
return '' + value; // cast to string
17315
}
17316
17317
if (typeof value === 'string') {
17318
value = value.trim();
17319
}
17320
return value + 'px';
17321
}
17322
17323
module.exports = dangerousStyleValue;
17324
17325
},{"4":4}],114:[function(_dereq_,module,exports){
17326
/**
17327
* Copyright 2013-2015, Facebook, Inc.
17328
* All rights reserved.
17329
*
17330
* This source code is licensed under the BSD-style license found in the
17331
* LICENSE file in the root directory of this source tree. An additional grant
17332
* of patent rights can be found in the PATENTS file in the same directory.
17333
*
17334
* @providesModule emptyFunction
17335
*/
17336
17337
function makeEmptyFunction(arg) {
17338
return function() {
17339
return arg;
17340
};
17341
}
17342
17343
/**
17344
* This function accepts and discards inputs; it has no side effects. This is
17345
* primarily useful idiomatically for overridable function endpoints which
17346
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
17347
*/
17348
function emptyFunction() {}
17349
17350
emptyFunction.thatReturns = makeEmptyFunction;
17351
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
17352
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
17353
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
17354
emptyFunction.thatReturnsThis = function() { return this; };
17355
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
17356
17357
module.exports = emptyFunction;
17358
17359
},{}],115:[function(_dereq_,module,exports){
17360
/**
17361
* Copyright 2013-2015, Facebook, Inc.
17362
* All rights reserved.
17363
*
17364
* This source code is licensed under the BSD-style license found in the
17365
* LICENSE file in the root directory of this source tree. An additional grant
17366
* of patent rights can be found in the PATENTS file in the same directory.
17367
*
17368
* @providesModule emptyObject
17369
*/
17370
17371
"use strict";
17372
17373
var emptyObject = {};
17374
17375
if ("production" !== "development") {
17376
Object.freeze(emptyObject);
17377
}
17378
17379
module.exports = emptyObject;
17380
17381
},{}],116:[function(_dereq_,module,exports){
17382
/**
17383
* Copyright 2013-2015, Facebook, Inc.
17384
* All rights reserved.
17385
*
17386
* This source code is licensed under the BSD-style license found in the
17387
* LICENSE file in the root directory of this source tree. An additional grant
17388
* of patent rights can be found in the PATENTS file in the same directory.
17389
*
17390
* @providesModule escapeTextContentForBrowser
17391
*/
17392
17393
'use strict';
17394
17395
var ESCAPE_LOOKUP = {
17396
'&': '&amp;',
17397
'>': '&gt;',
17398
'<': '&lt;',
17399
'"': '&quot;',
17400
'\'': '&#x27;'
17401
};
17402
17403
var ESCAPE_REGEX = /[&><"']/g;
17404
17405
function escaper(match) {
17406
return ESCAPE_LOOKUP[match];
17407
}
17408
17409
/**
17410
* Escapes text to prevent scripting attacks.
17411
*
17412
* @param {*} text Text value to escape.
17413
* @return {string} An escaped string.
17414
*/
17415
function escapeTextContentForBrowser(text) {
17416
return ('' + text).replace(ESCAPE_REGEX, escaper);
17417
}
17418
17419
module.exports = escapeTextContentForBrowser;
17420
17421
},{}],117:[function(_dereq_,module,exports){
17422
/**
17423
* Copyright 2013-2015, Facebook, Inc.
17424
* All rights reserved.
17425
*
17426
* This source code is licensed under the BSD-style license found in the
17427
* LICENSE file in the root directory of this source tree. An additional grant
17428
* of patent rights can be found in the PATENTS file in the same directory.
17429
*
17430
* @providesModule findDOMNode
17431
* @typechecks static-only
17432
*/
17433
17434
'use strict';
17435
17436
var ReactCurrentOwner = _dereq_(39);
17437
var ReactInstanceMap = _dereq_(67);
17438
var ReactMount = _dereq_(70);
17439
17440
var invariant = _dereq_(135);
17441
var isNode = _dereq_(137);
17442
var warning = _dereq_(154);
17443
17444
/**
17445
* Returns the DOM node rendered by this element.
17446
*
17447
* @param {ReactComponent|DOMElement} componentOrElement
17448
* @return {DOMElement} The root node of this element.
17449
*/
17450
function findDOMNode(componentOrElement) {
17451
if ("production" !== "development") {
17452
var owner = ReactCurrentOwner.current;
17453
if (owner !== null) {
17454
("production" !== "development" ? warning(
17455
owner._warnedAboutRefsInRender,
17456
'%s is accessing getDOMNode or findDOMNode inside its render(). ' +
17457
'render() should be a pure function of props and state. It should ' +
17458
'never access something that requires stale data from the previous ' +
17459
'render, such as refs. Move this logic to componentDidMount and ' +
17460
'componentDidUpdate instead.',
17461
owner.getName() || 'A component'
17462
) : null);
17463
owner._warnedAboutRefsInRender = true;
17464
}
17465
}
17466
if (componentOrElement == null) {
17467
return null;
17468
}
17469
if (isNode(componentOrElement)) {
17470
return componentOrElement;
17471
}
17472
if (ReactInstanceMap.has(componentOrElement)) {
17473
return ReactMount.getNodeFromInstance(componentOrElement);
17474
}
17475
("production" !== "development" ? invariant(
17476
componentOrElement.render == null ||
17477
typeof componentOrElement.render !== 'function',
17478
'Component (with keys: %s) contains `render` method ' +
17479
'but is not mounted in the DOM',
17480
Object.keys(componentOrElement)
17481
) : invariant(componentOrElement.render == null ||
17482
typeof componentOrElement.render !== 'function'));
17483
("production" !== "development" ? invariant(
17484
false,
17485
'Element appears to be neither ReactComponent nor DOMNode (keys: %s)',
17486
Object.keys(componentOrElement)
17487
) : invariant(false));
17488
}
17489
17490
module.exports = findDOMNode;
17491
17492
},{"135":135,"137":137,"154":154,"39":39,"67":67,"70":70}],118:[function(_dereq_,module,exports){
17493
/**
17494
* Copyright 2013-2015, Facebook, Inc.
17495
* All rights reserved.
17496
*
17497
* This source code is licensed under the BSD-style license found in the
17498
* LICENSE file in the root directory of this source tree. An additional grant
17499
* of patent rights can be found in the PATENTS file in the same directory.
17500
*
17501
* @providesModule flattenChildren
17502
*/
17503
17504
'use strict';
17505
17506
var traverseAllChildren = _dereq_(153);
17507
var warning = _dereq_(154);
17508
17509
/**
17510
* @param {function} traverseContext Context passed through traversal.
17511
* @param {?ReactComponent} child React child component.
17512
* @param {!string} name String name of key path to child.
17513
*/
17514
function flattenSingleChildIntoContext(traverseContext, child, name) {
17515
// We found a component instance.
17516
var result = traverseContext;
17517
var keyUnique = !result.hasOwnProperty(name);
17518
if ("production" !== "development") {
17519
("production" !== "development" ? warning(
17520
keyUnique,
17521
'flattenChildren(...): Encountered two children with the same key, ' +
17522
'`%s`. Child keys must be unique; when two children share a key, only ' +
17523
'the first child will be used.',
17524
name
17525
) : null);
17526
}
17527
if (keyUnique && child != null) {
17528
result[name] = child;
17529
}
17530
}
17531
17532
/**
17533
* Flattens children that are typically specified as `props.children`. Any null
17534
* children will not be included in the resulting object.
17535
* @return {!object} flattened children keyed by name.
17536
*/
17537
function flattenChildren(children) {
17538
if (children == null) {
17539
return children;
17540
}
17541
var result = {};
17542
traverseAllChildren(children, flattenSingleChildIntoContext, result);
17543
return result;
17544
}
17545
17546
module.exports = flattenChildren;
17547
17548
},{"153":153,"154":154}],119:[function(_dereq_,module,exports){
17549
/**
17550
* Copyright 2014-2015, Facebook, Inc.
17551
* All rights reserved.
17552
*
17553
* This source code is licensed under the BSD-style license found in the
17554
* LICENSE file in the root directory of this source tree. An additional grant
17555
* of patent rights can be found in the PATENTS file in the same directory.
17556
*
17557
* @providesModule focusNode
17558
*/
17559
17560
"use strict";
17561
17562
/**
17563
* @param {DOMElement} node input/textarea to focus
17564
*/
17565
function focusNode(node) {
17566
// IE8 can throw "Can't move focus to the control because it is invisible,
17567
// not enabled, or of a type that does not accept the focus." for all kinds of
17568
// reasons that are too expensive and fragile to test.
17569
try {
17570
node.focus();
17571
} catch(e) {
17572
}
17573
}
17574
17575
module.exports = focusNode;
17576
17577
},{}],120:[function(_dereq_,module,exports){
17578
/**
17579
* Copyright 2013-2015, Facebook, Inc.
17580
* All rights reserved.
17581
*
17582
* This source code is licensed under the BSD-style license found in the
17583
* LICENSE file in the root directory of this source tree. An additional grant
17584
* of patent rights can be found in the PATENTS file in the same directory.
17585
*
17586
* @providesModule forEachAccumulated
17587
*/
17588
17589
'use strict';
17590
17591
/**
17592
* @param {array} an "accumulation" of items which is either an Array or
17593
* a single item. Useful when paired with the `accumulate` module. This is a
17594
* simple utility that allows us to reason about a collection of items, but
17595
* handling the case when there is exactly one item (and we do not need to
17596
* allocate an array).
17597
*/
17598
var forEachAccumulated = function(arr, cb, scope) {
17599
if (Array.isArray(arr)) {
17600
arr.forEach(cb, scope);
17601
} else if (arr) {
17602
cb.call(scope, arr);
17603
}
17604
};
17605
17606
module.exports = forEachAccumulated;
17607
17608
},{}],121:[function(_dereq_,module,exports){
17609
/**
17610
* Copyright 2013-2015, Facebook, Inc.
17611
* All rights reserved.
17612
*
17613
* This source code is licensed under the BSD-style license found in the
17614
* LICENSE file in the root directory of this source tree. An additional grant
17615
* of patent rights can be found in the PATENTS file in the same directory.
17616
*
17617
* @providesModule getActiveElement
17618
* @typechecks
17619
*/
17620
17621
/**
17622
* Same as document.activeElement but wraps in a try-catch block. In IE it is
17623
* not safe to call document.activeElement if there is nothing focused.
17624
*
17625
* The activeElement will be null only if the document body is not yet defined.
17626
*/
17627
function getActiveElement() /*?DOMElement*/ {
17628
try {
17629
return document.activeElement || document.body;
17630
} catch (e) {
17631
return document.body;
17632
}
17633
}
17634
17635
module.exports = getActiveElement;
17636
17637
},{}],122:[function(_dereq_,module,exports){
17638
/**
17639
* Copyright 2013-2015, Facebook, Inc.
17640
* All rights reserved.
17641
*
17642
* This source code is licensed under the BSD-style license found in the
17643
* LICENSE file in the root directory of this source tree. An additional grant
17644
* of patent rights can be found in the PATENTS file in the same directory.
17645
*
17646
* @providesModule getEventCharCode
17647
* @typechecks static-only
17648
*/
17649
17650
'use strict';
17651
17652
/**
17653
* `charCode` represents the actual "character code" and is safe to use with
17654
* `String.fromCharCode`. As such, only keys that correspond to printable
17655
* characters produce a valid `charCode`, the only exception to this is Enter.
17656
* The Tab-key is considered non-printable and does not have a `charCode`,
17657
* presumably because it does not produce a tab-character in browsers.
17658
*
17659
* @param {object} nativeEvent Native browser event.
17660
* @return {string} Normalized `charCode` property.
17661
*/
17662
function getEventCharCode(nativeEvent) {
17663
var charCode;
17664
var keyCode = nativeEvent.keyCode;
17665
17666
if ('charCode' in nativeEvent) {
17667
charCode = nativeEvent.charCode;
17668
17669
// FF does not set `charCode` for the Enter-key, check against `keyCode`.
17670
if (charCode === 0 && keyCode === 13) {
17671
charCode = 13;
17672
}
17673
} else {
17674
// IE8 does not implement `charCode`, but `keyCode` has the correct value.
17675
charCode = keyCode;
17676
}
17677
17678
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
17679
// Must not discard the (non-)printable Enter-key.
17680
if (charCode >= 32 || charCode === 13) {
17681
return charCode;
17682
}
17683
17684
return 0;
17685
}
17686
17687
module.exports = getEventCharCode;
17688
17689
},{}],123:[function(_dereq_,module,exports){
17690
/**
17691
* Copyright 2013-2015, Facebook, Inc.
17692
* All rights reserved.
17693
*
17694
* This source code is licensed under the BSD-style license found in the
17695
* LICENSE file in the root directory of this source tree. An additional grant
17696
* of patent rights can be found in the PATENTS file in the same directory.
17697
*
17698
* @providesModule getEventKey
17699
* @typechecks static-only
17700
*/
17701
17702
'use strict';
17703
17704
var getEventCharCode = _dereq_(122);
17705
17706
/**
17707
* Normalization of deprecated HTML5 `key` values
17708
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
17709
*/
17710
var normalizeKey = {
17711
'Esc': 'Escape',
17712
'Spacebar': ' ',
17713
'Left': 'ArrowLeft',
17714
'Up': 'ArrowUp',
17715
'Right': 'ArrowRight',
17716
'Down': 'ArrowDown',
17717
'Del': 'Delete',
17718
'Win': 'OS',
17719
'Menu': 'ContextMenu',
17720
'Apps': 'ContextMenu',
17721
'Scroll': 'ScrollLock',
17722
'MozPrintableKey': 'Unidentified'
17723
};
17724
17725
/**
17726
* Translation from legacy `keyCode` to HTML5 `key`
17727
* Only special keys supported, all others depend on keyboard layout or browser
17728
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
17729
*/
17730
var translateToKey = {
17731
8: 'Backspace',
17732
9: 'Tab',
17733
12: 'Clear',
17734
13: 'Enter',
17735
16: 'Shift',
17736
17: 'Control',
17737
18: 'Alt',
17738
19: 'Pause',
17739
20: 'CapsLock',
17740
27: 'Escape',
17741
32: ' ',
17742
33: 'PageUp',
17743
34: 'PageDown',
17744
35: 'End',
17745
36: 'Home',
17746
37: 'ArrowLeft',
17747
38: 'ArrowUp',
17748
39: 'ArrowRight',
17749
40: 'ArrowDown',
17750
45: 'Insert',
17751
46: 'Delete',
17752
112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
17753
118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
17754
144: 'NumLock',
17755
145: 'ScrollLock',
17756
224: 'Meta'
17757
};
17758
17759
/**
17760
* @param {object} nativeEvent Native browser event.
17761
* @return {string} Normalized `key` property.
17762
*/
17763
function getEventKey(nativeEvent) {
17764
if (nativeEvent.key) {
17765
// Normalize inconsistent values reported by browsers due to
17766
// implementations of a working draft specification.
17767
17768
// FireFox implements `key` but returns `MozPrintableKey` for all
17769
// printable characters (normalized to `Unidentified`), ignore it.
17770
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
17771
if (key !== 'Unidentified') {
17772
return key;
17773
}
17774
}
17775
17776
// Browser does not implement `key`, polyfill as much of it as we can.
17777
if (nativeEvent.type === 'keypress') {
17778
var charCode = getEventCharCode(nativeEvent);
17779
17780
// The enter-key is technically both printable and non-printable and can
17781
// thus be captured by `keypress`, no other non-printable key should.
17782
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
17783
}
17784
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
17785
// While user keyboard layout determines the actual meaning of each
17786
// `keyCode` value, almost all function keys have a universal value.
17787
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
17788
}
17789
return '';
17790
}
17791
17792
module.exports = getEventKey;
17793
17794
},{"122":122}],124:[function(_dereq_,module,exports){
17795
/**
17796
* Copyright 2013-2015, Facebook, Inc.
17797
* All rights reserved.
17798
*
17799
* This source code is licensed under the BSD-style license found in the
17800
* LICENSE file in the root directory of this source tree. An additional grant
17801
* of patent rights can be found in the PATENTS file in the same directory.
17802
*
17803
* @providesModule getEventModifierState
17804
* @typechecks static-only
17805
*/
17806
17807
'use strict';
17808
17809
/**
17810
* Translation from modifier key to the associated property in the event.
17811
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
17812
*/
17813
17814
var modifierKeyToProp = {
17815
'Alt': 'altKey',
17816
'Control': 'ctrlKey',
17817
'Meta': 'metaKey',
17818
'Shift': 'shiftKey'
17819
};
17820
17821
// IE8 does not implement getModifierState so we simply map it to the only
17822
// modifier keys exposed by the event itself, does not support Lock-keys.
17823
// Currently, all major browsers except Chrome seems to support Lock-keys.
17824
function modifierStateGetter(keyArg) {
17825
/*jshint validthis:true */
17826
var syntheticEvent = this;
17827
var nativeEvent = syntheticEvent.nativeEvent;
17828
if (nativeEvent.getModifierState) {
17829
return nativeEvent.getModifierState(keyArg);
17830
}
17831
var keyProp = modifierKeyToProp[keyArg];
17832
return keyProp ? !!nativeEvent[keyProp] : false;
17833
}
17834
17835
function getEventModifierState(nativeEvent) {
17836
return modifierStateGetter;
17837
}
17838
17839
module.exports = getEventModifierState;
17840
17841
},{}],125:[function(_dereq_,module,exports){
17842
/**
17843
* Copyright 2013-2015, Facebook, Inc.
17844
* All rights reserved.
17845
*
17846
* This source code is licensed under the BSD-style license found in the
17847
* LICENSE file in the root directory of this source tree. An additional grant
17848
* of patent rights can be found in the PATENTS file in the same directory.
17849
*
17850
* @providesModule getEventTarget
17851
* @typechecks static-only
17852
*/
17853
17854
'use strict';
17855
17856
/**
17857
* Gets the target node from a native browser event by accounting for
17858
* inconsistencies in browser DOM APIs.
17859
*
17860
* @param {object} nativeEvent Native browser event.
17861
* @return {DOMEventTarget} Target node.
17862
*/
17863
function getEventTarget(nativeEvent) {
17864
var target = nativeEvent.target || nativeEvent.srcElement || window;
17865
// Safari may fire events on text nodes (Node.TEXT_NODE is 3).
17866
// @see http://www.quirksmode.org/js/events_properties.html
17867
return target.nodeType === 3 ? target.parentNode : target;
17868
}
17869
17870
module.exports = getEventTarget;
17871
17872
},{}],126:[function(_dereq_,module,exports){
17873
/**
17874
* Copyright 2013-2015, Facebook, Inc.
17875
* All rights reserved.
17876
*
17877
* This source code is licensed under the BSD-style license found in the
17878
* LICENSE file in the root directory of this source tree. An additional grant
17879
* of patent rights can be found in the PATENTS file in the same directory.
17880
*
17881
* @providesModule getIteratorFn
17882
* @typechecks static-only
17883
*/
17884
17885
'use strict';
17886
17887
/* global Symbol */
17888
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
17889
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
17890
17891
/**
17892
* Returns the iterator method function contained on the iterable object.
17893
*
17894
* Be sure to invoke the function with the iterable as context:
17895
*
17896
* var iteratorFn = getIteratorFn(myIterable);
17897
* if (iteratorFn) {
17898
* var iterator = iteratorFn.call(myIterable);
17899
* ...
17900
* }
17901
*
17902
* @param {?object} maybeIterable
17903
* @return {?function}
17904
*/
17905
function getIteratorFn(maybeIterable) {
17906
var iteratorFn = maybeIterable && (
17907
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
17908
);
17909
if (typeof iteratorFn === 'function') {
17910
return iteratorFn;
17911
}
17912
}
17913
17914
module.exports = getIteratorFn;
17915
17916
},{}],127:[function(_dereq_,module,exports){
17917
/**
17918
* Copyright 2013-2015, Facebook, Inc.
17919
* All rights reserved.
17920
*
17921
* This source code is licensed under the BSD-style license found in the
17922
* LICENSE file in the root directory of this source tree. An additional grant
17923
* of patent rights can be found in the PATENTS file in the same directory.
17924
*
17925
* @providesModule getMarkupWrap
17926
*/
17927
17928
var ExecutionEnvironment = _dereq_(21);
17929
17930
var invariant = _dereq_(135);
17931
17932
/**
17933
* Dummy container used to detect which wraps are necessary.
17934
*/
17935
var dummyNode =
17936
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
17937
17938
/**
17939
* Some browsers cannot use `innerHTML` to render certain elements standalone,
17940
* so we wrap them, render the wrapped nodes, then extract the desired node.
17941
*
17942
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
17943
*/
17944
var shouldWrap = {
17945
// Force wrapping for SVG elements because if they get created inside a <div>,
17946
// they will be initialized in the wrong namespace (and will not display).
17947
'circle': true,
17948
'clipPath': true,
17949
'defs': true,
17950
'ellipse': true,
17951
'g': true,
17952
'line': true,
17953
'linearGradient': true,
17954
'path': true,
17955
'polygon': true,
17956
'polyline': true,
17957
'radialGradient': true,
17958
'rect': true,
17959
'stop': true,
17960
'text': true
17961
};
17962
17963
var selectWrap = [1, '<select multiple="true">', '</select>'];
17964
var tableWrap = [1, '<table>', '</table>'];
17965
var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
17966
17967
var svgWrap = [1, '<svg>', '</svg>'];
17968
17969
var markupWrap = {
17970
'*': [1, '?<div>', '</div>'],
17971
17972
'area': [1, '<map>', '</map>'],
17973
'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
17974
'legend': [1, '<fieldset>', '</fieldset>'],
17975
'param': [1, '<object>', '</object>'],
17976
'tr': [2, '<table><tbody>', '</tbody></table>'],
17977
17978
'optgroup': selectWrap,
17979
'option': selectWrap,
17980
17981
'caption': tableWrap,
17982
'colgroup': tableWrap,
17983
'tbody': tableWrap,
17984
'tfoot': tableWrap,
17985
'thead': tableWrap,
17986
17987
'td': trWrap,
17988
'th': trWrap,
17989
17990
'circle': svgWrap,
17991
'clipPath': svgWrap,
17992
'defs': svgWrap,
17993
'ellipse': svgWrap,
17994
'g': svgWrap,
17995
'line': svgWrap,
17996
'linearGradient': svgWrap,
17997
'path': svgWrap,
17998
'polygon': svgWrap,
17999
'polyline': svgWrap,
18000
'radialGradient': svgWrap,
18001
'rect': svgWrap,
18002
'stop': svgWrap,
18003
'text': svgWrap
18004
};
18005
18006
/**
18007
* Gets the markup wrap configuration for the supplied `nodeName`.
18008
*
18009
* NOTE: This lazily detects which wraps are necessary for the current browser.
18010
*
18011
* @param {string} nodeName Lowercase `nodeName`.
18012
* @return {?array} Markup wrap configuration, if applicable.
18013
*/
18014
function getMarkupWrap(nodeName) {
18015
("production" !== "development" ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
18016
if (!markupWrap.hasOwnProperty(nodeName)) {
18017
nodeName = '*';
18018
}
18019
if (!shouldWrap.hasOwnProperty(nodeName)) {
18020
if (nodeName === '*') {
18021
dummyNode.innerHTML = '<link />';
18022
} else {
18023
dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
18024
}
18025
shouldWrap[nodeName] = !dummyNode.firstChild;
18026
}
18027
return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
18028
}
18029
18030
18031
module.exports = getMarkupWrap;
18032
18033
},{"135":135,"21":21}],128:[function(_dereq_,module,exports){
18034
/**
18035
* Copyright 2013-2015, Facebook, Inc.
18036
* All rights reserved.
18037
*
18038
* This source code is licensed under the BSD-style license found in the
18039
* LICENSE file in the root directory of this source tree. An additional grant
18040
* of patent rights can be found in the PATENTS file in the same directory.
18041
*
18042
* @providesModule getNodeForCharacterOffset
18043
*/
18044
18045
'use strict';
18046
18047
/**
18048
* Given any node return the first leaf node without children.
18049
*
18050
* @param {DOMElement|DOMTextNode} node
18051
* @return {DOMElement|DOMTextNode}
18052
*/
18053
function getLeafNode(node) {
18054
while (node && node.firstChild) {
18055
node = node.firstChild;
18056
}
18057
return node;
18058
}
18059
18060
/**
18061
* Get the next sibling within a container. This will walk up the
18062
* DOM if a node's siblings have been exhausted.
18063
*
18064
* @param {DOMElement|DOMTextNode} node
18065
* @return {?DOMElement|DOMTextNode}
18066
*/
18067
function getSiblingNode(node) {
18068
while (node) {
18069
if (node.nextSibling) {
18070
return node.nextSibling;
18071
}
18072
node = node.parentNode;
18073
}
18074
}
18075
18076
/**
18077
* Get object describing the nodes which contain characters at offset.
18078
*
18079
* @param {DOMElement|DOMTextNode} root
18080
* @param {number} offset
18081
* @return {?object}
18082
*/
18083
function getNodeForCharacterOffset(root, offset) {
18084
var node = getLeafNode(root);
18085
var nodeStart = 0;
18086
var nodeEnd = 0;
18087
18088
while (node) {
18089
if (node.nodeType === 3) {
18090
nodeEnd = nodeStart + node.textContent.length;
18091
18092
if (nodeStart <= offset && nodeEnd >= offset) {
18093
return {
18094
node: node,
18095
offset: offset - nodeStart
18096
};
18097
}
18098
18099
nodeStart = nodeEnd;
18100
}
18101
18102
node = getLeafNode(getSiblingNode(node));
18103
}
18104
}
18105
18106
module.exports = getNodeForCharacterOffset;
18107
18108
},{}],129:[function(_dereq_,module,exports){
18109
/**
18110
* Copyright 2013-2015, Facebook, Inc.
18111
* All rights reserved.
18112
*
18113
* This source code is licensed under the BSD-style license found in the
18114
* LICENSE file in the root directory of this source tree. An additional grant
18115
* of patent rights can be found in the PATENTS file in the same directory.
18116
*
18117
* @providesModule getReactRootElementInContainer
18118
*/
18119
18120
'use strict';
18121
18122
var DOC_NODE_TYPE = 9;
18123
18124
/**
18125
* @param {DOMElement|DOMDocument} container DOM element that may contain
18126
* a React component
18127
* @return {?*} DOM element that may have the reactRoot ID, or null.
18128
*/
18129
function getReactRootElementInContainer(container) {
18130
if (!container) {
18131
return null;
18132
}
18133
18134
if (container.nodeType === DOC_NODE_TYPE) {
18135
return container.documentElement;
18136
} else {
18137
return container.firstChild;
18138
}
18139
}
18140
18141
module.exports = getReactRootElementInContainer;
18142
18143
},{}],130:[function(_dereq_,module,exports){
18144
/**
18145
* Copyright 2013-2015, Facebook, Inc.
18146
* All rights reserved.
18147
*
18148
* This source code is licensed under the BSD-style license found in the
18149
* LICENSE file in the root directory of this source tree. An additional grant
18150
* of patent rights can be found in the PATENTS file in the same directory.
18151
*
18152
* @providesModule getTextContentAccessor
18153
*/
18154
18155
'use strict';
18156
18157
var ExecutionEnvironment = _dereq_(21);
18158
18159
var contentKey = null;
18160
18161
/**
18162
* Gets the key used to access text content on a DOM node.
18163
*
18164
* @return {?string} Key used to access text content.
18165
* @internal
18166
*/
18167
function getTextContentAccessor() {
18168
if (!contentKey && ExecutionEnvironment.canUseDOM) {
18169
// Prefer textContent to innerText because many browsers support both but
18170
// SVG <text> elements don't support innerText even when <div> does.
18171
contentKey = 'textContent' in document.documentElement ?
18172
'textContent' :
18173
'innerText';
18174
}
18175
return contentKey;
18176
}
18177
18178
module.exports = getTextContentAccessor;
18179
18180
},{"21":21}],131:[function(_dereq_,module,exports){
18181
/**
18182
* Copyright 2013-2015, Facebook, Inc.
18183
* All rights reserved.
18184
*
18185
* This source code is licensed under the BSD-style license found in the
18186
* LICENSE file in the root directory of this source tree. An additional grant
18187
* of patent rights can be found in the PATENTS file in the same directory.
18188
*
18189
* @providesModule getUnboundedScrollPosition
18190
* @typechecks
18191
*/
18192
18193
"use strict";
18194
18195
/**
18196
* Gets the scroll position of the supplied element or window.
18197
*
18198
* The return values are unbounded, unlike `getScrollPosition`. This means they
18199
* may be negative or exceed the element boundaries (which is possible using
18200
* inertial scrolling).
18201
*
18202
* @param {DOMWindow|DOMElement} scrollable
18203
* @return {object} Map with `x` and `y` keys.
18204
*/
18205
function getUnboundedScrollPosition(scrollable) {
18206
if (scrollable === window) {
18207
return {
18208
x: window.pageXOffset || document.documentElement.scrollLeft,
18209
y: window.pageYOffset || document.documentElement.scrollTop
18210
};
18211
}
18212
return {
18213
x: scrollable.scrollLeft,
18214
y: scrollable.scrollTop
18215
};
18216
}
18217
18218
module.exports = getUnboundedScrollPosition;
18219
18220
},{}],132:[function(_dereq_,module,exports){
18221
/**
18222
* Copyright 2013-2015, Facebook, Inc.
18223
* All rights reserved.
18224
*
18225
* This source code is licensed under the BSD-style license found in the
18226
* LICENSE file in the root directory of this source tree. An additional grant
18227
* of patent rights can be found in the PATENTS file in the same directory.
18228
*
18229
* @providesModule hyphenate
18230
* @typechecks
18231
*/
18232
18233
var _uppercasePattern = /([A-Z])/g;
18234
18235
/**
18236
* Hyphenates a camelcased string, for example:
18237
*
18238
* > hyphenate('backgroundColor')
18239
* < "background-color"
18240
*
18241
* For CSS style names, use `hyphenateStyleName` instead which works properly
18242
* with all vendor prefixes, including `ms`.
18243
*
18244
* @param {string} string
18245
* @return {string}
18246
*/
18247
function hyphenate(string) {
18248
return string.replace(_uppercasePattern, '-$1').toLowerCase();
18249
}
18250
18251
module.exports = hyphenate;
18252
18253
},{}],133:[function(_dereq_,module,exports){
18254
/**
18255
* Copyright 2013-2015, Facebook, Inc.
18256
* All rights reserved.
18257
*
18258
* This source code is licensed under the BSD-style license found in the
18259
* LICENSE file in the root directory of this source tree. An additional grant
18260
* of patent rights can be found in the PATENTS file in the same directory.
18261
*
18262
* @providesModule hyphenateStyleName
18263
* @typechecks
18264
*/
18265
18266
"use strict";
18267
18268
var hyphenate = _dereq_(132);
18269
18270
var msPattern = /^ms-/;
18271
18272
/**
18273
* Hyphenates a camelcased CSS property name, for example:
18274
*
18275
* > hyphenateStyleName('backgroundColor')
18276
* < "background-color"
18277
* > hyphenateStyleName('MozTransition')
18278
* < "-moz-transition"
18279
* > hyphenateStyleName('msTransition')
18280
* < "-ms-transition"
18281
*
18282
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
18283
* is converted to `-ms-`.
18284
*
18285
* @param {string} string
18286
* @return {string}
18287
*/
18288
function hyphenateStyleName(string) {
18289
return hyphenate(string).replace(msPattern, '-ms-');
18290
}
18291
18292
module.exports = hyphenateStyleName;
18293
18294
},{"132":132}],134:[function(_dereq_,module,exports){
18295
/**
18296
* Copyright 2013-2015, Facebook, Inc.
18297
* All rights reserved.
18298
*
18299
* This source code is licensed under the BSD-style license found in the
18300
* LICENSE file in the root directory of this source tree. An additional grant
18301
* of patent rights can be found in the PATENTS file in the same directory.
18302
*
18303
* @providesModule instantiateReactComponent
18304
* @typechecks static-only
18305
*/
18306
18307
'use strict';
18308
18309
var ReactCompositeComponent = _dereq_(37);
18310
var ReactEmptyComponent = _dereq_(59);
18311
var ReactNativeComponent = _dereq_(73);
18312
18313
var assign = _dereq_(27);
18314
var invariant = _dereq_(135);
18315
var warning = _dereq_(154);
18316
18317
// To avoid a cyclic dependency, we create the final class in this module
18318
var ReactCompositeComponentWrapper = function() { };
18319
assign(
18320
ReactCompositeComponentWrapper.prototype,
18321
ReactCompositeComponent.Mixin,
18322
{
18323
_instantiateReactComponent: instantiateReactComponent
18324
}
18325
);
18326
18327
/**
18328
* Check if the type reference is a known internal type. I.e. not a user
18329
* provided composite type.
18330
*
18331
* @param {function} type
18332
* @return {boolean} Returns true if this is a valid internal type.
18333
*/
18334
function isInternalComponentType(type) {
18335
return (
18336
typeof type === 'function' &&
18337
typeof type.prototype !== 'undefined' &&
18338
typeof type.prototype.mountComponent === 'function' &&
18339
typeof type.prototype.receiveComponent === 'function'
18340
);
18341
}
18342
18343
/**
18344
* Given a ReactNode, create an instance that will actually be mounted.
18345
*
18346
* @param {ReactNode} node
18347
* @param {*} parentCompositeType The composite type that resolved this.
18348
* @return {object} A new instance of the element's constructor.
18349
* @protected
18350
*/
18351
function instantiateReactComponent(node, parentCompositeType) {
18352
var instance;
18353
18354
if (node === null || node === false) {
18355
node = ReactEmptyComponent.emptyElement;
18356
}
18357
18358
if (typeof node === 'object') {
18359
var element = node;
18360
if ("production" !== "development") {
18361
("production" !== "development" ? warning(
18362
element && (typeof element.type === 'function' ||
18363
typeof element.type === 'string'),
18364
'Only functions or strings can be mounted as React components.'
18365
) : null);
18366
}
18367
18368
// Special case string values
18369
if (parentCompositeType === element.type &&
18370
typeof element.type === 'string') {
18371
// Avoid recursion if the wrapper renders itself.
18372
instance = ReactNativeComponent.createInternalComponent(element);
18373
// All native components are currently wrapped in a composite so we're
18374
// safe to assume that this is what we should instantiate.
18375
} else if (isInternalComponentType(element.type)) {
18376
// This is temporarily available for custom components that are not string
18377
// represenations. I.e. ART. Once those are updated to use the string
18378
// representation, we can drop this code path.
18379
instance = new element.type(element);
18380
} else {
18381
instance = new ReactCompositeComponentWrapper();
18382
}
18383
} else if (typeof node === 'string' || typeof node === 'number') {
18384
instance = ReactNativeComponent.createInstanceForText(node);
18385
} else {
18386
("production" !== "development" ? invariant(
18387
false,
18388
'Encountered invalid React node of type %s',
18389
typeof node
18390
) : invariant(false));
18391
}
18392
18393
if ("production" !== "development") {
18394
("production" !== "development" ? warning(
18395
typeof instance.construct === 'function' &&
18396
typeof instance.mountComponent === 'function' &&
18397
typeof instance.receiveComponent === 'function' &&
18398
typeof instance.unmountComponent === 'function',
18399
'Only React Components can be mounted.'
18400
) : null);
18401
}
18402
18403
// Sets up the instance. This can probably just move into the constructor now.
18404
instance.construct(node);
18405
18406
// These two fields are used by the DOM and ART diffing algorithms
18407
// respectively. Instead of using expandos on components, we should be
18408
// storing the state needed by the diffing algorithms elsewhere.
18409
instance._mountIndex = 0;
18410
instance._mountImage = null;
18411
18412
if ("production" !== "development") {
18413
instance._isOwnerNecessary = false;
18414
instance._warnedAboutRefsInRender = false;
18415
}
18416
18417
// Internal instances should fully constructed at this point, so they should
18418
// not get any new fields added to them at this point.
18419
if ("production" !== "development") {
18420
if (Object.preventExtensions) {
18421
Object.preventExtensions(instance);
18422
}
18423
}
18424
18425
return instance;
18426
}
18427
18428
module.exports = instantiateReactComponent;
18429
18430
},{"135":135,"154":154,"27":27,"37":37,"59":59,"73":73}],135:[function(_dereq_,module,exports){
18431
/**
18432
* Copyright 2013-2015, Facebook, Inc.
18433
* All rights reserved.
18434
*
18435
* This source code is licensed under the BSD-style license found in the
18436
* LICENSE file in the root directory of this source tree. An additional grant
18437
* of patent rights can be found in the PATENTS file in the same directory.
18438
*
18439
* @providesModule invariant
18440
*/
18441
18442
"use strict";
18443
18444
/**
18445
* Use invariant() to assert state which your program assumes to be true.
18446
*
18447
* Provide sprintf-style format (only %s is supported) and arguments
18448
* to provide information about what broke and what you were
18449
* expecting.
18450
*
18451
* The invariant message will be stripped in production, but the invariant
18452
* will remain to ensure logic does not differ in production.
18453
*/
18454
18455
var invariant = function(condition, format, a, b, c, d, e, f) {
18456
if ("production" !== "development") {
18457
if (format === undefined) {
18458
throw new Error('invariant requires an error message argument');
18459
}
18460
}
18461
18462
if (!condition) {
18463
var error;
18464
if (format === undefined) {
18465
error = new Error(
18466
'Minified exception occurred; use the non-minified dev environment ' +
18467
'for the full error message and additional helpful warnings.'
18468
);
18469
} else {
18470
var args = [a, b, c, d, e, f];
18471
var argIndex = 0;
18472
error = new Error(
18473
'Invariant Violation: ' +
18474
format.replace(/%s/g, function() { return args[argIndex++]; })
18475
);
18476
}
18477
18478
error.framesToPop = 1; // we don't care about invariant's own frame
18479
throw error;
18480
}
18481
};
18482
18483
module.exports = invariant;
18484
18485
},{}],136:[function(_dereq_,module,exports){
18486
/**
18487
* Copyright 2013-2015, Facebook, Inc.
18488
* All rights reserved.
18489
*
18490
* This source code is licensed under the BSD-style license found in the
18491
* LICENSE file in the root directory of this source tree. An additional grant
18492
* of patent rights can be found in the PATENTS file in the same directory.
18493
*
18494
* @providesModule isEventSupported
18495
*/
18496
18497
'use strict';
18498
18499
var ExecutionEnvironment = _dereq_(21);
18500
18501
var useHasFeature;
18502
if (ExecutionEnvironment.canUseDOM) {
18503
useHasFeature =
18504
document.implementation &&
18505
document.implementation.hasFeature &&
18506
// always returns true in newer browsers as per the standard.
18507
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
18508
document.implementation.hasFeature('', '') !== true;
18509
}
18510
18511
/**
18512
* Checks if an event is supported in the current execution environment.
18513
*
18514
* NOTE: This will not work correctly for non-generic events such as `change`,
18515
* `reset`, `load`, `error`, and `select`.
18516
*
18517
* Borrows from Modernizr.
18518
*
18519
* @param {string} eventNameSuffix Event name, e.g. "click".
18520
* @param {?boolean} capture Check if the capture phase is supported.
18521
* @return {boolean} True if the event is supported.
18522
* @internal
18523
* @license Modernizr 3.0.0pre (Custom Build) | MIT
18524
*/
18525
function isEventSupported(eventNameSuffix, capture) {
18526
if (!ExecutionEnvironment.canUseDOM ||
18527
capture && !('addEventListener' in document)) {
18528
return false;
18529
}
18530
18531
var eventName = 'on' + eventNameSuffix;
18532
var isSupported = eventName in document;
18533
18534
if (!isSupported) {
18535
var element = document.createElement('div');
18536
element.setAttribute(eventName, 'return;');
18537
isSupported = typeof element[eventName] === 'function';
18538
}
18539
18540
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
18541
// This is the only way to test support for the `wheel` event in IE9+.
18542
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
18543
}
18544
18545
return isSupported;
18546
}
18547
18548
module.exports = isEventSupported;
18549
18550
},{"21":21}],137:[function(_dereq_,module,exports){
18551
/**
18552
* Copyright 2013-2015, Facebook, Inc.
18553
* All rights reserved.
18554
*
18555
* This source code is licensed under the BSD-style license found in the
18556
* LICENSE file in the root directory of this source tree. An additional grant
18557
* of patent rights can be found in the PATENTS file in the same directory.
18558
*
18559
* @providesModule isNode
18560
* @typechecks
18561
*/
18562
18563
/**
18564
* @param {*} object The object to check.
18565
* @return {boolean} Whether or not the object is a DOM node.
18566
*/
18567
function isNode(object) {
18568
return !!(object && (
18569
((typeof Node === 'function' ? object instanceof Node : typeof object === 'object' &&
18570
typeof object.nodeType === 'number' &&
18571
typeof object.nodeName === 'string'))
18572
));
18573
}
18574
18575
module.exports = isNode;
18576
18577
},{}],138:[function(_dereq_,module,exports){
18578
/**
18579
* Copyright 2013-2015, Facebook, Inc.
18580
* All rights reserved.
18581
*
18582
* This source code is licensed under the BSD-style license found in the
18583
* LICENSE file in the root directory of this source tree. An additional grant
18584
* of patent rights can be found in the PATENTS file in the same directory.
18585
*
18586
* @providesModule isTextInputElement
18587
*/
18588
18589
'use strict';
18590
18591
/**
18592
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
18593
*/
18594
var supportedInputTypes = {
18595
'color': true,
18596
'date': true,
18597
'datetime': true,
18598
'datetime-local': true,
18599
'email': true,
18600
'month': true,
18601
'number': true,
18602
'password': true,
18603
'range': true,
18604
'search': true,
18605
'tel': true,
18606
'text': true,
18607
'time': true,
18608
'url': true,
18609
'week': true
18610
};
18611
18612
function isTextInputElement(elem) {
18613
return elem && (
18614
(elem.nodeName === 'INPUT' && supportedInputTypes[elem.type] || elem.nodeName === 'TEXTAREA')
18615
);
18616
}
18617
18618
module.exports = isTextInputElement;
18619
18620
},{}],139:[function(_dereq_,module,exports){
18621
/**
18622
* Copyright 2013-2015, Facebook, Inc.
18623
* All rights reserved.
18624
*
18625
* This source code is licensed under the BSD-style license found in the
18626
* LICENSE file in the root directory of this source tree. An additional grant
18627
* of patent rights can be found in the PATENTS file in the same directory.
18628
*
18629
* @providesModule isTextNode
18630
* @typechecks
18631
*/
18632
18633
var isNode = _dereq_(137);
18634
18635
/**
18636
* @param {*} object The object to check.
18637
* @return {boolean} Whether or not the object is a DOM text node.
18638
*/
18639
function isTextNode(object) {
18640
return isNode(object) && object.nodeType == 3;
18641
}
18642
18643
module.exports = isTextNode;
18644
18645
},{"137":137}],140:[function(_dereq_,module,exports){
18646
/**
18647
* Copyright 2013-2015, Facebook, Inc.
18648
* All rights reserved.
18649
*
18650
* This source code is licensed under the BSD-style license found in the
18651
* LICENSE file in the root directory of this source tree. An additional grant
18652
* of patent rights can be found in the PATENTS file in the same directory.
18653
*
18654
* @providesModule keyMirror
18655
* @typechecks static-only
18656
*/
18657
18658
'use strict';
18659
18660
var invariant = _dereq_(135);
18661
18662
/**
18663
* Constructs an enumeration with keys equal to their value.
18664
*
18665
* For example:
18666
*
18667
* var COLORS = keyMirror({blue: null, red: null});
18668
* var myColor = COLORS.blue;
18669
* var isColorValid = !!COLORS[myColor];
18670
*
18671
* The last line could not be performed if the values of the generated enum were
18672
* not equal to their keys.
18673
*
18674
* Input: {key1: val1, key2: val2}
18675
* Output: {key1: key1, key2: key2}
18676
*
18677
* @param {object} obj
18678
* @return {object}
18679
*/
18680
var keyMirror = function(obj) {
18681
var ret = {};
18682
var key;
18683
("production" !== "development" ? invariant(
18684
obj instanceof Object && !Array.isArray(obj),
18685
'keyMirror(...): Argument must be an object.'
18686
) : invariant(obj instanceof Object && !Array.isArray(obj)));
18687
for (key in obj) {
18688
if (!obj.hasOwnProperty(key)) {
18689
continue;
18690
}
18691
ret[key] = key;
18692
}
18693
return ret;
18694
};
18695
18696
module.exports = keyMirror;
18697
18698
},{"135":135}],141:[function(_dereq_,module,exports){
18699
/**
18700
* Copyright 2013-2015, Facebook, Inc.
18701
* All rights reserved.
18702
*
18703
* This source code is licensed under the BSD-style license found in the
18704
* LICENSE file in the root directory of this source tree. An additional grant
18705
* of patent rights can be found in the PATENTS file in the same directory.
18706
*
18707
* @providesModule keyOf
18708
*/
18709
18710
/**
18711
* Allows extraction of a minified key. Let's the build system minify keys
18712
* without loosing the ability to dynamically use key strings as values
18713
* themselves. Pass in an object with a single key/val pair and it will return
18714
* you the string key of that single record. Suppose you want to grab the
18715
* value for a key 'className' inside of an object. Key/val minification may
18716
* have aliased that key to be 'xa12'. keyOf({className: null}) will return
18717
* 'xa12' in that case. Resolve keys you want to use once at startup time, then
18718
* reuse those resolutions.
18719
*/
18720
var keyOf = function(oneKeyObj) {
18721
var key;
18722
for (key in oneKeyObj) {
18723
if (!oneKeyObj.hasOwnProperty(key)) {
18724
continue;
18725
}
18726
return key;
18727
}
18728
return null;
18729
};
18730
18731
18732
module.exports = keyOf;
18733
18734
},{}],142:[function(_dereq_,module,exports){
18735
/**
18736
* Copyright 2013-2015, Facebook, Inc.
18737
* All rights reserved.
18738
*
18739
* This source code is licensed under the BSD-style license found in the
18740
* LICENSE file in the root directory of this source tree. An additional grant
18741
* of patent rights can be found in the PATENTS file in the same directory.
18742
*
18743
* @providesModule mapObject
18744
*/
18745
18746
'use strict';
18747
18748
var hasOwnProperty = Object.prototype.hasOwnProperty;
18749
18750
/**
18751
* Executes the provided `callback` once for each enumerable own property in the
18752
* object and constructs a new object from the results. The `callback` is
18753
* invoked with three arguments:
18754
*
18755
* - the property value
18756
* - the property name
18757
* - the object being traversed
18758
*
18759
* Properties that are added after the call to `mapObject` will not be visited
18760
* by `callback`. If the values of existing properties are changed, the value
18761
* passed to `callback` will be the value at the time `mapObject` visits them.
18762
* Properties that are deleted before being visited are not visited.
18763
*
18764
* @grep function objectMap()
18765
* @grep function objMap()
18766
*
18767
* @param {?object} object
18768
* @param {function} callback
18769
* @param {*} context
18770
* @return {?object}
18771
*/
18772
function mapObject(object, callback, context) {
18773
if (!object) {
18774
return null;
18775
}
18776
var result = {};
18777
for (var name in object) {
18778
if (hasOwnProperty.call(object, name)) {
18779
result[name] = callback.call(context, object[name], name, object);
18780
}
18781
}
18782
return result;
18783
}
18784
18785
module.exports = mapObject;
18786
18787
},{}],143:[function(_dereq_,module,exports){
18788
/**
18789
* Copyright 2013-2015, Facebook, Inc.
18790
* All rights reserved.
18791
*
18792
* This source code is licensed under the BSD-style license found in the
18793
* LICENSE file in the root directory of this source tree. An additional grant
18794
* of patent rights can be found in the PATENTS file in the same directory.
18795
*
18796
* @providesModule memoizeStringOnly
18797
* @typechecks static-only
18798
*/
18799
18800
'use strict';
18801
18802
/**
18803
* Memoizes the return value of a function that accepts one string argument.
18804
*
18805
* @param {function} callback
18806
* @return {function}
18807
*/
18808
function memoizeStringOnly(callback) {
18809
var cache = {};
18810
return function(string) {
18811
if (!cache.hasOwnProperty(string)) {
18812
cache[string] = callback.call(this, string);
18813
}
18814
return cache[string];
18815
};
18816
}
18817
18818
module.exports = memoizeStringOnly;
18819
18820
},{}],144:[function(_dereq_,module,exports){
18821
/**
18822
* Copyright 2013-2015, Facebook, Inc.
18823
* All rights reserved.
18824
*
18825
* This source code is licensed under the BSD-style license found in the
18826
* LICENSE file in the root directory of this source tree. An additional grant
18827
* of patent rights can be found in the PATENTS file in the same directory.
18828
*
18829
* @providesModule onlyChild
18830
*/
18831
'use strict';
18832
18833
var ReactElement = _dereq_(57);
18834
18835
var invariant = _dereq_(135);
18836
18837
/**
18838
* Returns the first child in a collection of children and verifies that there
18839
* is only one child in the collection. The current implementation of this
18840
* function assumes that a single child gets passed without a wrapper, but the
18841
* purpose of this helper function is to abstract away the particular structure
18842
* of children.
18843
*
18844
* @param {?object} children Child collection structure.
18845
* @return {ReactComponent} The first and only `ReactComponent` contained in the
18846
* structure.
18847
*/
18848
function onlyChild(children) {
18849
("production" !== "development" ? invariant(
18850
ReactElement.isValidElement(children),
18851
'onlyChild must be passed a children with exactly one child.'
18852
) : invariant(ReactElement.isValidElement(children)));
18853
return children;
18854
}
18855
18856
module.exports = onlyChild;
18857
18858
},{"135":135,"57":57}],145:[function(_dereq_,module,exports){
18859
/**
18860
* Copyright 2013-2015, Facebook, Inc.
18861
* All rights reserved.
18862
*
18863
* This source code is licensed under the BSD-style license found in the
18864
* LICENSE file in the root directory of this source tree. An additional grant
18865
* of patent rights can be found in the PATENTS file in the same directory.
18866
*
18867
* @providesModule performance
18868
* @typechecks
18869
*/
18870
18871
"use strict";
18872
18873
var ExecutionEnvironment = _dereq_(21);
18874
18875
var performance;
18876
18877
if (ExecutionEnvironment.canUseDOM) {
18878
performance =
18879
window.performance ||
18880
window.msPerformance ||
18881
window.webkitPerformance;
18882
}
18883
18884
module.exports = performance || {};
18885
18886
},{"21":21}],146:[function(_dereq_,module,exports){
18887
/**
18888
* Copyright 2013-2015, Facebook, Inc.
18889
* All rights reserved.
18890
*
18891
* This source code is licensed under the BSD-style license found in the
18892
* LICENSE file in the root directory of this source tree. An additional grant
18893
* of patent rights can be found in the PATENTS file in the same directory.
18894
*
18895
* @providesModule performanceNow
18896
* @typechecks
18897
*/
18898
18899
var performance = _dereq_(145);
18900
18901
/**
18902
* Detect if we can use `window.performance.now()` and gracefully fallback to
18903
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
18904
* because of Facebook's testing infrastructure.
18905
*/
18906
if (!performance || !performance.now) {
18907
performance = Date;
18908
}
18909
18910
var performanceNow = performance.now.bind(performance);
18911
18912
module.exports = performanceNow;
18913
18914
},{"145":145}],147:[function(_dereq_,module,exports){
18915
/**
18916
* Copyright 2013-2015, Facebook, Inc.
18917
* All rights reserved.
18918
*
18919
* This source code is licensed under the BSD-style license found in the
18920
* LICENSE file in the root directory of this source tree. An additional grant
18921
* of patent rights can be found in the PATENTS file in the same directory.
18922
*
18923
* @providesModule quoteAttributeValueForBrowser
18924
*/
18925
18926
'use strict';
18927
18928
var escapeTextContentForBrowser = _dereq_(116);
18929
18930
/**
18931
* Escapes attribute value to prevent scripting attacks.
18932
*
18933
* @param {*} value Value to escape.
18934
* @return {string} An escaped string.
18935
*/
18936
function quoteAttributeValueForBrowser(value) {
18937
return '"' + escapeTextContentForBrowser(value) + '"';
18938
}
18939
18940
module.exports = quoteAttributeValueForBrowser;
18941
18942
},{"116":116}],148:[function(_dereq_,module,exports){
18943
/**
18944
* Copyright 2013-2015, Facebook, Inc.
18945
* All rights reserved.
18946
*
18947
* This source code is licensed under the BSD-style license found in the
18948
* LICENSE file in the root directory of this source tree. An additional grant
18949
* of patent rights can be found in the PATENTS file in the same directory.
18950
*
18951
* @providesModule setInnerHTML
18952
*/
18953
18954
/* globals MSApp */
18955
18956
'use strict';
18957
18958
var ExecutionEnvironment = _dereq_(21);
18959
18960
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
18961
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
18962
18963
/**
18964
* Set the innerHTML property of a node, ensuring that whitespace is preserved
18965
* even in IE8.
18966
*
18967
* @param {DOMElement} node
18968
* @param {string} html
18969
* @internal
18970
*/
18971
var setInnerHTML = function(node, html) {
18972
node.innerHTML = html;
18973
};
18974
18975
// Win8 apps: Allow all html to be inserted
18976
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
18977
setInnerHTML = function(node, html) {
18978
MSApp.execUnsafeLocalFunction(function() {
18979
node.innerHTML = html;
18980
});
18981
};
18982
}
18983
18984
if (ExecutionEnvironment.canUseDOM) {
18985
// IE8: When updating a just created node with innerHTML only leading
18986
// whitespace is removed. When updating an existing node with innerHTML
18987
// whitespace in root TextNodes is also collapsed.
18988
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
18989
18990
// Feature detection; only IE8 is known to behave improperly like this.
18991
var testElement = document.createElement('div');
18992
testElement.innerHTML = ' ';
18993
if (testElement.innerHTML === '') {
18994
setInnerHTML = function(node, html) {
18995
// Magic theory: IE8 supposedly differentiates between added and updated
18996
// nodes when processing innerHTML, innerHTML on updated nodes suffers
18997
// from worse whitespace behavior. Re-adding a node like this triggers
18998
// the initial and more favorable whitespace behavior.
18999
// TODO: What to do on a detached node?
19000
if (node.parentNode) {
19001
node.parentNode.replaceChild(node, node);
19002
}
19003
19004
// We also implement a workaround for non-visible tags disappearing into
19005
// thin air on IE8, this only happens if there is no visible text
19006
// in-front of the non-visible tags. Piggyback on the whitespace fix
19007
// and simply check if any non-visible tags appear in the source.
19008
if (WHITESPACE_TEST.test(html) ||
19009
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
19010
// Recover leading whitespace by temporarily prepending any character.
19011
// \uFEFF has the potential advantage of being zero-width/invisible.
19012
node.innerHTML = '\uFEFF' + html;
19013
19014
// deleteData leaves an empty `TextNode` which offsets the index of all
19015
// children. Definitely want to avoid this.
19016
var textNode = node.firstChild;
19017
if (textNode.data.length === 1) {
19018
node.removeChild(textNode);
19019
} else {
19020
textNode.deleteData(0, 1);
19021
}
19022
} else {
19023
node.innerHTML = html;
19024
}
19025
};
19026
}
19027
}
19028
19029
module.exports = setInnerHTML;
19030
19031
},{"21":21}],149:[function(_dereq_,module,exports){
19032
/**
19033
* Copyright 2013-2015, Facebook, Inc.
19034
* All rights reserved.
19035
*
19036
* This source code is licensed under the BSD-style license found in the
19037
* LICENSE file in the root directory of this source tree. An additional grant
19038
* of patent rights can be found in the PATENTS file in the same directory.
19039
*
19040
* @providesModule setTextContent
19041
*/
19042
19043
'use strict';
19044
19045
var ExecutionEnvironment = _dereq_(21);
19046
var escapeTextContentForBrowser = _dereq_(116);
19047
var setInnerHTML = _dereq_(148);
19048
19049
/**
19050
* Set the textContent property of a node, ensuring that whitespace is preserved
19051
* even in IE8. innerText is a poor substitute for textContent and, among many
19052
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
19053
* as it should.
19054
*
19055
* @param {DOMElement} node
19056
* @param {string} text
19057
* @internal
19058
*/
19059
var setTextContent = function(node, text) {
19060
node.textContent = text;
19061
};
19062
19063
if (ExecutionEnvironment.canUseDOM) {
19064
if (!('textContent' in document.documentElement)) {
19065
setTextContent = function(node, text) {
19066
setInnerHTML(node, escapeTextContentForBrowser(text));
19067
};
19068
}
19069
}
19070
19071
module.exports = setTextContent;
19072
19073
},{"116":116,"148":148,"21":21}],150:[function(_dereq_,module,exports){
19074
/**
19075
* Copyright 2013-2015, Facebook, Inc.
19076
* All rights reserved.
19077
*
19078
* This source code is licensed under the BSD-style license found in the
19079
* LICENSE file in the root directory of this source tree. An additional grant
19080
* of patent rights can be found in the PATENTS file in the same directory.
19081
*
19082
* @providesModule shallowEqual
19083
*/
19084
19085
'use strict';
19086
19087
/**
19088
* Performs equality by iterating through keys on an object and returning
19089
* false when any key has values which are not strictly equal between
19090
* objA and objB. Returns true when the values of all keys are strictly equal.
19091
*
19092
* @return {boolean}
19093
*/
19094
function shallowEqual(objA, objB) {
19095
if (objA === objB) {
19096
return true;
19097
}
19098
var key;
19099
// Test for A's keys different from B.
19100
for (key in objA) {
19101
if (objA.hasOwnProperty(key) &&
19102
(!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
19103
return false;
19104
}
19105
}
19106
// Test for B's keys missing from A.
19107
for (key in objB) {
19108
if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
19109
return false;
19110
}
19111
}
19112
return true;
19113
}
19114
19115
module.exports = shallowEqual;
19116
19117
},{}],151:[function(_dereq_,module,exports){
19118
/**
19119
* Copyright 2013-2015, Facebook, Inc.
19120
* All rights reserved.
19121
*
19122
* This source code is licensed under the BSD-style license found in the
19123
* LICENSE file in the root directory of this source tree. An additional grant
19124
* of patent rights can be found in the PATENTS file in the same directory.
19125
*
19126
* @providesModule shouldUpdateReactComponent
19127
* @typechecks static-only
19128
*/
19129
19130
'use strict';
19131
19132
var warning = _dereq_(154);
19133
19134
/**
19135
* Given a `prevElement` and `nextElement`, determines if the existing
19136
* instance should be updated as opposed to being destroyed or replaced by a new
19137
* instance. Both arguments are elements. This ensures that this logic can
19138
* operate on stateless trees without any backing instance.
19139
*
19140
* @param {?object} prevElement
19141
* @param {?object} nextElement
19142
* @return {boolean} True if the existing instance should be updated.
19143
* @protected
19144
*/
19145
function shouldUpdateReactComponent(prevElement, nextElement) {
19146
if (prevElement != null && nextElement != null) {
19147
var prevType = typeof prevElement;
19148
var nextType = typeof nextElement;
19149
if (prevType === 'string' || prevType === 'number') {
19150
return (nextType === 'string' || nextType === 'number');
19151
} else {
19152
if (nextType === 'object' &&
19153
prevElement.type === nextElement.type &&
19154
prevElement.key === nextElement.key) {
19155
var ownersMatch = prevElement._owner === nextElement._owner;
19156
var prevName = null;
19157
var nextName = null;
19158
var nextDisplayName = null;
19159
if ("production" !== "development") {
19160
if (!ownersMatch) {
19161
if (prevElement._owner != null &&
19162
prevElement._owner.getPublicInstance() != null &&
19163
prevElement._owner.getPublicInstance().constructor != null) {
19164
prevName =
19165
prevElement._owner.getPublicInstance().constructor.displayName;
19166
}
19167
if (nextElement._owner != null &&
19168
nextElement._owner.getPublicInstance() != null &&
19169
nextElement._owner.getPublicInstance().constructor != null) {
19170
nextName =
19171
nextElement._owner.getPublicInstance().constructor.displayName;
19172
}
19173
if (nextElement.type != null &&
19174
nextElement.type.displayName != null) {
19175
nextDisplayName = nextElement.type.displayName;
19176
}
19177
if (nextElement.type != null && typeof nextElement.type === 'string') {
19178
nextDisplayName = nextElement.type;
19179
}
19180
if (typeof nextElement.type !== 'string' ||
19181
nextElement.type === 'input' ||
19182
nextElement.type === 'textarea') {
19183
if ((prevElement._owner != null &&
19184
prevElement._owner._isOwnerNecessary === false) ||
19185
(nextElement._owner != null &&
19186
nextElement._owner._isOwnerNecessary === false)) {
19187
if (prevElement._owner != null) {
19188
prevElement._owner._isOwnerNecessary = true;
19189
}
19190
if (nextElement._owner != null) {
19191
nextElement._owner._isOwnerNecessary = true;
19192
}
19193
("production" !== "development" ? warning(
19194
false,
19195
'<%s /> is being rendered by both %s and %s using the same ' +
19196
'key (%s) in the same place. Currently, this means that ' +
19197
'they don\'t preserve state. This behavior should be very ' +
19198
'rare so we\'re considering deprecating it. Please contact ' +
19199
'the React team and explain your use case so that we can ' +
19200
'take that into consideration.',
19201
nextDisplayName || 'Unknown Component',
19202
prevName || '[Unknown]',
19203
nextName || '[Unknown]',
19204
prevElement.key
19205
) : null);
19206
}
19207
}
19208
}
19209
}
19210
return ownersMatch;
19211
}
19212
}
19213
}
19214
return false;
19215
}
19216
19217
module.exports = shouldUpdateReactComponent;
19218
19219
},{"154":154}],152:[function(_dereq_,module,exports){
19220
/**
19221
* Copyright 2014-2015, Facebook, Inc.
19222
* All rights reserved.
19223
*
19224
* This source code is licensed under the BSD-style license found in the
19225
* LICENSE file in the root directory of this source tree. An additional grant
19226
* of patent rights can be found in the PATENTS file in the same directory.
19227
*
19228
* @providesModule toArray
19229
* @typechecks
19230
*/
19231
19232
var invariant = _dereq_(135);
19233
19234
/**
19235
* Convert array-like objects to arrays.
19236
*
19237
* This API assumes the caller knows the contents of the data type. For less
19238
* well defined inputs use createArrayFromMixed.
19239
*
19240
* @param {object|function|filelist} obj
19241
* @return {array}
19242
*/
19243
function toArray(obj) {
19244
var length = obj.length;
19245
19246
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
19247
// old versions of Safari).
19248
("production" !== "development" ? invariant(
19249
!Array.isArray(obj) &&
19250
(typeof obj === 'object' || typeof obj === 'function'),
19251
'toArray: Array-like object expected'
19252
) : invariant(!Array.isArray(obj) &&
19253
(typeof obj === 'object' || typeof obj === 'function')));
19254
19255
("production" !== "development" ? invariant(
19256
typeof length === 'number',
19257
'toArray: Object needs a length property'
19258
) : invariant(typeof length === 'number'));
19259
19260
("production" !== "development" ? invariant(
19261
length === 0 ||
19262
(length - 1) in obj,
19263
'toArray: Object should have keys for indices'
19264
) : invariant(length === 0 ||
19265
(length - 1) in obj));
19266
19267
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
19268
// without method will throw during the slice call and skip straight to the
19269
// fallback.
19270
if (obj.hasOwnProperty) {
19271
try {
19272
return Array.prototype.slice.call(obj);
19273
} catch (e) {
19274
// IE < 9 does not support Array#slice on collections objects
19275
}
19276
}
19277
19278
// Fall back to copying key by key. This assumes all keys have a value,
19279
// so will not preserve sparsely populated inputs.
19280
var ret = Array(length);
19281
for (var ii = 0; ii < length; ii++) {
19282
ret[ii] = obj[ii];
19283
}
19284
return ret;
19285
}
19286
19287
module.exports = toArray;
19288
19289
},{"135":135}],153:[function(_dereq_,module,exports){
19290
/**
19291
* Copyright 2013-2015, Facebook, Inc.
19292
* All rights reserved.
19293
*
19294
* This source code is licensed under the BSD-style license found in the
19295
* LICENSE file in the root directory of this source tree. An additional grant
19296
* of patent rights can be found in the PATENTS file in the same directory.
19297
*
19298
* @providesModule traverseAllChildren
19299
*/
19300
19301
'use strict';
19302
19303
var ReactElement = _dereq_(57);
19304
var ReactFragment = _dereq_(63);
19305
var ReactInstanceHandles = _dereq_(66);
19306
19307
var getIteratorFn = _dereq_(126);
19308
var invariant = _dereq_(135);
19309
var warning = _dereq_(154);
19310
19311
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
19312
var SUBSEPARATOR = ':';
19313
19314
/**
19315
* TODO: Test that a single child and an array with one item have the same key
19316
* pattern.
19317
*/
19318
19319
var userProvidedKeyEscaperLookup = {
19320
'=': '=0',
19321
'.': '=1',
19322
':': '=2'
19323
};
19324
19325
var userProvidedKeyEscapeRegex = /[=.:]/g;
19326
19327
var didWarnAboutMaps = false;
19328
19329
function userProvidedKeyEscaper(match) {
19330
return userProvidedKeyEscaperLookup[match];
19331
}
19332
19333
/**
19334
* Generate a key string that identifies a component within a set.
19335
*
19336
* @param {*} component A component that could contain a manual key.
19337
* @param {number} index Index that is used if a manual key is not provided.
19338
* @return {string}
19339
*/
19340
function getComponentKey(component, index) {
19341
if (component && component.key != null) {
19342
// Explicit key
19343
return wrapUserProvidedKey(component.key);
19344
}
19345
// Implicit key determined by the index in the set
19346
return index.toString(36);
19347
}
19348
19349
/**
19350
* Escape a component key so that it is safe to use in a reactid.
19351
*
19352
* @param {*} key Component key to be escaped.
19353
* @return {string} An escaped string.
19354
*/
19355
function escapeUserProvidedKey(text) {
19356
return ('' + text).replace(
19357
userProvidedKeyEscapeRegex,
19358
userProvidedKeyEscaper
19359
);
19360
}
19361
19362
/**
19363
* Wrap a `key` value explicitly provided by the user to distinguish it from
19364
* implicitly-generated keys generated by a component's index in its parent.
19365
*
19366
* @param {string} key Value of a user-provided `key` attribute
19367
* @return {string}
19368
*/
19369
function wrapUserProvidedKey(key) {
19370
return '$' + escapeUserProvidedKey(key);
19371
}
19372
19373
/**
19374
* @param {?*} children Children tree container.
19375
* @param {!string} nameSoFar Name of the key path so far.
19376
* @param {!number} indexSoFar Number of children encountered until this point.
19377
* @param {!function} callback Callback to invoke with each child found.
19378
* @param {?*} traverseContext Used to pass information throughout the traversal
19379
* process.
19380
* @return {!number} The number of children in this subtree.
19381
*/
19382
function traverseAllChildrenImpl(
19383
children,
19384
nameSoFar,
19385
indexSoFar,
19386
callback,
19387
traverseContext
19388
) {
19389
var type = typeof children;
19390
19391
if (type === 'undefined' || type === 'boolean') {
19392
// All of the above are perceived as null.
19393
children = null;
19394
}
19395
19396
if (children === null ||
19397
type === 'string' ||
19398
type === 'number' ||
19399
ReactElement.isValidElement(children)) {
19400
callback(
19401
traverseContext,
19402
children,
19403
// If it's the only child, treat the name as if it was wrapped in an array
19404
// so that it's consistent if the number of children grows.
19405
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
19406
indexSoFar
19407
);
19408
return 1;
19409
}
19410
19411
var child, nextName, nextIndex;
19412
var subtreeCount = 0; // Count of children found in the current subtree.
19413
19414
if (Array.isArray(children)) {
19415
for (var i = 0; i < children.length; i++) {
19416
child = children[i];
19417
nextName = (
19418
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
19419
getComponentKey(child, i)
19420
);
19421
nextIndex = indexSoFar + subtreeCount;
19422
subtreeCount += traverseAllChildrenImpl(
19423
child,
19424
nextName,
19425
nextIndex,
19426
callback,
19427
traverseContext
19428
);
19429
}
19430
} else {
19431
var iteratorFn = getIteratorFn(children);
19432
if (iteratorFn) {
19433
var iterator = iteratorFn.call(children);
19434
var step;
19435
if (iteratorFn !== children.entries) {
19436
var ii = 0;
19437
while (!(step = iterator.next()).done) {
19438
child = step.value;
19439
nextName = (
19440
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
19441
getComponentKey(child, ii++)
19442
);
19443
nextIndex = indexSoFar + subtreeCount;
19444
subtreeCount += traverseAllChildrenImpl(
19445
child,
19446
nextName,
19447
nextIndex,
19448
callback,
19449
traverseContext
19450
);
19451
}
19452
} else {
19453
if ("production" !== "development") {
19454
("production" !== "development" ? warning(
19455
didWarnAboutMaps,
19456
'Using Maps as children is not yet fully supported. It is an ' +
19457
'experimental feature that might be removed. Convert it to a ' +
19458
'sequence / iterable of keyed ReactElements instead.'
19459
) : null);
19460
didWarnAboutMaps = true;
19461
}
19462
// Iterator will provide entry [k,v] tuples rather than values.
19463
while (!(step = iterator.next()).done) {
19464
var entry = step.value;
19465
if (entry) {
19466
child = entry[1];
19467
nextName = (
19468
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
19469
wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
19470
getComponentKey(child, 0)
19471
);
19472
nextIndex = indexSoFar + subtreeCount;
19473
subtreeCount += traverseAllChildrenImpl(
19474
child,
19475
nextName,
19476
nextIndex,
19477
callback,
19478
traverseContext
19479
);
19480
}
19481
}
19482
}
19483
} else if (type === 'object') {
19484
("production" !== "development" ? invariant(
19485
children.nodeType !== 1,
19486
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
19487
'elements are not valid children of React components.'
19488
) : invariant(children.nodeType !== 1));
19489
var fragment = ReactFragment.extract(children);
19490
for (var key in fragment) {
19491
if (fragment.hasOwnProperty(key)) {
19492
child = fragment[key];
19493
nextName = (
19494
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
19495
wrapUserProvidedKey(key) + SUBSEPARATOR +
19496
getComponentKey(child, 0)
19497
);
19498
nextIndex = indexSoFar + subtreeCount;
19499
subtreeCount += traverseAllChildrenImpl(
19500
child,
19501
nextName,
19502
nextIndex,
19503
callback,
19504
traverseContext
19505
);
19506
}
19507
}
19508
}
19509
}
19510
19511
return subtreeCount;
19512
}
19513
19514
/**
19515
* Traverses children that are typically specified as `props.children`, but
19516
* might also be specified through attributes:
19517
*
19518
* - `traverseAllChildren(this.props.children, ...)`
19519
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
19520
*
19521
* The `traverseContext` is an optional argument that is passed through the
19522
* entire traversal. It can be used to store accumulations or anything else that
19523
* the callback might find relevant.
19524
*
19525
* @param {?*} children Children tree object.
19526
* @param {!function} callback To invoke upon traversing each child.
19527
* @param {?*} traverseContext Context for traversal.
19528
* @return {!number} The number of children in this subtree.
19529
*/
19530
function traverseAllChildren(children, callback, traverseContext) {
19531
if (children == null) {
19532
return 0;
19533
}
19534
19535
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
19536
}
19537
19538
module.exports = traverseAllChildren;
19539
19540
},{"126":126,"135":135,"154":154,"57":57,"63":63,"66":66}],154:[function(_dereq_,module,exports){
19541
/**
19542
* Copyright 2014-2015, Facebook, Inc.
19543
* All rights reserved.
19544
*
19545
* This source code is licensed under the BSD-style license found in the
19546
* LICENSE file in the root directory of this source tree. An additional grant
19547
* of patent rights can be found in the PATENTS file in the same directory.
19548
*
19549
* @providesModule warning
19550
*/
19551
19552
"use strict";
19553
19554
var emptyFunction = _dereq_(114);
19555
19556
/**
19557
* Similar to invariant but only logs a warning if the condition is not met.
19558
* This can be used to log issues in development environments in critical
19559
* paths. Removing the logging code for production environments will keep the
19560
* same logic and follow the same code paths.
19561
*/
19562
19563
var warning = emptyFunction;
19564
19565
if ("production" !== "development") {
19566
warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
19567
if (format === undefined) {
19568
throw new Error(
19569
'`warning(condition, format, ...args)` requires a warning ' +
19570
'message argument'
19571
);
19572
}
19573
19574
if (format.length < 10 || /^[s\W]*$/.test(format)) {
19575
throw new Error(
19576
'The warning format should be able to uniquely identify this ' +
19577
'warning. Please, use a more descriptive format than: ' + format
19578
);
19579
}
19580
19581
if (format.indexOf('Failed Composite propType: ') === 0) {
19582
return; // Ignore CompositeComponent proptype check.
19583
}
19584
19585
if (!condition) {
19586
var argIndex = 0;
19587
var message = 'Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];});
19588
console.warn(message);
19589
try {
19590
// --- Welcome to debugging React ---
19591
// This error was thrown as a convenience so that you can use this stack
19592
// to find the callsite that caused this warning to fire.
19593
throw new Error(message);
19594
} catch(x) {}
19595
}
19596
};
19597
}
19598
19599
module.exports = warning;
19600
19601
},{"114":114}]},{},[1])(1)
19602
});
19603