Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 50965
1
/**
2
* React (with addons) 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 ReactWithAddons
14
*/
15
16
/**
17
* This module exists purely in the open source project, and is meant as a way
18
* to create a separate standalone build of React. This build has "addons", or
19
* functionality we've built and think might be useful but doesn't have a good
20
* place to live inside React core.
21
*/
22
23
'use strict';
24
25
var LinkedStateMixin = _dereq_(25);
26
var React = _dereq_(31);
27
var ReactComponentWithPureRenderMixin =
28
_dereq_(42);
29
var ReactCSSTransitionGroup = _dereq_(34);
30
var ReactFragment = _dereq_(69);
31
var ReactTransitionGroup = _dereq_(98);
32
var ReactUpdates = _dereq_(100);
33
34
var cx = _dereq_(127);
35
var cloneWithProps = _dereq_(122);
36
var update = _dereq_(170);
37
38
React.addons = {
39
CSSTransitionGroup: ReactCSSTransitionGroup,
40
LinkedStateMixin: LinkedStateMixin,
41
PureRenderMixin: ReactComponentWithPureRenderMixin,
42
TransitionGroup: ReactTransitionGroup,
43
44
batchedUpdates: ReactUpdates.batchedUpdates,
45
classSet: cx,
46
cloneWithProps: cloneWithProps,
47
createFragment: ReactFragment.create,
48
update: update
49
};
50
51
if ("production" !== "development") {
52
React.addons.Perf = _dereq_(61);
53
React.addons.TestUtils = _dereq_(95);
54
}
55
56
module.exports = React;
57
58
},{"100":100,"122":122,"127":127,"170":170,"25":25,"31":31,"34":34,"42":42,"61":61,"69":69,"95":95,"98":98}],2:[function(_dereq_,module,exports){
59
/**
60
* Copyright 2013-2015, Facebook, Inc.
61
* All rights reserved.
62
*
63
* This source code is licensed under the BSD-style license found in the
64
* LICENSE file in the root directory of this source tree. An additional grant
65
* of patent rights can be found in the PATENTS file in the same directory.
66
*
67
* @providesModule AutoFocusMixin
68
* @typechecks static-only
69
*/
70
71
'use strict';
72
73
var focusNode = _dereq_(134);
74
75
var AutoFocusMixin = {
76
componentDidMount: function() {
77
if (this.props.autoFocus) {
78
focusNode(this.getDOMNode());
79
}
80
}
81
};
82
83
module.exports = AutoFocusMixin;
84
85
},{"134":134}],3:[function(_dereq_,module,exports){
86
/**
87
* Copyright 2013-2015 Facebook, Inc.
88
* All rights reserved.
89
*
90
* This source code is licensed under the BSD-style license found in the
91
* LICENSE file in the root directory of this source tree. An additional grant
92
* of patent rights can be found in the PATENTS file in the same directory.
93
*
94
* @providesModule BeforeInputEventPlugin
95
* @typechecks static-only
96
*/
97
98
'use strict';
99
100
var EventConstants = _dereq_(16);
101
var EventPropagators = _dereq_(21);
102
var ExecutionEnvironment = _dereq_(22);
103
var FallbackCompositionState = _dereq_(23);
104
var SyntheticCompositionEvent = _dereq_(106);
105
var SyntheticInputEvent = _dereq_(110);
106
107
var keyOf = _dereq_(157);
108
109
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
110
var START_KEYCODE = 229;
111
112
var canUseCompositionEvent = (
113
ExecutionEnvironment.canUseDOM &&
114
'CompositionEvent' in window
115
);
116
117
var documentMode = null;
118
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
119
documentMode = document.documentMode;
120
}
121
122
// Webkit offers a very useful `textInput` event that can be used to
123
// directly represent `beforeInput`. The IE `textinput` event is not as
124
// useful, so we don't use it.
125
var canUseTextInputEvent = (
126
ExecutionEnvironment.canUseDOM &&
127
'TextEvent' in window &&
128
!documentMode &&
129
!isPresto()
130
);
131
132
// In IE9+, we have access to composition events, but the data supplied
133
// by the native compositionend event may be incorrect. Japanese ideographic
134
// spaces, for instance (\u3000) are not recorded correctly.
135
var useFallbackCompositionData = (
136
ExecutionEnvironment.canUseDOM &&
137
(
138
(!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11)
139
)
140
);
141
142
/**
143
* Opera <= 12 includes TextEvent in window, but does not fire
144
* text input events. Rely on keypress instead.
145
*/
146
function isPresto() {
147
var opera = window.opera;
148
return (
149
typeof opera === 'object' &&
150
typeof opera.version === 'function' &&
151
parseInt(opera.version(), 10) <= 12
152
);
153
}
154
155
var SPACEBAR_CODE = 32;
156
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
157
158
var topLevelTypes = EventConstants.topLevelTypes;
159
160
// Events and their corresponding property names.
161
var eventTypes = {
162
beforeInput: {
163
phasedRegistrationNames: {
164
bubbled: keyOf({onBeforeInput: null}),
165
captured: keyOf({onBeforeInputCapture: null})
166
},
167
dependencies: [
168
topLevelTypes.topCompositionEnd,
169
topLevelTypes.topKeyPress,
170
topLevelTypes.topTextInput,
171
topLevelTypes.topPaste
172
]
173
},
174
compositionEnd: {
175
phasedRegistrationNames: {
176
bubbled: keyOf({onCompositionEnd: null}),
177
captured: keyOf({onCompositionEndCapture: null})
178
},
179
dependencies: [
180
topLevelTypes.topBlur,
181
topLevelTypes.topCompositionEnd,
182
topLevelTypes.topKeyDown,
183
topLevelTypes.topKeyPress,
184
topLevelTypes.topKeyUp,
185
topLevelTypes.topMouseDown
186
]
187
},
188
compositionStart: {
189
phasedRegistrationNames: {
190
bubbled: keyOf({onCompositionStart: null}),
191
captured: keyOf({onCompositionStartCapture: null})
192
},
193
dependencies: [
194
topLevelTypes.topBlur,
195
topLevelTypes.topCompositionStart,
196
topLevelTypes.topKeyDown,
197
topLevelTypes.topKeyPress,
198
topLevelTypes.topKeyUp,
199
topLevelTypes.topMouseDown
200
]
201
},
202
compositionUpdate: {
203
phasedRegistrationNames: {
204
bubbled: keyOf({onCompositionUpdate: null}),
205
captured: keyOf({onCompositionUpdateCapture: null})
206
},
207
dependencies: [
208
topLevelTypes.topBlur,
209
topLevelTypes.topCompositionUpdate,
210
topLevelTypes.topKeyDown,
211
topLevelTypes.topKeyPress,
212
topLevelTypes.topKeyUp,
213
topLevelTypes.topMouseDown
214
]
215
}
216
};
217
218
// Track whether we've ever handled a keypress on the space key.
219
var hasSpaceKeypress = false;
220
221
/**
222
* Return whether a native keypress event is assumed to be a command.
223
* This is required because Firefox fires `keypress` events for key commands
224
* (cut, copy, select-all, etc.) even though no character is inserted.
225
*/
226
function isKeypressCommand(nativeEvent) {
227
return (
228
(nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
229
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
230
!(nativeEvent.ctrlKey && nativeEvent.altKey)
231
);
232
}
233
234
235
/**
236
* Translate native top level events into event types.
237
*
238
* @param {string} topLevelType
239
* @return {object}
240
*/
241
function getCompositionEventType(topLevelType) {
242
switch (topLevelType) {
243
case topLevelTypes.topCompositionStart:
244
return eventTypes.compositionStart;
245
case topLevelTypes.topCompositionEnd:
246
return eventTypes.compositionEnd;
247
case topLevelTypes.topCompositionUpdate:
248
return eventTypes.compositionUpdate;
249
}
250
}
251
252
/**
253
* Does our fallback best-guess model think this event signifies that
254
* composition has begun?
255
*
256
* @param {string} topLevelType
257
* @param {object} nativeEvent
258
* @return {boolean}
259
*/
260
function isFallbackCompositionStart(topLevelType, nativeEvent) {
261
return (
262
topLevelType === topLevelTypes.topKeyDown &&
263
nativeEvent.keyCode === START_KEYCODE
264
);
265
}
266
267
/**
268
* Does our fallback mode think that this event is the end of composition?
269
*
270
* @param {string} topLevelType
271
* @param {object} nativeEvent
272
* @return {boolean}
273
*/
274
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
275
switch (topLevelType) {
276
case topLevelTypes.topKeyUp:
277
// Command keys insert or clear IME input.
278
return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
279
case topLevelTypes.topKeyDown:
280
// Expect IME keyCode on each keydown. If we get any other
281
// code we must have exited earlier.
282
return (nativeEvent.keyCode !== START_KEYCODE);
283
case topLevelTypes.topKeyPress:
284
case topLevelTypes.topMouseDown:
285
case topLevelTypes.topBlur:
286
// Events are not possible without cancelling IME.
287
return true;
288
default:
289
return false;
290
}
291
}
292
293
/**
294
* Google Input Tools provides composition data via a CustomEvent,
295
* with the `data` property populated in the `detail` object. If this
296
* is available on the event object, use it. If not, this is a plain
297
* composition event and we have nothing special to extract.
298
*
299
* @param {object} nativeEvent
300
* @return {?string}
301
*/
302
function getDataFromCustomEvent(nativeEvent) {
303
var detail = nativeEvent.detail;
304
if (typeof detail === 'object' && 'data' in detail) {
305
return detail.data;
306
}
307
return null;
308
}
309
310
// Track the current IME composition fallback object, if any.
311
var currentComposition = null;
312
313
/**
314
* @param {string} topLevelType Record from `EventConstants`.
315
* @param {DOMEventTarget} topLevelTarget The listening component root node.
316
* @param {string} topLevelTargetID ID of `topLevelTarget`.
317
* @param {object} nativeEvent Native browser event.
318
* @return {?object} A SyntheticCompositionEvent.
319
*/
320
function extractCompositionEvent(
321
topLevelType,
322
topLevelTarget,
323
topLevelTargetID,
324
nativeEvent
325
) {
326
var eventType;
327
var fallbackData;
328
329
if (canUseCompositionEvent) {
330
eventType = getCompositionEventType(topLevelType);
331
} else if (!currentComposition) {
332
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
333
eventType = eventTypes.compositionStart;
334
}
335
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
336
eventType = eventTypes.compositionEnd;
337
}
338
339
if (!eventType) {
340
return null;
341
}
342
343
if (useFallbackCompositionData) {
344
// The current composition is stored statically and must not be
345
// overwritten while composition continues.
346
if (!currentComposition && eventType === eventTypes.compositionStart) {
347
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
348
} else if (eventType === eventTypes.compositionEnd) {
349
if (currentComposition) {
350
fallbackData = currentComposition.getData();
351
}
352
}
353
}
354
355
var event = SyntheticCompositionEvent.getPooled(
356
eventType,
357
topLevelTargetID,
358
nativeEvent
359
);
360
361
if (fallbackData) {
362
// Inject data generated from fallback path into the synthetic event.
363
// This matches the property of native CompositionEventInterface.
364
event.data = fallbackData;
365
} else {
366
var customData = getDataFromCustomEvent(nativeEvent);
367
if (customData !== null) {
368
event.data = customData;
369
}
370
}
371
372
EventPropagators.accumulateTwoPhaseDispatches(event);
373
return event;
374
}
375
376
/**
377
* @param {string} topLevelType Record from `EventConstants`.
378
* @param {object} nativeEvent Native browser event.
379
* @return {?string} The string corresponding to this `beforeInput` event.
380
*/
381
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
382
switch (topLevelType) {
383
case topLevelTypes.topCompositionEnd:
384
return getDataFromCustomEvent(nativeEvent);
385
case topLevelTypes.topKeyPress:
386
/**
387
* If native `textInput` events are available, our goal is to make
388
* use of them. However, there is a special case: the spacebar key.
389
* In Webkit, preventing default on a spacebar `textInput` event
390
* cancels character insertion, but it *also* causes the browser
391
* to fall back to its default spacebar behavior of scrolling the
392
* page.
393
*
394
* Tracking at:
395
* https://code.google.com/p/chromium/issues/detail?id=355103
396
*
397
* To avoid this issue, use the keypress event as if no `textInput`
398
* event is available.
399
*/
400
var which = nativeEvent.which;
401
if (which !== SPACEBAR_CODE) {
402
return null;
403
}
404
405
hasSpaceKeypress = true;
406
return SPACEBAR_CHAR;
407
408
case topLevelTypes.topTextInput:
409
// Record the characters to be added to the DOM.
410
var chars = nativeEvent.data;
411
412
// If it's a spacebar character, assume that we have already handled
413
// it at the keypress level and bail immediately. Android Chrome
414
// doesn't give us keycodes, so we need to blacklist it.
415
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
416
return null;
417
}
418
419
return chars;
420
421
default:
422
// For other native event types, do nothing.
423
return null;
424
}
425
}
426
427
/**
428
* For browsers that do not provide the `textInput` event, extract the
429
* appropriate string to use for SyntheticInputEvent.
430
*
431
* @param {string} topLevelType Record from `EventConstants`.
432
* @param {object} nativeEvent Native browser event.
433
* @return {?string} The fallback string for this `beforeInput` event.
434
*/
435
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
436
// If we are currently composing (IME) and using a fallback to do so,
437
// try to extract the composed characters from the fallback object.
438
if (currentComposition) {
439
if (
440
topLevelType === topLevelTypes.topCompositionEnd ||
441
isFallbackCompositionEnd(topLevelType, nativeEvent)
442
) {
443
var chars = currentComposition.getData();
444
FallbackCompositionState.release(currentComposition);
445
currentComposition = null;
446
return chars;
447
}
448
return null;
449
}
450
451
switch (topLevelType) {
452
case topLevelTypes.topPaste:
453
// If a paste event occurs after a keypress, throw out the input
454
// chars. Paste events should not lead to BeforeInput events.
455
return null;
456
case topLevelTypes.topKeyPress:
457
/**
458
* As of v27, Firefox may fire keypress events even when no character
459
* will be inserted. A few possibilities:
460
*
461
* - `which` is `0`. Arrow keys, Esc key, etc.
462
*
463
* - `which` is the pressed key code, but no char is available.
464
* Ex: 'AltGr + d` in Polish. There is no modified character for
465
* this key combination and no character is inserted into the
466
* document, but FF fires the keypress for char code `100` anyway.
467
* No `input` event will occur.
468
*
469
* - `which` is the pressed key code, but a command combination is
470
* being used. Ex: `Cmd+C`. No character is inserted, and no
471
* `input` event will occur.
472
*/
473
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
474
return String.fromCharCode(nativeEvent.which);
475
}
476
return null;
477
case topLevelTypes.topCompositionEnd:
478
return useFallbackCompositionData ? null : nativeEvent.data;
479
default:
480
return null;
481
}
482
}
483
484
/**
485
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
486
* `textInput` or fallback behavior.
487
*
488
* @param {string} topLevelType Record from `EventConstants`.
489
* @param {DOMEventTarget} topLevelTarget The listening component root node.
490
* @param {string} topLevelTargetID ID of `topLevelTarget`.
491
* @param {object} nativeEvent Native browser event.
492
* @return {?object} A SyntheticInputEvent.
493
*/
494
function extractBeforeInputEvent(
495
topLevelType,
496
topLevelTarget,
497
topLevelTargetID,
498
nativeEvent
499
) {
500
var chars;
501
502
if (canUseTextInputEvent) {
503
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
504
} else {
505
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
506
}
507
508
// If no characters are being inserted, no BeforeInput event should
509
// be fired.
510
if (!chars) {
511
return null;
512
}
513
514
var event = SyntheticInputEvent.getPooled(
515
eventTypes.beforeInput,
516
topLevelTargetID,
517
nativeEvent
518
);
519
520
event.data = chars;
521
EventPropagators.accumulateTwoPhaseDispatches(event);
522
return event;
523
}
524
525
/**
526
* Create an `onBeforeInput` event to match
527
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
528
*
529
* This event plugin is based on the native `textInput` event
530
* available in Chrome, Safari, Opera, and IE. This event fires after
531
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
532
*
533
* `beforeInput` is spec'd but not implemented in any browsers, and
534
* the `input` event does not provide any useful information about what has
535
* actually been added, contrary to the spec. Thus, `textInput` is the best
536
* available event to identify the characters that have actually been inserted
537
* into the target node.
538
*
539
* This plugin is also responsible for emitting `composition` events, thus
540
* allowing us to share composition fallback code for both `beforeInput` and
541
* `composition` event types.
542
*/
543
var BeforeInputEventPlugin = {
544
545
eventTypes: eventTypes,
546
547
/**
548
* @param {string} topLevelType Record from `EventConstants`.
549
* @param {DOMEventTarget} topLevelTarget The listening component root node.
550
* @param {string} topLevelTargetID ID of `topLevelTarget`.
551
* @param {object} nativeEvent Native browser event.
552
* @return {*} An accumulation of synthetic events.
553
* @see {EventPluginHub.extractEvents}
554
*/
555
extractEvents: function(
556
topLevelType,
557
topLevelTarget,
558
topLevelTargetID,
559
nativeEvent
560
) {
561
return [
562
extractCompositionEvent(
563
topLevelType,
564
topLevelTarget,
565
topLevelTargetID,
566
nativeEvent
567
),
568
extractBeforeInputEvent(
569
topLevelType,
570
topLevelTarget,
571
topLevelTargetID,
572
nativeEvent
573
)
574
];
575
}
576
};
577
578
module.exports = BeforeInputEventPlugin;
579
580
},{"106":106,"110":110,"157":157,"16":16,"21":21,"22":22,"23":23}],4:[function(_dereq_,module,exports){
581
/**
582
* Copyright 2013-2015, Facebook, Inc.
583
* All rights reserved.
584
*
585
* This source code is licensed under the BSD-style license found in the
586
* LICENSE file in the root directory of this source tree. An additional grant
587
* of patent rights can be found in the PATENTS file in the same directory.
588
*
589
* @providesModule CSSCore
590
* @typechecks
591
*/
592
593
var invariant = _dereq_(150);
594
595
/**
596
* The CSSCore module specifies the API (and implements most of the methods)
597
* that should be used when dealing with the display of elements (via their
598
* CSS classes and visibility on screen. It is an API focused on mutating the
599
* display and not reading it as no logical state should be encoded in the
600
* display of elements.
601
*/
602
603
var CSSCore = {
604
605
/**
606
* Adds the class passed in to the element if it doesn't already have it.
607
*
608
* @param {DOMElement} element the element to set the class on
609
* @param {string} className the CSS className
610
* @return {DOMElement} the element passed in
611
*/
612
addClass: function(element, className) {
613
("production" !== "development" ? invariant(
614
!/\s/.test(className),
615
'CSSCore.addClass takes only a single class name. "%s" contains ' +
616
'multiple classes.', className
617
) : invariant(!/\s/.test(className)));
618
619
if (className) {
620
if (element.classList) {
621
element.classList.add(className);
622
} else if (!CSSCore.hasClass(element, className)) {
623
element.className = element.className + ' ' + className;
624
}
625
}
626
return element;
627
},
628
629
/**
630
* Removes the class passed in from the element
631
*
632
* @param {DOMElement} element the element to set the class on
633
* @param {string} className the CSS className
634
* @return {DOMElement} the element passed in
635
*/
636
removeClass: function(element, className) {
637
("production" !== "development" ? invariant(
638
!/\s/.test(className),
639
'CSSCore.removeClass takes only a single class name. "%s" contains ' +
640
'multiple classes.', className
641
) : invariant(!/\s/.test(className)));
642
643
if (className) {
644
if (element.classList) {
645
element.classList.remove(className);
646
} else if (CSSCore.hasClass(element, className)) {
647
element.className = element.className
648
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
649
.replace(/\s+/g, ' ') // multiple spaces to one
650
.replace(/^\s*|\s*$/g, ''); // trim the ends
651
}
652
}
653
return element;
654
},
655
656
/**
657
* Helper to add or remove a class from an element based on a condition.
658
*
659
* @param {DOMElement} element the element to set the class on
660
* @param {string} className the CSS className
661
* @param {*} bool condition to whether to add or remove the class
662
* @return {DOMElement} the element passed in
663
*/
664
conditionClass: function(element, className, bool) {
665
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
666
},
667
668
/**
669
* Tests whether the element has the class specified.
670
*
671
* @param {DOMNode|DOMWindow} element the element to set the class on
672
* @param {string} className the CSS className
673
* @return {boolean} true if the element has the class, false if not
674
*/
675
hasClass: function(element, className) {
676
("production" !== "development" ? invariant(
677
!/\s/.test(className),
678
'CSS.hasClass takes only a single class name.'
679
) : invariant(!/\s/.test(className)));
680
if (element.classList) {
681
return !!className && element.classList.contains(className);
682
}
683
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
684
}
685
686
};
687
688
module.exports = CSSCore;
689
690
},{"150":150}],5:[function(_dereq_,module,exports){
691
/**
692
* Copyright 2013-2015, Facebook, Inc.
693
* All rights reserved.
694
*
695
* This source code is licensed under the BSD-style license found in the
696
* LICENSE file in the root directory of this source tree. An additional grant
697
* of patent rights can be found in the PATENTS file in the same directory.
698
*
699
* @providesModule CSSProperty
700
*/
701
702
'use strict';
703
704
/**
705
* CSS properties which accept numbers but are not in units of "px".
706
*/
707
var isUnitlessNumber = {
708
boxFlex: true,
709
boxFlexGroup: true,
710
columnCount: true,
711
flex: true,
712
flexGrow: true,
713
flexPositive: true,
714
flexShrink: true,
715
flexNegative: true,
716
fontWeight: true,
717
lineClamp: true,
718
lineHeight: true,
719
opacity: true,
720
order: true,
721
orphans: true,
722
widows: true,
723
zIndex: true,
724
zoom: true,
725
726
// SVG-related properties
727
fillOpacity: true,
728
strokeDashoffset: true,
729
strokeOpacity: true,
730
strokeWidth: true
731
};
732
733
/**
734
* @param {string} prefix vendor-specific prefix, eg: Webkit
735
* @param {string} key style name, eg: transitionDuration
736
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
737
* WebkitTransitionDuration
738
*/
739
function prefixKey(prefix, key) {
740
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
741
}
742
743
/**
744
* Support style names that may come passed in prefixed by adding permutations
745
* of vendor prefixes.
746
*/
747
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
748
749
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
750
// infinite loop, because it iterates over the newly added props too.
751
Object.keys(isUnitlessNumber).forEach(function(prop) {
752
prefixes.forEach(function(prefix) {
753
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
754
});
755
});
756
757
/**
758
* Most style properties can be unset by doing .style[prop] = '' but IE8
759
* doesn't like doing that with shorthand properties so for the properties that
760
* IE8 breaks on, which are listed here, we instead unset each of the
761
* individual properties. See http://bugs.jquery.com/ticket/12385.
762
* The 4-value 'clock' properties like margin, padding, border-width seem to
763
* behave without any problems. Curiously, list-style works too without any
764
* special prodding.
765
*/
766
var shorthandPropertyExpansions = {
767
background: {
768
backgroundImage: true,
769
backgroundPosition: true,
770
backgroundRepeat: true,
771
backgroundColor: true
772
},
773
border: {
774
borderWidth: true,
775
borderStyle: true,
776
borderColor: true
777
},
778
borderBottom: {
779
borderBottomWidth: true,
780
borderBottomStyle: true,
781
borderBottomColor: true
782
},
783
borderLeft: {
784
borderLeftWidth: true,
785
borderLeftStyle: true,
786
borderLeftColor: true
787
},
788
borderRight: {
789
borderRightWidth: true,
790
borderRightStyle: true,
791
borderRightColor: true
792
},
793
borderTop: {
794
borderTopWidth: true,
795
borderTopStyle: true,
796
borderTopColor: true
797
},
798
font: {
799
fontStyle: true,
800
fontVariant: true,
801
fontWeight: true,
802
fontSize: true,
803
lineHeight: true,
804
fontFamily: true
805
}
806
};
807
808
var CSSProperty = {
809
isUnitlessNumber: isUnitlessNumber,
810
shorthandPropertyExpansions: shorthandPropertyExpansions
811
};
812
813
module.exports = CSSProperty;
814
815
},{}],6:[function(_dereq_,module,exports){
816
/**
817
* Copyright 2013-2015, Facebook, Inc.
818
* All rights reserved.
819
*
820
* This source code is licensed under the BSD-style license found in the
821
* LICENSE file in the root directory of this source tree. An additional grant
822
* of patent rights can be found in the PATENTS file in the same directory.
823
*
824
* @providesModule CSSPropertyOperations
825
* @typechecks static-only
826
*/
827
828
'use strict';
829
830
var CSSProperty = _dereq_(5);
831
var ExecutionEnvironment = _dereq_(22);
832
833
var camelizeStyleName = _dereq_(121);
834
var dangerousStyleValue = _dereq_(128);
835
var hyphenateStyleName = _dereq_(148);
836
var memoizeStringOnly = _dereq_(159);
837
var warning = _dereq_(171);
838
839
var processStyleName = memoizeStringOnly(function(styleName) {
840
return hyphenateStyleName(styleName);
841
});
842
843
var styleFloatAccessor = 'cssFloat';
844
if (ExecutionEnvironment.canUseDOM) {
845
// IE8 only supports accessing cssFloat (standard) as styleFloat
846
if (document.documentElement.style.cssFloat === undefined) {
847
styleFloatAccessor = 'styleFloat';
848
}
849
}
850
851
if ("production" !== "development") {
852
// 'msTransform' is correct, but the other prefixes should be capitalized
853
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
854
855
// style values shouldn't contain a semicolon
856
var badStyleValueWithSemicolonPattern = /;\s*$/;
857
858
var warnedStyleNames = {};
859
var warnedStyleValues = {};
860
861
var warnHyphenatedStyleName = 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 style property %s. Did you mean %s?',
870
name,
871
camelizeStyleName(name)
872
) : null);
873
};
874
875
var warnBadVendoredStyleName = function(name) {
876
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
877
return;
878
}
879
880
warnedStyleNames[name] = true;
881
("production" !== "development" ? warning(
882
false,
883
'Unsupported vendor-prefixed style property %s. Did you mean %s?',
884
name,
885
name.charAt(0).toUpperCase() + name.slice(1)
886
) : null);
887
};
888
889
var warnStyleValueWithSemicolon = function(name, value) {
890
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
891
return;
892
}
893
894
warnedStyleValues[value] = true;
895
("production" !== "development" ? warning(
896
false,
897
'Style property values shouldn\'t contain a semicolon. ' +
898
'Try "%s: %s" instead.',
899
name,
900
value.replace(badStyleValueWithSemicolonPattern, '')
901
) : null);
902
};
903
904
/**
905
* @param {string} name
906
* @param {*} value
907
*/
908
var warnValidStyle = function(name, value) {
909
if (name.indexOf('-') > -1) {
910
warnHyphenatedStyleName(name);
911
} else if (badVendoredStyleNamePattern.test(name)) {
912
warnBadVendoredStyleName(name);
913
} else if (badStyleValueWithSemicolonPattern.test(value)) {
914
warnStyleValueWithSemicolon(name, value);
915
}
916
};
917
}
918
919
/**
920
* Operations for dealing with CSS properties.
921
*/
922
var CSSPropertyOperations = {
923
924
/**
925
* Serializes a mapping of style properties for use as inline styles:
926
*
927
* > createMarkupForStyles({width: '200px', height: 0})
928
* "width:200px;height:0;"
929
*
930
* Undefined values are ignored so that declarative programming is easier.
931
* The result should be HTML-escaped before insertion into the DOM.
932
*
933
* @param {object} styles
934
* @return {?string}
935
*/
936
createMarkupForStyles: function(styles) {
937
var serialized = '';
938
for (var styleName in styles) {
939
if (!styles.hasOwnProperty(styleName)) {
940
continue;
941
}
942
var styleValue = styles[styleName];
943
if ("production" !== "development") {
944
warnValidStyle(styleName, styleValue);
945
}
946
if (styleValue != null) {
947
serialized += processStyleName(styleName) + ':';
948
serialized += dangerousStyleValue(styleName, styleValue) + ';';
949
}
950
}
951
return serialized || null;
952
},
953
954
/**
955
* Sets the value for multiple styles on a node. If a value is specified as
956
* '' (empty string), the corresponding style property will be unset.
957
*
958
* @param {DOMElement} node
959
* @param {object} styles
960
*/
961
setValueForStyles: function(node, styles) {
962
var style = node.style;
963
for (var styleName in styles) {
964
if (!styles.hasOwnProperty(styleName)) {
965
continue;
966
}
967
if ("production" !== "development") {
968
warnValidStyle(styleName, styles[styleName]);
969
}
970
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
971
if (styleName === 'float') {
972
styleName = styleFloatAccessor;
973
}
974
if (styleValue) {
975
style[styleName] = styleValue;
976
} else {
977
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
978
if (expansion) {
979
// Shorthand property that IE8 won't like unsetting, so unset each
980
// component to placate it
981
for (var individualStyleName in expansion) {
982
style[individualStyleName] = '';
983
}
984
} else {
985
style[styleName] = '';
986
}
987
}
988
}
989
}
990
991
};
992
993
module.exports = CSSPropertyOperations;
994
995
},{"121":121,"128":128,"148":148,"159":159,"171":171,"22":22,"5":5}],7:[function(_dereq_,module,exports){
996
/**
997
* Copyright 2013-2015, Facebook, Inc.
998
* All rights reserved.
999
*
1000
* This source code is licensed under the BSD-style license found in the
1001
* LICENSE file in the root directory of this source tree. An additional grant
1002
* of patent rights can be found in the PATENTS file in the same directory.
1003
*
1004
* @providesModule CallbackQueue
1005
*/
1006
1007
'use strict';
1008
1009
var PooledClass = _dereq_(30);
1010
1011
var assign = _dereq_(29);
1012
var invariant = _dereq_(150);
1013
1014
/**
1015
* A specialized pseudo-event module to help keep track of components waiting to
1016
* be notified when their DOM representations are available for use.
1017
*
1018
* This implements `PooledClass`, so you should never need to instantiate this.
1019
* Instead, use `CallbackQueue.getPooled()`.
1020
*
1021
* @class ReactMountReady
1022
* @implements PooledClass
1023
* @internal
1024
*/
1025
function CallbackQueue() {
1026
this._callbacks = null;
1027
this._contexts = null;
1028
}
1029
1030
assign(CallbackQueue.prototype, {
1031
1032
/**
1033
* Enqueues a callback to be invoked when `notifyAll` is invoked.
1034
*
1035
* @param {function} callback Invoked when `notifyAll` is invoked.
1036
* @param {?object} context Context to call `callback` with.
1037
* @internal
1038
*/
1039
enqueue: function(callback, context) {
1040
this._callbacks = this._callbacks || [];
1041
this._contexts = this._contexts || [];
1042
this._callbacks.push(callback);
1043
this._contexts.push(context);
1044
},
1045
1046
/**
1047
* Invokes all enqueued callbacks and clears the queue. This is invoked after
1048
* the DOM representation of a component has been created or updated.
1049
*
1050
* @internal
1051
*/
1052
notifyAll: function() {
1053
var callbacks = this._callbacks;
1054
var contexts = this._contexts;
1055
if (callbacks) {
1056
("production" !== "development" ? invariant(
1057
callbacks.length === contexts.length,
1058
'Mismatched list of contexts in callback queue'
1059
) : invariant(callbacks.length === contexts.length));
1060
this._callbacks = null;
1061
this._contexts = null;
1062
for (var i = 0, l = callbacks.length; i < l; i++) {
1063
callbacks[i].call(contexts[i]);
1064
}
1065
callbacks.length = 0;
1066
contexts.length = 0;
1067
}
1068
},
1069
1070
/**
1071
* Resets the internal queue.
1072
*
1073
* @internal
1074
*/
1075
reset: function() {
1076
this._callbacks = null;
1077
this._contexts = null;
1078
},
1079
1080
/**
1081
* `PooledClass` looks for this.
1082
*/
1083
destructor: function() {
1084
this.reset();
1085
}
1086
1087
});
1088
1089
PooledClass.addPoolingTo(CallbackQueue);
1090
1091
module.exports = CallbackQueue;
1092
1093
},{"150":150,"29":29,"30":30}],8:[function(_dereq_,module,exports){
1094
/**
1095
* Copyright 2013-2015, Facebook, Inc.
1096
* All rights reserved.
1097
*
1098
* This source code is licensed under the BSD-style license found in the
1099
* LICENSE file in the root directory of this source tree. An additional grant
1100
* of patent rights can be found in the PATENTS file in the same directory.
1101
*
1102
* @providesModule ChangeEventPlugin
1103
*/
1104
1105
'use strict';
1106
1107
var EventConstants = _dereq_(16);
1108
var EventPluginHub = _dereq_(18);
1109
var EventPropagators = _dereq_(21);
1110
var ExecutionEnvironment = _dereq_(22);
1111
var ReactUpdates = _dereq_(100);
1112
var SyntheticEvent = _dereq_(108);
1113
1114
var isEventSupported = _dereq_(151);
1115
var isTextInputElement = _dereq_(153);
1116
var keyOf = _dereq_(157);
1117
1118
var topLevelTypes = EventConstants.topLevelTypes;
1119
1120
var eventTypes = {
1121
change: {
1122
phasedRegistrationNames: {
1123
bubbled: keyOf({onChange: null}),
1124
captured: keyOf({onChangeCapture: null})
1125
},
1126
dependencies: [
1127
topLevelTypes.topBlur,
1128
topLevelTypes.topChange,
1129
topLevelTypes.topClick,
1130
topLevelTypes.topFocus,
1131
topLevelTypes.topInput,
1132
topLevelTypes.topKeyDown,
1133
topLevelTypes.topKeyUp,
1134
topLevelTypes.topSelectionChange
1135
]
1136
}
1137
};
1138
1139
/**
1140
* For IE shims
1141
*/
1142
var activeElement = null;
1143
var activeElementID = null;
1144
var activeElementValue = null;
1145
var activeElementValueProp = null;
1146
1147
/**
1148
* SECTION: handle `change` event
1149
*/
1150
function shouldUseChangeEvent(elem) {
1151
return (
1152
elem.nodeName === 'SELECT' ||
1153
(elem.nodeName === 'INPUT' && elem.type === 'file')
1154
);
1155
}
1156
1157
var doesChangeEventBubble = false;
1158
if (ExecutionEnvironment.canUseDOM) {
1159
// See `handleChange` comment below
1160
doesChangeEventBubble = isEventSupported('change') && (
1161
(!('documentMode' in document) || document.documentMode > 8)
1162
);
1163
}
1164
1165
function manualDispatchChangeEvent(nativeEvent) {
1166
var event = SyntheticEvent.getPooled(
1167
eventTypes.change,
1168
activeElementID,
1169
nativeEvent
1170
);
1171
EventPropagators.accumulateTwoPhaseDispatches(event);
1172
1173
// If change and propertychange bubbled, we'd just bind to it like all the
1174
// other events and have it go through ReactBrowserEventEmitter. Since it
1175
// doesn't, we manually listen for the events and so we have to enqueue and
1176
// process the abstract event manually.
1177
//
1178
// Batching is necessary here in order to ensure that all event handlers run
1179
// before the next rerender (including event handlers attached to ancestor
1180
// elements instead of directly on the input). Without this, controlled
1181
// components don't work properly in conjunction with event bubbling because
1182
// the component is rerendered and the value reverted before all the event
1183
// handlers can run. See https://github.com/facebook/react/issues/708.
1184
ReactUpdates.batchedUpdates(runEventInBatch, event);
1185
}
1186
1187
function runEventInBatch(event) {
1188
EventPluginHub.enqueueEvents(event);
1189
EventPluginHub.processEventQueue();
1190
}
1191
1192
function startWatchingForChangeEventIE8(target, targetID) {
1193
activeElement = target;
1194
activeElementID = targetID;
1195
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
1196
}
1197
1198
function stopWatchingForChangeEventIE8() {
1199
if (!activeElement) {
1200
return;
1201
}
1202
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
1203
activeElement = null;
1204
activeElementID = null;
1205
}
1206
1207
function getTargetIDForChangeEvent(
1208
topLevelType,
1209
topLevelTarget,
1210
topLevelTargetID) {
1211
if (topLevelType === topLevelTypes.topChange) {
1212
return topLevelTargetID;
1213
}
1214
}
1215
function handleEventsForChangeEventIE8(
1216
topLevelType,
1217
topLevelTarget,
1218
topLevelTargetID) {
1219
if (topLevelType === topLevelTypes.topFocus) {
1220
// stopWatching() should be a noop here but we call it just in case we
1221
// missed a blur event somehow.
1222
stopWatchingForChangeEventIE8();
1223
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
1224
} else if (topLevelType === topLevelTypes.topBlur) {
1225
stopWatchingForChangeEventIE8();
1226
}
1227
}
1228
1229
1230
/**
1231
* SECTION: handle `input` event
1232
*/
1233
var isInputEventSupported = false;
1234
if (ExecutionEnvironment.canUseDOM) {
1235
// IE9 claims to support the input event but fails to trigger it when
1236
// deleting text, so we ignore its input events
1237
isInputEventSupported = isEventSupported('input') && (
1238
(!('documentMode' in document) || document.documentMode > 9)
1239
);
1240
}
1241
1242
/**
1243
* (For old IE.) Replacement getter/setter for the `value` property that gets
1244
* set on the active element.
1245
*/
1246
var newValueProp = {
1247
get: function() {
1248
return activeElementValueProp.get.call(this);
1249
},
1250
set: function(val) {
1251
// Cast to a string so we can do equality checks.
1252
activeElementValue = '' + val;
1253
activeElementValueProp.set.call(this, val);
1254
}
1255
};
1256
1257
/**
1258
* (For old IE.) Starts tracking propertychange events on the passed-in element
1259
* and override the value property so that we can distinguish user events from
1260
* value changes in JS.
1261
*/
1262
function startWatchingForValueChange(target, targetID) {
1263
activeElement = target;
1264
activeElementID = targetID;
1265
activeElementValue = target.value;
1266
activeElementValueProp = Object.getOwnPropertyDescriptor(
1267
target.constructor.prototype,
1268
'value'
1269
);
1270
1271
Object.defineProperty(activeElement, 'value', newValueProp);
1272
activeElement.attachEvent('onpropertychange', handlePropertyChange);
1273
}
1274
1275
/**
1276
* (For old IE.) Removes the event listeners from the currently-tracked element,
1277
* if any exists.
1278
*/
1279
function stopWatchingForValueChange() {
1280
if (!activeElement) {
1281
return;
1282
}
1283
1284
// delete restores the original property definition
1285
delete activeElement.value;
1286
activeElement.detachEvent('onpropertychange', handlePropertyChange);
1287
1288
activeElement = null;
1289
activeElementID = null;
1290
activeElementValue = null;
1291
activeElementValueProp = null;
1292
}
1293
1294
/**
1295
* (For old IE.) Handles a propertychange event, sending a `change` event if
1296
* the value of the active element has changed.
1297
*/
1298
function handlePropertyChange(nativeEvent) {
1299
if (nativeEvent.propertyName !== 'value') {
1300
return;
1301
}
1302
var value = nativeEvent.srcElement.value;
1303
if (value === activeElementValue) {
1304
return;
1305
}
1306
activeElementValue = value;
1307
1308
manualDispatchChangeEvent(nativeEvent);
1309
}
1310
1311
/**
1312
* If a `change` event should be fired, returns the target's ID.
1313
*/
1314
function getTargetIDForInputEvent(
1315
topLevelType,
1316
topLevelTarget,
1317
topLevelTargetID) {
1318
if (topLevelType === topLevelTypes.topInput) {
1319
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
1320
// what we want so fall through here and trigger an abstract event
1321
return topLevelTargetID;
1322
}
1323
}
1324
1325
// For IE8 and IE9.
1326
function handleEventsForInputEventIE(
1327
topLevelType,
1328
topLevelTarget,
1329
topLevelTargetID) {
1330
if (topLevelType === topLevelTypes.topFocus) {
1331
// In IE8, we can capture almost all .value changes by adding a
1332
// propertychange handler and looking for events with propertyName
1333
// equal to 'value'
1334
// In IE9, propertychange fires for most input events but is buggy and
1335
// doesn't fire when text is deleted, but conveniently, selectionchange
1336
// appears to fire in all of the remaining cases so we catch those and
1337
// forward the event if the value has changed
1338
// In either case, we don't want to call the event handler if the value
1339
// is changed from JS so we redefine a setter for `.value` that updates
1340
// our activeElementValue variable, allowing us to ignore those changes
1341
//
1342
// stopWatching() should be a noop here but we call it just in case we
1343
// missed a blur event somehow.
1344
stopWatchingForValueChange();
1345
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
1346
} else if (topLevelType === topLevelTypes.topBlur) {
1347
stopWatchingForValueChange();
1348
}
1349
}
1350
1351
// For IE8 and IE9.
1352
function getTargetIDForInputEventIE(
1353
topLevelType,
1354
topLevelTarget,
1355
topLevelTargetID) {
1356
if (topLevelType === topLevelTypes.topSelectionChange ||
1357
topLevelType === topLevelTypes.topKeyUp ||
1358
topLevelType === topLevelTypes.topKeyDown) {
1359
// On the selectionchange event, the target is just document which isn't
1360
// helpful for us so just check activeElement instead.
1361
//
1362
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
1363
// propertychange on the first input event after setting `value` from a
1364
// script and fires only keydown, keypress, keyup. Catching keyup usually
1365
// gets it and catching keydown lets us fire an event for the first
1366
// keystroke if user does a key repeat (it'll be a little delayed: right
1367
// before the second keystroke). Other input methods (e.g., paste) seem to
1368
// fire selectionchange normally.
1369
if (activeElement && activeElement.value !== activeElementValue) {
1370
activeElementValue = activeElement.value;
1371
return activeElementID;
1372
}
1373
}
1374
}
1375
1376
1377
/**
1378
* SECTION: handle `click` event
1379
*/
1380
function shouldUseClickEvent(elem) {
1381
// Use the `click` event to detect changes to checkbox and radio inputs.
1382
// This approach works across all browsers, whereas `change` does not fire
1383
// until `blur` in IE8.
1384
return (
1385
elem.nodeName === 'INPUT' &&
1386
(elem.type === 'checkbox' || elem.type === 'radio')
1387
);
1388
}
1389
1390
function getTargetIDForClickEvent(
1391
topLevelType,
1392
topLevelTarget,
1393
topLevelTargetID) {
1394
if (topLevelType === topLevelTypes.topClick) {
1395
return topLevelTargetID;
1396
}
1397
}
1398
1399
/**
1400
* This plugin creates an `onChange` event that normalizes change events
1401
* across form elements. This event fires at a time when it's possible to
1402
* change the element's value without seeing a flicker.
1403
*
1404
* Supported elements are:
1405
* - input (see `isTextInputElement`)
1406
* - textarea
1407
* - select
1408
*/
1409
var ChangeEventPlugin = {
1410
1411
eventTypes: eventTypes,
1412
1413
/**
1414
* @param {string} topLevelType Record from `EventConstants`.
1415
* @param {DOMEventTarget} topLevelTarget The listening component root node.
1416
* @param {string} topLevelTargetID ID of `topLevelTarget`.
1417
* @param {object} nativeEvent Native browser event.
1418
* @return {*} An accumulation of synthetic events.
1419
* @see {EventPluginHub.extractEvents}
1420
*/
1421
extractEvents: function(
1422
topLevelType,
1423
topLevelTarget,
1424
topLevelTargetID,
1425
nativeEvent) {
1426
1427
var getTargetIDFunc, handleEventFunc;
1428
if (shouldUseChangeEvent(topLevelTarget)) {
1429
if (doesChangeEventBubble) {
1430
getTargetIDFunc = getTargetIDForChangeEvent;
1431
} else {
1432
handleEventFunc = handleEventsForChangeEventIE8;
1433
}
1434
} else if (isTextInputElement(topLevelTarget)) {
1435
if (isInputEventSupported) {
1436
getTargetIDFunc = getTargetIDForInputEvent;
1437
} else {
1438
getTargetIDFunc = getTargetIDForInputEventIE;
1439
handleEventFunc = handleEventsForInputEventIE;
1440
}
1441
} else if (shouldUseClickEvent(topLevelTarget)) {
1442
getTargetIDFunc = getTargetIDForClickEvent;
1443
}
1444
1445
if (getTargetIDFunc) {
1446
var targetID = getTargetIDFunc(
1447
topLevelType,
1448
topLevelTarget,
1449
topLevelTargetID
1450
);
1451
if (targetID) {
1452
var event = SyntheticEvent.getPooled(
1453
eventTypes.change,
1454
targetID,
1455
nativeEvent
1456
);
1457
EventPropagators.accumulateTwoPhaseDispatches(event);
1458
return event;
1459
}
1460
}
1461
1462
if (handleEventFunc) {
1463
handleEventFunc(
1464
topLevelType,
1465
topLevelTarget,
1466
topLevelTargetID
1467
);
1468
}
1469
}
1470
1471
};
1472
1473
module.exports = ChangeEventPlugin;
1474
1475
},{"100":100,"108":108,"151":151,"153":153,"157":157,"16":16,"18":18,"21":21,"22":22}],9:[function(_dereq_,module,exports){
1476
/**
1477
* Copyright 2013-2015, Facebook, Inc.
1478
* All rights reserved.
1479
*
1480
* This source code is licensed under the BSD-style license found in the
1481
* LICENSE file in the root directory of this source tree. An additional grant
1482
* of patent rights can be found in the PATENTS file in the same directory.
1483
*
1484
* @providesModule ClientReactRootIndex
1485
* @typechecks
1486
*/
1487
1488
'use strict';
1489
1490
var nextReactRootIndex = 0;
1491
1492
var ClientReactRootIndex = {
1493
createReactRootIndex: function() {
1494
return nextReactRootIndex++;
1495
}
1496
};
1497
1498
module.exports = ClientReactRootIndex;
1499
1500
},{}],10:[function(_dereq_,module,exports){
1501
/**
1502
* Copyright 2013-2015, Facebook, Inc.
1503
* All rights reserved.
1504
*
1505
* This source code is licensed under the BSD-style license found in the
1506
* LICENSE file in the root directory of this source tree. An additional grant
1507
* of patent rights can be found in the PATENTS file in the same directory.
1508
*
1509
* @providesModule DOMChildrenOperations
1510
* @typechecks static-only
1511
*/
1512
1513
'use strict';
1514
1515
var Danger = _dereq_(13);
1516
var ReactMultiChildUpdateTypes = _dereq_(79);
1517
1518
var setTextContent = _dereq_(165);
1519
var invariant = _dereq_(150);
1520
1521
/**
1522
* Inserts `childNode` as a child of `parentNode` at the `index`.
1523
*
1524
* @param {DOMElement} parentNode Parent node in which to insert.
1525
* @param {DOMElement} childNode Child node to insert.
1526
* @param {number} index Index at which to insert the child.
1527
* @internal
1528
*/
1529
function insertChildAt(parentNode, childNode, index) {
1530
// By exploiting arrays returning `undefined` for an undefined index, we can
1531
// rely exclusively on `insertBefore(node, null)` instead of also using
1532
// `appendChild(node)`. However, using `undefined` is not allowed by all
1533
// browsers so we must replace it with `null`.
1534
parentNode.insertBefore(
1535
childNode,
1536
parentNode.childNodes[index] || null
1537
);
1538
}
1539
1540
/**
1541
* Operations for updating with DOM children.
1542
*/
1543
var DOMChildrenOperations = {
1544
1545
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
1546
1547
updateTextContent: setTextContent,
1548
1549
/**
1550
* Updates a component's children by processing a series of updates. The
1551
* update configurations are each expected to have a `parentNode` property.
1552
*
1553
* @param {array<object>} updates List of update configurations.
1554
* @param {array<string>} markupList List of markup strings.
1555
* @internal
1556
*/
1557
processUpdates: function(updates, markupList) {
1558
var update;
1559
// Mapping from parent IDs to initial child orderings.
1560
var initialChildren = null;
1561
// List of children that will be moved or removed.
1562
var updatedChildren = null;
1563
1564
for (var i = 0; i < updates.length; i++) {
1565
update = updates[i];
1566
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
1567
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
1568
var updatedIndex = update.fromIndex;
1569
var updatedChild = update.parentNode.childNodes[updatedIndex];
1570
var parentID = update.parentID;
1571
1572
("production" !== "development" ? invariant(
1573
updatedChild,
1574
'processUpdates(): Unable to find child %s of element. This ' +
1575
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
1576
'browser), usually due to forgetting a <tbody> when using tables, ' +
1577
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
1578
'in an <svg> parent. Try inspecting the child nodes of the element ' +
1579
'with React ID `%s`.',
1580
updatedIndex,
1581
parentID
1582
) : invariant(updatedChild));
1583
1584
initialChildren = initialChildren || {};
1585
initialChildren[parentID] = initialChildren[parentID] || [];
1586
initialChildren[parentID][updatedIndex] = updatedChild;
1587
1588
updatedChildren = updatedChildren || [];
1589
updatedChildren.push(updatedChild);
1590
}
1591
}
1592
1593
var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
1594
1595
// Remove updated children first so that `toIndex` is consistent.
1596
if (updatedChildren) {
1597
for (var j = 0; j < updatedChildren.length; j++) {
1598
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
1599
}
1600
}
1601
1602
for (var k = 0; k < updates.length; k++) {
1603
update = updates[k];
1604
switch (update.type) {
1605
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
1606
insertChildAt(
1607
update.parentNode,
1608
renderedMarkup[update.markupIndex],
1609
update.toIndex
1610
);
1611
break;
1612
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
1613
insertChildAt(
1614
update.parentNode,
1615
initialChildren[update.parentID][update.fromIndex],
1616
update.toIndex
1617
);
1618
break;
1619
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
1620
setTextContent(
1621
update.parentNode,
1622
update.textContent
1623
);
1624
break;
1625
case ReactMultiChildUpdateTypes.REMOVE_NODE:
1626
// Already removed by the for-loop above.
1627
break;
1628
}
1629
}
1630
}
1631
1632
};
1633
1634
module.exports = DOMChildrenOperations;
1635
1636
},{"13":13,"150":150,"165":165,"79":79}],11:[function(_dereq_,module,exports){
1637
/**
1638
* Copyright 2013-2015, Facebook, Inc.
1639
* All rights reserved.
1640
*
1641
* This source code is licensed under the BSD-style license found in the
1642
* LICENSE file in the root directory of this source tree. An additional grant
1643
* of patent rights can be found in the PATENTS file in the same directory.
1644
*
1645
* @providesModule DOMProperty
1646
* @typechecks static-only
1647
*/
1648
1649
/*jslint bitwise: true */
1650
1651
'use strict';
1652
1653
var invariant = _dereq_(150);
1654
1655
function checkMask(value, bitmask) {
1656
return (value & bitmask) === bitmask;
1657
}
1658
1659
var DOMPropertyInjection = {
1660
/**
1661
* Mapping from normalized, camelcased property names to a configuration that
1662
* specifies how the associated DOM property should be accessed or rendered.
1663
*/
1664
MUST_USE_ATTRIBUTE: 0x1,
1665
MUST_USE_PROPERTY: 0x2,
1666
HAS_SIDE_EFFECTS: 0x4,
1667
HAS_BOOLEAN_VALUE: 0x8,
1668
HAS_NUMERIC_VALUE: 0x10,
1669
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
1670
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
1671
1672
/**
1673
* Inject some specialized knowledge about the DOM. This takes a config object
1674
* with the following properties:
1675
*
1676
* isCustomAttribute: function that given an attribute name will return true
1677
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
1678
* attributes where it's impossible to enumerate all of the possible
1679
* attribute names,
1680
*
1681
* Properties: object mapping DOM property name to one of the
1682
* DOMPropertyInjection constants or null. If your attribute isn't in here,
1683
* it won't get written to the DOM.
1684
*
1685
* DOMAttributeNames: object mapping React attribute name to the DOM
1686
* attribute name. Attribute names not specified use the **lowercase**
1687
* normalized name.
1688
*
1689
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
1690
* Property names not specified use the normalized name.
1691
*
1692
* DOMMutationMethods: Properties that require special mutation methods. If
1693
* `value` is undefined, the mutation method should unset the property.
1694
*
1695
* @param {object} domPropertyConfig the config as described above.
1696
*/
1697
injectDOMPropertyConfig: function(domPropertyConfig) {
1698
var Properties = domPropertyConfig.Properties || {};
1699
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
1700
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
1701
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
1702
1703
if (domPropertyConfig.isCustomAttribute) {
1704
DOMProperty._isCustomAttributeFunctions.push(
1705
domPropertyConfig.isCustomAttribute
1706
);
1707
}
1708
1709
for (var propName in Properties) {
1710
("production" !== "development" ? invariant(
1711
!DOMProperty.isStandardName.hasOwnProperty(propName),
1712
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
1713
'\'%s\' which has already been injected. You may be accidentally ' +
1714
'injecting the same DOM property config twice, or you may be ' +
1715
'injecting two configs that have conflicting property names.',
1716
propName
1717
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
1718
1719
DOMProperty.isStandardName[propName] = true;
1720
1721
var lowerCased = propName.toLowerCase();
1722
DOMProperty.getPossibleStandardName[lowerCased] = propName;
1723
1724
if (DOMAttributeNames.hasOwnProperty(propName)) {
1725
var attributeName = DOMAttributeNames[propName];
1726
DOMProperty.getPossibleStandardName[attributeName] = propName;
1727
DOMProperty.getAttributeName[propName] = attributeName;
1728
} else {
1729
DOMProperty.getAttributeName[propName] = lowerCased;
1730
}
1731
1732
DOMProperty.getPropertyName[propName] =
1733
DOMPropertyNames.hasOwnProperty(propName) ?
1734
DOMPropertyNames[propName] :
1735
propName;
1736
1737
if (DOMMutationMethods.hasOwnProperty(propName)) {
1738
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
1739
} else {
1740
DOMProperty.getMutationMethod[propName] = null;
1741
}
1742
1743
var propConfig = Properties[propName];
1744
DOMProperty.mustUseAttribute[propName] =
1745
checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
1746
DOMProperty.mustUseProperty[propName] =
1747
checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
1748
DOMProperty.hasSideEffects[propName] =
1749
checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
1750
DOMProperty.hasBooleanValue[propName] =
1751
checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
1752
DOMProperty.hasNumericValue[propName] =
1753
checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
1754
DOMProperty.hasPositiveNumericValue[propName] =
1755
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
1756
DOMProperty.hasOverloadedBooleanValue[propName] =
1757
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
1758
1759
("production" !== "development" ? invariant(
1760
!DOMProperty.mustUseAttribute[propName] ||
1761
!DOMProperty.mustUseProperty[propName],
1762
'DOMProperty: Cannot require using both attribute and property: %s',
1763
propName
1764
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
1765
!DOMProperty.mustUseProperty[propName]));
1766
("production" !== "development" ? invariant(
1767
DOMProperty.mustUseProperty[propName] ||
1768
!DOMProperty.hasSideEffects[propName],
1769
'DOMProperty: Properties that have side effects must use property: %s',
1770
propName
1771
) : invariant(DOMProperty.mustUseProperty[propName] ||
1772
!DOMProperty.hasSideEffects[propName]));
1773
("production" !== "development" ? invariant(
1774
!!DOMProperty.hasBooleanValue[propName] +
1775
!!DOMProperty.hasNumericValue[propName] +
1776
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
1777
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
1778
'numeric value, but not a combination: %s',
1779
propName
1780
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
1781
!!DOMProperty.hasNumericValue[propName] +
1782
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
1783
}
1784
}
1785
};
1786
var defaultValueCache = {};
1787
1788
/**
1789
* DOMProperty exports lookup objects that can be used like functions:
1790
*
1791
* > DOMProperty.isValid['id']
1792
* true
1793
* > DOMProperty.isValid['foobar']
1794
* undefined
1795
*
1796
* Although this may be confusing, it performs better in general.
1797
*
1798
* @see http://jsperf.com/key-exists
1799
* @see http://jsperf.com/key-missing
1800
*/
1801
var DOMProperty = {
1802
1803
ID_ATTRIBUTE_NAME: 'data-reactid',
1804
1805
/**
1806
* Checks whether a property name is a standard property.
1807
* @type {Object}
1808
*/
1809
isStandardName: {},
1810
1811
/**
1812
* Mapping from lowercase property names to the properly cased version, used
1813
* to warn in the case of missing properties.
1814
* @type {Object}
1815
*/
1816
getPossibleStandardName: {},
1817
1818
/**
1819
* Mapping from normalized names to attribute names that differ. Attribute
1820
* names are used when rendering markup or with `*Attribute()`.
1821
* @type {Object}
1822
*/
1823
getAttributeName: {},
1824
1825
/**
1826
* Mapping from normalized names to properties on DOM node instances.
1827
* (This includes properties that mutate due to external factors.)
1828
* @type {Object}
1829
*/
1830
getPropertyName: {},
1831
1832
/**
1833
* Mapping from normalized names to mutation methods. This will only exist if
1834
* mutation cannot be set simply by the property or `setAttribute()`.
1835
* @type {Object}
1836
*/
1837
getMutationMethod: {},
1838
1839
/**
1840
* Whether the property must be accessed and mutated as an object property.
1841
* @type {Object}
1842
*/
1843
mustUseAttribute: {},
1844
1845
/**
1846
* Whether the property must be accessed and mutated using `*Attribute()`.
1847
* (This includes anything that fails `<propName> in <element>`.)
1848
* @type {Object}
1849
*/
1850
mustUseProperty: {},
1851
1852
/**
1853
* Whether or not setting a value causes side effects such as triggering
1854
* resources to be loaded or text selection changes. We must ensure that
1855
* the value is only set if it has changed.
1856
* @type {Object}
1857
*/
1858
hasSideEffects: {},
1859
1860
/**
1861
* Whether the property should be removed when set to a falsey value.
1862
* @type {Object}
1863
*/
1864
hasBooleanValue: {},
1865
1866
/**
1867
* Whether the property must be numeric or parse as a
1868
* numeric and should be removed when set to a falsey value.
1869
* @type {Object}
1870
*/
1871
hasNumericValue: {},
1872
1873
/**
1874
* Whether the property must be positive numeric or parse as a positive
1875
* numeric and should be removed when set to a falsey value.
1876
* @type {Object}
1877
*/
1878
hasPositiveNumericValue: {},
1879
1880
/**
1881
* Whether the property can be used as a flag as well as with a value. Removed
1882
* when strictly equal to false; present without a value when strictly equal
1883
* to true; present with a value otherwise.
1884
* @type {Object}
1885
*/
1886
hasOverloadedBooleanValue: {},
1887
1888
/**
1889
* All of the isCustomAttribute() functions that have been injected.
1890
*/
1891
_isCustomAttributeFunctions: [],
1892
1893
/**
1894
* Checks whether a property name is a custom attribute.
1895
* @method
1896
*/
1897
isCustomAttribute: function(attributeName) {
1898
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
1899
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
1900
if (isCustomAttributeFn(attributeName)) {
1901
return true;
1902
}
1903
}
1904
return false;
1905
},
1906
1907
/**
1908
* Returns the default property value for a DOM property (i.e., not an
1909
* attribute). Most default values are '' or false, but not all. Worse yet,
1910
* some (in particular, `type`) vary depending on the type of element.
1911
*
1912
* TODO: Is it better to grab all the possible properties when creating an
1913
* element to avoid having to create the same element twice?
1914
*/
1915
getDefaultValueForProperty: function(nodeName, prop) {
1916
var nodeDefaults = defaultValueCache[nodeName];
1917
var testElement;
1918
if (!nodeDefaults) {
1919
defaultValueCache[nodeName] = nodeDefaults = {};
1920
}
1921
if (!(prop in nodeDefaults)) {
1922
testElement = document.createElement(nodeName);
1923
nodeDefaults[prop] = testElement[prop];
1924
}
1925
return nodeDefaults[prop];
1926
},
1927
1928
injection: DOMPropertyInjection
1929
};
1930
1931
module.exports = DOMProperty;
1932
1933
},{"150":150}],12:[function(_dereq_,module,exports){
1934
/**
1935
* Copyright 2013-2015, Facebook, Inc.
1936
* All rights reserved.
1937
*
1938
* This source code is licensed under the BSD-style license found in the
1939
* LICENSE file in the root directory of this source tree. An additional grant
1940
* of patent rights can be found in the PATENTS file in the same directory.
1941
*
1942
* @providesModule DOMPropertyOperations
1943
* @typechecks static-only
1944
*/
1945
1946
'use strict';
1947
1948
var DOMProperty = _dereq_(11);
1949
1950
var quoteAttributeValueForBrowser = _dereq_(163);
1951
var warning = _dereq_(171);
1952
1953
function shouldIgnoreValue(name, value) {
1954
return value == null ||
1955
(DOMProperty.hasBooleanValue[name] && !value) ||
1956
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
1957
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
1958
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
1959
}
1960
1961
if ("production" !== "development") {
1962
var reactProps = {
1963
children: true,
1964
dangerouslySetInnerHTML: true,
1965
key: true,
1966
ref: true
1967
};
1968
var warnedProperties = {};
1969
1970
var warnUnknownProperty = function(name) {
1971
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
1972
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
1973
return;
1974
}
1975
1976
warnedProperties[name] = true;
1977
var lowerCasedName = name.toLowerCase();
1978
1979
// data-* attributes should be lowercase; suggest the lowercase version
1980
var standardName = (
1981
DOMProperty.isCustomAttribute(lowerCasedName) ?
1982
lowerCasedName :
1983
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
1984
DOMProperty.getPossibleStandardName[lowerCasedName] :
1985
null
1986
);
1987
1988
// For now, only warn when we have a suggested correction. This prevents
1989
// logging too much when using transferPropsTo.
1990
("production" !== "development" ? warning(
1991
standardName == null,
1992
'Unknown DOM property %s. Did you mean %s?',
1993
name,
1994
standardName
1995
) : null);
1996
1997
};
1998
}
1999
2000
/**
2001
* Operations for dealing with DOM properties.
2002
*/
2003
var DOMPropertyOperations = {
2004
2005
/**
2006
* Creates markup for the ID property.
2007
*
2008
* @param {string} id Unescaped ID.
2009
* @return {string} Markup string.
2010
*/
2011
createMarkupForID: function(id) {
2012
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
2013
quoteAttributeValueForBrowser(id);
2014
},
2015
2016
/**
2017
* Creates markup for a property.
2018
*
2019
* @param {string} name
2020
* @param {*} value
2021
* @return {?string} Markup string, or null if the property was invalid.
2022
*/
2023
createMarkupForProperty: function(name, value) {
2024
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2025
DOMProperty.isStandardName[name]) {
2026
if (shouldIgnoreValue(name, value)) {
2027
return '';
2028
}
2029
var attributeName = DOMProperty.getAttributeName[name];
2030
if (DOMProperty.hasBooleanValue[name] ||
2031
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
2032
return attributeName;
2033
}
2034
return attributeName + '=' + quoteAttributeValueForBrowser(value);
2035
} else if (DOMProperty.isCustomAttribute(name)) {
2036
if (value == null) {
2037
return '';
2038
}
2039
return name + '=' + quoteAttributeValueForBrowser(value);
2040
} else if ("production" !== "development") {
2041
warnUnknownProperty(name);
2042
}
2043
return null;
2044
},
2045
2046
/**
2047
* Sets the value for a property on a node.
2048
*
2049
* @param {DOMElement} node
2050
* @param {string} name
2051
* @param {*} value
2052
*/
2053
setValueForProperty: function(node, name, value) {
2054
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2055
DOMProperty.isStandardName[name]) {
2056
var mutationMethod = DOMProperty.getMutationMethod[name];
2057
if (mutationMethod) {
2058
mutationMethod(node, value);
2059
} else if (shouldIgnoreValue(name, value)) {
2060
this.deleteValueForProperty(node, name);
2061
} else if (DOMProperty.mustUseAttribute[name]) {
2062
// `setAttribute` with objects becomes only `[object]` in IE8/9,
2063
// ('' + value) makes it output the correct toString()-value.
2064
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
2065
} else {
2066
var propName = DOMProperty.getPropertyName[name];
2067
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
2068
// property type before comparing; only `value` does and is string.
2069
if (!DOMProperty.hasSideEffects[name] ||
2070
('' + node[propName]) !== ('' + value)) {
2071
// Contrary to `setAttribute`, object properties are properly
2072
// `toString`ed by IE8/9.
2073
node[propName] = value;
2074
}
2075
}
2076
} else if (DOMProperty.isCustomAttribute(name)) {
2077
if (value == null) {
2078
node.removeAttribute(name);
2079
} else {
2080
node.setAttribute(name, '' + value);
2081
}
2082
} else if ("production" !== "development") {
2083
warnUnknownProperty(name);
2084
}
2085
},
2086
2087
/**
2088
* Deletes the value for a property on a node.
2089
*
2090
* @param {DOMElement} node
2091
* @param {string} name
2092
*/
2093
deleteValueForProperty: function(node, name) {
2094
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
2095
DOMProperty.isStandardName[name]) {
2096
var mutationMethod = DOMProperty.getMutationMethod[name];
2097
if (mutationMethod) {
2098
mutationMethod(node, undefined);
2099
} else if (DOMProperty.mustUseAttribute[name]) {
2100
node.removeAttribute(DOMProperty.getAttributeName[name]);
2101
} else {
2102
var propName = DOMProperty.getPropertyName[name];
2103
var defaultValue = DOMProperty.getDefaultValueForProperty(
2104
node.nodeName,
2105
propName
2106
);
2107
if (!DOMProperty.hasSideEffects[name] ||
2108
('' + node[propName]) !== defaultValue) {
2109
node[propName] = defaultValue;
2110
}
2111
}
2112
} else if (DOMProperty.isCustomAttribute(name)) {
2113
node.removeAttribute(name);
2114
} else if ("production" !== "development") {
2115
warnUnknownProperty(name);
2116
}
2117
}
2118
2119
};
2120
2121
module.exports = DOMPropertyOperations;
2122
2123
},{"11":11,"163":163,"171":171}],13:[function(_dereq_,module,exports){
2124
/**
2125
* Copyright 2013-2015, Facebook, Inc.
2126
* All rights reserved.
2127
*
2128
* This source code is licensed under the BSD-style license found in the
2129
* LICENSE file in the root directory of this source tree. An additional grant
2130
* of patent rights can be found in the PATENTS file in the same directory.
2131
*
2132
* @providesModule Danger
2133
* @typechecks static-only
2134
*/
2135
2136
/*jslint evil: true, sub: true */
2137
2138
'use strict';
2139
2140
var ExecutionEnvironment = _dereq_(22);
2141
2142
var createNodesFromMarkup = _dereq_(126);
2143
var emptyFunction = _dereq_(129);
2144
var getMarkupWrap = _dereq_(142);
2145
var invariant = _dereq_(150);
2146
2147
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
2148
var RESULT_INDEX_ATTR = 'data-danger-index';
2149
2150
/**
2151
* Extracts the `nodeName` from a string of markup.
2152
*
2153
* NOTE: Extracting the `nodeName` does not require a regular expression match
2154
* because we make assumptions about React-generated markup (i.e. there are no
2155
* spaces surrounding the opening tag and there is at least one attribute).
2156
*
2157
* @param {string} markup String of markup.
2158
* @return {string} Node name of the supplied markup.
2159
* @see http://jsperf.com/extract-nodename
2160
*/
2161
function getNodeName(markup) {
2162
return markup.substring(1, markup.indexOf(' '));
2163
}
2164
2165
var Danger = {
2166
2167
/**
2168
* Renders markup into an array of nodes. The markup is expected to render
2169
* into a list of root nodes. Also, the length of `resultList` and
2170
* `markupList` should be the same.
2171
*
2172
* @param {array<string>} markupList List of markup strings to render.
2173
* @return {array<DOMElement>} List of rendered nodes.
2174
* @internal
2175
*/
2176
dangerouslyRenderMarkup: function(markupList) {
2177
("production" !== "development" ? invariant(
2178
ExecutionEnvironment.canUseDOM,
2179
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
2180
'thread. Make sure `window` and `document` are available globally ' +
2181
'before requiring React when unit testing or use ' +
2182
'React.renderToString for server rendering.'
2183
) : invariant(ExecutionEnvironment.canUseDOM));
2184
var nodeName;
2185
var markupByNodeName = {};
2186
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
2187
for (var i = 0; i < markupList.length; i++) {
2188
("production" !== "development" ? invariant(
2189
markupList[i],
2190
'dangerouslyRenderMarkup(...): Missing markup.'
2191
) : invariant(markupList[i]));
2192
nodeName = getNodeName(markupList[i]);
2193
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
2194
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
2195
markupByNodeName[nodeName][i] = markupList[i];
2196
}
2197
var resultList = [];
2198
var resultListAssignmentCount = 0;
2199
for (nodeName in markupByNodeName) {
2200
if (!markupByNodeName.hasOwnProperty(nodeName)) {
2201
continue;
2202
}
2203
var markupListByNodeName = markupByNodeName[nodeName];
2204
2205
// This for-in loop skips the holes of the sparse array. The order of
2206
// iteration should follow the order of assignment, which happens to match
2207
// numerical index order, but we don't rely on that.
2208
var resultIndex;
2209
for (resultIndex in markupListByNodeName) {
2210
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
2211
var markup = markupListByNodeName[resultIndex];
2212
2213
// Push the requested markup with an additional RESULT_INDEX_ATTR
2214
// attribute. If the markup does not start with a < character, it
2215
// will be discarded below (with an appropriate console.error).
2216
markupListByNodeName[resultIndex] = markup.replace(
2217
OPEN_TAG_NAME_EXP,
2218
// This index will be parsed back out below.
2219
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
2220
);
2221
}
2222
}
2223
2224
// Render each group of markup with similar wrapping `nodeName`.
2225
var renderNodes = createNodesFromMarkup(
2226
markupListByNodeName.join(''),
2227
emptyFunction // Do nothing special with <script> tags.
2228
);
2229
2230
for (var j = 0; j < renderNodes.length; ++j) {
2231
var renderNode = renderNodes[j];
2232
if (renderNode.hasAttribute &&
2233
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
2234
2235
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
2236
renderNode.removeAttribute(RESULT_INDEX_ATTR);
2237
2238
("production" !== "development" ? invariant(
2239
!resultList.hasOwnProperty(resultIndex),
2240
'Danger: Assigning to an already-occupied result index.'
2241
) : invariant(!resultList.hasOwnProperty(resultIndex)));
2242
2243
resultList[resultIndex] = renderNode;
2244
2245
// This should match resultList.length and markupList.length when
2246
// we're done.
2247
resultListAssignmentCount += 1;
2248
2249
} else if ("production" !== "development") {
2250
console.error(
2251
'Danger: Discarding unexpected node:',
2252
renderNode
2253
);
2254
}
2255
}
2256
}
2257
2258
// Although resultList was populated out of order, it should now be a dense
2259
// array.
2260
("production" !== "development" ? invariant(
2261
resultListAssignmentCount === resultList.length,
2262
'Danger: Did not assign to every index of resultList.'
2263
) : invariant(resultListAssignmentCount === resultList.length));
2264
2265
("production" !== "development" ? invariant(
2266
resultList.length === markupList.length,
2267
'Danger: Expected markup to render %s nodes, but rendered %s.',
2268
markupList.length,
2269
resultList.length
2270
) : invariant(resultList.length === markupList.length));
2271
2272
return resultList;
2273
},
2274
2275
/**
2276
* Replaces a node with a string of markup at its current position within its
2277
* parent. The markup must render into a single root node.
2278
*
2279
* @param {DOMElement} oldChild Child node to replace.
2280
* @param {string} markup Markup to render in place of the child node.
2281
* @internal
2282
*/
2283
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
2284
("production" !== "development" ? invariant(
2285
ExecutionEnvironment.canUseDOM,
2286
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
2287
'worker thread. Make sure `window` and `document` are available ' +
2288
'globally before requiring React when unit testing or use ' +
2289
'React.renderToString for server rendering.'
2290
) : invariant(ExecutionEnvironment.canUseDOM));
2291
("production" !== "development" ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
2292
("production" !== "development" ? invariant(
2293
oldChild.tagName.toLowerCase() !== 'html',
2294
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
2295
'<html> node. This is because browser quirks make this unreliable ' +
2296
'and/or slow. If you want to render to the root you must use ' +
2297
'server rendering. See React.renderToString().'
2298
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
2299
2300
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
2301
oldChild.parentNode.replaceChild(newChild, oldChild);
2302
}
2303
2304
};
2305
2306
module.exports = Danger;
2307
2308
},{"126":126,"129":129,"142":142,"150":150,"22":22}],14:[function(_dereq_,module,exports){
2309
/**
2310
* Copyright 2013-2015, Facebook, Inc.
2311
* All rights reserved.
2312
*
2313
* This source code is licensed under the BSD-style license found in the
2314
* LICENSE file in the root directory of this source tree. An additional grant
2315
* of patent rights can be found in the PATENTS file in the same directory.
2316
*
2317
* @providesModule DefaultEventPluginOrder
2318
*/
2319
2320
'use strict';
2321
2322
var keyOf = _dereq_(157);
2323
2324
/**
2325
* Module that is injectable into `EventPluginHub`, that specifies a
2326
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
2327
* plugins, without having to package every one of them. This is better than
2328
* having plugins be ordered in the same order that they are injected because
2329
* that ordering would be influenced by the packaging order.
2330
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
2331
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
2332
*/
2333
var DefaultEventPluginOrder = [
2334
keyOf({ResponderEventPlugin: null}),
2335
keyOf({SimpleEventPlugin: null}),
2336
keyOf({TapEventPlugin: null}),
2337
keyOf({EnterLeaveEventPlugin: null}),
2338
keyOf({ChangeEventPlugin: null}),
2339
keyOf({SelectEventPlugin: null}),
2340
keyOf({BeforeInputEventPlugin: null}),
2341
keyOf({AnalyticsEventPlugin: null}),
2342
keyOf({MobileSafariClickEventPlugin: null})
2343
];
2344
2345
module.exports = DefaultEventPluginOrder;
2346
2347
},{"157":157}],15:[function(_dereq_,module,exports){
2348
/**
2349
* Copyright 2013-2015, Facebook, Inc.
2350
* All rights reserved.
2351
*
2352
* This source code is licensed under the BSD-style license found in the
2353
* LICENSE file in the root directory of this source tree. An additional grant
2354
* of patent rights can be found in the PATENTS file in the same directory.
2355
*
2356
* @providesModule EnterLeaveEventPlugin
2357
* @typechecks static-only
2358
*/
2359
2360
'use strict';
2361
2362
var EventConstants = _dereq_(16);
2363
var EventPropagators = _dereq_(21);
2364
var SyntheticMouseEvent = _dereq_(112);
2365
2366
var ReactMount = _dereq_(77);
2367
var keyOf = _dereq_(157);
2368
2369
var topLevelTypes = EventConstants.topLevelTypes;
2370
var getFirstReactDOM = ReactMount.getFirstReactDOM;
2371
2372
var eventTypes = {
2373
mouseEnter: {
2374
registrationName: keyOf({onMouseEnter: null}),
2375
dependencies: [
2376
topLevelTypes.topMouseOut,
2377
topLevelTypes.topMouseOver
2378
]
2379
},
2380
mouseLeave: {
2381
registrationName: keyOf({onMouseLeave: null}),
2382
dependencies: [
2383
topLevelTypes.topMouseOut,
2384
topLevelTypes.topMouseOver
2385
]
2386
}
2387
};
2388
2389
var extractedEvents = [null, null];
2390
2391
var EnterLeaveEventPlugin = {
2392
2393
eventTypes: eventTypes,
2394
2395
/**
2396
* For almost every interaction we care about, there will be both a top-level
2397
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
2398
* we do not extract duplicate events. However, moving the mouse into the
2399
* browser from outside will not fire a `mouseout` event. In this case, we use
2400
* the `mouseover` top-level event.
2401
*
2402
* @param {string} topLevelType Record from `EventConstants`.
2403
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2404
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2405
* @param {object} nativeEvent Native browser event.
2406
* @return {*} An accumulation of synthetic events.
2407
* @see {EventPluginHub.extractEvents}
2408
*/
2409
extractEvents: function(
2410
topLevelType,
2411
topLevelTarget,
2412
topLevelTargetID,
2413
nativeEvent) {
2414
if (topLevelType === topLevelTypes.topMouseOver &&
2415
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
2416
return null;
2417
}
2418
if (topLevelType !== topLevelTypes.topMouseOut &&
2419
topLevelType !== topLevelTypes.topMouseOver) {
2420
// Must not be a mouse in or mouse out - ignoring.
2421
return null;
2422
}
2423
2424
var win;
2425
if (topLevelTarget.window === topLevelTarget) {
2426
// `topLevelTarget` is probably a window object.
2427
win = topLevelTarget;
2428
} else {
2429
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
2430
var doc = topLevelTarget.ownerDocument;
2431
if (doc) {
2432
win = doc.defaultView || doc.parentWindow;
2433
} else {
2434
win = window;
2435
}
2436
}
2437
2438
var from, to;
2439
if (topLevelType === topLevelTypes.topMouseOut) {
2440
from = topLevelTarget;
2441
to =
2442
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
2443
win;
2444
} else {
2445
from = win;
2446
to = topLevelTarget;
2447
}
2448
2449
if (from === to) {
2450
// Nothing pertains to our managed components.
2451
return null;
2452
}
2453
2454
var fromID = from ? ReactMount.getID(from) : '';
2455
var toID = to ? ReactMount.getID(to) : '';
2456
2457
var leave = SyntheticMouseEvent.getPooled(
2458
eventTypes.mouseLeave,
2459
fromID,
2460
nativeEvent
2461
);
2462
leave.type = 'mouseleave';
2463
leave.target = from;
2464
leave.relatedTarget = to;
2465
2466
var enter = SyntheticMouseEvent.getPooled(
2467
eventTypes.mouseEnter,
2468
toID,
2469
nativeEvent
2470
);
2471
enter.type = 'mouseenter';
2472
enter.target = to;
2473
enter.relatedTarget = from;
2474
2475
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
2476
2477
extractedEvents[0] = leave;
2478
extractedEvents[1] = enter;
2479
2480
return extractedEvents;
2481
}
2482
2483
};
2484
2485
module.exports = EnterLeaveEventPlugin;
2486
2487
},{"112":112,"157":157,"16":16,"21":21,"77":77}],16:[function(_dereq_,module,exports){
2488
/**
2489
* Copyright 2013-2015, Facebook, Inc.
2490
* All rights reserved.
2491
*
2492
* This source code is licensed under the BSD-style license found in the
2493
* LICENSE file in the root directory of this source tree. An additional grant
2494
* of patent rights can be found in the PATENTS file in the same directory.
2495
*
2496
* @providesModule EventConstants
2497
*/
2498
2499
'use strict';
2500
2501
var keyMirror = _dereq_(156);
2502
2503
var PropagationPhases = keyMirror({bubbled: null, captured: null});
2504
2505
/**
2506
* Types of raw signals from the browser caught at the top level.
2507
*/
2508
var topLevelTypes = keyMirror({
2509
topBlur: null,
2510
topChange: null,
2511
topClick: null,
2512
topCompositionEnd: null,
2513
topCompositionStart: null,
2514
topCompositionUpdate: null,
2515
topContextMenu: null,
2516
topCopy: null,
2517
topCut: null,
2518
topDoubleClick: null,
2519
topDrag: null,
2520
topDragEnd: null,
2521
topDragEnter: null,
2522
topDragExit: null,
2523
topDragLeave: null,
2524
topDragOver: null,
2525
topDragStart: null,
2526
topDrop: null,
2527
topError: null,
2528
topFocus: null,
2529
topInput: null,
2530
topKeyDown: null,
2531
topKeyPress: null,
2532
topKeyUp: null,
2533
topLoad: null,
2534
topMouseDown: null,
2535
topMouseMove: null,
2536
topMouseOut: null,
2537
topMouseOver: null,
2538
topMouseUp: null,
2539
topPaste: null,
2540
topReset: null,
2541
topScroll: null,
2542
topSelectionChange: null,
2543
topSubmit: null,
2544
topTextInput: null,
2545
topTouchCancel: null,
2546
topTouchEnd: null,
2547
topTouchMove: null,
2548
topTouchStart: null,
2549
topWheel: null
2550
});
2551
2552
var EventConstants = {
2553
topLevelTypes: topLevelTypes,
2554
PropagationPhases: PropagationPhases
2555
};
2556
2557
module.exports = EventConstants;
2558
2559
},{"156":156}],17:[function(_dereq_,module,exports){
2560
/**
2561
* Copyright 2013-2015, Facebook, Inc.
2562
*
2563
* Licensed under the Apache License, Version 2.0 (the "License");
2564
* you may not use this file except in compliance with the License.
2565
* You may obtain a copy of the License at
2566
*
2567
* http://www.apache.org/licenses/LICENSE-2.0
2568
*
2569
* Unless required by applicable law or agreed to in writing, software
2570
* distributed under the License is distributed on an "AS IS" BASIS,
2571
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2572
* See the License for the specific language governing permissions and
2573
* limitations under the License.
2574
*
2575
* @providesModule EventListener
2576
* @typechecks
2577
*/
2578
2579
var emptyFunction = _dereq_(129);
2580
2581
/**
2582
* Upstream version of event listener. Does not take into account specific
2583
* nature of platform.
2584
*/
2585
var EventListener = {
2586
/**
2587
* Listen to DOM events during the bubble phase.
2588
*
2589
* @param {DOMEventTarget} target DOM element to register listener on.
2590
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2591
* @param {function} callback Callback function.
2592
* @return {object} Object with a `remove` method.
2593
*/
2594
listen: function(target, eventType, callback) {
2595
if (target.addEventListener) {
2596
target.addEventListener(eventType, callback, false);
2597
return {
2598
remove: function() {
2599
target.removeEventListener(eventType, callback, false);
2600
}
2601
};
2602
} else if (target.attachEvent) {
2603
target.attachEvent('on' + eventType, callback);
2604
return {
2605
remove: function() {
2606
target.detachEvent('on' + eventType, callback);
2607
}
2608
};
2609
}
2610
},
2611
2612
/**
2613
* Listen to DOM events during the capture phase.
2614
*
2615
* @param {DOMEventTarget} target DOM element to register listener on.
2616
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
2617
* @param {function} callback Callback function.
2618
* @return {object} Object with a `remove` method.
2619
*/
2620
capture: function(target, eventType, callback) {
2621
if (!target.addEventListener) {
2622
if ("production" !== "development") {
2623
console.error(
2624
'Attempted to listen to events during the capture phase on a ' +
2625
'browser that does not support the capture phase. Your application ' +
2626
'will not receive some events.'
2627
);
2628
}
2629
return {
2630
remove: emptyFunction
2631
};
2632
} else {
2633
target.addEventListener(eventType, callback, true);
2634
return {
2635
remove: function() {
2636
target.removeEventListener(eventType, callback, true);
2637
}
2638
};
2639
}
2640
},
2641
2642
registerDefault: function() {}
2643
};
2644
2645
module.exports = EventListener;
2646
2647
},{"129":129}],18:[function(_dereq_,module,exports){
2648
/**
2649
* Copyright 2013-2015, Facebook, Inc.
2650
* All rights reserved.
2651
*
2652
* This source code is licensed under the BSD-style license found in the
2653
* LICENSE file in the root directory of this source tree. An additional grant
2654
* of patent rights can be found in the PATENTS file in the same directory.
2655
*
2656
* @providesModule EventPluginHub
2657
*/
2658
2659
'use strict';
2660
2661
var EventPluginRegistry = _dereq_(19);
2662
var EventPluginUtils = _dereq_(20);
2663
2664
var accumulateInto = _dereq_(118);
2665
var forEachAccumulated = _dereq_(135);
2666
var invariant = _dereq_(150);
2667
2668
/**
2669
* Internal store for event listeners
2670
*/
2671
var listenerBank = {};
2672
2673
/**
2674
* Internal queue of events that have accumulated their dispatches and are
2675
* waiting to have their dispatches executed.
2676
*/
2677
var eventQueue = null;
2678
2679
/**
2680
* Dispatches an event and releases it back into the pool, unless persistent.
2681
*
2682
* @param {?object} event Synthetic event to be dispatched.
2683
* @private
2684
*/
2685
var executeDispatchesAndRelease = function(event) {
2686
if (event) {
2687
var executeDispatch = EventPluginUtils.executeDispatch;
2688
// Plugins can provide custom behavior when dispatching events.
2689
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
2690
if (PluginModule && PluginModule.executeDispatch) {
2691
executeDispatch = PluginModule.executeDispatch;
2692
}
2693
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
2694
2695
if (!event.isPersistent()) {
2696
event.constructor.release(event);
2697
}
2698
}
2699
};
2700
2701
/**
2702
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
2703
* hierarchy given ids of the logical DOM elements involved.
2704
*/
2705
var InstanceHandle = null;
2706
2707
function validateInstanceHandle() {
2708
var valid =
2709
InstanceHandle &&
2710
InstanceHandle.traverseTwoPhase &&
2711
InstanceHandle.traverseEnterLeave;
2712
("production" !== "development" ? invariant(
2713
valid,
2714
'InstanceHandle not injected before use!'
2715
) : invariant(valid));
2716
}
2717
2718
/**
2719
* This is a unified interface for event plugins to be installed and configured.
2720
*
2721
* Event plugins can implement the following properties:
2722
*
2723
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
2724
* Required. When a top-level event is fired, this method is expected to
2725
* extract synthetic events that will in turn be queued and dispatched.
2726
*
2727
* `eventTypes` {object}
2728
* Optional, plugins that fire events must publish a mapping of registration
2729
* names that are used to register listeners. Values of this mapping must
2730
* be objects that contain `registrationName` or `phasedRegistrationNames`.
2731
*
2732
* `executeDispatch` {function(object, function, string)}
2733
* Optional, allows plugins to override how an event gets dispatched. By
2734
* default, the listener is simply invoked.
2735
*
2736
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
2737
*
2738
* @public
2739
*/
2740
var EventPluginHub = {
2741
2742
/**
2743
* Methods for injecting dependencies.
2744
*/
2745
injection: {
2746
2747
/**
2748
* @param {object} InjectedMount
2749
* @public
2750
*/
2751
injectMount: EventPluginUtils.injection.injectMount,
2752
2753
/**
2754
* @param {object} InjectedInstanceHandle
2755
* @public
2756
*/
2757
injectInstanceHandle: function(InjectedInstanceHandle) {
2758
InstanceHandle = InjectedInstanceHandle;
2759
if ("production" !== "development") {
2760
validateInstanceHandle();
2761
}
2762
},
2763
2764
getInstanceHandle: function() {
2765
if ("production" !== "development") {
2766
validateInstanceHandle();
2767
}
2768
return InstanceHandle;
2769
},
2770
2771
/**
2772
* @param {array} InjectedEventPluginOrder
2773
* @public
2774
*/
2775
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
2776
2777
/**
2778
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
2779
*/
2780
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
2781
2782
},
2783
2784
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
2785
2786
registrationNameModules: EventPluginRegistry.registrationNameModules,
2787
2788
/**
2789
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
2790
*
2791
* @param {string} id ID of the DOM element.
2792
* @param {string} registrationName Name of listener (e.g. `onClick`).
2793
* @param {?function} listener The callback to store.
2794
*/
2795
putListener: function(id, registrationName, listener) {
2796
("production" !== "development" ? invariant(
2797
!listener || typeof listener === 'function',
2798
'Expected %s listener to be a function, instead got type %s',
2799
registrationName, typeof listener
2800
) : invariant(!listener || typeof listener === 'function'));
2801
2802
var bankForRegistrationName =
2803
listenerBank[registrationName] || (listenerBank[registrationName] = {});
2804
bankForRegistrationName[id] = listener;
2805
},
2806
2807
/**
2808
* @param {string} id ID of the DOM element.
2809
* @param {string} registrationName Name of listener (e.g. `onClick`).
2810
* @return {?function} The stored callback.
2811
*/
2812
getListener: function(id, registrationName) {
2813
var bankForRegistrationName = listenerBank[registrationName];
2814
return bankForRegistrationName && bankForRegistrationName[id];
2815
},
2816
2817
/**
2818
* Deletes a listener from the registration bank.
2819
*
2820
* @param {string} id ID of the DOM element.
2821
* @param {string} registrationName Name of listener (e.g. `onClick`).
2822
*/
2823
deleteListener: function(id, registrationName) {
2824
var bankForRegistrationName = listenerBank[registrationName];
2825
if (bankForRegistrationName) {
2826
delete bankForRegistrationName[id];
2827
}
2828
},
2829
2830
/**
2831
* Deletes all listeners for the DOM element with the supplied ID.
2832
*
2833
* @param {string} id ID of the DOM element.
2834
*/
2835
deleteAllListeners: function(id) {
2836
for (var registrationName in listenerBank) {
2837
delete listenerBank[registrationName][id];
2838
}
2839
},
2840
2841
/**
2842
* Allows registered plugins an opportunity to extract events from top-level
2843
* native browser events.
2844
*
2845
* @param {string} topLevelType Record from `EventConstants`.
2846
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2847
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2848
* @param {object} nativeEvent Native browser event.
2849
* @return {*} An accumulation of synthetic events.
2850
* @internal
2851
*/
2852
extractEvents: function(
2853
topLevelType,
2854
topLevelTarget,
2855
topLevelTargetID,
2856
nativeEvent) {
2857
var events;
2858
var plugins = EventPluginRegistry.plugins;
2859
for (var i = 0, l = plugins.length; i < l; i++) {
2860
// Not every plugin in the ordering may be loaded at runtime.
2861
var possiblePlugin = plugins[i];
2862
if (possiblePlugin) {
2863
var extractedEvents = possiblePlugin.extractEvents(
2864
topLevelType,
2865
topLevelTarget,
2866
topLevelTargetID,
2867
nativeEvent
2868
);
2869
if (extractedEvents) {
2870
events = accumulateInto(events, extractedEvents);
2871
}
2872
}
2873
}
2874
return events;
2875
},
2876
2877
/**
2878
* Enqueues a synthetic event that should be dispatched when
2879
* `processEventQueue` is invoked.
2880
*
2881
* @param {*} events An accumulation of synthetic events.
2882
* @internal
2883
*/
2884
enqueueEvents: function(events) {
2885
if (events) {
2886
eventQueue = accumulateInto(eventQueue, events);
2887
}
2888
},
2889
2890
/**
2891
* Dispatches all synthetic events on the event queue.
2892
*
2893
* @internal
2894
*/
2895
processEventQueue: function() {
2896
// Set `eventQueue` to null before processing it so that we can tell if more
2897
// events get enqueued while processing.
2898
var processingEventQueue = eventQueue;
2899
eventQueue = null;
2900
forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
2901
("production" !== "development" ? invariant(
2902
!eventQueue,
2903
'processEventQueue(): Additional events were enqueued while processing ' +
2904
'an event queue. Support for this has not yet been implemented.'
2905
) : invariant(!eventQueue));
2906
},
2907
2908
/**
2909
* These are needed for tests only. Do not use!
2910
*/
2911
__purge: function() {
2912
listenerBank = {};
2913
},
2914
2915
__getListenerBank: function() {
2916
return listenerBank;
2917
}
2918
2919
};
2920
2921
module.exports = EventPluginHub;
2922
2923
},{"118":118,"135":135,"150":150,"19":19,"20":20}],19:[function(_dereq_,module,exports){
2924
/**
2925
* Copyright 2013-2015, Facebook, Inc.
2926
* All rights reserved.
2927
*
2928
* This source code is licensed under the BSD-style license found in the
2929
* LICENSE file in the root directory of this source tree. An additional grant
2930
* of patent rights can be found in the PATENTS file in the same directory.
2931
*
2932
* @providesModule EventPluginRegistry
2933
* @typechecks static-only
2934
*/
2935
2936
'use strict';
2937
2938
var invariant = _dereq_(150);
2939
2940
/**
2941
* Injectable ordering of event plugins.
2942
*/
2943
var EventPluginOrder = null;
2944
2945
/**
2946
* Injectable mapping from names to event plugin modules.
2947
*/
2948
var namesToPlugins = {};
2949
2950
/**
2951
* Recomputes the plugin list using the injected plugins and plugin ordering.
2952
*
2953
* @private
2954
*/
2955
function recomputePluginOrdering() {
2956
if (!EventPluginOrder) {
2957
// Wait until an `EventPluginOrder` is injected.
2958
return;
2959
}
2960
for (var pluginName in namesToPlugins) {
2961
var PluginModule = namesToPlugins[pluginName];
2962
var pluginIndex = EventPluginOrder.indexOf(pluginName);
2963
("production" !== "development" ? invariant(
2964
pluginIndex > -1,
2965
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
2966
'the plugin ordering, `%s`.',
2967
pluginName
2968
) : invariant(pluginIndex > -1));
2969
if (EventPluginRegistry.plugins[pluginIndex]) {
2970
continue;
2971
}
2972
("production" !== "development" ? invariant(
2973
PluginModule.extractEvents,
2974
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
2975
'method, but `%s` does not.',
2976
pluginName
2977
) : invariant(PluginModule.extractEvents));
2978
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
2979
var publishedEvents = PluginModule.eventTypes;
2980
for (var eventName in publishedEvents) {
2981
("production" !== "development" ? invariant(
2982
publishEventForPlugin(
2983
publishedEvents[eventName],
2984
PluginModule,
2985
eventName
2986
),
2987
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
2988
eventName,
2989
pluginName
2990
) : invariant(publishEventForPlugin(
2991
publishedEvents[eventName],
2992
PluginModule,
2993
eventName
2994
)));
2995
}
2996
}
2997
}
2998
2999
/**
3000
* Publishes an event so that it can be dispatched by the supplied plugin.
3001
*
3002
* @param {object} dispatchConfig Dispatch configuration for the event.
3003
* @param {object} PluginModule Plugin publishing the event.
3004
* @return {boolean} True if the event was successfully published.
3005
* @private
3006
*/
3007
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
3008
("production" !== "development" ? invariant(
3009
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
3010
'EventPluginHub: More than one plugin attempted to publish the same ' +
3011
'event name, `%s`.',
3012
eventName
3013
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
3014
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
3015
3016
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
3017
if (phasedRegistrationNames) {
3018
for (var phaseName in phasedRegistrationNames) {
3019
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
3020
var phasedRegistrationName = phasedRegistrationNames[phaseName];
3021
publishRegistrationName(
3022
phasedRegistrationName,
3023
PluginModule,
3024
eventName
3025
);
3026
}
3027
}
3028
return true;
3029
} else if (dispatchConfig.registrationName) {
3030
publishRegistrationName(
3031
dispatchConfig.registrationName,
3032
PluginModule,
3033
eventName
3034
);
3035
return true;
3036
}
3037
return false;
3038
}
3039
3040
/**
3041
* Publishes a registration name that is used to identify dispatched events and
3042
* can be used with `EventPluginHub.putListener` to register listeners.
3043
*
3044
* @param {string} registrationName Registration name to add.
3045
* @param {object} PluginModule Plugin publishing the event.
3046
* @private
3047
*/
3048
function publishRegistrationName(registrationName, PluginModule, eventName) {
3049
("production" !== "development" ? invariant(
3050
!EventPluginRegistry.registrationNameModules[registrationName],
3051
'EventPluginHub: More than one plugin attempted to publish the same ' +
3052
'registration name, `%s`.',
3053
registrationName
3054
) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
3055
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
3056
EventPluginRegistry.registrationNameDependencies[registrationName] =
3057
PluginModule.eventTypes[eventName].dependencies;
3058
}
3059
3060
/**
3061
* Registers plugins so that they can extract and dispatch events.
3062
*
3063
* @see {EventPluginHub}
3064
*/
3065
var EventPluginRegistry = {
3066
3067
/**
3068
* Ordered list of injected plugins.
3069
*/
3070
plugins: [],
3071
3072
/**
3073
* Mapping from event name to dispatch config
3074
*/
3075
eventNameDispatchConfigs: {},
3076
3077
/**
3078
* Mapping from registration name to plugin module
3079
*/
3080
registrationNameModules: {},
3081
3082
/**
3083
* Mapping from registration name to event name
3084
*/
3085
registrationNameDependencies: {},
3086
3087
/**
3088
* Injects an ordering of plugins (by plugin name). This allows the ordering
3089
* to be decoupled from injection of the actual plugins so that ordering is
3090
* always deterministic regardless of packaging, on-the-fly injection, etc.
3091
*
3092
* @param {array} InjectedEventPluginOrder
3093
* @internal
3094
* @see {EventPluginHub.injection.injectEventPluginOrder}
3095
*/
3096
injectEventPluginOrder: function(InjectedEventPluginOrder) {
3097
("production" !== "development" ? invariant(
3098
!EventPluginOrder,
3099
'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
3100
'once. You are likely trying to load more than one copy of React.'
3101
) : invariant(!EventPluginOrder));
3102
// Clone the ordering so it cannot be dynamically mutated.
3103
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
3104
recomputePluginOrdering();
3105
},
3106
3107
/**
3108
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
3109
* in the ordering injected by `injectEventPluginOrder`.
3110
*
3111
* Plugins can be injected as part of page initialization or on-the-fly.
3112
*
3113
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
3114
* @internal
3115
* @see {EventPluginHub.injection.injectEventPluginsByName}
3116
*/
3117
injectEventPluginsByName: function(injectedNamesToPlugins) {
3118
var isOrderingDirty = false;
3119
for (var pluginName in injectedNamesToPlugins) {
3120
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
3121
continue;
3122
}
3123
var PluginModule = injectedNamesToPlugins[pluginName];
3124
if (!namesToPlugins.hasOwnProperty(pluginName) ||
3125
namesToPlugins[pluginName] !== PluginModule) {
3126
("production" !== "development" ? invariant(
3127
!namesToPlugins[pluginName],
3128
'EventPluginRegistry: Cannot inject two different event plugins ' +
3129
'using the same name, `%s`.',
3130
pluginName
3131
) : invariant(!namesToPlugins[pluginName]));
3132
namesToPlugins[pluginName] = PluginModule;
3133
isOrderingDirty = true;
3134
}
3135
}
3136
if (isOrderingDirty) {
3137
recomputePluginOrdering();
3138
}
3139
},
3140
3141
/**
3142
* Looks up the plugin for the supplied event.
3143
*
3144
* @param {object} event A synthetic event.
3145
* @return {?object} The plugin that created the supplied event.
3146
* @internal
3147
*/
3148
getPluginModuleForEvent: function(event) {
3149
var dispatchConfig = event.dispatchConfig;
3150
if (dispatchConfig.registrationName) {
3151
return EventPluginRegistry.registrationNameModules[
3152
dispatchConfig.registrationName
3153
] || null;
3154
}
3155
for (var phase in dispatchConfig.phasedRegistrationNames) {
3156
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
3157
continue;
3158
}
3159
var PluginModule = EventPluginRegistry.registrationNameModules[
3160
dispatchConfig.phasedRegistrationNames[phase]
3161
];
3162
if (PluginModule) {
3163
return PluginModule;
3164
}
3165
}
3166
return null;
3167
},
3168
3169
/**
3170
* Exposed for unit testing.
3171
* @private
3172
*/
3173
_resetEventPlugins: function() {
3174
EventPluginOrder = null;
3175
for (var pluginName in namesToPlugins) {
3176
if (namesToPlugins.hasOwnProperty(pluginName)) {
3177
delete namesToPlugins[pluginName];
3178
}
3179
}
3180
EventPluginRegistry.plugins.length = 0;
3181
3182
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
3183
for (var eventName in eventNameDispatchConfigs) {
3184
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
3185
delete eventNameDispatchConfigs[eventName];
3186
}
3187
}
3188
3189
var registrationNameModules = EventPluginRegistry.registrationNameModules;
3190
for (var registrationName in registrationNameModules) {
3191
if (registrationNameModules.hasOwnProperty(registrationName)) {
3192
delete registrationNameModules[registrationName];
3193
}
3194
}
3195
}
3196
3197
};
3198
3199
module.exports = EventPluginRegistry;
3200
3201
},{"150":150}],20:[function(_dereq_,module,exports){
3202
/**
3203
* Copyright 2013-2015, Facebook, Inc.
3204
* All rights reserved.
3205
*
3206
* This source code is licensed under the BSD-style license found in the
3207
* LICENSE file in the root directory of this source tree. An additional grant
3208
* of patent rights can be found in the PATENTS file in the same directory.
3209
*
3210
* @providesModule EventPluginUtils
3211
*/
3212
3213
'use strict';
3214
3215
var EventConstants = _dereq_(16);
3216
3217
var invariant = _dereq_(150);
3218
3219
/**
3220
* Injected dependencies:
3221
*/
3222
3223
/**
3224
* - `Mount`: [required] Module that can convert between React dom IDs and
3225
* actual node references.
3226
*/
3227
var injection = {
3228
Mount: null,
3229
injectMount: function(InjectedMount) {
3230
injection.Mount = InjectedMount;
3231
if ("production" !== "development") {
3232
("production" !== "development" ? invariant(
3233
InjectedMount && InjectedMount.getNode,
3234
'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
3235
'is missing getNode.'
3236
) : invariant(InjectedMount && InjectedMount.getNode));
3237
}
3238
}
3239
};
3240
3241
var topLevelTypes = EventConstants.topLevelTypes;
3242
3243
function isEndish(topLevelType) {
3244
return topLevelType === topLevelTypes.topMouseUp ||
3245
topLevelType === topLevelTypes.topTouchEnd ||
3246
topLevelType === topLevelTypes.topTouchCancel;
3247
}
3248
3249
function isMoveish(topLevelType) {
3250
return topLevelType === topLevelTypes.topMouseMove ||
3251
topLevelType === topLevelTypes.topTouchMove;
3252
}
3253
function isStartish(topLevelType) {
3254
return topLevelType === topLevelTypes.topMouseDown ||
3255
topLevelType === topLevelTypes.topTouchStart;
3256
}
3257
3258
3259
var validateEventDispatches;
3260
if ("production" !== "development") {
3261
validateEventDispatches = function(event) {
3262
var dispatchListeners = event._dispatchListeners;
3263
var dispatchIDs = event._dispatchIDs;
3264
3265
var listenersIsArr = Array.isArray(dispatchListeners);
3266
var idsIsArr = Array.isArray(dispatchIDs);
3267
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
3268
var listenersLen = listenersIsArr ?
3269
dispatchListeners.length :
3270
dispatchListeners ? 1 : 0;
3271
3272
("production" !== "development" ? invariant(
3273
idsIsArr === listenersIsArr && IDsLen === listenersLen,
3274
'EventPluginUtils: Invalid `event`.'
3275
) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
3276
};
3277
}
3278
3279
/**
3280
* Invokes `cb(event, listener, id)`. Avoids using call if no scope is
3281
* provided. The `(listener,id)` pair effectively forms the "dispatch" but are
3282
* kept separate to conserve memory.
3283
*/
3284
function forEachEventDispatch(event, cb) {
3285
var dispatchListeners = event._dispatchListeners;
3286
var dispatchIDs = event._dispatchIDs;
3287
if ("production" !== "development") {
3288
validateEventDispatches(event);
3289
}
3290
if (Array.isArray(dispatchListeners)) {
3291
for (var i = 0; i < dispatchListeners.length; i++) {
3292
if (event.isPropagationStopped()) {
3293
break;
3294
}
3295
// Listeners and IDs are two parallel arrays that are always in sync.
3296
cb(event, dispatchListeners[i], dispatchIDs[i]);
3297
}
3298
} else if (dispatchListeners) {
3299
cb(event, dispatchListeners, dispatchIDs);
3300
}
3301
}
3302
3303
/**
3304
* Default implementation of PluginModule.executeDispatch().
3305
* @param {SyntheticEvent} SyntheticEvent to handle
3306
* @param {function} Application-level callback
3307
* @param {string} domID DOM id to pass to the callback.
3308
*/
3309
function executeDispatch(event, listener, domID) {
3310
event.currentTarget = injection.Mount.getNode(domID);
3311
var returnValue = listener(event, domID);
3312
event.currentTarget = null;
3313
return returnValue;
3314
}
3315
3316
/**
3317
* Standard/simple iteration through an event's collected dispatches.
3318
*/
3319
function executeDispatchesInOrder(event, cb) {
3320
forEachEventDispatch(event, cb);
3321
event._dispatchListeners = null;
3322
event._dispatchIDs = null;
3323
}
3324
3325
/**
3326
* Standard/simple iteration through an event's collected dispatches, but stops
3327
* at the first dispatch execution returning true, and returns that id.
3328
*
3329
* @return id of the first dispatch execution who's listener returns true, or
3330
* null if no listener returned true.
3331
*/
3332
function executeDispatchesInOrderStopAtTrueImpl(event) {
3333
var dispatchListeners = event._dispatchListeners;
3334
var dispatchIDs = event._dispatchIDs;
3335
if ("production" !== "development") {
3336
validateEventDispatches(event);
3337
}
3338
if (Array.isArray(dispatchListeners)) {
3339
for (var i = 0; i < dispatchListeners.length; i++) {
3340
if (event.isPropagationStopped()) {
3341
break;
3342
}
3343
// Listeners and IDs are two parallel arrays that are always in sync.
3344
if (dispatchListeners[i](event, dispatchIDs[i])) {
3345
return dispatchIDs[i];
3346
}
3347
}
3348
} else if (dispatchListeners) {
3349
if (dispatchListeners(event, dispatchIDs)) {
3350
return dispatchIDs;
3351
}
3352
}
3353
return null;
3354
}
3355
3356
/**
3357
* @see executeDispatchesInOrderStopAtTrueImpl
3358
*/
3359
function executeDispatchesInOrderStopAtTrue(event) {
3360
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
3361
event._dispatchIDs = null;
3362
event._dispatchListeners = null;
3363
return ret;
3364
}
3365
3366
/**
3367
* Execution of a "direct" dispatch - there must be at most one dispatch
3368
* accumulated on the event or it is considered an error. It doesn't really make
3369
* sense for an event with multiple dispatches (bubbled) to keep track of the
3370
* return values at each dispatch execution, but it does tend to make sense when
3371
* dealing with "direct" dispatches.
3372
*
3373
* @return The return value of executing the single dispatch.
3374
*/
3375
function executeDirectDispatch(event) {
3376
if ("production" !== "development") {
3377
validateEventDispatches(event);
3378
}
3379
var dispatchListener = event._dispatchListeners;
3380
var dispatchID = event._dispatchIDs;
3381
("production" !== "development" ? invariant(
3382
!Array.isArray(dispatchListener),
3383
'executeDirectDispatch(...): Invalid `event`.'
3384
) : invariant(!Array.isArray(dispatchListener)));
3385
var res = dispatchListener ?
3386
dispatchListener(event, dispatchID) :
3387
null;
3388
event._dispatchListeners = null;
3389
event._dispatchIDs = null;
3390
return res;
3391
}
3392
3393
/**
3394
* @param {SyntheticEvent} event
3395
* @return {bool} True iff number of dispatches accumulated is greater than 0.
3396
*/
3397
function hasDispatches(event) {
3398
return !!event._dispatchListeners;
3399
}
3400
3401
/**
3402
* General utilities that are useful in creating custom Event Plugins.
3403
*/
3404
var EventPluginUtils = {
3405
isEndish: isEndish,
3406
isMoveish: isMoveish,
3407
isStartish: isStartish,
3408
3409
executeDirectDispatch: executeDirectDispatch,
3410
executeDispatch: executeDispatch,
3411
executeDispatchesInOrder: executeDispatchesInOrder,
3412
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
3413
hasDispatches: hasDispatches,
3414
injection: injection,
3415
useTouchEvents: false
3416
};
3417
3418
module.exports = EventPluginUtils;
3419
3420
},{"150":150,"16":16}],21:[function(_dereq_,module,exports){
3421
/**
3422
* Copyright 2013-2015, Facebook, Inc.
3423
* All rights reserved.
3424
*
3425
* This source code is licensed under the BSD-style license found in the
3426
* LICENSE file in the root directory of this source tree. An additional grant
3427
* of patent rights can be found in the PATENTS file in the same directory.
3428
*
3429
* @providesModule EventPropagators
3430
*/
3431
3432
'use strict';
3433
3434
var EventConstants = _dereq_(16);
3435
var EventPluginHub = _dereq_(18);
3436
3437
var accumulateInto = _dereq_(118);
3438
var forEachAccumulated = _dereq_(135);
3439
3440
var PropagationPhases = EventConstants.PropagationPhases;
3441
var getListener = EventPluginHub.getListener;
3442
3443
/**
3444
* Some event types have a notion of different registration names for different
3445
* "phases" of propagation. This finds listeners by a given phase.
3446
*/
3447
function listenerAtPhase(id, event, propagationPhase) {
3448
var registrationName =
3449
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
3450
return getListener(id, registrationName);
3451
}
3452
3453
/**
3454
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
3455
* here, allows us to not have to bind or create functions for each event.
3456
* Mutating the event's members allows us to not have to create a wrapping
3457
* "dispatch" object that pairs the event with the listener.
3458
*/
3459
function accumulateDirectionalDispatches(domID, upwards, event) {
3460
if ("production" !== "development") {
3461
if (!domID) {
3462
throw new Error('Dispatching id must not be null');
3463
}
3464
}
3465
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
3466
var listener = listenerAtPhase(domID, event, phase);
3467
if (listener) {
3468
event._dispatchListeners =
3469
accumulateInto(event._dispatchListeners, listener);
3470
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
3471
}
3472
}
3473
3474
/**
3475
* Collect dispatches (must be entirely collected before dispatching - see unit
3476
* tests). Lazily allocate the array to conserve memory. We must loop through
3477
* each event and perform the traversal for each one. We can not perform a
3478
* single traversal for the entire collection of events because each event may
3479
* have a different target.
3480
*/
3481
function accumulateTwoPhaseDispatchesSingle(event) {
3482
if (event && event.dispatchConfig.phasedRegistrationNames) {
3483
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
3484
event.dispatchMarker,
3485
accumulateDirectionalDispatches,
3486
event
3487
);
3488
}
3489
}
3490
3491
3492
/**
3493
* Accumulates without regard to direction, does not look for phased
3494
* registration names. Same as `accumulateDirectDispatchesSingle` but without
3495
* requiring that the `dispatchMarker` be the same as the dispatched ID.
3496
*/
3497
function accumulateDispatches(id, ignoredDirection, event) {
3498
if (event && event.dispatchConfig.registrationName) {
3499
var registrationName = event.dispatchConfig.registrationName;
3500
var listener = getListener(id, registrationName);
3501
if (listener) {
3502
event._dispatchListeners =
3503
accumulateInto(event._dispatchListeners, listener);
3504
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
3505
}
3506
}
3507
}
3508
3509
/**
3510
* Accumulates dispatches on an `SyntheticEvent`, but only for the
3511
* `dispatchMarker`.
3512
* @param {SyntheticEvent} event
3513
*/
3514
function accumulateDirectDispatchesSingle(event) {
3515
if (event && event.dispatchConfig.registrationName) {
3516
accumulateDispatches(event.dispatchMarker, null, event);
3517
}
3518
}
3519
3520
function accumulateTwoPhaseDispatches(events) {
3521
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
3522
}
3523
3524
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
3525
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
3526
fromID,
3527
toID,
3528
accumulateDispatches,
3529
leave,
3530
enter
3531
);
3532
}
3533
3534
3535
function accumulateDirectDispatches(events) {
3536
forEachAccumulated(events, accumulateDirectDispatchesSingle);
3537
}
3538
3539
3540
3541
/**
3542
* A small set of propagation patterns, each of which will accept a small amount
3543
* of information, and generate a set of "dispatch ready event objects" - which
3544
* are sets of events that have already been annotated with a set of dispatched
3545
* listener functions/ids. The API is designed this way to discourage these
3546
* propagation strategies from actually executing the dispatches, since we
3547
* always want to collect the entire set of dispatches before executing event a
3548
* single one.
3549
*
3550
* @constructor EventPropagators
3551
*/
3552
var EventPropagators = {
3553
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
3554
accumulateDirectDispatches: accumulateDirectDispatches,
3555
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
3556
};
3557
3558
module.exports = EventPropagators;
3559
3560
},{"118":118,"135":135,"16":16,"18":18}],22:[function(_dereq_,module,exports){
3561
/**
3562
* Copyright 2013-2015, Facebook, Inc.
3563
* All rights reserved.
3564
*
3565
* This source code is licensed under the BSD-style license found in the
3566
* LICENSE file in the root directory of this source tree. An additional grant
3567
* of patent rights can be found in the PATENTS file in the same directory.
3568
*
3569
* @providesModule ExecutionEnvironment
3570
*/
3571
3572
/*jslint evil: true */
3573
3574
"use strict";
3575
3576
var canUseDOM = !!(
3577
(typeof window !== 'undefined' &&
3578
window.document && window.document.createElement)
3579
);
3580
3581
/**
3582
* Simple, lightweight module assisting with the detection and context of
3583
* Worker. Helps avoid circular dependencies and allows code to reason about
3584
* whether or not they are in a Worker, even if they never include the main
3585
* `ReactWorker` dependency.
3586
*/
3587
var ExecutionEnvironment = {
3588
3589
canUseDOM: canUseDOM,
3590
3591
canUseWorkers: typeof Worker !== 'undefined',
3592
3593
canUseEventListeners:
3594
canUseDOM && !!(window.addEventListener || window.attachEvent),
3595
3596
canUseViewport: canUseDOM && !!window.screen,
3597
3598
isInWorker: !canUseDOM // For now, this is true - might change in the future.
3599
3600
};
3601
3602
module.exports = ExecutionEnvironment;
3603
3604
},{}],23:[function(_dereq_,module,exports){
3605
/**
3606
* Copyright 2013-2015, Facebook, Inc.
3607
* All rights reserved.
3608
*
3609
* This source code is licensed under the BSD-style license found in the
3610
* LICENSE file in the root directory of this source tree. An additional grant
3611
* of patent rights can be found in the PATENTS file in the same directory.
3612
*
3613
* @providesModule FallbackCompositionState
3614
* @typechecks static-only
3615
*/
3616
3617
'use strict';
3618
3619
var PooledClass = _dereq_(30);
3620
3621
var assign = _dereq_(29);
3622
var getTextContentAccessor = _dereq_(145);
3623
3624
/**
3625
* This helper class stores information about text content of a target node,
3626
* allowing comparison of content before and after a given event.
3627
*
3628
* Identify the node where selection currently begins, then observe
3629
* both its text content and its current position in the DOM. Since the
3630
* browser may natively replace the target node during composition, we can
3631
* use its position to find its replacement.
3632
*
3633
* @param {DOMEventTarget} root
3634
*/
3635
function FallbackCompositionState(root) {
3636
this._root = root;
3637
this._startText = this.getText();
3638
this._fallbackText = null;
3639
}
3640
3641
assign(FallbackCompositionState.prototype, {
3642
/**
3643
* Get current text of input.
3644
*
3645
* @return {string}
3646
*/
3647
getText: function() {
3648
if ('value' in this._root) {
3649
return this._root.value;
3650
}
3651
return this._root[getTextContentAccessor()];
3652
},
3653
3654
/**
3655
* Determine the differing substring between the initially stored
3656
* text content and the current content.
3657
*
3658
* @return {string}
3659
*/
3660
getData: function() {
3661
if (this._fallbackText) {
3662
return this._fallbackText;
3663
}
3664
3665
var start;
3666
var startValue = this._startText;
3667
var startLength = startValue.length;
3668
var end;
3669
var endValue = this.getText();
3670
var endLength = endValue.length;
3671
3672
for (start = 0; start < startLength; start++) {
3673
if (startValue[start] !== endValue[start]) {
3674
break;
3675
}
3676
}
3677
3678
var minEnd = startLength - start;
3679
for (end = 1; end <= minEnd; end++) {
3680
if (startValue[startLength - end] !== endValue[endLength - end]) {
3681
break;
3682
}
3683
}
3684
3685
var sliceTail = end > 1 ? 1 - end : undefined;
3686
this._fallbackText = endValue.slice(start, sliceTail);
3687
return this._fallbackText;
3688
}
3689
});
3690
3691
PooledClass.addPoolingTo(FallbackCompositionState);
3692
3693
module.exports = FallbackCompositionState;
3694
3695
},{"145":145,"29":29,"30":30}],24:[function(_dereq_,module,exports){
3696
/**
3697
* Copyright 2013-2015, Facebook, Inc.
3698
* All rights reserved.
3699
*
3700
* This source code is licensed under the BSD-style license found in the
3701
* LICENSE file in the root directory of this source tree. An additional grant
3702
* of patent rights can be found in the PATENTS file in the same directory.
3703
*
3704
* @providesModule HTMLDOMPropertyConfig
3705
*/
3706
3707
/*jslint bitwise: true*/
3708
3709
'use strict';
3710
3711
var DOMProperty = _dereq_(11);
3712
var ExecutionEnvironment = _dereq_(22);
3713
3714
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
3715
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
3716
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
3717
var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
3718
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
3719
var HAS_POSITIVE_NUMERIC_VALUE =
3720
DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
3721
var HAS_OVERLOADED_BOOLEAN_VALUE =
3722
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
3723
3724
var hasSVG;
3725
if (ExecutionEnvironment.canUseDOM) {
3726
var implementation = document.implementation;
3727
hasSVG = (
3728
implementation &&
3729
implementation.hasFeature &&
3730
implementation.hasFeature(
3731
'http://www.w3.org/TR/SVG11/feature#BasicStructure',
3732
'1.1'
3733
)
3734
);
3735
}
3736
3737
3738
var HTMLDOMPropertyConfig = {
3739
isCustomAttribute: RegExp.prototype.test.bind(
3740
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
3741
),
3742
Properties: {
3743
/**
3744
* Standard Properties
3745
*/
3746
accept: null,
3747
acceptCharset: null,
3748
accessKey: null,
3749
action: null,
3750
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3751
allowTransparency: MUST_USE_ATTRIBUTE,
3752
alt: null,
3753
async: HAS_BOOLEAN_VALUE,
3754
autoComplete: null,
3755
// autoFocus is polyfilled/normalized by AutoFocusMixin
3756
// autoFocus: HAS_BOOLEAN_VALUE,
3757
autoPlay: HAS_BOOLEAN_VALUE,
3758
cellPadding: null,
3759
cellSpacing: null,
3760
charSet: MUST_USE_ATTRIBUTE,
3761
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3762
classID: MUST_USE_ATTRIBUTE,
3763
// To set className on SVG elements, it's necessary to use .setAttribute;
3764
// this works on HTML elements too in all browsers except IE8. Conveniently,
3765
// IE8 doesn't support SVG and so we can simply use the attribute in
3766
// browsers that support SVG and the property in browsers that don't,
3767
// regardless of whether the element is HTML or SVG.
3768
className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
3769
cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3770
colSpan: null,
3771
content: null,
3772
contentEditable: null,
3773
contextMenu: MUST_USE_ATTRIBUTE,
3774
controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3775
coords: null,
3776
crossOrigin: null,
3777
data: null, // For `<object />` acts as `src`.
3778
dateTime: MUST_USE_ATTRIBUTE,
3779
defer: HAS_BOOLEAN_VALUE,
3780
dir: null,
3781
disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3782
download: HAS_OVERLOADED_BOOLEAN_VALUE,
3783
draggable: null,
3784
encType: null,
3785
form: MUST_USE_ATTRIBUTE,
3786
formAction: MUST_USE_ATTRIBUTE,
3787
formEncType: MUST_USE_ATTRIBUTE,
3788
formMethod: MUST_USE_ATTRIBUTE,
3789
formNoValidate: HAS_BOOLEAN_VALUE,
3790
formTarget: MUST_USE_ATTRIBUTE,
3791
frameBorder: MUST_USE_ATTRIBUTE,
3792
headers: null,
3793
height: MUST_USE_ATTRIBUTE,
3794
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3795
high: null,
3796
href: null,
3797
hrefLang: null,
3798
htmlFor: null,
3799
httpEquiv: null,
3800
icon: null,
3801
id: MUST_USE_PROPERTY,
3802
label: null,
3803
lang: null,
3804
list: MUST_USE_ATTRIBUTE,
3805
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3806
low: null,
3807
manifest: MUST_USE_ATTRIBUTE,
3808
marginHeight: null,
3809
marginWidth: null,
3810
max: null,
3811
maxLength: MUST_USE_ATTRIBUTE,
3812
media: MUST_USE_ATTRIBUTE,
3813
mediaGroup: null,
3814
method: null,
3815
min: null,
3816
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3817
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3818
name: null,
3819
noValidate: HAS_BOOLEAN_VALUE,
3820
open: HAS_BOOLEAN_VALUE,
3821
optimum: null,
3822
pattern: null,
3823
placeholder: null,
3824
poster: null,
3825
preload: null,
3826
radioGroup: null,
3827
readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3828
rel: null,
3829
required: HAS_BOOLEAN_VALUE,
3830
role: MUST_USE_ATTRIBUTE,
3831
rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3832
rowSpan: null,
3833
sandbox: null,
3834
scope: null,
3835
scoped: HAS_BOOLEAN_VALUE,
3836
scrolling: null,
3837
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3838
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
3839
shape: null,
3840
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
3841
sizes: MUST_USE_ATTRIBUTE,
3842
span: HAS_POSITIVE_NUMERIC_VALUE,
3843
spellCheck: null,
3844
src: null,
3845
srcDoc: MUST_USE_PROPERTY,
3846
srcSet: MUST_USE_ATTRIBUTE,
3847
start: HAS_NUMERIC_VALUE,
3848
step: null,
3849
style: null,
3850
tabIndex: null,
3851
target: null,
3852
title: null,
3853
type: null,
3854
useMap: null,
3855
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
3856
width: MUST_USE_ATTRIBUTE,
3857
wmode: MUST_USE_ATTRIBUTE,
3858
3859
/**
3860
* Non-standard Properties
3861
*/
3862
// autoCapitalize and autoCorrect are supported in Mobile Safari for
3863
// keyboard hints.
3864
autoCapitalize: null,
3865
autoCorrect: null,
3866
// itemProp, itemScope, itemType are for
3867
// Microdata support. See http://schema.org/docs/gs.html
3868
itemProp: MUST_USE_ATTRIBUTE,
3869
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
3870
itemType: MUST_USE_ATTRIBUTE,
3871
// itemID and itemRef are for Microdata support as well but
3872
// only specified in the the WHATWG spec document. See
3873
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
3874
itemID: MUST_USE_ATTRIBUTE,
3875
itemRef: MUST_USE_ATTRIBUTE,
3876
// property is supported for OpenGraph in meta tags.
3877
property: null,
3878
// IE-only attribute that controls focus behavior
3879
unselectable: MUST_USE_ATTRIBUTE
3880
},
3881
DOMAttributeNames: {
3882
acceptCharset: 'accept-charset',
3883
className: 'class',
3884
htmlFor: 'for',
3885
httpEquiv: 'http-equiv'
3886
},
3887
DOMPropertyNames: {
3888
autoCapitalize: 'autocapitalize',
3889
autoComplete: 'autocomplete',
3890
autoCorrect: 'autocorrect',
3891
autoFocus: 'autofocus',
3892
autoPlay: 'autoplay',
3893
// `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
3894
// http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
3895
encType: 'encoding',
3896
hrefLang: 'hreflang',
3897
radioGroup: 'radiogroup',
3898
spellCheck: 'spellcheck',
3899
srcDoc: 'srcdoc',
3900
srcSet: 'srcset'
3901
}
3902
};
3903
3904
module.exports = HTMLDOMPropertyConfig;
3905
3906
},{"11":11,"22":22}],25:[function(_dereq_,module,exports){
3907
/**
3908
* Copyright 2013-2015, Facebook, Inc.
3909
* All rights reserved.
3910
*
3911
* This source code is licensed under the BSD-style license found in the
3912
* LICENSE file in the root directory of this source tree. An additional grant
3913
* of patent rights can be found in the PATENTS file in the same directory.
3914
*
3915
* @providesModule LinkedStateMixin
3916
* @typechecks static-only
3917
*/
3918
3919
'use strict';
3920
3921
var ReactLink = _dereq_(75);
3922
var ReactStateSetters = _dereq_(94);
3923
3924
/**
3925
* A simple mixin around ReactLink.forState().
3926
*/
3927
var LinkedStateMixin = {
3928
/**
3929
* Create a ReactLink that's linked to part of this component's state. The
3930
* ReactLink will have the current value of this.state[key] and will call
3931
* setState() when a change is requested.
3932
*
3933
* @param {string} key state key to update. Note: you may want to use keyOf()
3934
* if you're using Google Closure Compiler advanced mode.
3935
* @return {ReactLink} ReactLink instance linking to the state.
3936
*/
3937
linkState: function(key) {
3938
return new ReactLink(
3939
this.state[key],
3940
ReactStateSetters.createStateKeySetter(this, key)
3941
);
3942
}
3943
};
3944
3945
module.exports = LinkedStateMixin;
3946
3947
},{"75":75,"94":94}],26:[function(_dereq_,module,exports){
3948
/**
3949
* Copyright 2013-2015, Facebook, Inc.
3950
* All rights reserved.
3951
*
3952
* This source code is licensed under the BSD-style license found in the
3953
* LICENSE file in the root directory of this source tree. An additional grant
3954
* of patent rights can be found in the PATENTS file in the same directory.
3955
*
3956
* @providesModule LinkedValueUtils
3957
* @typechecks static-only
3958
*/
3959
3960
'use strict';
3961
3962
var ReactPropTypes = _dereq_(86);
3963
3964
var invariant = _dereq_(150);
3965
3966
var hasReadOnlyValue = {
3967
'button': true,
3968
'checkbox': true,
3969
'image': true,
3970
'hidden': true,
3971
'radio': true,
3972
'reset': true,
3973
'submit': true
3974
};
3975
3976
function _assertSingleLink(input) {
3977
("production" !== "development" ? invariant(
3978
input.props.checkedLink == null || input.props.valueLink == null,
3979
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
3980
'checkedLink, you probably don\'t want to use valueLink and vice versa.'
3981
) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
3982
}
3983
function _assertValueLink(input) {
3984
_assertSingleLink(input);
3985
("production" !== "development" ? invariant(
3986
input.props.value == null && input.props.onChange == null,
3987
'Cannot provide a valueLink and a value or onChange event. If you want ' +
3988
'to use value or onChange, you probably don\'t want to use valueLink.'
3989
) : invariant(input.props.value == null && input.props.onChange == null));
3990
}
3991
3992
function _assertCheckedLink(input) {
3993
_assertSingleLink(input);
3994
("production" !== "development" ? invariant(
3995
input.props.checked == null && input.props.onChange == null,
3996
'Cannot provide a checkedLink and a checked property or onChange event. ' +
3997
'If you want to use checked or onChange, you probably don\'t want to ' +
3998
'use checkedLink'
3999
) : invariant(input.props.checked == null && input.props.onChange == null));
4000
}
4001
4002
/**
4003
* @param {SyntheticEvent} e change event to handle
4004
*/
4005
function _handleLinkedValueChange(e) {
4006
/*jshint validthis:true */
4007
this.props.valueLink.requestChange(e.target.value);
4008
}
4009
4010
/**
4011
* @param {SyntheticEvent} e change event to handle
4012
*/
4013
function _handleLinkedCheckChange(e) {
4014
/*jshint validthis:true */
4015
this.props.checkedLink.requestChange(e.target.checked);
4016
}
4017
4018
/**
4019
* Provide a linked `value` attribute for controlled forms. You should not use
4020
* this outside of the ReactDOM controlled form components.
4021
*/
4022
var LinkedValueUtils = {
4023
Mixin: {
4024
propTypes: {
4025
value: function(props, propName, componentName) {
4026
if (!props[propName] ||
4027
hasReadOnlyValue[props.type] ||
4028
props.onChange ||
4029
props.readOnly ||
4030
props.disabled) {
4031
return null;
4032
}
4033
return new Error(
4034
'You provided a `value` prop to a form field without an ' +
4035
'`onChange` handler. This will render a read-only field. If ' +
4036
'the field should be mutable use `defaultValue`. Otherwise, ' +
4037
'set either `onChange` or `readOnly`.'
4038
);
4039
},
4040
checked: function(props, propName, componentName) {
4041
if (!props[propName] ||
4042
props.onChange ||
4043
props.readOnly ||
4044
props.disabled) {
4045
return null;
4046
}
4047
return new Error(
4048
'You provided a `checked` prop to a form field without an ' +
4049
'`onChange` handler. This will render a read-only field. If ' +
4050
'the field should be mutable use `defaultChecked`. Otherwise, ' +
4051
'set either `onChange` or `readOnly`.'
4052
);
4053
},
4054
onChange: ReactPropTypes.func
4055
}
4056
},
4057
4058
/**
4059
* @param {ReactComponent} input Form component
4060
* @return {*} current value of the input either from value prop or link.
4061
*/
4062
getValue: function(input) {
4063
if (input.props.valueLink) {
4064
_assertValueLink(input);
4065
return input.props.valueLink.value;
4066
}
4067
return input.props.value;
4068
},
4069
4070
/**
4071
* @param {ReactComponent} input Form component
4072
* @return {*} current checked status of the input either from checked prop
4073
* or link.
4074
*/
4075
getChecked: function(input) {
4076
if (input.props.checkedLink) {
4077
_assertCheckedLink(input);
4078
return input.props.checkedLink.value;
4079
}
4080
return input.props.checked;
4081
},
4082
4083
/**
4084
* @param {ReactComponent} input Form component
4085
* @return {function} change callback either from onChange prop or link.
4086
*/
4087
getOnChange: function(input) {
4088
if (input.props.valueLink) {
4089
_assertValueLink(input);
4090
return _handleLinkedValueChange;
4091
} else if (input.props.checkedLink) {
4092
_assertCheckedLink(input);
4093
return _handleLinkedCheckChange;
4094
}
4095
return input.props.onChange;
4096
}
4097
};
4098
4099
module.exports = LinkedValueUtils;
4100
4101
},{"150":150,"86":86}],27:[function(_dereq_,module,exports){
4102
/**
4103
* Copyright 2014-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 LocalEventTrapMixin
4111
*/
4112
4113
'use strict';
4114
4115
var ReactBrowserEventEmitter = _dereq_(33);
4116
4117
var accumulateInto = _dereq_(118);
4118
var forEachAccumulated = _dereq_(135);
4119
var invariant = _dereq_(150);
4120
4121
function remove(event) {
4122
event.remove();
4123
}
4124
4125
var LocalEventTrapMixin = {
4126
trapBubbledEvent:function(topLevelType, handlerBaseName) {
4127
("production" !== "development" ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
4128
// If a component renders to null or if another component fatals and causes
4129
// the state of the tree to be corrupted, `node` here can be null.
4130
var node = this.getDOMNode();
4131
("production" !== "development" ? invariant(
4132
node,
4133
'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
4134
) : invariant(node));
4135
var listener = ReactBrowserEventEmitter.trapBubbledEvent(
4136
topLevelType,
4137
handlerBaseName,
4138
node
4139
);
4140
this._localEventListeners =
4141
accumulateInto(this._localEventListeners, listener);
4142
},
4143
4144
// trapCapturedEvent would look nearly identical. We don't implement that
4145
// method because it isn't currently needed.
4146
4147
componentWillUnmount:function() {
4148
if (this._localEventListeners) {
4149
forEachAccumulated(this._localEventListeners, remove);
4150
}
4151
}
4152
};
4153
4154
module.exports = LocalEventTrapMixin;
4155
4156
},{"118":118,"135":135,"150":150,"33":33}],28:[function(_dereq_,module,exports){
4157
/**
4158
* Copyright 2013-2015, Facebook, Inc.
4159
* All rights reserved.
4160
*
4161
* This source code is licensed under the BSD-style license found in the
4162
* LICENSE file in the root directory of this source tree. An additional grant
4163
* of patent rights can be found in the PATENTS file in the same directory.
4164
*
4165
* @providesModule MobileSafariClickEventPlugin
4166
* @typechecks static-only
4167
*/
4168
4169
'use strict';
4170
4171
var EventConstants = _dereq_(16);
4172
4173
var emptyFunction = _dereq_(129);
4174
4175
var topLevelTypes = EventConstants.topLevelTypes;
4176
4177
/**
4178
* Mobile Safari does not fire properly bubble click events on non-interactive
4179
* elements, which means delegated click listeners do not fire. The workaround
4180
* for this bug involves attaching an empty click listener on the target node.
4181
*
4182
* This particular plugin works around the bug by attaching an empty click
4183
* listener on `touchstart` (which does fire on every element).
4184
*/
4185
var MobileSafariClickEventPlugin = {
4186
4187
eventTypes: null,
4188
4189
/**
4190
* @param {string} topLevelType Record from `EventConstants`.
4191
* @param {DOMEventTarget} topLevelTarget The listening component root node.
4192
* @param {string} topLevelTargetID ID of `topLevelTarget`.
4193
* @param {object} nativeEvent Native browser event.
4194
* @return {*} An accumulation of synthetic events.
4195
* @see {EventPluginHub.extractEvents}
4196
*/
4197
extractEvents: function(
4198
topLevelType,
4199
topLevelTarget,
4200
topLevelTargetID,
4201
nativeEvent) {
4202
if (topLevelType === topLevelTypes.topTouchStart) {
4203
var target = nativeEvent.target;
4204
if (target && !target.onclick) {
4205
target.onclick = emptyFunction;
4206
}
4207
}
4208
}
4209
4210
};
4211
4212
module.exports = MobileSafariClickEventPlugin;
4213
4214
},{"129":129,"16":16}],29:[function(_dereq_,module,exports){
4215
/**
4216
* Copyright 2014-2015, Facebook, Inc.
4217
* All rights reserved.
4218
*
4219
* This source code is licensed under the BSD-style license found in the
4220
* LICENSE file in the root directory of this source tree. An additional grant
4221
* of patent rights can be found in the PATENTS file in the same directory.
4222
*
4223
* @providesModule Object.assign
4224
*/
4225
4226
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
4227
4228
'use strict';
4229
4230
function assign(target, sources) {
4231
if (target == null) {
4232
throw new TypeError('Object.assign target cannot be null or undefined');
4233
}
4234
4235
var to = Object(target);
4236
var hasOwnProperty = Object.prototype.hasOwnProperty;
4237
4238
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
4239
var nextSource = arguments[nextIndex];
4240
if (nextSource == null) {
4241
continue;
4242
}
4243
4244
var from = Object(nextSource);
4245
4246
// We don't currently support accessors nor proxies. Therefore this
4247
// copy cannot throw. If we ever supported this then we must handle
4248
// exceptions and side-effects. We don't support symbols so they won't
4249
// be transferred.
4250
4251
for (var key in from) {
4252
if (hasOwnProperty.call(from, key)) {
4253
to[key] = from[key];
4254
}
4255
}
4256
}
4257
4258
return to;
4259
}
4260
4261
module.exports = assign;
4262
4263
},{}],30:[function(_dereq_,module,exports){
4264
/**
4265
* Copyright 2013-2015, Facebook, Inc.
4266
* All rights reserved.
4267
*
4268
* This source code is licensed under the BSD-style license found in the
4269
* LICENSE file in the root directory of this source tree. An additional grant
4270
* of patent rights can be found in the PATENTS file in the same directory.
4271
*
4272
* @providesModule PooledClass
4273
*/
4274
4275
'use strict';
4276
4277
var invariant = _dereq_(150);
4278
4279
/**
4280
* Static poolers. Several custom versions for each potential number of
4281
* arguments. A completely generic pooler is easy to implement, but would
4282
* require accessing the `arguments` object. In each of these, `this` refers to
4283
* the Class itself, not an instance. If any others are needed, simply add them
4284
* here, or in their own files.
4285
*/
4286
var oneArgumentPooler = function(copyFieldsFrom) {
4287
var Klass = this;
4288
if (Klass.instancePool.length) {
4289
var instance = Klass.instancePool.pop();
4290
Klass.call(instance, copyFieldsFrom);
4291
return instance;
4292
} else {
4293
return new Klass(copyFieldsFrom);
4294
}
4295
};
4296
4297
var twoArgumentPooler = function(a1, a2) {
4298
var Klass = this;
4299
if (Klass.instancePool.length) {
4300
var instance = Klass.instancePool.pop();
4301
Klass.call(instance, a1, a2);
4302
return instance;
4303
} else {
4304
return new Klass(a1, a2);
4305
}
4306
};
4307
4308
var threeArgumentPooler = function(a1, a2, a3) {
4309
var Klass = this;
4310
if (Klass.instancePool.length) {
4311
var instance = Klass.instancePool.pop();
4312
Klass.call(instance, a1, a2, a3);
4313
return instance;
4314
} else {
4315
return new Klass(a1, a2, a3);
4316
}
4317
};
4318
4319
var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
4320
var Klass = this;
4321
if (Klass.instancePool.length) {
4322
var instance = Klass.instancePool.pop();
4323
Klass.call(instance, a1, a2, a3, a4, a5);
4324
return instance;
4325
} else {
4326
return new Klass(a1, a2, a3, a4, a5);
4327
}
4328
};
4329
4330
var standardReleaser = function(instance) {
4331
var Klass = this;
4332
("production" !== "development" ? invariant(
4333
instance instanceof Klass,
4334
'Trying to release an instance into a pool of a different type.'
4335
) : invariant(instance instanceof Klass));
4336
if (instance.destructor) {
4337
instance.destructor();
4338
}
4339
if (Klass.instancePool.length < Klass.poolSize) {
4340
Klass.instancePool.push(instance);
4341
}
4342
};
4343
4344
var DEFAULT_POOL_SIZE = 10;
4345
var DEFAULT_POOLER = oneArgumentPooler;
4346
4347
/**
4348
* Augments `CopyConstructor` to be a poolable class, augmenting only the class
4349
* itself (statically) not adding any prototypical fields. Any CopyConstructor
4350
* you give this may have a `poolSize` property, and will look for a
4351
* prototypical `destructor` on instances (optional).
4352
*
4353
* @param {Function} CopyConstructor Constructor that can be used to reset.
4354
* @param {Function} pooler Customizable pooler.
4355
*/
4356
var addPoolingTo = function(CopyConstructor, pooler) {
4357
var NewKlass = CopyConstructor;
4358
NewKlass.instancePool = [];
4359
NewKlass.getPooled = pooler || DEFAULT_POOLER;
4360
if (!NewKlass.poolSize) {
4361
NewKlass.poolSize = DEFAULT_POOL_SIZE;
4362
}
4363
NewKlass.release = standardReleaser;
4364
return NewKlass;
4365
};
4366
4367
var PooledClass = {
4368
addPoolingTo: addPoolingTo,
4369
oneArgumentPooler: oneArgumentPooler,
4370
twoArgumentPooler: twoArgumentPooler,
4371
threeArgumentPooler: threeArgumentPooler,
4372
fiveArgumentPooler: fiveArgumentPooler
4373
};
4374
4375
module.exports = PooledClass;
4376
4377
},{"150":150}],31:[function(_dereq_,module,exports){
4378
/**
4379
* Copyright 2013-2015, Facebook, Inc.
4380
* All rights reserved.
4381
*
4382
* This source code is licensed under the BSD-style license found in the
4383
* LICENSE file in the root directory of this source tree. An additional grant
4384
* of patent rights can be found in the PATENTS file in the same directory.
4385
*
4386
* @providesModule React
4387
*/
4388
4389
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
4390
4391
'use strict';
4392
4393
var EventPluginUtils = _dereq_(20);
4394
var ReactChildren = _dereq_(37);
4395
var ReactComponent = _dereq_(39);
4396
var ReactClass = _dereq_(38);
4397
var ReactContext = _dereq_(44);
4398
var ReactCurrentOwner = _dereq_(45);
4399
var ReactElement = _dereq_(63);
4400
var ReactElementValidator = _dereq_(64);
4401
var ReactDOM = _dereq_(46);
4402
var ReactDOMTextComponent = _dereq_(57);
4403
var ReactDefaultInjection = _dereq_(60);
4404
var ReactInstanceHandles = _dereq_(72);
4405
var ReactMount = _dereq_(77);
4406
var ReactPerf = _dereq_(82);
4407
var ReactPropTypes = _dereq_(86);
4408
var ReactReconciler = _dereq_(89);
4409
var ReactServerRendering = _dereq_(92);
4410
4411
var assign = _dereq_(29);
4412
var findDOMNode = _dereq_(132);
4413
var onlyChild = _dereq_(160);
4414
4415
ReactDefaultInjection.inject();
4416
4417
var createElement = ReactElement.createElement;
4418
var createFactory = ReactElement.createFactory;
4419
var cloneElement = ReactElement.cloneElement;
4420
4421
if ("production" !== "development") {
4422
createElement = ReactElementValidator.createElement;
4423
createFactory = ReactElementValidator.createFactory;
4424
cloneElement = ReactElementValidator.cloneElement;
4425
}
4426
4427
var render = ReactPerf.measure('React', 'render', ReactMount.render);
4428
4429
var React = {
4430
Children: {
4431
map: ReactChildren.map,
4432
forEach: ReactChildren.forEach,
4433
count: ReactChildren.count,
4434
only: onlyChild
4435
},
4436
Component: ReactComponent,
4437
DOM: ReactDOM,
4438
PropTypes: ReactPropTypes,
4439
initializeTouchEvents: function(shouldUseTouch) {
4440
EventPluginUtils.useTouchEvents = shouldUseTouch;
4441
},
4442
createClass: ReactClass.createClass,
4443
createElement: createElement,
4444
cloneElement: cloneElement,
4445
createFactory: createFactory,
4446
createMixin: function(mixin) {
4447
// Currently a noop. Will be used to validate and trace mixins.
4448
return mixin;
4449
},
4450
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
4451
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
4452
findDOMNode: findDOMNode,
4453
render: render,
4454
renderToString: ReactServerRendering.renderToString,
4455
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
4456
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
4457
isValidElement: ReactElement.isValidElement,
4458
withContext: ReactContext.withContext,
4459
4460
// Hook for JSX spread, don't use this for anything else.
4461
__spread: assign
4462
};
4463
4464
// Inject the runtime into a devtools global hook regardless of browser.
4465
// Allows for debugging when the hook is injected on the page.
4466
if (
4467
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
4468
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
4469
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
4470
CurrentOwner: ReactCurrentOwner,
4471
InstanceHandles: ReactInstanceHandles,
4472
Mount: ReactMount,
4473
Reconciler: ReactReconciler,
4474
TextComponent: ReactDOMTextComponent
4475
});
4476
}
4477
4478
if ("production" !== "development") {
4479
var ExecutionEnvironment = _dereq_(22);
4480
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
4481
4482
// If we're in Chrome, look for the devtools marker and provide a download
4483
// link if not installed.
4484
if (navigator.userAgent.indexOf('Chrome') > -1) {
4485
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
4486
console.debug(
4487
'Download the React DevTools for a better development experience: ' +
4488
'https://fb.me/react-devtools'
4489
);
4490
}
4491
}
4492
4493
var expectedFeatures = [
4494
// shims
4495
Array.isArray,
4496
Array.prototype.every,
4497
Array.prototype.forEach,
4498
Array.prototype.indexOf,
4499
Array.prototype.map,
4500
Date.now,
4501
Function.prototype.bind,
4502
Object.keys,
4503
String.prototype.split,
4504
String.prototype.trim,
4505
4506
// shams
4507
Object.create,
4508
Object.freeze
4509
];
4510
4511
for (var i = 0; i < expectedFeatures.length; i++) {
4512
if (!expectedFeatures[i]) {
4513
console.error(
4514
'One or more ES5 shim/shams expected by React are not available: ' +
4515
'https://fb.me/react-warning-polyfills'
4516
);
4517
break;
4518
}
4519
}
4520
}
4521
}
4522
4523
React.version = '0.13.3';
4524
4525
module.exports = React;
4526
4527
},{"132":132,"160":160,"20":20,"22":22,"29":29,"37":37,"38":38,"39":39,"44":44,"45":45,"46":46,"57":57,"60":60,"63":63,"64":64,"72":72,"77":77,"82":82,"86":86,"89":89,"92":92}],32:[function(_dereq_,module,exports){
4528
/**
4529
* Copyright 2013-2015, Facebook, Inc.
4530
* All rights reserved.
4531
*
4532
* This source code is licensed under the BSD-style license found in the
4533
* LICENSE file in the root directory of this source tree. An additional grant
4534
* of patent rights can be found in the PATENTS file in the same directory.
4535
*
4536
* @providesModule ReactBrowserComponentMixin
4537
*/
4538
4539
'use strict';
4540
4541
var findDOMNode = _dereq_(132);
4542
4543
var ReactBrowserComponentMixin = {
4544
/**
4545
* Returns the DOM node rendered by this component.
4546
*
4547
* @return {DOMElement} The root node of this component.
4548
* @final
4549
* @protected
4550
*/
4551
getDOMNode: function() {
4552
return findDOMNode(this);
4553
}
4554
};
4555
4556
module.exports = ReactBrowserComponentMixin;
4557
4558
},{"132":132}],33:[function(_dereq_,module,exports){
4559
/**
4560
* Copyright 2013-2015, Facebook, Inc.
4561
* All rights reserved.
4562
*
4563
* This source code is licensed under the BSD-style license found in the
4564
* LICENSE file in the root directory of this source tree. An additional grant
4565
* of patent rights can be found in the PATENTS file in the same directory.
4566
*
4567
* @providesModule ReactBrowserEventEmitter
4568
* @typechecks static-only
4569
*/
4570
4571
'use strict';
4572
4573
var EventConstants = _dereq_(16);
4574
var EventPluginHub = _dereq_(18);
4575
var EventPluginRegistry = _dereq_(19);
4576
var ReactEventEmitterMixin = _dereq_(67);
4577
var ViewportMetrics = _dereq_(117);
4578
4579
var assign = _dereq_(29);
4580
var isEventSupported = _dereq_(151);
4581
4582
/**
4583
* Summary of `ReactBrowserEventEmitter` event handling:
4584
*
4585
* - Top-level delegation is used to trap most native browser events. This
4586
* may only occur in the main thread and is the responsibility of
4587
* ReactEventListener, which is injected and can therefore support pluggable
4588
* event sources. This is the only work that occurs in the main thread.
4589
*
4590
* - We normalize and de-duplicate events to account for browser quirks. This
4591
* may be done in the worker thread.
4592
*
4593
* - Forward these native events (with the associated top-level type used to
4594
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
4595
* to extract any synthetic events.
4596
*
4597
* - The `EventPluginHub` will then process each event by annotating them with
4598
* "dispatches", a sequence of listeners and IDs that care about that event.
4599
*
4600
* - The `EventPluginHub` then dispatches the events.
4601
*
4602
* Overview of React and the event system:
4603
*
4604
* +------------+ .
4605
* | DOM | .
4606
* +------------+ .
4607
* | .
4608
* v .
4609
* +------------+ .
4610
* | ReactEvent | .
4611
* | Listener | .
4612
* +------------+ . +-----------+
4613
* | . +--------+|SimpleEvent|
4614
* | . | |Plugin |
4615
* +-----|------+ . v +-----------+
4616
* | | | . +--------------+ +------------+
4617
* | +-----------.--->|EventPluginHub| | Event |
4618
* | | . | | +-----------+ | Propagators|
4619
* | ReactEvent | . | | |TapEvent | |------------|
4620
* | Emitter | . | |<---+|Plugin | |other plugin|
4621
* | | . | | +-----------+ | utilities |
4622
* | +-----------.--->| | +------------+
4623
* | | | . +--------------+
4624
* +-----|------+ . ^ +-----------+
4625
* | . | |Enter/Leave|
4626
* + . +-------+|Plugin |
4627
* +-------------+ . +-----------+
4628
* | application | .
4629
* |-------------| .
4630
* | | .
4631
* | | .
4632
* +-------------+ .
4633
* .
4634
* React Core . General Purpose Event Plugin System
4635
*/
4636
4637
var alreadyListeningTo = {};
4638
var isMonitoringScrollValue = false;
4639
var reactTopListenersCounter = 0;
4640
4641
// For events like 'submit' which don't consistently bubble (which we trap at a
4642
// lower node than `document`), binding at `document` would cause duplicate
4643
// events so we don't include them here
4644
var topEventMapping = {
4645
topBlur: 'blur',
4646
topChange: 'change',
4647
topClick: 'click',
4648
topCompositionEnd: 'compositionend',
4649
topCompositionStart: 'compositionstart',
4650
topCompositionUpdate: 'compositionupdate',
4651
topContextMenu: 'contextmenu',
4652
topCopy: 'copy',
4653
topCut: 'cut',
4654
topDoubleClick: 'dblclick',
4655
topDrag: 'drag',
4656
topDragEnd: 'dragend',
4657
topDragEnter: 'dragenter',
4658
topDragExit: 'dragexit',
4659
topDragLeave: 'dragleave',
4660
topDragOver: 'dragover',
4661
topDragStart: 'dragstart',
4662
topDrop: 'drop',
4663
topFocus: 'focus',
4664
topInput: 'input',
4665
topKeyDown: 'keydown',
4666
topKeyPress: 'keypress',
4667
topKeyUp: 'keyup',
4668
topMouseDown: 'mousedown',
4669
topMouseMove: 'mousemove',
4670
topMouseOut: 'mouseout',
4671
topMouseOver: 'mouseover',
4672
topMouseUp: 'mouseup',
4673
topPaste: 'paste',
4674
topScroll: 'scroll',
4675
topSelectionChange: 'selectionchange',
4676
topTextInput: 'textInput',
4677
topTouchCancel: 'touchcancel',
4678
topTouchEnd: 'touchend',
4679
topTouchMove: 'touchmove',
4680
topTouchStart: 'touchstart',
4681
topWheel: 'wheel'
4682
};
4683
4684
/**
4685
* To ensure no conflicts with other potential React instances on the page
4686
*/
4687
var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2);
4688
4689
function getListeningForDocument(mountAt) {
4690
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
4691
// directly.
4692
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
4693
mountAt[topListenersIDKey] = reactTopListenersCounter++;
4694
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
4695
}
4696
return alreadyListeningTo[mountAt[topListenersIDKey]];
4697
}
4698
4699
/**
4700
* `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
4701
* example:
4702
*
4703
* ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
4704
*
4705
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
4706
*
4707
* @internal
4708
*/
4709
var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
4710
4711
/**
4712
* Injectable event backend
4713
*/
4714
ReactEventListener: null,
4715
4716
injection: {
4717
/**
4718
* @param {object} ReactEventListener
4719
*/
4720
injectReactEventListener: function(ReactEventListener) {
4721
ReactEventListener.setHandleTopLevel(
4722
ReactBrowserEventEmitter.handleTopLevel
4723
);
4724
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
4725
}
4726
},
4727
4728
/**
4729
* Sets whether or not any created callbacks should be enabled.
4730
*
4731
* @param {boolean} enabled True if callbacks should be enabled.
4732
*/
4733
setEnabled: function(enabled) {
4734
if (ReactBrowserEventEmitter.ReactEventListener) {
4735
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
4736
}
4737
},
4738
4739
/**
4740
* @return {boolean} True if callbacks are enabled.
4741
*/
4742
isEnabled: function() {
4743
return !!(
4744
(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled())
4745
);
4746
},
4747
4748
/**
4749
* We listen for bubbled touch events on the document object.
4750
*
4751
* Firefox v8.01 (and possibly others) exhibited strange behavior when
4752
* mounting `onmousemove` events at some node that was not the document
4753
* element. The symptoms were that if your mouse is not moving over something
4754
* contained within that mount point (for example on the background) the
4755
* top-level listeners for `onmousemove` won't be called. However, if you
4756
* register the `mousemove` on the document object, then it will of course
4757
* catch all `mousemove`s. This along with iOS quirks, justifies restricting
4758
* top-level listeners to the document object only, at least for these
4759
* movement types of events and possibly all events.
4760
*
4761
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
4762
*
4763
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
4764
* they bubble to document.
4765
*
4766
* @param {string} registrationName Name of listener (e.g. `onClick`).
4767
* @param {object} contentDocumentHandle Document which owns the container
4768
*/
4769
listenTo: function(registrationName, contentDocumentHandle) {
4770
var mountAt = contentDocumentHandle;
4771
var isListening = getListeningForDocument(mountAt);
4772
var dependencies = EventPluginRegistry.
4773
registrationNameDependencies[registrationName];
4774
4775
var topLevelTypes = EventConstants.topLevelTypes;
4776
for (var i = 0, l = dependencies.length; i < l; i++) {
4777
var dependency = dependencies[i];
4778
if (!(
4779
(isListening.hasOwnProperty(dependency) && isListening[dependency])
4780
)) {
4781
if (dependency === topLevelTypes.topWheel) {
4782
if (isEventSupported('wheel')) {
4783
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4784
topLevelTypes.topWheel,
4785
'wheel',
4786
mountAt
4787
);
4788
} else if (isEventSupported('mousewheel')) {
4789
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4790
topLevelTypes.topWheel,
4791
'mousewheel',
4792
mountAt
4793
);
4794
} else {
4795
// Firefox needs to capture a different mouse scroll event.
4796
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
4797
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4798
topLevelTypes.topWheel,
4799
'DOMMouseScroll',
4800
mountAt
4801
);
4802
}
4803
} else if (dependency === topLevelTypes.topScroll) {
4804
4805
if (isEventSupported('scroll', true)) {
4806
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4807
topLevelTypes.topScroll,
4808
'scroll',
4809
mountAt
4810
);
4811
} else {
4812
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4813
topLevelTypes.topScroll,
4814
'scroll',
4815
ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
4816
);
4817
}
4818
} else if (dependency === topLevelTypes.topFocus ||
4819
dependency === topLevelTypes.topBlur) {
4820
4821
if (isEventSupported('focus', true)) {
4822
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4823
topLevelTypes.topFocus,
4824
'focus',
4825
mountAt
4826
);
4827
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4828
topLevelTypes.topBlur,
4829
'blur',
4830
mountAt
4831
);
4832
} else if (isEventSupported('focusin')) {
4833
// IE has `focusin` and `focusout` events which bubble.
4834
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
4835
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4836
topLevelTypes.topFocus,
4837
'focusin',
4838
mountAt
4839
);
4840
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4841
topLevelTypes.topBlur,
4842
'focusout',
4843
mountAt
4844
);
4845
}
4846
4847
// to make sure blur and focus event listeners are only attached once
4848
isListening[topLevelTypes.topBlur] = true;
4849
isListening[topLevelTypes.topFocus] = true;
4850
} else if (topEventMapping.hasOwnProperty(dependency)) {
4851
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4852
dependency,
4853
topEventMapping[dependency],
4854
mountAt
4855
);
4856
}
4857
4858
isListening[dependency] = true;
4859
}
4860
}
4861
},
4862
4863
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
4864
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
4865
topLevelType,
4866
handlerBaseName,
4867
handle
4868
);
4869
},
4870
4871
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
4872
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
4873
topLevelType,
4874
handlerBaseName,
4875
handle
4876
);
4877
},
4878
4879
/**
4880
* Listens to window scroll and resize events. We cache scroll values so that
4881
* application code can access them without triggering reflows.
4882
*
4883
* NOTE: Scroll events do not bubble.
4884
*
4885
* @see http://www.quirksmode.org/dom/events/scroll.html
4886
*/
4887
ensureScrollValueMonitoring: function() {
4888
if (!isMonitoringScrollValue) {
4889
var refresh = ViewportMetrics.refreshScrollValues;
4890
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
4891
isMonitoringScrollValue = true;
4892
}
4893
},
4894
4895
eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
4896
4897
registrationNameModules: EventPluginHub.registrationNameModules,
4898
4899
putListener: EventPluginHub.putListener,
4900
4901
getListener: EventPluginHub.getListener,
4902
4903
deleteListener: EventPluginHub.deleteListener,
4904
4905
deleteAllListeners: EventPluginHub.deleteAllListeners
4906
4907
});
4908
4909
module.exports = ReactBrowserEventEmitter;
4910
4911
},{"117":117,"151":151,"16":16,"18":18,"19":19,"29":29,"67":67}],34:[function(_dereq_,module,exports){
4912
/**
4913
* Copyright 2013-2015, Facebook, Inc.
4914
* All rights reserved.
4915
*
4916
* This source code is licensed under the BSD-style license found in the
4917
* LICENSE file in the root directory of this source tree. An additional grant
4918
* of patent rights can be found in the PATENTS file in the same directory.
4919
*
4920
* @typechecks
4921
* @providesModule ReactCSSTransitionGroup
4922
*/
4923
4924
'use strict';
4925
4926
var React = _dereq_(31);
4927
4928
var assign = _dereq_(29);
4929
4930
var ReactTransitionGroup = React.createFactory(
4931
_dereq_(98)
4932
);
4933
var ReactCSSTransitionGroupChild = React.createFactory(
4934
_dereq_(35)
4935
);
4936
4937
var ReactCSSTransitionGroup = React.createClass({
4938
displayName: 'ReactCSSTransitionGroup',
4939
4940
propTypes: {
4941
transitionName: React.PropTypes.string.isRequired,
4942
transitionAppear: React.PropTypes.bool,
4943
transitionEnter: React.PropTypes.bool,
4944
transitionLeave: React.PropTypes.bool
4945
},
4946
4947
getDefaultProps: function() {
4948
return {
4949
transitionAppear: false,
4950
transitionEnter: true,
4951
transitionLeave: true
4952
};
4953
},
4954
4955
_wrapChild: function(child) {
4956
// We need to provide this childFactory so that
4957
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
4958
// leave while it is leaving.
4959
return ReactCSSTransitionGroupChild(
4960
{
4961
name: this.props.transitionName,
4962
appear: this.props.transitionAppear,
4963
enter: this.props.transitionEnter,
4964
leave: this.props.transitionLeave
4965
},
4966
child
4967
);
4968
},
4969
4970
render: function() {
4971
return (
4972
ReactTransitionGroup(
4973
assign({}, this.props, {childFactory: this._wrapChild})
4974
)
4975
);
4976
}
4977
});
4978
4979
module.exports = ReactCSSTransitionGroup;
4980
4981
},{"29":29,"31":31,"35":35,"98":98}],35:[function(_dereq_,module,exports){
4982
/**
4983
* Copyright 2013-2015, Facebook, Inc.
4984
* All rights reserved.
4985
*
4986
* This source code is licensed under the BSD-style license found in the
4987
* LICENSE file in the root directory of this source tree. An additional grant
4988
* of patent rights can be found in the PATENTS file in the same directory.
4989
*
4990
* @typechecks
4991
* @providesModule ReactCSSTransitionGroupChild
4992
*/
4993
4994
'use strict';
4995
4996
var React = _dereq_(31);
4997
4998
var CSSCore = _dereq_(4);
4999
var ReactTransitionEvents = _dereq_(97);
5000
5001
var onlyChild = _dereq_(160);
5002
var warning = _dereq_(171);
5003
5004
// We don't remove the element from the DOM until we receive an animationend or
5005
// transitionend event. If the user screws up and forgets to add an animation
5006
// their node will be stuck in the DOM forever, so we detect if an animation
5007
// does not start and if it doesn't, we just call the end listener immediately.
5008
var TICK = 17;
5009
var NO_EVENT_TIMEOUT = 5000;
5010
5011
var noEventListener = null;
5012
5013
5014
if ("production" !== "development") {
5015
noEventListener = function() {
5016
("production" !== "development" ? warning(
5017
false,
5018
'transition(): tried to perform an animation without ' +
5019
'an animationend or transitionend event after timeout (' +
5020
'%sms). You should either disable this ' +
5021
'transition in JS or add a CSS animation/transition.',
5022
NO_EVENT_TIMEOUT
5023
) : null);
5024
};
5025
}
5026
5027
var ReactCSSTransitionGroupChild = React.createClass({
5028
displayName: 'ReactCSSTransitionGroupChild',
5029
5030
transition: function(animationType, finishCallback) {
5031
var node = this.getDOMNode();
5032
var className = this.props.name + '-' + animationType;
5033
var activeClassName = className + '-active';
5034
var noEventTimeout = null;
5035
5036
var endListener = function(e) {
5037
if (e && e.target !== node) {
5038
return;
5039
}
5040
if ("production" !== "development") {
5041
clearTimeout(noEventTimeout);
5042
}
5043
5044
CSSCore.removeClass(node, className);
5045
CSSCore.removeClass(node, activeClassName);
5046
5047
ReactTransitionEvents.removeEndEventListener(node, endListener);
5048
5049
// Usually this optional callback is used for informing an owner of
5050
// a leave animation and telling it to remove the child.
5051
if (finishCallback) {
5052
finishCallback();
5053
}
5054
};
5055
5056
ReactTransitionEvents.addEndEventListener(node, endListener);
5057
5058
CSSCore.addClass(node, className);
5059
5060
// Need to do this to actually trigger a transition.
5061
this.queueClass(activeClassName);
5062
5063
if ("production" !== "development") {
5064
noEventTimeout = setTimeout(noEventListener, NO_EVENT_TIMEOUT);
5065
}
5066
},
5067
5068
queueClass: function(className) {
5069
this.classNameQueue.push(className);
5070
5071
if (!this.timeout) {
5072
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
5073
}
5074
},
5075
5076
flushClassNameQueue: function() {
5077
if (this.isMounted()) {
5078
this.classNameQueue.forEach(
5079
CSSCore.addClass.bind(CSSCore, this.getDOMNode())
5080
);
5081
}
5082
this.classNameQueue.length = 0;
5083
this.timeout = null;
5084
},
5085
5086
componentWillMount: function() {
5087
this.classNameQueue = [];
5088
},
5089
5090
componentWillUnmount: function() {
5091
if (this.timeout) {
5092
clearTimeout(this.timeout);
5093
}
5094
},
5095
5096
componentWillAppear: function(done) {
5097
if (this.props.appear) {
5098
this.transition('appear', done);
5099
} else {
5100
done();
5101
}
5102
},
5103
5104
componentWillEnter: function(done) {
5105
if (this.props.enter) {
5106
this.transition('enter', done);
5107
} else {
5108
done();
5109
}
5110
},
5111
5112
componentWillLeave: function(done) {
5113
if (this.props.leave) {
5114
this.transition('leave', done);
5115
} else {
5116
done();
5117
}
5118
},
5119
5120
render: function() {
5121
return onlyChild(this.props.children);
5122
}
5123
});
5124
5125
module.exports = ReactCSSTransitionGroupChild;
5126
5127
},{"160":160,"171":171,"31":31,"4":4,"97":97}],36:[function(_dereq_,module,exports){
5128
/**
5129
* Copyright 2014-2015, Facebook, Inc.
5130
* All rights reserved.
5131
*
5132
* This source code is licensed under the BSD-style license found in the
5133
* LICENSE file in the root directory of this source tree. An additional grant
5134
* of patent rights can be found in the PATENTS file in the same directory.
5135
*
5136
* @providesModule ReactChildReconciler
5137
* @typechecks static-only
5138
*/
5139
5140
'use strict';
5141
5142
var ReactReconciler = _dereq_(89);
5143
5144
var flattenChildren = _dereq_(133);
5145
var instantiateReactComponent = _dereq_(149);
5146
var shouldUpdateReactComponent = _dereq_(167);
5147
5148
/**
5149
* ReactChildReconciler provides helpers for initializing or updating a set of
5150
* children. Its output is suitable for passing it onto ReactMultiChild which
5151
* does diffed reordering and insertion.
5152
*/
5153
var ReactChildReconciler = {
5154
5155
/**
5156
* Generates a "mount image" for each of the supplied children. In the case
5157
* of `ReactDOMComponent`, a mount image is a string of markup.
5158
*
5159
* @param {?object} nestedChildNodes Nested child maps.
5160
* @return {?object} A set of child instances.
5161
* @internal
5162
*/
5163
instantiateChildren: function(nestedChildNodes, transaction, context) {
5164
var children = flattenChildren(nestedChildNodes);
5165
for (var name in children) {
5166
if (children.hasOwnProperty(name)) {
5167
var child = children[name];
5168
// The rendered children must be turned into instances as they're
5169
// mounted.
5170
var childInstance = instantiateReactComponent(child, null);
5171
children[name] = childInstance;
5172
}
5173
}
5174
return children;
5175
},
5176
5177
/**
5178
* Updates the rendered children and returns a new set of children.
5179
*
5180
* @param {?object} prevChildren Previously initialized set of children.
5181
* @param {?object} nextNestedChildNodes Nested child maps.
5182
* @param {ReactReconcileTransaction} transaction
5183
* @param {object} context
5184
* @return {?object} A new set of child instances.
5185
* @internal
5186
*/
5187
updateChildren: function(
5188
prevChildren,
5189
nextNestedChildNodes,
5190
transaction,
5191
context) {
5192
// We currently don't have a way to track moves here but if we use iterators
5193
// instead of for..in we can zip the iterators and check if an item has
5194
// moved.
5195
// TODO: If nothing has changed, return the prevChildren object so that we
5196
// can quickly bailout if nothing has changed.
5197
var nextChildren = flattenChildren(nextNestedChildNodes);
5198
if (!nextChildren && !prevChildren) {
5199
return null;
5200
}
5201
var name;
5202
for (name in nextChildren) {
5203
if (!nextChildren.hasOwnProperty(name)) {
5204
continue;
5205
}
5206
var prevChild = prevChildren && prevChildren[name];
5207
var prevElement = prevChild && prevChild._currentElement;
5208
var nextElement = nextChildren[name];
5209
if (shouldUpdateReactComponent(prevElement, nextElement)) {
5210
ReactReconciler.receiveComponent(
5211
prevChild, nextElement, transaction, context
5212
);
5213
nextChildren[name] = prevChild;
5214
} else {
5215
if (prevChild) {
5216
ReactReconciler.unmountComponent(prevChild, name);
5217
}
5218
// The child must be instantiated before it's mounted.
5219
var nextChildInstance = instantiateReactComponent(
5220
nextElement,
5221
null
5222
);
5223
nextChildren[name] = nextChildInstance;
5224
}
5225
}
5226
// Unmount children that are no longer present.
5227
for (name in prevChildren) {
5228
if (prevChildren.hasOwnProperty(name) &&
5229
!(nextChildren && nextChildren.hasOwnProperty(name))) {
5230
ReactReconciler.unmountComponent(prevChildren[name]);
5231
}
5232
}
5233
return nextChildren;
5234
},
5235
5236
/**
5237
* Unmounts all rendered children. This should be used to clean up children
5238
* when this component is unmounted.
5239
*
5240
* @param {?object} renderedChildren Previously initialized set of children.
5241
* @internal
5242
*/
5243
unmountChildren: function(renderedChildren) {
5244
for (var name in renderedChildren) {
5245
var renderedChild = renderedChildren[name];
5246
ReactReconciler.unmountComponent(renderedChild);
5247
}
5248
}
5249
5250
};
5251
5252
module.exports = ReactChildReconciler;
5253
5254
},{"133":133,"149":149,"167":167,"89":89}],37:[function(_dereq_,module,exports){
5255
/**
5256
* Copyright 2013-2015, Facebook, Inc.
5257
* All rights reserved.
5258
*
5259
* This source code is licensed under the BSD-style license found in the
5260
* LICENSE file in the root directory of this source tree. An additional grant
5261
* of patent rights can be found in the PATENTS file in the same directory.
5262
*
5263
* @providesModule ReactChildren
5264
*/
5265
5266
'use strict';
5267
5268
var PooledClass = _dereq_(30);
5269
var ReactFragment = _dereq_(69);
5270
5271
var traverseAllChildren = _dereq_(169);
5272
var warning = _dereq_(171);
5273
5274
var twoArgumentPooler = PooledClass.twoArgumentPooler;
5275
var threeArgumentPooler = PooledClass.threeArgumentPooler;
5276
5277
/**
5278
* PooledClass representing the bookkeeping associated with performing a child
5279
* traversal. Allows avoiding binding callbacks.
5280
*
5281
* @constructor ForEachBookKeeping
5282
* @param {!function} forEachFunction Function to perform traversal with.
5283
* @param {?*} forEachContext Context to perform context with.
5284
*/
5285
function ForEachBookKeeping(forEachFunction, forEachContext) {
5286
this.forEachFunction = forEachFunction;
5287
this.forEachContext = forEachContext;
5288
}
5289
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
5290
5291
function forEachSingleChild(traverseContext, child, name, i) {
5292
var forEachBookKeeping = traverseContext;
5293
forEachBookKeeping.forEachFunction.call(
5294
forEachBookKeeping.forEachContext, child, i);
5295
}
5296
5297
/**
5298
* Iterates through children that are typically specified as `props.children`.
5299
*
5300
* The provided forEachFunc(child, index) will be called for each
5301
* leaf child.
5302
*
5303
* @param {?*} children Children tree container.
5304
* @param {function(*, int)} forEachFunc.
5305
* @param {*} forEachContext Context for forEachContext.
5306
*/
5307
function forEachChildren(children, forEachFunc, forEachContext) {
5308
if (children == null) {
5309
return children;
5310
}
5311
5312
var traverseContext =
5313
ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
5314
traverseAllChildren(children, forEachSingleChild, traverseContext);
5315
ForEachBookKeeping.release(traverseContext);
5316
}
5317
5318
/**
5319
* PooledClass representing the bookkeeping associated with performing a child
5320
* mapping. Allows avoiding binding callbacks.
5321
*
5322
* @constructor MapBookKeeping
5323
* @param {!*} mapResult Object containing the ordered map of results.
5324
* @param {!function} mapFunction Function to perform mapping with.
5325
* @param {?*} mapContext Context to perform mapping with.
5326
*/
5327
function MapBookKeeping(mapResult, mapFunction, mapContext) {
5328
this.mapResult = mapResult;
5329
this.mapFunction = mapFunction;
5330
this.mapContext = mapContext;
5331
}
5332
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
5333
5334
function mapSingleChildIntoContext(traverseContext, child, name, i) {
5335
var mapBookKeeping = traverseContext;
5336
var mapResult = mapBookKeeping.mapResult;
5337
5338
var keyUnique = !mapResult.hasOwnProperty(name);
5339
if ("production" !== "development") {
5340
("production" !== "development" ? warning(
5341
keyUnique,
5342
'ReactChildren.map(...): Encountered two children with the same key, ' +
5343
'`%s`. Child keys must be unique; when two children share a key, only ' +
5344
'the first child will be used.',
5345
name
5346
) : null);
5347
}
5348
5349
if (keyUnique) {
5350
var mappedChild =
5351
mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
5352
mapResult[name] = mappedChild;
5353
}
5354
}
5355
5356
/**
5357
* Maps children that are typically specified as `props.children`.
5358
*
5359
* The provided mapFunction(child, key, index) will be called for each
5360
* leaf child.
5361
*
5362
* TODO: This may likely break any calls to `ReactChildren.map` that were
5363
* previously relying on the fact that we guarded against null children.
5364
*
5365
* @param {?*} children Children tree container.
5366
* @param {function(*, int)} mapFunction.
5367
* @param {*} mapContext Context for mapFunction.
5368
* @return {object} Object containing the ordered map of results.
5369
*/
5370
function mapChildren(children, func, context) {
5371
if (children == null) {
5372
return children;
5373
}
5374
5375
var mapResult = {};
5376
var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
5377
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
5378
MapBookKeeping.release(traverseContext);
5379
return ReactFragment.create(mapResult);
5380
}
5381
5382
function forEachSingleChildDummy(traverseContext, child, name, i) {
5383
return null;
5384
}
5385
5386
/**
5387
* Count the number of children that are typically specified as
5388
* `props.children`.
5389
*
5390
* @param {?*} children Children tree container.
5391
* @return {number} The number of children.
5392
*/
5393
function countChildren(children, context) {
5394
return traverseAllChildren(children, forEachSingleChildDummy, null);
5395
}
5396
5397
var ReactChildren = {
5398
forEach: forEachChildren,
5399
map: mapChildren,
5400
count: countChildren
5401
};
5402
5403
module.exports = ReactChildren;
5404
5405
},{"169":169,"171":171,"30":30,"69":69}],38:[function(_dereq_,module,exports){
5406
/**
5407
* Copyright 2013-2015, Facebook, Inc.
5408
* All rights reserved.
5409
*
5410
* This source code is licensed under the BSD-style license found in the
5411
* LICENSE file in the root directory of this source tree. An additional grant
5412
* of patent rights can be found in the PATENTS file in the same directory.
5413
*
5414
* @providesModule ReactClass
5415
*/
5416
5417
'use strict';
5418
5419
var ReactComponent = _dereq_(39);
5420
var ReactCurrentOwner = _dereq_(45);
5421
var ReactElement = _dereq_(63);
5422
var ReactErrorUtils = _dereq_(66);
5423
var ReactInstanceMap = _dereq_(73);
5424
var ReactLifeCycle = _dereq_(74);
5425
var ReactPropTypeLocations = _dereq_(85);
5426
var ReactPropTypeLocationNames = _dereq_(84);
5427
var ReactUpdateQueue = _dereq_(99);
5428
5429
var assign = _dereq_(29);
5430
var invariant = _dereq_(150);
5431
var keyMirror = _dereq_(156);
5432
var keyOf = _dereq_(157);
5433
var warning = _dereq_(171);
5434
5435
var MIXINS_KEY = keyOf({mixins: null});
5436
5437
/**
5438
* Policies that describe methods in `ReactClassInterface`.
5439
*/
5440
var SpecPolicy = keyMirror({
5441
/**
5442
* These methods may be defined only once by the class specification or mixin.
5443
*/
5444
DEFINE_ONCE: null,
5445
/**
5446
* These methods may be defined by both the class specification and mixins.
5447
* Subsequent definitions will be chained. These methods must return void.
5448
*/
5449
DEFINE_MANY: null,
5450
/**
5451
* These methods are overriding the base class.
5452
*/
5453
OVERRIDE_BASE: null,
5454
/**
5455
* These methods are similar to DEFINE_MANY, except we assume they return
5456
* objects. We try to merge the keys of the return values of all the mixed in
5457
* functions. If there is a key conflict we throw.
5458
*/
5459
DEFINE_MANY_MERGED: null
5460
});
5461
5462
5463
var injectedMixins = [];
5464
5465
/**
5466
* Composite components are higher-level components that compose other composite
5467
* or native components.
5468
*
5469
* To create a new type of `ReactClass`, pass a specification of
5470
* your new class to `React.createClass`. The only requirement of your class
5471
* specification is that you implement a `render` method.
5472
*
5473
* var MyComponent = React.createClass({
5474
* render: function() {
5475
* return <div>Hello World</div>;
5476
* }
5477
* });
5478
*
5479
* The class specification supports a specific protocol of methods that have
5480
* special meaning (e.g. `render`). See `ReactClassInterface` for
5481
* more the comprehensive protocol. Any other properties and methods in the
5482
* class specification will available on the prototype.
5483
*
5484
* @interface ReactClassInterface
5485
* @internal
5486
*/
5487
var ReactClassInterface = {
5488
5489
/**
5490
* An array of Mixin objects to include when defining your component.
5491
*
5492
* @type {array}
5493
* @optional
5494
*/
5495
mixins: SpecPolicy.DEFINE_MANY,
5496
5497
/**
5498
* An object containing properties and methods that should be defined on
5499
* the component's constructor instead of its prototype (static methods).
5500
*
5501
* @type {object}
5502
* @optional
5503
*/
5504
statics: SpecPolicy.DEFINE_MANY,
5505
5506
/**
5507
* Definition of prop types for this component.
5508
*
5509
* @type {object}
5510
* @optional
5511
*/
5512
propTypes: SpecPolicy.DEFINE_MANY,
5513
5514
/**
5515
* Definition of context types for this component.
5516
*
5517
* @type {object}
5518
* @optional
5519
*/
5520
contextTypes: SpecPolicy.DEFINE_MANY,
5521
5522
/**
5523
* Definition of context types this component sets for its children.
5524
*
5525
* @type {object}
5526
* @optional
5527
*/
5528
childContextTypes: SpecPolicy.DEFINE_MANY,
5529
5530
// ==== Definition methods ====
5531
5532
/**
5533
* Invoked when the component is mounted. Values in the mapping will be set on
5534
* `this.props` if that prop is not specified (i.e. using an `in` check).
5535
*
5536
* This method is invoked before `getInitialState` and therefore cannot rely
5537
* on `this.state` or use `this.setState`.
5538
*
5539
* @return {object}
5540
* @optional
5541
*/
5542
getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
5543
5544
/**
5545
* Invoked once before the component is mounted. The return value will be used
5546
* as the initial value of `this.state`.
5547
*
5548
* getInitialState: function() {
5549
* return {
5550
* isOn: false,
5551
* fooBaz: new BazFoo()
5552
* }
5553
* }
5554
*
5555
* @return {object}
5556
* @optional
5557
*/
5558
getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
5559
5560
/**
5561
* @return {object}
5562
* @optional
5563
*/
5564
getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
5565
5566
/**
5567
* Uses props from `this.props` and state from `this.state` to render the
5568
* structure of the component.
5569
*
5570
* No guarantees are made about when or how often this method is invoked, so
5571
* it must not have side effects.
5572
*
5573
* render: function() {
5574
* var name = this.props.name;
5575
* return <div>Hello, {name}!</div>;
5576
* }
5577
*
5578
* @return {ReactComponent}
5579
* @nosideeffects
5580
* @required
5581
*/
5582
render: SpecPolicy.DEFINE_ONCE,
5583
5584
5585
5586
// ==== Delegate methods ====
5587
5588
/**
5589
* Invoked when the component is initially created and about to be mounted.
5590
* This may have side effects, but any external subscriptions or data created
5591
* by this method must be cleaned up in `componentWillUnmount`.
5592
*
5593
* @optional
5594
*/
5595
componentWillMount: SpecPolicy.DEFINE_MANY,
5596
5597
/**
5598
* Invoked when the component has been mounted and has a DOM representation.
5599
* However, there is no guarantee that the DOM node is in the document.
5600
*
5601
* Use this as an opportunity to operate on the DOM when the component has
5602
* been mounted (initialized and rendered) for the first time.
5603
*
5604
* @param {DOMElement} rootNode DOM element representing the component.
5605
* @optional
5606
*/
5607
componentDidMount: SpecPolicy.DEFINE_MANY,
5608
5609
/**
5610
* Invoked before the component receives new props.
5611
*
5612
* Use this as an opportunity to react to a prop transition by updating the
5613
* state using `this.setState`. Current props are accessed via `this.props`.
5614
*
5615
* componentWillReceiveProps: function(nextProps, nextContext) {
5616
* this.setState({
5617
* likesIncreasing: nextProps.likeCount > this.props.likeCount
5618
* });
5619
* }
5620
*
5621
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
5622
* transition may cause a state change, but the opposite is not true. If you
5623
* need it, you are probably looking for `componentWillUpdate`.
5624
*
5625
* @param {object} nextProps
5626
* @optional
5627
*/
5628
componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
5629
5630
/**
5631
* Invoked while deciding if the component should be updated as a result of
5632
* receiving new props, state and/or context.
5633
*
5634
* Use this as an opportunity to `return false` when you're certain that the
5635
* transition to the new props/state/context will not require a component
5636
* update.
5637
*
5638
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
5639
* return !equal(nextProps, this.props) ||
5640
* !equal(nextState, this.state) ||
5641
* !equal(nextContext, this.context);
5642
* }
5643
*
5644
* @param {object} nextProps
5645
* @param {?object} nextState
5646
* @param {?object} nextContext
5647
* @return {boolean} True if the component should update.
5648
* @optional
5649
*/
5650
shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
5651
5652
/**
5653
* Invoked when the component is about to update due to a transition from
5654
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
5655
* and `nextContext`.
5656
*
5657
* Use this as an opportunity to perform preparation before an update occurs.
5658
*
5659
* NOTE: You **cannot** use `this.setState()` in this method.
5660
*
5661
* @param {object} nextProps
5662
* @param {?object} nextState
5663
* @param {?object} nextContext
5664
* @param {ReactReconcileTransaction} transaction
5665
* @optional
5666
*/
5667
componentWillUpdate: SpecPolicy.DEFINE_MANY,
5668
5669
/**
5670
* Invoked when the component's DOM representation has been updated.
5671
*
5672
* Use this as an opportunity to operate on the DOM when the component has
5673
* been updated.
5674
*
5675
* @param {object} prevProps
5676
* @param {?object} prevState
5677
* @param {?object} prevContext
5678
* @param {DOMElement} rootNode DOM element representing the component.
5679
* @optional
5680
*/
5681
componentDidUpdate: SpecPolicy.DEFINE_MANY,
5682
5683
/**
5684
* Invoked when the component is about to be removed from its parent and have
5685
* its DOM representation destroyed.
5686
*
5687
* Use this as an opportunity to deallocate any external resources.
5688
*
5689
* NOTE: There is no `componentDidUnmount` since your component will have been
5690
* destroyed by that point.
5691
*
5692
* @optional
5693
*/
5694
componentWillUnmount: SpecPolicy.DEFINE_MANY,
5695
5696
5697
5698
// ==== Advanced methods ====
5699
5700
/**
5701
* Updates the component's currently mounted DOM representation.
5702
*
5703
* By default, this implements React's rendering and reconciliation algorithm.
5704
* Sophisticated clients may wish to override this.
5705
*
5706
* @param {ReactReconcileTransaction} transaction
5707
* @internal
5708
* @overridable
5709
*/
5710
updateComponent: SpecPolicy.OVERRIDE_BASE
5711
5712
};
5713
5714
/**
5715
* Mapping from class specification keys to special processing functions.
5716
*
5717
* Although these are declared like instance properties in the specification
5718
* when defining classes using `React.createClass`, they are actually static
5719
* and are accessible on the constructor instead of the prototype. Despite
5720
* being static, they must be defined outside of the "statics" key under
5721
* which all other static methods are defined.
5722
*/
5723
var RESERVED_SPEC_KEYS = {
5724
displayName: function(Constructor, displayName) {
5725
Constructor.displayName = displayName;
5726
},
5727
mixins: function(Constructor, mixins) {
5728
if (mixins) {
5729
for (var i = 0; i < mixins.length; i++) {
5730
mixSpecIntoComponent(Constructor, mixins[i]);
5731
}
5732
}
5733
},
5734
childContextTypes: function(Constructor, childContextTypes) {
5735
if ("production" !== "development") {
5736
validateTypeDef(
5737
Constructor,
5738
childContextTypes,
5739
ReactPropTypeLocations.childContext
5740
);
5741
}
5742
Constructor.childContextTypes = assign(
5743
{},
5744
Constructor.childContextTypes,
5745
childContextTypes
5746
);
5747
},
5748
contextTypes: function(Constructor, contextTypes) {
5749
if ("production" !== "development") {
5750
validateTypeDef(
5751
Constructor,
5752
contextTypes,
5753
ReactPropTypeLocations.context
5754
);
5755
}
5756
Constructor.contextTypes = assign(
5757
{},
5758
Constructor.contextTypes,
5759
contextTypes
5760
);
5761
},
5762
/**
5763
* Special case getDefaultProps which should move into statics but requires
5764
* automatic merging.
5765
*/
5766
getDefaultProps: function(Constructor, getDefaultProps) {
5767
if (Constructor.getDefaultProps) {
5768
Constructor.getDefaultProps = createMergedResultFunction(
5769
Constructor.getDefaultProps,
5770
getDefaultProps
5771
);
5772
} else {
5773
Constructor.getDefaultProps = getDefaultProps;
5774
}
5775
},
5776
propTypes: function(Constructor, propTypes) {
5777
if ("production" !== "development") {
5778
validateTypeDef(
5779
Constructor,
5780
propTypes,
5781
ReactPropTypeLocations.prop
5782
);
5783
}
5784
Constructor.propTypes = assign(
5785
{},
5786
Constructor.propTypes,
5787
propTypes
5788
);
5789
},
5790
statics: function(Constructor, statics) {
5791
mixStaticSpecIntoComponent(Constructor, statics);
5792
}
5793
};
5794
5795
function validateTypeDef(Constructor, typeDef, location) {
5796
for (var propName in typeDef) {
5797
if (typeDef.hasOwnProperty(propName)) {
5798
// use a warning instead of an invariant so components
5799
// don't show up in prod but not in __DEV__
5800
("production" !== "development" ? warning(
5801
typeof typeDef[propName] === 'function',
5802
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
5803
'React.PropTypes.',
5804
Constructor.displayName || 'ReactClass',
5805
ReactPropTypeLocationNames[location],
5806
propName
5807
) : null);
5808
}
5809
}
5810
}
5811
5812
function validateMethodOverride(proto, name) {
5813
var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
5814
ReactClassInterface[name] :
5815
null;
5816
5817
// Disallow overriding of base class methods unless explicitly allowed.
5818
if (ReactClassMixin.hasOwnProperty(name)) {
5819
("production" !== "development" ? invariant(
5820
specPolicy === SpecPolicy.OVERRIDE_BASE,
5821
'ReactClassInterface: You are attempting to override ' +
5822
'`%s` from your class specification. Ensure that your method names ' +
5823
'do not overlap with React methods.',
5824
name
5825
) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
5826
}
5827
5828
// Disallow defining methods more than once unless explicitly allowed.
5829
if (proto.hasOwnProperty(name)) {
5830
("production" !== "development" ? invariant(
5831
specPolicy === SpecPolicy.DEFINE_MANY ||
5832
specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
5833
'ReactClassInterface: You are attempting to define ' +
5834
'`%s` on your component more than once. This conflict may be due ' +
5835
'to a mixin.',
5836
name
5837
) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
5838
specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
5839
}
5840
}
5841
5842
/**
5843
* Mixin helper which handles policy validation and reserved
5844
* specification keys when building React classses.
5845
*/
5846
function mixSpecIntoComponent(Constructor, spec) {
5847
if (!spec) {
5848
return;
5849
}
5850
5851
("production" !== "development" ? invariant(
5852
typeof spec !== 'function',
5853
'ReactClass: You\'re attempting to ' +
5854
'use a component class as a mixin. Instead, just use a regular object.'
5855
) : invariant(typeof spec !== 'function'));
5856
("production" !== "development" ? invariant(
5857
!ReactElement.isValidElement(spec),
5858
'ReactClass: You\'re attempting to ' +
5859
'use a component as a mixin. Instead, just use a regular object.'
5860
) : invariant(!ReactElement.isValidElement(spec)));
5861
5862
var proto = Constructor.prototype;
5863
5864
// By handling mixins before any other properties, we ensure the same
5865
// chaining order is applied to methods with DEFINE_MANY policy, whether
5866
// mixins are listed before or after these methods in the spec.
5867
if (spec.hasOwnProperty(MIXINS_KEY)) {
5868
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
5869
}
5870
5871
for (var name in spec) {
5872
if (!spec.hasOwnProperty(name)) {
5873
continue;
5874
}
5875
5876
if (name === MIXINS_KEY) {
5877
// We have already handled mixins in a special case above
5878
continue;
5879
}
5880
5881
var property = spec[name];
5882
validateMethodOverride(proto, name);
5883
5884
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
5885
RESERVED_SPEC_KEYS[name](Constructor, property);
5886
} else {
5887
// Setup methods on prototype:
5888
// The following member methods should not be automatically bound:
5889
// 1. Expected ReactClass methods (in the "interface").
5890
// 2. Overridden methods (that were mixed in).
5891
var isReactClassMethod =
5892
ReactClassInterface.hasOwnProperty(name);
5893
var isAlreadyDefined = proto.hasOwnProperty(name);
5894
var markedDontBind = property && property.__reactDontBind;
5895
var isFunction = typeof property === 'function';
5896
var shouldAutoBind =
5897
isFunction &&
5898
!isReactClassMethod &&
5899
!isAlreadyDefined &&
5900
!markedDontBind;
5901
5902
if (shouldAutoBind) {
5903
if (!proto.__reactAutoBindMap) {
5904
proto.__reactAutoBindMap = {};
5905
}
5906
proto.__reactAutoBindMap[name] = property;
5907
proto[name] = property;
5908
} else {
5909
if (isAlreadyDefined) {
5910
var specPolicy = ReactClassInterface[name];
5911
5912
// These cases should already be caught by validateMethodOverride
5913
("production" !== "development" ? invariant(
5914
isReactClassMethod && (
5915
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
5916
),
5917
'ReactClass: Unexpected spec policy %s for key %s ' +
5918
'when mixing in component specs.',
5919
specPolicy,
5920
name
5921
) : invariant(isReactClassMethod && (
5922
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
5923
)));
5924
5925
// For methods which are defined more than once, call the existing
5926
// methods before calling the new property, merging if appropriate.
5927
if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
5928
proto[name] = createMergedResultFunction(proto[name], property);
5929
} else if (specPolicy === SpecPolicy.DEFINE_MANY) {
5930
proto[name] = createChainedFunction(proto[name], property);
5931
}
5932
} else {
5933
proto[name] = property;
5934
if ("production" !== "development") {
5935
// Add verbose displayName to the function, which helps when looking
5936
// at profiling tools.
5937
if (typeof property === 'function' && spec.displayName) {
5938
proto[name].displayName = spec.displayName + '_' + name;
5939
}
5940
}
5941
}
5942
}
5943
}
5944
}
5945
}
5946
5947
function mixStaticSpecIntoComponent(Constructor, statics) {
5948
if (!statics) {
5949
return;
5950
}
5951
for (var name in statics) {
5952
var property = statics[name];
5953
if (!statics.hasOwnProperty(name)) {
5954
continue;
5955
}
5956
5957
var isReserved = name in RESERVED_SPEC_KEYS;
5958
("production" !== "development" ? invariant(
5959
!isReserved,
5960
'ReactClass: You are attempting to define a reserved ' +
5961
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
5962
'as an instance property instead; it will still be accessible on the ' +
5963
'constructor.',
5964
name
5965
) : invariant(!isReserved));
5966
5967
var isInherited = name in Constructor;
5968
("production" !== "development" ? invariant(
5969
!isInherited,
5970
'ReactClass: You are attempting to define ' +
5971
'`%s` on your component more than once. This conflict may be ' +
5972
'due to a mixin.',
5973
name
5974
) : invariant(!isInherited));
5975
Constructor[name] = property;
5976
}
5977
}
5978
5979
/**
5980
* Merge two objects, but throw if both contain the same key.
5981
*
5982
* @param {object} one The first object, which is mutated.
5983
* @param {object} two The second object
5984
* @return {object} one after it has been mutated to contain everything in two.
5985
*/
5986
function mergeIntoWithNoDuplicateKeys(one, two) {
5987
("production" !== "development" ? invariant(
5988
one && two && typeof one === 'object' && typeof two === 'object',
5989
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
5990
) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
5991
5992
for (var key in two) {
5993
if (two.hasOwnProperty(key)) {
5994
("production" !== "development" ? invariant(
5995
one[key] === undefined,
5996
'mergeIntoWithNoDuplicateKeys(): ' +
5997
'Tried to merge two objects with the same key: `%s`. This conflict ' +
5998
'may be due to a mixin; in particular, this may be caused by two ' +
5999
'getInitialState() or getDefaultProps() methods returning objects ' +
6000
'with clashing keys.',
6001
key
6002
) : invariant(one[key] === undefined));
6003
one[key] = two[key];
6004
}
6005
}
6006
return one;
6007
}
6008
6009
/**
6010
* Creates a function that invokes two functions and merges their return values.
6011
*
6012
* @param {function} one Function to invoke first.
6013
* @param {function} two Function to invoke second.
6014
* @return {function} Function that invokes the two argument functions.
6015
* @private
6016
*/
6017
function createMergedResultFunction(one, two) {
6018
return function mergedResult() {
6019
var a = one.apply(this, arguments);
6020
var b = two.apply(this, arguments);
6021
if (a == null) {
6022
return b;
6023
} else if (b == null) {
6024
return a;
6025
}
6026
var c = {};
6027
mergeIntoWithNoDuplicateKeys(c, a);
6028
mergeIntoWithNoDuplicateKeys(c, b);
6029
return c;
6030
};
6031
}
6032
6033
/**
6034
* Creates a function that invokes two functions and ignores their return vales.
6035
*
6036
* @param {function} one Function to invoke first.
6037
* @param {function} two Function to invoke second.
6038
* @return {function} Function that invokes the two argument functions.
6039
* @private
6040
*/
6041
function createChainedFunction(one, two) {
6042
return function chainedFunction() {
6043
one.apply(this, arguments);
6044
two.apply(this, arguments);
6045
};
6046
}
6047
6048
/**
6049
* Binds a method to the component.
6050
*
6051
* @param {object} component Component whose method is going to be bound.
6052
* @param {function} method Method to be bound.
6053
* @return {function} The bound method.
6054
*/
6055
function bindAutoBindMethod(component, method) {
6056
var boundMethod = method.bind(component);
6057
if ("production" !== "development") {
6058
boundMethod.__reactBoundContext = component;
6059
boundMethod.__reactBoundMethod = method;
6060
boundMethod.__reactBoundArguments = null;
6061
var componentName = component.constructor.displayName;
6062
var _bind = boundMethod.bind;
6063
/* eslint-disable block-scoped-var, no-undef */
6064
boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
6065
// User is trying to bind() an autobound method; we effectively will
6066
// ignore the value of "this" that the user is trying to use, so
6067
// let's warn.
6068
if (newThis !== component && newThis !== null) {
6069
("production" !== "development" ? warning(
6070
false,
6071
'bind(): React component methods may only be bound to the ' +
6072
'component instance. See %s',
6073
componentName
6074
) : null);
6075
} else if (!args.length) {
6076
("production" !== "development" ? warning(
6077
false,
6078
'bind(): You are binding a component method to the component. ' +
6079
'React does this for you automatically in a high-performance ' +
6080
'way, so you can safely remove this call. See %s',
6081
componentName
6082
) : null);
6083
return boundMethod;
6084
}
6085
var reboundMethod = _bind.apply(boundMethod, arguments);
6086
reboundMethod.__reactBoundContext = component;
6087
reboundMethod.__reactBoundMethod = method;
6088
reboundMethod.__reactBoundArguments = args;
6089
return reboundMethod;
6090
/* eslint-enable */
6091
};
6092
}
6093
return boundMethod;
6094
}
6095
6096
/**
6097
* Binds all auto-bound methods in a component.
6098
*
6099
* @param {object} component Component whose method is going to be bound.
6100
*/
6101
function bindAutoBindMethods(component) {
6102
for (var autoBindKey in component.__reactAutoBindMap) {
6103
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
6104
var method = component.__reactAutoBindMap[autoBindKey];
6105
component[autoBindKey] = bindAutoBindMethod(
6106
component,
6107
ReactErrorUtils.guard(
6108
method,
6109
component.constructor.displayName + '.' + autoBindKey
6110
)
6111
);
6112
}
6113
}
6114
}
6115
6116
var typeDeprecationDescriptor = {
6117
enumerable: false,
6118
get: function() {
6119
var displayName = this.displayName || this.name || 'Component';
6120
("production" !== "development" ? warning(
6121
false,
6122
'%s.type is deprecated. Use %s directly to access the class.',
6123
displayName,
6124
displayName
6125
) : null);
6126
Object.defineProperty(this, 'type', {
6127
value: this
6128
});
6129
return this;
6130
}
6131
};
6132
6133
/**
6134
* Add more to the ReactClass base class. These are all legacy features and
6135
* therefore not already part of the modern ReactComponent.
6136
*/
6137
var ReactClassMixin = {
6138
6139
/**
6140
* TODO: This will be deprecated because state should always keep a consistent
6141
* type signature and the only use case for this, is to avoid that.
6142
*/
6143
replaceState: function(newState, callback) {
6144
ReactUpdateQueue.enqueueReplaceState(this, newState);
6145
if (callback) {
6146
ReactUpdateQueue.enqueueCallback(this, callback);
6147
}
6148
},
6149
6150
/**
6151
* Checks whether or not this composite component is mounted.
6152
* @return {boolean} True if mounted, false otherwise.
6153
* @protected
6154
* @final
6155
*/
6156
isMounted: function() {
6157
if ("production" !== "development") {
6158
var owner = ReactCurrentOwner.current;
6159
if (owner !== null) {
6160
("production" !== "development" ? warning(
6161
owner._warnedAboutRefsInRender,
6162
'%s is accessing isMounted inside its render() function. ' +
6163
'render() should be a pure function of props and state. It should ' +
6164
'never access something that requires stale data from the previous ' +
6165
'render, such as refs. Move this logic to componentDidMount and ' +
6166
'componentDidUpdate instead.',
6167
owner.getName() || 'A component'
6168
) : null);
6169
owner._warnedAboutRefsInRender = true;
6170
}
6171
}
6172
var internalInstance = ReactInstanceMap.get(this);
6173
return (
6174
internalInstance &&
6175
internalInstance !== ReactLifeCycle.currentlyMountingInstance
6176
);
6177
},
6178
6179
/**
6180
* Sets a subset of the props.
6181
*
6182
* @param {object} partialProps Subset of the next props.
6183
* @param {?function} callback Called after props are updated.
6184
* @final
6185
* @public
6186
* @deprecated
6187
*/
6188
setProps: function(partialProps, callback) {
6189
ReactUpdateQueue.enqueueSetProps(this, partialProps);
6190
if (callback) {
6191
ReactUpdateQueue.enqueueCallback(this, callback);
6192
}
6193
},
6194
6195
/**
6196
* Replace all the props.
6197
*
6198
* @param {object} newProps Subset of the next props.
6199
* @param {?function} callback Called after props are updated.
6200
* @final
6201
* @public
6202
* @deprecated
6203
*/
6204
replaceProps: function(newProps, callback) {
6205
ReactUpdateQueue.enqueueReplaceProps(this, newProps);
6206
if (callback) {
6207
ReactUpdateQueue.enqueueCallback(this, callback);
6208
}
6209
}
6210
};
6211
6212
var ReactClassComponent = function() {};
6213
assign(
6214
ReactClassComponent.prototype,
6215
ReactComponent.prototype,
6216
ReactClassMixin
6217
);
6218
6219
/**
6220
* Module for creating composite components.
6221
*
6222
* @class ReactClass
6223
*/
6224
var ReactClass = {
6225
6226
/**
6227
* Creates a composite component class given a class specification.
6228
*
6229
* @param {object} spec Class specification (which must define `render`).
6230
* @return {function} Component constructor function.
6231
* @public
6232
*/
6233
createClass: function(spec) {
6234
var Constructor = function(props, context) {
6235
// This constructor is overridden by mocks. The argument is used
6236
// by mocks to assert on what gets mounted.
6237
6238
if ("production" !== "development") {
6239
("production" !== "development" ? warning(
6240
this instanceof Constructor,
6241
'Something is calling a React component directly. Use a factory or ' +
6242
'JSX instead. See: https://fb.me/react-legacyfactory'
6243
) : null);
6244
}
6245
6246
// Wire up auto-binding
6247
if (this.__reactAutoBindMap) {
6248
bindAutoBindMethods(this);
6249
}
6250
6251
this.props = props;
6252
this.context = context;
6253
this.state = null;
6254
6255
// ReactClasses doesn't have constructors. Instead, they use the
6256
// getInitialState and componentWillMount methods for initialization.
6257
6258
var initialState = this.getInitialState ? this.getInitialState() : null;
6259
if ("production" !== "development") {
6260
// We allow auto-mocks to proceed as if they're returning null.
6261
if (typeof initialState === 'undefined' &&
6262
this.getInitialState._isMockFunction) {
6263
// This is probably bad practice. Consider warning here and
6264
// deprecating this convenience.
6265
initialState = null;
6266
}
6267
}
6268
("production" !== "development" ? invariant(
6269
typeof initialState === 'object' && !Array.isArray(initialState),
6270
'%s.getInitialState(): must return an object or null',
6271
Constructor.displayName || 'ReactCompositeComponent'
6272
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
6273
6274
this.state = initialState;
6275
};
6276
Constructor.prototype = new ReactClassComponent();
6277
Constructor.prototype.constructor = Constructor;
6278
6279
injectedMixins.forEach(
6280
mixSpecIntoComponent.bind(null, Constructor)
6281
);
6282
6283
mixSpecIntoComponent(Constructor, spec);
6284
6285
// Initialize the defaultProps property after all mixins have been merged
6286
if (Constructor.getDefaultProps) {
6287
Constructor.defaultProps = Constructor.getDefaultProps();
6288
}
6289
6290
if ("production" !== "development") {
6291
// This is a tag to indicate that the use of these method names is ok,
6292
// since it's used with createClass. If it's not, then it's likely a
6293
// mistake so we'll warn you to use the static property, property
6294
// initializer or constructor respectively.
6295
if (Constructor.getDefaultProps) {
6296
Constructor.getDefaultProps.isReactClassApproved = {};
6297
}
6298
if (Constructor.prototype.getInitialState) {
6299
Constructor.prototype.getInitialState.isReactClassApproved = {};
6300
}
6301
}
6302
6303
("production" !== "development" ? invariant(
6304
Constructor.prototype.render,
6305
'createClass(...): Class specification must implement a `render` method.'
6306
) : invariant(Constructor.prototype.render));
6307
6308
if ("production" !== "development") {
6309
("production" !== "development" ? warning(
6310
!Constructor.prototype.componentShouldUpdate,
6311
'%s has a method called ' +
6312
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
6313
'The name is phrased as a question because the function is ' +
6314
'expected to return a value.',
6315
spec.displayName || 'A component'
6316
) : null);
6317
}
6318
6319
// Reduce time spent doing lookups by setting these on the prototype.
6320
for (var methodName in ReactClassInterface) {
6321
if (!Constructor.prototype[methodName]) {
6322
Constructor.prototype[methodName] = null;
6323
}
6324
}
6325
6326
// Legacy hook
6327
Constructor.type = Constructor;
6328
if ("production" !== "development") {
6329
try {
6330
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
6331
} catch (x) {
6332
// IE will fail on defineProperty (es5-shim/sham too)
6333
}
6334
}
6335
6336
return Constructor;
6337
},
6338
6339
injection: {
6340
injectMixin: function(mixin) {
6341
injectedMixins.push(mixin);
6342
}
6343
}
6344
6345
};
6346
6347
module.exports = ReactClass;
6348
6349
},{"150":150,"156":156,"157":157,"171":171,"29":29,"39":39,"45":45,"63":63,"66":66,"73":73,"74":74,"84":84,"85":85,"99":99}],39:[function(_dereq_,module,exports){
6350
/**
6351
* Copyright 2013-2015, Facebook, Inc.
6352
* All rights reserved.
6353
*
6354
* This source code is licensed under the BSD-style license found in the
6355
* LICENSE file in the root directory of this source tree. An additional grant
6356
* of patent rights can be found in the PATENTS file in the same directory.
6357
*
6358
* @providesModule ReactComponent
6359
*/
6360
6361
'use strict';
6362
6363
var ReactUpdateQueue = _dereq_(99);
6364
6365
var invariant = _dereq_(150);
6366
var warning = _dereq_(171);
6367
6368
/**
6369
* Base class helpers for the updating state of a component.
6370
*/
6371
function ReactComponent(props, context) {
6372
this.props = props;
6373
this.context = context;
6374
}
6375
6376
/**
6377
* Sets a subset of the state. Always use this to mutate
6378
* state. You should treat `this.state` as immutable.
6379
*
6380
* There is no guarantee that `this.state` will be immediately updated, so
6381
* accessing `this.state` after calling this method may return the old value.
6382
*
6383
* There is no guarantee that calls to `setState` will run synchronously,
6384
* as they may eventually be batched together. You can provide an optional
6385
* callback that will be executed when the call to setState is actually
6386
* completed.
6387
*
6388
* When a function is provided to setState, it will be called at some point in
6389
* the future (not synchronously). It will be called with the up to date
6390
* component arguments (state, props, context). These values can be different
6391
* from this.* because your function may be called after receiveProps but before
6392
* shouldComponentUpdate, and this new state, props, and context will not yet be
6393
* assigned to this.
6394
*
6395
* @param {object|function} partialState Next partial state or function to
6396
* produce next partial state to be merged with current state.
6397
* @param {?function} callback Called after state is updated.
6398
* @final
6399
* @protected
6400
*/
6401
ReactComponent.prototype.setState = function(partialState, callback) {
6402
("production" !== "development" ? invariant(
6403
typeof partialState === 'object' ||
6404
typeof partialState === 'function' ||
6405
partialState == null,
6406
'setState(...): takes an object of state variables to update or a ' +
6407
'function which returns an object of state variables.'
6408
) : invariant(typeof partialState === 'object' ||
6409
typeof partialState === 'function' ||
6410
partialState == null));
6411
if ("production" !== "development") {
6412
("production" !== "development" ? warning(
6413
partialState != null,
6414
'setState(...): You passed an undefined or null state object; ' +
6415
'instead, use forceUpdate().'
6416
) : null);
6417
}
6418
ReactUpdateQueue.enqueueSetState(this, partialState);
6419
if (callback) {
6420
ReactUpdateQueue.enqueueCallback(this, callback);
6421
}
6422
};
6423
6424
/**
6425
* Forces an update. This should only be invoked when it is known with
6426
* certainty that we are **not** in a DOM transaction.
6427
*
6428
* You may want to call this when you know that some deeper aspect of the
6429
* component's state has changed but `setState` was not called.
6430
*
6431
* This will not invoke `shouldComponentUpdate`, but it will invoke
6432
* `componentWillUpdate` and `componentDidUpdate`.
6433
*
6434
* @param {?function} callback Called after update is complete.
6435
* @final
6436
* @protected
6437
*/
6438
ReactComponent.prototype.forceUpdate = function(callback) {
6439
ReactUpdateQueue.enqueueForceUpdate(this);
6440
if (callback) {
6441
ReactUpdateQueue.enqueueCallback(this, callback);
6442
}
6443
};
6444
6445
/**
6446
* Deprecated APIs. These APIs used to exist on classic React classes but since
6447
* we would like to deprecate them, we're not going to move them over to this
6448
* modern base class. Instead, we define a getter that warns if it's accessed.
6449
*/
6450
if ("production" !== "development") {
6451
var deprecatedAPIs = {
6452
getDOMNode: [
6453
'getDOMNode',
6454
'Use React.findDOMNode(component) instead.'
6455
],
6456
isMounted: [
6457
'isMounted',
6458
'Instead, make sure to clean up subscriptions and pending requests in ' +
6459
'componentWillUnmount to prevent memory leaks.'
6460
],
6461
replaceProps: [
6462
'replaceProps',
6463
'Instead call React.render again at the top level.'
6464
],
6465
replaceState: [
6466
'replaceState',
6467
'Refactor your code to use setState instead (see ' +
6468
'https://github.com/facebook/react/issues/3236).'
6469
],
6470
setProps: [
6471
'setProps',
6472
'Instead call React.render again at the top level.'
6473
]
6474
};
6475
var defineDeprecationWarning = function(methodName, info) {
6476
try {
6477
Object.defineProperty(ReactComponent.prototype, methodName, {
6478
get: function() {
6479
("production" !== "development" ? warning(
6480
false,
6481
'%s(...) is deprecated in plain JavaScript React classes. %s',
6482
info[0],
6483
info[1]
6484
) : null);
6485
return undefined;
6486
}
6487
});
6488
} catch (x) {
6489
// IE will fail on defineProperty (es5-shim/sham too)
6490
}
6491
};
6492
for (var fnName in deprecatedAPIs) {
6493
if (deprecatedAPIs.hasOwnProperty(fnName)) {
6494
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
6495
}
6496
}
6497
}
6498
6499
module.exports = ReactComponent;
6500
6501
},{"150":150,"171":171,"99":99}],40:[function(_dereq_,module,exports){
6502
/**
6503
* Copyright 2013-2015, Facebook, Inc.
6504
* All rights reserved.
6505
*
6506
* This source code is licensed under the BSD-style license found in the
6507
* LICENSE file in the root directory of this source tree. An additional grant
6508
* of patent rights can be found in the PATENTS file in the same directory.
6509
*
6510
* @providesModule ReactComponentBrowserEnvironment
6511
*/
6512
6513
/*jslint evil: true */
6514
6515
'use strict';
6516
6517
var ReactDOMIDOperations = _dereq_(50);
6518
var ReactMount = _dereq_(77);
6519
6520
/**
6521
* Abstracts away all functionality of the reconciler that requires knowledge of
6522
* the browser context. TODO: These callers should be refactored to avoid the
6523
* need for this injection.
6524
*/
6525
var ReactComponentBrowserEnvironment = {
6526
6527
processChildrenUpdates:
6528
ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
6529
6530
replaceNodeWithMarkupByID:
6531
ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
6532
6533
/**
6534
* If a particular environment requires that some resources be cleaned up,
6535
* specify this in the injected Mixin. In the DOM, we would likely want to
6536
* purge any cached node ID lookups.
6537
*
6538
* @private
6539
*/
6540
unmountIDFromEnvironment: function(rootNodeID) {
6541
ReactMount.purgeID(rootNodeID);
6542
}
6543
6544
};
6545
6546
module.exports = ReactComponentBrowserEnvironment;
6547
6548
},{"50":50,"77":77}],41:[function(_dereq_,module,exports){
6549
/**
6550
* Copyright 2014-2015, Facebook, Inc.
6551
* All rights reserved.
6552
*
6553
* This source code is licensed under the BSD-style license found in the
6554
* LICENSE file in the root directory of this source tree. An additional grant
6555
* of patent rights can be found in the PATENTS file in the same directory.
6556
*
6557
* @providesModule ReactComponentEnvironment
6558
*/
6559
6560
'use strict';
6561
6562
var invariant = _dereq_(150);
6563
6564
var injected = false;
6565
6566
var ReactComponentEnvironment = {
6567
6568
/**
6569
* Optionally injectable environment dependent cleanup hook. (server vs.
6570
* browser etc). Example: A browser system caches DOM nodes based on component
6571
* ID and must remove that cache entry when this instance is unmounted.
6572
*/
6573
unmountIDFromEnvironment: null,
6574
6575
/**
6576
* Optionally injectable hook for swapping out mount images in the middle of
6577
* the tree.
6578
*/
6579
replaceNodeWithMarkupByID: null,
6580
6581
/**
6582
* Optionally injectable hook for processing a queue of child updates. Will
6583
* later move into MultiChildComponents.
6584
*/
6585
processChildrenUpdates: null,
6586
6587
injection: {
6588
injectEnvironment: function(environment) {
6589
("production" !== "development" ? invariant(
6590
!injected,
6591
'ReactCompositeComponent: injectEnvironment() can only be called once.'
6592
) : invariant(!injected));
6593
ReactComponentEnvironment.unmountIDFromEnvironment =
6594
environment.unmountIDFromEnvironment;
6595
ReactComponentEnvironment.replaceNodeWithMarkupByID =
6596
environment.replaceNodeWithMarkupByID;
6597
ReactComponentEnvironment.processChildrenUpdates =
6598
environment.processChildrenUpdates;
6599
injected = true;
6600
}
6601
}
6602
6603
};
6604
6605
module.exports = ReactComponentEnvironment;
6606
6607
},{"150":150}],42:[function(_dereq_,module,exports){
6608
/**
6609
* Copyright 2013-2015, Facebook, Inc.
6610
* All rights reserved.
6611
*
6612
* This source code is licensed under the BSD-style license found in the
6613
* LICENSE file in the root directory of this source tree. An additional grant
6614
* of patent rights can be found in the PATENTS file in the same directory.
6615
*
6616
* @providesModule ReactComponentWithPureRenderMixin
6617
*/
6618
6619
'use strict';
6620
6621
var shallowEqual = _dereq_(166);
6622
6623
/**
6624
* If your React component's render function is "pure", e.g. it will render the
6625
* same result given the same props and state, provide this Mixin for a
6626
* considerable performance boost.
6627
*
6628
* Most React components have pure render functions.
6629
*
6630
* Example:
6631
*
6632
* var ReactComponentWithPureRenderMixin =
6633
* require('ReactComponentWithPureRenderMixin');
6634
* React.createClass({
6635
* mixins: [ReactComponentWithPureRenderMixin],
6636
*
6637
* render: function() {
6638
* return <div className={this.props.className}>foo</div>;
6639
* }
6640
* });
6641
*
6642
* Note: This only checks shallow equality for props and state. If these contain
6643
* complex data structures this mixin may have false-negatives for deeper
6644
* differences. Only mixin to components which have simple props and state, or
6645
* use `forceUpdate()` when you know deep data structures have changed.
6646
*/
6647
var ReactComponentWithPureRenderMixin = {
6648
shouldComponentUpdate: function(nextProps, nextState) {
6649
return !shallowEqual(this.props, nextProps) ||
6650
!shallowEqual(this.state, nextState);
6651
}
6652
};
6653
6654
module.exports = ReactComponentWithPureRenderMixin;
6655
6656
},{"166":166}],43:[function(_dereq_,module,exports){
6657
/**
6658
* Copyright 2013-2015, Facebook, Inc.
6659
* All rights reserved.
6660
*
6661
* This source code is licensed under the BSD-style license found in the
6662
* LICENSE file in the root directory of this source tree. An additional grant
6663
* of patent rights can be found in the PATENTS file in the same directory.
6664
*
6665
* @providesModule ReactCompositeComponent
6666
*/
6667
6668
'use strict';
6669
6670
var ReactComponentEnvironment = _dereq_(41);
6671
var ReactContext = _dereq_(44);
6672
var ReactCurrentOwner = _dereq_(45);
6673
var ReactElement = _dereq_(63);
6674
var ReactElementValidator = _dereq_(64);
6675
var ReactInstanceMap = _dereq_(73);
6676
var ReactLifeCycle = _dereq_(74);
6677
var ReactNativeComponent = _dereq_(80);
6678
var ReactPerf = _dereq_(82);
6679
var ReactPropTypeLocations = _dereq_(85);
6680
var ReactPropTypeLocationNames = _dereq_(84);
6681
var ReactReconciler = _dereq_(89);
6682
var ReactUpdates = _dereq_(100);
6683
6684
var assign = _dereq_(29);
6685
var emptyObject = _dereq_(130);
6686
var invariant = _dereq_(150);
6687
var shouldUpdateReactComponent = _dereq_(167);
6688
var warning = _dereq_(171);
6689
6690
function getDeclarationErrorAddendum(component) {
6691
var owner = component._currentElement._owner || null;
6692
if (owner) {
6693
var name = owner.getName();
6694
if (name) {
6695
return ' Check the render method of `' + name + '`.';
6696
}
6697
}
6698
return '';
6699
}
6700
6701
/**
6702
* ------------------ The Life-Cycle of a Composite Component ------------------
6703
*
6704
* - constructor: Initialization of state. The instance is now retained.
6705
* - componentWillMount
6706
* - render
6707
* - [children's constructors]
6708
* - [children's componentWillMount and render]
6709
* - [children's componentDidMount]
6710
* - componentDidMount
6711
*
6712
* Update Phases:
6713
* - componentWillReceiveProps (only called if parent updated)
6714
* - shouldComponentUpdate
6715
* - componentWillUpdate
6716
* - render
6717
* - [children's constructors or receive props phases]
6718
* - componentDidUpdate
6719
*
6720
* - componentWillUnmount
6721
* - [children's componentWillUnmount]
6722
* - [children destroyed]
6723
* - (destroyed): The instance is now blank, released by React and ready for GC.
6724
*
6725
* -----------------------------------------------------------------------------
6726
*/
6727
6728
/**
6729
* An incrementing ID assigned to each component when it is mounted. This is
6730
* used to enforce the order in which `ReactUpdates` updates dirty components.
6731
*
6732
* @private
6733
*/
6734
var nextMountID = 1;
6735
6736
/**
6737
* @lends {ReactCompositeComponent.prototype}
6738
*/
6739
var ReactCompositeComponentMixin = {
6740
6741
/**
6742
* Base constructor for all composite component.
6743
*
6744
* @param {ReactElement} element
6745
* @final
6746
* @internal
6747
*/
6748
construct: function(element) {
6749
this._currentElement = element;
6750
this._rootNodeID = null;
6751
this._instance = null;
6752
6753
// See ReactUpdateQueue
6754
this._pendingElement = null;
6755
this._pendingStateQueue = null;
6756
this._pendingReplaceState = false;
6757
this._pendingForceUpdate = false;
6758
6759
this._renderedComponent = null;
6760
6761
this._context = null;
6762
this._mountOrder = 0;
6763
this._isTopLevel = false;
6764
6765
// See ReactUpdates and ReactUpdateQueue.
6766
this._pendingCallbacks = null;
6767
},
6768
6769
/**
6770
* Initializes the component, renders markup, and registers event listeners.
6771
*
6772
* @param {string} rootID DOM ID of the root node.
6773
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
6774
* @return {?string} Rendered markup to be inserted into the DOM.
6775
* @final
6776
* @internal
6777
*/
6778
mountComponent: function(rootID, transaction, context) {
6779
this._context = context;
6780
this._mountOrder = nextMountID++;
6781
this._rootNodeID = rootID;
6782
6783
var publicProps = this._processProps(this._currentElement.props);
6784
var publicContext = this._processContext(this._currentElement._context);
6785
6786
var Component = ReactNativeComponent.getComponentClassForElement(
6787
this._currentElement
6788
);
6789
6790
// Initialize the public class
6791
var inst = new Component(publicProps, publicContext);
6792
6793
if ("production" !== "development") {
6794
// This will throw later in _renderValidatedComponent, but add an early
6795
// warning now to help debugging
6796
("production" !== "development" ? warning(
6797
inst.render != null,
6798
'%s(...): No `render` method found on the returned component ' +
6799
'instance: you may have forgotten to define `render` in your ' +
6800
'component or you may have accidentally tried to render an element ' +
6801
'whose type is a function that isn\'t a React component.',
6802
Component.displayName || Component.name || 'Component'
6803
) : null);
6804
}
6805
6806
// These should be set up in the constructor, but as a convenience for
6807
// simpler class abstractions, we set them up after the fact.
6808
inst.props = publicProps;
6809
inst.context = publicContext;
6810
inst.refs = emptyObject;
6811
6812
this._instance = inst;
6813
6814
// Store a reference from the instance back to the internal representation
6815
ReactInstanceMap.set(inst, this);
6816
6817
if ("production" !== "development") {
6818
this._warnIfContextsDiffer(this._currentElement._context, context);
6819
}
6820
6821
if ("production" !== "development") {
6822
// Since plain JS classes are defined without any special initialization
6823
// logic, we can not catch common errors early. Therefore, we have to
6824
// catch them here, at initialization time, instead.
6825
("production" !== "development" ? warning(
6826
!inst.getInitialState ||
6827
inst.getInitialState.isReactClassApproved,
6828
'getInitialState was defined on %s, a plain JavaScript class. ' +
6829
'This is only supported for classes created using React.createClass. ' +
6830
'Did you mean to define a state property instead?',
6831
this.getName() || 'a component'
6832
) : null);
6833
("production" !== "development" ? warning(
6834
!inst.getDefaultProps ||
6835
inst.getDefaultProps.isReactClassApproved,
6836
'getDefaultProps was defined on %s, a plain JavaScript class. ' +
6837
'This is only supported for classes created using React.createClass. ' +
6838
'Use a static property to define defaultProps instead.',
6839
this.getName() || 'a component'
6840
) : null);
6841
("production" !== "development" ? warning(
6842
!inst.propTypes,
6843
'propTypes was defined as an instance property on %s. Use a static ' +
6844
'property to define propTypes instead.',
6845
this.getName() || 'a component'
6846
) : null);
6847
("production" !== "development" ? warning(
6848
!inst.contextTypes,
6849
'contextTypes was defined as an instance property on %s. Use a ' +
6850
'static property to define contextTypes instead.',
6851
this.getName() || 'a component'
6852
) : null);
6853
("production" !== "development" ? warning(
6854
typeof inst.componentShouldUpdate !== 'function',
6855
'%s has a method called ' +
6856
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
6857
'The name is phrased as a question because the function is ' +
6858
'expected to return a value.',
6859
(this.getName() || 'A component')
6860
) : null);
6861
}
6862
6863
var initialState = inst.state;
6864
if (initialState === undefined) {
6865
inst.state = initialState = null;
6866
}
6867
("production" !== "development" ? invariant(
6868
typeof initialState === 'object' && !Array.isArray(initialState),
6869
'%s.state: must be set to an object or null',
6870
this.getName() || 'ReactCompositeComponent'
6871
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
6872
6873
this._pendingStateQueue = null;
6874
this._pendingReplaceState = false;
6875
this._pendingForceUpdate = false;
6876
6877
var childContext;
6878
var renderedElement;
6879
6880
var previouslyMounting = ReactLifeCycle.currentlyMountingInstance;
6881
ReactLifeCycle.currentlyMountingInstance = this;
6882
try {
6883
if (inst.componentWillMount) {
6884
inst.componentWillMount();
6885
// When mounting, calls to `setState` by `componentWillMount` will set
6886
// `this._pendingStateQueue` without triggering a re-render.
6887
if (this._pendingStateQueue) {
6888
inst.state = this._processPendingState(inst.props, inst.context);
6889
}
6890
}
6891
6892
childContext = this._getValidatedChildContext(context);
6893
renderedElement = this._renderValidatedComponent(childContext);
6894
} finally {
6895
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
6896
}
6897
6898
this._renderedComponent = this._instantiateReactComponent(
6899
renderedElement,
6900
this._currentElement.type // The wrapping type
6901
);
6902
6903
var markup = ReactReconciler.mountComponent(
6904
this._renderedComponent,
6905
rootID,
6906
transaction,
6907
this._mergeChildContext(context, childContext)
6908
);
6909
if (inst.componentDidMount) {
6910
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
6911
}
6912
6913
return markup;
6914
},
6915
6916
/**
6917
* Releases any resources allocated by `mountComponent`.
6918
*
6919
* @final
6920
* @internal
6921
*/
6922
unmountComponent: function() {
6923
var inst = this._instance;
6924
6925
if (inst.componentWillUnmount) {
6926
var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
6927
ReactLifeCycle.currentlyUnmountingInstance = this;
6928
try {
6929
inst.componentWillUnmount();
6930
} finally {
6931
ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
6932
}
6933
}
6934
6935
ReactReconciler.unmountComponent(this._renderedComponent);
6936
this._renderedComponent = null;
6937
6938
// Reset pending fields
6939
this._pendingStateQueue = null;
6940
this._pendingReplaceState = false;
6941
this._pendingForceUpdate = false;
6942
this._pendingCallbacks = null;
6943
this._pendingElement = null;
6944
6945
// These fields do not really need to be reset since this object is no
6946
// longer accessible.
6947
this._context = null;
6948
this._rootNodeID = null;
6949
6950
// Delete the reference from the instance to this internal representation
6951
// which allow the internals to be properly cleaned up even if the user
6952
// leaks a reference to the public instance.
6953
ReactInstanceMap.remove(inst);
6954
6955
// Some existing components rely on inst.props even after they've been
6956
// destroyed (in event handlers).
6957
// TODO: inst.props = null;
6958
// TODO: inst.state = null;
6959
// TODO: inst.context = null;
6960
},
6961
6962
/**
6963
* Schedule a partial update to the props. Only used for internal testing.
6964
*
6965
* @param {object} partialProps Subset of the next props.
6966
* @param {?function} callback Called after props are updated.
6967
* @final
6968
* @internal
6969
*/
6970
_setPropsInternal: function(partialProps, callback) {
6971
// This is a deoptimized path. We optimize for always having an element.
6972
// This creates an extra internal element.
6973
var element = this._pendingElement || this._currentElement;
6974
this._pendingElement = ReactElement.cloneAndReplaceProps(
6975
element,
6976
assign({}, element.props, partialProps)
6977
);
6978
ReactUpdates.enqueueUpdate(this, callback);
6979
},
6980
6981
/**
6982
* Filters the context object to only contain keys specified in
6983
* `contextTypes`
6984
*
6985
* @param {object} context
6986
* @return {?object}
6987
* @private
6988
*/
6989
_maskContext: function(context) {
6990
var maskedContext = null;
6991
// This really should be getting the component class for the element,
6992
// but we know that we're not going to need it for built-ins.
6993
if (typeof this._currentElement.type === 'string') {
6994
return emptyObject;
6995
}
6996
var contextTypes = this._currentElement.type.contextTypes;
6997
if (!contextTypes) {
6998
return emptyObject;
6999
}
7000
maskedContext = {};
7001
for (var contextName in contextTypes) {
7002
maskedContext[contextName] = context[contextName];
7003
}
7004
return maskedContext;
7005
},
7006
7007
/**
7008
* Filters the context object to only contain keys specified in
7009
* `contextTypes`, and asserts that they are valid.
7010
*
7011
* @param {object} context
7012
* @return {?object}
7013
* @private
7014
*/
7015
_processContext: function(context) {
7016
var maskedContext = this._maskContext(context);
7017
if ("production" !== "development") {
7018
var Component = ReactNativeComponent.getComponentClassForElement(
7019
this._currentElement
7020
);
7021
if (Component.contextTypes) {
7022
this._checkPropTypes(
7023
Component.contextTypes,
7024
maskedContext,
7025
ReactPropTypeLocations.context
7026
);
7027
}
7028
}
7029
return maskedContext;
7030
},
7031
7032
/**
7033
* @param {object} currentContext
7034
* @return {object}
7035
* @private
7036
*/
7037
_getValidatedChildContext: function(currentContext) {
7038
var inst = this._instance;
7039
var childContext = inst.getChildContext && inst.getChildContext();
7040
if (childContext) {
7041
("production" !== "development" ? invariant(
7042
typeof inst.constructor.childContextTypes === 'object',
7043
'%s.getChildContext(): childContextTypes must be defined in order to ' +
7044
'use getChildContext().',
7045
this.getName() || 'ReactCompositeComponent'
7046
) : invariant(typeof inst.constructor.childContextTypes === 'object'));
7047
if ("production" !== "development") {
7048
this._checkPropTypes(
7049
inst.constructor.childContextTypes,
7050
childContext,
7051
ReactPropTypeLocations.childContext
7052
);
7053
}
7054
for (var name in childContext) {
7055
("production" !== "development" ? invariant(
7056
name in inst.constructor.childContextTypes,
7057
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
7058
this.getName() || 'ReactCompositeComponent',
7059
name
7060
) : invariant(name in inst.constructor.childContextTypes));
7061
}
7062
return childContext;
7063
}
7064
return null;
7065
},
7066
7067
_mergeChildContext: function(currentContext, childContext) {
7068
if (childContext) {
7069
return assign({}, currentContext, childContext);
7070
}
7071
return currentContext;
7072
},
7073
7074
/**
7075
* Processes props by setting default values for unspecified props and
7076
* asserting that the props are valid. Does not mutate its argument; returns
7077
* a new props object with defaults merged in.
7078
*
7079
* @param {object} newProps
7080
* @return {object}
7081
* @private
7082
*/
7083
_processProps: function(newProps) {
7084
if ("production" !== "development") {
7085
var Component = ReactNativeComponent.getComponentClassForElement(
7086
this._currentElement
7087
);
7088
if (Component.propTypes) {
7089
this._checkPropTypes(
7090
Component.propTypes,
7091
newProps,
7092
ReactPropTypeLocations.prop
7093
);
7094
}
7095
}
7096
return newProps;
7097
},
7098
7099
/**
7100
* Assert that the props are valid
7101
*
7102
* @param {object} propTypes Map of prop name to a ReactPropType
7103
* @param {object} props
7104
* @param {string} location e.g. "prop", "context", "child context"
7105
* @private
7106
*/
7107
_checkPropTypes: function(propTypes, props, location) {
7108
// TODO: Stop validating prop types here and only use the element
7109
// validation.
7110
var componentName = this.getName();
7111
for (var propName in propTypes) {
7112
if (propTypes.hasOwnProperty(propName)) {
7113
var error;
7114
try {
7115
// This is intentionally an invariant that gets caught. It's the same
7116
// behavior as without this statement except with a better message.
7117
("production" !== "development" ? invariant(
7118
typeof propTypes[propName] === 'function',
7119
'%s: %s type `%s` is invalid; it must be a function, usually ' +
7120
'from React.PropTypes.',
7121
componentName || 'React class',
7122
ReactPropTypeLocationNames[location],
7123
propName
7124
) : invariant(typeof propTypes[propName] === 'function'));
7125
error = propTypes[propName](props, propName, componentName, location);
7126
} catch (ex) {
7127
error = ex;
7128
}
7129
if (error instanceof Error) {
7130
// We may want to extend this logic for similar errors in
7131
// React.render calls, so I'm abstracting it away into
7132
// a function to minimize refactoring in the future
7133
var addendum = getDeclarationErrorAddendum(this);
7134
7135
if (location === ReactPropTypeLocations.prop) {
7136
// Preface gives us something to blacklist in warning module
7137
("production" !== "development" ? warning(
7138
false,
7139
'Failed Composite propType: %s%s',
7140
error.message,
7141
addendum
7142
) : null);
7143
} else {
7144
("production" !== "development" ? warning(
7145
false,
7146
'Failed Context Types: %s%s',
7147
error.message,
7148
addendum
7149
) : null);
7150
}
7151
}
7152
}
7153
}
7154
},
7155
7156
receiveComponent: function(nextElement, transaction, nextContext) {
7157
var prevElement = this._currentElement;
7158
var prevContext = this._context;
7159
7160
this._pendingElement = null;
7161
7162
this.updateComponent(
7163
transaction,
7164
prevElement,
7165
nextElement,
7166
prevContext,
7167
nextContext
7168
);
7169
},
7170
7171
/**
7172
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
7173
* is set, update the component.
7174
*
7175
* @param {ReactReconcileTransaction} transaction
7176
* @internal
7177
*/
7178
performUpdateIfNecessary: function(transaction) {
7179
if (this._pendingElement != null) {
7180
ReactReconciler.receiveComponent(
7181
this,
7182
this._pendingElement || this._currentElement,
7183
transaction,
7184
this._context
7185
);
7186
}
7187
7188
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
7189
if ("production" !== "development") {
7190
ReactElementValidator.checkAndWarnForMutatedProps(
7191
this._currentElement
7192
);
7193
}
7194
7195
this.updateComponent(
7196
transaction,
7197
this._currentElement,
7198
this._currentElement,
7199
this._context,
7200
this._context
7201
);
7202
}
7203
},
7204
7205
/**
7206
* Compare two contexts, warning if they are different
7207
* TODO: Remove this check when owner-context is removed
7208
*/
7209
_warnIfContextsDiffer: function(ownerBasedContext, parentBasedContext) {
7210
ownerBasedContext = this._maskContext(ownerBasedContext);
7211
parentBasedContext = this._maskContext(parentBasedContext);
7212
var parentKeys = Object.keys(parentBasedContext).sort();
7213
var displayName = this.getName() || 'ReactCompositeComponent';
7214
for (var i = 0; i < parentKeys.length; i++) {
7215
var key = parentKeys[i];
7216
("production" !== "development" ? warning(
7217
ownerBasedContext[key] === parentBasedContext[key],
7218
'owner-based and parent-based contexts differ ' +
7219
'(values: `%s` vs `%s`) for key (%s) while mounting %s ' +
7220
'(see: http://fb.me/react-context-by-parent)',
7221
ownerBasedContext[key],
7222
parentBasedContext[key],
7223
key,
7224
displayName
7225
) : null);
7226
}
7227
},
7228
7229
/**
7230
* Perform an update to a mounted component. The componentWillReceiveProps and
7231
* shouldComponentUpdate methods are called, then (assuming the update isn't
7232
* skipped) the remaining update lifecycle methods are called and the DOM
7233
* representation is updated.
7234
*
7235
* By default, this implements React's rendering and reconciliation algorithm.
7236
* Sophisticated clients may wish to override this.
7237
*
7238
* @param {ReactReconcileTransaction} transaction
7239
* @param {ReactElement} prevParentElement
7240
* @param {ReactElement} nextParentElement
7241
* @internal
7242
* @overridable
7243
*/
7244
updateComponent: function(
7245
transaction,
7246
prevParentElement,
7247
nextParentElement,
7248
prevUnmaskedContext,
7249
nextUnmaskedContext
7250
) {
7251
var inst = this._instance;
7252
7253
var nextContext = inst.context;
7254
var nextProps = inst.props;
7255
7256
// Distinguish between a props update versus a simple state update
7257
if (prevParentElement !== nextParentElement) {
7258
nextContext = this._processContext(nextParentElement._context);
7259
nextProps = this._processProps(nextParentElement.props);
7260
7261
if ("production" !== "development") {
7262
if (nextUnmaskedContext != null) {
7263
this._warnIfContextsDiffer(
7264
nextParentElement._context,
7265
nextUnmaskedContext
7266
);
7267
}
7268
}
7269
7270
// An update here will schedule an update but immediately set
7271
// _pendingStateQueue which will ensure that any state updates gets
7272
// immediately reconciled instead of waiting for the next batch.
7273
7274
if (inst.componentWillReceiveProps) {
7275
inst.componentWillReceiveProps(nextProps, nextContext);
7276
}
7277
}
7278
7279
var nextState = this._processPendingState(nextProps, nextContext);
7280
7281
var shouldUpdate =
7282
this._pendingForceUpdate ||
7283
!inst.shouldComponentUpdate ||
7284
inst.shouldComponentUpdate(nextProps, nextState, nextContext);
7285
7286
if ("production" !== "development") {
7287
("production" !== "development" ? warning(
7288
typeof shouldUpdate !== 'undefined',
7289
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
7290
'boolean value. Make sure to return true or false.',
7291
this.getName() || 'ReactCompositeComponent'
7292
) : null);
7293
}
7294
7295
if (shouldUpdate) {
7296
this._pendingForceUpdate = false;
7297
// Will set `this.props`, `this.state` and `this.context`.
7298
this._performComponentUpdate(
7299
nextParentElement,
7300
nextProps,
7301
nextState,
7302
nextContext,
7303
transaction,
7304
nextUnmaskedContext
7305
);
7306
} else {
7307
// If it's determined that a component should not update, we still want
7308
// to set props and state but we shortcut the rest of the update.
7309
this._currentElement = nextParentElement;
7310
this._context = nextUnmaskedContext;
7311
inst.props = nextProps;
7312
inst.state = nextState;
7313
inst.context = nextContext;
7314
}
7315
},
7316
7317
_processPendingState: function(props, context) {
7318
var inst = this._instance;
7319
var queue = this._pendingStateQueue;
7320
var replace = this._pendingReplaceState;
7321
this._pendingReplaceState = false;
7322
this._pendingStateQueue = null;
7323
7324
if (!queue) {
7325
return inst.state;
7326
}
7327
7328
if (replace && queue.length === 1) {
7329
return queue[0];
7330
}
7331
7332
var nextState = assign({}, replace ? queue[0] : inst.state);
7333
for (var i = replace ? 1 : 0; i < queue.length; i++) {
7334
var partial = queue[i];
7335
assign(
7336
nextState,
7337
typeof partial === 'function' ?
7338
partial.call(inst, nextState, props, context) :
7339
partial
7340
);
7341
}
7342
7343
return nextState;
7344
},
7345
7346
/**
7347
* Merges new props and state, notifies delegate methods of update and
7348
* performs update.
7349
*
7350
* @param {ReactElement} nextElement Next element
7351
* @param {object} nextProps Next public object to set as properties.
7352
* @param {?object} nextState Next object to set as state.
7353
* @param {?object} nextContext Next public object to set as context.
7354
* @param {ReactReconcileTransaction} transaction
7355
* @param {?object} unmaskedContext
7356
* @private
7357
*/
7358
_performComponentUpdate: function(
7359
nextElement,
7360
nextProps,
7361
nextState,
7362
nextContext,
7363
transaction,
7364
unmaskedContext
7365
) {
7366
var inst = this._instance;
7367
7368
var prevProps = inst.props;
7369
var prevState = inst.state;
7370
var prevContext = inst.context;
7371
7372
if (inst.componentWillUpdate) {
7373
inst.componentWillUpdate(nextProps, nextState, nextContext);
7374
}
7375
7376
this._currentElement = nextElement;
7377
this._context = unmaskedContext;
7378
inst.props = nextProps;
7379
inst.state = nextState;
7380
inst.context = nextContext;
7381
7382
this._updateRenderedComponent(transaction, unmaskedContext);
7383
7384
if (inst.componentDidUpdate) {
7385
transaction.getReactMountReady().enqueue(
7386
inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext),
7387
inst
7388
);
7389
}
7390
},
7391
7392
/**
7393
* Call the component's `render` method and update the DOM accordingly.
7394
*
7395
* @param {ReactReconcileTransaction} transaction
7396
* @internal
7397
*/
7398
_updateRenderedComponent: function(transaction, context) {
7399
var prevComponentInstance = this._renderedComponent;
7400
var prevRenderedElement = prevComponentInstance._currentElement;
7401
var childContext = this._getValidatedChildContext();
7402
var nextRenderedElement = this._renderValidatedComponent(childContext);
7403
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
7404
ReactReconciler.receiveComponent(
7405
prevComponentInstance,
7406
nextRenderedElement,
7407
transaction,
7408
this._mergeChildContext(context, childContext)
7409
);
7410
} else {
7411
// These two IDs are actually the same! But nothing should rely on that.
7412
var thisID = this._rootNodeID;
7413
var prevComponentID = prevComponentInstance._rootNodeID;
7414
ReactReconciler.unmountComponent(prevComponentInstance);
7415
7416
this._renderedComponent = this._instantiateReactComponent(
7417
nextRenderedElement,
7418
this._currentElement.type
7419
);
7420
var nextMarkup = ReactReconciler.mountComponent(
7421
this._renderedComponent,
7422
thisID,
7423
transaction,
7424
this._mergeChildContext(context, childContext)
7425
);
7426
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
7427
}
7428
},
7429
7430
/**
7431
* @protected
7432
*/
7433
_replaceNodeWithMarkupByID: function(prevComponentID, nextMarkup) {
7434
ReactComponentEnvironment.replaceNodeWithMarkupByID(
7435
prevComponentID,
7436
nextMarkup
7437
);
7438
},
7439
7440
/**
7441
* @protected
7442
*/
7443
_renderValidatedComponentWithoutOwnerOrContext: function() {
7444
var inst = this._instance;
7445
var renderedComponent = inst.render();
7446
if ("production" !== "development") {
7447
// We allow auto-mocks to proceed as if they're returning null.
7448
if (typeof renderedComponent === 'undefined' &&
7449
inst.render._isMockFunction) {
7450
// This is probably bad practice. Consider warning here and
7451
// deprecating this convenience.
7452
renderedComponent = null;
7453
}
7454
}
7455
7456
return renderedComponent;
7457
},
7458
7459
/**
7460
* @private
7461
*/
7462
_renderValidatedComponent: function(childContext) {
7463
var renderedComponent;
7464
var previousContext = ReactContext.current;
7465
ReactContext.current = this._mergeChildContext(
7466
this._currentElement._context,
7467
childContext
7468
);
7469
ReactCurrentOwner.current = this;
7470
try {
7471
renderedComponent =
7472
this._renderValidatedComponentWithoutOwnerOrContext();
7473
} finally {
7474
ReactContext.current = previousContext;
7475
ReactCurrentOwner.current = null;
7476
}
7477
("production" !== "development" ? invariant(
7478
// TODO: An `isValidNode` function would probably be more appropriate
7479
renderedComponent === null || renderedComponent === false ||
7480
ReactElement.isValidElement(renderedComponent),
7481
'%s.render(): A valid ReactComponent must be returned. You may have ' +
7482
'returned undefined, an array or some other invalid object.',
7483
this.getName() || 'ReactCompositeComponent'
7484
) : invariant(// TODO: An `isValidNode` function would probably be more appropriate
7485
renderedComponent === null || renderedComponent === false ||
7486
ReactElement.isValidElement(renderedComponent)));
7487
return renderedComponent;
7488
},
7489
7490
/**
7491
* Lazily allocates the refs object and stores `component` as `ref`.
7492
*
7493
* @param {string} ref Reference name.
7494
* @param {component} component Component to store as `ref`.
7495
* @final
7496
* @private
7497
*/
7498
attachRef: function(ref, component) {
7499
var inst = this.getPublicInstance();
7500
var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
7501
refs[ref] = component.getPublicInstance();
7502
},
7503
7504
/**
7505
* Detaches a reference name.
7506
*
7507
* @param {string} ref Name to dereference.
7508
* @final
7509
* @private
7510
*/
7511
detachRef: function(ref) {
7512
var refs = this.getPublicInstance().refs;
7513
delete refs[ref];
7514
},
7515
7516
/**
7517
* Get a text description of the component that can be used to identify it
7518
* in error messages.
7519
* @return {string} The name or null.
7520
* @internal
7521
*/
7522
getName: function() {
7523
var type = this._currentElement.type;
7524
var constructor = this._instance && this._instance.constructor;
7525
return (
7526
type.displayName || (constructor && constructor.displayName) ||
7527
type.name || (constructor && constructor.name) ||
7528
null
7529
);
7530
},
7531
7532
/**
7533
* Get the publicly accessible representation of this component - i.e. what
7534
* is exposed by refs and returned by React.render. Can be null for stateless
7535
* components.
7536
*
7537
* @return {ReactComponent} the public component instance.
7538
* @internal
7539
*/
7540
getPublicInstance: function() {
7541
return this._instance;
7542
},
7543
7544
// Stub
7545
_instantiateReactComponent: null
7546
7547
};
7548
7549
ReactPerf.measureMethods(
7550
ReactCompositeComponentMixin,
7551
'ReactCompositeComponent',
7552
{
7553
mountComponent: 'mountComponent',
7554
updateComponent: 'updateComponent',
7555
_renderValidatedComponent: '_renderValidatedComponent'
7556
}
7557
);
7558
7559
var ReactCompositeComponent = {
7560
7561
Mixin: ReactCompositeComponentMixin
7562
7563
};
7564
7565
module.exports = ReactCompositeComponent;
7566
7567
},{"100":100,"130":130,"150":150,"167":167,"171":171,"29":29,"41":41,"44":44,"45":45,"63":63,"64":64,"73":73,"74":74,"80":80,"82":82,"84":84,"85":85,"89":89}],44:[function(_dereq_,module,exports){
7568
/**
7569
* Copyright 2013-2015, Facebook, Inc.
7570
* All rights reserved.
7571
*
7572
* This source code is licensed under the BSD-style license found in the
7573
* LICENSE file in the root directory of this source tree. An additional grant
7574
* of patent rights can be found in the PATENTS file in the same directory.
7575
*
7576
* @providesModule ReactContext
7577
*/
7578
7579
'use strict';
7580
7581
var assign = _dereq_(29);
7582
var emptyObject = _dereq_(130);
7583
var warning = _dereq_(171);
7584
7585
var didWarn = false;
7586
7587
/**
7588
* Keeps track of the current context.
7589
*
7590
* The context is automatically passed down the component ownership hierarchy
7591
* and is accessible via `this.context` on ReactCompositeComponents.
7592
*/
7593
var ReactContext = {
7594
7595
/**
7596
* @internal
7597
* @type {object}
7598
*/
7599
current: emptyObject,
7600
7601
/**
7602
* Temporarily extends the current context while executing scopedCallback.
7603
*
7604
* A typical use case might look like
7605
*
7606
* render: function() {
7607
* var children = ReactContext.withContext({foo: 'foo'}, () => (
7608
*
7609
* ));
7610
* return <div>{children}</div>;
7611
* }
7612
*
7613
* @param {object} newContext New context to merge into the existing context
7614
* @param {function} scopedCallback Callback to run with the new context
7615
* @return {ReactComponent|array<ReactComponent>}
7616
*/
7617
withContext: function(newContext, scopedCallback) {
7618
if ("production" !== "development") {
7619
("production" !== "development" ? warning(
7620
didWarn,
7621
'withContext is deprecated and will be removed in a future version. ' +
7622
'Use a wrapper component with getChildContext instead.'
7623
) : null);
7624
7625
didWarn = true;
7626
}
7627
7628
var result;
7629
var previousContext = ReactContext.current;
7630
ReactContext.current = assign({}, previousContext, newContext);
7631
try {
7632
result = scopedCallback();
7633
} finally {
7634
ReactContext.current = previousContext;
7635
}
7636
return result;
7637
}
7638
7639
};
7640
7641
module.exports = ReactContext;
7642
7643
},{"130":130,"171":171,"29":29}],45:[function(_dereq_,module,exports){
7644
/**
7645
* Copyright 2013-2015, Facebook, Inc.
7646
* All rights reserved.
7647
*
7648
* This source code is licensed under the BSD-style license found in the
7649
* LICENSE file in the root directory of this source tree. An additional grant
7650
* of patent rights can be found in the PATENTS file in the same directory.
7651
*
7652
* @providesModule ReactCurrentOwner
7653
*/
7654
7655
'use strict';
7656
7657
/**
7658
* Keeps track of the current owner.
7659
*
7660
* The current owner is the component who should own any components that are
7661
* currently being constructed.
7662
*
7663
* The depth indicate how many composite components are above this render level.
7664
*/
7665
var ReactCurrentOwner = {
7666
7667
/**
7668
* @internal
7669
* @type {ReactComponent}
7670
*/
7671
current: null
7672
7673
};
7674
7675
module.exports = ReactCurrentOwner;
7676
7677
},{}],46:[function(_dereq_,module,exports){
7678
/**
7679
* Copyright 2013-2015, Facebook, Inc.
7680
* All rights reserved.
7681
*
7682
* This source code is licensed under the BSD-style license found in the
7683
* LICENSE file in the root directory of this source tree. An additional grant
7684
* of patent rights can be found in the PATENTS file in the same directory.
7685
*
7686
* @providesModule ReactDOM
7687
* @typechecks static-only
7688
*/
7689
7690
'use strict';
7691
7692
var ReactElement = _dereq_(63);
7693
var ReactElementValidator = _dereq_(64);
7694
7695
var mapObject = _dereq_(158);
7696
7697
/**
7698
* Create a factory that creates HTML tag elements.
7699
*
7700
* @param {string} tag Tag name (e.g. `div`).
7701
* @private
7702
*/
7703
function createDOMFactory(tag) {
7704
if ("production" !== "development") {
7705
return ReactElementValidator.createFactory(tag);
7706
}
7707
return ReactElement.createFactory(tag);
7708
}
7709
7710
/**
7711
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
7712
* This is also accessible via `React.DOM`.
7713
*
7714
* @public
7715
*/
7716
var ReactDOM = mapObject({
7717
a: 'a',
7718
abbr: 'abbr',
7719
address: 'address',
7720
area: 'area',
7721
article: 'article',
7722
aside: 'aside',
7723
audio: 'audio',
7724
b: 'b',
7725
base: 'base',
7726
bdi: 'bdi',
7727
bdo: 'bdo',
7728
big: 'big',
7729
blockquote: 'blockquote',
7730
body: 'body',
7731
br: 'br',
7732
button: 'button',
7733
canvas: 'canvas',
7734
caption: 'caption',
7735
cite: 'cite',
7736
code: 'code',
7737
col: 'col',
7738
colgroup: 'colgroup',
7739
data: 'data',
7740
datalist: 'datalist',
7741
dd: 'dd',
7742
del: 'del',
7743
details: 'details',
7744
dfn: 'dfn',
7745
dialog: 'dialog',
7746
div: 'div',
7747
dl: 'dl',
7748
dt: 'dt',
7749
em: 'em',
7750
embed: 'embed',
7751
fieldset: 'fieldset',
7752
figcaption: 'figcaption',
7753
figure: 'figure',
7754
footer: 'footer',
7755
form: 'form',
7756
h1: 'h1',
7757
h2: 'h2',
7758
h3: 'h3',
7759
h4: 'h4',
7760
h5: 'h5',
7761
h6: 'h6',
7762
head: 'head',
7763
header: 'header',
7764
hr: 'hr',
7765
html: 'html',
7766
i: 'i',
7767
iframe: 'iframe',
7768
img: 'img',
7769
input: 'input',
7770
ins: 'ins',
7771
kbd: 'kbd',
7772
keygen: 'keygen',
7773
label: 'label',
7774
legend: 'legend',
7775
li: 'li',
7776
link: 'link',
7777
main: 'main',
7778
map: 'map',
7779
mark: 'mark',
7780
menu: 'menu',
7781
menuitem: 'menuitem',
7782
meta: 'meta',
7783
meter: 'meter',
7784
nav: 'nav',
7785
noscript: 'noscript',
7786
object: 'object',
7787
ol: 'ol',
7788
optgroup: 'optgroup',
7789
option: 'option',
7790
output: 'output',
7791
p: 'p',
7792
param: 'param',
7793
picture: 'picture',
7794
pre: 'pre',
7795
progress: 'progress',
7796
q: 'q',
7797
rp: 'rp',
7798
rt: 'rt',
7799
ruby: 'ruby',
7800
s: 's',
7801
samp: 'samp',
7802
script: 'script',
7803
section: 'section',
7804
select: 'select',
7805
small: 'small',
7806
source: 'source',
7807
span: 'span',
7808
strong: 'strong',
7809
style: 'style',
7810
sub: 'sub',
7811
summary: 'summary',
7812
sup: 'sup',
7813
table: 'table',
7814
tbody: 'tbody',
7815
td: 'td',
7816
textarea: 'textarea',
7817
tfoot: 'tfoot',
7818
th: 'th',
7819
thead: 'thead',
7820
time: 'time',
7821
title: 'title',
7822
tr: 'tr',
7823
track: 'track',
7824
u: 'u',
7825
ul: 'ul',
7826
'var': 'var',
7827
video: 'video',
7828
wbr: 'wbr',
7829
7830
// SVG
7831
circle: 'circle',
7832
clipPath: 'clipPath',
7833
defs: 'defs',
7834
ellipse: 'ellipse',
7835
g: 'g',
7836
line: 'line',
7837
linearGradient: 'linearGradient',
7838
mask: 'mask',
7839
path: 'path',
7840
pattern: 'pattern',
7841
polygon: 'polygon',
7842
polyline: 'polyline',
7843
radialGradient: 'radialGradient',
7844
rect: 'rect',
7845
stop: 'stop',
7846
svg: 'svg',
7847
text: 'text',
7848
tspan: 'tspan'
7849
7850
}, createDOMFactory);
7851
7852
module.exports = ReactDOM;
7853
7854
},{"158":158,"63":63,"64":64}],47:[function(_dereq_,module,exports){
7855
/**
7856
* Copyright 2013-2015, Facebook, Inc.
7857
* All rights reserved.
7858
*
7859
* This source code is licensed under the BSD-style license found in the
7860
* LICENSE file in the root directory of this source tree. An additional grant
7861
* of patent rights can be found in the PATENTS file in the same directory.
7862
*
7863
* @providesModule ReactDOMButton
7864
*/
7865
7866
'use strict';
7867
7868
var AutoFocusMixin = _dereq_(2);
7869
var ReactBrowserComponentMixin = _dereq_(32);
7870
var ReactClass = _dereq_(38);
7871
var ReactElement = _dereq_(63);
7872
7873
var keyMirror = _dereq_(156);
7874
7875
var button = ReactElement.createFactory('button');
7876
7877
var mouseListenerNames = keyMirror({
7878
onClick: true,
7879
onDoubleClick: true,
7880
onMouseDown: true,
7881
onMouseMove: true,
7882
onMouseUp: true,
7883
onClickCapture: true,
7884
onDoubleClickCapture: true,
7885
onMouseDownCapture: true,
7886
onMouseMoveCapture: true,
7887
onMouseUpCapture: true
7888
});
7889
7890
/**
7891
* Implements a <button> native component that does not receive mouse events
7892
* when `disabled` is set.
7893
*/
7894
var ReactDOMButton = ReactClass.createClass({
7895
displayName: 'ReactDOMButton',
7896
tagName: 'BUTTON',
7897
7898
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
7899
7900
render: function() {
7901
var props = {};
7902
7903
// Copy the props; except the mouse listeners if we're disabled
7904
for (var key in this.props) {
7905
if (this.props.hasOwnProperty(key) &&
7906
(!this.props.disabled || !mouseListenerNames[key])) {
7907
props[key] = this.props[key];
7908
}
7909
}
7910
7911
return button(props, this.props.children);
7912
}
7913
7914
});
7915
7916
module.exports = ReactDOMButton;
7917
7918
},{"156":156,"2":2,"32":32,"38":38,"63":63}],48:[function(_dereq_,module,exports){
7919
/**
7920
* Copyright 2013-2015, Facebook, Inc.
7921
* All rights reserved.
7922
*
7923
* This source code is licensed under the BSD-style license found in the
7924
* LICENSE file in the root directory of this source tree. An additional grant
7925
* of patent rights can be found in the PATENTS file in the same directory.
7926
*
7927
* @providesModule ReactDOMComponent
7928
* @typechecks static-only
7929
*/
7930
7931
/* global hasOwnProperty:true */
7932
7933
'use strict';
7934
7935
var CSSPropertyOperations = _dereq_(6);
7936
var DOMProperty = _dereq_(11);
7937
var DOMPropertyOperations = _dereq_(12);
7938
var ReactBrowserEventEmitter = _dereq_(33);
7939
var ReactComponentBrowserEnvironment =
7940
_dereq_(40);
7941
var ReactMount = _dereq_(77);
7942
var ReactMultiChild = _dereq_(78);
7943
var ReactPerf = _dereq_(82);
7944
7945
var assign = _dereq_(29);
7946
var escapeTextContentForBrowser = _dereq_(131);
7947
var invariant = _dereq_(150);
7948
var isEventSupported = _dereq_(151);
7949
var keyOf = _dereq_(157);
7950
var warning = _dereq_(171);
7951
7952
var deleteListener = ReactBrowserEventEmitter.deleteListener;
7953
var listenTo = ReactBrowserEventEmitter.listenTo;
7954
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
7955
7956
// For quickly matching children type, to test if can be treated as content.
7957
var CONTENT_TYPES = {'string': true, 'number': true};
7958
7959
var STYLE = keyOf({style: null});
7960
7961
var ELEMENT_NODE_TYPE = 1;
7962
7963
/**
7964
* Optionally injectable operations for mutating the DOM
7965
*/
7966
var BackendIDOperations = null;
7967
7968
/**
7969
* @param {?object} props
7970
*/
7971
function assertValidProps(props) {
7972
if (!props) {
7973
return;
7974
}
7975
// Note the use of `==` which checks for null or undefined.
7976
if (props.dangerouslySetInnerHTML != null) {
7977
("production" !== "development" ? invariant(
7978
props.children == null,
7979
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
7980
) : invariant(props.children == null));
7981
("production" !== "development" ? invariant(
7982
typeof props.dangerouslySetInnerHTML === 'object' &&
7983
'__html' in props.dangerouslySetInnerHTML,
7984
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
7985
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' +
7986
'for more information.'
7987
) : invariant(typeof props.dangerouslySetInnerHTML === 'object' &&
7988
'__html' in props.dangerouslySetInnerHTML));
7989
}
7990
if ("production" !== "development") {
7991
("production" !== "development" ? warning(
7992
props.innerHTML == null,
7993
'Directly setting property `innerHTML` is not permitted. ' +
7994
'For more information, lookup documentation on `dangerouslySetInnerHTML`.'
7995
) : null);
7996
("production" !== "development" ? warning(
7997
!props.contentEditable || props.children == null,
7998
'A component is `contentEditable` and contains `children` managed by ' +
7999
'React. It is now your responsibility to guarantee that none of ' +
8000
'those nodes are unexpectedly modified or duplicated. This is ' +
8001
'probably not intentional.'
8002
) : null);
8003
}
8004
("production" !== "development" ? invariant(
8005
props.style == null || typeof props.style === 'object',
8006
'The `style` prop expects a mapping from style properties to values, ' +
8007
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
8008
'using JSX.'
8009
) : invariant(props.style == null || typeof props.style === 'object'));
8010
}
8011
8012
function putListener(id, registrationName, listener, transaction) {
8013
if ("production" !== "development") {
8014
// IE8 has no API for event capturing and the `onScroll` event doesn't
8015
// bubble.
8016
("production" !== "development" ? warning(
8017
registrationName !== 'onScroll' || isEventSupported('scroll', true),
8018
'This browser doesn\'t support the `onScroll` event'
8019
) : null);
8020
}
8021
var container = ReactMount.findReactContainerForID(id);
8022
if (container) {
8023
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
8024
container.ownerDocument :
8025
container;
8026
listenTo(registrationName, doc);
8027
}
8028
transaction.getPutListenerQueue().enqueuePutListener(
8029
id,
8030
registrationName,
8031
listener
8032
);
8033
}
8034
8035
// For HTML, certain tags should omit their close tag. We keep a whitelist for
8036
// those special cased tags.
8037
8038
var omittedCloseTags = {
8039
'area': true,
8040
'base': true,
8041
'br': true,
8042
'col': true,
8043
'embed': true,
8044
'hr': true,
8045
'img': true,
8046
'input': true,
8047
'keygen': true,
8048
'link': true,
8049
'meta': true,
8050
'param': true,
8051
'source': true,
8052
'track': true,
8053
'wbr': true
8054
// NOTE: menuitem's close tag should be omitted, but that causes problems.
8055
};
8056
8057
// We accept any tag to be rendered but since this gets injected into abitrary
8058
// HTML, we want to make sure that it's a safe tag.
8059
// http://www.w3.org/TR/REC-xml/#NT-Name
8060
8061
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
8062
var validatedTagCache = {};
8063
var hasOwnProperty = {}.hasOwnProperty;
8064
8065
function validateDangerousTag(tag) {
8066
if (!hasOwnProperty.call(validatedTagCache, tag)) {
8067
("production" !== "development" ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
8068
validatedTagCache[tag] = true;
8069
}
8070
}
8071
8072
/**
8073
* Creates a new React class that is idempotent and capable of containing other
8074
* React components. It accepts event listeners and DOM properties that are
8075
* valid according to `DOMProperty`.
8076
*
8077
* - Event listeners: `onClick`, `onMouseDown`, etc.
8078
* - DOM properties: `className`, `name`, `title`, etc.
8079
*
8080
* The `style` property functions differently from the DOM API. It accepts an
8081
* object mapping of style properties to values.
8082
*
8083
* @constructor ReactDOMComponent
8084
* @extends ReactMultiChild
8085
*/
8086
function ReactDOMComponent(tag) {
8087
validateDangerousTag(tag);
8088
this._tag = tag;
8089
this._renderedChildren = null;
8090
this._previousStyleCopy = null;
8091
this._rootNodeID = null;
8092
}
8093
8094
ReactDOMComponent.displayName = 'ReactDOMComponent';
8095
8096
ReactDOMComponent.Mixin = {
8097
8098
construct: function(element) {
8099
this._currentElement = element;
8100
},
8101
8102
/**
8103
* Generates root tag markup then recurses. This method has side effects and
8104
* is not idempotent.
8105
*
8106
* @internal
8107
* @param {string} rootID The root DOM ID for this node.
8108
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
8109
* @return {string} The computed markup.
8110
*/
8111
mountComponent: function(rootID, transaction, context) {
8112
this._rootNodeID = rootID;
8113
assertValidProps(this._currentElement.props);
8114
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
8115
return (
8116
this._createOpenTagMarkupAndPutListeners(transaction) +
8117
this._createContentMarkup(transaction, context) +
8118
closeTag
8119
);
8120
},
8121
8122
/**
8123
* Creates markup for the open tag and all attributes.
8124
*
8125
* This method has side effects because events get registered.
8126
*
8127
* Iterating over object properties is faster than iterating over arrays.
8128
* @see http://jsperf.com/obj-vs-arr-iteration
8129
*
8130
* @private
8131
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
8132
* @return {string} Markup of opening tag.
8133
*/
8134
_createOpenTagMarkupAndPutListeners: function(transaction) {
8135
var props = this._currentElement.props;
8136
var ret = '<' + this._tag;
8137
8138
for (var propKey in props) {
8139
if (!props.hasOwnProperty(propKey)) {
8140
continue;
8141
}
8142
var propValue = props[propKey];
8143
if (propValue == null) {
8144
continue;
8145
}
8146
if (registrationNameModules.hasOwnProperty(propKey)) {
8147
putListener(this._rootNodeID, propKey, propValue, transaction);
8148
} else {
8149
if (propKey === STYLE) {
8150
if (propValue) {
8151
propValue = this._previousStyleCopy = assign({}, props.style);
8152
}
8153
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
8154
}
8155
var markup =
8156
DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
8157
if (markup) {
8158
ret += ' ' + markup;
8159
}
8160
}
8161
}
8162
8163
// For static pages, no need to put React ID and checksum. Saves lots of
8164
// bytes.
8165
if (transaction.renderToStaticMarkup) {
8166
return ret + '>';
8167
}
8168
8169
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
8170
return ret + ' ' + markupForID + '>';
8171
},
8172
8173
/**
8174
* Creates markup for the content between the tags.
8175
*
8176
* @private
8177
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
8178
* @param {object} context
8179
* @return {string} Content markup.
8180
*/
8181
_createContentMarkup: function(transaction, context) {
8182
var prefix = '';
8183
if (this._tag === 'listing' ||
8184
this._tag === 'pre' ||
8185
this._tag === 'textarea') {
8186
// Add an initial newline because browsers ignore the first newline in
8187
// a <listing>, <pre>, or <textarea> as an "authoring convenience" -- see
8188
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody.
8189
prefix = '\n';
8190
}
8191
8192
var props = this._currentElement.props;
8193
8194
// Intentional use of != to avoid catching zero/false.
8195
var innerHTML = props.dangerouslySetInnerHTML;
8196
if (innerHTML != null) {
8197
if (innerHTML.__html != null) {
8198
return prefix + innerHTML.__html;
8199
}
8200
} else {
8201
var contentToUse =
8202
CONTENT_TYPES[typeof props.children] ? props.children : null;
8203
var childrenToUse = contentToUse != null ? null : props.children;
8204
if (contentToUse != null) {
8205
return prefix + escapeTextContentForBrowser(contentToUse);
8206
} else if (childrenToUse != null) {
8207
var mountImages = this.mountChildren(
8208
childrenToUse,
8209
transaction,
8210
context
8211
);
8212
return prefix + mountImages.join('');
8213
}
8214
}
8215
return prefix;
8216
},
8217
8218
receiveComponent: function(nextElement, transaction, context) {
8219
var prevElement = this._currentElement;
8220
this._currentElement = nextElement;
8221
this.updateComponent(transaction, prevElement, nextElement, context);
8222
},
8223
8224
/**
8225
* Updates a native DOM component after it has already been allocated and
8226
* attached to the DOM. Reconciles the root DOM node, then recurses.
8227
*
8228
* @param {ReactReconcileTransaction} transaction
8229
* @param {ReactElement} prevElement
8230
* @param {ReactElement} nextElement
8231
* @internal
8232
* @overridable
8233
*/
8234
updateComponent: function(transaction, prevElement, nextElement, context) {
8235
assertValidProps(this._currentElement.props);
8236
this._updateDOMProperties(prevElement.props, transaction);
8237
this._updateDOMChildren(prevElement.props, transaction, context);
8238
},
8239
8240
/**
8241
* Reconciles the properties by detecting differences in property values and
8242
* updating the DOM as necessary. This function is probably the single most
8243
* critical path for performance optimization.
8244
*
8245
* TODO: Benchmark whether checking for changed values in memory actually
8246
* improves performance (especially statically positioned elements).
8247
* TODO: Benchmark the effects of putting this at the top since 99% of props
8248
* do not change for a given reconciliation.
8249
* TODO: Benchmark areas that can be improved with caching.
8250
*
8251
* @private
8252
* @param {object} lastProps
8253
* @param {ReactReconcileTransaction} transaction
8254
*/
8255
_updateDOMProperties: function(lastProps, transaction) {
8256
var nextProps = this._currentElement.props;
8257
var propKey;
8258
var styleName;
8259
var styleUpdates;
8260
for (propKey in lastProps) {
8261
if (nextProps.hasOwnProperty(propKey) ||
8262
!lastProps.hasOwnProperty(propKey)) {
8263
continue;
8264
}
8265
if (propKey === STYLE) {
8266
var lastStyle = this._previousStyleCopy;
8267
for (styleName in lastStyle) {
8268
if (lastStyle.hasOwnProperty(styleName)) {
8269
styleUpdates = styleUpdates || {};
8270
styleUpdates[styleName] = '';
8271
}
8272
}
8273
this._previousStyleCopy = null;
8274
} else if (registrationNameModules.hasOwnProperty(propKey)) {
8275
deleteListener(this._rootNodeID, propKey);
8276
} else if (
8277
DOMProperty.isStandardName[propKey] ||
8278
DOMProperty.isCustomAttribute(propKey)) {
8279
BackendIDOperations.deletePropertyByID(
8280
this._rootNodeID,
8281
propKey
8282
);
8283
}
8284
}
8285
for (propKey in nextProps) {
8286
var nextProp = nextProps[propKey];
8287
var lastProp = propKey === STYLE ?
8288
this._previousStyleCopy :
8289
lastProps[propKey];
8290
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
8291
continue;
8292
}
8293
if (propKey === STYLE) {
8294
if (nextProp) {
8295
nextProp = this._previousStyleCopy = assign({}, nextProp);
8296
} else {
8297
this._previousStyleCopy = null;
8298
}
8299
if (lastProp) {
8300
// Unset styles on `lastProp` but not on `nextProp`.
8301
for (styleName in lastProp) {
8302
if (lastProp.hasOwnProperty(styleName) &&
8303
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
8304
styleUpdates = styleUpdates || {};
8305
styleUpdates[styleName] = '';
8306
}
8307
}
8308
// Update styles that changed since `lastProp`.
8309
for (styleName in nextProp) {
8310
if (nextProp.hasOwnProperty(styleName) &&
8311
lastProp[styleName] !== nextProp[styleName]) {
8312
styleUpdates = styleUpdates || {};
8313
styleUpdates[styleName] = nextProp[styleName];
8314
}
8315
}
8316
} else {
8317
// Relies on `updateStylesByID` not mutating `styleUpdates`.
8318
styleUpdates = nextProp;
8319
}
8320
} else if (registrationNameModules.hasOwnProperty(propKey)) {
8321
putListener(this._rootNodeID, propKey, nextProp, transaction);
8322
} else if (
8323
DOMProperty.isStandardName[propKey] ||
8324
DOMProperty.isCustomAttribute(propKey)) {
8325
BackendIDOperations.updatePropertyByID(
8326
this._rootNodeID,
8327
propKey,
8328
nextProp
8329
);
8330
}
8331
}
8332
if (styleUpdates) {
8333
BackendIDOperations.updateStylesByID(
8334
this._rootNodeID,
8335
styleUpdates
8336
);
8337
}
8338
},
8339
8340
/**
8341
* Reconciles the children with the various properties that affect the
8342
* children content.
8343
*
8344
* @param {object} lastProps
8345
* @param {ReactReconcileTransaction} transaction
8346
*/
8347
_updateDOMChildren: function(lastProps, transaction, context) {
8348
var nextProps = this._currentElement.props;
8349
8350
var lastContent =
8351
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
8352
var nextContent =
8353
CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
8354
8355
var lastHtml =
8356
lastProps.dangerouslySetInnerHTML &&
8357
lastProps.dangerouslySetInnerHTML.__html;
8358
var nextHtml =
8359
nextProps.dangerouslySetInnerHTML &&
8360
nextProps.dangerouslySetInnerHTML.__html;
8361
8362
// Note the use of `!=` which checks for null or undefined.
8363
var lastChildren = lastContent != null ? null : lastProps.children;
8364
var nextChildren = nextContent != null ? null : nextProps.children;
8365
8366
// If we're switching from children to content/html or vice versa, remove
8367
// the old content
8368
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
8369
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
8370
if (lastChildren != null && nextChildren == null) {
8371
this.updateChildren(null, transaction, context);
8372
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
8373
this.updateTextContent('');
8374
}
8375
8376
if (nextContent != null) {
8377
if (lastContent !== nextContent) {
8378
this.updateTextContent('' + nextContent);
8379
}
8380
} else if (nextHtml != null) {
8381
if (lastHtml !== nextHtml) {
8382
BackendIDOperations.updateInnerHTMLByID(
8383
this._rootNodeID,
8384
nextHtml
8385
);
8386
}
8387
} else if (nextChildren != null) {
8388
this.updateChildren(nextChildren, transaction, context);
8389
}
8390
},
8391
8392
/**
8393
* Destroys all event registrations for this instance. Does not remove from
8394
* the DOM. That must be done by the parent.
8395
*
8396
* @internal
8397
*/
8398
unmountComponent: function() {
8399
this.unmountChildren();
8400
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
8401
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
8402
this._rootNodeID = null;
8403
}
8404
8405
};
8406
8407
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
8408
mountComponent: 'mountComponent',
8409
updateComponent: 'updateComponent'
8410
});
8411
8412
assign(
8413
ReactDOMComponent.prototype,
8414
ReactDOMComponent.Mixin,
8415
ReactMultiChild.Mixin
8416
);
8417
8418
ReactDOMComponent.injection = {
8419
injectIDOperations: function(IDOperations) {
8420
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
8421
}
8422
};
8423
8424
module.exports = ReactDOMComponent;
8425
8426
},{"11":11,"12":12,"131":131,"150":150,"151":151,"157":157,"171":171,"29":29,"33":33,"40":40,"6":6,"77":77,"78":78,"82":82}],49:[function(_dereq_,module,exports){
8427
/**
8428
* Copyright 2013-2015, Facebook, Inc.
8429
* All rights reserved.
8430
*
8431
* This source code is licensed under the BSD-style license found in the
8432
* LICENSE file in the root directory of this source tree. An additional grant
8433
* of patent rights can be found in the PATENTS file in the same directory.
8434
*
8435
* @providesModule ReactDOMForm
8436
*/
8437
8438
'use strict';
8439
8440
var EventConstants = _dereq_(16);
8441
var LocalEventTrapMixin = _dereq_(27);
8442
var ReactBrowserComponentMixin = _dereq_(32);
8443
var ReactClass = _dereq_(38);
8444
var ReactElement = _dereq_(63);
8445
8446
var form = ReactElement.createFactory('form');
8447
8448
/**
8449
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
8450
* to capture it on the <form> element itself. There are lots of hacks we could
8451
* do to accomplish this, but the most reliable is to make <form> a
8452
* composite component and use `componentDidMount` to attach the event handlers.
8453
*/
8454
var ReactDOMForm = ReactClass.createClass({
8455
displayName: 'ReactDOMForm',
8456
tagName: 'FORM',
8457
8458
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
8459
8460
render: function() {
8461
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
8462
// `jshint` fails to parse JSX so in order for linting to work in the open
8463
// source repo, we need to just use `ReactDOM.form`.
8464
return form(this.props);
8465
},
8466
8467
componentDidMount: function() {
8468
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
8469
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
8470
}
8471
});
8472
8473
module.exports = ReactDOMForm;
8474
8475
},{"16":16,"27":27,"32":32,"38":38,"63":63}],50:[function(_dereq_,module,exports){
8476
/**
8477
* Copyright 2013-2015, Facebook, Inc.
8478
* All rights reserved.
8479
*
8480
* This source code is licensed under the BSD-style license found in the
8481
* LICENSE file in the root directory of this source tree. An additional grant
8482
* of patent rights can be found in the PATENTS file in the same directory.
8483
*
8484
* @providesModule ReactDOMIDOperations
8485
* @typechecks static-only
8486
*/
8487
8488
/*jslint evil: true */
8489
8490
'use strict';
8491
8492
var CSSPropertyOperations = _dereq_(6);
8493
var DOMChildrenOperations = _dereq_(10);
8494
var DOMPropertyOperations = _dereq_(12);
8495
var ReactMount = _dereq_(77);
8496
var ReactPerf = _dereq_(82);
8497
8498
var invariant = _dereq_(150);
8499
var setInnerHTML = _dereq_(164);
8500
8501
/**
8502
* Errors for properties that should not be updated with `updatePropertyById()`.
8503
*
8504
* @type {object}
8505
* @private
8506
*/
8507
var INVALID_PROPERTY_ERRORS = {
8508
dangerouslySetInnerHTML:
8509
'`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
8510
style: '`style` must be set using `updateStylesByID()`.'
8511
};
8512
8513
/**
8514
* Operations used to process updates to DOM nodes. This is made injectable via
8515
* `ReactDOMComponent.BackendIDOperations`.
8516
*/
8517
var ReactDOMIDOperations = {
8518
8519
/**
8520
* Updates a DOM node with new property values. This should only be used to
8521
* update DOM properties in `DOMProperty`.
8522
*
8523
* @param {string} id ID of the node to update.
8524
* @param {string} name A valid property name, see `DOMProperty`.
8525
* @param {*} value New value of the property.
8526
* @internal
8527
*/
8528
updatePropertyByID: function(id, name, value) {
8529
var node = ReactMount.getNode(id);
8530
("production" !== "development" ? invariant(
8531
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
8532
'updatePropertyByID(...): %s',
8533
INVALID_PROPERTY_ERRORS[name]
8534
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
8535
8536
// If we're updating to null or undefined, we should remove the property
8537
// from the DOM node instead of inadvertantly setting to a string. This
8538
// brings us in line with the same behavior we have on initial render.
8539
if (value != null) {
8540
DOMPropertyOperations.setValueForProperty(node, name, value);
8541
} else {
8542
DOMPropertyOperations.deleteValueForProperty(node, name);
8543
}
8544
},
8545
8546
/**
8547
* Updates a DOM node to remove a property. This should only be used to remove
8548
* DOM properties in `DOMProperty`.
8549
*
8550
* @param {string} id ID of the node to update.
8551
* @param {string} name A property name to remove, see `DOMProperty`.
8552
* @internal
8553
*/
8554
deletePropertyByID: function(id, name, value) {
8555
var node = ReactMount.getNode(id);
8556
("production" !== "development" ? invariant(
8557
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
8558
'updatePropertyByID(...): %s',
8559
INVALID_PROPERTY_ERRORS[name]
8560
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
8561
DOMPropertyOperations.deleteValueForProperty(node, name, value);
8562
},
8563
8564
/**
8565
* Updates a DOM node with new style values. If a value is specified as '',
8566
* the corresponding style property will be unset.
8567
*
8568
* @param {string} id ID of the node to update.
8569
* @param {object} styles Mapping from styles to values.
8570
* @internal
8571
*/
8572
updateStylesByID: function(id, styles) {
8573
var node = ReactMount.getNode(id);
8574
CSSPropertyOperations.setValueForStyles(node, styles);
8575
},
8576
8577
/**
8578
* Updates a DOM node's innerHTML.
8579
*
8580
* @param {string} id ID of the node to update.
8581
* @param {string} html An HTML string.
8582
* @internal
8583
*/
8584
updateInnerHTMLByID: function(id, html) {
8585
var node = ReactMount.getNode(id);
8586
setInnerHTML(node, html);
8587
},
8588
8589
/**
8590
* Updates a DOM node's text content set by `props.content`.
8591
*
8592
* @param {string} id ID of the node to update.
8593
* @param {string} content Text content.
8594
* @internal
8595
*/
8596
updateTextContentByID: function(id, content) {
8597
var node = ReactMount.getNode(id);
8598
DOMChildrenOperations.updateTextContent(node, content);
8599
},
8600
8601
/**
8602
* Replaces a DOM node that exists in the document with markup.
8603
*
8604
* @param {string} id ID of child to be replaced.
8605
* @param {string} markup Dangerous markup to inject in place of child.
8606
* @internal
8607
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
8608
*/
8609
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
8610
var node = ReactMount.getNode(id);
8611
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
8612
},
8613
8614
/**
8615
* Updates a component's children by processing a series of updates.
8616
*
8617
* @param {array<object>} updates List of update configurations.
8618
* @param {array<string>} markup List of markup strings.
8619
* @internal
8620
*/
8621
dangerouslyProcessChildrenUpdates: function(updates, markup) {
8622
for (var i = 0; i < updates.length; i++) {
8623
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
8624
}
8625
DOMChildrenOperations.processUpdates(updates, markup);
8626
}
8627
};
8628
8629
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
8630
updatePropertyByID: 'updatePropertyByID',
8631
deletePropertyByID: 'deletePropertyByID',
8632
updateStylesByID: 'updateStylesByID',
8633
updateInnerHTMLByID: 'updateInnerHTMLByID',
8634
updateTextContentByID: 'updateTextContentByID',
8635
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
8636
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
8637
});
8638
8639
module.exports = ReactDOMIDOperations;
8640
8641
},{"10":10,"12":12,"150":150,"164":164,"6":6,"77":77,"82":82}],51:[function(_dereq_,module,exports){
8642
/**
8643
* Copyright 2013-2015, Facebook, Inc.
8644
* All rights reserved.
8645
*
8646
* This source code is licensed under the BSD-style license found in the
8647
* LICENSE file in the root directory of this source tree. An additional grant
8648
* of patent rights can be found in the PATENTS file in the same directory.
8649
*
8650
* @providesModule ReactDOMIframe
8651
*/
8652
8653
'use strict';
8654
8655
var EventConstants = _dereq_(16);
8656
var LocalEventTrapMixin = _dereq_(27);
8657
var ReactBrowserComponentMixin = _dereq_(32);
8658
var ReactClass = _dereq_(38);
8659
var ReactElement = _dereq_(63);
8660
8661
var iframe = ReactElement.createFactory('iframe');
8662
8663
/**
8664
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
8665
* capture it on the <iframe> element itself. There are lots of hacks we could
8666
* do to accomplish this, but the most reliable is to make <iframe> a composite
8667
* component and use `componentDidMount` to attach the event handlers.
8668
*/
8669
var ReactDOMIframe = ReactClass.createClass({
8670
displayName: 'ReactDOMIframe',
8671
tagName: 'IFRAME',
8672
8673
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
8674
8675
render: function() {
8676
return iframe(this.props);
8677
},
8678
8679
componentDidMount: function() {
8680
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
8681
}
8682
});
8683
8684
module.exports = ReactDOMIframe;
8685
8686
},{"16":16,"27":27,"32":32,"38":38,"63":63}],52:[function(_dereq_,module,exports){
8687
/**
8688
* Copyright 2013-2015, Facebook, Inc.
8689
* All rights reserved.
8690
*
8691
* This source code is licensed under the BSD-style license found in the
8692
* LICENSE file in the root directory of this source tree. An additional grant
8693
* of patent rights can be found in the PATENTS file in the same directory.
8694
*
8695
* @providesModule ReactDOMImg
8696
*/
8697
8698
'use strict';
8699
8700
var EventConstants = _dereq_(16);
8701
var LocalEventTrapMixin = _dereq_(27);
8702
var ReactBrowserComponentMixin = _dereq_(32);
8703
var ReactClass = _dereq_(38);
8704
var ReactElement = _dereq_(63);
8705
8706
var img = ReactElement.createFactory('img');
8707
8708
/**
8709
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
8710
* capture it on the <img> element itself. There are lots of hacks we could do
8711
* to accomplish this, but the most reliable is to make <img> a composite
8712
* component and use `componentDidMount` to attach the event handlers.
8713
*/
8714
var ReactDOMImg = ReactClass.createClass({
8715
displayName: 'ReactDOMImg',
8716
tagName: 'IMG',
8717
8718
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
8719
8720
render: function() {
8721
return img(this.props);
8722
},
8723
8724
componentDidMount: function() {
8725
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
8726
this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
8727
}
8728
});
8729
8730
module.exports = ReactDOMImg;
8731
8732
},{"16":16,"27":27,"32":32,"38":38,"63":63}],53:[function(_dereq_,module,exports){
8733
/**
8734
* Copyright 2013-2015, Facebook, Inc.
8735
* All rights reserved.
8736
*
8737
* This source code is licensed under the BSD-style license found in the
8738
* LICENSE file in the root directory of this source tree. An additional grant
8739
* of patent rights can be found in the PATENTS file in the same directory.
8740
*
8741
* @providesModule ReactDOMInput
8742
*/
8743
8744
'use strict';
8745
8746
var AutoFocusMixin = _dereq_(2);
8747
var DOMPropertyOperations = _dereq_(12);
8748
var LinkedValueUtils = _dereq_(26);
8749
var ReactBrowserComponentMixin = _dereq_(32);
8750
var ReactClass = _dereq_(38);
8751
var ReactElement = _dereq_(63);
8752
var ReactMount = _dereq_(77);
8753
var ReactUpdates = _dereq_(100);
8754
8755
var assign = _dereq_(29);
8756
var invariant = _dereq_(150);
8757
8758
var input = ReactElement.createFactory('input');
8759
8760
var instancesByReactID = {};
8761
8762
function forceUpdateIfMounted() {
8763
/*jshint validthis:true */
8764
if (this.isMounted()) {
8765
this.forceUpdate();
8766
}
8767
}
8768
8769
/**
8770
* Implements an <input> native component that allows setting these optional
8771
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
8772
*
8773
* If `checked` or `value` are not supplied (or null/undefined), user actions
8774
* that affect the checked state or value will trigger updates to the element.
8775
*
8776
* If they are supplied (and not null/undefined), the rendered element will not
8777
* trigger updates to the element. Instead, the props must change in order for
8778
* the rendered element to be updated.
8779
*
8780
* The rendered element will be initialized as unchecked (or `defaultChecked`)
8781
* with an empty value (or `defaultValue`).
8782
*
8783
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
8784
*/
8785
var ReactDOMInput = ReactClass.createClass({
8786
displayName: 'ReactDOMInput',
8787
tagName: 'INPUT',
8788
8789
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
8790
8791
getInitialState: function() {
8792
var defaultValue = this.props.defaultValue;
8793
return {
8794
initialChecked: this.props.defaultChecked || false,
8795
initialValue: defaultValue != null ? defaultValue : null
8796
};
8797
},
8798
8799
render: function() {
8800
// Clone `this.props` so we don't mutate the input.
8801
var props = assign({}, this.props);
8802
8803
props.defaultChecked = null;
8804
props.defaultValue = null;
8805
8806
var value = LinkedValueUtils.getValue(this);
8807
props.value = value != null ? value : this.state.initialValue;
8808
8809
var checked = LinkedValueUtils.getChecked(this);
8810
props.checked = checked != null ? checked : this.state.initialChecked;
8811
8812
props.onChange = this._handleChange;
8813
8814
return input(props, this.props.children);
8815
},
8816
8817
componentDidMount: function() {
8818
var id = ReactMount.getID(this.getDOMNode());
8819
instancesByReactID[id] = this;
8820
},
8821
8822
componentWillUnmount: function() {
8823
var rootNode = this.getDOMNode();
8824
var id = ReactMount.getID(rootNode);
8825
delete instancesByReactID[id];
8826
},
8827
8828
componentDidUpdate: function(prevProps, prevState, prevContext) {
8829
var rootNode = this.getDOMNode();
8830
if (this.props.checked != null) {
8831
DOMPropertyOperations.setValueForProperty(
8832
rootNode,
8833
'checked',
8834
this.props.checked || false
8835
);
8836
}
8837
8838
var value = LinkedValueUtils.getValue(this);
8839
if (value != null) {
8840
// Cast `value` to a string to ensure the value is set correctly. While
8841
// browsers typically do this as necessary, jsdom doesn't.
8842
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
8843
}
8844
},
8845
8846
_handleChange: function(event) {
8847
var returnValue;
8848
var onChange = LinkedValueUtils.getOnChange(this);
8849
if (onChange) {
8850
returnValue = onChange.call(this, event);
8851
}
8852
// Here we use asap to wait until all updates have propagated, which
8853
// is important when using controlled components within layers:
8854
// https://github.com/facebook/react/issues/1698
8855
ReactUpdates.asap(forceUpdateIfMounted, this);
8856
8857
var name = this.props.name;
8858
if (this.props.type === 'radio' && name != null) {
8859
var rootNode = this.getDOMNode();
8860
var queryRoot = rootNode;
8861
8862
while (queryRoot.parentNode) {
8863
queryRoot = queryRoot.parentNode;
8864
}
8865
8866
// If `rootNode.form` was non-null, then we could try `form.elements`,
8867
// but that sometimes behaves strangely in IE8. We could also try using
8868
// `form.getElementsByName`, but that will only return direct children
8869
// and won't include inputs that use the HTML5 `form=` attribute. Since
8870
// the input might not even be in a form, let's just use the global
8871
// `querySelectorAll` to ensure we don't miss anything.
8872
var group = queryRoot.querySelectorAll(
8873
'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
8874
8875
for (var i = 0, groupLen = group.length; i < groupLen; i++) {
8876
var otherNode = group[i];
8877
if (otherNode === rootNode ||
8878
otherNode.form !== rootNode.form) {
8879
continue;
8880
}
8881
var otherID = ReactMount.getID(otherNode);
8882
("production" !== "development" ? invariant(
8883
otherID,
8884
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
8885
'same `name` is not supported.'
8886
) : invariant(otherID));
8887
var otherInstance = instancesByReactID[otherID];
8888
("production" !== "development" ? invariant(
8889
otherInstance,
8890
'ReactDOMInput: Unknown radio button ID %s.',
8891
otherID
8892
) : invariant(otherInstance));
8893
// If this is a controlled radio button group, forcing the input that
8894
// was previously checked to update will cause it to be come re-checked
8895
// as appropriate.
8896
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
8897
}
8898
}
8899
8900
return returnValue;
8901
}
8902
8903
});
8904
8905
module.exports = ReactDOMInput;
8906
8907
},{"100":100,"12":12,"150":150,"2":2,"26":26,"29":29,"32":32,"38":38,"63":63,"77":77}],54:[function(_dereq_,module,exports){
8908
/**
8909
* Copyright 2013-2015, Facebook, Inc.
8910
* All rights reserved.
8911
*
8912
* This source code is licensed under the BSD-style license found in the
8913
* LICENSE file in the root directory of this source tree. An additional grant
8914
* of patent rights can be found in the PATENTS file in the same directory.
8915
*
8916
* @providesModule ReactDOMOption
8917
*/
8918
8919
'use strict';
8920
8921
var ReactBrowserComponentMixin = _dereq_(32);
8922
var ReactClass = _dereq_(38);
8923
var ReactElement = _dereq_(63);
8924
8925
var warning = _dereq_(171);
8926
8927
var option = ReactElement.createFactory('option');
8928
8929
/**
8930
* Implements an <option> native component that warns when `selected` is set.
8931
*/
8932
var ReactDOMOption = ReactClass.createClass({
8933
displayName: 'ReactDOMOption',
8934
tagName: 'OPTION',
8935
8936
mixins: [ReactBrowserComponentMixin],
8937
8938
componentWillMount: function() {
8939
// TODO (yungsters): Remove support for `selected` in <option>.
8940
if ("production" !== "development") {
8941
("production" !== "development" ? warning(
8942
this.props.selected == null,
8943
'Use the `defaultValue` or `value` props on <select> instead of ' +
8944
'setting `selected` on <option>.'
8945
) : null);
8946
}
8947
},
8948
8949
render: function() {
8950
return option(this.props, this.props.children);
8951
}
8952
8953
});
8954
8955
module.exports = ReactDOMOption;
8956
8957
},{"171":171,"32":32,"38":38,"63":63}],55:[function(_dereq_,module,exports){
8958
/**
8959
* Copyright 2013-2015, Facebook, Inc.
8960
* All rights reserved.
8961
*
8962
* This source code is licensed under the BSD-style license found in the
8963
* LICENSE file in the root directory of this source tree. An additional grant
8964
* of patent rights can be found in the PATENTS file in the same directory.
8965
*
8966
* @providesModule ReactDOMSelect
8967
*/
8968
8969
'use strict';
8970
8971
var AutoFocusMixin = _dereq_(2);
8972
var LinkedValueUtils = _dereq_(26);
8973
var ReactBrowserComponentMixin = _dereq_(32);
8974
var ReactClass = _dereq_(38);
8975
var ReactElement = _dereq_(63);
8976
var ReactUpdates = _dereq_(100);
8977
8978
var assign = _dereq_(29);
8979
8980
var select = ReactElement.createFactory('select');
8981
8982
function updateOptionsIfPendingUpdateAndMounted() {
8983
/*jshint validthis:true */
8984
if (this._pendingUpdate) {
8985
this._pendingUpdate = false;
8986
var value = LinkedValueUtils.getValue(this);
8987
if (value != null && this.isMounted()) {
8988
updateOptions(this, value);
8989
}
8990
}
8991
}
8992
8993
/**
8994
* Validation function for `value` and `defaultValue`.
8995
* @private
8996
*/
8997
function selectValueType(props, propName, componentName) {
8998
if (props[propName] == null) {
8999
return null;
9000
}
9001
if (props.multiple) {
9002
if (!Array.isArray(props[propName])) {
9003
return new Error(
9004
("The `" + propName + "` prop supplied to <select> must be an array if ") +
9005
("`multiple` is true.")
9006
);
9007
}
9008
} else {
9009
if (Array.isArray(props[propName])) {
9010
return new Error(
9011
("The `" + propName + "` prop supplied to <select> must be a scalar ") +
9012
("value if `multiple` is false.")
9013
);
9014
}
9015
}
9016
}
9017
9018
/**
9019
* @param {ReactComponent} component Instance of ReactDOMSelect
9020
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
9021
* @private
9022
*/
9023
function updateOptions(component, propValue) {
9024
var selectedValue, i, l;
9025
var options = component.getDOMNode().options;
9026
9027
if (component.props.multiple) {
9028
selectedValue = {};
9029
for (i = 0, l = propValue.length; i < l; i++) {
9030
selectedValue['' + propValue[i]] = true;
9031
}
9032
for (i = 0, l = options.length; i < l; i++) {
9033
var selected = selectedValue.hasOwnProperty(options[i].value);
9034
if (options[i].selected !== selected) {
9035
options[i].selected = selected;
9036
}
9037
}
9038
} else {
9039
// Do not set `select.value` as exact behavior isn't consistent across all
9040
// browsers for all cases.
9041
selectedValue = '' + propValue;
9042
for (i = 0, l = options.length; i < l; i++) {
9043
if (options[i].value === selectedValue) {
9044
options[i].selected = true;
9045
return;
9046
}
9047
}
9048
if (options.length) {
9049
options[0].selected = true;
9050
}
9051
}
9052
}
9053
9054
/**
9055
* Implements a <select> native component that allows optionally setting the
9056
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
9057
* stringable. If `multiple` is true, the prop must be an array of stringables.
9058
*
9059
* If `value` is not supplied (or null/undefined), user actions that change the
9060
* selected option will trigger updates to the rendered options.
9061
*
9062
* If it is supplied (and not null/undefined), the rendered options will not
9063
* update in response to user actions. Instead, the `value` prop must change in
9064
* order for the rendered options to update.
9065
*
9066
* If `defaultValue` is provided, any options with the supplied values will be
9067
* selected.
9068
*/
9069
var ReactDOMSelect = ReactClass.createClass({
9070
displayName: 'ReactDOMSelect',
9071
tagName: 'SELECT',
9072
9073
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
9074
9075
propTypes: {
9076
defaultValue: selectValueType,
9077
value: selectValueType
9078
},
9079
9080
render: function() {
9081
// Clone `this.props` so we don't mutate the input.
9082
var props = assign({}, this.props);
9083
9084
props.onChange = this._handleChange;
9085
props.value = null;
9086
9087
return select(props, this.props.children);
9088
},
9089
9090
componentWillMount: function() {
9091
this._pendingUpdate = false;
9092
},
9093
9094
componentDidMount: function() {
9095
var value = LinkedValueUtils.getValue(this);
9096
if (value != null) {
9097
updateOptions(this, value);
9098
} else if (this.props.defaultValue != null) {
9099
updateOptions(this, this.props.defaultValue);
9100
}
9101
},
9102
9103
componentDidUpdate: function(prevProps) {
9104
var value = LinkedValueUtils.getValue(this);
9105
if (value != null) {
9106
this._pendingUpdate = false;
9107
updateOptions(this, value);
9108
} else if (!prevProps.multiple !== !this.props.multiple) {
9109
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
9110
if (this.props.defaultValue != null) {
9111
updateOptions(this, this.props.defaultValue);
9112
} else {
9113
// Revert the select back to its default unselected state.
9114
updateOptions(this, this.props.multiple ? [] : '');
9115
}
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
9126
this._pendingUpdate = true;
9127
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
9128
return returnValue;
9129
}
9130
9131
});
9132
9133
module.exports = ReactDOMSelect;
9134
9135
},{"100":100,"2":2,"26":26,"29":29,"32":32,"38":38,"63":63}],56:[function(_dereq_,module,exports){
9136
/**
9137
* Copyright 2013-2015, Facebook, Inc.
9138
* All rights reserved.
9139
*
9140
* This source code is licensed under the BSD-style license found in the
9141
* LICENSE file in the root directory of this source tree. An additional grant
9142
* of patent rights can be found in the PATENTS file in the same directory.
9143
*
9144
* @providesModule ReactDOMSelection
9145
*/
9146
9147
'use strict';
9148
9149
var ExecutionEnvironment = _dereq_(22);
9150
9151
var getNodeForCharacterOffset = _dereq_(143);
9152
var getTextContentAccessor = _dereq_(145);
9153
9154
/**
9155
* While `isCollapsed` is available on the Selection object and `collapsed`
9156
* is available on the Range object, IE11 sometimes gets them wrong.
9157
* If the anchor/focus nodes and offsets are the same, the range is collapsed.
9158
*/
9159
function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
9160
return anchorNode === focusNode && anchorOffset === focusOffset;
9161
}
9162
9163
/**
9164
* Get the appropriate anchor and focus node/offset pairs for IE.
9165
*
9166
* The catch here is that IE's selection API doesn't provide information
9167
* about whether the selection is forward or backward, so we have to
9168
* behave as though it's always forward.
9169
*
9170
* IE text differs from modern selection in that it behaves as though
9171
* block elements end with a new line. This means character offsets will
9172
* differ between the two APIs.
9173
*
9174
* @param {DOMElement} node
9175
* @return {object}
9176
*/
9177
function getIEOffsets(node) {
9178
var selection = document.selection;
9179
var selectedRange = selection.createRange();
9180
var selectedLength = selectedRange.text.length;
9181
9182
// Duplicate selection so we can move range without breaking user selection.
9183
var fromStart = selectedRange.duplicate();
9184
fromStart.moveToElementText(node);
9185
fromStart.setEndPoint('EndToStart', selectedRange);
9186
9187
var startOffset = fromStart.text.length;
9188
var endOffset = startOffset + selectedLength;
9189
9190
return {
9191
start: startOffset,
9192
end: endOffset
9193
};
9194
}
9195
9196
/**
9197
* @param {DOMElement} node
9198
* @return {?object}
9199
*/
9200
function getModernOffsets(node) {
9201
var selection = window.getSelection && window.getSelection();
9202
9203
if (!selection || selection.rangeCount === 0) {
9204
return null;
9205
}
9206
9207
var anchorNode = selection.anchorNode;
9208
var anchorOffset = selection.anchorOffset;
9209
var focusNode = selection.focusNode;
9210
var focusOffset = selection.focusOffset;
9211
9212
var currentRange = selection.getRangeAt(0);
9213
9214
// If the node and offset values are the same, the selection is collapsed.
9215
// `Selection.isCollapsed` is available natively, but IE sometimes gets
9216
// this value wrong.
9217
var isSelectionCollapsed = isCollapsed(
9218
selection.anchorNode,
9219
selection.anchorOffset,
9220
selection.focusNode,
9221
selection.focusOffset
9222
);
9223
9224
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
9225
9226
var tempRange = currentRange.cloneRange();
9227
tempRange.selectNodeContents(node);
9228
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
9229
9230
var isTempRangeCollapsed = isCollapsed(
9231
tempRange.startContainer,
9232
tempRange.startOffset,
9233
tempRange.endContainer,
9234
tempRange.endOffset
9235
);
9236
9237
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
9238
var end = start + rangeLength;
9239
9240
// Detect whether the selection is backward.
9241
var detectionRange = document.createRange();
9242
detectionRange.setStart(anchorNode, anchorOffset);
9243
detectionRange.setEnd(focusNode, focusOffset);
9244
var isBackward = detectionRange.collapsed;
9245
9246
return {
9247
start: isBackward ? end : start,
9248
end: isBackward ? start : end
9249
};
9250
}
9251
9252
/**
9253
* @param {DOMElement|DOMTextNode} node
9254
* @param {object} offsets
9255
*/
9256
function setIEOffsets(node, offsets) {
9257
var range = document.selection.createRange().duplicate();
9258
var start, end;
9259
9260
if (typeof offsets.end === 'undefined') {
9261
start = offsets.start;
9262
end = start;
9263
} else if (offsets.start > offsets.end) {
9264
start = offsets.end;
9265
end = offsets.start;
9266
} else {
9267
start = offsets.start;
9268
end = offsets.end;
9269
}
9270
9271
range.moveToElementText(node);
9272
range.moveStart('character', start);
9273
range.setEndPoint('EndToStart', range);
9274
range.moveEnd('character', end - start);
9275
range.select();
9276
}
9277
9278
/**
9279
* In modern non-IE browsers, we can support both forward and backward
9280
* selections.
9281
*
9282
* Note: IE10+ supports the Selection object, but it does not support
9283
* the `extend` method, which means that even in modern IE, it's not possible
9284
* to programatically create a backward selection. Thus, for all IE
9285
* versions, we use the old IE API to create our selections.
9286
*
9287
* @param {DOMElement|DOMTextNode} node
9288
* @param {object} offsets
9289
*/
9290
function setModernOffsets(node, offsets) {
9291
if (!window.getSelection) {
9292
return;
9293
}
9294
9295
var selection = window.getSelection();
9296
var length = node[getTextContentAccessor()].length;
9297
var start = Math.min(offsets.start, length);
9298
var end = typeof offsets.end === 'undefined' ?
9299
start : Math.min(offsets.end, length);
9300
9301
// IE 11 uses modern selection, but doesn't support the extend method.
9302
// Flip backward selections, so we can set with a single range.
9303
if (!selection.extend && start > end) {
9304
var temp = end;
9305
end = start;
9306
start = temp;
9307
}
9308
9309
var startMarker = getNodeForCharacterOffset(node, start);
9310
var endMarker = getNodeForCharacterOffset(node, end);
9311
9312
if (startMarker && endMarker) {
9313
var range = document.createRange();
9314
range.setStart(startMarker.node, startMarker.offset);
9315
selection.removeAllRanges();
9316
9317
if (start > end) {
9318
selection.addRange(range);
9319
selection.extend(endMarker.node, endMarker.offset);
9320
} else {
9321
range.setEnd(endMarker.node, endMarker.offset);
9322
selection.addRange(range);
9323
}
9324
}
9325
}
9326
9327
var useIEOffsets = (
9328
ExecutionEnvironment.canUseDOM &&
9329
'selection' in document &&
9330
!('getSelection' in window)
9331
);
9332
9333
var ReactDOMSelection = {
9334
/**
9335
* @param {DOMElement} node
9336
*/
9337
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
9338
9339
/**
9340
* @param {DOMElement|DOMTextNode} node
9341
* @param {object} offsets
9342
*/
9343
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
9344
};
9345
9346
module.exports = ReactDOMSelection;
9347
9348
},{"143":143,"145":145,"22":22}],57:[function(_dereq_,module,exports){
9349
/**
9350
* Copyright 2013-2015, Facebook, Inc.
9351
* All rights reserved.
9352
*
9353
* This source code is licensed under the BSD-style license found in the
9354
* LICENSE file in the root directory of this source tree. An additional grant
9355
* of patent rights can be found in the PATENTS file in the same directory.
9356
*
9357
* @providesModule ReactDOMTextComponent
9358
* @typechecks static-only
9359
*/
9360
9361
'use strict';
9362
9363
var DOMPropertyOperations = _dereq_(12);
9364
var ReactComponentBrowserEnvironment =
9365
_dereq_(40);
9366
var ReactDOMComponent = _dereq_(48);
9367
9368
var assign = _dereq_(29);
9369
var escapeTextContentForBrowser = _dereq_(131);
9370
9371
/**
9372
* Text nodes violate a couple assumptions that React makes about components:
9373
*
9374
* - When mounting text into the DOM, adjacent text nodes are merged.
9375
* - Text nodes cannot be assigned a React root ID.
9376
*
9377
* This component is used to wrap strings in elements so that they can undergo
9378
* the same reconciliation that is applied to elements.
9379
*
9380
* TODO: Investigate representing React components in the DOM with text nodes.
9381
*
9382
* @class ReactDOMTextComponent
9383
* @extends ReactComponent
9384
* @internal
9385
*/
9386
var ReactDOMTextComponent = function(props) {
9387
// This constructor and its argument is currently used by mocks.
9388
};
9389
9390
assign(ReactDOMTextComponent.prototype, {
9391
9392
/**
9393
* @param {ReactText} text
9394
* @internal
9395
*/
9396
construct: function(text) {
9397
// TODO: This is really a ReactText (ReactNode), not a ReactElement
9398
this._currentElement = text;
9399
this._stringText = '' + text;
9400
9401
// Properties
9402
this._rootNodeID = null;
9403
this._mountIndex = 0;
9404
},
9405
9406
/**
9407
* Creates the markup for this text node. This node is not intended to have
9408
* any features besides containing text content.
9409
*
9410
* @param {string} rootID DOM ID of the root node.
9411
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
9412
* @return {string} Markup for this text node.
9413
* @internal
9414
*/
9415
mountComponent: function(rootID, transaction, context) {
9416
this._rootNodeID = rootID;
9417
var escapedText = escapeTextContentForBrowser(this._stringText);
9418
9419
if (transaction.renderToStaticMarkup) {
9420
// Normally we'd wrap this in a `span` for the reasons stated above, but
9421
// since this is a situation where React won't take over (static pages),
9422
// we can simply return the text as it is.
9423
return escapedText;
9424
}
9425
9426
return (
9427
'<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
9428
escapedText +
9429
'</span>'
9430
);
9431
},
9432
9433
/**
9434
* Updates this component by updating the text content.
9435
*
9436
* @param {ReactText} nextText The next text content
9437
* @param {ReactReconcileTransaction} transaction
9438
* @internal
9439
*/
9440
receiveComponent: function(nextText, transaction) {
9441
if (nextText !== this._currentElement) {
9442
this._currentElement = nextText;
9443
var nextStringText = '' + nextText;
9444
if (nextStringText !== this._stringText) {
9445
// TODO: Save this as pending props and use performUpdateIfNecessary
9446
// and/or updateComponent to do the actual update for consistency with
9447
// other component types?
9448
this._stringText = nextStringText;
9449
ReactDOMComponent.BackendIDOperations.updateTextContentByID(
9450
this._rootNodeID,
9451
nextStringText
9452
);
9453
}
9454
}
9455
},
9456
9457
unmountComponent: function() {
9458
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
9459
}
9460
9461
});
9462
9463
module.exports = ReactDOMTextComponent;
9464
9465
},{"12":12,"131":131,"29":29,"40":40,"48":48}],58:[function(_dereq_,module,exports){
9466
/**
9467
* Copyright 2013-2015, Facebook, Inc.
9468
* All rights reserved.
9469
*
9470
* This source code is licensed under the BSD-style license found in the
9471
* LICENSE file in the root directory of this source tree. An additional grant
9472
* of patent rights can be found in the PATENTS file in the same directory.
9473
*
9474
* @providesModule ReactDOMTextarea
9475
*/
9476
9477
'use strict';
9478
9479
var AutoFocusMixin = _dereq_(2);
9480
var DOMPropertyOperations = _dereq_(12);
9481
var LinkedValueUtils = _dereq_(26);
9482
var ReactBrowserComponentMixin = _dereq_(32);
9483
var ReactClass = _dereq_(38);
9484
var ReactElement = _dereq_(63);
9485
var ReactUpdates = _dereq_(100);
9486
9487
var assign = _dereq_(29);
9488
var invariant = _dereq_(150);
9489
9490
var warning = _dereq_(171);
9491
9492
var textarea = ReactElement.createFactory('textarea');
9493
9494
function forceUpdateIfMounted() {
9495
/*jshint validthis:true */
9496
if (this.isMounted()) {
9497
this.forceUpdate();
9498
}
9499
}
9500
9501
/**
9502
* Implements a <textarea> native component that allows setting `value`, and
9503
* `defaultValue`. This differs from the traditional DOM API because value is
9504
* usually set as PCDATA children.
9505
*
9506
* If `value` is not supplied (or null/undefined), user actions that affect the
9507
* value will trigger updates to the element.
9508
*
9509
* If `value` is supplied (and not null/undefined), the rendered element will
9510
* not trigger updates to the element. Instead, the `value` prop must change in
9511
* order for the rendered element to be updated.
9512
*
9513
* The rendered element will be initialized with an empty value, the prop
9514
* `defaultValue` if specified, or the children content (deprecated).
9515
*/
9516
var ReactDOMTextarea = ReactClass.createClass({
9517
displayName: 'ReactDOMTextarea',
9518
tagName: 'TEXTAREA',
9519
9520
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
9521
9522
getInitialState: function() {
9523
var defaultValue = this.props.defaultValue;
9524
// TODO (yungsters): Remove support for children content in <textarea>.
9525
var children = this.props.children;
9526
if (children != null) {
9527
if ("production" !== "development") {
9528
("production" !== "development" ? warning(
9529
false,
9530
'Use the `defaultValue` or `value` props instead of setting ' +
9531
'children on <textarea>.'
9532
) : null);
9533
}
9534
("production" !== "development" ? invariant(
9535
defaultValue == null,
9536
'If you supply `defaultValue` on a <textarea>, do not pass children.'
9537
) : invariant(defaultValue == null));
9538
if (Array.isArray(children)) {
9539
("production" !== "development" ? invariant(
9540
children.length <= 1,
9541
'<textarea> can only have at most one child.'
9542
) : invariant(children.length <= 1));
9543
children = children[0];
9544
}
9545
9546
defaultValue = '' + children;
9547
}
9548
if (defaultValue == null) {
9549
defaultValue = '';
9550
}
9551
var value = LinkedValueUtils.getValue(this);
9552
return {
9553
// We save the initial value so that `ReactDOMComponent` doesn't update
9554
// `textContent` (unnecessary since we update value).
9555
// The initial value can be a boolean or object so that's why it's
9556
// forced to be a string.
9557
initialValue: '' + (value != null ? value : defaultValue)
9558
};
9559
},
9560
9561
render: function() {
9562
// Clone `this.props` so we don't mutate the input.
9563
var props = assign({}, this.props);
9564
9565
("production" !== "development" ? invariant(
9566
props.dangerouslySetInnerHTML == null,
9567
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
9568
) : invariant(props.dangerouslySetInnerHTML == null));
9569
9570
props.defaultValue = null;
9571
props.value = null;
9572
props.onChange = this._handleChange;
9573
9574
// Always set children to the same thing. In IE9, the selection range will
9575
// get reset if `textContent` is mutated.
9576
return textarea(props, this.state.initialValue);
9577
},
9578
9579
componentDidUpdate: function(prevProps, prevState, prevContext) {
9580
var value = LinkedValueUtils.getValue(this);
9581
if (value != null) {
9582
var rootNode = this.getDOMNode();
9583
// Cast `value` to a string to ensure the value is set correctly. While
9584
// browsers typically do this as necessary, jsdom doesn't.
9585
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
9586
}
9587
},
9588
9589
_handleChange: function(event) {
9590
var returnValue;
9591
var onChange = LinkedValueUtils.getOnChange(this);
9592
if (onChange) {
9593
returnValue = onChange.call(this, event);
9594
}
9595
ReactUpdates.asap(forceUpdateIfMounted, this);
9596
return returnValue;
9597
}
9598
9599
});
9600
9601
module.exports = ReactDOMTextarea;
9602
9603
},{"100":100,"12":12,"150":150,"171":171,"2":2,"26":26,"29":29,"32":32,"38":38,"63":63}],59:[function(_dereq_,module,exports){
9604
/**
9605
* Copyright 2013-2015, Facebook, Inc.
9606
* All rights reserved.
9607
*
9608
* This source code is licensed under the BSD-style license found in the
9609
* LICENSE file in the root directory of this source tree. An additional grant
9610
* of patent rights can be found in the PATENTS file in the same directory.
9611
*
9612
* @providesModule ReactDefaultBatchingStrategy
9613
*/
9614
9615
'use strict';
9616
9617
var ReactUpdates = _dereq_(100);
9618
var Transaction = _dereq_(116);
9619
9620
var assign = _dereq_(29);
9621
var emptyFunction = _dereq_(129);
9622
9623
var RESET_BATCHED_UPDATES = {
9624
initialize: emptyFunction,
9625
close: function() {
9626
ReactDefaultBatchingStrategy.isBatchingUpdates = false;
9627
}
9628
};
9629
9630
var FLUSH_BATCHED_UPDATES = {
9631
initialize: emptyFunction,
9632
close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
9633
};
9634
9635
var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
9636
9637
function ReactDefaultBatchingStrategyTransaction() {
9638
this.reinitializeTransaction();
9639
}
9640
9641
assign(
9642
ReactDefaultBatchingStrategyTransaction.prototype,
9643
Transaction.Mixin,
9644
{
9645
getTransactionWrappers: function() {
9646
return TRANSACTION_WRAPPERS;
9647
}
9648
}
9649
);
9650
9651
var transaction = new ReactDefaultBatchingStrategyTransaction();
9652
9653
var ReactDefaultBatchingStrategy = {
9654
isBatchingUpdates: false,
9655
9656
/**
9657
* Call the provided function in a context within which calls to `setState`
9658
* and friends are batched such that components aren't updated unnecessarily.
9659
*/
9660
batchedUpdates: function(callback, a, b, c, d) {
9661
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
9662
9663
ReactDefaultBatchingStrategy.isBatchingUpdates = true;
9664
9665
// The code is written this way to avoid extra allocations
9666
if (alreadyBatchingUpdates) {
9667
callback(a, b, c, d);
9668
} else {
9669
transaction.perform(callback, null, a, b, c, d);
9670
}
9671
}
9672
};
9673
9674
module.exports = ReactDefaultBatchingStrategy;
9675
9676
},{"100":100,"116":116,"129":129,"29":29}],60:[function(_dereq_,module,exports){
9677
/**
9678
* Copyright 2013-2015, Facebook, Inc.
9679
* All rights reserved.
9680
*
9681
* This source code is licensed under the BSD-style license found in the
9682
* LICENSE file in the root directory of this source tree. An additional grant
9683
* of patent rights can be found in the PATENTS file in the same directory.
9684
*
9685
* @providesModule ReactDefaultInjection
9686
*/
9687
9688
'use strict';
9689
9690
var BeforeInputEventPlugin = _dereq_(3);
9691
var ChangeEventPlugin = _dereq_(8);
9692
var ClientReactRootIndex = _dereq_(9);
9693
var DefaultEventPluginOrder = _dereq_(14);
9694
var EnterLeaveEventPlugin = _dereq_(15);
9695
var ExecutionEnvironment = _dereq_(22);
9696
var HTMLDOMPropertyConfig = _dereq_(24);
9697
var MobileSafariClickEventPlugin = _dereq_(28);
9698
var ReactBrowserComponentMixin = _dereq_(32);
9699
var ReactClass = _dereq_(38);
9700
var ReactComponentBrowserEnvironment =
9701
_dereq_(40);
9702
var ReactDefaultBatchingStrategy = _dereq_(59);
9703
var ReactDOMComponent = _dereq_(48);
9704
var ReactDOMButton = _dereq_(47);
9705
var ReactDOMForm = _dereq_(49);
9706
var ReactDOMImg = _dereq_(52);
9707
var ReactDOMIDOperations = _dereq_(50);
9708
var ReactDOMIframe = _dereq_(51);
9709
var ReactDOMInput = _dereq_(53);
9710
var ReactDOMOption = _dereq_(54);
9711
var ReactDOMSelect = _dereq_(55);
9712
var ReactDOMTextarea = _dereq_(58);
9713
var ReactDOMTextComponent = _dereq_(57);
9714
var ReactElement = _dereq_(63);
9715
var ReactEventListener = _dereq_(68);
9716
var ReactInjection = _dereq_(70);
9717
var ReactInstanceHandles = _dereq_(72);
9718
var ReactMount = _dereq_(77);
9719
var ReactReconcileTransaction = _dereq_(88);
9720
var SelectEventPlugin = _dereq_(102);
9721
var ServerReactRootIndex = _dereq_(103);
9722
var SimpleEventPlugin = _dereq_(104);
9723
var SVGDOMPropertyConfig = _dereq_(101);
9724
9725
var createFullPageComponent = _dereq_(125);
9726
9727
function autoGenerateWrapperClass(type) {
9728
return ReactClass.createClass({
9729
tagName: type.toUpperCase(),
9730
render: function() {
9731
return new ReactElement(
9732
type,
9733
null,
9734
null,
9735
null,
9736
null,
9737
this.props
9738
);
9739
}
9740
});
9741
}
9742
9743
function inject() {
9744
ReactInjection.EventEmitter.injectReactEventListener(
9745
ReactEventListener
9746
);
9747
9748
/**
9749
* Inject modules for resolving DOM hierarchy and plugin ordering.
9750
*/
9751
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
9752
ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
9753
ReactInjection.EventPluginHub.injectMount(ReactMount);
9754
9755
/**
9756
* Some important event plugins included by default (without having to require
9757
* them).
9758
*/
9759
ReactInjection.EventPluginHub.injectEventPluginsByName({
9760
SimpleEventPlugin: SimpleEventPlugin,
9761
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
9762
ChangeEventPlugin: ChangeEventPlugin,
9763
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
9764
SelectEventPlugin: SelectEventPlugin,
9765
BeforeInputEventPlugin: BeforeInputEventPlugin
9766
});
9767
9768
ReactInjection.NativeComponent.injectGenericComponentClass(
9769
ReactDOMComponent
9770
);
9771
9772
ReactInjection.NativeComponent.injectTextComponentClass(
9773
ReactDOMTextComponent
9774
);
9775
9776
ReactInjection.NativeComponent.injectAutoWrapper(
9777
autoGenerateWrapperClass
9778
);
9779
9780
// This needs to happen before createFullPageComponent() otherwise the mixin
9781
// won't be included.
9782
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
9783
9784
ReactInjection.NativeComponent.injectComponentClasses({
9785
'button': ReactDOMButton,
9786
'form': ReactDOMForm,
9787
'iframe': ReactDOMIframe,
9788
'img': ReactDOMImg,
9789
'input': ReactDOMInput,
9790
'option': ReactDOMOption,
9791
'select': ReactDOMSelect,
9792
'textarea': ReactDOMTextarea,
9793
9794
'html': createFullPageComponent('html'),
9795
'head': createFullPageComponent('head'),
9796
'body': createFullPageComponent('body')
9797
});
9798
9799
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
9800
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
9801
9802
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
9803
9804
ReactInjection.Updates.injectReconcileTransaction(
9805
ReactReconcileTransaction
9806
);
9807
ReactInjection.Updates.injectBatchingStrategy(
9808
ReactDefaultBatchingStrategy
9809
);
9810
9811
ReactInjection.RootIndex.injectCreateReactRootIndex(
9812
ExecutionEnvironment.canUseDOM ?
9813
ClientReactRootIndex.createReactRootIndex :
9814
ServerReactRootIndex.createReactRootIndex
9815
);
9816
9817
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
9818
ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
9819
9820
if ("production" !== "development") {
9821
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
9822
if ((/[?&]react_perf\b/).test(url)) {
9823
var ReactDefaultPerf = _dereq_(61);
9824
ReactDefaultPerf.start();
9825
}
9826
}
9827
}
9828
9829
module.exports = {
9830
inject: inject
9831
};
9832
9833
},{"101":101,"102":102,"103":103,"104":104,"125":125,"14":14,"15":15,"22":22,"24":24,"28":28,"3":3,"32":32,"38":38,"40":40,"47":47,"48":48,"49":49,"50":50,"51":51,"52":52,"53":53,"54":54,"55":55,"57":57,"58":58,"59":59,"61":61,"63":63,"68":68,"70":70,"72":72,"77":77,"8":8,"88":88,"9":9}],61:[function(_dereq_,module,exports){
9834
/**
9835
* Copyright 2013-2015, Facebook, Inc.
9836
* All rights reserved.
9837
*
9838
* This source code is licensed under the BSD-style license found in the
9839
* LICENSE file in the root directory of this source tree. An additional grant
9840
* of patent rights can be found in the PATENTS file in the same directory.
9841
*
9842
* @providesModule ReactDefaultPerf
9843
* @typechecks static-only
9844
*/
9845
9846
'use strict';
9847
9848
var DOMProperty = _dereq_(11);
9849
var ReactDefaultPerfAnalysis = _dereq_(62);
9850
var ReactMount = _dereq_(77);
9851
var ReactPerf = _dereq_(82);
9852
9853
var performanceNow = _dereq_(162);
9854
9855
function roundFloat(val) {
9856
return Math.floor(val * 100) / 100;
9857
}
9858
9859
function addValue(obj, key, val) {
9860
obj[key] = (obj[key] || 0) + val;
9861
}
9862
9863
var ReactDefaultPerf = {
9864
_allMeasurements: [], // last item in the list is the current one
9865
_mountStack: [0],
9866
_injected: false,
9867
9868
start: function() {
9869
if (!ReactDefaultPerf._injected) {
9870
ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
9871
}
9872
9873
ReactDefaultPerf._allMeasurements.length = 0;
9874
ReactPerf.enableMeasure = true;
9875
},
9876
9877
stop: function() {
9878
ReactPerf.enableMeasure = false;
9879
},
9880
9881
getLastMeasurements: function() {
9882
return ReactDefaultPerf._allMeasurements;
9883
},
9884
9885
printExclusive: function(measurements) {
9886
measurements = measurements || ReactDefaultPerf._allMeasurements;
9887
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
9888
console.table(summary.map(function(item) {
9889
return {
9890
'Component class name': item.componentName,
9891
'Total inclusive time (ms)': roundFloat(item.inclusive),
9892
'Exclusive mount time (ms)': roundFloat(item.exclusive),
9893
'Exclusive render time (ms)': roundFloat(item.render),
9894
'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
9895
'Render time per instance (ms)': roundFloat(item.render / item.count),
9896
'Instances': item.count
9897
};
9898
}));
9899
// TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
9900
// number.
9901
},
9902
9903
printInclusive: function(measurements) {
9904
measurements = measurements || ReactDefaultPerf._allMeasurements;
9905
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
9906
console.table(summary.map(function(item) {
9907
return {
9908
'Owner > component': item.componentName,
9909
'Inclusive time (ms)': roundFloat(item.time),
9910
'Instances': item.count
9911
};
9912
}));
9913
console.log(
9914
'Total time:',
9915
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9916
);
9917
},
9918
9919
getMeasurementsSummaryMap: function(measurements) {
9920
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
9921
measurements,
9922
true
9923
);
9924
return summary.map(function(item) {
9925
return {
9926
'Owner > component': item.componentName,
9927
'Wasted time (ms)': item.time,
9928
'Instances': item.count
9929
};
9930
});
9931
},
9932
9933
printWasted: function(measurements) {
9934
measurements = measurements || ReactDefaultPerf._allMeasurements;
9935
console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
9936
console.log(
9937
'Total time:',
9938
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9939
);
9940
},
9941
9942
printDOM: function(measurements) {
9943
measurements = measurements || ReactDefaultPerf._allMeasurements;
9944
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
9945
console.table(summary.map(function(item) {
9946
var result = {};
9947
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
9948
result['type'] = item.type;
9949
result['args'] = JSON.stringify(item.args);
9950
return result;
9951
}));
9952
console.log(
9953
'Total time:',
9954
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
9955
);
9956
},
9957
9958
_recordWrite: function(id, fnName, totalTime, args) {
9959
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
9960
var writes =
9961
ReactDefaultPerf
9962
._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
9963
.writes;
9964
writes[id] = writes[id] || [];
9965
writes[id].push({
9966
type: fnName,
9967
time: totalTime,
9968
args: args
9969
});
9970
},
9971
9972
measure: function(moduleName, fnName, func) {
9973
return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
9974
var totalTime;
9975
var rv;
9976
var start;
9977
9978
if (fnName === '_renderNewRootComponent' ||
9979
fnName === 'flushBatchedUpdates') {
9980
// A "measurement" is a set of metrics recorded for each flush. We want
9981
// to group the metrics for a given flush together so we can look at the
9982
// components that rendered and the DOM operations that actually
9983
// happened to determine the amount of "wasted work" performed.
9984
ReactDefaultPerf._allMeasurements.push({
9985
exclusive: {},
9986
inclusive: {},
9987
render: {},
9988
counts: {},
9989
writes: {},
9990
displayNames: {},
9991
totalTime: 0
9992
});
9993
start = performanceNow();
9994
rv = func.apply(this, args);
9995
ReactDefaultPerf._allMeasurements[
9996
ReactDefaultPerf._allMeasurements.length - 1
9997
].totalTime = performanceNow() - start;
9998
return rv;
9999
} else if (fnName === '_mountImageIntoNode' ||
10000
moduleName === 'ReactDOMIDOperations') {
10001
start = performanceNow();
10002
rv = func.apply(this, args);
10003
totalTime = performanceNow() - start;
10004
10005
if (fnName === '_mountImageIntoNode') {
10006
var mountID = ReactMount.getID(args[1]);
10007
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
10008
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
10009
// special format
10010
args[0].forEach(function(update) {
10011
var writeArgs = {};
10012
if (update.fromIndex !== null) {
10013
writeArgs.fromIndex = update.fromIndex;
10014
}
10015
if (update.toIndex !== null) {
10016
writeArgs.toIndex = update.toIndex;
10017
}
10018
if (update.textContent !== null) {
10019
writeArgs.textContent = update.textContent;
10020
}
10021
if (update.markupIndex !== null) {
10022
writeArgs.markup = args[1][update.markupIndex];
10023
}
10024
ReactDefaultPerf._recordWrite(
10025
update.parentID,
10026
update.type,
10027
totalTime,
10028
writeArgs
10029
);
10030
});
10031
} else {
10032
// basic format
10033
ReactDefaultPerf._recordWrite(
10034
args[0],
10035
fnName,
10036
totalTime,
10037
Array.prototype.slice.call(args, 1)
10038
);
10039
}
10040
return rv;
10041
} else if (moduleName === 'ReactCompositeComponent' && (
10042
(// TODO: receiveComponent()?
10043
(fnName === 'mountComponent' ||
10044
fnName === 'updateComponent' || fnName === '_renderValidatedComponent')))) {
10045
10046
if (typeof this._currentElement.type === 'string') {
10047
return func.apply(this, args);
10048
}
10049
10050
var rootNodeID = fnName === 'mountComponent' ?
10051
args[0] :
10052
this._rootNodeID;
10053
var isRender = fnName === '_renderValidatedComponent';
10054
var isMount = fnName === 'mountComponent';
10055
10056
var mountStack = ReactDefaultPerf._mountStack;
10057
var entry = ReactDefaultPerf._allMeasurements[
10058
ReactDefaultPerf._allMeasurements.length - 1
10059
];
10060
10061
if (isRender) {
10062
addValue(entry.counts, rootNodeID, 1);
10063
} else if (isMount) {
10064
mountStack.push(0);
10065
}
10066
10067
start = performanceNow();
10068
rv = func.apply(this, args);
10069
totalTime = performanceNow() - start;
10070
10071
if (isRender) {
10072
addValue(entry.render, rootNodeID, totalTime);
10073
} else if (isMount) {
10074
var subMountTime = mountStack.pop();
10075
mountStack[mountStack.length - 1] += totalTime;
10076
addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
10077
addValue(entry.inclusive, rootNodeID, totalTime);
10078
} else {
10079
addValue(entry.inclusive, rootNodeID, totalTime);
10080
}
10081
10082
entry.displayNames[rootNodeID] = {
10083
current: this.getName(),
10084
owner: this._currentElement._owner ?
10085
this._currentElement._owner.getName() :
10086
'<root>'
10087
};
10088
10089
return rv;
10090
} else {
10091
return func.apply(this, args);
10092
}
10093
};
10094
}
10095
};
10096
10097
module.exports = ReactDefaultPerf;
10098
10099
},{"11":11,"162":162,"62":62,"77":77,"82":82}],62:[function(_dereq_,module,exports){
10100
/**
10101
* Copyright 2013-2015, Facebook, Inc.
10102
* All rights reserved.
10103
*
10104
* This source code is licensed under the BSD-style license found in the
10105
* LICENSE file in the root directory of this source tree. An additional grant
10106
* of patent rights can be found in the PATENTS file in the same directory.
10107
*
10108
* @providesModule ReactDefaultPerfAnalysis
10109
*/
10110
10111
var assign = _dereq_(29);
10112
10113
// Don't try to save users less than 1.2ms (a number I made up)
10114
var DONT_CARE_THRESHOLD = 1.2;
10115
var DOM_OPERATION_TYPES = {
10116
'_mountImageIntoNode': 'set innerHTML',
10117
INSERT_MARKUP: 'set innerHTML',
10118
MOVE_EXISTING: 'move',
10119
REMOVE_NODE: 'remove',
10120
TEXT_CONTENT: 'set textContent',
10121
'updatePropertyByID': 'update attribute',
10122
'deletePropertyByID': 'delete attribute',
10123
'updateStylesByID': 'update styles',
10124
'updateInnerHTMLByID': 'set innerHTML',
10125
'dangerouslyReplaceNodeWithMarkupByID': 'replace'
10126
};
10127
10128
function getTotalTime(measurements) {
10129
// TODO: return number of DOM ops? could be misleading.
10130
// TODO: measure dropped frames after reconcile?
10131
// TODO: log total time of each reconcile and the top-level component
10132
// class that triggered it.
10133
var totalTime = 0;
10134
for (var i = 0; i < measurements.length; i++) {
10135
var measurement = measurements[i];
10136
totalTime += measurement.totalTime;
10137
}
10138
return totalTime;
10139
}
10140
10141
function getDOMSummary(measurements) {
10142
var items = [];
10143
for (var i = 0; i < measurements.length; i++) {
10144
var measurement = measurements[i];
10145
var id;
10146
10147
for (id in measurement.writes) {
10148
measurement.writes[id].forEach(function(write) {
10149
items.push({
10150
id: id,
10151
type: DOM_OPERATION_TYPES[write.type] || write.type,
10152
args: write.args
10153
});
10154
});
10155
}
10156
}
10157
return items;
10158
}
10159
10160
function getExclusiveSummary(measurements) {
10161
var candidates = {};
10162
var displayName;
10163
10164
for (var i = 0; i < measurements.length; i++) {
10165
var measurement = measurements[i];
10166
var allIDs = assign(
10167
{},
10168
measurement.exclusive,
10169
measurement.inclusive
10170
);
10171
10172
for (var id in allIDs) {
10173
displayName = measurement.displayNames[id].current;
10174
10175
candidates[displayName] = candidates[displayName] || {
10176
componentName: displayName,
10177
inclusive: 0,
10178
exclusive: 0,
10179
render: 0,
10180
count: 0
10181
};
10182
if (measurement.render[id]) {
10183
candidates[displayName].render += measurement.render[id];
10184
}
10185
if (measurement.exclusive[id]) {
10186
candidates[displayName].exclusive += measurement.exclusive[id];
10187
}
10188
if (measurement.inclusive[id]) {
10189
candidates[displayName].inclusive += measurement.inclusive[id];
10190
}
10191
if (measurement.counts[id]) {
10192
candidates[displayName].count += measurement.counts[id];
10193
}
10194
}
10195
}
10196
10197
// Now make a sorted array with the results.
10198
var arr = [];
10199
for (displayName in candidates) {
10200
if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
10201
arr.push(candidates[displayName]);
10202
}
10203
}
10204
10205
arr.sort(function(a, b) {
10206
return b.exclusive - a.exclusive;
10207
});
10208
10209
return arr;
10210
}
10211
10212
function getInclusiveSummary(measurements, onlyClean) {
10213
var candidates = {};
10214
var inclusiveKey;
10215
10216
for (var i = 0; i < measurements.length; i++) {
10217
var measurement = measurements[i];
10218
var allIDs = assign(
10219
{},
10220
measurement.exclusive,
10221
measurement.inclusive
10222
);
10223
var cleanComponents;
10224
10225
if (onlyClean) {
10226
cleanComponents = getUnchangedComponents(measurement);
10227
}
10228
10229
for (var id in allIDs) {
10230
if (onlyClean && !cleanComponents[id]) {
10231
continue;
10232
}
10233
10234
var displayName = measurement.displayNames[id];
10235
10236
// Inclusive time is not useful for many components without knowing where
10237
// they are instantiated. So we aggregate inclusive time with both the
10238
// owner and current displayName as the key.
10239
inclusiveKey = displayName.owner + ' > ' + displayName.current;
10240
10241
candidates[inclusiveKey] = candidates[inclusiveKey] || {
10242
componentName: inclusiveKey,
10243
time: 0,
10244
count: 0
10245
};
10246
10247
if (measurement.inclusive[id]) {
10248
candidates[inclusiveKey].time += measurement.inclusive[id];
10249
}
10250
if (measurement.counts[id]) {
10251
candidates[inclusiveKey].count += measurement.counts[id];
10252
}
10253
}
10254
}
10255
10256
// Now make a sorted array with the results.
10257
var arr = [];
10258
for (inclusiveKey in candidates) {
10259
if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
10260
arr.push(candidates[inclusiveKey]);
10261
}
10262
}
10263
10264
arr.sort(function(a, b) {
10265
return b.time - a.time;
10266
});
10267
10268
return arr;
10269
}
10270
10271
function getUnchangedComponents(measurement) {
10272
// For a given reconcile, look at which components did not actually
10273
// render anything to the DOM and return a mapping of their ID to
10274
// the amount of time it took to render the entire subtree.
10275
var cleanComponents = {};
10276
var dirtyLeafIDs = Object.keys(measurement.writes);
10277
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
10278
10279
for (var id in allIDs) {
10280
var isDirty = false;
10281
// For each component that rendered, see if a component that triggered
10282
// a DOM op is in its subtree.
10283
for (var i = 0; i < dirtyLeafIDs.length; i++) {
10284
if (dirtyLeafIDs[i].indexOf(id) === 0) {
10285
isDirty = true;
10286
break;
10287
}
10288
}
10289
if (!isDirty && measurement.counts[id] > 0) {
10290
cleanComponents[id] = true;
10291
}
10292
}
10293
return cleanComponents;
10294
}
10295
10296
var ReactDefaultPerfAnalysis = {
10297
getExclusiveSummary: getExclusiveSummary,
10298
getInclusiveSummary: getInclusiveSummary,
10299
getDOMSummary: getDOMSummary,
10300
getTotalTime: getTotalTime
10301
};
10302
10303
module.exports = ReactDefaultPerfAnalysis;
10304
10305
},{"29":29}],63:[function(_dereq_,module,exports){
10306
/**
10307
* Copyright 2014-2015, Facebook, Inc.
10308
* All rights reserved.
10309
*
10310
* This source code is licensed under the BSD-style license found in the
10311
* LICENSE file in the root directory of this source tree. An additional grant
10312
* of patent rights can be found in the PATENTS file in the same directory.
10313
*
10314
* @providesModule ReactElement
10315
*/
10316
10317
'use strict';
10318
10319
var ReactContext = _dereq_(44);
10320
var ReactCurrentOwner = _dereq_(45);
10321
10322
var assign = _dereq_(29);
10323
var warning = _dereq_(171);
10324
10325
var RESERVED_PROPS = {
10326
key: true,
10327
ref: true
10328
};
10329
10330
/**
10331
* Warn for mutations.
10332
*
10333
* @internal
10334
* @param {object} object
10335
* @param {string} key
10336
*/
10337
function defineWarningProperty(object, key) {
10338
Object.defineProperty(object, key, {
10339
10340
configurable: false,
10341
enumerable: true,
10342
10343
get: function() {
10344
if (!this._store) {
10345
return null;
10346
}
10347
return this._store[key];
10348
},
10349
10350
set: function(value) {
10351
("production" !== "development" ? warning(
10352
false,
10353
'Don\'t set the %s property of the React element. Instead, ' +
10354
'specify the correct value when initially creating the element.',
10355
key
10356
) : null);
10357
this._store[key] = value;
10358
}
10359
10360
});
10361
}
10362
10363
/**
10364
* This is updated to true if the membrane is successfully created.
10365
*/
10366
var useMutationMembrane = false;
10367
10368
/**
10369
* Warn for mutations.
10370
*
10371
* @internal
10372
* @param {object} element
10373
*/
10374
function defineMutationMembrane(prototype) {
10375
try {
10376
var pseudoFrozenProperties = {
10377
props: true
10378
};
10379
for (var key in pseudoFrozenProperties) {
10380
defineWarningProperty(prototype, key);
10381
}
10382
useMutationMembrane = true;
10383
} catch (x) {
10384
// IE will fail on defineProperty
10385
}
10386
}
10387
10388
/**
10389
* Base constructor for all React elements. This is only used to make this
10390
* work with a dynamic instanceof check. Nothing should live on this prototype.
10391
*
10392
* @param {*} type
10393
* @param {string|object} ref
10394
* @param {*} key
10395
* @param {*} props
10396
* @internal
10397
*/
10398
var ReactElement = function(type, key, ref, owner, context, props) {
10399
// Built-in properties that belong on the element
10400
this.type = type;
10401
this.key = key;
10402
this.ref = ref;
10403
10404
// Record the component responsible for creating this element.
10405
this._owner = owner;
10406
10407
// TODO: Deprecate withContext, and then the context becomes accessible
10408
// through the owner.
10409
this._context = context;
10410
10411
if ("production" !== "development") {
10412
// The validation flag and props are currently mutative. We put them on
10413
// an external backing store so that we can freeze the whole object.
10414
// This can be replaced with a WeakMap once they are implemented in
10415
// commonly used development environments.
10416
this._store = {props: props, originalProps: assign({}, props)};
10417
10418
// To make comparing ReactElements easier for testing purposes, we make
10419
// the validation flag non-enumerable (where possible, which should
10420
// include every environment we run tests in), so the test framework
10421
// ignores it.
10422
try {
10423
Object.defineProperty(this._store, 'validated', {
10424
configurable: false,
10425
enumerable: false,
10426
writable: true
10427
});
10428
} catch (x) {
10429
}
10430
this._store.validated = false;
10431
10432
// We're not allowed to set props directly on the object so we early
10433
// return and rely on the prototype membrane to forward to the backing
10434
// store.
10435
if (useMutationMembrane) {
10436
Object.freeze(this);
10437
return;
10438
}
10439
}
10440
10441
this.props = props;
10442
};
10443
10444
// We intentionally don't expose the function on the constructor property.
10445
// ReactElement should be indistinguishable from a plain object.
10446
ReactElement.prototype = {
10447
_isReactElement: true
10448
};
10449
10450
if ("production" !== "development") {
10451
defineMutationMembrane(ReactElement.prototype);
10452
}
10453
10454
ReactElement.createElement = function(type, config, children) {
10455
var propName;
10456
10457
// Reserved names are extracted
10458
var props = {};
10459
10460
var key = null;
10461
var ref = null;
10462
10463
if (config != null) {
10464
ref = config.ref === undefined ? null : config.ref;
10465
key = config.key === undefined ? null : '' + config.key;
10466
// Remaining properties are added to a new props object
10467
for (propName in config) {
10468
if (config.hasOwnProperty(propName) &&
10469
!RESERVED_PROPS.hasOwnProperty(propName)) {
10470
props[propName] = config[propName];
10471
}
10472
}
10473
}
10474
10475
// Children can be more than one argument, and those are transferred onto
10476
// the newly allocated props object.
10477
var childrenLength = arguments.length - 2;
10478
if (childrenLength === 1) {
10479
props.children = children;
10480
} else if (childrenLength > 1) {
10481
var childArray = Array(childrenLength);
10482
for (var i = 0; i < childrenLength; i++) {
10483
childArray[i] = arguments[i + 2];
10484
}
10485
props.children = childArray;
10486
}
10487
10488
// Resolve default props
10489
if (type && type.defaultProps) {
10490
var defaultProps = type.defaultProps;
10491
for (propName in defaultProps) {
10492
if (typeof props[propName] === 'undefined') {
10493
props[propName] = defaultProps[propName];
10494
}
10495
}
10496
}
10497
10498
return new ReactElement(
10499
type,
10500
key,
10501
ref,
10502
ReactCurrentOwner.current,
10503
ReactContext.current,
10504
props
10505
);
10506
};
10507
10508
ReactElement.createFactory = function(type) {
10509
var factory = ReactElement.createElement.bind(null, type);
10510
// Expose the type on the factory and the prototype so that it can be
10511
// easily accessed on elements. E.g. <Foo />.type === Foo.type.
10512
// This should not be named `constructor` since this may not be the function
10513
// that created the element, and it may not even be a constructor.
10514
// Legacy hook TODO: Warn if this is accessed
10515
factory.type = type;
10516
return factory;
10517
};
10518
10519
ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
10520
var newElement = new ReactElement(
10521
oldElement.type,
10522
oldElement.key,
10523
oldElement.ref,
10524
oldElement._owner,
10525
oldElement._context,
10526
newProps
10527
);
10528
10529
if ("production" !== "development") {
10530
// If the key on the original is valid, then the clone is valid
10531
newElement._store.validated = oldElement._store.validated;
10532
}
10533
return newElement;
10534
};
10535
10536
ReactElement.cloneElement = function(element, config, children) {
10537
var propName;
10538
10539
// Original props are copied
10540
var props = assign({}, element.props);
10541
10542
// Reserved names are extracted
10543
var key = element.key;
10544
var ref = element.ref;
10545
10546
// Owner will be preserved, unless ref is overridden
10547
var owner = element._owner;
10548
10549
if (config != null) {
10550
if (config.ref !== undefined) {
10551
// Silently steal the ref from the parent.
10552
ref = config.ref;
10553
owner = ReactCurrentOwner.current;
10554
}
10555
if (config.key !== undefined) {
10556
key = '' + config.key;
10557
}
10558
// Remaining properties override existing props
10559
for (propName in config) {
10560
if (config.hasOwnProperty(propName) &&
10561
!RESERVED_PROPS.hasOwnProperty(propName)) {
10562
props[propName] = config[propName];
10563
}
10564
}
10565
}
10566
10567
// Children can be more than one argument, and those are transferred onto
10568
// the newly allocated props object.
10569
var childrenLength = arguments.length - 2;
10570
if (childrenLength === 1) {
10571
props.children = children;
10572
} else if (childrenLength > 1) {
10573
var childArray = Array(childrenLength);
10574
for (var i = 0; i < childrenLength; i++) {
10575
childArray[i] = arguments[i + 2];
10576
}
10577
props.children = childArray;
10578
}
10579
10580
return new ReactElement(
10581
element.type,
10582
key,
10583
ref,
10584
owner,
10585
element._context,
10586
props
10587
);
10588
};
10589
10590
/**
10591
* @param {?object} object
10592
* @return {boolean} True if `object` is a valid component.
10593
* @final
10594
*/
10595
ReactElement.isValidElement = function(object) {
10596
// ReactTestUtils is often used outside of beforeEach where as React is
10597
// within it. This leads to two different instances of React on the same
10598
// page. To identify a element from a different React instance we use
10599
// a flag instead of an instanceof check.
10600
var isElement = !!(object && object._isReactElement);
10601
// if (isElement && !(object instanceof ReactElement)) {
10602
// This is an indicator that you're using multiple versions of React at the
10603
// same time. This will screw with ownership and stuff. Fix it, please.
10604
// TODO: We could possibly warn here.
10605
// }
10606
return isElement;
10607
};
10608
10609
module.exports = ReactElement;
10610
10611
},{"171":171,"29":29,"44":44,"45":45}],64:[function(_dereq_,module,exports){
10612
/**
10613
* Copyright 2014-2015, Facebook, Inc.
10614
* All rights reserved.
10615
*
10616
* This source code is licensed under the BSD-style license found in the
10617
* LICENSE file in the root directory of this source tree. An additional grant
10618
* of patent rights can be found in the PATENTS file in the same directory.
10619
*
10620
* @providesModule ReactElementValidator
10621
*/
10622
10623
/**
10624
* ReactElementValidator provides a wrapper around a element factory
10625
* which validates the props passed to the element. This is intended to be
10626
* used only in DEV and could be replaced by a static type checker for languages
10627
* that support it.
10628
*/
10629
10630
'use strict';
10631
10632
var ReactElement = _dereq_(63);
10633
var ReactFragment = _dereq_(69);
10634
var ReactPropTypeLocations = _dereq_(85);
10635
var ReactPropTypeLocationNames = _dereq_(84);
10636
var ReactCurrentOwner = _dereq_(45);
10637
var ReactNativeComponent = _dereq_(80);
10638
10639
var getIteratorFn = _dereq_(141);
10640
var invariant = _dereq_(150);
10641
var warning = _dereq_(171);
10642
10643
function getDeclarationErrorAddendum() {
10644
if (ReactCurrentOwner.current) {
10645
var name = ReactCurrentOwner.current.getName();
10646
if (name) {
10647
return ' Check the render method of `' + name + '`.';
10648
}
10649
}
10650
return '';
10651
}
10652
10653
/**
10654
* Warn if there's no key explicitly set on dynamic arrays of children or
10655
* object keys are not valid. This allows us to keep track of children between
10656
* updates.
10657
*/
10658
var ownerHasKeyUseWarning = {};
10659
10660
var loggedTypeFailures = {};
10661
10662
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
10663
10664
/**
10665
* Gets the instance's name for use in warnings.
10666
*
10667
* @internal
10668
* @return {?string} Display name or undefined
10669
*/
10670
function getName(instance) {
10671
var publicInstance = instance && instance.getPublicInstance();
10672
if (!publicInstance) {
10673
return undefined;
10674
}
10675
var constructor = publicInstance.constructor;
10676
if (!constructor) {
10677
return undefined;
10678
}
10679
return constructor.displayName || constructor.name || undefined;
10680
}
10681
10682
/**
10683
* Gets the current owner's displayName for use in warnings.
10684
*
10685
* @internal
10686
* @return {?string} Display name or undefined
10687
*/
10688
function getCurrentOwnerDisplayName() {
10689
var current = ReactCurrentOwner.current;
10690
return (
10691
current && getName(current) || undefined
10692
);
10693
}
10694
10695
/**
10696
* Warn if the element doesn't have an explicit key assigned to it.
10697
* This element is in an array. The array could grow and shrink or be
10698
* reordered. All children that haven't already been validated are required to
10699
* have a "key" property assigned to it.
10700
*
10701
* @internal
10702
* @param {ReactElement} element Element that requires a key.
10703
* @param {*} parentType element's parent's type.
10704
*/
10705
function validateExplicitKey(element, parentType) {
10706
if (element._store.validated || element.key != null) {
10707
return;
10708
}
10709
element._store.validated = true;
10710
10711
warnAndMonitorForKeyUse(
10712
'Each child in an array or iterator should have a unique "key" prop.',
10713
element,
10714
parentType
10715
);
10716
}
10717
10718
/**
10719
* Warn if the key is being defined as an object property but has an incorrect
10720
* value.
10721
*
10722
* @internal
10723
* @param {string} name Property name of the key.
10724
* @param {ReactElement} element Component that requires a key.
10725
* @param {*} parentType element's parent's type.
10726
*/
10727
function validatePropertyKey(name, element, parentType) {
10728
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
10729
return;
10730
}
10731
warnAndMonitorForKeyUse(
10732
'Child objects should have non-numeric keys so ordering is preserved.',
10733
element,
10734
parentType
10735
);
10736
}
10737
10738
/**
10739
* Shared warning and monitoring code for the key warnings.
10740
*
10741
* @internal
10742
* @param {string} message The base warning that gets output.
10743
* @param {ReactElement} element Component that requires a key.
10744
* @param {*} parentType element's parent's type.
10745
*/
10746
function warnAndMonitorForKeyUse(message, element, parentType) {
10747
var ownerName = getCurrentOwnerDisplayName();
10748
var parentName = typeof parentType === 'string' ?
10749
parentType : parentType.displayName || parentType.name;
10750
10751
var useName = ownerName || parentName;
10752
var memoizer = ownerHasKeyUseWarning[message] || (
10753
(ownerHasKeyUseWarning[message] = {})
10754
);
10755
if (memoizer.hasOwnProperty(useName)) {
10756
return;
10757
}
10758
memoizer[useName] = true;
10759
10760
var parentOrOwnerAddendum =
10761
ownerName ? (" Check the render method of " + ownerName + ".") :
10762
parentName ? (" Check the React.render call using <" + parentName + ">.") :
10763
'';
10764
10765
// Usually the current owner is the offender, but if it accepts children as a
10766
// property, it may be the creator of the child that's responsible for
10767
// assigning it a key.
10768
var childOwnerAddendum = '';
10769
if (element &&
10770
element._owner &&
10771
element._owner !== ReactCurrentOwner.current) {
10772
// Name of the component that originally created this child.
10773
var childOwnerName = getName(element._owner);
10774
10775
childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
10776
}
10777
10778
("production" !== "development" ? warning(
10779
false,
10780
message + '%s%s See https://fb.me/react-warning-keys for more information.',
10781
parentOrOwnerAddendum,
10782
childOwnerAddendum
10783
) : null);
10784
}
10785
10786
/**
10787
* Ensure that every element either is passed in a static location, in an
10788
* array with an explicit keys property defined, or in an object literal
10789
* with valid key property.
10790
*
10791
* @internal
10792
* @param {ReactNode} node Statically passed child of any type.
10793
* @param {*} parentType node's parent's type.
10794
*/
10795
function validateChildKeys(node, parentType) {
10796
if (Array.isArray(node)) {
10797
for (var i = 0; i < node.length; i++) {
10798
var child = node[i];
10799
if (ReactElement.isValidElement(child)) {
10800
validateExplicitKey(child, parentType);
10801
}
10802
}
10803
} else if (ReactElement.isValidElement(node)) {
10804
// This element was passed in a valid location.
10805
node._store.validated = true;
10806
} else if (node) {
10807
var iteratorFn = getIteratorFn(node);
10808
// Entry iterators provide implicit keys.
10809
if (iteratorFn) {
10810
if (iteratorFn !== node.entries) {
10811
var iterator = iteratorFn.call(node);
10812
var step;
10813
while (!(step = iterator.next()).done) {
10814
if (ReactElement.isValidElement(step.value)) {
10815
validateExplicitKey(step.value, parentType);
10816
}
10817
}
10818
}
10819
} else if (typeof node === 'object') {
10820
var fragment = ReactFragment.extractIfFragment(node);
10821
for (var key in fragment) {
10822
if (fragment.hasOwnProperty(key)) {
10823
validatePropertyKey(key, fragment[key], parentType);
10824
}
10825
}
10826
}
10827
}
10828
}
10829
10830
/**
10831
* Assert that the props are valid
10832
*
10833
* @param {string} componentName Name of the component for error messages.
10834
* @param {object} propTypes Map of prop name to a ReactPropType
10835
* @param {object} props
10836
* @param {string} location e.g. "prop", "context", "child context"
10837
* @private
10838
*/
10839
function checkPropTypes(componentName, propTypes, props, location) {
10840
for (var propName in propTypes) {
10841
if (propTypes.hasOwnProperty(propName)) {
10842
var error;
10843
// Prop type validation may throw. In case they do, we don't want to
10844
// fail the render phase where it didn't fail before. So we log it.
10845
// After these have been cleaned up, we'll let them throw.
10846
try {
10847
// This is intentionally an invariant that gets caught. It's the same
10848
// behavior as without this statement except with a better message.
10849
("production" !== "development" ? invariant(
10850
typeof propTypes[propName] === 'function',
10851
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
10852
'React.PropTypes.',
10853
componentName || 'React class',
10854
ReactPropTypeLocationNames[location],
10855
propName
10856
) : invariant(typeof propTypes[propName] === 'function'));
10857
error = propTypes[propName](props, propName, componentName, location);
10858
} catch (ex) {
10859
error = ex;
10860
}
10861
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
10862
// Only monitor this failure once because there tends to be a lot of the
10863
// same error.
10864
loggedTypeFailures[error.message] = true;
10865
10866
var addendum = getDeclarationErrorAddendum(this);
10867
("production" !== "development" ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
10868
}
10869
}
10870
}
10871
}
10872
10873
var warnedPropsMutations = {};
10874
10875
/**
10876
* Warn about mutating props when setting `propName` on `element`.
10877
*
10878
* @param {string} propName The string key within props that was set
10879
* @param {ReactElement} element
10880
*/
10881
function warnForPropsMutation(propName, element) {
10882
var type = element.type;
10883
var elementName = typeof type === 'string' ? type : type.displayName;
10884
var ownerName = element._owner ?
10885
element._owner.getPublicInstance().constructor.displayName : null;
10886
10887
var warningKey = propName + '|' + elementName + '|' + ownerName;
10888
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
10889
return;
10890
}
10891
warnedPropsMutations[warningKey] = true;
10892
10893
var elementInfo = '';
10894
if (elementName) {
10895
elementInfo = ' <' + elementName + ' />';
10896
}
10897
var ownerInfo = '';
10898
if (ownerName) {
10899
ownerInfo = ' The element was created by ' + ownerName + '.';
10900
}
10901
10902
("production" !== "development" ? warning(
10903
false,
10904
'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
10905
'correct value when initially creating the element or use ' +
10906
'React.cloneElement to make a new element with updated props.%s',
10907
propName,
10908
elementInfo,
10909
ownerInfo
10910
) : null);
10911
}
10912
10913
// Inline Object.is polyfill
10914
function is(a, b) {
10915
if (a !== a) {
10916
// NaN
10917
return b !== b;
10918
}
10919
if (a === 0 && b === 0) {
10920
// +-0
10921
return 1 / a === 1 / b;
10922
}
10923
return a === b;
10924
}
10925
10926
/**
10927
* Given an element, check if its props have been mutated since element
10928
* creation (or the last call to this function). In particular, check if any
10929
* new props have been added, which we can't directly catch by defining warning
10930
* properties on the props object.
10931
*
10932
* @param {ReactElement} element
10933
*/
10934
function checkAndWarnForMutatedProps(element) {
10935
if (!element._store) {
10936
// Element was created using `new ReactElement` directly or with
10937
// `ReactElement.createElement`; skip mutation checking
10938
return;
10939
}
10940
10941
var originalProps = element._store.originalProps;
10942
var props = element.props;
10943
10944
for (var propName in props) {
10945
if (props.hasOwnProperty(propName)) {
10946
if (!originalProps.hasOwnProperty(propName) ||
10947
!is(originalProps[propName], props[propName])) {
10948
warnForPropsMutation(propName, element);
10949
10950
// Copy over the new value so that the two props objects match again
10951
originalProps[propName] = props[propName];
10952
}
10953
}
10954
}
10955
}
10956
10957
/**
10958
* Given an element, validate that its props follow the propTypes definition,
10959
* provided by the type.
10960
*
10961
* @param {ReactElement} element
10962
*/
10963
function validatePropTypes(element) {
10964
if (element.type == null) {
10965
// This has already warned. Don't throw.
10966
return;
10967
}
10968
// Extract the component class from the element. Converts string types
10969
// to a composite class which may have propTypes.
10970
// TODO: Validating a string's propTypes is not decoupled from the
10971
// rendering target which is problematic.
10972
var componentClass = ReactNativeComponent.getComponentClassForElement(
10973
element
10974
);
10975
var name = componentClass.displayName || componentClass.name;
10976
if (componentClass.propTypes) {
10977
checkPropTypes(
10978
name,
10979
componentClass.propTypes,
10980
element.props,
10981
ReactPropTypeLocations.prop
10982
);
10983
}
10984
if (typeof componentClass.getDefaultProps === 'function') {
10985
("production" !== "development" ? warning(
10986
componentClass.getDefaultProps.isReactClassApproved,
10987
'getDefaultProps is only used on classic React.createClass ' +
10988
'definitions. Use a static property named `defaultProps` instead.'
10989
) : null);
10990
}
10991
}
10992
10993
var ReactElementValidator = {
10994
10995
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
10996
10997
createElement: function(type, props, children) {
10998
// We warn in this case but don't throw. We expect the element creation to
10999
// succeed and there will likely be errors in render.
11000
("production" !== "development" ? warning(
11001
type != null,
11002
'React.createElement: type should not be null or undefined. It should ' +
11003
'be a string (for DOM elements) or a ReactClass (for composite ' +
11004
'components).'
11005
) : null);
11006
11007
var element = ReactElement.createElement.apply(this, arguments);
11008
11009
// The result can be nullish if a mock or a custom function is used.
11010
// TODO: Drop this when these are no longer allowed as the type argument.
11011
if (element == null) {
11012
return element;
11013
}
11014
11015
for (var i = 2; i < arguments.length; i++) {
11016
validateChildKeys(arguments[i], type);
11017
}
11018
11019
validatePropTypes(element);
11020
11021
return element;
11022
},
11023
11024
createFactory: function(type) {
11025
var validatedFactory = ReactElementValidator.createElement.bind(
11026
null,
11027
type
11028
);
11029
// Legacy hook TODO: Warn if this is accessed
11030
validatedFactory.type = type;
11031
11032
if ("production" !== "development") {
11033
try {
11034
Object.defineProperty(
11035
validatedFactory,
11036
'type',
11037
{
11038
enumerable: false,
11039
get: function() {
11040
("production" !== "development" ? warning(
11041
false,
11042
'Factory.type is deprecated. Access the class directly ' +
11043
'before passing it to createFactory.'
11044
) : null);
11045
Object.defineProperty(this, 'type', {
11046
value: type
11047
});
11048
return type;
11049
}
11050
}
11051
);
11052
} catch (x) {
11053
// IE will fail on defineProperty (es5-shim/sham too)
11054
}
11055
}
11056
11057
11058
return validatedFactory;
11059
},
11060
11061
cloneElement: function(element, props, children) {
11062
var newElement = ReactElement.cloneElement.apply(this, arguments);
11063
for (var i = 2; i < arguments.length; i++) {
11064
validateChildKeys(arguments[i], newElement.type);
11065
}
11066
validatePropTypes(newElement);
11067
return newElement;
11068
}
11069
11070
};
11071
11072
module.exports = ReactElementValidator;
11073
11074
},{"141":141,"150":150,"171":171,"45":45,"63":63,"69":69,"80":80,"84":84,"85":85}],65:[function(_dereq_,module,exports){
11075
/**
11076
* Copyright 2014-2015, Facebook, Inc.
11077
* All rights reserved.
11078
*
11079
* This source code is licensed under the BSD-style license found in the
11080
* LICENSE file in the root directory of this source tree. An additional grant
11081
* of patent rights can be found in the PATENTS file in the same directory.
11082
*
11083
* @providesModule ReactEmptyComponent
11084
*/
11085
11086
'use strict';
11087
11088
var ReactElement = _dereq_(63);
11089
var ReactInstanceMap = _dereq_(73);
11090
11091
var invariant = _dereq_(150);
11092
11093
var component;
11094
// This registry keeps track of the React IDs of the components that rendered to
11095
// `null` (in reality a placeholder such as `noscript`)
11096
var nullComponentIDsRegistry = {};
11097
11098
var ReactEmptyComponentInjection = {
11099
injectEmptyComponent: function(emptyComponent) {
11100
component = ReactElement.createFactory(emptyComponent);
11101
}
11102
};
11103
11104
var ReactEmptyComponentType = function() {};
11105
ReactEmptyComponentType.prototype.componentDidMount = function() {
11106
var internalInstance = ReactInstanceMap.get(this);
11107
// TODO: Make sure we run these methods in the correct order, we shouldn't
11108
// need this check. We're going to assume if we're here it means we ran
11109
// componentWillUnmount already so there is no internal instance (it gets
11110
// removed as part of the unmounting process).
11111
if (!internalInstance) {
11112
return;
11113
}
11114
registerNullComponentID(internalInstance._rootNodeID);
11115
};
11116
ReactEmptyComponentType.prototype.componentWillUnmount = function() {
11117
var internalInstance = ReactInstanceMap.get(this);
11118
// TODO: Get rid of this check. See TODO in componentDidMount.
11119
if (!internalInstance) {
11120
return;
11121
}
11122
deregisterNullComponentID(internalInstance._rootNodeID);
11123
};
11124
ReactEmptyComponentType.prototype.render = function() {
11125
("production" !== "development" ? invariant(
11126
component,
11127
'Trying to return null from a render, but no null placeholder component ' +
11128
'was injected.'
11129
) : invariant(component));
11130
return component();
11131
};
11132
11133
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
11134
11135
/**
11136
* Mark the component as having rendered to null.
11137
* @param {string} id Component's `_rootNodeID`.
11138
*/
11139
function registerNullComponentID(id) {
11140
nullComponentIDsRegistry[id] = true;
11141
}
11142
11143
/**
11144
* Unmark the component as having rendered to null: it renders to something now.
11145
* @param {string} id Component's `_rootNodeID`.
11146
*/
11147
function deregisterNullComponentID(id) {
11148
delete nullComponentIDsRegistry[id];
11149
}
11150
11151
/**
11152
* @param {string} id Component's `_rootNodeID`.
11153
* @return {boolean} True if the component is rendered to null.
11154
*/
11155
function isNullComponentID(id) {
11156
return !!nullComponentIDsRegistry[id];
11157
}
11158
11159
var ReactEmptyComponent = {
11160
emptyElement: emptyElement,
11161
injection: ReactEmptyComponentInjection,
11162
isNullComponentID: isNullComponentID
11163
};
11164
11165
module.exports = ReactEmptyComponent;
11166
11167
},{"150":150,"63":63,"73":73}],66:[function(_dereq_,module,exports){
11168
/**
11169
* Copyright 2013-2015, Facebook, Inc.
11170
* All rights reserved.
11171
*
11172
* This source code is licensed under the BSD-style license found in the
11173
* LICENSE file in the root directory of this source tree. An additional grant
11174
* of patent rights can be found in the PATENTS file in the same directory.
11175
*
11176
* @providesModule ReactErrorUtils
11177
* @typechecks
11178
*/
11179
11180
"use strict";
11181
11182
var ReactErrorUtils = {
11183
/**
11184
* Creates a guarded version of a function. This is supposed to make debugging
11185
* of event handlers easier. To aid debugging with the browser's debugger,
11186
* this currently simply returns the original function.
11187
*
11188
* @param {function} func Function to be executed
11189
* @param {string} name The name of the guard
11190
* @return {function}
11191
*/
11192
guard: function(func, name) {
11193
return func;
11194
}
11195
};
11196
11197
module.exports = ReactErrorUtils;
11198
11199
},{}],67:[function(_dereq_,module,exports){
11200
/**
11201
* Copyright 2013-2015, Facebook, Inc.
11202
* All rights reserved.
11203
*
11204
* This source code is licensed under the BSD-style license found in the
11205
* LICENSE file in the root directory of this source tree. An additional grant
11206
* of patent rights can be found in the PATENTS file in the same directory.
11207
*
11208
* @providesModule ReactEventEmitterMixin
11209
*/
11210
11211
'use strict';
11212
11213
var EventPluginHub = _dereq_(18);
11214
11215
function runEventQueueInBatch(events) {
11216
EventPluginHub.enqueueEvents(events);
11217
EventPluginHub.processEventQueue();
11218
}
11219
11220
var ReactEventEmitterMixin = {
11221
11222
/**
11223
* Streams a fired top-level event to `EventPluginHub` where plugins have the
11224
* opportunity to create `ReactEvent`s to be dispatched.
11225
*
11226
* @param {string} topLevelType Record from `EventConstants`.
11227
* @param {object} topLevelTarget The listening component root node.
11228
* @param {string} topLevelTargetID ID of `topLevelTarget`.
11229
* @param {object} nativeEvent Native environment event.
11230
*/
11231
handleTopLevel: function(
11232
topLevelType,
11233
topLevelTarget,
11234
topLevelTargetID,
11235
nativeEvent) {
11236
var events = EventPluginHub.extractEvents(
11237
topLevelType,
11238
topLevelTarget,
11239
topLevelTargetID,
11240
nativeEvent
11241
);
11242
11243
runEventQueueInBatch(events);
11244
}
11245
};
11246
11247
module.exports = ReactEventEmitterMixin;
11248
11249
},{"18":18}],68:[function(_dereq_,module,exports){
11250
/**
11251
* Copyright 2013-2015, Facebook, Inc.
11252
* All rights reserved.
11253
*
11254
* This source code is licensed under the BSD-style license found in the
11255
* LICENSE file in the root directory of this source tree. An additional grant
11256
* of patent rights can be found in the PATENTS file in the same directory.
11257
*
11258
* @providesModule ReactEventListener
11259
* @typechecks static-only
11260
*/
11261
11262
'use strict';
11263
11264
var EventListener = _dereq_(17);
11265
var ExecutionEnvironment = _dereq_(22);
11266
var PooledClass = _dereq_(30);
11267
var ReactInstanceHandles = _dereq_(72);
11268
var ReactMount = _dereq_(77);
11269
var ReactUpdates = _dereq_(100);
11270
11271
var assign = _dereq_(29);
11272
var getEventTarget = _dereq_(140);
11273
var getUnboundedScrollPosition = _dereq_(146);
11274
11275
/**
11276
* Finds the parent React component of `node`.
11277
*
11278
* @param {*} node
11279
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
11280
* is not nested.
11281
*/
11282
function findParent(node) {
11283
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
11284
// traversal, but caching is difficult to do correctly without using a
11285
// mutation observer to listen for all DOM changes.
11286
var nodeID = ReactMount.getID(node);
11287
var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
11288
var container = ReactMount.findReactContainerForID(rootID);
11289
var parent = ReactMount.getFirstReactDOM(container);
11290
return parent;
11291
}
11292
11293
// Used to store ancestor hierarchy in top level callback
11294
function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
11295
this.topLevelType = topLevelType;
11296
this.nativeEvent = nativeEvent;
11297
this.ancestors = [];
11298
}
11299
assign(TopLevelCallbackBookKeeping.prototype, {
11300
destructor: function() {
11301
this.topLevelType = null;
11302
this.nativeEvent = null;
11303
this.ancestors.length = 0;
11304
}
11305
});
11306
PooledClass.addPoolingTo(
11307
TopLevelCallbackBookKeeping,
11308
PooledClass.twoArgumentPooler
11309
);
11310
11311
function handleTopLevelImpl(bookKeeping) {
11312
var topLevelTarget = ReactMount.getFirstReactDOM(
11313
getEventTarget(bookKeeping.nativeEvent)
11314
) || window;
11315
11316
// Loop through the hierarchy, in case there's any nested components.
11317
// It's important that we build the array of ancestors before calling any
11318
// event handlers, because event handlers can modify the DOM, leading to
11319
// inconsistencies with ReactMount's node cache. See #1105.
11320
var ancestor = topLevelTarget;
11321
while (ancestor) {
11322
bookKeeping.ancestors.push(ancestor);
11323
ancestor = findParent(ancestor);
11324
}
11325
11326
for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
11327
topLevelTarget = bookKeeping.ancestors[i];
11328
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
11329
ReactEventListener._handleTopLevel(
11330
bookKeeping.topLevelType,
11331
topLevelTarget,
11332
topLevelTargetID,
11333
bookKeeping.nativeEvent
11334
);
11335
}
11336
}
11337
11338
function scrollValueMonitor(cb) {
11339
var scrollPosition = getUnboundedScrollPosition(window);
11340
cb(scrollPosition);
11341
}
11342
11343
var ReactEventListener = {
11344
_enabled: true,
11345
_handleTopLevel: null,
11346
11347
WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
11348
11349
setHandleTopLevel: function(handleTopLevel) {
11350
ReactEventListener._handleTopLevel = handleTopLevel;
11351
},
11352
11353
setEnabled: function(enabled) {
11354
ReactEventListener._enabled = !!enabled;
11355
},
11356
11357
isEnabled: function() {
11358
return ReactEventListener._enabled;
11359
},
11360
11361
11362
/**
11363
* Traps top-level events by using event bubbling.
11364
*
11365
* @param {string} topLevelType Record from `EventConstants`.
11366
* @param {string} handlerBaseName Event name (e.g. "click").
11367
* @param {object} handle Element on which to attach listener.
11368
* @return {object} An object with a remove function which will forcefully
11369
* remove the listener.
11370
* @internal
11371
*/
11372
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
11373
var element = handle;
11374
if (!element) {
11375
return null;
11376
}
11377
return EventListener.listen(
11378
element,
11379
handlerBaseName,
11380
ReactEventListener.dispatchEvent.bind(null, topLevelType)
11381
);
11382
},
11383
11384
/**
11385
* Traps a top-level event by using event capturing.
11386
*
11387
* @param {string} topLevelType Record from `EventConstants`.
11388
* @param {string} handlerBaseName Event name (e.g. "click").
11389
* @param {object} handle Element on which to attach listener.
11390
* @return {object} An object with a remove function which will forcefully
11391
* remove the listener.
11392
* @internal
11393
*/
11394
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
11395
var element = handle;
11396
if (!element) {
11397
return null;
11398
}
11399
return EventListener.capture(
11400
element,
11401
handlerBaseName,
11402
ReactEventListener.dispatchEvent.bind(null, topLevelType)
11403
);
11404
},
11405
11406
monitorScrollValue: function(refresh) {
11407
var callback = scrollValueMonitor.bind(null, refresh);
11408
EventListener.listen(window, 'scroll', callback);
11409
},
11410
11411
dispatchEvent: function(topLevelType, nativeEvent) {
11412
if (!ReactEventListener._enabled) {
11413
return;
11414
}
11415
11416
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
11417
topLevelType,
11418
nativeEvent
11419
);
11420
try {
11421
// Event queue being processed in the same cycle allows
11422
// `preventDefault`.
11423
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
11424
} finally {
11425
TopLevelCallbackBookKeeping.release(bookKeeping);
11426
}
11427
}
11428
};
11429
11430
module.exports = ReactEventListener;
11431
11432
},{"100":100,"140":140,"146":146,"17":17,"22":22,"29":29,"30":30,"72":72,"77":77}],69:[function(_dereq_,module,exports){
11433
/**
11434
* Copyright 2015, Facebook, Inc.
11435
* All rights reserved.
11436
*
11437
* This source code is licensed under the BSD-style license found in the
11438
* LICENSE file in the root directory of this source tree. An additional grant
11439
* of patent rights can be found in the PATENTS file in the same directory.
11440
*
11441
* @providesModule ReactFragment
11442
*/
11443
11444
'use strict';
11445
11446
var ReactElement = _dereq_(63);
11447
11448
var warning = _dereq_(171);
11449
11450
/**
11451
* We used to allow keyed objects to serve as a collection of ReactElements,
11452
* or nested sets. This allowed us a way to explicitly key a set a fragment of
11453
* components. This is now being replaced with an opaque data structure.
11454
* The upgrade path is to call React.addons.createFragment({ key: value }) to
11455
* create a keyed fragment. The resulting data structure is opaque, for now.
11456
*/
11457
11458
if ("production" !== "development") {
11459
var fragmentKey = '_reactFragment';
11460
var didWarnKey = '_reactDidWarn';
11461
var canWarnForReactFragment = false;
11462
11463
try {
11464
// Feature test. Don't even try to issue this warning if we can't use
11465
// enumerable: false.
11466
11467
var dummy = function() {
11468
return 1;
11469
};
11470
11471
Object.defineProperty(
11472
{},
11473
fragmentKey,
11474
{enumerable: false, value: true}
11475
);
11476
11477
Object.defineProperty(
11478
{},
11479
'key',
11480
{enumerable: true, get: dummy}
11481
);
11482
11483
canWarnForReactFragment = true;
11484
} catch (x) { }
11485
11486
var proxyPropertyAccessWithWarning = function(obj, key) {
11487
Object.defineProperty(obj, key, {
11488
enumerable: true,
11489
get: function() {
11490
("production" !== "development" ? warning(
11491
this[didWarnKey],
11492
'A ReactFragment is an opaque type. Accessing any of its ' +
11493
'properties is deprecated. Pass it to one of the React.Children ' +
11494
'helpers.'
11495
) : null);
11496
this[didWarnKey] = true;
11497
return this[fragmentKey][key];
11498
},
11499
set: function(value) {
11500
("production" !== "development" ? warning(
11501
this[didWarnKey],
11502
'A ReactFragment is an immutable opaque type. Mutating its ' +
11503
'properties is deprecated.'
11504
) : null);
11505
this[didWarnKey] = true;
11506
this[fragmentKey][key] = value;
11507
}
11508
});
11509
};
11510
11511
var issuedWarnings = {};
11512
11513
var didWarnForFragment = function(fragment) {
11514
// We use the keys and the type of the value as a heuristic to dedupe the
11515
// warning to avoid spamming too much.
11516
var fragmentCacheKey = '';
11517
for (var key in fragment) {
11518
fragmentCacheKey += key + ':' + (typeof fragment[key]) + ',';
11519
}
11520
var alreadyWarnedOnce = !!issuedWarnings[fragmentCacheKey];
11521
issuedWarnings[fragmentCacheKey] = true;
11522
return alreadyWarnedOnce;
11523
};
11524
}
11525
11526
var ReactFragment = {
11527
// Wrap a keyed object in an opaque proxy that warns you if you access any
11528
// of its properties.
11529
create: function(object) {
11530
if ("production" !== "development") {
11531
if (typeof object !== 'object' || !object || Array.isArray(object)) {
11532
("production" !== "development" ? warning(
11533
false,
11534
'React.addons.createFragment only accepts a single object.',
11535
object
11536
) : null);
11537
return object;
11538
}
11539
if (ReactElement.isValidElement(object)) {
11540
("production" !== "development" ? warning(
11541
false,
11542
'React.addons.createFragment does not accept a ReactElement ' +
11543
'without a wrapper object.'
11544
) : null);
11545
return object;
11546
}
11547
if (canWarnForReactFragment) {
11548
var proxy = {};
11549
Object.defineProperty(proxy, fragmentKey, {
11550
enumerable: false,
11551
value: object
11552
});
11553
Object.defineProperty(proxy, didWarnKey, {
11554
writable: true,
11555
enumerable: false,
11556
value: false
11557
});
11558
for (var key in object) {
11559
proxyPropertyAccessWithWarning(proxy, key);
11560
}
11561
Object.preventExtensions(proxy);
11562
return proxy;
11563
}
11564
}
11565
return object;
11566
},
11567
// Extract the original keyed object from the fragment opaque type. Warn if
11568
// a plain object is passed here.
11569
extract: function(fragment) {
11570
if ("production" !== "development") {
11571
if (canWarnForReactFragment) {
11572
if (!fragment[fragmentKey]) {
11573
("production" !== "development" ? warning(
11574
didWarnForFragment(fragment),
11575
'Any use of a keyed object should be wrapped in ' +
11576
'React.addons.createFragment(object) before being passed as a ' +
11577
'child.'
11578
) : null);
11579
return fragment;
11580
}
11581
return fragment[fragmentKey];
11582
}
11583
}
11584
return fragment;
11585
},
11586
// Check if this is a fragment and if so, extract the keyed object. If it
11587
// is a fragment-like object, warn that it should be wrapped. Ignore if we
11588
// can't determine what kind of object this is.
11589
extractIfFragment: function(fragment) {
11590
if ("production" !== "development") {
11591
if (canWarnForReactFragment) {
11592
// If it is the opaque type, return the keyed object.
11593
if (fragment[fragmentKey]) {
11594
return fragment[fragmentKey];
11595
}
11596
// Otherwise, check each property if it has an element, if it does
11597
// it is probably meant as a fragment, so we can warn early. Defer,
11598
// the warning to extract.
11599
for (var key in fragment) {
11600
if (fragment.hasOwnProperty(key) &&
11601
ReactElement.isValidElement(fragment[key])) {
11602
// This looks like a fragment object, we should provide an
11603
// early warning.
11604
return ReactFragment.extract(fragment);
11605
}
11606
}
11607
}
11608
}
11609
return fragment;
11610
}
11611
};
11612
11613
module.exports = ReactFragment;
11614
11615
},{"171":171,"63":63}],70:[function(_dereq_,module,exports){
11616
/**
11617
* Copyright 2013-2015, Facebook, Inc.
11618
* All rights reserved.
11619
*
11620
* This source code is licensed under the BSD-style license found in the
11621
* LICENSE file in the root directory of this source tree. An additional grant
11622
* of patent rights can be found in the PATENTS file in the same directory.
11623
*
11624
* @providesModule ReactInjection
11625
*/
11626
11627
'use strict';
11628
11629
var DOMProperty = _dereq_(11);
11630
var EventPluginHub = _dereq_(18);
11631
var ReactComponentEnvironment = _dereq_(41);
11632
var ReactClass = _dereq_(38);
11633
var ReactEmptyComponent = _dereq_(65);
11634
var ReactBrowserEventEmitter = _dereq_(33);
11635
var ReactNativeComponent = _dereq_(80);
11636
var ReactDOMComponent = _dereq_(48);
11637
var ReactPerf = _dereq_(82);
11638
var ReactRootIndex = _dereq_(91);
11639
var ReactUpdates = _dereq_(100);
11640
11641
var ReactInjection = {
11642
Component: ReactComponentEnvironment.injection,
11643
Class: ReactClass.injection,
11644
DOMComponent: ReactDOMComponent.injection,
11645
DOMProperty: DOMProperty.injection,
11646
EmptyComponent: ReactEmptyComponent.injection,
11647
EventPluginHub: EventPluginHub.injection,
11648
EventEmitter: ReactBrowserEventEmitter.injection,
11649
NativeComponent: ReactNativeComponent.injection,
11650
Perf: ReactPerf.injection,
11651
RootIndex: ReactRootIndex.injection,
11652
Updates: ReactUpdates.injection
11653
};
11654
11655
module.exports = ReactInjection;
11656
11657
},{"100":100,"11":11,"18":18,"33":33,"38":38,"41":41,"48":48,"65":65,"80":80,"82":82,"91":91}],71:[function(_dereq_,module,exports){
11658
/**
11659
* Copyright 2013-2015, Facebook, Inc.
11660
* All rights reserved.
11661
*
11662
* This source code is licensed under the BSD-style license found in the
11663
* LICENSE file in the root directory of this source tree. An additional grant
11664
* of patent rights can be found in the PATENTS file in the same directory.
11665
*
11666
* @providesModule ReactInputSelection
11667
*/
11668
11669
'use strict';
11670
11671
var ReactDOMSelection = _dereq_(56);
11672
11673
var containsNode = _dereq_(123);
11674
var focusNode = _dereq_(134);
11675
var getActiveElement = _dereq_(136);
11676
11677
function isInDocument(node) {
11678
return containsNode(document.documentElement, node);
11679
}
11680
11681
/**
11682
* @ReactInputSelection: React input selection module. Based on Selection.js,
11683
* but modified to be suitable for react and has a couple of bug fixes (doesn't
11684
* assume buttons have range selections allowed).
11685
* Input selection module for React.
11686
*/
11687
var ReactInputSelection = {
11688
11689
hasSelectionCapabilities: function(elem) {
11690
return elem && (
11691
((elem.nodeName === 'INPUT' && elem.type === 'text') ||
11692
elem.nodeName === 'TEXTAREA' || elem.contentEditable === 'true')
11693
);
11694
},
11695
11696
getSelectionInformation: function() {
11697
var focusedElem = getActiveElement();
11698
return {
11699
focusedElem: focusedElem,
11700
selectionRange:
11701
ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
11702
ReactInputSelection.getSelection(focusedElem) :
11703
null
11704
};
11705
},
11706
11707
/**
11708
* @restoreSelection: If any selection information was potentially lost,
11709
* restore it. This is useful when performing operations that could remove dom
11710
* nodes and place them back in, resulting in focus being lost.
11711
*/
11712
restoreSelection: function(priorSelectionInformation) {
11713
var curFocusedElem = getActiveElement();
11714
var priorFocusedElem = priorSelectionInformation.focusedElem;
11715
var priorSelectionRange = priorSelectionInformation.selectionRange;
11716
if (curFocusedElem !== priorFocusedElem &&
11717
isInDocument(priorFocusedElem)) {
11718
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
11719
ReactInputSelection.setSelection(
11720
priorFocusedElem,
11721
priorSelectionRange
11722
);
11723
}
11724
focusNode(priorFocusedElem);
11725
}
11726
},
11727
11728
/**
11729
* @getSelection: Gets the selection bounds of a focused textarea, input or
11730
* contentEditable node.
11731
* -@input: Look up selection bounds of this input
11732
* -@return {start: selectionStart, end: selectionEnd}
11733
*/
11734
getSelection: function(input) {
11735
var selection;
11736
11737
if ('selectionStart' in input) {
11738
// Modern browser with input or textarea.
11739
selection = {
11740
start: input.selectionStart,
11741
end: input.selectionEnd
11742
};
11743
} else if (document.selection && input.nodeName === 'INPUT') {
11744
// IE8 input.
11745
var range = document.selection.createRange();
11746
// There can only be one selection per document in IE, so it must
11747
// be in our element.
11748
if (range.parentElement() === input) {
11749
selection = {
11750
start: -range.moveStart('character', -input.value.length),
11751
end: -range.moveEnd('character', -input.value.length)
11752
};
11753
}
11754
} else {
11755
// Content editable or old IE textarea.
11756
selection = ReactDOMSelection.getOffsets(input);
11757
}
11758
11759
return selection || {start: 0, end: 0};
11760
},
11761
11762
/**
11763
* @setSelection: Sets the selection bounds of a textarea or input and focuses
11764
* the input.
11765
* -@input Set selection bounds of this input or textarea
11766
* -@offsets Object of same form that is returned from get*
11767
*/
11768
setSelection: function(input, offsets) {
11769
var start = offsets.start;
11770
var end = offsets.end;
11771
if (typeof end === 'undefined') {
11772
end = start;
11773
}
11774
11775
if ('selectionStart' in input) {
11776
input.selectionStart = start;
11777
input.selectionEnd = Math.min(end, input.value.length);
11778
} else if (document.selection && input.nodeName === 'INPUT') {
11779
var range = input.createTextRange();
11780
range.collapse(true);
11781
range.moveStart('character', start);
11782
range.moveEnd('character', end - start);
11783
range.select();
11784
} else {
11785
ReactDOMSelection.setOffsets(input, offsets);
11786
}
11787
}
11788
};
11789
11790
module.exports = ReactInputSelection;
11791
11792
},{"123":123,"134":134,"136":136,"56":56}],72:[function(_dereq_,module,exports){
11793
/**
11794
* Copyright 2013-2015, Facebook, Inc.
11795
* All rights reserved.
11796
*
11797
* This source code is licensed under the BSD-style license found in the
11798
* LICENSE file in the root directory of this source tree. An additional grant
11799
* of patent rights can be found in the PATENTS file in the same directory.
11800
*
11801
* @providesModule ReactInstanceHandles
11802
* @typechecks static-only
11803
*/
11804
11805
'use strict';
11806
11807
var ReactRootIndex = _dereq_(91);
11808
11809
var invariant = _dereq_(150);
11810
11811
var SEPARATOR = '.';
11812
var SEPARATOR_LENGTH = SEPARATOR.length;
11813
11814
/**
11815
* Maximum depth of traversals before we consider the possibility of a bad ID.
11816
*/
11817
var MAX_TREE_DEPTH = 100;
11818
11819
/**
11820
* Creates a DOM ID prefix to use when mounting React components.
11821
*
11822
* @param {number} index A unique integer
11823
* @return {string} React root ID.
11824
* @internal
11825
*/
11826
function getReactRootIDString(index) {
11827
return SEPARATOR + index.toString(36);
11828
}
11829
11830
/**
11831
* Checks if a character in the supplied ID is a separator or the end.
11832
*
11833
* @param {string} id A React DOM ID.
11834
* @param {number} index Index of the character to check.
11835
* @return {boolean} True if the character is a separator or end of the ID.
11836
* @private
11837
*/
11838
function isBoundary(id, index) {
11839
return id.charAt(index) === SEPARATOR || index === id.length;
11840
}
11841
11842
/**
11843
* Checks if the supplied string is a valid React DOM ID.
11844
*
11845
* @param {string} id A React DOM ID, maybe.
11846
* @return {boolean} True if the string is a valid React DOM ID.
11847
* @private
11848
*/
11849
function isValidID(id) {
11850
return id === '' || (
11851
id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
11852
);
11853
}
11854
11855
/**
11856
* Checks if the first ID is an ancestor of or equal to the second ID.
11857
*
11858
* @param {string} ancestorID
11859
* @param {string} descendantID
11860
* @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
11861
* @internal
11862
*/
11863
function isAncestorIDOf(ancestorID, descendantID) {
11864
return (
11865
descendantID.indexOf(ancestorID) === 0 &&
11866
isBoundary(descendantID, ancestorID.length)
11867
);
11868
}
11869
11870
/**
11871
* Gets the parent ID of the supplied React DOM ID, `id`.
11872
*
11873
* @param {string} id ID of a component.
11874
* @return {string} ID of the parent, or an empty string.
11875
* @private
11876
*/
11877
function getParentID(id) {
11878
return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
11879
}
11880
11881
/**
11882
* Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
11883
* supplied `destinationID`. If they are equal, the ID is returned.
11884
*
11885
* @param {string} ancestorID ID of an ancestor node of `destinationID`.
11886
* @param {string} destinationID ID of the destination node.
11887
* @return {string} Next ID on the path from `ancestorID` to `destinationID`.
11888
* @private
11889
*/
11890
function getNextDescendantID(ancestorID, destinationID) {
11891
("production" !== "development" ? invariant(
11892
isValidID(ancestorID) && isValidID(destinationID),
11893
'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
11894
ancestorID,
11895
destinationID
11896
) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
11897
("production" !== "development" ? invariant(
11898
isAncestorIDOf(ancestorID, destinationID),
11899
'getNextDescendantID(...): React has made an invalid assumption about ' +
11900
'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
11901
ancestorID,
11902
destinationID
11903
) : invariant(isAncestorIDOf(ancestorID, destinationID)));
11904
if (ancestorID === destinationID) {
11905
return ancestorID;
11906
}
11907
// Skip over the ancestor and the immediate separator. Traverse until we hit
11908
// another separator or we reach the end of `destinationID`.
11909
var start = ancestorID.length + SEPARATOR_LENGTH;
11910
var i;
11911
for (i = start; i < destinationID.length; i++) {
11912
if (isBoundary(destinationID, i)) {
11913
break;
11914
}
11915
}
11916
return destinationID.substr(0, i);
11917
}
11918
11919
/**
11920
* Gets the nearest common ancestor ID of two IDs.
11921
*
11922
* Using this ID scheme, the nearest common ancestor ID is the longest common
11923
* prefix of the two IDs that immediately preceded a "marker" in both strings.
11924
*
11925
* @param {string} oneID
11926
* @param {string} twoID
11927
* @return {string} Nearest common ancestor ID, or the empty string if none.
11928
* @private
11929
*/
11930
function getFirstCommonAncestorID(oneID, twoID) {
11931
var minLength = Math.min(oneID.length, twoID.length);
11932
if (minLength === 0) {
11933
return '';
11934
}
11935
var lastCommonMarkerIndex = 0;
11936
// Use `<=` to traverse until the "EOL" of the shorter string.
11937
for (var i = 0; i <= minLength; i++) {
11938
if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
11939
lastCommonMarkerIndex = i;
11940
} else if (oneID.charAt(i) !== twoID.charAt(i)) {
11941
break;
11942
}
11943
}
11944
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
11945
("production" !== "development" ? invariant(
11946
isValidID(longestCommonID),
11947
'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
11948
oneID,
11949
twoID,
11950
longestCommonID
11951
) : invariant(isValidID(longestCommonID)));
11952
return longestCommonID;
11953
}
11954
11955
/**
11956
* Traverses the parent path between two IDs (either up or down). The IDs must
11957
* not be the same, and there must exist a parent path between them. If the
11958
* callback returns `false`, traversal is stopped.
11959
*
11960
* @param {?string} start ID at which to start traversal.
11961
* @param {?string} stop ID at which to end traversal.
11962
* @param {function} cb Callback to invoke each ID with.
11963
* @param {?boolean} skipFirst Whether or not to skip the first node.
11964
* @param {?boolean} skipLast Whether or not to skip the last node.
11965
* @private
11966
*/
11967
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
11968
start = start || '';
11969
stop = stop || '';
11970
("production" !== "development" ? invariant(
11971
start !== stop,
11972
'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
11973
start
11974
) : invariant(start !== stop));
11975
var traverseUp = isAncestorIDOf(stop, start);
11976
("production" !== "development" ? invariant(
11977
traverseUp || isAncestorIDOf(start, stop),
11978
'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
11979
'not have a parent path.',
11980
start,
11981
stop
11982
) : invariant(traverseUp || isAncestorIDOf(start, stop)));
11983
// Traverse from `start` to `stop` one depth at a time.
11984
var depth = 0;
11985
var traverse = traverseUp ? getParentID : getNextDescendantID;
11986
for (var id = start; /* until break */; id = traverse(id, stop)) {
11987
var ret;
11988
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
11989
ret = cb(id, traverseUp, arg);
11990
}
11991
if (ret === false || id === stop) {
11992
// Only break //after// visiting `stop`.
11993
break;
11994
}
11995
("production" !== "development" ? invariant(
11996
depth++ < MAX_TREE_DEPTH,
11997
'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
11998
'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
11999
start, stop
12000
) : invariant(depth++ < MAX_TREE_DEPTH));
12001
}
12002
}
12003
12004
/**
12005
* Manages the IDs assigned to DOM representations of React components. This
12006
* uses a specific scheme in order to traverse the DOM efficiently (e.g. in
12007
* order to simulate events).
12008
*
12009
* @internal
12010
*/
12011
var ReactInstanceHandles = {
12012
12013
/**
12014
* Constructs a React root ID
12015
* @return {string} A React root ID.
12016
*/
12017
createReactRootID: function() {
12018
return getReactRootIDString(ReactRootIndex.createReactRootIndex());
12019
},
12020
12021
/**
12022
* Constructs a React ID by joining a root ID with a name.
12023
*
12024
* @param {string} rootID Root ID of a parent component.
12025
* @param {string} name A component's name (as flattened children).
12026
* @return {string} A React ID.
12027
* @internal
12028
*/
12029
createReactID: function(rootID, name) {
12030
return rootID + name;
12031
},
12032
12033
/**
12034
* Gets the DOM ID of the React component that is the root of the tree that
12035
* contains the React component with the supplied DOM ID.
12036
*
12037
* @param {string} id DOM ID of a React component.
12038
* @return {?string} DOM ID of the React component that is the root.
12039
* @internal
12040
*/
12041
getReactRootIDFromNodeID: function(id) {
12042
if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
12043
var index = id.indexOf(SEPARATOR, 1);
12044
return index > -1 ? id.substr(0, index) : id;
12045
}
12046
return null;
12047
},
12048
12049
/**
12050
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
12051
* should would receive a `mouseEnter` or `mouseLeave` event.
12052
*
12053
* NOTE: Does not invoke the callback on the nearest common ancestor because
12054
* nothing "entered" or "left" that element.
12055
*
12056
* @param {string} leaveID ID being left.
12057
* @param {string} enterID ID being entered.
12058
* @param {function} cb Callback to invoke on each entered/left ID.
12059
* @param {*} upArg Argument to invoke the callback with on left IDs.
12060
* @param {*} downArg Argument to invoke the callback with on entered IDs.
12061
* @internal
12062
*/
12063
traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
12064
var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
12065
if (ancestorID !== leaveID) {
12066
traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
12067
}
12068
if (ancestorID !== enterID) {
12069
traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
12070
}
12071
},
12072
12073
/**
12074
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
12075
*
12076
* NOTE: This traversal happens on IDs without touching the DOM.
12077
*
12078
* @param {string} targetID ID of the target node.
12079
* @param {function} cb Callback to invoke.
12080
* @param {*} arg Argument to invoke the callback with.
12081
* @internal
12082
*/
12083
traverseTwoPhase: function(targetID, cb, arg) {
12084
if (targetID) {
12085
traverseParentPath('', targetID, cb, arg, true, false);
12086
traverseParentPath(targetID, '', cb, arg, false, true);
12087
}
12088
},
12089
12090
/**
12091
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
12092
* example, passing `.0.$row-0.1` would result in `cb` getting called
12093
* with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
12094
*
12095
* NOTE: This traversal happens on IDs without touching the DOM.
12096
*
12097
* @param {string} targetID ID of the target node.
12098
* @param {function} cb Callback to invoke.
12099
* @param {*} arg Argument to invoke the callback with.
12100
* @internal
12101
*/
12102
traverseAncestors: function(targetID, cb, arg) {
12103
traverseParentPath('', targetID, cb, arg, true, false);
12104
},
12105
12106
/**
12107
* Exposed for unit testing.
12108
* @private
12109
*/
12110
_getFirstCommonAncestorID: getFirstCommonAncestorID,
12111
12112
/**
12113
* Exposed for unit testing.
12114
* @private
12115
*/
12116
_getNextDescendantID: getNextDescendantID,
12117
12118
isAncestorIDOf: isAncestorIDOf,
12119
12120
SEPARATOR: SEPARATOR
12121
12122
};
12123
12124
module.exports = ReactInstanceHandles;
12125
12126
},{"150":150,"91":91}],73:[function(_dereq_,module,exports){
12127
/**
12128
* Copyright 2013-2015, Facebook, Inc.
12129
* All rights reserved.
12130
*
12131
* This source code is licensed under the BSD-style license found in the
12132
* LICENSE file in the root directory of this source tree. An additional grant
12133
* of patent rights can be found in the PATENTS file in the same directory.
12134
*
12135
* @providesModule ReactInstanceMap
12136
*/
12137
12138
'use strict';
12139
12140
/**
12141
* `ReactInstanceMap` maintains a mapping from a public facing stateful
12142
* instance (key) and the internal representation (value). This allows public
12143
* methods to accept the user facing instance as an argument and map them back
12144
* to internal methods.
12145
*/
12146
12147
// TODO: Replace this with ES6: var ReactInstanceMap = new Map();
12148
var ReactInstanceMap = {
12149
12150
/**
12151
* This API should be called `delete` but we'd have to make sure to always
12152
* transform these to strings for IE support. When this transform is fully
12153
* supported we can rename it.
12154
*/
12155
remove: function(key) {
12156
key._reactInternalInstance = undefined;
12157
},
12158
12159
get: function(key) {
12160
return key._reactInternalInstance;
12161
},
12162
12163
has: function(key) {
12164
return key._reactInternalInstance !== undefined;
12165
},
12166
12167
set: function(key, value) {
12168
key._reactInternalInstance = value;
12169
}
12170
12171
};
12172
12173
module.exports = ReactInstanceMap;
12174
12175
},{}],74:[function(_dereq_,module,exports){
12176
/**
12177
* Copyright 2015, Facebook, Inc.
12178
* All rights reserved.
12179
*
12180
* This source code is licensed under the BSD-style license found in the
12181
* LICENSE file in the root directory of this source tree. An additional grant
12182
* of patent rights can be found in the PATENTS file in the same directory.
12183
*
12184
* @providesModule ReactLifeCycle
12185
*/
12186
12187
'use strict';
12188
12189
/**
12190
* This module manages the bookkeeping when a component is in the process
12191
* of being mounted or being unmounted. This is used as a way to enforce
12192
* invariants (or warnings) when it is not recommended to call
12193
* setState/forceUpdate.
12194
*
12195
* currentlyMountingInstance: During the construction phase, it is not possible
12196
* to trigger an update since the instance is not fully mounted yet. However, we
12197
* currently allow this as a convenience for mutating the initial state.
12198
*
12199
* currentlyUnmountingInstance: During the unmounting phase, the instance is
12200
* still mounted and can therefore schedule an update. However, this is not
12201
* recommended and probably an error since it's about to be unmounted.
12202
* Therefore we still want to trigger in an error for that case.
12203
*/
12204
12205
var ReactLifeCycle = {
12206
currentlyMountingInstance: null,
12207
currentlyUnmountingInstance: null
12208
};
12209
12210
module.exports = ReactLifeCycle;
12211
12212
},{}],75:[function(_dereq_,module,exports){
12213
/**
12214
* Copyright 2013-2015, Facebook, Inc.
12215
* All rights reserved.
12216
*
12217
* This source code is licensed under the BSD-style license found in the
12218
* LICENSE file in the root directory of this source tree. An additional grant
12219
* of patent rights can be found in the PATENTS file in the same directory.
12220
*
12221
* @providesModule ReactLink
12222
* @typechecks static-only
12223
*/
12224
12225
'use strict';
12226
12227
/**
12228
* ReactLink encapsulates a common pattern in which a component wants to modify
12229
* a prop received from its parent. ReactLink allows the parent to pass down a
12230
* value coupled with a callback that, when invoked, expresses an intent to
12231
* modify that value. For example:
12232
*
12233
* React.createClass({
12234
* getInitialState: function() {
12235
* return {value: ''};
12236
* },
12237
* render: function() {
12238
* var valueLink = new ReactLink(this.state.value, this._handleValueChange);
12239
* return <input valueLink={valueLink} />;
12240
* },
12241
* this._handleValueChange: function(newValue) {
12242
* this.setState({value: newValue});
12243
* }
12244
* });
12245
*
12246
* We have provided some sugary mixins to make the creation and
12247
* consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
12248
*/
12249
12250
var React = _dereq_(31);
12251
12252
/**
12253
* @param {*} value current value of the link
12254
* @param {function} requestChange callback to request a change
12255
*/
12256
function ReactLink(value, requestChange) {
12257
this.value = value;
12258
this.requestChange = requestChange;
12259
}
12260
12261
/**
12262
* Creates a PropType that enforces the ReactLink API and optionally checks the
12263
* type of the value being passed inside the link. Example:
12264
*
12265
* MyComponent.propTypes = {
12266
* tabIndexLink: ReactLink.PropTypes.link(React.PropTypes.number)
12267
* }
12268
*/
12269
function createLinkTypeChecker(linkType) {
12270
var shapes = {
12271
value: typeof linkType === 'undefined' ?
12272
React.PropTypes.any.isRequired :
12273
linkType.isRequired,
12274
requestChange: React.PropTypes.func.isRequired
12275
};
12276
return React.PropTypes.shape(shapes);
12277
}
12278
12279
ReactLink.PropTypes = {
12280
link: createLinkTypeChecker
12281
};
12282
12283
module.exports = ReactLink;
12284
12285
},{"31":31}],76:[function(_dereq_,module,exports){
12286
/**
12287
* Copyright 2013-2015, Facebook, Inc.
12288
* All rights reserved.
12289
*
12290
* This source code is licensed under the BSD-style license found in the
12291
* LICENSE file in the root directory of this source tree. An additional grant
12292
* of patent rights can be found in the PATENTS file in the same directory.
12293
*
12294
* @providesModule ReactMarkupChecksum
12295
*/
12296
12297
'use strict';
12298
12299
var adler32 = _dereq_(119);
12300
12301
var ReactMarkupChecksum = {
12302
CHECKSUM_ATTR_NAME: 'data-react-checksum',
12303
12304
/**
12305
* @param {string} markup Markup string
12306
* @return {string} Markup string with checksum attribute attached
12307
*/
12308
addChecksumToMarkup: function(markup) {
12309
var checksum = adler32(markup);
12310
return markup.replace(
12311
'>',
12312
' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
12313
);
12314
},
12315
12316
/**
12317
* @param {string} markup to use
12318
* @param {DOMElement} element root React element
12319
* @returns {boolean} whether or not the markup is the same
12320
*/
12321
canReuseMarkup: function(markup, element) {
12322
var existingChecksum = element.getAttribute(
12323
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
12324
);
12325
existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
12326
var markupChecksum = adler32(markup);
12327
return markupChecksum === existingChecksum;
12328
}
12329
};
12330
12331
module.exports = ReactMarkupChecksum;
12332
12333
},{"119":119}],77:[function(_dereq_,module,exports){
12334
/**
12335
* Copyright 2013-2015, Facebook, Inc.
12336
* All rights reserved.
12337
*
12338
* This source code is licensed under the BSD-style license found in the
12339
* LICENSE file in the root directory of this source tree. An additional grant
12340
* of patent rights can be found in the PATENTS file in the same directory.
12341
*
12342
* @providesModule ReactMount
12343
*/
12344
12345
'use strict';
12346
12347
var DOMProperty = _dereq_(11);
12348
var ReactBrowserEventEmitter = _dereq_(33);
12349
var ReactCurrentOwner = _dereq_(45);
12350
var ReactElement = _dereq_(63);
12351
var ReactElementValidator = _dereq_(64);
12352
var ReactEmptyComponent = _dereq_(65);
12353
var ReactInstanceHandles = _dereq_(72);
12354
var ReactInstanceMap = _dereq_(73);
12355
var ReactMarkupChecksum = _dereq_(76);
12356
var ReactPerf = _dereq_(82);
12357
var ReactReconciler = _dereq_(89);
12358
var ReactUpdateQueue = _dereq_(99);
12359
var ReactUpdates = _dereq_(100);
12360
12361
var emptyObject = _dereq_(130);
12362
var containsNode = _dereq_(123);
12363
var getReactRootElementInContainer = _dereq_(144);
12364
var instantiateReactComponent = _dereq_(149);
12365
var invariant = _dereq_(150);
12366
var setInnerHTML = _dereq_(164);
12367
var shouldUpdateReactComponent = _dereq_(167);
12368
var warning = _dereq_(171);
12369
12370
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
12371
12372
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
12373
var nodeCache = {};
12374
12375
var ELEMENT_NODE_TYPE = 1;
12376
var DOC_NODE_TYPE = 9;
12377
12378
/** Mapping from reactRootID to React component instance. */
12379
var instancesByReactRootID = {};
12380
12381
/** Mapping from reactRootID to `container` nodes. */
12382
var containersByReactRootID = {};
12383
12384
if ("production" !== "development") {
12385
/** __DEV__-only mapping from reactRootID to root elements. */
12386
var rootElementsByReactRootID = {};
12387
}
12388
12389
// Used to store breadth-first search state in findComponentRoot.
12390
var findComponentRootReusableArray = [];
12391
12392
/**
12393
* Finds the index of the first character
12394
* that's not common between the two given strings.
12395
*
12396
* @return {number} the index of the character where the strings diverge
12397
*/
12398
function firstDifferenceIndex(string1, string2) {
12399
var minLen = Math.min(string1.length, string2.length);
12400
for (var i = 0; i < minLen; i++) {
12401
if (string1.charAt(i) !== string2.charAt(i)) {
12402
return i;
12403
}
12404
}
12405
return string1.length === string2.length ? -1 : minLen;
12406
}
12407
12408
/**
12409
* @param {DOMElement} container DOM element that may contain a React component.
12410
* @return {?string} A "reactRoot" ID, if a React component is rendered.
12411
*/
12412
function getReactRootID(container) {
12413
var rootElement = getReactRootElementInContainer(container);
12414
return rootElement && ReactMount.getID(rootElement);
12415
}
12416
12417
/**
12418
* Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
12419
* element can return its control whose name or ID equals ATTR_NAME. All
12420
* DOM nodes support `getAttributeNode` but this can also get called on
12421
* other objects so just return '' if we're given something other than a
12422
* DOM node (such as window).
12423
*
12424
* @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
12425
* @return {string} ID of the supplied `domNode`.
12426
*/
12427
function getID(node) {
12428
var id = internalGetID(node);
12429
if (id) {
12430
if (nodeCache.hasOwnProperty(id)) {
12431
var cached = nodeCache[id];
12432
if (cached !== node) {
12433
("production" !== "development" ? invariant(
12434
!isValid(cached, id),
12435
'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
12436
ATTR_NAME, id
12437
) : invariant(!isValid(cached, id)));
12438
12439
nodeCache[id] = node;
12440
}
12441
} else {
12442
nodeCache[id] = node;
12443
}
12444
}
12445
12446
return id;
12447
}
12448
12449
function internalGetID(node) {
12450
// If node is something like a window, document, or text node, none of
12451
// which support attributes or a .getAttribute method, gracefully return
12452
// the empty string, as if the attribute were missing.
12453
return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
12454
}
12455
12456
/**
12457
* Sets the React-specific ID of the given node.
12458
*
12459
* @param {DOMElement} node The DOM node whose ID will be set.
12460
* @param {string} id The value of the ID attribute.
12461
*/
12462
function setID(node, id) {
12463
var oldID = internalGetID(node);
12464
if (oldID !== id) {
12465
delete nodeCache[oldID];
12466
}
12467
node.setAttribute(ATTR_NAME, id);
12468
nodeCache[id] = node;
12469
}
12470
12471
/**
12472
* Finds the node with the supplied React-generated DOM ID.
12473
*
12474
* @param {string} id A React-generated DOM ID.
12475
* @return {DOMElement} DOM node with the suppled `id`.
12476
* @internal
12477
*/
12478
function getNode(id) {
12479
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
12480
nodeCache[id] = ReactMount.findReactNodeByID(id);
12481
}
12482
return nodeCache[id];
12483
}
12484
12485
/**
12486
* Finds the node with the supplied public React instance.
12487
*
12488
* @param {*} instance A public React instance.
12489
* @return {?DOMElement} DOM node with the suppled `id`.
12490
* @internal
12491
*/
12492
function getNodeFromInstance(instance) {
12493
var id = ReactInstanceMap.get(instance)._rootNodeID;
12494
if (ReactEmptyComponent.isNullComponentID(id)) {
12495
return null;
12496
}
12497
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
12498
nodeCache[id] = ReactMount.findReactNodeByID(id);
12499
}
12500
return nodeCache[id];
12501
}
12502
12503
/**
12504
* A node is "valid" if it is contained by a currently mounted container.
12505
*
12506
* This means that the node does not have to be contained by a document in
12507
* order to be considered valid.
12508
*
12509
* @param {?DOMElement} node The candidate DOM node.
12510
* @param {string} id The expected ID of the node.
12511
* @return {boolean} Whether the node is contained by a mounted container.
12512
*/
12513
function isValid(node, id) {
12514
if (node) {
12515
("production" !== "development" ? invariant(
12516
internalGetID(node) === id,
12517
'ReactMount: Unexpected modification of `%s`',
12518
ATTR_NAME
12519
) : invariant(internalGetID(node) === id));
12520
12521
var container = ReactMount.findReactContainerForID(id);
12522
if (container && containsNode(container, node)) {
12523
return true;
12524
}
12525
}
12526
12527
return false;
12528
}
12529
12530
/**
12531
* Causes the cache to forget about one React-specific ID.
12532
*
12533
* @param {string} id The ID to forget.
12534
*/
12535
function purgeID(id) {
12536
delete nodeCache[id];
12537
}
12538
12539
var deepestNodeSoFar = null;
12540
function findDeepestCachedAncestorImpl(ancestorID) {
12541
var ancestor = nodeCache[ancestorID];
12542
if (ancestor && isValid(ancestor, ancestorID)) {
12543
deepestNodeSoFar = ancestor;
12544
} else {
12545
// This node isn't populated in the cache, so presumably none of its
12546
// descendants are. Break out of the loop.
12547
return false;
12548
}
12549
}
12550
12551
/**
12552
* Return the deepest cached node whose ID is a prefix of `targetID`.
12553
*/
12554
function findDeepestCachedAncestor(targetID) {
12555
deepestNodeSoFar = null;
12556
ReactInstanceHandles.traverseAncestors(
12557
targetID,
12558
findDeepestCachedAncestorImpl
12559
);
12560
12561
var foundNode = deepestNodeSoFar;
12562
deepestNodeSoFar = null;
12563
return foundNode;
12564
}
12565
12566
/**
12567
* Mounts this component and inserts it into the DOM.
12568
*
12569
* @param {ReactComponent} componentInstance The instance to mount.
12570
* @param {string} rootID DOM ID of the root node.
12571
* @param {DOMElement} container DOM element to mount into.
12572
* @param {ReactReconcileTransaction} transaction
12573
* @param {boolean} shouldReuseMarkup If true, do not insert markup
12574
*/
12575
function mountComponentIntoNode(
12576
componentInstance,
12577
rootID,
12578
container,
12579
transaction,
12580
shouldReuseMarkup) {
12581
var markup = ReactReconciler.mountComponent(
12582
componentInstance, rootID, transaction, emptyObject
12583
);
12584
componentInstance._isTopLevel = true;
12585
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
12586
}
12587
12588
/**
12589
* Batched mount.
12590
*
12591
* @param {ReactComponent} componentInstance The instance to mount.
12592
* @param {string} rootID DOM ID of the root node.
12593
* @param {DOMElement} container DOM element to mount into.
12594
* @param {boolean} shouldReuseMarkup If true, do not insert markup
12595
*/
12596
function batchedMountComponentIntoNode(
12597
componentInstance,
12598
rootID,
12599
container,
12600
shouldReuseMarkup) {
12601
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
12602
transaction.perform(
12603
mountComponentIntoNode,
12604
null,
12605
componentInstance,
12606
rootID,
12607
container,
12608
transaction,
12609
shouldReuseMarkup
12610
);
12611
ReactUpdates.ReactReconcileTransaction.release(transaction);
12612
}
12613
12614
/**
12615
* Mounting is the process of initializing a React component by creating its
12616
* representative DOM elements and inserting them into a supplied `container`.
12617
* Any prior content inside `container` is destroyed in the process.
12618
*
12619
* ReactMount.render(
12620
* component,
12621
* document.getElementById('container')
12622
* );
12623
*
12624
* <div id="container"> <-- Supplied `container`.
12625
* <div data-reactid=".3"> <-- Rendered reactRoot of React
12626
* // ... component.
12627
* </div>
12628
* </div>
12629
*
12630
* Inside of `container`, the first element rendered is the "reactRoot".
12631
*/
12632
var ReactMount = {
12633
/** Exposed for debugging purposes **/
12634
_instancesByReactRootID: instancesByReactRootID,
12635
12636
/**
12637
* This is a hook provided to support rendering React components while
12638
* ensuring that the apparent scroll position of its `container` does not
12639
* change.
12640
*
12641
* @param {DOMElement} container The `container` being rendered into.
12642
* @param {function} renderCallback This must be called once to do the render.
12643
*/
12644
scrollMonitor: function(container, renderCallback) {
12645
renderCallback();
12646
},
12647
12648
/**
12649
* Take a component that's already mounted into the DOM and replace its props
12650
* @param {ReactComponent} prevComponent component instance already in the DOM
12651
* @param {ReactElement} nextElement component instance to render
12652
* @param {DOMElement} container container to render into
12653
* @param {?function} callback function triggered on completion
12654
*/
12655
_updateRootComponent: function(
12656
prevComponent,
12657
nextElement,
12658
container,
12659
callback) {
12660
if ("production" !== "development") {
12661
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
12662
}
12663
12664
ReactMount.scrollMonitor(container, function() {
12665
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
12666
if (callback) {
12667
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
12668
}
12669
});
12670
12671
if ("production" !== "development") {
12672
// Record the root element in case it later gets transplanted.
12673
rootElementsByReactRootID[getReactRootID(container)] =
12674
getReactRootElementInContainer(container);
12675
}
12676
12677
return prevComponent;
12678
},
12679
12680
/**
12681
* Register a component into the instance map and starts scroll value
12682
* monitoring
12683
* @param {ReactComponent} nextComponent component instance to render
12684
* @param {DOMElement} container container to render into
12685
* @return {string} reactRoot ID prefix
12686
*/
12687
_registerComponent: function(nextComponent, container) {
12688
("production" !== "development" ? invariant(
12689
container && (
12690
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12691
),
12692
'_registerComponent(...): Target container is not a DOM element.'
12693
) : invariant(container && (
12694
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12695
)));
12696
12697
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
12698
12699
var reactRootID = ReactMount.registerContainer(container);
12700
instancesByReactRootID[reactRootID] = nextComponent;
12701
return reactRootID;
12702
},
12703
12704
/**
12705
* Render a new component into the DOM.
12706
* @param {ReactElement} nextElement element to render
12707
* @param {DOMElement} container container to render into
12708
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion
12709
* @return {ReactComponent} nextComponent
12710
*/
12711
_renderNewRootComponent: function(
12712
nextElement,
12713
container,
12714
shouldReuseMarkup
12715
) {
12716
// Various parts of our code (such as ReactCompositeComponent's
12717
// _renderValidatedComponent) assume that calls to render aren't nested;
12718
// verify that that's the case.
12719
("production" !== "development" ? warning(
12720
ReactCurrentOwner.current == null,
12721
'_renderNewRootComponent(): Render methods should be a pure function ' +
12722
'of props and state; triggering nested component updates from ' +
12723
'render is not allowed. If necessary, trigger nested updates in ' +
12724
'componentDidUpdate.'
12725
) : null);
12726
12727
var componentInstance = instantiateReactComponent(nextElement, null);
12728
var reactRootID = ReactMount._registerComponent(
12729
componentInstance,
12730
container
12731
);
12732
12733
// The initial render is synchronous but any updates that happen during
12734
// rendering, in componentWillMount or componentDidMount, will be batched
12735
// according to the current batching strategy.
12736
12737
ReactUpdates.batchedUpdates(
12738
batchedMountComponentIntoNode,
12739
componentInstance,
12740
reactRootID,
12741
container,
12742
shouldReuseMarkup
12743
);
12744
12745
if ("production" !== "development") {
12746
// Record the root element in case it later gets transplanted.
12747
rootElementsByReactRootID[reactRootID] =
12748
getReactRootElementInContainer(container);
12749
}
12750
12751
return componentInstance;
12752
},
12753
12754
/**
12755
* Renders a React component into the DOM in the supplied `container`.
12756
*
12757
* If the React component was previously rendered into `container`, this will
12758
* perform an update on it and only mutate the DOM as necessary to reflect the
12759
* latest React component.
12760
*
12761
* @param {ReactElement} nextElement Component element to render.
12762
* @param {DOMElement} container DOM element to render into.
12763
* @param {?function} callback function triggered on completion
12764
* @return {ReactComponent} Component instance rendered in `container`.
12765
*/
12766
render: function(nextElement, container, callback) {
12767
("production" !== "development" ? invariant(
12768
ReactElement.isValidElement(nextElement),
12769
'React.render(): Invalid component element.%s',
12770
(
12771
typeof nextElement === 'string' ?
12772
' Instead of passing an element string, make sure to instantiate ' +
12773
'it by passing it to React.createElement.' :
12774
typeof nextElement === 'function' ?
12775
' Instead of passing a component class, make sure to instantiate ' +
12776
'it by passing it to React.createElement.' :
12777
// Check if it quacks like an element
12778
nextElement != null && nextElement.props !== undefined ?
12779
' This may be caused by unintentionally loading two independent ' +
12780
'copies of React.' :
12781
''
12782
)
12783
) : invariant(ReactElement.isValidElement(nextElement)));
12784
12785
var prevComponent = instancesByReactRootID[getReactRootID(container)];
12786
12787
if (prevComponent) {
12788
var prevElement = prevComponent._currentElement;
12789
if (shouldUpdateReactComponent(prevElement, nextElement)) {
12790
return ReactMount._updateRootComponent(
12791
prevComponent,
12792
nextElement,
12793
container,
12794
callback
12795
).getPublicInstance();
12796
} else {
12797
ReactMount.unmountComponentAtNode(container);
12798
}
12799
}
12800
12801
var reactRootElement = getReactRootElementInContainer(container);
12802
var containerHasReactMarkup =
12803
reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
12804
12805
if ("production" !== "development") {
12806
if (!containerHasReactMarkup || reactRootElement.nextSibling) {
12807
var rootElementSibling = reactRootElement;
12808
while (rootElementSibling) {
12809
if (ReactMount.isRenderedByReact(rootElementSibling)) {
12810
("production" !== "development" ? warning(
12811
false,
12812
'render(): Target node has markup rendered by React, but there ' +
12813
'are unrelated nodes as well. This is most commonly caused by ' +
12814
'white-space inserted around server-rendered markup.'
12815
) : null);
12816
break;
12817
}
12818
12819
rootElementSibling = rootElementSibling.nextSibling;
12820
}
12821
}
12822
}
12823
12824
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
12825
12826
var component = ReactMount._renderNewRootComponent(
12827
nextElement,
12828
container,
12829
shouldReuseMarkup
12830
).getPublicInstance();
12831
if (callback) {
12832
callback.call(component);
12833
}
12834
return component;
12835
},
12836
12837
/**
12838
* Constructs a component instance of `constructor` with `initialProps` and
12839
* renders it into the supplied `container`.
12840
*
12841
* @param {function} constructor React component constructor.
12842
* @param {?object} props Initial props of the component instance.
12843
* @param {DOMElement} container DOM element to render into.
12844
* @return {ReactComponent} Component instance rendered in `container`.
12845
*/
12846
constructAndRenderComponent: function(constructor, props, container) {
12847
var element = ReactElement.createElement(constructor, props);
12848
return ReactMount.render(element, container);
12849
},
12850
12851
/**
12852
* Constructs a component instance of `constructor` with `initialProps` and
12853
* renders it into a container node identified by supplied `id`.
12854
*
12855
* @param {function} componentConstructor React component constructor
12856
* @param {?object} props Initial props of the component instance.
12857
* @param {string} id ID of the DOM element to render into.
12858
* @return {ReactComponent} Component instance rendered in the container node.
12859
*/
12860
constructAndRenderComponentByID: function(constructor, props, id) {
12861
var domNode = document.getElementById(id);
12862
("production" !== "development" ? invariant(
12863
domNode,
12864
'Tried to get element with id of "%s" but it is not present on the page.',
12865
id
12866
) : invariant(domNode));
12867
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
12868
},
12869
12870
/**
12871
* Registers a container node into which React components will be rendered.
12872
* This also creates the "reactRoot" ID that will be assigned to the element
12873
* rendered within.
12874
*
12875
* @param {DOMElement} container DOM element to register as a container.
12876
* @return {string} The "reactRoot" ID of elements rendered within.
12877
*/
12878
registerContainer: function(container) {
12879
var reactRootID = getReactRootID(container);
12880
if (reactRootID) {
12881
// If one exists, make sure it is a valid "reactRoot" ID.
12882
reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
12883
}
12884
if (!reactRootID) {
12885
// No valid "reactRoot" ID found, create one.
12886
reactRootID = ReactInstanceHandles.createReactRootID();
12887
}
12888
containersByReactRootID[reactRootID] = container;
12889
return reactRootID;
12890
},
12891
12892
/**
12893
* Unmounts and destroys the React component rendered in the `container`.
12894
*
12895
* @param {DOMElement} container DOM element containing a React component.
12896
* @return {boolean} True if a component was found in and unmounted from
12897
* `container`
12898
*/
12899
unmountComponentAtNode: function(container) {
12900
// Various parts of our code (such as ReactCompositeComponent's
12901
// _renderValidatedComponent) assume that calls to render aren't nested;
12902
// verify that that's the case. (Strictly speaking, unmounting won't cause a
12903
// render but we still don't expect to be in a render call here.)
12904
("production" !== "development" ? warning(
12905
ReactCurrentOwner.current == null,
12906
'unmountComponentAtNode(): Render methods should be a pure function of ' +
12907
'props and state; triggering nested component updates from render is ' +
12908
'not allowed. If necessary, trigger nested updates in ' +
12909
'componentDidUpdate.'
12910
) : null);
12911
12912
("production" !== "development" ? invariant(
12913
container && (
12914
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12915
),
12916
'unmountComponentAtNode(...): Target container is not a DOM element.'
12917
) : invariant(container && (
12918
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
12919
)));
12920
12921
var reactRootID = getReactRootID(container);
12922
var component = instancesByReactRootID[reactRootID];
12923
if (!component) {
12924
return false;
12925
}
12926
ReactMount.unmountComponentFromNode(component, container);
12927
delete instancesByReactRootID[reactRootID];
12928
delete containersByReactRootID[reactRootID];
12929
if ("production" !== "development") {
12930
delete rootElementsByReactRootID[reactRootID];
12931
}
12932
return true;
12933
},
12934
12935
/**
12936
* Unmounts a component and removes it from the DOM.
12937
*
12938
* @param {ReactComponent} instance React component instance.
12939
* @param {DOMElement} container DOM element to unmount from.
12940
* @final
12941
* @internal
12942
* @see {ReactMount.unmountComponentAtNode}
12943
*/
12944
unmountComponentFromNode: function(instance, container) {
12945
ReactReconciler.unmountComponent(instance);
12946
12947
if (container.nodeType === DOC_NODE_TYPE) {
12948
container = container.documentElement;
12949
}
12950
12951
// http://jsperf.com/emptying-a-node
12952
while (container.lastChild) {
12953
container.removeChild(container.lastChild);
12954
}
12955
},
12956
12957
/**
12958
* Finds the container DOM element that contains React component to which the
12959
* supplied DOM `id` belongs.
12960
*
12961
* @param {string} id The ID of an element rendered by a React component.
12962
* @return {?DOMElement} DOM element that contains the `id`.
12963
*/
12964
findReactContainerForID: function(id) {
12965
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
12966
var container = containersByReactRootID[reactRootID];
12967
12968
if ("production" !== "development") {
12969
var rootElement = rootElementsByReactRootID[reactRootID];
12970
if (rootElement && rootElement.parentNode !== container) {
12971
("production" !== "development" ? invariant(
12972
// Call internalGetID here because getID calls isValid which calls
12973
// findReactContainerForID (this function).
12974
internalGetID(rootElement) === reactRootID,
12975
'ReactMount: Root element ID differed from reactRootID.'
12976
) : invariant(// Call internalGetID here because getID calls isValid which calls
12977
// findReactContainerForID (this function).
12978
internalGetID(rootElement) === reactRootID));
12979
12980
var containerChild = container.firstChild;
12981
if (containerChild &&
12982
reactRootID === internalGetID(containerChild)) {
12983
// If the container has a new child with the same ID as the old
12984
// root element, then rootElementsByReactRootID[reactRootID] is
12985
// just stale and needs to be updated. The case that deserves a
12986
// warning is when the container is empty.
12987
rootElementsByReactRootID[reactRootID] = containerChild;
12988
} else {
12989
("production" !== "development" ? warning(
12990
false,
12991
'ReactMount: Root element has been removed from its original ' +
12992
'container. New container:', rootElement.parentNode
12993
) : null);
12994
}
12995
}
12996
}
12997
12998
return container;
12999
},
13000
13001
/**
13002
* Finds an element rendered by React with the supplied ID.
13003
*
13004
* @param {string} id ID of a DOM node in the React component.
13005
* @return {DOMElement} Root DOM node of the React component.
13006
*/
13007
findReactNodeByID: function(id) {
13008
var reactRoot = ReactMount.findReactContainerForID(id);
13009
return ReactMount.findComponentRoot(reactRoot, id);
13010
},
13011
13012
/**
13013
* True if the supplied `node` is rendered by React.
13014
*
13015
* @param {*} node DOM Element to check.
13016
* @return {boolean} True if the DOM Element appears to be rendered by React.
13017
* @internal
13018
*/
13019
isRenderedByReact: function(node) {
13020
if (node.nodeType !== 1) {
13021
// Not a DOMElement, therefore not a React component
13022
return false;
13023
}
13024
var id = ReactMount.getID(node);
13025
return id ? id.charAt(0) === SEPARATOR : false;
13026
},
13027
13028
/**
13029
* Traverses up the ancestors of the supplied node to find a node that is a
13030
* DOM representation of a React component.
13031
*
13032
* @param {*} node
13033
* @return {?DOMEventTarget}
13034
* @internal
13035
*/
13036
getFirstReactDOM: function(node) {
13037
var current = node;
13038
while (current && current.parentNode !== current) {
13039
if (ReactMount.isRenderedByReact(current)) {
13040
return current;
13041
}
13042
current = current.parentNode;
13043
}
13044
return null;
13045
},
13046
13047
/**
13048
* Finds a node with the supplied `targetID` inside of the supplied
13049
* `ancestorNode`. Exploits the ID naming scheme to perform the search
13050
* quickly.
13051
*
13052
* @param {DOMEventTarget} ancestorNode Search from this root.
13053
* @pararm {string} targetID ID of the DOM representation of the component.
13054
* @return {DOMEventTarget} DOM node with the supplied `targetID`.
13055
* @internal
13056
*/
13057
findComponentRoot: function(ancestorNode, targetID) {
13058
var firstChildren = findComponentRootReusableArray;
13059
var childIndex = 0;
13060
13061
var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
13062
13063
firstChildren[0] = deepestAncestor.firstChild;
13064
firstChildren.length = 1;
13065
13066
while (childIndex < firstChildren.length) {
13067
var child = firstChildren[childIndex++];
13068
var targetChild;
13069
13070
while (child) {
13071
var childID = ReactMount.getID(child);
13072
if (childID) {
13073
// Even if we find the node we're looking for, we finish looping
13074
// through its siblings to ensure they're cached so that we don't have
13075
// to revisit this node again. Otherwise, we make n^2 calls to getID
13076
// when visiting the many children of a single node in order.
13077
13078
if (targetID === childID) {
13079
targetChild = child;
13080
} else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
13081
// If we find a child whose ID is an ancestor of the given ID,
13082
// then we can be sure that we only want to search the subtree
13083
// rooted at this child, so we can throw out the rest of the
13084
// search state.
13085
firstChildren.length = childIndex = 0;
13086
firstChildren.push(child.firstChild);
13087
}
13088
13089
} else {
13090
// If this child had no ID, then there's a chance that it was
13091
// injected automatically by the browser, as when a `<table>`
13092
// element sprouts an extra `<tbody>` child as a side effect of
13093
// `.innerHTML` parsing. Optimistically continue down this
13094
// branch, but not before examining the other siblings.
13095
firstChildren.push(child.firstChild);
13096
}
13097
13098
child = child.nextSibling;
13099
}
13100
13101
if (targetChild) {
13102
// Emptying firstChildren/findComponentRootReusableArray is
13103
// not necessary for correctness, but it helps the GC reclaim
13104
// any nodes that were left at the end of the search.
13105
firstChildren.length = 0;
13106
13107
return targetChild;
13108
}
13109
}
13110
13111
firstChildren.length = 0;
13112
13113
("production" !== "development" ? invariant(
13114
false,
13115
'findComponentRoot(..., %s): Unable to find element. This probably ' +
13116
'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
13117
'usually due to forgetting a <tbody> when using tables, nesting tags ' +
13118
'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
13119
'parent. ' +
13120
'Try inspecting the child nodes of the element with React ID `%s`.',
13121
targetID,
13122
ReactMount.getID(ancestorNode)
13123
) : invariant(false));
13124
},
13125
13126
_mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
13127
("production" !== "development" ? invariant(
13128
container && (
13129
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
13130
),
13131
'mountComponentIntoNode(...): Target container is not valid.'
13132
) : invariant(container && (
13133
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
13134
)));
13135
13136
if (shouldReuseMarkup) {
13137
var rootElement = getReactRootElementInContainer(container);
13138
if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
13139
return;
13140
} else {
13141
var checksum = rootElement.getAttribute(
13142
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
13143
);
13144
rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
13145
13146
var rootMarkup = rootElement.outerHTML;
13147
rootElement.setAttribute(
13148
ReactMarkupChecksum.CHECKSUM_ATTR_NAME,
13149
checksum
13150
);
13151
13152
var diffIndex = firstDifferenceIndex(markup, rootMarkup);
13153
var difference = ' (client) ' +
13154
markup.substring(diffIndex - 20, diffIndex + 20) +
13155
'\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
13156
13157
("production" !== "development" ? invariant(
13158
container.nodeType !== DOC_NODE_TYPE,
13159
'You\'re trying to render a component to the document using ' +
13160
'server rendering but the checksum was invalid. This usually ' +
13161
'means you rendered a different component type or props on ' +
13162
'the client from the one on the server, or your render() ' +
13163
'methods are impure. React cannot handle this case due to ' +
13164
'cross-browser quirks by rendering at the document root. You ' +
13165
'should look for environment dependent code in your components ' +
13166
'and ensure the props are the same client and server side:\n%s',
13167
difference
13168
) : invariant(container.nodeType !== DOC_NODE_TYPE));
13169
13170
if ("production" !== "development") {
13171
("production" !== "development" ? warning(
13172
false,
13173
'React attempted to reuse markup in a container but the ' +
13174
'checksum was invalid. This generally means that you are ' +
13175
'using server rendering and the markup generated on the ' +
13176
'server was not what the client was expecting. React injected ' +
13177
'new markup to compensate which works but you have lost many ' +
13178
'of the benefits of server rendering. Instead, figure out ' +
13179
'why the markup being generated is different on the client ' +
13180
'or server:\n%s',
13181
difference
13182
) : null);
13183
}
13184
}
13185
}
13186
13187
("production" !== "development" ? invariant(
13188
container.nodeType !== DOC_NODE_TYPE,
13189
'You\'re trying to render a component to the document but ' +
13190
'you didn\'t use server rendering. We can\'t do this ' +
13191
'without using server rendering due to cross-browser quirks. ' +
13192
'See React.renderToString() for server rendering.'
13193
) : invariant(container.nodeType !== DOC_NODE_TYPE));
13194
13195
setInnerHTML(container, markup);
13196
},
13197
13198
/**
13199
* React ID utilities.
13200
*/
13201
13202
getReactRootID: getReactRootID,
13203
13204
getID: getID,
13205
13206
setID: setID,
13207
13208
getNode: getNode,
13209
13210
getNodeFromInstance: getNodeFromInstance,
13211
13212
purgeID: purgeID
13213
};
13214
13215
ReactPerf.measureMethods(ReactMount, 'ReactMount', {
13216
_renderNewRootComponent: '_renderNewRootComponent',
13217
_mountImageIntoNode: '_mountImageIntoNode'
13218
});
13219
13220
module.exports = ReactMount;
13221
13222
},{"100":100,"11":11,"123":123,"130":130,"144":144,"149":149,"150":150,"164":164,"167":167,"171":171,"33":33,"45":45,"63":63,"64":64,"65":65,"72":72,"73":73,"76":76,"82":82,"89":89,"99":99}],78:[function(_dereq_,module,exports){
13223
/**
13224
* Copyright 2013-2015, Facebook, Inc.
13225
* All rights reserved.
13226
*
13227
* This source code is licensed under the BSD-style license found in the
13228
* LICENSE file in the root directory of this source tree. An additional grant
13229
* of patent rights can be found in the PATENTS file in the same directory.
13230
*
13231
* @providesModule ReactMultiChild
13232
* @typechecks static-only
13233
*/
13234
13235
'use strict';
13236
13237
var ReactComponentEnvironment = _dereq_(41);
13238
var ReactMultiChildUpdateTypes = _dereq_(79);
13239
13240
var ReactReconciler = _dereq_(89);
13241
var ReactChildReconciler = _dereq_(36);
13242
13243
/**
13244
* Updating children of a component may trigger recursive updates. The depth is
13245
* used to batch recursive updates to render markup more efficiently.
13246
*
13247
* @type {number}
13248
* @private
13249
*/
13250
var updateDepth = 0;
13251
13252
/**
13253
* Queue of update configuration objects.
13254
*
13255
* Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
13256
*
13257
* @type {array<object>}
13258
* @private
13259
*/
13260
var updateQueue = [];
13261
13262
/**
13263
* Queue of markup to be rendered.
13264
*
13265
* @type {array<string>}
13266
* @private
13267
*/
13268
var markupQueue = [];
13269
13270
/**
13271
* Enqueues markup to be rendered and inserted at a supplied index.
13272
*
13273
* @param {string} parentID ID of the parent component.
13274
* @param {string} markup Markup that renders into an element.
13275
* @param {number} toIndex Destination index.
13276
* @private
13277
*/
13278
function enqueueMarkup(parentID, markup, toIndex) {
13279
// NOTE: Null values reduce hidden classes.
13280
updateQueue.push({
13281
parentID: parentID,
13282
parentNode: null,
13283
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
13284
markupIndex: markupQueue.push(markup) - 1,
13285
textContent: null,
13286
fromIndex: null,
13287
toIndex: toIndex
13288
});
13289
}
13290
13291
/**
13292
* Enqueues moving an existing element to another index.
13293
*
13294
* @param {string} parentID ID of the parent component.
13295
* @param {number} fromIndex Source index of the existing element.
13296
* @param {number} toIndex Destination index of the element.
13297
* @private
13298
*/
13299
function enqueueMove(parentID, fromIndex, toIndex) {
13300
// NOTE: Null values reduce hidden classes.
13301
updateQueue.push({
13302
parentID: parentID,
13303
parentNode: null,
13304
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
13305
markupIndex: null,
13306
textContent: null,
13307
fromIndex: fromIndex,
13308
toIndex: toIndex
13309
});
13310
}
13311
13312
/**
13313
* Enqueues removing an element at an index.
13314
*
13315
* @param {string} parentID ID of the parent component.
13316
* @param {number} fromIndex Index of the element to remove.
13317
* @private
13318
*/
13319
function enqueueRemove(parentID, fromIndex) {
13320
// NOTE: Null values reduce hidden classes.
13321
updateQueue.push({
13322
parentID: parentID,
13323
parentNode: null,
13324
type: ReactMultiChildUpdateTypes.REMOVE_NODE,
13325
markupIndex: null,
13326
textContent: null,
13327
fromIndex: fromIndex,
13328
toIndex: null
13329
});
13330
}
13331
13332
/**
13333
* Enqueues setting the text content.
13334
*
13335
* @param {string} parentID ID of the parent component.
13336
* @param {string} textContent Text content to set.
13337
* @private
13338
*/
13339
function enqueueTextContent(parentID, textContent) {
13340
// NOTE: Null values reduce hidden classes.
13341
updateQueue.push({
13342
parentID: parentID,
13343
parentNode: null,
13344
type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
13345
markupIndex: null,
13346
textContent: textContent,
13347
fromIndex: null,
13348
toIndex: null
13349
});
13350
}
13351
13352
/**
13353
* Processes any enqueued updates.
13354
*
13355
* @private
13356
*/
13357
function processQueue() {
13358
if (updateQueue.length) {
13359
ReactComponentEnvironment.processChildrenUpdates(
13360
updateQueue,
13361
markupQueue
13362
);
13363
clearQueue();
13364
}
13365
}
13366
13367
/**
13368
* Clears any enqueued updates.
13369
*
13370
* @private
13371
*/
13372
function clearQueue() {
13373
updateQueue.length = 0;
13374
markupQueue.length = 0;
13375
}
13376
13377
/**
13378
* ReactMultiChild are capable of reconciling multiple children.
13379
*
13380
* @class ReactMultiChild
13381
* @internal
13382
*/
13383
var ReactMultiChild = {
13384
13385
/**
13386
* Provides common functionality for components that must reconcile multiple
13387
* children. This is used by `ReactDOMComponent` to mount, update, and
13388
* unmount child components.
13389
*
13390
* @lends {ReactMultiChild.prototype}
13391
*/
13392
Mixin: {
13393
13394
/**
13395
* Generates a "mount image" for each of the supplied children. In the case
13396
* of `ReactDOMComponent`, a mount image is a string of markup.
13397
*
13398
* @param {?object} nestedChildren Nested child maps.
13399
* @return {array} An array of mounted representations.
13400
* @internal
13401
*/
13402
mountChildren: function(nestedChildren, transaction, context) {
13403
var children = ReactChildReconciler.instantiateChildren(
13404
nestedChildren, transaction, context
13405
);
13406
this._renderedChildren = children;
13407
var mountImages = [];
13408
var index = 0;
13409
for (var name in children) {
13410
if (children.hasOwnProperty(name)) {
13411
var child = children[name];
13412
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
13413
var rootID = this._rootNodeID + name;
13414
var mountImage = ReactReconciler.mountComponent(
13415
child,
13416
rootID,
13417
transaction,
13418
context
13419
);
13420
child._mountIndex = index;
13421
mountImages.push(mountImage);
13422
index++;
13423
}
13424
}
13425
return mountImages;
13426
},
13427
13428
/**
13429
* Replaces any rendered children with a text content string.
13430
*
13431
* @param {string} nextContent String of content.
13432
* @internal
13433
*/
13434
updateTextContent: function(nextContent) {
13435
updateDepth++;
13436
var errorThrown = true;
13437
try {
13438
var prevChildren = this._renderedChildren;
13439
// Remove any rendered children.
13440
ReactChildReconciler.unmountChildren(prevChildren);
13441
// TODO: The setTextContent operation should be enough
13442
for (var name in prevChildren) {
13443
if (prevChildren.hasOwnProperty(name)) {
13444
this._unmountChildByName(prevChildren[name], name);
13445
}
13446
}
13447
// Set new text content.
13448
this.setTextContent(nextContent);
13449
errorThrown = false;
13450
} finally {
13451
updateDepth--;
13452
if (!updateDepth) {
13453
if (errorThrown) {
13454
clearQueue();
13455
} else {
13456
processQueue();
13457
}
13458
}
13459
}
13460
},
13461
13462
/**
13463
* Updates the rendered children with new children.
13464
*
13465
* @param {?object} nextNestedChildren Nested child maps.
13466
* @param {ReactReconcileTransaction} transaction
13467
* @internal
13468
*/
13469
updateChildren: function(nextNestedChildren, transaction, context) {
13470
updateDepth++;
13471
var errorThrown = true;
13472
try {
13473
this._updateChildren(nextNestedChildren, transaction, context);
13474
errorThrown = false;
13475
} finally {
13476
updateDepth--;
13477
if (!updateDepth) {
13478
if (errorThrown) {
13479
clearQueue();
13480
} else {
13481
processQueue();
13482
}
13483
}
13484
13485
}
13486
},
13487
13488
/**
13489
* Improve performance by isolating this hot code path from the try/catch
13490
* block in `updateChildren`.
13491
*
13492
* @param {?object} nextNestedChildren Nested child maps.
13493
* @param {ReactReconcileTransaction} transaction
13494
* @final
13495
* @protected
13496
*/
13497
_updateChildren: function(nextNestedChildren, transaction, context) {
13498
var prevChildren = this._renderedChildren;
13499
var nextChildren = ReactChildReconciler.updateChildren(
13500
prevChildren, nextNestedChildren, transaction, context
13501
);
13502
this._renderedChildren = nextChildren;
13503
if (!nextChildren && !prevChildren) {
13504
return;
13505
}
13506
var name;
13507
// `nextIndex` will increment for each child in `nextChildren`, but
13508
// `lastIndex` will be the last index visited in `prevChildren`.
13509
var lastIndex = 0;
13510
var nextIndex = 0;
13511
for (name in nextChildren) {
13512
if (!nextChildren.hasOwnProperty(name)) {
13513
continue;
13514
}
13515
var prevChild = prevChildren && prevChildren[name];
13516
var nextChild = nextChildren[name];
13517
if (prevChild === nextChild) {
13518
this.moveChild(prevChild, nextIndex, lastIndex);
13519
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
13520
prevChild._mountIndex = nextIndex;
13521
} else {
13522
if (prevChild) {
13523
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
13524
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
13525
this._unmountChildByName(prevChild, name);
13526
}
13527
// The child must be instantiated before it's mounted.
13528
this._mountChildByNameAtIndex(
13529
nextChild, name, nextIndex, transaction, context
13530
);
13531
}
13532
nextIndex++;
13533
}
13534
// Remove children that are no longer present.
13535
for (name in prevChildren) {
13536
if (prevChildren.hasOwnProperty(name) &&
13537
!(nextChildren && nextChildren.hasOwnProperty(name))) {
13538
this._unmountChildByName(prevChildren[name], name);
13539
}
13540
}
13541
},
13542
13543
/**
13544
* Unmounts all rendered children. This should be used to clean up children
13545
* when this component is unmounted.
13546
*
13547
* @internal
13548
*/
13549
unmountChildren: function() {
13550
var renderedChildren = this._renderedChildren;
13551
ReactChildReconciler.unmountChildren(renderedChildren);
13552
this._renderedChildren = null;
13553
},
13554
13555
/**
13556
* Moves a child component to the supplied index.
13557
*
13558
* @param {ReactComponent} child Component to move.
13559
* @param {number} toIndex Destination index of the element.
13560
* @param {number} lastIndex Last index visited of the siblings of `child`.
13561
* @protected
13562
*/
13563
moveChild: function(child, toIndex, lastIndex) {
13564
// If the index of `child` is less than `lastIndex`, then it needs to
13565
// be moved. Otherwise, we do not need to move it because a child will be
13566
// inserted or moved before `child`.
13567
if (child._mountIndex < lastIndex) {
13568
enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
13569
}
13570
},
13571
13572
/**
13573
* Creates a child component.
13574
*
13575
* @param {ReactComponent} child Component to create.
13576
* @param {string} mountImage Markup to insert.
13577
* @protected
13578
*/
13579
createChild: function(child, mountImage) {
13580
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
13581
},
13582
13583
/**
13584
* Removes a child component.
13585
*
13586
* @param {ReactComponent} child Child to remove.
13587
* @protected
13588
*/
13589
removeChild: function(child) {
13590
enqueueRemove(this._rootNodeID, child._mountIndex);
13591
},
13592
13593
/**
13594
* Sets this text content string.
13595
*
13596
* @param {string} textContent Text content to set.
13597
* @protected
13598
*/
13599
setTextContent: function(textContent) {
13600
enqueueTextContent(this._rootNodeID, textContent);
13601
},
13602
13603
/**
13604
* Mounts a child with the supplied name.
13605
*
13606
* NOTE: This is part of `updateChildren` and is here for readability.
13607
*
13608
* @param {ReactComponent} child Component to mount.
13609
* @param {string} name Name of the child.
13610
* @param {number} index Index at which to insert the child.
13611
* @param {ReactReconcileTransaction} transaction
13612
* @private
13613
*/
13614
_mountChildByNameAtIndex: function(
13615
child,
13616
name,
13617
index,
13618
transaction,
13619
context) {
13620
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
13621
var rootID = this._rootNodeID + name;
13622
var mountImage = ReactReconciler.mountComponent(
13623
child,
13624
rootID,
13625
transaction,
13626
context
13627
);
13628
child._mountIndex = index;
13629
this.createChild(child, mountImage);
13630
},
13631
13632
/**
13633
* Unmounts a rendered child by name.
13634
*
13635
* NOTE: This is part of `updateChildren` and is here for readability.
13636
*
13637
* @param {ReactComponent} child Component to unmount.
13638
* @param {string} name Name of the child in `this._renderedChildren`.
13639
* @private
13640
*/
13641
_unmountChildByName: function(child, name) {
13642
this.removeChild(child);
13643
child._mountIndex = null;
13644
}
13645
13646
}
13647
13648
};
13649
13650
module.exports = ReactMultiChild;
13651
13652
},{"36":36,"41":41,"79":79,"89":89}],79:[function(_dereq_,module,exports){
13653
/**
13654
* Copyright 2013-2015, Facebook, Inc.
13655
* All rights reserved.
13656
*
13657
* This source code is licensed under the BSD-style license found in the
13658
* LICENSE file in the root directory of this source tree. An additional grant
13659
* of patent rights can be found in the PATENTS file in the same directory.
13660
*
13661
* @providesModule ReactMultiChildUpdateTypes
13662
*/
13663
13664
'use strict';
13665
13666
var keyMirror = _dereq_(156);
13667
13668
/**
13669
* When a component's children are updated, a series of update configuration
13670
* objects are created in order to batch and serialize the required changes.
13671
*
13672
* Enumerates all the possible types of update configurations.
13673
*
13674
* @internal
13675
*/
13676
var ReactMultiChildUpdateTypes = keyMirror({
13677
INSERT_MARKUP: null,
13678
MOVE_EXISTING: null,
13679
REMOVE_NODE: null,
13680
TEXT_CONTENT: null
13681
});
13682
13683
module.exports = ReactMultiChildUpdateTypes;
13684
13685
},{"156":156}],80:[function(_dereq_,module,exports){
13686
/**
13687
* Copyright 2014-2015, Facebook, Inc.
13688
* All rights reserved.
13689
*
13690
* This source code is licensed under the BSD-style license found in the
13691
* LICENSE file in the root directory of this source tree. An additional grant
13692
* of patent rights can be found in the PATENTS file in the same directory.
13693
*
13694
* @providesModule ReactNativeComponent
13695
*/
13696
13697
'use strict';
13698
13699
var assign = _dereq_(29);
13700
var invariant = _dereq_(150);
13701
13702
var autoGenerateWrapperClass = null;
13703
var genericComponentClass = null;
13704
// This registry keeps track of wrapper classes around native tags
13705
var tagToComponentClass = {};
13706
var textComponentClass = null;
13707
13708
var ReactNativeComponentInjection = {
13709
// This accepts a class that receives the tag string. This is a catch all
13710
// that can render any kind of tag.
13711
injectGenericComponentClass: function(componentClass) {
13712
genericComponentClass = componentClass;
13713
},
13714
// This accepts a text component class that takes the text string to be
13715
// rendered as props.
13716
injectTextComponentClass: function(componentClass) {
13717
textComponentClass = componentClass;
13718
},
13719
// This accepts a keyed object with classes as values. Each key represents a
13720
// tag. That particular tag will use this class instead of the generic one.
13721
injectComponentClasses: function(componentClasses) {
13722
assign(tagToComponentClass, componentClasses);
13723
},
13724
// Temporary hack since we expect DOM refs to behave like composites,
13725
// for this release.
13726
injectAutoWrapper: function(wrapperFactory) {
13727
autoGenerateWrapperClass = wrapperFactory;
13728
}
13729
};
13730
13731
/**
13732
* Get a composite component wrapper class for a specific tag.
13733
*
13734
* @param {ReactElement} element The tag for which to get the class.
13735
* @return {function} The React class constructor function.
13736
*/
13737
function getComponentClassForElement(element) {
13738
if (typeof element.type === 'function') {
13739
return element.type;
13740
}
13741
var tag = element.type;
13742
var componentClass = tagToComponentClass[tag];
13743
if (componentClass == null) {
13744
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
13745
}
13746
return componentClass;
13747
}
13748
13749
/**
13750
* Get a native internal component class for a specific tag.
13751
*
13752
* @param {ReactElement} element The element to create.
13753
* @return {function} The internal class constructor function.
13754
*/
13755
function createInternalComponent(element) {
13756
("production" !== "development" ? invariant(
13757
genericComponentClass,
13758
'There is no registered component for the tag %s',
13759
element.type
13760
) : invariant(genericComponentClass));
13761
return new genericComponentClass(element.type, element.props);
13762
}
13763
13764
/**
13765
* @param {ReactText} text
13766
* @return {ReactComponent}
13767
*/
13768
function createInstanceForText(text) {
13769
return new textComponentClass(text);
13770
}
13771
13772
/**
13773
* @param {ReactComponent} component
13774
* @return {boolean}
13775
*/
13776
function isTextComponent(component) {
13777
return component instanceof textComponentClass;
13778
}
13779
13780
var ReactNativeComponent = {
13781
getComponentClassForElement: getComponentClassForElement,
13782
createInternalComponent: createInternalComponent,
13783
createInstanceForText: createInstanceForText,
13784
isTextComponent: isTextComponent,
13785
injection: ReactNativeComponentInjection
13786
};
13787
13788
module.exports = ReactNativeComponent;
13789
13790
},{"150":150,"29":29}],81:[function(_dereq_,module,exports){
13791
/**
13792
* Copyright 2013-2015, Facebook, Inc.
13793
* All rights reserved.
13794
*
13795
* This source code is licensed under the BSD-style license found in the
13796
* LICENSE file in the root directory of this source tree. An additional grant
13797
* of patent rights can be found in the PATENTS file in the same directory.
13798
*
13799
* @providesModule ReactOwner
13800
*/
13801
13802
'use strict';
13803
13804
var invariant = _dereq_(150);
13805
13806
/**
13807
* ReactOwners are capable of storing references to owned components.
13808
*
13809
* All components are capable of //being// referenced by owner components, but
13810
* only ReactOwner components are capable of //referencing// owned components.
13811
* The named reference is known as a "ref".
13812
*
13813
* Refs are available when mounted and updated during reconciliation.
13814
*
13815
* var MyComponent = React.createClass({
13816
* render: function() {
13817
* return (
13818
* <div onClick={this.handleClick}>
13819
* <CustomComponent ref="custom" />
13820
* </div>
13821
* );
13822
* },
13823
* handleClick: function() {
13824
* this.refs.custom.handleClick();
13825
* },
13826
* componentDidMount: function() {
13827
* this.refs.custom.initialize();
13828
* }
13829
* });
13830
*
13831
* Refs should rarely be used. When refs are used, they should only be done to
13832
* control data that is not handled by React's data flow.
13833
*
13834
* @class ReactOwner
13835
*/
13836
var ReactOwner = {
13837
13838
/**
13839
* @param {?object} object
13840
* @return {boolean} True if `object` is a valid owner.
13841
* @final
13842
*/
13843
isValidOwner: function(object) {
13844
return !!(
13845
(object &&
13846
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
13847
);
13848
},
13849
13850
/**
13851
* Adds a component by ref to an owner component.
13852
*
13853
* @param {ReactComponent} component Component to reference.
13854
* @param {string} ref Name by which to refer to the component.
13855
* @param {ReactOwner} owner Component on which to record the ref.
13856
* @final
13857
* @internal
13858
*/
13859
addComponentAsRefTo: function(component, ref, owner) {
13860
("production" !== "development" ? invariant(
13861
ReactOwner.isValidOwner(owner),
13862
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
13863
'usually means that you\'re trying to add a ref to a component that ' +
13864
'doesn\'t have an owner (that is, was not created inside of another ' +
13865
'component\'s `render` method). Try rendering this component inside of ' +
13866
'a new top-level component which will hold the ref.'
13867
) : invariant(ReactOwner.isValidOwner(owner)));
13868
owner.attachRef(ref, component);
13869
},
13870
13871
/**
13872
* Removes a component by ref from an owner component.
13873
*
13874
* @param {ReactComponent} component Component to dereference.
13875
* @param {string} ref Name of the ref to remove.
13876
* @param {ReactOwner} owner Component on which the ref is recorded.
13877
* @final
13878
* @internal
13879
*/
13880
removeComponentAsRefFrom: function(component, ref, owner) {
13881
("production" !== "development" ? invariant(
13882
ReactOwner.isValidOwner(owner),
13883
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
13884
'usually means that you\'re trying to remove a ref to a component that ' +
13885
'doesn\'t have an owner (that is, was not created inside of another ' +
13886
'component\'s `render` method). Try rendering this component inside of ' +
13887
'a new top-level component which will hold the ref.'
13888
) : invariant(ReactOwner.isValidOwner(owner)));
13889
// Check that `component` is still the current ref because we do not want to
13890
// detach the ref if another component stole it.
13891
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
13892
owner.detachRef(ref);
13893
}
13894
}
13895
13896
};
13897
13898
module.exports = ReactOwner;
13899
13900
},{"150":150}],82:[function(_dereq_,module,exports){
13901
/**
13902
* Copyright 2013-2015, Facebook, Inc.
13903
* All rights reserved.
13904
*
13905
* This source code is licensed under the BSD-style license found in the
13906
* LICENSE file in the root directory of this source tree. An additional grant
13907
* of patent rights can be found in the PATENTS file in the same directory.
13908
*
13909
* @providesModule ReactPerf
13910
* @typechecks static-only
13911
*/
13912
13913
'use strict';
13914
13915
/**
13916
* ReactPerf is a general AOP system designed to measure performance. This
13917
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
13918
*/
13919
var ReactPerf = {
13920
/**
13921
* Boolean to enable/disable measurement. Set to false by default to prevent
13922
* accidental logging and perf loss.
13923
*/
13924
enableMeasure: false,
13925
13926
/**
13927
* Holds onto the measure function in use. By default, don't measure
13928
* anything, but we'll override this if we inject a measure function.
13929
*/
13930
storedMeasure: _noMeasure,
13931
13932
/**
13933
* @param {object} object
13934
* @param {string} objectName
13935
* @param {object<string>} methodNames
13936
*/
13937
measureMethods: function(object, objectName, methodNames) {
13938
if ("production" !== "development") {
13939
for (var key in methodNames) {
13940
if (!methodNames.hasOwnProperty(key)) {
13941
continue;
13942
}
13943
object[key] = ReactPerf.measure(
13944
objectName,
13945
methodNames[key],
13946
object[key]
13947
);
13948
}
13949
}
13950
},
13951
13952
/**
13953
* Use this to wrap methods you want to measure. Zero overhead in production.
13954
*
13955
* @param {string} objName
13956
* @param {string} fnName
13957
* @param {function} func
13958
* @return {function}
13959
*/
13960
measure: function(objName, fnName, func) {
13961
if ("production" !== "development") {
13962
var measuredFunc = null;
13963
var wrapper = function() {
13964
if (ReactPerf.enableMeasure) {
13965
if (!measuredFunc) {
13966
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
13967
}
13968
return measuredFunc.apply(this, arguments);
13969
}
13970
return func.apply(this, arguments);
13971
};
13972
wrapper.displayName = objName + '_' + fnName;
13973
return wrapper;
13974
}
13975
return func;
13976
},
13977
13978
injection: {
13979
/**
13980
* @param {function} measure
13981
*/
13982
injectMeasure: function(measure) {
13983
ReactPerf.storedMeasure = measure;
13984
}
13985
}
13986
};
13987
13988
/**
13989
* Simply passes through the measured function, without measuring it.
13990
*
13991
* @param {string} objName
13992
* @param {string} fnName
13993
* @param {function} func
13994
* @return {function}
13995
*/
13996
function _noMeasure(objName, fnName, func) {
13997
return func;
13998
}
13999
14000
module.exports = ReactPerf;
14001
14002
},{}],83:[function(_dereq_,module,exports){
14003
/**
14004
* Copyright 2013-2015, Facebook, Inc.
14005
* All rights reserved.
14006
*
14007
* This source code is licensed under the BSD-style license found in the
14008
* LICENSE file in the root directory of this source tree. An additional grant
14009
* of patent rights can be found in the PATENTS file in the same directory.
14010
*
14011
* @providesModule ReactPropTransferer
14012
*/
14013
14014
'use strict';
14015
14016
var assign = _dereq_(29);
14017
var emptyFunction = _dereq_(129);
14018
var joinClasses = _dereq_(155);
14019
14020
/**
14021
* Creates a transfer strategy that will merge prop values using the supplied
14022
* `mergeStrategy`. If a prop was previously unset, this just sets it.
14023
*
14024
* @param {function} mergeStrategy
14025
* @return {function}
14026
*/
14027
function createTransferStrategy(mergeStrategy) {
14028
return function(props, key, value) {
14029
if (!props.hasOwnProperty(key)) {
14030
props[key] = value;
14031
} else {
14032
props[key] = mergeStrategy(props[key], value);
14033
}
14034
};
14035
}
14036
14037
var transferStrategyMerge = createTransferStrategy(function(a, b) {
14038
// `merge` overrides the first object's (`props[key]` above) keys using the
14039
// second object's (`value`) keys. An object's style's existing `propA` would
14040
// get overridden. Flip the order here.
14041
return assign({}, b, a);
14042
});
14043
14044
/**
14045
* Transfer strategies dictate how props are transferred by `transferPropsTo`.
14046
* NOTE: if you add any more exceptions to this list you should be sure to
14047
* update `cloneWithProps()` accordingly.
14048
*/
14049
var TransferStrategies = {
14050
/**
14051
* Never transfer `children`.
14052
*/
14053
children: emptyFunction,
14054
/**
14055
* Transfer the `className` prop by merging them.
14056
*/
14057
className: createTransferStrategy(joinClasses),
14058
/**
14059
* Transfer the `style` prop (which is an object) by merging them.
14060
*/
14061
style: transferStrategyMerge
14062
};
14063
14064
/**
14065
* Mutates the first argument by transferring the properties from the second
14066
* argument.
14067
*
14068
* @param {object} props
14069
* @param {object} newProps
14070
* @return {object}
14071
*/
14072
function transferInto(props, newProps) {
14073
for (var thisKey in newProps) {
14074
if (!newProps.hasOwnProperty(thisKey)) {
14075
continue;
14076
}
14077
14078
var transferStrategy = TransferStrategies[thisKey];
14079
14080
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
14081
transferStrategy(props, thisKey, newProps[thisKey]);
14082
} else if (!props.hasOwnProperty(thisKey)) {
14083
props[thisKey] = newProps[thisKey];
14084
}
14085
}
14086
return props;
14087
}
14088
14089
/**
14090
* ReactPropTransferer are capable of transferring props to another component
14091
* using a `transferPropsTo` method.
14092
*
14093
* @class ReactPropTransferer
14094
*/
14095
var ReactPropTransferer = {
14096
14097
/**
14098
* Merge two props objects using TransferStrategies.
14099
*
14100
* @param {object} oldProps original props (they take precedence)
14101
* @param {object} newProps new props to merge in
14102
* @return {object} a new object containing both sets of props merged.
14103
*/
14104
mergeProps: function(oldProps, newProps) {
14105
return transferInto(assign({}, oldProps), newProps);
14106
}
14107
14108
};
14109
14110
module.exports = ReactPropTransferer;
14111
14112
},{"129":129,"155":155,"29":29}],84:[function(_dereq_,module,exports){
14113
/**
14114
* Copyright 2013-2015, Facebook, Inc.
14115
* All rights reserved.
14116
*
14117
* This source code is licensed under the BSD-style license found in the
14118
* LICENSE file in the root directory of this source tree. An additional grant
14119
* of patent rights can be found in the PATENTS file in the same directory.
14120
*
14121
* @providesModule ReactPropTypeLocationNames
14122
*/
14123
14124
'use strict';
14125
14126
var ReactPropTypeLocationNames = {};
14127
14128
if ("production" !== "development") {
14129
ReactPropTypeLocationNames = {
14130
prop: 'prop',
14131
context: 'context',
14132
childContext: 'child context'
14133
};
14134
}
14135
14136
module.exports = ReactPropTypeLocationNames;
14137
14138
},{}],85:[function(_dereq_,module,exports){
14139
/**
14140
* Copyright 2013-2015, Facebook, Inc.
14141
* All rights reserved.
14142
*
14143
* This source code is licensed under the BSD-style license found in the
14144
* LICENSE file in the root directory of this source tree. An additional grant
14145
* of patent rights can be found in the PATENTS file in the same directory.
14146
*
14147
* @providesModule ReactPropTypeLocations
14148
*/
14149
14150
'use strict';
14151
14152
var keyMirror = _dereq_(156);
14153
14154
var ReactPropTypeLocations = keyMirror({
14155
prop: null,
14156
context: null,
14157
childContext: null
14158
});
14159
14160
module.exports = ReactPropTypeLocations;
14161
14162
},{"156":156}],86:[function(_dereq_,module,exports){
14163
/**
14164
* Copyright 2013-2015, Facebook, Inc.
14165
* All rights reserved.
14166
*
14167
* This source code is licensed under the BSD-style license found in the
14168
* LICENSE file in the root directory of this source tree. An additional grant
14169
* of patent rights can be found in the PATENTS file in the same directory.
14170
*
14171
* @providesModule ReactPropTypes
14172
*/
14173
14174
'use strict';
14175
14176
var ReactElement = _dereq_(63);
14177
var ReactFragment = _dereq_(69);
14178
var ReactPropTypeLocationNames = _dereq_(84);
14179
14180
var emptyFunction = _dereq_(129);
14181
14182
/**
14183
* Collection of methods that allow declaration and validation of props that are
14184
* supplied to React components. Example usage:
14185
*
14186
* var Props = require('ReactPropTypes');
14187
* var MyArticle = React.createClass({
14188
* propTypes: {
14189
* // An optional string prop named "description".
14190
* description: Props.string,
14191
*
14192
* // A required enum prop named "category".
14193
* category: Props.oneOf(['News','Photos']).isRequired,
14194
*
14195
* // A prop named "dialog" that requires an instance of Dialog.
14196
* dialog: Props.instanceOf(Dialog).isRequired
14197
* },
14198
* render: function() { ... }
14199
* });
14200
*
14201
* A more formal specification of how these methods are used:
14202
*
14203
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
14204
* decl := ReactPropTypes.{type}(.isRequired)?
14205
*
14206
* Each and every declaration produces a function with the same signature. This
14207
* allows the creation of custom validation functions. For example:
14208
*
14209
* var MyLink = React.createClass({
14210
* propTypes: {
14211
* // An optional string or URI prop named "href".
14212
* href: function(props, propName, componentName) {
14213
* var propValue = props[propName];
14214
* if (propValue != null && typeof propValue !== 'string' &&
14215
* !(propValue instanceof URI)) {
14216
* return new Error(
14217
* 'Expected a string or an URI for ' + propName + ' in ' +
14218
* componentName
14219
* );
14220
* }
14221
* }
14222
* },
14223
* render: function() {...}
14224
* });
14225
*
14226
* @internal
14227
*/
14228
14229
var ANONYMOUS = '<<anonymous>>';
14230
14231
var elementTypeChecker = createElementTypeChecker();
14232
var nodeTypeChecker = createNodeChecker();
14233
14234
var ReactPropTypes = {
14235
array: createPrimitiveTypeChecker('array'),
14236
bool: createPrimitiveTypeChecker('boolean'),
14237
func: createPrimitiveTypeChecker('function'),
14238
number: createPrimitiveTypeChecker('number'),
14239
object: createPrimitiveTypeChecker('object'),
14240
string: createPrimitiveTypeChecker('string'),
14241
14242
any: createAnyTypeChecker(),
14243
arrayOf: createArrayOfTypeChecker,
14244
element: elementTypeChecker,
14245
instanceOf: createInstanceTypeChecker,
14246
node: nodeTypeChecker,
14247
objectOf: createObjectOfTypeChecker,
14248
oneOf: createEnumTypeChecker,
14249
oneOfType: createUnionTypeChecker,
14250
shape: createShapeTypeChecker
14251
};
14252
14253
function createChainableTypeChecker(validate) {
14254
function checkType(isRequired, props, propName, componentName, location) {
14255
componentName = componentName || ANONYMOUS;
14256
if (props[propName] == null) {
14257
var locationName = ReactPropTypeLocationNames[location];
14258
if (isRequired) {
14259
return new Error(
14260
("Required " + locationName + " `" + propName + "` was not specified in ") +
14261
("`" + componentName + "`.")
14262
);
14263
}
14264
return null;
14265
} else {
14266
return validate(props, propName, componentName, location);
14267
}
14268
}
14269
14270
var chainedCheckType = checkType.bind(null, false);
14271
chainedCheckType.isRequired = checkType.bind(null, true);
14272
14273
return chainedCheckType;
14274
}
14275
14276
function createPrimitiveTypeChecker(expectedType) {
14277
function validate(props, propName, componentName, location) {
14278
var propValue = props[propName];
14279
var propType = getPropType(propValue);
14280
if (propType !== expectedType) {
14281
var locationName = ReactPropTypeLocationNames[location];
14282
// `propValue` being instance of, say, date/regexp, pass the 'object'
14283
// check, but we can offer a more precise error message here rather than
14284
// 'of type `object`'.
14285
var preciseType = getPreciseType(propValue);
14286
14287
return new Error(
14288
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
14289
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
14290
);
14291
}
14292
return null;
14293
}
14294
return createChainableTypeChecker(validate);
14295
}
14296
14297
function createAnyTypeChecker() {
14298
return createChainableTypeChecker(emptyFunction.thatReturns(null));
14299
}
14300
14301
function createArrayOfTypeChecker(typeChecker) {
14302
function validate(props, propName, componentName, location) {
14303
var propValue = props[propName];
14304
if (!Array.isArray(propValue)) {
14305
var locationName = ReactPropTypeLocationNames[location];
14306
var propType = getPropType(propValue);
14307
return new Error(
14308
("Invalid " + locationName + " `" + propName + "` of type ") +
14309
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
14310
);
14311
}
14312
for (var i = 0; i < propValue.length; i++) {
14313
var error = typeChecker(propValue, i, componentName, location);
14314
if (error instanceof Error) {
14315
return error;
14316
}
14317
}
14318
return null;
14319
}
14320
return createChainableTypeChecker(validate);
14321
}
14322
14323
function createElementTypeChecker() {
14324
function validate(props, propName, componentName, location) {
14325
if (!ReactElement.isValidElement(props[propName])) {
14326
var locationName = ReactPropTypeLocationNames[location];
14327
return new Error(
14328
("Invalid " + locationName + " `" + propName + "` supplied to ") +
14329
("`" + componentName + "`, expected a ReactElement.")
14330
);
14331
}
14332
return null;
14333
}
14334
return createChainableTypeChecker(validate);
14335
}
14336
14337
function createInstanceTypeChecker(expectedClass) {
14338
function validate(props, propName, componentName, location) {
14339
if (!(props[propName] instanceof expectedClass)) {
14340
var locationName = ReactPropTypeLocationNames[location];
14341
var expectedClassName = expectedClass.name || ANONYMOUS;
14342
return new Error(
14343
("Invalid " + locationName + " `" + propName + "` supplied to ") +
14344
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
14345
);
14346
}
14347
return null;
14348
}
14349
return createChainableTypeChecker(validate);
14350
}
14351
14352
function createEnumTypeChecker(expectedValues) {
14353
function validate(props, propName, componentName, location) {
14354
var propValue = props[propName];
14355
for (var i = 0; i < expectedValues.length; i++) {
14356
if (propValue === expectedValues[i]) {
14357
return null;
14358
}
14359
}
14360
14361
var locationName = ReactPropTypeLocationNames[location];
14362
var valuesString = JSON.stringify(expectedValues);
14363
return new Error(
14364
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
14365
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
14366
);
14367
}
14368
return createChainableTypeChecker(validate);
14369
}
14370
14371
function createObjectOfTypeChecker(typeChecker) {
14372
function validate(props, propName, componentName, location) {
14373
var propValue = props[propName];
14374
var propType = getPropType(propValue);
14375
if (propType !== 'object') {
14376
var locationName = ReactPropTypeLocationNames[location];
14377
return new Error(
14378
("Invalid " + locationName + " `" + propName + "` of type ") +
14379
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
14380
);
14381
}
14382
for (var key in propValue) {
14383
if (propValue.hasOwnProperty(key)) {
14384
var error = typeChecker(propValue, key, componentName, location);
14385
if (error instanceof Error) {
14386
return error;
14387
}
14388
}
14389
}
14390
return null;
14391
}
14392
return createChainableTypeChecker(validate);
14393
}
14394
14395
function createUnionTypeChecker(arrayOfTypeCheckers) {
14396
function validate(props, propName, componentName, location) {
14397
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
14398
var checker = arrayOfTypeCheckers[i];
14399
if (checker(props, propName, componentName, location) == null) {
14400
return null;
14401
}
14402
}
14403
14404
var locationName = ReactPropTypeLocationNames[location];
14405
return new Error(
14406
("Invalid " + locationName + " `" + propName + "` supplied to ") +
14407
("`" + componentName + "`.")
14408
);
14409
}
14410
return createChainableTypeChecker(validate);
14411
}
14412
14413
function createNodeChecker() {
14414
function validate(props, propName, componentName, location) {
14415
if (!isNode(props[propName])) {
14416
var locationName = ReactPropTypeLocationNames[location];
14417
return new Error(
14418
("Invalid " + locationName + " `" + propName + "` supplied to ") +
14419
("`" + componentName + "`, expected a ReactNode.")
14420
);
14421
}
14422
return null;
14423
}
14424
return createChainableTypeChecker(validate);
14425
}
14426
14427
function createShapeTypeChecker(shapeTypes) {
14428
function validate(props, propName, componentName, location) {
14429
var propValue = props[propName];
14430
var propType = getPropType(propValue);
14431
if (propType !== 'object') {
14432
var locationName = ReactPropTypeLocationNames[location];
14433
return new Error(
14434
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
14435
("supplied to `" + componentName + "`, expected `object`.")
14436
);
14437
}
14438
for (var key in shapeTypes) {
14439
var checker = shapeTypes[key];
14440
if (!checker) {
14441
continue;
14442
}
14443
var error = checker(propValue, key, componentName, location);
14444
if (error) {
14445
return error;
14446
}
14447
}
14448
return null;
14449
}
14450
return createChainableTypeChecker(validate);
14451
}
14452
14453
function isNode(propValue) {
14454
switch (typeof propValue) {
14455
case 'number':
14456
case 'string':
14457
case 'undefined':
14458
return true;
14459
case 'boolean':
14460
return !propValue;
14461
case 'object':
14462
if (Array.isArray(propValue)) {
14463
return propValue.every(isNode);
14464
}
14465
if (propValue === null || ReactElement.isValidElement(propValue)) {
14466
return true;
14467
}
14468
propValue = ReactFragment.extractIfFragment(propValue);
14469
for (var k in propValue) {
14470
if (!isNode(propValue[k])) {
14471
return false;
14472
}
14473
}
14474
return true;
14475
default:
14476
return false;
14477
}
14478
}
14479
14480
// Equivalent of `typeof` but with special handling for array and regexp.
14481
function getPropType(propValue) {
14482
var propType = typeof propValue;
14483
if (Array.isArray(propValue)) {
14484
return 'array';
14485
}
14486
if (propValue instanceof RegExp) {
14487
// Old webkits (at least until Android 4.0) return 'function' rather than
14488
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
14489
// passes PropTypes.object.
14490
return 'object';
14491
}
14492
return propType;
14493
}
14494
14495
// This handles more types than `getPropType`. Only used for error messages.
14496
// See `createPrimitiveTypeChecker`.
14497
function getPreciseType(propValue) {
14498
var propType = getPropType(propValue);
14499
if (propType === 'object') {
14500
if (propValue instanceof Date) {
14501
return 'date';
14502
} else if (propValue instanceof RegExp) {
14503
return 'regexp';
14504
}
14505
}
14506
return propType;
14507
}
14508
14509
module.exports = ReactPropTypes;
14510
14511
},{"129":129,"63":63,"69":69,"84":84}],87:[function(_dereq_,module,exports){
14512
/**
14513
* Copyright 2013-2015, Facebook, Inc.
14514
* All rights reserved.
14515
*
14516
* This source code is licensed under the BSD-style license found in the
14517
* LICENSE file in the root directory of this source tree. An additional grant
14518
* of patent rights can be found in the PATENTS file in the same directory.
14519
*
14520
* @providesModule ReactPutListenerQueue
14521
*/
14522
14523
'use strict';
14524
14525
var PooledClass = _dereq_(30);
14526
var ReactBrowserEventEmitter = _dereq_(33);
14527
14528
var assign = _dereq_(29);
14529
14530
function ReactPutListenerQueue() {
14531
this.listenersToPut = [];
14532
}
14533
14534
assign(ReactPutListenerQueue.prototype, {
14535
enqueuePutListener: function(rootNodeID, propKey, propValue) {
14536
this.listenersToPut.push({
14537
rootNodeID: rootNodeID,
14538
propKey: propKey,
14539
propValue: propValue
14540
});
14541
},
14542
14543
putListeners: function() {
14544
for (var i = 0; i < this.listenersToPut.length; i++) {
14545
var listenerToPut = this.listenersToPut[i];
14546
ReactBrowserEventEmitter.putListener(
14547
listenerToPut.rootNodeID,
14548
listenerToPut.propKey,
14549
listenerToPut.propValue
14550
);
14551
}
14552
},
14553
14554
reset: function() {
14555
this.listenersToPut.length = 0;
14556
},
14557
14558
destructor: function() {
14559
this.reset();
14560
}
14561
});
14562
14563
PooledClass.addPoolingTo(ReactPutListenerQueue);
14564
14565
module.exports = ReactPutListenerQueue;
14566
14567
},{"29":29,"30":30,"33":33}],88:[function(_dereq_,module,exports){
14568
/**
14569
* Copyright 2013-2015, Facebook, Inc.
14570
* All rights reserved.
14571
*
14572
* This source code is licensed under the BSD-style license found in the
14573
* LICENSE file in the root directory of this source tree. An additional grant
14574
* of patent rights can be found in the PATENTS file in the same directory.
14575
*
14576
* @providesModule ReactReconcileTransaction
14577
* @typechecks static-only
14578
*/
14579
14580
'use strict';
14581
14582
var CallbackQueue = _dereq_(7);
14583
var PooledClass = _dereq_(30);
14584
var ReactBrowserEventEmitter = _dereq_(33);
14585
var ReactInputSelection = _dereq_(71);
14586
var ReactPutListenerQueue = _dereq_(87);
14587
var Transaction = _dereq_(116);
14588
14589
var assign = _dereq_(29);
14590
14591
/**
14592
* Ensures that, when possible, the selection range (currently selected text
14593
* input) is not disturbed by performing the transaction.
14594
*/
14595
var SELECTION_RESTORATION = {
14596
/**
14597
* @return {Selection} Selection information.
14598
*/
14599
initialize: ReactInputSelection.getSelectionInformation,
14600
/**
14601
* @param {Selection} sel Selection information returned from `initialize`.
14602
*/
14603
close: ReactInputSelection.restoreSelection
14604
};
14605
14606
/**
14607
* Suppresses events (blur/focus) that could be inadvertently dispatched due to
14608
* high level DOM manipulations (like temporarily removing a text input from the
14609
* DOM).
14610
*/
14611
var EVENT_SUPPRESSION = {
14612
/**
14613
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
14614
* the reconciliation.
14615
*/
14616
initialize: function() {
14617
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
14618
ReactBrowserEventEmitter.setEnabled(false);
14619
return currentlyEnabled;
14620
},
14621
14622
/**
14623
* @param {boolean} previouslyEnabled Enabled status of
14624
* `ReactBrowserEventEmitter` before the reconciliation occured. `close`
14625
* restores the previous value.
14626
*/
14627
close: function(previouslyEnabled) {
14628
ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
14629
}
14630
};
14631
14632
/**
14633
* Provides a queue for collecting `componentDidMount` and
14634
* `componentDidUpdate` callbacks during the the transaction.
14635
*/
14636
var ON_DOM_READY_QUEUEING = {
14637
/**
14638
* Initializes the internal `onDOMReady` queue.
14639
*/
14640
initialize: function() {
14641
this.reactMountReady.reset();
14642
},
14643
14644
/**
14645
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
14646
*/
14647
close: function() {
14648
this.reactMountReady.notifyAll();
14649
}
14650
};
14651
14652
var PUT_LISTENER_QUEUEING = {
14653
initialize: function() {
14654
this.putListenerQueue.reset();
14655
},
14656
14657
close: function() {
14658
this.putListenerQueue.putListeners();
14659
}
14660
};
14661
14662
/**
14663
* Executed within the scope of the `Transaction` instance. Consider these as
14664
* being member methods, but with an implied ordering while being isolated from
14665
* each other.
14666
*/
14667
var TRANSACTION_WRAPPERS = [
14668
PUT_LISTENER_QUEUEING,
14669
SELECTION_RESTORATION,
14670
EVENT_SUPPRESSION,
14671
ON_DOM_READY_QUEUEING
14672
];
14673
14674
/**
14675
* Currently:
14676
* - The order that these are listed in the transaction is critical:
14677
* - Suppresses events.
14678
* - Restores selection range.
14679
*
14680
* Future:
14681
* - Restore document/overflow scroll positions that were unintentionally
14682
* modified via DOM insertions above the top viewport boundary.
14683
* - Implement/integrate with customized constraint based layout system and keep
14684
* track of which dimensions must be remeasured.
14685
*
14686
* @class ReactReconcileTransaction
14687
*/
14688
function ReactReconcileTransaction() {
14689
this.reinitializeTransaction();
14690
// Only server-side rendering really needs this option (see
14691
// `ReactServerRendering`), but server-side uses
14692
// `ReactServerRenderingTransaction` instead. This option is here so that it's
14693
// accessible and defaults to false when `ReactDOMComponent` and
14694
// `ReactTextComponent` checks it in `mountComponent`.`
14695
this.renderToStaticMarkup = false;
14696
this.reactMountReady = CallbackQueue.getPooled(null);
14697
this.putListenerQueue = ReactPutListenerQueue.getPooled();
14698
}
14699
14700
var Mixin = {
14701
/**
14702
* @see Transaction
14703
* @abstract
14704
* @final
14705
* @return {array<object>} List of operation wrap proceedures.
14706
* TODO: convert to array<TransactionWrapper>
14707
*/
14708
getTransactionWrappers: function() {
14709
return TRANSACTION_WRAPPERS;
14710
},
14711
14712
/**
14713
* @return {object} The queue to collect `onDOMReady` callbacks with.
14714
*/
14715
getReactMountReady: function() {
14716
return this.reactMountReady;
14717
},
14718
14719
getPutListenerQueue: function() {
14720
return this.putListenerQueue;
14721
},
14722
14723
/**
14724
* `PooledClass` looks for this, and will invoke this before allowing this
14725
* instance to be resused.
14726
*/
14727
destructor: function() {
14728
CallbackQueue.release(this.reactMountReady);
14729
this.reactMountReady = null;
14730
14731
ReactPutListenerQueue.release(this.putListenerQueue);
14732
this.putListenerQueue = null;
14733
}
14734
};
14735
14736
14737
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
14738
14739
PooledClass.addPoolingTo(ReactReconcileTransaction);
14740
14741
module.exports = ReactReconcileTransaction;
14742
14743
},{"116":116,"29":29,"30":30,"33":33,"7":7,"71":71,"87":87}],89:[function(_dereq_,module,exports){
14744
/**
14745
* Copyright 2013-2015, Facebook, Inc.
14746
* All rights reserved.
14747
*
14748
* This source code is licensed under the BSD-style license found in the
14749
* LICENSE file in the root directory of this source tree. An additional grant
14750
* of patent rights can be found in the PATENTS file in the same directory.
14751
*
14752
* @providesModule ReactReconciler
14753
*/
14754
14755
'use strict';
14756
14757
var ReactRef = _dereq_(90);
14758
var ReactElementValidator = _dereq_(64);
14759
14760
/**
14761
* Helper to call ReactRef.attachRefs with this composite component, split out
14762
* to avoid allocations in the transaction mount-ready queue.
14763
*/
14764
function attachRefs() {
14765
ReactRef.attachRefs(this, this._currentElement);
14766
}
14767
14768
var ReactReconciler = {
14769
14770
/**
14771
* Initializes the component, renders markup, and registers event listeners.
14772
*
14773
* @param {ReactComponent} internalInstance
14774
* @param {string} rootID DOM ID of the root node.
14775
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
14776
* @return {?string} Rendered markup to be inserted into the DOM.
14777
* @final
14778
* @internal
14779
*/
14780
mountComponent: function(internalInstance, rootID, transaction, context) {
14781
var markup = internalInstance.mountComponent(rootID, transaction, context);
14782
if ("production" !== "development") {
14783
ReactElementValidator.checkAndWarnForMutatedProps(
14784
internalInstance._currentElement
14785
);
14786
}
14787
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
14788
return markup;
14789
},
14790
14791
/**
14792
* Releases any resources allocated by `mountComponent`.
14793
*
14794
* @final
14795
* @internal
14796
*/
14797
unmountComponent: function(internalInstance) {
14798
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
14799
internalInstance.unmountComponent();
14800
},
14801
14802
/**
14803
* Update a component using a new element.
14804
*
14805
* @param {ReactComponent} internalInstance
14806
* @param {ReactElement} nextElement
14807
* @param {ReactReconcileTransaction} transaction
14808
* @param {object} context
14809
* @internal
14810
*/
14811
receiveComponent: function(
14812
internalInstance, nextElement, transaction, context
14813
) {
14814
var prevElement = internalInstance._currentElement;
14815
14816
if (nextElement === prevElement && nextElement._owner != null) {
14817
// Since elements are immutable after the owner is rendered,
14818
// we can do a cheap identity compare here to determine if this is a
14819
// superfluous reconcile. It's possible for state to be mutable but such
14820
// change should trigger an update of the owner which would recreate
14821
// the element. We explicitly check for the existence of an owner since
14822
// it's possible for an element created outside a composite to be
14823
// deeply mutated and reused.
14824
return;
14825
}
14826
14827
if ("production" !== "development") {
14828
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
14829
}
14830
14831
var refsChanged = ReactRef.shouldUpdateRefs(
14832
prevElement,
14833
nextElement
14834
);
14835
14836
if (refsChanged) {
14837
ReactRef.detachRefs(internalInstance, prevElement);
14838
}
14839
14840
internalInstance.receiveComponent(nextElement, transaction, context);
14841
14842
if (refsChanged) {
14843
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
14844
}
14845
},
14846
14847
/**
14848
* Flush any dirty changes in a component.
14849
*
14850
* @param {ReactComponent} internalInstance
14851
* @param {ReactReconcileTransaction} transaction
14852
* @internal
14853
*/
14854
performUpdateIfNecessary: function(
14855
internalInstance,
14856
transaction
14857
) {
14858
internalInstance.performUpdateIfNecessary(transaction);
14859
}
14860
14861
};
14862
14863
module.exports = ReactReconciler;
14864
14865
},{"64":64,"90":90}],90:[function(_dereq_,module,exports){
14866
/**
14867
* Copyright 2013-2015, Facebook, Inc.
14868
* All rights reserved.
14869
*
14870
* This source code is licensed under the BSD-style license found in the
14871
* LICENSE file in the root directory of this source tree. An additional grant
14872
* of patent rights can be found in the PATENTS file in the same directory.
14873
*
14874
* @providesModule ReactRef
14875
*/
14876
14877
'use strict';
14878
14879
var ReactOwner = _dereq_(81);
14880
14881
var ReactRef = {};
14882
14883
function attachRef(ref, component, owner) {
14884
if (typeof ref === 'function') {
14885
ref(component.getPublicInstance());
14886
} else {
14887
// Legacy ref
14888
ReactOwner.addComponentAsRefTo(component, ref, owner);
14889
}
14890
}
14891
14892
function detachRef(ref, component, owner) {
14893
if (typeof ref === 'function') {
14894
ref(null);
14895
} else {
14896
// Legacy ref
14897
ReactOwner.removeComponentAsRefFrom(component, ref, owner);
14898
}
14899
}
14900
14901
ReactRef.attachRefs = function(instance, element) {
14902
var ref = element.ref;
14903
if (ref != null) {
14904
attachRef(ref, instance, element._owner);
14905
}
14906
};
14907
14908
ReactRef.shouldUpdateRefs = function(prevElement, nextElement) {
14909
// If either the owner or a `ref` has changed, make sure the newest owner
14910
// has stored a reference to `this`, and the previous owner (if different)
14911
// has forgotten the reference to `this`. We use the element instead
14912
// of the public this.props because the post processing cannot determine
14913
// a ref. The ref conceptually lives on the element.
14914
14915
// TODO: Should this even be possible? The owner cannot change because
14916
// it's forbidden by shouldUpdateReactComponent. The ref can change
14917
// if you swap the keys of but not the refs. Reconsider where this check
14918
// is made. It probably belongs where the key checking and
14919
// instantiateReactComponent is done.
14920
14921
return (
14922
nextElement._owner !== prevElement._owner ||
14923
nextElement.ref !== prevElement.ref
14924
);
14925
};
14926
14927
ReactRef.detachRefs = function(instance, element) {
14928
var ref = element.ref;
14929
if (ref != null) {
14930
detachRef(ref, instance, element._owner);
14931
}
14932
};
14933
14934
module.exports = ReactRef;
14935
14936
},{"81":81}],91:[function(_dereq_,module,exports){
14937
/**
14938
* Copyright 2013-2015, Facebook, Inc.
14939
* All rights reserved.
14940
*
14941
* This source code is licensed under the BSD-style license found in the
14942
* LICENSE file in the root directory of this source tree. An additional grant
14943
* of patent rights can be found in the PATENTS file in the same directory.
14944
*
14945
* @providesModule ReactRootIndex
14946
* @typechecks
14947
*/
14948
14949
'use strict';
14950
14951
var ReactRootIndexInjection = {
14952
/**
14953
* @param {function} _createReactRootIndex
14954
*/
14955
injectCreateReactRootIndex: function(_createReactRootIndex) {
14956
ReactRootIndex.createReactRootIndex = _createReactRootIndex;
14957
}
14958
};
14959
14960
var ReactRootIndex = {
14961
createReactRootIndex: null,
14962
injection: ReactRootIndexInjection
14963
};
14964
14965
module.exports = ReactRootIndex;
14966
14967
},{}],92:[function(_dereq_,module,exports){
14968
/**
14969
* Copyright 2013-2015, Facebook, Inc.
14970
* All rights reserved.
14971
*
14972
* This source code is licensed under the BSD-style license found in the
14973
* LICENSE file in the root directory of this source tree. An additional grant
14974
* of patent rights can be found in the PATENTS file in the same directory.
14975
*
14976
* @typechecks static-only
14977
* @providesModule ReactServerRendering
14978
*/
14979
'use strict';
14980
14981
var ReactElement = _dereq_(63);
14982
var ReactInstanceHandles = _dereq_(72);
14983
var ReactMarkupChecksum = _dereq_(76);
14984
var ReactServerRenderingTransaction =
14985
_dereq_(93);
14986
14987
var emptyObject = _dereq_(130);
14988
var instantiateReactComponent = _dereq_(149);
14989
var invariant = _dereq_(150);
14990
14991
/**
14992
* @param {ReactElement} element
14993
* @return {string} the HTML markup
14994
*/
14995
function renderToString(element) {
14996
("production" !== "development" ? invariant(
14997
ReactElement.isValidElement(element),
14998
'renderToString(): You must pass a valid ReactElement.'
14999
) : invariant(ReactElement.isValidElement(element)));
15000
15001
var transaction;
15002
try {
15003
var id = ReactInstanceHandles.createReactRootID();
15004
transaction = ReactServerRenderingTransaction.getPooled(false);
15005
15006
return transaction.perform(function() {
15007
var componentInstance = instantiateReactComponent(element, null);
15008
var markup =
15009
componentInstance.mountComponent(id, transaction, emptyObject);
15010
return ReactMarkupChecksum.addChecksumToMarkup(markup);
15011
}, null);
15012
} finally {
15013
ReactServerRenderingTransaction.release(transaction);
15014
}
15015
}
15016
15017
/**
15018
* @param {ReactElement} element
15019
* @return {string} the HTML markup, without the extra React ID and checksum
15020
* (for generating static pages)
15021
*/
15022
function renderToStaticMarkup(element) {
15023
("production" !== "development" ? invariant(
15024
ReactElement.isValidElement(element),
15025
'renderToStaticMarkup(): You must pass a valid ReactElement.'
15026
) : invariant(ReactElement.isValidElement(element)));
15027
15028
var transaction;
15029
try {
15030
var id = ReactInstanceHandles.createReactRootID();
15031
transaction = ReactServerRenderingTransaction.getPooled(true);
15032
15033
return transaction.perform(function() {
15034
var componentInstance = instantiateReactComponent(element, null);
15035
return componentInstance.mountComponent(id, transaction, emptyObject);
15036
}, null);
15037
} finally {
15038
ReactServerRenderingTransaction.release(transaction);
15039
}
15040
}
15041
15042
module.exports = {
15043
renderToString: renderToString,
15044
renderToStaticMarkup: renderToStaticMarkup
15045
};
15046
15047
},{"130":130,"149":149,"150":150,"63":63,"72":72,"76":76,"93":93}],93:[function(_dereq_,module,exports){
15048
/**
15049
* Copyright 2014-2015, Facebook, Inc.
15050
* All rights reserved.
15051
*
15052
* This source code is licensed under the BSD-style license found in the
15053
* LICENSE file in the root directory of this source tree. An additional grant
15054
* of patent rights can be found in the PATENTS file in the same directory.
15055
*
15056
* @providesModule ReactServerRenderingTransaction
15057
* @typechecks
15058
*/
15059
15060
'use strict';
15061
15062
var PooledClass = _dereq_(30);
15063
var CallbackQueue = _dereq_(7);
15064
var ReactPutListenerQueue = _dereq_(87);
15065
var Transaction = _dereq_(116);
15066
15067
var assign = _dereq_(29);
15068
var emptyFunction = _dereq_(129);
15069
15070
/**
15071
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
15072
* during the performing of the transaction.
15073
*/
15074
var ON_DOM_READY_QUEUEING = {
15075
/**
15076
* Initializes the internal `onDOMReady` queue.
15077
*/
15078
initialize: function() {
15079
this.reactMountReady.reset();
15080
},
15081
15082
close: emptyFunction
15083
};
15084
15085
var PUT_LISTENER_QUEUEING = {
15086
initialize: function() {
15087
this.putListenerQueue.reset();
15088
},
15089
15090
close: emptyFunction
15091
};
15092
15093
/**
15094
* Executed within the scope of the `Transaction` instance. Consider these as
15095
* being member methods, but with an implied ordering while being isolated from
15096
* each other.
15097
*/
15098
var TRANSACTION_WRAPPERS = [
15099
PUT_LISTENER_QUEUEING,
15100
ON_DOM_READY_QUEUEING
15101
];
15102
15103
/**
15104
* @class ReactServerRenderingTransaction
15105
* @param {boolean} renderToStaticMarkup
15106
*/
15107
function ReactServerRenderingTransaction(renderToStaticMarkup) {
15108
this.reinitializeTransaction();
15109
this.renderToStaticMarkup = renderToStaticMarkup;
15110
this.reactMountReady = CallbackQueue.getPooled(null);
15111
this.putListenerQueue = ReactPutListenerQueue.getPooled();
15112
}
15113
15114
var Mixin = {
15115
/**
15116
* @see Transaction
15117
* @abstract
15118
* @final
15119
* @return {array} Empty list of operation wrap proceedures.
15120
*/
15121
getTransactionWrappers: function() {
15122
return TRANSACTION_WRAPPERS;
15123
},
15124
15125
/**
15126
* @return {object} The queue to collect `onDOMReady` callbacks with.
15127
*/
15128
getReactMountReady: function() {
15129
return this.reactMountReady;
15130
},
15131
15132
getPutListenerQueue: function() {
15133
return this.putListenerQueue;
15134
},
15135
15136
/**
15137
* `PooledClass` looks for this, and will invoke this before allowing this
15138
* instance to be resused.
15139
*/
15140
destructor: function() {
15141
CallbackQueue.release(this.reactMountReady);
15142
this.reactMountReady = null;
15143
15144
ReactPutListenerQueue.release(this.putListenerQueue);
15145
this.putListenerQueue = null;
15146
}
15147
};
15148
15149
15150
assign(
15151
ReactServerRenderingTransaction.prototype,
15152
Transaction.Mixin,
15153
Mixin
15154
);
15155
15156
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
15157
15158
module.exports = ReactServerRenderingTransaction;
15159
15160
},{"116":116,"129":129,"29":29,"30":30,"7":7,"87":87}],94:[function(_dereq_,module,exports){
15161
/**
15162
* Copyright 2013-2015, Facebook, Inc.
15163
* All rights reserved.
15164
*
15165
* This source code is licensed under the BSD-style license found in the
15166
* LICENSE file in the root directory of this source tree. An additional grant
15167
* of patent rights can be found in the PATENTS file in the same directory.
15168
*
15169
* @providesModule ReactStateSetters
15170
*/
15171
15172
'use strict';
15173
15174
var ReactStateSetters = {
15175
/**
15176
* Returns a function that calls the provided function, and uses the result
15177
* of that to set the component's state.
15178
*
15179
* @param {ReactCompositeComponent} component
15180
* @param {function} funcReturningState Returned callback uses this to
15181
* determine how to update state.
15182
* @return {function} callback that when invoked uses funcReturningState to
15183
* determined the object literal to setState.
15184
*/
15185
createStateSetter: function(component, funcReturningState) {
15186
return function(a, b, c, d, e, f) {
15187
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
15188
if (partialState) {
15189
component.setState(partialState);
15190
}
15191
};
15192
},
15193
15194
/**
15195
* Returns a single-argument callback that can be used to update a single
15196
* key in the component's state.
15197
*
15198
* Note: this is memoized function, which makes it inexpensive to call.
15199
*
15200
* @param {ReactCompositeComponent} component
15201
* @param {string} key The key in the state that you should update.
15202
* @return {function} callback of 1 argument which calls setState() with
15203
* the provided keyName and callback argument.
15204
*/
15205
createStateKeySetter: function(component, key) {
15206
// Memoize the setters.
15207
var cache = component.__keySetters || (component.__keySetters = {});
15208
return cache[key] || (cache[key] = createStateKeySetter(component, key));
15209
}
15210
};
15211
15212
function createStateKeySetter(component, key) {
15213
// Partial state is allocated outside of the function closure so it can be
15214
// reused with every call, avoiding memory allocation when this function
15215
// is called.
15216
var partialState = {};
15217
return function stateKeySetter(value) {
15218
partialState[key] = value;
15219
component.setState(partialState);
15220
};
15221
}
15222
15223
ReactStateSetters.Mixin = {
15224
/**
15225
* Returns a function that calls the provided function, and uses the result
15226
* of that to set the component's state.
15227
*
15228
* For example, these statements are equivalent:
15229
*
15230
* this.setState({x: 1});
15231
* this.createStateSetter(function(xValue) {
15232
* return {x: xValue};
15233
* })(1);
15234
*
15235
* @param {function} funcReturningState Returned callback uses this to
15236
* determine how to update state.
15237
* @return {function} callback that when invoked uses funcReturningState to
15238
* determined the object literal to setState.
15239
*/
15240
createStateSetter: function(funcReturningState) {
15241
return ReactStateSetters.createStateSetter(this, funcReturningState);
15242
},
15243
15244
/**
15245
* Returns a single-argument callback that can be used to update a single
15246
* key in the component's state.
15247
*
15248
* For example, these statements are equivalent:
15249
*
15250
* this.setState({x: 1});
15251
* this.createStateKeySetter('x')(1);
15252
*
15253
* Note: this is memoized function, which makes it inexpensive to call.
15254
*
15255
* @param {string} key The key in the state that you should update.
15256
* @return {function} callback of 1 argument which calls setState() with
15257
* the provided keyName and callback argument.
15258
*/
15259
createStateKeySetter: function(key) {
15260
return ReactStateSetters.createStateKeySetter(this, key);
15261
}
15262
};
15263
15264
module.exports = ReactStateSetters;
15265
15266
},{}],95:[function(_dereq_,module,exports){
15267
/**
15268
* Copyright 2013-2015, Facebook, Inc.
15269
* All rights reserved.
15270
*
15271
* This source code is licensed under the BSD-style license found in the
15272
* LICENSE file in the root directory of this source tree. An additional grant
15273
* of patent rights can be found in the PATENTS file in the same directory.
15274
*
15275
* @providesModule ReactTestUtils
15276
*/
15277
15278
'use strict';
15279
15280
var EventConstants = _dereq_(16);
15281
var EventPluginHub = _dereq_(18);
15282
var EventPropagators = _dereq_(21);
15283
var React = _dereq_(31);
15284
var ReactElement = _dereq_(63);
15285
var ReactEmptyComponent = _dereq_(65);
15286
var ReactBrowserEventEmitter = _dereq_(33);
15287
var ReactCompositeComponent = _dereq_(43);
15288
var ReactInstanceHandles = _dereq_(72);
15289
var ReactInstanceMap = _dereq_(73);
15290
var ReactMount = _dereq_(77);
15291
var ReactUpdates = _dereq_(100);
15292
var SyntheticEvent = _dereq_(108);
15293
15294
var assign = _dereq_(29);
15295
var emptyObject = _dereq_(130);
15296
15297
var topLevelTypes = EventConstants.topLevelTypes;
15298
15299
function Event(suffix) {}
15300
15301
/**
15302
* @class ReactTestUtils
15303
*/
15304
15305
/**
15306
* Todo: Support the entire DOM.scry query syntax. For now, these simple
15307
* utilities will suffice for testing purposes.
15308
* @lends ReactTestUtils
15309
*/
15310
var ReactTestUtils = {
15311
renderIntoDocument: function(instance) {
15312
var div = document.createElement('div');
15313
// None of our tests actually require attaching the container to the
15314
// DOM, and doing so creates a mess that we rely on test isolation to
15315
// clean up, so we're going to stop honoring the name of this method
15316
// (and probably rename it eventually) if no problems arise.
15317
// document.documentElement.appendChild(div);
15318
return React.render(instance, div);
15319
},
15320
15321
isElement: function(element) {
15322
return ReactElement.isValidElement(element);
15323
},
15324
15325
isElementOfType: function(inst, convenienceConstructor) {
15326
return (
15327
ReactElement.isValidElement(inst) &&
15328
inst.type === convenienceConstructor
15329
);
15330
},
15331
15332
isDOMComponent: function(inst) {
15333
// TODO: Fix this heuristic. It's just here because composites can currently
15334
// pretend to be DOM components.
15335
return !!(inst && inst.tagName && inst.getDOMNode);
15336
},
15337
15338
isDOMComponentElement: function(inst) {
15339
return !!(inst &&
15340
ReactElement.isValidElement(inst) &&
15341
!!inst.tagName);
15342
},
15343
15344
isCompositeComponent: function(inst) {
15345
return typeof inst.render === 'function' &&
15346
typeof inst.setState === 'function';
15347
},
15348
15349
isCompositeComponentWithType: function(inst, type) {
15350
return !!(ReactTestUtils.isCompositeComponent(inst) &&
15351
(inst.constructor === type));
15352
},
15353
15354
isCompositeComponentElement: function(inst) {
15355
if (!ReactElement.isValidElement(inst)) {
15356
return false;
15357
}
15358
// We check the prototype of the type that will get mounted, not the
15359
// instance itself. This is a future proof way of duck typing.
15360
var prototype = inst.type.prototype;
15361
return (
15362
typeof prototype.render === 'function' &&
15363
typeof prototype.setState === 'function'
15364
);
15365
},
15366
15367
isCompositeComponentElementWithType: function(inst, type) {
15368
return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
15369
(inst.constructor === type));
15370
},
15371
15372
getRenderedChildOfCompositeComponent: function(inst) {
15373
if (!ReactTestUtils.isCompositeComponent(inst)) {
15374
return null;
15375
}
15376
var internalInstance = ReactInstanceMap.get(inst);
15377
return internalInstance._renderedComponent.getPublicInstance();
15378
},
15379
15380
findAllInRenderedTree: function(inst, test) {
15381
if (!inst) {
15382
return [];
15383
}
15384
var ret = test(inst) ? [inst] : [];
15385
if (ReactTestUtils.isDOMComponent(inst)) {
15386
var internalInstance = ReactInstanceMap.get(inst);
15387
var renderedChildren = internalInstance
15388
._renderedComponent
15389
._renderedChildren;
15390
var key;
15391
for (key in renderedChildren) {
15392
if (!renderedChildren.hasOwnProperty(key)) {
15393
continue;
15394
}
15395
if (!renderedChildren[key].getPublicInstance) {
15396
continue;
15397
}
15398
ret = ret.concat(
15399
ReactTestUtils.findAllInRenderedTree(
15400
renderedChildren[key].getPublicInstance(),
15401
test
15402
)
15403
);
15404
}
15405
} else if (ReactTestUtils.isCompositeComponent(inst)) {
15406
ret = ret.concat(
15407
ReactTestUtils.findAllInRenderedTree(
15408
ReactTestUtils.getRenderedChildOfCompositeComponent(inst),
15409
test
15410
)
15411
);
15412
}
15413
return ret;
15414
},
15415
15416
/**
15417
* Finds all instance of components in the rendered tree that are DOM
15418
* components with the class name matching `className`.
15419
* @return an array of all the matches.
15420
*/
15421
scryRenderedDOMComponentsWithClass: function(root, className) {
15422
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
15423
var instClassName = inst.props.className;
15424
return ReactTestUtils.isDOMComponent(inst) && (
15425
(instClassName && (' ' + instClassName + ' ').indexOf(' ' + className + ' ') !== -1)
15426
);
15427
});
15428
},
15429
15430
/**
15431
* Like scryRenderedDOMComponentsWithClass but expects there to be one result,
15432
* and returns that one result, or throws exception if there is any other
15433
* number of matches besides one.
15434
* @return {!ReactDOMComponent} The one match.
15435
*/
15436
findRenderedDOMComponentWithClass: function(root, className) {
15437
var all =
15438
ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
15439
if (all.length !== 1) {
15440
throw new Error('Did not find exactly one match ' +
15441
'(found: ' + all.length + ') for class:' + className
15442
);
15443
}
15444
return all[0];
15445
},
15446
15447
15448
/**
15449
* Finds all instance of components in the rendered tree that are DOM
15450
* components with the tag name matching `tagName`.
15451
* @return an array of all the matches.
15452
*/
15453
scryRenderedDOMComponentsWithTag: function(root, tagName) {
15454
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
15455
return ReactTestUtils.isDOMComponent(inst) &&
15456
inst.tagName === tagName.toUpperCase();
15457
});
15458
},
15459
15460
/**
15461
* Like scryRenderedDOMComponentsWithTag but expects there to be one result,
15462
* and returns that one result, or throws exception if there is any other
15463
* number of matches besides one.
15464
* @return {!ReactDOMComponent} The one match.
15465
*/
15466
findRenderedDOMComponentWithTag: function(root, tagName) {
15467
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
15468
if (all.length !== 1) {
15469
throw new Error('Did not find exactly one match for tag:' + tagName);
15470
}
15471
return all[0];
15472
},
15473
15474
15475
/**
15476
* Finds all instances of components with type equal to `componentType`.
15477
* @return an array of all the matches.
15478
*/
15479
scryRenderedComponentsWithType: function(root, componentType) {
15480
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
15481
return ReactTestUtils.isCompositeComponentWithType(
15482
inst,
15483
componentType
15484
);
15485
});
15486
},
15487
15488
/**
15489
* Same as `scryRenderedComponentsWithType` but expects there to be one result
15490
* and returns that one result, or throws exception if there is any other
15491
* number of matches besides one.
15492
* @return {!ReactComponent} The one match.
15493
*/
15494
findRenderedComponentWithType: function(root, componentType) {
15495
var all = ReactTestUtils.scryRenderedComponentsWithType(
15496
root,
15497
componentType
15498
);
15499
if (all.length !== 1) {
15500
throw new Error(
15501
'Did not find exactly one match for componentType:' + componentType
15502
);
15503
}
15504
return all[0];
15505
},
15506
15507
/**
15508
* Pass a mocked component module to this method to augment it with
15509
* useful methods that allow it to be used as a dummy React component.
15510
* Instead of rendering as usual, the component will become a simple
15511
* <div> containing any provided children.
15512
*
15513
* @param {object} module the mock function object exported from a
15514
* module that defines the component to be mocked
15515
* @param {?string} mockTagName optional dummy root tag name to return
15516
* from render method (overrides
15517
* module.mockTagName if provided)
15518
* @return {object} the ReactTestUtils object (for chaining)
15519
*/
15520
mockComponent: function(module, mockTagName) {
15521
mockTagName = mockTagName || module.mockTagName || "div";
15522
15523
module.prototype.render.mockImplementation(function() {
15524
return React.createElement(
15525
mockTagName,
15526
null,
15527
this.props.children
15528
);
15529
});
15530
15531
return this;
15532
},
15533
15534
/**
15535
* Simulates a top level event being dispatched from a raw event that occured
15536
* on an `Element` node.
15537
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`
15538
* @param {!Element} node The dom to simulate an event occurring on.
15539
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
15540
*/
15541
simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) {
15542
fakeNativeEvent.target = node;
15543
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(
15544
topLevelType,
15545
fakeNativeEvent
15546
);
15547
},
15548
15549
/**
15550
* Simulates a top level event being dispatched from a raw event that occured
15551
* on the `ReactDOMComponent` `comp`.
15552
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`.
15553
* @param comp {!ReactDOMComponent}
15554
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
15555
*/
15556
simulateNativeEventOnDOMComponent: function(
15557
topLevelType,
15558
comp,
15559
fakeNativeEvent) {
15560
ReactTestUtils.simulateNativeEventOnNode(
15561
topLevelType,
15562
comp.getDOMNode(),
15563
fakeNativeEvent
15564
);
15565
},
15566
15567
nativeTouchData: function(x, y) {
15568
return {
15569
touches: [
15570
{pageX: x, pageY: y}
15571
]
15572
};
15573
},
15574
15575
createRenderer: function() {
15576
return new ReactShallowRenderer();
15577
},
15578
15579
Simulate: null,
15580
SimulateNative: {}
15581
};
15582
15583
/**
15584
* @class ReactShallowRenderer
15585
*/
15586
var ReactShallowRenderer = function() {
15587
this._instance = null;
15588
};
15589
15590
ReactShallowRenderer.prototype.getRenderOutput = function() {
15591
return (
15592
(this._instance && this._instance._renderedComponent &&
15593
this._instance._renderedComponent._renderedOutput)
15594
|| null
15595
);
15596
};
15597
15598
var NoopInternalComponent = function(element) {
15599
this._renderedOutput = element;
15600
this._currentElement = element === null || element === false ?
15601
ReactEmptyComponent.emptyElement :
15602
element;
15603
};
15604
15605
NoopInternalComponent.prototype = {
15606
15607
mountComponent: function() {
15608
},
15609
15610
receiveComponent: function(element) {
15611
this._renderedOutput = element;
15612
this._currentElement = element === null || element === false ?
15613
ReactEmptyComponent.emptyElement :
15614
element;
15615
},
15616
15617
unmountComponent: function() {
15618
}
15619
15620
};
15621
15622
var ShallowComponentWrapper = function() { };
15623
assign(
15624
ShallowComponentWrapper.prototype,
15625
ReactCompositeComponent.Mixin, {
15626
_instantiateReactComponent: function(element) {
15627
return new NoopInternalComponent(element);
15628
},
15629
_replaceNodeWithMarkupByID: function() {},
15630
_renderValidatedComponent:
15631
ReactCompositeComponent.Mixin.
15632
_renderValidatedComponentWithoutOwnerOrContext
15633
}
15634
);
15635
15636
ReactShallowRenderer.prototype.render = function(element, context) {
15637
if (!context) {
15638
context = emptyObject;
15639
}
15640
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
15641
this._render(element, transaction, context);
15642
ReactUpdates.ReactReconcileTransaction.release(transaction);
15643
};
15644
15645
ReactShallowRenderer.prototype.unmount = function() {
15646
if (this._instance) {
15647
this._instance.unmountComponent();
15648
}
15649
};
15650
15651
ReactShallowRenderer.prototype._render = function(element, transaction, context) {
15652
if (!this._instance) {
15653
var rootID = ReactInstanceHandles.createReactRootID();
15654
var instance = new ShallowComponentWrapper(element.type);
15655
instance.construct(element);
15656
15657
instance.mountComponent(rootID, transaction, context);
15658
15659
this._instance = instance;
15660
} else {
15661
this._instance.receiveComponent(element, transaction, context);
15662
}
15663
};
15664
15665
/**
15666
* Exports:
15667
*
15668
* - `ReactTestUtils.Simulate.click(Element/ReactDOMComponent)`
15669
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactDOMComponent)`
15670
* - `ReactTestUtils.Simulate.change(Element/ReactDOMComponent)`
15671
* - ... (All keys from event plugin `eventTypes` objects)
15672
*/
15673
function makeSimulator(eventType) {
15674
return function(domComponentOrNode, eventData) {
15675
var node;
15676
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
15677
node = domComponentOrNode.getDOMNode();
15678
} else if (domComponentOrNode.tagName) {
15679
node = domComponentOrNode;
15680
}
15681
15682
var fakeNativeEvent = new Event();
15683
fakeNativeEvent.target = node;
15684
// We don't use SyntheticEvent.getPooled in order to not have to worry about
15685
// properly destroying any properties assigned from `eventData` upon release
15686
var event = new SyntheticEvent(
15687
ReactBrowserEventEmitter.eventNameDispatchConfigs[eventType],
15688
ReactMount.getID(node),
15689
fakeNativeEvent
15690
);
15691
assign(event, eventData);
15692
EventPropagators.accumulateTwoPhaseDispatches(event);
15693
15694
ReactUpdates.batchedUpdates(function() {
15695
EventPluginHub.enqueueEvents(event);
15696
EventPluginHub.processEventQueue();
15697
});
15698
};
15699
}
15700
15701
function buildSimulators() {
15702
ReactTestUtils.Simulate = {};
15703
15704
var eventType;
15705
for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
15706
/**
15707
* @param {!Element || ReactDOMComponent} domComponentOrNode
15708
* @param {?object} eventData Fake event data to use in SyntheticEvent.
15709
*/
15710
ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
15711
}
15712
}
15713
15714
// Rebuild ReactTestUtils.Simulate whenever event plugins are injected
15715
var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
15716
EventPluginHub.injection.injectEventPluginOrder = function() {
15717
oldInjectEventPluginOrder.apply(this, arguments);
15718
buildSimulators();
15719
};
15720
var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
15721
EventPluginHub.injection.injectEventPluginsByName = function() {
15722
oldInjectEventPlugins.apply(this, arguments);
15723
buildSimulators();
15724
};
15725
15726
buildSimulators();
15727
15728
/**
15729
* Exports:
15730
*
15731
* - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
15732
* - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
15733
* - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
15734
* - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
15735
* - ... (All keys from `EventConstants.topLevelTypes`)
15736
*
15737
* Note: Top level event types are a subset of the entire set of handler types
15738
* (which include a broader set of "synthetic" events). For example, onDragDone
15739
* is a synthetic event. Except when testing an event plugin or React's event
15740
* handling code specifically, you probably want to use ReactTestUtils.Simulate
15741
* to dispatch synthetic events.
15742
*/
15743
15744
function makeNativeSimulator(eventType) {
15745
return function(domComponentOrNode, nativeEventData) {
15746
var fakeNativeEvent = new Event(eventType);
15747
assign(fakeNativeEvent, nativeEventData);
15748
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
15749
ReactTestUtils.simulateNativeEventOnDOMComponent(
15750
eventType,
15751
domComponentOrNode,
15752
fakeNativeEvent
15753
);
15754
} else if (!!domComponentOrNode.tagName) {
15755
// Will allow on actual dom nodes.
15756
ReactTestUtils.simulateNativeEventOnNode(
15757
eventType,
15758
domComponentOrNode,
15759
fakeNativeEvent
15760
);
15761
}
15762
};
15763
}
15764
15765
var eventType;
15766
for (eventType in topLevelTypes) {
15767
// Event type is stored as 'topClick' - we transform that to 'click'
15768
var convenienceName = eventType.indexOf('top') === 0 ?
15769
eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
15770
/**
15771
* @param {!Element || ReactDOMComponent} domComponentOrNode
15772
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
15773
*/
15774
ReactTestUtils.SimulateNative[convenienceName] =
15775
makeNativeSimulator(eventType);
15776
}
15777
15778
module.exports = ReactTestUtils;
15779
15780
},{"100":100,"108":108,"130":130,"16":16,"18":18,"21":21,"29":29,"31":31,"33":33,"43":43,"63":63,"65":65,"72":72,"73":73,"77":77}],96:[function(_dereq_,module,exports){
15781
/**
15782
* Copyright 2013-2015, Facebook, Inc.
15783
* All rights reserved.
15784
*
15785
* This source code is licensed under the BSD-style license found in the
15786
* LICENSE file in the root directory of this source tree. An additional grant
15787
* of patent rights can be found in the PATENTS file in the same directory.
15788
*
15789
* @typechecks static-only
15790
* @providesModule ReactTransitionChildMapping
15791
*/
15792
15793
'use strict';
15794
15795
var ReactChildren = _dereq_(37);
15796
var ReactFragment = _dereq_(69);
15797
15798
var ReactTransitionChildMapping = {
15799
/**
15800
* Given `this.props.children`, return an object mapping key to child. Just
15801
* simple syntactic sugar around ReactChildren.map().
15802
*
15803
* @param {*} children `this.props.children`
15804
* @return {object} Mapping of key to child
15805
*/
15806
getChildMapping: function(children) {
15807
if (!children) {
15808
return children;
15809
}
15810
return ReactFragment.extract(ReactChildren.map(children, function(child) {
15811
return child;
15812
}));
15813
},
15814
15815
/**
15816
* When you're adding or removing children some may be added or removed in the
15817
* same render pass. We want to show *both* since we want to simultaneously
15818
* animate elements in and out. This function takes a previous set of keys
15819
* and a new set of keys and merges them with its best guess of the correct
15820
* ordering. In the future we may expose some of the utilities in
15821
* ReactMultiChild to make this easy, but for now React itself does not
15822
* directly have this concept of the union of prevChildren and nextChildren
15823
* so we implement it here.
15824
*
15825
* @param {object} prev prev children as returned from
15826
* `ReactTransitionChildMapping.getChildMapping()`.
15827
* @param {object} next next children as returned from
15828
* `ReactTransitionChildMapping.getChildMapping()`.
15829
* @return {object} a key set that contains all keys in `prev` and all keys
15830
* in `next` in a reasonable order.
15831
*/
15832
mergeChildMappings: function(prev, next) {
15833
prev = prev || {};
15834
next = next || {};
15835
15836
function getValueForKey(key) {
15837
if (next.hasOwnProperty(key)) {
15838
return next[key];
15839
} else {
15840
return prev[key];
15841
}
15842
}
15843
15844
// For each key of `next`, the list of keys to insert before that key in
15845
// the combined list
15846
var nextKeysPending = {};
15847
15848
var pendingKeys = [];
15849
for (var prevKey in prev) {
15850
if (next.hasOwnProperty(prevKey)) {
15851
if (pendingKeys.length) {
15852
nextKeysPending[prevKey] = pendingKeys;
15853
pendingKeys = [];
15854
}
15855
} else {
15856
pendingKeys.push(prevKey);
15857
}
15858
}
15859
15860
var i;
15861
var childMapping = {};
15862
for (var nextKey in next) {
15863
if (nextKeysPending.hasOwnProperty(nextKey)) {
15864
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
15865
var pendingNextKey = nextKeysPending[nextKey][i];
15866
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
15867
pendingNextKey
15868
);
15869
}
15870
}
15871
childMapping[nextKey] = getValueForKey(nextKey);
15872
}
15873
15874
// Finally, add the keys which didn't appear before any key in `next`
15875
for (i = 0; i < pendingKeys.length; i++) {
15876
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
15877
}
15878
15879
return childMapping;
15880
}
15881
};
15882
15883
module.exports = ReactTransitionChildMapping;
15884
15885
},{"37":37,"69":69}],97:[function(_dereq_,module,exports){
15886
/**
15887
* Copyright 2013-2015, Facebook, Inc.
15888
* All rights reserved.
15889
*
15890
* This source code is licensed under the BSD-style license found in the
15891
* LICENSE file in the root directory of this source tree. An additional grant
15892
* of patent rights can be found in the PATENTS file in the same directory.
15893
*
15894
* @providesModule ReactTransitionEvents
15895
*/
15896
15897
'use strict';
15898
15899
var ExecutionEnvironment = _dereq_(22);
15900
15901
/**
15902
* EVENT_NAME_MAP is used to determine which event fired when a
15903
* transition/animation ends, based on the style property used to
15904
* define that event.
15905
*/
15906
var EVENT_NAME_MAP = {
15907
transitionend: {
15908
'transition': 'transitionend',
15909
'WebkitTransition': 'webkitTransitionEnd',
15910
'MozTransition': 'mozTransitionEnd',
15911
'OTransition': 'oTransitionEnd',
15912
'msTransition': 'MSTransitionEnd'
15913
},
15914
15915
animationend: {
15916
'animation': 'animationend',
15917
'WebkitAnimation': 'webkitAnimationEnd',
15918
'MozAnimation': 'mozAnimationEnd',
15919
'OAnimation': 'oAnimationEnd',
15920
'msAnimation': 'MSAnimationEnd'
15921
}
15922
};
15923
15924
var endEvents = [];
15925
15926
function detectEvents() {
15927
var testEl = document.createElement('div');
15928
var style = testEl.style;
15929
15930
// On some platforms, in particular some releases of Android 4.x,
15931
// the un-prefixed "animation" and "transition" properties are defined on the
15932
// style object but the events that fire will still be prefixed, so we need
15933
// to check if the un-prefixed events are useable, and if not remove them
15934
// from the map
15935
if (!('AnimationEvent' in window)) {
15936
delete EVENT_NAME_MAP.animationend.animation;
15937
}
15938
15939
if (!('TransitionEvent' in window)) {
15940
delete EVENT_NAME_MAP.transitionend.transition;
15941
}
15942
15943
for (var baseEventName in EVENT_NAME_MAP) {
15944
var baseEvents = EVENT_NAME_MAP[baseEventName];
15945
for (var styleName in baseEvents) {
15946
if (styleName in style) {
15947
endEvents.push(baseEvents[styleName]);
15948
break;
15949
}
15950
}
15951
}
15952
}
15953
15954
if (ExecutionEnvironment.canUseDOM) {
15955
detectEvents();
15956
}
15957
15958
// We use the raw {add|remove}EventListener() call because EventListener
15959
// does not know how to remove event listeners and we really should
15960
// clean up. Also, these events are not triggered in older browsers
15961
// so we should be A-OK here.
15962
15963
function addEventListener(node, eventName, eventListener) {
15964
node.addEventListener(eventName, eventListener, false);
15965
}
15966
15967
function removeEventListener(node, eventName, eventListener) {
15968
node.removeEventListener(eventName, eventListener, false);
15969
}
15970
15971
var ReactTransitionEvents = {
15972
addEndEventListener: function(node, eventListener) {
15973
if (endEvents.length === 0) {
15974
// If CSS transitions are not supported, trigger an "end animation"
15975
// event immediately.
15976
window.setTimeout(eventListener, 0);
15977
return;
15978
}
15979
endEvents.forEach(function(endEvent) {
15980
addEventListener(node, endEvent, eventListener);
15981
});
15982
},
15983
15984
removeEndEventListener: function(node, eventListener) {
15985
if (endEvents.length === 0) {
15986
return;
15987
}
15988
endEvents.forEach(function(endEvent) {
15989
removeEventListener(node, endEvent, eventListener);
15990
});
15991
}
15992
};
15993
15994
module.exports = ReactTransitionEvents;
15995
15996
},{"22":22}],98:[function(_dereq_,module,exports){
15997
/**
15998
* Copyright 2013-2015, Facebook, Inc.
15999
* All rights reserved.
16000
*
16001
* This source code is licensed under the BSD-style license found in the
16002
* LICENSE file in the root directory of this source tree. An additional grant
16003
* of patent rights can be found in the PATENTS file in the same directory.
16004
*
16005
* @providesModule ReactTransitionGroup
16006
*/
16007
16008
'use strict';
16009
16010
var React = _dereq_(31);
16011
var ReactTransitionChildMapping = _dereq_(96);
16012
16013
var assign = _dereq_(29);
16014
var cloneWithProps = _dereq_(122);
16015
var emptyFunction = _dereq_(129);
16016
16017
var ReactTransitionGroup = React.createClass({
16018
displayName: 'ReactTransitionGroup',
16019
16020
propTypes: {
16021
component: React.PropTypes.any,
16022
childFactory: React.PropTypes.func
16023
},
16024
16025
getDefaultProps: function() {
16026
return {
16027
component: 'span',
16028
childFactory: emptyFunction.thatReturnsArgument
16029
};
16030
},
16031
16032
getInitialState: function() {
16033
return {
16034
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
16035
};
16036
},
16037
16038
componentWillMount: function() {
16039
this.currentlyTransitioningKeys = {};
16040
this.keysToEnter = [];
16041
this.keysToLeave = [];
16042
},
16043
16044
componentDidMount: function() {
16045
var initialChildMapping = this.state.children;
16046
for (var key in initialChildMapping) {
16047
if (initialChildMapping[key]) {
16048
this.performAppear(key);
16049
}
16050
}
16051
},
16052
16053
componentWillReceiveProps: function(nextProps) {
16054
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
16055
nextProps.children
16056
);
16057
var prevChildMapping = this.state.children;
16058
16059
this.setState({
16060
children: ReactTransitionChildMapping.mergeChildMappings(
16061
prevChildMapping,
16062
nextChildMapping
16063
)
16064
});
16065
16066
var key;
16067
16068
for (key in nextChildMapping) {
16069
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
16070
if (nextChildMapping[key] && !hasPrev &&
16071
!this.currentlyTransitioningKeys[key]) {
16072
this.keysToEnter.push(key);
16073
}
16074
}
16075
16076
for (key in prevChildMapping) {
16077
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
16078
if (prevChildMapping[key] && !hasNext &&
16079
!this.currentlyTransitioningKeys[key]) {
16080
this.keysToLeave.push(key);
16081
}
16082
}
16083
16084
// If we want to someday check for reordering, we could do it here.
16085
},
16086
16087
componentDidUpdate: function() {
16088
var keysToEnter = this.keysToEnter;
16089
this.keysToEnter = [];
16090
keysToEnter.forEach(this.performEnter);
16091
16092
var keysToLeave = this.keysToLeave;
16093
this.keysToLeave = [];
16094
keysToLeave.forEach(this.performLeave);
16095
},
16096
16097
performAppear: function(key) {
16098
this.currentlyTransitioningKeys[key] = true;
16099
16100
var component = this.refs[key];
16101
16102
if (component.componentWillAppear) {
16103
component.componentWillAppear(
16104
this._handleDoneAppearing.bind(this, key)
16105
);
16106
} else {
16107
this._handleDoneAppearing(key);
16108
}
16109
},
16110
16111
_handleDoneAppearing: function(key) {
16112
var component = this.refs[key];
16113
if (component.componentDidAppear) {
16114
component.componentDidAppear();
16115
}
16116
16117
delete this.currentlyTransitioningKeys[key];
16118
16119
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
16120
this.props.children
16121
);
16122
16123
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
16124
// This was removed before it had fully appeared. Remove it.
16125
this.performLeave(key);
16126
}
16127
},
16128
16129
performEnter: function(key) {
16130
this.currentlyTransitioningKeys[key] = true;
16131
16132
var component = this.refs[key];
16133
16134
if (component.componentWillEnter) {
16135
component.componentWillEnter(
16136
this._handleDoneEntering.bind(this, key)
16137
);
16138
} else {
16139
this._handleDoneEntering(key);
16140
}
16141
},
16142
16143
_handleDoneEntering: function(key) {
16144
var component = this.refs[key];
16145
if (component.componentDidEnter) {
16146
component.componentDidEnter();
16147
}
16148
16149
delete this.currentlyTransitioningKeys[key];
16150
16151
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
16152
this.props.children
16153
);
16154
16155
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
16156
// This was removed before it had fully entered. Remove it.
16157
this.performLeave(key);
16158
}
16159
},
16160
16161
performLeave: function(key) {
16162
this.currentlyTransitioningKeys[key] = true;
16163
16164
var component = this.refs[key];
16165
if (component.componentWillLeave) {
16166
component.componentWillLeave(this._handleDoneLeaving.bind(this, key));
16167
} else {
16168
// Note that this is somewhat dangerous b/c it calls setState()
16169
// again, effectively mutating the component before all the work
16170
// is done.
16171
this._handleDoneLeaving(key);
16172
}
16173
},
16174
16175
_handleDoneLeaving: function(key) {
16176
var component = this.refs[key];
16177
16178
if (component.componentDidLeave) {
16179
component.componentDidLeave();
16180
}
16181
16182
delete this.currentlyTransitioningKeys[key];
16183
16184
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
16185
this.props.children
16186
);
16187
16188
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
16189
// This entered again before it fully left. Add it again.
16190
this.performEnter(key);
16191
} else {
16192
var newChildren = assign({}, this.state.children);
16193
delete newChildren[key];
16194
this.setState({children: newChildren});
16195
}
16196
},
16197
16198
render: function() {
16199
// TODO: we could get rid of the need for the wrapper node
16200
// by cloning a single child
16201
var childrenToRender = [];
16202
for (var key in this.state.children) {
16203
var child = this.state.children[key];
16204
if (child) {
16205
// You may need to apply reactive updates to a child as it is leaving.
16206
// The normal React way to do it won't work since the child will have
16207
// already been removed. In case you need this behavior you can provide
16208
// a childFactory function to wrap every child, even the ones that are
16209
// leaving.
16210
childrenToRender.push(cloneWithProps(
16211
this.props.childFactory(child),
16212
{ref: key, key: key}
16213
));
16214
}
16215
}
16216
return React.createElement(
16217
this.props.component,
16218
this.props,
16219
childrenToRender
16220
);
16221
}
16222
});
16223
16224
module.exports = ReactTransitionGroup;
16225
16226
},{"122":122,"129":129,"29":29,"31":31,"96":96}],99:[function(_dereq_,module,exports){
16227
/**
16228
* Copyright 2015, Facebook, Inc.
16229
* All rights reserved.
16230
*
16231
* This source code is licensed under the BSD-style license found in the
16232
* LICENSE file in the root directory of this source tree. An additional grant
16233
* of patent rights can be found in the PATENTS file in the same directory.
16234
*
16235
* @providesModule ReactUpdateQueue
16236
*/
16237
16238
'use strict';
16239
16240
var ReactLifeCycle = _dereq_(74);
16241
var ReactCurrentOwner = _dereq_(45);
16242
var ReactElement = _dereq_(63);
16243
var ReactInstanceMap = _dereq_(73);
16244
var ReactUpdates = _dereq_(100);
16245
16246
var assign = _dereq_(29);
16247
var invariant = _dereq_(150);
16248
var warning = _dereq_(171);
16249
16250
function enqueueUpdate(internalInstance) {
16251
if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
16252
// If we're in a componentWillMount handler, don't enqueue a rerender
16253
// because ReactUpdates assumes we're in a browser context (which is
16254
// wrong for server rendering) and we're about to do a render anyway.
16255
// See bug in #1740.
16256
ReactUpdates.enqueueUpdate(internalInstance);
16257
}
16258
}
16259
16260
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
16261
("production" !== "development" ? invariant(
16262
ReactCurrentOwner.current == null,
16263
'%s(...): Cannot update during an existing state transition ' +
16264
'(such as within `render`). Render methods should be a pure function ' +
16265
'of props and state.',
16266
callerName
16267
) : invariant(ReactCurrentOwner.current == null));
16268
16269
var internalInstance = ReactInstanceMap.get(publicInstance);
16270
if (!internalInstance) {
16271
if ("production" !== "development") {
16272
// Only warn when we have a callerName. Otherwise we should be silent.
16273
// We're probably calling from enqueueCallback. We don't want to warn
16274
// there because we already warned for the corresponding lifecycle method.
16275
("production" !== "development" ? warning(
16276
!callerName,
16277
'%s(...): Can only update a mounted or mounting component. ' +
16278
'This usually means you called %s() on an unmounted ' +
16279
'component. This is a no-op.',
16280
callerName,
16281
callerName
16282
) : null);
16283
}
16284
return null;
16285
}
16286
16287
if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
16288
return null;
16289
}
16290
16291
return internalInstance;
16292
}
16293
16294
/**
16295
* ReactUpdateQueue allows for state updates to be scheduled into a later
16296
* reconciliation step.
16297
*/
16298
var ReactUpdateQueue = {
16299
16300
/**
16301
* Enqueue a callback that will be executed after all the pending updates
16302
* have processed.
16303
*
16304
* @param {ReactClass} publicInstance The instance to use as `this` context.
16305
* @param {?function} callback Called after state is updated.
16306
* @internal
16307
*/
16308
enqueueCallback: function(publicInstance, callback) {
16309
("production" !== "development" ? invariant(
16310
typeof callback === 'function',
16311
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
16312
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
16313
'isn\'t callable.'
16314
) : invariant(typeof callback === 'function'));
16315
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
16316
16317
// Previously we would throw an error if we didn't have an internal
16318
// instance. Since we want to make it a no-op instead, we mirror the same
16319
// behavior we have in other enqueue* methods.
16320
// We also need to ignore callbacks in componentWillMount. See
16321
// enqueueUpdates.
16322
if (!internalInstance ||
16323
internalInstance === ReactLifeCycle.currentlyMountingInstance) {
16324
return null;
16325
}
16326
16327
if (internalInstance._pendingCallbacks) {
16328
internalInstance._pendingCallbacks.push(callback);
16329
} else {
16330
internalInstance._pendingCallbacks = [callback];
16331
}
16332
// TODO: The callback here is ignored when setState is called from
16333
// componentWillMount. Either fix it or disallow doing so completely in
16334
// favor of getInitialState. Alternatively, we can disallow
16335
// componentWillMount during server-side rendering.
16336
enqueueUpdate(internalInstance);
16337
},
16338
16339
enqueueCallbackInternal: function(internalInstance, callback) {
16340
("production" !== "development" ? invariant(
16341
typeof callback === 'function',
16342
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
16343
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
16344
'isn\'t callable.'
16345
) : invariant(typeof callback === 'function'));
16346
if (internalInstance._pendingCallbacks) {
16347
internalInstance._pendingCallbacks.push(callback);
16348
} else {
16349
internalInstance._pendingCallbacks = [callback];
16350
}
16351
enqueueUpdate(internalInstance);
16352
},
16353
16354
/**
16355
* Forces an update. This should only be invoked when it is known with
16356
* certainty that we are **not** in a DOM transaction.
16357
*
16358
* You may want to call this when you know that some deeper aspect of the
16359
* component's state has changed but `setState` was not called.
16360
*
16361
* This will not invoke `shouldUpdateComponent`, but it will invoke
16362
* `componentWillUpdate` and `componentDidUpdate`.
16363
*
16364
* @param {ReactClass} publicInstance The instance that should rerender.
16365
* @internal
16366
*/
16367
enqueueForceUpdate: function(publicInstance) {
16368
var internalInstance = getInternalInstanceReadyForUpdate(
16369
publicInstance,
16370
'forceUpdate'
16371
);
16372
16373
if (!internalInstance) {
16374
return;
16375
}
16376
16377
internalInstance._pendingForceUpdate = true;
16378
16379
enqueueUpdate(internalInstance);
16380
},
16381
16382
/**
16383
* Replaces all of the state. Always use this or `setState` to mutate state.
16384
* You should treat `this.state` as immutable.
16385
*
16386
* There is no guarantee that `this.state` will be immediately updated, so
16387
* accessing `this.state` after calling this method may return the old value.
16388
*
16389
* @param {ReactClass} publicInstance The instance that should rerender.
16390
* @param {object} completeState Next state.
16391
* @internal
16392
*/
16393
enqueueReplaceState: function(publicInstance, completeState) {
16394
var internalInstance = getInternalInstanceReadyForUpdate(
16395
publicInstance,
16396
'replaceState'
16397
);
16398
16399
if (!internalInstance) {
16400
return;
16401
}
16402
16403
internalInstance._pendingStateQueue = [completeState];
16404
internalInstance._pendingReplaceState = true;
16405
16406
enqueueUpdate(internalInstance);
16407
},
16408
16409
/**
16410
* Sets a subset of the state. This only exists because _pendingState is
16411
* internal. This provides a merging strategy that is not available to deep
16412
* properties which is confusing. TODO: Expose pendingState or don't use it
16413
* during the merge.
16414
*
16415
* @param {ReactClass} publicInstance The instance that should rerender.
16416
* @param {object} partialState Next partial state to be merged with state.
16417
* @internal
16418
*/
16419
enqueueSetState: function(publicInstance, partialState) {
16420
var internalInstance = getInternalInstanceReadyForUpdate(
16421
publicInstance,
16422
'setState'
16423
);
16424
16425
if (!internalInstance) {
16426
return;
16427
}
16428
16429
var queue =
16430
internalInstance._pendingStateQueue ||
16431
(internalInstance._pendingStateQueue = []);
16432
queue.push(partialState);
16433
16434
enqueueUpdate(internalInstance);
16435
},
16436
16437
/**
16438
* Sets a subset of the props.
16439
*
16440
* @param {ReactClass} publicInstance The instance that should rerender.
16441
* @param {object} partialProps Subset of the next props.
16442
* @internal
16443
*/
16444
enqueueSetProps: function(publicInstance, partialProps) {
16445
var internalInstance = getInternalInstanceReadyForUpdate(
16446
publicInstance,
16447
'setProps'
16448
);
16449
16450
if (!internalInstance) {
16451
return;
16452
}
16453
16454
("production" !== "development" ? invariant(
16455
internalInstance._isTopLevel,
16456
'setProps(...): You called `setProps` on a ' +
16457
'component with a parent. This is an anti-pattern since props will ' +
16458
'get reactively updated when rendered. Instead, change the owner\'s ' +
16459
'`render` method to pass the correct value as props to the component ' +
16460
'where it is created.'
16461
) : invariant(internalInstance._isTopLevel));
16462
16463
// Merge with the pending element if it exists, otherwise with existing
16464
// element props.
16465
var element = internalInstance._pendingElement ||
16466
internalInstance._currentElement;
16467
var props = assign({}, element.props, partialProps);
16468
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
16469
element,
16470
props
16471
);
16472
16473
enqueueUpdate(internalInstance);
16474
},
16475
16476
/**
16477
* Replaces all of the props.
16478
*
16479
* @param {ReactClass} publicInstance The instance that should rerender.
16480
* @param {object} props New props.
16481
* @internal
16482
*/
16483
enqueueReplaceProps: function(publicInstance, props) {
16484
var internalInstance = getInternalInstanceReadyForUpdate(
16485
publicInstance,
16486
'replaceProps'
16487
);
16488
16489
if (!internalInstance) {
16490
return;
16491
}
16492
16493
("production" !== "development" ? invariant(
16494
internalInstance._isTopLevel,
16495
'replaceProps(...): You called `replaceProps` on a ' +
16496
'component with a parent. This is an anti-pattern since props will ' +
16497
'get reactively updated when rendered. Instead, change the owner\'s ' +
16498
'`render` method to pass the correct value as props to the component ' +
16499
'where it is created.'
16500
) : invariant(internalInstance._isTopLevel));
16501
16502
// Merge with the pending element if it exists, otherwise with existing
16503
// element props.
16504
var element = internalInstance._pendingElement ||
16505
internalInstance._currentElement;
16506
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
16507
element,
16508
props
16509
);
16510
16511
enqueueUpdate(internalInstance);
16512
},
16513
16514
enqueueElementInternal: function(internalInstance, newElement) {
16515
internalInstance._pendingElement = newElement;
16516
enqueueUpdate(internalInstance);
16517
}
16518
16519
};
16520
16521
module.exports = ReactUpdateQueue;
16522
16523
},{"100":100,"150":150,"171":171,"29":29,"45":45,"63":63,"73":73,"74":74}],100:[function(_dereq_,module,exports){
16524
/**
16525
* Copyright 2013-2015, Facebook, Inc.
16526
* All rights reserved.
16527
*
16528
* This source code is licensed under the BSD-style license found in the
16529
* LICENSE file in the root directory of this source tree. An additional grant
16530
* of patent rights can be found in the PATENTS file in the same directory.
16531
*
16532
* @providesModule ReactUpdates
16533
*/
16534
16535
'use strict';
16536
16537
var CallbackQueue = _dereq_(7);
16538
var PooledClass = _dereq_(30);
16539
var ReactCurrentOwner = _dereq_(45);
16540
var ReactPerf = _dereq_(82);
16541
var ReactReconciler = _dereq_(89);
16542
var Transaction = _dereq_(116);
16543
16544
var assign = _dereq_(29);
16545
var invariant = _dereq_(150);
16546
var warning = _dereq_(171);
16547
16548
var dirtyComponents = [];
16549
var asapCallbackQueue = CallbackQueue.getPooled();
16550
var asapEnqueued = false;
16551
16552
var batchingStrategy = null;
16553
16554
function ensureInjected() {
16555
("production" !== "development" ? invariant(
16556
ReactUpdates.ReactReconcileTransaction && batchingStrategy,
16557
'ReactUpdates: must inject a reconcile transaction class and batching ' +
16558
'strategy'
16559
) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
16560
}
16561
16562
var NESTED_UPDATES = {
16563
initialize: function() {
16564
this.dirtyComponentsLength = dirtyComponents.length;
16565
},
16566
close: function() {
16567
if (this.dirtyComponentsLength !== dirtyComponents.length) {
16568
// Additional updates were enqueued by componentDidUpdate handlers or
16569
// similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
16570
// these new updates so that if A's componentDidUpdate calls setState on
16571
// B, B will update before the callback A's updater provided when calling
16572
// setState.
16573
dirtyComponents.splice(0, this.dirtyComponentsLength);
16574
flushBatchedUpdates();
16575
} else {
16576
dirtyComponents.length = 0;
16577
}
16578
}
16579
};
16580
16581
var UPDATE_QUEUEING = {
16582
initialize: function() {
16583
this.callbackQueue.reset();
16584
},
16585
close: function() {
16586
this.callbackQueue.notifyAll();
16587
}
16588
};
16589
16590
var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
16591
16592
function ReactUpdatesFlushTransaction() {
16593
this.reinitializeTransaction();
16594
this.dirtyComponentsLength = null;
16595
this.callbackQueue = CallbackQueue.getPooled();
16596
this.reconcileTransaction =
16597
ReactUpdates.ReactReconcileTransaction.getPooled();
16598
}
16599
16600
assign(
16601
ReactUpdatesFlushTransaction.prototype,
16602
Transaction.Mixin, {
16603
getTransactionWrappers: function() {
16604
return TRANSACTION_WRAPPERS;
16605
},
16606
16607
destructor: function() {
16608
this.dirtyComponentsLength = null;
16609
CallbackQueue.release(this.callbackQueue);
16610
this.callbackQueue = null;
16611
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
16612
this.reconcileTransaction = null;
16613
},
16614
16615
perform: function(method, scope, a) {
16616
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
16617
// with this transaction's wrappers around it.
16618
return Transaction.Mixin.perform.call(
16619
this,
16620
this.reconcileTransaction.perform,
16621
this.reconcileTransaction,
16622
method,
16623
scope,
16624
a
16625
);
16626
}
16627
});
16628
16629
PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
16630
16631
function batchedUpdates(callback, a, b, c, d) {
16632
ensureInjected();
16633
batchingStrategy.batchedUpdates(callback, a, b, c, d);
16634
}
16635
16636
/**
16637
* Array comparator for ReactComponents by mount ordering.
16638
*
16639
* @param {ReactComponent} c1 first component you're comparing
16640
* @param {ReactComponent} c2 second component you're comparing
16641
* @return {number} Return value usable by Array.prototype.sort().
16642
*/
16643
function mountOrderComparator(c1, c2) {
16644
return c1._mountOrder - c2._mountOrder;
16645
}
16646
16647
function runBatchedUpdates(transaction) {
16648
var len = transaction.dirtyComponentsLength;
16649
("production" !== "development" ? invariant(
16650
len === dirtyComponents.length,
16651
'Expected flush transaction\'s stored dirty-components length (%s) to ' +
16652
'match dirty-components array length (%s).',
16653
len,
16654
dirtyComponents.length
16655
) : invariant(len === dirtyComponents.length));
16656
16657
// Since reconciling a component higher in the owner hierarchy usually (not
16658
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
16659
// them before their children by sorting the array.
16660
dirtyComponents.sort(mountOrderComparator);
16661
16662
for (var i = 0; i < len; i++) {
16663
// If a component is unmounted before pending changes apply, it will still
16664
// be here, but we assume that it has cleared its _pendingCallbacks and
16665
// that performUpdateIfNecessary is a noop.
16666
var component = dirtyComponents[i];
16667
16668
// If performUpdateIfNecessary happens to enqueue any new updates, we
16669
// shouldn't execute the callbacks until the next render happens, so
16670
// stash the callbacks first
16671
var callbacks = component._pendingCallbacks;
16672
component._pendingCallbacks = null;
16673
16674
ReactReconciler.performUpdateIfNecessary(
16675
component,
16676
transaction.reconcileTransaction
16677
);
16678
16679
if (callbacks) {
16680
for (var j = 0; j < callbacks.length; j++) {
16681
transaction.callbackQueue.enqueue(
16682
callbacks[j],
16683
component.getPublicInstance()
16684
);
16685
}
16686
}
16687
}
16688
}
16689
16690
var flushBatchedUpdates = function() {
16691
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
16692
// array and perform any updates enqueued by mount-ready handlers (i.e.,
16693
// componentDidUpdate) but we need to check here too in order to catch
16694
// updates enqueued by setState callbacks and asap calls.
16695
while (dirtyComponents.length || asapEnqueued) {
16696
if (dirtyComponents.length) {
16697
var transaction = ReactUpdatesFlushTransaction.getPooled();
16698
transaction.perform(runBatchedUpdates, null, transaction);
16699
ReactUpdatesFlushTransaction.release(transaction);
16700
}
16701
16702
if (asapEnqueued) {
16703
asapEnqueued = false;
16704
var queue = asapCallbackQueue;
16705
asapCallbackQueue = CallbackQueue.getPooled();
16706
queue.notifyAll();
16707
CallbackQueue.release(queue);
16708
}
16709
}
16710
};
16711
flushBatchedUpdates = ReactPerf.measure(
16712
'ReactUpdates',
16713
'flushBatchedUpdates',
16714
flushBatchedUpdates
16715
);
16716
16717
/**
16718
* Mark a component as needing a rerender, adding an optional callback to a
16719
* list of functions which will be executed once the rerender occurs.
16720
*/
16721
function enqueueUpdate(component) {
16722
ensureInjected();
16723
16724
// Various parts of our code (such as ReactCompositeComponent's
16725
// _renderValidatedComponent) assume that calls to render aren't nested;
16726
// verify that that's the case. (This is called by each top-level update
16727
// function, like setProps, setState, forceUpdate, etc.; creation and
16728
// destruction of top-level components is guarded in ReactMount.)
16729
("production" !== "development" ? warning(
16730
ReactCurrentOwner.current == null,
16731
'enqueueUpdate(): Render methods should be a pure function of props ' +
16732
'and state; triggering nested component updates from render is not ' +
16733
'allowed. If necessary, trigger nested updates in ' +
16734
'componentDidUpdate.'
16735
) : null);
16736
16737
if (!batchingStrategy.isBatchingUpdates) {
16738
batchingStrategy.batchedUpdates(enqueueUpdate, component);
16739
return;
16740
}
16741
16742
dirtyComponents.push(component);
16743
}
16744
16745
/**
16746
* Enqueue a callback to be run at the end of the current batching cycle. Throws
16747
* if no updates are currently being performed.
16748
*/
16749
function asap(callback, context) {
16750
("production" !== "development" ? invariant(
16751
batchingStrategy.isBatchingUpdates,
16752
'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
16753
'updates are not being batched.'
16754
) : invariant(batchingStrategy.isBatchingUpdates));
16755
asapCallbackQueue.enqueue(callback, context);
16756
asapEnqueued = true;
16757
}
16758
16759
var ReactUpdatesInjection = {
16760
injectReconcileTransaction: function(ReconcileTransaction) {
16761
("production" !== "development" ? invariant(
16762
ReconcileTransaction,
16763
'ReactUpdates: must provide a reconcile transaction class'
16764
) : invariant(ReconcileTransaction));
16765
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
16766
},
16767
16768
injectBatchingStrategy: function(_batchingStrategy) {
16769
("production" !== "development" ? invariant(
16770
_batchingStrategy,
16771
'ReactUpdates: must provide a batching strategy'
16772
) : invariant(_batchingStrategy));
16773
("production" !== "development" ? invariant(
16774
typeof _batchingStrategy.batchedUpdates === 'function',
16775
'ReactUpdates: must provide a batchedUpdates() function'
16776
) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
16777
("production" !== "development" ? invariant(
16778
typeof _batchingStrategy.isBatchingUpdates === 'boolean',
16779
'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
16780
) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
16781
batchingStrategy = _batchingStrategy;
16782
}
16783
};
16784
16785
var ReactUpdates = {
16786
/**
16787
* React references `ReactReconcileTransaction` using this property in order
16788
* to allow dependency injection.
16789
*
16790
* @internal
16791
*/
16792
ReactReconcileTransaction: null,
16793
16794
batchedUpdates: batchedUpdates,
16795
enqueueUpdate: enqueueUpdate,
16796
flushBatchedUpdates: flushBatchedUpdates,
16797
injection: ReactUpdatesInjection,
16798
asap: asap
16799
};
16800
16801
module.exports = ReactUpdates;
16802
16803
},{"116":116,"150":150,"171":171,"29":29,"30":30,"45":45,"7":7,"82":82,"89":89}],101:[function(_dereq_,module,exports){
16804
/**
16805
* Copyright 2013-2015, Facebook, Inc.
16806
* All rights reserved.
16807
*
16808
* This source code is licensed under the BSD-style license found in the
16809
* LICENSE file in the root directory of this source tree. An additional grant
16810
* of patent rights can be found in the PATENTS file in the same directory.
16811
*
16812
* @providesModule SVGDOMPropertyConfig
16813
*/
16814
16815
/*jslint bitwise: true*/
16816
16817
'use strict';
16818
16819
var DOMProperty = _dereq_(11);
16820
16821
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
16822
16823
var SVGDOMPropertyConfig = {
16824
Properties: {
16825
clipPath: MUST_USE_ATTRIBUTE,
16826
cx: MUST_USE_ATTRIBUTE,
16827
cy: MUST_USE_ATTRIBUTE,
16828
d: MUST_USE_ATTRIBUTE,
16829
dx: MUST_USE_ATTRIBUTE,
16830
dy: MUST_USE_ATTRIBUTE,
16831
fill: MUST_USE_ATTRIBUTE,
16832
fillOpacity: MUST_USE_ATTRIBUTE,
16833
fontFamily: MUST_USE_ATTRIBUTE,
16834
fontSize: MUST_USE_ATTRIBUTE,
16835
fx: MUST_USE_ATTRIBUTE,
16836
fy: MUST_USE_ATTRIBUTE,
16837
gradientTransform: MUST_USE_ATTRIBUTE,
16838
gradientUnits: MUST_USE_ATTRIBUTE,
16839
markerEnd: MUST_USE_ATTRIBUTE,
16840
markerMid: MUST_USE_ATTRIBUTE,
16841
markerStart: MUST_USE_ATTRIBUTE,
16842
offset: MUST_USE_ATTRIBUTE,
16843
opacity: MUST_USE_ATTRIBUTE,
16844
patternContentUnits: MUST_USE_ATTRIBUTE,
16845
patternUnits: MUST_USE_ATTRIBUTE,
16846
points: MUST_USE_ATTRIBUTE,
16847
preserveAspectRatio: MUST_USE_ATTRIBUTE,
16848
r: MUST_USE_ATTRIBUTE,
16849
rx: MUST_USE_ATTRIBUTE,
16850
ry: MUST_USE_ATTRIBUTE,
16851
spreadMethod: MUST_USE_ATTRIBUTE,
16852
stopColor: MUST_USE_ATTRIBUTE,
16853
stopOpacity: MUST_USE_ATTRIBUTE,
16854
stroke: MUST_USE_ATTRIBUTE,
16855
strokeDasharray: MUST_USE_ATTRIBUTE,
16856
strokeLinecap: MUST_USE_ATTRIBUTE,
16857
strokeOpacity: MUST_USE_ATTRIBUTE,
16858
strokeWidth: MUST_USE_ATTRIBUTE,
16859
textAnchor: MUST_USE_ATTRIBUTE,
16860
transform: MUST_USE_ATTRIBUTE,
16861
version: MUST_USE_ATTRIBUTE,
16862
viewBox: MUST_USE_ATTRIBUTE,
16863
x1: MUST_USE_ATTRIBUTE,
16864
x2: MUST_USE_ATTRIBUTE,
16865
x: MUST_USE_ATTRIBUTE,
16866
y1: MUST_USE_ATTRIBUTE,
16867
y2: MUST_USE_ATTRIBUTE,
16868
y: MUST_USE_ATTRIBUTE
16869
},
16870
DOMAttributeNames: {
16871
clipPath: 'clip-path',
16872
fillOpacity: 'fill-opacity',
16873
fontFamily: 'font-family',
16874
fontSize: 'font-size',
16875
gradientTransform: 'gradientTransform',
16876
gradientUnits: 'gradientUnits',
16877
markerEnd: 'marker-end',
16878
markerMid: 'marker-mid',
16879
markerStart: 'marker-start',
16880
patternContentUnits: 'patternContentUnits',
16881
patternUnits: 'patternUnits',
16882
preserveAspectRatio: 'preserveAspectRatio',
16883
spreadMethod: 'spreadMethod',
16884
stopColor: 'stop-color',
16885
stopOpacity: 'stop-opacity',
16886
strokeDasharray: 'stroke-dasharray',
16887
strokeLinecap: 'stroke-linecap',
16888
strokeOpacity: 'stroke-opacity',
16889
strokeWidth: 'stroke-width',
16890
textAnchor: 'text-anchor',
16891
viewBox: 'viewBox'
16892
}
16893
};
16894
16895
module.exports = SVGDOMPropertyConfig;
16896
16897
},{"11":11}],102:[function(_dereq_,module,exports){
16898
/**
16899
* Copyright 2013-2015, Facebook, Inc.
16900
* All rights reserved.
16901
*
16902
* This source code is licensed under the BSD-style license found in the
16903
* LICENSE file in the root directory of this source tree. An additional grant
16904
* of patent rights can be found in the PATENTS file in the same directory.
16905
*
16906
* @providesModule SelectEventPlugin
16907
*/
16908
16909
'use strict';
16910
16911
var EventConstants = _dereq_(16);
16912
var EventPropagators = _dereq_(21);
16913
var ReactInputSelection = _dereq_(71);
16914
var SyntheticEvent = _dereq_(108);
16915
16916
var getActiveElement = _dereq_(136);
16917
var isTextInputElement = _dereq_(153);
16918
var keyOf = _dereq_(157);
16919
var shallowEqual = _dereq_(166);
16920
16921
var topLevelTypes = EventConstants.topLevelTypes;
16922
16923
var eventTypes = {
16924
select: {
16925
phasedRegistrationNames: {
16926
bubbled: keyOf({onSelect: null}),
16927
captured: keyOf({onSelectCapture: null})
16928
},
16929
dependencies: [
16930
topLevelTypes.topBlur,
16931
topLevelTypes.topContextMenu,
16932
topLevelTypes.topFocus,
16933
topLevelTypes.topKeyDown,
16934
topLevelTypes.topMouseDown,
16935
topLevelTypes.topMouseUp,
16936
topLevelTypes.topSelectionChange
16937
]
16938
}
16939
};
16940
16941
var activeElement = null;
16942
var activeElementID = null;
16943
var lastSelection = null;
16944
var mouseDown = false;
16945
16946
/**
16947
* Get an object which is a unique representation of the current selection.
16948
*
16949
* The return value will not be consistent across nodes or browsers, but
16950
* two identical selections on the same node will return identical objects.
16951
*
16952
* @param {DOMElement} node
16953
* @param {object}
16954
*/
16955
function getSelection(node) {
16956
if ('selectionStart' in node &&
16957
ReactInputSelection.hasSelectionCapabilities(node)) {
16958
return {
16959
start: node.selectionStart,
16960
end: node.selectionEnd
16961
};
16962
} else if (window.getSelection) {
16963
var selection = window.getSelection();
16964
return {
16965
anchorNode: selection.anchorNode,
16966
anchorOffset: selection.anchorOffset,
16967
focusNode: selection.focusNode,
16968
focusOffset: selection.focusOffset
16969
};
16970
} else if (document.selection) {
16971
var range = document.selection.createRange();
16972
return {
16973
parentElement: range.parentElement(),
16974
text: range.text,
16975
top: range.boundingTop,
16976
left: range.boundingLeft
16977
};
16978
}
16979
}
16980
16981
/**
16982
* Poll selection to see whether it's changed.
16983
*
16984
* @param {object} nativeEvent
16985
* @return {?SyntheticEvent}
16986
*/
16987
function constructSelectEvent(nativeEvent) {
16988
// Ensure we have the right element, and that the user is not dragging a
16989
// selection (this matches native `select` event behavior). In HTML5, select
16990
// fires only on input and textarea thus if there's no focused element we
16991
// won't dispatch.
16992
if (mouseDown ||
16993
activeElement == null ||
16994
activeElement !== getActiveElement()) {
16995
return null;
16996
}
16997
16998
// Only fire when selection has actually changed.
16999
var currentSelection = getSelection(activeElement);
17000
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
17001
lastSelection = currentSelection;
17002
17003
var syntheticEvent = SyntheticEvent.getPooled(
17004
eventTypes.select,
17005
activeElementID,
17006
nativeEvent
17007
);
17008
17009
syntheticEvent.type = 'select';
17010
syntheticEvent.target = activeElement;
17011
17012
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
17013
17014
return syntheticEvent;
17015
}
17016
}
17017
17018
/**
17019
* This plugin creates an `onSelect` event that normalizes select events
17020
* across form elements.
17021
*
17022
* Supported elements are:
17023
* - input (see `isTextInputElement`)
17024
* - textarea
17025
* - contentEditable
17026
*
17027
* This differs from native browser implementations in the following ways:
17028
* - Fires on contentEditable fields as well as inputs.
17029
* - Fires for collapsed selection.
17030
* - Fires after user input.
17031
*/
17032
var SelectEventPlugin = {
17033
17034
eventTypes: eventTypes,
17035
17036
/**
17037
* @param {string} topLevelType Record from `EventConstants`.
17038
* @param {DOMEventTarget} topLevelTarget The listening component root node.
17039
* @param {string} topLevelTargetID ID of `topLevelTarget`.
17040
* @param {object} nativeEvent Native browser event.
17041
* @return {*} An accumulation of synthetic events.
17042
* @see {EventPluginHub.extractEvents}
17043
*/
17044
extractEvents: function(
17045
topLevelType,
17046
topLevelTarget,
17047
topLevelTargetID,
17048
nativeEvent) {
17049
17050
switch (topLevelType) {
17051
// Track the input node that has focus.
17052
case topLevelTypes.topFocus:
17053
if (isTextInputElement(topLevelTarget) ||
17054
topLevelTarget.contentEditable === 'true') {
17055
activeElement = topLevelTarget;
17056
activeElementID = topLevelTargetID;
17057
lastSelection = null;
17058
}
17059
break;
17060
case topLevelTypes.topBlur:
17061
activeElement = null;
17062
activeElementID = null;
17063
lastSelection = null;
17064
break;
17065
17066
// Don't fire the event while the user is dragging. This matches the
17067
// semantics of the native select event.
17068
case topLevelTypes.topMouseDown:
17069
mouseDown = true;
17070
break;
17071
case topLevelTypes.topContextMenu:
17072
case topLevelTypes.topMouseUp:
17073
mouseDown = false;
17074
return constructSelectEvent(nativeEvent);
17075
17076
// Chrome and IE fire non-standard event when selection is changed (and
17077
// sometimes when it hasn't).
17078
// Firefox doesn't support selectionchange, so check selection status
17079
// after each key entry. The selection changes after keydown and before
17080
// keyup, but we check on keydown as well in the case of holding down a
17081
// key, when multiple keydown events are fired but only one keyup is.
17082
case topLevelTypes.topSelectionChange:
17083
case topLevelTypes.topKeyDown:
17084
case topLevelTypes.topKeyUp:
17085
return constructSelectEvent(nativeEvent);
17086
}
17087
}
17088
};
17089
17090
module.exports = SelectEventPlugin;
17091
17092
},{"108":108,"136":136,"153":153,"157":157,"16":16,"166":166,"21":21,"71":71}],103:[function(_dereq_,module,exports){
17093
/**
17094
* Copyright 2013-2015, Facebook, Inc.
17095
* All rights reserved.
17096
*
17097
* This source code is licensed under the BSD-style license found in the
17098
* LICENSE file in the root directory of this source tree. An additional grant
17099
* of patent rights can be found in the PATENTS file in the same directory.
17100
*
17101
* @providesModule ServerReactRootIndex
17102
* @typechecks
17103
*/
17104
17105
'use strict';
17106
17107
/**
17108
* Size of the reactRoot ID space. We generate random numbers for React root
17109
* IDs and if there's a collision the events and DOM update system will
17110
* get confused. In the future we need a way to generate GUIDs but for
17111
* now this will work on a smaller scale.
17112
*/
17113
var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
17114
17115
var ServerReactRootIndex = {
17116
createReactRootIndex: function() {
17117
return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
17118
}
17119
};
17120
17121
module.exports = ServerReactRootIndex;
17122
17123
},{}],104:[function(_dereq_,module,exports){
17124
/**
17125
* Copyright 2013-2015, Facebook, Inc.
17126
* All rights reserved.
17127
*
17128
* This source code is licensed under the BSD-style license found in the
17129
* LICENSE file in the root directory of this source tree. An additional grant
17130
* of patent rights can be found in the PATENTS file in the same directory.
17131
*
17132
* @providesModule SimpleEventPlugin
17133
*/
17134
17135
'use strict';
17136
17137
var EventConstants = _dereq_(16);
17138
var EventPluginUtils = _dereq_(20);
17139
var EventPropagators = _dereq_(21);
17140
var SyntheticClipboardEvent = _dereq_(105);
17141
var SyntheticEvent = _dereq_(108);
17142
var SyntheticFocusEvent = _dereq_(109);
17143
var SyntheticKeyboardEvent = _dereq_(111);
17144
var SyntheticMouseEvent = _dereq_(112);
17145
var SyntheticDragEvent = _dereq_(107);
17146
var SyntheticTouchEvent = _dereq_(113);
17147
var SyntheticUIEvent = _dereq_(114);
17148
var SyntheticWheelEvent = _dereq_(115);
17149
17150
var getEventCharCode = _dereq_(137);
17151
17152
var invariant = _dereq_(150);
17153
var keyOf = _dereq_(157);
17154
var warning = _dereq_(171);
17155
17156
var topLevelTypes = EventConstants.topLevelTypes;
17157
17158
var eventTypes = {
17159
blur: {
17160
phasedRegistrationNames: {
17161
bubbled: keyOf({onBlur: true}),
17162
captured: keyOf({onBlurCapture: true})
17163
}
17164
},
17165
click: {
17166
phasedRegistrationNames: {
17167
bubbled: keyOf({onClick: true}),
17168
captured: keyOf({onClickCapture: true})
17169
}
17170
},
17171
contextMenu: {
17172
phasedRegistrationNames: {
17173
bubbled: keyOf({onContextMenu: true}),
17174
captured: keyOf({onContextMenuCapture: true})
17175
}
17176
},
17177
copy: {
17178
phasedRegistrationNames: {
17179
bubbled: keyOf({onCopy: true}),
17180
captured: keyOf({onCopyCapture: true})
17181
}
17182
},
17183
cut: {
17184
phasedRegistrationNames: {
17185
bubbled: keyOf({onCut: true}),
17186
captured: keyOf({onCutCapture: true})
17187
}
17188
},
17189
doubleClick: {
17190
phasedRegistrationNames: {
17191
bubbled: keyOf({onDoubleClick: true}),
17192
captured: keyOf({onDoubleClickCapture: true})
17193
}
17194
},
17195
drag: {
17196
phasedRegistrationNames: {
17197
bubbled: keyOf({onDrag: true}),
17198
captured: keyOf({onDragCapture: true})
17199
}
17200
},
17201
dragEnd: {
17202
phasedRegistrationNames: {
17203
bubbled: keyOf({onDragEnd: true}),
17204
captured: keyOf({onDragEndCapture: true})
17205
}
17206
},
17207
dragEnter: {
17208
phasedRegistrationNames: {
17209
bubbled: keyOf({onDragEnter: true}),
17210
captured: keyOf({onDragEnterCapture: true})
17211
}
17212
},
17213
dragExit: {
17214
phasedRegistrationNames: {
17215
bubbled: keyOf({onDragExit: true}),
17216
captured: keyOf({onDragExitCapture: true})
17217
}
17218
},
17219
dragLeave: {
17220
phasedRegistrationNames: {
17221
bubbled: keyOf({onDragLeave: true}),
17222
captured: keyOf({onDragLeaveCapture: true})
17223
}
17224
},
17225
dragOver: {
17226
phasedRegistrationNames: {
17227
bubbled: keyOf({onDragOver: true}),
17228
captured: keyOf({onDragOverCapture: true})
17229
}
17230
},
17231
dragStart: {
17232
phasedRegistrationNames: {
17233
bubbled: keyOf({onDragStart: true}),
17234
captured: keyOf({onDragStartCapture: true})
17235
}
17236
},
17237
drop: {
17238
phasedRegistrationNames: {
17239
bubbled: keyOf({onDrop: true}),
17240
captured: keyOf({onDropCapture: true})
17241
}
17242
},
17243
focus: {
17244
phasedRegistrationNames: {
17245
bubbled: keyOf({onFocus: true}),
17246
captured: keyOf({onFocusCapture: true})
17247
}
17248
},
17249
input: {
17250
phasedRegistrationNames: {
17251
bubbled: keyOf({onInput: true}),
17252
captured: keyOf({onInputCapture: true})
17253
}
17254
},
17255
keyDown: {
17256
phasedRegistrationNames: {
17257
bubbled: keyOf({onKeyDown: true}),
17258
captured: keyOf({onKeyDownCapture: true})
17259
}
17260
},
17261
keyPress: {
17262
phasedRegistrationNames: {
17263
bubbled: keyOf({onKeyPress: true}),
17264
captured: keyOf({onKeyPressCapture: true})
17265
}
17266
},
17267
keyUp: {
17268
phasedRegistrationNames: {
17269
bubbled: keyOf({onKeyUp: true}),
17270
captured: keyOf({onKeyUpCapture: true})
17271
}
17272
},
17273
load: {
17274
phasedRegistrationNames: {
17275
bubbled: keyOf({onLoad: true}),
17276
captured: keyOf({onLoadCapture: true})
17277
}
17278
},
17279
error: {
17280
phasedRegistrationNames: {
17281
bubbled: keyOf({onError: true}),
17282
captured: keyOf({onErrorCapture: true})
17283
}
17284
},
17285
// Note: We do not allow listening to mouseOver events. Instead, use the
17286
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
17287
mouseDown: {
17288
phasedRegistrationNames: {
17289
bubbled: keyOf({onMouseDown: true}),
17290
captured: keyOf({onMouseDownCapture: true})
17291
}
17292
},
17293
mouseMove: {
17294
phasedRegistrationNames: {
17295
bubbled: keyOf({onMouseMove: true}),
17296
captured: keyOf({onMouseMoveCapture: true})
17297
}
17298
},
17299
mouseOut: {
17300
phasedRegistrationNames: {
17301
bubbled: keyOf({onMouseOut: true}),
17302
captured: keyOf({onMouseOutCapture: true})
17303
}
17304
},
17305
mouseOver: {
17306
phasedRegistrationNames: {
17307
bubbled: keyOf({onMouseOver: true}),
17308
captured: keyOf({onMouseOverCapture: true})
17309
}
17310
},
17311
mouseUp: {
17312
phasedRegistrationNames: {
17313
bubbled: keyOf({onMouseUp: true}),
17314
captured: keyOf({onMouseUpCapture: true})
17315
}
17316
},
17317
paste: {
17318
phasedRegistrationNames: {
17319
bubbled: keyOf({onPaste: true}),
17320
captured: keyOf({onPasteCapture: true})
17321
}
17322
},
17323
reset: {
17324
phasedRegistrationNames: {
17325
bubbled: keyOf({onReset: true}),
17326
captured: keyOf({onResetCapture: true})
17327
}
17328
},
17329
scroll: {
17330
phasedRegistrationNames: {
17331
bubbled: keyOf({onScroll: true}),
17332
captured: keyOf({onScrollCapture: true})
17333
}
17334
},
17335
submit: {
17336
phasedRegistrationNames: {
17337
bubbled: keyOf({onSubmit: true}),
17338
captured: keyOf({onSubmitCapture: true})
17339
}
17340
},
17341
touchCancel: {
17342
phasedRegistrationNames: {
17343
bubbled: keyOf({onTouchCancel: true}),
17344
captured: keyOf({onTouchCancelCapture: true})
17345
}
17346
},
17347
touchEnd: {
17348
phasedRegistrationNames: {
17349
bubbled: keyOf({onTouchEnd: true}),
17350
captured: keyOf({onTouchEndCapture: true})
17351
}
17352
},
17353
touchMove: {
17354
phasedRegistrationNames: {
17355
bubbled: keyOf({onTouchMove: true}),
17356
captured: keyOf({onTouchMoveCapture: true})
17357
}
17358
},
17359
touchStart: {
17360
phasedRegistrationNames: {
17361
bubbled: keyOf({onTouchStart: true}),
17362
captured: keyOf({onTouchStartCapture: true})
17363
}
17364
},
17365
wheel: {
17366
phasedRegistrationNames: {
17367
bubbled: keyOf({onWheel: true}),
17368
captured: keyOf({onWheelCapture: true})
17369
}
17370
}
17371
};
17372
17373
var topLevelEventsToDispatchConfig = {
17374
topBlur: eventTypes.blur,
17375
topClick: eventTypes.click,
17376
topContextMenu: eventTypes.contextMenu,
17377
topCopy: eventTypes.copy,
17378
topCut: eventTypes.cut,
17379
topDoubleClick: eventTypes.doubleClick,
17380
topDrag: eventTypes.drag,
17381
topDragEnd: eventTypes.dragEnd,
17382
topDragEnter: eventTypes.dragEnter,
17383
topDragExit: eventTypes.dragExit,
17384
topDragLeave: eventTypes.dragLeave,
17385
topDragOver: eventTypes.dragOver,
17386
topDragStart: eventTypes.dragStart,
17387
topDrop: eventTypes.drop,
17388
topError: eventTypes.error,
17389
topFocus: eventTypes.focus,
17390
topInput: eventTypes.input,
17391
topKeyDown: eventTypes.keyDown,
17392
topKeyPress: eventTypes.keyPress,
17393
topKeyUp: eventTypes.keyUp,
17394
topLoad: eventTypes.load,
17395
topMouseDown: eventTypes.mouseDown,
17396
topMouseMove: eventTypes.mouseMove,
17397
topMouseOut: eventTypes.mouseOut,
17398
topMouseOver: eventTypes.mouseOver,
17399
topMouseUp: eventTypes.mouseUp,
17400
topPaste: eventTypes.paste,
17401
topReset: eventTypes.reset,
17402
topScroll: eventTypes.scroll,
17403
topSubmit: eventTypes.submit,
17404
topTouchCancel: eventTypes.touchCancel,
17405
topTouchEnd: eventTypes.touchEnd,
17406
topTouchMove: eventTypes.touchMove,
17407
topTouchStart: eventTypes.touchStart,
17408
topWheel: eventTypes.wheel
17409
};
17410
17411
for (var type in topLevelEventsToDispatchConfig) {
17412
topLevelEventsToDispatchConfig[type].dependencies = [type];
17413
}
17414
17415
var SimpleEventPlugin = {
17416
17417
eventTypes: eventTypes,
17418
17419
/**
17420
* Same as the default implementation, except cancels the event when return
17421
* value is false. This behavior will be disabled in a future release.
17422
*
17423
* @param {object} Event to be dispatched.
17424
* @param {function} Application-level callback.
17425
* @param {string} domID DOM ID to pass to the callback.
17426
*/
17427
executeDispatch: function(event, listener, domID) {
17428
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
17429
17430
("production" !== "development" ? warning(
17431
typeof returnValue !== 'boolean',
17432
'Returning `false` from an event handler is deprecated and will be ' +
17433
'ignored in a future release. Instead, manually call ' +
17434
'e.stopPropagation() or e.preventDefault(), as appropriate.'
17435
) : null);
17436
17437
if (returnValue === false) {
17438
event.stopPropagation();
17439
event.preventDefault();
17440
}
17441
},
17442
17443
/**
17444
* @param {string} topLevelType Record from `EventConstants`.
17445
* @param {DOMEventTarget} topLevelTarget The listening component root node.
17446
* @param {string} topLevelTargetID ID of `topLevelTarget`.
17447
* @param {object} nativeEvent Native browser event.
17448
* @return {*} An accumulation of synthetic events.
17449
* @see {EventPluginHub.extractEvents}
17450
*/
17451
extractEvents: function(
17452
topLevelType,
17453
topLevelTarget,
17454
topLevelTargetID,
17455
nativeEvent) {
17456
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
17457
if (!dispatchConfig) {
17458
return null;
17459
}
17460
var EventConstructor;
17461
switch (topLevelType) {
17462
case topLevelTypes.topInput:
17463
case topLevelTypes.topLoad:
17464
case topLevelTypes.topError:
17465
case topLevelTypes.topReset:
17466
case topLevelTypes.topSubmit:
17467
// HTML Events
17468
// @see http://www.w3.org/TR/html5/index.html#events-0
17469
EventConstructor = SyntheticEvent;
17470
break;
17471
case topLevelTypes.topKeyPress:
17472
// FireFox creates a keypress event for function keys too. This removes
17473
// the unwanted keypress events. Enter is however both printable and
17474
// non-printable. One would expect Tab to be as well (but it isn't).
17475
if (getEventCharCode(nativeEvent) === 0) {
17476
return null;
17477
}
17478
/* falls through */
17479
case topLevelTypes.topKeyDown:
17480
case topLevelTypes.topKeyUp:
17481
EventConstructor = SyntheticKeyboardEvent;
17482
break;
17483
case topLevelTypes.topBlur:
17484
case topLevelTypes.topFocus:
17485
EventConstructor = SyntheticFocusEvent;
17486
break;
17487
case topLevelTypes.topClick:
17488
// Firefox creates a click event on right mouse clicks. This removes the
17489
// unwanted click events.
17490
if (nativeEvent.button === 2) {
17491
return null;
17492
}
17493
/* falls through */
17494
case topLevelTypes.topContextMenu:
17495
case topLevelTypes.topDoubleClick:
17496
case topLevelTypes.topMouseDown:
17497
case topLevelTypes.topMouseMove:
17498
case topLevelTypes.topMouseOut:
17499
case topLevelTypes.topMouseOver:
17500
case topLevelTypes.topMouseUp:
17501
EventConstructor = SyntheticMouseEvent;
17502
break;
17503
case topLevelTypes.topDrag:
17504
case topLevelTypes.topDragEnd:
17505
case topLevelTypes.topDragEnter:
17506
case topLevelTypes.topDragExit:
17507
case topLevelTypes.topDragLeave:
17508
case topLevelTypes.topDragOver:
17509
case topLevelTypes.topDragStart:
17510
case topLevelTypes.topDrop:
17511
EventConstructor = SyntheticDragEvent;
17512
break;
17513
case topLevelTypes.topTouchCancel:
17514
case topLevelTypes.topTouchEnd:
17515
case topLevelTypes.topTouchMove:
17516
case topLevelTypes.topTouchStart:
17517
EventConstructor = SyntheticTouchEvent;
17518
break;
17519
case topLevelTypes.topScroll:
17520
EventConstructor = SyntheticUIEvent;
17521
break;
17522
case topLevelTypes.topWheel:
17523
EventConstructor = SyntheticWheelEvent;
17524
break;
17525
case topLevelTypes.topCopy:
17526
case topLevelTypes.topCut:
17527
case topLevelTypes.topPaste:
17528
EventConstructor = SyntheticClipboardEvent;
17529
break;
17530
}
17531
("production" !== "development" ? invariant(
17532
EventConstructor,
17533
'SimpleEventPlugin: Unhandled event type, `%s`.',
17534
topLevelType
17535
) : invariant(EventConstructor));
17536
var event = EventConstructor.getPooled(
17537
dispatchConfig,
17538
topLevelTargetID,
17539
nativeEvent
17540
);
17541
EventPropagators.accumulateTwoPhaseDispatches(event);
17542
return event;
17543
}
17544
17545
};
17546
17547
module.exports = SimpleEventPlugin;
17548
17549
},{"105":105,"107":107,"108":108,"109":109,"111":111,"112":112,"113":113,"114":114,"115":115,"137":137,"150":150,"157":157,"16":16,"171":171,"20":20,"21":21}],105:[function(_dereq_,module,exports){
17550
/**
17551
* Copyright 2013-2015, Facebook, Inc.
17552
* All rights reserved.
17553
*
17554
* This source code is licensed under the BSD-style license found in the
17555
* LICENSE file in the root directory of this source tree. An additional grant
17556
* of patent rights can be found in the PATENTS file in the same directory.
17557
*
17558
* @providesModule SyntheticClipboardEvent
17559
* @typechecks static-only
17560
*/
17561
17562
'use strict';
17563
17564
var SyntheticEvent = _dereq_(108);
17565
17566
/**
17567
* @interface Event
17568
* @see http://www.w3.org/TR/clipboard-apis/
17569
*/
17570
var ClipboardEventInterface = {
17571
clipboardData: function(event) {
17572
return (
17573
'clipboardData' in event ?
17574
event.clipboardData :
17575
window.clipboardData
17576
);
17577
}
17578
};
17579
17580
/**
17581
* @param {object} dispatchConfig Configuration used to dispatch this event.
17582
* @param {string} dispatchMarker Marker identifying the event target.
17583
* @param {object} nativeEvent Native browser event.
17584
* @extends {SyntheticUIEvent}
17585
*/
17586
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
17587
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
17588
}
17589
17590
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
17591
17592
module.exports = SyntheticClipboardEvent;
17593
17594
},{"108":108}],106:[function(_dereq_,module,exports){
17595
/**
17596
* Copyright 2013-2015, Facebook, Inc.
17597
* All rights reserved.
17598
*
17599
* This source code is licensed under the BSD-style license found in the
17600
* LICENSE file in the root directory of this source tree. An additional grant
17601
* of patent rights can be found in the PATENTS file in the same directory.
17602
*
17603
* @providesModule SyntheticCompositionEvent
17604
* @typechecks static-only
17605
*/
17606
17607
'use strict';
17608
17609
var SyntheticEvent = _dereq_(108);
17610
17611
/**
17612
* @interface Event
17613
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
17614
*/
17615
var CompositionEventInterface = {
17616
data: null
17617
};
17618
17619
/**
17620
* @param {object} dispatchConfig Configuration used to dispatch this event.
17621
* @param {string} dispatchMarker Marker identifying the event target.
17622
* @param {object} nativeEvent Native browser event.
17623
* @extends {SyntheticUIEvent}
17624
*/
17625
function SyntheticCompositionEvent(
17626
dispatchConfig,
17627
dispatchMarker,
17628
nativeEvent) {
17629
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
17630
}
17631
17632
SyntheticEvent.augmentClass(
17633
SyntheticCompositionEvent,
17634
CompositionEventInterface
17635
);
17636
17637
module.exports = SyntheticCompositionEvent;
17638
17639
},{"108":108}],107:[function(_dereq_,module,exports){
17640
/**
17641
* Copyright 2013-2015, Facebook, Inc.
17642
* All rights reserved.
17643
*
17644
* This source code is licensed under the BSD-style license found in the
17645
* LICENSE file in the root directory of this source tree. An additional grant
17646
* of patent rights can be found in the PATENTS file in the same directory.
17647
*
17648
* @providesModule SyntheticDragEvent
17649
* @typechecks static-only
17650
*/
17651
17652
'use strict';
17653
17654
var SyntheticMouseEvent = _dereq_(112);
17655
17656
/**
17657
* @interface DragEvent
17658
* @see http://www.w3.org/TR/DOM-Level-3-Events/
17659
*/
17660
var DragEventInterface = {
17661
dataTransfer: null
17662
};
17663
17664
/**
17665
* @param {object} dispatchConfig Configuration used to dispatch this event.
17666
* @param {string} dispatchMarker Marker identifying the event target.
17667
* @param {object} nativeEvent Native browser event.
17668
* @extends {SyntheticUIEvent}
17669
*/
17670
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
17671
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
17672
}
17673
17674
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
17675
17676
module.exports = SyntheticDragEvent;
17677
17678
},{"112":112}],108:[function(_dereq_,module,exports){
17679
/**
17680
* Copyright 2013-2015, Facebook, Inc.
17681
* All rights reserved.
17682
*
17683
* This source code is licensed under the BSD-style license found in the
17684
* LICENSE file in the root directory of this source tree. An additional grant
17685
* of patent rights can be found in the PATENTS file in the same directory.
17686
*
17687
* @providesModule SyntheticEvent
17688
* @typechecks static-only
17689
*/
17690
17691
'use strict';
17692
17693
var PooledClass = _dereq_(30);
17694
17695
var assign = _dereq_(29);
17696
var emptyFunction = _dereq_(129);
17697
var getEventTarget = _dereq_(140);
17698
17699
/**
17700
* @interface Event
17701
* @see http://www.w3.org/TR/DOM-Level-3-Events/
17702
*/
17703
var EventInterface = {
17704
type: null,
17705
target: getEventTarget,
17706
// currentTarget is set when dispatching; no use in copying it here
17707
currentTarget: emptyFunction.thatReturnsNull,
17708
eventPhase: null,
17709
bubbles: null,
17710
cancelable: null,
17711
timeStamp: function(event) {
17712
return event.timeStamp || Date.now();
17713
},
17714
defaultPrevented: null,
17715
isTrusted: null
17716
};
17717
17718
/**
17719
* Synthetic events are dispatched by event plugins, typically in response to a
17720
* top-level event delegation handler.
17721
*
17722
* These systems should generally use pooling to reduce the frequency of garbage
17723
* collection. The system should check `isPersistent` to determine whether the
17724
* event should be released into the pool after being dispatched. Users that
17725
* need a persisted event should invoke `persist`.
17726
*
17727
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
17728
* normalizing browser quirks. Subclasses do not necessarily have to implement a
17729
* DOM interface; custom application-specific events can also subclass this.
17730
*
17731
* @param {object} dispatchConfig Configuration used to dispatch this event.
17732
* @param {string} dispatchMarker Marker identifying the event target.
17733
* @param {object} nativeEvent Native browser event.
17734
*/
17735
function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
17736
this.dispatchConfig = dispatchConfig;
17737
this.dispatchMarker = dispatchMarker;
17738
this.nativeEvent = nativeEvent;
17739
17740
var Interface = this.constructor.Interface;
17741
for (var propName in Interface) {
17742
if (!Interface.hasOwnProperty(propName)) {
17743
continue;
17744
}
17745
var normalize = Interface[propName];
17746
if (normalize) {
17747
this[propName] = normalize(nativeEvent);
17748
} else {
17749
this[propName] = nativeEvent[propName];
17750
}
17751
}
17752
17753
var defaultPrevented = nativeEvent.defaultPrevented != null ?
17754
nativeEvent.defaultPrevented :
17755
nativeEvent.returnValue === false;
17756
if (defaultPrevented) {
17757
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
17758
} else {
17759
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
17760
}
17761
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
17762
}
17763
17764
assign(SyntheticEvent.prototype, {
17765
17766
preventDefault: function() {
17767
this.defaultPrevented = true;
17768
var event = this.nativeEvent;
17769
if (event.preventDefault) {
17770
event.preventDefault();
17771
} else {
17772
event.returnValue = false;
17773
}
17774
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
17775
},
17776
17777
stopPropagation: function() {
17778
var event = this.nativeEvent;
17779
if (event.stopPropagation) {
17780
event.stopPropagation();
17781
} else {
17782
event.cancelBubble = true;
17783
}
17784
this.isPropagationStopped = emptyFunction.thatReturnsTrue;
17785
},
17786
17787
/**
17788
* We release all dispatched `SyntheticEvent`s after each event loop, adding
17789
* them back into the pool. This allows a way to hold onto a reference that
17790
* won't be added back into the pool.
17791
*/
17792
persist: function() {
17793
this.isPersistent = emptyFunction.thatReturnsTrue;
17794
},
17795
17796
/**
17797
* Checks if this event should be released back into the pool.
17798
*
17799
* @return {boolean} True if this should not be released, false otherwise.
17800
*/
17801
isPersistent: emptyFunction.thatReturnsFalse,
17802
17803
/**
17804
* `PooledClass` looks for `destructor` on each instance it releases.
17805
*/
17806
destructor: function() {
17807
var Interface = this.constructor.Interface;
17808
for (var propName in Interface) {
17809
this[propName] = null;
17810
}
17811
this.dispatchConfig = null;
17812
this.dispatchMarker = null;
17813
this.nativeEvent = null;
17814
}
17815
17816
});
17817
17818
SyntheticEvent.Interface = EventInterface;
17819
17820
/**
17821
* Helper to reduce boilerplate when creating subclasses.
17822
*
17823
* @param {function} Class
17824
* @param {?object} Interface
17825
*/
17826
SyntheticEvent.augmentClass = function(Class, Interface) {
17827
var Super = this;
17828
17829
var prototype = Object.create(Super.prototype);
17830
assign(prototype, Class.prototype);
17831
Class.prototype = prototype;
17832
Class.prototype.constructor = Class;
17833
17834
Class.Interface = assign({}, Super.Interface, Interface);
17835
Class.augmentClass = Super.augmentClass;
17836
17837
PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
17838
};
17839
17840
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
17841
17842
module.exports = SyntheticEvent;
17843
17844
},{"129":129,"140":140,"29":29,"30":30}],109:[function(_dereq_,module,exports){
17845
/**
17846
* Copyright 2013-2015, Facebook, Inc.
17847
* All rights reserved.
17848
*
17849
* This source code is licensed under the BSD-style license found in the
17850
* LICENSE file in the root directory of this source tree. An additional grant
17851
* of patent rights can be found in the PATENTS file in the same directory.
17852
*
17853
* @providesModule SyntheticFocusEvent
17854
* @typechecks static-only
17855
*/
17856
17857
'use strict';
17858
17859
var SyntheticUIEvent = _dereq_(114);
17860
17861
/**
17862
* @interface FocusEvent
17863
* @see http://www.w3.org/TR/DOM-Level-3-Events/
17864
*/
17865
var FocusEventInterface = {
17866
relatedTarget: null
17867
};
17868
17869
/**
17870
* @param {object} dispatchConfig Configuration used to dispatch this event.
17871
* @param {string} dispatchMarker Marker identifying the event target.
17872
* @param {object} nativeEvent Native browser event.
17873
* @extends {SyntheticUIEvent}
17874
*/
17875
function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
17876
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
17877
}
17878
17879
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
17880
17881
module.exports = SyntheticFocusEvent;
17882
17883
},{"114":114}],110:[function(_dereq_,module,exports){
17884
/**
17885
* Copyright 2013-2015, Facebook, Inc.
17886
* All rights reserved.
17887
*
17888
* This source code is licensed under the BSD-style license found in the
17889
* LICENSE file in the root directory of this source tree. An additional grant
17890
* of patent rights can be found in the PATENTS file in the same directory.
17891
*
17892
* @providesModule SyntheticInputEvent
17893
* @typechecks static-only
17894
*/
17895
17896
'use strict';
17897
17898
var SyntheticEvent = _dereq_(108);
17899
17900
/**
17901
* @interface Event
17902
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
17903
* /#events-inputevents
17904
*/
17905
var InputEventInterface = {
17906
data: null
17907
};
17908
17909
/**
17910
* @param {object} dispatchConfig Configuration used to dispatch this event.
17911
* @param {string} dispatchMarker Marker identifying the event target.
17912
* @param {object} nativeEvent Native browser event.
17913
* @extends {SyntheticUIEvent}
17914
*/
17915
function SyntheticInputEvent(
17916
dispatchConfig,
17917
dispatchMarker,
17918
nativeEvent) {
17919
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
17920
}
17921
17922
SyntheticEvent.augmentClass(
17923
SyntheticInputEvent,
17924
InputEventInterface
17925
);
17926
17927
module.exports = SyntheticInputEvent;
17928
17929
},{"108":108}],111:[function(_dereq_,module,exports){
17930
/**
17931
* Copyright 2013-2015, Facebook, Inc.
17932
* All rights reserved.
17933
*
17934
* This source code is licensed under the BSD-style license found in the
17935
* LICENSE file in the root directory of this source tree. An additional grant
17936
* of patent rights can be found in the PATENTS file in the same directory.
17937
*
17938
* @providesModule SyntheticKeyboardEvent
17939
* @typechecks static-only
17940
*/
17941
17942
'use strict';
17943
17944
var SyntheticUIEvent = _dereq_(114);
17945
17946
var getEventCharCode = _dereq_(137);
17947
var getEventKey = _dereq_(138);
17948
var getEventModifierState = _dereq_(139);
17949
17950
/**
17951
* @interface KeyboardEvent
17952
* @see http://www.w3.org/TR/DOM-Level-3-Events/
17953
*/
17954
var KeyboardEventInterface = {
17955
key: getEventKey,
17956
location: null,
17957
ctrlKey: null,
17958
shiftKey: null,
17959
altKey: null,
17960
metaKey: null,
17961
repeat: null,
17962
locale: null,
17963
getModifierState: getEventModifierState,
17964
// Legacy Interface
17965
charCode: function(event) {
17966
// `charCode` is the result of a KeyPress event and represents the value of
17967
// the actual printable character.
17968
17969
// KeyPress is deprecated, but its replacement is not yet final and not
17970
// implemented in any major browser. Only KeyPress has charCode.
17971
if (event.type === 'keypress') {
17972
return getEventCharCode(event);
17973
}
17974
return 0;
17975
},
17976
keyCode: function(event) {
17977
// `keyCode` is the result of a KeyDown/Up event and represents the value of
17978
// physical keyboard key.
17979
17980
// The actual meaning of the value depends on the users' keyboard layout
17981
// which cannot be detected. Assuming that it is a US keyboard layout
17982
// provides a surprisingly accurate mapping for US and European users.
17983
// Due to this, it is left to the user to implement at this time.
17984
if (event.type === 'keydown' || event.type === 'keyup') {
17985
return event.keyCode;
17986
}
17987
return 0;
17988
},
17989
which: function(event) {
17990
// `which` is an alias for either `keyCode` or `charCode` depending on the
17991
// type of the event.
17992
if (event.type === 'keypress') {
17993
return getEventCharCode(event);
17994
}
17995
if (event.type === 'keydown' || event.type === 'keyup') {
17996
return event.keyCode;
17997
}
17998
return 0;
17999
}
18000
};
18001
18002
/**
18003
* @param {object} dispatchConfig Configuration used to dispatch this event.
18004
* @param {string} dispatchMarker Marker identifying the event target.
18005
* @param {object} nativeEvent Native browser event.
18006
* @extends {SyntheticUIEvent}
18007
*/
18008
function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
18009
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
18010
}
18011
18012
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
18013
18014
module.exports = SyntheticKeyboardEvent;
18015
18016
},{"114":114,"137":137,"138":138,"139":139}],112:[function(_dereq_,module,exports){
18017
/**
18018
* Copyright 2013-2015, Facebook, Inc.
18019
* All rights reserved.
18020
*
18021
* This source code is licensed under the BSD-style license found in the
18022
* LICENSE file in the root directory of this source tree. An additional grant
18023
* of patent rights can be found in the PATENTS file in the same directory.
18024
*
18025
* @providesModule SyntheticMouseEvent
18026
* @typechecks static-only
18027
*/
18028
18029
'use strict';
18030
18031
var SyntheticUIEvent = _dereq_(114);
18032
var ViewportMetrics = _dereq_(117);
18033
18034
var getEventModifierState = _dereq_(139);
18035
18036
/**
18037
* @interface MouseEvent
18038
* @see http://www.w3.org/TR/DOM-Level-3-Events/
18039
*/
18040
var MouseEventInterface = {
18041
screenX: null,
18042
screenY: null,
18043
clientX: null,
18044
clientY: null,
18045
ctrlKey: null,
18046
shiftKey: null,
18047
altKey: null,
18048
metaKey: null,
18049
getModifierState: getEventModifierState,
18050
button: function(event) {
18051
// Webkit, Firefox, IE9+
18052
// which: 1 2 3
18053
// button: 0 1 2 (standard)
18054
var button = event.button;
18055
if ('which' in event) {
18056
return button;
18057
}
18058
// IE<9
18059
// which: undefined
18060
// button: 0 0 0
18061
// button: 1 4 2 (onmouseup)
18062
return button === 2 ? 2 : button === 4 ? 1 : 0;
18063
},
18064
buttons: null,
18065
relatedTarget: function(event) {
18066
return event.relatedTarget || (
18067
((event.fromElement === event.srcElement ? event.toElement : event.fromElement))
18068
);
18069
},
18070
// "Proprietary" Interface.
18071
pageX: function(event) {
18072
return 'pageX' in event ?
18073
event.pageX :
18074
event.clientX + ViewportMetrics.currentScrollLeft;
18075
},
18076
pageY: function(event) {
18077
return 'pageY' in event ?
18078
event.pageY :
18079
event.clientY + ViewportMetrics.currentScrollTop;
18080
}
18081
};
18082
18083
/**
18084
* @param {object} dispatchConfig Configuration used to dispatch this event.
18085
* @param {string} dispatchMarker Marker identifying the event target.
18086
* @param {object} nativeEvent Native browser event.
18087
* @extends {SyntheticUIEvent}
18088
*/
18089
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
18090
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
18091
}
18092
18093
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
18094
18095
module.exports = SyntheticMouseEvent;
18096
18097
},{"114":114,"117":117,"139":139}],113:[function(_dereq_,module,exports){
18098
/**
18099
* Copyright 2013-2015, Facebook, Inc.
18100
* All rights reserved.
18101
*
18102
* This source code is licensed under the BSD-style license found in the
18103
* LICENSE file in the root directory of this source tree. An additional grant
18104
* of patent rights can be found in the PATENTS file in the same directory.
18105
*
18106
* @providesModule SyntheticTouchEvent
18107
* @typechecks static-only
18108
*/
18109
18110
'use strict';
18111
18112
var SyntheticUIEvent = _dereq_(114);
18113
18114
var getEventModifierState = _dereq_(139);
18115
18116
/**
18117
* @interface TouchEvent
18118
* @see http://www.w3.org/TR/touch-events/
18119
*/
18120
var TouchEventInterface = {
18121
touches: null,
18122
targetTouches: null,
18123
changedTouches: null,
18124
altKey: null,
18125
metaKey: null,
18126
ctrlKey: null,
18127
shiftKey: null,
18128
getModifierState: getEventModifierState
18129
};
18130
18131
/**
18132
* @param {object} dispatchConfig Configuration used to dispatch this event.
18133
* @param {string} dispatchMarker Marker identifying the event target.
18134
* @param {object} nativeEvent Native browser event.
18135
* @extends {SyntheticUIEvent}
18136
*/
18137
function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
18138
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
18139
}
18140
18141
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
18142
18143
module.exports = SyntheticTouchEvent;
18144
18145
},{"114":114,"139":139}],114:[function(_dereq_,module,exports){
18146
/**
18147
* Copyright 2013-2015, Facebook, Inc.
18148
* All rights reserved.
18149
*
18150
* This source code is licensed under the BSD-style license found in the
18151
* LICENSE file in the root directory of this source tree. An additional grant
18152
* of patent rights can be found in the PATENTS file in the same directory.
18153
*
18154
* @providesModule SyntheticUIEvent
18155
* @typechecks static-only
18156
*/
18157
18158
'use strict';
18159
18160
var SyntheticEvent = _dereq_(108);
18161
18162
var getEventTarget = _dereq_(140);
18163
18164
/**
18165
* @interface UIEvent
18166
* @see http://www.w3.org/TR/DOM-Level-3-Events/
18167
*/
18168
var UIEventInterface = {
18169
view: function(event) {
18170
if (event.view) {
18171
return event.view;
18172
}
18173
18174
var target = getEventTarget(event);
18175
if (target != null && target.window === target) {
18176
// target is a window object
18177
return target;
18178
}
18179
18180
var doc = target.ownerDocument;
18181
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
18182
if (doc) {
18183
return doc.defaultView || doc.parentWindow;
18184
} else {
18185
return window;
18186
}
18187
},
18188
detail: function(event) {
18189
return event.detail || 0;
18190
}
18191
};
18192
18193
/**
18194
* @param {object} dispatchConfig Configuration used to dispatch this event.
18195
* @param {string} dispatchMarker Marker identifying the event target.
18196
* @param {object} nativeEvent Native browser event.
18197
* @extends {SyntheticEvent}
18198
*/
18199
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
18200
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
18201
}
18202
18203
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
18204
18205
module.exports = SyntheticUIEvent;
18206
18207
},{"108":108,"140":140}],115:[function(_dereq_,module,exports){
18208
/**
18209
* Copyright 2013-2015, Facebook, Inc.
18210
* All rights reserved.
18211
*
18212
* This source code is licensed under the BSD-style license found in the
18213
* LICENSE file in the root directory of this source tree. An additional grant
18214
* of patent rights can be found in the PATENTS file in the same directory.
18215
*
18216
* @providesModule SyntheticWheelEvent
18217
* @typechecks static-only
18218
*/
18219
18220
'use strict';
18221
18222
var SyntheticMouseEvent = _dereq_(112);
18223
18224
/**
18225
* @interface WheelEvent
18226
* @see http://www.w3.org/TR/DOM-Level-3-Events/
18227
*/
18228
var WheelEventInterface = {
18229
deltaX: function(event) {
18230
return (
18231
'deltaX' in event ? event.deltaX :
18232
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
18233
'wheelDeltaX' in event ? -event.wheelDeltaX : 0
18234
);
18235
},
18236
deltaY: function(event) {
18237
return (
18238
'deltaY' in event ? event.deltaY :
18239
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
18240
'wheelDeltaY' in event ? -event.wheelDeltaY :
18241
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
18242
'wheelDelta' in event ? -event.wheelDelta : 0
18243
);
18244
},
18245
deltaZ: null,
18246
18247
// Browsers without "deltaMode" is reporting in raw wheel delta where one
18248
// notch on the scroll is always +/- 120, roughly equivalent to pixels.
18249
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
18250
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
18251
deltaMode: null
18252
};
18253
18254
/**
18255
* @param {object} dispatchConfig Configuration used to dispatch this event.
18256
* @param {string} dispatchMarker Marker identifying the event target.
18257
* @param {object} nativeEvent Native browser event.
18258
* @extends {SyntheticMouseEvent}
18259
*/
18260
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
18261
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
18262
}
18263
18264
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
18265
18266
module.exports = SyntheticWheelEvent;
18267
18268
},{"112":112}],116:[function(_dereq_,module,exports){
18269
/**
18270
* Copyright 2013-2015, Facebook, Inc.
18271
* All rights reserved.
18272
*
18273
* This source code is licensed under the BSD-style license found in the
18274
* LICENSE file in the root directory of this source tree. An additional grant
18275
* of patent rights can be found in the PATENTS file in the same directory.
18276
*
18277
* @providesModule Transaction
18278
*/
18279
18280
'use strict';
18281
18282
var invariant = _dereq_(150);
18283
18284
/**
18285
* `Transaction` creates a black box that is able to wrap any method such that
18286
* certain invariants are maintained before and after the method is invoked
18287
* (Even if an exception is thrown while invoking the wrapped method). Whoever
18288
* instantiates a transaction can provide enforcers of the invariants at
18289
* creation time. The `Transaction` class itself will supply one additional
18290
* automatic invariant for you - the invariant that any transaction instance
18291
* should not be run while it is already being run. You would typically create a
18292
* single instance of a `Transaction` for reuse multiple times, that potentially
18293
* is used to wrap several different methods. Wrappers are extremely simple -
18294
* they only require implementing two methods.
18295
*
18296
* <pre>
18297
* wrappers (injected at creation time)
18298
* + +
18299
* | |
18300
* +-----------------|--------|--------------+
18301
* | v | |
18302
* | +---------------+ | |
18303
* | +--| wrapper1 |---|----+ |
18304
* | | +---------------+ v | |
18305
* | | +-------------+ | |
18306
* | | +----| wrapper2 |--------+ |
18307
* | | | +-------------+ | | |
18308
* | | | | | |
18309
* | v v v v | wrapper
18310
* | +---+ +---+ +---------+ +---+ +---+ | invariants
18311
* perform(anyMethod) | | | | | | | | | | | | maintained
18312
* +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
18313
* | | | | | | | | | | | |
18314
* | | | | | | | | | | | |
18315
* | | | | | | | | | | | |
18316
* | +---+ +---+ +---------+ +---+ +---+ |
18317
* | initialize close |
18318
* +-----------------------------------------+
18319
* </pre>
18320
*
18321
* Use cases:
18322
* - Preserving the input selection ranges before/after reconciliation.
18323
* Restoring selection even in the event of an unexpected error.
18324
* - Deactivating events while rearranging the DOM, preventing blurs/focuses,
18325
* while guaranteeing that afterwards, the event system is reactivated.
18326
* - Flushing a queue of collected DOM mutations to the main UI thread after a
18327
* reconciliation takes place in a worker thread.
18328
* - Invoking any collected `componentDidUpdate` callbacks after rendering new
18329
* content.
18330
* - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
18331
* to preserve the `scrollTop` (an automatic scroll aware DOM).
18332
* - (Future use case): Layout calculations before and after DOM updates.
18333
*
18334
* Transactional plugin API:
18335
* - A module that has an `initialize` method that returns any precomputation.
18336
* - and a `close` method that accepts the precomputation. `close` is invoked
18337
* when the wrapped process is completed, or has failed.
18338
*
18339
* @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
18340
* that implement `initialize` and `close`.
18341
* @return {Transaction} Single transaction for reuse in thread.
18342
*
18343
* @class Transaction
18344
*/
18345
var Mixin = {
18346
/**
18347
* Sets up this instance so that it is prepared for collecting metrics. Does
18348
* so such that this setup method may be used on an instance that is already
18349
* initialized, in a way that does not consume additional memory upon reuse.
18350
* That can be useful if you decide to make your subclass of this mixin a
18351
* "PooledClass".
18352
*/
18353
reinitializeTransaction: function() {
18354
this.transactionWrappers = this.getTransactionWrappers();
18355
if (!this.wrapperInitData) {
18356
this.wrapperInitData = [];
18357
} else {
18358
this.wrapperInitData.length = 0;
18359
}
18360
this._isInTransaction = false;
18361
},
18362
18363
_isInTransaction: false,
18364
18365
/**
18366
* @abstract
18367
* @return {Array<TransactionWrapper>} Array of transaction wrappers.
18368
*/
18369
getTransactionWrappers: null,
18370
18371
isInTransaction: function() {
18372
return !!this._isInTransaction;
18373
},
18374
18375
/**
18376
* Executes the function within a safety window. Use this for the top level
18377
* methods that result in large amounts of computation/mutations that would
18378
* need to be safety checked.
18379
*
18380
* @param {function} method Member of scope to call.
18381
* @param {Object} scope Scope to invoke from.
18382
* @param {Object?=} args... Arguments to pass to the method (optional).
18383
* Helps prevent need to bind in many cases.
18384
* @return Return value from `method`.
18385
*/
18386
perform: function(method, scope, a, b, c, d, e, f) {
18387
("production" !== "development" ? invariant(
18388
!this.isInTransaction(),
18389
'Transaction.perform(...): Cannot initialize a transaction when there ' +
18390
'is already an outstanding transaction.'
18391
) : invariant(!this.isInTransaction()));
18392
var errorThrown;
18393
var ret;
18394
try {
18395
this._isInTransaction = true;
18396
// Catching errors makes debugging more difficult, so we start with
18397
// errorThrown set to true before setting it to false after calling
18398
// close -- if it's still set to true in the finally block, it means
18399
// one of these calls threw.
18400
errorThrown = true;
18401
this.initializeAll(0);
18402
ret = method.call(scope, a, b, c, d, e, f);
18403
errorThrown = false;
18404
} finally {
18405
try {
18406
if (errorThrown) {
18407
// If `method` throws, prefer to show that stack trace over any thrown
18408
// by invoking `closeAll`.
18409
try {
18410
this.closeAll(0);
18411
} catch (err) {
18412
}
18413
} else {
18414
// Since `method` didn't throw, we don't want to silence the exception
18415
// here.
18416
this.closeAll(0);
18417
}
18418
} finally {
18419
this._isInTransaction = false;
18420
}
18421
}
18422
return ret;
18423
},
18424
18425
initializeAll: function(startIndex) {
18426
var transactionWrappers = this.transactionWrappers;
18427
for (var i = startIndex; i < transactionWrappers.length; i++) {
18428
var wrapper = transactionWrappers[i];
18429
try {
18430
// Catching errors makes debugging more difficult, so we start with the
18431
// OBSERVED_ERROR state before overwriting it with the real return value
18432
// of initialize -- if it's still set to OBSERVED_ERROR in the finally
18433
// block, it means wrapper.initialize threw.
18434
this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
18435
this.wrapperInitData[i] = wrapper.initialize ?
18436
wrapper.initialize.call(this) :
18437
null;
18438
} finally {
18439
if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
18440
// The initializer for wrapper i threw an error; initialize the
18441
// remaining wrappers but silence any exceptions from them to ensure
18442
// that the first error is the one to bubble up.
18443
try {
18444
this.initializeAll(i + 1);
18445
} catch (err) {
18446
}
18447
}
18448
}
18449
}
18450
},
18451
18452
/**
18453
* Invokes each of `this.transactionWrappers.close[i]` functions, passing into
18454
* them the respective return values of `this.transactionWrappers.init[i]`
18455
* (`close`rs that correspond to initializers that failed will not be
18456
* invoked).
18457
*/
18458
closeAll: function(startIndex) {
18459
("production" !== "development" ? invariant(
18460
this.isInTransaction(),
18461
'Transaction.closeAll(): Cannot close transaction when none are open.'
18462
) : invariant(this.isInTransaction()));
18463
var transactionWrappers = this.transactionWrappers;
18464
for (var i = startIndex; i < transactionWrappers.length; i++) {
18465
var wrapper = transactionWrappers[i];
18466
var initData = this.wrapperInitData[i];
18467
var errorThrown;
18468
try {
18469
// Catching errors makes debugging more difficult, so we start with
18470
// errorThrown set to true before setting it to false after calling
18471
// close -- if it's still set to true in the finally block, it means
18472
// wrapper.close threw.
18473
errorThrown = true;
18474
if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) {
18475
wrapper.close.call(this, initData);
18476
}
18477
errorThrown = false;
18478
} finally {
18479
if (errorThrown) {
18480
// The closer for wrapper i threw an error; close the remaining
18481
// wrappers but silence any exceptions from them to ensure that the
18482
// first error is the one to bubble up.
18483
try {
18484
this.closeAll(i + 1);
18485
} catch (e) {
18486
}
18487
}
18488
}
18489
}
18490
this.wrapperInitData.length = 0;
18491
}
18492
};
18493
18494
var Transaction = {
18495
18496
Mixin: Mixin,
18497
18498
/**
18499
* Token to look for to determine if an error occured.
18500
*/
18501
OBSERVED_ERROR: {}
18502
18503
};
18504
18505
module.exports = Transaction;
18506
18507
},{"150":150}],117:[function(_dereq_,module,exports){
18508
/**
18509
* Copyright 2013-2015, Facebook, Inc.
18510
* All rights reserved.
18511
*
18512
* This source code is licensed under the BSD-style license found in the
18513
* LICENSE file in the root directory of this source tree. An additional grant
18514
* of patent rights can be found in the PATENTS file in the same directory.
18515
*
18516
* @providesModule ViewportMetrics
18517
*/
18518
18519
'use strict';
18520
18521
var ViewportMetrics = {
18522
18523
currentScrollLeft: 0,
18524
18525
currentScrollTop: 0,
18526
18527
refreshScrollValues: function(scrollPosition) {
18528
ViewportMetrics.currentScrollLeft = scrollPosition.x;
18529
ViewportMetrics.currentScrollTop = scrollPosition.y;
18530
}
18531
18532
};
18533
18534
module.exports = ViewportMetrics;
18535
18536
},{}],118:[function(_dereq_,module,exports){
18537
/**
18538
* Copyright 2014-2015, Facebook, Inc.
18539
* All rights reserved.
18540
*
18541
* This source code is licensed under the BSD-style license found in the
18542
* LICENSE file in the root directory of this source tree. An additional grant
18543
* of patent rights can be found in the PATENTS file in the same directory.
18544
*
18545
* @providesModule accumulateInto
18546
*/
18547
18548
'use strict';
18549
18550
var invariant = _dereq_(150);
18551
18552
/**
18553
*
18554
* Accumulates items that must not be null or undefined into the first one. This
18555
* is used to conserve memory by avoiding array allocations, and thus sacrifices
18556
* API cleanness. Since `current` can be null before being passed in and not
18557
* null after this function, make sure to assign it back to `current`:
18558
*
18559
* `a = accumulateInto(a, b);`
18560
*
18561
* This API should be sparingly used. Try `accumulate` for something cleaner.
18562
*
18563
* @return {*|array<*>} An accumulation of items.
18564
*/
18565
18566
function accumulateInto(current, next) {
18567
("production" !== "development" ? invariant(
18568
next != null,
18569
'accumulateInto(...): Accumulated items must not be null or undefined.'
18570
) : invariant(next != null));
18571
if (current == null) {
18572
return next;
18573
}
18574
18575
// Both are not empty. Warning: Never call x.concat(y) when you are not
18576
// certain that x is an Array (x could be a string with concat method).
18577
var currentIsArray = Array.isArray(current);
18578
var nextIsArray = Array.isArray(next);
18579
18580
if (currentIsArray && nextIsArray) {
18581
current.push.apply(current, next);
18582
return current;
18583
}
18584
18585
if (currentIsArray) {
18586
current.push(next);
18587
return current;
18588
}
18589
18590
if (nextIsArray) {
18591
// A bit too dangerous to mutate `next`.
18592
return [current].concat(next);
18593
}
18594
18595
return [current, next];
18596
}
18597
18598
module.exports = accumulateInto;
18599
18600
},{"150":150}],119:[function(_dereq_,module,exports){
18601
/**
18602
* Copyright 2013-2015, Facebook, Inc.
18603
* All rights reserved.
18604
*
18605
* This source code is licensed under the BSD-style license found in the
18606
* LICENSE file in the root directory of this source tree. An additional grant
18607
* of patent rights can be found in the PATENTS file in the same directory.
18608
*
18609
* @providesModule adler32
18610
*/
18611
18612
/* jslint bitwise:true */
18613
18614
'use strict';
18615
18616
var MOD = 65521;
18617
18618
// This is a clean-room implementation of adler32 designed for detecting
18619
// if markup is not what we expect it to be. It does not need to be
18620
// cryptographically strong, only reasonably good at detecting if markup
18621
// generated on the server is different than that on the client.
18622
function adler32(data) {
18623
var a = 1;
18624
var b = 0;
18625
for (var i = 0; i < data.length; i++) {
18626
a = (a + data.charCodeAt(i)) % MOD;
18627
b = (b + a) % MOD;
18628
}
18629
return a | (b << 16);
18630
}
18631
18632
module.exports = adler32;
18633
18634
},{}],120:[function(_dereq_,module,exports){
18635
/**
18636
* Copyright 2013-2015, Facebook, Inc.
18637
* All rights reserved.
18638
*
18639
* This source code is licensed under the BSD-style license found in the
18640
* LICENSE file in the root directory of this source tree. An additional grant
18641
* of patent rights can be found in the PATENTS file in the same directory.
18642
*
18643
* @providesModule camelize
18644
* @typechecks
18645
*/
18646
18647
var _hyphenPattern = /-(.)/g;
18648
18649
/**
18650
* Camelcases a hyphenated string, for example:
18651
*
18652
* > camelize('background-color')
18653
* < "backgroundColor"
18654
*
18655
* @param {string} string
18656
* @return {string}
18657
*/
18658
function camelize(string) {
18659
return string.replace(_hyphenPattern, function(_, character) {
18660
return character.toUpperCase();
18661
});
18662
}
18663
18664
module.exports = camelize;
18665
18666
},{}],121:[function(_dereq_,module,exports){
18667
/**
18668
* Copyright 2014-2015, Facebook, Inc.
18669
* All rights reserved.
18670
*
18671
* This source code is licensed under the BSD-style license found in the
18672
* LICENSE file in the root directory of this source tree. An additional grant
18673
* of patent rights can be found in the PATENTS file in the same directory.
18674
*
18675
* @providesModule camelizeStyleName
18676
* @typechecks
18677
*/
18678
18679
"use strict";
18680
18681
var camelize = _dereq_(120);
18682
18683
var msPattern = /^-ms-/;
18684
18685
/**
18686
* Camelcases a hyphenated CSS property name, for example:
18687
*
18688
* > camelizeStyleName('background-color')
18689
* < "backgroundColor"
18690
* > camelizeStyleName('-moz-transition')
18691
* < "MozTransition"
18692
* > camelizeStyleName('-ms-transition')
18693
* < "msTransition"
18694
*
18695
* As Andi Smith suggests
18696
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
18697
* is converted to lowercase `ms`.
18698
*
18699
* @param {string} string
18700
* @return {string}
18701
*/
18702
function camelizeStyleName(string) {
18703
return camelize(string.replace(msPattern, 'ms-'));
18704
}
18705
18706
module.exports = camelizeStyleName;
18707
18708
},{"120":120}],122:[function(_dereq_,module,exports){
18709
/**
18710
* Copyright 2013-2015, Facebook, Inc.
18711
* All rights reserved.
18712
*
18713
* This source code is licensed under the BSD-style license found in the
18714
* LICENSE file in the root directory of this source tree. An additional grant
18715
* of patent rights can be found in the PATENTS file in the same directory.
18716
*
18717
* @typechecks static-only
18718
* @providesModule cloneWithProps
18719
*/
18720
18721
'use strict';
18722
18723
var ReactElement = _dereq_(63);
18724
var ReactPropTransferer = _dereq_(83);
18725
18726
var keyOf = _dereq_(157);
18727
var warning = _dereq_(171);
18728
18729
var CHILDREN_PROP = keyOf({children: null});
18730
18731
/**
18732
* Sometimes you want to change the props of a child passed to you. Usually
18733
* this is to add a CSS class.
18734
*
18735
* @param {ReactElement} child child element you'd like to clone
18736
* @param {object} props props you'd like to modify. className and style will be
18737
* merged automatically.
18738
* @return {ReactElement} a clone of child with props merged in.
18739
*/
18740
function cloneWithProps(child, props) {
18741
if ("production" !== "development") {
18742
("production" !== "development" ? warning(
18743
!child.ref,
18744
'You are calling cloneWithProps() on a child with a ref. This is ' +
18745
'dangerous because you\'re creating a new child which will not be ' +
18746
'added as a ref to its parent.'
18747
) : null);
18748
}
18749
18750
var newProps = ReactPropTransferer.mergeProps(props, child.props);
18751
18752
// Use `child.props.children` if it is provided.
18753
if (!newProps.hasOwnProperty(CHILDREN_PROP) &&
18754
child.props.hasOwnProperty(CHILDREN_PROP)) {
18755
newProps.children = child.props.children;
18756
}
18757
18758
// The current API doesn't retain _owner and _context, which is why this
18759
// doesn't use ReactElement.cloneAndReplaceProps.
18760
return ReactElement.createElement(child.type, newProps);
18761
}
18762
18763
module.exports = cloneWithProps;
18764
18765
},{"157":157,"171":171,"63":63,"83":83}],123:[function(_dereq_,module,exports){
18766
/**
18767
* Copyright 2013-2015, Facebook, Inc.
18768
* All rights reserved.
18769
*
18770
* This source code is licensed under the BSD-style license found in the
18771
* LICENSE file in the root directory of this source tree. An additional grant
18772
* of patent rights can be found in the PATENTS file in the same directory.
18773
*
18774
* @providesModule containsNode
18775
* @typechecks
18776
*/
18777
18778
var isTextNode = _dereq_(154);
18779
18780
/*jslint bitwise:true */
18781
18782
/**
18783
* Checks if a given DOM node contains or is another DOM node.
18784
*
18785
* @param {?DOMNode} outerNode Outer DOM node.
18786
* @param {?DOMNode} innerNode Inner DOM node.
18787
* @return {boolean} True if `outerNode` contains or is `innerNode`.
18788
*/
18789
function containsNode(outerNode, innerNode) {
18790
if (!outerNode || !innerNode) {
18791
return false;
18792
} else if (outerNode === innerNode) {
18793
return true;
18794
} else if (isTextNode(outerNode)) {
18795
return false;
18796
} else if (isTextNode(innerNode)) {
18797
return containsNode(outerNode, innerNode.parentNode);
18798
} else if (outerNode.contains) {
18799
return outerNode.contains(innerNode);
18800
} else if (outerNode.compareDocumentPosition) {
18801
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
18802
} else {
18803
return false;
18804
}
18805
}
18806
18807
module.exports = containsNode;
18808
18809
},{"154":154}],124:[function(_dereq_,module,exports){
18810
/**
18811
* Copyright 2013-2015, Facebook, Inc.
18812
* All rights reserved.
18813
*
18814
* This source code is licensed under the BSD-style license found in the
18815
* LICENSE file in the root directory of this source tree. An additional grant
18816
* of patent rights can be found in the PATENTS file in the same directory.
18817
*
18818
* @providesModule createArrayFromMixed
18819
* @typechecks
18820
*/
18821
18822
var toArray = _dereq_(168);
18823
18824
/**
18825
* Perform a heuristic test to determine if an object is "array-like".
18826
*
18827
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
18828
* Joshu replied: "Mu."
18829
*
18830
* This function determines if its argument has "array nature": it returns
18831
* true if the argument is an actual array, an `arguments' object, or an
18832
* HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
18833
*
18834
* It will return false for other array-like objects like Filelist.
18835
*
18836
* @param {*} obj
18837
* @return {boolean}
18838
*/
18839
function hasArrayNature(obj) {
18840
return (
18841
// not null/false
18842
!!obj &&
18843
// arrays are objects, NodeLists are functions in Safari
18844
(typeof obj == 'object' || typeof obj == 'function') &&
18845
// quacks like an array
18846
('length' in obj) &&
18847
// not window
18848
!('setInterval' in obj) &&
18849
// no DOM node should be considered an array-like
18850
// a 'select' element has 'length' and 'item' properties on IE8
18851
(typeof obj.nodeType != 'number') &&
18852
(
18853
// a real array
18854
(// HTMLCollection/NodeList
18855
(Array.isArray(obj) ||
18856
// arguments
18857
('callee' in obj) || 'item' in obj))
18858
)
18859
);
18860
}
18861
18862
/**
18863
* Ensure that the argument is an array by wrapping it in an array if it is not.
18864
* Creates a copy of the argument if it is already an array.
18865
*
18866
* This is mostly useful idiomatically:
18867
*
18868
* var createArrayFromMixed = require('createArrayFromMixed');
18869
*
18870
* function takesOneOrMoreThings(things) {
18871
* things = createArrayFromMixed(things);
18872
* ...
18873
* }
18874
*
18875
* This allows you to treat `things' as an array, but accept scalars in the API.
18876
*
18877
* If you need to convert an array-like object, like `arguments`, into an array
18878
* use toArray instead.
18879
*
18880
* @param {*} obj
18881
* @return {array}
18882
*/
18883
function createArrayFromMixed(obj) {
18884
if (!hasArrayNature(obj)) {
18885
return [obj];
18886
} else if (Array.isArray(obj)) {
18887
return obj.slice();
18888
} else {
18889
return toArray(obj);
18890
}
18891
}
18892
18893
module.exports = createArrayFromMixed;
18894
18895
},{"168":168}],125:[function(_dereq_,module,exports){
18896
/**
18897
* Copyright 2013-2015, Facebook, Inc.
18898
* All rights reserved.
18899
*
18900
* This source code is licensed under the BSD-style license found in the
18901
* LICENSE file in the root directory of this source tree. An additional grant
18902
* of patent rights can be found in the PATENTS file in the same directory.
18903
*
18904
* @providesModule createFullPageComponent
18905
* @typechecks
18906
*/
18907
18908
'use strict';
18909
18910
// Defeat circular references by requiring this directly.
18911
var ReactClass = _dereq_(38);
18912
var ReactElement = _dereq_(63);
18913
18914
var invariant = _dereq_(150);
18915
18916
/**
18917
* Create a component that will throw an exception when unmounted.
18918
*
18919
* Components like <html> <head> and <body> can't be removed or added
18920
* easily in a cross-browser way, however it's valuable to be able to
18921
* take advantage of React's reconciliation for styling and <title>
18922
* management. So we just document it and throw in dangerous cases.
18923
*
18924
* @param {string} tag The tag to wrap
18925
* @return {function} convenience constructor of new component
18926
*/
18927
function createFullPageComponent(tag) {
18928
var elementFactory = ReactElement.createFactory(tag);
18929
18930
var FullPageComponent = ReactClass.createClass({
18931
tagName: tag.toUpperCase(),
18932
displayName: 'ReactFullPageComponent' + tag,
18933
18934
componentWillUnmount: function() {
18935
("production" !== "development" ? invariant(
18936
false,
18937
'%s tried to unmount. Because of cross-browser quirks it is ' +
18938
'impossible to unmount some top-level components (eg <html>, <head>, ' +
18939
'and <body>) reliably and efficiently. To fix this, have a single ' +
18940
'top-level component that never unmounts render these elements.',
18941
this.constructor.displayName
18942
) : invariant(false));
18943
},
18944
18945
render: function() {
18946
return elementFactory(this.props);
18947
}
18948
});
18949
18950
return FullPageComponent;
18951
}
18952
18953
module.exports = createFullPageComponent;
18954
18955
},{"150":150,"38":38,"63":63}],126:[function(_dereq_,module,exports){
18956
/**
18957
* Copyright 2013-2015, Facebook, Inc.
18958
* All rights reserved.
18959
*
18960
* This source code is licensed under the BSD-style license found in the
18961
* LICENSE file in the root directory of this source tree. An additional grant
18962
* of patent rights can be found in the PATENTS file in the same directory.
18963
*
18964
* @providesModule createNodesFromMarkup
18965
* @typechecks
18966
*/
18967
18968
/*jslint evil: true, sub: true */
18969
18970
var ExecutionEnvironment = _dereq_(22);
18971
18972
var createArrayFromMixed = _dereq_(124);
18973
var getMarkupWrap = _dereq_(142);
18974
var invariant = _dereq_(150);
18975
18976
/**
18977
* Dummy container used to render all markup.
18978
*/
18979
var dummyNode =
18980
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
18981
18982
/**
18983
* Pattern used by `getNodeName`.
18984
*/
18985
var nodeNamePattern = /^\s*<(\w+)/;
18986
18987
/**
18988
* Extracts the `nodeName` of the first element in a string of markup.
18989
*
18990
* @param {string} markup String of markup.
18991
* @return {?string} Node name of the supplied markup.
18992
*/
18993
function getNodeName(markup) {
18994
var nodeNameMatch = markup.match(nodeNamePattern);
18995
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
18996
}
18997
18998
/**
18999
* Creates an array containing the nodes rendered from the supplied markup. The
19000
* optionally supplied `handleScript` function will be invoked once for each
19001
* <script> element that is rendered. If no `handleScript` function is supplied,
19002
* an exception is thrown if any <script> elements are rendered.
19003
*
19004
* @param {string} markup A string of valid HTML markup.
19005
* @param {?function} handleScript Invoked once for each rendered <script>.
19006
* @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
19007
*/
19008
function createNodesFromMarkup(markup, handleScript) {
19009
var node = dummyNode;
19010
("production" !== "development" ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
19011
var nodeName = getNodeName(markup);
19012
19013
var wrap = nodeName && getMarkupWrap(nodeName);
19014
if (wrap) {
19015
node.innerHTML = wrap[1] + markup + wrap[2];
19016
19017
var wrapDepth = wrap[0];
19018
while (wrapDepth--) {
19019
node = node.lastChild;
19020
}
19021
} else {
19022
node.innerHTML = markup;
19023
}
19024
19025
var scripts = node.getElementsByTagName('script');
19026
if (scripts.length) {
19027
("production" !== "development" ? invariant(
19028
handleScript,
19029
'createNodesFromMarkup(...): Unexpected <script> element rendered.'
19030
) : invariant(handleScript));
19031
createArrayFromMixed(scripts).forEach(handleScript);
19032
}
19033
19034
var nodes = createArrayFromMixed(node.childNodes);
19035
while (node.lastChild) {
19036
node.removeChild(node.lastChild);
19037
}
19038
return nodes;
19039
}
19040
19041
module.exports = createNodesFromMarkup;
19042
19043
},{"124":124,"142":142,"150":150,"22":22}],127:[function(_dereq_,module,exports){
19044
/**
19045
* Copyright 2013-2015, Facebook, Inc.
19046
* All rights reserved.
19047
*
19048
* This source code is licensed under the BSD-style license found in the
19049
* LICENSE file in the root directory of this source tree. An additional grant
19050
* of patent rights can be found in the PATENTS file in the same directory.
19051
*
19052
* @providesModule cx
19053
*/
19054
19055
/**
19056
* This function is used to mark string literals representing CSS class names
19057
* so that they can be transformed statically. This allows for modularization
19058
* and minification of CSS class names.
19059
*
19060
* In static_upstream, this function is actually implemented, but it should
19061
* eventually be replaced with something more descriptive, and the transform
19062
* that is used in the main stack should be ported for use elsewhere.
19063
*
19064
* @param string|object className to modularize, or an object of key/values.
19065
* In the object case, the values are conditions that
19066
* determine if the className keys should be included.
19067
* @param [string ...] Variable list of classNames in the string case.
19068
* @return string Renderable space-separated CSS className.
19069
*/
19070
19071
'use strict';
19072
var warning = _dereq_(171);
19073
19074
var warned = false;
19075
19076
function cx(classNames) {
19077
if ("production" !== "development") {
19078
("production" !== "development" ? warning(
19079
warned,
19080
'React.addons.classSet will be deprecated in a future version. See ' +
19081
'http://fb.me/react-addons-classset'
19082
) : null);
19083
warned = true;
19084
}
19085
19086
if (typeof classNames == 'object') {
19087
return Object.keys(classNames).filter(function(className) {
19088
return classNames[className];
19089
}).join(' ');
19090
} else {
19091
return Array.prototype.join.call(arguments, ' ');
19092
}
19093
}
19094
19095
module.exports = cx;
19096
19097
},{"171":171}],128:[function(_dereq_,module,exports){
19098
/**
19099
* Copyright 2013-2015, Facebook, Inc.
19100
* All rights reserved.
19101
*
19102
* This source code is licensed under the BSD-style license found in the
19103
* LICENSE file in the root directory of this source tree. An additional grant
19104
* of patent rights can be found in the PATENTS file in the same directory.
19105
*
19106
* @providesModule dangerousStyleValue
19107
* @typechecks static-only
19108
*/
19109
19110
'use strict';
19111
19112
var CSSProperty = _dereq_(5);
19113
19114
var isUnitlessNumber = CSSProperty.isUnitlessNumber;
19115
19116
/**
19117
* Convert a value into the proper css writable value. The style name `name`
19118
* should be logical (no hyphens), as specified
19119
* in `CSSProperty.isUnitlessNumber`.
19120
*
19121
* @param {string} name CSS property name such as `topMargin`.
19122
* @param {*} value CSS property value such as `10px`.
19123
* @return {string} Normalized style value with dimensions applied.
19124
*/
19125
function dangerousStyleValue(name, value) {
19126
// Note that we've removed escapeTextForBrowser() calls here since the
19127
// whole string will be escaped when the attribute is injected into
19128
// the markup. If you provide unsafe user data here they can inject
19129
// arbitrary CSS which may be problematic (I couldn't repro this):
19130
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
19131
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
19132
// This is not an XSS hole but instead a potential CSS injection issue
19133
// which has lead to a greater discussion about how we're going to
19134
// trust URLs moving forward. See #2115901
19135
19136
var isEmpty = value == null || typeof value === 'boolean' || value === '';
19137
if (isEmpty) {
19138
return '';
19139
}
19140
19141
var isNonNumeric = isNaN(value);
19142
if (isNonNumeric || value === 0 ||
19143
isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
19144
return '' + value; // cast to string
19145
}
19146
19147
if (typeof value === 'string') {
19148
value = value.trim();
19149
}
19150
return value + 'px';
19151
}
19152
19153
module.exports = dangerousStyleValue;
19154
19155
},{"5":5}],129:[function(_dereq_,module,exports){
19156
/**
19157
* Copyright 2013-2015, Facebook, Inc.
19158
* All rights reserved.
19159
*
19160
* This source code is licensed under the BSD-style license found in the
19161
* LICENSE file in the root directory of this source tree. An additional grant
19162
* of patent rights can be found in the PATENTS file in the same directory.
19163
*
19164
* @providesModule emptyFunction
19165
*/
19166
19167
function makeEmptyFunction(arg) {
19168
return function() {
19169
return arg;
19170
};
19171
}
19172
19173
/**
19174
* This function accepts and discards inputs; it has no side effects. This is
19175
* primarily useful idiomatically for overridable function endpoints which
19176
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
19177
*/
19178
function emptyFunction() {}
19179
19180
emptyFunction.thatReturns = makeEmptyFunction;
19181
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
19182
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
19183
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
19184
emptyFunction.thatReturnsThis = function() { return this; };
19185
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
19186
19187
module.exports = emptyFunction;
19188
19189
},{}],130:[function(_dereq_,module,exports){
19190
/**
19191
* Copyright 2013-2015, Facebook, Inc.
19192
* All rights reserved.
19193
*
19194
* This source code is licensed under the BSD-style license found in the
19195
* LICENSE file in the root directory of this source tree. An additional grant
19196
* of patent rights can be found in the PATENTS file in the same directory.
19197
*
19198
* @providesModule emptyObject
19199
*/
19200
19201
"use strict";
19202
19203
var emptyObject = {};
19204
19205
if ("production" !== "development") {
19206
Object.freeze(emptyObject);
19207
}
19208
19209
module.exports = emptyObject;
19210
19211
},{}],131:[function(_dereq_,module,exports){
19212
/**
19213
* Copyright 2013-2015, Facebook, Inc.
19214
* All rights reserved.
19215
*
19216
* This source code is licensed under the BSD-style license found in the
19217
* LICENSE file in the root directory of this source tree. An additional grant
19218
* of patent rights can be found in the PATENTS file in the same directory.
19219
*
19220
* @providesModule escapeTextContentForBrowser
19221
*/
19222
19223
'use strict';
19224
19225
var ESCAPE_LOOKUP = {
19226
'&': '&amp;',
19227
'>': '&gt;',
19228
'<': '&lt;',
19229
'"': '&quot;',
19230
'\'': '&#x27;'
19231
};
19232
19233
var ESCAPE_REGEX = /[&><"']/g;
19234
19235
function escaper(match) {
19236
return ESCAPE_LOOKUP[match];
19237
}
19238
19239
/**
19240
* Escapes text to prevent scripting attacks.
19241
*
19242
* @param {*} text Text value to escape.
19243
* @return {string} An escaped string.
19244
*/
19245
function escapeTextContentForBrowser(text) {
19246
return ('' + text).replace(ESCAPE_REGEX, escaper);
19247
}
19248
19249
module.exports = escapeTextContentForBrowser;
19250
19251
},{}],132:[function(_dereq_,module,exports){
19252
/**
19253
* Copyright 2013-2015, Facebook, Inc.
19254
* All rights reserved.
19255
*
19256
* This source code is licensed under the BSD-style license found in the
19257
* LICENSE file in the root directory of this source tree. An additional grant
19258
* of patent rights can be found in the PATENTS file in the same directory.
19259
*
19260
* @providesModule findDOMNode
19261
* @typechecks static-only
19262
*/
19263
19264
'use strict';
19265
19266
var ReactCurrentOwner = _dereq_(45);
19267
var ReactInstanceMap = _dereq_(73);
19268
var ReactMount = _dereq_(77);
19269
19270
var invariant = _dereq_(150);
19271
var isNode = _dereq_(152);
19272
var warning = _dereq_(171);
19273
19274
/**
19275
* Returns the DOM node rendered by this element.
19276
*
19277
* @param {ReactComponent|DOMElement} componentOrElement
19278
* @return {DOMElement} The root node of this element.
19279
*/
19280
function findDOMNode(componentOrElement) {
19281
if ("production" !== "development") {
19282
var owner = ReactCurrentOwner.current;
19283
if (owner !== null) {
19284
("production" !== "development" ? warning(
19285
owner._warnedAboutRefsInRender,
19286
'%s is accessing getDOMNode or findDOMNode inside its render(). ' +
19287
'render() should be a pure function of props and state. It should ' +
19288
'never access something that requires stale data from the previous ' +
19289
'render, such as refs. Move this logic to componentDidMount and ' +
19290
'componentDidUpdate instead.',
19291
owner.getName() || 'A component'
19292
) : null);
19293
owner._warnedAboutRefsInRender = true;
19294
}
19295
}
19296
if (componentOrElement == null) {
19297
return null;
19298
}
19299
if (isNode(componentOrElement)) {
19300
return componentOrElement;
19301
}
19302
if (ReactInstanceMap.has(componentOrElement)) {
19303
return ReactMount.getNodeFromInstance(componentOrElement);
19304
}
19305
("production" !== "development" ? invariant(
19306
componentOrElement.render == null ||
19307
typeof componentOrElement.render !== 'function',
19308
'Component (with keys: %s) contains `render` method ' +
19309
'but is not mounted in the DOM',
19310
Object.keys(componentOrElement)
19311
) : invariant(componentOrElement.render == null ||
19312
typeof componentOrElement.render !== 'function'));
19313
("production" !== "development" ? invariant(
19314
false,
19315
'Element appears to be neither ReactComponent nor DOMNode (keys: %s)',
19316
Object.keys(componentOrElement)
19317
) : invariant(false));
19318
}
19319
19320
module.exports = findDOMNode;
19321
19322
},{"150":150,"152":152,"171":171,"45":45,"73":73,"77":77}],133:[function(_dereq_,module,exports){
19323
/**
19324
* Copyright 2013-2015, Facebook, Inc.
19325
* All rights reserved.
19326
*
19327
* This source code is licensed under the BSD-style license found in the
19328
* LICENSE file in the root directory of this source tree. An additional grant
19329
* of patent rights can be found in the PATENTS file in the same directory.
19330
*
19331
* @providesModule flattenChildren
19332
*/
19333
19334
'use strict';
19335
19336
var traverseAllChildren = _dereq_(169);
19337
var warning = _dereq_(171);
19338
19339
/**
19340
* @param {function} traverseContext Context passed through traversal.
19341
* @param {?ReactComponent} child React child component.
19342
* @param {!string} name String name of key path to child.
19343
*/
19344
function flattenSingleChildIntoContext(traverseContext, child, name) {
19345
// We found a component instance.
19346
var result = traverseContext;
19347
var keyUnique = !result.hasOwnProperty(name);
19348
if ("production" !== "development") {
19349
("production" !== "development" ? warning(
19350
keyUnique,
19351
'flattenChildren(...): Encountered two children with the same key, ' +
19352
'`%s`. Child keys must be unique; when two children share a key, only ' +
19353
'the first child will be used.',
19354
name
19355
) : null);
19356
}
19357
if (keyUnique && child != null) {
19358
result[name] = child;
19359
}
19360
}
19361
19362
/**
19363
* Flattens children that are typically specified as `props.children`. Any null
19364
* children will not be included in the resulting object.
19365
* @return {!object} flattened children keyed by name.
19366
*/
19367
function flattenChildren(children) {
19368
if (children == null) {
19369
return children;
19370
}
19371
var result = {};
19372
traverseAllChildren(children, flattenSingleChildIntoContext, result);
19373
return result;
19374
}
19375
19376
module.exports = flattenChildren;
19377
19378
},{"169":169,"171":171}],134:[function(_dereq_,module,exports){
19379
/**
19380
* Copyright 2014-2015, Facebook, Inc.
19381
* All rights reserved.
19382
*
19383
* This source code is licensed under the BSD-style license found in the
19384
* LICENSE file in the root directory of this source tree. An additional grant
19385
* of patent rights can be found in the PATENTS file in the same directory.
19386
*
19387
* @providesModule focusNode
19388
*/
19389
19390
"use strict";
19391
19392
/**
19393
* @param {DOMElement} node input/textarea to focus
19394
*/
19395
function focusNode(node) {
19396
// IE8 can throw "Can't move focus to the control because it is invisible,
19397
// not enabled, or of a type that does not accept the focus." for all kinds of
19398
// reasons that are too expensive and fragile to test.
19399
try {
19400
node.focus();
19401
} catch(e) {
19402
}
19403
}
19404
19405
module.exports = focusNode;
19406
19407
},{}],135:[function(_dereq_,module,exports){
19408
/**
19409
* Copyright 2013-2015, Facebook, Inc.
19410
* All rights reserved.
19411
*
19412
* This source code is licensed under the BSD-style license found in the
19413
* LICENSE file in the root directory of this source tree. An additional grant
19414
* of patent rights can be found in the PATENTS file in the same directory.
19415
*
19416
* @providesModule forEachAccumulated
19417
*/
19418
19419
'use strict';
19420
19421
/**
19422
* @param {array} an "accumulation" of items which is either an Array or
19423
* a single item. Useful when paired with the `accumulate` module. This is a
19424
* simple utility that allows us to reason about a collection of items, but
19425
* handling the case when there is exactly one item (and we do not need to
19426
* allocate an array).
19427
*/
19428
var forEachAccumulated = function(arr, cb, scope) {
19429
if (Array.isArray(arr)) {
19430
arr.forEach(cb, scope);
19431
} else if (arr) {
19432
cb.call(scope, arr);
19433
}
19434
};
19435
19436
module.exports = forEachAccumulated;
19437
19438
},{}],136:[function(_dereq_,module,exports){
19439
/**
19440
* Copyright 2013-2015, Facebook, Inc.
19441
* All rights reserved.
19442
*
19443
* This source code is licensed under the BSD-style license found in the
19444
* LICENSE file in the root directory of this source tree. An additional grant
19445
* of patent rights can be found in the PATENTS file in the same directory.
19446
*
19447
* @providesModule getActiveElement
19448
* @typechecks
19449
*/
19450
19451
/**
19452
* Same as document.activeElement but wraps in a try-catch block. In IE it is
19453
* not safe to call document.activeElement if there is nothing focused.
19454
*
19455
* The activeElement will be null only if the document body is not yet defined.
19456
*/
19457
function getActiveElement() /*?DOMElement*/ {
19458
try {
19459
return document.activeElement || document.body;
19460
} catch (e) {
19461
return document.body;
19462
}
19463
}
19464
19465
module.exports = getActiveElement;
19466
19467
},{}],137:[function(_dereq_,module,exports){
19468
/**
19469
* Copyright 2013-2015, Facebook, Inc.
19470
* All rights reserved.
19471
*
19472
* This source code is licensed under the BSD-style license found in the
19473
* LICENSE file in the root directory of this source tree. An additional grant
19474
* of patent rights can be found in the PATENTS file in the same directory.
19475
*
19476
* @providesModule getEventCharCode
19477
* @typechecks static-only
19478
*/
19479
19480
'use strict';
19481
19482
/**
19483
* `charCode` represents the actual "character code" and is safe to use with
19484
* `String.fromCharCode`. As such, only keys that correspond to printable
19485
* characters produce a valid `charCode`, the only exception to this is Enter.
19486
* The Tab-key is considered non-printable and does not have a `charCode`,
19487
* presumably because it does not produce a tab-character in browsers.
19488
*
19489
* @param {object} nativeEvent Native browser event.
19490
* @return {string} Normalized `charCode` property.
19491
*/
19492
function getEventCharCode(nativeEvent) {
19493
var charCode;
19494
var keyCode = nativeEvent.keyCode;
19495
19496
if ('charCode' in nativeEvent) {
19497
charCode = nativeEvent.charCode;
19498
19499
// FF does not set `charCode` for the Enter-key, check against `keyCode`.
19500
if (charCode === 0 && keyCode === 13) {
19501
charCode = 13;
19502
}
19503
} else {
19504
// IE8 does not implement `charCode`, but `keyCode` has the correct value.
19505
charCode = keyCode;
19506
}
19507
19508
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
19509
// Must not discard the (non-)printable Enter-key.
19510
if (charCode >= 32 || charCode === 13) {
19511
return charCode;
19512
}
19513
19514
return 0;
19515
}
19516
19517
module.exports = getEventCharCode;
19518
19519
},{}],138:[function(_dereq_,module,exports){
19520
/**
19521
* Copyright 2013-2015, Facebook, Inc.
19522
* All rights reserved.
19523
*
19524
* This source code is licensed under the BSD-style license found in the
19525
* LICENSE file in the root directory of this source tree. An additional grant
19526
* of patent rights can be found in the PATENTS file in the same directory.
19527
*
19528
* @providesModule getEventKey
19529
* @typechecks static-only
19530
*/
19531
19532
'use strict';
19533
19534
var getEventCharCode = _dereq_(137);
19535
19536
/**
19537
* Normalization of deprecated HTML5 `key` values
19538
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
19539
*/
19540
var normalizeKey = {
19541
'Esc': 'Escape',
19542
'Spacebar': ' ',
19543
'Left': 'ArrowLeft',
19544
'Up': 'ArrowUp',
19545
'Right': 'ArrowRight',
19546
'Down': 'ArrowDown',
19547
'Del': 'Delete',
19548
'Win': 'OS',
19549
'Menu': 'ContextMenu',
19550
'Apps': 'ContextMenu',
19551
'Scroll': 'ScrollLock',
19552
'MozPrintableKey': 'Unidentified'
19553
};
19554
19555
/**
19556
* Translation from legacy `keyCode` to HTML5 `key`
19557
* Only special keys supported, all others depend on keyboard layout or browser
19558
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
19559
*/
19560
var translateToKey = {
19561
8: 'Backspace',
19562
9: 'Tab',
19563
12: 'Clear',
19564
13: 'Enter',
19565
16: 'Shift',
19566
17: 'Control',
19567
18: 'Alt',
19568
19: 'Pause',
19569
20: 'CapsLock',
19570
27: 'Escape',
19571
32: ' ',
19572
33: 'PageUp',
19573
34: 'PageDown',
19574
35: 'End',
19575
36: 'Home',
19576
37: 'ArrowLeft',
19577
38: 'ArrowUp',
19578
39: 'ArrowRight',
19579
40: 'ArrowDown',
19580
45: 'Insert',
19581
46: 'Delete',
19582
112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
19583
118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
19584
144: 'NumLock',
19585
145: 'ScrollLock',
19586
224: 'Meta'
19587
};
19588
19589
/**
19590
* @param {object} nativeEvent Native browser event.
19591
* @return {string} Normalized `key` property.
19592
*/
19593
function getEventKey(nativeEvent) {
19594
if (nativeEvent.key) {
19595
// Normalize inconsistent values reported by browsers due to
19596
// implementations of a working draft specification.
19597
19598
// FireFox implements `key` but returns `MozPrintableKey` for all
19599
// printable characters (normalized to `Unidentified`), ignore it.
19600
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
19601
if (key !== 'Unidentified') {
19602
return key;
19603
}
19604
}
19605
19606
// Browser does not implement `key`, polyfill as much of it as we can.
19607
if (nativeEvent.type === 'keypress') {
19608
var charCode = getEventCharCode(nativeEvent);
19609
19610
// The enter-key is technically both printable and non-printable and can
19611
// thus be captured by `keypress`, no other non-printable key should.
19612
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
19613
}
19614
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
19615
// While user keyboard layout determines the actual meaning of each
19616
// `keyCode` value, almost all function keys have a universal value.
19617
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
19618
}
19619
return '';
19620
}
19621
19622
module.exports = getEventKey;
19623
19624
},{"137":137}],139:[function(_dereq_,module,exports){
19625
/**
19626
* Copyright 2013-2015, Facebook, Inc.
19627
* All rights reserved.
19628
*
19629
* This source code is licensed under the BSD-style license found in the
19630
* LICENSE file in the root directory of this source tree. An additional grant
19631
* of patent rights can be found in the PATENTS file in the same directory.
19632
*
19633
* @providesModule getEventModifierState
19634
* @typechecks static-only
19635
*/
19636
19637
'use strict';
19638
19639
/**
19640
* Translation from modifier key to the associated property in the event.
19641
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
19642
*/
19643
19644
var modifierKeyToProp = {
19645
'Alt': 'altKey',
19646
'Control': 'ctrlKey',
19647
'Meta': 'metaKey',
19648
'Shift': 'shiftKey'
19649
};
19650
19651
// IE8 does not implement getModifierState so we simply map it to the only
19652
// modifier keys exposed by the event itself, does not support Lock-keys.
19653
// Currently, all major browsers except Chrome seems to support Lock-keys.
19654
function modifierStateGetter(keyArg) {
19655
/*jshint validthis:true */
19656
var syntheticEvent = this;
19657
var nativeEvent = syntheticEvent.nativeEvent;
19658
if (nativeEvent.getModifierState) {
19659
return nativeEvent.getModifierState(keyArg);
19660
}
19661
var keyProp = modifierKeyToProp[keyArg];
19662
return keyProp ? !!nativeEvent[keyProp] : false;
19663
}
19664
19665
function getEventModifierState(nativeEvent) {
19666
return modifierStateGetter;
19667
}
19668
19669
module.exports = getEventModifierState;
19670
19671
},{}],140:[function(_dereq_,module,exports){
19672
/**
19673
* Copyright 2013-2015, Facebook, Inc.
19674
* All rights reserved.
19675
*
19676
* This source code is licensed under the BSD-style license found in the
19677
* LICENSE file in the root directory of this source tree. An additional grant
19678
* of patent rights can be found in the PATENTS file in the same directory.
19679
*
19680
* @providesModule getEventTarget
19681
* @typechecks static-only
19682
*/
19683
19684
'use strict';
19685
19686
/**
19687
* Gets the target node from a native browser event by accounting for
19688
* inconsistencies in browser DOM APIs.
19689
*
19690
* @param {object} nativeEvent Native browser event.
19691
* @return {DOMEventTarget} Target node.
19692
*/
19693
function getEventTarget(nativeEvent) {
19694
var target = nativeEvent.target || nativeEvent.srcElement || window;
19695
// Safari may fire events on text nodes (Node.TEXT_NODE is 3).
19696
// @see http://www.quirksmode.org/js/events_properties.html
19697
return target.nodeType === 3 ? target.parentNode : target;
19698
}
19699
19700
module.exports = getEventTarget;
19701
19702
},{}],141:[function(_dereq_,module,exports){
19703
/**
19704
* Copyright 2013-2015, Facebook, Inc.
19705
* All rights reserved.
19706
*
19707
* This source code is licensed under the BSD-style license found in the
19708
* LICENSE file in the root directory of this source tree. An additional grant
19709
* of patent rights can be found in the PATENTS file in the same directory.
19710
*
19711
* @providesModule getIteratorFn
19712
* @typechecks static-only
19713
*/
19714
19715
'use strict';
19716
19717
/* global Symbol */
19718
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
19719
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
19720
19721
/**
19722
* Returns the iterator method function contained on the iterable object.
19723
*
19724
* Be sure to invoke the function with the iterable as context:
19725
*
19726
* var iteratorFn = getIteratorFn(myIterable);
19727
* if (iteratorFn) {
19728
* var iterator = iteratorFn.call(myIterable);
19729
* ...
19730
* }
19731
*
19732
* @param {?object} maybeIterable
19733
* @return {?function}
19734
*/
19735
function getIteratorFn(maybeIterable) {
19736
var iteratorFn = maybeIterable && (
19737
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
19738
);
19739
if (typeof iteratorFn === 'function') {
19740
return iteratorFn;
19741
}
19742
}
19743
19744
module.exports = getIteratorFn;
19745
19746
},{}],142:[function(_dereq_,module,exports){
19747
/**
19748
* Copyright 2013-2015, Facebook, Inc.
19749
* All rights reserved.
19750
*
19751
* This source code is licensed under the BSD-style license found in the
19752
* LICENSE file in the root directory of this source tree. An additional grant
19753
* of patent rights can be found in the PATENTS file in the same directory.
19754
*
19755
* @providesModule getMarkupWrap
19756
*/
19757
19758
var ExecutionEnvironment = _dereq_(22);
19759
19760
var invariant = _dereq_(150);
19761
19762
/**
19763
* Dummy container used to detect which wraps are necessary.
19764
*/
19765
var dummyNode =
19766
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
19767
19768
/**
19769
* Some browsers cannot use `innerHTML` to render certain elements standalone,
19770
* so we wrap them, render the wrapped nodes, then extract the desired node.
19771
*
19772
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
19773
*/
19774
var shouldWrap = {
19775
// Force wrapping for SVG elements because if they get created inside a <div>,
19776
// they will be initialized in the wrong namespace (and will not display).
19777
'circle': true,
19778
'clipPath': true,
19779
'defs': true,
19780
'ellipse': true,
19781
'g': true,
19782
'line': true,
19783
'linearGradient': true,
19784
'path': true,
19785
'polygon': true,
19786
'polyline': true,
19787
'radialGradient': true,
19788
'rect': true,
19789
'stop': true,
19790
'text': true
19791
};
19792
19793
var selectWrap = [1, '<select multiple="true">', '</select>'];
19794
var tableWrap = [1, '<table>', '</table>'];
19795
var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
19796
19797
var svgWrap = [1, '<svg>', '</svg>'];
19798
19799
var markupWrap = {
19800
'*': [1, '?<div>', '</div>'],
19801
19802
'area': [1, '<map>', '</map>'],
19803
'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
19804
'legend': [1, '<fieldset>', '</fieldset>'],
19805
'param': [1, '<object>', '</object>'],
19806
'tr': [2, '<table><tbody>', '</tbody></table>'],
19807
19808
'optgroup': selectWrap,
19809
'option': selectWrap,
19810
19811
'caption': tableWrap,
19812
'colgroup': tableWrap,
19813
'tbody': tableWrap,
19814
'tfoot': tableWrap,
19815
'thead': tableWrap,
19816
19817
'td': trWrap,
19818
'th': trWrap,
19819
19820
'circle': svgWrap,
19821
'clipPath': svgWrap,
19822
'defs': svgWrap,
19823
'ellipse': svgWrap,
19824
'g': svgWrap,
19825
'line': svgWrap,
19826
'linearGradient': svgWrap,
19827
'path': svgWrap,
19828
'polygon': svgWrap,
19829
'polyline': svgWrap,
19830
'radialGradient': svgWrap,
19831
'rect': svgWrap,
19832
'stop': svgWrap,
19833
'text': svgWrap
19834
};
19835
19836
/**
19837
* Gets the markup wrap configuration for the supplied `nodeName`.
19838
*
19839
* NOTE: This lazily detects which wraps are necessary for the current browser.
19840
*
19841
* @param {string} nodeName Lowercase `nodeName`.
19842
* @return {?array} Markup wrap configuration, if applicable.
19843
*/
19844
function getMarkupWrap(nodeName) {
19845
("production" !== "development" ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
19846
if (!markupWrap.hasOwnProperty(nodeName)) {
19847
nodeName = '*';
19848
}
19849
if (!shouldWrap.hasOwnProperty(nodeName)) {
19850
if (nodeName === '*') {
19851
dummyNode.innerHTML = '<link />';
19852
} else {
19853
dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
19854
}
19855
shouldWrap[nodeName] = !dummyNode.firstChild;
19856
}
19857
return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
19858
}
19859
19860
19861
module.exports = getMarkupWrap;
19862
19863
},{"150":150,"22":22}],143:[function(_dereq_,module,exports){
19864
/**
19865
* Copyright 2013-2015, Facebook, Inc.
19866
* All rights reserved.
19867
*
19868
* This source code is licensed under the BSD-style license found in the
19869
* LICENSE file in the root directory of this source tree. An additional grant
19870
* of patent rights can be found in the PATENTS file in the same directory.
19871
*
19872
* @providesModule getNodeForCharacterOffset
19873
*/
19874
19875
'use strict';
19876
19877
/**
19878
* Given any node return the first leaf node without children.
19879
*
19880
* @param {DOMElement|DOMTextNode} node
19881
* @return {DOMElement|DOMTextNode}
19882
*/
19883
function getLeafNode(node) {
19884
while (node && node.firstChild) {
19885
node = node.firstChild;
19886
}
19887
return node;
19888
}
19889
19890
/**
19891
* Get the next sibling within a container. This will walk up the
19892
* DOM if a node's siblings have been exhausted.
19893
*
19894
* @param {DOMElement|DOMTextNode} node
19895
* @return {?DOMElement|DOMTextNode}
19896
*/
19897
function getSiblingNode(node) {
19898
while (node) {
19899
if (node.nextSibling) {
19900
return node.nextSibling;
19901
}
19902
node = node.parentNode;
19903
}
19904
}
19905
19906
/**
19907
* Get object describing the nodes which contain characters at offset.
19908
*
19909
* @param {DOMElement|DOMTextNode} root
19910
* @param {number} offset
19911
* @return {?object}
19912
*/
19913
function getNodeForCharacterOffset(root, offset) {
19914
var node = getLeafNode(root);
19915
var nodeStart = 0;
19916
var nodeEnd = 0;
19917
19918
while (node) {
19919
if (node.nodeType === 3) {
19920
nodeEnd = nodeStart + node.textContent.length;
19921
19922
if (nodeStart <= offset && nodeEnd >= offset) {
19923
return {
19924
node: node,
19925
offset: offset - nodeStart
19926
};
19927
}
19928
19929
nodeStart = nodeEnd;
19930
}
19931
19932
node = getLeafNode(getSiblingNode(node));
19933
}
19934
}
19935
19936
module.exports = getNodeForCharacterOffset;
19937
19938
},{}],144:[function(_dereq_,module,exports){
19939
/**
19940
* Copyright 2013-2015, Facebook, Inc.
19941
* All rights reserved.
19942
*
19943
* This source code is licensed under the BSD-style license found in the
19944
* LICENSE file in the root directory of this source tree. An additional grant
19945
* of patent rights can be found in the PATENTS file in the same directory.
19946
*
19947
* @providesModule getReactRootElementInContainer
19948
*/
19949
19950
'use strict';
19951
19952
var DOC_NODE_TYPE = 9;
19953
19954
/**
19955
* @param {DOMElement|DOMDocument} container DOM element that may contain
19956
* a React component
19957
* @return {?*} DOM element that may have the reactRoot ID, or null.
19958
*/
19959
function getReactRootElementInContainer(container) {
19960
if (!container) {
19961
return null;
19962
}
19963
19964
if (container.nodeType === DOC_NODE_TYPE) {
19965
return container.documentElement;
19966
} else {
19967
return container.firstChild;
19968
}
19969
}
19970
19971
module.exports = getReactRootElementInContainer;
19972
19973
},{}],145:[function(_dereq_,module,exports){
19974
/**
19975
* Copyright 2013-2015, Facebook, Inc.
19976
* All rights reserved.
19977
*
19978
* This source code is licensed under the BSD-style license found in the
19979
* LICENSE file in the root directory of this source tree. An additional grant
19980
* of patent rights can be found in the PATENTS file in the same directory.
19981
*
19982
* @providesModule getTextContentAccessor
19983
*/
19984
19985
'use strict';
19986
19987
var ExecutionEnvironment = _dereq_(22);
19988
19989
var contentKey = null;
19990
19991
/**
19992
* Gets the key used to access text content on a DOM node.
19993
*
19994
* @return {?string} Key used to access text content.
19995
* @internal
19996
*/
19997
function getTextContentAccessor() {
19998
if (!contentKey && ExecutionEnvironment.canUseDOM) {
19999
// Prefer textContent to innerText because many browsers support both but
20000
// SVG <text> elements don't support innerText even when <div> does.
20001
contentKey = 'textContent' in document.documentElement ?
20002
'textContent' :
20003
'innerText';
20004
}
20005
return contentKey;
20006
}
20007
20008
module.exports = getTextContentAccessor;
20009
20010
},{"22":22}],146:[function(_dereq_,module,exports){
20011
/**
20012
* Copyright 2013-2015, Facebook, Inc.
20013
* All rights reserved.
20014
*
20015
* This source code is licensed under the BSD-style license found in the
20016
* LICENSE file in the root directory of this source tree. An additional grant
20017
* of patent rights can be found in the PATENTS file in the same directory.
20018
*
20019
* @providesModule getUnboundedScrollPosition
20020
* @typechecks
20021
*/
20022
20023
"use strict";
20024
20025
/**
20026
* Gets the scroll position of the supplied element or window.
20027
*
20028
* The return values are unbounded, unlike `getScrollPosition`. This means they
20029
* may be negative or exceed the element boundaries (which is possible using
20030
* inertial scrolling).
20031
*
20032
* @param {DOMWindow|DOMElement} scrollable
20033
* @return {object} Map with `x` and `y` keys.
20034
*/
20035
function getUnboundedScrollPosition(scrollable) {
20036
if (scrollable === window) {
20037
return {
20038
x: window.pageXOffset || document.documentElement.scrollLeft,
20039
y: window.pageYOffset || document.documentElement.scrollTop
20040
};
20041
}
20042
return {
20043
x: scrollable.scrollLeft,
20044
y: scrollable.scrollTop
20045
};
20046
}
20047
20048
module.exports = getUnboundedScrollPosition;
20049
20050
},{}],147:[function(_dereq_,module,exports){
20051
/**
20052
* Copyright 2013-2015, Facebook, Inc.
20053
* All rights reserved.
20054
*
20055
* This source code is licensed under the BSD-style license found in the
20056
* LICENSE file in the root directory of this source tree. An additional grant
20057
* of patent rights can be found in the PATENTS file in the same directory.
20058
*
20059
* @providesModule hyphenate
20060
* @typechecks
20061
*/
20062
20063
var _uppercasePattern = /([A-Z])/g;
20064
20065
/**
20066
* Hyphenates a camelcased string, for example:
20067
*
20068
* > hyphenate('backgroundColor')
20069
* < "background-color"
20070
*
20071
* For CSS style names, use `hyphenateStyleName` instead which works properly
20072
* with all vendor prefixes, including `ms`.
20073
*
20074
* @param {string} string
20075
* @return {string}
20076
*/
20077
function hyphenate(string) {
20078
return string.replace(_uppercasePattern, '-$1').toLowerCase();
20079
}
20080
20081
module.exports = hyphenate;
20082
20083
},{}],148:[function(_dereq_,module,exports){
20084
/**
20085
* Copyright 2013-2015, Facebook, Inc.
20086
* All rights reserved.
20087
*
20088
* This source code is licensed under the BSD-style license found in the
20089
* LICENSE file in the root directory of this source tree. An additional grant
20090
* of patent rights can be found in the PATENTS file in the same directory.
20091
*
20092
* @providesModule hyphenateStyleName
20093
* @typechecks
20094
*/
20095
20096
"use strict";
20097
20098
var hyphenate = _dereq_(147);
20099
20100
var msPattern = /^ms-/;
20101
20102
/**
20103
* Hyphenates a camelcased CSS property name, for example:
20104
*
20105
* > hyphenateStyleName('backgroundColor')
20106
* < "background-color"
20107
* > hyphenateStyleName('MozTransition')
20108
* < "-moz-transition"
20109
* > hyphenateStyleName('msTransition')
20110
* < "-ms-transition"
20111
*
20112
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
20113
* is converted to `-ms-`.
20114
*
20115
* @param {string} string
20116
* @return {string}
20117
*/
20118
function hyphenateStyleName(string) {
20119
return hyphenate(string).replace(msPattern, '-ms-');
20120
}
20121
20122
module.exports = hyphenateStyleName;
20123
20124
},{"147":147}],149:[function(_dereq_,module,exports){
20125
/**
20126
* Copyright 2013-2015, Facebook, Inc.
20127
* All rights reserved.
20128
*
20129
* This source code is licensed under the BSD-style license found in the
20130
* LICENSE file in the root directory of this source tree. An additional grant
20131
* of patent rights can be found in the PATENTS file in the same directory.
20132
*
20133
* @providesModule instantiateReactComponent
20134
* @typechecks static-only
20135
*/
20136
20137
'use strict';
20138
20139
var ReactCompositeComponent = _dereq_(43);
20140
var ReactEmptyComponent = _dereq_(65);
20141
var ReactNativeComponent = _dereq_(80);
20142
20143
var assign = _dereq_(29);
20144
var invariant = _dereq_(150);
20145
var warning = _dereq_(171);
20146
20147
// To avoid a cyclic dependency, we create the final class in this module
20148
var ReactCompositeComponentWrapper = function() { };
20149
assign(
20150
ReactCompositeComponentWrapper.prototype,
20151
ReactCompositeComponent.Mixin,
20152
{
20153
_instantiateReactComponent: instantiateReactComponent
20154
}
20155
);
20156
20157
/**
20158
* Check if the type reference is a known internal type. I.e. not a user
20159
* provided composite type.
20160
*
20161
* @param {function} type
20162
* @return {boolean} Returns true if this is a valid internal type.
20163
*/
20164
function isInternalComponentType(type) {
20165
return (
20166
typeof type === 'function' &&
20167
typeof type.prototype !== 'undefined' &&
20168
typeof type.prototype.mountComponent === 'function' &&
20169
typeof type.prototype.receiveComponent === 'function'
20170
);
20171
}
20172
20173
/**
20174
* Given a ReactNode, create an instance that will actually be mounted.
20175
*
20176
* @param {ReactNode} node
20177
* @param {*} parentCompositeType The composite type that resolved this.
20178
* @return {object} A new instance of the element's constructor.
20179
* @protected
20180
*/
20181
function instantiateReactComponent(node, parentCompositeType) {
20182
var instance;
20183
20184
if (node === null || node === false) {
20185
node = ReactEmptyComponent.emptyElement;
20186
}
20187
20188
if (typeof node === 'object') {
20189
var element = node;
20190
if ("production" !== "development") {
20191
("production" !== "development" ? warning(
20192
element && (typeof element.type === 'function' ||
20193
typeof element.type === 'string'),
20194
'Only functions or strings can be mounted as React components.'
20195
) : null);
20196
}
20197
20198
// Special case string values
20199
if (parentCompositeType === element.type &&
20200
typeof element.type === 'string') {
20201
// Avoid recursion if the wrapper renders itself.
20202
instance = ReactNativeComponent.createInternalComponent(element);
20203
// All native components are currently wrapped in a composite so we're
20204
// safe to assume that this is what we should instantiate.
20205
} else if (isInternalComponentType(element.type)) {
20206
// This is temporarily available for custom components that are not string
20207
// represenations. I.e. ART. Once those are updated to use the string
20208
// representation, we can drop this code path.
20209
instance = new element.type(element);
20210
} else {
20211
instance = new ReactCompositeComponentWrapper();
20212
}
20213
} else if (typeof node === 'string' || typeof node === 'number') {
20214
instance = ReactNativeComponent.createInstanceForText(node);
20215
} else {
20216
("production" !== "development" ? invariant(
20217
false,
20218
'Encountered invalid React node of type %s',
20219
typeof node
20220
) : invariant(false));
20221
}
20222
20223
if ("production" !== "development") {
20224
("production" !== "development" ? warning(
20225
typeof instance.construct === 'function' &&
20226
typeof instance.mountComponent === 'function' &&
20227
typeof instance.receiveComponent === 'function' &&
20228
typeof instance.unmountComponent === 'function',
20229
'Only React Components can be mounted.'
20230
) : null);
20231
}
20232
20233
// Sets up the instance. This can probably just move into the constructor now.
20234
instance.construct(node);
20235
20236
// These two fields are used by the DOM and ART diffing algorithms
20237
// respectively. Instead of using expandos on components, we should be
20238
// storing the state needed by the diffing algorithms elsewhere.
20239
instance._mountIndex = 0;
20240
instance._mountImage = null;
20241
20242
if ("production" !== "development") {
20243
instance._isOwnerNecessary = false;
20244
instance._warnedAboutRefsInRender = false;
20245
}
20246
20247
// Internal instances should fully constructed at this point, so they should
20248
// not get any new fields added to them at this point.
20249
if ("production" !== "development") {
20250
if (Object.preventExtensions) {
20251
Object.preventExtensions(instance);
20252
}
20253
}
20254
20255
return instance;
20256
}
20257
20258
module.exports = instantiateReactComponent;
20259
20260
},{"150":150,"171":171,"29":29,"43":43,"65":65,"80":80}],150:[function(_dereq_,module,exports){
20261
/**
20262
* Copyright 2013-2015, Facebook, Inc.
20263
* All rights reserved.
20264
*
20265
* This source code is licensed under the BSD-style license found in the
20266
* LICENSE file in the root directory of this source tree. An additional grant
20267
* of patent rights can be found in the PATENTS file in the same directory.
20268
*
20269
* @providesModule invariant
20270
*/
20271
20272
"use strict";
20273
20274
/**
20275
* Use invariant() to assert state which your program assumes to be true.
20276
*
20277
* Provide sprintf-style format (only %s is supported) and arguments
20278
* to provide information about what broke and what you were
20279
* expecting.
20280
*
20281
* The invariant message will be stripped in production, but the invariant
20282
* will remain to ensure logic does not differ in production.
20283
*/
20284
20285
var invariant = function(condition, format, a, b, c, d, e, f) {
20286
if ("production" !== "development") {
20287
if (format === undefined) {
20288
throw new Error('invariant requires an error message argument');
20289
}
20290
}
20291
20292
if (!condition) {
20293
var error;
20294
if (format === undefined) {
20295
error = new Error(
20296
'Minified exception occurred; use the non-minified dev environment ' +
20297
'for the full error message and additional helpful warnings.'
20298
);
20299
} else {
20300
var args = [a, b, c, d, e, f];
20301
var argIndex = 0;
20302
error = new Error(
20303
'Invariant Violation: ' +
20304
format.replace(/%s/g, function() { return args[argIndex++]; })
20305
);
20306
}
20307
20308
error.framesToPop = 1; // we don't care about invariant's own frame
20309
throw error;
20310
}
20311
};
20312
20313
module.exports = invariant;
20314
20315
},{}],151:[function(_dereq_,module,exports){
20316
/**
20317
* Copyright 2013-2015, Facebook, Inc.
20318
* All rights reserved.
20319
*
20320
* This source code is licensed under the BSD-style license found in the
20321
* LICENSE file in the root directory of this source tree. An additional grant
20322
* of patent rights can be found in the PATENTS file in the same directory.
20323
*
20324
* @providesModule isEventSupported
20325
*/
20326
20327
'use strict';
20328
20329
var ExecutionEnvironment = _dereq_(22);
20330
20331
var useHasFeature;
20332
if (ExecutionEnvironment.canUseDOM) {
20333
useHasFeature =
20334
document.implementation &&
20335
document.implementation.hasFeature &&
20336
// always returns true in newer browsers as per the standard.
20337
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
20338
document.implementation.hasFeature('', '') !== true;
20339
}
20340
20341
/**
20342
* Checks if an event is supported in the current execution environment.
20343
*
20344
* NOTE: This will not work correctly for non-generic events such as `change`,
20345
* `reset`, `load`, `error`, and `select`.
20346
*
20347
* Borrows from Modernizr.
20348
*
20349
* @param {string} eventNameSuffix Event name, e.g. "click".
20350
* @param {?boolean} capture Check if the capture phase is supported.
20351
* @return {boolean} True if the event is supported.
20352
* @internal
20353
* @license Modernizr 3.0.0pre (Custom Build) | MIT
20354
*/
20355
function isEventSupported(eventNameSuffix, capture) {
20356
if (!ExecutionEnvironment.canUseDOM ||
20357
capture && !('addEventListener' in document)) {
20358
return false;
20359
}
20360
20361
var eventName = 'on' + eventNameSuffix;
20362
var isSupported = eventName in document;
20363
20364
if (!isSupported) {
20365
var element = document.createElement('div');
20366
element.setAttribute(eventName, 'return;');
20367
isSupported = typeof element[eventName] === 'function';
20368
}
20369
20370
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
20371
// This is the only way to test support for the `wheel` event in IE9+.
20372
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
20373
}
20374
20375
return isSupported;
20376
}
20377
20378
module.exports = isEventSupported;
20379
20380
},{"22":22}],152:[function(_dereq_,module,exports){
20381
/**
20382
* Copyright 2013-2015, Facebook, Inc.
20383
* All rights reserved.
20384
*
20385
* This source code is licensed under the BSD-style license found in the
20386
* LICENSE file in the root directory of this source tree. An additional grant
20387
* of patent rights can be found in the PATENTS file in the same directory.
20388
*
20389
* @providesModule isNode
20390
* @typechecks
20391
*/
20392
20393
/**
20394
* @param {*} object The object to check.
20395
* @return {boolean} Whether or not the object is a DOM node.
20396
*/
20397
function isNode(object) {
20398
return !!(object && (
20399
((typeof Node === 'function' ? object instanceof Node : typeof object === 'object' &&
20400
typeof object.nodeType === 'number' &&
20401
typeof object.nodeName === 'string'))
20402
));
20403
}
20404
20405
module.exports = isNode;
20406
20407
},{}],153:[function(_dereq_,module,exports){
20408
/**
20409
* Copyright 2013-2015, Facebook, Inc.
20410
* All rights reserved.
20411
*
20412
* This source code is licensed under the BSD-style license found in the
20413
* LICENSE file in the root directory of this source tree. An additional grant
20414
* of patent rights can be found in the PATENTS file in the same directory.
20415
*
20416
* @providesModule isTextInputElement
20417
*/
20418
20419
'use strict';
20420
20421
/**
20422
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
20423
*/
20424
var supportedInputTypes = {
20425
'color': true,
20426
'date': true,
20427
'datetime': true,
20428
'datetime-local': true,
20429
'email': true,
20430
'month': true,
20431
'number': true,
20432
'password': true,
20433
'range': true,
20434
'search': true,
20435
'tel': true,
20436
'text': true,
20437
'time': true,
20438
'url': true,
20439
'week': true
20440
};
20441
20442
function isTextInputElement(elem) {
20443
return elem && (
20444
(elem.nodeName === 'INPUT' && supportedInputTypes[elem.type] || elem.nodeName === 'TEXTAREA')
20445
);
20446
}
20447
20448
module.exports = isTextInputElement;
20449
20450
},{}],154:[function(_dereq_,module,exports){
20451
/**
20452
* Copyright 2013-2015, Facebook, Inc.
20453
* All rights reserved.
20454
*
20455
* This source code is licensed under the BSD-style license found in the
20456
* LICENSE file in the root directory of this source tree. An additional grant
20457
* of patent rights can be found in the PATENTS file in the same directory.
20458
*
20459
* @providesModule isTextNode
20460
* @typechecks
20461
*/
20462
20463
var isNode = _dereq_(152);
20464
20465
/**
20466
* @param {*} object The object to check.
20467
* @return {boolean} Whether or not the object is a DOM text node.
20468
*/
20469
function isTextNode(object) {
20470
return isNode(object) && object.nodeType == 3;
20471
}
20472
20473
module.exports = isTextNode;
20474
20475
},{"152":152}],155:[function(_dereq_,module,exports){
20476
/**
20477
* Copyright 2013-2015, Facebook, Inc.
20478
* All rights reserved.
20479
*
20480
* This source code is licensed under the BSD-style license found in the
20481
* LICENSE file in the root directory of this source tree. An additional grant
20482
* of patent rights can be found in the PATENTS file in the same directory.
20483
*
20484
* @providesModule joinClasses
20485
* @typechecks static-only
20486
*/
20487
20488
'use strict';
20489
20490
/**
20491
* Combines multiple className strings into one.
20492
* http://jsperf.com/joinclasses-args-vs-array
20493
*
20494
* @param {...?string} classes
20495
* @return {string}
20496
*/
20497
function joinClasses(className/*, ... */) {
20498
if (!className) {
20499
className = '';
20500
}
20501
var nextClass;
20502
var argLength = arguments.length;
20503
if (argLength > 1) {
20504
for (var ii = 1; ii < argLength; ii++) {
20505
nextClass = arguments[ii];
20506
if (nextClass) {
20507
className = (className ? className + ' ' : '') + nextClass;
20508
}
20509
}
20510
}
20511
return className;
20512
}
20513
20514
module.exports = joinClasses;
20515
20516
},{}],156:[function(_dereq_,module,exports){
20517
/**
20518
* Copyright 2013-2015, Facebook, Inc.
20519
* All rights reserved.
20520
*
20521
* This source code is licensed under the BSD-style license found in the
20522
* LICENSE file in the root directory of this source tree. An additional grant
20523
* of patent rights can be found in the PATENTS file in the same directory.
20524
*
20525
* @providesModule keyMirror
20526
* @typechecks static-only
20527
*/
20528
20529
'use strict';
20530
20531
var invariant = _dereq_(150);
20532
20533
/**
20534
* Constructs an enumeration with keys equal to their value.
20535
*
20536
* For example:
20537
*
20538
* var COLORS = keyMirror({blue: null, red: null});
20539
* var myColor = COLORS.blue;
20540
* var isColorValid = !!COLORS[myColor];
20541
*
20542
* The last line could not be performed if the values of the generated enum were
20543
* not equal to their keys.
20544
*
20545
* Input: {key1: val1, key2: val2}
20546
* Output: {key1: key1, key2: key2}
20547
*
20548
* @param {object} obj
20549
* @return {object}
20550
*/
20551
var keyMirror = function(obj) {
20552
var ret = {};
20553
var key;
20554
("production" !== "development" ? invariant(
20555
obj instanceof Object && !Array.isArray(obj),
20556
'keyMirror(...): Argument must be an object.'
20557
) : invariant(obj instanceof Object && !Array.isArray(obj)));
20558
for (key in obj) {
20559
if (!obj.hasOwnProperty(key)) {
20560
continue;
20561
}
20562
ret[key] = key;
20563
}
20564
return ret;
20565
};
20566
20567
module.exports = keyMirror;
20568
20569
},{"150":150}],157:[function(_dereq_,module,exports){
20570
/**
20571
* Copyright 2013-2015, Facebook, Inc.
20572
* All rights reserved.
20573
*
20574
* This source code is licensed under the BSD-style license found in the
20575
* LICENSE file in the root directory of this source tree. An additional grant
20576
* of patent rights can be found in the PATENTS file in the same directory.
20577
*
20578
* @providesModule keyOf
20579
*/
20580
20581
/**
20582
* Allows extraction of a minified key. Let's the build system minify keys
20583
* without loosing the ability to dynamically use key strings as values
20584
* themselves. Pass in an object with a single key/val pair and it will return
20585
* you the string key of that single record. Suppose you want to grab the
20586
* value for a key 'className' inside of an object. Key/val minification may
20587
* have aliased that key to be 'xa12'. keyOf({className: null}) will return
20588
* 'xa12' in that case. Resolve keys you want to use once at startup time, then
20589
* reuse those resolutions.
20590
*/
20591
var keyOf = function(oneKeyObj) {
20592
var key;
20593
for (key in oneKeyObj) {
20594
if (!oneKeyObj.hasOwnProperty(key)) {
20595
continue;
20596
}
20597
return key;
20598
}
20599
return null;
20600
};
20601
20602
20603
module.exports = keyOf;
20604
20605
},{}],158:[function(_dereq_,module,exports){
20606
/**
20607
* Copyright 2013-2015, Facebook, Inc.
20608
* All rights reserved.
20609
*
20610
* This source code is licensed under the BSD-style license found in the
20611
* LICENSE file in the root directory of this source tree. An additional grant
20612
* of patent rights can be found in the PATENTS file in the same directory.
20613
*
20614
* @providesModule mapObject
20615
*/
20616
20617
'use strict';
20618
20619
var hasOwnProperty = Object.prototype.hasOwnProperty;
20620
20621
/**
20622
* Executes the provided `callback` once for each enumerable own property in the
20623
* object and constructs a new object from the results. The `callback` is
20624
* invoked with three arguments:
20625
*
20626
* - the property value
20627
* - the property name
20628
* - the object being traversed
20629
*
20630
* Properties that are added after the call to `mapObject` will not be visited
20631
* by `callback`. If the values of existing properties are changed, the value
20632
* passed to `callback` will be the value at the time `mapObject` visits them.
20633
* Properties that are deleted before being visited are not visited.
20634
*
20635
* @grep function objectMap()
20636
* @grep function objMap()
20637
*
20638
* @param {?object} object
20639
* @param {function} callback
20640
* @param {*} context
20641
* @return {?object}
20642
*/
20643
function mapObject(object, callback, context) {
20644
if (!object) {
20645
return null;
20646
}
20647
var result = {};
20648
for (var name in object) {
20649
if (hasOwnProperty.call(object, name)) {
20650
result[name] = callback.call(context, object[name], name, object);
20651
}
20652
}
20653
return result;
20654
}
20655
20656
module.exports = mapObject;
20657
20658
},{}],159:[function(_dereq_,module,exports){
20659
/**
20660
* Copyright 2013-2015, Facebook, Inc.
20661
* All rights reserved.
20662
*
20663
* This source code is licensed under the BSD-style license found in the
20664
* LICENSE file in the root directory of this source tree. An additional grant
20665
* of patent rights can be found in the PATENTS file in the same directory.
20666
*
20667
* @providesModule memoizeStringOnly
20668
* @typechecks static-only
20669
*/
20670
20671
'use strict';
20672
20673
/**
20674
* Memoizes the return value of a function that accepts one string argument.
20675
*
20676
* @param {function} callback
20677
* @return {function}
20678
*/
20679
function memoizeStringOnly(callback) {
20680
var cache = {};
20681
return function(string) {
20682
if (!cache.hasOwnProperty(string)) {
20683
cache[string] = callback.call(this, string);
20684
}
20685
return cache[string];
20686
};
20687
}
20688
20689
module.exports = memoizeStringOnly;
20690
20691
},{}],160:[function(_dereq_,module,exports){
20692
/**
20693
* Copyright 2013-2015, Facebook, Inc.
20694
* All rights reserved.
20695
*
20696
* This source code is licensed under the BSD-style license found in the
20697
* LICENSE file in the root directory of this source tree. An additional grant
20698
* of patent rights can be found in the PATENTS file in the same directory.
20699
*
20700
* @providesModule onlyChild
20701
*/
20702
'use strict';
20703
20704
var ReactElement = _dereq_(63);
20705
20706
var invariant = _dereq_(150);
20707
20708
/**
20709
* Returns the first child in a collection of children and verifies that there
20710
* is only one child in the collection. The current implementation of this
20711
* function assumes that a single child gets passed without a wrapper, but the
20712
* purpose of this helper function is to abstract away the particular structure
20713
* of children.
20714
*
20715
* @param {?object} children Child collection structure.
20716
* @return {ReactComponent} The first and only `ReactComponent` contained in the
20717
* structure.
20718
*/
20719
function onlyChild(children) {
20720
("production" !== "development" ? invariant(
20721
ReactElement.isValidElement(children),
20722
'onlyChild must be passed a children with exactly one child.'
20723
) : invariant(ReactElement.isValidElement(children)));
20724
return children;
20725
}
20726
20727
module.exports = onlyChild;
20728
20729
},{"150":150,"63":63}],161:[function(_dereq_,module,exports){
20730
/**
20731
* Copyright 2013-2015, Facebook, Inc.
20732
* All rights reserved.
20733
*
20734
* This source code is licensed under the BSD-style license found in the
20735
* LICENSE file in the root directory of this source tree. An additional grant
20736
* of patent rights can be found in the PATENTS file in the same directory.
20737
*
20738
* @providesModule performance
20739
* @typechecks
20740
*/
20741
20742
"use strict";
20743
20744
var ExecutionEnvironment = _dereq_(22);
20745
20746
var performance;
20747
20748
if (ExecutionEnvironment.canUseDOM) {
20749
performance =
20750
window.performance ||
20751
window.msPerformance ||
20752
window.webkitPerformance;
20753
}
20754
20755
module.exports = performance || {};
20756
20757
},{"22":22}],162:[function(_dereq_,module,exports){
20758
/**
20759
* Copyright 2013-2015, Facebook, Inc.
20760
* All rights reserved.
20761
*
20762
* This source code is licensed under the BSD-style license found in the
20763
* LICENSE file in the root directory of this source tree. An additional grant
20764
* of patent rights can be found in the PATENTS file in the same directory.
20765
*
20766
* @providesModule performanceNow
20767
* @typechecks
20768
*/
20769
20770
var performance = _dereq_(161);
20771
20772
/**
20773
* Detect if we can use `window.performance.now()` and gracefully fallback to
20774
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
20775
* because of Facebook's testing infrastructure.
20776
*/
20777
if (!performance || !performance.now) {
20778
performance = Date;
20779
}
20780
20781
var performanceNow = performance.now.bind(performance);
20782
20783
module.exports = performanceNow;
20784
20785
},{"161":161}],163:[function(_dereq_,module,exports){
20786
/**
20787
* Copyright 2013-2015, Facebook, Inc.
20788
* All rights reserved.
20789
*
20790
* This source code is licensed under the BSD-style license found in the
20791
* LICENSE file in the root directory of this source tree. An additional grant
20792
* of patent rights can be found in the PATENTS file in the same directory.
20793
*
20794
* @providesModule quoteAttributeValueForBrowser
20795
*/
20796
20797
'use strict';
20798
20799
var escapeTextContentForBrowser = _dereq_(131);
20800
20801
/**
20802
* Escapes attribute value to prevent scripting attacks.
20803
*
20804
* @param {*} value Value to escape.
20805
* @return {string} An escaped string.
20806
*/
20807
function quoteAttributeValueForBrowser(value) {
20808
return '"' + escapeTextContentForBrowser(value) + '"';
20809
}
20810
20811
module.exports = quoteAttributeValueForBrowser;
20812
20813
},{"131":131}],164:[function(_dereq_,module,exports){
20814
/**
20815
* Copyright 2013-2015, Facebook, Inc.
20816
* All rights reserved.
20817
*
20818
* This source code is licensed under the BSD-style license found in the
20819
* LICENSE file in the root directory of this source tree. An additional grant
20820
* of patent rights can be found in the PATENTS file in the same directory.
20821
*
20822
* @providesModule setInnerHTML
20823
*/
20824
20825
/* globals MSApp */
20826
20827
'use strict';
20828
20829
var ExecutionEnvironment = _dereq_(22);
20830
20831
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
20832
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
20833
20834
/**
20835
* Set the innerHTML property of a node, ensuring that whitespace is preserved
20836
* even in IE8.
20837
*
20838
* @param {DOMElement} node
20839
* @param {string} html
20840
* @internal
20841
*/
20842
var setInnerHTML = function(node, html) {
20843
node.innerHTML = html;
20844
};
20845
20846
// Win8 apps: Allow all html to be inserted
20847
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
20848
setInnerHTML = function(node, html) {
20849
MSApp.execUnsafeLocalFunction(function() {
20850
node.innerHTML = html;
20851
});
20852
};
20853
}
20854
20855
if (ExecutionEnvironment.canUseDOM) {
20856
// IE8: When updating a just created node with innerHTML only leading
20857
// whitespace is removed. When updating an existing node with innerHTML
20858
// whitespace in root TextNodes is also collapsed.
20859
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
20860
20861
// Feature detection; only IE8 is known to behave improperly like this.
20862
var testElement = document.createElement('div');
20863
testElement.innerHTML = ' ';
20864
if (testElement.innerHTML === '') {
20865
setInnerHTML = function(node, html) {
20866
// Magic theory: IE8 supposedly differentiates between added and updated
20867
// nodes when processing innerHTML, innerHTML on updated nodes suffers
20868
// from worse whitespace behavior. Re-adding a node like this triggers
20869
// the initial and more favorable whitespace behavior.
20870
// TODO: What to do on a detached node?
20871
if (node.parentNode) {
20872
node.parentNode.replaceChild(node, node);
20873
}
20874
20875
// We also implement a workaround for non-visible tags disappearing into
20876
// thin air on IE8, this only happens if there is no visible text
20877
// in-front of the non-visible tags. Piggyback on the whitespace fix
20878
// and simply check if any non-visible tags appear in the source.
20879
if (WHITESPACE_TEST.test(html) ||
20880
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
20881
// Recover leading whitespace by temporarily prepending any character.
20882
// \uFEFF has the potential advantage of being zero-width/invisible.
20883
node.innerHTML = '\uFEFF' + html;
20884
20885
// deleteData leaves an empty `TextNode` which offsets the index of all
20886
// children. Definitely want to avoid this.
20887
var textNode = node.firstChild;
20888
if (textNode.data.length === 1) {
20889
node.removeChild(textNode);
20890
} else {
20891
textNode.deleteData(0, 1);
20892
}
20893
} else {
20894
node.innerHTML = html;
20895
}
20896
};
20897
}
20898
}
20899
20900
module.exports = setInnerHTML;
20901
20902
},{"22":22}],165:[function(_dereq_,module,exports){
20903
/**
20904
* Copyright 2013-2015, Facebook, Inc.
20905
* All rights reserved.
20906
*
20907
* This source code is licensed under the BSD-style license found in the
20908
* LICENSE file in the root directory of this source tree. An additional grant
20909
* of patent rights can be found in the PATENTS file in the same directory.
20910
*
20911
* @providesModule setTextContent
20912
*/
20913
20914
'use strict';
20915
20916
var ExecutionEnvironment = _dereq_(22);
20917
var escapeTextContentForBrowser = _dereq_(131);
20918
var setInnerHTML = _dereq_(164);
20919
20920
/**
20921
* Set the textContent property of a node, ensuring that whitespace is preserved
20922
* even in IE8. innerText is a poor substitute for textContent and, among many
20923
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
20924
* as it should.
20925
*
20926
* @param {DOMElement} node
20927
* @param {string} text
20928
* @internal
20929
*/
20930
var setTextContent = function(node, text) {
20931
node.textContent = text;
20932
};
20933
20934
if (ExecutionEnvironment.canUseDOM) {
20935
if (!('textContent' in document.documentElement)) {
20936
setTextContent = function(node, text) {
20937
setInnerHTML(node, escapeTextContentForBrowser(text));
20938
};
20939
}
20940
}
20941
20942
module.exports = setTextContent;
20943
20944
},{"131":131,"164":164,"22":22}],166:[function(_dereq_,module,exports){
20945
/**
20946
* Copyright 2013-2015, Facebook, Inc.
20947
* All rights reserved.
20948
*
20949
* This source code is licensed under the BSD-style license found in the
20950
* LICENSE file in the root directory of this source tree. An additional grant
20951
* of patent rights can be found in the PATENTS file in the same directory.
20952
*
20953
* @providesModule shallowEqual
20954
*/
20955
20956
'use strict';
20957
20958
/**
20959
* Performs equality by iterating through keys on an object and returning
20960
* false when any key has values which are not strictly equal between
20961
* objA and objB. Returns true when the values of all keys are strictly equal.
20962
*
20963
* @return {boolean}
20964
*/
20965
function shallowEqual(objA, objB) {
20966
if (objA === objB) {
20967
return true;
20968
}
20969
var key;
20970
// Test for A's keys different from B.
20971
for (key in objA) {
20972
if (objA.hasOwnProperty(key) &&
20973
(!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
20974
return false;
20975
}
20976
}
20977
// Test for B's keys missing from A.
20978
for (key in objB) {
20979
if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
20980
return false;
20981
}
20982
}
20983
return true;
20984
}
20985
20986
module.exports = shallowEqual;
20987
20988
},{}],167:[function(_dereq_,module,exports){
20989
/**
20990
* Copyright 2013-2015, Facebook, Inc.
20991
* All rights reserved.
20992
*
20993
* This source code is licensed under the BSD-style license found in the
20994
* LICENSE file in the root directory of this source tree. An additional grant
20995
* of patent rights can be found in the PATENTS file in the same directory.
20996
*
20997
* @providesModule shouldUpdateReactComponent
20998
* @typechecks static-only
20999
*/
21000
21001
'use strict';
21002
21003
var warning = _dereq_(171);
21004
21005
/**
21006
* Given a `prevElement` and `nextElement`, determines if the existing
21007
* instance should be updated as opposed to being destroyed or replaced by a new
21008
* instance. Both arguments are elements. This ensures that this logic can
21009
* operate on stateless trees without any backing instance.
21010
*
21011
* @param {?object} prevElement
21012
* @param {?object} nextElement
21013
* @return {boolean} True if the existing instance should be updated.
21014
* @protected
21015
*/
21016
function shouldUpdateReactComponent(prevElement, nextElement) {
21017
if (prevElement != null && nextElement != null) {
21018
var prevType = typeof prevElement;
21019
var nextType = typeof nextElement;
21020
if (prevType === 'string' || prevType === 'number') {
21021
return (nextType === 'string' || nextType === 'number');
21022
} else {
21023
if (nextType === 'object' &&
21024
prevElement.type === nextElement.type &&
21025
prevElement.key === nextElement.key) {
21026
var ownersMatch = prevElement._owner === nextElement._owner;
21027
var prevName = null;
21028
var nextName = null;
21029
var nextDisplayName = null;
21030
if ("production" !== "development") {
21031
if (!ownersMatch) {
21032
if (prevElement._owner != null &&
21033
prevElement._owner.getPublicInstance() != null &&
21034
prevElement._owner.getPublicInstance().constructor != null) {
21035
prevName =
21036
prevElement._owner.getPublicInstance().constructor.displayName;
21037
}
21038
if (nextElement._owner != null &&
21039
nextElement._owner.getPublicInstance() != null &&
21040
nextElement._owner.getPublicInstance().constructor != null) {
21041
nextName =
21042
nextElement._owner.getPublicInstance().constructor.displayName;
21043
}
21044
if (nextElement.type != null &&
21045
nextElement.type.displayName != null) {
21046
nextDisplayName = nextElement.type.displayName;
21047
}
21048
if (nextElement.type != null && typeof nextElement.type === 'string') {
21049
nextDisplayName = nextElement.type;
21050
}
21051
if (typeof nextElement.type !== 'string' ||
21052
nextElement.type === 'input' ||
21053
nextElement.type === 'textarea') {
21054
if ((prevElement._owner != null &&
21055
prevElement._owner._isOwnerNecessary === false) ||
21056
(nextElement._owner != null &&
21057
nextElement._owner._isOwnerNecessary === false)) {
21058
if (prevElement._owner != null) {
21059
prevElement._owner._isOwnerNecessary = true;
21060
}
21061
if (nextElement._owner != null) {
21062
nextElement._owner._isOwnerNecessary = true;
21063
}
21064
("production" !== "development" ? warning(
21065
false,
21066
'<%s /> is being rendered by both %s and %s using the same ' +
21067
'key (%s) in the same place. Currently, this means that ' +
21068
'they don\'t preserve state. This behavior should be very ' +
21069
'rare so we\'re considering deprecating it. Please contact ' +
21070
'the React team and explain your use case so that we can ' +
21071
'take that into consideration.',
21072
nextDisplayName || 'Unknown Component',
21073
prevName || '[Unknown]',
21074
nextName || '[Unknown]',
21075
prevElement.key
21076
) : null);
21077
}
21078
}
21079
}
21080
}
21081
return ownersMatch;
21082
}
21083
}
21084
}
21085
return false;
21086
}
21087
21088
module.exports = shouldUpdateReactComponent;
21089
21090
},{"171":171}],168:[function(_dereq_,module,exports){
21091
/**
21092
* Copyright 2014-2015, Facebook, Inc.
21093
* All rights reserved.
21094
*
21095
* This source code is licensed under the BSD-style license found in the
21096
* LICENSE file in the root directory of this source tree. An additional grant
21097
* of patent rights can be found in the PATENTS file in the same directory.
21098
*
21099
* @providesModule toArray
21100
* @typechecks
21101
*/
21102
21103
var invariant = _dereq_(150);
21104
21105
/**
21106
* Convert array-like objects to arrays.
21107
*
21108
* This API assumes the caller knows the contents of the data type. For less
21109
* well defined inputs use createArrayFromMixed.
21110
*
21111
* @param {object|function|filelist} obj
21112
* @return {array}
21113
*/
21114
function toArray(obj) {
21115
var length = obj.length;
21116
21117
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
21118
// old versions of Safari).
21119
("production" !== "development" ? invariant(
21120
!Array.isArray(obj) &&
21121
(typeof obj === 'object' || typeof obj === 'function'),
21122
'toArray: Array-like object expected'
21123
) : invariant(!Array.isArray(obj) &&
21124
(typeof obj === 'object' || typeof obj === 'function')));
21125
21126
("production" !== "development" ? invariant(
21127
typeof length === 'number',
21128
'toArray: Object needs a length property'
21129
) : invariant(typeof length === 'number'));
21130
21131
("production" !== "development" ? invariant(
21132
length === 0 ||
21133
(length - 1) in obj,
21134
'toArray: Object should have keys for indices'
21135
) : invariant(length === 0 ||
21136
(length - 1) in obj));
21137
21138
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
21139
// without method will throw during the slice call and skip straight to the
21140
// fallback.
21141
if (obj.hasOwnProperty) {
21142
try {
21143
return Array.prototype.slice.call(obj);
21144
} catch (e) {
21145
// IE < 9 does not support Array#slice on collections objects
21146
}
21147
}
21148
21149
// Fall back to copying key by key. This assumes all keys have a value,
21150
// so will not preserve sparsely populated inputs.
21151
var ret = Array(length);
21152
for (var ii = 0; ii < length; ii++) {
21153
ret[ii] = obj[ii];
21154
}
21155
return ret;
21156
}
21157
21158
module.exports = toArray;
21159
21160
},{"150":150}],169:[function(_dereq_,module,exports){
21161
/**
21162
* Copyright 2013-2015, Facebook, Inc.
21163
* All rights reserved.
21164
*
21165
* This source code is licensed under the BSD-style license found in the
21166
* LICENSE file in the root directory of this source tree. An additional grant
21167
* of patent rights can be found in the PATENTS file in the same directory.
21168
*
21169
* @providesModule traverseAllChildren
21170
*/
21171
21172
'use strict';
21173
21174
var ReactElement = _dereq_(63);
21175
var ReactFragment = _dereq_(69);
21176
var ReactInstanceHandles = _dereq_(72);
21177
21178
var getIteratorFn = _dereq_(141);
21179
var invariant = _dereq_(150);
21180
var warning = _dereq_(171);
21181
21182
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
21183
var SUBSEPARATOR = ':';
21184
21185
/**
21186
* TODO: Test that a single child and an array with one item have the same key
21187
* pattern.
21188
*/
21189
21190
var userProvidedKeyEscaperLookup = {
21191
'=': '=0',
21192
'.': '=1',
21193
':': '=2'
21194
};
21195
21196
var userProvidedKeyEscapeRegex = /[=.:]/g;
21197
21198
var didWarnAboutMaps = false;
21199
21200
function userProvidedKeyEscaper(match) {
21201
return userProvidedKeyEscaperLookup[match];
21202
}
21203
21204
/**
21205
* Generate a key string that identifies a component within a set.
21206
*
21207
* @param {*} component A component that could contain a manual key.
21208
* @param {number} index Index that is used if a manual key is not provided.
21209
* @return {string}
21210
*/
21211
function getComponentKey(component, index) {
21212
if (component && component.key != null) {
21213
// Explicit key
21214
return wrapUserProvidedKey(component.key);
21215
}
21216
// Implicit key determined by the index in the set
21217
return index.toString(36);
21218
}
21219
21220
/**
21221
* Escape a component key so that it is safe to use in a reactid.
21222
*
21223
* @param {*} key Component key to be escaped.
21224
* @return {string} An escaped string.
21225
*/
21226
function escapeUserProvidedKey(text) {
21227
return ('' + text).replace(
21228
userProvidedKeyEscapeRegex,
21229
userProvidedKeyEscaper
21230
);
21231
}
21232
21233
/**
21234
* Wrap a `key` value explicitly provided by the user to distinguish it from
21235
* implicitly-generated keys generated by a component's index in its parent.
21236
*
21237
* @param {string} key Value of a user-provided `key` attribute
21238
* @return {string}
21239
*/
21240
function wrapUserProvidedKey(key) {
21241
return '$' + escapeUserProvidedKey(key);
21242
}
21243
21244
/**
21245
* @param {?*} children Children tree container.
21246
* @param {!string} nameSoFar Name of the key path so far.
21247
* @param {!number} indexSoFar Number of children encountered until this point.
21248
* @param {!function} callback Callback to invoke with each child found.
21249
* @param {?*} traverseContext Used to pass information throughout the traversal
21250
* process.
21251
* @return {!number} The number of children in this subtree.
21252
*/
21253
function traverseAllChildrenImpl(
21254
children,
21255
nameSoFar,
21256
indexSoFar,
21257
callback,
21258
traverseContext
21259
) {
21260
var type = typeof children;
21261
21262
if (type === 'undefined' || type === 'boolean') {
21263
// All of the above are perceived as null.
21264
children = null;
21265
}
21266
21267
if (children === null ||
21268
type === 'string' ||
21269
type === 'number' ||
21270
ReactElement.isValidElement(children)) {
21271
callback(
21272
traverseContext,
21273
children,
21274
// If it's the only child, treat the name as if it was wrapped in an array
21275
// so that it's consistent if the number of children grows.
21276
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
21277
indexSoFar
21278
);
21279
return 1;
21280
}
21281
21282
var child, nextName, nextIndex;
21283
var subtreeCount = 0; // Count of children found in the current subtree.
21284
21285
if (Array.isArray(children)) {
21286
for (var i = 0; i < children.length; i++) {
21287
child = children[i];
21288
nextName = (
21289
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
21290
getComponentKey(child, i)
21291
);
21292
nextIndex = indexSoFar + subtreeCount;
21293
subtreeCount += traverseAllChildrenImpl(
21294
child,
21295
nextName,
21296
nextIndex,
21297
callback,
21298
traverseContext
21299
);
21300
}
21301
} else {
21302
var iteratorFn = getIteratorFn(children);
21303
if (iteratorFn) {
21304
var iterator = iteratorFn.call(children);
21305
var step;
21306
if (iteratorFn !== children.entries) {
21307
var ii = 0;
21308
while (!(step = iterator.next()).done) {
21309
child = step.value;
21310
nextName = (
21311
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
21312
getComponentKey(child, ii++)
21313
);
21314
nextIndex = indexSoFar + subtreeCount;
21315
subtreeCount += traverseAllChildrenImpl(
21316
child,
21317
nextName,
21318
nextIndex,
21319
callback,
21320
traverseContext
21321
);
21322
}
21323
} else {
21324
if ("production" !== "development") {
21325
("production" !== "development" ? warning(
21326
didWarnAboutMaps,
21327
'Using Maps as children is not yet fully supported. It is an ' +
21328
'experimental feature that might be removed. Convert it to a ' +
21329
'sequence / iterable of keyed ReactElements instead.'
21330
) : null);
21331
didWarnAboutMaps = true;
21332
}
21333
// Iterator will provide entry [k,v] tuples rather than values.
21334
while (!(step = iterator.next()).done) {
21335
var entry = step.value;
21336
if (entry) {
21337
child = entry[1];
21338
nextName = (
21339
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
21340
wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
21341
getComponentKey(child, 0)
21342
);
21343
nextIndex = indexSoFar + subtreeCount;
21344
subtreeCount += traverseAllChildrenImpl(
21345
child,
21346
nextName,
21347
nextIndex,
21348
callback,
21349
traverseContext
21350
);
21351
}
21352
}
21353
}
21354
} else if (type === 'object') {
21355
("production" !== "development" ? invariant(
21356
children.nodeType !== 1,
21357
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
21358
'elements are not valid children of React components.'
21359
) : invariant(children.nodeType !== 1));
21360
var fragment = ReactFragment.extract(children);
21361
for (var key in fragment) {
21362
if (fragment.hasOwnProperty(key)) {
21363
child = fragment[key];
21364
nextName = (
21365
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
21366
wrapUserProvidedKey(key) + SUBSEPARATOR +
21367
getComponentKey(child, 0)
21368
);
21369
nextIndex = indexSoFar + subtreeCount;
21370
subtreeCount += traverseAllChildrenImpl(
21371
child,
21372
nextName,
21373
nextIndex,
21374
callback,
21375
traverseContext
21376
);
21377
}
21378
}
21379
}
21380
}
21381
21382
return subtreeCount;
21383
}
21384
21385
/**
21386
* Traverses children that are typically specified as `props.children`, but
21387
* might also be specified through attributes:
21388
*
21389
* - `traverseAllChildren(this.props.children, ...)`
21390
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
21391
*
21392
* The `traverseContext` is an optional argument that is passed through the
21393
* entire traversal. It can be used to store accumulations or anything else that
21394
* the callback might find relevant.
21395
*
21396
* @param {?*} children Children tree object.
21397
* @param {!function} callback To invoke upon traversing each child.
21398
* @param {?*} traverseContext Context for traversal.
21399
* @return {!number} The number of children in this subtree.
21400
*/
21401
function traverseAllChildren(children, callback, traverseContext) {
21402
if (children == null) {
21403
return 0;
21404
}
21405
21406
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
21407
}
21408
21409
module.exports = traverseAllChildren;
21410
21411
},{"141":141,"150":150,"171":171,"63":63,"69":69,"72":72}],170:[function(_dereq_,module,exports){
21412
/**
21413
* Copyright 2013-2015, Facebook, Inc.
21414
* All rights reserved.
21415
*
21416
* This source code is licensed under the BSD-style license found in the
21417
* LICENSE file in the root directory of this source tree. An additional grant
21418
* of patent rights can be found in the PATENTS file in the same directory.
21419
*
21420
* @providesModule update
21421
*/
21422
21423
/* global hasOwnProperty:true */
21424
21425
'use strict';
21426
21427
var assign = _dereq_(29);
21428
var keyOf = _dereq_(157);
21429
var invariant = _dereq_(150);
21430
var hasOwnProperty = {}.hasOwnProperty;
21431
21432
function shallowCopy(x) {
21433
if (Array.isArray(x)) {
21434
return x.concat();
21435
} else if (x && typeof x === 'object') {
21436
return assign(new x.constructor(), x);
21437
} else {
21438
return x;
21439
}
21440
}
21441
21442
var COMMAND_PUSH = keyOf({$push: null});
21443
var COMMAND_UNSHIFT = keyOf({$unshift: null});
21444
var COMMAND_SPLICE = keyOf({$splice: null});
21445
var COMMAND_SET = keyOf({$set: null});
21446
var COMMAND_MERGE = keyOf({$merge: null});
21447
var COMMAND_APPLY = keyOf({$apply: null});
21448
21449
var ALL_COMMANDS_LIST = [
21450
COMMAND_PUSH,
21451
COMMAND_UNSHIFT,
21452
COMMAND_SPLICE,
21453
COMMAND_SET,
21454
COMMAND_MERGE,
21455
COMMAND_APPLY
21456
];
21457
21458
var ALL_COMMANDS_SET = {};
21459
21460
ALL_COMMANDS_LIST.forEach(function(command) {
21461
ALL_COMMANDS_SET[command] = true;
21462
});
21463
21464
function invariantArrayCase(value, spec, command) {
21465
("production" !== "development" ? invariant(
21466
Array.isArray(value),
21467
'update(): expected target of %s to be an array; got %s.',
21468
command,
21469
value
21470
) : invariant(Array.isArray(value)));
21471
var specValue = spec[command];
21472
("production" !== "development" ? invariant(
21473
Array.isArray(specValue),
21474
'update(): expected spec of %s to be an array; got %s. ' +
21475
'Did you forget to wrap your parameter in an array?',
21476
command,
21477
specValue
21478
) : invariant(Array.isArray(specValue)));
21479
}
21480
21481
function update(value, spec) {
21482
("production" !== "development" ? invariant(
21483
typeof spec === 'object',
21484
'update(): You provided a key path to update() that did not contain one ' +
21485
'of %s. Did you forget to include {%s: ...}?',
21486
ALL_COMMANDS_LIST.join(', '),
21487
COMMAND_SET
21488
) : invariant(typeof spec === 'object'));
21489
21490
if (hasOwnProperty.call(spec, COMMAND_SET)) {
21491
("production" !== "development" ? invariant(
21492
Object.keys(spec).length === 1,
21493
'Cannot have more than one key in an object with %s',
21494
COMMAND_SET
21495
) : invariant(Object.keys(spec).length === 1));
21496
21497
return spec[COMMAND_SET];
21498
}
21499
21500
var nextValue = shallowCopy(value);
21501
21502
if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
21503
var mergeObj = spec[COMMAND_MERGE];
21504
("production" !== "development" ? invariant(
21505
mergeObj && typeof mergeObj === 'object',
21506
'update(): %s expects a spec of type \'object\'; got %s',
21507
COMMAND_MERGE,
21508
mergeObj
21509
) : invariant(mergeObj && typeof mergeObj === 'object'));
21510
("production" !== "development" ? invariant(
21511
nextValue && typeof nextValue === 'object',
21512
'update(): %s expects a target of type \'object\'; got %s',
21513
COMMAND_MERGE,
21514
nextValue
21515
) : invariant(nextValue && typeof nextValue === 'object'));
21516
assign(nextValue, spec[COMMAND_MERGE]);
21517
}
21518
21519
if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
21520
invariantArrayCase(value, spec, COMMAND_PUSH);
21521
spec[COMMAND_PUSH].forEach(function(item) {
21522
nextValue.push(item);
21523
});
21524
}
21525
21526
if (hasOwnProperty.call(spec, COMMAND_UNSHIFT)) {
21527
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
21528
spec[COMMAND_UNSHIFT].forEach(function(item) {
21529
nextValue.unshift(item);
21530
});
21531
}
21532
21533
if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
21534
("production" !== "development" ? invariant(
21535
Array.isArray(value),
21536
'Expected %s target to be an array; got %s',
21537
COMMAND_SPLICE,
21538
value
21539
) : invariant(Array.isArray(value)));
21540
("production" !== "development" ? invariant(
21541
Array.isArray(spec[COMMAND_SPLICE]),
21542
'update(): expected spec of %s to be an array of arrays; got %s. ' +
21543
'Did you forget to wrap your parameters in an array?',
21544
COMMAND_SPLICE,
21545
spec[COMMAND_SPLICE]
21546
) : invariant(Array.isArray(spec[COMMAND_SPLICE])));
21547
spec[COMMAND_SPLICE].forEach(function(args) {
21548
("production" !== "development" ? invariant(
21549
Array.isArray(args),
21550
'update(): expected spec of %s to be an array of arrays; got %s. ' +
21551
'Did you forget to wrap your parameters in an array?',
21552
COMMAND_SPLICE,
21553
spec[COMMAND_SPLICE]
21554
) : invariant(Array.isArray(args)));
21555
nextValue.splice.apply(nextValue, args);
21556
});
21557
}
21558
21559
if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
21560
("production" !== "development" ? invariant(
21561
typeof spec[COMMAND_APPLY] === 'function',
21562
'update(): expected spec of %s to be a function; got %s.',
21563
COMMAND_APPLY,
21564
spec[COMMAND_APPLY]
21565
) : invariant(typeof spec[COMMAND_APPLY] === 'function'));
21566
nextValue = spec[COMMAND_APPLY](nextValue);
21567
}
21568
21569
for (var k in spec) {
21570
if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) {
21571
nextValue[k] = update(value[k], spec[k]);
21572
}
21573
}
21574
21575
return nextValue;
21576
}
21577
21578
module.exports = update;
21579
21580
},{"150":150,"157":157,"29":29}],171:[function(_dereq_,module,exports){
21581
/**
21582
* Copyright 2014-2015, Facebook, Inc.
21583
* All rights reserved.
21584
*
21585
* This source code is licensed under the BSD-style license found in the
21586
* LICENSE file in the root directory of this source tree. An additional grant
21587
* of patent rights can be found in the PATENTS file in the same directory.
21588
*
21589
* @providesModule warning
21590
*/
21591
21592
"use strict";
21593
21594
var emptyFunction = _dereq_(129);
21595
21596
/**
21597
* Similar to invariant but only logs a warning if the condition is not met.
21598
* This can be used to log issues in development environments in critical
21599
* paths. Removing the logging code for production environments will keep the
21600
* same logic and follow the same code paths.
21601
*/
21602
21603
var warning = emptyFunction;
21604
21605
if ("production" !== "development") {
21606
warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
21607
if (format === undefined) {
21608
throw new Error(
21609
'`warning(condition, format, ...args)` requires a warning ' +
21610
'message argument'
21611
);
21612
}
21613
21614
if (format.length < 10 || /^[s\W]*$/.test(format)) {
21615
throw new Error(
21616
'The warning format should be able to uniquely identify this ' +
21617
'warning. Please, use a more descriptive format than: ' + format
21618
);
21619
}
21620
21621
if (format.indexOf('Failed Composite propType: ') === 0) {
21622
return; // Ignore CompositeComponent proptype check.
21623
}
21624
21625
if (!condition) {
21626
var argIndex = 0;
21627
var message = 'Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];});
21628
console.warn(message);
21629
try {
21630
// --- Welcome to debugging React ---
21631
// This error was thrown as a convenience so that you can use this stack
21632
// to find the callsite that caused this warning to fire.
21633
throw new Error(message);
21634
} catch(x) {}
21635
}
21636
};
21637
}
21638
21639
module.exports = warning;
21640
21641
},{"129":129}]},{},[1])(1)
21642
});
21643