Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 50993
1
(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(require,module,exports){
2
// shim for using process in browser
3
4
var process = module.exports = {};
5
var queue = [];
6
var draining = false;
7
var currentQueue;
8
var queueIndex = -1;
9
10
function cleanUpNextTick() {
11
draining = false;
12
if (currentQueue.length) {
13
queue = currentQueue.concat(queue);
14
} else {
15
queueIndex = -1;
16
}
17
if (queue.length) {
18
drainQueue();
19
}
20
}
21
22
function drainQueue() {
23
if (draining) {
24
return;
25
}
26
var timeout = setTimeout(cleanUpNextTick);
27
draining = true;
28
29
var len = queue.length;
30
while(len) {
31
currentQueue = queue;
32
queue = [];
33
while (++queueIndex < len) {
34
currentQueue[queueIndex].run();
35
}
36
queueIndex = -1;
37
len = queue.length;
38
}
39
currentQueue = null;
40
draining = false;
41
clearTimeout(timeout);
42
}
43
44
process.nextTick = function (fun) {
45
var args = new Array(arguments.length - 1);
46
if (arguments.length > 1) {
47
for (var i = 1; i < arguments.length; i++) {
48
args[i - 1] = arguments[i];
49
}
50
}
51
queue.push(new Item(fun, args));
52
if (queue.length === 1 && !draining) {
53
setTimeout(drainQueue, 0);
54
}
55
};
56
57
// v8 likes predictible objects
58
function Item(fun, array) {
59
this.fun = fun;
60
this.array = array;
61
}
62
Item.prototype.run = function () {
63
this.fun.apply(null, this.array);
64
};
65
process.title = 'browser';
66
process.browser = true;
67
process.env = {};
68
process.argv = [];
69
process.version = ''; // empty string to avoid regexp issues
70
process.versions = {};
71
72
function noop() {}
73
74
process.on = noop;
75
process.addListener = noop;
76
process.once = noop;
77
process.off = noop;
78
process.removeListener = noop;
79
process.removeAllListeners = noop;
80
process.emit = noop;
81
82
process.binding = function (name) {
83
throw new Error('process.binding is not supported');
84
};
85
86
// TODO(shtylman)
87
process.cwd = function () { return '/' };
88
process.chdir = function (dir) {
89
throw new Error('process.chdir is not supported');
90
};
91
process.umask = function() { return 0; };
92
93
},{}],2:[function(require,module,exports){
94
module.exports = require('./lib/addons/FluxComponent');
95
96
},{"./lib/addons/FluxComponent":6}],3:[function(require,module,exports){
97
(function (process){
98
'use strict';
99
100
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
101
102
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
103
104
/**
105
* Actions
106
*
107
* Instances of the Actions class represent a set of actions. (In Flux parlance,
108
* these might be more accurately denoted as Action Creators, while Action
109
* refers to the payload sent to the dispatcher, but this is... confusing. We
110
* will use Action to mean the function you call to trigger a dispatch.)
111
*
112
* Create actions by extending from the base Actions class and adding methods.
113
* All methods on the prototype (except the constructor) will be
114
* converted into actions. The return value of an action is used as the body
115
* of the payload sent to the dispatcher.
116
*/
117
118
var _uniqueId = require('uniqueid');
119
120
var uniqueId = _interopRequire(_uniqueId);
121
122
var Actions = (function () {
123
function Actions() {
124
_classCallCheck(this, Actions);
125
126
this._baseId = uniqueId();
127
128
var methodNames = this._getActionMethodNames();
129
for (var i = 0; i < methodNames.length; i++) {
130
var methodName = methodNames[i];
131
this._wrapAction(methodName);
132
}
133
134
this.getConstants = this.getActionIds;
135
}
136
137
Actions.prototype.getActionIds = function getActionIds() {
138
var _this = this;
139
140
return this._getActionMethodNames().reduce(function (result, actionName) {
141
result[actionName] = _this[actionName]._id;
142
return result;
143
}, {});
144
};
145
146
Actions.prototype._getActionMethodNames = function _getActionMethodNames(instance) {
147
var _this2 = this;
148
149
return Object.getOwnPropertyNames(this.constructor.prototype).filter(function (name) {
150
return name !== 'constructor' && typeof _this2[name] === 'function';
151
});
152
};
153
154
Actions.prototype._wrapAction = function _wrapAction(methodName) {
155
var _this3 = this;
156
157
var originalMethod = this[methodName];
158
var actionId = this._createActionId(methodName);
159
160
var action = function action() {
161
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
162
args[_key] = arguments[_key];
163
}
164
165
var body = originalMethod.apply(_this3, args);
166
167
if (isPromise(body)) {
168
var promise = body;
169
_this3._dispatchAsync(actionId, promise, args, methodName);
170
} else {
171
_this3._dispatch(actionId, body, args, methodName);
172
}
173
174
// Return original method's return value to caller
175
return body;
176
};
177
178
action._id = actionId;
179
180
this[methodName] = action;
181
};
182
183
/**
184
* Create unique string constant for an action method, using
185
* @param {string} methodName - Name of the action method
186
*/
187
188
Actions.prototype._createActionId = function _createActionId(methodName) {
189
return '' + this._baseId + '-' + methodName;
190
};
191
192
Actions.prototype._dispatch = function _dispatch(actionId, body, args, methodName) {
193
if (typeof this.dispatch === 'function') {
194
if (typeof body !== 'undefined') {
195
this.dispatch(actionId, body, args);
196
}
197
} else {
198
if (process.env.NODE_ENV !== 'production') {
199
console.warn('You\'ve attempted to perform the action ' + ('' + this.constructor.name + '#' + methodName + ', but it hasn\'t been added ') + 'to a Flux instance.');
200
}
201
}
202
203
return body;
204
};
205
206
Actions.prototype._dispatchAsync = function _dispatchAsync(actionId, promise, args, methodName) {
207
if (typeof this.dispatchAsync === 'function') {
208
this.dispatchAsync(actionId, promise, args);
209
} else {
210
if (process.env.NODE_ENV !== 'production') {
211
console.warn('You\'ve attempted to perform the asynchronous action ' + ('' + this.constructor.name + '#' + methodName + ', but it hasn\'t been added ') + 'to a Flux instance.');
212
}
213
}
214
};
215
216
return Actions;
217
})();
218
219
module.exports = Actions;
220
221
function isPromise(value) {
222
return value && typeof value.then === 'function';
223
}
224
}).call(this,require('_process'))
225
},{"_process":1,"uniqueid":13}],4:[function(require,module,exports){
226
(function (process){
227
'use strict';
228
229
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
230
231
var _bind = Function.prototype.bind;
232
233
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
234
235
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
236
237
exports.__esModule = true;
238
/**
239
* Flux
240
*
241
* The main Flux class.
242
*/
243
244
var _Store = require('./Store');
245
246
var Store = _interopRequire(_Store);
247
248
var _Actions = require('./Actions');
249
250
var Actions = _interopRequire(_Actions);
251
252
var _Dispatcher = require('flux');
253
254
var _EventEmitter2 = require('eventemitter3');
255
256
var EventEmitter = _interopRequire(_EventEmitter2);
257
258
var _assign = require('object-assign');
259
260
var assign = _interopRequire(_assign);
261
262
var Flux = (function (_EventEmitter) {
263
function Flux() {
264
_classCallCheck(this, Flux);
265
266
_EventEmitter.call(this);
267
268
this.dispatcher = new _Dispatcher.Dispatcher();
269
270
this._stores = {};
271
this._actions = {};
272
}
273
274
_inherits(Flux, _EventEmitter);
275
276
Flux.prototype.createStore = function createStore(key, _Store) {
277
for (var _len = arguments.length, constructorArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
278
constructorArgs[_key - 2] = arguments[_key];
279
}
280
281
if (!(_Store.prototype instanceof Store)) {
282
var className = getClassName(_Store);
283
284
throw new Error('You\'ve attempted to create a store from the class ' + className + ', which ' + 'does not have the base Store class in its prototype chain. Make sure ' + ('you\'re using the `extends` keyword: `class ' + className + ' extends ') + 'Store { ... }`');
285
}
286
287
if (this._stores.hasOwnProperty(key) && this._stores[key]) {
288
throw new Error('You\'ve attempted to create multiple stores with key ' + key + '. Keys must ' + 'be unique.');
289
}
290
291
var store = new (_bind.apply(_Store, [null].concat(constructorArgs)))();
292
var token = this.dispatcher.register(store.handler.bind(store));
293
294
store._waitFor = this.waitFor.bind(this);
295
store._token = token;
296
store._getAllActionIds = this.getAllActionIds.bind(this);
297
298
this._stores[key] = store;
299
300
return store;
301
};
302
303
Flux.prototype.getStore = function getStore(key) {
304
return this._stores.hasOwnProperty(key) ? this._stores[key] : undefined;
305
};
306
307
Flux.prototype.removeStore = function removeStore(key) {
308
if (this._stores.hasOwnProperty(key)) {
309
this._stores[key].removeAllListeners();
310
this.dispatcher.unregister(this._stores[key]._token);
311
delete this._stores[key];
312
} else {
313
throw new Error('You\'ve attempted to remove store with key ' + key + ' which does not exist.');
314
}
315
};
316
317
Flux.prototype.createActions = function createActions(key, _Actions) {
318
for (var _len2 = arguments.length, constructorArgs = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
319
constructorArgs[_key2 - 2] = arguments[_key2];
320
}
321
322
if (!(_Actions.prototype instanceof Actions) && _Actions !== Actions) {
323
if (typeof _Actions === 'function') {
324
var className = getClassName(_Actions);
325
326
throw new Error('You\'ve attempted to create actions from the class ' + className + ', which ' + 'does not have the base Actions class in its prototype chain. Make ' + ('sure you\'re using the `extends` keyword: `class ' + className + ' ') + 'extends Actions { ... }`');
327
} else {
328
var properties = _Actions;
329
_Actions = (function (_Actions2) {
330
var _class = function () {
331
_classCallCheck(this, _class);
332
333
if (_Actions2 != null) {
334
_Actions2.apply(this, arguments);
335
}
336
};
337
338
_inherits(_class, _Actions2);
339
340
return _class;
341
})(Actions);
342
assign(_Actions.prototype, properties);
343
}
344
}
345
346
if (this._actions.hasOwnProperty(key) && this._actions[key]) {
347
throw new Error('You\'ve attempted to create multiple actions with key ' + key + '. Keys ' + 'must be unique.');
348
}
349
350
var actions = new (_bind.apply(_Actions, [null].concat(constructorArgs)))();
351
actions.dispatch = this.dispatch.bind(this);
352
actions.dispatchAsync = this.dispatchAsync.bind(this);
353
354
this._actions[key] = actions;
355
356
return actions;
357
};
358
359
Flux.prototype.getActions = function getActions(key) {
360
return this._actions.hasOwnProperty(key) ? this._actions[key] : undefined;
361
};
362
363
Flux.prototype.getActionIds = function getActionIds(key) {
364
var actions = this.getActions(key);
365
366
if (!actions) {
367
return;
368
}return actions.getConstants();
369
};
370
371
Flux.prototype.removeActions = function removeActions(key) {
372
if (this._actions.hasOwnProperty(key)) {
373
delete this._actions[key];
374
} else {
375
throw new Error('You\'ve attempted to remove actions with key ' + key + ' which does not exist.');
376
}
377
};
378
379
Flux.prototype.getAllActionIds = function getAllActionIds() {
380
var actionIds = [];
381
382
for (var key in this._actions) {
383
if (!this._actions.hasOwnProperty(key)) continue;
384
385
var actionConstants = this._actions[key].getConstants();
386
387
actionIds = actionIds.concat(getValues(actionConstants));
388
}
389
390
return actionIds;
391
};
392
393
Flux.prototype.dispatch = function dispatch(actionId, body) {
394
this._dispatch({ actionId: actionId, body: body });
395
};
396
397
Flux.prototype.dispatchAsync = function dispatchAsync(actionId, promise, actionArgs) {
398
var _this = this;
399
400
var payload = {
401
actionId: actionId,
402
async: 'begin'
403
};
404
405
if (actionArgs) payload.actionArgs = actionArgs;
406
407
this._dispatch(payload);
408
409
return promise.then(function (body) {
410
_this._dispatch({
411
actionId: actionId,
412
body: body,
413
async: 'success'
414
});
415
416
return body;
417
}, function (error) {
418
_this._dispatch({
419
actionId: actionId,
420
error: error,
421
async: 'failure'
422
});
423
})['catch'](function (error) {
424
_this.emit('error', error);
425
426
throw error;
427
});
428
};
429
430
Flux.prototype._dispatch = function _dispatch(payload) {
431
this.dispatcher.dispatch(payload);
432
this.emit('dispatch', payload);
433
};
434
435
Flux.prototype.waitFor = function waitFor(tokensOrStores) {
436
437
if (!Array.isArray(tokensOrStores)) tokensOrStores = [tokensOrStores];
438
439
var ensureIsToken = function ensureIsToken(tokenOrStore) {
440
return tokenOrStore instanceof Store ? tokenOrStore._token : tokenOrStore;
441
};
442
443
var tokens = tokensOrStores.map(ensureIsToken);
444
445
this.dispatcher.waitFor(tokens);
446
};
447
448
Flux.prototype.removeAllStoreListeners = function removeAllStoreListeners(event) {
449
for (var key in this._stores) {
450
if (!this._stores.hasOwnProperty(key)) continue;
451
452
var store = this._stores[key];
453
454
store.removeAllListeners(event);
455
}
456
};
457
458
Flux.prototype.serialize = function serialize() {
459
var stateTree = {};
460
461
for (var key in this._stores) {
462
if (!this._stores.hasOwnProperty(key)) continue;
463
464
var store = this._stores[key];
465
466
var serialize = store.constructor.serialize;
467
468
if (typeof serialize !== 'function') continue;
469
470
var serializedStoreState = serialize(store.state);
471
472
if (typeof serializedStoreState !== 'string') {
473
var className = store.constructor.name;
474
475
if (process.env.NODE_ENV !== 'production') {
476
console.warn('The store with key \'' + key + '\' was not serialized because the static ' + ('method `' + className + '.serialize()` returned a non-string with type ') + ('\'' + typeof serializedStoreState + '\'.'));
477
}
478
}
479
480
stateTree[key] = serializedStoreState;
481
482
if (typeof store.constructor.deserialize !== 'function') {
483
var className = store.constructor.name;
484
485
if (process.env.NODE_ENV !== 'production') {
486
console.warn('The class `' + className + '` has a `serialize()` method, but no ' + 'corresponding `deserialize()` method.');
487
}
488
}
489
}
490
491
return JSON.stringify(stateTree);
492
};
493
494
Flux.prototype.deserialize = function deserialize(serializedState) {
495
var stateMap = undefined;
496
497
try {
498
stateMap = JSON.parse(serializedState);
499
} catch (error) {
500
var className = this.constructor.name;
501
502
if (process.env.NODE_ENV !== 'production') {
503
throw new Error('Invalid value passed to `' + className + '#deserialize()`: ' + ('' + serializedState));
504
}
505
}
506
507
for (var key in this._stores) {
508
if (!this._stores.hasOwnProperty(key)) continue;
509
510
var store = this._stores[key];
511
512
var deserialize = store.constructor.deserialize;
513
514
if (typeof deserialize !== 'function') continue;
515
516
var storeStateString = stateMap[key];
517
var storeState = deserialize(storeStateString);
518
519
store.replaceState(storeState);
520
521
if (typeof store.constructor.serialize !== 'function') {
522
var className = store.constructor.name;
523
524
if (process.env.NODE_ENV !== 'production') {
525
console.warn('The class `' + className + '` has a `deserialize()` method, but no ' + 'corresponding `serialize()` method.');
526
}
527
}
528
}
529
};
530
531
return Flux;
532
})(EventEmitter);
533
534
exports['default'] = Flux;
535
536
// Aliases
537
Flux.prototype.getConstants = Flux.prototype.getActionIds;
538
Flux.prototype.getAllConstants = Flux.prototype.getAllActionIds;
539
Flux.prototype.dehydrate = Flux.prototype.serialize;
540
Flux.prototype.hydrate = Flux.prototype.deserialize;
541
542
function getClassName(Class) {
543
return Class.prototype.constructor.name;
544
}
545
546
function getValues(object) {
547
var values = [];
548
549
for (var key in object) {
550
if (!object.hasOwnProperty(key)) continue;
551
552
values.push(object[key]);
553
}
554
555
return values;
556
}
557
558
var Flummox = Flux;
559
560
exports.Flux = Flux;
561
exports.Flummox = Flummox;
562
exports.Store = Store;
563
exports.Actions = Actions;
564
}).call(this,require('_process'))
565
},{"./Actions":3,"./Store":5,"_process":1,"eventemitter3":8,"flux":9,"object-assign":12}],5:[function(require,module,exports){
566
'use strict';
567
568
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
569
570
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
571
572
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
573
574
/**
575
* Store
576
*
577
* Stores hold application state. They respond to actions sent by the dispatcher
578
* and broadcast change events to listeners, so they can grab the latest data.
579
* The key thing to remember is that the only way stores receive information
580
* from the outside world is via the dispatcher.
581
*/
582
583
var _EventEmitter2 = require('eventemitter3');
584
585
var EventEmitter = _interopRequire(_EventEmitter2);
586
587
var _assign = require('object-assign');
588
589
var assign = _interopRequire(_assign);
590
591
var Store = (function (_EventEmitter) {
592
593
/**
594
* Stores are initialized with a reference
595
* @type {Object}
596
*/
597
598
function Store() {
599
_classCallCheck(this, Store);
600
601
_EventEmitter.call(this);
602
603
this.state = null;
604
605
this._handlers = {};
606
this._asyncHandlers = {};
607
this._catchAllHandlers = [];
608
this._catchAllAsyncHandlers = {
609
begin: [],
610
success: [],
611
failure: [] };
612
}
613
614
_inherits(Store, _EventEmitter);
615
616
Store.prototype.setState = function setState(newState) {
617
// Do a transactional state update if a function is passed
618
if (typeof newState === 'function') {
619
var prevState = this._isHandlingDispatch ? this._pendingState : this.state;
620
621
newState = newState(prevState);
622
}
623
624
if (this._isHandlingDispatch) {
625
this._pendingState = this._assignState(this._pendingState, newState);
626
this._emitChangeAfterHandlingDispatch = true;
627
} else {
628
this.state = this._assignState(this.state, newState);
629
this.emit('change');
630
}
631
};
632
633
Store.prototype.replaceState = function replaceState(newState) {
634
if (this._isHandlingDispatch) {
635
this._pendingState = this._assignState(undefined, newState);
636
this._emitChangeAfterHandlingDispatch = true;
637
} else {
638
this.state = this._assignState(undefined, newState);
639
this.emit('change');
640
}
641
};
642
643
Store.prototype.getStateAsObject = function getStateAsObject() {
644
return this.state;
645
};
646
647
Store.assignState = function assignState(oldState, newState) {
648
return assign({}, oldState, newState);
649
};
650
651
Store.prototype._assignState = function _assignState() {
652
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
653
args[_key] = arguments[_key];
654
}
655
656
return (this.constructor.assignState || Store.assignState).apply(undefined, args);
657
};
658
659
Store.prototype.forceUpdate = function forceUpdate() {
660
if (this._isHandlingDispatch) {
661
this._emitChangeAfterHandlingDispatch = true;
662
} else {
663
this.emit('change');
664
}
665
};
666
667
Store.prototype.register = function register(actionId, handler) {
668
actionId = ensureActionId(actionId);
669
670
if (typeof handler !== 'function') {
671
return;
672
}this._handlers[actionId] = handler.bind(this);
673
};
674
675
Store.prototype.registerAsync = function registerAsync(actionId, beginHandler, successHandler, failureHandler) {
676
actionId = ensureActionId(actionId);
677
678
var asyncHandlers = this._bindAsyncHandlers({
679
begin: beginHandler,
680
success: successHandler,
681
failure: failureHandler });
682
683
this._asyncHandlers[actionId] = asyncHandlers;
684
};
685
686
Store.prototype.registerAll = function registerAll(handler) {
687
if (typeof handler !== 'function') {
688
return;
689
}this._catchAllHandlers.push(handler.bind(this));
690
};
691
692
Store.prototype.registerAllAsync = function registerAllAsync(beginHandler, successHandler, failureHandler) {
693
var _this = this;
694
695
var asyncHandlers = this._bindAsyncHandlers({
696
begin: beginHandler,
697
success: successHandler,
698
failure: failureHandler });
699
700
Object.keys(asyncHandlers).forEach(function (key) {
701
_this._catchAllAsyncHandlers[key].push(asyncHandlers[key]);
702
});
703
};
704
705
Store.prototype._bindAsyncHandlers = function _bindAsyncHandlers(asyncHandlers) {
706
for (var key in asyncHandlers) {
707
if (!asyncHandlers.hasOwnProperty(key)) continue;
708
709
var handler = asyncHandlers[key];
710
711
if (typeof handler === 'function') {
712
asyncHandlers[key] = handler.bind(this);
713
} else {
714
delete asyncHandlers[key];
715
}
716
}
717
718
return asyncHandlers;
719
};
720
721
Store.prototype.waitFor = function waitFor(tokensOrStores) {
722
this._waitFor(tokensOrStores);
723
};
724
725
Store.prototype.handler = function handler(payload) {
726
var body = payload.body;
727
var actionId = payload.actionId;
728
var _async = payload.async;
729
var actionArgs = payload.actionArgs;
730
var error = payload.error;
731
732
var _allHandlers = this._catchAllHandlers;
733
var _handler = this._handlers[actionId];
734
735
var _allAsyncHandlers = this._catchAllAsyncHandlers[_async];
736
var _asyncHandler = this._asyncHandlers[actionId] && this._asyncHandlers[actionId][_async];
737
738
if (_async) {
739
var beginOrFailureHandlers = _allAsyncHandlers.concat([_asyncHandler]);
740
741
switch (_async) {
742
case 'begin':
743
this._performHandler(beginOrFailureHandlers, actionArgs);
744
return;
745
case 'failure':
746
this._performHandler(beginOrFailureHandlers, [error]);
747
return;
748
case 'success':
749
this._performHandler(_allAsyncHandlers.concat([_asyncHandler || _handler].concat(_asyncHandler && [] || _allHandlers)), [body]);
750
return;
751
default:
752
return;
753
}
754
}
755
756
this._performHandler(_allHandlers.concat([_handler]), [body]);
757
};
758
759
Store.prototype._performHandler = function _performHandler(_handlers, args) {
760
this._isHandlingDispatch = true;
761
this._pendingState = this._assignState(undefined, this.state);
762
this._emitChangeAfterHandlingDispatch = false;
763
764
try {
765
this._performHandlers(_handlers, args);
766
} finally {
767
if (this._emitChangeAfterHandlingDispatch) {
768
this.state = this._pendingState;
769
this.emit('change');
770
}
771
772
this._isHandlingDispatch = false;
773
this._pendingState = undefined;
774
this._emitChangeAfterHandlingDispatch = false;
775
}
776
};
777
778
Store.prototype._performHandlers = function _performHandlers(_handlers, args) {
779
var _this2 = this;
780
781
_handlers.forEach(function (_handler) {
782
return typeof _handler === 'function' && _handler.apply(_this2, args);
783
});
784
};
785
786
return Store;
787
})(EventEmitter);
788
789
module.exports = Store;
790
791
function ensureActionId(actionOrActionId) {
792
return typeof actionOrActionId === 'function' ? actionOrActionId._id : actionOrActionId;
793
}
794
},{"eventemitter3":8,"object-assign":12}],6:[function(require,module,exports){
795
'use strict';
796
797
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
798
799
var _objectWithoutProperties = function (obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; };
800
801
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
802
803
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
804
805
/**
806
* Flux Component
807
*
808
* Component interface to reactComponentMethods module.
809
*
810
* Children of FluxComponent are given access to the flux instance via
811
* `context.flux`. Use this near the top of your app hierarchy and all children
812
* will have easy access to the flux instance (including, of course, other
813
* Flux components!):
814
*
815
* <FluxComponent flux={flux}>
816
* ...the rest of your app
817
* </FluxComponent>
818
*
819
* Now any child can access the flux instance again like this:
820
*
821
* <FluxComponent>
822
* ...children
823
* </FluxComponent>
824
*
825
* We don't need the flux prop this time because flux is already part of
826
* the context.
827
*
828
* Additionally, immediate children are given a `flux` prop.
829
*
830
* The component has an optional prop `connectToStores`, which is passed to
831
* `this.connectToStores` and used to set the initial state. The component's
832
* state is injected as props to the child components.
833
*
834
* The practical upshot of all this is that fluxMixin, state changes, and
835
* context are now simply implementation details. Among other things, this means
836
* you can write your components as plain ES6 classes. Here's an example:
837
*
838
* class ParentComponent extends React.Component {
839
*
840
* render() {
841
* <FluxComponent connectToStores="fooStore">
842
* <ChildComponent />
843
* </FluxComponent>
844
* }
845
*
846
* }
847
*
848
* ChildComponent in this example has prop `flux` containing the flux instance,
849
* and props that sync with each of the state keys of fooStore.
850
*/
851
852
var _React = require('react/addons');
853
854
var React = _interopRequire(_React);
855
856
var _instanceMethods$staticProperties = require('./reactComponentMethods');
857
858
var _assign = require('object-assign');
859
860
var assign = _interopRequire(_assign);
861
862
var FluxComponent = (function (_React$Component) {
863
function FluxComponent(props, context) {
864
_classCallCheck(this, FluxComponent);
865
866
_React$Component.call(this, props, context);
867
868
this.initialize();
869
870
this.state = this.connectToStores(props.connectToStores, props.stateGetter);
871
872
this.wrapChild = this.wrapChild.bind(this);
873
}
874
875
_inherits(FluxComponent, _React$Component);
876
877
FluxComponent.prototype.wrapChild = function wrapChild(child) {
878
return React.addons.cloneWithProps(child, this.getChildProps());
879
};
880
881
FluxComponent.prototype.getChildProps = function getChildProps() {
882
var _props = this.props;
883
var children = _props.children;
884
var render = _props.render;
885
var connectToStores = _props.connectToStores;
886
var stateGetter = _props.stateGetter;
887
var flux = _props.flux;
888
889
var extraProps = _objectWithoutProperties(_props, ['children', 'render', 'connectToStores', 'stateGetter', 'flux']);
890
891
return assign({ flux: this.getFlux() }, // TODO: remove in next major version
892
this.state, extraProps);
893
};
894
895
FluxComponent.prototype.render = (function (_render) {
896
function render() {
897
return _render.apply(this, arguments);
898
}
899
900
render.toString = function () {
901
return render.toString();
902
};
903
904
return render;
905
})(function () {
906
var _props2 = this.props;
907
var children = _props2.children;
908
var render = _props2.render;
909
910
if (typeof render === 'function') {
911
return render(this.getChildProps(), this.getFlux());
912
}
913
914
if (!children) return null;
915
916
if (!Array.isArray(children)) {
917
var child = children;
918
return this.wrapChild(child);
919
} else {
920
return React.createElement(
921
'span',
922
null,
923
React.Children.map(children, this.wrapChild)
924
);
925
}
926
});
927
928
return FluxComponent;
929
})(React.Component);
930
931
assign(FluxComponent.prototype, _instanceMethods$staticProperties.instanceMethods);
932
933
assign(FluxComponent, _instanceMethods$staticProperties.staticProperties);
934
935
module.exports = FluxComponent;
936
},{"./reactComponentMethods":7,"object-assign":12,"react/addons":14}],7:[function(require,module,exports){
937
'use strict';
938
939
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj['default'] : obj; };
940
941
exports.__esModule = true;
942
/**
943
* React Component methods. These are the primitives used to implement
944
* fluxMixin and FluxComponent.
945
*
946
* Exposes a Flux instance as `this.flux`. This requires that flux be passed as
947
* either context or as a prop (prop takes precedence). Children also are given
948
* access to flux instance as `context.flux`.
949
*
950
* It also adds the method `connectToStores()`, which ensures that the component
951
* state stays in sync with the specified Flux stores. See the inline docs
952
* of `connectToStores` for details.
953
*/
954
955
var _React$PropTypes = require('react');
956
957
var React = _interopRequire(_React$PropTypes);
958
959
var _Flux = require('../Flux');
960
961
var _assign = require('object-assign');
962
963
var assign = _interopRequire(_assign);
964
965
var instanceMethods = {
966
967
getChildContext: function getChildContext() {
968
var flux = this.getFlux();
969
970
if (!flux) {
971
return {};
972
}return { flux: flux };
973
},
974
975
getFlux: function getFlux() {
976
return this.props.flux || this.context.flux;
977
},
978
979
initialize: function initialize() {
980
this._fluxStateGetters = [];
981
this._fluxListeners = {};
982
this.flux = this.getFlux();
983
984
if (!(this.flux instanceof _Flux.Flux)) {
985
// TODO: print the actual class name here
986
throw new Error('fluxMixin: Could not find Flux instance. Ensure that your component ' + 'has either `this.context.flux` or `this.props.flux`.');
987
}
988
},
989
990
componentWillUnmount: function componentWillUnmount() {
991
var flux = this.getFlux();
992
993
for (var key in this._fluxListeners) {
994
if (!this._fluxListeners.hasOwnProperty(key)) continue;
995
996
var store = flux.getStore(key);
997
if (typeof store === 'undefined') continue;
998
999
var listener = this._fluxListeners[key];
1000
1001
store.removeListener('change', listener);
1002
}
1003
},
1004
1005
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
1006
this.updateStores(nextProps);
1007
},
1008
1009
updateStores: function updateStores() {
1010
var props = arguments[0] === undefined ? this.props : arguments[0];
1011
1012
var state = this.getStoreState(props);
1013
this.setState(state);
1014
},
1015
1016
getStoreState: function getStoreState() {
1017
var props = arguments[0] === undefined ? this.props : arguments[0];
1018
1019
return this._fluxStateGetters.reduce(function (result, stateGetter) {
1020
var getter = stateGetter.getter;
1021
var stores = stateGetter.stores;
1022
1023
var stateFromStores = getter(stores, props);
1024
return assign(result, stateFromStores);
1025
}, {});
1026
},
1027
1028
/**
1029
* Connect component to stores, get the combined initial state, and
1030
* subscribe to future changes. There are three ways to call it. The
1031
* simplest is to pass a single store key and, optionally, a state getter.
1032
* The state getter is a function that takes the store as a parameter and
1033
* returns the state that should be passed to the component's `setState()`.
1034
* If no state getter is specified, the default getter is used, which simply
1035
* returns the entire store state.
1036
*
1037
* The second form accepts an array of store keys. With this form, the state
1038
* getter is called once with an array of store instances (in the same order
1039
* as the store keys). the default getter performance a reduce on the entire
1040
* state for each store.
1041
*
1042
* The last form accepts an object of store keys mapped to state getters. As
1043
* a shortcut, you can pass `null` as a state getter to use the default
1044
* state getter.
1045
*
1046
* Returns the combined initial state of all specified stores.
1047
*
1048
* This way you can write all the initialization and update logic in a single
1049
* location, without having to mess with adding/removing listeners.
1050
*
1051
* @type {string|array|object} stateGetterMap - map of keys to getters
1052
* @returns {object} Combined initial state of stores
1053
*/
1054
connectToStores: function connectToStores() {
1055
var _this = this;
1056
1057
var stateGetterMap = arguments[0] === undefined ? {} : arguments[0];
1058
var stateGetter = arguments[1] === undefined ? null : arguments[1];
1059
1060
var flux = this.getFlux();
1061
1062
var getStore = function getStore(key) {
1063
var store = flux.getStore(key);
1064
1065
if (typeof store === 'undefined') {
1066
throw new Error('connectToStores(): Store with key \'' + key + '\' does not exist.');
1067
}
1068
1069
return store;
1070
};
1071
1072
if (typeof stateGetterMap === 'string') {
1073
var key = stateGetterMap;
1074
var store = getStore(key);
1075
var getter = stateGetter || defaultStateGetter;
1076
1077
this._fluxStateGetters.push({ stores: store, getter: getter });
1078
var listener = createStoreListener(this, store, getter);
1079
1080
store.addListener('change', listener);
1081
this._fluxListeners[key] = listener;
1082
} else if (Array.isArray(stateGetterMap)) {
1083
(function () {
1084
var stores = stateGetterMap.map(getStore);
1085
var getter = stateGetter || defaultReduceStateGetter;
1086
1087
_this._fluxStateGetters.push({ stores: stores, getter: getter });
1088
var listener = createStoreListener(_this, stores, getter);
1089
1090
stateGetterMap.forEach(function (key, index) {
1091
var store = stores[index];
1092
store.addListener('change', listener);
1093
_this._fluxListeners[key] = listener;
1094
});
1095
})();
1096
} else {
1097
for (var key in stateGetterMap) {
1098
var store = getStore(key);
1099
var getter = stateGetterMap[key] || defaultStateGetter;
1100
1101
this._fluxStateGetters.push({ stores: store, getter: getter });
1102
var listener = createStoreListener(this, store, getter);
1103
1104
store.addListener('change', listener);
1105
this._fluxListeners[key] = listener;
1106
}
1107
}
1108
1109
return this.getStoreState();
1110
}
1111
1112
};
1113
1114
var staticProperties = {
1115
contextTypes: {
1116
flux: _React$PropTypes.PropTypes.instanceOf(_Flux.Flux) },
1117
1118
childContextTypes: {
1119
flux: _React$PropTypes.PropTypes.instanceOf(_Flux.Flux) },
1120
1121
propTypes: {
1122
connectToStores: _React$PropTypes.PropTypes.oneOfType([_React$PropTypes.PropTypes.string, _React$PropTypes.PropTypes.arrayOf(_React$PropTypes.PropTypes.string), _React$PropTypes.PropTypes.object]),
1123
flux: _React$PropTypes.PropTypes.instanceOf(_Flux.Flux),
1124
render: React.PropTypes.func,
1125
stateGetter: React.PropTypes.func } };
1126
1127
exports.instanceMethods = instanceMethods;
1128
exports.staticProperties = staticProperties;
1129
1130
function createStoreListener(component, store, storeStateGetter) {
1131
return (function () {
1132
var state = storeStateGetter(store, this.props);
1133
this.setState(state);
1134
}).bind(component);
1135
}
1136
1137
function defaultStateGetter(store) {
1138
return store.getStateAsObject();
1139
}
1140
1141
function defaultReduceStateGetter(stores) {
1142
return stores.reduce(function (result, store) {
1143
return assign(result, store.getStateAsObject());
1144
}, {});
1145
}
1146
},{"../Flux":4,"object-assign":12,"react":186}],8:[function(require,module,exports){
1147
'use strict';
1148
1149
/**
1150
* Representation of a single EventEmitter function.
1151
*
1152
* @param {Function} fn Event handler to be called.
1153
* @param {Mixed} context Context for function execution.
1154
* @param {Boolean} once Only emit once
1155
* @api private
1156
*/
1157
function EE(fn, context, once) {
1158
this.fn = fn;
1159
this.context = context;
1160
this.once = once || false;
1161
}
1162
1163
/**
1164
* Minimal EventEmitter interface that is molded against the Node.js
1165
* EventEmitter interface.
1166
*
1167
* @constructor
1168
* @api public
1169
*/
1170
function EventEmitter() { /* Nothing to set */ }
1171
1172
/**
1173
* Holds the assigned EventEmitters by name.
1174
*
1175
* @type {Object}
1176
* @private
1177
*/
1178
EventEmitter.prototype._events = undefined;
1179
1180
/**
1181
* Return a list of assigned event listeners.
1182
*
1183
* @param {String} event The events that should be listed.
1184
* @returns {Array}
1185
* @api public
1186
*/
1187
EventEmitter.prototype.listeners = function listeners(event) {
1188
if (!this._events || !this._events[event]) return [];
1189
if (this._events[event].fn) return [this._events[event].fn];
1190
1191
for (var i = 0, l = this._events[event].length, ee = new Array(l); i < l; i++) {
1192
ee[i] = this._events[event][i].fn;
1193
}
1194
1195
return ee;
1196
};
1197
1198
/**
1199
* Emit an event to all registered event listeners.
1200
*
1201
* @param {String} event The name of the event.
1202
* @returns {Boolean} Indication if we've emitted an event.
1203
* @api public
1204
*/
1205
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
1206
if (!this._events || !this._events[event]) return false;
1207
1208
var listeners = this._events[event]
1209
, len = arguments.length
1210
, args
1211
, i;
1212
1213
if ('function' === typeof listeners.fn) {
1214
if (listeners.once) this.removeListener(event, listeners.fn, true);
1215
1216
switch (len) {
1217
case 1: return listeners.fn.call(listeners.context), true;
1218
case 2: return listeners.fn.call(listeners.context, a1), true;
1219
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
1220
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
1221
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
1222
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
1223
}
1224
1225
for (i = 1, args = new Array(len -1); i < len; i++) {
1226
args[i - 1] = arguments[i];
1227
}
1228
1229
listeners.fn.apply(listeners.context, args);
1230
} else {
1231
var length = listeners.length
1232
, j;
1233
1234
for (i = 0; i < length; i++) {
1235
if (listeners[i].once) this.removeListener(event, listeners[i].fn, true);
1236
1237
switch (len) {
1238
case 1: listeners[i].fn.call(listeners[i].context); break;
1239
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
1240
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
1241
default:
1242
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
1243
args[j - 1] = arguments[j];
1244
}
1245
1246
listeners[i].fn.apply(listeners[i].context, args);
1247
}
1248
}
1249
}
1250
1251
return true;
1252
};
1253
1254
/**
1255
* Register a new EventListener for the given event.
1256
*
1257
* @param {String} event Name of the event.
1258
* @param {Functon} fn Callback function.
1259
* @param {Mixed} context The context of the function.
1260
* @api public
1261
*/
1262
EventEmitter.prototype.on = function on(event, fn, context) {
1263
var listener = new EE(fn, context || this);
1264
1265
if (!this._events) this._events = {};
1266
if (!this._events[event]) this._events[event] = listener;
1267
else {
1268
if (!this._events[event].fn) this._events[event].push(listener);
1269
else this._events[event] = [
1270
this._events[event], listener
1271
];
1272
}
1273
1274
return this;
1275
};
1276
1277
/**
1278
* Add an EventListener that's only called once.
1279
*
1280
* @param {String} event Name of the event.
1281
* @param {Function} fn Callback function.
1282
* @param {Mixed} context The context of the function.
1283
* @api public
1284
*/
1285
EventEmitter.prototype.once = function once(event, fn, context) {
1286
var listener = new EE(fn, context || this, true);
1287
1288
if (!this._events) this._events = {};
1289
if (!this._events[event]) this._events[event] = listener;
1290
else {
1291
if (!this._events[event].fn) this._events[event].push(listener);
1292
else this._events[event] = [
1293
this._events[event], listener
1294
];
1295
}
1296
1297
return this;
1298
};
1299
1300
/**
1301
* Remove event listeners.
1302
*
1303
* @param {String} event The event we want to remove.
1304
* @param {Function} fn The listener that we need to find.
1305
* @param {Boolean} once Only remove once listeners.
1306
* @api public
1307
*/
1308
EventEmitter.prototype.removeListener = function removeListener(event, fn, once) {
1309
if (!this._events || !this._events[event]) return this;
1310
1311
var listeners = this._events[event]
1312
, events = [];
1313
1314
if (fn) {
1315
if (listeners.fn && (listeners.fn !== fn || (once && !listeners.once))) {
1316
events.push(listeners);
1317
}
1318
if (!listeners.fn) for (var i = 0, length = listeners.length; i < length; i++) {
1319
if (listeners[i].fn !== fn || (once && !listeners[i].once)) {
1320
events.push(listeners[i]);
1321
}
1322
}
1323
}
1324
1325
//
1326
// Reset the array, or remove it completely if we have no more listeners.
1327
//
1328
if (events.length) {
1329
this._events[event] = events.length === 1 ? events[0] : events;
1330
} else {
1331
delete this._events[event];
1332
}
1333
1334
return this;
1335
};
1336
1337
/**
1338
* Remove all listeners or only the listeners for the specified event.
1339
*
1340
* @param {String} event The event want to remove all listeners for.
1341
* @api public
1342
*/
1343
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
1344
if (!this._events) return this;
1345
1346
if (event) delete this._events[event];
1347
else this._events = {};
1348
1349
return this;
1350
};
1351
1352
//
1353
// Alias methods names because people roll like that.
1354
//
1355
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
1356
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
1357
1358
//
1359
// This function doesn't apply anymore.
1360
//
1361
EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
1362
return this;
1363
};
1364
1365
//
1366
// Expose the module.
1367
//
1368
EventEmitter.EventEmitter = EventEmitter;
1369
EventEmitter.EventEmitter2 = EventEmitter;
1370
EventEmitter.EventEmitter3 = EventEmitter;
1371
1372
//
1373
// Expose the module.
1374
//
1375
module.exports = EventEmitter;
1376
1377
},{}],9:[function(require,module,exports){
1378
/**
1379
* Copyright (c) 2014-2015, Facebook, Inc.
1380
* All rights reserved.
1381
*
1382
* This source code is licensed under the BSD-style license found in the
1383
* LICENSE file in the root directory of this source tree. An additional grant
1384
* of patent rights can be found in the PATENTS file in the same directory.
1385
*/
1386
1387
module.exports.Dispatcher = require('./lib/Dispatcher')
1388
1389
},{"./lib/Dispatcher":10}],10:[function(require,module,exports){
1390
/*
1391
* Copyright (c) 2014, Facebook, Inc.
1392
* All rights reserved.
1393
*
1394
* This source code is licensed under the BSD-style license found in the
1395
* LICENSE file in the root directory of this source tree. An additional grant
1396
* of patent rights can be found in the PATENTS file in the same directory.
1397
*
1398
* @providesModule Dispatcher
1399
* @typechecks
1400
*/
1401
1402
"use strict";
1403
1404
var invariant = require('./invariant');
1405
1406
var _lastID = 1;
1407
var _prefix = 'ID_';
1408
1409
/**
1410
* Dispatcher is used to broadcast payloads to registered callbacks. This is
1411
* different from generic pub-sub systems in two ways:
1412
*
1413
* 1) Callbacks are not subscribed to particular events. Every payload is
1414
* dispatched to every registered callback.
1415
* 2) Callbacks can be deferred in whole or part until other callbacks have
1416
* been executed.
1417
*
1418
* For example, consider this hypothetical flight destination form, which
1419
* selects a default city when a country is selected:
1420
*
1421
* var flightDispatcher = new Dispatcher();
1422
*
1423
* // Keeps track of which country is selected
1424
* var CountryStore = {country: null};
1425
*
1426
* // Keeps track of which city is selected
1427
* var CityStore = {city: null};
1428
*
1429
* // Keeps track of the base flight price of the selected city
1430
* var FlightPriceStore = {price: null}
1431
*
1432
* When a user changes the selected city, we dispatch the payload:
1433
*
1434
* flightDispatcher.dispatch({
1435
* actionType: 'city-update',
1436
* selectedCity: 'paris'
1437
* });
1438
*
1439
* This payload is digested by `CityStore`:
1440
*
1441
* flightDispatcher.register(function(payload) {
1442
* if (payload.actionType === 'city-update') {
1443
* CityStore.city = payload.selectedCity;
1444
* }
1445
* });
1446
*
1447
* When the user selects a country, we dispatch the payload:
1448
*
1449
* flightDispatcher.dispatch({
1450
* actionType: 'country-update',
1451
* selectedCountry: 'australia'
1452
* });
1453
*
1454
* This payload is digested by both stores:
1455
*
1456
* CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
1457
* if (payload.actionType === 'country-update') {
1458
* CountryStore.country = payload.selectedCountry;
1459
* }
1460
* });
1461
*
1462
* When the callback to update `CountryStore` is registered, we save a reference
1463
* to the returned token. Using this token with `waitFor()`, we can guarantee
1464
* that `CountryStore` is updated before the callback that updates `CityStore`
1465
* needs to query its data.
1466
*
1467
* CityStore.dispatchToken = flightDispatcher.register(function(payload) {
1468
* if (payload.actionType === 'country-update') {
1469
* // `CountryStore.country` may not be updated.
1470
* flightDispatcher.waitFor([CountryStore.dispatchToken]);
1471
* // `CountryStore.country` is now guaranteed to be updated.
1472
*
1473
* // Select the default city for the new country
1474
* CityStore.city = getDefaultCityForCountry(CountryStore.country);
1475
* }
1476
* });
1477
*
1478
* The usage of `waitFor()` can be chained, for example:
1479
*
1480
* FlightPriceStore.dispatchToken =
1481
* flightDispatcher.register(function(payload) {
1482
* switch (payload.actionType) {
1483
* case 'country-update':
1484
* flightDispatcher.waitFor([CityStore.dispatchToken]);
1485
* FlightPriceStore.price =
1486
* getFlightPriceStore(CountryStore.country, CityStore.city);
1487
* break;
1488
*
1489
* case 'city-update':
1490
* FlightPriceStore.price =
1491
* FlightPriceStore(CountryStore.country, CityStore.city);
1492
* break;
1493
* }
1494
* });
1495
*
1496
* The `country-update` payload will be guaranteed to invoke the stores'
1497
* registered callbacks in order: `CountryStore`, `CityStore`, then
1498
* `FlightPriceStore`.
1499
*/
1500
1501
function Dispatcher() {
1502
this.$Dispatcher_callbacks = {};
1503
this.$Dispatcher_isPending = {};
1504
this.$Dispatcher_isHandled = {};
1505
this.$Dispatcher_isDispatching = false;
1506
this.$Dispatcher_pendingPayload = null;
1507
}
1508
1509
/**
1510
* Registers a callback to be invoked with every dispatched payload. Returns
1511
* a token that can be used with `waitFor()`.
1512
*
1513
* @param {function} callback
1514
* @return {string}
1515
*/
1516
Dispatcher.prototype.register=function(callback) {
1517
var id = _prefix + _lastID++;
1518
this.$Dispatcher_callbacks[id] = callback;
1519
return id;
1520
};
1521
1522
/**
1523
* Removes a callback based on its token.
1524
*
1525
* @param {string} id
1526
*/
1527
Dispatcher.prototype.unregister=function(id) {
1528
invariant(
1529
this.$Dispatcher_callbacks[id],
1530
'Dispatcher.unregister(...): `%s` does not map to a registered callback.',
1531
id
1532
);
1533
delete this.$Dispatcher_callbacks[id];
1534
};
1535
1536
/**
1537
* Waits for the callbacks specified to be invoked before continuing execution
1538
* of the current callback. This method should only be used by a callback in
1539
* response to a dispatched payload.
1540
*
1541
* @param {array<string>} ids
1542
*/
1543
Dispatcher.prototype.waitFor=function(ids) {
1544
invariant(
1545
this.$Dispatcher_isDispatching,
1546
'Dispatcher.waitFor(...): Must be invoked while dispatching.'
1547
);
1548
for (var ii = 0; ii < ids.length; ii++) {
1549
var id = ids[ii];
1550
if (this.$Dispatcher_isPending[id]) {
1551
invariant(
1552
this.$Dispatcher_isHandled[id],
1553
'Dispatcher.waitFor(...): Circular dependency detected while ' +
1554
'waiting for `%s`.',
1555
id
1556
);
1557
continue;
1558
}
1559
invariant(
1560
this.$Dispatcher_callbacks[id],
1561
'Dispatcher.waitFor(...): `%s` does not map to a registered callback.',
1562
id
1563
);
1564
this.$Dispatcher_invokeCallback(id);
1565
}
1566
};
1567
1568
/**
1569
* Dispatches a payload to all registered callbacks.
1570
*
1571
* @param {object} payload
1572
*/
1573
Dispatcher.prototype.dispatch=function(payload) {
1574
invariant(
1575
!this.$Dispatcher_isDispatching,
1576
'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.'
1577
);
1578
this.$Dispatcher_startDispatching(payload);
1579
try {
1580
for (var id in this.$Dispatcher_callbacks) {
1581
if (this.$Dispatcher_isPending[id]) {
1582
continue;
1583
}
1584
this.$Dispatcher_invokeCallback(id);
1585
}
1586
} finally {
1587
this.$Dispatcher_stopDispatching();
1588
}
1589
};
1590
1591
/**
1592
* Is this Dispatcher currently dispatching.
1593
*
1594
* @return {boolean}
1595
*/
1596
Dispatcher.prototype.isDispatching=function() {
1597
return this.$Dispatcher_isDispatching;
1598
};
1599
1600
/**
1601
* Call the callback stored with the given id. Also do some internal
1602
* bookkeeping.
1603
*
1604
* @param {string} id
1605
* @internal
1606
*/
1607
Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) {
1608
this.$Dispatcher_isPending[id] = true;
1609
this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload);
1610
this.$Dispatcher_isHandled[id] = true;
1611
};
1612
1613
/**
1614
* Set up bookkeeping needed when dispatching.
1615
*
1616
* @param {object} payload
1617
* @internal
1618
*/
1619
Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) {
1620
for (var id in this.$Dispatcher_callbacks) {
1621
this.$Dispatcher_isPending[id] = false;
1622
this.$Dispatcher_isHandled[id] = false;
1623
}
1624
this.$Dispatcher_pendingPayload = payload;
1625
this.$Dispatcher_isDispatching = true;
1626
};
1627
1628
/**
1629
* Clear bookkeeping used for dispatching.
1630
*
1631
* @internal
1632
*/
1633
Dispatcher.prototype.$Dispatcher_stopDispatching=function() {
1634
this.$Dispatcher_pendingPayload = null;
1635
this.$Dispatcher_isDispatching = false;
1636
};
1637
1638
1639
module.exports = Dispatcher;
1640
1641
},{"./invariant":11}],11:[function(require,module,exports){
1642
/**
1643
* Copyright (c) 2014, Facebook, Inc.
1644
* All rights reserved.
1645
*
1646
* This source code is licensed under the BSD-style license found in the
1647
* LICENSE file in the root directory of this source tree. An additional grant
1648
* of patent rights can be found in the PATENTS file in the same directory.
1649
*
1650
* @providesModule invariant
1651
*/
1652
1653
"use strict";
1654
1655
/**
1656
* Use invariant() to assert state which your program assumes to be true.
1657
*
1658
* Provide sprintf-style format (only %s is supported) and arguments
1659
* to provide information about what broke and what you were
1660
* expecting.
1661
*
1662
* The invariant message will be stripped in production, but the invariant
1663
* will remain to ensure logic does not differ in production.
1664
*/
1665
1666
var invariant = function(condition, format, a, b, c, d, e, f) {
1667
if (false) {
1668
if (format === undefined) {
1669
throw new Error('invariant requires an error message argument');
1670
}
1671
}
1672
1673
if (!condition) {
1674
var error;
1675
if (format === undefined) {
1676
error = new Error(
1677
'Minified exception occurred; use the non-minified dev environment ' +
1678
'for the full error message and additional helpful warnings.'
1679
);
1680
} else {
1681
var args = [a, b, c, d, e, f];
1682
var argIndex = 0;
1683
error = new Error(
1684
'Invariant Violation: ' +
1685
format.replace(/%s/g, function() { return args[argIndex++]; })
1686
);
1687
}
1688
1689
error.framesToPop = 1; // we don't care about invariant's own frame
1690
throw error;
1691
}
1692
};
1693
1694
module.exports = invariant;
1695
1696
},{}],12:[function(require,module,exports){
1697
'use strict';
1698
1699
function ToObject(val) {
1700
if (val == null) {
1701
throw new TypeError('Object.assign cannot be called with null or undefined');
1702
}
1703
1704
return Object(val);
1705
}
1706
1707
module.exports = Object.assign || function (target, source) {
1708
var from;
1709
var keys;
1710
var to = ToObject(target);
1711
1712
for (var s = 1; s < arguments.length; s++) {
1713
from = arguments[s];
1714
keys = Object.keys(Object(from));
1715
1716
for (var i = 0; i < keys.length; i++) {
1717
to[keys[i]] = from[keys[i]];
1718
}
1719
}
1720
1721
return to;
1722
};
1723
1724
},{}],13:[function(require,module,exports){
1725
'use strict';
1726
1727
1728
var count = 0;
1729
1730
/**
1731
* Generate a unique ID.
1732
*
1733
* Optionally pass a prefix to prepend, a suffix to append, or a
1734
* multiplier to use on the ID.
1735
*
1736
* ```js
1737
* uniqueId(); //=> '25'
1738
*
1739
* uniqueId({prefix: 'apple_'});
1740
* //=> 'apple_10'
1741
*
1742
* uniqueId({suffix: '_orange'});
1743
* //=> '10_orange'
1744
*
1745
* uniqueId({multiplier: 5});
1746
* //=> 5, 10, 15, 20...
1747
* ```
1748
*
1749
* To reset the `id` to zero, do `id.reset()`.
1750
*
1751
* @param {Object} `options` Optionally pass a `prefix`, `suffix` and/or `multiplier.
1752
* @return {String} The unique id.
1753
* @api public
1754
*/
1755
1756
var id = module.exports = function (options) {
1757
options = options || {};
1758
1759
var prefix = options.prefix;
1760
var suffix = options.suffix;
1761
1762
var id = ++count * (options.multiplier || 1);
1763
1764
if (prefix == null) {
1765
prefix = '';
1766
}
1767
1768
if (suffix == null) {
1769
suffix = '';
1770
}
1771
1772
return String(prefix) + id + String(suffix);
1773
};
1774
1775
1776
id.reset = function() {
1777
return count = 0;
1778
};
1779
},{}],14:[function(require,module,exports){
1780
module.exports = require('./lib/ReactWithAddons');
1781
1782
},{"./lib/ReactWithAddons":114}],15:[function(require,module,exports){
1783
/**
1784
* Copyright 2013-2015, Facebook, Inc.
1785
* All rights reserved.
1786
*
1787
* This source code is licensed under the BSD-style license found in the
1788
* LICENSE file in the root directory of this source tree. An additional grant
1789
* of patent rights can be found in the PATENTS file in the same directory.
1790
*
1791
* @providesModule AutoFocusMixin
1792
* @typechecks static-only
1793
*/
1794
1795
'use strict';
1796
1797
var focusNode = require("./focusNode");
1798
1799
var AutoFocusMixin = {
1800
componentDidMount: function() {
1801
if (this.props.autoFocus) {
1802
focusNode(this.getDOMNode());
1803
}
1804
}
1805
};
1806
1807
module.exports = AutoFocusMixin;
1808
1809
},{"./focusNode":148}],16:[function(require,module,exports){
1810
/**
1811
* Copyright 2013-2015 Facebook, Inc.
1812
* All rights reserved.
1813
*
1814
* This source code is licensed under the BSD-style license found in the
1815
* LICENSE file in the root directory of this source tree. An additional grant
1816
* of patent rights can be found in the PATENTS file in the same directory.
1817
*
1818
* @providesModule BeforeInputEventPlugin
1819
* @typechecks static-only
1820
*/
1821
1822
'use strict';
1823
1824
var EventConstants = require("./EventConstants");
1825
var EventPropagators = require("./EventPropagators");
1826
var ExecutionEnvironment = require("./ExecutionEnvironment");
1827
var FallbackCompositionState = require("./FallbackCompositionState");
1828
var SyntheticCompositionEvent = require("./SyntheticCompositionEvent");
1829
var SyntheticInputEvent = require("./SyntheticInputEvent");
1830
1831
var keyOf = require("./keyOf");
1832
1833
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
1834
var START_KEYCODE = 229;
1835
1836
var canUseCompositionEvent = (
1837
ExecutionEnvironment.canUseDOM &&
1838
'CompositionEvent' in window
1839
);
1840
1841
var documentMode = null;
1842
if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
1843
documentMode = document.documentMode;
1844
}
1845
1846
// Webkit offers a very useful `textInput` event that can be used to
1847
// directly represent `beforeInput`. The IE `textinput` event is not as
1848
// useful, so we don't use it.
1849
var canUseTextInputEvent = (
1850
ExecutionEnvironment.canUseDOM &&
1851
'TextEvent' in window &&
1852
!documentMode &&
1853
!isPresto()
1854
);
1855
1856
// In IE9+, we have access to composition events, but the data supplied
1857
// by the native compositionend event may be incorrect. Japanese ideographic
1858
// spaces, for instance (\u3000) are not recorded correctly.
1859
var useFallbackCompositionData = (
1860
ExecutionEnvironment.canUseDOM &&
1861
(
1862
(!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11)
1863
)
1864
);
1865
1866
/**
1867
* Opera <= 12 includes TextEvent in window, but does not fire
1868
* text input events. Rely on keypress instead.
1869
*/
1870
function isPresto() {
1871
var opera = window.opera;
1872
return (
1873
typeof opera === 'object' &&
1874
typeof opera.version === 'function' &&
1875
parseInt(opera.version(), 10) <= 12
1876
);
1877
}
1878
1879
var SPACEBAR_CODE = 32;
1880
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
1881
1882
var topLevelTypes = EventConstants.topLevelTypes;
1883
1884
// Events and their corresponding property names.
1885
var eventTypes = {
1886
beforeInput: {
1887
phasedRegistrationNames: {
1888
bubbled: keyOf({onBeforeInput: null}),
1889
captured: keyOf({onBeforeInputCapture: null})
1890
},
1891
dependencies: [
1892
topLevelTypes.topCompositionEnd,
1893
topLevelTypes.topKeyPress,
1894
topLevelTypes.topTextInput,
1895
topLevelTypes.topPaste
1896
]
1897
},
1898
compositionEnd: {
1899
phasedRegistrationNames: {
1900
bubbled: keyOf({onCompositionEnd: null}),
1901
captured: keyOf({onCompositionEndCapture: null})
1902
},
1903
dependencies: [
1904
topLevelTypes.topBlur,
1905
topLevelTypes.topCompositionEnd,
1906
topLevelTypes.topKeyDown,
1907
topLevelTypes.topKeyPress,
1908
topLevelTypes.topKeyUp,
1909
topLevelTypes.topMouseDown
1910
]
1911
},
1912
compositionStart: {
1913
phasedRegistrationNames: {
1914
bubbled: keyOf({onCompositionStart: null}),
1915
captured: keyOf({onCompositionStartCapture: null})
1916
},
1917
dependencies: [
1918
topLevelTypes.topBlur,
1919
topLevelTypes.topCompositionStart,
1920
topLevelTypes.topKeyDown,
1921
topLevelTypes.topKeyPress,
1922
topLevelTypes.topKeyUp,
1923
topLevelTypes.topMouseDown
1924
]
1925
},
1926
compositionUpdate: {
1927
phasedRegistrationNames: {
1928
bubbled: keyOf({onCompositionUpdate: null}),
1929
captured: keyOf({onCompositionUpdateCapture: null})
1930
},
1931
dependencies: [
1932
topLevelTypes.topBlur,
1933
topLevelTypes.topCompositionUpdate,
1934
topLevelTypes.topKeyDown,
1935
topLevelTypes.topKeyPress,
1936
topLevelTypes.topKeyUp,
1937
topLevelTypes.topMouseDown
1938
]
1939
}
1940
};
1941
1942
// Track whether we've ever handled a keypress on the space key.
1943
var hasSpaceKeypress = false;
1944
1945
/**
1946
* Return whether a native keypress event is assumed to be a command.
1947
* This is required because Firefox fires `keypress` events for key commands
1948
* (cut, copy, select-all, etc.) even though no character is inserted.
1949
*/
1950
function isKeypressCommand(nativeEvent) {
1951
return (
1952
(nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
1953
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
1954
!(nativeEvent.ctrlKey && nativeEvent.altKey)
1955
);
1956
}
1957
1958
1959
/**
1960
* Translate native top level events into event types.
1961
*
1962
* @param {string} topLevelType
1963
* @return {object}
1964
*/
1965
function getCompositionEventType(topLevelType) {
1966
switch (topLevelType) {
1967
case topLevelTypes.topCompositionStart:
1968
return eventTypes.compositionStart;
1969
case topLevelTypes.topCompositionEnd:
1970
return eventTypes.compositionEnd;
1971
case topLevelTypes.topCompositionUpdate:
1972
return eventTypes.compositionUpdate;
1973
}
1974
}
1975
1976
/**
1977
* Does our fallback best-guess model think this event signifies that
1978
* composition has begun?
1979
*
1980
* @param {string} topLevelType
1981
* @param {object} nativeEvent
1982
* @return {boolean}
1983
*/
1984
function isFallbackCompositionStart(topLevelType, nativeEvent) {
1985
return (
1986
topLevelType === topLevelTypes.topKeyDown &&
1987
nativeEvent.keyCode === START_KEYCODE
1988
);
1989
}
1990
1991
/**
1992
* Does our fallback mode think that this event is the end of composition?
1993
*
1994
* @param {string} topLevelType
1995
* @param {object} nativeEvent
1996
* @return {boolean}
1997
*/
1998
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
1999
switch (topLevelType) {
2000
case topLevelTypes.topKeyUp:
2001
// Command keys insert or clear IME input.
2002
return (END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1);
2003
case topLevelTypes.topKeyDown:
2004
// Expect IME keyCode on each keydown. If we get any other
2005
// code we must have exited earlier.
2006
return (nativeEvent.keyCode !== START_KEYCODE);
2007
case topLevelTypes.topKeyPress:
2008
case topLevelTypes.topMouseDown:
2009
case topLevelTypes.topBlur:
2010
// Events are not possible without cancelling IME.
2011
return true;
2012
default:
2013
return false;
2014
}
2015
}
2016
2017
/**
2018
* Google Input Tools provides composition data via a CustomEvent,
2019
* with the `data` property populated in the `detail` object. If this
2020
* is available on the event object, use it. If not, this is a plain
2021
* composition event and we have nothing special to extract.
2022
*
2023
* @param {object} nativeEvent
2024
* @return {?string}
2025
*/
2026
function getDataFromCustomEvent(nativeEvent) {
2027
var detail = nativeEvent.detail;
2028
if (typeof detail === 'object' && 'data' in detail) {
2029
return detail.data;
2030
}
2031
return null;
2032
}
2033
2034
// Track the current IME composition fallback object, if any.
2035
var currentComposition = null;
2036
2037
/**
2038
* @param {string} topLevelType Record from `EventConstants`.
2039
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2040
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2041
* @param {object} nativeEvent Native browser event.
2042
* @return {?object} A SyntheticCompositionEvent.
2043
*/
2044
function extractCompositionEvent(
2045
topLevelType,
2046
topLevelTarget,
2047
topLevelTargetID,
2048
nativeEvent
2049
) {
2050
var eventType;
2051
var fallbackData;
2052
2053
if (canUseCompositionEvent) {
2054
eventType = getCompositionEventType(topLevelType);
2055
} else if (!currentComposition) {
2056
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
2057
eventType = eventTypes.compositionStart;
2058
}
2059
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
2060
eventType = eventTypes.compositionEnd;
2061
}
2062
2063
if (!eventType) {
2064
return null;
2065
}
2066
2067
if (useFallbackCompositionData) {
2068
// The current composition is stored statically and must not be
2069
// overwritten while composition continues.
2070
if (!currentComposition && eventType === eventTypes.compositionStart) {
2071
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
2072
} else if (eventType === eventTypes.compositionEnd) {
2073
if (currentComposition) {
2074
fallbackData = currentComposition.getData();
2075
}
2076
}
2077
}
2078
2079
var event = SyntheticCompositionEvent.getPooled(
2080
eventType,
2081
topLevelTargetID,
2082
nativeEvent
2083
);
2084
2085
if (fallbackData) {
2086
// Inject data generated from fallback path into the synthetic event.
2087
// This matches the property of native CompositionEventInterface.
2088
event.data = fallbackData;
2089
} else {
2090
var customData = getDataFromCustomEvent(nativeEvent);
2091
if (customData !== null) {
2092
event.data = customData;
2093
}
2094
}
2095
2096
EventPropagators.accumulateTwoPhaseDispatches(event);
2097
return event;
2098
}
2099
2100
/**
2101
* @param {string} topLevelType Record from `EventConstants`.
2102
* @param {object} nativeEvent Native browser event.
2103
* @return {?string} The string corresponding to this `beforeInput` event.
2104
*/
2105
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
2106
switch (topLevelType) {
2107
case topLevelTypes.topCompositionEnd:
2108
return getDataFromCustomEvent(nativeEvent);
2109
case topLevelTypes.topKeyPress:
2110
/**
2111
* If native `textInput` events are available, our goal is to make
2112
* use of them. However, there is a special case: the spacebar key.
2113
* In Webkit, preventing default on a spacebar `textInput` event
2114
* cancels character insertion, but it *also* causes the browser
2115
* to fall back to its default spacebar behavior of scrolling the
2116
* page.
2117
*
2118
* Tracking at:
2119
* https://code.google.com/p/chromium/issues/detail?id=355103
2120
*
2121
* To avoid this issue, use the keypress event as if no `textInput`
2122
* event is available.
2123
*/
2124
var which = nativeEvent.which;
2125
if (which !== SPACEBAR_CODE) {
2126
return null;
2127
}
2128
2129
hasSpaceKeypress = true;
2130
return SPACEBAR_CHAR;
2131
2132
case topLevelTypes.topTextInput:
2133
// Record the characters to be added to the DOM.
2134
var chars = nativeEvent.data;
2135
2136
// If it's a spacebar character, assume that we have already handled
2137
// it at the keypress level and bail immediately. Android Chrome
2138
// doesn't give us keycodes, so we need to blacklist it.
2139
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
2140
return null;
2141
}
2142
2143
return chars;
2144
2145
default:
2146
// For other native event types, do nothing.
2147
return null;
2148
}
2149
}
2150
2151
/**
2152
* For browsers that do not provide the `textInput` event, extract the
2153
* appropriate string to use for SyntheticInputEvent.
2154
*
2155
* @param {string} topLevelType Record from `EventConstants`.
2156
* @param {object} nativeEvent Native browser event.
2157
* @return {?string} The fallback string for this `beforeInput` event.
2158
*/
2159
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
2160
// If we are currently composing (IME) and using a fallback to do so,
2161
// try to extract the composed characters from the fallback object.
2162
if (currentComposition) {
2163
if (
2164
topLevelType === topLevelTypes.topCompositionEnd ||
2165
isFallbackCompositionEnd(topLevelType, nativeEvent)
2166
) {
2167
var chars = currentComposition.getData();
2168
FallbackCompositionState.release(currentComposition);
2169
currentComposition = null;
2170
return chars;
2171
}
2172
return null;
2173
}
2174
2175
switch (topLevelType) {
2176
case topLevelTypes.topPaste:
2177
// If a paste event occurs after a keypress, throw out the input
2178
// chars. Paste events should not lead to BeforeInput events.
2179
return null;
2180
case topLevelTypes.topKeyPress:
2181
/**
2182
* As of v27, Firefox may fire keypress events even when no character
2183
* will be inserted. A few possibilities:
2184
*
2185
* - `which` is `0`. Arrow keys, Esc key, etc.
2186
*
2187
* - `which` is the pressed key code, but no char is available.
2188
* Ex: 'AltGr + d` in Polish. There is no modified character for
2189
* this key combination and no character is inserted into the
2190
* document, but FF fires the keypress for char code `100` anyway.
2191
* No `input` event will occur.
2192
*
2193
* - `which` is the pressed key code, but a command combination is
2194
* being used. Ex: `Cmd+C`. No character is inserted, and no
2195
* `input` event will occur.
2196
*/
2197
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
2198
return String.fromCharCode(nativeEvent.which);
2199
}
2200
return null;
2201
case topLevelTypes.topCompositionEnd:
2202
return useFallbackCompositionData ? null : nativeEvent.data;
2203
default:
2204
return null;
2205
}
2206
}
2207
2208
/**
2209
* Extract a SyntheticInputEvent for `beforeInput`, based on either native
2210
* `textInput` or fallback behavior.
2211
*
2212
* @param {string} topLevelType Record from `EventConstants`.
2213
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2214
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2215
* @param {object} nativeEvent Native browser event.
2216
* @return {?object} A SyntheticInputEvent.
2217
*/
2218
function extractBeforeInputEvent(
2219
topLevelType,
2220
topLevelTarget,
2221
topLevelTargetID,
2222
nativeEvent
2223
) {
2224
var chars;
2225
2226
if (canUseTextInputEvent) {
2227
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
2228
} else {
2229
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
2230
}
2231
2232
// If no characters are being inserted, no BeforeInput event should
2233
// be fired.
2234
if (!chars) {
2235
return null;
2236
}
2237
2238
var event = SyntheticInputEvent.getPooled(
2239
eventTypes.beforeInput,
2240
topLevelTargetID,
2241
nativeEvent
2242
);
2243
2244
event.data = chars;
2245
EventPropagators.accumulateTwoPhaseDispatches(event);
2246
return event;
2247
}
2248
2249
/**
2250
* Create an `onBeforeInput` event to match
2251
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
2252
*
2253
* This event plugin is based on the native `textInput` event
2254
* available in Chrome, Safari, Opera, and IE. This event fires after
2255
* `onKeyPress` and `onCompositionEnd`, but before `onInput`.
2256
*
2257
* `beforeInput` is spec'd but not implemented in any browsers, and
2258
* the `input` event does not provide any useful information about what has
2259
* actually been added, contrary to the spec. Thus, `textInput` is the best
2260
* available event to identify the characters that have actually been inserted
2261
* into the target node.
2262
*
2263
* This plugin is also responsible for emitting `composition` events, thus
2264
* allowing us to share composition fallback code for both `beforeInput` and
2265
* `composition` event types.
2266
*/
2267
var BeforeInputEventPlugin = {
2268
2269
eventTypes: eventTypes,
2270
2271
/**
2272
* @param {string} topLevelType Record from `EventConstants`.
2273
* @param {DOMEventTarget} topLevelTarget The listening component root node.
2274
* @param {string} topLevelTargetID ID of `topLevelTarget`.
2275
* @param {object} nativeEvent Native browser event.
2276
* @return {*} An accumulation of synthetic events.
2277
* @see {EventPluginHub.extractEvents}
2278
*/
2279
extractEvents: function(
2280
topLevelType,
2281
topLevelTarget,
2282
topLevelTargetID,
2283
nativeEvent
2284
) {
2285
return [
2286
extractCompositionEvent(
2287
topLevelType,
2288
topLevelTarget,
2289
topLevelTargetID,
2290
nativeEvent
2291
),
2292
extractBeforeInputEvent(
2293
topLevelType,
2294
topLevelTarget,
2295
topLevelTargetID,
2296
nativeEvent
2297
)
2298
];
2299
}
2300
};
2301
2302
module.exports = BeforeInputEventPlugin;
2303
2304
},{"./EventConstants":29,"./EventPropagators":34,"./ExecutionEnvironment":35,"./FallbackCompositionState":36,"./SyntheticCompositionEvent":120,"./SyntheticInputEvent":124,"./keyOf":171}],17:[function(require,module,exports){
2305
(function (process){
2306
/**
2307
* Copyright 2013-2015, Facebook, Inc.
2308
* All rights reserved.
2309
*
2310
* This source code is licensed under the BSD-style license found in the
2311
* LICENSE file in the root directory of this source tree. An additional grant
2312
* of patent rights can be found in the PATENTS file in the same directory.
2313
*
2314
* @providesModule CSSCore
2315
* @typechecks
2316
*/
2317
2318
var invariant = require("./invariant");
2319
2320
/**
2321
* The CSSCore module specifies the API (and implements most of the methods)
2322
* that should be used when dealing with the display of elements (via their
2323
* CSS classes and visibility on screen. It is an API focused on mutating the
2324
* display and not reading it as no logical state should be encoded in the
2325
* display of elements.
2326
*/
2327
2328
var CSSCore = {
2329
2330
/**
2331
* Adds the class passed in to the element if it doesn't already have it.
2332
*
2333
* @param {DOMElement} element the element to set the class on
2334
* @param {string} className the CSS className
2335
* @return {DOMElement} the element passed in
2336
*/
2337
addClass: function(element, className) {
2338
("production" !== process.env.NODE_ENV ? invariant(
2339
!/\s/.test(className),
2340
'CSSCore.addClass takes only a single class name. "%s" contains ' +
2341
'multiple classes.', className
2342
) : invariant(!/\s/.test(className)));
2343
2344
if (className) {
2345
if (element.classList) {
2346
element.classList.add(className);
2347
} else if (!CSSCore.hasClass(element, className)) {
2348
element.className = element.className + ' ' + className;
2349
}
2350
}
2351
return element;
2352
},
2353
2354
/**
2355
* Removes the class passed in from the element
2356
*
2357
* @param {DOMElement} element the element to set the class on
2358
* @param {string} className the CSS className
2359
* @return {DOMElement} the element passed in
2360
*/
2361
removeClass: function(element, className) {
2362
("production" !== process.env.NODE_ENV ? invariant(
2363
!/\s/.test(className),
2364
'CSSCore.removeClass takes only a single class name. "%s" contains ' +
2365
'multiple classes.', className
2366
) : invariant(!/\s/.test(className)));
2367
2368
if (className) {
2369
if (element.classList) {
2370
element.classList.remove(className);
2371
} else if (CSSCore.hasClass(element, className)) {
2372
element.className = element.className
2373
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
2374
.replace(/\s+/g, ' ') // multiple spaces to one
2375
.replace(/^\s*|\s*$/g, ''); // trim the ends
2376
}
2377
}
2378
return element;
2379
},
2380
2381
/**
2382
* Helper to add or remove a class from an element based on a condition.
2383
*
2384
* @param {DOMElement} element the element to set the class on
2385
* @param {string} className the CSS className
2386
* @param {*} bool condition to whether to add or remove the class
2387
* @return {DOMElement} the element passed in
2388
*/
2389
conditionClass: function(element, className, bool) {
2390
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
2391
},
2392
2393
/**
2394
* Tests whether the element has the class specified.
2395
*
2396
* @param {DOMNode|DOMWindow} element the element to set the class on
2397
* @param {string} className the CSS className
2398
* @return {boolean} true if the element has the class, false if not
2399
*/
2400
hasClass: function(element, className) {
2401
("production" !== process.env.NODE_ENV ? invariant(
2402
!/\s/.test(className),
2403
'CSS.hasClass takes only a single class name.'
2404
) : invariant(!/\s/.test(className)));
2405
if (element.classList) {
2406
return !!className && element.classList.contains(className);
2407
}
2408
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
2409
}
2410
2411
};
2412
2413
module.exports = CSSCore;
2414
2415
}).call(this,require('_process'))
2416
},{"./invariant":164,"_process":1}],18:[function(require,module,exports){
2417
/**
2418
* Copyright 2013-2015, Facebook, Inc.
2419
* All rights reserved.
2420
*
2421
* This source code is licensed under the BSD-style license found in the
2422
* LICENSE file in the root directory of this source tree. An additional grant
2423
* of patent rights can be found in the PATENTS file in the same directory.
2424
*
2425
* @providesModule CSSProperty
2426
*/
2427
2428
'use strict';
2429
2430
/**
2431
* CSS properties which accept numbers but are not in units of "px".
2432
*/
2433
var isUnitlessNumber = {
2434
boxFlex: true,
2435
boxFlexGroup: true,
2436
columnCount: true,
2437
flex: true,
2438
flexGrow: true,
2439
flexPositive: true,
2440
flexShrink: true,
2441
flexNegative: true,
2442
fontWeight: true,
2443
lineClamp: true,
2444
lineHeight: true,
2445
opacity: true,
2446
order: true,
2447
orphans: true,
2448
widows: true,
2449
zIndex: true,
2450
zoom: true,
2451
2452
// SVG-related properties
2453
fillOpacity: true,
2454
strokeDashoffset: true,
2455
strokeOpacity: true,
2456
strokeWidth: true
2457
};
2458
2459
/**
2460
* @param {string} prefix vendor-specific prefix, eg: Webkit
2461
* @param {string} key style name, eg: transitionDuration
2462
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
2463
* WebkitTransitionDuration
2464
*/
2465
function prefixKey(prefix, key) {
2466
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
2467
}
2468
2469
/**
2470
* Support style names that may come passed in prefixed by adding permutations
2471
* of vendor prefixes.
2472
*/
2473
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
2474
2475
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
2476
// infinite loop, because it iterates over the newly added props too.
2477
Object.keys(isUnitlessNumber).forEach(function(prop) {
2478
prefixes.forEach(function(prefix) {
2479
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
2480
});
2481
});
2482
2483
/**
2484
* Most style properties can be unset by doing .style[prop] = '' but IE8
2485
* doesn't like doing that with shorthand properties so for the properties that
2486
* IE8 breaks on, which are listed here, we instead unset each of the
2487
* individual properties. See http://bugs.jquery.com/ticket/12385.
2488
* The 4-value 'clock' properties like margin, padding, border-width seem to
2489
* behave without any problems. Curiously, list-style works too without any
2490
* special prodding.
2491
*/
2492
var shorthandPropertyExpansions = {
2493
background: {
2494
backgroundImage: true,
2495
backgroundPosition: true,
2496
backgroundRepeat: true,
2497
backgroundColor: true
2498
},
2499
border: {
2500
borderWidth: true,
2501
borderStyle: true,
2502
borderColor: true
2503
},
2504
borderBottom: {
2505
borderBottomWidth: true,
2506
borderBottomStyle: true,
2507
borderBottomColor: true
2508
},
2509
borderLeft: {
2510
borderLeftWidth: true,
2511
borderLeftStyle: true,
2512
borderLeftColor: true
2513
},
2514
borderRight: {
2515
borderRightWidth: true,
2516
borderRightStyle: true,
2517
borderRightColor: true
2518
},
2519
borderTop: {
2520
borderTopWidth: true,
2521
borderTopStyle: true,
2522
borderTopColor: true
2523
},
2524
font: {
2525
fontStyle: true,
2526
fontVariant: true,
2527
fontWeight: true,
2528
fontSize: true,
2529
lineHeight: true,
2530
fontFamily: true
2531
}
2532
};
2533
2534
var CSSProperty = {
2535
isUnitlessNumber: isUnitlessNumber,
2536
shorthandPropertyExpansions: shorthandPropertyExpansions
2537
};
2538
2539
module.exports = CSSProperty;
2540
2541
},{}],19:[function(require,module,exports){
2542
(function (process){
2543
/**
2544
* Copyright 2013-2015, Facebook, Inc.
2545
* All rights reserved.
2546
*
2547
* This source code is licensed under the BSD-style license found in the
2548
* LICENSE file in the root directory of this source tree. An additional grant
2549
* of patent rights can be found in the PATENTS file in the same directory.
2550
*
2551
* @providesModule CSSPropertyOperations
2552
* @typechecks static-only
2553
*/
2554
2555
'use strict';
2556
2557
var CSSProperty = require("./CSSProperty");
2558
var ExecutionEnvironment = require("./ExecutionEnvironment");
2559
2560
var camelizeStyleName = require("./camelizeStyleName");
2561
var dangerousStyleValue = require("./dangerousStyleValue");
2562
var hyphenateStyleName = require("./hyphenateStyleName");
2563
var memoizeStringOnly = require("./memoizeStringOnly");
2564
var warning = require("./warning");
2565
2566
var processStyleName = memoizeStringOnly(function(styleName) {
2567
return hyphenateStyleName(styleName);
2568
});
2569
2570
var styleFloatAccessor = 'cssFloat';
2571
if (ExecutionEnvironment.canUseDOM) {
2572
// IE8 only supports accessing cssFloat (standard) as styleFloat
2573
if (document.documentElement.style.cssFloat === undefined) {
2574
styleFloatAccessor = 'styleFloat';
2575
}
2576
}
2577
2578
if ("production" !== process.env.NODE_ENV) {
2579
// 'msTransform' is correct, but the other prefixes should be capitalized
2580
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
2581
2582
// style values shouldn't contain a semicolon
2583
var badStyleValueWithSemicolonPattern = /;\s*$/;
2584
2585
var warnedStyleNames = {};
2586
var warnedStyleValues = {};
2587
2588
var warnHyphenatedStyleName = function(name) {
2589
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
2590
return;
2591
}
2592
2593
warnedStyleNames[name] = true;
2594
("production" !== process.env.NODE_ENV ? warning(
2595
false,
2596
'Unsupported style property %s. Did you mean %s?',
2597
name,
2598
camelizeStyleName(name)
2599
) : null);
2600
};
2601
2602
var warnBadVendoredStyleName = function(name) {
2603
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
2604
return;
2605
}
2606
2607
warnedStyleNames[name] = true;
2608
("production" !== process.env.NODE_ENV ? warning(
2609
false,
2610
'Unsupported vendor-prefixed style property %s. Did you mean %s?',
2611
name,
2612
name.charAt(0).toUpperCase() + name.slice(1)
2613
) : null);
2614
};
2615
2616
var warnStyleValueWithSemicolon = function(name, value) {
2617
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
2618
return;
2619
}
2620
2621
warnedStyleValues[value] = true;
2622
("production" !== process.env.NODE_ENV ? warning(
2623
false,
2624
'Style property values shouldn\'t contain a semicolon. ' +
2625
'Try "%s: %s" instead.',
2626
name,
2627
value.replace(badStyleValueWithSemicolonPattern, '')
2628
) : null);
2629
};
2630
2631
/**
2632
* @param {string} name
2633
* @param {*} value
2634
*/
2635
var warnValidStyle = function(name, value) {
2636
if (name.indexOf('-') > -1) {
2637
warnHyphenatedStyleName(name);
2638
} else if (badVendoredStyleNamePattern.test(name)) {
2639
warnBadVendoredStyleName(name);
2640
} else if (badStyleValueWithSemicolonPattern.test(value)) {
2641
warnStyleValueWithSemicolon(name, value);
2642
}
2643
};
2644
}
2645
2646
/**
2647
* Operations for dealing with CSS properties.
2648
*/
2649
var CSSPropertyOperations = {
2650
2651
/**
2652
* Serializes a mapping of style properties for use as inline styles:
2653
*
2654
* > createMarkupForStyles({width: '200px', height: 0})
2655
* "width:200px;height:0;"
2656
*
2657
* Undefined values are ignored so that declarative programming is easier.
2658
* The result should be HTML-escaped before insertion into the DOM.
2659
*
2660
* @param {object} styles
2661
* @return {?string}
2662
*/
2663
createMarkupForStyles: function(styles) {
2664
var serialized = '';
2665
for (var styleName in styles) {
2666
if (!styles.hasOwnProperty(styleName)) {
2667
continue;
2668
}
2669
var styleValue = styles[styleName];
2670
if ("production" !== process.env.NODE_ENV) {
2671
warnValidStyle(styleName, styleValue);
2672
}
2673
if (styleValue != null) {
2674
serialized += processStyleName(styleName) + ':';
2675
serialized += dangerousStyleValue(styleName, styleValue) + ';';
2676
}
2677
}
2678
return serialized || null;
2679
},
2680
2681
/**
2682
* Sets the value for multiple styles on a node. If a value is specified as
2683
* '' (empty string), the corresponding style property will be unset.
2684
*
2685
* @param {DOMElement} node
2686
* @param {object} styles
2687
*/
2688
setValueForStyles: function(node, styles) {
2689
var style = node.style;
2690
for (var styleName in styles) {
2691
if (!styles.hasOwnProperty(styleName)) {
2692
continue;
2693
}
2694
if ("production" !== process.env.NODE_ENV) {
2695
warnValidStyle(styleName, styles[styleName]);
2696
}
2697
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
2698
if (styleName === 'float') {
2699
styleName = styleFloatAccessor;
2700
}
2701
if (styleValue) {
2702
style[styleName] = styleValue;
2703
} else {
2704
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
2705
if (expansion) {
2706
// Shorthand property that IE8 won't like unsetting, so unset each
2707
// component to placate it
2708
for (var individualStyleName in expansion) {
2709
style[individualStyleName] = '';
2710
}
2711
} else {
2712
style[styleName] = '';
2713
}
2714
}
2715
}
2716
}
2717
2718
};
2719
2720
module.exports = CSSPropertyOperations;
2721
2722
}).call(this,require('_process'))
2723
},{"./CSSProperty":18,"./ExecutionEnvironment":35,"./camelizeStyleName":135,"./dangerousStyleValue":142,"./hyphenateStyleName":162,"./memoizeStringOnly":173,"./warning":185,"_process":1}],20:[function(require,module,exports){
2724
(function (process){
2725
/**
2726
* Copyright 2013-2015, Facebook, Inc.
2727
* All rights reserved.
2728
*
2729
* This source code is licensed under the BSD-style license found in the
2730
* LICENSE file in the root directory of this source tree. An additional grant
2731
* of patent rights can be found in the PATENTS file in the same directory.
2732
*
2733
* @providesModule CallbackQueue
2734
*/
2735
2736
'use strict';
2737
2738
var PooledClass = require("./PooledClass");
2739
2740
var assign = require("./Object.assign");
2741
var invariant = require("./invariant");
2742
2743
/**
2744
* A specialized pseudo-event module to help keep track of components waiting to
2745
* be notified when their DOM representations are available for use.
2746
*
2747
* This implements `PooledClass`, so you should never need to instantiate this.
2748
* Instead, use `CallbackQueue.getPooled()`.
2749
*
2750
* @class ReactMountReady
2751
* @implements PooledClass
2752
* @internal
2753
*/
2754
function CallbackQueue() {
2755
this._callbacks = null;
2756
this._contexts = null;
2757
}
2758
2759
assign(CallbackQueue.prototype, {
2760
2761
/**
2762
* Enqueues a callback to be invoked when `notifyAll` is invoked.
2763
*
2764
* @param {function} callback Invoked when `notifyAll` is invoked.
2765
* @param {?object} context Context to call `callback` with.
2766
* @internal
2767
*/
2768
enqueue: function(callback, context) {
2769
this._callbacks = this._callbacks || [];
2770
this._contexts = this._contexts || [];
2771
this._callbacks.push(callback);
2772
this._contexts.push(context);
2773
},
2774
2775
/**
2776
* Invokes all enqueued callbacks and clears the queue. This is invoked after
2777
* the DOM representation of a component has been created or updated.
2778
*
2779
* @internal
2780
*/
2781
notifyAll: function() {
2782
var callbacks = this._callbacks;
2783
var contexts = this._contexts;
2784
if (callbacks) {
2785
("production" !== process.env.NODE_ENV ? invariant(
2786
callbacks.length === contexts.length,
2787
'Mismatched list of contexts in callback queue'
2788
) : invariant(callbacks.length === contexts.length));
2789
this._callbacks = null;
2790
this._contexts = null;
2791
for (var i = 0, l = callbacks.length; i < l; i++) {
2792
callbacks[i].call(contexts[i]);
2793
}
2794
callbacks.length = 0;
2795
contexts.length = 0;
2796
}
2797
},
2798
2799
/**
2800
* Resets the internal queue.
2801
*
2802
* @internal
2803
*/
2804
reset: function() {
2805
this._callbacks = null;
2806
this._contexts = null;
2807
},
2808
2809
/**
2810
* `PooledClass` looks for this.
2811
*/
2812
destructor: function() {
2813
this.reset();
2814
}
2815
2816
});
2817
2818
PooledClass.addPoolingTo(CallbackQueue);
2819
2820
module.exports = CallbackQueue;
2821
2822
}).call(this,require('_process'))
2823
},{"./Object.assign":42,"./PooledClass":43,"./invariant":164,"_process":1}],21:[function(require,module,exports){
2824
/**
2825
* Copyright 2013-2015, Facebook, Inc.
2826
* All rights reserved.
2827
*
2828
* This source code is licensed under the BSD-style license found in the
2829
* LICENSE file in the root directory of this source tree. An additional grant
2830
* of patent rights can be found in the PATENTS file in the same directory.
2831
*
2832
* @providesModule ChangeEventPlugin
2833
*/
2834
2835
'use strict';
2836
2837
var EventConstants = require("./EventConstants");
2838
var EventPluginHub = require("./EventPluginHub");
2839
var EventPropagators = require("./EventPropagators");
2840
var ExecutionEnvironment = require("./ExecutionEnvironment");
2841
var ReactUpdates = require("./ReactUpdates");
2842
var SyntheticEvent = require("./SyntheticEvent");
2843
2844
var isEventSupported = require("./isEventSupported");
2845
var isTextInputElement = require("./isTextInputElement");
2846
var keyOf = require("./keyOf");
2847
2848
var topLevelTypes = EventConstants.topLevelTypes;
2849
2850
var eventTypes = {
2851
change: {
2852
phasedRegistrationNames: {
2853
bubbled: keyOf({onChange: null}),
2854
captured: keyOf({onChangeCapture: null})
2855
},
2856
dependencies: [
2857
topLevelTypes.topBlur,
2858
topLevelTypes.topChange,
2859
topLevelTypes.topClick,
2860
topLevelTypes.topFocus,
2861
topLevelTypes.topInput,
2862
topLevelTypes.topKeyDown,
2863
topLevelTypes.topKeyUp,
2864
topLevelTypes.topSelectionChange
2865
]
2866
}
2867
};
2868
2869
/**
2870
* For IE shims
2871
*/
2872
var activeElement = null;
2873
var activeElementID = null;
2874
var activeElementValue = null;
2875
var activeElementValueProp = null;
2876
2877
/**
2878
* SECTION: handle `change` event
2879
*/
2880
function shouldUseChangeEvent(elem) {
2881
return (
2882
elem.nodeName === 'SELECT' ||
2883
(elem.nodeName === 'INPUT' && elem.type === 'file')
2884
);
2885
}
2886
2887
var doesChangeEventBubble = false;
2888
if (ExecutionEnvironment.canUseDOM) {
2889
// See `handleChange` comment below
2890
doesChangeEventBubble = isEventSupported('change') && (
2891
(!('documentMode' in document) || document.documentMode > 8)
2892
);
2893
}
2894
2895
function manualDispatchChangeEvent(nativeEvent) {
2896
var event = SyntheticEvent.getPooled(
2897
eventTypes.change,
2898
activeElementID,
2899
nativeEvent
2900
);
2901
EventPropagators.accumulateTwoPhaseDispatches(event);
2902
2903
// If change and propertychange bubbled, we'd just bind to it like all the
2904
// other events and have it go through ReactBrowserEventEmitter. Since it
2905
// doesn't, we manually listen for the events and so we have to enqueue and
2906
// process the abstract event manually.
2907
//
2908
// Batching is necessary here in order to ensure that all event handlers run
2909
// before the next rerender (including event handlers attached to ancestor
2910
// elements instead of directly on the input). Without this, controlled
2911
// components don't work properly in conjunction with event bubbling because
2912
// the component is rerendered and the value reverted before all the event
2913
// handlers can run. See https://github.com/facebook/react/issues/708.
2914
ReactUpdates.batchedUpdates(runEventInBatch, event);
2915
}
2916
2917
function runEventInBatch(event) {
2918
EventPluginHub.enqueueEvents(event);
2919
EventPluginHub.processEventQueue();
2920
}
2921
2922
function startWatchingForChangeEventIE8(target, targetID) {
2923
activeElement = target;
2924
activeElementID = targetID;
2925
activeElement.attachEvent('onchange', manualDispatchChangeEvent);
2926
}
2927
2928
function stopWatchingForChangeEventIE8() {
2929
if (!activeElement) {
2930
return;
2931
}
2932
activeElement.detachEvent('onchange', manualDispatchChangeEvent);
2933
activeElement = null;
2934
activeElementID = null;
2935
}
2936
2937
function getTargetIDForChangeEvent(
2938
topLevelType,
2939
topLevelTarget,
2940
topLevelTargetID) {
2941
if (topLevelType === topLevelTypes.topChange) {
2942
return topLevelTargetID;
2943
}
2944
}
2945
function handleEventsForChangeEventIE8(
2946
topLevelType,
2947
topLevelTarget,
2948
topLevelTargetID) {
2949
if (topLevelType === topLevelTypes.topFocus) {
2950
// stopWatching() should be a noop here but we call it just in case we
2951
// missed a blur event somehow.
2952
stopWatchingForChangeEventIE8();
2953
startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
2954
} else if (topLevelType === topLevelTypes.topBlur) {
2955
stopWatchingForChangeEventIE8();
2956
}
2957
}
2958
2959
2960
/**
2961
* SECTION: handle `input` event
2962
*/
2963
var isInputEventSupported = false;
2964
if (ExecutionEnvironment.canUseDOM) {
2965
// IE9 claims to support the input event but fails to trigger it when
2966
// deleting text, so we ignore its input events
2967
isInputEventSupported = isEventSupported('input') && (
2968
(!('documentMode' in document) || document.documentMode > 9)
2969
);
2970
}
2971
2972
/**
2973
* (For old IE.) Replacement getter/setter for the `value` property that gets
2974
* set on the active element.
2975
*/
2976
var newValueProp = {
2977
get: function() {
2978
return activeElementValueProp.get.call(this);
2979
},
2980
set: function(val) {
2981
// Cast to a string so we can do equality checks.
2982
activeElementValue = '' + val;
2983
activeElementValueProp.set.call(this, val);
2984
}
2985
};
2986
2987
/**
2988
* (For old IE.) Starts tracking propertychange events on the passed-in element
2989
* and override the value property so that we can distinguish user events from
2990
* value changes in JS.
2991
*/
2992
function startWatchingForValueChange(target, targetID) {
2993
activeElement = target;
2994
activeElementID = targetID;
2995
activeElementValue = target.value;
2996
activeElementValueProp = Object.getOwnPropertyDescriptor(
2997
target.constructor.prototype,
2998
'value'
2999
);
3000
3001
Object.defineProperty(activeElement, 'value', newValueProp);
3002
activeElement.attachEvent('onpropertychange', handlePropertyChange);
3003
}
3004
3005
/**
3006
* (For old IE.) Removes the event listeners from the currently-tracked element,
3007
* if any exists.
3008
*/
3009
function stopWatchingForValueChange() {
3010
if (!activeElement) {
3011
return;
3012
}
3013
3014
// delete restores the original property definition
3015
delete activeElement.value;
3016
activeElement.detachEvent('onpropertychange', handlePropertyChange);
3017
3018
activeElement = null;
3019
activeElementID = null;
3020
activeElementValue = null;
3021
activeElementValueProp = null;
3022
}
3023
3024
/**
3025
* (For old IE.) Handles a propertychange event, sending a `change` event if
3026
* the value of the active element has changed.
3027
*/
3028
function handlePropertyChange(nativeEvent) {
3029
if (nativeEvent.propertyName !== 'value') {
3030
return;
3031
}
3032
var value = nativeEvent.srcElement.value;
3033
if (value === activeElementValue) {
3034
return;
3035
}
3036
activeElementValue = value;
3037
3038
manualDispatchChangeEvent(nativeEvent);
3039
}
3040
3041
/**
3042
* If a `change` event should be fired, returns the target's ID.
3043
*/
3044
function getTargetIDForInputEvent(
3045
topLevelType,
3046
topLevelTarget,
3047
topLevelTargetID) {
3048
if (topLevelType === topLevelTypes.topInput) {
3049
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
3050
// what we want so fall through here and trigger an abstract event
3051
return topLevelTargetID;
3052
}
3053
}
3054
3055
// For IE8 and IE9.
3056
function handleEventsForInputEventIE(
3057
topLevelType,
3058
topLevelTarget,
3059
topLevelTargetID) {
3060
if (topLevelType === topLevelTypes.topFocus) {
3061
// In IE8, we can capture almost all .value changes by adding a
3062
// propertychange handler and looking for events with propertyName
3063
// equal to 'value'
3064
// In IE9, propertychange fires for most input events but is buggy and
3065
// doesn't fire when text is deleted, but conveniently, selectionchange
3066
// appears to fire in all of the remaining cases so we catch those and
3067
// forward the event if the value has changed
3068
// In either case, we don't want to call the event handler if the value
3069
// is changed from JS so we redefine a setter for `.value` that updates
3070
// our activeElementValue variable, allowing us to ignore those changes
3071
//
3072
// stopWatching() should be a noop here but we call it just in case we
3073
// missed a blur event somehow.
3074
stopWatchingForValueChange();
3075
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
3076
} else if (topLevelType === topLevelTypes.topBlur) {
3077
stopWatchingForValueChange();
3078
}
3079
}
3080
3081
// For IE8 and IE9.
3082
function getTargetIDForInputEventIE(
3083
topLevelType,
3084
topLevelTarget,
3085
topLevelTargetID) {
3086
if (topLevelType === topLevelTypes.topSelectionChange ||
3087
topLevelType === topLevelTypes.topKeyUp ||
3088
topLevelType === topLevelTypes.topKeyDown) {
3089
// On the selectionchange event, the target is just document which isn't
3090
// helpful for us so just check activeElement instead.
3091
//
3092
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
3093
// propertychange on the first input event after setting `value` from a
3094
// script and fires only keydown, keypress, keyup. Catching keyup usually
3095
// gets it and catching keydown lets us fire an event for the first
3096
// keystroke if user does a key repeat (it'll be a little delayed: right
3097
// before the second keystroke). Other input methods (e.g., paste) seem to
3098
// fire selectionchange normally.
3099
if (activeElement && activeElement.value !== activeElementValue) {
3100
activeElementValue = activeElement.value;
3101
return activeElementID;
3102
}
3103
}
3104
}
3105
3106
3107
/**
3108
* SECTION: handle `click` event
3109
*/
3110
function shouldUseClickEvent(elem) {
3111
// Use the `click` event to detect changes to checkbox and radio inputs.
3112
// This approach works across all browsers, whereas `change` does not fire
3113
// until `blur` in IE8.
3114
return (
3115
elem.nodeName === 'INPUT' &&
3116
(elem.type === 'checkbox' || elem.type === 'radio')
3117
);
3118
}
3119
3120
function getTargetIDForClickEvent(
3121
topLevelType,
3122
topLevelTarget,
3123
topLevelTargetID) {
3124
if (topLevelType === topLevelTypes.topClick) {
3125
return topLevelTargetID;
3126
}
3127
}
3128
3129
/**
3130
* This plugin creates an `onChange` event that normalizes change events
3131
* across form elements. This event fires at a time when it's possible to
3132
* change the element's value without seeing a flicker.
3133
*
3134
* Supported elements are:
3135
* - input (see `isTextInputElement`)
3136
* - textarea
3137
* - select
3138
*/
3139
var ChangeEventPlugin = {
3140
3141
eventTypes: eventTypes,
3142
3143
/**
3144
* @param {string} topLevelType Record from `EventConstants`.
3145
* @param {DOMEventTarget} topLevelTarget The listening component root node.
3146
* @param {string} topLevelTargetID ID of `topLevelTarget`.
3147
* @param {object} nativeEvent Native browser event.
3148
* @return {*} An accumulation of synthetic events.
3149
* @see {EventPluginHub.extractEvents}
3150
*/
3151
extractEvents: function(
3152
topLevelType,
3153
topLevelTarget,
3154
topLevelTargetID,
3155
nativeEvent) {
3156
3157
var getTargetIDFunc, handleEventFunc;
3158
if (shouldUseChangeEvent(topLevelTarget)) {
3159
if (doesChangeEventBubble) {
3160
getTargetIDFunc = getTargetIDForChangeEvent;
3161
} else {
3162
handleEventFunc = handleEventsForChangeEventIE8;
3163
}
3164
} else if (isTextInputElement(topLevelTarget)) {
3165
if (isInputEventSupported) {
3166
getTargetIDFunc = getTargetIDForInputEvent;
3167
} else {
3168
getTargetIDFunc = getTargetIDForInputEventIE;
3169
handleEventFunc = handleEventsForInputEventIE;
3170
}
3171
} else if (shouldUseClickEvent(topLevelTarget)) {
3172
getTargetIDFunc = getTargetIDForClickEvent;
3173
}
3174
3175
if (getTargetIDFunc) {
3176
var targetID = getTargetIDFunc(
3177
topLevelType,
3178
topLevelTarget,
3179
topLevelTargetID
3180
);
3181
if (targetID) {
3182
var event = SyntheticEvent.getPooled(
3183
eventTypes.change,
3184
targetID,
3185
nativeEvent
3186
);
3187
EventPropagators.accumulateTwoPhaseDispatches(event);
3188
return event;
3189
}
3190
}
3191
3192
if (handleEventFunc) {
3193
handleEventFunc(
3194
topLevelType,
3195
topLevelTarget,
3196
topLevelTargetID
3197
);
3198
}
3199
}
3200
3201
};
3202
3203
module.exports = ChangeEventPlugin;
3204
3205
},{"./EventConstants":29,"./EventPluginHub":31,"./EventPropagators":34,"./ExecutionEnvironment":35,"./ReactUpdates":113,"./SyntheticEvent":122,"./isEventSupported":165,"./isTextInputElement":167,"./keyOf":171}],22:[function(require,module,exports){
3206
/**
3207
* Copyright 2013-2015, Facebook, Inc.
3208
* All rights reserved.
3209
*
3210
* This source code is licensed under the BSD-style license found in the
3211
* LICENSE file in the root directory of this source tree. An additional grant
3212
* of patent rights can be found in the PATENTS file in the same directory.
3213
*
3214
* @providesModule ClientReactRootIndex
3215
* @typechecks
3216
*/
3217
3218
'use strict';
3219
3220
var nextReactRootIndex = 0;
3221
3222
var ClientReactRootIndex = {
3223
createReactRootIndex: function() {
3224
return nextReactRootIndex++;
3225
}
3226
};
3227
3228
module.exports = ClientReactRootIndex;
3229
3230
},{}],23:[function(require,module,exports){
3231
(function (process){
3232
/**
3233
* Copyright 2013-2015, Facebook, Inc.
3234
* All rights reserved.
3235
*
3236
* This source code is licensed under the BSD-style license found in the
3237
* LICENSE file in the root directory of this source tree. An additional grant
3238
* of patent rights can be found in the PATENTS file in the same directory.
3239
*
3240
* @providesModule DOMChildrenOperations
3241
* @typechecks static-only
3242
*/
3243
3244
'use strict';
3245
3246
var Danger = require("./Danger");
3247
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
3248
3249
var setTextContent = require("./setTextContent");
3250
var invariant = require("./invariant");
3251
3252
/**
3253
* Inserts `childNode` as a child of `parentNode` at the `index`.
3254
*
3255
* @param {DOMElement} parentNode Parent node in which to insert.
3256
* @param {DOMElement} childNode Child node to insert.
3257
* @param {number} index Index at which to insert the child.
3258
* @internal
3259
*/
3260
function insertChildAt(parentNode, childNode, index) {
3261
// By exploiting arrays returning `undefined` for an undefined index, we can
3262
// rely exclusively on `insertBefore(node, null)` instead of also using
3263
// `appendChild(node)`. However, using `undefined` is not allowed by all
3264
// browsers so we must replace it with `null`.
3265
parentNode.insertBefore(
3266
childNode,
3267
parentNode.childNodes[index] || null
3268
);
3269
}
3270
3271
/**
3272
* Operations for updating with DOM children.
3273
*/
3274
var DOMChildrenOperations = {
3275
3276
dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
3277
3278
updateTextContent: setTextContent,
3279
3280
/**
3281
* Updates a component's children by processing a series of updates. The
3282
* update configurations are each expected to have a `parentNode` property.
3283
*
3284
* @param {array<object>} updates List of update configurations.
3285
* @param {array<string>} markupList List of markup strings.
3286
* @internal
3287
*/
3288
processUpdates: function(updates, markupList) {
3289
var update;
3290
// Mapping from parent IDs to initial child orderings.
3291
var initialChildren = null;
3292
// List of children that will be moved or removed.
3293
var updatedChildren = null;
3294
3295
for (var i = 0; i < updates.length; i++) {
3296
update = updates[i];
3297
if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
3298
update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
3299
var updatedIndex = update.fromIndex;
3300
var updatedChild = update.parentNode.childNodes[updatedIndex];
3301
var parentID = update.parentID;
3302
3303
("production" !== process.env.NODE_ENV ? invariant(
3304
updatedChild,
3305
'processUpdates(): Unable to find child %s of element. This ' +
3306
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
3307
'browser), usually due to forgetting a <tbody> when using tables, ' +
3308
'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' +
3309
'in an <svg> parent. Try inspecting the child nodes of the element ' +
3310
'with React ID `%s`.',
3311
updatedIndex,
3312
parentID
3313
) : invariant(updatedChild));
3314
3315
initialChildren = initialChildren || {};
3316
initialChildren[parentID] = initialChildren[parentID] || [];
3317
initialChildren[parentID][updatedIndex] = updatedChild;
3318
3319
updatedChildren = updatedChildren || [];
3320
updatedChildren.push(updatedChild);
3321
}
3322
}
3323
3324
var renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
3325
3326
// Remove updated children first so that `toIndex` is consistent.
3327
if (updatedChildren) {
3328
for (var j = 0; j < updatedChildren.length; j++) {
3329
updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
3330
}
3331
}
3332
3333
for (var k = 0; k < updates.length; k++) {
3334
update = updates[k];
3335
switch (update.type) {
3336
case ReactMultiChildUpdateTypes.INSERT_MARKUP:
3337
insertChildAt(
3338
update.parentNode,
3339
renderedMarkup[update.markupIndex],
3340
update.toIndex
3341
);
3342
break;
3343
case ReactMultiChildUpdateTypes.MOVE_EXISTING:
3344
insertChildAt(
3345
update.parentNode,
3346
initialChildren[update.parentID][update.fromIndex],
3347
update.toIndex
3348
);
3349
break;
3350
case ReactMultiChildUpdateTypes.TEXT_CONTENT:
3351
setTextContent(
3352
update.parentNode,
3353
update.textContent
3354
);
3355
break;
3356
case ReactMultiChildUpdateTypes.REMOVE_NODE:
3357
// Already removed by the for-loop above.
3358
break;
3359
}
3360
}
3361
}
3362
3363
};
3364
3365
module.exports = DOMChildrenOperations;
3366
3367
}).call(this,require('_process'))
3368
},{"./Danger":26,"./ReactMultiChildUpdateTypes":92,"./invariant":164,"./setTextContent":179,"_process":1}],24:[function(require,module,exports){
3369
(function (process){
3370
/**
3371
* Copyright 2013-2015, Facebook, Inc.
3372
* All rights reserved.
3373
*
3374
* This source code is licensed under the BSD-style license found in the
3375
* LICENSE file in the root directory of this source tree. An additional grant
3376
* of patent rights can be found in the PATENTS file in the same directory.
3377
*
3378
* @providesModule DOMProperty
3379
* @typechecks static-only
3380
*/
3381
3382
/*jslint bitwise: true */
3383
3384
'use strict';
3385
3386
var invariant = require("./invariant");
3387
3388
function checkMask(value, bitmask) {
3389
return (value & bitmask) === bitmask;
3390
}
3391
3392
var DOMPropertyInjection = {
3393
/**
3394
* Mapping from normalized, camelcased property names to a configuration that
3395
* specifies how the associated DOM property should be accessed or rendered.
3396
*/
3397
MUST_USE_ATTRIBUTE: 0x1,
3398
MUST_USE_PROPERTY: 0x2,
3399
HAS_SIDE_EFFECTS: 0x4,
3400
HAS_BOOLEAN_VALUE: 0x8,
3401
HAS_NUMERIC_VALUE: 0x10,
3402
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
3403
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
3404
3405
/**
3406
* Inject some specialized knowledge about the DOM. This takes a config object
3407
* with the following properties:
3408
*
3409
* isCustomAttribute: function that given an attribute name will return true
3410
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
3411
* attributes where it's impossible to enumerate all of the possible
3412
* attribute names,
3413
*
3414
* Properties: object mapping DOM property name to one of the
3415
* DOMPropertyInjection constants or null. If your attribute isn't in here,
3416
* it won't get written to the DOM.
3417
*
3418
* DOMAttributeNames: object mapping React attribute name to the DOM
3419
* attribute name. Attribute names not specified use the **lowercase**
3420
* normalized name.
3421
*
3422
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
3423
* Property names not specified use the normalized name.
3424
*
3425
* DOMMutationMethods: Properties that require special mutation methods. If
3426
* `value` is undefined, the mutation method should unset the property.
3427
*
3428
* @param {object} domPropertyConfig the config as described above.
3429
*/
3430
injectDOMPropertyConfig: function(domPropertyConfig) {
3431
var Properties = domPropertyConfig.Properties || {};
3432
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
3433
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
3434
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
3435
3436
if (domPropertyConfig.isCustomAttribute) {
3437
DOMProperty._isCustomAttributeFunctions.push(
3438
domPropertyConfig.isCustomAttribute
3439
);
3440
}
3441
3442
for (var propName in Properties) {
3443
("production" !== process.env.NODE_ENV ? invariant(
3444
!DOMProperty.isStandardName.hasOwnProperty(propName),
3445
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
3446
'\'%s\' which has already been injected. You may be accidentally ' +
3447
'injecting the same DOM property config twice, or you may be ' +
3448
'injecting two configs that have conflicting property names.',
3449
propName
3450
) : invariant(!DOMProperty.isStandardName.hasOwnProperty(propName)));
3451
3452
DOMProperty.isStandardName[propName] = true;
3453
3454
var lowerCased = propName.toLowerCase();
3455
DOMProperty.getPossibleStandardName[lowerCased] = propName;
3456
3457
if (DOMAttributeNames.hasOwnProperty(propName)) {
3458
var attributeName = DOMAttributeNames[propName];
3459
DOMProperty.getPossibleStandardName[attributeName] = propName;
3460
DOMProperty.getAttributeName[propName] = attributeName;
3461
} else {
3462
DOMProperty.getAttributeName[propName] = lowerCased;
3463
}
3464
3465
DOMProperty.getPropertyName[propName] =
3466
DOMPropertyNames.hasOwnProperty(propName) ?
3467
DOMPropertyNames[propName] :
3468
propName;
3469
3470
if (DOMMutationMethods.hasOwnProperty(propName)) {
3471
DOMProperty.getMutationMethod[propName] = DOMMutationMethods[propName];
3472
} else {
3473
DOMProperty.getMutationMethod[propName] = null;
3474
}
3475
3476
var propConfig = Properties[propName];
3477
DOMProperty.mustUseAttribute[propName] =
3478
checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
3479
DOMProperty.mustUseProperty[propName] =
3480
checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
3481
DOMProperty.hasSideEffects[propName] =
3482
checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
3483
DOMProperty.hasBooleanValue[propName] =
3484
checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
3485
DOMProperty.hasNumericValue[propName] =
3486
checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
3487
DOMProperty.hasPositiveNumericValue[propName] =
3488
checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
3489
DOMProperty.hasOverloadedBooleanValue[propName] =
3490
checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
3491
3492
("production" !== process.env.NODE_ENV ? invariant(
3493
!DOMProperty.mustUseAttribute[propName] ||
3494
!DOMProperty.mustUseProperty[propName],
3495
'DOMProperty: Cannot require using both attribute and property: %s',
3496
propName
3497
) : invariant(!DOMProperty.mustUseAttribute[propName] ||
3498
!DOMProperty.mustUseProperty[propName]));
3499
("production" !== process.env.NODE_ENV ? invariant(
3500
DOMProperty.mustUseProperty[propName] ||
3501
!DOMProperty.hasSideEffects[propName],
3502
'DOMProperty: Properties that have side effects must use property: %s',
3503
propName
3504
) : invariant(DOMProperty.mustUseProperty[propName] ||
3505
!DOMProperty.hasSideEffects[propName]));
3506
("production" !== process.env.NODE_ENV ? invariant(
3507
!!DOMProperty.hasBooleanValue[propName] +
3508
!!DOMProperty.hasNumericValue[propName] +
3509
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1,
3510
'DOMProperty: Value can be one of boolean, overloaded boolean, or ' +
3511
'numeric value, but not a combination: %s',
3512
propName
3513
) : invariant(!!DOMProperty.hasBooleanValue[propName] +
3514
!!DOMProperty.hasNumericValue[propName] +
3515
!!DOMProperty.hasOverloadedBooleanValue[propName] <= 1));
3516
}
3517
}
3518
};
3519
var defaultValueCache = {};
3520
3521
/**
3522
* DOMProperty exports lookup objects that can be used like functions:
3523
*
3524
* > DOMProperty.isValid['id']
3525
* true
3526
* > DOMProperty.isValid['foobar']
3527
* undefined
3528
*
3529
* Although this may be confusing, it performs better in general.
3530
*
3531
* @see http://jsperf.com/key-exists
3532
* @see http://jsperf.com/key-missing
3533
*/
3534
var DOMProperty = {
3535
3536
ID_ATTRIBUTE_NAME: 'data-reactid',
3537
3538
/**
3539
* Checks whether a property name is a standard property.
3540
* @type {Object}
3541
*/
3542
isStandardName: {},
3543
3544
/**
3545
* Mapping from lowercase property names to the properly cased version, used
3546
* to warn in the case of missing properties.
3547
* @type {Object}
3548
*/
3549
getPossibleStandardName: {},
3550
3551
/**
3552
* Mapping from normalized names to attribute names that differ. Attribute
3553
* names are used when rendering markup or with `*Attribute()`.
3554
* @type {Object}
3555
*/
3556
getAttributeName: {},
3557
3558
/**
3559
* Mapping from normalized names to properties on DOM node instances.
3560
* (This includes properties that mutate due to external factors.)
3561
* @type {Object}
3562
*/
3563
getPropertyName: {},
3564
3565
/**
3566
* Mapping from normalized names to mutation methods. This will only exist if
3567
* mutation cannot be set simply by the property or `setAttribute()`.
3568
* @type {Object}
3569
*/
3570
getMutationMethod: {},
3571
3572
/**
3573
* Whether the property must be accessed and mutated as an object property.
3574
* @type {Object}
3575
*/
3576
mustUseAttribute: {},
3577
3578
/**
3579
* Whether the property must be accessed and mutated using `*Attribute()`.
3580
* (This includes anything that fails `<propName> in <element>`.)
3581
* @type {Object}
3582
*/
3583
mustUseProperty: {},
3584
3585
/**
3586
* Whether or not setting a value causes side effects such as triggering
3587
* resources to be loaded or text selection changes. We must ensure that
3588
* the value is only set if it has changed.
3589
* @type {Object}
3590
*/
3591
hasSideEffects: {},
3592
3593
/**
3594
* Whether the property should be removed when set to a falsey value.
3595
* @type {Object}
3596
*/
3597
hasBooleanValue: {},
3598
3599
/**
3600
* Whether the property must be numeric or parse as a
3601
* numeric and should be removed when set to a falsey value.
3602
* @type {Object}
3603
*/
3604
hasNumericValue: {},
3605
3606
/**
3607
* Whether the property must be positive numeric or parse as a positive
3608
* numeric and should be removed when set to a falsey value.
3609
* @type {Object}
3610
*/
3611
hasPositiveNumericValue: {},
3612
3613
/**
3614
* Whether the property can be used as a flag as well as with a value. Removed
3615
* when strictly equal to false; present without a value when strictly equal
3616
* to true; present with a value otherwise.
3617
* @type {Object}
3618
*/
3619
hasOverloadedBooleanValue: {},
3620
3621
/**
3622
* All of the isCustomAttribute() functions that have been injected.
3623
*/
3624
_isCustomAttributeFunctions: [],
3625
3626
/**
3627
* Checks whether a property name is a custom attribute.
3628
* @method
3629
*/
3630
isCustomAttribute: function(attributeName) {
3631
for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
3632
var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
3633
if (isCustomAttributeFn(attributeName)) {
3634
return true;
3635
}
3636
}
3637
return false;
3638
},
3639
3640
/**
3641
* Returns the default property value for a DOM property (i.e., not an
3642
* attribute). Most default values are '' or false, but not all. Worse yet,
3643
* some (in particular, `type`) vary depending on the type of element.
3644
*
3645
* TODO: Is it better to grab all the possible properties when creating an
3646
* element to avoid having to create the same element twice?
3647
*/
3648
getDefaultValueForProperty: function(nodeName, prop) {
3649
var nodeDefaults = defaultValueCache[nodeName];
3650
var testElement;
3651
if (!nodeDefaults) {
3652
defaultValueCache[nodeName] = nodeDefaults = {};
3653
}
3654
if (!(prop in nodeDefaults)) {
3655
testElement = document.createElement(nodeName);
3656
nodeDefaults[prop] = testElement[prop];
3657
}
3658
return nodeDefaults[prop];
3659
},
3660
3661
injection: DOMPropertyInjection
3662
};
3663
3664
module.exports = DOMProperty;
3665
3666
}).call(this,require('_process'))
3667
},{"./invariant":164,"_process":1}],25:[function(require,module,exports){
3668
(function (process){
3669
/**
3670
* Copyright 2013-2015, Facebook, Inc.
3671
* All rights reserved.
3672
*
3673
* This source code is licensed under the BSD-style license found in the
3674
* LICENSE file in the root directory of this source tree. An additional grant
3675
* of patent rights can be found in the PATENTS file in the same directory.
3676
*
3677
* @providesModule DOMPropertyOperations
3678
* @typechecks static-only
3679
*/
3680
3681
'use strict';
3682
3683
var DOMProperty = require("./DOMProperty");
3684
3685
var quoteAttributeValueForBrowser = require("./quoteAttributeValueForBrowser");
3686
var warning = require("./warning");
3687
3688
function shouldIgnoreValue(name, value) {
3689
return value == null ||
3690
(DOMProperty.hasBooleanValue[name] && !value) ||
3691
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
3692
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
3693
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
3694
}
3695
3696
if ("production" !== process.env.NODE_ENV) {
3697
var reactProps = {
3698
children: true,
3699
dangerouslySetInnerHTML: true,
3700
key: true,
3701
ref: true
3702
};
3703
var warnedProperties = {};
3704
3705
var warnUnknownProperty = function(name) {
3706
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
3707
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
3708
return;
3709
}
3710
3711
warnedProperties[name] = true;
3712
var lowerCasedName = name.toLowerCase();
3713
3714
// data-* attributes should be lowercase; suggest the lowercase version
3715
var standardName = (
3716
DOMProperty.isCustomAttribute(lowerCasedName) ?
3717
lowerCasedName :
3718
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
3719
DOMProperty.getPossibleStandardName[lowerCasedName] :
3720
null
3721
);
3722
3723
// For now, only warn when we have a suggested correction. This prevents
3724
// logging too much when using transferPropsTo.
3725
("production" !== process.env.NODE_ENV ? warning(
3726
standardName == null,
3727
'Unknown DOM property %s. Did you mean %s?',
3728
name,
3729
standardName
3730
) : null);
3731
3732
};
3733
}
3734
3735
/**
3736
* Operations for dealing with DOM properties.
3737
*/
3738
var DOMPropertyOperations = {
3739
3740
/**
3741
* Creates markup for the ID property.
3742
*
3743
* @param {string} id Unescaped ID.
3744
* @return {string} Markup string.
3745
*/
3746
createMarkupForID: function(id) {
3747
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
3748
quoteAttributeValueForBrowser(id);
3749
},
3750
3751
/**
3752
* Creates markup for a property.
3753
*
3754
* @param {string} name
3755
* @param {*} value
3756
* @return {?string} Markup string, or null if the property was invalid.
3757
*/
3758
createMarkupForProperty: function(name, value) {
3759
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
3760
DOMProperty.isStandardName[name]) {
3761
if (shouldIgnoreValue(name, value)) {
3762
return '';
3763
}
3764
var attributeName = DOMProperty.getAttributeName[name];
3765
if (DOMProperty.hasBooleanValue[name] ||
3766
(DOMProperty.hasOverloadedBooleanValue[name] && value === true)) {
3767
return attributeName;
3768
}
3769
return attributeName + '=' + quoteAttributeValueForBrowser(value);
3770
} else if (DOMProperty.isCustomAttribute(name)) {
3771
if (value == null) {
3772
return '';
3773
}
3774
return name + '=' + quoteAttributeValueForBrowser(value);
3775
} else if ("production" !== process.env.NODE_ENV) {
3776
warnUnknownProperty(name);
3777
}
3778
return null;
3779
},
3780
3781
/**
3782
* Sets the value for a property on a node.
3783
*
3784
* @param {DOMElement} node
3785
* @param {string} name
3786
* @param {*} value
3787
*/
3788
setValueForProperty: function(node, name, value) {
3789
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
3790
DOMProperty.isStandardName[name]) {
3791
var mutationMethod = DOMProperty.getMutationMethod[name];
3792
if (mutationMethod) {
3793
mutationMethod(node, value);
3794
} else if (shouldIgnoreValue(name, value)) {
3795
this.deleteValueForProperty(node, name);
3796
} else if (DOMProperty.mustUseAttribute[name]) {
3797
// `setAttribute` with objects becomes only `[object]` in IE8/9,
3798
// ('' + value) makes it output the correct toString()-value.
3799
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
3800
} else {
3801
var propName = DOMProperty.getPropertyName[name];
3802
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
3803
// property type before comparing; only `value` does and is string.
3804
if (!DOMProperty.hasSideEffects[name] ||
3805
('' + node[propName]) !== ('' + value)) {
3806
// Contrary to `setAttribute`, object properties are properly
3807
// `toString`ed by IE8/9.
3808
node[propName] = value;
3809
}
3810
}
3811
} else if (DOMProperty.isCustomAttribute(name)) {
3812
if (value == null) {
3813
node.removeAttribute(name);
3814
} else {
3815
node.setAttribute(name, '' + value);
3816
}
3817
} else if ("production" !== process.env.NODE_ENV) {
3818
warnUnknownProperty(name);
3819
}
3820
},
3821
3822
/**
3823
* Deletes the value for a property on a node.
3824
*
3825
* @param {DOMElement} node
3826
* @param {string} name
3827
*/
3828
deleteValueForProperty: function(node, name) {
3829
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
3830
DOMProperty.isStandardName[name]) {
3831
var mutationMethod = DOMProperty.getMutationMethod[name];
3832
if (mutationMethod) {
3833
mutationMethod(node, undefined);
3834
} else if (DOMProperty.mustUseAttribute[name]) {
3835
node.removeAttribute(DOMProperty.getAttributeName[name]);
3836
} else {
3837
var propName = DOMProperty.getPropertyName[name];
3838
var defaultValue = DOMProperty.getDefaultValueForProperty(
3839
node.nodeName,
3840
propName
3841
);
3842
if (!DOMProperty.hasSideEffects[name] ||
3843
('' + node[propName]) !== defaultValue) {
3844
node[propName] = defaultValue;
3845
}
3846
}
3847
} else if (DOMProperty.isCustomAttribute(name)) {
3848
node.removeAttribute(name);
3849
} else if ("production" !== process.env.NODE_ENV) {
3850
warnUnknownProperty(name);
3851
}
3852
}
3853
3854
};
3855
3856
module.exports = DOMPropertyOperations;
3857
3858
}).call(this,require('_process'))
3859
},{"./DOMProperty":24,"./quoteAttributeValueForBrowser":177,"./warning":185,"_process":1}],26:[function(require,module,exports){
3860
(function (process){
3861
/**
3862
* Copyright 2013-2015, Facebook, Inc.
3863
* All rights reserved.
3864
*
3865
* This source code is licensed under the BSD-style license found in the
3866
* LICENSE file in the root directory of this source tree. An additional grant
3867
* of patent rights can be found in the PATENTS file in the same directory.
3868
*
3869
* @providesModule Danger
3870
* @typechecks static-only
3871
*/
3872
3873
/*jslint evil: true, sub: true */
3874
3875
'use strict';
3876
3877
var ExecutionEnvironment = require("./ExecutionEnvironment");
3878
3879
var createNodesFromMarkup = require("./createNodesFromMarkup");
3880
var emptyFunction = require("./emptyFunction");
3881
var getMarkupWrap = require("./getMarkupWrap");
3882
var invariant = require("./invariant");
3883
3884
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
3885
var RESULT_INDEX_ATTR = 'data-danger-index';
3886
3887
/**
3888
* Extracts the `nodeName` from a string of markup.
3889
*
3890
* NOTE: Extracting the `nodeName` does not require a regular expression match
3891
* because we make assumptions about React-generated markup (i.e. there are no
3892
* spaces surrounding the opening tag and there is at least one attribute).
3893
*
3894
* @param {string} markup String of markup.
3895
* @return {string} Node name of the supplied markup.
3896
* @see http://jsperf.com/extract-nodename
3897
*/
3898
function getNodeName(markup) {
3899
return markup.substring(1, markup.indexOf(' '));
3900
}
3901
3902
var Danger = {
3903
3904
/**
3905
* Renders markup into an array of nodes. The markup is expected to render
3906
* into a list of root nodes. Also, the length of `resultList` and
3907
* `markupList` should be the same.
3908
*
3909
* @param {array<string>} markupList List of markup strings to render.
3910
* @return {array<DOMElement>} List of rendered nodes.
3911
* @internal
3912
*/
3913
dangerouslyRenderMarkup: function(markupList) {
3914
("production" !== process.env.NODE_ENV ? invariant(
3915
ExecutionEnvironment.canUseDOM,
3916
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
3917
'thread. Make sure `window` and `document` are available globally ' +
3918
'before requiring React when unit testing or use ' +
3919
'React.renderToString for server rendering.'
3920
) : invariant(ExecutionEnvironment.canUseDOM));
3921
var nodeName;
3922
var markupByNodeName = {};
3923
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
3924
for (var i = 0; i < markupList.length; i++) {
3925
("production" !== process.env.NODE_ENV ? invariant(
3926
markupList[i],
3927
'dangerouslyRenderMarkup(...): Missing markup.'
3928
) : invariant(markupList[i]));
3929
nodeName = getNodeName(markupList[i]);
3930
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
3931
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
3932
markupByNodeName[nodeName][i] = markupList[i];
3933
}
3934
var resultList = [];
3935
var resultListAssignmentCount = 0;
3936
for (nodeName in markupByNodeName) {
3937
if (!markupByNodeName.hasOwnProperty(nodeName)) {
3938
continue;
3939
}
3940
var markupListByNodeName = markupByNodeName[nodeName];
3941
3942
// This for-in loop skips the holes of the sparse array. The order of
3943
// iteration should follow the order of assignment, which happens to match
3944
// numerical index order, but we don't rely on that.
3945
var resultIndex;
3946
for (resultIndex in markupListByNodeName) {
3947
if (markupListByNodeName.hasOwnProperty(resultIndex)) {
3948
var markup = markupListByNodeName[resultIndex];
3949
3950
// Push the requested markup with an additional RESULT_INDEX_ATTR
3951
// attribute. If the markup does not start with a < character, it
3952
// will be discarded below (with an appropriate console.error).
3953
markupListByNodeName[resultIndex] = markup.replace(
3954
OPEN_TAG_NAME_EXP,
3955
// This index will be parsed back out below.
3956
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
3957
);
3958
}
3959
}
3960
3961
// Render each group of markup with similar wrapping `nodeName`.
3962
var renderNodes = createNodesFromMarkup(
3963
markupListByNodeName.join(''),
3964
emptyFunction // Do nothing special with <script> tags.
3965
);
3966
3967
for (var j = 0; j < renderNodes.length; ++j) {
3968
var renderNode = renderNodes[j];
3969
if (renderNode.hasAttribute &&
3970
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
3971
3972
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
3973
renderNode.removeAttribute(RESULT_INDEX_ATTR);
3974
3975
("production" !== process.env.NODE_ENV ? invariant(
3976
!resultList.hasOwnProperty(resultIndex),
3977
'Danger: Assigning to an already-occupied result index.'
3978
) : invariant(!resultList.hasOwnProperty(resultIndex)));
3979
3980
resultList[resultIndex] = renderNode;
3981
3982
// This should match resultList.length and markupList.length when
3983
// we're done.
3984
resultListAssignmentCount += 1;
3985
3986
} else if ("production" !== process.env.NODE_ENV) {
3987
console.error(
3988
'Danger: Discarding unexpected node:',
3989
renderNode
3990
);
3991
}
3992
}
3993
}
3994
3995
// Although resultList was populated out of order, it should now be a dense
3996
// array.
3997
("production" !== process.env.NODE_ENV ? invariant(
3998
resultListAssignmentCount === resultList.length,
3999
'Danger: Did not assign to every index of resultList.'
4000
) : invariant(resultListAssignmentCount === resultList.length));
4001
4002
("production" !== process.env.NODE_ENV ? invariant(
4003
resultList.length === markupList.length,
4004
'Danger: Expected markup to render %s nodes, but rendered %s.',
4005
markupList.length,
4006
resultList.length
4007
) : invariant(resultList.length === markupList.length));
4008
4009
return resultList;
4010
},
4011
4012
/**
4013
* Replaces a node with a string of markup at its current position within its
4014
* parent. The markup must render into a single root node.
4015
*
4016
* @param {DOMElement} oldChild Child node to replace.
4017
* @param {string} markup Markup to render in place of the child node.
4018
* @internal
4019
*/
4020
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
4021
("production" !== process.env.NODE_ENV ? invariant(
4022
ExecutionEnvironment.canUseDOM,
4023
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
4024
'worker thread. Make sure `window` and `document` are available ' +
4025
'globally before requiring React when unit testing or use ' +
4026
'React.renderToString for server rendering.'
4027
) : invariant(ExecutionEnvironment.canUseDOM));
4028
("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
4029
("production" !== process.env.NODE_ENV ? invariant(
4030
oldChild.tagName.toLowerCase() !== 'html',
4031
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
4032
'<html> node. This is because browser quirks make this unreliable ' +
4033
'and/or slow. If you want to render to the root you must use ' +
4034
'server rendering. See React.renderToString().'
4035
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
4036
4037
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
4038
oldChild.parentNode.replaceChild(newChild, oldChild);
4039
}
4040
4041
};
4042
4043
module.exports = Danger;
4044
4045
}).call(this,require('_process'))
4046
},{"./ExecutionEnvironment":35,"./createNodesFromMarkup":140,"./emptyFunction":143,"./getMarkupWrap":156,"./invariant":164,"_process":1}],27:[function(require,module,exports){
4047
/**
4048
* Copyright 2013-2015, Facebook, Inc.
4049
* All rights reserved.
4050
*
4051
* This source code is licensed under the BSD-style license found in the
4052
* LICENSE file in the root directory of this source tree. An additional grant
4053
* of patent rights can be found in the PATENTS file in the same directory.
4054
*
4055
* @providesModule DefaultEventPluginOrder
4056
*/
4057
4058
'use strict';
4059
4060
var keyOf = require("./keyOf");
4061
4062
/**
4063
* Module that is injectable into `EventPluginHub`, that specifies a
4064
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
4065
* plugins, without having to package every one of them. This is better than
4066
* having plugins be ordered in the same order that they are injected because
4067
* that ordering would be influenced by the packaging order.
4068
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
4069
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
4070
*/
4071
var DefaultEventPluginOrder = [
4072
keyOf({ResponderEventPlugin: null}),
4073
keyOf({SimpleEventPlugin: null}),
4074
keyOf({TapEventPlugin: null}),
4075
keyOf({EnterLeaveEventPlugin: null}),
4076
keyOf({ChangeEventPlugin: null}),
4077
keyOf({SelectEventPlugin: null}),
4078
keyOf({BeforeInputEventPlugin: null}),
4079
keyOf({AnalyticsEventPlugin: null}),
4080
keyOf({MobileSafariClickEventPlugin: null})
4081
];
4082
4083
module.exports = DefaultEventPluginOrder;
4084
4085
},{"./keyOf":171}],28:[function(require,module,exports){
4086
/**
4087
* Copyright 2013-2015, Facebook, Inc.
4088
* All rights reserved.
4089
*
4090
* This source code is licensed under the BSD-style license found in the
4091
* LICENSE file in the root directory of this source tree. An additional grant
4092
* of patent rights can be found in the PATENTS file in the same directory.
4093
*
4094
* @providesModule EnterLeaveEventPlugin
4095
* @typechecks static-only
4096
*/
4097
4098
'use strict';
4099
4100
var EventConstants = require("./EventConstants");
4101
var EventPropagators = require("./EventPropagators");
4102
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
4103
4104
var ReactMount = require("./ReactMount");
4105
var keyOf = require("./keyOf");
4106
4107
var topLevelTypes = EventConstants.topLevelTypes;
4108
var getFirstReactDOM = ReactMount.getFirstReactDOM;
4109
4110
var eventTypes = {
4111
mouseEnter: {
4112
registrationName: keyOf({onMouseEnter: null}),
4113
dependencies: [
4114
topLevelTypes.topMouseOut,
4115
topLevelTypes.topMouseOver
4116
]
4117
},
4118
mouseLeave: {
4119
registrationName: keyOf({onMouseLeave: null}),
4120
dependencies: [
4121
topLevelTypes.topMouseOut,
4122
topLevelTypes.topMouseOver
4123
]
4124
}
4125
};
4126
4127
var extractedEvents = [null, null];
4128
4129
var EnterLeaveEventPlugin = {
4130
4131
eventTypes: eventTypes,
4132
4133
/**
4134
* For almost every interaction we care about, there will be both a top-level
4135
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
4136
* we do not extract duplicate events. However, moving the mouse into the
4137
* browser from outside will not fire a `mouseout` event. In this case, we use
4138
* the `mouseover` top-level event.
4139
*
4140
* @param {string} topLevelType Record from `EventConstants`.
4141
* @param {DOMEventTarget} topLevelTarget The listening component root node.
4142
* @param {string} topLevelTargetID ID of `topLevelTarget`.
4143
* @param {object} nativeEvent Native browser event.
4144
* @return {*} An accumulation of synthetic events.
4145
* @see {EventPluginHub.extractEvents}
4146
*/
4147
extractEvents: function(
4148
topLevelType,
4149
topLevelTarget,
4150
topLevelTargetID,
4151
nativeEvent) {
4152
if (topLevelType === topLevelTypes.topMouseOver &&
4153
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
4154
return null;
4155
}
4156
if (topLevelType !== topLevelTypes.topMouseOut &&
4157
topLevelType !== topLevelTypes.topMouseOver) {
4158
// Must not be a mouse in or mouse out - ignoring.
4159
return null;
4160
}
4161
4162
var win;
4163
if (topLevelTarget.window === topLevelTarget) {
4164
// `topLevelTarget` is probably a window object.
4165
win = topLevelTarget;
4166
} else {
4167
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
4168
var doc = topLevelTarget.ownerDocument;
4169
if (doc) {
4170
win = doc.defaultView || doc.parentWindow;
4171
} else {
4172
win = window;
4173
}
4174
}
4175
4176
var from, to;
4177
if (topLevelType === topLevelTypes.topMouseOut) {
4178
from = topLevelTarget;
4179
to =
4180
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
4181
win;
4182
} else {
4183
from = win;
4184
to = topLevelTarget;
4185
}
4186
4187
if (from === to) {
4188
// Nothing pertains to our managed components.
4189
return null;
4190
}
4191
4192
var fromID = from ? ReactMount.getID(from) : '';
4193
var toID = to ? ReactMount.getID(to) : '';
4194
4195
var leave = SyntheticMouseEvent.getPooled(
4196
eventTypes.mouseLeave,
4197
fromID,
4198
nativeEvent
4199
);
4200
leave.type = 'mouseleave';
4201
leave.target = from;
4202
leave.relatedTarget = to;
4203
4204
var enter = SyntheticMouseEvent.getPooled(
4205
eventTypes.mouseEnter,
4206
toID,
4207
nativeEvent
4208
);
4209
enter.type = 'mouseenter';
4210
enter.target = to;
4211
enter.relatedTarget = from;
4212
4213
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
4214
4215
extractedEvents[0] = leave;
4216
extractedEvents[1] = enter;
4217
4218
return extractedEvents;
4219
}
4220
4221
};
4222
4223
module.exports = EnterLeaveEventPlugin;
4224
4225
},{"./EventConstants":29,"./EventPropagators":34,"./ReactMount":90,"./SyntheticMouseEvent":126,"./keyOf":171}],29:[function(require,module,exports){
4226
/**
4227
* Copyright 2013-2015, Facebook, Inc.
4228
* All rights reserved.
4229
*
4230
* This source code is licensed under the BSD-style license found in the
4231
* LICENSE file in the root directory of this source tree. An additional grant
4232
* of patent rights can be found in the PATENTS file in the same directory.
4233
*
4234
* @providesModule EventConstants
4235
*/
4236
4237
'use strict';
4238
4239
var keyMirror = require("./keyMirror");
4240
4241
var PropagationPhases = keyMirror({bubbled: null, captured: null});
4242
4243
/**
4244
* Types of raw signals from the browser caught at the top level.
4245
*/
4246
var topLevelTypes = keyMirror({
4247
topBlur: null,
4248
topChange: null,
4249
topClick: null,
4250
topCompositionEnd: null,
4251
topCompositionStart: null,
4252
topCompositionUpdate: null,
4253
topContextMenu: null,
4254
topCopy: null,
4255
topCut: null,
4256
topDoubleClick: null,
4257
topDrag: null,
4258
topDragEnd: null,
4259
topDragEnter: null,
4260
topDragExit: null,
4261
topDragLeave: null,
4262
topDragOver: null,
4263
topDragStart: null,
4264
topDrop: null,
4265
topError: null,
4266
topFocus: null,
4267
topInput: null,
4268
topKeyDown: null,
4269
topKeyPress: null,
4270
topKeyUp: null,
4271
topLoad: null,
4272
topMouseDown: null,
4273
topMouseMove: null,
4274
topMouseOut: null,
4275
topMouseOver: null,
4276
topMouseUp: null,
4277
topPaste: null,
4278
topReset: null,
4279
topScroll: null,
4280
topSelectionChange: null,
4281
topSubmit: null,
4282
topTextInput: null,
4283
topTouchCancel: null,
4284
topTouchEnd: null,
4285
topTouchMove: null,
4286
topTouchStart: null,
4287
topWheel: null
4288
});
4289
4290
var EventConstants = {
4291
topLevelTypes: topLevelTypes,
4292
PropagationPhases: PropagationPhases
4293
};
4294
4295
module.exports = EventConstants;
4296
4297
},{"./keyMirror":170}],30:[function(require,module,exports){
4298
(function (process){
4299
/**
4300
* Copyright 2013-2015, Facebook, Inc.
4301
*
4302
* Licensed under the Apache License, Version 2.0 (the "License");
4303
* you may not use this file except in compliance with the License.
4304
* You may obtain a copy of the License at
4305
*
4306
* http://www.apache.org/licenses/LICENSE-2.0
4307
*
4308
* Unless required by applicable law or agreed to in writing, software
4309
* distributed under the License is distributed on an "AS IS" BASIS,
4310
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4311
* See the License for the specific language governing permissions and
4312
* limitations under the License.
4313
*
4314
* @providesModule EventListener
4315
* @typechecks
4316
*/
4317
4318
var emptyFunction = require("./emptyFunction");
4319
4320
/**
4321
* Upstream version of event listener. Does not take into account specific
4322
* nature of platform.
4323
*/
4324
var EventListener = {
4325
/**
4326
* Listen to DOM events during the bubble phase.
4327
*
4328
* @param {DOMEventTarget} target DOM element to register listener on.
4329
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
4330
* @param {function} callback Callback function.
4331
* @return {object} Object with a `remove` method.
4332
*/
4333
listen: function(target, eventType, callback) {
4334
if (target.addEventListener) {
4335
target.addEventListener(eventType, callback, false);
4336
return {
4337
remove: function() {
4338
target.removeEventListener(eventType, callback, false);
4339
}
4340
};
4341
} else if (target.attachEvent) {
4342
target.attachEvent('on' + eventType, callback);
4343
return {
4344
remove: function() {
4345
target.detachEvent('on' + eventType, callback);
4346
}
4347
};
4348
}
4349
},
4350
4351
/**
4352
* Listen to DOM events during the capture phase.
4353
*
4354
* @param {DOMEventTarget} target DOM element to register listener on.
4355
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
4356
* @param {function} callback Callback function.
4357
* @return {object} Object with a `remove` method.
4358
*/
4359
capture: function(target, eventType, callback) {
4360
if (!target.addEventListener) {
4361
if ("production" !== process.env.NODE_ENV) {
4362
console.error(
4363
'Attempted to listen to events during the capture phase on a ' +
4364
'browser that does not support the capture phase. Your application ' +
4365
'will not receive some events.'
4366
);
4367
}
4368
return {
4369
remove: emptyFunction
4370
};
4371
} else {
4372
target.addEventListener(eventType, callback, true);
4373
return {
4374
remove: function() {
4375
target.removeEventListener(eventType, callback, true);
4376
}
4377
};
4378
}
4379
},
4380
4381
registerDefault: function() {}
4382
};
4383
4384
module.exports = EventListener;
4385
4386
}).call(this,require('_process'))
4387
},{"./emptyFunction":143,"_process":1}],31:[function(require,module,exports){
4388
(function (process){
4389
/**
4390
* Copyright 2013-2015, Facebook, Inc.
4391
* All rights reserved.
4392
*
4393
* This source code is licensed under the BSD-style license found in the
4394
* LICENSE file in the root directory of this source tree. An additional grant
4395
* of patent rights can be found in the PATENTS file in the same directory.
4396
*
4397
* @providesModule EventPluginHub
4398
*/
4399
4400
'use strict';
4401
4402
var EventPluginRegistry = require("./EventPluginRegistry");
4403
var EventPluginUtils = require("./EventPluginUtils");
4404
4405
var accumulateInto = require("./accumulateInto");
4406
var forEachAccumulated = require("./forEachAccumulated");
4407
var invariant = require("./invariant");
4408
4409
/**
4410
* Internal store for event listeners
4411
*/
4412
var listenerBank = {};
4413
4414
/**
4415
* Internal queue of events that have accumulated their dispatches and are
4416
* waiting to have their dispatches executed.
4417
*/
4418
var eventQueue = null;
4419
4420
/**
4421
* Dispatches an event and releases it back into the pool, unless persistent.
4422
*
4423
* @param {?object} event Synthetic event to be dispatched.
4424
* @private
4425
*/
4426
var executeDispatchesAndRelease = function(event) {
4427
if (event) {
4428
var executeDispatch = EventPluginUtils.executeDispatch;
4429
// Plugins can provide custom behavior when dispatching events.
4430
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
4431
if (PluginModule && PluginModule.executeDispatch) {
4432
executeDispatch = PluginModule.executeDispatch;
4433
}
4434
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
4435
4436
if (!event.isPersistent()) {
4437
event.constructor.release(event);
4438
}
4439
}
4440
};
4441
4442
/**
4443
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
4444
* hierarchy given ids of the logical DOM elements involved.
4445
*/
4446
var InstanceHandle = null;
4447
4448
function validateInstanceHandle() {
4449
var valid =
4450
InstanceHandle &&
4451
InstanceHandle.traverseTwoPhase &&
4452
InstanceHandle.traverseEnterLeave;
4453
("production" !== process.env.NODE_ENV ? invariant(
4454
valid,
4455
'InstanceHandle not injected before use!'
4456
) : invariant(valid));
4457
}
4458
4459
/**
4460
* This is a unified interface for event plugins to be installed and configured.
4461
*
4462
* Event plugins can implement the following properties:
4463
*
4464
* `extractEvents` {function(string, DOMEventTarget, string, object): *}
4465
* Required. When a top-level event is fired, this method is expected to
4466
* extract synthetic events that will in turn be queued and dispatched.
4467
*
4468
* `eventTypes` {object}
4469
* Optional, plugins that fire events must publish a mapping of registration
4470
* names that are used to register listeners. Values of this mapping must
4471
* be objects that contain `registrationName` or `phasedRegistrationNames`.
4472
*
4473
* `executeDispatch` {function(object, function, string)}
4474
* Optional, allows plugins to override how an event gets dispatched. By
4475
* default, the listener is simply invoked.
4476
*
4477
* Each plugin that is injected into `EventsPluginHub` is immediately operable.
4478
*
4479
* @public
4480
*/
4481
var EventPluginHub = {
4482
4483
/**
4484
* Methods for injecting dependencies.
4485
*/
4486
injection: {
4487
4488
/**
4489
* @param {object} InjectedMount
4490
* @public
4491
*/
4492
injectMount: EventPluginUtils.injection.injectMount,
4493
4494
/**
4495
* @param {object} InjectedInstanceHandle
4496
* @public
4497
*/
4498
injectInstanceHandle: function(InjectedInstanceHandle) {
4499
InstanceHandle = InjectedInstanceHandle;
4500
if ("production" !== process.env.NODE_ENV) {
4501
validateInstanceHandle();
4502
}
4503
},
4504
4505
getInstanceHandle: function() {
4506
if ("production" !== process.env.NODE_ENV) {
4507
validateInstanceHandle();
4508
}
4509
return InstanceHandle;
4510
},
4511
4512
/**
4513
* @param {array} InjectedEventPluginOrder
4514
* @public
4515
*/
4516
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
4517
4518
/**
4519
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
4520
*/
4521
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
4522
4523
},
4524
4525
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
4526
4527
registrationNameModules: EventPluginRegistry.registrationNameModules,
4528
4529
/**
4530
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
4531
*
4532
* @param {string} id ID of the DOM element.
4533
* @param {string} registrationName Name of listener (e.g. `onClick`).
4534
* @param {?function} listener The callback to store.
4535
*/
4536
putListener: function(id, registrationName, listener) {
4537
("production" !== process.env.NODE_ENV ? invariant(
4538
!listener || typeof listener === 'function',
4539
'Expected %s listener to be a function, instead got type %s',
4540
registrationName, typeof listener
4541
) : invariant(!listener || typeof listener === 'function'));
4542
4543
var bankForRegistrationName =
4544
listenerBank[registrationName] || (listenerBank[registrationName] = {});
4545
bankForRegistrationName[id] = listener;
4546
},
4547
4548
/**
4549
* @param {string} id ID of the DOM element.
4550
* @param {string} registrationName Name of listener (e.g. `onClick`).
4551
* @return {?function} The stored callback.
4552
*/
4553
getListener: function(id, registrationName) {
4554
var bankForRegistrationName = listenerBank[registrationName];
4555
return bankForRegistrationName && bankForRegistrationName[id];
4556
},
4557
4558
/**
4559
* Deletes a listener from the registration bank.
4560
*
4561
* @param {string} id ID of the DOM element.
4562
* @param {string} registrationName Name of listener (e.g. `onClick`).
4563
*/
4564
deleteListener: function(id, registrationName) {
4565
var bankForRegistrationName = listenerBank[registrationName];
4566
if (bankForRegistrationName) {
4567
delete bankForRegistrationName[id];
4568
}
4569
},
4570
4571
/**
4572
* Deletes all listeners for the DOM element with the supplied ID.
4573
*
4574
* @param {string} id ID of the DOM element.
4575
*/
4576
deleteAllListeners: function(id) {
4577
for (var registrationName in listenerBank) {
4578
delete listenerBank[registrationName][id];
4579
}
4580
},
4581
4582
/**
4583
* Allows registered plugins an opportunity to extract events from top-level
4584
* native browser events.
4585
*
4586
* @param {string} topLevelType Record from `EventConstants`.
4587
* @param {DOMEventTarget} topLevelTarget The listening component root node.
4588
* @param {string} topLevelTargetID ID of `topLevelTarget`.
4589
* @param {object} nativeEvent Native browser event.
4590
* @return {*} An accumulation of synthetic events.
4591
* @internal
4592
*/
4593
extractEvents: function(
4594
topLevelType,
4595
topLevelTarget,
4596
topLevelTargetID,
4597
nativeEvent) {
4598
var events;
4599
var plugins = EventPluginRegistry.plugins;
4600
for (var i = 0, l = plugins.length; i < l; i++) {
4601
// Not every plugin in the ordering may be loaded at runtime.
4602
var possiblePlugin = plugins[i];
4603
if (possiblePlugin) {
4604
var extractedEvents = possiblePlugin.extractEvents(
4605
topLevelType,
4606
topLevelTarget,
4607
topLevelTargetID,
4608
nativeEvent
4609
);
4610
if (extractedEvents) {
4611
events = accumulateInto(events, extractedEvents);
4612
}
4613
}
4614
}
4615
return events;
4616
},
4617
4618
/**
4619
* Enqueues a synthetic event that should be dispatched when
4620
* `processEventQueue` is invoked.
4621
*
4622
* @param {*} events An accumulation of synthetic events.
4623
* @internal
4624
*/
4625
enqueueEvents: function(events) {
4626
if (events) {
4627
eventQueue = accumulateInto(eventQueue, events);
4628
}
4629
},
4630
4631
/**
4632
* Dispatches all synthetic events on the event queue.
4633
*
4634
* @internal
4635
*/
4636
processEventQueue: function() {
4637
// Set `eventQueue` to null before processing it so that we can tell if more
4638
// events get enqueued while processing.
4639
var processingEventQueue = eventQueue;
4640
eventQueue = null;
4641
forEachAccumulated(processingEventQueue, executeDispatchesAndRelease);
4642
("production" !== process.env.NODE_ENV ? invariant(
4643
!eventQueue,
4644
'processEventQueue(): Additional events were enqueued while processing ' +
4645
'an event queue. Support for this has not yet been implemented.'
4646
) : invariant(!eventQueue));
4647
},
4648
4649
/**
4650
* These are needed for tests only. Do not use!
4651
*/
4652
__purge: function() {
4653
listenerBank = {};
4654
},
4655
4656
__getListenerBank: function() {
4657
return listenerBank;
4658
}
4659
4660
};
4661
4662
module.exports = EventPluginHub;
4663
4664
}).call(this,require('_process'))
4665
},{"./EventPluginRegistry":32,"./EventPluginUtils":33,"./accumulateInto":132,"./forEachAccumulated":149,"./invariant":164,"_process":1}],32:[function(require,module,exports){
4666
(function (process){
4667
/**
4668
* Copyright 2013-2015, Facebook, Inc.
4669
* All rights reserved.
4670
*
4671
* This source code is licensed under the BSD-style license found in the
4672
* LICENSE file in the root directory of this source tree. An additional grant
4673
* of patent rights can be found in the PATENTS file in the same directory.
4674
*
4675
* @providesModule EventPluginRegistry
4676
* @typechecks static-only
4677
*/
4678
4679
'use strict';
4680
4681
var invariant = require("./invariant");
4682
4683
/**
4684
* Injectable ordering of event plugins.
4685
*/
4686
var EventPluginOrder = null;
4687
4688
/**
4689
* Injectable mapping from names to event plugin modules.
4690
*/
4691
var namesToPlugins = {};
4692
4693
/**
4694
* Recomputes the plugin list using the injected plugins and plugin ordering.
4695
*
4696
* @private
4697
*/
4698
function recomputePluginOrdering() {
4699
if (!EventPluginOrder) {
4700
// Wait until an `EventPluginOrder` is injected.
4701
return;
4702
}
4703
for (var pluginName in namesToPlugins) {
4704
var PluginModule = namesToPlugins[pluginName];
4705
var pluginIndex = EventPluginOrder.indexOf(pluginName);
4706
("production" !== process.env.NODE_ENV ? invariant(
4707
pluginIndex > -1,
4708
'EventPluginRegistry: Cannot inject event plugins that do not exist in ' +
4709
'the plugin ordering, `%s`.',
4710
pluginName
4711
) : invariant(pluginIndex > -1));
4712
if (EventPluginRegistry.plugins[pluginIndex]) {
4713
continue;
4714
}
4715
("production" !== process.env.NODE_ENV ? invariant(
4716
PluginModule.extractEvents,
4717
'EventPluginRegistry: Event plugins must implement an `extractEvents` ' +
4718
'method, but `%s` does not.',
4719
pluginName
4720
) : invariant(PluginModule.extractEvents));
4721
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
4722
var publishedEvents = PluginModule.eventTypes;
4723
for (var eventName in publishedEvents) {
4724
("production" !== process.env.NODE_ENV ? invariant(
4725
publishEventForPlugin(
4726
publishedEvents[eventName],
4727
PluginModule,
4728
eventName
4729
),
4730
'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.',
4731
eventName,
4732
pluginName
4733
) : invariant(publishEventForPlugin(
4734
publishedEvents[eventName],
4735
PluginModule,
4736
eventName
4737
)));
4738
}
4739
}
4740
}
4741
4742
/**
4743
* Publishes an event so that it can be dispatched by the supplied plugin.
4744
*
4745
* @param {object} dispatchConfig Dispatch configuration for the event.
4746
* @param {object} PluginModule Plugin publishing the event.
4747
* @return {boolean} True if the event was successfully published.
4748
* @private
4749
*/
4750
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
4751
("production" !== process.env.NODE_ENV ? invariant(
4752
!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName),
4753
'EventPluginHub: More than one plugin attempted to publish the same ' +
4754
'event name, `%s`.',
4755
eventName
4756
) : invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName)));
4757
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
4758
4759
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
4760
if (phasedRegistrationNames) {
4761
for (var phaseName in phasedRegistrationNames) {
4762
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
4763
var phasedRegistrationName = phasedRegistrationNames[phaseName];
4764
publishRegistrationName(
4765
phasedRegistrationName,
4766
PluginModule,
4767
eventName
4768
);
4769
}
4770
}
4771
return true;
4772
} else if (dispatchConfig.registrationName) {
4773
publishRegistrationName(
4774
dispatchConfig.registrationName,
4775
PluginModule,
4776
eventName
4777
);
4778
return true;
4779
}
4780
return false;
4781
}
4782
4783
/**
4784
* Publishes a registration name that is used to identify dispatched events and
4785
* can be used with `EventPluginHub.putListener` to register listeners.
4786
*
4787
* @param {string} registrationName Registration name to add.
4788
* @param {object} PluginModule Plugin publishing the event.
4789
* @private
4790
*/
4791
function publishRegistrationName(registrationName, PluginModule, eventName) {
4792
("production" !== process.env.NODE_ENV ? invariant(
4793
!EventPluginRegistry.registrationNameModules[registrationName],
4794
'EventPluginHub: More than one plugin attempted to publish the same ' +
4795
'registration name, `%s`.',
4796
registrationName
4797
) : invariant(!EventPluginRegistry.registrationNameModules[registrationName]));
4798
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
4799
EventPluginRegistry.registrationNameDependencies[registrationName] =
4800
PluginModule.eventTypes[eventName].dependencies;
4801
}
4802
4803
/**
4804
* Registers plugins so that they can extract and dispatch events.
4805
*
4806
* @see {EventPluginHub}
4807
*/
4808
var EventPluginRegistry = {
4809
4810
/**
4811
* Ordered list of injected plugins.
4812
*/
4813
plugins: [],
4814
4815
/**
4816
* Mapping from event name to dispatch config
4817
*/
4818
eventNameDispatchConfigs: {},
4819
4820
/**
4821
* Mapping from registration name to plugin module
4822
*/
4823
registrationNameModules: {},
4824
4825
/**
4826
* Mapping from registration name to event name
4827
*/
4828
registrationNameDependencies: {},
4829
4830
/**
4831
* Injects an ordering of plugins (by plugin name). This allows the ordering
4832
* to be decoupled from injection of the actual plugins so that ordering is
4833
* always deterministic regardless of packaging, on-the-fly injection, etc.
4834
*
4835
* @param {array} InjectedEventPluginOrder
4836
* @internal
4837
* @see {EventPluginHub.injection.injectEventPluginOrder}
4838
*/
4839
injectEventPluginOrder: function(InjectedEventPluginOrder) {
4840
("production" !== process.env.NODE_ENV ? invariant(
4841
!EventPluginOrder,
4842
'EventPluginRegistry: Cannot inject event plugin ordering more than ' +
4843
'once. You are likely trying to load more than one copy of React.'
4844
) : invariant(!EventPluginOrder));
4845
// Clone the ordering so it cannot be dynamically mutated.
4846
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
4847
recomputePluginOrdering();
4848
},
4849
4850
/**
4851
* Injects plugins to be used by `EventPluginHub`. The plugin names must be
4852
* in the ordering injected by `injectEventPluginOrder`.
4853
*
4854
* Plugins can be injected as part of page initialization or on-the-fly.
4855
*
4856
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
4857
* @internal
4858
* @see {EventPluginHub.injection.injectEventPluginsByName}
4859
*/
4860
injectEventPluginsByName: function(injectedNamesToPlugins) {
4861
var isOrderingDirty = false;
4862
for (var pluginName in injectedNamesToPlugins) {
4863
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
4864
continue;
4865
}
4866
var PluginModule = injectedNamesToPlugins[pluginName];
4867
if (!namesToPlugins.hasOwnProperty(pluginName) ||
4868
namesToPlugins[pluginName] !== PluginModule) {
4869
("production" !== process.env.NODE_ENV ? invariant(
4870
!namesToPlugins[pluginName],
4871
'EventPluginRegistry: Cannot inject two different event plugins ' +
4872
'using the same name, `%s`.',
4873
pluginName
4874
) : invariant(!namesToPlugins[pluginName]));
4875
namesToPlugins[pluginName] = PluginModule;
4876
isOrderingDirty = true;
4877
}
4878
}
4879
if (isOrderingDirty) {
4880
recomputePluginOrdering();
4881
}
4882
},
4883
4884
/**
4885
* Looks up the plugin for the supplied event.
4886
*
4887
* @param {object} event A synthetic event.
4888
* @return {?object} The plugin that created the supplied event.
4889
* @internal
4890
*/
4891
getPluginModuleForEvent: function(event) {
4892
var dispatchConfig = event.dispatchConfig;
4893
if (dispatchConfig.registrationName) {
4894
return EventPluginRegistry.registrationNameModules[
4895
dispatchConfig.registrationName
4896
] || null;
4897
}
4898
for (var phase in dispatchConfig.phasedRegistrationNames) {
4899
if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
4900
continue;
4901
}
4902
var PluginModule = EventPluginRegistry.registrationNameModules[
4903
dispatchConfig.phasedRegistrationNames[phase]
4904
];
4905
if (PluginModule) {
4906
return PluginModule;
4907
}
4908
}
4909
return null;
4910
},
4911
4912
/**
4913
* Exposed for unit testing.
4914
* @private
4915
*/
4916
_resetEventPlugins: function() {
4917
EventPluginOrder = null;
4918
for (var pluginName in namesToPlugins) {
4919
if (namesToPlugins.hasOwnProperty(pluginName)) {
4920
delete namesToPlugins[pluginName];
4921
}
4922
}
4923
EventPluginRegistry.plugins.length = 0;
4924
4925
var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
4926
for (var eventName in eventNameDispatchConfigs) {
4927
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
4928
delete eventNameDispatchConfigs[eventName];
4929
}
4930
}
4931
4932
var registrationNameModules = EventPluginRegistry.registrationNameModules;
4933
for (var registrationName in registrationNameModules) {
4934
if (registrationNameModules.hasOwnProperty(registrationName)) {
4935
delete registrationNameModules[registrationName];
4936
}
4937
}
4938
}
4939
4940
};
4941
4942
module.exports = EventPluginRegistry;
4943
4944
}).call(this,require('_process'))
4945
},{"./invariant":164,"_process":1}],33:[function(require,module,exports){
4946
(function (process){
4947
/**
4948
* Copyright 2013-2015, Facebook, Inc.
4949
* All rights reserved.
4950
*
4951
* This source code is licensed under the BSD-style license found in the
4952
* LICENSE file in the root directory of this source tree. An additional grant
4953
* of patent rights can be found in the PATENTS file in the same directory.
4954
*
4955
* @providesModule EventPluginUtils
4956
*/
4957
4958
'use strict';
4959
4960
var EventConstants = require("./EventConstants");
4961
4962
var invariant = require("./invariant");
4963
4964
/**
4965
* Injected dependencies:
4966
*/
4967
4968
/**
4969
* - `Mount`: [required] Module that can convert between React dom IDs and
4970
* actual node references.
4971
*/
4972
var injection = {
4973
Mount: null,
4974
injectMount: function(InjectedMount) {
4975
injection.Mount = InjectedMount;
4976
if ("production" !== process.env.NODE_ENV) {
4977
("production" !== process.env.NODE_ENV ? invariant(
4978
InjectedMount && InjectedMount.getNode,
4979
'EventPluginUtils.injection.injectMount(...): Injected Mount module ' +
4980
'is missing getNode.'
4981
) : invariant(InjectedMount && InjectedMount.getNode));
4982
}
4983
}
4984
};
4985
4986
var topLevelTypes = EventConstants.topLevelTypes;
4987
4988
function isEndish(topLevelType) {
4989
return topLevelType === topLevelTypes.topMouseUp ||
4990
topLevelType === topLevelTypes.topTouchEnd ||
4991
topLevelType === topLevelTypes.topTouchCancel;
4992
}
4993
4994
function isMoveish(topLevelType) {
4995
return topLevelType === topLevelTypes.topMouseMove ||
4996
topLevelType === topLevelTypes.topTouchMove;
4997
}
4998
function isStartish(topLevelType) {
4999
return topLevelType === topLevelTypes.topMouseDown ||
5000
topLevelType === topLevelTypes.topTouchStart;
5001
}
5002
5003
5004
var validateEventDispatches;
5005
if ("production" !== process.env.NODE_ENV) {
5006
validateEventDispatches = function(event) {
5007
var dispatchListeners = event._dispatchListeners;
5008
var dispatchIDs = event._dispatchIDs;
5009
5010
var listenersIsArr = Array.isArray(dispatchListeners);
5011
var idsIsArr = Array.isArray(dispatchIDs);
5012
var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
5013
var listenersLen = listenersIsArr ?
5014
dispatchListeners.length :
5015
dispatchListeners ? 1 : 0;
5016
5017
("production" !== process.env.NODE_ENV ? invariant(
5018
idsIsArr === listenersIsArr && IDsLen === listenersLen,
5019
'EventPluginUtils: Invalid `event`.'
5020
) : invariant(idsIsArr === listenersIsArr && IDsLen === listenersLen));
5021
};
5022
}
5023
5024
/**
5025
* Invokes `cb(event, listener, id)`. Avoids using call if no scope is
5026
* provided. The `(listener,id)` pair effectively forms the "dispatch" but are
5027
* kept separate to conserve memory.
5028
*/
5029
function forEachEventDispatch(event, cb) {
5030
var dispatchListeners = event._dispatchListeners;
5031
var dispatchIDs = event._dispatchIDs;
5032
if ("production" !== process.env.NODE_ENV) {
5033
validateEventDispatches(event);
5034
}
5035
if (Array.isArray(dispatchListeners)) {
5036
for (var i = 0; i < dispatchListeners.length; i++) {
5037
if (event.isPropagationStopped()) {
5038
break;
5039
}
5040
// Listeners and IDs are two parallel arrays that are always in sync.
5041
cb(event, dispatchListeners[i], dispatchIDs[i]);
5042
}
5043
} else if (dispatchListeners) {
5044
cb(event, dispatchListeners, dispatchIDs);
5045
}
5046
}
5047
5048
/**
5049
* Default implementation of PluginModule.executeDispatch().
5050
* @param {SyntheticEvent} SyntheticEvent to handle
5051
* @param {function} Application-level callback
5052
* @param {string} domID DOM id to pass to the callback.
5053
*/
5054
function executeDispatch(event, listener, domID) {
5055
event.currentTarget = injection.Mount.getNode(domID);
5056
var returnValue = listener(event, domID);
5057
event.currentTarget = null;
5058
return returnValue;
5059
}
5060
5061
/**
5062
* Standard/simple iteration through an event's collected dispatches.
5063
*/
5064
function executeDispatchesInOrder(event, cb) {
5065
forEachEventDispatch(event, cb);
5066
event._dispatchListeners = null;
5067
event._dispatchIDs = null;
5068
}
5069
5070
/**
5071
* Standard/simple iteration through an event's collected dispatches, but stops
5072
* at the first dispatch execution returning true, and returns that id.
5073
*
5074
* @return id of the first dispatch execution who's listener returns true, or
5075
* null if no listener returned true.
5076
*/
5077
function executeDispatchesInOrderStopAtTrueImpl(event) {
5078
var dispatchListeners = event._dispatchListeners;
5079
var dispatchIDs = event._dispatchIDs;
5080
if ("production" !== process.env.NODE_ENV) {
5081
validateEventDispatches(event);
5082
}
5083
if (Array.isArray(dispatchListeners)) {
5084
for (var i = 0; i < dispatchListeners.length; i++) {
5085
if (event.isPropagationStopped()) {
5086
break;
5087
}
5088
// Listeners and IDs are two parallel arrays that are always in sync.
5089
if (dispatchListeners[i](event, dispatchIDs[i])) {
5090
return dispatchIDs[i];
5091
}
5092
}
5093
} else if (dispatchListeners) {
5094
if (dispatchListeners(event, dispatchIDs)) {
5095
return dispatchIDs;
5096
}
5097
}
5098
return null;
5099
}
5100
5101
/**
5102
* @see executeDispatchesInOrderStopAtTrueImpl
5103
*/
5104
function executeDispatchesInOrderStopAtTrue(event) {
5105
var ret = executeDispatchesInOrderStopAtTrueImpl(event);
5106
event._dispatchIDs = null;
5107
event._dispatchListeners = null;
5108
return ret;
5109
}
5110
5111
/**
5112
* Execution of a "direct" dispatch - there must be at most one dispatch
5113
* accumulated on the event or it is considered an error. It doesn't really make
5114
* sense for an event with multiple dispatches (bubbled) to keep track of the
5115
* return values at each dispatch execution, but it does tend to make sense when
5116
* dealing with "direct" dispatches.
5117
*
5118
* @return The return value of executing the single dispatch.
5119
*/
5120
function executeDirectDispatch(event) {
5121
if ("production" !== process.env.NODE_ENV) {
5122
validateEventDispatches(event);
5123
}
5124
var dispatchListener = event._dispatchListeners;
5125
var dispatchID = event._dispatchIDs;
5126
("production" !== process.env.NODE_ENV ? invariant(
5127
!Array.isArray(dispatchListener),
5128
'executeDirectDispatch(...): Invalid `event`.'
5129
) : invariant(!Array.isArray(dispatchListener)));
5130
var res = dispatchListener ?
5131
dispatchListener(event, dispatchID) :
5132
null;
5133
event._dispatchListeners = null;
5134
event._dispatchIDs = null;
5135
return res;
5136
}
5137
5138
/**
5139
* @param {SyntheticEvent} event
5140
* @return {bool} True iff number of dispatches accumulated is greater than 0.
5141
*/
5142
function hasDispatches(event) {
5143
return !!event._dispatchListeners;
5144
}
5145
5146
/**
5147
* General utilities that are useful in creating custom Event Plugins.
5148
*/
5149
var EventPluginUtils = {
5150
isEndish: isEndish,
5151
isMoveish: isMoveish,
5152
isStartish: isStartish,
5153
5154
executeDirectDispatch: executeDirectDispatch,
5155
executeDispatch: executeDispatch,
5156
executeDispatchesInOrder: executeDispatchesInOrder,
5157
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
5158
hasDispatches: hasDispatches,
5159
injection: injection,
5160
useTouchEvents: false
5161
};
5162
5163
module.exports = EventPluginUtils;
5164
5165
}).call(this,require('_process'))
5166
},{"./EventConstants":29,"./invariant":164,"_process":1}],34:[function(require,module,exports){
5167
(function (process){
5168
/**
5169
* Copyright 2013-2015, Facebook, Inc.
5170
* All rights reserved.
5171
*
5172
* This source code is licensed under the BSD-style license found in the
5173
* LICENSE file in the root directory of this source tree. An additional grant
5174
* of patent rights can be found in the PATENTS file in the same directory.
5175
*
5176
* @providesModule EventPropagators
5177
*/
5178
5179
'use strict';
5180
5181
var EventConstants = require("./EventConstants");
5182
var EventPluginHub = require("./EventPluginHub");
5183
5184
var accumulateInto = require("./accumulateInto");
5185
var forEachAccumulated = require("./forEachAccumulated");
5186
5187
var PropagationPhases = EventConstants.PropagationPhases;
5188
var getListener = EventPluginHub.getListener;
5189
5190
/**
5191
* Some event types have a notion of different registration names for different
5192
* "phases" of propagation. This finds listeners by a given phase.
5193
*/
5194
function listenerAtPhase(id, event, propagationPhase) {
5195
var registrationName =
5196
event.dispatchConfig.phasedRegistrationNames[propagationPhase];
5197
return getListener(id, registrationName);
5198
}
5199
5200
/**
5201
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function
5202
* here, allows us to not have to bind or create functions for each event.
5203
* Mutating the event's members allows us to not have to create a wrapping
5204
* "dispatch" object that pairs the event with the listener.
5205
*/
5206
function accumulateDirectionalDispatches(domID, upwards, event) {
5207
if ("production" !== process.env.NODE_ENV) {
5208
if (!domID) {
5209
throw new Error('Dispatching id must not be null');
5210
}
5211
}
5212
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
5213
var listener = listenerAtPhase(domID, event, phase);
5214
if (listener) {
5215
event._dispatchListeners =
5216
accumulateInto(event._dispatchListeners, listener);
5217
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
5218
}
5219
}
5220
5221
/**
5222
* Collect dispatches (must be entirely collected before dispatching - see unit
5223
* tests). Lazily allocate the array to conserve memory. We must loop through
5224
* each event and perform the traversal for each one. We can not perform a
5225
* single traversal for the entire collection of events because each event may
5226
* have a different target.
5227
*/
5228
function accumulateTwoPhaseDispatchesSingle(event) {
5229
if (event && event.dispatchConfig.phasedRegistrationNames) {
5230
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
5231
event.dispatchMarker,
5232
accumulateDirectionalDispatches,
5233
event
5234
);
5235
}
5236
}
5237
5238
5239
/**
5240
* Accumulates without regard to direction, does not look for phased
5241
* registration names. Same as `accumulateDirectDispatchesSingle` but without
5242
* requiring that the `dispatchMarker` be the same as the dispatched ID.
5243
*/
5244
function accumulateDispatches(id, ignoredDirection, event) {
5245
if (event && event.dispatchConfig.registrationName) {
5246
var registrationName = event.dispatchConfig.registrationName;
5247
var listener = getListener(id, registrationName);
5248
if (listener) {
5249
event._dispatchListeners =
5250
accumulateInto(event._dispatchListeners, listener);
5251
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
5252
}
5253
}
5254
}
5255
5256
/**
5257
* Accumulates dispatches on an `SyntheticEvent`, but only for the
5258
* `dispatchMarker`.
5259
* @param {SyntheticEvent} event
5260
*/
5261
function accumulateDirectDispatchesSingle(event) {
5262
if (event && event.dispatchConfig.registrationName) {
5263
accumulateDispatches(event.dispatchMarker, null, event);
5264
}
5265
}
5266
5267
function accumulateTwoPhaseDispatches(events) {
5268
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
5269
}
5270
5271
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
5272
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
5273
fromID,
5274
toID,
5275
accumulateDispatches,
5276
leave,
5277
enter
5278
);
5279
}
5280
5281
5282
function accumulateDirectDispatches(events) {
5283
forEachAccumulated(events, accumulateDirectDispatchesSingle);
5284
}
5285
5286
5287
5288
/**
5289
* A small set of propagation patterns, each of which will accept a small amount
5290
* of information, and generate a set of "dispatch ready event objects" - which
5291
* are sets of events that have already been annotated with a set of dispatched
5292
* listener functions/ids. The API is designed this way to discourage these
5293
* propagation strategies from actually executing the dispatches, since we
5294
* always want to collect the entire set of dispatches before executing event a
5295
* single one.
5296
*
5297
* @constructor EventPropagators
5298
*/
5299
var EventPropagators = {
5300
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
5301
accumulateDirectDispatches: accumulateDirectDispatches,
5302
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
5303
};
5304
5305
module.exports = EventPropagators;
5306
5307
}).call(this,require('_process'))
5308
},{"./EventConstants":29,"./EventPluginHub":31,"./accumulateInto":132,"./forEachAccumulated":149,"_process":1}],35:[function(require,module,exports){
5309
/**
5310
* Copyright 2013-2015, Facebook, Inc.
5311
* All rights reserved.
5312
*
5313
* This source code is licensed under the BSD-style license found in the
5314
* LICENSE file in the root directory of this source tree. An additional grant
5315
* of patent rights can be found in the PATENTS file in the same directory.
5316
*
5317
* @providesModule ExecutionEnvironment
5318
*/
5319
5320
/*jslint evil: true */
5321
5322
"use strict";
5323
5324
var canUseDOM = !!(
5325
(typeof window !== 'undefined' &&
5326
window.document && window.document.createElement)
5327
);
5328
5329
/**
5330
* Simple, lightweight module assisting with the detection and context of
5331
* Worker. Helps avoid circular dependencies and allows code to reason about
5332
* whether or not they are in a Worker, even if they never include the main
5333
* `ReactWorker` dependency.
5334
*/
5335
var ExecutionEnvironment = {
5336
5337
canUseDOM: canUseDOM,
5338
5339
canUseWorkers: typeof Worker !== 'undefined',
5340
5341
canUseEventListeners:
5342
canUseDOM && !!(window.addEventListener || window.attachEvent),
5343
5344
canUseViewport: canUseDOM && !!window.screen,
5345
5346
isInWorker: !canUseDOM // For now, this is true - might change in the future.
5347
5348
};
5349
5350
module.exports = ExecutionEnvironment;
5351
5352
},{}],36:[function(require,module,exports){
5353
/**
5354
* Copyright 2013-2015, Facebook, Inc.
5355
* All rights reserved.
5356
*
5357
* This source code is licensed under the BSD-style license found in the
5358
* LICENSE file in the root directory of this source tree. An additional grant
5359
* of patent rights can be found in the PATENTS file in the same directory.
5360
*
5361
* @providesModule FallbackCompositionState
5362
* @typechecks static-only
5363
*/
5364
5365
'use strict';
5366
5367
var PooledClass = require("./PooledClass");
5368
5369
var assign = require("./Object.assign");
5370
var getTextContentAccessor = require("./getTextContentAccessor");
5371
5372
/**
5373
* This helper class stores information about text content of a target node,
5374
* allowing comparison of content before and after a given event.
5375
*
5376
* Identify the node where selection currently begins, then observe
5377
* both its text content and its current position in the DOM. Since the
5378
* browser may natively replace the target node during composition, we can
5379
* use its position to find its replacement.
5380
*
5381
* @param {DOMEventTarget} root
5382
*/
5383
function FallbackCompositionState(root) {
5384
this._root = root;
5385
this._startText = this.getText();
5386
this._fallbackText = null;
5387
}
5388
5389
assign(FallbackCompositionState.prototype, {
5390
/**
5391
* Get current text of input.
5392
*
5393
* @return {string}
5394
*/
5395
getText: function() {
5396
if ('value' in this._root) {
5397
return this._root.value;
5398
}
5399
return this._root[getTextContentAccessor()];
5400
},
5401
5402
/**
5403
* Determine the differing substring between the initially stored
5404
* text content and the current content.
5405
*
5406
* @return {string}
5407
*/
5408
getData: function() {
5409
if (this._fallbackText) {
5410
return this._fallbackText;
5411
}
5412
5413
var start;
5414
var startValue = this._startText;
5415
var startLength = startValue.length;
5416
var end;
5417
var endValue = this.getText();
5418
var endLength = endValue.length;
5419
5420
for (start = 0; start < startLength; start++) {
5421
if (startValue[start] !== endValue[start]) {
5422
break;
5423
}
5424
}
5425
5426
var minEnd = startLength - start;
5427
for (end = 1; end <= minEnd; end++) {
5428
if (startValue[startLength - end] !== endValue[endLength - end]) {
5429
break;
5430
}
5431
}
5432
5433
var sliceTail = end > 1 ? 1 - end : undefined;
5434
this._fallbackText = endValue.slice(start, sliceTail);
5435
return this._fallbackText;
5436
}
5437
});
5438
5439
PooledClass.addPoolingTo(FallbackCompositionState);
5440
5441
module.exports = FallbackCompositionState;
5442
5443
},{"./Object.assign":42,"./PooledClass":43,"./getTextContentAccessor":159}],37:[function(require,module,exports){
5444
/**
5445
* Copyright 2013-2015, Facebook, Inc.
5446
* All rights reserved.
5447
*
5448
* This source code is licensed under the BSD-style license found in the
5449
* LICENSE file in the root directory of this source tree. An additional grant
5450
* of patent rights can be found in the PATENTS file in the same directory.
5451
*
5452
* @providesModule HTMLDOMPropertyConfig
5453
*/
5454
5455
/*jslint bitwise: true*/
5456
5457
'use strict';
5458
5459
var DOMProperty = require("./DOMProperty");
5460
var ExecutionEnvironment = require("./ExecutionEnvironment");
5461
5462
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
5463
var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
5464
var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
5465
var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
5466
var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
5467
var HAS_POSITIVE_NUMERIC_VALUE =
5468
DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
5469
var HAS_OVERLOADED_BOOLEAN_VALUE =
5470
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
5471
5472
var hasSVG;
5473
if (ExecutionEnvironment.canUseDOM) {
5474
var implementation = document.implementation;
5475
hasSVG = (
5476
implementation &&
5477
implementation.hasFeature &&
5478
implementation.hasFeature(
5479
'http://www.w3.org/TR/SVG11/feature#BasicStructure',
5480
'1.1'
5481
)
5482
);
5483
}
5484
5485
5486
var HTMLDOMPropertyConfig = {
5487
isCustomAttribute: RegExp.prototype.test.bind(
5488
/^(data|aria)-[a-z_][a-z\d_.\-]*$/
5489
),
5490
Properties: {
5491
/**
5492
* Standard Properties
5493
*/
5494
accept: null,
5495
acceptCharset: null,
5496
accessKey: null,
5497
action: null,
5498
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
5499
allowTransparency: MUST_USE_ATTRIBUTE,
5500
alt: null,
5501
async: HAS_BOOLEAN_VALUE,
5502
autoComplete: null,
5503
// autoFocus is polyfilled/normalized by AutoFocusMixin
5504
// autoFocus: HAS_BOOLEAN_VALUE,
5505
autoPlay: HAS_BOOLEAN_VALUE,
5506
cellPadding: null,
5507
cellSpacing: null,
5508
charSet: MUST_USE_ATTRIBUTE,
5509
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5510
classID: MUST_USE_ATTRIBUTE,
5511
// To set className on SVG elements, it's necessary to use .setAttribute;
5512
// this works on HTML elements too in all browsers except IE8. Conveniently,
5513
// IE8 doesn't support SVG and so we can simply use the attribute in
5514
// browsers that support SVG and the property in browsers that don't,
5515
// regardless of whether the element is HTML or SVG.
5516
className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
5517
cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
5518
colSpan: null,
5519
content: null,
5520
contentEditable: null,
5521
contextMenu: MUST_USE_ATTRIBUTE,
5522
controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5523
coords: null,
5524
crossOrigin: null,
5525
data: null, // For `<object />` acts as `src`.
5526
dateTime: MUST_USE_ATTRIBUTE,
5527
defer: HAS_BOOLEAN_VALUE,
5528
dir: null,
5529
disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
5530
download: HAS_OVERLOADED_BOOLEAN_VALUE,
5531
draggable: null,
5532
encType: null,
5533
form: MUST_USE_ATTRIBUTE,
5534
formAction: MUST_USE_ATTRIBUTE,
5535
formEncType: MUST_USE_ATTRIBUTE,
5536
formMethod: MUST_USE_ATTRIBUTE,
5537
formNoValidate: HAS_BOOLEAN_VALUE,
5538
formTarget: MUST_USE_ATTRIBUTE,
5539
frameBorder: MUST_USE_ATTRIBUTE,
5540
headers: null,
5541
height: MUST_USE_ATTRIBUTE,
5542
hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
5543
high: null,
5544
href: null,
5545
hrefLang: null,
5546
htmlFor: null,
5547
httpEquiv: null,
5548
icon: null,
5549
id: MUST_USE_PROPERTY,
5550
label: null,
5551
lang: null,
5552
list: MUST_USE_ATTRIBUTE,
5553
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5554
low: null,
5555
manifest: MUST_USE_ATTRIBUTE,
5556
marginHeight: null,
5557
marginWidth: null,
5558
max: null,
5559
maxLength: MUST_USE_ATTRIBUTE,
5560
media: MUST_USE_ATTRIBUTE,
5561
mediaGroup: null,
5562
method: null,
5563
min: null,
5564
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5565
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5566
name: null,
5567
noValidate: HAS_BOOLEAN_VALUE,
5568
open: HAS_BOOLEAN_VALUE,
5569
optimum: null,
5570
pattern: null,
5571
placeholder: null,
5572
poster: null,
5573
preload: null,
5574
radioGroup: null,
5575
readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5576
rel: null,
5577
required: HAS_BOOLEAN_VALUE,
5578
role: MUST_USE_ATTRIBUTE,
5579
rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
5580
rowSpan: null,
5581
sandbox: null,
5582
scope: null,
5583
scoped: HAS_BOOLEAN_VALUE,
5584
scrolling: null,
5585
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
5586
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
5587
shape: null,
5588
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
5589
sizes: MUST_USE_ATTRIBUTE,
5590
span: HAS_POSITIVE_NUMERIC_VALUE,
5591
spellCheck: null,
5592
src: null,
5593
srcDoc: MUST_USE_PROPERTY,
5594
srcSet: MUST_USE_ATTRIBUTE,
5595
start: HAS_NUMERIC_VALUE,
5596
step: null,
5597
style: null,
5598
tabIndex: null,
5599
target: null,
5600
title: null,
5601
type: null,
5602
useMap: null,
5603
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
5604
width: MUST_USE_ATTRIBUTE,
5605
wmode: MUST_USE_ATTRIBUTE,
5606
5607
/**
5608
* Non-standard Properties
5609
*/
5610
// autoCapitalize and autoCorrect are supported in Mobile Safari for
5611
// keyboard hints.
5612
autoCapitalize: null,
5613
autoCorrect: null,
5614
// itemProp, itemScope, itemType are for
5615
// Microdata support. See http://schema.org/docs/gs.html
5616
itemProp: MUST_USE_ATTRIBUTE,
5617
itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
5618
itemType: MUST_USE_ATTRIBUTE,
5619
// itemID and itemRef are for Microdata support as well but
5620
// only specified in the the WHATWG spec document. See
5621
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
5622
itemID: MUST_USE_ATTRIBUTE,
5623
itemRef: MUST_USE_ATTRIBUTE,
5624
// property is supported for OpenGraph in meta tags.
5625
property: null,
5626
// IE-only attribute that controls focus behavior
5627
unselectable: MUST_USE_ATTRIBUTE
5628
},
5629
DOMAttributeNames: {
5630
acceptCharset: 'accept-charset',
5631
className: 'class',
5632
htmlFor: 'for',
5633
httpEquiv: 'http-equiv'
5634
},
5635
DOMPropertyNames: {
5636
autoCapitalize: 'autocapitalize',
5637
autoComplete: 'autocomplete',
5638
autoCorrect: 'autocorrect',
5639
autoFocus: 'autofocus',
5640
autoPlay: 'autoplay',
5641
// `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
5642
// http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
5643
encType: 'encoding',
5644
hrefLang: 'hreflang',
5645
radioGroup: 'radiogroup',
5646
spellCheck: 'spellcheck',
5647
srcDoc: 'srcdoc',
5648
srcSet: 'srcset'
5649
}
5650
};
5651
5652
module.exports = HTMLDOMPropertyConfig;
5653
5654
},{"./DOMProperty":24,"./ExecutionEnvironment":35}],38:[function(require,module,exports){
5655
/**
5656
* Copyright 2013-2015, Facebook, Inc.
5657
* All rights reserved.
5658
*
5659
* This source code is licensed under the BSD-style license found in the
5660
* LICENSE file in the root directory of this source tree. An additional grant
5661
* of patent rights can be found in the PATENTS file in the same directory.
5662
*
5663
* @providesModule LinkedStateMixin
5664
* @typechecks static-only
5665
*/
5666
5667
'use strict';
5668
5669
var ReactLink = require("./ReactLink");
5670
var ReactStateSetters = require("./ReactStateSetters");
5671
5672
/**
5673
* A simple mixin around ReactLink.forState().
5674
*/
5675
var LinkedStateMixin = {
5676
/**
5677
* Create a ReactLink that's linked to part of this component's state. The
5678
* ReactLink will have the current value of this.state[key] and will call
5679
* setState() when a change is requested.
5680
*
5681
* @param {string} key state key to update. Note: you may want to use keyOf()
5682
* if you're using Google Closure Compiler advanced mode.
5683
* @return {ReactLink} ReactLink instance linking to the state.
5684
*/
5685
linkState: function(key) {
5686
return new ReactLink(
5687
this.state[key],
5688
ReactStateSetters.createStateKeySetter(this, key)
5689
);
5690
}
5691
};
5692
5693
module.exports = LinkedStateMixin;
5694
5695
},{"./ReactLink":88,"./ReactStateSetters":107}],39:[function(require,module,exports){
5696
(function (process){
5697
/**
5698
* Copyright 2013-2015, Facebook, Inc.
5699
* All rights reserved.
5700
*
5701
* This source code is licensed under the BSD-style license found in the
5702
* LICENSE file in the root directory of this source tree. An additional grant
5703
* of patent rights can be found in the PATENTS file in the same directory.
5704
*
5705
* @providesModule LinkedValueUtils
5706
* @typechecks static-only
5707
*/
5708
5709
'use strict';
5710
5711
var ReactPropTypes = require("./ReactPropTypes");
5712
5713
var invariant = require("./invariant");
5714
5715
var hasReadOnlyValue = {
5716
'button': true,
5717
'checkbox': true,
5718
'image': true,
5719
'hidden': true,
5720
'radio': true,
5721
'reset': true,
5722
'submit': true
5723
};
5724
5725
function _assertSingleLink(input) {
5726
("production" !== process.env.NODE_ENV ? invariant(
5727
input.props.checkedLink == null || input.props.valueLink == null,
5728
'Cannot provide a checkedLink and a valueLink. If you want to use ' +
5729
'checkedLink, you probably don\'t want to use valueLink and vice versa.'
5730
) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
5731
}
5732
function _assertValueLink(input) {
5733
_assertSingleLink(input);
5734
("production" !== process.env.NODE_ENV ? invariant(
5735
input.props.value == null && input.props.onChange == null,
5736
'Cannot provide a valueLink and a value or onChange event. If you want ' +
5737
'to use value or onChange, you probably don\'t want to use valueLink.'
5738
) : invariant(input.props.value == null && input.props.onChange == null));
5739
}
5740
5741
function _assertCheckedLink(input) {
5742
_assertSingleLink(input);
5743
("production" !== process.env.NODE_ENV ? invariant(
5744
input.props.checked == null && input.props.onChange == null,
5745
'Cannot provide a checkedLink and a checked property or onChange event. ' +
5746
'If you want to use checked or onChange, you probably don\'t want to ' +
5747
'use checkedLink'
5748
) : invariant(input.props.checked == null && input.props.onChange == null));
5749
}
5750
5751
/**
5752
* @param {SyntheticEvent} e change event to handle
5753
*/
5754
function _handleLinkedValueChange(e) {
5755
/*jshint validthis:true */
5756
this.props.valueLink.requestChange(e.target.value);
5757
}
5758
5759
/**
5760
* @param {SyntheticEvent} e change event to handle
5761
*/
5762
function _handleLinkedCheckChange(e) {
5763
/*jshint validthis:true */
5764
this.props.checkedLink.requestChange(e.target.checked);
5765
}
5766
5767
/**
5768
* Provide a linked `value` attribute for controlled forms. You should not use
5769
* this outside of the ReactDOM controlled form components.
5770
*/
5771
var LinkedValueUtils = {
5772
Mixin: {
5773
propTypes: {
5774
value: function(props, propName, componentName) {
5775
if (!props[propName] ||
5776
hasReadOnlyValue[props.type] ||
5777
props.onChange ||
5778
props.readOnly ||
5779
props.disabled) {
5780
return null;
5781
}
5782
return new Error(
5783
'You provided a `value` prop to a form field without an ' +
5784
'`onChange` handler. This will render a read-only field. If ' +
5785
'the field should be mutable use `defaultValue`. Otherwise, ' +
5786
'set either `onChange` or `readOnly`.'
5787
);
5788
},
5789
checked: function(props, propName, componentName) {
5790
if (!props[propName] ||
5791
props.onChange ||
5792
props.readOnly ||
5793
props.disabled) {
5794
return null;
5795
}
5796
return new Error(
5797
'You provided a `checked` prop to a form field without an ' +
5798
'`onChange` handler. This will render a read-only field. If ' +
5799
'the field should be mutable use `defaultChecked`. Otherwise, ' +
5800
'set either `onChange` or `readOnly`.'
5801
);
5802
},
5803
onChange: ReactPropTypes.func
5804
}
5805
},
5806
5807
/**
5808
* @param {ReactComponent} input Form component
5809
* @return {*} current value of the input either from value prop or link.
5810
*/
5811
getValue: function(input) {
5812
if (input.props.valueLink) {
5813
_assertValueLink(input);
5814
return input.props.valueLink.value;
5815
}
5816
return input.props.value;
5817
},
5818
5819
/**
5820
* @param {ReactComponent} input Form component
5821
* @return {*} current checked status of the input either from checked prop
5822
* or link.
5823
*/
5824
getChecked: function(input) {
5825
if (input.props.checkedLink) {
5826
_assertCheckedLink(input);
5827
return input.props.checkedLink.value;
5828
}
5829
return input.props.checked;
5830
},
5831
5832
/**
5833
* @param {ReactComponent} input Form component
5834
* @return {function} change callback either from onChange prop or link.
5835
*/
5836
getOnChange: function(input) {
5837
if (input.props.valueLink) {
5838
_assertValueLink(input);
5839
return _handleLinkedValueChange;
5840
} else if (input.props.checkedLink) {
5841
_assertCheckedLink(input);
5842
return _handleLinkedCheckChange;
5843
}
5844
return input.props.onChange;
5845
}
5846
};
5847
5848
module.exports = LinkedValueUtils;
5849
5850
}).call(this,require('_process'))
5851
},{"./ReactPropTypes":99,"./invariant":164,"_process":1}],40:[function(require,module,exports){
5852
(function (process){
5853
/**
5854
* Copyright 2014-2015, Facebook, Inc.
5855
* All rights reserved.
5856
*
5857
* This source code is licensed under the BSD-style license found in the
5858
* LICENSE file in the root directory of this source tree. An additional grant
5859
* of patent rights can be found in the PATENTS file in the same directory.
5860
*
5861
* @providesModule LocalEventTrapMixin
5862
*/
5863
5864
'use strict';
5865
5866
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
5867
5868
var accumulateInto = require("./accumulateInto");
5869
var forEachAccumulated = require("./forEachAccumulated");
5870
var invariant = require("./invariant");
5871
5872
function remove(event) {
5873
event.remove();
5874
}
5875
5876
var LocalEventTrapMixin = {
5877
trapBubbledEvent:function(topLevelType, handlerBaseName) {
5878
("production" !== process.env.NODE_ENV ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
5879
// If a component renders to null or if another component fatals and causes
5880
// the state of the tree to be corrupted, `node` here can be null.
5881
var node = this.getDOMNode();
5882
("production" !== process.env.NODE_ENV ? invariant(
5883
node,
5884
'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
5885
) : invariant(node));
5886
var listener = ReactBrowserEventEmitter.trapBubbledEvent(
5887
topLevelType,
5888
handlerBaseName,
5889
node
5890
);
5891
this._localEventListeners =
5892
accumulateInto(this._localEventListeners, listener);
5893
},
5894
5895
// trapCapturedEvent would look nearly identical. We don't implement that
5896
// method because it isn't currently needed.
5897
5898
componentWillUnmount:function() {
5899
if (this._localEventListeners) {
5900
forEachAccumulated(this._localEventListeners, remove);
5901
}
5902
}
5903
};
5904
5905
module.exports = LocalEventTrapMixin;
5906
5907
}).call(this,require('_process'))
5908
},{"./ReactBrowserEventEmitter":46,"./accumulateInto":132,"./forEachAccumulated":149,"./invariant":164,"_process":1}],41:[function(require,module,exports){
5909
/**
5910
* Copyright 2013-2015, Facebook, Inc.
5911
* All rights reserved.
5912
*
5913
* This source code is licensed under the BSD-style license found in the
5914
* LICENSE file in the root directory of this source tree. An additional grant
5915
* of patent rights can be found in the PATENTS file in the same directory.
5916
*
5917
* @providesModule MobileSafariClickEventPlugin
5918
* @typechecks static-only
5919
*/
5920
5921
'use strict';
5922
5923
var EventConstants = require("./EventConstants");
5924
5925
var emptyFunction = require("./emptyFunction");
5926
5927
var topLevelTypes = EventConstants.topLevelTypes;
5928
5929
/**
5930
* Mobile Safari does not fire properly bubble click events on non-interactive
5931
* elements, which means delegated click listeners do not fire. The workaround
5932
* for this bug involves attaching an empty click listener on the target node.
5933
*
5934
* This particular plugin works around the bug by attaching an empty click
5935
* listener on `touchstart` (which does fire on every element).
5936
*/
5937
var MobileSafariClickEventPlugin = {
5938
5939
eventTypes: null,
5940
5941
/**
5942
* @param {string} topLevelType Record from `EventConstants`.
5943
* @param {DOMEventTarget} topLevelTarget The listening component root node.
5944
* @param {string} topLevelTargetID ID of `topLevelTarget`.
5945
* @param {object} nativeEvent Native browser event.
5946
* @return {*} An accumulation of synthetic events.
5947
* @see {EventPluginHub.extractEvents}
5948
*/
5949
extractEvents: function(
5950
topLevelType,
5951
topLevelTarget,
5952
topLevelTargetID,
5953
nativeEvent) {
5954
if (topLevelType === topLevelTypes.topTouchStart) {
5955
var target = nativeEvent.target;
5956
if (target && !target.onclick) {
5957
target.onclick = emptyFunction;
5958
}
5959
}
5960
}
5961
5962
};
5963
5964
module.exports = MobileSafariClickEventPlugin;
5965
5966
},{"./EventConstants":29,"./emptyFunction":143}],42:[function(require,module,exports){
5967
/**
5968
* Copyright 2014-2015, Facebook, Inc.
5969
* All rights reserved.
5970
*
5971
* This source code is licensed under the BSD-style license found in the
5972
* LICENSE file in the root directory of this source tree. An additional grant
5973
* of patent rights can be found in the PATENTS file in the same directory.
5974
*
5975
* @providesModule Object.assign
5976
*/
5977
5978
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
5979
5980
'use strict';
5981
5982
function assign(target, sources) {
5983
if (target == null) {
5984
throw new TypeError('Object.assign target cannot be null or undefined');
5985
}
5986
5987
var to = Object(target);
5988
var hasOwnProperty = Object.prototype.hasOwnProperty;
5989
5990
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
5991
var nextSource = arguments[nextIndex];
5992
if (nextSource == null) {
5993
continue;
5994
}
5995
5996
var from = Object(nextSource);
5997
5998
// We don't currently support accessors nor proxies. Therefore this
5999
// copy cannot throw. If we ever supported this then we must handle
6000
// exceptions and side-effects. We don't support symbols so they won't
6001
// be transferred.
6002
6003
for (var key in from) {
6004
if (hasOwnProperty.call(from, key)) {
6005
to[key] = from[key];
6006
}
6007
}
6008
}
6009
6010
return to;
6011
}
6012
6013
module.exports = assign;
6014
6015
},{}],43:[function(require,module,exports){
6016
(function (process){
6017
/**
6018
* Copyright 2013-2015, Facebook, Inc.
6019
* All rights reserved.
6020
*
6021
* This source code is licensed under the BSD-style license found in the
6022
* LICENSE file in the root directory of this source tree. An additional grant
6023
* of patent rights can be found in the PATENTS file in the same directory.
6024
*
6025
* @providesModule PooledClass
6026
*/
6027
6028
'use strict';
6029
6030
var invariant = require("./invariant");
6031
6032
/**
6033
* Static poolers. Several custom versions for each potential number of
6034
* arguments. A completely generic pooler is easy to implement, but would
6035
* require accessing the `arguments` object. In each of these, `this` refers to
6036
* the Class itself, not an instance. If any others are needed, simply add them
6037
* here, or in their own files.
6038
*/
6039
var oneArgumentPooler = function(copyFieldsFrom) {
6040
var Klass = this;
6041
if (Klass.instancePool.length) {
6042
var instance = Klass.instancePool.pop();
6043
Klass.call(instance, copyFieldsFrom);
6044
return instance;
6045
} else {
6046
return new Klass(copyFieldsFrom);
6047
}
6048
};
6049
6050
var twoArgumentPooler = function(a1, a2) {
6051
var Klass = this;
6052
if (Klass.instancePool.length) {
6053
var instance = Klass.instancePool.pop();
6054
Klass.call(instance, a1, a2);
6055
return instance;
6056
} else {
6057
return new Klass(a1, a2);
6058
}
6059
};
6060
6061
var threeArgumentPooler = function(a1, a2, a3) {
6062
var Klass = this;
6063
if (Klass.instancePool.length) {
6064
var instance = Klass.instancePool.pop();
6065
Klass.call(instance, a1, a2, a3);
6066
return instance;
6067
} else {
6068
return new Klass(a1, a2, a3);
6069
}
6070
};
6071
6072
var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
6073
var Klass = this;
6074
if (Klass.instancePool.length) {
6075
var instance = Klass.instancePool.pop();
6076
Klass.call(instance, a1, a2, a3, a4, a5);
6077
return instance;
6078
} else {
6079
return new Klass(a1, a2, a3, a4, a5);
6080
}
6081
};
6082
6083
var standardReleaser = function(instance) {
6084
var Klass = this;
6085
("production" !== process.env.NODE_ENV ? invariant(
6086
instance instanceof Klass,
6087
'Trying to release an instance into a pool of a different type.'
6088
) : invariant(instance instanceof Klass));
6089
if (instance.destructor) {
6090
instance.destructor();
6091
}
6092
if (Klass.instancePool.length < Klass.poolSize) {
6093
Klass.instancePool.push(instance);
6094
}
6095
};
6096
6097
var DEFAULT_POOL_SIZE = 10;
6098
var DEFAULT_POOLER = oneArgumentPooler;
6099
6100
/**
6101
* Augments `CopyConstructor` to be a poolable class, augmenting only the class
6102
* itself (statically) not adding any prototypical fields. Any CopyConstructor
6103
* you give this may have a `poolSize` property, and will look for a
6104
* prototypical `destructor` on instances (optional).
6105
*
6106
* @param {Function} CopyConstructor Constructor that can be used to reset.
6107
* @param {Function} pooler Customizable pooler.
6108
*/
6109
var addPoolingTo = function(CopyConstructor, pooler) {
6110
var NewKlass = CopyConstructor;
6111
NewKlass.instancePool = [];
6112
NewKlass.getPooled = pooler || DEFAULT_POOLER;
6113
if (!NewKlass.poolSize) {
6114
NewKlass.poolSize = DEFAULT_POOL_SIZE;
6115
}
6116
NewKlass.release = standardReleaser;
6117
return NewKlass;
6118
};
6119
6120
var PooledClass = {
6121
addPoolingTo: addPoolingTo,
6122
oneArgumentPooler: oneArgumentPooler,
6123
twoArgumentPooler: twoArgumentPooler,
6124
threeArgumentPooler: threeArgumentPooler,
6125
fiveArgumentPooler: fiveArgumentPooler
6126
};
6127
6128
module.exports = PooledClass;
6129
6130
}).call(this,require('_process'))
6131
},{"./invariant":164,"_process":1}],44:[function(require,module,exports){
6132
(function (process){
6133
/**
6134
* Copyright 2013-2015, Facebook, Inc.
6135
* All rights reserved.
6136
*
6137
* This source code is licensed under the BSD-style license found in the
6138
* LICENSE file in the root directory of this source tree. An additional grant
6139
* of patent rights can be found in the PATENTS file in the same directory.
6140
*
6141
* @providesModule React
6142
*/
6143
6144
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
6145
6146
'use strict';
6147
6148
var EventPluginUtils = require("./EventPluginUtils");
6149
var ReactChildren = require("./ReactChildren");
6150
var ReactComponent = require("./ReactComponent");
6151
var ReactClass = require("./ReactClass");
6152
var ReactContext = require("./ReactContext");
6153
var ReactCurrentOwner = require("./ReactCurrentOwner");
6154
var ReactElement = require("./ReactElement");
6155
var ReactElementValidator = require("./ReactElementValidator");
6156
var ReactDOM = require("./ReactDOM");
6157
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
6158
var ReactDefaultInjection = require("./ReactDefaultInjection");
6159
var ReactInstanceHandles = require("./ReactInstanceHandles");
6160
var ReactMount = require("./ReactMount");
6161
var ReactPerf = require("./ReactPerf");
6162
var ReactPropTypes = require("./ReactPropTypes");
6163
var ReactReconciler = require("./ReactReconciler");
6164
var ReactServerRendering = require("./ReactServerRendering");
6165
6166
var assign = require("./Object.assign");
6167
var findDOMNode = require("./findDOMNode");
6168
var onlyChild = require("./onlyChild");
6169
6170
ReactDefaultInjection.inject();
6171
6172
var createElement = ReactElement.createElement;
6173
var createFactory = ReactElement.createFactory;
6174
var cloneElement = ReactElement.cloneElement;
6175
6176
if ("production" !== process.env.NODE_ENV) {
6177
createElement = ReactElementValidator.createElement;
6178
createFactory = ReactElementValidator.createFactory;
6179
cloneElement = ReactElementValidator.cloneElement;
6180
}
6181
6182
var render = ReactPerf.measure('React', 'render', ReactMount.render);
6183
6184
var React = {
6185
Children: {
6186
map: ReactChildren.map,
6187
forEach: ReactChildren.forEach,
6188
count: ReactChildren.count,
6189
only: onlyChild
6190
},
6191
Component: ReactComponent,
6192
DOM: ReactDOM,
6193
PropTypes: ReactPropTypes,
6194
initializeTouchEvents: function(shouldUseTouch) {
6195
EventPluginUtils.useTouchEvents = shouldUseTouch;
6196
},
6197
createClass: ReactClass.createClass,
6198
createElement: createElement,
6199
cloneElement: cloneElement,
6200
createFactory: createFactory,
6201
createMixin: function(mixin) {
6202
// Currently a noop. Will be used to validate and trace mixins.
6203
return mixin;
6204
},
6205
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
6206
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
6207
findDOMNode: findDOMNode,
6208
render: render,
6209
renderToString: ReactServerRendering.renderToString,
6210
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
6211
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
6212
isValidElement: ReactElement.isValidElement,
6213
withContext: ReactContext.withContext,
6214
6215
// Hook for JSX spread, don't use this for anything else.
6216
__spread: assign
6217
};
6218
6219
// Inject the runtime into a devtools global hook regardless of browser.
6220
// Allows for debugging when the hook is injected on the page.
6221
if (
6222
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
6223
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
6224
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
6225
CurrentOwner: ReactCurrentOwner,
6226
InstanceHandles: ReactInstanceHandles,
6227
Mount: ReactMount,
6228
Reconciler: ReactReconciler,
6229
TextComponent: ReactDOMTextComponent
6230
});
6231
}
6232
6233
if ("production" !== process.env.NODE_ENV) {
6234
var ExecutionEnvironment = require("./ExecutionEnvironment");
6235
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
6236
6237
// If we're in Chrome, look for the devtools marker and provide a download
6238
// link if not installed.
6239
if (navigator.userAgent.indexOf('Chrome') > -1) {
6240
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
6241
console.debug(
6242
'Download the React DevTools for a better development experience: ' +
6243
'https://fb.me/react-devtools'
6244
);
6245
}
6246
}
6247
6248
var expectedFeatures = [
6249
// shims
6250
Array.isArray,
6251
Array.prototype.every,
6252
Array.prototype.forEach,
6253
Array.prototype.indexOf,
6254
Array.prototype.map,
6255
Date.now,
6256
Function.prototype.bind,
6257
Object.keys,
6258
String.prototype.split,
6259
String.prototype.trim,
6260
6261
// shams
6262
Object.create,
6263
Object.freeze
6264
];
6265
6266
for (var i = 0; i < expectedFeatures.length; i++) {
6267
if (!expectedFeatures[i]) {
6268
console.error(
6269
'One or more ES5 shim/shams expected by React are not available: ' +
6270
'https://fb.me/react-warning-polyfills'
6271
);
6272
break;
6273
}
6274
}
6275
}
6276
}
6277
6278
React.version = '0.13.3';
6279
6280
module.exports = React;
6281
6282
}).call(this,require('_process'))
6283
},{"./EventPluginUtils":33,"./ExecutionEnvironment":35,"./Object.assign":42,"./ReactChildren":50,"./ReactClass":51,"./ReactComponent":52,"./ReactContext":57,"./ReactCurrentOwner":58,"./ReactDOM":59,"./ReactDOMTextComponent":70,"./ReactDefaultInjection":73,"./ReactElement":76,"./ReactElementValidator":77,"./ReactInstanceHandles":85,"./ReactMount":90,"./ReactPerf":95,"./ReactPropTypes":99,"./ReactReconciler":102,"./ReactServerRendering":105,"./findDOMNode":146,"./onlyChild":174,"_process":1}],45:[function(require,module,exports){
6284
/**
6285
* Copyright 2013-2015, Facebook, Inc.
6286
* All rights reserved.
6287
*
6288
* This source code is licensed under the BSD-style license found in the
6289
* LICENSE file in the root directory of this source tree. An additional grant
6290
* of patent rights can be found in the PATENTS file in the same directory.
6291
*
6292
* @providesModule ReactBrowserComponentMixin
6293
*/
6294
6295
'use strict';
6296
6297
var findDOMNode = require("./findDOMNode");
6298
6299
var ReactBrowserComponentMixin = {
6300
/**
6301
* Returns the DOM node rendered by this component.
6302
*
6303
* @return {DOMElement} The root node of this component.
6304
* @final
6305
* @protected
6306
*/
6307
getDOMNode: function() {
6308
return findDOMNode(this);
6309
}
6310
};
6311
6312
module.exports = ReactBrowserComponentMixin;
6313
6314
},{"./findDOMNode":146}],46:[function(require,module,exports){
6315
/**
6316
* Copyright 2013-2015, Facebook, Inc.
6317
* All rights reserved.
6318
*
6319
* This source code is licensed under the BSD-style license found in the
6320
* LICENSE file in the root directory of this source tree. An additional grant
6321
* of patent rights can be found in the PATENTS file in the same directory.
6322
*
6323
* @providesModule ReactBrowserEventEmitter
6324
* @typechecks static-only
6325
*/
6326
6327
'use strict';
6328
6329
var EventConstants = require("./EventConstants");
6330
var EventPluginHub = require("./EventPluginHub");
6331
var EventPluginRegistry = require("./EventPluginRegistry");
6332
var ReactEventEmitterMixin = require("./ReactEventEmitterMixin");
6333
var ViewportMetrics = require("./ViewportMetrics");
6334
6335
var assign = require("./Object.assign");
6336
var isEventSupported = require("./isEventSupported");
6337
6338
/**
6339
* Summary of `ReactBrowserEventEmitter` event handling:
6340
*
6341
* - Top-level delegation is used to trap most native browser events. This
6342
* may only occur in the main thread and is the responsibility of
6343
* ReactEventListener, which is injected and can therefore support pluggable
6344
* event sources. This is the only work that occurs in the main thread.
6345
*
6346
* - We normalize and de-duplicate events to account for browser quirks. This
6347
* may be done in the worker thread.
6348
*
6349
* - Forward these native events (with the associated top-level type used to
6350
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
6351
* to extract any synthetic events.
6352
*
6353
* - The `EventPluginHub` will then process each event by annotating them with
6354
* "dispatches", a sequence of listeners and IDs that care about that event.
6355
*
6356
* - The `EventPluginHub` then dispatches the events.
6357
*
6358
* Overview of React and the event system:
6359
*
6360
* +------------+ .
6361
* | DOM | .
6362
* +------------+ .
6363
* | .
6364
* v .
6365
* +------------+ .
6366
* | ReactEvent | .
6367
* | Listener | .
6368
* +------------+ . +-----------+
6369
* | . +--------+|SimpleEvent|
6370
* | . | |Plugin |
6371
* +-----|------+ . v +-----------+
6372
* | | | . +--------------+ +------------+
6373
* | +-----------.--->|EventPluginHub| | Event |
6374
* | | . | | +-----------+ | Propagators|
6375
* | ReactEvent | . | | |TapEvent | |------------|
6376
* | Emitter | . | |<---+|Plugin | |other plugin|
6377
* | | . | | +-----------+ | utilities |
6378
* | +-----------.--->| | +------------+
6379
* | | | . +--------------+
6380
* +-----|------+ . ^ +-----------+
6381
* | . | |Enter/Leave|
6382
* + . +-------+|Plugin |
6383
* +-------------+ . +-----------+
6384
* | application | .
6385
* |-------------| .
6386
* | | .
6387
* | | .
6388
* +-------------+ .
6389
* .
6390
* React Core . General Purpose Event Plugin System
6391
*/
6392
6393
var alreadyListeningTo = {};
6394
var isMonitoringScrollValue = false;
6395
var reactTopListenersCounter = 0;
6396
6397
// For events like 'submit' which don't consistently bubble (which we trap at a
6398
// lower node than `document`), binding at `document` would cause duplicate
6399
// events so we don't include them here
6400
var topEventMapping = {
6401
topBlur: 'blur',
6402
topChange: 'change',
6403
topClick: 'click',
6404
topCompositionEnd: 'compositionend',
6405
topCompositionStart: 'compositionstart',
6406
topCompositionUpdate: 'compositionupdate',
6407
topContextMenu: 'contextmenu',
6408
topCopy: 'copy',
6409
topCut: 'cut',
6410
topDoubleClick: 'dblclick',
6411
topDrag: 'drag',
6412
topDragEnd: 'dragend',
6413
topDragEnter: 'dragenter',
6414
topDragExit: 'dragexit',
6415
topDragLeave: 'dragleave',
6416
topDragOver: 'dragover',
6417
topDragStart: 'dragstart',
6418
topDrop: 'drop',
6419
topFocus: 'focus',
6420
topInput: 'input',
6421
topKeyDown: 'keydown',
6422
topKeyPress: 'keypress',
6423
topKeyUp: 'keyup',
6424
topMouseDown: 'mousedown',
6425
topMouseMove: 'mousemove',
6426
topMouseOut: 'mouseout',
6427
topMouseOver: 'mouseover',
6428
topMouseUp: 'mouseup',
6429
topPaste: 'paste',
6430
topScroll: 'scroll',
6431
topSelectionChange: 'selectionchange',
6432
topTextInput: 'textInput',
6433
topTouchCancel: 'touchcancel',
6434
topTouchEnd: 'touchend',
6435
topTouchMove: 'touchmove',
6436
topTouchStart: 'touchstart',
6437
topWheel: 'wheel'
6438
};
6439
6440
/**
6441
* To ensure no conflicts with other potential React instances on the page
6442
*/
6443
var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2);
6444
6445
function getListeningForDocument(mountAt) {
6446
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
6447
// directly.
6448
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
6449
mountAt[topListenersIDKey] = reactTopListenersCounter++;
6450
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
6451
}
6452
return alreadyListeningTo[mountAt[topListenersIDKey]];
6453
}
6454
6455
/**
6456
* `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
6457
* example:
6458
*
6459
* ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
6460
*
6461
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
6462
*
6463
* @internal
6464
*/
6465
var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
6466
6467
/**
6468
* Injectable event backend
6469
*/
6470
ReactEventListener: null,
6471
6472
injection: {
6473
/**
6474
* @param {object} ReactEventListener
6475
*/
6476
injectReactEventListener: function(ReactEventListener) {
6477
ReactEventListener.setHandleTopLevel(
6478
ReactBrowserEventEmitter.handleTopLevel
6479
);
6480
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
6481
}
6482
},
6483
6484
/**
6485
* Sets whether or not any created callbacks should be enabled.
6486
*
6487
* @param {boolean} enabled True if callbacks should be enabled.
6488
*/
6489
setEnabled: function(enabled) {
6490
if (ReactBrowserEventEmitter.ReactEventListener) {
6491
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
6492
}
6493
},
6494
6495
/**
6496
* @return {boolean} True if callbacks are enabled.
6497
*/
6498
isEnabled: function() {
6499
return !!(
6500
(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled())
6501
);
6502
},
6503
6504
/**
6505
* We listen for bubbled touch events on the document object.
6506
*
6507
* Firefox v8.01 (and possibly others) exhibited strange behavior when
6508
* mounting `onmousemove` events at some node that was not the document
6509
* element. The symptoms were that if your mouse is not moving over something
6510
* contained within that mount point (for example on the background) the
6511
* top-level listeners for `onmousemove` won't be called. However, if you
6512
* register the `mousemove` on the document object, then it will of course
6513
* catch all `mousemove`s. This along with iOS quirks, justifies restricting
6514
* top-level listeners to the document object only, at least for these
6515
* movement types of events and possibly all events.
6516
*
6517
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
6518
*
6519
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
6520
* they bubble to document.
6521
*
6522
* @param {string} registrationName Name of listener (e.g. `onClick`).
6523
* @param {object} contentDocumentHandle Document which owns the container
6524
*/
6525
listenTo: function(registrationName, contentDocumentHandle) {
6526
var mountAt = contentDocumentHandle;
6527
var isListening = getListeningForDocument(mountAt);
6528
var dependencies = EventPluginRegistry.
6529
registrationNameDependencies[registrationName];
6530
6531
var topLevelTypes = EventConstants.topLevelTypes;
6532
for (var i = 0, l = dependencies.length; i < l; i++) {
6533
var dependency = dependencies[i];
6534
if (!(
6535
(isListening.hasOwnProperty(dependency) && isListening[dependency])
6536
)) {
6537
if (dependency === topLevelTypes.topWheel) {
6538
if (isEventSupported('wheel')) {
6539
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6540
topLevelTypes.topWheel,
6541
'wheel',
6542
mountAt
6543
);
6544
} else if (isEventSupported('mousewheel')) {
6545
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6546
topLevelTypes.topWheel,
6547
'mousewheel',
6548
mountAt
6549
);
6550
} else {
6551
// Firefox needs to capture a different mouse scroll event.
6552
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
6553
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6554
topLevelTypes.topWheel,
6555
'DOMMouseScroll',
6556
mountAt
6557
);
6558
}
6559
} else if (dependency === topLevelTypes.topScroll) {
6560
6561
if (isEventSupported('scroll', true)) {
6562
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
6563
topLevelTypes.topScroll,
6564
'scroll',
6565
mountAt
6566
);
6567
} else {
6568
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6569
topLevelTypes.topScroll,
6570
'scroll',
6571
ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
6572
);
6573
}
6574
} else if (dependency === topLevelTypes.topFocus ||
6575
dependency === topLevelTypes.topBlur) {
6576
6577
if (isEventSupported('focus', true)) {
6578
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
6579
topLevelTypes.topFocus,
6580
'focus',
6581
mountAt
6582
);
6583
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
6584
topLevelTypes.topBlur,
6585
'blur',
6586
mountAt
6587
);
6588
} else if (isEventSupported('focusin')) {
6589
// IE has `focusin` and `focusout` events which bubble.
6590
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
6591
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6592
topLevelTypes.topFocus,
6593
'focusin',
6594
mountAt
6595
);
6596
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6597
topLevelTypes.topBlur,
6598
'focusout',
6599
mountAt
6600
);
6601
}
6602
6603
// to make sure blur and focus event listeners are only attached once
6604
isListening[topLevelTypes.topBlur] = true;
6605
isListening[topLevelTypes.topFocus] = true;
6606
} else if (topEventMapping.hasOwnProperty(dependency)) {
6607
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6608
dependency,
6609
topEventMapping[dependency],
6610
mountAt
6611
);
6612
}
6613
6614
isListening[dependency] = true;
6615
}
6616
}
6617
},
6618
6619
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
6620
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
6621
topLevelType,
6622
handlerBaseName,
6623
handle
6624
);
6625
},
6626
6627
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
6628
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
6629
topLevelType,
6630
handlerBaseName,
6631
handle
6632
);
6633
},
6634
6635
/**
6636
* Listens to window scroll and resize events. We cache scroll values so that
6637
* application code can access them without triggering reflows.
6638
*
6639
* NOTE: Scroll events do not bubble.
6640
*
6641
* @see http://www.quirksmode.org/dom/events/scroll.html
6642
*/
6643
ensureScrollValueMonitoring: function() {
6644
if (!isMonitoringScrollValue) {
6645
var refresh = ViewportMetrics.refreshScrollValues;
6646
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
6647
isMonitoringScrollValue = true;
6648
}
6649
},
6650
6651
eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
6652
6653
registrationNameModules: EventPluginHub.registrationNameModules,
6654
6655
putListener: EventPluginHub.putListener,
6656
6657
getListener: EventPluginHub.getListener,
6658
6659
deleteListener: EventPluginHub.deleteListener,
6660
6661
deleteAllListeners: EventPluginHub.deleteAllListeners
6662
6663
});
6664
6665
module.exports = ReactBrowserEventEmitter;
6666
6667
},{"./EventConstants":29,"./EventPluginHub":31,"./EventPluginRegistry":32,"./Object.assign":42,"./ReactEventEmitterMixin":80,"./ViewportMetrics":131,"./isEventSupported":165}],47:[function(require,module,exports){
6668
/**
6669
* Copyright 2013-2015, Facebook, Inc.
6670
* All rights reserved.
6671
*
6672
* This source code is licensed under the BSD-style license found in the
6673
* LICENSE file in the root directory of this source tree. An additional grant
6674
* of patent rights can be found in the PATENTS file in the same directory.
6675
*
6676
* @typechecks
6677
* @providesModule ReactCSSTransitionGroup
6678
*/
6679
6680
'use strict';
6681
6682
var React = require("./React");
6683
6684
var assign = require("./Object.assign");
6685
6686
var ReactTransitionGroup = React.createFactory(
6687
require("./ReactTransitionGroup")
6688
);
6689
var ReactCSSTransitionGroupChild = React.createFactory(
6690
require("./ReactCSSTransitionGroupChild")
6691
);
6692
6693
var ReactCSSTransitionGroup = React.createClass({
6694
displayName: 'ReactCSSTransitionGroup',
6695
6696
propTypes: {
6697
transitionName: React.PropTypes.string.isRequired,
6698
transitionAppear: React.PropTypes.bool,
6699
transitionEnter: React.PropTypes.bool,
6700
transitionLeave: React.PropTypes.bool
6701
},
6702
6703
getDefaultProps: function() {
6704
return {
6705
transitionAppear: false,
6706
transitionEnter: true,
6707
transitionLeave: true
6708
};
6709
},
6710
6711
_wrapChild: function(child) {
6712
// We need to provide this childFactory so that
6713
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
6714
// leave while it is leaving.
6715
return ReactCSSTransitionGroupChild(
6716
{
6717
name: this.props.transitionName,
6718
appear: this.props.transitionAppear,
6719
enter: this.props.transitionEnter,
6720
leave: this.props.transitionLeave
6721
},
6722
child
6723
);
6724
},
6725
6726
render: function() {
6727
return (
6728
ReactTransitionGroup(
6729
assign({}, this.props, {childFactory: this._wrapChild})
6730
)
6731
);
6732
}
6733
});
6734
6735
module.exports = ReactCSSTransitionGroup;
6736
6737
},{"./Object.assign":42,"./React":44,"./ReactCSSTransitionGroupChild":48,"./ReactTransitionGroup":111}],48:[function(require,module,exports){
6738
(function (process){
6739
/**
6740
* Copyright 2013-2015, Facebook, Inc.
6741
* All rights reserved.
6742
*
6743
* This source code is licensed under the BSD-style license found in the
6744
* LICENSE file in the root directory of this source tree. An additional grant
6745
* of patent rights can be found in the PATENTS file in the same directory.
6746
*
6747
* @typechecks
6748
* @providesModule ReactCSSTransitionGroupChild
6749
*/
6750
6751
'use strict';
6752
6753
var React = require("./React");
6754
6755
var CSSCore = require("./CSSCore");
6756
var ReactTransitionEvents = require("./ReactTransitionEvents");
6757
6758
var onlyChild = require("./onlyChild");
6759
var warning = require("./warning");
6760
6761
// We don't remove the element from the DOM until we receive an animationend or
6762
// transitionend event. If the user screws up and forgets to add an animation
6763
// their node will be stuck in the DOM forever, so we detect if an animation
6764
// does not start and if it doesn't, we just call the end listener immediately.
6765
var TICK = 17;
6766
var NO_EVENT_TIMEOUT = 5000;
6767
6768
var noEventListener = null;
6769
6770
6771
if ("production" !== process.env.NODE_ENV) {
6772
noEventListener = function() {
6773
("production" !== process.env.NODE_ENV ? warning(
6774
false,
6775
'transition(): tried to perform an animation without ' +
6776
'an animationend or transitionend event after timeout (' +
6777
'%sms). You should either disable this ' +
6778
'transition in JS or add a CSS animation/transition.',
6779
NO_EVENT_TIMEOUT
6780
) : null);
6781
};
6782
}
6783
6784
var ReactCSSTransitionGroupChild = React.createClass({
6785
displayName: 'ReactCSSTransitionGroupChild',
6786
6787
transition: function(animationType, finishCallback) {
6788
var node = this.getDOMNode();
6789
var className = this.props.name + '-' + animationType;
6790
var activeClassName = className + '-active';
6791
var noEventTimeout = null;
6792
6793
var endListener = function(e) {
6794
if (e && e.target !== node) {
6795
return;
6796
}
6797
if ("production" !== process.env.NODE_ENV) {
6798
clearTimeout(noEventTimeout);
6799
}
6800
6801
CSSCore.removeClass(node, className);
6802
CSSCore.removeClass(node, activeClassName);
6803
6804
ReactTransitionEvents.removeEndEventListener(node, endListener);
6805
6806
// Usually this optional callback is used for informing an owner of
6807
// a leave animation and telling it to remove the child.
6808
if (finishCallback) {
6809
finishCallback();
6810
}
6811
};
6812
6813
ReactTransitionEvents.addEndEventListener(node, endListener);
6814
6815
CSSCore.addClass(node, className);
6816
6817
// Need to do this to actually trigger a transition.
6818
this.queueClass(activeClassName);
6819
6820
if ("production" !== process.env.NODE_ENV) {
6821
noEventTimeout = setTimeout(noEventListener, NO_EVENT_TIMEOUT);
6822
}
6823
},
6824
6825
queueClass: function(className) {
6826
this.classNameQueue.push(className);
6827
6828
if (!this.timeout) {
6829
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
6830
}
6831
},
6832
6833
flushClassNameQueue: function() {
6834
if (this.isMounted()) {
6835
this.classNameQueue.forEach(
6836
CSSCore.addClass.bind(CSSCore, this.getDOMNode())
6837
);
6838
}
6839
this.classNameQueue.length = 0;
6840
this.timeout = null;
6841
},
6842
6843
componentWillMount: function() {
6844
this.classNameQueue = [];
6845
},
6846
6847
componentWillUnmount: function() {
6848
if (this.timeout) {
6849
clearTimeout(this.timeout);
6850
}
6851
},
6852
6853
componentWillAppear: function(done) {
6854
if (this.props.appear) {
6855
this.transition('appear', done);
6856
} else {
6857
done();
6858
}
6859
},
6860
6861
componentWillEnter: function(done) {
6862
if (this.props.enter) {
6863
this.transition('enter', done);
6864
} else {
6865
done();
6866
}
6867
},
6868
6869
componentWillLeave: function(done) {
6870
if (this.props.leave) {
6871
this.transition('leave', done);
6872
} else {
6873
done();
6874
}
6875
},
6876
6877
render: function() {
6878
return onlyChild(this.props.children);
6879
}
6880
});
6881
6882
module.exports = ReactCSSTransitionGroupChild;
6883
6884
}).call(this,require('_process'))
6885
},{"./CSSCore":17,"./React":44,"./ReactTransitionEvents":110,"./onlyChild":174,"./warning":185,"_process":1}],49:[function(require,module,exports){
6886
/**
6887
* Copyright 2014-2015, Facebook, Inc.
6888
* All rights reserved.
6889
*
6890
* This source code is licensed under the BSD-style license found in the
6891
* LICENSE file in the root directory of this source tree. An additional grant
6892
* of patent rights can be found in the PATENTS file in the same directory.
6893
*
6894
* @providesModule ReactChildReconciler
6895
* @typechecks static-only
6896
*/
6897
6898
'use strict';
6899
6900
var ReactReconciler = require("./ReactReconciler");
6901
6902
var flattenChildren = require("./flattenChildren");
6903
var instantiateReactComponent = require("./instantiateReactComponent");
6904
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
6905
6906
/**
6907
* ReactChildReconciler provides helpers for initializing or updating a set of
6908
* children. Its output is suitable for passing it onto ReactMultiChild which
6909
* does diffed reordering and insertion.
6910
*/
6911
var ReactChildReconciler = {
6912
6913
/**
6914
* Generates a "mount image" for each of the supplied children. In the case
6915
* of `ReactDOMComponent`, a mount image is a string of markup.
6916
*
6917
* @param {?object} nestedChildNodes Nested child maps.
6918
* @return {?object} A set of child instances.
6919
* @internal
6920
*/
6921
instantiateChildren: function(nestedChildNodes, transaction, context) {
6922
var children = flattenChildren(nestedChildNodes);
6923
for (var name in children) {
6924
if (children.hasOwnProperty(name)) {
6925
var child = children[name];
6926
// The rendered children must be turned into instances as they're
6927
// mounted.
6928
var childInstance = instantiateReactComponent(child, null);
6929
children[name] = childInstance;
6930
}
6931
}
6932
return children;
6933
},
6934
6935
/**
6936
* Updates the rendered children and returns a new set of children.
6937
*
6938
* @param {?object} prevChildren Previously initialized set of children.
6939
* @param {?object} nextNestedChildNodes Nested child maps.
6940
* @param {ReactReconcileTransaction} transaction
6941
* @param {object} context
6942
* @return {?object} A new set of child instances.
6943
* @internal
6944
*/
6945
updateChildren: function(
6946
prevChildren,
6947
nextNestedChildNodes,
6948
transaction,
6949
context) {
6950
// We currently don't have a way to track moves here but if we use iterators
6951
// instead of for..in we can zip the iterators and check if an item has
6952
// moved.
6953
// TODO: If nothing has changed, return the prevChildren object so that we
6954
// can quickly bailout if nothing has changed.
6955
var nextChildren = flattenChildren(nextNestedChildNodes);
6956
if (!nextChildren && !prevChildren) {
6957
return null;
6958
}
6959
var name;
6960
for (name in nextChildren) {
6961
if (!nextChildren.hasOwnProperty(name)) {
6962
continue;
6963
}
6964
var prevChild = prevChildren && prevChildren[name];
6965
var prevElement = prevChild && prevChild._currentElement;
6966
var nextElement = nextChildren[name];
6967
if (shouldUpdateReactComponent(prevElement, nextElement)) {
6968
ReactReconciler.receiveComponent(
6969
prevChild, nextElement, transaction, context
6970
);
6971
nextChildren[name] = prevChild;
6972
} else {
6973
if (prevChild) {
6974
ReactReconciler.unmountComponent(prevChild, name);
6975
}
6976
// The child must be instantiated before it's mounted.
6977
var nextChildInstance = instantiateReactComponent(
6978
nextElement,
6979
null
6980
);
6981
nextChildren[name] = nextChildInstance;
6982
}
6983
}
6984
// Unmount children that are no longer present.
6985
for (name in prevChildren) {
6986
if (prevChildren.hasOwnProperty(name) &&
6987
!(nextChildren && nextChildren.hasOwnProperty(name))) {
6988
ReactReconciler.unmountComponent(prevChildren[name]);
6989
}
6990
}
6991
return nextChildren;
6992
},
6993
6994
/**
6995
* Unmounts all rendered children. This should be used to clean up children
6996
* when this component is unmounted.
6997
*
6998
* @param {?object} renderedChildren Previously initialized set of children.
6999
* @internal
7000
*/
7001
unmountChildren: function(renderedChildren) {
7002
for (var name in renderedChildren) {
7003
var renderedChild = renderedChildren[name];
7004
ReactReconciler.unmountComponent(renderedChild);
7005
}
7006
}
7007
7008
};
7009
7010
module.exports = ReactChildReconciler;
7011
7012
},{"./ReactReconciler":102,"./flattenChildren":147,"./instantiateReactComponent":163,"./shouldUpdateReactComponent":181}],50:[function(require,module,exports){
7013
(function (process){
7014
/**
7015
* Copyright 2013-2015, Facebook, Inc.
7016
* All rights reserved.
7017
*
7018
* This source code is licensed under the BSD-style license found in the
7019
* LICENSE file in the root directory of this source tree. An additional grant
7020
* of patent rights can be found in the PATENTS file in the same directory.
7021
*
7022
* @providesModule ReactChildren
7023
*/
7024
7025
'use strict';
7026
7027
var PooledClass = require("./PooledClass");
7028
var ReactFragment = require("./ReactFragment");
7029
7030
var traverseAllChildren = require("./traverseAllChildren");
7031
var warning = require("./warning");
7032
7033
var twoArgumentPooler = PooledClass.twoArgumentPooler;
7034
var threeArgumentPooler = PooledClass.threeArgumentPooler;
7035
7036
/**
7037
* PooledClass representing the bookkeeping associated with performing a child
7038
* traversal. Allows avoiding binding callbacks.
7039
*
7040
* @constructor ForEachBookKeeping
7041
* @param {!function} forEachFunction Function to perform traversal with.
7042
* @param {?*} forEachContext Context to perform context with.
7043
*/
7044
function ForEachBookKeeping(forEachFunction, forEachContext) {
7045
this.forEachFunction = forEachFunction;
7046
this.forEachContext = forEachContext;
7047
}
7048
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
7049
7050
function forEachSingleChild(traverseContext, child, name, i) {
7051
var forEachBookKeeping = traverseContext;
7052
forEachBookKeeping.forEachFunction.call(
7053
forEachBookKeeping.forEachContext, child, i);
7054
}
7055
7056
/**
7057
* Iterates through children that are typically specified as `props.children`.
7058
*
7059
* The provided forEachFunc(child, index) will be called for each
7060
* leaf child.
7061
*
7062
* @param {?*} children Children tree container.
7063
* @param {function(*, int)} forEachFunc.
7064
* @param {*} forEachContext Context for forEachContext.
7065
*/
7066
function forEachChildren(children, forEachFunc, forEachContext) {
7067
if (children == null) {
7068
return children;
7069
}
7070
7071
var traverseContext =
7072
ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
7073
traverseAllChildren(children, forEachSingleChild, traverseContext);
7074
ForEachBookKeeping.release(traverseContext);
7075
}
7076
7077
/**
7078
* PooledClass representing the bookkeeping associated with performing a child
7079
* mapping. Allows avoiding binding callbacks.
7080
*
7081
* @constructor MapBookKeeping
7082
* @param {!*} mapResult Object containing the ordered map of results.
7083
* @param {!function} mapFunction Function to perform mapping with.
7084
* @param {?*} mapContext Context to perform mapping with.
7085
*/
7086
function MapBookKeeping(mapResult, mapFunction, mapContext) {
7087
this.mapResult = mapResult;
7088
this.mapFunction = mapFunction;
7089
this.mapContext = mapContext;
7090
}
7091
PooledClass.addPoolingTo(MapBookKeeping, threeArgumentPooler);
7092
7093
function mapSingleChildIntoContext(traverseContext, child, name, i) {
7094
var mapBookKeeping = traverseContext;
7095
var mapResult = mapBookKeeping.mapResult;
7096
7097
var keyUnique = !mapResult.hasOwnProperty(name);
7098
if ("production" !== process.env.NODE_ENV) {
7099
("production" !== process.env.NODE_ENV ? warning(
7100
keyUnique,
7101
'ReactChildren.map(...): Encountered two children with the same key, ' +
7102
'`%s`. Child keys must be unique; when two children share a key, only ' +
7103
'the first child will be used.',
7104
name
7105
) : null);
7106
}
7107
7108
if (keyUnique) {
7109
var mappedChild =
7110
mapBookKeeping.mapFunction.call(mapBookKeeping.mapContext, child, i);
7111
mapResult[name] = mappedChild;
7112
}
7113
}
7114
7115
/**
7116
* Maps children that are typically specified as `props.children`.
7117
*
7118
* The provided mapFunction(child, key, index) will be called for each
7119
* leaf child.
7120
*
7121
* TODO: This may likely break any calls to `ReactChildren.map` that were
7122
* previously relying on the fact that we guarded against null children.
7123
*
7124
* @param {?*} children Children tree container.
7125
* @param {function(*, int)} mapFunction.
7126
* @param {*} mapContext Context for mapFunction.
7127
* @return {object} Object containing the ordered map of results.
7128
*/
7129
function mapChildren(children, func, context) {
7130
if (children == null) {
7131
return children;
7132
}
7133
7134
var mapResult = {};
7135
var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
7136
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
7137
MapBookKeeping.release(traverseContext);
7138
return ReactFragment.create(mapResult);
7139
}
7140
7141
function forEachSingleChildDummy(traverseContext, child, name, i) {
7142
return null;
7143
}
7144
7145
/**
7146
* Count the number of children that are typically specified as
7147
* `props.children`.
7148
*
7149
* @param {?*} children Children tree container.
7150
* @return {number} The number of children.
7151
*/
7152
function countChildren(children, context) {
7153
return traverseAllChildren(children, forEachSingleChildDummy, null);
7154
}
7155
7156
var ReactChildren = {
7157
forEach: forEachChildren,
7158
map: mapChildren,
7159
count: countChildren
7160
};
7161
7162
module.exports = ReactChildren;
7163
7164
}).call(this,require('_process'))
7165
},{"./PooledClass":43,"./ReactFragment":82,"./traverseAllChildren":183,"./warning":185,"_process":1}],51:[function(require,module,exports){
7166
(function (process){
7167
/**
7168
* Copyright 2013-2015, Facebook, Inc.
7169
* All rights reserved.
7170
*
7171
* This source code is licensed under the BSD-style license found in the
7172
* LICENSE file in the root directory of this source tree. An additional grant
7173
* of patent rights can be found in the PATENTS file in the same directory.
7174
*
7175
* @providesModule ReactClass
7176
*/
7177
7178
'use strict';
7179
7180
var ReactComponent = require("./ReactComponent");
7181
var ReactCurrentOwner = require("./ReactCurrentOwner");
7182
var ReactElement = require("./ReactElement");
7183
var ReactErrorUtils = require("./ReactErrorUtils");
7184
var ReactInstanceMap = require("./ReactInstanceMap");
7185
var ReactLifeCycle = require("./ReactLifeCycle");
7186
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
7187
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
7188
var ReactUpdateQueue = require("./ReactUpdateQueue");
7189
7190
var assign = require("./Object.assign");
7191
var invariant = require("./invariant");
7192
var keyMirror = require("./keyMirror");
7193
var keyOf = require("./keyOf");
7194
var warning = require("./warning");
7195
7196
var MIXINS_KEY = keyOf({mixins: null});
7197
7198
/**
7199
* Policies that describe methods in `ReactClassInterface`.
7200
*/
7201
var SpecPolicy = keyMirror({
7202
/**
7203
* These methods may be defined only once by the class specification or mixin.
7204
*/
7205
DEFINE_ONCE: null,
7206
/**
7207
* These methods may be defined by both the class specification and mixins.
7208
* Subsequent definitions will be chained. These methods must return void.
7209
*/
7210
DEFINE_MANY: null,
7211
/**
7212
* These methods are overriding the base class.
7213
*/
7214
OVERRIDE_BASE: null,
7215
/**
7216
* These methods are similar to DEFINE_MANY, except we assume they return
7217
* objects. We try to merge the keys of the return values of all the mixed in
7218
* functions. If there is a key conflict we throw.
7219
*/
7220
DEFINE_MANY_MERGED: null
7221
});
7222
7223
7224
var injectedMixins = [];
7225
7226
/**
7227
* Composite components are higher-level components that compose other composite
7228
* or native components.
7229
*
7230
* To create a new type of `ReactClass`, pass a specification of
7231
* your new class to `React.createClass`. The only requirement of your class
7232
* specification is that you implement a `render` method.
7233
*
7234
* var MyComponent = React.createClass({
7235
* render: function() {
7236
* return <div>Hello World</div>;
7237
* }
7238
* });
7239
*
7240
* The class specification supports a specific protocol of methods that have
7241
* special meaning (e.g. `render`). See `ReactClassInterface` for
7242
* more the comprehensive protocol. Any other properties and methods in the
7243
* class specification will available on the prototype.
7244
*
7245
* @interface ReactClassInterface
7246
* @internal
7247
*/
7248
var ReactClassInterface = {
7249
7250
/**
7251
* An array of Mixin objects to include when defining your component.
7252
*
7253
* @type {array}
7254
* @optional
7255
*/
7256
mixins: SpecPolicy.DEFINE_MANY,
7257
7258
/**
7259
* An object containing properties and methods that should be defined on
7260
* the component's constructor instead of its prototype (static methods).
7261
*
7262
* @type {object}
7263
* @optional
7264
*/
7265
statics: SpecPolicy.DEFINE_MANY,
7266
7267
/**
7268
* Definition of prop types for this component.
7269
*
7270
* @type {object}
7271
* @optional
7272
*/
7273
propTypes: SpecPolicy.DEFINE_MANY,
7274
7275
/**
7276
* Definition of context types for this component.
7277
*
7278
* @type {object}
7279
* @optional
7280
*/
7281
contextTypes: SpecPolicy.DEFINE_MANY,
7282
7283
/**
7284
* Definition of context types this component sets for its children.
7285
*
7286
* @type {object}
7287
* @optional
7288
*/
7289
childContextTypes: SpecPolicy.DEFINE_MANY,
7290
7291
// ==== Definition methods ====
7292
7293
/**
7294
* Invoked when the component is mounted. Values in the mapping will be set on
7295
* `this.props` if that prop is not specified (i.e. using an `in` check).
7296
*
7297
* This method is invoked before `getInitialState` and therefore cannot rely
7298
* on `this.state` or use `this.setState`.
7299
*
7300
* @return {object}
7301
* @optional
7302
*/
7303
getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
7304
7305
/**
7306
* Invoked once before the component is mounted. The return value will be used
7307
* as the initial value of `this.state`.
7308
*
7309
* getInitialState: function() {
7310
* return {
7311
* isOn: false,
7312
* fooBaz: new BazFoo()
7313
* }
7314
* }
7315
*
7316
* @return {object}
7317
* @optional
7318
*/
7319
getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
7320
7321
/**
7322
* @return {object}
7323
* @optional
7324
*/
7325
getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
7326
7327
/**
7328
* Uses props from `this.props` and state from `this.state` to render the
7329
* structure of the component.
7330
*
7331
* No guarantees are made about when or how often this method is invoked, so
7332
* it must not have side effects.
7333
*
7334
* render: function() {
7335
* var name = this.props.name;
7336
* return <div>Hello, {name}!</div>;
7337
* }
7338
*
7339
* @return {ReactComponent}
7340
* @nosideeffects
7341
* @required
7342
*/
7343
render: SpecPolicy.DEFINE_ONCE,
7344
7345
7346
7347
// ==== Delegate methods ====
7348
7349
/**
7350
* Invoked when the component is initially created and about to be mounted.
7351
* This may have side effects, but any external subscriptions or data created
7352
* by this method must be cleaned up in `componentWillUnmount`.
7353
*
7354
* @optional
7355
*/
7356
componentWillMount: SpecPolicy.DEFINE_MANY,
7357
7358
/**
7359
* Invoked when the component has been mounted and has a DOM representation.
7360
* However, there is no guarantee that the DOM node is in the document.
7361
*
7362
* Use this as an opportunity to operate on the DOM when the component has
7363
* been mounted (initialized and rendered) for the first time.
7364
*
7365
* @param {DOMElement} rootNode DOM element representing the component.
7366
* @optional
7367
*/
7368
componentDidMount: SpecPolicy.DEFINE_MANY,
7369
7370
/**
7371
* Invoked before the component receives new props.
7372
*
7373
* Use this as an opportunity to react to a prop transition by updating the
7374
* state using `this.setState`. Current props are accessed via `this.props`.
7375
*
7376
* componentWillReceiveProps: function(nextProps, nextContext) {
7377
* this.setState({
7378
* likesIncreasing: nextProps.likeCount > this.props.likeCount
7379
* });
7380
* }
7381
*
7382
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
7383
* transition may cause a state change, but the opposite is not true. If you
7384
* need it, you are probably looking for `componentWillUpdate`.
7385
*
7386
* @param {object} nextProps
7387
* @optional
7388
*/
7389
componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
7390
7391
/**
7392
* Invoked while deciding if the component should be updated as a result of
7393
* receiving new props, state and/or context.
7394
*
7395
* Use this as an opportunity to `return false` when you're certain that the
7396
* transition to the new props/state/context will not require a component
7397
* update.
7398
*
7399
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
7400
* return !equal(nextProps, this.props) ||
7401
* !equal(nextState, this.state) ||
7402
* !equal(nextContext, this.context);
7403
* }
7404
*
7405
* @param {object} nextProps
7406
* @param {?object} nextState
7407
* @param {?object} nextContext
7408
* @return {boolean} True if the component should update.
7409
* @optional
7410
*/
7411
shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
7412
7413
/**
7414
* Invoked when the component is about to update due to a transition from
7415
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
7416
* and `nextContext`.
7417
*
7418
* Use this as an opportunity to perform preparation before an update occurs.
7419
*
7420
* NOTE: You **cannot** use `this.setState()` in this method.
7421
*
7422
* @param {object} nextProps
7423
* @param {?object} nextState
7424
* @param {?object} nextContext
7425
* @param {ReactReconcileTransaction} transaction
7426
* @optional
7427
*/
7428
componentWillUpdate: SpecPolicy.DEFINE_MANY,
7429
7430
/**
7431
* Invoked when the component's DOM representation has been updated.
7432
*
7433
* Use this as an opportunity to operate on the DOM when the component has
7434
* been updated.
7435
*
7436
* @param {object} prevProps
7437
* @param {?object} prevState
7438
* @param {?object} prevContext
7439
* @param {DOMElement} rootNode DOM element representing the component.
7440
* @optional
7441
*/
7442
componentDidUpdate: SpecPolicy.DEFINE_MANY,
7443
7444
/**
7445
* Invoked when the component is about to be removed from its parent and have
7446
* its DOM representation destroyed.
7447
*
7448
* Use this as an opportunity to deallocate any external resources.
7449
*
7450
* NOTE: There is no `componentDidUnmount` since your component will have been
7451
* destroyed by that point.
7452
*
7453
* @optional
7454
*/
7455
componentWillUnmount: SpecPolicy.DEFINE_MANY,
7456
7457
7458
7459
// ==== Advanced methods ====
7460
7461
/**
7462
* Updates the component's currently mounted DOM representation.
7463
*
7464
* By default, this implements React's rendering and reconciliation algorithm.
7465
* Sophisticated clients may wish to override this.
7466
*
7467
* @param {ReactReconcileTransaction} transaction
7468
* @internal
7469
* @overridable
7470
*/
7471
updateComponent: SpecPolicy.OVERRIDE_BASE
7472
7473
};
7474
7475
/**
7476
* Mapping from class specification keys to special processing functions.
7477
*
7478
* Although these are declared like instance properties in the specification
7479
* when defining classes using `React.createClass`, they are actually static
7480
* and are accessible on the constructor instead of the prototype. Despite
7481
* being static, they must be defined outside of the "statics" key under
7482
* which all other static methods are defined.
7483
*/
7484
var RESERVED_SPEC_KEYS = {
7485
displayName: function(Constructor, displayName) {
7486
Constructor.displayName = displayName;
7487
},
7488
mixins: function(Constructor, mixins) {
7489
if (mixins) {
7490
for (var i = 0; i < mixins.length; i++) {
7491
mixSpecIntoComponent(Constructor, mixins[i]);
7492
}
7493
}
7494
},
7495
childContextTypes: function(Constructor, childContextTypes) {
7496
if ("production" !== process.env.NODE_ENV) {
7497
validateTypeDef(
7498
Constructor,
7499
childContextTypes,
7500
ReactPropTypeLocations.childContext
7501
);
7502
}
7503
Constructor.childContextTypes = assign(
7504
{},
7505
Constructor.childContextTypes,
7506
childContextTypes
7507
);
7508
},
7509
contextTypes: function(Constructor, contextTypes) {
7510
if ("production" !== process.env.NODE_ENV) {
7511
validateTypeDef(
7512
Constructor,
7513
contextTypes,
7514
ReactPropTypeLocations.context
7515
);
7516
}
7517
Constructor.contextTypes = assign(
7518
{},
7519
Constructor.contextTypes,
7520
contextTypes
7521
);
7522
},
7523
/**
7524
* Special case getDefaultProps which should move into statics but requires
7525
* automatic merging.
7526
*/
7527
getDefaultProps: function(Constructor, getDefaultProps) {
7528
if (Constructor.getDefaultProps) {
7529
Constructor.getDefaultProps = createMergedResultFunction(
7530
Constructor.getDefaultProps,
7531
getDefaultProps
7532
);
7533
} else {
7534
Constructor.getDefaultProps = getDefaultProps;
7535
}
7536
},
7537
propTypes: function(Constructor, propTypes) {
7538
if ("production" !== process.env.NODE_ENV) {
7539
validateTypeDef(
7540
Constructor,
7541
propTypes,
7542
ReactPropTypeLocations.prop
7543
);
7544
}
7545
Constructor.propTypes = assign(
7546
{},
7547
Constructor.propTypes,
7548
propTypes
7549
);
7550
},
7551
statics: function(Constructor, statics) {
7552
mixStaticSpecIntoComponent(Constructor, statics);
7553
}
7554
};
7555
7556
function validateTypeDef(Constructor, typeDef, location) {
7557
for (var propName in typeDef) {
7558
if (typeDef.hasOwnProperty(propName)) {
7559
// use a warning instead of an invariant so components
7560
// don't show up in prod but not in __DEV__
7561
("production" !== process.env.NODE_ENV ? warning(
7562
typeof typeDef[propName] === 'function',
7563
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
7564
'React.PropTypes.',
7565
Constructor.displayName || 'ReactClass',
7566
ReactPropTypeLocationNames[location],
7567
propName
7568
) : null);
7569
}
7570
}
7571
}
7572
7573
function validateMethodOverride(proto, name) {
7574
var specPolicy = ReactClassInterface.hasOwnProperty(name) ?
7575
ReactClassInterface[name] :
7576
null;
7577
7578
// Disallow overriding of base class methods unless explicitly allowed.
7579
if (ReactClassMixin.hasOwnProperty(name)) {
7580
("production" !== process.env.NODE_ENV ? invariant(
7581
specPolicy === SpecPolicy.OVERRIDE_BASE,
7582
'ReactClassInterface: You are attempting to override ' +
7583
'`%s` from your class specification. Ensure that your method names ' +
7584
'do not overlap with React methods.',
7585
name
7586
) : invariant(specPolicy === SpecPolicy.OVERRIDE_BASE));
7587
}
7588
7589
// Disallow defining methods more than once unless explicitly allowed.
7590
if (proto.hasOwnProperty(name)) {
7591
("production" !== process.env.NODE_ENV ? invariant(
7592
specPolicy === SpecPolicy.DEFINE_MANY ||
7593
specPolicy === SpecPolicy.DEFINE_MANY_MERGED,
7594
'ReactClassInterface: You are attempting to define ' +
7595
'`%s` on your component more than once. This conflict may be due ' +
7596
'to a mixin.',
7597
name
7598
) : invariant(specPolicy === SpecPolicy.DEFINE_MANY ||
7599
specPolicy === SpecPolicy.DEFINE_MANY_MERGED));
7600
}
7601
}
7602
7603
/**
7604
* Mixin helper which handles policy validation and reserved
7605
* specification keys when building React classses.
7606
*/
7607
function mixSpecIntoComponent(Constructor, spec) {
7608
if (!spec) {
7609
return;
7610
}
7611
7612
("production" !== process.env.NODE_ENV ? invariant(
7613
typeof spec !== 'function',
7614
'ReactClass: You\'re attempting to ' +
7615
'use a component class as a mixin. Instead, just use a regular object.'
7616
) : invariant(typeof spec !== 'function'));
7617
("production" !== process.env.NODE_ENV ? invariant(
7618
!ReactElement.isValidElement(spec),
7619
'ReactClass: You\'re attempting to ' +
7620
'use a component as a mixin. Instead, just use a regular object.'
7621
) : invariant(!ReactElement.isValidElement(spec)));
7622
7623
var proto = Constructor.prototype;
7624
7625
// By handling mixins before any other properties, we ensure the same
7626
// chaining order is applied to methods with DEFINE_MANY policy, whether
7627
// mixins are listed before or after these methods in the spec.
7628
if (spec.hasOwnProperty(MIXINS_KEY)) {
7629
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
7630
}
7631
7632
for (var name in spec) {
7633
if (!spec.hasOwnProperty(name)) {
7634
continue;
7635
}
7636
7637
if (name === MIXINS_KEY) {
7638
// We have already handled mixins in a special case above
7639
continue;
7640
}
7641
7642
var property = spec[name];
7643
validateMethodOverride(proto, name);
7644
7645
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
7646
RESERVED_SPEC_KEYS[name](Constructor, property);
7647
} else {
7648
// Setup methods on prototype:
7649
// The following member methods should not be automatically bound:
7650
// 1. Expected ReactClass methods (in the "interface").
7651
// 2. Overridden methods (that were mixed in).
7652
var isReactClassMethod =
7653
ReactClassInterface.hasOwnProperty(name);
7654
var isAlreadyDefined = proto.hasOwnProperty(name);
7655
var markedDontBind = property && property.__reactDontBind;
7656
var isFunction = typeof property === 'function';
7657
var shouldAutoBind =
7658
isFunction &&
7659
!isReactClassMethod &&
7660
!isAlreadyDefined &&
7661
!markedDontBind;
7662
7663
if (shouldAutoBind) {
7664
if (!proto.__reactAutoBindMap) {
7665
proto.__reactAutoBindMap = {};
7666
}
7667
proto.__reactAutoBindMap[name] = property;
7668
proto[name] = property;
7669
} else {
7670
if (isAlreadyDefined) {
7671
var specPolicy = ReactClassInterface[name];
7672
7673
// These cases should already be caught by validateMethodOverride
7674
("production" !== process.env.NODE_ENV ? invariant(
7675
isReactClassMethod && (
7676
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
7677
),
7678
'ReactClass: Unexpected spec policy %s for key %s ' +
7679
'when mixing in component specs.',
7680
specPolicy,
7681
name
7682
) : invariant(isReactClassMethod && (
7683
(specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)
7684
)));
7685
7686
// For methods which are defined more than once, call the existing
7687
// methods before calling the new property, merging if appropriate.
7688
if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
7689
proto[name] = createMergedResultFunction(proto[name], property);
7690
} else if (specPolicy === SpecPolicy.DEFINE_MANY) {
7691
proto[name] = createChainedFunction(proto[name], property);
7692
}
7693
} else {
7694
proto[name] = property;
7695
if ("production" !== process.env.NODE_ENV) {
7696
// Add verbose displayName to the function, which helps when looking
7697
// at profiling tools.
7698
if (typeof property === 'function' && spec.displayName) {
7699
proto[name].displayName = spec.displayName + '_' + name;
7700
}
7701
}
7702
}
7703
}
7704
}
7705
}
7706
}
7707
7708
function mixStaticSpecIntoComponent(Constructor, statics) {
7709
if (!statics) {
7710
return;
7711
}
7712
for (var name in statics) {
7713
var property = statics[name];
7714
if (!statics.hasOwnProperty(name)) {
7715
continue;
7716
}
7717
7718
var isReserved = name in RESERVED_SPEC_KEYS;
7719
("production" !== process.env.NODE_ENV ? invariant(
7720
!isReserved,
7721
'ReactClass: You are attempting to define a reserved ' +
7722
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
7723
'as an instance property instead; it will still be accessible on the ' +
7724
'constructor.',
7725
name
7726
) : invariant(!isReserved));
7727
7728
var isInherited = name in Constructor;
7729
("production" !== process.env.NODE_ENV ? invariant(
7730
!isInherited,
7731
'ReactClass: You are attempting to define ' +
7732
'`%s` on your component more than once. This conflict may be ' +
7733
'due to a mixin.',
7734
name
7735
) : invariant(!isInherited));
7736
Constructor[name] = property;
7737
}
7738
}
7739
7740
/**
7741
* Merge two objects, but throw if both contain the same key.
7742
*
7743
* @param {object} one The first object, which is mutated.
7744
* @param {object} two The second object
7745
* @return {object} one after it has been mutated to contain everything in two.
7746
*/
7747
function mergeIntoWithNoDuplicateKeys(one, two) {
7748
("production" !== process.env.NODE_ENV ? invariant(
7749
one && two && typeof one === 'object' && typeof two === 'object',
7750
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'
7751
) : invariant(one && two && typeof one === 'object' && typeof two === 'object'));
7752
7753
for (var key in two) {
7754
if (two.hasOwnProperty(key)) {
7755
("production" !== process.env.NODE_ENV ? invariant(
7756
one[key] === undefined,
7757
'mergeIntoWithNoDuplicateKeys(): ' +
7758
'Tried to merge two objects with the same key: `%s`. This conflict ' +
7759
'may be due to a mixin; in particular, this may be caused by two ' +
7760
'getInitialState() or getDefaultProps() methods returning objects ' +
7761
'with clashing keys.',
7762
key
7763
) : invariant(one[key] === undefined));
7764
one[key] = two[key];
7765
}
7766
}
7767
return one;
7768
}
7769
7770
/**
7771
* Creates a function that invokes two functions and merges their return values.
7772
*
7773
* @param {function} one Function to invoke first.
7774
* @param {function} two Function to invoke second.
7775
* @return {function} Function that invokes the two argument functions.
7776
* @private
7777
*/
7778
function createMergedResultFunction(one, two) {
7779
return function mergedResult() {
7780
var a = one.apply(this, arguments);
7781
var b = two.apply(this, arguments);
7782
if (a == null) {
7783
return b;
7784
} else if (b == null) {
7785
return a;
7786
}
7787
var c = {};
7788
mergeIntoWithNoDuplicateKeys(c, a);
7789
mergeIntoWithNoDuplicateKeys(c, b);
7790
return c;
7791
};
7792
}
7793
7794
/**
7795
* Creates a function that invokes two functions and ignores their return vales.
7796
*
7797
* @param {function} one Function to invoke first.
7798
* @param {function} two Function to invoke second.
7799
* @return {function} Function that invokes the two argument functions.
7800
* @private
7801
*/
7802
function createChainedFunction(one, two) {
7803
return function chainedFunction() {
7804
one.apply(this, arguments);
7805
two.apply(this, arguments);
7806
};
7807
}
7808
7809
/**
7810
* Binds a method to the component.
7811
*
7812
* @param {object} component Component whose method is going to be bound.
7813
* @param {function} method Method to be bound.
7814
* @return {function} The bound method.
7815
*/
7816
function bindAutoBindMethod(component, method) {
7817
var boundMethod = method.bind(component);
7818
if ("production" !== process.env.NODE_ENV) {
7819
boundMethod.__reactBoundContext = component;
7820
boundMethod.__reactBoundMethod = method;
7821
boundMethod.__reactBoundArguments = null;
7822
var componentName = component.constructor.displayName;
7823
var _bind = boundMethod.bind;
7824
/* eslint-disable block-scoped-var, no-undef */
7825
boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
7826
// User is trying to bind() an autobound method; we effectively will
7827
// ignore the value of "this" that the user is trying to use, so
7828
// let's warn.
7829
if (newThis !== component && newThis !== null) {
7830
("production" !== process.env.NODE_ENV ? warning(
7831
false,
7832
'bind(): React component methods may only be bound to the ' +
7833
'component instance. See %s',
7834
componentName
7835
) : null);
7836
} else if (!args.length) {
7837
("production" !== process.env.NODE_ENV ? warning(
7838
false,
7839
'bind(): You are binding a component method to the component. ' +
7840
'React does this for you automatically in a high-performance ' +
7841
'way, so you can safely remove this call. See %s',
7842
componentName
7843
) : null);
7844
return boundMethod;
7845
}
7846
var reboundMethod = _bind.apply(boundMethod, arguments);
7847
reboundMethod.__reactBoundContext = component;
7848
reboundMethod.__reactBoundMethod = method;
7849
reboundMethod.__reactBoundArguments = args;
7850
return reboundMethod;
7851
/* eslint-enable */
7852
};
7853
}
7854
return boundMethod;
7855
}
7856
7857
/**
7858
* Binds all auto-bound methods in a component.
7859
*
7860
* @param {object} component Component whose method is going to be bound.
7861
*/
7862
function bindAutoBindMethods(component) {
7863
for (var autoBindKey in component.__reactAutoBindMap) {
7864
if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
7865
var method = component.__reactAutoBindMap[autoBindKey];
7866
component[autoBindKey] = bindAutoBindMethod(
7867
component,
7868
ReactErrorUtils.guard(
7869
method,
7870
component.constructor.displayName + '.' + autoBindKey
7871
)
7872
);
7873
}
7874
}
7875
}
7876
7877
var typeDeprecationDescriptor = {
7878
enumerable: false,
7879
get: function() {
7880
var displayName = this.displayName || this.name || 'Component';
7881
("production" !== process.env.NODE_ENV ? warning(
7882
false,
7883
'%s.type is deprecated. Use %s directly to access the class.',
7884
displayName,
7885
displayName
7886
) : null);
7887
Object.defineProperty(this, 'type', {
7888
value: this
7889
});
7890
return this;
7891
}
7892
};
7893
7894
/**
7895
* Add more to the ReactClass base class. These are all legacy features and
7896
* therefore not already part of the modern ReactComponent.
7897
*/
7898
var ReactClassMixin = {
7899
7900
/**
7901
* TODO: This will be deprecated because state should always keep a consistent
7902
* type signature and the only use case for this, is to avoid that.
7903
*/
7904
replaceState: function(newState, callback) {
7905
ReactUpdateQueue.enqueueReplaceState(this, newState);
7906
if (callback) {
7907
ReactUpdateQueue.enqueueCallback(this, callback);
7908
}
7909
},
7910
7911
/**
7912
* Checks whether or not this composite component is mounted.
7913
* @return {boolean} True if mounted, false otherwise.
7914
* @protected
7915
* @final
7916
*/
7917
isMounted: function() {
7918
if ("production" !== process.env.NODE_ENV) {
7919
var owner = ReactCurrentOwner.current;
7920
if (owner !== null) {
7921
("production" !== process.env.NODE_ENV ? warning(
7922
owner._warnedAboutRefsInRender,
7923
'%s is accessing isMounted inside its render() function. ' +
7924
'render() should be a pure function of props and state. It should ' +
7925
'never access something that requires stale data from the previous ' +
7926
'render, such as refs. Move this logic to componentDidMount and ' +
7927
'componentDidUpdate instead.',
7928
owner.getName() || 'A component'
7929
) : null);
7930
owner._warnedAboutRefsInRender = true;
7931
}
7932
}
7933
var internalInstance = ReactInstanceMap.get(this);
7934
return (
7935
internalInstance &&
7936
internalInstance !== ReactLifeCycle.currentlyMountingInstance
7937
);
7938
},
7939
7940
/**
7941
* Sets a subset of the props.
7942
*
7943
* @param {object} partialProps Subset of the next props.
7944
* @param {?function} callback Called after props are updated.
7945
* @final
7946
* @public
7947
* @deprecated
7948
*/
7949
setProps: function(partialProps, callback) {
7950
ReactUpdateQueue.enqueueSetProps(this, partialProps);
7951
if (callback) {
7952
ReactUpdateQueue.enqueueCallback(this, callback);
7953
}
7954
},
7955
7956
/**
7957
* Replace all the props.
7958
*
7959
* @param {object} newProps Subset of the next props.
7960
* @param {?function} callback Called after props are updated.
7961
* @final
7962
* @public
7963
* @deprecated
7964
*/
7965
replaceProps: function(newProps, callback) {
7966
ReactUpdateQueue.enqueueReplaceProps(this, newProps);
7967
if (callback) {
7968
ReactUpdateQueue.enqueueCallback(this, callback);
7969
}
7970
}
7971
};
7972
7973
var ReactClassComponent = function() {};
7974
assign(
7975
ReactClassComponent.prototype,
7976
ReactComponent.prototype,
7977
ReactClassMixin
7978
);
7979
7980
/**
7981
* Module for creating composite components.
7982
*
7983
* @class ReactClass
7984
*/
7985
var ReactClass = {
7986
7987
/**
7988
* Creates a composite component class given a class specification.
7989
*
7990
* @param {object} spec Class specification (which must define `render`).
7991
* @return {function} Component constructor function.
7992
* @public
7993
*/
7994
createClass: function(spec) {
7995
var Constructor = function(props, context) {
7996
// This constructor is overridden by mocks. The argument is used
7997
// by mocks to assert on what gets mounted.
7998
7999
if ("production" !== process.env.NODE_ENV) {
8000
("production" !== process.env.NODE_ENV ? warning(
8001
this instanceof Constructor,
8002
'Something is calling a React component directly. Use a factory or ' +
8003
'JSX instead. See: https://fb.me/react-legacyfactory'
8004
) : null);
8005
}
8006
8007
// Wire up auto-binding
8008
if (this.__reactAutoBindMap) {
8009
bindAutoBindMethods(this);
8010
}
8011
8012
this.props = props;
8013
this.context = context;
8014
this.state = null;
8015
8016
// ReactClasses doesn't have constructors. Instead, they use the
8017
// getInitialState and componentWillMount methods for initialization.
8018
8019
var initialState = this.getInitialState ? this.getInitialState() : null;
8020
if ("production" !== process.env.NODE_ENV) {
8021
// We allow auto-mocks to proceed as if they're returning null.
8022
if (typeof initialState === 'undefined' &&
8023
this.getInitialState._isMockFunction) {
8024
// This is probably bad practice. Consider warning here and
8025
// deprecating this convenience.
8026
initialState = null;
8027
}
8028
}
8029
("production" !== process.env.NODE_ENV ? invariant(
8030
typeof initialState === 'object' && !Array.isArray(initialState),
8031
'%s.getInitialState(): must return an object or null',
8032
Constructor.displayName || 'ReactCompositeComponent'
8033
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
8034
8035
this.state = initialState;
8036
};
8037
Constructor.prototype = new ReactClassComponent();
8038
Constructor.prototype.constructor = Constructor;
8039
8040
injectedMixins.forEach(
8041
mixSpecIntoComponent.bind(null, Constructor)
8042
);
8043
8044
mixSpecIntoComponent(Constructor, spec);
8045
8046
// Initialize the defaultProps property after all mixins have been merged
8047
if (Constructor.getDefaultProps) {
8048
Constructor.defaultProps = Constructor.getDefaultProps();
8049
}
8050
8051
if ("production" !== process.env.NODE_ENV) {
8052
// This is a tag to indicate that the use of these method names is ok,
8053
// since it's used with createClass. If it's not, then it's likely a
8054
// mistake so we'll warn you to use the static property, property
8055
// initializer or constructor respectively.
8056
if (Constructor.getDefaultProps) {
8057
Constructor.getDefaultProps.isReactClassApproved = {};
8058
}
8059
if (Constructor.prototype.getInitialState) {
8060
Constructor.prototype.getInitialState.isReactClassApproved = {};
8061
}
8062
}
8063
8064
("production" !== process.env.NODE_ENV ? invariant(
8065
Constructor.prototype.render,
8066
'createClass(...): Class specification must implement a `render` method.'
8067
) : invariant(Constructor.prototype.render));
8068
8069
if ("production" !== process.env.NODE_ENV) {
8070
("production" !== process.env.NODE_ENV ? warning(
8071
!Constructor.prototype.componentShouldUpdate,
8072
'%s has a method called ' +
8073
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
8074
'The name is phrased as a question because the function is ' +
8075
'expected to return a value.',
8076
spec.displayName || 'A component'
8077
) : null);
8078
}
8079
8080
// Reduce time spent doing lookups by setting these on the prototype.
8081
for (var methodName in ReactClassInterface) {
8082
if (!Constructor.prototype[methodName]) {
8083
Constructor.prototype[methodName] = null;
8084
}
8085
}
8086
8087
// Legacy hook
8088
Constructor.type = Constructor;
8089
if ("production" !== process.env.NODE_ENV) {
8090
try {
8091
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
8092
} catch (x) {
8093
// IE will fail on defineProperty (es5-shim/sham too)
8094
}
8095
}
8096
8097
return Constructor;
8098
},
8099
8100
injection: {
8101
injectMixin: function(mixin) {
8102
injectedMixins.push(mixin);
8103
}
8104
}
8105
8106
};
8107
8108
module.exports = ReactClass;
8109
8110
}).call(this,require('_process'))
8111
},{"./Object.assign":42,"./ReactComponent":52,"./ReactCurrentOwner":58,"./ReactElement":76,"./ReactErrorUtils":79,"./ReactInstanceMap":86,"./ReactLifeCycle":87,"./ReactPropTypeLocationNames":97,"./ReactPropTypeLocations":98,"./ReactUpdateQueue":112,"./invariant":164,"./keyMirror":170,"./keyOf":171,"./warning":185,"_process":1}],52:[function(require,module,exports){
8112
(function (process){
8113
/**
8114
* Copyright 2013-2015, Facebook, Inc.
8115
* All rights reserved.
8116
*
8117
* This source code is licensed under the BSD-style license found in the
8118
* LICENSE file in the root directory of this source tree. An additional grant
8119
* of patent rights can be found in the PATENTS file in the same directory.
8120
*
8121
* @providesModule ReactComponent
8122
*/
8123
8124
'use strict';
8125
8126
var ReactUpdateQueue = require("./ReactUpdateQueue");
8127
8128
var invariant = require("./invariant");
8129
var warning = require("./warning");
8130
8131
/**
8132
* Base class helpers for the updating state of a component.
8133
*/
8134
function ReactComponent(props, context) {
8135
this.props = props;
8136
this.context = context;
8137
}
8138
8139
/**
8140
* Sets a subset of the state. Always use this to mutate
8141
* state. You should treat `this.state` as immutable.
8142
*
8143
* There is no guarantee that `this.state` will be immediately updated, so
8144
* accessing `this.state` after calling this method may return the old value.
8145
*
8146
* There is no guarantee that calls to `setState` will run synchronously,
8147
* as they may eventually be batched together. You can provide an optional
8148
* callback that will be executed when the call to setState is actually
8149
* completed.
8150
*
8151
* When a function is provided to setState, it will be called at some point in
8152
* the future (not synchronously). It will be called with the up to date
8153
* component arguments (state, props, context). These values can be different
8154
* from this.* because your function may be called after receiveProps but before
8155
* shouldComponentUpdate, and this new state, props, and context will not yet be
8156
* assigned to this.
8157
*
8158
* @param {object|function} partialState Next partial state or function to
8159
* produce next partial state to be merged with current state.
8160
* @param {?function} callback Called after state is updated.
8161
* @final
8162
* @protected
8163
*/
8164
ReactComponent.prototype.setState = function(partialState, callback) {
8165
("production" !== process.env.NODE_ENV ? invariant(
8166
typeof partialState === 'object' ||
8167
typeof partialState === 'function' ||
8168
partialState == null,
8169
'setState(...): takes an object of state variables to update or a ' +
8170
'function which returns an object of state variables.'
8171
) : invariant(typeof partialState === 'object' ||
8172
typeof partialState === 'function' ||
8173
partialState == null));
8174
if ("production" !== process.env.NODE_ENV) {
8175
("production" !== process.env.NODE_ENV ? warning(
8176
partialState != null,
8177
'setState(...): You passed an undefined or null state object; ' +
8178
'instead, use forceUpdate().'
8179
) : null);
8180
}
8181
ReactUpdateQueue.enqueueSetState(this, partialState);
8182
if (callback) {
8183
ReactUpdateQueue.enqueueCallback(this, callback);
8184
}
8185
};
8186
8187
/**
8188
* Forces an update. This should only be invoked when it is known with
8189
* certainty that we are **not** in a DOM transaction.
8190
*
8191
* You may want to call this when you know that some deeper aspect of the
8192
* component's state has changed but `setState` was not called.
8193
*
8194
* This will not invoke `shouldComponentUpdate`, but it will invoke
8195
* `componentWillUpdate` and `componentDidUpdate`.
8196
*
8197
* @param {?function} callback Called after update is complete.
8198
* @final
8199
* @protected
8200
*/
8201
ReactComponent.prototype.forceUpdate = function(callback) {
8202
ReactUpdateQueue.enqueueForceUpdate(this);
8203
if (callback) {
8204
ReactUpdateQueue.enqueueCallback(this, callback);
8205
}
8206
};
8207
8208
/**
8209
* Deprecated APIs. These APIs used to exist on classic React classes but since
8210
* we would like to deprecate them, we're not going to move them over to this
8211
* modern base class. Instead, we define a getter that warns if it's accessed.
8212
*/
8213
if ("production" !== process.env.NODE_ENV) {
8214
var deprecatedAPIs = {
8215
getDOMNode: [
8216
'getDOMNode',
8217
'Use React.findDOMNode(component) instead.'
8218
],
8219
isMounted: [
8220
'isMounted',
8221
'Instead, make sure to clean up subscriptions and pending requests in ' +
8222
'componentWillUnmount to prevent memory leaks.'
8223
],
8224
replaceProps: [
8225
'replaceProps',
8226
'Instead, call React.render again at the top level.'
8227
],
8228
replaceState: [
8229
'replaceState',
8230
'Refactor your code to use setState instead (see ' +
8231
'https://github.com/facebook/react/issues/3236).'
8232
],
8233
setProps: [
8234
'setProps',
8235
'Instead, call React.render again at the top level.'
8236
]
8237
};
8238
var defineDeprecationWarning = function(methodName, info) {
8239
try {
8240
Object.defineProperty(ReactComponent.prototype, methodName, {
8241
get: function() {
8242
("production" !== process.env.NODE_ENV ? warning(
8243
false,
8244
'%s(...) is deprecated in plain JavaScript React classes. %s',
8245
info[0],
8246
info[1]
8247
) : null);
8248
return undefined;
8249
}
8250
});
8251
} catch (x) {
8252
// IE will fail on defineProperty (es5-shim/sham too)
8253
}
8254
};
8255
for (var fnName in deprecatedAPIs) {
8256
if (deprecatedAPIs.hasOwnProperty(fnName)) {
8257
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
8258
}
8259
}
8260
}
8261
8262
module.exports = ReactComponent;
8263
8264
}).call(this,require('_process'))
8265
},{"./ReactUpdateQueue":112,"./invariant":164,"./warning":185,"_process":1}],53:[function(require,module,exports){
8266
/**
8267
* Copyright 2013-2015, Facebook, Inc.
8268
* All rights reserved.
8269
*
8270
* This source code is licensed under the BSD-style license found in the
8271
* LICENSE file in the root directory of this source tree. An additional grant
8272
* of patent rights can be found in the PATENTS file in the same directory.
8273
*
8274
* @providesModule ReactComponentBrowserEnvironment
8275
*/
8276
8277
/*jslint evil: true */
8278
8279
'use strict';
8280
8281
var ReactDOMIDOperations = require("./ReactDOMIDOperations");
8282
var ReactMount = require("./ReactMount");
8283
8284
/**
8285
* Abstracts away all functionality of the reconciler that requires knowledge of
8286
* the browser context. TODO: These callers should be refactored to avoid the
8287
* need for this injection.
8288
*/
8289
var ReactComponentBrowserEnvironment = {
8290
8291
processChildrenUpdates:
8292
ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
8293
8294
replaceNodeWithMarkupByID:
8295
ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
8296
8297
/**
8298
* If a particular environment requires that some resources be cleaned up,
8299
* specify this in the injected Mixin. In the DOM, we would likely want to
8300
* purge any cached node ID lookups.
8301
*
8302
* @private
8303
*/
8304
unmountIDFromEnvironment: function(rootNodeID) {
8305
ReactMount.purgeID(rootNodeID);
8306
}
8307
8308
};
8309
8310
module.exports = ReactComponentBrowserEnvironment;
8311
8312
},{"./ReactDOMIDOperations":63,"./ReactMount":90}],54:[function(require,module,exports){
8313
(function (process){
8314
/**
8315
* Copyright 2014-2015, Facebook, Inc.
8316
* All rights reserved.
8317
*
8318
* This source code is licensed under the BSD-style license found in the
8319
* LICENSE file in the root directory of this source tree. An additional grant
8320
* of patent rights can be found in the PATENTS file in the same directory.
8321
*
8322
* @providesModule ReactComponentEnvironment
8323
*/
8324
8325
'use strict';
8326
8327
var invariant = require("./invariant");
8328
8329
var injected = false;
8330
8331
var ReactComponentEnvironment = {
8332
8333
/**
8334
* Optionally injectable environment dependent cleanup hook. (server vs.
8335
* browser etc). Example: A browser system caches DOM nodes based on component
8336
* ID and must remove that cache entry when this instance is unmounted.
8337
*/
8338
unmountIDFromEnvironment: null,
8339
8340
/**
8341
* Optionally injectable hook for swapping out mount images in the middle of
8342
* the tree.
8343
*/
8344
replaceNodeWithMarkupByID: null,
8345
8346
/**
8347
* Optionally injectable hook for processing a queue of child updates. Will
8348
* later move into MultiChildComponents.
8349
*/
8350
processChildrenUpdates: null,
8351
8352
injection: {
8353
injectEnvironment: function(environment) {
8354
("production" !== process.env.NODE_ENV ? invariant(
8355
!injected,
8356
'ReactCompositeComponent: injectEnvironment() can only be called once.'
8357
) : invariant(!injected));
8358
ReactComponentEnvironment.unmountIDFromEnvironment =
8359
environment.unmountIDFromEnvironment;
8360
ReactComponentEnvironment.replaceNodeWithMarkupByID =
8361
environment.replaceNodeWithMarkupByID;
8362
ReactComponentEnvironment.processChildrenUpdates =
8363
environment.processChildrenUpdates;
8364
injected = true;
8365
}
8366
}
8367
8368
};
8369
8370
module.exports = ReactComponentEnvironment;
8371
8372
}).call(this,require('_process'))
8373
},{"./invariant":164,"_process":1}],55:[function(require,module,exports){
8374
/**
8375
* Copyright 2013-2015, Facebook, Inc.
8376
* All rights reserved.
8377
*
8378
* This source code is licensed under the BSD-style license found in the
8379
* LICENSE file in the root directory of this source tree. An additional grant
8380
* of patent rights can be found in the PATENTS file in the same directory.
8381
*
8382
* @providesModule ReactComponentWithPureRenderMixin
8383
*/
8384
8385
'use strict';
8386
8387
var shallowEqual = require("./shallowEqual");
8388
8389
/**
8390
* If your React component's render function is "pure", e.g. it will render the
8391
* same result given the same props and state, provide this Mixin for a
8392
* considerable performance boost.
8393
*
8394
* Most React components have pure render functions.
8395
*
8396
* Example:
8397
*
8398
* var ReactComponentWithPureRenderMixin =
8399
* require('ReactComponentWithPureRenderMixin');
8400
* React.createClass({
8401
* mixins: [ReactComponentWithPureRenderMixin],
8402
*
8403
* render: function() {
8404
* return <div className={this.props.className}>foo</div>;
8405
* }
8406
* });
8407
*
8408
* Note: This only checks shallow equality for props and state. If these contain
8409
* complex data structures this mixin may have false-negatives for deeper
8410
* differences. Only mixin to components which have simple props and state, or
8411
* use `forceUpdate()` when you know deep data structures have changed.
8412
*/
8413
var ReactComponentWithPureRenderMixin = {
8414
shouldComponentUpdate: function(nextProps, nextState) {
8415
return !shallowEqual(this.props, nextProps) ||
8416
!shallowEqual(this.state, nextState);
8417
}
8418
};
8419
8420
module.exports = ReactComponentWithPureRenderMixin;
8421
8422
},{"./shallowEqual":180}],56:[function(require,module,exports){
8423
(function (process){
8424
/**
8425
* Copyright 2013-2015, Facebook, Inc.
8426
* All rights reserved.
8427
*
8428
* This source code is licensed under the BSD-style license found in the
8429
* LICENSE file in the root directory of this source tree. An additional grant
8430
* of patent rights can be found in the PATENTS file in the same directory.
8431
*
8432
* @providesModule ReactCompositeComponent
8433
*/
8434
8435
'use strict';
8436
8437
var ReactComponentEnvironment = require("./ReactComponentEnvironment");
8438
var ReactContext = require("./ReactContext");
8439
var ReactCurrentOwner = require("./ReactCurrentOwner");
8440
var ReactElement = require("./ReactElement");
8441
var ReactElementValidator = require("./ReactElementValidator");
8442
var ReactInstanceMap = require("./ReactInstanceMap");
8443
var ReactLifeCycle = require("./ReactLifeCycle");
8444
var ReactNativeComponent = require("./ReactNativeComponent");
8445
var ReactPerf = require("./ReactPerf");
8446
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
8447
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
8448
var ReactReconciler = require("./ReactReconciler");
8449
var ReactUpdates = require("./ReactUpdates");
8450
8451
var assign = require("./Object.assign");
8452
var emptyObject = require("./emptyObject");
8453
var invariant = require("./invariant");
8454
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
8455
var warning = require("./warning");
8456
8457
function getDeclarationErrorAddendum(component) {
8458
var owner = component._currentElement._owner || null;
8459
if (owner) {
8460
var name = owner.getName();
8461
if (name) {
8462
return ' Check the render method of `' + name + '`.';
8463
}
8464
}
8465
return '';
8466
}
8467
8468
/**
8469
* ------------------ The Life-Cycle of a Composite Component ------------------
8470
*
8471
* - constructor: Initialization of state. The instance is now retained.
8472
* - componentWillMount
8473
* - render
8474
* - [children's constructors]
8475
* - [children's componentWillMount and render]
8476
* - [children's componentDidMount]
8477
* - componentDidMount
8478
*
8479
* Update Phases:
8480
* - componentWillReceiveProps (only called if parent updated)
8481
* - shouldComponentUpdate
8482
* - componentWillUpdate
8483
* - render
8484
* - [children's constructors or receive props phases]
8485
* - componentDidUpdate
8486
*
8487
* - componentWillUnmount
8488
* - [children's componentWillUnmount]
8489
* - [children destroyed]
8490
* - (destroyed): The instance is now blank, released by React and ready for GC.
8491
*
8492
* -----------------------------------------------------------------------------
8493
*/
8494
8495
/**
8496
* An incrementing ID assigned to each component when it is mounted. This is
8497
* used to enforce the order in which `ReactUpdates` updates dirty components.
8498
*
8499
* @private
8500
*/
8501
var nextMountID = 1;
8502
8503
/**
8504
* @lends {ReactCompositeComponent.prototype}
8505
*/
8506
var ReactCompositeComponentMixin = {
8507
8508
/**
8509
* Base constructor for all composite component.
8510
*
8511
* @param {ReactElement} element
8512
* @final
8513
* @internal
8514
*/
8515
construct: function(element) {
8516
this._currentElement = element;
8517
this._rootNodeID = null;
8518
this._instance = null;
8519
8520
// See ReactUpdateQueue
8521
this._pendingElement = null;
8522
this._pendingStateQueue = null;
8523
this._pendingReplaceState = false;
8524
this._pendingForceUpdate = false;
8525
8526
this._renderedComponent = null;
8527
8528
this._context = null;
8529
this._mountOrder = 0;
8530
this._isTopLevel = false;
8531
8532
// See ReactUpdates and ReactUpdateQueue.
8533
this._pendingCallbacks = null;
8534
},
8535
8536
/**
8537
* Initializes the component, renders markup, and registers event listeners.
8538
*
8539
* @param {string} rootID DOM ID of the root node.
8540
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
8541
* @return {?string} Rendered markup to be inserted into the DOM.
8542
* @final
8543
* @internal
8544
*/
8545
mountComponent: function(rootID, transaction, context) {
8546
this._context = context;
8547
this._mountOrder = nextMountID++;
8548
this._rootNodeID = rootID;
8549
8550
var publicProps = this._processProps(this._currentElement.props);
8551
var publicContext = this._processContext(this._currentElement._context);
8552
8553
var Component = ReactNativeComponent.getComponentClassForElement(
8554
this._currentElement
8555
);
8556
8557
// Initialize the public class
8558
var inst = new Component(publicProps, publicContext);
8559
8560
if ("production" !== process.env.NODE_ENV) {
8561
// This will throw later in _renderValidatedComponent, but add an early
8562
// warning now to help debugging
8563
("production" !== process.env.NODE_ENV ? warning(
8564
inst.render != null,
8565
'%s(...): No `render` method found on the returned component ' +
8566
'instance: you may have forgotten to define `render` in your ' +
8567
'component or you may have accidentally tried to render an element ' +
8568
'whose type is a function that isn\'t a React component.',
8569
Component.displayName || Component.name || 'Component'
8570
) : null);
8571
}
8572
8573
// These should be set up in the constructor, but as a convenience for
8574
// simpler class abstractions, we set them up after the fact.
8575
inst.props = publicProps;
8576
inst.context = publicContext;
8577
inst.refs = emptyObject;
8578
8579
this._instance = inst;
8580
8581
// Store a reference from the instance back to the internal representation
8582
ReactInstanceMap.set(inst, this);
8583
8584
if ("production" !== process.env.NODE_ENV) {
8585
this._warnIfContextsDiffer(this._currentElement._context, context);
8586
}
8587
8588
if ("production" !== process.env.NODE_ENV) {
8589
// Since plain JS classes are defined without any special initialization
8590
// logic, we can not catch common errors early. Therefore, we have to
8591
// catch them here, at initialization time, instead.
8592
("production" !== process.env.NODE_ENV ? warning(
8593
!inst.getInitialState ||
8594
inst.getInitialState.isReactClassApproved,
8595
'getInitialState was defined on %s, a plain JavaScript class. ' +
8596
'This is only supported for classes created using React.createClass. ' +
8597
'Did you mean to define a state property instead?',
8598
this.getName() || 'a component'
8599
) : null);
8600
("production" !== process.env.NODE_ENV ? warning(
8601
!inst.getDefaultProps ||
8602
inst.getDefaultProps.isReactClassApproved,
8603
'getDefaultProps was defined on %s, a plain JavaScript class. ' +
8604
'This is only supported for classes created using React.createClass. ' +
8605
'Use a static property to define defaultProps instead.',
8606
this.getName() || 'a component'
8607
) : null);
8608
("production" !== process.env.NODE_ENV ? warning(
8609
!inst.propTypes,
8610
'propTypes was defined as an instance property on %s. Use a static ' +
8611
'property to define propTypes instead.',
8612
this.getName() || 'a component'
8613
) : null);
8614
("production" !== process.env.NODE_ENV ? warning(
8615
!inst.contextTypes,
8616
'contextTypes was defined as an instance property on %s. Use a ' +
8617
'static property to define contextTypes instead.',
8618
this.getName() || 'a component'
8619
) : null);
8620
("production" !== process.env.NODE_ENV ? warning(
8621
typeof inst.componentShouldUpdate !== 'function',
8622
'%s has a method called ' +
8623
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
8624
'The name is phrased as a question because the function is ' +
8625
'expected to return a value.',
8626
(this.getName() || 'A component')
8627
) : null);
8628
}
8629
8630
var initialState = inst.state;
8631
if (initialState === undefined) {
8632
inst.state = initialState = null;
8633
}
8634
("production" !== process.env.NODE_ENV ? invariant(
8635
typeof initialState === 'object' && !Array.isArray(initialState),
8636
'%s.state: must be set to an object or null',
8637
this.getName() || 'ReactCompositeComponent'
8638
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
8639
8640
this._pendingStateQueue = null;
8641
this._pendingReplaceState = false;
8642
this._pendingForceUpdate = false;
8643
8644
var childContext;
8645
var renderedElement;
8646
8647
var previouslyMounting = ReactLifeCycle.currentlyMountingInstance;
8648
ReactLifeCycle.currentlyMountingInstance = this;
8649
try {
8650
if (inst.componentWillMount) {
8651
inst.componentWillMount();
8652
// When mounting, calls to `setState` by `componentWillMount` will set
8653
// `this._pendingStateQueue` without triggering a re-render.
8654
if (this._pendingStateQueue) {
8655
inst.state = this._processPendingState(inst.props, inst.context);
8656
}
8657
}
8658
8659
childContext = this._getValidatedChildContext(context);
8660
renderedElement = this._renderValidatedComponent(childContext);
8661
} finally {
8662
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
8663
}
8664
8665
this._renderedComponent = this._instantiateReactComponent(
8666
renderedElement,
8667
this._currentElement.type // The wrapping type
8668
);
8669
8670
var markup = ReactReconciler.mountComponent(
8671
this._renderedComponent,
8672
rootID,
8673
transaction,
8674
this._mergeChildContext(context, childContext)
8675
);
8676
if (inst.componentDidMount) {
8677
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
8678
}
8679
8680
return markup;
8681
},
8682
8683
/**
8684
* Releases any resources allocated by `mountComponent`.
8685
*
8686
* @final
8687
* @internal
8688
*/
8689
unmountComponent: function() {
8690
var inst = this._instance;
8691
8692
if (inst.componentWillUnmount) {
8693
var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
8694
ReactLifeCycle.currentlyUnmountingInstance = this;
8695
try {
8696
inst.componentWillUnmount();
8697
} finally {
8698
ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
8699
}
8700
}
8701
8702
ReactReconciler.unmountComponent(this._renderedComponent);
8703
this._renderedComponent = null;
8704
8705
// Reset pending fields
8706
this._pendingStateQueue = null;
8707
this._pendingReplaceState = false;
8708
this._pendingForceUpdate = false;
8709
this._pendingCallbacks = null;
8710
this._pendingElement = null;
8711
8712
// These fields do not really need to be reset since this object is no
8713
// longer accessible.
8714
this._context = null;
8715
this._rootNodeID = null;
8716
8717
// Delete the reference from the instance to this internal representation
8718
// which allow the internals to be properly cleaned up even if the user
8719
// leaks a reference to the public instance.
8720
ReactInstanceMap.remove(inst);
8721
8722
// Some existing components rely on inst.props even after they've been
8723
// destroyed (in event handlers).
8724
// TODO: inst.props = null;
8725
// TODO: inst.state = null;
8726
// TODO: inst.context = null;
8727
},
8728
8729
/**
8730
* Schedule a partial update to the props. Only used for internal testing.
8731
*
8732
* @param {object} partialProps Subset of the next props.
8733
* @param {?function} callback Called after props are updated.
8734
* @final
8735
* @internal
8736
*/
8737
_setPropsInternal: function(partialProps, callback) {
8738
// This is a deoptimized path. We optimize for always having an element.
8739
// This creates an extra internal element.
8740
var element = this._pendingElement || this._currentElement;
8741
this._pendingElement = ReactElement.cloneAndReplaceProps(
8742
element,
8743
assign({}, element.props, partialProps)
8744
);
8745
ReactUpdates.enqueueUpdate(this, callback);
8746
},
8747
8748
/**
8749
* Filters the context object to only contain keys specified in
8750
* `contextTypes`
8751
*
8752
* @param {object} context
8753
* @return {?object}
8754
* @private
8755
*/
8756
_maskContext: function(context) {
8757
var maskedContext = null;
8758
// This really should be getting the component class for the element,
8759
// but we know that we're not going to need it for built-ins.
8760
if (typeof this._currentElement.type === 'string') {
8761
return emptyObject;
8762
}
8763
var contextTypes = this._currentElement.type.contextTypes;
8764
if (!contextTypes) {
8765
return emptyObject;
8766
}
8767
maskedContext = {};
8768
for (var contextName in contextTypes) {
8769
maskedContext[contextName] = context[contextName];
8770
}
8771
return maskedContext;
8772
},
8773
8774
/**
8775
* Filters the context object to only contain keys specified in
8776
* `contextTypes`, and asserts that they are valid.
8777
*
8778
* @param {object} context
8779
* @return {?object}
8780
* @private
8781
*/
8782
_processContext: function(context) {
8783
var maskedContext = this._maskContext(context);
8784
if ("production" !== process.env.NODE_ENV) {
8785
var Component = ReactNativeComponent.getComponentClassForElement(
8786
this._currentElement
8787
);
8788
if (Component.contextTypes) {
8789
this._checkPropTypes(
8790
Component.contextTypes,
8791
maskedContext,
8792
ReactPropTypeLocations.context
8793
);
8794
}
8795
}
8796
return maskedContext;
8797
},
8798
8799
/**
8800
* @param {object} currentContext
8801
* @return {object}
8802
* @private
8803
*/
8804
_getValidatedChildContext: function(currentContext) {
8805
var inst = this._instance;
8806
var childContext = inst.getChildContext && inst.getChildContext();
8807
if (childContext) {
8808
("production" !== process.env.NODE_ENV ? invariant(
8809
typeof inst.constructor.childContextTypes === 'object',
8810
'%s.getChildContext(): childContextTypes must be defined in order to ' +
8811
'use getChildContext().',
8812
this.getName() || 'ReactCompositeComponent'
8813
) : invariant(typeof inst.constructor.childContextTypes === 'object'));
8814
if ("production" !== process.env.NODE_ENV) {
8815
this._checkPropTypes(
8816
inst.constructor.childContextTypes,
8817
childContext,
8818
ReactPropTypeLocations.childContext
8819
);
8820
}
8821
for (var name in childContext) {
8822
("production" !== process.env.NODE_ENV ? invariant(
8823
name in inst.constructor.childContextTypes,
8824
'%s.getChildContext(): key "%s" is not defined in childContextTypes.',
8825
this.getName() || 'ReactCompositeComponent',
8826
name
8827
) : invariant(name in inst.constructor.childContextTypes));
8828
}
8829
return childContext;
8830
}
8831
return null;
8832
},
8833
8834
_mergeChildContext: function(currentContext, childContext) {
8835
if (childContext) {
8836
return assign({}, currentContext, childContext);
8837
}
8838
return currentContext;
8839
},
8840
8841
/**
8842
* Processes props by setting default values for unspecified props and
8843
* asserting that the props are valid. Does not mutate its argument; returns
8844
* a new props object with defaults merged in.
8845
*
8846
* @param {object} newProps
8847
* @return {object}
8848
* @private
8849
*/
8850
_processProps: function(newProps) {
8851
if ("production" !== process.env.NODE_ENV) {
8852
var Component = ReactNativeComponent.getComponentClassForElement(
8853
this._currentElement
8854
);
8855
if (Component.propTypes) {
8856
this._checkPropTypes(
8857
Component.propTypes,
8858
newProps,
8859
ReactPropTypeLocations.prop
8860
);
8861
}
8862
}
8863
return newProps;
8864
},
8865
8866
/**
8867
* Assert that the props are valid
8868
*
8869
* @param {object} propTypes Map of prop name to a ReactPropType
8870
* @param {object} props
8871
* @param {string} location e.g. "prop", "context", "child context"
8872
* @private
8873
*/
8874
_checkPropTypes: function(propTypes, props, location) {
8875
// TODO: Stop validating prop types here and only use the element
8876
// validation.
8877
var componentName = this.getName();
8878
for (var propName in propTypes) {
8879
if (propTypes.hasOwnProperty(propName)) {
8880
var error;
8881
try {
8882
// This is intentionally an invariant that gets caught. It's the same
8883
// behavior as without this statement except with a better message.
8884
("production" !== process.env.NODE_ENV ? invariant(
8885
typeof propTypes[propName] === 'function',
8886
'%s: %s type `%s` is invalid; it must be a function, usually ' +
8887
'from React.PropTypes.',
8888
componentName || 'React class',
8889
ReactPropTypeLocationNames[location],
8890
propName
8891
) : invariant(typeof propTypes[propName] === 'function'));
8892
error = propTypes[propName](props, propName, componentName, location);
8893
} catch (ex) {
8894
error = ex;
8895
}
8896
if (error instanceof Error) {
8897
// We may want to extend this logic for similar errors in
8898
// React.render calls, so I'm abstracting it away into
8899
// a function to minimize refactoring in the future
8900
var addendum = getDeclarationErrorAddendum(this);
8901
8902
if (location === ReactPropTypeLocations.prop) {
8903
// Preface gives us something to blacklist in warning module
8904
("production" !== process.env.NODE_ENV ? warning(
8905
false,
8906
'Failed Composite propType: %s%s',
8907
error.message,
8908
addendum
8909
) : null);
8910
} else {
8911
("production" !== process.env.NODE_ENV ? warning(
8912
false,
8913
'Failed Context Types: %s%s',
8914
error.message,
8915
addendum
8916
) : null);
8917
}
8918
}
8919
}
8920
}
8921
},
8922
8923
receiveComponent: function(nextElement, transaction, nextContext) {
8924
var prevElement = this._currentElement;
8925
var prevContext = this._context;
8926
8927
this._pendingElement = null;
8928
8929
this.updateComponent(
8930
transaction,
8931
prevElement,
8932
nextElement,
8933
prevContext,
8934
nextContext
8935
);
8936
},
8937
8938
/**
8939
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
8940
* is set, update the component.
8941
*
8942
* @param {ReactReconcileTransaction} transaction
8943
* @internal
8944
*/
8945
performUpdateIfNecessary: function(transaction) {
8946
if (this._pendingElement != null) {
8947
ReactReconciler.receiveComponent(
8948
this,
8949
this._pendingElement || this._currentElement,
8950
transaction,
8951
this._context
8952
);
8953
}
8954
8955
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
8956
if ("production" !== process.env.NODE_ENV) {
8957
ReactElementValidator.checkAndWarnForMutatedProps(
8958
this._currentElement
8959
);
8960
}
8961
8962
this.updateComponent(
8963
transaction,
8964
this._currentElement,
8965
this._currentElement,
8966
this._context,
8967
this._context
8968
);
8969
}
8970
},
8971
8972
/**
8973
* Compare two contexts, warning if they are different
8974
* TODO: Remove this check when owner-context is removed
8975
*/
8976
_warnIfContextsDiffer: function(ownerBasedContext, parentBasedContext) {
8977
ownerBasedContext = this._maskContext(ownerBasedContext);
8978
parentBasedContext = this._maskContext(parentBasedContext);
8979
var parentKeys = Object.keys(parentBasedContext).sort();
8980
var displayName = this.getName() || 'ReactCompositeComponent';
8981
for (var i = 0; i < parentKeys.length; i++) {
8982
var key = parentKeys[i];
8983
("production" !== process.env.NODE_ENV ? warning(
8984
ownerBasedContext[key] === parentBasedContext[key],
8985
'owner-based and parent-based contexts differ ' +
8986
'(values: `%s` vs `%s`) for key (%s) while mounting %s ' +
8987
'(see: http://fb.me/react-context-by-parent)',
8988
ownerBasedContext[key],
8989
parentBasedContext[key],
8990
key,
8991
displayName
8992
) : null);
8993
}
8994
},
8995
8996
/**
8997
* Perform an update to a mounted component. The componentWillReceiveProps and
8998
* shouldComponentUpdate methods are called, then (assuming the update isn't
8999
* skipped) the remaining update lifecycle methods are called and the DOM
9000
* representation is updated.
9001
*
9002
* By default, this implements React's rendering and reconciliation algorithm.
9003
* Sophisticated clients may wish to override this.
9004
*
9005
* @param {ReactReconcileTransaction} transaction
9006
* @param {ReactElement} prevParentElement
9007
* @param {ReactElement} nextParentElement
9008
* @internal
9009
* @overridable
9010
*/
9011
updateComponent: function(
9012
transaction,
9013
prevParentElement,
9014
nextParentElement,
9015
prevUnmaskedContext,
9016
nextUnmaskedContext
9017
) {
9018
var inst = this._instance;
9019
9020
var nextContext = inst.context;
9021
var nextProps = inst.props;
9022
9023
// Distinguish between a props update versus a simple state update
9024
if (prevParentElement !== nextParentElement) {
9025
nextContext = this._processContext(nextParentElement._context);
9026
nextProps = this._processProps(nextParentElement.props);
9027
9028
if ("production" !== process.env.NODE_ENV) {
9029
if (nextUnmaskedContext != null) {
9030
this._warnIfContextsDiffer(
9031
nextParentElement._context,
9032
nextUnmaskedContext
9033
);
9034
}
9035
}
9036
9037
// An update here will schedule an update but immediately set
9038
// _pendingStateQueue which will ensure that any state updates gets
9039
// immediately reconciled instead of waiting for the next batch.
9040
9041
if (inst.componentWillReceiveProps) {
9042
inst.componentWillReceiveProps(nextProps, nextContext);
9043
}
9044
}
9045
9046
var nextState = this._processPendingState(nextProps, nextContext);
9047
9048
var shouldUpdate =
9049
this._pendingForceUpdate ||
9050
!inst.shouldComponentUpdate ||
9051
inst.shouldComponentUpdate(nextProps, nextState, nextContext);
9052
9053
if ("production" !== process.env.NODE_ENV) {
9054
("production" !== process.env.NODE_ENV ? warning(
9055
typeof shouldUpdate !== 'undefined',
9056
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
9057
'boolean value. Make sure to return true or false.',
9058
this.getName() || 'ReactCompositeComponent'
9059
) : null);
9060
}
9061
9062
if (shouldUpdate) {
9063
this._pendingForceUpdate = false;
9064
// Will set `this.props`, `this.state` and `this.context`.
9065
this._performComponentUpdate(
9066
nextParentElement,
9067
nextProps,
9068
nextState,
9069
nextContext,
9070
transaction,
9071
nextUnmaskedContext
9072
);
9073
} else {
9074
// If it's determined that a component should not update, we still want
9075
// to set props and state but we shortcut the rest of the update.
9076
this._currentElement = nextParentElement;
9077
this._context = nextUnmaskedContext;
9078
inst.props = nextProps;
9079
inst.state = nextState;
9080
inst.context = nextContext;
9081
}
9082
},
9083
9084
_processPendingState: function(props, context) {
9085
var inst = this._instance;
9086
var queue = this._pendingStateQueue;
9087
var replace = this._pendingReplaceState;
9088
this._pendingReplaceState = false;
9089
this._pendingStateQueue = null;
9090
9091
if (!queue) {
9092
return inst.state;
9093
}
9094
9095
if (replace && queue.length === 1) {
9096
return queue[0];
9097
}
9098
9099
var nextState = assign({}, replace ? queue[0] : inst.state);
9100
for (var i = replace ? 1 : 0; i < queue.length; i++) {
9101
var partial = queue[i];
9102
assign(
9103
nextState,
9104
typeof partial === 'function' ?
9105
partial.call(inst, nextState, props, context) :
9106
partial
9107
);
9108
}
9109
9110
return nextState;
9111
},
9112
9113
/**
9114
* Merges new props and state, notifies delegate methods of update and
9115
* performs update.
9116
*
9117
* @param {ReactElement} nextElement Next element
9118
* @param {object} nextProps Next public object to set as properties.
9119
* @param {?object} nextState Next object to set as state.
9120
* @param {?object} nextContext Next public object to set as context.
9121
* @param {ReactReconcileTransaction} transaction
9122
* @param {?object} unmaskedContext
9123
* @private
9124
*/
9125
_performComponentUpdate: function(
9126
nextElement,
9127
nextProps,
9128
nextState,
9129
nextContext,
9130
transaction,
9131
unmaskedContext
9132
) {
9133
var inst = this._instance;
9134
9135
var prevProps = inst.props;
9136
var prevState = inst.state;
9137
var prevContext = inst.context;
9138
9139
if (inst.componentWillUpdate) {
9140
inst.componentWillUpdate(nextProps, nextState, nextContext);
9141
}
9142
9143
this._currentElement = nextElement;
9144
this._context = unmaskedContext;
9145
inst.props = nextProps;
9146
inst.state = nextState;
9147
inst.context = nextContext;
9148
9149
this._updateRenderedComponent(transaction, unmaskedContext);
9150
9151
if (inst.componentDidUpdate) {
9152
transaction.getReactMountReady().enqueue(
9153
inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext),
9154
inst
9155
);
9156
}
9157
},
9158
9159
/**
9160
* Call the component's `render` method and update the DOM accordingly.
9161
*
9162
* @param {ReactReconcileTransaction} transaction
9163
* @internal
9164
*/
9165
_updateRenderedComponent: function(transaction, context) {
9166
var prevComponentInstance = this._renderedComponent;
9167
var prevRenderedElement = prevComponentInstance._currentElement;
9168
var childContext = this._getValidatedChildContext();
9169
var nextRenderedElement = this._renderValidatedComponent(childContext);
9170
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
9171
ReactReconciler.receiveComponent(
9172
prevComponentInstance,
9173
nextRenderedElement,
9174
transaction,
9175
this._mergeChildContext(context, childContext)
9176
);
9177
} else {
9178
// These two IDs are actually the same! But nothing should rely on that.
9179
var thisID = this._rootNodeID;
9180
var prevComponentID = prevComponentInstance._rootNodeID;
9181
ReactReconciler.unmountComponent(prevComponentInstance);
9182
9183
this._renderedComponent = this._instantiateReactComponent(
9184
nextRenderedElement,
9185
this._currentElement.type
9186
);
9187
var nextMarkup = ReactReconciler.mountComponent(
9188
this._renderedComponent,
9189
thisID,
9190
transaction,
9191
this._mergeChildContext(context, childContext)
9192
);
9193
this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
9194
}
9195
},
9196
9197
/**
9198
* @protected
9199
*/
9200
_replaceNodeWithMarkupByID: function(prevComponentID, nextMarkup) {
9201
ReactComponentEnvironment.replaceNodeWithMarkupByID(
9202
prevComponentID,
9203
nextMarkup
9204
);
9205
},
9206
9207
/**
9208
* @protected
9209
*/
9210
_renderValidatedComponentWithoutOwnerOrContext: function() {
9211
var inst = this._instance;
9212
var renderedComponent = inst.render();
9213
if ("production" !== process.env.NODE_ENV) {
9214
// We allow auto-mocks to proceed as if they're returning null.
9215
if (typeof renderedComponent === 'undefined' &&
9216
inst.render._isMockFunction) {
9217
// This is probably bad practice. Consider warning here and
9218
// deprecating this convenience.
9219
renderedComponent = null;
9220
}
9221
}
9222
9223
return renderedComponent;
9224
},
9225
9226
/**
9227
* @private
9228
*/
9229
_renderValidatedComponent: function(childContext) {
9230
var renderedComponent;
9231
var previousContext = ReactContext.current;
9232
ReactContext.current = this._mergeChildContext(
9233
this._currentElement._context,
9234
childContext
9235
);
9236
ReactCurrentOwner.current = this;
9237
try {
9238
renderedComponent =
9239
this._renderValidatedComponentWithoutOwnerOrContext();
9240
} finally {
9241
ReactContext.current = previousContext;
9242
ReactCurrentOwner.current = null;
9243
}
9244
("production" !== process.env.NODE_ENV ? invariant(
9245
// TODO: An `isValidNode` function would probably be more appropriate
9246
renderedComponent === null || renderedComponent === false ||
9247
ReactElement.isValidElement(renderedComponent),
9248
'%s.render(): A valid ReactComponent must be returned. You may have ' +
9249
'returned undefined, an array or some other invalid object.',
9250
this.getName() || 'ReactCompositeComponent'
9251
) : invariant(// TODO: An `isValidNode` function would probably be more appropriate
9252
renderedComponent === null || renderedComponent === false ||
9253
ReactElement.isValidElement(renderedComponent)));
9254
return renderedComponent;
9255
},
9256
9257
/**
9258
* Lazily allocates the refs object and stores `component` as `ref`.
9259
*
9260
* @param {string} ref Reference name.
9261
* @param {component} component Component to store as `ref`.
9262
* @final
9263
* @private
9264
*/
9265
attachRef: function(ref, component) {
9266
var inst = this.getPublicInstance();
9267
var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
9268
refs[ref] = component.getPublicInstance();
9269
},
9270
9271
/**
9272
* Detaches a reference name.
9273
*
9274
* @param {string} ref Name to dereference.
9275
* @final
9276
* @private
9277
*/
9278
detachRef: function(ref) {
9279
var refs = this.getPublicInstance().refs;
9280
delete refs[ref];
9281
},
9282
9283
/**
9284
* Get a text description of the component that can be used to identify it
9285
* in error messages.
9286
* @return {string} The name or null.
9287
* @internal
9288
*/
9289
getName: function() {
9290
var type = this._currentElement.type;
9291
var constructor = this._instance && this._instance.constructor;
9292
return (
9293
type.displayName || (constructor && constructor.displayName) ||
9294
type.name || (constructor && constructor.name) ||
9295
null
9296
);
9297
},
9298
9299
/**
9300
* Get the publicly accessible representation of this component - i.e. what
9301
* is exposed by refs and returned by React.render. Can be null for stateless
9302
* components.
9303
*
9304
* @return {ReactComponent} the public component instance.
9305
* @internal
9306
*/
9307
getPublicInstance: function() {
9308
return this._instance;
9309
},
9310
9311
// Stub
9312
_instantiateReactComponent: null
9313
9314
};
9315
9316
ReactPerf.measureMethods(
9317
ReactCompositeComponentMixin,
9318
'ReactCompositeComponent',
9319
{
9320
mountComponent: 'mountComponent',
9321
updateComponent: 'updateComponent',
9322
_renderValidatedComponent: '_renderValidatedComponent'
9323
}
9324
);
9325
9326
var ReactCompositeComponent = {
9327
9328
Mixin: ReactCompositeComponentMixin
9329
9330
};
9331
9332
module.exports = ReactCompositeComponent;
9333
9334
}).call(this,require('_process'))
9335
},{"./Object.assign":42,"./ReactComponentEnvironment":54,"./ReactContext":57,"./ReactCurrentOwner":58,"./ReactElement":76,"./ReactElementValidator":77,"./ReactInstanceMap":86,"./ReactLifeCycle":87,"./ReactNativeComponent":93,"./ReactPerf":95,"./ReactPropTypeLocationNames":97,"./ReactPropTypeLocations":98,"./ReactReconciler":102,"./ReactUpdates":113,"./emptyObject":144,"./invariant":164,"./shouldUpdateReactComponent":181,"./warning":185,"_process":1}],57:[function(require,module,exports){
9336
(function (process){
9337
/**
9338
* Copyright 2013-2015, Facebook, Inc.
9339
* All rights reserved.
9340
*
9341
* This source code is licensed under the BSD-style license found in the
9342
* LICENSE file in the root directory of this source tree. An additional grant
9343
* of patent rights can be found in the PATENTS file in the same directory.
9344
*
9345
* @providesModule ReactContext
9346
*/
9347
9348
'use strict';
9349
9350
var assign = require("./Object.assign");
9351
var emptyObject = require("./emptyObject");
9352
var warning = require("./warning");
9353
9354
var didWarn = false;
9355
9356
/**
9357
* Keeps track of the current context.
9358
*
9359
* The context is automatically passed down the component ownership hierarchy
9360
* and is accessible via `this.context` on ReactCompositeComponents.
9361
*/
9362
var ReactContext = {
9363
9364
/**
9365
* @internal
9366
* @type {object}
9367
*/
9368
current: emptyObject,
9369
9370
/**
9371
* Temporarily extends the current context while executing scopedCallback.
9372
*
9373
* A typical use case might look like
9374
*
9375
* render: function() {
9376
* var children = ReactContext.withContext({foo: 'foo'}, () => (
9377
*
9378
* ));
9379
* return <div>{children}</div>;
9380
* }
9381
*
9382
* @param {object} newContext New context to merge into the existing context
9383
* @param {function} scopedCallback Callback to run with the new context
9384
* @return {ReactComponent|array<ReactComponent>}
9385
*/
9386
withContext: function(newContext, scopedCallback) {
9387
if ("production" !== process.env.NODE_ENV) {
9388
("production" !== process.env.NODE_ENV ? warning(
9389
didWarn,
9390
'withContext is deprecated and will be removed in a future version. ' +
9391
'Use a wrapper component with getChildContext instead.'
9392
) : null);
9393
9394
didWarn = true;
9395
}
9396
9397
var result;
9398
var previousContext = ReactContext.current;
9399
ReactContext.current = assign({}, previousContext, newContext);
9400
try {
9401
result = scopedCallback();
9402
} finally {
9403
ReactContext.current = previousContext;
9404
}
9405
return result;
9406
}
9407
9408
};
9409
9410
module.exports = ReactContext;
9411
9412
}).call(this,require('_process'))
9413
},{"./Object.assign":42,"./emptyObject":144,"./warning":185,"_process":1}],58:[function(require,module,exports){
9414
/**
9415
* Copyright 2013-2015, Facebook, Inc.
9416
* All rights reserved.
9417
*
9418
* This source code is licensed under the BSD-style license found in the
9419
* LICENSE file in the root directory of this source tree. An additional grant
9420
* of patent rights can be found in the PATENTS file in the same directory.
9421
*
9422
* @providesModule ReactCurrentOwner
9423
*/
9424
9425
'use strict';
9426
9427
/**
9428
* Keeps track of the current owner.
9429
*
9430
* The current owner is the component who should own any components that are
9431
* currently being constructed.
9432
*
9433
* The depth indicate how many composite components are above this render level.
9434
*/
9435
var ReactCurrentOwner = {
9436
9437
/**
9438
* @internal
9439
* @type {ReactComponent}
9440
*/
9441
current: null
9442
9443
};
9444
9445
module.exports = ReactCurrentOwner;
9446
9447
},{}],59:[function(require,module,exports){
9448
(function (process){
9449
/**
9450
* Copyright 2013-2015, Facebook, Inc.
9451
* All rights reserved.
9452
*
9453
* This source code is licensed under the BSD-style license found in the
9454
* LICENSE file in the root directory of this source tree. An additional grant
9455
* of patent rights can be found in the PATENTS file in the same directory.
9456
*
9457
* @providesModule ReactDOM
9458
* @typechecks static-only
9459
*/
9460
9461
'use strict';
9462
9463
var ReactElement = require("./ReactElement");
9464
var ReactElementValidator = require("./ReactElementValidator");
9465
9466
var mapObject = require("./mapObject");
9467
9468
/**
9469
* Create a factory that creates HTML tag elements.
9470
*
9471
* @param {string} tag Tag name (e.g. `div`).
9472
* @private
9473
*/
9474
function createDOMFactory(tag) {
9475
if ("production" !== process.env.NODE_ENV) {
9476
return ReactElementValidator.createFactory(tag);
9477
}
9478
return ReactElement.createFactory(tag);
9479
}
9480
9481
/**
9482
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
9483
* This is also accessible via `React.DOM`.
9484
*
9485
* @public
9486
*/
9487
var ReactDOM = mapObject({
9488
a: 'a',
9489
abbr: 'abbr',
9490
address: 'address',
9491
area: 'area',
9492
article: 'article',
9493
aside: 'aside',
9494
audio: 'audio',
9495
b: 'b',
9496
base: 'base',
9497
bdi: 'bdi',
9498
bdo: 'bdo',
9499
big: 'big',
9500
blockquote: 'blockquote',
9501
body: 'body',
9502
br: 'br',
9503
button: 'button',
9504
canvas: 'canvas',
9505
caption: 'caption',
9506
cite: 'cite',
9507
code: 'code',
9508
col: 'col',
9509
colgroup: 'colgroup',
9510
data: 'data',
9511
datalist: 'datalist',
9512
dd: 'dd',
9513
del: 'del',
9514
details: 'details',
9515
dfn: 'dfn',
9516
dialog: 'dialog',
9517
div: 'div',
9518
dl: 'dl',
9519
dt: 'dt',
9520
em: 'em',
9521
embed: 'embed',
9522
fieldset: 'fieldset',
9523
figcaption: 'figcaption',
9524
figure: 'figure',
9525
footer: 'footer',
9526
form: 'form',
9527
h1: 'h1',
9528
h2: 'h2',
9529
h3: 'h3',
9530
h4: 'h4',
9531
h5: 'h5',
9532
h6: 'h6',
9533
head: 'head',
9534
header: 'header',
9535
hr: 'hr',
9536
html: 'html',
9537
i: 'i',
9538
iframe: 'iframe',
9539
img: 'img',
9540
input: 'input',
9541
ins: 'ins',
9542
kbd: 'kbd',
9543
keygen: 'keygen',
9544
label: 'label',
9545
legend: 'legend',
9546
li: 'li',
9547
link: 'link',
9548
main: 'main',
9549
map: 'map',
9550
mark: 'mark',
9551
menu: 'menu',
9552
menuitem: 'menuitem',
9553
meta: 'meta',
9554
meter: 'meter',
9555
nav: 'nav',
9556
noscript: 'noscript',
9557
object: 'object',
9558
ol: 'ol',
9559
optgroup: 'optgroup',
9560
option: 'option',
9561
output: 'output',
9562
p: 'p',
9563
param: 'param',
9564
picture: 'picture',
9565
pre: 'pre',
9566
progress: 'progress',
9567
q: 'q',
9568
rp: 'rp',
9569
rt: 'rt',
9570
ruby: 'ruby',
9571
s: 's',
9572
samp: 'samp',
9573
script: 'script',
9574
section: 'section',
9575
select: 'select',
9576
small: 'small',
9577
source: 'source',
9578
span: 'span',
9579
strong: 'strong',
9580
style: 'style',
9581
sub: 'sub',
9582
summary: 'summary',
9583
sup: 'sup',
9584
table: 'table',
9585
tbody: 'tbody',
9586
td: 'td',
9587
textarea: 'textarea',
9588
tfoot: 'tfoot',
9589
th: 'th',
9590
thead: 'thead',
9591
time: 'time',
9592
title: 'title',
9593
tr: 'tr',
9594
track: 'track',
9595
u: 'u',
9596
ul: 'ul',
9597
'var': 'var',
9598
video: 'video',
9599
wbr: 'wbr',
9600
9601
// SVG
9602
circle: 'circle',
9603
clipPath: 'clipPath',
9604
defs: 'defs',
9605
ellipse: 'ellipse',
9606
g: 'g',
9607
line: 'line',
9608
linearGradient: 'linearGradient',
9609
mask: 'mask',
9610
path: 'path',
9611
pattern: 'pattern',
9612
polygon: 'polygon',
9613
polyline: 'polyline',
9614
radialGradient: 'radialGradient',
9615
rect: 'rect',
9616
stop: 'stop',
9617
svg: 'svg',
9618
text: 'text',
9619
tspan: 'tspan'
9620
9621
}, createDOMFactory);
9622
9623
module.exports = ReactDOM;
9624
9625
}).call(this,require('_process'))
9626
},{"./ReactElement":76,"./ReactElementValidator":77,"./mapObject":172,"_process":1}],60:[function(require,module,exports){
9627
/**
9628
* Copyright 2013-2015, Facebook, Inc.
9629
* All rights reserved.
9630
*
9631
* This source code is licensed under the BSD-style license found in the
9632
* LICENSE file in the root directory of this source tree. An additional grant
9633
* of patent rights can be found in the PATENTS file in the same directory.
9634
*
9635
* @providesModule ReactDOMButton
9636
*/
9637
9638
'use strict';
9639
9640
var AutoFocusMixin = require("./AutoFocusMixin");
9641
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
9642
var ReactClass = require("./ReactClass");
9643
var ReactElement = require("./ReactElement");
9644
9645
var keyMirror = require("./keyMirror");
9646
9647
var button = ReactElement.createFactory('button');
9648
9649
var mouseListenerNames = keyMirror({
9650
onClick: true,
9651
onDoubleClick: true,
9652
onMouseDown: true,
9653
onMouseMove: true,
9654
onMouseUp: true,
9655
onClickCapture: true,
9656
onDoubleClickCapture: true,
9657
onMouseDownCapture: true,
9658
onMouseMoveCapture: true,
9659
onMouseUpCapture: true
9660
});
9661
9662
/**
9663
* Implements a <button> native component that does not receive mouse events
9664
* when `disabled` is set.
9665
*/
9666
var ReactDOMButton = ReactClass.createClass({
9667
displayName: 'ReactDOMButton',
9668
tagName: 'BUTTON',
9669
9670
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
9671
9672
render: function() {
9673
var props = {};
9674
9675
// Copy the props; except the mouse listeners if we're disabled
9676
for (var key in this.props) {
9677
if (this.props.hasOwnProperty(key) &&
9678
(!this.props.disabled || !mouseListenerNames[key])) {
9679
props[key] = this.props[key];
9680
}
9681
}
9682
9683
return button(props, this.props.children);
9684
}
9685
9686
});
9687
9688
module.exports = ReactDOMButton;
9689
9690
},{"./AutoFocusMixin":15,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76,"./keyMirror":170}],61:[function(require,module,exports){
9691
(function (process){
9692
/**
9693
* Copyright 2013-2015, Facebook, Inc.
9694
* All rights reserved.
9695
*
9696
* This source code is licensed under the BSD-style license found in the
9697
* LICENSE file in the root directory of this source tree. An additional grant
9698
* of patent rights can be found in the PATENTS file in the same directory.
9699
*
9700
* @providesModule ReactDOMComponent
9701
* @typechecks static-only
9702
*/
9703
9704
/* global hasOwnProperty:true */
9705
9706
'use strict';
9707
9708
var CSSPropertyOperations = require("./CSSPropertyOperations");
9709
var DOMProperty = require("./DOMProperty");
9710
var DOMPropertyOperations = require("./DOMPropertyOperations");
9711
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
9712
var ReactComponentBrowserEnvironment =
9713
require("./ReactComponentBrowserEnvironment");
9714
var ReactMount = require("./ReactMount");
9715
var ReactMultiChild = require("./ReactMultiChild");
9716
var ReactPerf = require("./ReactPerf");
9717
9718
var assign = require("./Object.assign");
9719
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
9720
var invariant = require("./invariant");
9721
var isEventSupported = require("./isEventSupported");
9722
var keyOf = require("./keyOf");
9723
var warning = require("./warning");
9724
9725
var deleteListener = ReactBrowserEventEmitter.deleteListener;
9726
var listenTo = ReactBrowserEventEmitter.listenTo;
9727
var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
9728
9729
// For quickly matching children type, to test if can be treated as content.
9730
var CONTENT_TYPES = {'string': true, 'number': true};
9731
9732
var STYLE = keyOf({style: null});
9733
9734
var ELEMENT_NODE_TYPE = 1;
9735
9736
/**
9737
* Optionally injectable operations for mutating the DOM
9738
*/
9739
var BackendIDOperations = null;
9740
9741
/**
9742
* @param {?object} props
9743
*/
9744
function assertValidProps(props) {
9745
if (!props) {
9746
return;
9747
}
9748
// Note the use of `==` which checks for null or undefined.
9749
if (props.dangerouslySetInnerHTML != null) {
9750
("production" !== process.env.NODE_ENV ? invariant(
9751
props.children == null,
9752
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
9753
) : invariant(props.children == null));
9754
("production" !== process.env.NODE_ENV ? invariant(
9755
typeof props.dangerouslySetInnerHTML === 'object' &&
9756
'__html' in props.dangerouslySetInnerHTML,
9757
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
9758
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' +
9759
'for more information.'
9760
) : invariant(typeof props.dangerouslySetInnerHTML === 'object' &&
9761
'__html' in props.dangerouslySetInnerHTML));
9762
}
9763
if ("production" !== process.env.NODE_ENV) {
9764
("production" !== process.env.NODE_ENV ? warning(
9765
props.innerHTML == null,
9766
'Directly setting property `innerHTML` is not permitted. ' +
9767
'For more information, lookup documentation on `dangerouslySetInnerHTML`.'
9768
) : null);
9769
("production" !== process.env.NODE_ENV ? warning(
9770
!props.contentEditable || props.children == null,
9771
'A component is `contentEditable` and contains `children` managed by ' +
9772
'React. It is now your responsibility to guarantee that none of ' +
9773
'those nodes are unexpectedly modified or duplicated. This is ' +
9774
'probably not intentional.'
9775
) : null);
9776
}
9777
("production" !== process.env.NODE_ENV ? invariant(
9778
props.style == null || typeof props.style === 'object',
9779
'The `style` prop expects a mapping from style properties to values, ' +
9780
'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' +
9781
'using JSX.'
9782
) : invariant(props.style == null || typeof props.style === 'object'));
9783
}
9784
9785
function putListener(id, registrationName, listener, transaction) {
9786
if ("production" !== process.env.NODE_ENV) {
9787
// IE8 has no API for event capturing and the `onScroll` event doesn't
9788
// bubble.
9789
("production" !== process.env.NODE_ENV ? warning(
9790
registrationName !== 'onScroll' || isEventSupported('scroll', true),
9791
'This browser doesn\'t support the `onScroll` event'
9792
) : null);
9793
}
9794
var container = ReactMount.findReactContainerForID(id);
9795
if (container) {
9796
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
9797
container.ownerDocument :
9798
container;
9799
listenTo(registrationName, doc);
9800
}
9801
transaction.getPutListenerQueue().enqueuePutListener(
9802
id,
9803
registrationName,
9804
listener
9805
);
9806
}
9807
9808
// For HTML, certain tags should omit their close tag. We keep a whitelist for
9809
// those special cased tags.
9810
9811
var omittedCloseTags = {
9812
'area': true,
9813
'base': true,
9814
'br': true,
9815
'col': true,
9816
'embed': true,
9817
'hr': true,
9818
'img': true,
9819
'input': true,
9820
'keygen': true,
9821
'link': true,
9822
'meta': true,
9823
'param': true,
9824
'source': true,
9825
'track': true,
9826
'wbr': true
9827
// NOTE: menuitem's close tag should be omitted, but that causes problems.
9828
};
9829
9830
// We accept any tag to be rendered but since this gets injected into abitrary
9831
// HTML, we want to make sure that it's a safe tag.
9832
// http://www.w3.org/TR/REC-xml/#NT-Name
9833
9834
var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
9835
var validatedTagCache = {};
9836
var hasOwnProperty = {}.hasOwnProperty;
9837
9838
function validateDangerousTag(tag) {
9839
if (!hasOwnProperty.call(validatedTagCache, tag)) {
9840
("production" !== process.env.NODE_ENV ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
9841
validatedTagCache[tag] = true;
9842
}
9843
}
9844
9845
/**
9846
* Creates a new React class that is idempotent and capable of containing other
9847
* React components. It accepts event listeners and DOM properties that are
9848
* valid according to `DOMProperty`.
9849
*
9850
* - Event listeners: `onClick`, `onMouseDown`, etc.
9851
* - DOM properties: `className`, `name`, `title`, etc.
9852
*
9853
* The `style` property functions differently from the DOM API. It accepts an
9854
* object mapping of style properties to values.
9855
*
9856
* @constructor ReactDOMComponent
9857
* @extends ReactMultiChild
9858
*/
9859
function ReactDOMComponent(tag) {
9860
validateDangerousTag(tag);
9861
this._tag = tag;
9862
this._renderedChildren = null;
9863
this._previousStyleCopy = null;
9864
this._rootNodeID = null;
9865
}
9866
9867
ReactDOMComponent.displayName = 'ReactDOMComponent';
9868
9869
ReactDOMComponent.Mixin = {
9870
9871
construct: function(element) {
9872
this._currentElement = element;
9873
},
9874
9875
/**
9876
* Generates root tag markup then recurses. This method has side effects and
9877
* is not idempotent.
9878
*
9879
* @internal
9880
* @param {string} rootID The root DOM ID for this node.
9881
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
9882
* @return {string} The computed markup.
9883
*/
9884
mountComponent: function(rootID, transaction, context) {
9885
this._rootNodeID = rootID;
9886
assertValidProps(this._currentElement.props);
9887
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
9888
return (
9889
this._createOpenTagMarkupAndPutListeners(transaction) +
9890
this._createContentMarkup(transaction, context) +
9891
closeTag
9892
);
9893
},
9894
9895
/**
9896
* Creates markup for the open tag and all attributes.
9897
*
9898
* This method has side effects because events get registered.
9899
*
9900
* Iterating over object properties is faster than iterating over arrays.
9901
* @see http://jsperf.com/obj-vs-arr-iteration
9902
*
9903
* @private
9904
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
9905
* @return {string} Markup of opening tag.
9906
*/
9907
_createOpenTagMarkupAndPutListeners: function(transaction) {
9908
var props = this._currentElement.props;
9909
var ret = '<' + this._tag;
9910
9911
for (var propKey in props) {
9912
if (!props.hasOwnProperty(propKey)) {
9913
continue;
9914
}
9915
var propValue = props[propKey];
9916
if (propValue == null) {
9917
continue;
9918
}
9919
if (registrationNameModules.hasOwnProperty(propKey)) {
9920
putListener(this._rootNodeID, propKey, propValue, transaction);
9921
} else {
9922
if (propKey === STYLE) {
9923
if (propValue) {
9924
propValue = this._previousStyleCopy = assign({}, props.style);
9925
}
9926
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
9927
}
9928
var markup =
9929
DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
9930
if (markup) {
9931
ret += ' ' + markup;
9932
}
9933
}
9934
}
9935
9936
// For static pages, no need to put React ID and checksum. Saves lots of
9937
// bytes.
9938
if (transaction.renderToStaticMarkup) {
9939
return ret + '>';
9940
}
9941
9942
var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
9943
return ret + ' ' + markupForID + '>';
9944
},
9945
9946
/**
9947
* Creates markup for the content between the tags.
9948
*
9949
* @private
9950
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
9951
* @param {object} context
9952
* @return {string} Content markup.
9953
*/
9954
_createContentMarkup: function(transaction, context) {
9955
var prefix = '';
9956
if (this._tag === 'listing' ||
9957
this._tag === 'pre' ||
9958
this._tag === 'textarea') {
9959
// Add an initial newline because browsers ignore the first newline in
9960
// a <listing>, <pre>, or <textarea> as an "authoring convenience" -- see
9961
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody.
9962
prefix = '\n';
9963
}
9964
9965
var props = this._currentElement.props;
9966
9967
// Intentional use of != to avoid catching zero/false.
9968
var innerHTML = props.dangerouslySetInnerHTML;
9969
if (innerHTML != null) {
9970
if (innerHTML.__html != null) {
9971
return prefix + innerHTML.__html;
9972
}
9973
} else {
9974
var contentToUse =
9975
CONTENT_TYPES[typeof props.children] ? props.children : null;
9976
var childrenToUse = contentToUse != null ? null : props.children;
9977
if (contentToUse != null) {
9978
return prefix + escapeTextContentForBrowser(contentToUse);
9979
} else if (childrenToUse != null) {
9980
var mountImages = this.mountChildren(
9981
childrenToUse,
9982
transaction,
9983
context
9984
);
9985
return prefix + mountImages.join('');
9986
}
9987
}
9988
return prefix;
9989
},
9990
9991
receiveComponent: function(nextElement, transaction, context) {
9992
var prevElement = this._currentElement;
9993
this._currentElement = nextElement;
9994
this.updateComponent(transaction, prevElement, nextElement, context);
9995
},
9996
9997
/**
9998
* Updates a native DOM component after it has already been allocated and
9999
* attached to the DOM. Reconciles the root DOM node, then recurses.
10000
*
10001
* @param {ReactReconcileTransaction} transaction
10002
* @param {ReactElement} prevElement
10003
* @param {ReactElement} nextElement
10004
* @internal
10005
* @overridable
10006
*/
10007
updateComponent: function(transaction, prevElement, nextElement, context) {
10008
assertValidProps(this._currentElement.props);
10009
this._updateDOMProperties(prevElement.props, transaction);
10010
this._updateDOMChildren(prevElement.props, transaction, context);
10011
},
10012
10013
/**
10014
* Reconciles the properties by detecting differences in property values and
10015
* updating the DOM as necessary. This function is probably the single most
10016
* critical path for performance optimization.
10017
*
10018
* TODO: Benchmark whether checking for changed values in memory actually
10019
* improves performance (especially statically positioned elements).
10020
* TODO: Benchmark the effects of putting this at the top since 99% of props
10021
* do not change for a given reconciliation.
10022
* TODO: Benchmark areas that can be improved with caching.
10023
*
10024
* @private
10025
* @param {object} lastProps
10026
* @param {ReactReconcileTransaction} transaction
10027
*/
10028
_updateDOMProperties: function(lastProps, transaction) {
10029
var nextProps = this._currentElement.props;
10030
var propKey;
10031
var styleName;
10032
var styleUpdates;
10033
for (propKey in lastProps) {
10034
if (nextProps.hasOwnProperty(propKey) ||
10035
!lastProps.hasOwnProperty(propKey)) {
10036
continue;
10037
}
10038
if (propKey === STYLE) {
10039
var lastStyle = this._previousStyleCopy;
10040
for (styleName in lastStyle) {
10041
if (lastStyle.hasOwnProperty(styleName)) {
10042
styleUpdates = styleUpdates || {};
10043
styleUpdates[styleName] = '';
10044
}
10045
}
10046
this._previousStyleCopy = null;
10047
} else if (registrationNameModules.hasOwnProperty(propKey)) {
10048
deleteListener(this._rootNodeID, propKey);
10049
} else if (
10050
DOMProperty.isStandardName[propKey] ||
10051
DOMProperty.isCustomAttribute(propKey)) {
10052
BackendIDOperations.deletePropertyByID(
10053
this._rootNodeID,
10054
propKey
10055
);
10056
}
10057
}
10058
for (propKey in nextProps) {
10059
var nextProp = nextProps[propKey];
10060
var lastProp = propKey === STYLE ?
10061
this._previousStyleCopy :
10062
lastProps[propKey];
10063
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
10064
continue;
10065
}
10066
if (propKey === STYLE) {
10067
if (nextProp) {
10068
nextProp = this._previousStyleCopy = assign({}, nextProp);
10069
} else {
10070
this._previousStyleCopy = null;
10071
}
10072
if (lastProp) {
10073
// Unset styles on `lastProp` but not on `nextProp`.
10074
for (styleName in lastProp) {
10075
if (lastProp.hasOwnProperty(styleName) &&
10076
(!nextProp || !nextProp.hasOwnProperty(styleName))) {
10077
styleUpdates = styleUpdates || {};
10078
styleUpdates[styleName] = '';
10079
}
10080
}
10081
// Update styles that changed since `lastProp`.
10082
for (styleName in nextProp) {
10083
if (nextProp.hasOwnProperty(styleName) &&
10084
lastProp[styleName] !== nextProp[styleName]) {
10085
styleUpdates = styleUpdates || {};
10086
styleUpdates[styleName] = nextProp[styleName];
10087
}
10088
}
10089
} else {
10090
// Relies on `updateStylesByID` not mutating `styleUpdates`.
10091
styleUpdates = nextProp;
10092
}
10093
} else if (registrationNameModules.hasOwnProperty(propKey)) {
10094
putListener(this._rootNodeID, propKey, nextProp, transaction);
10095
} else if (
10096
DOMProperty.isStandardName[propKey] ||
10097
DOMProperty.isCustomAttribute(propKey)) {
10098
BackendIDOperations.updatePropertyByID(
10099
this._rootNodeID,
10100
propKey,
10101
nextProp
10102
);
10103
}
10104
}
10105
if (styleUpdates) {
10106
BackendIDOperations.updateStylesByID(
10107
this._rootNodeID,
10108
styleUpdates
10109
);
10110
}
10111
},
10112
10113
/**
10114
* Reconciles the children with the various properties that affect the
10115
* children content.
10116
*
10117
* @param {object} lastProps
10118
* @param {ReactReconcileTransaction} transaction
10119
*/
10120
_updateDOMChildren: function(lastProps, transaction, context) {
10121
var nextProps = this._currentElement.props;
10122
10123
var lastContent =
10124
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
10125
var nextContent =
10126
CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
10127
10128
var lastHtml =
10129
lastProps.dangerouslySetInnerHTML &&
10130
lastProps.dangerouslySetInnerHTML.__html;
10131
var nextHtml =
10132
nextProps.dangerouslySetInnerHTML &&
10133
nextProps.dangerouslySetInnerHTML.__html;
10134
10135
// Note the use of `!=` which checks for null or undefined.
10136
var lastChildren = lastContent != null ? null : lastProps.children;
10137
var nextChildren = nextContent != null ? null : nextProps.children;
10138
10139
// If we're switching from children to content/html or vice versa, remove
10140
// the old content
10141
var lastHasContentOrHtml = lastContent != null || lastHtml != null;
10142
var nextHasContentOrHtml = nextContent != null || nextHtml != null;
10143
if (lastChildren != null && nextChildren == null) {
10144
this.updateChildren(null, transaction, context);
10145
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
10146
this.updateTextContent('');
10147
}
10148
10149
if (nextContent != null) {
10150
if (lastContent !== nextContent) {
10151
this.updateTextContent('' + nextContent);
10152
}
10153
} else if (nextHtml != null) {
10154
if (lastHtml !== nextHtml) {
10155
BackendIDOperations.updateInnerHTMLByID(
10156
this._rootNodeID,
10157
nextHtml
10158
);
10159
}
10160
} else if (nextChildren != null) {
10161
this.updateChildren(nextChildren, transaction, context);
10162
}
10163
},
10164
10165
/**
10166
* Destroys all event registrations for this instance. Does not remove from
10167
* the DOM. That must be done by the parent.
10168
*
10169
* @internal
10170
*/
10171
unmountComponent: function() {
10172
this.unmountChildren();
10173
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
10174
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
10175
this._rootNodeID = null;
10176
}
10177
10178
};
10179
10180
ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
10181
mountComponent: 'mountComponent',
10182
updateComponent: 'updateComponent'
10183
});
10184
10185
assign(
10186
ReactDOMComponent.prototype,
10187
ReactDOMComponent.Mixin,
10188
ReactMultiChild.Mixin
10189
);
10190
10191
ReactDOMComponent.injection = {
10192
injectIDOperations: function(IDOperations) {
10193
ReactDOMComponent.BackendIDOperations = BackendIDOperations = IDOperations;
10194
}
10195
};
10196
10197
module.exports = ReactDOMComponent;
10198
10199
}).call(this,require('_process'))
10200
},{"./CSSPropertyOperations":19,"./DOMProperty":24,"./DOMPropertyOperations":25,"./Object.assign":42,"./ReactBrowserEventEmitter":46,"./ReactComponentBrowserEnvironment":53,"./ReactMount":90,"./ReactMultiChild":91,"./ReactPerf":95,"./escapeTextContentForBrowser":145,"./invariant":164,"./isEventSupported":165,"./keyOf":171,"./warning":185,"_process":1}],62:[function(require,module,exports){
10201
/**
10202
* Copyright 2013-2015, Facebook, Inc.
10203
* All rights reserved.
10204
*
10205
* This source code is licensed under the BSD-style license found in the
10206
* LICENSE file in the root directory of this source tree. An additional grant
10207
* of patent rights can be found in the PATENTS file in the same directory.
10208
*
10209
* @providesModule ReactDOMForm
10210
*/
10211
10212
'use strict';
10213
10214
var EventConstants = require("./EventConstants");
10215
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
10216
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10217
var ReactClass = require("./ReactClass");
10218
var ReactElement = require("./ReactElement");
10219
10220
var form = ReactElement.createFactory('form');
10221
10222
/**
10223
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
10224
* to capture it on the <form> element itself. There are lots of hacks we could
10225
* do to accomplish this, but the most reliable is to make <form> a
10226
* composite component and use `componentDidMount` to attach the event handlers.
10227
*/
10228
var ReactDOMForm = ReactClass.createClass({
10229
displayName: 'ReactDOMForm',
10230
tagName: 'FORM',
10231
10232
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
10233
10234
render: function() {
10235
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
10236
// `jshint` fails to parse JSX so in order for linting to work in the open
10237
// source repo, we need to just use `ReactDOM.form`.
10238
return form(this.props);
10239
},
10240
10241
componentDidMount: function() {
10242
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
10243
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
10244
}
10245
});
10246
10247
module.exports = ReactDOMForm;
10248
10249
},{"./EventConstants":29,"./LocalEventTrapMixin":40,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76}],63:[function(require,module,exports){
10250
(function (process){
10251
/**
10252
* Copyright 2013-2015, Facebook, Inc.
10253
* All rights reserved.
10254
*
10255
* This source code is licensed under the BSD-style license found in the
10256
* LICENSE file in the root directory of this source tree. An additional grant
10257
* of patent rights can be found in the PATENTS file in the same directory.
10258
*
10259
* @providesModule ReactDOMIDOperations
10260
* @typechecks static-only
10261
*/
10262
10263
/*jslint evil: true */
10264
10265
'use strict';
10266
10267
var CSSPropertyOperations = require("./CSSPropertyOperations");
10268
var DOMChildrenOperations = require("./DOMChildrenOperations");
10269
var DOMPropertyOperations = require("./DOMPropertyOperations");
10270
var ReactMount = require("./ReactMount");
10271
var ReactPerf = require("./ReactPerf");
10272
10273
var invariant = require("./invariant");
10274
var setInnerHTML = require("./setInnerHTML");
10275
10276
/**
10277
* Errors for properties that should not be updated with `updatePropertyById()`.
10278
*
10279
* @type {object}
10280
* @private
10281
*/
10282
var INVALID_PROPERTY_ERRORS = {
10283
dangerouslySetInnerHTML:
10284
'`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
10285
style: '`style` must be set using `updateStylesByID()`.'
10286
};
10287
10288
/**
10289
* Operations used to process updates to DOM nodes. This is made injectable via
10290
* `ReactDOMComponent.BackendIDOperations`.
10291
*/
10292
var ReactDOMIDOperations = {
10293
10294
/**
10295
* Updates a DOM node with new property values. This should only be used to
10296
* update DOM properties in `DOMProperty`.
10297
*
10298
* @param {string} id ID of the node to update.
10299
* @param {string} name A valid property name, see `DOMProperty`.
10300
* @param {*} value New value of the property.
10301
* @internal
10302
*/
10303
updatePropertyByID: function(id, name, value) {
10304
var node = ReactMount.getNode(id);
10305
("production" !== process.env.NODE_ENV ? invariant(
10306
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
10307
'updatePropertyByID(...): %s',
10308
INVALID_PROPERTY_ERRORS[name]
10309
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
10310
10311
// If we're updating to null or undefined, we should remove the property
10312
// from the DOM node instead of inadvertantly setting to a string. This
10313
// brings us in line with the same behavior we have on initial render.
10314
if (value != null) {
10315
DOMPropertyOperations.setValueForProperty(node, name, value);
10316
} else {
10317
DOMPropertyOperations.deleteValueForProperty(node, name);
10318
}
10319
},
10320
10321
/**
10322
* Updates a DOM node to remove a property. This should only be used to remove
10323
* DOM properties in `DOMProperty`.
10324
*
10325
* @param {string} id ID of the node to update.
10326
* @param {string} name A property name to remove, see `DOMProperty`.
10327
* @internal
10328
*/
10329
deletePropertyByID: function(id, name, value) {
10330
var node = ReactMount.getNode(id);
10331
("production" !== process.env.NODE_ENV ? invariant(
10332
!INVALID_PROPERTY_ERRORS.hasOwnProperty(name),
10333
'updatePropertyByID(...): %s',
10334
INVALID_PROPERTY_ERRORS[name]
10335
) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name)));
10336
DOMPropertyOperations.deleteValueForProperty(node, name, value);
10337
},
10338
10339
/**
10340
* Updates a DOM node with new style values. If a value is specified as '',
10341
* the corresponding style property will be unset.
10342
*
10343
* @param {string} id ID of the node to update.
10344
* @param {object} styles Mapping from styles to values.
10345
* @internal
10346
*/
10347
updateStylesByID: function(id, styles) {
10348
var node = ReactMount.getNode(id);
10349
CSSPropertyOperations.setValueForStyles(node, styles);
10350
},
10351
10352
/**
10353
* Updates a DOM node's innerHTML.
10354
*
10355
* @param {string} id ID of the node to update.
10356
* @param {string} html An HTML string.
10357
* @internal
10358
*/
10359
updateInnerHTMLByID: function(id, html) {
10360
var node = ReactMount.getNode(id);
10361
setInnerHTML(node, html);
10362
},
10363
10364
/**
10365
* Updates a DOM node's text content set by `props.content`.
10366
*
10367
* @param {string} id ID of the node to update.
10368
* @param {string} content Text content.
10369
* @internal
10370
*/
10371
updateTextContentByID: function(id, content) {
10372
var node = ReactMount.getNode(id);
10373
DOMChildrenOperations.updateTextContent(node, content);
10374
},
10375
10376
/**
10377
* Replaces a DOM node that exists in the document with markup.
10378
*
10379
* @param {string} id ID of child to be replaced.
10380
* @param {string} markup Dangerous markup to inject in place of child.
10381
* @internal
10382
* @see {Danger.dangerouslyReplaceNodeWithMarkup}
10383
*/
10384
dangerouslyReplaceNodeWithMarkupByID: function(id, markup) {
10385
var node = ReactMount.getNode(id);
10386
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
10387
},
10388
10389
/**
10390
* Updates a component's children by processing a series of updates.
10391
*
10392
* @param {array<object>} updates List of update configurations.
10393
* @param {array<string>} markup List of markup strings.
10394
* @internal
10395
*/
10396
dangerouslyProcessChildrenUpdates: function(updates, markup) {
10397
for (var i = 0; i < updates.length; i++) {
10398
updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
10399
}
10400
DOMChildrenOperations.processUpdates(updates, markup);
10401
}
10402
};
10403
10404
ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
10405
updatePropertyByID: 'updatePropertyByID',
10406
deletePropertyByID: 'deletePropertyByID',
10407
updateStylesByID: 'updateStylesByID',
10408
updateInnerHTMLByID: 'updateInnerHTMLByID',
10409
updateTextContentByID: 'updateTextContentByID',
10410
dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
10411
dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
10412
});
10413
10414
module.exports = ReactDOMIDOperations;
10415
10416
}).call(this,require('_process'))
10417
},{"./CSSPropertyOperations":19,"./DOMChildrenOperations":23,"./DOMPropertyOperations":25,"./ReactMount":90,"./ReactPerf":95,"./invariant":164,"./setInnerHTML":178,"_process":1}],64:[function(require,module,exports){
10418
/**
10419
* Copyright 2013-2015, Facebook, Inc.
10420
* All rights reserved.
10421
*
10422
* This source code is licensed under the BSD-style license found in the
10423
* LICENSE file in the root directory of this source tree. An additional grant
10424
* of patent rights can be found in the PATENTS file in the same directory.
10425
*
10426
* @providesModule ReactDOMIframe
10427
*/
10428
10429
'use strict';
10430
10431
var EventConstants = require("./EventConstants");
10432
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
10433
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10434
var ReactClass = require("./ReactClass");
10435
var ReactElement = require("./ReactElement");
10436
10437
var iframe = ReactElement.createFactory('iframe');
10438
10439
/**
10440
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
10441
* capture it on the <iframe> element itself. There are lots of hacks we could
10442
* do to accomplish this, but the most reliable is to make <iframe> a composite
10443
* component and use `componentDidMount` to attach the event handlers.
10444
*/
10445
var ReactDOMIframe = ReactClass.createClass({
10446
displayName: 'ReactDOMIframe',
10447
tagName: 'IFRAME',
10448
10449
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
10450
10451
render: function() {
10452
return iframe(this.props);
10453
},
10454
10455
componentDidMount: function() {
10456
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
10457
}
10458
});
10459
10460
module.exports = ReactDOMIframe;
10461
10462
},{"./EventConstants":29,"./LocalEventTrapMixin":40,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76}],65:[function(require,module,exports){
10463
/**
10464
* Copyright 2013-2015, Facebook, Inc.
10465
* All rights reserved.
10466
*
10467
* This source code is licensed under the BSD-style license found in the
10468
* LICENSE file in the root directory of this source tree. An additional grant
10469
* of patent rights can be found in the PATENTS file in the same directory.
10470
*
10471
* @providesModule ReactDOMImg
10472
*/
10473
10474
'use strict';
10475
10476
var EventConstants = require("./EventConstants");
10477
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
10478
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10479
var ReactClass = require("./ReactClass");
10480
var ReactElement = require("./ReactElement");
10481
10482
var img = ReactElement.createFactory('img');
10483
10484
/**
10485
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
10486
* capture it on the <img> element itself. There are lots of hacks we could do
10487
* to accomplish this, but the most reliable is to make <img> a composite
10488
* component and use `componentDidMount` to attach the event handlers.
10489
*/
10490
var ReactDOMImg = ReactClass.createClass({
10491
displayName: 'ReactDOMImg',
10492
tagName: 'IMG',
10493
10494
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
10495
10496
render: function() {
10497
return img(this.props);
10498
},
10499
10500
componentDidMount: function() {
10501
this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');
10502
this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');
10503
}
10504
});
10505
10506
module.exports = ReactDOMImg;
10507
10508
},{"./EventConstants":29,"./LocalEventTrapMixin":40,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76}],66:[function(require,module,exports){
10509
(function (process){
10510
/**
10511
* Copyright 2013-2015, Facebook, Inc.
10512
* All rights reserved.
10513
*
10514
* This source code is licensed under the BSD-style license found in the
10515
* LICENSE file in the root directory of this source tree. An additional grant
10516
* of patent rights can be found in the PATENTS file in the same directory.
10517
*
10518
* @providesModule ReactDOMInput
10519
*/
10520
10521
'use strict';
10522
10523
var AutoFocusMixin = require("./AutoFocusMixin");
10524
var DOMPropertyOperations = require("./DOMPropertyOperations");
10525
var LinkedValueUtils = require("./LinkedValueUtils");
10526
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10527
var ReactClass = require("./ReactClass");
10528
var ReactElement = require("./ReactElement");
10529
var ReactMount = require("./ReactMount");
10530
var ReactUpdates = require("./ReactUpdates");
10531
10532
var assign = require("./Object.assign");
10533
var invariant = require("./invariant");
10534
10535
var input = ReactElement.createFactory('input');
10536
10537
var instancesByReactID = {};
10538
10539
function forceUpdateIfMounted() {
10540
/*jshint validthis:true */
10541
if (this.isMounted()) {
10542
this.forceUpdate();
10543
}
10544
}
10545
10546
/**
10547
* Implements an <input> native component that allows setting these optional
10548
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
10549
*
10550
* If `checked` or `value` are not supplied (or null/undefined), user actions
10551
* that affect the checked state or value will trigger updates to the element.
10552
*
10553
* If they are supplied (and not null/undefined), the rendered element will not
10554
* trigger updates to the element. Instead, the props must change in order for
10555
* the rendered element to be updated.
10556
*
10557
* The rendered element will be initialized as unchecked (or `defaultChecked`)
10558
* with an empty value (or `defaultValue`).
10559
*
10560
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
10561
*/
10562
var ReactDOMInput = ReactClass.createClass({
10563
displayName: 'ReactDOMInput',
10564
tagName: 'INPUT',
10565
10566
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
10567
10568
getInitialState: function() {
10569
var defaultValue = this.props.defaultValue;
10570
return {
10571
initialChecked: this.props.defaultChecked || false,
10572
initialValue: defaultValue != null ? defaultValue : null
10573
};
10574
},
10575
10576
render: function() {
10577
// Clone `this.props` so we don't mutate the input.
10578
var props = assign({}, this.props);
10579
10580
props.defaultChecked = null;
10581
props.defaultValue = null;
10582
10583
var value = LinkedValueUtils.getValue(this);
10584
props.value = value != null ? value : this.state.initialValue;
10585
10586
var checked = LinkedValueUtils.getChecked(this);
10587
props.checked = checked != null ? checked : this.state.initialChecked;
10588
10589
props.onChange = this._handleChange;
10590
10591
return input(props, this.props.children);
10592
},
10593
10594
componentDidMount: function() {
10595
var id = ReactMount.getID(this.getDOMNode());
10596
instancesByReactID[id] = this;
10597
},
10598
10599
componentWillUnmount: function() {
10600
var rootNode = this.getDOMNode();
10601
var id = ReactMount.getID(rootNode);
10602
delete instancesByReactID[id];
10603
},
10604
10605
componentDidUpdate: function(prevProps, prevState, prevContext) {
10606
var rootNode = this.getDOMNode();
10607
if (this.props.checked != null) {
10608
DOMPropertyOperations.setValueForProperty(
10609
rootNode,
10610
'checked',
10611
this.props.checked || false
10612
);
10613
}
10614
10615
var value = LinkedValueUtils.getValue(this);
10616
if (value != null) {
10617
// Cast `value` to a string to ensure the value is set correctly. While
10618
// browsers typically do this as necessary, jsdom doesn't.
10619
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
10620
}
10621
},
10622
10623
_handleChange: function(event) {
10624
var returnValue;
10625
var onChange = LinkedValueUtils.getOnChange(this);
10626
if (onChange) {
10627
returnValue = onChange.call(this, event);
10628
}
10629
// Here we use asap to wait until all updates have propagated, which
10630
// is important when using controlled components within layers:
10631
// https://github.com/facebook/react/issues/1698
10632
ReactUpdates.asap(forceUpdateIfMounted, this);
10633
10634
var name = this.props.name;
10635
if (this.props.type === 'radio' && name != null) {
10636
var rootNode = this.getDOMNode();
10637
var queryRoot = rootNode;
10638
10639
while (queryRoot.parentNode) {
10640
queryRoot = queryRoot.parentNode;
10641
}
10642
10643
// If `rootNode.form` was non-null, then we could try `form.elements`,
10644
// but that sometimes behaves strangely in IE8. We could also try using
10645
// `form.getElementsByName`, but that will only return direct children
10646
// and won't include inputs that use the HTML5 `form=` attribute. Since
10647
// the input might not even be in a form, let's just use the global
10648
// `querySelectorAll` to ensure we don't miss anything.
10649
var group = queryRoot.querySelectorAll(
10650
'input[name=' + JSON.stringify('' + name) + '][type="radio"]');
10651
10652
for (var i = 0, groupLen = group.length; i < groupLen; i++) {
10653
var otherNode = group[i];
10654
if (otherNode === rootNode ||
10655
otherNode.form !== rootNode.form) {
10656
continue;
10657
}
10658
var otherID = ReactMount.getID(otherNode);
10659
("production" !== process.env.NODE_ENV ? invariant(
10660
otherID,
10661
'ReactDOMInput: Mixing React and non-React radio inputs with the ' +
10662
'same `name` is not supported.'
10663
) : invariant(otherID));
10664
var otherInstance = instancesByReactID[otherID];
10665
("production" !== process.env.NODE_ENV ? invariant(
10666
otherInstance,
10667
'ReactDOMInput: Unknown radio button ID %s.',
10668
otherID
10669
) : invariant(otherInstance));
10670
// If this is a controlled radio button group, forcing the input that
10671
// was previously checked to update will cause it to be come re-checked
10672
// as appropriate.
10673
ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
10674
}
10675
}
10676
10677
return returnValue;
10678
}
10679
10680
});
10681
10682
module.exports = ReactDOMInput;
10683
10684
}).call(this,require('_process'))
10685
},{"./AutoFocusMixin":15,"./DOMPropertyOperations":25,"./LinkedValueUtils":39,"./Object.assign":42,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76,"./ReactMount":90,"./ReactUpdates":113,"./invariant":164,"_process":1}],67:[function(require,module,exports){
10686
(function (process){
10687
/**
10688
* Copyright 2013-2015, Facebook, Inc.
10689
* All rights reserved.
10690
*
10691
* This source code is licensed under the BSD-style license found in the
10692
* LICENSE file in the root directory of this source tree. An additional grant
10693
* of patent rights can be found in the PATENTS file in the same directory.
10694
*
10695
* @providesModule ReactDOMOption
10696
*/
10697
10698
'use strict';
10699
10700
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10701
var ReactClass = require("./ReactClass");
10702
var ReactElement = require("./ReactElement");
10703
10704
var warning = require("./warning");
10705
10706
var option = ReactElement.createFactory('option');
10707
10708
/**
10709
* Implements an <option> native component that warns when `selected` is set.
10710
*/
10711
var ReactDOMOption = ReactClass.createClass({
10712
displayName: 'ReactDOMOption',
10713
tagName: 'OPTION',
10714
10715
mixins: [ReactBrowserComponentMixin],
10716
10717
componentWillMount: function() {
10718
// TODO (yungsters): Remove support for `selected` in <option>.
10719
if ("production" !== process.env.NODE_ENV) {
10720
("production" !== process.env.NODE_ENV ? warning(
10721
this.props.selected == null,
10722
'Use the `defaultValue` or `value` props on <select> instead of ' +
10723
'setting `selected` on <option>.'
10724
) : null);
10725
}
10726
},
10727
10728
render: function() {
10729
return option(this.props, this.props.children);
10730
}
10731
10732
});
10733
10734
module.exports = ReactDOMOption;
10735
10736
}).call(this,require('_process'))
10737
},{"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76,"./warning":185,"_process":1}],68:[function(require,module,exports){
10738
/**
10739
* Copyright 2013-2015, Facebook, Inc.
10740
* All rights reserved.
10741
*
10742
* This source code is licensed under the BSD-style license found in the
10743
* LICENSE file in the root directory of this source tree. An additional grant
10744
* of patent rights can be found in the PATENTS file in the same directory.
10745
*
10746
* @providesModule ReactDOMSelect
10747
*/
10748
10749
'use strict';
10750
10751
var AutoFocusMixin = require("./AutoFocusMixin");
10752
var LinkedValueUtils = require("./LinkedValueUtils");
10753
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
10754
var ReactClass = require("./ReactClass");
10755
var ReactElement = require("./ReactElement");
10756
var ReactUpdates = require("./ReactUpdates");
10757
10758
var assign = require("./Object.assign");
10759
10760
var select = ReactElement.createFactory('select');
10761
10762
function updateOptionsIfPendingUpdateAndMounted() {
10763
/*jshint validthis:true */
10764
if (this._pendingUpdate) {
10765
this._pendingUpdate = false;
10766
var value = LinkedValueUtils.getValue(this);
10767
if (value != null && this.isMounted()) {
10768
updateOptions(this, value);
10769
}
10770
}
10771
}
10772
10773
/**
10774
* Validation function for `value` and `defaultValue`.
10775
* @private
10776
*/
10777
function selectValueType(props, propName, componentName) {
10778
if (props[propName] == null) {
10779
return null;
10780
}
10781
if (props.multiple) {
10782
if (!Array.isArray(props[propName])) {
10783
return new Error(
10784
("The `" + propName + "` prop supplied to <select> must be an array if ") +
10785
("`multiple` is true.")
10786
);
10787
}
10788
} else {
10789
if (Array.isArray(props[propName])) {
10790
return new Error(
10791
("The `" + propName + "` prop supplied to <select> must be a scalar ") +
10792
("value if `multiple` is false.")
10793
);
10794
}
10795
}
10796
}
10797
10798
/**
10799
* @param {ReactComponent} component Instance of ReactDOMSelect
10800
* @param {*} propValue A stringable (with `multiple`, a list of stringables).
10801
* @private
10802
*/
10803
function updateOptions(component, propValue) {
10804
var selectedValue, i, l;
10805
var options = component.getDOMNode().options;
10806
10807
if (component.props.multiple) {
10808
selectedValue = {};
10809
for (i = 0, l = propValue.length; i < l; i++) {
10810
selectedValue['' + propValue[i]] = true;
10811
}
10812
for (i = 0, l = options.length; i < l; i++) {
10813
var selected = selectedValue.hasOwnProperty(options[i].value);
10814
if (options[i].selected !== selected) {
10815
options[i].selected = selected;
10816
}
10817
}
10818
} else {
10819
// Do not set `select.value` as exact behavior isn't consistent across all
10820
// browsers for all cases.
10821
selectedValue = '' + propValue;
10822
for (i = 0, l = options.length; i < l; i++) {
10823
if (options[i].value === selectedValue) {
10824
options[i].selected = true;
10825
return;
10826
}
10827
}
10828
if (options.length) {
10829
options[0].selected = true;
10830
}
10831
}
10832
}
10833
10834
/**
10835
* Implements a <select> native component that allows optionally setting the
10836
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a
10837
* stringable. If `multiple` is true, the prop must be an array of stringables.
10838
*
10839
* If `value` is not supplied (or null/undefined), user actions that change the
10840
* selected option will trigger updates to the rendered options.
10841
*
10842
* If it is supplied (and not null/undefined), the rendered options will not
10843
* update in response to user actions. Instead, the `value` prop must change in
10844
* order for the rendered options to update.
10845
*
10846
* If `defaultValue` is provided, any options with the supplied values will be
10847
* selected.
10848
*/
10849
var ReactDOMSelect = ReactClass.createClass({
10850
displayName: 'ReactDOMSelect',
10851
tagName: 'SELECT',
10852
10853
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
10854
10855
propTypes: {
10856
defaultValue: selectValueType,
10857
value: selectValueType
10858
},
10859
10860
render: function() {
10861
// Clone `this.props` so we don't mutate the input.
10862
var props = assign({}, this.props);
10863
10864
props.onChange = this._handleChange;
10865
props.value = null;
10866
10867
return select(props, this.props.children);
10868
},
10869
10870
componentWillMount: function() {
10871
this._pendingUpdate = false;
10872
},
10873
10874
componentDidMount: function() {
10875
var value = LinkedValueUtils.getValue(this);
10876
if (value != null) {
10877
updateOptions(this, value);
10878
} else if (this.props.defaultValue != null) {
10879
updateOptions(this, this.props.defaultValue);
10880
}
10881
},
10882
10883
componentDidUpdate: function(prevProps) {
10884
var value = LinkedValueUtils.getValue(this);
10885
if (value != null) {
10886
this._pendingUpdate = false;
10887
updateOptions(this, value);
10888
} else if (!prevProps.multiple !== !this.props.multiple) {
10889
// For simplicity, reapply `defaultValue` if `multiple` is toggled.
10890
if (this.props.defaultValue != null) {
10891
updateOptions(this, this.props.defaultValue);
10892
} else {
10893
// Revert the select back to its default unselected state.
10894
updateOptions(this, this.props.multiple ? [] : '');
10895
}
10896
}
10897
},
10898
10899
_handleChange: function(event) {
10900
var returnValue;
10901
var onChange = LinkedValueUtils.getOnChange(this);
10902
if (onChange) {
10903
returnValue = onChange.call(this, event);
10904
}
10905
10906
this._pendingUpdate = true;
10907
ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
10908
return returnValue;
10909
}
10910
10911
});
10912
10913
module.exports = ReactDOMSelect;
10914
10915
},{"./AutoFocusMixin":15,"./LinkedValueUtils":39,"./Object.assign":42,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76,"./ReactUpdates":113}],69:[function(require,module,exports){
10916
/**
10917
* Copyright 2013-2015, Facebook, Inc.
10918
* All rights reserved.
10919
*
10920
* This source code is licensed under the BSD-style license found in the
10921
* LICENSE file in the root directory of this source tree. An additional grant
10922
* of patent rights can be found in the PATENTS file in the same directory.
10923
*
10924
* @providesModule ReactDOMSelection
10925
*/
10926
10927
'use strict';
10928
10929
var ExecutionEnvironment = require("./ExecutionEnvironment");
10930
10931
var getNodeForCharacterOffset = require("./getNodeForCharacterOffset");
10932
var getTextContentAccessor = require("./getTextContentAccessor");
10933
10934
/**
10935
* While `isCollapsed` is available on the Selection object and `collapsed`
10936
* is available on the Range object, IE11 sometimes gets them wrong.
10937
* If the anchor/focus nodes and offsets are the same, the range is collapsed.
10938
*/
10939
function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
10940
return anchorNode === focusNode && anchorOffset === focusOffset;
10941
}
10942
10943
/**
10944
* Get the appropriate anchor and focus node/offset pairs for IE.
10945
*
10946
* The catch here is that IE's selection API doesn't provide information
10947
* about whether the selection is forward or backward, so we have to
10948
* behave as though it's always forward.
10949
*
10950
* IE text differs from modern selection in that it behaves as though
10951
* block elements end with a new line. This means character offsets will
10952
* differ between the two APIs.
10953
*
10954
* @param {DOMElement} node
10955
* @return {object}
10956
*/
10957
function getIEOffsets(node) {
10958
var selection = document.selection;
10959
var selectedRange = selection.createRange();
10960
var selectedLength = selectedRange.text.length;
10961
10962
// Duplicate selection so we can move range without breaking user selection.
10963
var fromStart = selectedRange.duplicate();
10964
fromStart.moveToElementText(node);
10965
fromStart.setEndPoint('EndToStart', selectedRange);
10966
10967
var startOffset = fromStart.text.length;
10968
var endOffset = startOffset + selectedLength;
10969
10970
return {
10971
start: startOffset,
10972
end: endOffset
10973
};
10974
}
10975
10976
/**
10977
* @param {DOMElement} node
10978
* @return {?object}
10979
*/
10980
function getModernOffsets(node) {
10981
var selection = window.getSelection && window.getSelection();
10982
10983
if (!selection || selection.rangeCount === 0) {
10984
return null;
10985
}
10986
10987
var anchorNode = selection.anchorNode;
10988
var anchorOffset = selection.anchorOffset;
10989
var focusNode = selection.focusNode;
10990
var focusOffset = selection.focusOffset;
10991
10992
var currentRange = selection.getRangeAt(0);
10993
10994
// If the node and offset values are the same, the selection is collapsed.
10995
// `Selection.isCollapsed` is available natively, but IE sometimes gets
10996
// this value wrong.
10997
var isSelectionCollapsed = isCollapsed(
10998
selection.anchorNode,
10999
selection.anchorOffset,
11000
selection.focusNode,
11001
selection.focusOffset
11002
);
11003
11004
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
11005
11006
var tempRange = currentRange.cloneRange();
11007
tempRange.selectNodeContents(node);
11008
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
11009
11010
var isTempRangeCollapsed = isCollapsed(
11011
tempRange.startContainer,
11012
tempRange.startOffset,
11013
tempRange.endContainer,
11014
tempRange.endOffset
11015
);
11016
11017
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
11018
var end = start + rangeLength;
11019
11020
// Detect whether the selection is backward.
11021
var detectionRange = document.createRange();
11022
detectionRange.setStart(anchorNode, anchorOffset);
11023
detectionRange.setEnd(focusNode, focusOffset);
11024
var isBackward = detectionRange.collapsed;
11025
11026
return {
11027
start: isBackward ? end : start,
11028
end: isBackward ? start : end
11029
};
11030
}
11031
11032
/**
11033
* @param {DOMElement|DOMTextNode} node
11034
* @param {object} offsets
11035
*/
11036
function setIEOffsets(node, offsets) {
11037
var range = document.selection.createRange().duplicate();
11038
var start, end;
11039
11040
if (typeof offsets.end === 'undefined') {
11041
start = offsets.start;
11042
end = start;
11043
} else if (offsets.start > offsets.end) {
11044
start = offsets.end;
11045
end = offsets.start;
11046
} else {
11047
start = offsets.start;
11048
end = offsets.end;
11049
}
11050
11051
range.moveToElementText(node);
11052
range.moveStart('character', start);
11053
range.setEndPoint('EndToStart', range);
11054
range.moveEnd('character', end - start);
11055
range.select();
11056
}
11057
11058
/**
11059
* In modern non-IE browsers, we can support both forward and backward
11060
* selections.
11061
*
11062
* Note: IE10+ supports the Selection object, but it does not support
11063
* the `extend` method, which means that even in modern IE, it's not possible
11064
* to programatically create a backward selection. Thus, for all IE
11065
* versions, we use the old IE API to create our selections.
11066
*
11067
* @param {DOMElement|DOMTextNode} node
11068
* @param {object} offsets
11069
*/
11070
function setModernOffsets(node, offsets) {
11071
if (!window.getSelection) {
11072
return;
11073
}
11074
11075
var selection = window.getSelection();
11076
var length = node[getTextContentAccessor()].length;
11077
var start = Math.min(offsets.start, length);
11078
var end = typeof offsets.end === 'undefined' ?
11079
start : Math.min(offsets.end, length);
11080
11081
// IE 11 uses modern selection, but doesn't support the extend method.
11082
// Flip backward selections, so we can set with a single range.
11083
if (!selection.extend && start > end) {
11084
var temp = end;
11085
end = start;
11086
start = temp;
11087
}
11088
11089
var startMarker = getNodeForCharacterOffset(node, start);
11090
var endMarker = getNodeForCharacterOffset(node, end);
11091
11092
if (startMarker && endMarker) {
11093
var range = document.createRange();
11094
range.setStart(startMarker.node, startMarker.offset);
11095
selection.removeAllRanges();
11096
11097
if (start > end) {
11098
selection.addRange(range);
11099
selection.extend(endMarker.node, endMarker.offset);
11100
} else {
11101
range.setEnd(endMarker.node, endMarker.offset);
11102
selection.addRange(range);
11103
}
11104
}
11105
}
11106
11107
var useIEOffsets = (
11108
ExecutionEnvironment.canUseDOM &&
11109
'selection' in document &&
11110
!('getSelection' in window)
11111
);
11112
11113
var ReactDOMSelection = {
11114
/**
11115
* @param {DOMElement} node
11116
*/
11117
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
11118
11119
/**
11120
* @param {DOMElement|DOMTextNode} node
11121
* @param {object} offsets
11122
*/
11123
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
11124
};
11125
11126
module.exports = ReactDOMSelection;
11127
11128
},{"./ExecutionEnvironment":35,"./getNodeForCharacterOffset":157,"./getTextContentAccessor":159}],70:[function(require,module,exports){
11129
/**
11130
* Copyright 2013-2015, Facebook, Inc.
11131
* All rights reserved.
11132
*
11133
* This source code is licensed under the BSD-style license found in the
11134
* LICENSE file in the root directory of this source tree. An additional grant
11135
* of patent rights can be found in the PATENTS file in the same directory.
11136
*
11137
* @providesModule ReactDOMTextComponent
11138
* @typechecks static-only
11139
*/
11140
11141
'use strict';
11142
11143
var DOMPropertyOperations = require("./DOMPropertyOperations");
11144
var ReactComponentBrowserEnvironment =
11145
require("./ReactComponentBrowserEnvironment");
11146
var ReactDOMComponent = require("./ReactDOMComponent");
11147
11148
var assign = require("./Object.assign");
11149
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
11150
11151
/**
11152
* Text nodes violate a couple assumptions that React makes about components:
11153
*
11154
* - When mounting text into the DOM, adjacent text nodes are merged.
11155
* - Text nodes cannot be assigned a React root ID.
11156
*
11157
* This component is used to wrap strings in elements so that they can undergo
11158
* the same reconciliation that is applied to elements.
11159
*
11160
* TODO: Investigate representing React components in the DOM with text nodes.
11161
*
11162
* @class ReactDOMTextComponent
11163
* @extends ReactComponent
11164
* @internal
11165
*/
11166
var ReactDOMTextComponent = function(props) {
11167
// This constructor and its argument is currently used by mocks.
11168
};
11169
11170
assign(ReactDOMTextComponent.prototype, {
11171
11172
/**
11173
* @param {ReactText} text
11174
* @internal
11175
*/
11176
construct: function(text) {
11177
// TODO: This is really a ReactText (ReactNode), not a ReactElement
11178
this._currentElement = text;
11179
this._stringText = '' + text;
11180
11181
// Properties
11182
this._rootNodeID = null;
11183
this._mountIndex = 0;
11184
},
11185
11186
/**
11187
* Creates the markup for this text node. This node is not intended to have
11188
* any features besides containing text content.
11189
*
11190
* @param {string} rootID DOM ID of the root node.
11191
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
11192
* @return {string} Markup for this text node.
11193
* @internal
11194
*/
11195
mountComponent: function(rootID, transaction, context) {
11196
this._rootNodeID = rootID;
11197
var escapedText = escapeTextContentForBrowser(this._stringText);
11198
11199
if (transaction.renderToStaticMarkup) {
11200
// Normally we'd wrap this in a `span` for the reasons stated above, but
11201
// since this is a situation where React won't take over (static pages),
11202
// we can simply return the text as it is.
11203
return escapedText;
11204
}
11205
11206
return (
11207
'<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
11208
escapedText +
11209
'</span>'
11210
);
11211
},
11212
11213
/**
11214
* Updates this component by updating the text content.
11215
*
11216
* @param {ReactText} nextText The next text content
11217
* @param {ReactReconcileTransaction} transaction
11218
* @internal
11219
*/
11220
receiveComponent: function(nextText, transaction) {
11221
if (nextText !== this._currentElement) {
11222
this._currentElement = nextText;
11223
var nextStringText = '' + nextText;
11224
if (nextStringText !== this._stringText) {
11225
// TODO: Save this as pending props and use performUpdateIfNecessary
11226
// and/or updateComponent to do the actual update for consistency with
11227
// other component types?
11228
this._stringText = nextStringText;
11229
ReactDOMComponent.BackendIDOperations.updateTextContentByID(
11230
this._rootNodeID,
11231
nextStringText
11232
);
11233
}
11234
}
11235
},
11236
11237
unmountComponent: function() {
11238
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
11239
}
11240
11241
});
11242
11243
module.exports = ReactDOMTextComponent;
11244
11245
},{"./DOMPropertyOperations":25,"./Object.assign":42,"./ReactComponentBrowserEnvironment":53,"./ReactDOMComponent":61,"./escapeTextContentForBrowser":145}],71:[function(require,module,exports){
11246
(function (process){
11247
/**
11248
* Copyright 2013-2015, Facebook, Inc.
11249
* All rights reserved.
11250
*
11251
* This source code is licensed under the BSD-style license found in the
11252
* LICENSE file in the root directory of this source tree. An additional grant
11253
* of patent rights can be found in the PATENTS file in the same directory.
11254
*
11255
* @providesModule ReactDOMTextarea
11256
*/
11257
11258
'use strict';
11259
11260
var AutoFocusMixin = require("./AutoFocusMixin");
11261
var DOMPropertyOperations = require("./DOMPropertyOperations");
11262
var LinkedValueUtils = require("./LinkedValueUtils");
11263
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
11264
var ReactClass = require("./ReactClass");
11265
var ReactElement = require("./ReactElement");
11266
var ReactUpdates = require("./ReactUpdates");
11267
11268
var assign = require("./Object.assign");
11269
var invariant = require("./invariant");
11270
11271
var warning = require("./warning");
11272
11273
var textarea = ReactElement.createFactory('textarea');
11274
11275
function forceUpdateIfMounted() {
11276
/*jshint validthis:true */
11277
if (this.isMounted()) {
11278
this.forceUpdate();
11279
}
11280
}
11281
11282
/**
11283
* Implements a <textarea> native component that allows setting `value`, and
11284
* `defaultValue`. This differs from the traditional DOM API because value is
11285
* usually set as PCDATA children.
11286
*
11287
* If `value` is not supplied (or null/undefined), user actions that affect the
11288
* value will trigger updates to the element.
11289
*
11290
* If `value` is supplied (and not null/undefined), the rendered element will
11291
* not trigger updates to the element. Instead, the `value` prop must change in
11292
* order for the rendered element to be updated.
11293
*
11294
* The rendered element will be initialized with an empty value, the prop
11295
* `defaultValue` if specified, or the children content (deprecated).
11296
*/
11297
var ReactDOMTextarea = ReactClass.createClass({
11298
displayName: 'ReactDOMTextarea',
11299
tagName: 'TEXTAREA',
11300
11301
mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
11302
11303
getInitialState: function() {
11304
var defaultValue = this.props.defaultValue;
11305
// TODO (yungsters): Remove support for children content in <textarea>.
11306
var children = this.props.children;
11307
if (children != null) {
11308
if ("production" !== process.env.NODE_ENV) {
11309
("production" !== process.env.NODE_ENV ? warning(
11310
false,
11311
'Use the `defaultValue` or `value` props instead of setting ' +
11312
'children on <textarea>.'
11313
) : null);
11314
}
11315
("production" !== process.env.NODE_ENV ? invariant(
11316
defaultValue == null,
11317
'If you supply `defaultValue` on a <textarea>, do not pass children.'
11318
) : invariant(defaultValue == null));
11319
if (Array.isArray(children)) {
11320
("production" !== process.env.NODE_ENV ? invariant(
11321
children.length <= 1,
11322
'<textarea> can only have at most one child.'
11323
) : invariant(children.length <= 1));
11324
children = children[0];
11325
}
11326
11327
defaultValue = '' + children;
11328
}
11329
if (defaultValue == null) {
11330
defaultValue = '';
11331
}
11332
var value = LinkedValueUtils.getValue(this);
11333
return {
11334
// We save the initial value so that `ReactDOMComponent` doesn't update
11335
// `textContent` (unnecessary since we update value).
11336
// The initial value can be a boolean or object so that's why it's
11337
// forced to be a string.
11338
initialValue: '' + (value != null ? value : defaultValue)
11339
};
11340
},
11341
11342
render: function() {
11343
// Clone `this.props` so we don't mutate the input.
11344
var props = assign({}, this.props);
11345
11346
("production" !== process.env.NODE_ENV ? invariant(
11347
props.dangerouslySetInnerHTML == null,
11348
'`dangerouslySetInnerHTML` does not make sense on <textarea>.'
11349
) : invariant(props.dangerouslySetInnerHTML == null));
11350
11351
props.defaultValue = null;
11352
props.value = null;
11353
props.onChange = this._handleChange;
11354
11355
// Always set children to the same thing. In IE9, the selection range will
11356
// get reset if `textContent` is mutated.
11357
return textarea(props, this.state.initialValue);
11358
},
11359
11360
componentDidUpdate: function(prevProps, prevState, prevContext) {
11361
var value = LinkedValueUtils.getValue(this);
11362
if (value != null) {
11363
var rootNode = this.getDOMNode();
11364
// Cast `value` to a string to ensure the value is set correctly. While
11365
// browsers typically do this as necessary, jsdom doesn't.
11366
DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
11367
}
11368
},
11369
11370
_handleChange: function(event) {
11371
var returnValue;
11372
var onChange = LinkedValueUtils.getOnChange(this);
11373
if (onChange) {
11374
returnValue = onChange.call(this, event);
11375
}
11376
ReactUpdates.asap(forceUpdateIfMounted, this);
11377
return returnValue;
11378
}
11379
11380
});
11381
11382
module.exports = ReactDOMTextarea;
11383
11384
}).call(this,require('_process'))
11385
},{"./AutoFocusMixin":15,"./DOMPropertyOperations":25,"./LinkedValueUtils":39,"./Object.assign":42,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactElement":76,"./ReactUpdates":113,"./invariant":164,"./warning":185,"_process":1}],72:[function(require,module,exports){
11386
/**
11387
* Copyright 2013-2015, Facebook, Inc.
11388
* All rights reserved.
11389
*
11390
* This source code is licensed under the BSD-style license found in the
11391
* LICENSE file in the root directory of this source tree. An additional grant
11392
* of patent rights can be found in the PATENTS file in the same directory.
11393
*
11394
* @providesModule ReactDefaultBatchingStrategy
11395
*/
11396
11397
'use strict';
11398
11399
var ReactUpdates = require("./ReactUpdates");
11400
var Transaction = require("./Transaction");
11401
11402
var assign = require("./Object.assign");
11403
var emptyFunction = require("./emptyFunction");
11404
11405
var RESET_BATCHED_UPDATES = {
11406
initialize: emptyFunction,
11407
close: function() {
11408
ReactDefaultBatchingStrategy.isBatchingUpdates = false;
11409
}
11410
};
11411
11412
var FLUSH_BATCHED_UPDATES = {
11413
initialize: emptyFunction,
11414
close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
11415
};
11416
11417
var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
11418
11419
function ReactDefaultBatchingStrategyTransaction() {
11420
this.reinitializeTransaction();
11421
}
11422
11423
assign(
11424
ReactDefaultBatchingStrategyTransaction.prototype,
11425
Transaction.Mixin,
11426
{
11427
getTransactionWrappers: function() {
11428
return TRANSACTION_WRAPPERS;
11429
}
11430
}
11431
);
11432
11433
var transaction = new ReactDefaultBatchingStrategyTransaction();
11434
11435
var ReactDefaultBatchingStrategy = {
11436
isBatchingUpdates: false,
11437
11438
/**
11439
* Call the provided function in a context within which calls to `setState`
11440
* and friends are batched such that components aren't updated unnecessarily.
11441
*/
11442
batchedUpdates: function(callback, a, b, c, d) {
11443
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
11444
11445
ReactDefaultBatchingStrategy.isBatchingUpdates = true;
11446
11447
// The code is written this way to avoid extra allocations
11448
if (alreadyBatchingUpdates) {
11449
callback(a, b, c, d);
11450
} else {
11451
transaction.perform(callback, null, a, b, c, d);
11452
}
11453
}
11454
};
11455
11456
module.exports = ReactDefaultBatchingStrategy;
11457
11458
},{"./Object.assign":42,"./ReactUpdates":113,"./Transaction":130,"./emptyFunction":143}],73:[function(require,module,exports){
11459
(function (process){
11460
/**
11461
* Copyright 2013-2015, Facebook, Inc.
11462
* All rights reserved.
11463
*
11464
* This source code is licensed under the BSD-style license found in the
11465
* LICENSE file in the root directory of this source tree. An additional grant
11466
* of patent rights can be found in the PATENTS file in the same directory.
11467
*
11468
* @providesModule ReactDefaultInjection
11469
*/
11470
11471
'use strict';
11472
11473
var BeforeInputEventPlugin = require("./BeforeInputEventPlugin");
11474
var ChangeEventPlugin = require("./ChangeEventPlugin");
11475
var ClientReactRootIndex = require("./ClientReactRootIndex");
11476
var DefaultEventPluginOrder = require("./DefaultEventPluginOrder");
11477
var EnterLeaveEventPlugin = require("./EnterLeaveEventPlugin");
11478
var ExecutionEnvironment = require("./ExecutionEnvironment");
11479
var HTMLDOMPropertyConfig = require("./HTMLDOMPropertyConfig");
11480
var MobileSafariClickEventPlugin = require("./MobileSafariClickEventPlugin");
11481
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
11482
var ReactClass = require("./ReactClass");
11483
var ReactComponentBrowserEnvironment =
11484
require("./ReactComponentBrowserEnvironment");
11485
var ReactDefaultBatchingStrategy = require("./ReactDefaultBatchingStrategy");
11486
var ReactDOMComponent = require("./ReactDOMComponent");
11487
var ReactDOMButton = require("./ReactDOMButton");
11488
var ReactDOMForm = require("./ReactDOMForm");
11489
var ReactDOMImg = require("./ReactDOMImg");
11490
var ReactDOMIDOperations = require("./ReactDOMIDOperations");
11491
var ReactDOMIframe = require("./ReactDOMIframe");
11492
var ReactDOMInput = require("./ReactDOMInput");
11493
var ReactDOMOption = require("./ReactDOMOption");
11494
var ReactDOMSelect = require("./ReactDOMSelect");
11495
var ReactDOMTextarea = require("./ReactDOMTextarea");
11496
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
11497
var ReactElement = require("./ReactElement");
11498
var ReactEventListener = require("./ReactEventListener");
11499
var ReactInjection = require("./ReactInjection");
11500
var ReactInstanceHandles = require("./ReactInstanceHandles");
11501
var ReactMount = require("./ReactMount");
11502
var ReactReconcileTransaction = require("./ReactReconcileTransaction");
11503
var SelectEventPlugin = require("./SelectEventPlugin");
11504
var ServerReactRootIndex = require("./ServerReactRootIndex");
11505
var SimpleEventPlugin = require("./SimpleEventPlugin");
11506
var SVGDOMPropertyConfig = require("./SVGDOMPropertyConfig");
11507
11508
var createFullPageComponent = require("./createFullPageComponent");
11509
11510
function autoGenerateWrapperClass(type) {
11511
return ReactClass.createClass({
11512
tagName: type.toUpperCase(),
11513
render: function() {
11514
return new ReactElement(
11515
type,
11516
null,
11517
null,
11518
null,
11519
null,
11520
this.props
11521
);
11522
}
11523
});
11524
}
11525
11526
function inject() {
11527
ReactInjection.EventEmitter.injectReactEventListener(
11528
ReactEventListener
11529
);
11530
11531
/**
11532
* Inject modules for resolving DOM hierarchy and plugin ordering.
11533
*/
11534
ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
11535
ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
11536
ReactInjection.EventPluginHub.injectMount(ReactMount);
11537
11538
/**
11539
* Some important event plugins included by default (without having to require
11540
* them).
11541
*/
11542
ReactInjection.EventPluginHub.injectEventPluginsByName({
11543
SimpleEventPlugin: SimpleEventPlugin,
11544
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
11545
ChangeEventPlugin: ChangeEventPlugin,
11546
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
11547
SelectEventPlugin: SelectEventPlugin,
11548
BeforeInputEventPlugin: BeforeInputEventPlugin
11549
});
11550
11551
ReactInjection.NativeComponent.injectGenericComponentClass(
11552
ReactDOMComponent
11553
);
11554
11555
ReactInjection.NativeComponent.injectTextComponentClass(
11556
ReactDOMTextComponent
11557
);
11558
11559
ReactInjection.NativeComponent.injectAutoWrapper(
11560
autoGenerateWrapperClass
11561
);
11562
11563
// This needs to happen before createFullPageComponent() otherwise the mixin
11564
// won't be included.
11565
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
11566
11567
ReactInjection.NativeComponent.injectComponentClasses({
11568
'button': ReactDOMButton,
11569
'form': ReactDOMForm,
11570
'iframe': ReactDOMIframe,
11571
'img': ReactDOMImg,
11572
'input': ReactDOMInput,
11573
'option': ReactDOMOption,
11574
'select': ReactDOMSelect,
11575
'textarea': ReactDOMTextarea,
11576
11577
'html': createFullPageComponent('html'),
11578
'head': createFullPageComponent('head'),
11579
'body': createFullPageComponent('body')
11580
});
11581
11582
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
11583
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
11584
11585
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
11586
11587
ReactInjection.Updates.injectReconcileTransaction(
11588
ReactReconcileTransaction
11589
);
11590
ReactInjection.Updates.injectBatchingStrategy(
11591
ReactDefaultBatchingStrategy
11592
);
11593
11594
ReactInjection.RootIndex.injectCreateReactRootIndex(
11595
ExecutionEnvironment.canUseDOM ?
11596
ClientReactRootIndex.createReactRootIndex :
11597
ServerReactRootIndex.createReactRootIndex
11598
);
11599
11600
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
11601
ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
11602
11603
if ("production" !== process.env.NODE_ENV) {
11604
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
11605
if ((/[?&]react_perf\b/).test(url)) {
11606
var ReactDefaultPerf = require("./ReactDefaultPerf");
11607
ReactDefaultPerf.start();
11608
}
11609
}
11610
}
11611
11612
module.exports = {
11613
inject: inject
11614
};
11615
11616
}).call(this,require('_process'))
11617
},{"./BeforeInputEventPlugin":16,"./ChangeEventPlugin":21,"./ClientReactRootIndex":22,"./DefaultEventPluginOrder":27,"./EnterLeaveEventPlugin":28,"./ExecutionEnvironment":35,"./HTMLDOMPropertyConfig":37,"./MobileSafariClickEventPlugin":41,"./ReactBrowserComponentMixin":45,"./ReactClass":51,"./ReactComponentBrowserEnvironment":53,"./ReactDOMButton":60,"./ReactDOMComponent":61,"./ReactDOMForm":62,"./ReactDOMIDOperations":63,"./ReactDOMIframe":64,"./ReactDOMImg":65,"./ReactDOMInput":66,"./ReactDOMOption":67,"./ReactDOMSelect":68,"./ReactDOMTextComponent":70,"./ReactDOMTextarea":71,"./ReactDefaultBatchingStrategy":72,"./ReactDefaultPerf":74,"./ReactElement":76,"./ReactEventListener":81,"./ReactInjection":83,"./ReactInstanceHandles":85,"./ReactMount":90,"./ReactReconcileTransaction":101,"./SVGDOMPropertyConfig":115,"./SelectEventPlugin":116,"./ServerReactRootIndex":117,"./SimpleEventPlugin":118,"./createFullPageComponent":139,"_process":1}],74:[function(require,module,exports){
11618
/**
11619
* Copyright 2013-2015, Facebook, Inc.
11620
* All rights reserved.
11621
*
11622
* This source code is licensed under the BSD-style license found in the
11623
* LICENSE file in the root directory of this source tree. An additional grant
11624
* of patent rights can be found in the PATENTS file in the same directory.
11625
*
11626
* @providesModule ReactDefaultPerf
11627
* @typechecks static-only
11628
*/
11629
11630
'use strict';
11631
11632
var DOMProperty = require("./DOMProperty");
11633
var ReactDefaultPerfAnalysis = require("./ReactDefaultPerfAnalysis");
11634
var ReactMount = require("./ReactMount");
11635
var ReactPerf = require("./ReactPerf");
11636
11637
var performanceNow = require("./performanceNow");
11638
11639
function roundFloat(val) {
11640
return Math.floor(val * 100) / 100;
11641
}
11642
11643
function addValue(obj, key, val) {
11644
obj[key] = (obj[key] || 0) + val;
11645
}
11646
11647
var ReactDefaultPerf = {
11648
_allMeasurements: [], // last item in the list is the current one
11649
_mountStack: [0],
11650
_injected: false,
11651
11652
start: function() {
11653
if (!ReactDefaultPerf._injected) {
11654
ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
11655
}
11656
11657
ReactDefaultPerf._allMeasurements.length = 0;
11658
ReactPerf.enableMeasure = true;
11659
},
11660
11661
stop: function() {
11662
ReactPerf.enableMeasure = false;
11663
},
11664
11665
getLastMeasurements: function() {
11666
return ReactDefaultPerf._allMeasurements;
11667
},
11668
11669
printExclusive: function(measurements) {
11670
measurements = measurements || ReactDefaultPerf._allMeasurements;
11671
var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
11672
console.table(summary.map(function(item) {
11673
return {
11674
'Component class name': item.componentName,
11675
'Total inclusive time (ms)': roundFloat(item.inclusive),
11676
'Exclusive mount time (ms)': roundFloat(item.exclusive),
11677
'Exclusive render time (ms)': roundFloat(item.render),
11678
'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
11679
'Render time per instance (ms)': roundFloat(item.render / item.count),
11680
'Instances': item.count
11681
};
11682
}));
11683
// TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
11684
// number.
11685
},
11686
11687
printInclusive: function(measurements) {
11688
measurements = measurements || ReactDefaultPerf._allMeasurements;
11689
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
11690
console.table(summary.map(function(item) {
11691
return {
11692
'Owner > component': item.componentName,
11693
'Inclusive time (ms)': roundFloat(item.time),
11694
'Instances': item.count
11695
};
11696
}));
11697
console.log(
11698
'Total time:',
11699
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
11700
);
11701
},
11702
11703
getMeasurementsSummaryMap: function(measurements) {
11704
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
11705
measurements,
11706
true
11707
);
11708
return summary.map(function(item) {
11709
return {
11710
'Owner > component': item.componentName,
11711
'Wasted time (ms)': item.time,
11712
'Instances': item.count
11713
};
11714
});
11715
},
11716
11717
printWasted: function(measurements) {
11718
measurements = measurements || ReactDefaultPerf._allMeasurements;
11719
console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
11720
console.log(
11721
'Total time:',
11722
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
11723
);
11724
},
11725
11726
printDOM: function(measurements) {
11727
measurements = measurements || ReactDefaultPerf._allMeasurements;
11728
var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
11729
console.table(summary.map(function(item) {
11730
var result = {};
11731
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
11732
result['type'] = item.type;
11733
result['args'] = JSON.stringify(item.args);
11734
return result;
11735
}));
11736
console.log(
11737
'Total time:',
11738
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
11739
);
11740
},
11741
11742
_recordWrite: function(id, fnName, totalTime, args) {
11743
// TODO: totalTime isn't that useful since it doesn't count paints/reflows
11744
var writes =
11745
ReactDefaultPerf
11746
._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1]
11747
.writes;
11748
writes[id] = writes[id] || [];
11749
writes[id].push({
11750
type: fnName,
11751
time: totalTime,
11752
args: args
11753
});
11754
},
11755
11756
measure: function(moduleName, fnName, func) {
11757
return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
11758
var totalTime;
11759
var rv;
11760
var start;
11761
11762
if (fnName === '_renderNewRootComponent' ||
11763
fnName === 'flushBatchedUpdates') {
11764
// A "measurement" is a set of metrics recorded for each flush. We want
11765
// to group the metrics for a given flush together so we can look at the
11766
// components that rendered and the DOM operations that actually
11767
// happened to determine the amount of "wasted work" performed.
11768
ReactDefaultPerf._allMeasurements.push({
11769
exclusive: {},
11770
inclusive: {},
11771
render: {},
11772
counts: {},
11773
writes: {},
11774
displayNames: {},
11775
totalTime: 0
11776
});
11777
start = performanceNow();
11778
rv = func.apply(this, args);
11779
ReactDefaultPerf._allMeasurements[
11780
ReactDefaultPerf._allMeasurements.length - 1
11781
].totalTime = performanceNow() - start;
11782
return rv;
11783
} else if (fnName === '_mountImageIntoNode' ||
11784
moduleName === 'ReactDOMIDOperations') {
11785
start = performanceNow();
11786
rv = func.apply(this, args);
11787
totalTime = performanceNow() - start;
11788
11789
if (fnName === '_mountImageIntoNode') {
11790
var mountID = ReactMount.getID(args[1]);
11791
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
11792
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
11793
// special format
11794
args[0].forEach(function(update) {
11795
var writeArgs = {};
11796
if (update.fromIndex !== null) {
11797
writeArgs.fromIndex = update.fromIndex;
11798
}
11799
if (update.toIndex !== null) {
11800
writeArgs.toIndex = update.toIndex;
11801
}
11802
if (update.textContent !== null) {
11803
writeArgs.textContent = update.textContent;
11804
}
11805
if (update.markupIndex !== null) {
11806
writeArgs.markup = args[1][update.markupIndex];
11807
}
11808
ReactDefaultPerf._recordWrite(
11809
update.parentID,
11810
update.type,
11811
totalTime,
11812
writeArgs
11813
);
11814
});
11815
} else {
11816
// basic format
11817
ReactDefaultPerf._recordWrite(
11818
args[0],
11819
fnName,
11820
totalTime,
11821
Array.prototype.slice.call(args, 1)
11822
);
11823
}
11824
return rv;
11825
} else if (moduleName === 'ReactCompositeComponent' && (
11826
(// TODO: receiveComponent()?
11827
(fnName === 'mountComponent' ||
11828
fnName === 'updateComponent' || fnName === '_renderValidatedComponent')))) {
11829
11830
if (typeof this._currentElement.type === 'string') {
11831
return func.apply(this, args);
11832
}
11833
11834
var rootNodeID = fnName === 'mountComponent' ?
11835
args[0] :
11836
this._rootNodeID;
11837
var isRender = fnName === '_renderValidatedComponent';
11838
var isMount = fnName === 'mountComponent';
11839
11840
var mountStack = ReactDefaultPerf._mountStack;
11841
var entry = ReactDefaultPerf._allMeasurements[
11842
ReactDefaultPerf._allMeasurements.length - 1
11843
];
11844
11845
if (isRender) {
11846
addValue(entry.counts, rootNodeID, 1);
11847
} else if (isMount) {
11848
mountStack.push(0);
11849
}
11850
11851
start = performanceNow();
11852
rv = func.apply(this, args);
11853
totalTime = performanceNow() - start;
11854
11855
if (isRender) {
11856
addValue(entry.render, rootNodeID, totalTime);
11857
} else if (isMount) {
11858
var subMountTime = mountStack.pop();
11859
mountStack[mountStack.length - 1] += totalTime;
11860
addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
11861
addValue(entry.inclusive, rootNodeID, totalTime);
11862
} else {
11863
addValue(entry.inclusive, rootNodeID, totalTime);
11864
}
11865
11866
entry.displayNames[rootNodeID] = {
11867
current: this.getName(),
11868
owner: this._currentElement._owner ?
11869
this._currentElement._owner.getName() :
11870
'<root>'
11871
};
11872
11873
return rv;
11874
} else {
11875
return func.apply(this, args);
11876
}
11877
};
11878
}
11879
};
11880
11881
module.exports = ReactDefaultPerf;
11882
11883
},{"./DOMProperty":24,"./ReactDefaultPerfAnalysis":75,"./ReactMount":90,"./ReactPerf":95,"./performanceNow":176}],75:[function(require,module,exports){
11884
/**
11885
* Copyright 2013-2015, Facebook, Inc.
11886
* All rights reserved.
11887
*
11888
* This source code is licensed under the BSD-style license found in the
11889
* LICENSE file in the root directory of this source tree. An additional grant
11890
* of patent rights can be found in the PATENTS file in the same directory.
11891
*
11892
* @providesModule ReactDefaultPerfAnalysis
11893
*/
11894
11895
var assign = require("./Object.assign");
11896
11897
// Don't try to save users less than 1.2ms (a number I made up)
11898
var DONT_CARE_THRESHOLD = 1.2;
11899
var DOM_OPERATION_TYPES = {
11900
'_mountImageIntoNode': 'set innerHTML',
11901
INSERT_MARKUP: 'set innerHTML',
11902
MOVE_EXISTING: 'move',
11903
REMOVE_NODE: 'remove',
11904
TEXT_CONTENT: 'set textContent',
11905
'updatePropertyByID': 'update attribute',
11906
'deletePropertyByID': 'delete attribute',
11907
'updateStylesByID': 'update styles',
11908
'updateInnerHTMLByID': 'set innerHTML',
11909
'dangerouslyReplaceNodeWithMarkupByID': 'replace'
11910
};
11911
11912
function getTotalTime(measurements) {
11913
// TODO: return number of DOM ops? could be misleading.
11914
// TODO: measure dropped frames after reconcile?
11915
// TODO: log total time of each reconcile and the top-level component
11916
// class that triggered it.
11917
var totalTime = 0;
11918
for (var i = 0; i < measurements.length; i++) {
11919
var measurement = measurements[i];
11920
totalTime += measurement.totalTime;
11921
}
11922
return totalTime;
11923
}
11924
11925
function getDOMSummary(measurements) {
11926
var items = [];
11927
for (var i = 0; i < measurements.length; i++) {
11928
var measurement = measurements[i];
11929
var id;
11930
11931
for (id in measurement.writes) {
11932
measurement.writes[id].forEach(function(write) {
11933
items.push({
11934
id: id,
11935
type: DOM_OPERATION_TYPES[write.type] || write.type,
11936
args: write.args
11937
});
11938
});
11939
}
11940
}
11941
return items;
11942
}
11943
11944
function getExclusiveSummary(measurements) {
11945
var candidates = {};
11946
var displayName;
11947
11948
for (var i = 0; i < measurements.length; i++) {
11949
var measurement = measurements[i];
11950
var allIDs = assign(
11951
{},
11952
measurement.exclusive,
11953
measurement.inclusive
11954
);
11955
11956
for (var id in allIDs) {
11957
displayName = measurement.displayNames[id].current;
11958
11959
candidates[displayName] = candidates[displayName] || {
11960
componentName: displayName,
11961
inclusive: 0,
11962
exclusive: 0,
11963
render: 0,
11964
count: 0
11965
};
11966
if (measurement.render[id]) {
11967
candidates[displayName].render += measurement.render[id];
11968
}
11969
if (measurement.exclusive[id]) {
11970
candidates[displayName].exclusive += measurement.exclusive[id];
11971
}
11972
if (measurement.inclusive[id]) {
11973
candidates[displayName].inclusive += measurement.inclusive[id];
11974
}
11975
if (measurement.counts[id]) {
11976
candidates[displayName].count += measurement.counts[id];
11977
}
11978
}
11979
}
11980
11981
// Now make a sorted array with the results.
11982
var arr = [];
11983
for (displayName in candidates) {
11984
if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
11985
arr.push(candidates[displayName]);
11986
}
11987
}
11988
11989
arr.sort(function(a, b) {
11990
return b.exclusive - a.exclusive;
11991
});
11992
11993
return arr;
11994
}
11995
11996
function getInclusiveSummary(measurements, onlyClean) {
11997
var candidates = {};
11998
var inclusiveKey;
11999
12000
for (var i = 0; i < measurements.length; i++) {
12001
var measurement = measurements[i];
12002
var allIDs = assign(
12003
{},
12004
measurement.exclusive,
12005
measurement.inclusive
12006
);
12007
var cleanComponents;
12008
12009
if (onlyClean) {
12010
cleanComponents = getUnchangedComponents(measurement);
12011
}
12012
12013
for (var id in allIDs) {
12014
if (onlyClean && !cleanComponents[id]) {
12015
continue;
12016
}
12017
12018
var displayName = measurement.displayNames[id];
12019
12020
// Inclusive time is not useful for many components without knowing where
12021
// they are instantiated. So we aggregate inclusive time with both the
12022
// owner and current displayName as the key.
12023
inclusiveKey = displayName.owner + ' > ' + displayName.current;
12024
12025
candidates[inclusiveKey] = candidates[inclusiveKey] || {
12026
componentName: inclusiveKey,
12027
time: 0,
12028
count: 0
12029
};
12030
12031
if (measurement.inclusive[id]) {
12032
candidates[inclusiveKey].time += measurement.inclusive[id];
12033
}
12034
if (measurement.counts[id]) {
12035
candidates[inclusiveKey].count += measurement.counts[id];
12036
}
12037
}
12038
}
12039
12040
// Now make a sorted array with the results.
12041
var arr = [];
12042
for (inclusiveKey in candidates) {
12043
if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
12044
arr.push(candidates[inclusiveKey]);
12045
}
12046
}
12047
12048
arr.sort(function(a, b) {
12049
return b.time - a.time;
12050
});
12051
12052
return arr;
12053
}
12054
12055
function getUnchangedComponents(measurement) {
12056
// For a given reconcile, look at which components did not actually
12057
// render anything to the DOM and return a mapping of their ID to
12058
// the amount of time it took to render the entire subtree.
12059
var cleanComponents = {};
12060
var dirtyLeafIDs = Object.keys(measurement.writes);
12061
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
12062
12063
for (var id in allIDs) {
12064
var isDirty = false;
12065
// For each component that rendered, see if a component that triggered
12066
// a DOM op is in its subtree.
12067
for (var i = 0; i < dirtyLeafIDs.length; i++) {
12068
if (dirtyLeafIDs[i].indexOf(id) === 0) {
12069
isDirty = true;
12070
break;
12071
}
12072
}
12073
if (!isDirty && measurement.counts[id] > 0) {
12074
cleanComponents[id] = true;
12075
}
12076
}
12077
return cleanComponents;
12078
}
12079
12080
var ReactDefaultPerfAnalysis = {
12081
getExclusiveSummary: getExclusiveSummary,
12082
getInclusiveSummary: getInclusiveSummary,
12083
getDOMSummary: getDOMSummary,
12084
getTotalTime: getTotalTime
12085
};
12086
12087
module.exports = ReactDefaultPerfAnalysis;
12088
12089
},{"./Object.assign":42}],76:[function(require,module,exports){
12090
(function (process){
12091
/**
12092
* Copyright 2014-2015, Facebook, Inc.
12093
* All rights reserved.
12094
*
12095
* This source code is licensed under the BSD-style license found in the
12096
* LICENSE file in the root directory of this source tree. An additional grant
12097
* of patent rights can be found in the PATENTS file in the same directory.
12098
*
12099
* @providesModule ReactElement
12100
*/
12101
12102
'use strict';
12103
12104
var ReactContext = require("./ReactContext");
12105
var ReactCurrentOwner = require("./ReactCurrentOwner");
12106
12107
var assign = require("./Object.assign");
12108
var warning = require("./warning");
12109
12110
var RESERVED_PROPS = {
12111
key: true,
12112
ref: true
12113
};
12114
12115
/**
12116
* Warn for mutations.
12117
*
12118
* @internal
12119
* @param {object} object
12120
* @param {string} key
12121
*/
12122
function defineWarningProperty(object, key) {
12123
Object.defineProperty(object, key, {
12124
12125
configurable: false,
12126
enumerable: true,
12127
12128
get: function() {
12129
if (!this._store) {
12130
return null;
12131
}
12132
return this._store[key];
12133
},
12134
12135
set: function(value) {
12136
("production" !== process.env.NODE_ENV ? warning(
12137
false,
12138
'Don\'t set the %s property of the React element. Instead, ' +
12139
'specify the correct value when initially creating the element.',
12140
key
12141
) : null);
12142
this._store[key] = value;
12143
}
12144
12145
});
12146
}
12147
12148
/**
12149
* This is updated to true if the membrane is successfully created.
12150
*/
12151
var useMutationMembrane = false;
12152
12153
/**
12154
* Warn for mutations.
12155
*
12156
* @internal
12157
* @param {object} element
12158
*/
12159
function defineMutationMembrane(prototype) {
12160
try {
12161
var pseudoFrozenProperties = {
12162
props: true
12163
};
12164
for (var key in pseudoFrozenProperties) {
12165
defineWarningProperty(prototype, key);
12166
}
12167
useMutationMembrane = true;
12168
} catch (x) {
12169
// IE will fail on defineProperty
12170
}
12171
}
12172
12173
/**
12174
* Base constructor for all React elements. This is only used to make this
12175
* work with a dynamic instanceof check. Nothing should live on this prototype.
12176
*
12177
* @param {*} type
12178
* @param {string|object} ref
12179
* @param {*} key
12180
* @param {*} props
12181
* @internal
12182
*/
12183
var ReactElement = function(type, key, ref, owner, context, props) {
12184
// Built-in properties that belong on the element
12185
this.type = type;
12186
this.key = key;
12187
this.ref = ref;
12188
12189
// Record the component responsible for creating this element.
12190
this._owner = owner;
12191
12192
// TODO: Deprecate withContext, and then the context becomes accessible
12193
// through the owner.
12194
this._context = context;
12195
12196
if ("production" !== process.env.NODE_ENV) {
12197
// The validation flag and props are currently mutative. We put them on
12198
// an external backing store so that we can freeze the whole object.
12199
// This can be replaced with a WeakMap once they are implemented in
12200
// commonly used development environments.
12201
this._store = {props: props, originalProps: assign({}, props)};
12202
12203
// To make comparing ReactElements easier for testing purposes, we make
12204
// the validation flag non-enumerable (where possible, which should
12205
// include every environment we run tests in), so the test framework
12206
// ignores it.
12207
try {
12208
Object.defineProperty(this._store, 'validated', {
12209
configurable: false,
12210
enumerable: false,
12211
writable: true
12212
});
12213
} catch (x) {
12214
}
12215
this._store.validated = false;
12216
12217
// We're not allowed to set props directly on the object so we early
12218
// return and rely on the prototype membrane to forward to the backing
12219
// store.
12220
if (useMutationMembrane) {
12221
Object.freeze(this);
12222
return;
12223
}
12224
}
12225
12226
this.props = props;
12227
};
12228
12229
// We intentionally don't expose the function on the constructor property.
12230
// ReactElement should be indistinguishable from a plain object.
12231
ReactElement.prototype = {
12232
_isReactElement: true
12233
};
12234
12235
if ("production" !== process.env.NODE_ENV) {
12236
defineMutationMembrane(ReactElement.prototype);
12237
}
12238
12239
ReactElement.createElement = function(type, config, children) {
12240
var propName;
12241
12242
// Reserved names are extracted
12243
var props = {};
12244
12245
var key = null;
12246
var ref = null;
12247
12248
if (config != null) {
12249
ref = config.ref === undefined ? null : config.ref;
12250
key = config.key === undefined ? null : '' + config.key;
12251
// Remaining properties are added to a new props object
12252
for (propName in config) {
12253
if (config.hasOwnProperty(propName) &&
12254
!RESERVED_PROPS.hasOwnProperty(propName)) {
12255
props[propName] = config[propName];
12256
}
12257
}
12258
}
12259
12260
// Children can be more than one argument, and those are transferred onto
12261
// the newly allocated props object.
12262
var childrenLength = arguments.length - 2;
12263
if (childrenLength === 1) {
12264
props.children = children;
12265
} else if (childrenLength > 1) {
12266
var childArray = Array(childrenLength);
12267
for (var i = 0; i < childrenLength; i++) {
12268
childArray[i] = arguments[i + 2];
12269
}
12270
props.children = childArray;
12271
}
12272
12273
// Resolve default props
12274
if (type && type.defaultProps) {
12275
var defaultProps = type.defaultProps;
12276
for (propName in defaultProps) {
12277
if (typeof props[propName] === 'undefined') {
12278
props[propName] = defaultProps[propName];
12279
}
12280
}
12281
}
12282
12283
return new ReactElement(
12284
type,
12285
key,
12286
ref,
12287
ReactCurrentOwner.current,
12288
ReactContext.current,
12289
props
12290
);
12291
};
12292
12293
ReactElement.createFactory = function(type) {
12294
var factory = ReactElement.createElement.bind(null, type);
12295
// Expose the type on the factory and the prototype so that it can be
12296
// easily accessed on elements. E.g. <Foo />.type === Foo.type.
12297
// This should not be named `constructor` since this may not be the function
12298
// that created the element, and it may not even be a constructor.
12299
// Legacy hook TODO: Warn if this is accessed
12300
factory.type = type;
12301
return factory;
12302
};
12303
12304
ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
12305
var newElement = new ReactElement(
12306
oldElement.type,
12307
oldElement.key,
12308
oldElement.ref,
12309
oldElement._owner,
12310
oldElement._context,
12311
newProps
12312
);
12313
12314
if ("production" !== process.env.NODE_ENV) {
12315
// If the key on the original is valid, then the clone is valid
12316
newElement._store.validated = oldElement._store.validated;
12317
}
12318
return newElement;
12319
};
12320
12321
ReactElement.cloneElement = function(element, config, children) {
12322
var propName;
12323
12324
// Original props are copied
12325
var props = assign({}, element.props);
12326
12327
// Reserved names are extracted
12328
var key = element.key;
12329
var ref = element.ref;
12330
12331
// Owner will be preserved, unless ref is overridden
12332
var owner = element._owner;
12333
12334
if (config != null) {
12335
if (config.ref !== undefined) {
12336
// Silently steal the ref from the parent.
12337
ref = config.ref;
12338
owner = ReactCurrentOwner.current;
12339
}
12340
if (config.key !== undefined) {
12341
key = '' + config.key;
12342
}
12343
// Remaining properties override existing props
12344
for (propName in config) {
12345
if (config.hasOwnProperty(propName) &&
12346
!RESERVED_PROPS.hasOwnProperty(propName)) {
12347
props[propName] = config[propName];
12348
}
12349
}
12350
}
12351
12352
// Children can be more than one argument, and those are transferred onto
12353
// the newly allocated props object.
12354
var childrenLength = arguments.length - 2;
12355
if (childrenLength === 1) {
12356
props.children = children;
12357
} else if (childrenLength > 1) {
12358
var childArray = Array(childrenLength);
12359
for (var i = 0; i < childrenLength; i++) {
12360
childArray[i] = arguments[i + 2];
12361
}
12362
props.children = childArray;
12363
}
12364
12365
return new ReactElement(
12366
element.type,
12367
key,
12368
ref,
12369
owner,
12370
element._context,
12371
props
12372
);
12373
};
12374
12375
/**
12376
* @param {?object} object
12377
* @return {boolean} True if `object` is a valid component.
12378
* @final
12379
*/
12380
ReactElement.isValidElement = function(object) {
12381
// ReactTestUtils is often used outside of beforeEach where as React is
12382
// within it. This leads to two different instances of React on the same
12383
// page. To identify a element from a different React instance we use
12384
// a flag instead of an instanceof check.
12385
var isElement = !!(object && object._isReactElement);
12386
// if (isElement && !(object instanceof ReactElement)) {
12387
// This is an indicator that you're using multiple versions of React at the
12388
// same time. This will screw with ownership and stuff. Fix it, please.
12389
// TODO: We could possibly warn here.
12390
// }
12391
return isElement;
12392
};
12393
12394
module.exports = ReactElement;
12395
12396
}).call(this,require('_process'))
12397
},{"./Object.assign":42,"./ReactContext":57,"./ReactCurrentOwner":58,"./warning":185,"_process":1}],77:[function(require,module,exports){
12398
(function (process){
12399
/**
12400
* Copyright 2014-2015, Facebook, Inc.
12401
* All rights reserved.
12402
*
12403
* This source code is licensed under the BSD-style license found in the
12404
* LICENSE file in the root directory of this source tree. An additional grant
12405
* of patent rights can be found in the PATENTS file in the same directory.
12406
*
12407
* @providesModule ReactElementValidator
12408
*/
12409
12410
/**
12411
* ReactElementValidator provides a wrapper around a element factory
12412
* which validates the props passed to the element. This is intended to be
12413
* used only in DEV and could be replaced by a static type checker for languages
12414
* that support it.
12415
*/
12416
12417
'use strict';
12418
12419
var ReactElement = require("./ReactElement");
12420
var ReactFragment = require("./ReactFragment");
12421
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
12422
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
12423
var ReactCurrentOwner = require("./ReactCurrentOwner");
12424
var ReactNativeComponent = require("./ReactNativeComponent");
12425
12426
var getIteratorFn = require("./getIteratorFn");
12427
var invariant = require("./invariant");
12428
var warning = require("./warning");
12429
12430
function getDeclarationErrorAddendum() {
12431
if (ReactCurrentOwner.current) {
12432
var name = ReactCurrentOwner.current.getName();
12433
if (name) {
12434
return ' Check the render method of `' + name + '`.';
12435
}
12436
}
12437
return '';
12438
}
12439
12440
/**
12441
* Warn if there's no key explicitly set on dynamic arrays of children or
12442
* object keys are not valid. This allows us to keep track of children between
12443
* updates.
12444
*/
12445
var ownerHasKeyUseWarning = {};
12446
12447
var loggedTypeFailures = {};
12448
12449
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
12450
12451
/**
12452
* Gets the instance's name for use in warnings.
12453
*
12454
* @internal
12455
* @return {?string} Display name or undefined
12456
*/
12457
function getName(instance) {
12458
var publicInstance = instance && instance.getPublicInstance();
12459
if (!publicInstance) {
12460
return undefined;
12461
}
12462
var constructor = publicInstance.constructor;
12463
if (!constructor) {
12464
return undefined;
12465
}
12466
return constructor.displayName || constructor.name || undefined;
12467
}
12468
12469
/**
12470
* Gets the current owner's displayName for use in warnings.
12471
*
12472
* @internal
12473
* @return {?string} Display name or undefined
12474
*/
12475
function getCurrentOwnerDisplayName() {
12476
var current = ReactCurrentOwner.current;
12477
return (
12478
current && getName(current) || undefined
12479
);
12480
}
12481
12482
/**
12483
* Warn if the element doesn't have an explicit key assigned to it.
12484
* This element is in an array. The array could grow and shrink or be
12485
* reordered. All children that haven't already been validated are required to
12486
* have a "key" property assigned to it.
12487
*
12488
* @internal
12489
* @param {ReactElement} element Element that requires a key.
12490
* @param {*} parentType element's parent's type.
12491
*/
12492
function validateExplicitKey(element, parentType) {
12493
if (element._store.validated || element.key != null) {
12494
return;
12495
}
12496
element._store.validated = true;
12497
12498
warnAndMonitorForKeyUse(
12499
'Each child in an array or iterator should have a unique "key" prop.',
12500
element,
12501
parentType
12502
);
12503
}
12504
12505
/**
12506
* Warn if the key is being defined as an object property but has an incorrect
12507
* value.
12508
*
12509
* @internal
12510
* @param {string} name Property name of the key.
12511
* @param {ReactElement} element Component that requires a key.
12512
* @param {*} parentType element's parent's type.
12513
*/
12514
function validatePropertyKey(name, element, parentType) {
12515
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
12516
return;
12517
}
12518
warnAndMonitorForKeyUse(
12519
'Child objects should have non-numeric keys so ordering is preserved.',
12520
element,
12521
parentType
12522
);
12523
}
12524
12525
/**
12526
* Shared warning and monitoring code for the key warnings.
12527
*
12528
* @internal
12529
* @param {string} message The base warning that gets output.
12530
* @param {ReactElement} element Component that requires a key.
12531
* @param {*} parentType element's parent's type.
12532
*/
12533
function warnAndMonitorForKeyUse(message, element, parentType) {
12534
var ownerName = getCurrentOwnerDisplayName();
12535
var parentName = typeof parentType === 'string' ?
12536
parentType : parentType.displayName || parentType.name;
12537
12538
var useName = ownerName || parentName;
12539
var memoizer = ownerHasKeyUseWarning[message] || (
12540
(ownerHasKeyUseWarning[message] = {})
12541
);
12542
if (memoizer.hasOwnProperty(useName)) {
12543
return;
12544
}
12545
memoizer[useName] = true;
12546
12547
var parentOrOwnerAddendum =
12548
ownerName ? (" Check the render method of " + ownerName + ".") :
12549
parentName ? (" Check the React.render call using <" + parentName + ">.") :
12550
'';
12551
12552
// Usually the current owner is the offender, but if it accepts children as a
12553
// property, it may be the creator of the child that's responsible for
12554
// assigning it a key.
12555
var childOwnerAddendum = '';
12556
if (element &&
12557
element._owner &&
12558
element._owner !== ReactCurrentOwner.current) {
12559
// Name of the component that originally created this child.
12560
var childOwnerName = getName(element._owner);
12561
12562
childOwnerAddendum = (" It was passed a child from " + childOwnerName + ".");
12563
}
12564
12565
("production" !== process.env.NODE_ENV ? warning(
12566
false,
12567
message + '%s%s See https://fb.me/react-warning-keys for more information.',
12568
parentOrOwnerAddendum,
12569
childOwnerAddendum
12570
) : null);
12571
}
12572
12573
/**
12574
* Ensure that every element either is passed in a static location, in an
12575
* array with an explicit keys property defined, or in an object literal
12576
* with valid key property.
12577
*
12578
* @internal
12579
* @param {ReactNode} node Statically passed child of any type.
12580
* @param {*} parentType node's parent's type.
12581
*/
12582
function validateChildKeys(node, parentType) {
12583
if (Array.isArray(node)) {
12584
for (var i = 0; i < node.length; i++) {
12585
var child = node[i];
12586
if (ReactElement.isValidElement(child)) {
12587
validateExplicitKey(child, parentType);
12588
}
12589
}
12590
} else if (ReactElement.isValidElement(node)) {
12591
// This element was passed in a valid location.
12592
node._store.validated = true;
12593
} else if (node) {
12594
var iteratorFn = getIteratorFn(node);
12595
// Entry iterators provide implicit keys.
12596
if (iteratorFn) {
12597
if (iteratorFn !== node.entries) {
12598
var iterator = iteratorFn.call(node);
12599
var step;
12600
while (!(step = iterator.next()).done) {
12601
if (ReactElement.isValidElement(step.value)) {
12602
validateExplicitKey(step.value, parentType);
12603
}
12604
}
12605
}
12606
} else if (typeof node === 'object') {
12607
var fragment = ReactFragment.extractIfFragment(node);
12608
for (var key in fragment) {
12609
if (fragment.hasOwnProperty(key)) {
12610
validatePropertyKey(key, fragment[key], parentType);
12611
}
12612
}
12613
}
12614
}
12615
}
12616
12617
/**
12618
* Assert that the props are valid
12619
*
12620
* @param {string} componentName Name of the component for error messages.
12621
* @param {object} propTypes Map of prop name to a ReactPropType
12622
* @param {object} props
12623
* @param {string} location e.g. "prop", "context", "child context"
12624
* @private
12625
*/
12626
function checkPropTypes(componentName, propTypes, props, location) {
12627
for (var propName in propTypes) {
12628
if (propTypes.hasOwnProperty(propName)) {
12629
var error;
12630
// Prop type validation may throw. In case they do, we don't want to
12631
// fail the render phase where it didn't fail before. So we log it.
12632
// After these have been cleaned up, we'll let them throw.
12633
try {
12634
// This is intentionally an invariant that gets caught. It's the same
12635
// behavior as without this statement except with a better message.
12636
("production" !== process.env.NODE_ENV ? invariant(
12637
typeof propTypes[propName] === 'function',
12638
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
12639
'React.PropTypes.',
12640
componentName || 'React class',
12641
ReactPropTypeLocationNames[location],
12642
propName
12643
) : invariant(typeof propTypes[propName] === 'function'));
12644
error = propTypes[propName](props, propName, componentName, location);
12645
} catch (ex) {
12646
error = ex;
12647
}
12648
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
12649
// Only monitor this failure once because there tends to be a lot of the
12650
// same error.
12651
loggedTypeFailures[error.message] = true;
12652
12653
var addendum = getDeclarationErrorAddendum(this);
12654
("production" !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null);
12655
}
12656
}
12657
}
12658
}
12659
12660
var warnedPropsMutations = {};
12661
12662
/**
12663
* Warn about mutating props when setting `propName` on `element`.
12664
*
12665
* @param {string} propName The string key within props that was set
12666
* @param {ReactElement} element
12667
*/
12668
function warnForPropsMutation(propName, element) {
12669
var type = element.type;
12670
var elementName = typeof type === 'string' ? type : type.displayName;
12671
var ownerName = element._owner ?
12672
element._owner.getPublicInstance().constructor.displayName : null;
12673
12674
var warningKey = propName + '|' + elementName + '|' + ownerName;
12675
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
12676
return;
12677
}
12678
warnedPropsMutations[warningKey] = true;
12679
12680
var elementInfo = '';
12681
if (elementName) {
12682
elementInfo = ' <' + elementName + ' />';
12683
}
12684
var ownerInfo = '';
12685
if (ownerName) {
12686
ownerInfo = ' The element was created by ' + ownerName + '.';
12687
}
12688
12689
("production" !== process.env.NODE_ENV ? warning(
12690
false,
12691
'Don\'t set .props.%s of the React component%s. Instead, specify the ' +
12692
'correct value when initially creating the element or use ' +
12693
'React.cloneElement to make a new element with updated props.%s',
12694
propName,
12695
elementInfo,
12696
ownerInfo
12697
) : null);
12698
}
12699
12700
// Inline Object.is polyfill
12701
function is(a, b) {
12702
if (a !== a) {
12703
// NaN
12704
return b !== b;
12705
}
12706
if (a === 0 && b === 0) {
12707
// +-0
12708
return 1 / a === 1 / b;
12709
}
12710
return a === b;
12711
}
12712
12713
/**
12714
* Given an element, check if its props have been mutated since element
12715
* creation (or the last call to this function). In particular, check if any
12716
* new props have been added, which we can't directly catch by defining warning
12717
* properties on the props object.
12718
*
12719
* @param {ReactElement} element
12720
*/
12721
function checkAndWarnForMutatedProps(element) {
12722
if (!element._store) {
12723
// Element was created using `new ReactElement` directly or with
12724
// `ReactElement.createElement`; skip mutation checking
12725
return;
12726
}
12727
12728
var originalProps = element._store.originalProps;
12729
var props = element.props;
12730
12731
for (var propName in props) {
12732
if (props.hasOwnProperty(propName)) {
12733
if (!originalProps.hasOwnProperty(propName) ||
12734
!is(originalProps[propName], props[propName])) {
12735
warnForPropsMutation(propName, element);
12736
12737
// Copy over the new value so that the two props objects match again
12738
originalProps[propName] = props[propName];
12739
}
12740
}
12741
}
12742
}
12743
12744
/**
12745
* Given an element, validate that its props follow the propTypes definition,
12746
* provided by the type.
12747
*
12748
* @param {ReactElement} element
12749
*/
12750
function validatePropTypes(element) {
12751
if (element.type == null) {
12752
// This has already warned. Don't throw.
12753
return;
12754
}
12755
// Extract the component class from the element. Converts string types
12756
// to a composite class which may have propTypes.
12757
// TODO: Validating a string's propTypes is not decoupled from the
12758
// rendering target which is problematic.
12759
var componentClass = ReactNativeComponent.getComponentClassForElement(
12760
element
12761
);
12762
var name = componentClass.displayName || componentClass.name;
12763
if (componentClass.propTypes) {
12764
checkPropTypes(
12765
name,
12766
componentClass.propTypes,
12767
element.props,
12768
ReactPropTypeLocations.prop
12769
);
12770
}
12771
if (typeof componentClass.getDefaultProps === 'function') {
12772
("production" !== process.env.NODE_ENV ? warning(
12773
componentClass.getDefaultProps.isReactClassApproved,
12774
'getDefaultProps is only used on classic React.createClass ' +
12775
'definitions. Use a static property named `defaultProps` instead.'
12776
) : null);
12777
}
12778
}
12779
12780
var ReactElementValidator = {
12781
12782
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
12783
12784
createElement: function(type, props, children) {
12785
// We warn in this case but don't throw. We expect the element creation to
12786
// succeed and there will likely be errors in render.
12787
("production" !== process.env.NODE_ENV ? warning(
12788
type != null,
12789
'React.createElement: type should not be null or undefined. It should ' +
12790
'be a string (for DOM elements) or a ReactClass (for composite ' +
12791
'components).'
12792
) : null);
12793
12794
var element = ReactElement.createElement.apply(this, arguments);
12795
12796
// The result can be nullish if a mock or a custom function is used.
12797
// TODO: Drop this when these are no longer allowed as the type argument.
12798
if (element == null) {
12799
return element;
12800
}
12801
12802
for (var i = 2; i < arguments.length; i++) {
12803
validateChildKeys(arguments[i], type);
12804
}
12805
12806
validatePropTypes(element);
12807
12808
return element;
12809
},
12810
12811
createFactory: function(type) {
12812
var validatedFactory = ReactElementValidator.createElement.bind(
12813
null,
12814
type
12815
);
12816
// Legacy hook TODO: Warn if this is accessed
12817
validatedFactory.type = type;
12818
12819
if ("production" !== process.env.NODE_ENV) {
12820
try {
12821
Object.defineProperty(
12822
validatedFactory,
12823
'type',
12824
{
12825
enumerable: false,
12826
get: function() {
12827
("production" !== process.env.NODE_ENV ? warning(
12828
false,
12829
'Factory.type is deprecated. Access the class directly ' +
12830
'before passing it to createFactory.'
12831
) : null);
12832
Object.defineProperty(this, 'type', {
12833
value: type
12834
});
12835
return type;
12836
}
12837
}
12838
);
12839
} catch (x) {
12840
// IE will fail on defineProperty (es5-shim/sham too)
12841
}
12842
}
12843
12844
12845
return validatedFactory;
12846
},
12847
12848
cloneElement: function(element, props, children) {
12849
var newElement = ReactElement.cloneElement.apply(this, arguments);
12850
for (var i = 2; i < arguments.length; i++) {
12851
validateChildKeys(arguments[i], newElement.type);
12852
}
12853
validatePropTypes(newElement);
12854
return newElement;
12855
}
12856
12857
};
12858
12859
module.exports = ReactElementValidator;
12860
12861
}).call(this,require('_process'))
12862
},{"./ReactCurrentOwner":58,"./ReactElement":76,"./ReactFragment":82,"./ReactNativeComponent":93,"./ReactPropTypeLocationNames":97,"./ReactPropTypeLocations":98,"./getIteratorFn":155,"./invariant":164,"./warning":185,"_process":1}],78:[function(require,module,exports){
12863
(function (process){
12864
/**
12865
* Copyright 2014-2015, Facebook, Inc.
12866
* All rights reserved.
12867
*
12868
* This source code is licensed under the BSD-style license found in the
12869
* LICENSE file in the root directory of this source tree. An additional grant
12870
* of patent rights can be found in the PATENTS file in the same directory.
12871
*
12872
* @providesModule ReactEmptyComponent
12873
*/
12874
12875
'use strict';
12876
12877
var ReactElement = require("./ReactElement");
12878
var ReactInstanceMap = require("./ReactInstanceMap");
12879
12880
var invariant = require("./invariant");
12881
12882
var component;
12883
// This registry keeps track of the React IDs of the components that rendered to
12884
// `null` (in reality a placeholder such as `noscript`)
12885
var nullComponentIDsRegistry = {};
12886
12887
var ReactEmptyComponentInjection = {
12888
injectEmptyComponent: function(emptyComponent) {
12889
component = ReactElement.createFactory(emptyComponent);
12890
}
12891
};
12892
12893
var ReactEmptyComponentType = function() {};
12894
ReactEmptyComponentType.prototype.componentDidMount = function() {
12895
var internalInstance = ReactInstanceMap.get(this);
12896
// TODO: Make sure we run these methods in the correct order, we shouldn't
12897
// need this check. We're going to assume if we're here it means we ran
12898
// componentWillUnmount already so there is no internal instance (it gets
12899
// removed as part of the unmounting process).
12900
if (!internalInstance) {
12901
return;
12902
}
12903
registerNullComponentID(internalInstance._rootNodeID);
12904
};
12905
ReactEmptyComponentType.prototype.componentWillUnmount = function() {
12906
var internalInstance = ReactInstanceMap.get(this);
12907
// TODO: Get rid of this check. See TODO in componentDidMount.
12908
if (!internalInstance) {
12909
return;
12910
}
12911
deregisterNullComponentID(internalInstance._rootNodeID);
12912
};
12913
ReactEmptyComponentType.prototype.render = function() {
12914
("production" !== process.env.NODE_ENV ? invariant(
12915
component,
12916
'Trying to return null from a render, but no null placeholder component ' +
12917
'was injected.'
12918
) : invariant(component));
12919
return component();
12920
};
12921
12922
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
12923
12924
/**
12925
* Mark the component as having rendered to null.
12926
* @param {string} id Component's `_rootNodeID`.
12927
*/
12928
function registerNullComponentID(id) {
12929
nullComponentIDsRegistry[id] = true;
12930
}
12931
12932
/**
12933
* Unmark the component as having rendered to null: it renders to something now.
12934
* @param {string} id Component's `_rootNodeID`.
12935
*/
12936
function deregisterNullComponentID(id) {
12937
delete nullComponentIDsRegistry[id];
12938
}
12939
12940
/**
12941
* @param {string} id Component's `_rootNodeID`.
12942
* @return {boolean} True if the component is rendered to null.
12943
*/
12944
function isNullComponentID(id) {
12945
return !!nullComponentIDsRegistry[id];
12946
}
12947
12948
var ReactEmptyComponent = {
12949
emptyElement: emptyElement,
12950
injection: ReactEmptyComponentInjection,
12951
isNullComponentID: isNullComponentID
12952
};
12953
12954
module.exports = ReactEmptyComponent;
12955
12956
}).call(this,require('_process'))
12957
},{"./ReactElement":76,"./ReactInstanceMap":86,"./invariant":164,"_process":1}],79:[function(require,module,exports){
12958
/**
12959
* Copyright 2013-2015, Facebook, Inc.
12960
* All rights reserved.
12961
*
12962
* This source code is licensed under the BSD-style license found in the
12963
* LICENSE file in the root directory of this source tree. An additional grant
12964
* of patent rights can be found in the PATENTS file in the same directory.
12965
*
12966
* @providesModule ReactErrorUtils
12967
* @typechecks
12968
*/
12969
12970
"use strict";
12971
12972
var ReactErrorUtils = {
12973
/**
12974
* Creates a guarded version of a function. This is supposed to make debugging
12975
* of event handlers easier. To aid debugging with the browser's debugger,
12976
* this currently simply returns the original function.
12977
*
12978
* @param {function} func Function to be executed
12979
* @param {string} name The name of the guard
12980
* @return {function}
12981
*/
12982
guard: function(func, name) {
12983
return func;
12984
}
12985
};
12986
12987
module.exports = ReactErrorUtils;
12988
12989
},{}],80:[function(require,module,exports){
12990
/**
12991
* Copyright 2013-2015, Facebook, Inc.
12992
* All rights reserved.
12993
*
12994
* This source code is licensed under the BSD-style license found in the
12995
* LICENSE file in the root directory of this source tree. An additional grant
12996
* of patent rights can be found in the PATENTS file in the same directory.
12997
*
12998
* @providesModule ReactEventEmitterMixin
12999
*/
13000
13001
'use strict';
13002
13003
var EventPluginHub = require("./EventPluginHub");
13004
13005
function runEventQueueInBatch(events) {
13006
EventPluginHub.enqueueEvents(events);
13007
EventPluginHub.processEventQueue();
13008
}
13009
13010
var ReactEventEmitterMixin = {
13011
13012
/**
13013
* Streams a fired top-level event to `EventPluginHub` where plugins have the
13014
* opportunity to create `ReactEvent`s to be dispatched.
13015
*
13016
* @param {string} topLevelType Record from `EventConstants`.
13017
* @param {object} topLevelTarget The listening component root node.
13018
* @param {string} topLevelTargetID ID of `topLevelTarget`.
13019
* @param {object} nativeEvent Native environment event.
13020
*/
13021
handleTopLevel: function(
13022
topLevelType,
13023
topLevelTarget,
13024
topLevelTargetID,
13025
nativeEvent) {
13026
var events = EventPluginHub.extractEvents(
13027
topLevelType,
13028
topLevelTarget,
13029
topLevelTargetID,
13030
nativeEvent
13031
);
13032
13033
runEventQueueInBatch(events);
13034
}
13035
};
13036
13037
module.exports = ReactEventEmitterMixin;
13038
13039
},{"./EventPluginHub":31}],81:[function(require,module,exports){
13040
/**
13041
* Copyright 2013-2015, Facebook, Inc.
13042
* All rights reserved.
13043
*
13044
* This source code is licensed under the BSD-style license found in the
13045
* LICENSE file in the root directory of this source tree. An additional grant
13046
* of patent rights can be found in the PATENTS file in the same directory.
13047
*
13048
* @providesModule ReactEventListener
13049
* @typechecks static-only
13050
*/
13051
13052
'use strict';
13053
13054
var EventListener = require("./EventListener");
13055
var ExecutionEnvironment = require("./ExecutionEnvironment");
13056
var PooledClass = require("./PooledClass");
13057
var ReactInstanceHandles = require("./ReactInstanceHandles");
13058
var ReactMount = require("./ReactMount");
13059
var ReactUpdates = require("./ReactUpdates");
13060
13061
var assign = require("./Object.assign");
13062
var getEventTarget = require("./getEventTarget");
13063
var getUnboundedScrollPosition = require("./getUnboundedScrollPosition");
13064
13065
/**
13066
* Finds the parent React component of `node`.
13067
*
13068
* @param {*} node
13069
* @return {?DOMEventTarget} Parent container, or `null` if the specified node
13070
* is not nested.
13071
*/
13072
function findParent(node) {
13073
// TODO: It may be a good idea to cache this to prevent unnecessary DOM
13074
// traversal, but caching is difficult to do correctly without using a
13075
// mutation observer to listen for all DOM changes.
13076
var nodeID = ReactMount.getID(node);
13077
var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
13078
var container = ReactMount.findReactContainerForID(rootID);
13079
var parent = ReactMount.getFirstReactDOM(container);
13080
return parent;
13081
}
13082
13083
// Used to store ancestor hierarchy in top level callback
13084
function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
13085
this.topLevelType = topLevelType;
13086
this.nativeEvent = nativeEvent;
13087
this.ancestors = [];
13088
}
13089
assign(TopLevelCallbackBookKeeping.prototype, {
13090
destructor: function() {
13091
this.topLevelType = null;
13092
this.nativeEvent = null;
13093
this.ancestors.length = 0;
13094
}
13095
});
13096
PooledClass.addPoolingTo(
13097
TopLevelCallbackBookKeeping,
13098
PooledClass.twoArgumentPooler
13099
);
13100
13101
function handleTopLevelImpl(bookKeeping) {
13102
var topLevelTarget = ReactMount.getFirstReactDOM(
13103
getEventTarget(bookKeeping.nativeEvent)
13104
) || window;
13105
13106
// Loop through the hierarchy, in case there's any nested components.
13107
// It's important that we build the array of ancestors before calling any
13108
// event handlers, because event handlers can modify the DOM, leading to
13109
// inconsistencies with ReactMount's node cache. See #1105.
13110
var ancestor = topLevelTarget;
13111
while (ancestor) {
13112
bookKeeping.ancestors.push(ancestor);
13113
ancestor = findParent(ancestor);
13114
}
13115
13116
for (var i = 0, l = bookKeeping.ancestors.length; i < l; i++) {
13117
topLevelTarget = bookKeeping.ancestors[i];
13118
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
13119
ReactEventListener._handleTopLevel(
13120
bookKeeping.topLevelType,
13121
topLevelTarget,
13122
topLevelTargetID,
13123
bookKeeping.nativeEvent
13124
);
13125
}
13126
}
13127
13128
function scrollValueMonitor(cb) {
13129
var scrollPosition = getUnboundedScrollPosition(window);
13130
cb(scrollPosition);
13131
}
13132
13133
var ReactEventListener = {
13134
_enabled: true,
13135
_handleTopLevel: null,
13136
13137
WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
13138
13139
setHandleTopLevel: function(handleTopLevel) {
13140
ReactEventListener._handleTopLevel = handleTopLevel;
13141
},
13142
13143
setEnabled: function(enabled) {
13144
ReactEventListener._enabled = !!enabled;
13145
},
13146
13147
isEnabled: function() {
13148
return ReactEventListener._enabled;
13149
},
13150
13151
13152
/**
13153
* Traps top-level events by using event bubbling.
13154
*
13155
* @param {string} topLevelType Record from `EventConstants`.
13156
* @param {string} handlerBaseName Event name (e.g. "click").
13157
* @param {object} handle Element on which to attach listener.
13158
* @return {object} An object with a remove function which will forcefully
13159
* remove the listener.
13160
* @internal
13161
*/
13162
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
13163
var element = handle;
13164
if (!element) {
13165
return null;
13166
}
13167
return EventListener.listen(
13168
element,
13169
handlerBaseName,
13170
ReactEventListener.dispatchEvent.bind(null, topLevelType)
13171
);
13172
},
13173
13174
/**
13175
* Traps a top-level event by using event capturing.
13176
*
13177
* @param {string} topLevelType Record from `EventConstants`.
13178
* @param {string} handlerBaseName Event name (e.g. "click").
13179
* @param {object} handle Element on which to attach listener.
13180
* @return {object} An object with a remove function which will forcefully
13181
* remove the listener.
13182
* @internal
13183
*/
13184
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
13185
var element = handle;
13186
if (!element) {
13187
return null;
13188
}
13189
return EventListener.capture(
13190
element,
13191
handlerBaseName,
13192
ReactEventListener.dispatchEvent.bind(null, topLevelType)
13193
);
13194
},
13195
13196
monitorScrollValue: function(refresh) {
13197
var callback = scrollValueMonitor.bind(null, refresh);
13198
EventListener.listen(window, 'scroll', callback);
13199
},
13200
13201
dispatchEvent: function(topLevelType, nativeEvent) {
13202
if (!ReactEventListener._enabled) {
13203
return;
13204
}
13205
13206
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(
13207
topLevelType,
13208
nativeEvent
13209
);
13210
try {
13211
// Event queue being processed in the same cycle allows
13212
// `preventDefault`.
13213
ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
13214
} finally {
13215
TopLevelCallbackBookKeeping.release(bookKeeping);
13216
}
13217
}
13218
};
13219
13220
module.exports = ReactEventListener;
13221
13222
},{"./EventListener":30,"./ExecutionEnvironment":35,"./Object.assign":42,"./PooledClass":43,"./ReactInstanceHandles":85,"./ReactMount":90,"./ReactUpdates":113,"./getEventTarget":154,"./getUnboundedScrollPosition":160}],82:[function(require,module,exports){
13223
(function (process){
13224
/**
13225
* Copyright 2015, Facebook, Inc.
13226
* All rights reserved.
13227
*
13228
* This source code is licensed under the BSD-style license found in the
13229
* LICENSE file in the root directory of this source tree. An additional grant
13230
* of patent rights can be found in the PATENTS file in the same directory.
13231
*
13232
* @providesModule ReactFragment
13233
*/
13234
13235
'use strict';
13236
13237
var ReactElement = require("./ReactElement");
13238
13239
var warning = require("./warning");
13240
13241
/**
13242
* We used to allow keyed objects to serve as a collection of ReactElements,
13243
* or nested sets. This allowed us a way to explicitly key a set a fragment of
13244
* components. This is now being replaced with an opaque data structure.
13245
* The upgrade path is to call React.addons.createFragment({ key: value }) to
13246
* create a keyed fragment. The resulting data structure is opaque, for now.
13247
*/
13248
13249
if ("production" !== process.env.NODE_ENV) {
13250
var fragmentKey = '_reactFragment';
13251
var didWarnKey = '_reactDidWarn';
13252
var canWarnForReactFragment = false;
13253
13254
try {
13255
// Feature test. Don't even try to issue this warning if we can't use
13256
// enumerable: false.
13257
13258
var dummy = function() {
13259
return 1;
13260
};
13261
13262
Object.defineProperty(
13263
{},
13264
fragmentKey,
13265
{enumerable: false, value: true}
13266
);
13267
13268
Object.defineProperty(
13269
{},
13270
'key',
13271
{enumerable: true, get: dummy}
13272
);
13273
13274
canWarnForReactFragment = true;
13275
} catch (x) { }
13276
13277
var proxyPropertyAccessWithWarning = function(obj, key) {
13278
Object.defineProperty(obj, key, {
13279
enumerable: true,
13280
get: function() {
13281
("production" !== process.env.NODE_ENV ? warning(
13282
this[didWarnKey],
13283
'A ReactFragment is an opaque type. Accessing any of its ' +
13284
'properties is deprecated. Pass it to one of the React.Children ' +
13285
'helpers.'
13286
) : null);
13287
this[didWarnKey] = true;
13288
return this[fragmentKey][key];
13289
},
13290
set: function(value) {
13291
("production" !== process.env.NODE_ENV ? warning(
13292
this[didWarnKey],
13293
'A ReactFragment is an immutable opaque type. Mutating its ' +
13294
'properties is deprecated.'
13295
) : null);
13296
this[didWarnKey] = true;
13297
this[fragmentKey][key] = value;
13298
}
13299
});
13300
};
13301
13302
var issuedWarnings = {};
13303
13304
var didWarnForFragment = function(fragment) {
13305
// We use the keys and the type of the value as a heuristic to dedupe the
13306
// warning to avoid spamming too much.
13307
var fragmentCacheKey = '';
13308
for (var key in fragment) {
13309
fragmentCacheKey += key + ':' + (typeof fragment[key]) + ',';
13310
}
13311
var alreadyWarnedOnce = !!issuedWarnings[fragmentCacheKey];
13312
issuedWarnings[fragmentCacheKey] = true;
13313
return alreadyWarnedOnce;
13314
};
13315
}
13316
13317
var ReactFragment = {
13318
// Wrap a keyed object in an opaque proxy that warns you if you access any
13319
// of its properties.
13320
create: function(object) {
13321
if ("production" !== process.env.NODE_ENV) {
13322
if (typeof object !== 'object' || !object || Array.isArray(object)) {
13323
("production" !== process.env.NODE_ENV ? warning(
13324
false,
13325
'React.addons.createFragment only accepts a single object.',
13326
object
13327
) : null);
13328
return object;
13329
}
13330
if (ReactElement.isValidElement(object)) {
13331
("production" !== process.env.NODE_ENV ? warning(
13332
false,
13333
'React.addons.createFragment does not accept a ReactElement ' +
13334
'without a wrapper object.'
13335
) : null);
13336
return object;
13337
}
13338
if (canWarnForReactFragment) {
13339
var proxy = {};
13340
Object.defineProperty(proxy, fragmentKey, {
13341
enumerable: false,
13342
value: object
13343
});
13344
Object.defineProperty(proxy, didWarnKey, {
13345
writable: true,
13346
enumerable: false,
13347
value: false
13348
});
13349
for (var key in object) {
13350
proxyPropertyAccessWithWarning(proxy, key);
13351
}
13352
Object.preventExtensions(proxy);
13353
return proxy;
13354
}
13355
}
13356
return object;
13357
},
13358
// Extract the original keyed object from the fragment opaque type. Warn if
13359
// a plain object is passed here.
13360
extract: function(fragment) {
13361
if ("production" !== process.env.NODE_ENV) {
13362
if (canWarnForReactFragment) {
13363
if (!fragment[fragmentKey]) {
13364
("production" !== process.env.NODE_ENV ? warning(
13365
didWarnForFragment(fragment),
13366
'Any use of a keyed object should be wrapped in ' +
13367
'React.addons.createFragment(object) before being passed as a ' +
13368
'child.'
13369
) : null);
13370
return fragment;
13371
}
13372
return fragment[fragmentKey];
13373
}
13374
}
13375
return fragment;
13376
},
13377
// Check if this is a fragment and if so, extract the keyed object. If it
13378
// is a fragment-like object, warn that it should be wrapped. Ignore if we
13379
// can't determine what kind of object this is.
13380
extractIfFragment: function(fragment) {
13381
if ("production" !== process.env.NODE_ENV) {
13382
if (canWarnForReactFragment) {
13383
// If it is the opaque type, return the keyed object.
13384
if (fragment[fragmentKey]) {
13385
return fragment[fragmentKey];
13386
}
13387
// Otherwise, check each property if it has an element, if it does
13388
// it is probably meant as a fragment, so we can warn early. Defer,
13389
// the warning to extract.
13390
for (var key in fragment) {
13391
if (fragment.hasOwnProperty(key) &&
13392
ReactElement.isValidElement(fragment[key])) {
13393
// This looks like a fragment object, we should provide an
13394
// early warning.
13395
return ReactFragment.extract(fragment);
13396
}
13397
}
13398
}
13399
}
13400
return fragment;
13401
}
13402
};
13403
13404
module.exports = ReactFragment;
13405
13406
}).call(this,require('_process'))
13407
},{"./ReactElement":76,"./warning":185,"_process":1}],83:[function(require,module,exports){
13408
/**
13409
* Copyright 2013-2015, Facebook, Inc.
13410
* All rights reserved.
13411
*
13412
* This source code is licensed under the BSD-style license found in the
13413
* LICENSE file in the root directory of this source tree. An additional grant
13414
* of patent rights can be found in the PATENTS file in the same directory.
13415
*
13416
* @providesModule ReactInjection
13417
*/
13418
13419
'use strict';
13420
13421
var DOMProperty = require("./DOMProperty");
13422
var EventPluginHub = require("./EventPluginHub");
13423
var ReactComponentEnvironment = require("./ReactComponentEnvironment");
13424
var ReactClass = require("./ReactClass");
13425
var ReactEmptyComponent = require("./ReactEmptyComponent");
13426
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
13427
var ReactNativeComponent = require("./ReactNativeComponent");
13428
var ReactDOMComponent = require("./ReactDOMComponent");
13429
var ReactPerf = require("./ReactPerf");
13430
var ReactRootIndex = require("./ReactRootIndex");
13431
var ReactUpdates = require("./ReactUpdates");
13432
13433
var ReactInjection = {
13434
Component: ReactComponentEnvironment.injection,
13435
Class: ReactClass.injection,
13436
DOMComponent: ReactDOMComponent.injection,
13437
DOMProperty: DOMProperty.injection,
13438
EmptyComponent: ReactEmptyComponent.injection,
13439
EventPluginHub: EventPluginHub.injection,
13440
EventEmitter: ReactBrowserEventEmitter.injection,
13441
NativeComponent: ReactNativeComponent.injection,
13442
Perf: ReactPerf.injection,
13443
RootIndex: ReactRootIndex.injection,
13444
Updates: ReactUpdates.injection
13445
};
13446
13447
module.exports = ReactInjection;
13448
13449
},{"./DOMProperty":24,"./EventPluginHub":31,"./ReactBrowserEventEmitter":46,"./ReactClass":51,"./ReactComponentEnvironment":54,"./ReactDOMComponent":61,"./ReactEmptyComponent":78,"./ReactNativeComponent":93,"./ReactPerf":95,"./ReactRootIndex":104,"./ReactUpdates":113}],84:[function(require,module,exports){
13450
/**
13451
* Copyright 2013-2015, Facebook, Inc.
13452
* All rights reserved.
13453
*
13454
* This source code is licensed under the BSD-style license found in the
13455
* LICENSE file in the root directory of this source tree. An additional grant
13456
* of patent rights can be found in the PATENTS file in the same directory.
13457
*
13458
* @providesModule ReactInputSelection
13459
*/
13460
13461
'use strict';
13462
13463
var ReactDOMSelection = require("./ReactDOMSelection");
13464
13465
var containsNode = require("./containsNode");
13466
var focusNode = require("./focusNode");
13467
var getActiveElement = require("./getActiveElement");
13468
13469
function isInDocument(node) {
13470
return containsNode(document.documentElement, node);
13471
}
13472
13473
/**
13474
* @ReactInputSelection: React input selection module. Based on Selection.js,
13475
* but modified to be suitable for react and has a couple of bug fixes (doesn't
13476
* assume buttons have range selections allowed).
13477
* Input selection module for React.
13478
*/
13479
var ReactInputSelection = {
13480
13481
hasSelectionCapabilities: function(elem) {
13482
return elem && (
13483
((elem.nodeName === 'INPUT' && elem.type === 'text') ||
13484
elem.nodeName === 'TEXTAREA' || elem.contentEditable === 'true')
13485
);
13486
},
13487
13488
getSelectionInformation: function() {
13489
var focusedElem = getActiveElement();
13490
return {
13491
focusedElem: focusedElem,
13492
selectionRange:
13493
ReactInputSelection.hasSelectionCapabilities(focusedElem) ?
13494
ReactInputSelection.getSelection(focusedElem) :
13495
null
13496
};
13497
},
13498
13499
/**
13500
* @restoreSelection: If any selection information was potentially lost,
13501
* restore it. This is useful when performing operations that could remove dom
13502
* nodes and place them back in, resulting in focus being lost.
13503
*/
13504
restoreSelection: function(priorSelectionInformation) {
13505
var curFocusedElem = getActiveElement();
13506
var priorFocusedElem = priorSelectionInformation.focusedElem;
13507
var priorSelectionRange = priorSelectionInformation.selectionRange;
13508
if (curFocusedElem !== priorFocusedElem &&
13509
isInDocument(priorFocusedElem)) {
13510
if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
13511
ReactInputSelection.setSelection(
13512
priorFocusedElem,
13513
priorSelectionRange
13514
);
13515
}
13516
focusNode(priorFocusedElem);
13517
}
13518
},
13519
13520
/**
13521
* @getSelection: Gets the selection bounds of a focused textarea, input or
13522
* contentEditable node.
13523
* -@input: Look up selection bounds of this input
13524
* -@return {start: selectionStart, end: selectionEnd}
13525
*/
13526
getSelection: function(input) {
13527
var selection;
13528
13529
if ('selectionStart' in input) {
13530
// Modern browser with input or textarea.
13531
selection = {
13532
start: input.selectionStart,
13533
end: input.selectionEnd
13534
};
13535
} else if (document.selection && input.nodeName === 'INPUT') {
13536
// IE8 input.
13537
var range = document.selection.createRange();
13538
// There can only be one selection per document in IE, so it must
13539
// be in our element.
13540
if (range.parentElement() === input) {
13541
selection = {
13542
start: -range.moveStart('character', -input.value.length),
13543
end: -range.moveEnd('character', -input.value.length)
13544
};
13545
}
13546
} else {
13547
// Content editable or old IE textarea.
13548
selection = ReactDOMSelection.getOffsets(input);
13549
}
13550
13551
return selection || {start: 0, end: 0};
13552
},
13553
13554
/**
13555
* @setSelection: Sets the selection bounds of a textarea or input and focuses
13556
* the input.
13557
* -@input Set selection bounds of this input or textarea
13558
* -@offsets Object of same form that is returned from get*
13559
*/
13560
setSelection: function(input, offsets) {
13561
var start = offsets.start;
13562
var end = offsets.end;
13563
if (typeof end === 'undefined') {
13564
end = start;
13565
}
13566
13567
if ('selectionStart' in input) {
13568
input.selectionStart = start;
13569
input.selectionEnd = Math.min(end, input.value.length);
13570
} else if (document.selection && input.nodeName === 'INPUT') {
13571
var range = input.createTextRange();
13572
range.collapse(true);
13573
range.moveStart('character', start);
13574
range.moveEnd('character', end - start);
13575
range.select();
13576
} else {
13577
ReactDOMSelection.setOffsets(input, offsets);
13578
}
13579
}
13580
};
13581
13582
module.exports = ReactInputSelection;
13583
13584
},{"./ReactDOMSelection":69,"./containsNode":137,"./focusNode":148,"./getActiveElement":150}],85:[function(require,module,exports){
13585
(function (process){
13586
/**
13587
* Copyright 2013-2015, Facebook, Inc.
13588
* All rights reserved.
13589
*
13590
* This source code is licensed under the BSD-style license found in the
13591
* LICENSE file in the root directory of this source tree. An additional grant
13592
* of patent rights can be found in the PATENTS file in the same directory.
13593
*
13594
* @providesModule ReactInstanceHandles
13595
* @typechecks static-only
13596
*/
13597
13598
'use strict';
13599
13600
var ReactRootIndex = require("./ReactRootIndex");
13601
13602
var invariant = require("./invariant");
13603
13604
var SEPARATOR = '.';
13605
var SEPARATOR_LENGTH = SEPARATOR.length;
13606
13607
/**
13608
* Maximum depth of traversals before we consider the possibility of a bad ID.
13609
*/
13610
var MAX_TREE_DEPTH = 100;
13611
13612
/**
13613
* Creates a DOM ID prefix to use when mounting React components.
13614
*
13615
* @param {number} index A unique integer
13616
* @return {string} React root ID.
13617
* @internal
13618
*/
13619
function getReactRootIDString(index) {
13620
return SEPARATOR + index.toString(36);
13621
}
13622
13623
/**
13624
* Checks if a character in the supplied ID is a separator or the end.
13625
*
13626
* @param {string} id A React DOM ID.
13627
* @param {number} index Index of the character to check.
13628
* @return {boolean} True if the character is a separator or end of the ID.
13629
* @private
13630
*/
13631
function isBoundary(id, index) {
13632
return id.charAt(index) === SEPARATOR || index === id.length;
13633
}
13634
13635
/**
13636
* Checks if the supplied string is a valid React DOM ID.
13637
*
13638
* @param {string} id A React DOM ID, maybe.
13639
* @return {boolean} True if the string is a valid React DOM ID.
13640
* @private
13641
*/
13642
function isValidID(id) {
13643
return id === '' || (
13644
id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR
13645
);
13646
}
13647
13648
/**
13649
* Checks if the first ID is an ancestor of or equal to the second ID.
13650
*
13651
* @param {string} ancestorID
13652
* @param {string} descendantID
13653
* @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
13654
* @internal
13655
*/
13656
function isAncestorIDOf(ancestorID, descendantID) {
13657
return (
13658
descendantID.indexOf(ancestorID) === 0 &&
13659
isBoundary(descendantID, ancestorID.length)
13660
);
13661
}
13662
13663
/**
13664
* Gets the parent ID of the supplied React DOM ID, `id`.
13665
*
13666
* @param {string} id ID of a component.
13667
* @return {string} ID of the parent, or an empty string.
13668
* @private
13669
*/
13670
function getParentID(id) {
13671
return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
13672
}
13673
13674
/**
13675
* Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
13676
* supplied `destinationID`. If they are equal, the ID is returned.
13677
*
13678
* @param {string} ancestorID ID of an ancestor node of `destinationID`.
13679
* @param {string} destinationID ID of the destination node.
13680
* @return {string} Next ID on the path from `ancestorID` to `destinationID`.
13681
* @private
13682
*/
13683
function getNextDescendantID(ancestorID, destinationID) {
13684
("production" !== process.env.NODE_ENV ? invariant(
13685
isValidID(ancestorID) && isValidID(destinationID),
13686
'getNextDescendantID(%s, %s): Received an invalid React DOM ID.',
13687
ancestorID,
13688
destinationID
13689
) : invariant(isValidID(ancestorID) && isValidID(destinationID)));
13690
("production" !== process.env.NODE_ENV ? invariant(
13691
isAncestorIDOf(ancestorID, destinationID),
13692
'getNextDescendantID(...): React has made an invalid assumption about ' +
13693
'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.',
13694
ancestorID,
13695
destinationID
13696
) : invariant(isAncestorIDOf(ancestorID, destinationID)));
13697
if (ancestorID === destinationID) {
13698
return ancestorID;
13699
}
13700
// Skip over the ancestor and the immediate separator. Traverse until we hit
13701
// another separator or we reach the end of `destinationID`.
13702
var start = ancestorID.length + SEPARATOR_LENGTH;
13703
var i;
13704
for (i = start; i < destinationID.length; i++) {
13705
if (isBoundary(destinationID, i)) {
13706
break;
13707
}
13708
}
13709
return destinationID.substr(0, i);
13710
}
13711
13712
/**
13713
* Gets the nearest common ancestor ID of two IDs.
13714
*
13715
* Using this ID scheme, the nearest common ancestor ID is the longest common
13716
* prefix of the two IDs that immediately preceded a "marker" in both strings.
13717
*
13718
* @param {string} oneID
13719
* @param {string} twoID
13720
* @return {string} Nearest common ancestor ID, or the empty string if none.
13721
* @private
13722
*/
13723
function getFirstCommonAncestorID(oneID, twoID) {
13724
var minLength = Math.min(oneID.length, twoID.length);
13725
if (minLength === 0) {
13726
return '';
13727
}
13728
var lastCommonMarkerIndex = 0;
13729
// Use `<=` to traverse until the "EOL" of the shorter string.
13730
for (var i = 0; i <= minLength; i++) {
13731
if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
13732
lastCommonMarkerIndex = i;
13733
} else if (oneID.charAt(i) !== twoID.charAt(i)) {
13734
break;
13735
}
13736
}
13737
var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
13738
("production" !== process.env.NODE_ENV ? invariant(
13739
isValidID(longestCommonID),
13740
'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s',
13741
oneID,
13742
twoID,
13743
longestCommonID
13744
) : invariant(isValidID(longestCommonID)));
13745
return longestCommonID;
13746
}
13747
13748
/**
13749
* Traverses the parent path between two IDs (either up or down). The IDs must
13750
* not be the same, and there must exist a parent path between them. If the
13751
* callback returns `false`, traversal is stopped.
13752
*
13753
* @param {?string} start ID at which to start traversal.
13754
* @param {?string} stop ID at which to end traversal.
13755
* @param {function} cb Callback to invoke each ID with.
13756
* @param {?boolean} skipFirst Whether or not to skip the first node.
13757
* @param {?boolean} skipLast Whether or not to skip the last node.
13758
* @private
13759
*/
13760
function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
13761
start = start || '';
13762
stop = stop || '';
13763
("production" !== process.env.NODE_ENV ? invariant(
13764
start !== stop,
13765
'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.',
13766
start
13767
) : invariant(start !== stop));
13768
var traverseUp = isAncestorIDOf(stop, start);
13769
("production" !== process.env.NODE_ENV ? invariant(
13770
traverseUp || isAncestorIDOf(start, stop),
13771
'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' +
13772
'not have a parent path.',
13773
start,
13774
stop
13775
) : invariant(traverseUp || isAncestorIDOf(start, stop)));
13776
// Traverse from `start` to `stop` one depth at a time.
13777
var depth = 0;
13778
var traverse = traverseUp ? getParentID : getNextDescendantID;
13779
for (var id = start; /* until break */; id = traverse(id, stop)) {
13780
var ret;
13781
if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
13782
ret = cb(id, traverseUp, arg);
13783
}
13784
if (ret === false || id === stop) {
13785
// Only break //after// visiting `stop`.
13786
break;
13787
}
13788
("production" !== process.env.NODE_ENV ? invariant(
13789
depth++ < MAX_TREE_DEPTH,
13790
'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' +
13791
'traversing the React DOM ID tree. This may be due to malformed IDs: %s',
13792
start, stop
13793
) : invariant(depth++ < MAX_TREE_DEPTH));
13794
}
13795
}
13796
13797
/**
13798
* Manages the IDs assigned to DOM representations of React components. This
13799
* uses a specific scheme in order to traverse the DOM efficiently (e.g. in
13800
* order to simulate events).
13801
*
13802
* @internal
13803
*/
13804
var ReactInstanceHandles = {
13805
13806
/**
13807
* Constructs a React root ID
13808
* @return {string} A React root ID.
13809
*/
13810
createReactRootID: function() {
13811
return getReactRootIDString(ReactRootIndex.createReactRootIndex());
13812
},
13813
13814
/**
13815
* Constructs a React ID by joining a root ID with a name.
13816
*
13817
* @param {string} rootID Root ID of a parent component.
13818
* @param {string} name A component's name (as flattened children).
13819
* @return {string} A React ID.
13820
* @internal
13821
*/
13822
createReactID: function(rootID, name) {
13823
return rootID + name;
13824
},
13825
13826
/**
13827
* Gets the DOM ID of the React component that is the root of the tree that
13828
* contains the React component with the supplied DOM ID.
13829
*
13830
* @param {string} id DOM ID of a React component.
13831
* @return {?string} DOM ID of the React component that is the root.
13832
* @internal
13833
*/
13834
getReactRootIDFromNodeID: function(id) {
13835
if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
13836
var index = id.indexOf(SEPARATOR, 1);
13837
return index > -1 ? id.substr(0, index) : id;
13838
}
13839
return null;
13840
},
13841
13842
/**
13843
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
13844
* should would receive a `mouseEnter` or `mouseLeave` event.
13845
*
13846
* NOTE: Does not invoke the callback on the nearest common ancestor because
13847
* nothing "entered" or "left" that element.
13848
*
13849
* @param {string} leaveID ID being left.
13850
* @param {string} enterID ID being entered.
13851
* @param {function} cb Callback to invoke on each entered/left ID.
13852
* @param {*} upArg Argument to invoke the callback with on left IDs.
13853
* @param {*} downArg Argument to invoke the callback with on entered IDs.
13854
* @internal
13855
*/
13856
traverseEnterLeave: function(leaveID, enterID, cb, upArg, downArg) {
13857
var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
13858
if (ancestorID !== leaveID) {
13859
traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
13860
}
13861
if (ancestorID !== enterID) {
13862
traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
13863
}
13864
},
13865
13866
/**
13867
* Simulates the traversal of a two-phase, capture/bubble event dispatch.
13868
*
13869
* NOTE: This traversal happens on IDs without touching the DOM.
13870
*
13871
* @param {string} targetID ID of the target node.
13872
* @param {function} cb Callback to invoke.
13873
* @param {*} arg Argument to invoke the callback with.
13874
* @internal
13875
*/
13876
traverseTwoPhase: function(targetID, cb, arg) {
13877
if (targetID) {
13878
traverseParentPath('', targetID, cb, arg, true, false);
13879
traverseParentPath(targetID, '', cb, arg, false, true);
13880
}
13881
},
13882
13883
/**
13884
* Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
13885
* example, passing `.0.$row-0.1` would result in `cb` getting called
13886
* with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
13887
*
13888
* NOTE: This traversal happens on IDs without touching the DOM.
13889
*
13890
* @param {string} targetID ID of the target node.
13891
* @param {function} cb Callback to invoke.
13892
* @param {*} arg Argument to invoke the callback with.
13893
* @internal
13894
*/
13895
traverseAncestors: function(targetID, cb, arg) {
13896
traverseParentPath('', targetID, cb, arg, true, false);
13897
},
13898
13899
/**
13900
* Exposed for unit testing.
13901
* @private
13902
*/
13903
_getFirstCommonAncestorID: getFirstCommonAncestorID,
13904
13905
/**
13906
* Exposed for unit testing.
13907
* @private
13908
*/
13909
_getNextDescendantID: getNextDescendantID,
13910
13911
isAncestorIDOf: isAncestorIDOf,
13912
13913
SEPARATOR: SEPARATOR
13914
13915
};
13916
13917
module.exports = ReactInstanceHandles;
13918
13919
}).call(this,require('_process'))
13920
},{"./ReactRootIndex":104,"./invariant":164,"_process":1}],86:[function(require,module,exports){
13921
/**
13922
* Copyright 2013-2015, Facebook, Inc.
13923
* All rights reserved.
13924
*
13925
* This source code is licensed under the BSD-style license found in the
13926
* LICENSE file in the root directory of this source tree. An additional grant
13927
* of patent rights can be found in the PATENTS file in the same directory.
13928
*
13929
* @providesModule ReactInstanceMap
13930
*/
13931
13932
'use strict';
13933
13934
/**
13935
* `ReactInstanceMap` maintains a mapping from a public facing stateful
13936
* instance (key) and the internal representation (value). This allows public
13937
* methods to accept the user facing instance as an argument and map them back
13938
* to internal methods.
13939
*/
13940
13941
// TODO: Replace this with ES6: var ReactInstanceMap = new Map();
13942
var ReactInstanceMap = {
13943
13944
/**
13945
* This API should be called `delete` but we'd have to make sure to always
13946
* transform these to strings for IE support. When this transform is fully
13947
* supported we can rename it.
13948
*/
13949
remove: function(key) {
13950
key._reactInternalInstance = undefined;
13951
},
13952
13953
get: function(key) {
13954
return key._reactInternalInstance;
13955
},
13956
13957
has: function(key) {
13958
return key._reactInternalInstance !== undefined;
13959
},
13960
13961
set: function(key, value) {
13962
key._reactInternalInstance = value;
13963
}
13964
13965
};
13966
13967
module.exports = ReactInstanceMap;
13968
13969
},{}],87:[function(require,module,exports){
13970
/**
13971
* Copyright 2015, Facebook, Inc.
13972
* All rights reserved.
13973
*
13974
* This source code is licensed under the BSD-style license found in the
13975
* LICENSE file in the root directory of this source tree. An additional grant
13976
* of patent rights can be found in the PATENTS file in the same directory.
13977
*
13978
* @providesModule ReactLifeCycle
13979
*/
13980
13981
'use strict';
13982
13983
/**
13984
* This module manages the bookkeeping when a component is in the process
13985
* of being mounted or being unmounted. This is used as a way to enforce
13986
* invariants (or warnings) when it is not recommended to call
13987
* setState/forceUpdate.
13988
*
13989
* currentlyMountingInstance: During the construction phase, it is not possible
13990
* to trigger an update since the instance is not fully mounted yet. However, we
13991
* currently allow this as a convenience for mutating the initial state.
13992
*
13993
* currentlyUnmountingInstance: During the unmounting phase, the instance is
13994
* still mounted and can therefore schedule an update. However, this is not
13995
* recommended and probably an error since it's about to be unmounted.
13996
* Therefore we still want to trigger in an error for that case.
13997
*/
13998
13999
var ReactLifeCycle = {
14000
currentlyMountingInstance: null,
14001
currentlyUnmountingInstance: null
14002
};
14003
14004
module.exports = ReactLifeCycle;
14005
14006
},{}],88:[function(require,module,exports){
14007
/**
14008
* Copyright 2013-2015, Facebook, Inc.
14009
* All rights reserved.
14010
*
14011
* This source code is licensed under the BSD-style license found in the
14012
* LICENSE file in the root directory of this source tree. An additional grant
14013
* of patent rights can be found in the PATENTS file in the same directory.
14014
*
14015
* @providesModule ReactLink
14016
* @typechecks static-only
14017
*/
14018
14019
'use strict';
14020
14021
/**
14022
* ReactLink encapsulates a common pattern in which a component wants to modify
14023
* a prop received from its parent. ReactLink allows the parent to pass down a
14024
* value coupled with a callback that, when invoked, expresses an intent to
14025
* modify that value. For example:
14026
*
14027
* React.createClass({
14028
* getInitialState: function() {
14029
* return {value: ''};
14030
* },
14031
* render: function() {
14032
* var valueLink = new ReactLink(this.state.value, this._handleValueChange);
14033
* return <input valueLink={valueLink} />;
14034
* },
14035
* this._handleValueChange: function(newValue) {
14036
* this.setState({value: newValue});
14037
* }
14038
* });
14039
*
14040
* We have provided some sugary mixins to make the creation and
14041
* consumption of ReactLink easier; see LinkedValueUtils and LinkedStateMixin.
14042
*/
14043
14044
var React = require("./React");
14045
14046
/**
14047
* @param {*} value current value of the link
14048
* @param {function} requestChange callback to request a change
14049
*/
14050
function ReactLink(value, requestChange) {
14051
this.value = value;
14052
this.requestChange = requestChange;
14053
}
14054
14055
/**
14056
* Creates a PropType that enforces the ReactLink API and optionally checks the
14057
* type of the value being passed inside the link. Example:
14058
*
14059
* MyComponent.propTypes = {
14060
* tabIndexLink: ReactLink.PropTypes.link(React.PropTypes.number)
14061
* }
14062
*/
14063
function createLinkTypeChecker(linkType) {
14064
var shapes = {
14065
value: typeof linkType === 'undefined' ?
14066
React.PropTypes.any.isRequired :
14067
linkType.isRequired,
14068
requestChange: React.PropTypes.func.isRequired
14069
};
14070
return React.PropTypes.shape(shapes);
14071
}
14072
14073
ReactLink.PropTypes = {
14074
link: createLinkTypeChecker
14075
};
14076
14077
module.exports = ReactLink;
14078
14079
},{"./React":44}],89:[function(require,module,exports){
14080
/**
14081
* Copyright 2013-2015, Facebook, Inc.
14082
* All rights reserved.
14083
*
14084
* This source code is licensed under the BSD-style license found in the
14085
* LICENSE file in the root directory of this source tree. An additional grant
14086
* of patent rights can be found in the PATENTS file in the same directory.
14087
*
14088
* @providesModule ReactMarkupChecksum
14089
*/
14090
14091
'use strict';
14092
14093
var adler32 = require("./adler32");
14094
14095
var ReactMarkupChecksum = {
14096
CHECKSUM_ATTR_NAME: 'data-react-checksum',
14097
14098
/**
14099
* @param {string} markup Markup string
14100
* @return {string} Markup string with checksum attribute attached
14101
*/
14102
addChecksumToMarkup: function(markup) {
14103
var checksum = adler32(markup);
14104
return markup.replace(
14105
'>',
14106
' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">'
14107
);
14108
},
14109
14110
/**
14111
* @param {string} markup to use
14112
* @param {DOMElement} element root React element
14113
* @returns {boolean} whether or not the markup is the same
14114
*/
14115
canReuseMarkup: function(markup, element) {
14116
var existingChecksum = element.getAttribute(
14117
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
14118
);
14119
existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
14120
var markupChecksum = adler32(markup);
14121
return markupChecksum === existingChecksum;
14122
}
14123
};
14124
14125
module.exports = ReactMarkupChecksum;
14126
14127
},{"./adler32":133}],90:[function(require,module,exports){
14128
(function (process){
14129
/**
14130
* Copyright 2013-2015, Facebook, Inc.
14131
* All rights reserved.
14132
*
14133
* This source code is licensed under the BSD-style license found in the
14134
* LICENSE file in the root directory of this source tree. An additional grant
14135
* of patent rights can be found in the PATENTS file in the same directory.
14136
*
14137
* @providesModule ReactMount
14138
*/
14139
14140
'use strict';
14141
14142
var DOMProperty = require("./DOMProperty");
14143
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
14144
var ReactCurrentOwner = require("./ReactCurrentOwner");
14145
var ReactElement = require("./ReactElement");
14146
var ReactElementValidator = require("./ReactElementValidator");
14147
var ReactEmptyComponent = require("./ReactEmptyComponent");
14148
var ReactInstanceHandles = require("./ReactInstanceHandles");
14149
var ReactInstanceMap = require("./ReactInstanceMap");
14150
var ReactMarkupChecksum = require("./ReactMarkupChecksum");
14151
var ReactPerf = require("./ReactPerf");
14152
var ReactReconciler = require("./ReactReconciler");
14153
var ReactUpdateQueue = require("./ReactUpdateQueue");
14154
var ReactUpdates = require("./ReactUpdates");
14155
14156
var emptyObject = require("./emptyObject");
14157
var containsNode = require("./containsNode");
14158
var getReactRootElementInContainer = require("./getReactRootElementInContainer");
14159
var instantiateReactComponent = require("./instantiateReactComponent");
14160
var invariant = require("./invariant");
14161
var setInnerHTML = require("./setInnerHTML");
14162
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
14163
var warning = require("./warning");
14164
14165
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
14166
14167
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
14168
var nodeCache = {};
14169
14170
var ELEMENT_NODE_TYPE = 1;
14171
var DOC_NODE_TYPE = 9;
14172
14173
/** Mapping from reactRootID to React component instance. */
14174
var instancesByReactRootID = {};
14175
14176
/** Mapping from reactRootID to `container` nodes. */
14177
var containersByReactRootID = {};
14178
14179
if ("production" !== process.env.NODE_ENV) {
14180
/** __DEV__-only mapping from reactRootID to root elements. */
14181
var rootElementsByReactRootID = {};
14182
}
14183
14184
// Used to store breadth-first search state in findComponentRoot.
14185
var findComponentRootReusableArray = [];
14186
14187
/**
14188
* Finds the index of the first character
14189
* that's not common between the two given strings.
14190
*
14191
* @return {number} the index of the character where the strings diverge
14192
*/
14193
function firstDifferenceIndex(string1, string2) {
14194
var minLen = Math.min(string1.length, string2.length);
14195
for (var i = 0; i < minLen; i++) {
14196
if (string1.charAt(i) !== string2.charAt(i)) {
14197
return i;
14198
}
14199
}
14200
return string1.length === string2.length ? -1 : minLen;
14201
}
14202
14203
/**
14204
* @param {DOMElement} container DOM element that may contain a React component.
14205
* @return {?string} A "reactRoot" ID, if a React component is rendered.
14206
*/
14207
function getReactRootID(container) {
14208
var rootElement = getReactRootElementInContainer(container);
14209
return rootElement && ReactMount.getID(rootElement);
14210
}
14211
14212
/**
14213
* Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
14214
* element can return its control whose name or ID equals ATTR_NAME. All
14215
* DOM nodes support `getAttributeNode` but this can also get called on
14216
* other objects so just return '' if we're given something other than a
14217
* DOM node (such as window).
14218
*
14219
* @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
14220
* @return {string} ID of the supplied `domNode`.
14221
*/
14222
function getID(node) {
14223
var id = internalGetID(node);
14224
if (id) {
14225
if (nodeCache.hasOwnProperty(id)) {
14226
var cached = nodeCache[id];
14227
if (cached !== node) {
14228
("production" !== process.env.NODE_ENV ? invariant(
14229
!isValid(cached, id),
14230
'ReactMount: Two valid but unequal nodes with the same `%s`: %s',
14231
ATTR_NAME, id
14232
) : invariant(!isValid(cached, id)));
14233
14234
nodeCache[id] = node;
14235
}
14236
} else {
14237
nodeCache[id] = node;
14238
}
14239
}
14240
14241
return id;
14242
}
14243
14244
function internalGetID(node) {
14245
// If node is something like a window, document, or text node, none of
14246
// which support attributes or a .getAttribute method, gracefully return
14247
// the empty string, as if the attribute were missing.
14248
return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
14249
}
14250
14251
/**
14252
* Sets the React-specific ID of the given node.
14253
*
14254
* @param {DOMElement} node The DOM node whose ID will be set.
14255
* @param {string} id The value of the ID attribute.
14256
*/
14257
function setID(node, id) {
14258
var oldID = internalGetID(node);
14259
if (oldID !== id) {
14260
delete nodeCache[oldID];
14261
}
14262
node.setAttribute(ATTR_NAME, id);
14263
nodeCache[id] = node;
14264
}
14265
14266
/**
14267
* Finds the node with the supplied React-generated DOM ID.
14268
*
14269
* @param {string} id A React-generated DOM ID.
14270
* @return {DOMElement} DOM node with the suppled `id`.
14271
* @internal
14272
*/
14273
function getNode(id) {
14274
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
14275
nodeCache[id] = ReactMount.findReactNodeByID(id);
14276
}
14277
return nodeCache[id];
14278
}
14279
14280
/**
14281
* Finds the node with the supplied public React instance.
14282
*
14283
* @param {*} instance A public React instance.
14284
* @return {?DOMElement} DOM node with the suppled `id`.
14285
* @internal
14286
*/
14287
function getNodeFromInstance(instance) {
14288
var id = ReactInstanceMap.get(instance)._rootNodeID;
14289
if (ReactEmptyComponent.isNullComponentID(id)) {
14290
return null;
14291
}
14292
if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
14293
nodeCache[id] = ReactMount.findReactNodeByID(id);
14294
}
14295
return nodeCache[id];
14296
}
14297
14298
/**
14299
* A node is "valid" if it is contained by a currently mounted container.
14300
*
14301
* This means that the node does not have to be contained by a document in
14302
* order to be considered valid.
14303
*
14304
* @param {?DOMElement} node The candidate DOM node.
14305
* @param {string} id The expected ID of the node.
14306
* @return {boolean} Whether the node is contained by a mounted container.
14307
*/
14308
function isValid(node, id) {
14309
if (node) {
14310
("production" !== process.env.NODE_ENV ? invariant(
14311
internalGetID(node) === id,
14312
'ReactMount: Unexpected modification of `%s`',
14313
ATTR_NAME
14314
) : invariant(internalGetID(node) === id));
14315
14316
var container = ReactMount.findReactContainerForID(id);
14317
if (container && containsNode(container, node)) {
14318
return true;
14319
}
14320
}
14321
14322
return false;
14323
}
14324
14325
/**
14326
* Causes the cache to forget about one React-specific ID.
14327
*
14328
* @param {string} id The ID to forget.
14329
*/
14330
function purgeID(id) {
14331
delete nodeCache[id];
14332
}
14333
14334
var deepestNodeSoFar = null;
14335
function findDeepestCachedAncestorImpl(ancestorID) {
14336
var ancestor = nodeCache[ancestorID];
14337
if (ancestor && isValid(ancestor, ancestorID)) {
14338
deepestNodeSoFar = ancestor;
14339
} else {
14340
// This node isn't populated in the cache, so presumably none of its
14341
// descendants are. Break out of the loop.
14342
return false;
14343
}
14344
}
14345
14346
/**
14347
* Return the deepest cached node whose ID is a prefix of `targetID`.
14348
*/
14349
function findDeepestCachedAncestor(targetID) {
14350
deepestNodeSoFar = null;
14351
ReactInstanceHandles.traverseAncestors(
14352
targetID,
14353
findDeepestCachedAncestorImpl
14354
);
14355
14356
var foundNode = deepestNodeSoFar;
14357
deepestNodeSoFar = null;
14358
return foundNode;
14359
}
14360
14361
/**
14362
* Mounts this component and inserts it into the DOM.
14363
*
14364
* @param {ReactComponent} componentInstance The instance to mount.
14365
* @param {string} rootID DOM ID of the root node.
14366
* @param {DOMElement} container DOM element to mount into.
14367
* @param {ReactReconcileTransaction} transaction
14368
* @param {boolean} shouldReuseMarkup If true, do not insert markup
14369
*/
14370
function mountComponentIntoNode(
14371
componentInstance,
14372
rootID,
14373
container,
14374
transaction,
14375
shouldReuseMarkup) {
14376
var markup = ReactReconciler.mountComponent(
14377
componentInstance, rootID, transaction, emptyObject
14378
);
14379
componentInstance._isTopLevel = true;
14380
ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
14381
}
14382
14383
/**
14384
* Batched mount.
14385
*
14386
* @param {ReactComponent} componentInstance The instance to mount.
14387
* @param {string} rootID DOM ID of the root node.
14388
* @param {DOMElement} container DOM element to mount into.
14389
* @param {boolean} shouldReuseMarkup If true, do not insert markup
14390
*/
14391
function batchedMountComponentIntoNode(
14392
componentInstance,
14393
rootID,
14394
container,
14395
shouldReuseMarkup) {
14396
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
14397
transaction.perform(
14398
mountComponentIntoNode,
14399
null,
14400
componentInstance,
14401
rootID,
14402
container,
14403
transaction,
14404
shouldReuseMarkup
14405
);
14406
ReactUpdates.ReactReconcileTransaction.release(transaction);
14407
}
14408
14409
/**
14410
* Mounting is the process of initializing a React component by creating its
14411
* representative DOM elements and inserting them into a supplied `container`.
14412
* Any prior content inside `container` is destroyed in the process.
14413
*
14414
* ReactMount.render(
14415
* component,
14416
* document.getElementById('container')
14417
* );
14418
*
14419
* <div id="container"> <-- Supplied `container`.
14420
* <div data-reactid=".3"> <-- Rendered reactRoot of React
14421
* // ... component.
14422
* </div>
14423
* </div>
14424
*
14425
* Inside of `container`, the first element rendered is the "reactRoot".
14426
*/
14427
var ReactMount = {
14428
/** Exposed for debugging purposes **/
14429
_instancesByReactRootID: instancesByReactRootID,
14430
14431
/**
14432
* This is a hook provided to support rendering React components while
14433
* ensuring that the apparent scroll position of its `container` does not
14434
* change.
14435
*
14436
* @param {DOMElement} container The `container` being rendered into.
14437
* @param {function} renderCallback This must be called once to do the render.
14438
*/
14439
scrollMonitor: function(container, renderCallback) {
14440
renderCallback();
14441
},
14442
14443
/**
14444
* Take a component that's already mounted into the DOM and replace its props
14445
* @param {ReactComponent} prevComponent component instance already in the DOM
14446
* @param {ReactElement} nextElement component instance to render
14447
* @param {DOMElement} container container to render into
14448
* @param {?function} callback function triggered on completion
14449
*/
14450
_updateRootComponent: function(
14451
prevComponent,
14452
nextElement,
14453
container,
14454
callback) {
14455
if ("production" !== process.env.NODE_ENV) {
14456
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
14457
}
14458
14459
ReactMount.scrollMonitor(container, function() {
14460
ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
14461
if (callback) {
14462
ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
14463
}
14464
});
14465
14466
if ("production" !== process.env.NODE_ENV) {
14467
// Record the root element in case it later gets transplanted.
14468
rootElementsByReactRootID[getReactRootID(container)] =
14469
getReactRootElementInContainer(container);
14470
}
14471
14472
return prevComponent;
14473
},
14474
14475
/**
14476
* Register a component into the instance map and starts scroll value
14477
* monitoring
14478
* @param {ReactComponent} nextComponent component instance to render
14479
* @param {DOMElement} container container to render into
14480
* @return {string} reactRoot ID prefix
14481
*/
14482
_registerComponent: function(nextComponent, container) {
14483
("production" !== process.env.NODE_ENV ? invariant(
14484
container && (
14485
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14486
),
14487
'_registerComponent(...): Target container is not a DOM element.'
14488
) : invariant(container && (
14489
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14490
)));
14491
14492
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
14493
14494
var reactRootID = ReactMount.registerContainer(container);
14495
instancesByReactRootID[reactRootID] = nextComponent;
14496
return reactRootID;
14497
},
14498
14499
/**
14500
* Render a new component into the DOM.
14501
* @param {ReactElement} nextElement element to render
14502
* @param {DOMElement} container container to render into
14503
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion
14504
* @return {ReactComponent} nextComponent
14505
*/
14506
_renderNewRootComponent: function(
14507
nextElement,
14508
container,
14509
shouldReuseMarkup
14510
) {
14511
// Various parts of our code (such as ReactCompositeComponent's
14512
// _renderValidatedComponent) assume that calls to render aren't nested;
14513
// verify that that's the case.
14514
("production" !== process.env.NODE_ENV ? warning(
14515
ReactCurrentOwner.current == null,
14516
'_renderNewRootComponent(): Render methods should be a pure function ' +
14517
'of props and state; triggering nested component updates from ' +
14518
'render is not allowed. If necessary, trigger nested updates in ' +
14519
'componentDidUpdate.'
14520
) : null);
14521
14522
var componentInstance = instantiateReactComponent(nextElement, null);
14523
var reactRootID = ReactMount._registerComponent(
14524
componentInstance,
14525
container
14526
);
14527
14528
// The initial render is synchronous but any updates that happen during
14529
// rendering, in componentWillMount or componentDidMount, will be batched
14530
// according to the current batching strategy.
14531
14532
ReactUpdates.batchedUpdates(
14533
batchedMountComponentIntoNode,
14534
componentInstance,
14535
reactRootID,
14536
container,
14537
shouldReuseMarkup
14538
);
14539
14540
if ("production" !== process.env.NODE_ENV) {
14541
// Record the root element in case it later gets transplanted.
14542
rootElementsByReactRootID[reactRootID] =
14543
getReactRootElementInContainer(container);
14544
}
14545
14546
return componentInstance;
14547
},
14548
14549
/**
14550
* Renders a React component into the DOM in the supplied `container`.
14551
*
14552
* If the React component was previously rendered into `container`, this will
14553
* perform an update on it and only mutate the DOM as necessary to reflect the
14554
* latest React component.
14555
*
14556
* @param {ReactElement} nextElement Component element to render.
14557
* @param {DOMElement} container DOM element to render into.
14558
* @param {?function} callback function triggered on completion
14559
* @return {ReactComponent} Component instance rendered in `container`.
14560
*/
14561
render: function(nextElement, container, callback) {
14562
("production" !== process.env.NODE_ENV ? invariant(
14563
ReactElement.isValidElement(nextElement),
14564
'React.render(): Invalid component element.%s',
14565
(
14566
typeof nextElement === 'string' ?
14567
' Instead of passing an element string, make sure to instantiate ' +
14568
'it by passing it to React.createElement.' :
14569
typeof nextElement === 'function' ?
14570
' Instead of passing a component class, make sure to instantiate ' +
14571
'it by passing it to React.createElement.' :
14572
// Check if it quacks like an element
14573
nextElement != null && nextElement.props !== undefined ?
14574
' This may be caused by unintentionally loading two independent ' +
14575
'copies of React.' :
14576
''
14577
)
14578
) : invariant(ReactElement.isValidElement(nextElement)));
14579
14580
var prevComponent = instancesByReactRootID[getReactRootID(container)];
14581
14582
if (prevComponent) {
14583
var prevElement = prevComponent._currentElement;
14584
if (shouldUpdateReactComponent(prevElement, nextElement)) {
14585
return ReactMount._updateRootComponent(
14586
prevComponent,
14587
nextElement,
14588
container,
14589
callback
14590
).getPublicInstance();
14591
} else {
14592
ReactMount.unmountComponentAtNode(container);
14593
}
14594
}
14595
14596
var reactRootElement = getReactRootElementInContainer(container);
14597
var containerHasReactMarkup =
14598
reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
14599
14600
if ("production" !== process.env.NODE_ENV) {
14601
if (!containerHasReactMarkup || reactRootElement.nextSibling) {
14602
var rootElementSibling = reactRootElement;
14603
while (rootElementSibling) {
14604
if (ReactMount.isRenderedByReact(rootElementSibling)) {
14605
("production" !== process.env.NODE_ENV ? warning(
14606
false,
14607
'render(): Target node has markup rendered by React, but there ' +
14608
'are unrelated nodes as well. This is most commonly caused by ' +
14609
'white-space inserted around server-rendered markup.'
14610
) : null);
14611
break;
14612
}
14613
14614
rootElementSibling = rootElementSibling.nextSibling;
14615
}
14616
}
14617
}
14618
14619
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
14620
14621
var component = ReactMount._renderNewRootComponent(
14622
nextElement,
14623
container,
14624
shouldReuseMarkup
14625
).getPublicInstance();
14626
if (callback) {
14627
callback.call(component);
14628
}
14629
return component;
14630
},
14631
14632
/**
14633
* Constructs a component instance of `constructor` with `initialProps` and
14634
* renders it into the supplied `container`.
14635
*
14636
* @param {function} constructor React component constructor.
14637
* @param {?object} props Initial props of the component instance.
14638
* @param {DOMElement} container DOM element to render into.
14639
* @return {ReactComponent} Component instance rendered in `container`.
14640
*/
14641
constructAndRenderComponent: function(constructor, props, container) {
14642
var element = ReactElement.createElement(constructor, props);
14643
return ReactMount.render(element, container);
14644
},
14645
14646
/**
14647
* Constructs a component instance of `constructor` with `initialProps` and
14648
* renders it into a container node identified by supplied `id`.
14649
*
14650
* @param {function} componentConstructor React component constructor
14651
* @param {?object} props Initial props of the component instance.
14652
* @param {string} id ID of the DOM element to render into.
14653
* @return {ReactComponent} Component instance rendered in the container node.
14654
*/
14655
constructAndRenderComponentByID: function(constructor, props, id) {
14656
var domNode = document.getElementById(id);
14657
("production" !== process.env.NODE_ENV ? invariant(
14658
domNode,
14659
'Tried to get element with id of "%s" but it is not present on the page.',
14660
id
14661
) : invariant(domNode));
14662
return ReactMount.constructAndRenderComponent(constructor, props, domNode);
14663
},
14664
14665
/**
14666
* Registers a container node into which React components will be rendered.
14667
* This also creates the "reactRoot" ID that will be assigned to the element
14668
* rendered within.
14669
*
14670
* @param {DOMElement} container DOM element to register as a container.
14671
* @return {string} The "reactRoot" ID of elements rendered within.
14672
*/
14673
registerContainer: function(container) {
14674
var reactRootID = getReactRootID(container);
14675
if (reactRootID) {
14676
// If one exists, make sure it is a valid "reactRoot" ID.
14677
reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
14678
}
14679
if (!reactRootID) {
14680
// No valid "reactRoot" ID found, create one.
14681
reactRootID = ReactInstanceHandles.createReactRootID();
14682
}
14683
containersByReactRootID[reactRootID] = container;
14684
return reactRootID;
14685
},
14686
14687
/**
14688
* Unmounts and destroys the React component rendered in the `container`.
14689
*
14690
* @param {DOMElement} container DOM element containing a React component.
14691
* @return {boolean} True if a component was found in and unmounted from
14692
* `container`
14693
*/
14694
unmountComponentAtNode: function(container) {
14695
// Various parts of our code (such as ReactCompositeComponent's
14696
// _renderValidatedComponent) assume that calls to render aren't nested;
14697
// verify that that's the case. (Strictly speaking, unmounting won't cause a
14698
// render but we still don't expect to be in a render call here.)
14699
("production" !== process.env.NODE_ENV ? warning(
14700
ReactCurrentOwner.current == null,
14701
'unmountComponentAtNode(): Render methods should be a pure function of ' +
14702
'props and state; triggering nested component updates from render is ' +
14703
'not allowed. If necessary, trigger nested updates in ' +
14704
'componentDidUpdate.'
14705
) : null);
14706
14707
("production" !== process.env.NODE_ENV ? invariant(
14708
container && (
14709
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14710
),
14711
'unmountComponentAtNode(...): Target container is not a DOM element.'
14712
) : invariant(container && (
14713
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14714
)));
14715
14716
var reactRootID = getReactRootID(container);
14717
var component = instancesByReactRootID[reactRootID];
14718
if (!component) {
14719
return false;
14720
}
14721
ReactMount.unmountComponentFromNode(component, container);
14722
delete instancesByReactRootID[reactRootID];
14723
delete containersByReactRootID[reactRootID];
14724
if ("production" !== process.env.NODE_ENV) {
14725
delete rootElementsByReactRootID[reactRootID];
14726
}
14727
return true;
14728
},
14729
14730
/**
14731
* Unmounts a component and removes it from the DOM.
14732
*
14733
* @param {ReactComponent} instance React component instance.
14734
* @param {DOMElement} container DOM element to unmount from.
14735
* @final
14736
* @internal
14737
* @see {ReactMount.unmountComponentAtNode}
14738
*/
14739
unmountComponentFromNode: function(instance, container) {
14740
ReactReconciler.unmountComponent(instance);
14741
14742
if (container.nodeType === DOC_NODE_TYPE) {
14743
container = container.documentElement;
14744
}
14745
14746
// http://jsperf.com/emptying-a-node
14747
while (container.lastChild) {
14748
container.removeChild(container.lastChild);
14749
}
14750
},
14751
14752
/**
14753
* Finds the container DOM element that contains React component to which the
14754
* supplied DOM `id` belongs.
14755
*
14756
* @param {string} id The ID of an element rendered by a React component.
14757
* @return {?DOMElement} DOM element that contains the `id`.
14758
*/
14759
findReactContainerForID: function(id) {
14760
var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
14761
var container = containersByReactRootID[reactRootID];
14762
14763
if ("production" !== process.env.NODE_ENV) {
14764
var rootElement = rootElementsByReactRootID[reactRootID];
14765
if (rootElement && rootElement.parentNode !== container) {
14766
("production" !== process.env.NODE_ENV ? invariant(
14767
// Call internalGetID here because getID calls isValid which calls
14768
// findReactContainerForID (this function).
14769
internalGetID(rootElement) === reactRootID,
14770
'ReactMount: Root element ID differed from reactRootID.'
14771
) : invariant(// Call internalGetID here because getID calls isValid which calls
14772
// findReactContainerForID (this function).
14773
internalGetID(rootElement) === reactRootID));
14774
14775
var containerChild = container.firstChild;
14776
if (containerChild &&
14777
reactRootID === internalGetID(containerChild)) {
14778
// If the container has a new child with the same ID as the old
14779
// root element, then rootElementsByReactRootID[reactRootID] is
14780
// just stale and needs to be updated. The case that deserves a
14781
// warning is when the container is empty.
14782
rootElementsByReactRootID[reactRootID] = containerChild;
14783
} else {
14784
("production" !== process.env.NODE_ENV ? warning(
14785
false,
14786
'ReactMount: Root element has been removed from its original ' +
14787
'container. New container:', rootElement.parentNode
14788
) : null);
14789
}
14790
}
14791
}
14792
14793
return container;
14794
},
14795
14796
/**
14797
* Finds an element rendered by React with the supplied ID.
14798
*
14799
* @param {string} id ID of a DOM node in the React component.
14800
* @return {DOMElement} Root DOM node of the React component.
14801
*/
14802
findReactNodeByID: function(id) {
14803
var reactRoot = ReactMount.findReactContainerForID(id);
14804
return ReactMount.findComponentRoot(reactRoot, id);
14805
},
14806
14807
/**
14808
* True if the supplied `node` is rendered by React.
14809
*
14810
* @param {*} node DOM Element to check.
14811
* @return {boolean} True if the DOM Element appears to be rendered by React.
14812
* @internal
14813
*/
14814
isRenderedByReact: function(node) {
14815
if (node.nodeType !== 1) {
14816
// Not a DOMElement, therefore not a React component
14817
return false;
14818
}
14819
var id = ReactMount.getID(node);
14820
return id ? id.charAt(0) === SEPARATOR : false;
14821
},
14822
14823
/**
14824
* Traverses up the ancestors of the supplied node to find a node that is a
14825
* DOM representation of a React component.
14826
*
14827
* @param {*} node
14828
* @return {?DOMEventTarget}
14829
* @internal
14830
*/
14831
getFirstReactDOM: function(node) {
14832
var current = node;
14833
while (current && current.parentNode !== current) {
14834
if (ReactMount.isRenderedByReact(current)) {
14835
return current;
14836
}
14837
current = current.parentNode;
14838
}
14839
return null;
14840
},
14841
14842
/**
14843
* Finds a node with the supplied `targetID` inside of the supplied
14844
* `ancestorNode`. Exploits the ID naming scheme to perform the search
14845
* quickly.
14846
*
14847
* @param {DOMEventTarget} ancestorNode Search from this root.
14848
* @pararm {string} targetID ID of the DOM representation of the component.
14849
* @return {DOMEventTarget} DOM node with the supplied `targetID`.
14850
* @internal
14851
*/
14852
findComponentRoot: function(ancestorNode, targetID) {
14853
var firstChildren = findComponentRootReusableArray;
14854
var childIndex = 0;
14855
14856
var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
14857
14858
firstChildren[0] = deepestAncestor.firstChild;
14859
firstChildren.length = 1;
14860
14861
while (childIndex < firstChildren.length) {
14862
var child = firstChildren[childIndex++];
14863
var targetChild;
14864
14865
while (child) {
14866
var childID = ReactMount.getID(child);
14867
if (childID) {
14868
// Even if we find the node we're looking for, we finish looping
14869
// through its siblings to ensure they're cached so that we don't have
14870
// to revisit this node again. Otherwise, we make n^2 calls to getID
14871
// when visiting the many children of a single node in order.
14872
14873
if (targetID === childID) {
14874
targetChild = child;
14875
} else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
14876
// If we find a child whose ID is an ancestor of the given ID,
14877
// then we can be sure that we only want to search the subtree
14878
// rooted at this child, so we can throw out the rest of the
14879
// search state.
14880
firstChildren.length = childIndex = 0;
14881
firstChildren.push(child.firstChild);
14882
}
14883
14884
} else {
14885
// If this child had no ID, then there's a chance that it was
14886
// injected automatically by the browser, as when a `<table>`
14887
// element sprouts an extra `<tbody>` child as a side effect of
14888
// `.innerHTML` parsing. Optimistically continue down this
14889
// branch, but not before examining the other siblings.
14890
firstChildren.push(child.firstChild);
14891
}
14892
14893
child = child.nextSibling;
14894
}
14895
14896
if (targetChild) {
14897
// Emptying firstChildren/findComponentRootReusableArray is
14898
// not necessary for correctness, but it helps the GC reclaim
14899
// any nodes that were left at the end of the search.
14900
firstChildren.length = 0;
14901
14902
return targetChild;
14903
}
14904
}
14905
14906
firstChildren.length = 0;
14907
14908
("production" !== process.env.NODE_ENV ? invariant(
14909
false,
14910
'findComponentRoot(..., %s): Unable to find element. This probably ' +
14911
'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
14912
'usually due to forgetting a <tbody> when using tables, nesting tags ' +
14913
'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
14914
'parent. ' +
14915
'Try inspecting the child nodes of the element with React ID `%s`.',
14916
targetID,
14917
ReactMount.getID(ancestorNode)
14918
) : invariant(false));
14919
},
14920
14921
_mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
14922
("production" !== process.env.NODE_ENV ? invariant(
14923
container && (
14924
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14925
),
14926
'mountComponentIntoNode(...): Target container is not valid.'
14927
) : invariant(container && (
14928
(container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
14929
)));
14930
14931
if (shouldReuseMarkup) {
14932
var rootElement = getReactRootElementInContainer(container);
14933
if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
14934
return;
14935
} else {
14936
var checksum = rootElement.getAttribute(
14937
ReactMarkupChecksum.CHECKSUM_ATTR_NAME
14938
);
14939
rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
14940
14941
var rootMarkup = rootElement.outerHTML;
14942
rootElement.setAttribute(
14943
ReactMarkupChecksum.CHECKSUM_ATTR_NAME,
14944
checksum
14945
);
14946
14947
var diffIndex = firstDifferenceIndex(markup, rootMarkup);
14948
var difference = ' (client) ' +
14949
markup.substring(diffIndex - 20, diffIndex + 20) +
14950
'\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
14951
14952
("production" !== process.env.NODE_ENV ? invariant(
14953
container.nodeType !== DOC_NODE_TYPE,
14954
'You\'re trying to render a component to the document using ' +
14955
'server rendering but the checksum was invalid. This usually ' +
14956
'means you rendered a different component type or props on ' +
14957
'the client from the one on the server, or your render() ' +
14958
'methods are impure. React cannot handle this case due to ' +
14959
'cross-browser quirks by rendering at the document root. You ' +
14960
'should look for environment dependent code in your components ' +
14961
'and ensure the props are the same client and server side:\n%s',
14962
difference
14963
) : invariant(container.nodeType !== DOC_NODE_TYPE));
14964
14965
if ("production" !== process.env.NODE_ENV) {
14966
("production" !== process.env.NODE_ENV ? warning(
14967
false,
14968
'React attempted to reuse markup in a container but the ' +
14969
'checksum was invalid. This generally means that you are ' +
14970
'using server rendering and the markup generated on the ' +
14971
'server was not what the client was expecting. React injected ' +
14972
'new markup to compensate which works but you have lost many ' +
14973
'of the benefits of server rendering. Instead, figure out ' +
14974
'why the markup being generated is different on the client ' +
14975
'or server:\n%s',
14976
difference
14977
) : null);
14978
}
14979
}
14980
}
14981
14982
("production" !== process.env.NODE_ENV ? invariant(
14983
container.nodeType !== DOC_NODE_TYPE,
14984
'You\'re trying to render a component to the document but ' +
14985
'you didn\'t use server rendering. We can\'t do this ' +
14986
'without using server rendering due to cross-browser quirks. ' +
14987
'See React.renderToString() for server rendering.'
14988
) : invariant(container.nodeType !== DOC_NODE_TYPE));
14989
14990
setInnerHTML(container, markup);
14991
},
14992
14993
/**
14994
* React ID utilities.
14995
*/
14996
14997
getReactRootID: getReactRootID,
14998
14999
getID: getID,
15000
15001
setID: setID,
15002
15003
getNode: getNode,
15004
15005
getNodeFromInstance: getNodeFromInstance,
15006
15007
purgeID: purgeID
15008
};
15009
15010
ReactPerf.measureMethods(ReactMount, 'ReactMount', {
15011
_renderNewRootComponent: '_renderNewRootComponent',
15012
_mountImageIntoNode: '_mountImageIntoNode'
15013
});
15014
15015
module.exports = ReactMount;
15016
15017
}).call(this,require('_process'))
15018
},{"./DOMProperty":24,"./ReactBrowserEventEmitter":46,"./ReactCurrentOwner":58,"./ReactElement":76,"./ReactElementValidator":77,"./ReactEmptyComponent":78,"./ReactInstanceHandles":85,"./ReactInstanceMap":86,"./ReactMarkupChecksum":89,"./ReactPerf":95,"./ReactReconciler":102,"./ReactUpdateQueue":112,"./ReactUpdates":113,"./containsNode":137,"./emptyObject":144,"./getReactRootElementInContainer":158,"./instantiateReactComponent":163,"./invariant":164,"./setInnerHTML":178,"./shouldUpdateReactComponent":181,"./warning":185,"_process":1}],91:[function(require,module,exports){
15019
/**
15020
* Copyright 2013-2015, Facebook, Inc.
15021
* All rights reserved.
15022
*
15023
* This source code is licensed under the BSD-style license found in the
15024
* LICENSE file in the root directory of this source tree. An additional grant
15025
* of patent rights can be found in the PATENTS file in the same directory.
15026
*
15027
* @providesModule ReactMultiChild
15028
* @typechecks static-only
15029
*/
15030
15031
'use strict';
15032
15033
var ReactComponentEnvironment = require("./ReactComponentEnvironment");
15034
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
15035
15036
var ReactReconciler = require("./ReactReconciler");
15037
var ReactChildReconciler = require("./ReactChildReconciler");
15038
15039
/**
15040
* Updating children of a component may trigger recursive updates. The depth is
15041
* used to batch recursive updates to render markup more efficiently.
15042
*
15043
* @type {number}
15044
* @private
15045
*/
15046
var updateDepth = 0;
15047
15048
/**
15049
* Queue of update configuration objects.
15050
*
15051
* Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
15052
*
15053
* @type {array<object>}
15054
* @private
15055
*/
15056
var updateQueue = [];
15057
15058
/**
15059
* Queue of markup to be rendered.
15060
*
15061
* @type {array<string>}
15062
* @private
15063
*/
15064
var markupQueue = [];
15065
15066
/**
15067
* Enqueues markup to be rendered and inserted at a supplied index.
15068
*
15069
* @param {string} parentID ID of the parent component.
15070
* @param {string} markup Markup that renders into an element.
15071
* @param {number} toIndex Destination index.
15072
* @private
15073
*/
15074
function enqueueMarkup(parentID, markup, toIndex) {
15075
// NOTE: Null values reduce hidden classes.
15076
updateQueue.push({
15077
parentID: parentID,
15078
parentNode: null,
15079
type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
15080
markupIndex: markupQueue.push(markup) - 1,
15081
textContent: null,
15082
fromIndex: null,
15083
toIndex: toIndex
15084
});
15085
}
15086
15087
/**
15088
* Enqueues moving an existing element to another index.
15089
*
15090
* @param {string} parentID ID of the parent component.
15091
* @param {number} fromIndex Source index of the existing element.
15092
* @param {number} toIndex Destination index of the element.
15093
* @private
15094
*/
15095
function enqueueMove(parentID, fromIndex, toIndex) {
15096
// NOTE: Null values reduce hidden classes.
15097
updateQueue.push({
15098
parentID: parentID,
15099
parentNode: null,
15100
type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
15101
markupIndex: null,
15102
textContent: null,
15103
fromIndex: fromIndex,
15104
toIndex: toIndex
15105
});
15106
}
15107
15108
/**
15109
* Enqueues removing an element at an index.
15110
*
15111
* @param {string} parentID ID of the parent component.
15112
* @param {number} fromIndex Index of the element to remove.
15113
* @private
15114
*/
15115
function enqueueRemove(parentID, fromIndex) {
15116
// NOTE: Null values reduce hidden classes.
15117
updateQueue.push({
15118
parentID: parentID,
15119
parentNode: null,
15120
type: ReactMultiChildUpdateTypes.REMOVE_NODE,
15121
markupIndex: null,
15122
textContent: null,
15123
fromIndex: fromIndex,
15124
toIndex: null
15125
});
15126
}
15127
15128
/**
15129
* Enqueues setting the text content.
15130
*
15131
* @param {string} parentID ID of the parent component.
15132
* @param {string} textContent Text content to set.
15133
* @private
15134
*/
15135
function enqueueTextContent(parentID, textContent) {
15136
// NOTE: Null values reduce hidden classes.
15137
updateQueue.push({
15138
parentID: parentID,
15139
parentNode: null,
15140
type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
15141
markupIndex: null,
15142
textContent: textContent,
15143
fromIndex: null,
15144
toIndex: null
15145
});
15146
}
15147
15148
/**
15149
* Processes any enqueued updates.
15150
*
15151
* @private
15152
*/
15153
function processQueue() {
15154
if (updateQueue.length) {
15155
ReactComponentEnvironment.processChildrenUpdates(
15156
updateQueue,
15157
markupQueue
15158
);
15159
clearQueue();
15160
}
15161
}
15162
15163
/**
15164
* Clears any enqueued updates.
15165
*
15166
* @private
15167
*/
15168
function clearQueue() {
15169
updateQueue.length = 0;
15170
markupQueue.length = 0;
15171
}
15172
15173
/**
15174
* ReactMultiChild are capable of reconciling multiple children.
15175
*
15176
* @class ReactMultiChild
15177
* @internal
15178
*/
15179
var ReactMultiChild = {
15180
15181
/**
15182
* Provides common functionality for components that must reconcile multiple
15183
* children. This is used by `ReactDOMComponent` to mount, update, and
15184
* unmount child components.
15185
*
15186
* @lends {ReactMultiChild.prototype}
15187
*/
15188
Mixin: {
15189
15190
/**
15191
* Generates a "mount image" for each of the supplied children. In the case
15192
* of `ReactDOMComponent`, a mount image is a string of markup.
15193
*
15194
* @param {?object} nestedChildren Nested child maps.
15195
* @return {array} An array of mounted representations.
15196
* @internal
15197
*/
15198
mountChildren: function(nestedChildren, transaction, context) {
15199
var children = ReactChildReconciler.instantiateChildren(
15200
nestedChildren, transaction, context
15201
);
15202
this._renderedChildren = children;
15203
var mountImages = [];
15204
var index = 0;
15205
for (var name in children) {
15206
if (children.hasOwnProperty(name)) {
15207
var child = children[name];
15208
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
15209
var rootID = this._rootNodeID + name;
15210
var mountImage = ReactReconciler.mountComponent(
15211
child,
15212
rootID,
15213
transaction,
15214
context
15215
);
15216
child._mountIndex = index;
15217
mountImages.push(mountImage);
15218
index++;
15219
}
15220
}
15221
return mountImages;
15222
},
15223
15224
/**
15225
* Replaces any rendered children with a text content string.
15226
*
15227
* @param {string} nextContent String of content.
15228
* @internal
15229
*/
15230
updateTextContent: function(nextContent) {
15231
updateDepth++;
15232
var errorThrown = true;
15233
try {
15234
var prevChildren = this._renderedChildren;
15235
// Remove any rendered children.
15236
ReactChildReconciler.unmountChildren(prevChildren);
15237
// TODO: The setTextContent operation should be enough
15238
for (var name in prevChildren) {
15239
if (prevChildren.hasOwnProperty(name)) {
15240
this._unmountChildByName(prevChildren[name], name);
15241
}
15242
}
15243
// Set new text content.
15244
this.setTextContent(nextContent);
15245
errorThrown = false;
15246
} finally {
15247
updateDepth--;
15248
if (!updateDepth) {
15249
if (errorThrown) {
15250
clearQueue();
15251
} else {
15252
processQueue();
15253
}
15254
}
15255
}
15256
},
15257
15258
/**
15259
* Updates the rendered children with new children.
15260
*
15261
* @param {?object} nextNestedChildren Nested child maps.
15262
* @param {ReactReconcileTransaction} transaction
15263
* @internal
15264
*/
15265
updateChildren: function(nextNestedChildren, transaction, context) {
15266
updateDepth++;
15267
var errorThrown = true;
15268
try {
15269
this._updateChildren(nextNestedChildren, transaction, context);
15270
errorThrown = false;
15271
} finally {
15272
updateDepth--;
15273
if (!updateDepth) {
15274
if (errorThrown) {
15275
clearQueue();
15276
} else {
15277
processQueue();
15278
}
15279
}
15280
15281
}
15282
},
15283
15284
/**
15285
* Improve performance by isolating this hot code path from the try/catch
15286
* block in `updateChildren`.
15287
*
15288
* @param {?object} nextNestedChildren Nested child maps.
15289
* @param {ReactReconcileTransaction} transaction
15290
* @final
15291
* @protected
15292
*/
15293
_updateChildren: function(nextNestedChildren, transaction, context) {
15294
var prevChildren = this._renderedChildren;
15295
var nextChildren = ReactChildReconciler.updateChildren(
15296
prevChildren, nextNestedChildren, transaction, context
15297
);
15298
this._renderedChildren = nextChildren;
15299
if (!nextChildren && !prevChildren) {
15300
return;
15301
}
15302
var name;
15303
// `nextIndex` will increment for each child in `nextChildren`, but
15304
// `lastIndex` will be the last index visited in `prevChildren`.
15305
var lastIndex = 0;
15306
var nextIndex = 0;
15307
for (name in nextChildren) {
15308
if (!nextChildren.hasOwnProperty(name)) {
15309
continue;
15310
}
15311
var prevChild = prevChildren && prevChildren[name];
15312
var nextChild = nextChildren[name];
15313
if (prevChild === nextChild) {
15314
this.moveChild(prevChild, nextIndex, lastIndex);
15315
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
15316
prevChild._mountIndex = nextIndex;
15317
} else {
15318
if (prevChild) {
15319
// Update `lastIndex` before `_mountIndex` gets unset by unmounting.
15320
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
15321
this._unmountChildByName(prevChild, name);
15322
}
15323
// The child must be instantiated before it's mounted.
15324
this._mountChildByNameAtIndex(
15325
nextChild, name, nextIndex, transaction, context
15326
);
15327
}
15328
nextIndex++;
15329
}
15330
// Remove children that are no longer present.
15331
for (name in prevChildren) {
15332
if (prevChildren.hasOwnProperty(name) &&
15333
!(nextChildren && nextChildren.hasOwnProperty(name))) {
15334
this._unmountChildByName(prevChildren[name], name);
15335
}
15336
}
15337
},
15338
15339
/**
15340
* Unmounts all rendered children. This should be used to clean up children
15341
* when this component is unmounted.
15342
*
15343
* @internal
15344
*/
15345
unmountChildren: function() {
15346
var renderedChildren = this._renderedChildren;
15347
ReactChildReconciler.unmountChildren(renderedChildren);
15348
this._renderedChildren = null;
15349
},
15350
15351
/**
15352
* Moves a child component to the supplied index.
15353
*
15354
* @param {ReactComponent} child Component to move.
15355
* @param {number} toIndex Destination index of the element.
15356
* @param {number} lastIndex Last index visited of the siblings of `child`.
15357
* @protected
15358
*/
15359
moveChild: function(child, toIndex, lastIndex) {
15360
// If the index of `child` is less than `lastIndex`, then it needs to
15361
// be moved. Otherwise, we do not need to move it because a child will be
15362
// inserted or moved before `child`.
15363
if (child._mountIndex < lastIndex) {
15364
enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
15365
}
15366
},
15367
15368
/**
15369
* Creates a child component.
15370
*
15371
* @param {ReactComponent} child Component to create.
15372
* @param {string} mountImage Markup to insert.
15373
* @protected
15374
*/
15375
createChild: function(child, mountImage) {
15376
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
15377
},
15378
15379
/**
15380
* Removes a child component.
15381
*
15382
* @param {ReactComponent} child Child to remove.
15383
* @protected
15384
*/
15385
removeChild: function(child) {
15386
enqueueRemove(this._rootNodeID, child._mountIndex);
15387
},
15388
15389
/**
15390
* Sets this text content string.
15391
*
15392
* @param {string} textContent Text content to set.
15393
* @protected
15394
*/
15395
setTextContent: function(textContent) {
15396
enqueueTextContent(this._rootNodeID, textContent);
15397
},
15398
15399
/**
15400
* Mounts a child with the supplied name.
15401
*
15402
* NOTE: This is part of `updateChildren` and is here for readability.
15403
*
15404
* @param {ReactComponent} child Component to mount.
15405
* @param {string} name Name of the child.
15406
* @param {number} index Index at which to insert the child.
15407
* @param {ReactReconcileTransaction} transaction
15408
* @private
15409
*/
15410
_mountChildByNameAtIndex: function(
15411
child,
15412
name,
15413
index,
15414
transaction,
15415
context) {
15416
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
15417
var rootID = this._rootNodeID + name;
15418
var mountImage = ReactReconciler.mountComponent(
15419
child,
15420
rootID,
15421
transaction,
15422
context
15423
);
15424
child._mountIndex = index;
15425
this.createChild(child, mountImage);
15426
},
15427
15428
/**
15429
* Unmounts a rendered child by name.
15430
*
15431
* NOTE: This is part of `updateChildren` and is here for readability.
15432
*
15433
* @param {ReactComponent} child Component to unmount.
15434
* @param {string} name Name of the child in `this._renderedChildren`.
15435
* @private
15436
*/
15437
_unmountChildByName: function(child, name) {
15438
this.removeChild(child);
15439
child._mountIndex = null;
15440
}
15441
15442
}
15443
15444
};
15445
15446
module.exports = ReactMultiChild;
15447
15448
},{"./ReactChildReconciler":49,"./ReactComponentEnvironment":54,"./ReactMultiChildUpdateTypes":92,"./ReactReconciler":102}],92:[function(require,module,exports){
15449
/**
15450
* Copyright 2013-2015, Facebook, Inc.
15451
* All rights reserved.
15452
*
15453
* This source code is licensed under the BSD-style license found in the
15454
* LICENSE file in the root directory of this source tree. An additional grant
15455
* of patent rights can be found in the PATENTS file in the same directory.
15456
*
15457
* @providesModule ReactMultiChildUpdateTypes
15458
*/
15459
15460
'use strict';
15461
15462
var keyMirror = require("./keyMirror");
15463
15464
/**
15465
* When a component's children are updated, a series of update configuration
15466
* objects are created in order to batch and serialize the required changes.
15467
*
15468
* Enumerates all the possible types of update configurations.
15469
*
15470
* @internal
15471
*/
15472
var ReactMultiChildUpdateTypes = keyMirror({
15473
INSERT_MARKUP: null,
15474
MOVE_EXISTING: null,
15475
REMOVE_NODE: null,
15476
TEXT_CONTENT: null
15477
});
15478
15479
module.exports = ReactMultiChildUpdateTypes;
15480
15481
},{"./keyMirror":170}],93:[function(require,module,exports){
15482
(function (process){
15483
/**
15484
* Copyright 2014-2015, Facebook, Inc.
15485
* All rights reserved.
15486
*
15487
* This source code is licensed under the BSD-style license found in the
15488
* LICENSE file in the root directory of this source tree. An additional grant
15489
* of patent rights can be found in the PATENTS file in the same directory.
15490
*
15491
* @providesModule ReactNativeComponent
15492
*/
15493
15494
'use strict';
15495
15496
var assign = require("./Object.assign");
15497
var invariant = require("./invariant");
15498
15499
var autoGenerateWrapperClass = null;
15500
var genericComponentClass = null;
15501
// This registry keeps track of wrapper classes around native tags
15502
var tagToComponentClass = {};
15503
var textComponentClass = null;
15504
15505
var ReactNativeComponentInjection = {
15506
// This accepts a class that receives the tag string. This is a catch all
15507
// that can render any kind of tag.
15508
injectGenericComponentClass: function(componentClass) {
15509
genericComponentClass = componentClass;
15510
},
15511
// This accepts a text component class that takes the text string to be
15512
// rendered as props.
15513
injectTextComponentClass: function(componentClass) {
15514
textComponentClass = componentClass;
15515
},
15516
// This accepts a keyed object with classes as values. Each key represents a
15517
// tag. That particular tag will use this class instead of the generic one.
15518
injectComponentClasses: function(componentClasses) {
15519
assign(tagToComponentClass, componentClasses);
15520
},
15521
// Temporary hack since we expect DOM refs to behave like composites,
15522
// for this release.
15523
injectAutoWrapper: function(wrapperFactory) {
15524
autoGenerateWrapperClass = wrapperFactory;
15525
}
15526
};
15527
15528
/**
15529
* Get a composite component wrapper class for a specific tag.
15530
*
15531
* @param {ReactElement} element The tag for which to get the class.
15532
* @return {function} The React class constructor function.
15533
*/
15534
function getComponentClassForElement(element) {
15535
if (typeof element.type === 'function') {
15536
return element.type;
15537
}
15538
var tag = element.type;
15539
var componentClass = tagToComponentClass[tag];
15540
if (componentClass == null) {
15541
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
15542
}
15543
return componentClass;
15544
}
15545
15546
/**
15547
* Get a native internal component class for a specific tag.
15548
*
15549
* @param {ReactElement} element The element to create.
15550
* @return {function} The internal class constructor function.
15551
*/
15552
function createInternalComponent(element) {
15553
("production" !== process.env.NODE_ENV ? invariant(
15554
genericComponentClass,
15555
'There is no registered component for the tag %s',
15556
element.type
15557
) : invariant(genericComponentClass));
15558
return new genericComponentClass(element.type, element.props);
15559
}
15560
15561
/**
15562
* @param {ReactText} text
15563
* @return {ReactComponent}
15564
*/
15565
function createInstanceForText(text) {
15566
return new textComponentClass(text);
15567
}
15568
15569
/**
15570
* @param {ReactComponent} component
15571
* @return {boolean}
15572
*/
15573
function isTextComponent(component) {
15574
return component instanceof textComponentClass;
15575
}
15576
15577
var ReactNativeComponent = {
15578
getComponentClassForElement: getComponentClassForElement,
15579
createInternalComponent: createInternalComponent,
15580
createInstanceForText: createInstanceForText,
15581
isTextComponent: isTextComponent,
15582
injection: ReactNativeComponentInjection
15583
};
15584
15585
module.exports = ReactNativeComponent;
15586
15587
}).call(this,require('_process'))
15588
},{"./Object.assign":42,"./invariant":164,"_process":1}],94:[function(require,module,exports){
15589
(function (process){
15590
/**
15591
* Copyright 2013-2015, Facebook, Inc.
15592
* All rights reserved.
15593
*
15594
* This source code is licensed under the BSD-style license found in the
15595
* LICENSE file in the root directory of this source tree. An additional grant
15596
* of patent rights can be found in the PATENTS file in the same directory.
15597
*
15598
* @providesModule ReactOwner
15599
*/
15600
15601
'use strict';
15602
15603
var invariant = require("./invariant");
15604
15605
/**
15606
* ReactOwners are capable of storing references to owned components.
15607
*
15608
* All components are capable of //being// referenced by owner components, but
15609
* only ReactOwner components are capable of //referencing// owned components.
15610
* The named reference is known as a "ref".
15611
*
15612
* Refs are available when mounted and updated during reconciliation.
15613
*
15614
* var MyComponent = React.createClass({
15615
* render: function() {
15616
* return (
15617
* <div onClick={this.handleClick}>
15618
* <CustomComponent ref="custom" />
15619
* </div>
15620
* );
15621
* },
15622
* handleClick: function() {
15623
* this.refs.custom.handleClick();
15624
* },
15625
* componentDidMount: function() {
15626
* this.refs.custom.initialize();
15627
* }
15628
* });
15629
*
15630
* Refs should rarely be used. When refs are used, they should only be done to
15631
* control data that is not handled by React's data flow.
15632
*
15633
* @class ReactOwner
15634
*/
15635
var ReactOwner = {
15636
15637
/**
15638
* @param {?object} object
15639
* @return {boolean} True if `object` is a valid owner.
15640
* @final
15641
*/
15642
isValidOwner: function(object) {
15643
return !!(
15644
(object &&
15645
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
15646
);
15647
},
15648
15649
/**
15650
* Adds a component by ref to an owner component.
15651
*
15652
* @param {ReactComponent} component Component to reference.
15653
* @param {string} ref Name by which to refer to the component.
15654
* @param {ReactOwner} owner Component on which to record the ref.
15655
* @final
15656
* @internal
15657
*/
15658
addComponentAsRefTo: function(component, ref, owner) {
15659
("production" !== process.env.NODE_ENV ? invariant(
15660
ReactOwner.isValidOwner(owner),
15661
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
15662
'usually means that you\'re trying to add a ref to a component that ' +
15663
'doesn\'t have an owner (that is, was not created inside of another ' +
15664
'component\'s `render` method). Try rendering this component inside of ' +
15665
'a new top-level component which will hold the ref.'
15666
) : invariant(ReactOwner.isValidOwner(owner)));
15667
owner.attachRef(ref, component);
15668
},
15669
15670
/**
15671
* Removes a component by ref from an owner component.
15672
*
15673
* @param {ReactComponent} component Component to dereference.
15674
* @param {string} ref Name of the ref to remove.
15675
* @param {ReactOwner} owner Component on which the ref is recorded.
15676
* @final
15677
* @internal
15678
*/
15679
removeComponentAsRefFrom: function(component, ref, owner) {
15680
("production" !== process.env.NODE_ENV ? invariant(
15681
ReactOwner.isValidOwner(owner),
15682
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
15683
'usually means that you\'re trying to remove a ref to a component that ' +
15684
'doesn\'t have an owner (that is, was not created inside of another ' +
15685
'component\'s `render` method). Try rendering this component inside of ' +
15686
'a new top-level component which will hold the ref.'
15687
) : invariant(ReactOwner.isValidOwner(owner)));
15688
// Check that `component` is still the current ref because we do not want to
15689
// detach the ref if another component stole it.
15690
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
15691
owner.detachRef(ref);
15692
}
15693
}
15694
15695
};
15696
15697
module.exports = ReactOwner;
15698
15699
}).call(this,require('_process'))
15700
},{"./invariant":164,"_process":1}],95:[function(require,module,exports){
15701
(function (process){
15702
/**
15703
* Copyright 2013-2015, Facebook, Inc.
15704
* All rights reserved.
15705
*
15706
* This source code is licensed under the BSD-style license found in the
15707
* LICENSE file in the root directory of this source tree. An additional grant
15708
* of patent rights can be found in the PATENTS file in the same directory.
15709
*
15710
* @providesModule ReactPerf
15711
* @typechecks static-only
15712
*/
15713
15714
'use strict';
15715
15716
/**
15717
* ReactPerf is a general AOP system designed to measure performance. This
15718
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
15719
*/
15720
var ReactPerf = {
15721
/**
15722
* Boolean to enable/disable measurement. Set to false by default to prevent
15723
* accidental logging and perf loss.
15724
*/
15725
enableMeasure: false,
15726
15727
/**
15728
* Holds onto the measure function in use. By default, don't measure
15729
* anything, but we'll override this if we inject a measure function.
15730
*/
15731
storedMeasure: _noMeasure,
15732
15733
/**
15734
* @param {object} object
15735
* @param {string} objectName
15736
* @param {object<string>} methodNames
15737
*/
15738
measureMethods: function(object, objectName, methodNames) {
15739
if ("production" !== process.env.NODE_ENV) {
15740
for (var key in methodNames) {
15741
if (!methodNames.hasOwnProperty(key)) {
15742
continue;
15743
}
15744
object[key] = ReactPerf.measure(
15745
objectName,
15746
methodNames[key],
15747
object[key]
15748
);
15749
}
15750
}
15751
},
15752
15753
/**
15754
* Use this to wrap methods you want to measure. Zero overhead in production.
15755
*
15756
* @param {string} objName
15757
* @param {string} fnName
15758
* @param {function} func
15759
* @return {function}
15760
*/
15761
measure: function(objName, fnName, func) {
15762
if ("production" !== process.env.NODE_ENV) {
15763
var measuredFunc = null;
15764
var wrapper = function() {
15765
if (ReactPerf.enableMeasure) {
15766
if (!measuredFunc) {
15767
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
15768
}
15769
return measuredFunc.apply(this, arguments);
15770
}
15771
return func.apply(this, arguments);
15772
};
15773
wrapper.displayName = objName + '_' + fnName;
15774
return wrapper;
15775
}
15776
return func;
15777
},
15778
15779
injection: {
15780
/**
15781
* @param {function} measure
15782
*/
15783
injectMeasure: function(measure) {
15784
ReactPerf.storedMeasure = measure;
15785
}
15786
}
15787
};
15788
15789
/**
15790
* Simply passes through the measured function, without measuring it.
15791
*
15792
* @param {string} objName
15793
* @param {string} fnName
15794
* @param {function} func
15795
* @return {function}
15796
*/
15797
function _noMeasure(objName, fnName, func) {
15798
return func;
15799
}
15800
15801
module.exports = ReactPerf;
15802
15803
}).call(this,require('_process'))
15804
},{"_process":1}],96:[function(require,module,exports){
15805
/**
15806
* Copyright 2013-2015, Facebook, Inc.
15807
* All rights reserved.
15808
*
15809
* This source code is licensed under the BSD-style license found in the
15810
* LICENSE file in the root directory of this source tree. An additional grant
15811
* of patent rights can be found in the PATENTS file in the same directory.
15812
*
15813
* @providesModule ReactPropTransferer
15814
*/
15815
15816
'use strict';
15817
15818
var assign = require("./Object.assign");
15819
var emptyFunction = require("./emptyFunction");
15820
var joinClasses = require("./joinClasses");
15821
15822
/**
15823
* Creates a transfer strategy that will merge prop values using the supplied
15824
* `mergeStrategy`. If a prop was previously unset, this just sets it.
15825
*
15826
* @param {function} mergeStrategy
15827
* @return {function}
15828
*/
15829
function createTransferStrategy(mergeStrategy) {
15830
return function(props, key, value) {
15831
if (!props.hasOwnProperty(key)) {
15832
props[key] = value;
15833
} else {
15834
props[key] = mergeStrategy(props[key], value);
15835
}
15836
};
15837
}
15838
15839
var transferStrategyMerge = createTransferStrategy(function(a, b) {
15840
// `merge` overrides the first object's (`props[key]` above) keys using the
15841
// second object's (`value`) keys. An object's style's existing `propA` would
15842
// get overridden. Flip the order here.
15843
return assign({}, b, a);
15844
});
15845
15846
/**
15847
* Transfer strategies dictate how props are transferred by `transferPropsTo`.
15848
* NOTE: if you add any more exceptions to this list you should be sure to
15849
* update `cloneWithProps()` accordingly.
15850
*/
15851
var TransferStrategies = {
15852
/**
15853
* Never transfer `children`.
15854
*/
15855
children: emptyFunction,
15856
/**
15857
* Transfer the `className` prop by merging them.
15858
*/
15859
className: createTransferStrategy(joinClasses),
15860
/**
15861
* Transfer the `style` prop (which is an object) by merging them.
15862
*/
15863
style: transferStrategyMerge
15864
};
15865
15866
/**
15867
* Mutates the first argument by transferring the properties from the second
15868
* argument.
15869
*
15870
* @param {object} props
15871
* @param {object} newProps
15872
* @return {object}
15873
*/
15874
function transferInto(props, newProps) {
15875
for (var thisKey in newProps) {
15876
if (!newProps.hasOwnProperty(thisKey)) {
15877
continue;
15878
}
15879
15880
var transferStrategy = TransferStrategies[thisKey];
15881
15882
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
15883
transferStrategy(props, thisKey, newProps[thisKey]);
15884
} else if (!props.hasOwnProperty(thisKey)) {
15885
props[thisKey] = newProps[thisKey];
15886
}
15887
}
15888
return props;
15889
}
15890
15891
/**
15892
* ReactPropTransferer are capable of transferring props to another component
15893
* using a `transferPropsTo` method.
15894
*
15895
* @class ReactPropTransferer
15896
*/
15897
var ReactPropTransferer = {
15898
15899
/**
15900
* Merge two props objects using TransferStrategies.
15901
*
15902
* @param {object} oldProps original props (they take precedence)
15903
* @param {object} newProps new props to merge in
15904
* @return {object} a new object containing both sets of props merged.
15905
*/
15906
mergeProps: function(oldProps, newProps) {
15907
return transferInto(assign({}, oldProps), newProps);
15908
}
15909
15910
};
15911
15912
module.exports = ReactPropTransferer;
15913
15914
},{"./Object.assign":42,"./emptyFunction":143,"./joinClasses":169}],97:[function(require,module,exports){
15915
(function (process){
15916
/**
15917
* Copyright 2013-2015, Facebook, Inc.
15918
* All rights reserved.
15919
*
15920
* This source code is licensed under the BSD-style license found in the
15921
* LICENSE file in the root directory of this source tree. An additional grant
15922
* of patent rights can be found in the PATENTS file in the same directory.
15923
*
15924
* @providesModule ReactPropTypeLocationNames
15925
*/
15926
15927
'use strict';
15928
15929
var ReactPropTypeLocationNames = {};
15930
15931
if ("production" !== process.env.NODE_ENV) {
15932
ReactPropTypeLocationNames = {
15933
prop: 'prop',
15934
context: 'context',
15935
childContext: 'child context'
15936
};
15937
}
15938
15939
module.exports = ReactPropTypeLocationNames;
15940
15941
}).call(this,require('_process'))
15942
},{"_process":1}],98:[function(require,module,exports){
15943
/**
15944
* Copyright 2013-2015, Facebook, Inc.
15945
* All rights reserved.
15946
*
15947
* This source code is licensed under the BSD-style license found in the
15948
* LICENSE file in the root directory of this source tree. An additional grant
15949
* of patent rights can be found in the PATENTS file in the same directory.
15950
*
15951
* @providesModule ReactPropTypeLocations
15952
*/
15953
15954
'use strict';
15955
15956
var keyMirror = require("./keyMirror");
15957
15958
var ReactPropTypeLocations = keyMirror({
15959
prop: null,
15960
context: null,
15961
childContext: null
15962
});
15963
15964
module.exports = ReactPropTypeLocations;
15965
15966
},{"./keyMirror":170}],99:[function(require,module,exports){
15967
/**
15968
* Copyright 2013-2015, Facebook, Inc.
15969
* All rights reserved.
15970
*
15971
* This source code is licensed under the BSD-style license found in the
15972
* LICENSE file in the root directory of this source tree. An additional grant
15973
* of patent rights can be found in the PATENTS file in the same directory.
15974
*
15975
* @providesModule ReactPropTypes
15976
*/
15977
15978
'use strict';
15979
15980
var ReactElement = require("./ReactElement");
15981
var ReactFragment = require("./ReactFragment");
15982
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
15983
15984
var emptyFunction = require("./emptyFunction");
15985
15986
/**
15987
* Collection of methods that allow declaration and validation of props that are
15988
* supplied to React components. Example usage:
15989
*
15990
* var Props = require('ReactPropTypes');
15991
* var MyArticle = React.createClass({
15992
* propTypes: {
15993
* // An optional string prop named "description".
15994
* description: Props.string,
15995
*
15996
* // A required enum prop named "category".
15997
* category: Props.oneOf(['News','Photos']).isRequired,
15998
*
15999
* // A prop named "dialog" that requires an instance of Dialog.
16000
* dialog: Props.instanceOf(Dialog).isRequired
16001
* },
16002
* render: function() { ... }
16003
* });
16004
*
16005
* A more formal specification of how these methods are used:
16006
*
16007
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
16008
* decl := ReactPropTypes.{type}(.isRequired)?
16009
*
16010
* Each and every declaration produces a function with the same signature. This
16011
* allows the creation of custom validation functions. For example:
16012
*
16013
* var MyLink = React.createClass({
16014
* propTypes: {
16015
* // An optional string or URI prop named "href".
16016
* href: function(props, propName, componentName) {
16017
* var propValue = props[propName];
16018
* if (propValue != null && typeof propValue !== 'string' &&
16019
* !(propValue instanceof URI)) {
16020
* return new Error(
16021
* 'Expected a string or an URI for ' + propName + ' in ' +
16022
* componentName
16023
* );
16024
* }
16025
* }
16026
* },
16027
* render: function() {...}
16028
* });
16029
*
16030
* @internal
16031
*/
16032
16033
var ANONYMOUS = '<<anonymous>>';
16034
16035
var elementTypeChecker = createElementTypeChecker();
16036
var nodeTypeChecker = createNodeChecker();
16037
16038
var ReactPropTypes = {
16039
array: createPrimitiveTypeChecker('array'),
16040
bool: createPrimitiveTypeChecker('boolean'),
16041
func: createPrimitiveTypeChecker('function'),
16042
number: createPrimitiveTypeChecker('number'),
16043
object: createPrimitiveTypeChecker('object'),
16044
string: createPrimitiveTypeChecker('string'),
16045
16046
any: createAnyTypeChecker(),
16047
arrayOf: createArrayOfTypeChecker,
16048
element: elementTypeChecker,
16049
instanceOf: createInstanceTypeChecker,
16050
node: nodeTypeChecker,
16051
objectOf: createObjectOfTypeChecker,
16052
oneOf: createEnumTypeChecker,
16053
oneOfType: createUnionTypeChecker,
16054
shape: createShapeTypeChecker
16055
};
16056
16057
function createChainableTypeChecker(validate) {
16058
function checkType(isRequired, props, propName, componentName, location) {
16059
componentName = componentName || ANONYMOUS;
16060
if (props[propName] == null) {
16061
var locationName = ReactPropTypeLocationNames[location];
16062
if (isRequired) {
16063
return new Error(
16064
("Required " + locationName + " `" + propName + "` was not specified in ") +
16065
("`" + componentName + "`.")
16066
);
16067
}
16068
return null;
16069
} else {
16070
return validate(props, propName, componentName, location);
16071
}
16072
}
16073
16074
var chainedCheckType = checkType.bind(null, false);
16075
chainedCheckType.isRequired = checkType.bind(null, true);
16076
16077
return chainedCheckType;
16078
}
16079
16080
function createPrimitiveTypeChecker(expectedType) {
16081
function validate(props, propName, componentName, location) {
16082
var propValue = props[propName];
16083
var propType = getPropType(propValue);
16084
if (propType !== expectedType) {
16085
var locationName = ReactPropTypeLocationNames[location];
16086
// `propValue` being instance of, say, date/regexp, pass the 'object'
16087
// check, but we can offer a more precise error message here rather than
16088
// 'of type `object`'.
16089
var preciseType = getPreciseType(propValue);
16090
16091
return new Error(
16092
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
16093
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
16094
);
16095
}
16096
return null;
16097
}
16098
return createChainableTypeChecker(validate);
16099
}
16100
16101
function createAnyTypeChecker() {
16102
return createChainableTypeChecker(emptyFunction.thatReturns(null));
16103
}
16104
16105
function createArrayOfTypeChecker(typeChecker) {
16106
function validate(props, propName, componentName, location) {
16107
var propValue = props[propName];
16108
if (!Array.isArray(propValue)) {
16109
var locationName = ReactPropTypeLocationNames[location];
16110
var propType = getPropType(propValue);
16111
return new Error(
16112
("Invalid " + locationName + " `" + propName + "` of type ") +
16113
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
16114
);
16115
}
16116
for (var i = 0; i < propValue.length; i++) {
16117
var error = typeChecker(propValue, i, componentName, location);
16118
if (error instanceof Error) {
16119
return error;
16120
}
16121
}
16122
return null;
16123
}
16124
return createChainableTypeChecker(validate);
16125
}
16126
16127
function createElementTypeChecker() {
16128
function validate(props, propName, componentName, location) {
16129
if (!ReactElement.isValidElement(props[propName])) {
16130
var locationName = ReactPropTypeLocationNames[location];
16131
return new Error(
16132
("Invalid " + locationName + " `" + propName + "` supplied to ") +
16133
("`" + componentName + "`, expected a ReactElement.")
16134
);
16135
}
16136
return null;
16137
}
16138
return createChainableTypeChecker(validate);
16139
}
16140
16141
function createInstanceTypeChecker(expectedClass) {
16142
function validate(props, propName, componentName, location) {
16143
if (!(props[propName] instanceof expectedClass)) {
16144
var locationName = ReactPropTypeLocationNames[location];
16145
var expectedClassName = expectedClass.name || ANONYMOUS;
16146
return new Error(
16147
("Invalid " + locationName + " `" + propName + "` supplied to ") +
16148
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
16149
);
16150
}
16151
return null;
16152
}
16153
return createChainableTypeChecker(validate);
16154
}
16155
16156
function createEnumTypeChecker(expectedValues) {
16157
function validate(props, propName, componentName, location) {
16158
var propValue = props[propName];
16159
for (var i = 0; i < expectedValues.length; i++) {
16160
if (propValue === expectedValues[i]) {
16161
return null;
16162
}
16163
}
16164
16165
var locationName = ReactPropTypeLocationNames[location];
16166
var valuesString = JSON.stringify(expectedValues);
16167
return new Error(
16168
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
16169
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
16170
);
16171
}
16172
return createChainableTypeChecker(validate);
16173
}
16174
16175
function createObjectOfTypeChecker(typeChecker) {
16176
function validate(props, propName, componentName, location) {
16177
var propValue = props[propName];
16178
var propType = getPropType(propValue);
16179
if (propType !== 'object') {
16180
var locationName = ReactPropTypeLocationNames[location];
16181
return new Error(
16182
("Invalid " + locationName + " `" + propName + "` of type ") +
16183
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
16184
);
16185
}
16186
for (var key in propValue) {
16187
if (propValue.hasOwnProperty(key)) {
16188
var error = typeChecker(propValue, key, componentName, location);
16189
if (error instanceof Error) {
16190
return error;
16191
}
16192
}
16193
}
16194
return null;
16195
}
16196
return createChainableTypeChecker(validate);
16197
}
16198
16199
function createUnionTypeChecker(arrayOfTypeCheckers) {
16200
function validate(props, propName, componentName, location) {
16201
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
16202
var checker = arrayOfTypeCheckers[i];
16203
if (checker(props, propName, componentName, location) == null) {
16204
return null;
16205
}
16206
}
16207
16208
var locationName = ReactPropTypeLocationNames[location];
16209
return new Error(
16210
("Invalid " + locationName + " `" + propName + "` supplied to ") +
16211
("`" + componentName + "`.")
16212
);
16213
}
16214
return createChainableTypeChecker(validate);
16215
}
16216
16217
function createNodeChecker() {
16218
function validate(props, propName, componentName, location) {
16219
if (!isNode(props[propName])) {
16220
var locationName = ReactPropTypeLocationNames[location];
16221
return new Error(
16222
("Invalid " + locationName + " `" + propName + "` supplied to ") +
16223
("`" + componentName + "`, expected a ReactNode.")
16224
);
16225
}
16226
return null;
16227
}
16228
return createChainableTypeChecker(validate);
16229
}
16230
16231
function createShapeTypeChecker(shapeTypes) {
16232
function validate(props, propName, componentName, location) {
16233
var propValue = props[propName];
16234
var propType = getPropType(propValue);
16235
if (propType !== 'object') {
16236
var locationName = ReactPropTypeLocationNames[location];
16237
return new Error(
16238
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
16239
("supplied to `" + componentName + "`, expected `object`.")
16240
);
16241
}
16242
for (var key in shapeTypes) {
16243
var checker = shapeTypes[key];
16244
if (!checker) {
16245
continue;
16246
}
16247
var error = checker(propValue, key, componentName, location);
16248
if (error) {
16249
return error;
16250
}
16251
}
16252
return null;
16253
}
16254
return createChainableTypeChecker(validate);
16255
}
16256
16257
function isNode(propValue) {
16258
switch (typeof propValue) {
16259
case 'number':
16260
case 'string':
16261
case 'undefined':
16262
return true;
16263
case 'boolean':
16264
return !propValue;
16265
case 'object':
16266
if (Array.isArray(propValue)) {
16267
return propValue.every(isNode);
16268
}
16269
if (propValue === null || ReactElement.isValidElement(propValue)) {
16270
return true;
16271
}
16272
propValue = ReactFragment.extractIfFragment(propValue);
16273
for (var k in propValue) {
16274
if (!isNode(propValue[k])) {
16275
return false;
16276
}
16277
}
16278
return true;
16279
default:
16280
return false;
16281
}
16282
}
16283
16284
// Equivalent of `typeof` but with special handling for array and regexp.
16285
function getPropType(propValue) {
16286
var propType = typeof propValue;
16287
if (Array.isArray(propValue)) {
16288
return 'array';
16289
}
16290
if (propValue instanceof RegExp) {
16291
// Old webkits (at least until Android 4.0) return 'function' rather than
16292
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
16293
// passes PropTypes.object.
16294
return 'object';
16295
}
16296
return propType;
16297
}
16298
16299
// This handles more types than `getPropType`. Only used for error messages.
16300
// See `createPrimitiveTypeChecker`.
16301
function getPreciseType(propValue) {
16302
var propType = getPropType(propValue);
16303
if (propType === 'object') {
16304
if (propValue instanceof Date) {
16305
return 'date';
16306
} else if (propValue instanceof RegExp) {
16307
return 'regexp';
16308
}
16309
}
16310
return propType;
16311
}
16312
16313
module.exports = ReactPropTypes;
16314
16315
},{"./ReactElement":76,"./ReactFragment":82,"./ReactPropTypeLocationNames":97,"./emptyFunction":143}],100:[function(require,module,exports){
16316
/**
16317
* Copyright 2013-2015, Facebook, Inc.
16318
* All rights reserved.
16319
*
16320
* This source code is licensed under the BSD-style license found in the
16321
* LICENSE file in the root directory of this source tree. An additional grant
16322
* of patent rights can be found in the PATENTS file in the same directory.
16323
*
16324
* @providesModule ReactPutListenerQueue
16325
*/
16326
16327
'use strict';
16328
16329
var PooledClass = require("./PooledClass");
16330
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
16331
16332
var assign = require("./Object.assign");
16333
16334
function ReactPutListenerQueue() {
16335
this.listenersToPut = [];
16336
}
16337
16338
assign(ReactPutListenerQueue.prototype, {
16339
enqueuePutListener: function(rootNodeID, propKey, propValue) {
16340
this.listenersToPut.push({
16341
rootNodeID: rootNodeID,
16342
propKey: propKey,
16343
propValue: propValue
16344
});
16345
},
16346
16347
putListeners: function() {
16348
for (var i = 0; i < this.listenersToPut.length; i++) {
16349
var listenerToPut = this.listenersToPut[i];
16350
ReactBrowserEventEmitter.putListener(
16351
listenerToPut.rootNodeID,
16352
listenerToPut.propKey,
16353
listenerToPut.propValue
16354
);
16355
}
16356
},
16357
16358
reset: function() {
16359
this.listenersToPut.length = 0;
16360
},
16361
16362
destructor: function() {
16363
this.reset();
16364
}
16365
});
16366
16367
PooledClass.addPoolingTo(ReactPutListenerQueue);
16368
16369
module.exports = ReactPutListenerQueue;
16370
16371
},{"./Object.assign":42,"./PooledClass":43,"./ReactBrowserEventEmitter":46}],101:[function(require,module,exports){
16372
/**
16373
* Copyright 2013-2015, Facebook, Inc.
16374
* All rights reserved.
16375
*
16376
* This source code is licensed under the BSD-style license found in the
16377
* LICENSE file in the root directory of this source tree. An additional grant
16378
* of patent rights can be found in the PATENTS file in the same directory.
16379
*
16380
* @providesModule ReactReconcileTransaction
16381
* @typechecks static-only
16382
*/
16383
16384
'use strict';
16385
16386
var CallbackQueue = require("./CallbackQueue");
16387
var PooledClass = require("./PooledClass");
16388
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
16389
var ReactInputSelection = require("./ReactInputSelection");
16390
var ReactPutListenerQueue = require("./ReactPutListenerQueue");
16391
var Transaction = require("./Transaction");
16392
16393
var assign = require("./Object.assign");
16394
16395
/**
16396
* Ensures that, when possible, the selection range (currently selected text
16397
* input) is not disturbed by performing the transaction.
16398
*/
16399
var SELECTION_RESTORATION = {
16400
/**
16401
* @return {Selection} Selection information.
16402
*/
16403
initialize: ReactInputSelection.getSelectionInformation,
16404
/**
16405
* @param {Selection} sel Selection information returned from `initialize`.
16406
*/
16407
close: ReactInputSelection.restoreSelection
16408
};
16409
16410
/**
16411
* Suppresses events (blur/focus) that could be inadvertently dispatched due to
16412
* high level DOM manipulations (like temporarily removing a text input from the
16413
* DOM).
16414
*/
16415
var EVENT_SUPPRESSION = {
16416
/**
16417
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
16418
* the reconciliation.
16419
*/
16420
initialize: function() {
16421
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
16422
ReactBrowserEventEmitter.setEnabled(false);
16423
return currentlyEnabled;
16424
},
16425
16426
/**
16427
* @param {boolean} previouslyEnabled Enabled status of
16428
* `ReactBrowserEventEmitter` before the reconciliation occured. `close`
16429
* restores the previous value.
16430
*/
16431
close: function(previouslyEnabled) {
16432
ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
16433
}
16434
};
16435
16436
/**
16437
* Provides a queue for collecting `componentDidMount` and
16438
* `componentDidUpdate` callbacks during the the transaction.
16439
*/
16440
var ON_DOM_READY_QUEUEING = {
16441
/**
16442
* Initializes the internal `onDOMReady` queue.
16443
*/
16444
initialize: function() {
16445
this.reactMountReady.reset();
16446
},
16447
16448
/**
16449
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
16450
*/
16451
close: function() {
16452
this.reactMountReady.notifyAll();
16453
}
16454
};
16455
16456
var PUT_LISTENER_QUEUEING = {
16457
initialize: function() {
16458
this.putListenerQueue.reset();
16459
},
16460
16461
close: function() {
16462
this.putListenerQueue.putListeners();
16463
}
16464
};
16465
16466
/**
16467
* Executed within the scope of the `Transaction` instance. Consider these as
16468
* being member methods, but with an implied ordering while being isolated from
16469
* each other.
16470
*/
16471
var TRANSACTION_WRAPPERS = [
16472
PUT_LISTENER_QUEUEING,
16473
SELECTION_RESTORATION,
16474
EVENT_SUPPRESSION,
16475
ON_DOM_READY_QUEUEING
16476
];
16477
16478
/**
16479
* Currently:
16480
* - The order that these are listed in the transaction is critical:
16481
* - Suppresses events.
16482
* - Restores selection range.
16483
*
16484
* Future:
16485
* - Restore document/overflow scroll positions that were unintentionally
16486
* modified via DOM insertions above the top viewport boundary.
16487
* - Implement/integrate with customized constraint based layout system and keep
16488
* track of which dimensions must be remeasured.
16489
*
16490
* @class ReactReconcileTransaction
16491
*/
16492
function ReactReconcileTransaction() {
16493
this.reinitializeTransaction();
16494
// Only server-side rendering really needs this option (see
16495
// `ReactServerRendering`), but server-side uses
16496
// `ReactServerRenderingTransaction` instead. This option is here so that it's
16497
// accessible and defaults to false when `ReactDOMComponent` and
16498
// `ReactTextComponent` checks it in `mountComponent`.`
16499
this.renderToStaticMarkup = false;
16500
this.reactMountReady = CallbackQueue.getPooled(null);
16501
this.putListenerQueue = ReactPutListenerQueue.getPooled();
16502
}
16503
16504
var Mixin = {
16505
/**
16506
* @see Transaction
16507
* @abstract
16508
* @final
16509
* @return {array<object>} List of operation wrap proceedures.
16510
* TODO: convert to array<TransactionWrapper>
16511
*/
16512
getTransactionWrappers: function() {
16513
return TRANSACTION_WRAPPERS;
16514
},
16515
16516
/**
16517
* @return {object} The queue to collect `onDOMReady` callbacks with.
16518
*/
16519
getReactMountReady: function() {
16520
return this.reactMountReady;
16521
},
16522
16523
getPutListenerQueue: function() {
16524
return this.putListenerQueue;
16525
},
16526
16527
/**
16528
* `PooledClass` looks for this, and will invoke this before allowing this
16529
* instance to be resused.
16530
*/
16531
destructor: function() {
16532
CallbackQueue.release(this.reactMountReady);
16533
this.reactMountReady = null;
16534
16535
ReactPutListenerQueue.release(this.putListenerQueue);
16536
this.putListenerQueue = null;
16537
}
16538
};
16539
16540
16541
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
16542
16543
PooledClass.addPoolingTo(ReactReconcileTransaction);
16544
16545
module.exports = ReactReconcileTransaction;
16546
16547
},{"./CallbackQueue":20,"./Object.assign":42,"./PooledClass":43,"./ReactBrowserEventEmitter":46,"./ReactInputSelection":84,"./ReactPutListenerQueue":100,"./Transaction":130}],102:[function(require,module,exports){
16548
(function (process){
16549
/**
16550
* Copyright 2013-2015, Facebook, Inc.
16551
* All rights reserved.
16552
*
16553
* This source code is licensed under the BSD-style license found in the
16554
* LICENSE file in the root directory of this source tree. An additional grant
16555
* of patent rights can be found in the PATENTS file in the same directory.
16556
*
16557
* @providesModule ReactReconciler
16558
*/
16559
16560
'use strict';
16561
16562
var ReactRef = require("./ReactRef");
16563
var ReactElementValidator = require("./ReactElementValidator");
16564
16565
/**
16566
* Helper to call ReactRef.attachRefs with this composite component, split out
16567
* to avoid allocations in the transaction mount-ready queue.
16568
*/
16569
function attachRefs() {
16570
ReactRef.attachRefs(this, this._currentElement);
16571
}
16572
16573
var ReactReconciler = {
16574
16575
/**
16576
* Initializes the component, renders markup, and registers event listeners.
16577
*
16578
* @param {ReactComponent} internalInstance
16579
* @param {string} rootID DOM ID of the root node.
16580
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
16581
* @return {?string} Rendered markup to be inserted into the DOM.
16582
* @final
16583
* @internal
16584
*/
16585
mountComponent: function(internalInstance, rootID, transaction, context) {
16586
var markup = internalInstance.mountComponent(rootID, transaction, context);
16587
if ("production" !== process.env.NODE_ENV) {
16588
ReactElementValidator.checkAndWarnForMutatedProps(
16589
internalInstance._currentElement
16590
);
16591
}
16592
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
16593
return markup;
16594
},
16595
16596
/**
16597
* Releases any resources allocated by `mountComponent`.
16598
*
16599
* @final
16600
* @internal
16601
*/
16602
unmountComponent: function(internalInstance) {
16603
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
16604
internalInstance.unmountComponent();
16605
},
16606
16607
/**
16608
* Update a component using a new element.
16609
*
16610
* @param {ReactComponent} internalInstance
16611
* @param {ReactElement} nextElement
16612
* @param {ReactReconcileTransaction} transaction
16613
* @param {object} context
16614
* @internal
16615
*/
16616
receiveComponent: function(
16617
internalInstance, nextElement, transaction, context
16618
) {
16619
var prevElement = internalInstance._currentElement;
16620
16621
if (nextElement === prevElement && nextElement._owner != null) {
16622
// Since elements are immutable after the owner is rendered,
16623
// we can do a cheap identity compare here to determine if this is a
16624
// superfluous reconcile. It's possible for state to be mutable but such
16625
// change should trigger an update of the owner which would recreate
16626
// the element. We explicitly check for the existence of an owner since
16627
// it's possible for an element created outside a composite to be
16628
// deeply mutated and reused.
16629
return;
16630
}
16631
16632
if ("production" !== process.env.NODE_ENV) {
16633
ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
16634
}
16635
16636
var refsChanged = ReactRef.shouldUpdateRefs(
16637
prevElement,
16638
nextElement
16639
);
16640
16641
if (refsChanged) {
16642
ReactRef.detachRefs(internalInstance, prevElement);
16643
}
16644
16645
internalInstance.receiveComponent(nextElement, transaction, context);
16646
16647
if (refsChanged) {
16648
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
16649
}
16650
},
16651
16652
/**
16653
* Flush any dirty changes in a component.
16654
*
16655
* @param {ReactComponent} internalInstance
16656
* @param {ReactReconcileTransaction} transaction
16657
* @internal
16658
*/
16659
performUpdateIfNecessary: function(
16660
internalInstance,
16661
transaction
16662
) {
16663
internalInstance.performUpdateIfNecessary(transaction);
16664
}
16665
16666
};
16667
16668
module.exports = ReactReconciler;
16669
16670
}).call(this,require('_process'))
16671
},{"./ReactElementValidator":77,"./ReactRef":103,"_process":1}],103:[function(require,module,exports){
16672
/**
16673
* Copyright 2013-2015, Facebook, Inc.
16674
* All rights reserved.
16675
*
16676
* This source code is licensed under the BSD-style license found in the
16677
* LICENSE file in the root directory of this source tree. An additional grant
16678
* of patent rights can be found in the PATENTS file in the same directory.
16679
*
16680
* @providesModule ReactRef
16681
*/
16682
16683
'use strict';
16684
16685
var ReactOwner = require("./ReactOwner");
16686
16687
var ReactRef = {};
16688
16689
function attachRef(ref, component, owner) {
16690
if (typeof ref === 'function') {
16691
ref(component.getPublicInstance());
16692
} else {
16693
// Legacy ref
16694
ReactOwner.addComponentAsRefTo(component, ref, owner);
16695
}
16696
}
16697
16698
function detachRef(ref, component, owner) {
16699
if (typeof ref === 'function') {
16700
ref(null);
16701
} else {
16702
// Legacy ref
16703
ReactOwner.removeComponentAsRefFrom(component, ref, owner);
16704
}
16705
}
16706
16707
ReactRef.attachRefs = function(instance, element) {
16708
var ref = element.ref;
16709
if (ref != null) {
16710
attachRef(ref, instance, element._owner);
16711
}
16712
};
16713
16714
ReactRef.shouldUpdateRefs = function(prevElement, nextElement) {
16715
// If either the owner or a `ref` has changed, make sure the newest owner
16716
// has stored a reference to `this`, and the previous owner (if different)
16717
// has forgotten the reference to `this`. We use the element instead
16718
// of the public this.props because the post processing cannot determine
16719
// a ref. The ref conceptually lives on the element.
16720
16721
// TODO: Should this even be possible? The owner cannot change because
16722
// it's forbidden by shouldUpdateReactComponent. The ref can change
16723
// if you swap the keys of but not the refs. Reconsider where this check
16724
// is made. It probably belongs where the key checking and
16725
// instantiateReactComponent is done.
16726
16727
return (
16728
nextElement._owner !== prevElement._owner ||
16729
nextElement.ref !== prevElement.ref
16730
);
16731
};
16732
16733
ReactRef.detachRefs = function(instance, element) {
16734
var ref = element.ref;
16735
if (ref != null) {
16736
detachRef(ref, instance, element._owner);
16737
}
16738
};
16739
16740
module.exports = ReactRef;
16741
16742
},{"./ReactOwner":94}],104:[function(require,module,exports){
16743
/**
16744
* Copyright 2013-2015, Facebook, Inc.
16745
* All rights reserved.
16746
*
16747
* This source code is licensed under the BSD-style license found in the
16748
* LICENSE file in the root directory of this source tree. An additional grant
16749
* of patent rights can be found in the PATENTS file in the same directory.
16750
*
16751
* @providesModule ReactRootIndex
16752
* @typechecks
16753
*/
16754
16755
'use strict';
16756
16757
var ReactRootIndexInjection = {
16758
/**
16759
* @param {function} _createReactRootIndex
16760
*/
16761
injectCreateReactRootIndex: function(_createReactRootIndex) {
16762
ReactRootIndex.createReactRootIndex = _createReactRootIndex;
16763
}
16764
};
16765
16766
var ReactRootIndex = {
16767
createReactRootIndex: null,
16768
injection: ReactRootIndexInjection
16769
};
16770
16771
module.exports = ReactRootIndex;
16772
16773
},{}],105:[function(require,module,exports){
16774
(function (process){
16775
/**
16776
* Copyright 2013-2015, Facebook, Inc.
16777
* All rights reserved.
16778
*
16779
* This source code is licensed under the BSD-style license found in the
16780
* LICENSE file in the root directory of this source tree. An additional grant
16781
* of patent rights can be found in the PATENTS file in the same directory.
16782
*
16783
* @typechecks static-only
16784
* @providesModule ReactServerRendering
16785
*/
16786
'use strict';
16787
16788
var ReactElement = require("./ReactElement");
16789
var ReactInstanceHandles = require("./ReactInstanceHandles");
16790
var ReactMarkupChecksum = require("./ReactMarkupChecksum");
16791
var ReactServerRenderingTransaction =
16792
require("./ReactServerRenderingTransaction");
16793
16794
var emptyObject = require("./emptyObject");
16795
var instantiateReactComponent = require("./instantiateReactComponent");
16796
var invariant = require("./invariant");
16797
16798
/**
16799
* @param {ReactElement} element
16800
* @return {string} the HTML markup
16801
*/
16802
function renderToString(element) {
16803
("production" !== process.env.NODE_ENV ? invariant(
16804
ReactElement.isValidElement(element),
16805
'renderToString(): You must pass a valid ReactElement.'
16806
) : invariant(ReactElement.isValidElement(element)));
16807
16808
var transaction;
16809
try {
16810
var id = ReactInstanceHandles.createReactRootID();
16811
transaction = ReactServerRenderingTransaction.getPooled(false);
16812
16813
return transaction.perform(function() {
16814
var componentInstance = instantiateReactComponent(element, null);
16815
var markup =
16816
componentInstance.mountComponent(id, transaction, emptyObject);
16817
return ReactMarkupChecksum.addChecksumToMarkup(markup);
16818
}, null);
16819
} finally {
16820
ReactServerRenderingTransaction.release(transaction);
16821
}
16822
}
16823
16824
/**
16825
* @param {ReactElement} element
16826
* @return {string} the HTML markup, without the extra React ID and checksum
16827
* (for generating static pages)
16828
*/
16829
function renderToStaticMarkup(element) {
16830
("production" !== process.env.NODE_ENV ? invariant(
16831
ReactElement.isValidElement(element),
16832
'renderToStaticMarkup(): You must pass a valid ReactElement.'
16833
) : invariant(ReactElement.isValidElement(element)));
16834
16835
var transaction;
16836
try {
16837
var id = ReactInstanceHandles.createReactRootID();
16838
transaction = ReactServerRenderingTransaction.getPooled(true);
16839
16840
return transaction.perform(function() {
16841
var componentInstance = instantiateReactComponent(element, null);
16842
return componentInstance.mountComponent(id, transaction, emptyObject);
16843
}, null);
16844
} finally {
16845
ReactServerRenderingTransaction.release(transaction);
16846
}
16847
}
16848
16849
module.exports = {
16850
renderToString: renderToString,
16851
renderToStaticMarkup: renderToStaticMarkup
16852
};
16853
16854
}).call(this,require('_process'))
16855
},{"./ReactElement":76,"./ReactInstanceHandles":85,"./ReactMarkupChecksum":89,"./ReactServerRenderingTransaction":106,"./emptyObject":144,"./instantiateReactComponent":163,"./invariant":164,"_process":1}],106:[function(require,module,exports){
16856
/**
16857
* Copyright 2014-2015, Facebook, Inc.
16858
* All rights reserved.
16859
*
16860
* This source code is licensed under the BSD-style license found in the
16861
* LICENSE file in the root directory of this source tree. An additional grant
16862
* of patent rights can be found in the PATENTS file in the same directory.
16863
*
16864
* @providesModule ReactServerRenderingTransaction
16865
* @typechecks
16866
*/
16867
16868
'use strict';
16869
16870
var PooledClass = require("./PooledClass");
16871
var CallbackQueue = require("./CallbackQueue");
16872
var ReactPutListenerQueue = require("./ReactPutListenerQueue");
16873
var Transaction = require("./Transaction");
16874
16875
var assign = require("./Object.assign");
16876
var emptyFunction = require("./emptyFunction");
16877
16878
/**
16879
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
16880
* during the performing of the transaction.
16881
*/
16882
var ON_DOM_READY_QUEUEING = {
16883
/**
16884
* Initializes the internal `onDOMReady` queue.
16885
*/
16886
initialize: function() {
16887
this.reactMountReady.reset();
16888
},
16889
16890
close: emptyFunction
16891
};
16892
16893
var PUT_LISTENER_QUEUEING = {
16894
initialize: function() {
16895
this.putListenerQueue.reset();
16896
},
16897
16898
close: emptyFunction
16899
};
16900
16901
/**
16902
* Executed within the scope of the `Transaction` instance. Consider these as
16903
* being member methods, but with an implied ordering while being isolated from
16904
* each other.
16905
*/
16906
var TRANSACTION_WRAPPERS = [
16907
PUT_LISTENER_QUEUEING,
16908
ON_DOM_READY_QUEUEING
16909
];
16910
16911
/**
16912
* @class ReactServerRenderingTransaction
16913
* @param {boolean} renderToStaticMarkup
16914
*/
16915
function ReactServerRenderingTransaction(renderToStaticMarkup) {
16916
this.reinitializeTransaction();
16917
this.renderToStaticMarkup = renderToStaticMarkup;
16918
this.reactMountReady = CallbackQueue.getPooled(null);
16919
this.putListenerQueue = ReactPutListenerQueue.getPooled();
16920
}
16921
16922
var Mixin = {
16923
/**
16924
* @see Transaction
16925
* @abstract
16926
* @final
16927
* @return {array} Empty list of operation wrap proceedures.
16928
*/
16929
getTransactionWrappers: function() {
16930
return TRANSACTION_WRAPPERS;
16931
},
16932
16933
/**
16934
* @return {object} The queue to collect `onDOMReady` callbacks with.
16935
*/
16936
getReactMountReady: function() {
16937
return this.reactMountReady;
16938
},
16939
16940
getPutListenerQueue: function() {
16941
return this.putListenerQueue;
16942
},
16943
16944
/**
16945
* `PooledClass` looks for this, and will invoke this before allowing this
16946
* instance to be resused.
16947
*/
16948
destructor: function() {
16949
CallbackQueue.release(this.reactMountReady);
16950
this.reactMountReady = null;
16951
16952
ReactPutListenerQueue.release(this.putListenerQueue);
16953
this.putListenerQueue = null;
16954
}
16955
};
16956
16957
16958
assign(
16959
ReactServerRenderingTransaction.prototype,
16960
Transaction.Mixin,
16961
Mixin
16962
);
16963
16964
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
16965
16966
module.exports = ReactServerRenderingTransaction;
16967
16968
},{"./CallbackQueue":20,"./Object.assign":42,"./PooledClass":43,"./ReactPutListenerQueue":100,"./Transaction":130,"./emptyFunction":143}],107:[function(require,module,exports){
16969
/**
16970
* Copyright 2013-2015, Facebook, Inc.
16971
* All rights reserved.
16972
*
16973
* This source code is licensed under the BSD-style license found in the
16974
* LICENSE file in the root directory of this source tree. An additional grant
16975
* of patent rights can be found in the PATENTS file in the same directory.
16976
*
16977
* @providesModule ReactStateSetters
16978
*/
16979
16980
'use strict';
16981
16982
var ReactStateSetters = {
16983
/**
16984
* Returns a function that calls the provided function, and uses the result
16985
* of that to set the component's state.
16986
*
16987
* @param {ReactCompositeComponent} component
16988
* @param {function} funcReturningState Returned callback uses this to
16989
* determine how to update state.
16990
* @return {function} callback that when invoked uses funcReturningState to
16991
* determined the object literal to setState.
16992
*/
16993
createStateSetter: function(component, funcReturningState) {
16994
return function(a, b, c, d, e, f) {
16995
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
16996
if (partialState) {
16997
component.setState(partialState);
16998
}
16999
};
17000
},
17001
17002
/**
17003
* Returns a single-argument callback that can be used to update a single
17004
* key in the component's state.
17005
*
17006
* Note: this is memoized function, which makes it inexpensive to call.
17007
*
17008
* @param {ReactCompositeComponent} component
17009
* @param {string} key The key in the state that you should update.
17010
* @return {function} callback of 1 argument which calls setState() with
17011
* the provided keyName and callback argument.
17012
*/
17013
createStateKeySetter: function(component, key) {
17014
// Memoize the setters.
17015
var cache = component.__keySetters || (component.__keySetters = {});
17016
return cache[key] || (cache[key] = createStateKeySetter(component, key));
17017
}
17018
};
17019
17020
function createStateKeySetter(component, key) {
17021
// Partial state is allocated outside of the function closure so it can be
17022
// reused with every call, avoiding memory allocation when this function
17023
// is called.
17024
var partialState = {};
17025
return function stateKeySetter(value) {
17026
partialState[key] = value;
17027
component.setState(partialState);
17028
};
17029
}
17030
17031
ReactStateSetters.Mixin = {
17032
/**
17033
* Returns a function that calls the provided function, and uses the result
17034
* of that to set the component's state.
17035
*
17036
* For example, these statements are equivalent:
17037
*
17038
* this.setState({x: 1});
17039
* this.createStateSetter(function(xValue) {
17040
* return {x: xValue};
17041
* })(1);
17042
*
17043
* @param {function} funcReturningState Returned callback uses this to
17044
* determine how to update state.
17045
* @return {function} callback that when invoked uses funcReturningState to
17046
* determined the object literal to setState.
17047
*/
17048
createStateSetter: function(funcReturningState) {
17049
return ReactStateSetters.createStateSetter(this, funcReturningState);
17050
},
17051
17052
/**
17053
* Returns a single-argument callback that can be used to update a single
17054
* key in the component's state.
17055
*
17056
* For example, these statements are equivalent:
17057
*
17058
* this.setState({x: 1});
17059
* this.createStateKeySetter('x')(1);
17060
*
17061
* Note: this is memoized function, which makes it inexpensive to call.
17062
*
17063
* @param {string} key The key in the state that you should update.
17064
* @return {function} callback of 1 argument which calls setState() with
17065
* the provided keyName and callback argument.
17066
*/
17067
createStateKeySetter: function(key) {
17068
return ReactStateSetters.createStateKeySetter(this, key);
17069
}
17070
};
17071
17072
module.exports = ReactStateSetters;
17073
17074
},{}],108:[function(require,module,exports){
17075
/**
17076
* Copyright 2013-2015, Facebook, Inc.
17077
* All rights reserved.
17078
*
17079
* This source code is licensed under the BSD-style license found in the
17080
* LICENSE file in the root directory of this source tree. An additional grant
17081
* of patent rights can be found in the PATENTS file in the same directory.
17082
*
17083
* @providesModule ReactTestUtils
17084
*/
17085
17086
'use strict';
17087
17088
var EventConstants = require("./EventConstants");
17089
var EventPluginHub = require("./EventPluginHub");
17090
var EventPropagators = require("./EventPropagators");
17091
var React = require("./React");
17092
var ReactElement = require("./ReactElement");
17093
var ReactEmptyComponent = require("./ReactEmptyComponent");
17094
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
17095
var ReactCompositeComponent = require("./ReactCompositeComponent");
17096
var ReactInstanceHandles = require("./ReactInstanceHandles");
17097
var ReactInstanceMap = require("./ReactInstanceMap");
17098
var ReactMount = require("./ReactMount");
17099
var ReactUpdates = require("./ReactUpdates");
17100
var SyntheticEvent = require("./SyntheticEvent");
17101
17102
var assign = require("./Object.assign");
17103
var emptyObject = require("./emptyObject");
17104
17105
var topLevelTypes = EventConstants.topLevelTypes;
17106
17107
function Event(suffix) {}
17108
17109
/**
17110
* @class ReactTestUtils
17111
*/
17112
17113
/**
17114
* Todo: Support the entire DOM.scry query syntax. For now, these simple
17115
* utilities will suffice for testing purposes.
17116
* @lends ReactTestUtils
17117
*/
17118
var ReactTestUtils = {
17119
renderIntoDocument: function(instance) {
17120
var div = document.createElement('div');
17121
// None of our tests actually require attaching the container to the
17122
// DOM, and doing so creates a mess that we rely on test isolation to
17123
// clean up, so we're going to stop honoring the name of this method
17124
// (and probably rename it eventually) if no problems arise.
17125
// document.documentElement.appendChild(div);
17126
return React.render(instance, div);
17127
},
17128
17129
isElement: function(element) {
17130
return ReactElement.isValidElement(element);
17131
},
17132
17133
isElementOfType: function(inst, convenienceConstructor) {
17134
return (
17135
ReactElement.isValidElement(inst) &&
17136
inst.type === convenienceConstructor
17137
);
17138
},
17139
17140
isDOMComponent: function(inst) {
17141
// TODO: Fix this heuristic. It's just here because composites can currently
17142
// pretend to be DOM components.
17143
return !!(inst && inst.tagName && inst.getDOMNode);
17144
},
17145
17146
isDOMComponentElement: function(inst) {
17147
return !!(inst &&
17148
ReactElement.isValidElement(inst) &&
17149
!!inst.tagName);
17150
},
17151
17152
isCompositeComponent: function(inst) {
17153
return typeof inst.render === 'function' &&
17154
typeof inst.setState === 'function';
17155
},
17156
17157
isCompositeComponentWithType: function(inst, type) {
17158
return !!(ReactTestUtils.isCompositeComponent(inst) &&
17159
(inst.constructor === type));
17160
},
17161
17162
isCompositeComponentElement: function(inst) {
17163
if (!ReactElement.isValidElement(inst)) {
17164
return false;
17165
}
17166
// We check the prototype of the type that will get mounted, not the
17167
// instance itself. This is a future proof way of duck typing.
17168
var prototype = inst.type.prototype;
17169
return (
17170
typeof prototype.render === 'function' &&
17171
typeof prototype.setState === 'function'
17172
);
17173
},
17174
17175
isCompositeComponentElementWithType: function(inst, type) {
17176
return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
17177
(inst.constructor === type));
17178
},
17179
17180
getRenderedChildOfCompositeComponent: function(inst) {
17181
if (!ReactTestUtils.isCompositeComponent(inst)) {
17182
return null;
17183
}
17184
var internalInstance = ReactInstanceMap.get(inst);
17185
return internalInstance._renderedComponent.getPublicInstance();
17186
},
17187
17188
findAllInRenderedTree: function(inst, test) {
17189
if (!inst) {
17190
return [];
17191
}
17192
var ret = test(inst) ? [inst] : [];
17193
if (ReactTestUtils.isDOMComponent(inst)) {
17194
var internalInstance = ReactInstanceMap.get(inst);
17195
var renderedChildren = internalInstance
17196
._renderedComponent
17197
._renderedChildren;
17198
var key;
17199
for (key in renderedChildren) {
17200
if (!renderedChildren.hasOwnProperty(key)) {
17201
continue;
17202
}
17203
if (!renderedChildren[key].getPublicInstance) {
17204
continue;
17205
}
17206
ret = ret.concat(
17207
ReactTestUtils.findAllInRenderedTree(
17208
renderedChildren[key].getPublicInstance(),
17209
test
17210
)
17211
);
17212
}
17213
} else if (ReactTestUtils.isCompositeComponent(inst)) {
17214
ret = ret.concat(
17215
ReactTestUtils.findAllInRenderedTree(
17216
ReactTestUtils.getRenderedChildOfCompositeComponent(inst),
17217
test
17218
)
17219
);
17220
}
17221
return ret;
17222
},
17223
17224
/**
17225
* Finds all instance of components in the rendered tree that are DOM
17226
* components with the class name matching `className`.
17227
* @return an array of all the matches.
17228
*/
17229
scryRenderedDOMComponentsWithClass: function(root, className) {
17230
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
17231
var instClassName = inst.props.className;
17232
return ReactTestUtils.isDOMComponent(inst) && (
17233
(instClassName && (' ' + instClassName + ' ').indexOf(' ' + className + ' ') !== -1)
17234
);
17235
});
17236
},
17237
17238
/**
17239
* Like scryRenderedDOMComponentsWithClass but expects there to be one result,
17240
* and returns that one result, or throws exception if there is any other
17241
* number of matches besides one.
17242
* @return {!ReactDOMComponent} The one match.
17243
*/
17244
findRenderedDOMComponentWithClass: function(root, className) {
17245
var all =
17246
ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
17247
if (all.length !== 1) {
17248
throw new Error('Did not find exactly one match ' +
17249
'(found: ' + all.length + ') for class:' + className
17250
);
17251
}
17252
return all[0];
17253
},
17254
17255
17256
/**
17257
* Finds all instance of components in the rendered tree that are DOM
17258
* components with the tag name matching `tagName`.
17259
* @return an array of all the matches.
17260
*/
17261
scryRenderedDOMComponentsWithTag: function(root, tagName) {
17262
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
17263
return ReactTestUtils.isDOMComponent(inst) &&
17264
inst.tagName === tagName.toUpperCase();
17265
});
17266
},
17267
17268
/**
17269
* Like scryRenderedDOMComponentsWithTag but expects there to be one result,
17270
* and returns that one result, or throws exception if there is any other
17271
* number of matches besides one.
17272
* @return {!ReactDOMComponent} The one match.
17273
*/
17274
findRenderedDOMComponentWithTag: function(root, tagName) {
17275
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
17276
if (all.length !== 1) {
17277
throw new Error('Did not find exactly one match for tag:' + tagName);
17278
}
17279
return all[0];
17280
},
17281
17282
17283
/**
17284
* Finds all instances of components with type equal to `componentType`.
17285
* @return an array of all the matches.
17286
*/
17287
scryRenderedComponentsWithType: function(root, componentType) {
17288
return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
17289
return ReactTestUtils.isCompositeComponentWithType(
17290
inst,
17291
componentType
17292
);
17293
});
17294
},
17295
17296
/**
17297
* Same as `scryRenderedComponentsWithType` but expects there to be one result
17298
* and returns that one result, or throws exception if there is any other
17299
* number of matches besides one.
17300
* @return {!ReactComponent} The one match.
17301
*/
17302
findRenderedComponentWithType: function(root, componentType) {
17303
var all = ReactTestUtils.scryRenderedComponentsWithType(
17304
root,
17305
componentType
17306
);
17307
if (all.length !== 1) {
17308
throw new Error(
17309
'Did not find exactly one match for componentType:' + componentType
17310
);
17311
}
17312
return all[0];
17313
},
17314
17315
/**
17316
* Pass a mocked component module to this method to augment it with
17317
* useful methods that allow it to be used as a dummy React component.
17318
* Instead of rendering as usual, the component will become a simple
17319
* <div> containing any provided children.
17320
*
17321
* @param {object} module the mock function object exported from a
17322
* module that defines the component to be mocked
17323
* @param {?string} mockTagName optional dummy root tag name to return
17324
* from render method (overrides
17325
* module.mockTagName if provided)
17326
* @return {object} the ReactTestUtils object (for chaining)
17327
*/
17328
mockComponent: function(module, mockTagName) {
17329
mockTagName = mockTagName || module.mockTagName || "div";
17330
17331
module.prototype.render.mockImplementation(function() {
17332
return React.createElement(
17333
mockTagName,
17334
null,
17335
this.props.children
17336
);
17337
});
17338
17339
return this;
17340
},
17341
17342
/**
17343
* Simulates a top level event being dispatched from a raw event that occured
17344
* on an `Element` node.
17345
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`
17346
* @param {!Element} node The dom to simulate an event occurring on.
17347
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
17348
*/
17349
simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) {
17350
fakeNativeEvent.target = node;
17351
ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(
17352
topLevelType,
17353
fakeNativeEvent
17354
);
17355
},
17356
17357
/**
17358
* Simulates a top level event being dispatched from a raw event that occured
17359
* on the `ReactDOMComponent` `comp`.
17360
* @param topLevelType {Object} A type from `EventConstants.topLevelTypes`.
17361
* @param comp {!ReactDOMComponent}
17362
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
17363
*/
17364
simulateNativeEventOnDOMComponent: function(
17365
topLevelType,
17366
comp,
17367
fakeNativeEvent) {
17368
ReactTestUtils.simulateNativeEventOnNode(
17369
topLevelType,
17370
comp.getDOMNode(),
17371
fakeNativeEvent
17372
);
17373
},
17374
17375
nativeTouchData: function(x, y) {
17376
return {
17377
touches: [
17378
{pageX: x, pageY: y}
17379
]
17380
};
17381
},
17382
17383
createRenderer: function() {
17384
return new ReactShallowRenderer();
17385
},
17386
17387
Simulate: null,
17388
SimulateNative: {}
17389
};
17390
17391
/**
17392
* @class ReactShallowRenderer
17393
*/
17394
var ReactShallowRenderer = function() {
17395
this._instance = null;
17396
};
17397
17398
ReactShallowRenderer.prototype.getRenderOutput = function() {
17399
return (
17400
(this._instance && this._instance._renderedComponent &&
17401
this._instance._renderedComponent._renderedOutput)
17402
|| null
17403
);
17404
};
17405
17406
var NoopInternalComponent = function(element) {
17407
this._renderedOutput = element;
17408
this._currentElement = element === null || element === false ?
17409
ReactEmptyComponent.emptyElement :
17410
element;
17411
};
17412
17413
NoopInternalComponent.prototype = {
17414
17415
mountComponent: function() {
17416
},
17417
17418
receiveComponent: function(element) {
17419
this._renderedOutput = element;
17420
this._currentElement = element === null || element === false ?
17421
ReactEmptyComponent.emptyElement :
17422
element;
17423
},
17424
17425
unmountComponent: function() {
17426
}
17427
17428
};
17429
17430
var ShallowComponentWrapper = function() { };
17431
assign(
17432
ShallowComponentWrapper.prototype,
17433
ReactCompositeComponent.Mixin, {
17434
_instantiateReactComponent: function(element) {
17435
return new NoopInternalComponent(element);
17436
},
17437
_replaceNodeWithMarkupByID: function() {},
17438
_renderValidatedComponent:
17439
ReactCompositeComponent.Mixin.
17440
_renderValidatedComponentWithoutOwnerOrContext
17441
}
17442
);
17443
17444
ReactShallowRenderer.prototype.render = function(element, context) {
17445
if (!context) {
17446
context = emptyObject;
17447
}
17448
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
17449
this._render(element, transaction, context);
17450
ReactUpdates.ReactReconcileTransaction.release(transaction);
17451
};
17452
17453
ReactShallowRenderer.prototype.unmount = function() {
17454
if (this._instance) {
17455
this._instance.unmountComponent();
17456
}
17457
};
17458
17459
ReactShallowRenderer.prototype._render = function(element, transaction, context) {
17460
if (!this._instance) {
17461
var rootID = ReactInstanceHandles.createReactRootID();
17462
var instance = new ShallowComponentWrapper(element.type);
17463
instance.construct(element);
17464
17465
instance.mountComponent(rootID, transaction, context);
17466
17467
this._instance = instance;
17468
} else {
17469
this._instance.receiveComponent(element, transaction, context);
17470
}
17471
};
17472
17473
/**
17474
* Exports:
17475
*
17476
* - `ReactTestUtils.Simulate.click(Element/ReactDOMComponent)`
17477
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactDOMComponent)`
17478
* - `ReactTestUtils.Simulate.change(Element/ReactDOMComponent)`
17479
* - ... (All keys from event plugin `eventTypes` objects)
17480
*/
17481
function makeSimulator(eventType) {
17482
return function(domComponentOrNode, eventData) {
17483
var node;
17484
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
17485
node = domComponentOrNode.getDOMNode();
17486
} else if (domComponentOrNode.tagName) {
17487
node = domComponentOrNode;
17488
}
17489
17490
var fakeNativeEvent = new Event();
17491
fakeNativeEvent.target = node;
17492
// We don't use SyntheticEvent.getPooled in order to not have to worry about
17493
// properly destroying any properties assigned from `eventData` upon release
17494
var event = new SyntheticEvent(
17495
ReactBrowserEventEmitter.eventNameDispatchConfigs[eventType],
17496
ReactMount.getID(node),
17497
fakeNativeEvent
17498
);
17499
assign(event, eventData);
17500
EventPropagators.accumulateTwoPhaseDispatches(event);
17501
17502
ReactUpdates.batchedUpdates(function() {
17503
EventPluginHub.enqueueEvents(event);
17504
EventPluginHub.processEventQueue();
17505
});
17506
};
17507
}
17508
17509
function buildSimulators() {
17510
ReactTestUtils.Simulate = {};
17511
17512
var eventType;
17513
for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
17514
/**
17515
* @param {!Element || ReactDOMComponent} domComponentOrNode
17516
* @param {?object} eventData Fake event data to use in SyntheticEvent.
17517
*/
17518
ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
17519
}
17520
}
17521
17522
// Rebuild ReactTestUtils.Simulate whenever event plugins are injected
17523
var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
17524
EventPluginHub.injection.injectEventPluginOrder = function() {
17525
oldInjectEventPluginOrder.apply(this, arguments);
17526
buildSimulators();
17527
};
17528
var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
17529
EventPluginHub.injection.injectEventPluginsByName = function() {
17530
oldInjectEventPlugins.apply(this, arguments);
17531
buildSimulators();
17532
};
17533
17534
buildSimulators();
17535
17536
/**
17537
* Exports:
17538
*
17539
* - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
17540
* - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
17541
* - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
17542
* - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
17543
* - ... (All keys from `EventConstants.topLevelTypes`)
17544
*
17545
* Note: Top level event types are a subset of the entire set of handler types
17546
* (which include a broader set of "synthetic" events). For example, onDragDone
17547
* is a synthetic event. Except when testing an event plugin or React's event
17548
* handling code specifically, you probably want to use ReactTestUtils.Simulate
17549
* to dispatch synthetic events.
17550
*/
17551
17552
function makeNativeSimulator(eventType) {
17553
return function(domComponentOrNode, nativeEventData) {
17554
var fakeNativeEvent = new Event(eventType);
17555
assign(fakeNativeEvent, nativeEventData);
17556
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
17557
ReactTestUtils.simulateNativeEventOnDOMComponent(
17558
eventType,
17559
domComponentOrNode,
17560
fakeNativeEvent
17561
);
17562
} else if (!!domComponentOrNode.tagName) {
17563
// Will allow on actual dom nodes.
17564
ReactTestUtils.simulateNativeEventOnNode(
17565
eventType,
17566
domComponentOrNode,
17567
fakeNativeEvent
17568
);
17569
}
17570
};
17571
}
17572
17573
var eventType;
17574
for (eventType in topLevelTypes) {
17575
// Event type is stored as 'topClick' - we transform that to 'click'
17576
var convenienceName = eventType.indexOf('top') === 0 ?
17577
eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
17578
/**
17579
* @param {!Element || ReactDOMComponent} domComponentOrNode
17580
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
17581
*/
17582
ReactTestUtils.SimulateNative[convenienceName] =
17583
makeNativeSimulator(eventType);
17584
}
17585
17586
module.exports = ReactTestUtils;
17587
17588
},{"./EventConstants":29,"./EventPluginHub":31,"./EventPropagators":34,"./Object.assign":42,"./React":44,"./ReactBrowserEventEmitter":46,"./ReactCompositeComponent":56,"./ReactElement":76,"./ReactEmptyComponent":78,"./ReactInstanceHandles":85,"./ReactInstanceMap":86,"./ReactMount":90,"./ReactUpdates":113,"./SyntheticEvent":122,"./emptyObject":144}],109:[function(require,module,exports){
17589
/**
17590
* Copyright 2013-2015, Facebook, Inc.
17591
* All rights reserved.
17592
*
17593
* This source code is licensed under the BSD-style license found in the
17594
* LICENSE file in the root directory of this source tree. An additional grant
17595
* of patent rights can be found in the PATENTS file in the same directory.
17596
*
17597
* @typechecks static-only
17598
* @providesModule ReactTransitionChildMapping
17599
*/
17600
17601
'use strict';
17602
17603
var ReactChildren = require("./ReactChildren");
17604
var ReactFragment = require("./ReactFragment");
17605
17606
var ReactTransitionChildMapping = {
17607
/**
17608
* Given `this.props.children`, return an object mapping key to child. Just
17609
* simple syntactic sugar around ReactChildren.map().
17610
*
17611
* @param {*} children `this.props.children`
17612
* @return {object} Mapping of key to child
17613
*/
17614
getChildMapping: function(children) {
17615
if (!children) {
17616
return children;
17617
}
17618
return ReactFragment.extract(ReactChildren.map(children, function(child) {
17619
return child;
17620
}));
17621
},
17622
17623
/**
17624
* When you're adding or removing children some may be added or removed in the
17625
* same render pass. We want to show *both* since we want to simultaneously
17626
* animate elements in and out. This function takes a previous set of keys
17627
* and a new set of keys and merges them with its best guess of the correct
17628
* ordering. In the future we may expose some of the utilities in
17629
* ReactMultiChild to make this easy, but for now React itself does not
17630
* directly have this concept of the union of prevChildren and nextChildren
17631
* so we implement it here.
17632
*
17633
* @param {object} prev prev children as returned from
17634
* `ReactTransitionChildMapping.getChildMapping()`.
17635
* @param {object} next next children as returned from
17636
* `ReactTransitionChildMapping.getChildMapping()`.
17637
* @return {object} a key set that contains all keys in `prev` and all keys
17638
* in `next` in a reasonable order.
17639
*/
17640
mergeChildMappings: function(prev, next) {
17641
prev = prev || {};
17642
next = next || {};
17643
17644
function getValueForKey(key) {
17645
if (next.hasOwnProperty(key)) {
17646
return next[key];
17647
} else {
17648
return prev[key];
17649
}
17650
}
17651
17652
// For each key of `next`, the list of keys to insert before that key in
17653
// the combined list
17654
var nextKeysPending = {};
17655
17656
var pendingKeys = [];
17657
for (var prevKey in prev) {
17658
if (next.hasOwnProperty(prevKey)) {
17659
if (pendingKeys.length) {
17660
nextKeysPending[prevKey] = pendingKeys;
17661
pendingKeys = [];
17662
}
17663
} else {
17664
pendingKeys.push(prevKey);
17665
}
17666
}
17667
17668
var i;
17669
var childMapping = {};
17670
for (var nextKey in next) {
17671
if (nextKeysPending.hasOwnProperty(nextKey)) {
17672
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
17673
var pendingNextKey = nextKeysPending[nextKey][i];
17674
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
17675
pendingNextKey
17676
);
17677
}
17678
}
17679
childMapping[nextKey] = getValueForKey(nextKey);
17680
}
17681
17682
// Finally, add the keys which didn't appear before any key in `next`
17683
for (i = 0; i < pendingKeys.length; i++) {
17684
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
17685
}
17686
17687
return childMapping;
17688
}
17689
};
17690
17691
module.exports = ReactTransitionChildMapping;
17692
17693
},{"./ReactChildren":50,"./ReactFragment":82}],110:[function(require,module,exports){
17694
/**
17695
* Copyright 2013-2015, Facebook, Inc.
17696
* All rights reserved.
17697
*
17698
* This source code is licensed under the BSD-style license found in the
17699
* LICENSE file in the root directory of this source tree. An additional grant
17700
* of patent rights can be found in the PATENTS file in the same directory.
17701
*
17702
* @providesModule ReactTransitionEvents
17703
*/
17704
17705
'use strict';
17706
17707
var ExecutionEnvironment = require("./ExecutionEnvironment");
17708
17709
/**
17710
* EVENT_NAME_MAP is used to determine which event fired when a
17711
* transition/animation ends, based on the style property used to
17712
* define that event.
17713
*/
17714
var EVENT_NAME_MAP = {
17715
transitionend: {
17716
'transition': 'transitionend',
17717
'WebkitTransition': 'webkitTransitionEnd',
17718
'MozTransition': 'mozTransitionEnd',
17719
'OTransition': 'oTransitionEnd',
17720
'msTransition': 'MSTransitionEnd'
17721
},
17722
17723
animationend: {
17724
'animation': 'animationend',
17725
'WebkitAnimation': 'webkitAnimationEnd',
17726
'MozAnimation': 'mozAnimationEnd',
17727
'OAnimation': 'oAnimationEnd',
17728
'msAnimation': 'MSAnimationEnd'
17729
}
17730
};
17731
17732
var endEvents = [];
17733
17734
function detectEvents() {
17735
var testEl = document.createElement('div');
17736
var style = testEl.style;
17737
17738
// On some platforms, in particular some releases of Android 4.x,
17739
// the un-prefixed "animation" and "transition" properties are defined on the
17740
// style object but the events that fire will still be prefixed, so we need
17741
// to check if the un-prefixed events are useable, and if not remove them
17742
// from the map
17743
if (!('AnimationEvent' in window)) {
17744
delete EVENT_NAME_MAP.animationend.animation;
17745
}
17746
17747
if (!('TransitionEvent' in window)) {
17748
delete EVENT_NAME_MAP.transitionend.transition;
17749
}
17750
17751
for (var baseEventName in EVENT_NAME_MAP) {
17752
var baseEvents = EVENT_NAME_MAP[baseEventName];
17753
for (var styleName in baseEvents) {
17754
if (styleName in style) {
17755
endEvents.push(baseEvents[styleName]);
17756
break;
17757
}
17758
}
17759
}
17760
}
17761
17762
if (ExecutionEnvironment.canUseDOM) {
17763
detectEvents();
17764
}
17765
17766
// We use the raw {add|remove}EventListener() call because EventListener
17767
// does not know how to remove event listeners and we really should
17768
// clean up. Also, these events are not triggered in older browsers
17769
// so we should be A-OK here.
17770
17771
function addEventListener(node, eventName, eventListener) {
17772
node.addEventListener(eventName, eventListener, false);
17773
}
17774
17775
function removeEventListener(node, eventName, eventListener) {
17776
node.removeEventListener(eventName, eventListener, false);
17777
}
17778
17779
var ReactTransitionEvents = {
17780
addEndEventListener: function(node, eventListener) {
17781
if (endEvents.length === 0) {
17782
// If CSS transitions are not supported, trigger an "end animation"
17783
// event immediately.
17784
window.setTimeout(eventListener, 0);
17785
return;
17786
}
17787
endEvents.forEach(function(endEvent) {
17788
addEventListener(node, endEvent, eventListener);
17789
});
17790
},
17791
17792
removeEndEventListener: function(node, eventListener) {
17793
if (endEvents.length === 0) {
17794
return;
17795
}
17796
endEvents.forEach(function(endEvent) {
17797
removeEventListener(node, endEvent, eventListener);
17798
});
17799
}
17800
};
17801
17802
module.exports = ReactTransitionEvents;
17803
17804
},{"./ExecutionEnvironment":35}],111:[function(require,module,exports){
17805
/**
17806
* Copyright 2013-2015, Facebook, Inc.
17807
* All rights reserved.
17808
*
17809
* This source code is licensed under the BSD-style license found in the
17810
* LICENSE file in the root directory of this source tree. An additional grant
17811
* of patent rights can be found in the PATENTS file in the same directory.
17812
*
17813
* @providesModule ReactTransitionGroup
17814
*/
17815
17816
'use strict';
17817
17818
var React = require("./React");
17819
var ReactTransitionChildMapping = require("./ReactTransitionChildMapping");
17820
17821
var assign = require("./Object.assign");
17822
var cloneWithProps = require("./cloneWithProps");
17823
var emptyFunction = require("./emptyFunction");
17824
17825
var ReactTransitionGroup = React.createClass({
17826
displayName: 'ReactTransitionGroup',
17827
17828
propTypes: {
17829
component: React.PropTypes.any,
17830
childFactory: React.PropTypes.func
17831
},
17832
17833
getDefaultProps: function() {
17834
return {
17835
component: 'span',
17836
childFactory: emptyFunction.thatReturnsArgument
17837
};
17838
},
17839
17840
getInitialState: function() {
17841
return {
17842
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
17843
};
17844
},
17845
17846
componentWillMount: function() {
17847
this.currentlyTransitioningKeys = {};
17848
this.keysToEnter = [];
17849
this.keysToLeave = [];
17850
},
17851
17852
componentDidMount: function() {
17853
var initialChildMapping = this.state.children;
17854
for (var key in initialChildMapping) {
17855
if (initialChildMapping[key]) {
17856
this.performAppear(key);
17857
}
17858
}
17859
},
17860
17861
componentWillReceiveProps: function(nextProps) {
17862
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
17863
nextProps.children
17864
);
17865
var prevChildMapping = this.state.children;
17866
17867
this.setState({
17868
children: ReactTransitionChildMapping.mergeChildMappings(
17869
prevChildMapping,
17870
nextChildMapping
17871
)
17872
});
17873
17874
var key;
17875
17876
for (key in nextChildMapping) {
17877
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
17878
if (nextChildMapping[key] && !hasPrev &&
17879
!this.currentlyTransitioningKeys[key]) {
17880
this.keysToEnter.push(key);
17881
}
17882
}
17883
17884
for (key in prevChildMapping) {
17885
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
17886
if (prevChildMapping[key] && !hasNext &&
17887
!this.currentlyTransitioningKeys[key]) {
17888
this.keysToLeave.push(key);
17889
}
17890
}
17891
17892
// If we want to someday check for reordering, we could do it here.
17893
},
17894
17895
componentDidUpdate: function() {
17896
var keysToEnter = this.keysToEnter;
17897
this.keysToEnter = [];
17898
keysToEnter.forEach(this.performEnter);
17899
17900
var keysToLeave = this.keysToLeave;
17901
this.keysToLeave = [];
17902
keysToLeave.forEach(this.performLeave);
17903
},
17904
17905
performAppear: function(key) {
17906
this.currentlyTransitioningKeys[key] = true;
17907
17908
var component = this.refs[key];
17909
17910
if (component.componentWillAppear) {
17911
component.componentWillAppear(
17912
this._handleDoneAppearing.bind(this, key)
17913
);
17914
} else {
17915
this._handleDoneAppearing(key);
17916
}
17917
},
17918
17919
_handleDoneAppearing: function(key) {
17920
var component = this.refs[key];
17921
if (component.componentDidAppear) {
17922
component.componentDidAppear();
17923
}
17924
17925
delete this.currentlyTransitioningKeys[key];
17926
17927
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
17928
this.props.children
17929
);
17930
17931
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
17932
// This was removed before it had fully appeared. Remove it.
17933
this.performLeave(key);
17934
}
17935
},
17936
17937
performEnter: function(key) {
17938
this.currentlyTransitioningKeys[key] = true;
17939
17940
var component = this.refs[key];
17941
17942
if (component.componentWillEnter) {
17943
component.componentWillEnter(
17944
this._handleDoneEntering.bind(this, key)
17945
);
17946
} else {
17947
this._handleDoneEntering(key);
17948
}
17949
},
17950
17951
_handleDoneEntering: function(key) {
17952
var component = this.refs[key];
17953
if (component.componentDidEnter) {
17954
component.componentDidEnter();
17955
}
17956
17957
delete this.currentlyTransitioningKeys[key];
17958
17959
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
17960
this.props.children
17961
);
17962
17963
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
17964
// This was removed before it had fully entered. Remove it.
17965
this.performLeave(key);
17966
}
17967
},
17968
17969
performLeave: function(key) {
17970
this.currentlyTransitioningKeys[key] = true;
17971
17972
var component = this.refs[key];
17973
if (component.componentWillLeave) {
17974
component.componentWillLeave(this._handleDoneLeaving.bind(this, key));
17975
} else {
17976
// Note that this is somewhat dangerous b/c it calls setState()
17977
// again, effectively mutating the component before all the work
17978
// is done.
17979
this._handleDoneLeaving(key);
17980
}
17981
},
17982
17983
_handleDoneLeaving: function(key) {
17984
var component = this.refs[key];
17985
17986
if (component.componentDidLeave) {
17987
component.componentDidLeave();
17988
}
17989
17990
delete this.currentlyTransitioningKeys[key];
17991
17992
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
17993
this.props.children
17994
);
17995
17996
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
17997
// This entered again before it fully left. Add it again.
17998
this.performEnter(key);
17999
} else {
18000
var newChildren = assign({}, this.state.children);
18001
delete newChildren[key];
18002
this.setState({children: newChildren});
18003
}
18004
},
18005
18006
render: function() {
18007
// TODO: we could get rid of the need for the wrapper node
18008
// by cloning a single child
18009
var childrenToRender = [];
18010
for (var key in this.state.children) {
18011
var child = this.state.children[key];
18012
if (child) {
18013
// You may need to apply reactive updates to a child as it is leaving.
18014
// The normal React way to do it won't work since the child will have
18015
// already been removed. In case you need this behavior you can provide
18016
// a childFactory function to wrap every child, even the ones that are
18017
// leaving.
18018
childrenToRender.push(cloneWithProps(
18019
this.props.childFactory(child),
18020
{ref: key, key: key}
18021
));
18022
}
18023
}
18024
return React.createElement(
18025
this.props.component,
18026
this.props,
18027
childrenToRender
18028
);
18029
}
18030
});
18031
18032
module.exports = ReactTransitionGroup;
18033
18034
},{"./Object.assign":42,"./React":44,"./ReactTransitionChildMapping":109,"./cloneWithProps":136,"./emptyFunction":143}],112:[function(require,module,exports){
18035
(function (process){
18036
/**
18037
* Copyright 2015, Facebook, Inc.
18038
* All rights reserved.
18039
*
18040
* This source code is licensed under the BSD-style license found in the
18041
* LICENSE file in the root directory of this source tree. An additional grant
18042
* of patent rights can be found in the PATENTS file in the same directory.
18043
*
18044
* @providesModule ReactUpdateQueue
18045
*/
18046
18047
'use strict';
18048
18049
var ReactLifeCycle = require("./ReactLifeCycle");
18050
var ReactCurrentOwner = require("./ReactCurrentOwner");
18051
var ReactElement = require("./ReactElement");
18052
var ReactInstanceMap = require("./ReactInstanceMap");
18053
var ReactUpdates = require("./ReactUpdates");
18054
18055
var assign = require("./Object.assign");
18056
var invariant = require("./invariant");
18057
var warning = require("./warning");
18058
18059
function enqueueUpdate(internalInstance) {
18060
if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
18061
// If we're in a componentWillMount handler, don't enqueue a rerender
18062
// because ReactUpdates assumes we're in a browser context (which is
18063
// wrong for server rendering) and we're about to do a render anyway.
18064
// See bug in #1740.
18065
ReactUpdates.enqueueUpdate(internalInstance);
18066
}
18067
}
18068
18069
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
18070
("production" !== process.env.NODE_ENV ? invariant(
18071
ReactCurrentOwner.current == null,
18072
'%s(...): Cannot update during an existing state transition ' +
18073
'(such as within `render`). Render methods should be a pure function ' +
18074
'of props and state.',
18075
callerName
18076
) : invariant(ReactCurrentOwner.current == null));
18077
18078
var internalInstance = ReactInstanceMap.get(publicInstance);
18079
if (!internalInstance) {
18080
if ("production" !== process.env.NODE_ENV) {
18081
// Only warn when we have a callerName. Otherwise we should be silent.
18082
// We're probably calling from enqueueCallback. We don't want to warn
18083
// there because we already warned for the corresponding lifecycle method.
18084
("production" !== process.env.NODE_ENV ? warning(
18085
!callerName,
18086
'%s(...): Can only update a mounted or mounting component. ' +
18087
'This usually means you called %s() on an unmounted ' +
18088
'component. This is a no-op.',
18089
callerName,
18090
callerName
18091
) : null);
18092
}
18093
return null;
18094
}
18095
18096
if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
18097
return null;
18098
}
18099
18100
return internalInstance;
18101
}
18102
18103
/**
18104
* ReactUpdateQueue allows for state updates to be scheduled into a later
18105
* reconciliation step.
18106
*/
18107
var ReactUpdateQueue = {
18108
18109
/**
18110
* Enqueue a callback that will be executed after all the pending updates
18111
* have processed.
18112
*
18113
* @param {ReactClass} publicInstance The instance to use as `this` context.
18114
* @param {?function} callback Called after state is updated.
18115
* @internal
18116
*/
18117
enqueueCallback: function(publicInstance, callback) {
18118
("production" !== process.env.NODE_ENV ? invariant(
18119
typeof callback === 'function',
18120
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
18121
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
18122
'isn\'t callable.'
18123
) : invariant(typeof callback === 'function'));
18124
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
18125
18126
// Previously we would throw an error if we didn't have an internal
18127
// instance. Since we want to make it a no-op instead, we mirror the same
18128
// behavior we have in other enqueue* methods.
18129
// We also need to ignore callbacks in componentWillMount. See
18130
// enqueueUpdates.
18131
if (!internalInstance ||
18132
internalInstance === ReactLifeCycle.currentlyMountingInstance) {
18133
return null;
18134
}
18135
18136
if (internalInstance._pendingCallbacks) {
18137
internalInstance._pendingCallbacks.push(callback);
18138
} else {
18139
internalInstance._pendingCallbacks = [callback];
18140
}
18141
// TODO: The callback here is ignored when setState is called from
18142
// componentWillMount. Either fix it or disallow doing so completely in
18143
// favor of getInitialState. Alternatively, we can disallow
18144
// componentWillMount during server-side rendering.
18145
enqueueUpdate(internalInstance);
18146
},
18147
18148
enqueueCallbackInternal: function(internalInstance, callback) {
18149
("production" !== process.env.NODE_ENV ? invariant(
18150
typeof callback === 'function',
18151
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
18152
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
18153
'isn\'t callable.'
18154
) : invariant(typeof callback === 'function'));
18155
if (internalInstance._pendingCallbacks) {
18156
internalInstance._pendingCallbacks.push(callback);
18157
} else {
18158
internalInstance._pendingCallbacks = [callback];
18159
}
18160
enqueueUpdate(internalInstance);
18161
},
18162
18163
/**
18164
* Forces an update. This should only be invoked when it is known with
18165
* certainty that we are **not** in a DOM transaction.
18166
*
18167
* You may want to call this when you know that some deeper aspect of the
18168
* component's state has changed but `setState` was not called.
18169
*
18170
* This will not invoke `shouldUpdateComponent`, but it will invoke
18171
* `componentWillUpdate` and `componentDidUpdate`.
18172
*
18173
* @param {ReactClass} publicInstance The instance that should rerender.
18174
* @internal
18175
*/
18176
enqueueForceUpdate: function(publicInstance) {
18177
var internalInstance = getInternalInstanceReadyForUpdate(
18178
publicInstance,
18179
'forceUpdate'
18180
);
18181
18182
if (!internalInstance) {
18183
return;
18184
}
18185
18186
internalInstance._pendingForceUpdate = true;
18187
18188
enqueueUpdate(internalInstance);
18189
},
18190
18191
/**
18192
* Replaces all of the state. Always use this or `setState` to mutate state.
18193
* You should treat `this.state` as immutable.
18194
*
18195
* There is no guarantee that `this.state` will be immediately updated, so
18196
* accessing `this.state` after calling this method may return the old value.
18197
*
18198
* @param {ReactClass} publicInstance The instance that should rerender.
18199
* @param {object} completeState Next state.
18200
* @internal
18201
*/
18202
enqueueReplaceState: function(publicInstance, completeState) {
18203
var internalInstance = getInternalInstanceReadyForUpdate(
18204
publicInstance,
18205
'replaceState'
18206
);
18207
18208
if (!internalInstance) {
18209
return;
18210
}
18211
18212
internalInstance._pendingStateQueue = [completeState];
18213
internalInstance._pendingReplaceState = true;
18214
18215
enqueueUpdate(internalInstance);
18216
},
18217
18218
/**
18219
* Sets a subset of the state. This only exists because _pendingState is
18220
* internal. This provides a merging strategy that is not available to deep
18221
* properties which is confusing. TODO: Expose pendingState or don't use it
18222
* during the merge.
18223
*
18224
* @param {ReactClass} publicInstance The instance that should rerender.
18225
* @param {object} partialState Next partial state to be merged with state.
18226
* @internal
18227
*/
18228
enqueueSetState: function(publicInstance, partialState) {
18229
var internalInstance = getInternalInstanceReadyForUpdate(
18230
publicInstance,
18231
'setState'
18232
);
18233
18234
if (!internalInstance) {
18235
return;
18236
}
18237
18238
var queue =
18239
internalInstance._pendingStateQueue ||
18240
(internalInstance._pendingStateQueue = []);
18241
queue.push(partialState);
18242
18243
enqueueUpdate(internalInstance);
18244
},
18245
18246
/**
18247
* Sets a subset of the props.
18248
*
18249
* @param {ReactClass} publicInstance The instance that should rerender.
18250
* @param {object} partialProps Subset of the next props.
18251
* @internal
18252
*/
18253
enqueueSetProps: function(publicInstance, partialProps) {
18254
var internalInstance = getInternalInstanceReadyForUpdate(
18255
publicInstance,
18256
'setProps'
18257
);
18258
18259
if (!internalInstance) {
18260
return;
18261
}
18262
18263
("production" !== process.env.NODE_ENV ? invariant(
18264
internalInstance._isTopLevel,
18265
'setProps(...): You called `setProps` on a ' +
18266
'component with a parent. This is an anti-pattern since props will ' +
18267
'get reactively updated when rendered. Instead, change the owner\'s ' +
18268
'`render` method to pass the correct value as props to the component ' +
18269
'where it is created.'
18270
) : invariant(internalInstance._isTopLevel));
18271
18272
// Merge with the pending element if it exists, otherwise with existing
18273
// element props.
18274
var element = internalInstance._pendingElement ||
18275
internalInstance._currentElement;
18276
var props = assign({}, element.props, partialProps);
18277
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
18278
element,
18279
props
18280
);
18281
18282
enqueueUpdate(internalInstance);
18283
},
18284
18285
/**
18286
* Replaces all of the props.
18287
*
18288
* @param {ReactClass} publicInstance The instance that should rerender.
18289
* @param {object} props New props.
18290
* @internal
18291
*/
18292
enqueueReplaceProps: function(publicInstance, props) {
18293
var internalInstance = getInternalInstanceReadyForUpdate(
18294
publicInstance,
18295
'replaceProps'
18296
);
18297
18298
if (!internalInstance) {
18299
return;
18300
}
18301
18302
("production" !== process.env.NODE_ENV ? invariant(
18303
internalInstance._isTopLevel,
18304
'replaceProps(...): You called `replaceProps` on a ' +
18305
'component with a parent. This is an anti-pattern since props will ' +
18306
'get reactively updated when rendered. Instead, change the owner\'s ' +
18307
'`render` method to pass the correct value as props to the component ' +
18308
'where it is created.'
18309
) : invariant(internalInstance._isTopLevel));
18310
18311
// Merge with the pending element if it exists, otherwise with existing
18312
// element props.
18313
var element = internalInstance._pendingElement ||
18314
internalInstance._currentElement;
18315
internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(
18316
element,
18317
props
18318
);
18319
18320
enqueueUpdate(internalInstance);
18321
},
18322
18323
enqueueElementInternal: function(internalInstance, newElement) {
18324
internalInstance._pendingElement = newElement;
18325
enqueueUpdate(internalInstance);
18326
}
18327
18328
};
18329
18330
module.exports = ReactUpdateQueue;
18331
18332
}).call(this,require('_process'))
18333
},{"./Object.assign":42,"./ReactCurrentOwner":58,"./ReactElement":76,"./ReactInstanceMap":86,"./ReactLifeCycle":87,"./ReactUpdates":113,"./invariant":164,"./warning":185,"_process":1}],113:[function(require,module,exports){
18334
(function (process){
18335
/**
18336
* Copyright 2013-2015, Facebook, Inc.
18337
* All rights reserved.
18338
*
18339
* This source code is licensed under the BSD-style license found in the
18340
* LICENSE file in the root directory of this source tree. An additional grant
18341
* of patent rights can be found in the PATENTS file in the same directory.
18342
*
18343
* @providesModule ReactUpdates
18344
*/
18345
18346
'use strict';
18347
18348
var CallbackQueue = require("./CallbackQueue");
18349
var PooledClass = require("./PooledClass");
18350
var ReactCurrentOwner = require("./ReactCurrentOwner");
18351
var ReactPerf = require("./ReactPerf");
18352
var ReactReconciler = require("./ReactReconciler");
18353
var Transaction = require("./Transaction");
18354
18355
var assign = require("./Object.assign");
18356
var invariant = require("./invariant");
18357
var warning = require("./warning");
18358
18359
var dirtyComponents = [];
18360
var asapCallbackQueue = CallbackQueue.getPooled();
18361
var asapEnqueued = false;
18362
18363
var batchingStrategy = null;
18364
18365
function ensureInjected() {
18366
("production" !== process.env.NODE_ENV ? invariant(
18367
ReactUpdates.ReactReconcileTransaction && batchingStrategy,
18368
'ReactUpdates: must inject a reconcile transaction class and batching ' +
18369
'strategy'
18370
) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
18371
}
18372
18373
var NESTED_UPDATES = {
18374
initialize: function() {
18375
this.dirtyComponentsLength = dirtyComponents.length;
18376
},
18377
close: function() {
18378
if (this.dirtyComponentsLength !== dirtyComponents.length) {
18379
// Additional updates were enqueued by componentDidUpdate handlers or
18380
// similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
18381
// these new updates so that if A's componentDidUpdate calls setState on
18382
// B, B will update before the callback A's updater provided when calling
18383
// setState.
18384
dirtyComponents.splice(0, this.dirtyComponentsLength);
18385
flushBatchedUpdates();
18386
} else {
18387
dirtyComponents.length = 0;
18388
}
18389
}
18390
};
18391
18392
var UPDATE_QUEUEING = {
18393
initialize: function() {
18394
this.callbackQueue.reset();
18395
},
18396
close: function() {
18397
this.callbackQueue.notifyAll();
18398
}
18399
};
18400
18401
var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
18402
18403
function ReactUpdatesFlushTransaction() {
18404
this.reinitializeTransaction();
18405
this.dirtyComponentsLength = null;
18406
this.callbackQueue = CallbackQueue.getPooled();
18407
this.reconcileTransaction =
18408
ReactUpdates.ReactReconcileTransaction.getPooled();
18409
}
18410
18411
assign(
18412
ReactUpdatesFlushTransaction.prototype,
18413
Transaction.Mixin, {
18414
getTransactionWrappers: function() {
18415
return TRANSACTION_WRAPPERS;
18416
},
18417
18418
destructor: function() {
18419
this.dirtyComponentsLength = null;
18420
CallbackQueue.release(this.callbackQueue);
18421
this.callbackQueue = null;
18422
ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
18423
this.reconcileTransaction = null;
18424
},
18425
18426
perform: function(method, scope, a) {
18427
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
18428
// with this transaction's wrappers around it.
18429
return Transaction.Mixin.perform.call(
18430
this,
18431
this.reconcileTransaction.perform,
18432
this.reconcileTransaction,
18433
method,
18434
scope,
18435
a
18436
);
18437
}
18438
});
18439
18440
PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
18441
18442
function batchedUpdates(callback, a, b, c, d) {
18443
ensureInjected();
18444
batchingStrategy.batchedUpdates(callback, a, b, c, d);
18445
}
18446
18447
/**
18448
* Array comparator for ReactComponents by mount ordering.
18449
*
18450
* @param {ReactComponent} c1 first component you're comparing
18451
* @param {ReactComponent} c2 second component you're comparing
18452
* @return {number} Return value usable by Array.prototype.sort().
18453
*/
18454
function mountOrderComparator(c1, c2) {
18455
return c1._mountOrder - c2._mountOrder;
18456
}
18457
18458
function runBatchedUpdates(transaction) {
18459
var len = transaction.dirtyComponentsLength;
18460
("production" !== process.env.NODE_ENV ? invariant(
18461
len === dirtyComponents.length,
18462
'Expected flush transaction\'s stored dirty-components length (%s) to ' +
18463
'match dirty-components array length (%s).',
18464
len,
18465
dirtyComponents.length
18466
) : invariant(len === dirtyComponents.length));
18467
18468
// Since reconciling a component higher in the owner hierarchy usually (not
18469
// always -- see shouldComponentUpdate()) will reconcile children, reconcile
18470
// them before their children by sorting the array.
18471
dirtyComponents.sort(mountOrderComparator);
18472
18473
for (var i = 0; i < len; i++) {
18474
// If a component is unmounted before pending changes apply, it will still
18475
// be here, but we assume that it has cleared its _pendingCallbacks and
18476
// that performUpdateIfNecessary is a noop.
18477
var component = dirtyComponents[i];
18478
18479
// If performUpdateIfNecessary happens to enqueue any new updates, we
18480
// shouldn't execute the callbacks until the next render happens, so
18481
// stash the callbacks first
18482
var callbacks = component._pendingCallbacks;
18483
component._pendingCallbacks = null;
18484
18485
ReactReconciler.performUpdateIfNecessary(
18486
component,
18487
transaction.reconcileTransaction
18488
);
18489
18490
if (callbacks) {
18491
for (var j = 0; j < callbacks.length; j++) {
18492
transaction.callbackQueue.enqueue(
18493
callbacks[j],
18494
component.getPublicInstance()
18495
);
18496
}
18497
}
18498
}
18499
}
18500
18501
var flushBatchedUpdates = function() {
18502
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
18503
// array and perform any updates enqueued by mount-ready handlers (i.e.,
18504
// componentDidUpdate) but we need to check here too in order to catch
18505
// updates enqueued by setState callbacks and asap calls.
18506
while (dirtyComponents.length || asapEnqueued) {
18507
if (dirtyComponents.length) {
18508
var transaction = ReactUpdatesFlushTransaction.getPooled();
18509
transaction.perform(runBatchedUpdates, null, transaction);
18510
ReactUpdatesFlushTransaction.release(transaction);
18511
}
18512
18513
if (asapEnqueued) {
18514
asapEnqueued = false;
18515
var queue = asapCallbackQueue;
18516
asapCallbackQueue = CallbackQueue.getPooled();
18517
queue.notifyAll();
18518
CallbackQueue.release(queue);
18519
}
18520
}
18521
};
18522
flushBatchedUpdates = ReactPerf.measure(
18523
'ReactUpdates',
18524
'flushBatchedUpdates',
18525
flushBatchedUpdates
18526
);
18527
18528
/**
18529
* Mark a component as needing a rerender, adding an optional callback to a
18530
* list of functions which will be executed once the rerender occurs.
18531
*/
18532
function enqueueUpdate(component) {
18533
ensureInjected();
18534
18535
// Various parts of our code (such as ReactCompositeComponent's
18536
// _renderValidatedComponent) assume that calls to render aren't nested;
18537
// verify that that's the case. (This is called by each top-level update
18538
// function, like setProps, setState, forceUpdate, etc.; creation and
18539
// destruction of top-level components is guarded in ReactMount.)
18540
("production" !== process.env.NODE_ENV ? warning(
18541
ReactCurrentOwner.current == null,
18542
'enqueueUpdate(): Render methods should be a pure function of props ' +
18543
'and state; triggering nested component updates from render is not ' +
18544
'allowed. If necessary, trigger nested updates in ' +
18545
'componentDidUpdate.'
18546
) : null);
18547
18548
if (!batchingStrategy.isBatchingUpdates) {
18549
batchingStrategy.batchedUpdates(enqueueUpdate, component);
18550
return;
18551
}
18552
18553
dirtyComponents.push(component);
18554
}
18555
18556
/**
18557
* Enqueue a callback to be run at the end of the current batching cycle. Throws
18558
* if no updates are currently being performed.
18559
*/
18560
function asap(callback, context) {
18561
("production" !== process.env.NODE_ENV ? invariant(
18562
batchingStrategy.isBatchingUpdates,
18563
'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
18564
'updates are not being batched.'
18565
) : invariant(batchingStrategy.isBatchingUpdates));
18566
asapCallbackQueue.enqueue(callback, context);
18567
asapEnqueued = true;
18568
}
18569
18570
var ReactUpdatesInjection = {
18571
injectReconcileTransaction: function(ReconcileTransaction) {
18572
("production" !== process.env.NODE_ENV ? invariant(
18573
ReconcileTransaction,
18574
'ReactUpdates: must provide a reconcile transaction class'
18575
) : invariant(ReconcileTransaction));
18576
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
18577
},
18578
18579
injectBatchingStrategy: function(_batchingStrategy) {
18580
("production" !== process.env.NODE_ENV ? invariant(
18581
_batchingStrategy,
18582
'ReactUpdates: must provide a batching strategy'
18583
) : invariant(_batchingStrategy));
18584
("production" !== process.env.NODE_ENV ? invariant(
18585
typeof _batchingStrategy.batchedUpdates === 'function',
18586
'ReactUpdates: must provide a batchedUpdates() function'
18587
) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
18588
("production" !== process.env.NODE_ENV ? invariant(
18589
typeof _batchingStrategy.isBatchingUpdates === 'boolean',
18590
'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
18591
) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
18592
batchingStrategy = _batchingStrategy;
18593
}
18594
};
18595
18596
var ReactUpdates = {
18597
/**
18598
* React references `ReactReconcileTransaction` using this property in order
18599
* to allow dependency injection.
18600
*
18601
* @internal
18602
*/
18603
ReactReconcileTransaction: null,
18604
18605
batchedUpdates: batchedUpdates,
18606
enqueueUpdate: enqueueUpdate,
18607
flushBatchedUpdates: flushBatchedUpdates,
18608
injection: ReactUpdatesInjection,
18609
asap: asap
18610
};
18611
18612
module.exports = ReactUpdates;
18613
18614
}).call(this,require('_process'))
18615
},{"./CallbackQueue":20,"./Object.assign":42,"./PooledClass":43,"./ReactCurrentOwner":58,"./ReactPerf":95,"./ReactReconciler":102,"./Transaction":130,"./invariant":164,"./warning":185,"_process":1}],114:[function(require,module,exports){
18616
(function (process){
18617
/**
18618
* Copyright 2013-2015, Facebook, Inc.
18619
* All rights reserved.
18620
*
18621
* This source code is licensed under the BSD-style license found in the
18622
* LICENSE file in the root directory of this source tree. An additional grant
18623
* of patent rights can be found in the PATENTS file in the same directory.
18624
*
18625
* @providesModule ReactWithAddons
18626
*/
18627
18628
/**
18629
* This module exists purely in the open source project, and is meant as a way
18630
* to create a separate standalone build of React. This build has "addons", or
18631
* functionality we've built and think might be useful but doesn't have a good
18632
* place to live inside React core.
18633
*/
18634
18635
'use strict';
18636
18637
var LinkedStateMixin = require("./LinkedStateMixin");
18638
var React = require("./React");
18639
var ReactComponentWithPureRenderMixin =
18640
require("./ReactComponentWithPureRenderMixin");
18641
var ReactCSSTransitionGroup = require("./ReactCSSTransitionGroup");
18642
var ReactFragment = require("./ReactFragment");
18643
var ReactTransitionGroup = require("./ReactTransitionGroup");
18644
var ReactUpdates = require("./ReactUpdates");
18645
18646
var cx = require("./cx");
18647
var cloneWithProps = require("./cloneWithProps");
18648
var update = require("./update");
18649
18650
React.addons = {
18651
CSSTransitionGroup: ReactCSSTransitionGroup,
18652
LinkedStateMixin: LinkedStateMixin,
18653
PureRenderMixin: ReactComponentWithPureRenderMixin,
18654
TransitionGroup: ReactTransitionGroup,
18655
18656
batchedUpdates: ReactUpdates.batchedUpdates,
18657
classSet: cx,
18658
cloneWithProps: cloneWithProps,
18659
createFragment: ReactFragment.create,
18660
update: update
18661
};
18662
18663
if ("production" !== process.env.NODE_ENV) {
18664
React.addons.Perf = require("./ReactDefaultPerf");
18665
React.addons.TestUtils = require("./ReactTestUtils");
18666
}
18667
18668
module.exports = React;
18669
18670
}).call(this,require('_process'))
18671
},{"./LinkedStateMixin":38,"./React":44,"./ReactCSSTransitionGroup":47,"./ReactComponentWithPureRenderMixin":55,"./ReactDefaultPerf":74,"./ReactFragment":82,"./ReactTestUtils":108,"./ReactTransitionGroup":111,"./ReactUpdates":113,"./cloneWithProps":136,"./cx":141,"./update":184,"_process":1}],115:[function(require,module,exports){
18672
/**
18673
* Copyright 2013-2015, Facebook, Inc.
18674
* All rights reserved.
18675
*
18676
* This source code is licensed under the BSD-style license found in the
18677
* LICENSE file in the root directory of this source tree. An additional grant
18678
* of patent rights can be found in the PATENTS file in the same directory.
18679
*
18680
* @providesModule SVGDOMPropertyConfig
18681
*/
18682
18683
/*jslint bitwise: true*/
18684
18685
'use strict';
18686
18687
var DOMProperty = require("./DOMProperty");
18688
18689
var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
18690
18691
var SVGDOMPropertyConfig = {
18692
Properties: {
18693
clipPath: MUST_USE_ATTRIBUTE,
18694
cx: MUST_USE_ATTRIBUTE,
18695
cy: MUST_USE_ATTRIBUTE,
18696
d: MUST_USE_ATTRIBUTE,
18697
dx: MUST_USE_ATTRIBUTE,
18698
dy: MUST_USE_ATTRIBUTE,
18699
fill: MUST_USE_ATTRIBUTE,
18700
fillOpacity: MUST_USE_ATTRIBUTE,
18701
fontFamily: MUST_USE_ATTRIBUTE,
18702
fontSize: MUST_USE_ATTRIBUTE,
18703
fx: MUST_USE_ATTRIBUTE,
18704
fy: MUST_USE_ATTRIBUTE,
18705
gradientTransform: MUST_USE_ATTRIBUTE,
18706
gradientUnits: MUST_USE_ATTRIBUTE,
18707
markerEnd: MUST_USE_ATTRIBUTE,
18708
markerMid: MUST_USE_ATTRIBUTE,
18709
markerStart: MUST_USE_ATTRIBUTE,
18710
offset: MUST_USE_ATTRIBUTE,
18711
opacity: MUST_USE_ATTRIBUTE,
18712
patternContentUnits: MUST_USE_ATTRIBUTE,
18713
patternUnits: MUST_USE_ATTRIBUTE,
18714
points: MUST_USE_ATTRIBUTE,
18715
preserveAspectRatio: MUST_USE_ATTRIBUTE,
18716
r: MUST_USE_ATTRIBUTE,
18717
rx: MUST_USE_ATTRIBUTE,
18718
ry: MUST_USE_ATTRIBUTE,
18719
spreadMethod: MUST_USE_ATTRIBUTE,
18720
stopColor: MUST_USE_ATTRIBUTE,
18721
stopOpacity: MUST_USE_ATTRIBUTE,
18722
stroke: MUST_USE_ATTRIBUTE,
18723
strokeDasharray: MUST_USE_ATTRIBUTE,
18724
strokeLinecap: MUST_USE_ATTRIBUTE,
18725
strokeOpacity: MUST_USE_ATTRIBUTE,
18726
strokeWidth: MUST_USE_ATTRIBUTE,
18727
textAnchor: MUST_USE_ATTRIBUTE,
18728
transform: MUST_USE_ATTRIBUTE,
18729
version: MUST_USE_ATTRIBUTE,
18730
viewBox: MUST_USE_ATTRIBUTE,
18731
x1: MUST_USE_ATTRIBUTE,
18732
x2: MUST_USE_ATTRIBUTE,
18733
x: MUST_USE_ATTRIBUTE,
18734
y1: MUST_USE_ATTRIBUTE,
18735
y2: MUST_USE_ATTRIBUTE,
18736
y: MUST_USE_ATTRIBUTE
18737
},
18738
DOMAttributeNames: {
18739
clipPath: 'clip-path',
18740
fillOpacity: 'fill-opacity',
18741
fontFamily: 'font-family',
18742
fontSize: 'font-size',
18743
gradientTransform: 'gradientTransform',
18744
gradientUnits: 'gradientUnits',
18745
markerEnd: 'marker-end',
18746
markerMid: 'marker-mid',
18747
markerStart: 'marker-start',
18748
patternContentUnits: 'patternContentUnits',
18749
patternUnits: 'patternUnits',
18750
preserveAspectRatio: 'preserveAspectRatio',
18751
spreadMethod: 'spreadMethod',
18752
stopColor: 'stop-color',
18753
stopOpacity: 'stop-opacity',
18754
strokeDasharray: 'stroke-dasharray',
18755
strokeLinecap: 'stroke-linecap',
18756
strokeOpacity: 'stroke-opacity',
18757
strokeWidth: 'stroke-width',
18758
textAnchor: 'text-anchor',
18759
viewBox: 'viewBox'
18760
}
18761
};
18762
18763
module.exports = SVGDOMPropertyConfig;
18764
18765
},{"./DOMProperty":24}],116:[function(require,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 SelectEventPlugin
18775
*/
18776
18777
'use strict';
18778
18779
var EventConstants = require("./EventConstants");
18780
var EventPropagators = require("./EventPropagators");
18781
var ReactInputSelection = require("./ReactInputSelection");
18782
var SyntheticEvent = require("./SyntheticEvent");
18783
18784
var getActiveElement = require("./getActiveElement");
18785
var isTextInputElement = require("./isTextInputElement");
18786
var keyOf = require("./keyOf");
18787
var shallowEqual = require("./shallowEqual");
18788
18789
var topLevelTypes = EventConstants.topLevelTypes;
18790
18791
var eventTypes = {
18792
select: {
18793
phasedRegistrationNames: {
18794
bubbled: keyOf({onSelect: null}),
18795
captured: keyOf({onSelectCapture: null})
18796
},
18797
dependencies: [
18798
topLevelTypes.topBlur,
18799
topLevelTypes.topContextMenu,
18800
topLevelTypes.topFocus,
18801
topLevelTypes.topKeyDown,
18802
topLevelTypes.topMouseDown,
18803
topLevelTypes.topMouseUp,
18804
topLevelTypes.topSelectionChange
18805
]
18806
}
18807
};
18808
18809
var activeElement = null;
18810
var activeElementID = null;
18811
var lastSelection = null;
18812
var mouseDown = false;
18813
18814
/**
18815
* Get an object which is a unique representation of the current selection.
18816
*
18817
* The return value will not be consistent across nodes or browsers, but
18818
* two identical selections on the same node will return identical objects.
18819
*
18820
* @param {DOMElement} node
18821
* @param {object}
18822
*/
18823
function getSelection(node) {
18824
if ('selectionStart' in node &&
18825
ReactInputSelection.hasSelectionCapabilities(node)) {
18826
return {
18827
start: node.selectionStart,
18828
end: node.selectionEnd
18829
};
18830
} else if (window.getSelection) {
18831
var selection = window.getSelection();
18832
return {
18833
anchorNode: selection.anchorNode,
18834
anchorOffset: selection.anchorOffset,
18835
focusNode: selection.focusNode,
18836
focusOffset: selection.focusOffset
18837
};
18838
} else if (document.selection) {
18839
var range = document.selection.createRange();
18840
return {
18841
parentElement: range.parentElement(),
18842
text: range.text,
18843
top: range.boundingTop,
18844
left: range.boundingLeft
18845
};
18846
}
18847
}
18848
18849
/**
18850
* Poll selection to see whether it's changed.
18851
*
18852
* @param {object} nativeEvent
18853
* @return {?SyntheticEvent}
18854
*/
18855
function constructSelectEvent(nativeEvent) {
18856
// Ensure we have the right element, and that the user is not dragging a
18857
// selection (this matches native `select` event behavior). In HTML5, select
18858
// fires only on input and textarea thus if there's no focused element we
18859
// won't dispatch.
18860
if (mouseDown ||
18861
activeElement == null ||
18862
activeElement !== getActiveElement()) {
18863
return null;
18864
}
18865
18866
// Only fire when selection has actually changed.
18867
var currentSelection = getSelection(activeElement);
18868
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
18869
lastSelection = currentSelection;
18870
18871
var syntheticEvent = SyntheticEvent.getPooled(
18872
eventTypes.select,
18873
activeElementID,
18874
nativeEvent
18875
);
18876
18877
syntheticEvent.type = 'select';
18878
syntheticEvent.target = activeElement;
18879
18880
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
18881
18882
return syntheticEvent;
18883
}
18884
}
18885
18886
/**
18887
* This plugin creates an `onSelect` event that normalizes select events
18888
* across form elements.
18889
*
18890
* Supported elements are:
18891
* - input (see `isTextInputElement`)
18892
* - textarea
18893
* - contentEditable
18894
*
18895
* This differs from native browser implementations in the following ways:
18896
* - Fires on contentEditable fields as well as inputs.
18897
* - Fires for collapsed selection.
18898
* - Fires after user input.
18899
*/
18900
var SelectEventPlugin = {
18901
18902
eventTypes: eventTypes,
18903
18904
/**
18905
* @param {string} topLevelType Record from `EventConstants`.
18906
* @param {DOMEventTarget} topLevelTarget The listening component root node.
18907
* @param {string} topLevelTargetID ID of `topLevelTarget`.
18908
* @param {object} nativeEvent Native browser event.
18909
* @return {*} An accumulation of synthetic events.
18910
* @see {EventPluginHub.extractEvents}
18911
*/
18912
extractEvents: function(
18913
topLevelType,
18914
topLevelTarget,
18915
topLevelTargetID,
18916
nativeEvent) {
18917
18918
switch (topLevelType) {
18919
// Track the input node that has focus.
18920
case topLevelTypes.topFocus:
18921
if (isTextInputElement(topLevelTarget) ||
18922
topLevelTarget.contentEditable === 'true') {
18923
activeElement = topLevelTarget;
18924
activeElementID = topLevelTargetID;
18925
lastSelection = null;
18926
}
18927
break;
18928
case topLevelTypes.topBlur:
18929
activeElement = null;
18930
activeElementID = null;
18931
lastSelection = null;
18932
break;
18933
18934
// Don't fire the event while the user is dragging. This matches the
18935
// semantics of the native select event.
18936
case topLevelTypes.topMouseDown:
18937
mouseDown = true;
18938
break;
18939
case topLevelTypes.topContextMenu:
18940
case topLevelTypes.topMouseUp:
18941
mouseDown = false;
18942
return constructSelectEvent(nativeEvent);
18943
18944
// Chrome and IE fire non-standard event when selection is changed (and
18945
// sometimes when it hasn't).
18946
// Firefox doesn't support selectionchange, so check selection status
18947
// after each key entry. The selection changes after keydown and before
18948
// keyup, but we check on keydown as well in the case of holding down a
18949
// key, when multiple keydown events are fired but only one keyup is.
18950
case topLevelTypes.topSelectionChange:
18951
case topLevelTypes.topKeyDown:
18952
case topLevelTypes.topKeyUp:
18953
return constructSelectEvent(nativeEvent);
18954
}
18955
}
18956
};
18957
18958
module.exports = SelectEventPlugin;
18959
18960
},{"./EventConstants":29,"./EventPropagators":34,"./ReactInputSelection":84,"./SyntheticEvent":122,"./getActiveElement":150,"./isTextInputElement":167,"./keyOf":171,"./shallowEqual":180}],117:[function(require,module,exports){
18961
/**
18962
* Copyright 2013-2015, Facebook, Inc.
18963
* All rights reserved.
18964
*
18965
* This source code is licensed under the BSD-style license found in the
18966
* LICENSE file in the root directory of this source tree. An additional grant
18967
* of patent rights can be found in the PATENTS file in the same directory.
18968
*
18969
* @providesModule ServerReactRootIndex
18970
* @typechecks
18971
*/
18972
18973
'use strict';
18974
18975
/**
18976
* Size of the reactRoot ID space. We generate random numbers for React root
18977
* IDs and if there's a collision the events and DOM update system will
18978
* get confused. In the future we need a way to generate GUIDs but for
18979
* now this will work on a smaller scale.
18980
*/
18981
var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
18982
18983
var ServerReactRootIndex = {
18984
createReactRootIndex: function() {
18985
return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
18986
}
18987
};
18988
18989
module.exports = ServerReactRootIndex;
18990
18991
},{}],118:[function(require,module,exports){
18992
(function (process){
18993
/**
18994
* Copyright 2013-2015, Facebook, Inc.
18995
* All rights reserved.
18996
*
18997
* This source code is licensed under the BSD-style license found in the
18998
* LICENSE file in the root directory of this source tree. An additional grant
18999
* of patent rights can be found in the PATENTS file in the same directory.
19000
*
19001
* @providesModule SimpleEventPlugin
19002
*/
19003
19004
'use strict';
19005
19006
var EventConstants = require("./EventConstants");
19007
var EventPluginUtils = require("./EventPluginUtils");
19008
var EventPropagators = require("./EventPropagators");
19009
var SyntheticClipboardEvent = require("./SyntheticClipboardEvent");
19010
var SyntheticEvent = require("./SyntheticEvent");
19011
var SyntheticFocusEvent = require("./SyntheticFocusEvent");
19012
var SyntheticKeyboardEvent = require("./SyntheticKeyboardEvent");
19013
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
19014
var SyntheticDragEvent = require("./SyntheticDragEvent");
19015
var SyntheticTouchEvent = require("./SyntheticTouchEvent");
19016
var SyntheticUIEvent = require("./SyntheticUIEvent");
19017
var SyntheticWheelEvent = require("./SyntheticWheelEvent");
19018
19019
var getEventCharCode = require("./getEventCharCode");
19020
19021
var invariant = require("./invariant");
19022
var keyOf = require("./keyOf");
19023
var warning = require("./warning");
19024
19025
var topLevelTypes = EventConstants.topLevelTypes;
19026
19027
var eventTypes = {
19028
blur: {
19029
phasedRegistrationNames: {
19030
bubbled: keyOf({onBlur: true}),
19031
captured: keyOf({onBlurCapture: true})
19032
}
19033
},
19034
click: {
19035
phasedRegistrationNames: {
19036
bubbled: keyOf({onClick: true}),
19037
captured: keyOf({onClickCapture: true})
19038
}
19039
},
19040
contextMenu: {
19041
phasedRegistrationNames: {
19042
bubbled: keyOf({onContextMenu: true}),
19043
captured: keyOf({onContextMenuCapture: true})
19044
}
19045
},
19046
copy: {
19047
phasedRegistrationNames: {
19048
bubbled: keyOf({onCopy: true}),
19049
captured: keyOf({onCopyCapture: true})
19050
}
19051
},
19052
cut: {
19053
phasedRegistrationNames: {
19054
bubbled: keyOf({onCut: true}),
19055
captured: keyOf({onCutCapture: true})
19056
}
19057
},
19058
doubleClick: {
19059
phasedRegistrationNames: {
19060
bubbled: keyOf({onDoubleClick: true}),
19061
captured: keyOf({onDoubleClickCapture: true})
19062
}
19063
},
19064
drag: {
19065
phasedRegistrationNames: {
19066
bubbled: keyOf({onDrag: true}),
19067
captured: keyOf({onDragCapture: true})
19068
}
19069
},
19070
dragEnd: {
19071
phasedRegistrationNames: {
19072
bubbled: keyOf({onDragEnd: true}),
19073
captured: keyOf({onDragEndCapture: true})
19074
}
19075
},
19076
dragEnter: {
19077
phasedRegistrationNames: {
19078
bubbled: keyOf({onDragEnter: true}),
19079
captured: keyOf({onDragEnterCapture: true})
19080
}
19081
},
19082
dragExit: {
19083
phasedRegistrationNames: {
19084
bubbled: keyOf({onDragExit: true}),
19085
captured: keyOf({onDragExitCapture: true})
19086
}
19087
},
19088
dragLeave: {
19089
phasedRegistrationNames: {
19090
bubbled: keyOf({onDragLeave: true}),
19091
captured: keyOf({onDragLeaveCapture: true})
19092
}
19093
},
19094
dragOver: {
19095
phasedRegistrationNames: {
19096
bubbled: keyOf({onDragOver: true}),
19097
captured: keyOf({onDragOverCapture: true})
19098
}
19099
},
19100
dragStart: {
19101
phasedRegistrationNames: {
19102
bubbled: keyOf({onDragStart: true}),
19103
captured: keyOf({onDragStartCapture: true})
19104
}
19105
},
19106
drop: {
19107
phasedRegistrationNames: {
19108
bubbled: keyOf({onDrop: true}),
19109
captured: keyOf({onDropCapture: true})
19110
}
19111
},
19112
focus: {
19113
phasedRegistrationNames: {
19114
bubbled: keyOf({onFocus: true}),
19115
captured: keyOf({onFocusCapture: true})
19116
}
19117
},
19118
input: {
19119
phasedRegistrationNames: {
19120
bubbled: keyOf({onInput: true}),
19121
captured: keyOf({onInputCapture: true})
19122
}
19123
},
19124
keyDown: {
19125
phasedRegistrationNames: {
19126
bubbled: keyOf({onKeyDown: true}),
19127
captured: keyOf({onKeyDownCapture: true})
19128
}
19129
},
19130
keyPress: {
19131
phasedRegistrationNames: {
19132
bubbled: keyOf({onKeyPress: true}),
19133
captured: keyOf({onKeyPressCapture: true})
19134
}
19135
},
19136
keyUp: {
19137
phasedRegistrationNames: {
19138
bubbled: keyOf({onKeyUp: true}),
19139
captured: keyOf({onKeyUpCapture: true})
19140
}
19141
},
19142
load: {
19143
phasedRegistrationNames: {
19144
bubbled: keyOf({onLoad: true}),
19145
captured: keyOf({onLoadCapture: true})
19146
}
19147
},
19148
error: {
19149
phasedRegistrationNames: {
19150
bubbled: keyOf({onError: true}),
19151
captured: keyOf({onErrorCapture: true})
19152
}
19153
},
19154
// Note: We do not allow listening to mouseOver events. Instead, use the
19155
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
19156
mouseDown: {
19157
phasedRegistrationNames: {
19158
bubbled: keyOf({onMouseDown: true}),
19159
captured: keyOf({onMouseDownCapture: true})
19160
}
19161
},
19162
mouseMove: {
19163
phasedRegistrationNames: {
19164
bubbled: keyOf({onMouseMove: true}),
19165
captured: keyOf({onMouseMoveCapture: true})
19166
}
19167
},
19168
mouseOut: {
19169
phasedRegistrationNames: {
19170
bubbled: keyOf({onMouseOut: true}),
19171
captured: keyOf({onMouseOutCapture: true})
19172
}
19173
},
19174
mouseOver: {
19175
phasedRegistrationNames: {
19176
bubbled: keyOf({onMouseOver: true}),
19177
captured: keyOf({onMouseOverCapture: true})
19178
}
19179
},
19180
mouseUp: {
19181
phasedRegistrationNames: {
19182
bubbled: keyOf({onMouseUp: true}),
19183
captured: keyOf({onMouseUpCapture: true})
19184
}
19185
},
19186
paste: {
19187
phasedRegistrationNames: {
19188
bubbled: keyOf({onPaste: true}),
19189
captured: keyOf({onPasteCapture: true})
19190
}
19191
},
19192
reset: {
19193
phasedRegistrationNames: {
19194
bubbled: keyOf({onReset: true}),
19195
captured: keyOf({onResetCapture: true})
19196
}
19197
},
19198
scroll: {
19199
phasedRegistrationNames: {
19200
bubbled: keyOf({onScroll: true}),
19201
captured: keyOf({onScrollCapture: true})
19202
}
19203
},
19204
submit: {
19205
phasedRegistrationNames: {
19206
bubbled: keyOf({onSubmit: true}),
19207
captured: keyOf({onSubmitCapture: true})
19208
}
19209
},
19210
touchCancel: {
19211
phasedRegistrationNames: {
19212
bubbled: keyOf({onTouchCancel: true}),
19213
captured: keyOf({onTouchCancelCapture: true})
19214
}
19215
},
19216
touchEnd: {
19217
phasedRegistrationNames: {
19218
bubbled: keyOf({onTouchEnd: true}),
19219
captured: keyOf({onTouchEndCapture: true})
19220
}
19221
},
19222
touchMove: {
19223
phasedRegistrationNames: {
19224
bubbled: keyOf({onTouchMove: true}),
19225
captured: keyOf({onTouchMoveCapture: true})
19226
}
19227
},
19228
touchStart: {
19229
phasedRegistrationNames: {
19230
bubbled: keyOf({onTouchStart: true}),
19231
captured: keyOf({onTouchStartCapture: true})
19232
}
19233
},
19234
wheel: {
19235
phasedRegistrationNames: {
19236
bubbled: keyOf({onWheel: true}),
19237
captured: keyOf({onWheelCapture: true})
19238
}
19239
}
19240
};
19241
19242
var topLevelEventsToDispatchConfig = {
19243
topBlur: eventTypes.blur,
19244
topClick: eventTypes.click,
19245
topContextMenu: eventTypes.contextMenu,
19246
topCopy: eventTypes.copy,
19247
topCut: eventTypes.cut,
19248
topDoubleClick: eventTypes.doubleClick,
19249
topDrag: eventTypes.drag,
19250
topDragEnd: eventTypes.dragEnd,
19251
topDragEnter: eventTypes.dragEnter,
19252
topDragExit: eventTypes.dragExit,
19253
topDragLeave: eventTypes.dragLeave,
19254
topDragOver: eventTypes.dragOver,
19255
topDragStart: eventTypes.dragStart,
19256
topDrop: eventTypes.drop,
19257
topError: eventTypes.error,
19258
topFocus: eventTypes.focus,
19259
topInput: eventTypes.input,
19260
topKeyDown: eventTypes.keyDown,
19261
topKeyPress: eventTypes.keyPress,
19262
topKeyUp: eventTypes.keyUp,
19263
topLoad: eventTypes.load,
19264
topMouseDown: eventTypes.mouseDown,
19265
topMouseMove: eventTypes.mouseMove,
19266
topMouseOut: eventTypes.mouseOut,
19267
topMouseOver: eventTypes.mouseOver,
19268
topMouseUp: eventTypes.mouseUp,
19269
topPaste: eventTypes.paste,
19270
topReset: eventTypes.reset,
19271
topScroll: eventTypes.scroll,
19272
topSubmit: eventTypes.submit,
19273
topTouchCancel: eventTypes.touchCancel,
19274
topTouchEnd: eventTypes.touchEnd,
19275
topTouchMove: eventTypes.touchMove,
19276
topTouchStart: eventTypes.touchStart,
19277
topWheel: eventTypes.wheel
19278
};
19279
19280
for (var type in topLevelEventsToDispatchConfig) {
19281
topLevelEventsToDispatchConfig[type].dependencies = [type];
19282
}
19283
19284
var SimpleEventPlugin = {
19285
19286
eventTypes: eventTypes,
19287
19288
/**
19289
* Same as the default implementation, except cancels the event when return
19290
* value is false. This behavior will be disabled in a future release.
19291
*
19292
* @param {object} Event to be dispatched.
19293
* @param {function} Application-level callback.
19294
* @param {string} domID DOM ID to pass to the callback.
19295
*/
19296
executeDispatch: function(event, listener, domID) {
19297
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
19298
19299
("production" !== process.env.NODE_ENV ? warning(
19300
typeof returnValue !== 'boolean',
19301
'Returning `false` from an event handler is deprecated and will be ' +
19302
'ignored in a future release. Instead, manually call ' +
19303
'e.stopPropagation() or e.preventDefault(), as appropriate.'
19304
) : null);
19305
19306
if (returnValue === false) {
19307
event.stopPropagation();
19308
event.preventDefault();
19309
}
19310
},
19311
19312
/**
19313
* @param {string} topLevelType Record from `EventConstants`.
19314
* @param {DOMEventTarget} topLevelTarget The listening component root node.
19315
* @param {string} topLevelTargetID ID of `topLevelTarget`.
19316
* @param {object} nativeEvent Native browser event.
19317
* @return {*} An accumulation of synthetic events.
19318
* @see {EventPluginHub.extractEvents}
19319
*/
19320
extractEvents: function(
19321
topLevelType,
19322
topLevelTarget,
19323
topLevelTargetID,
19324
nativeEvent) {
19325
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
19326
if (!dispatchConfig) {
19327
return null;
19328
}
19329
var EventConstructor;
19330
switch (topLevelType) {
19331
case topLevelTypes.topInput:
19332
case topLevelTypes.topLoad:
19333
case topLevelTypes.topError:
19334
case topLevelTypes.topReset:
19335
case topLevelTypes.topSubmit:
19336
// HTML Events
19337
// @see http://www.w3.org/TR/html5/index.html#events-0
19338
EventConstructor = SyntheticEvent;
19339
break;
19340
case topLevelTypes.topKeyPress:
19341
// FireFox creates a keypress event for function keys too. This removes
19342
// the unwanted keypress events. Enter is however both printable and
19343
// non-printable. One would expect Tab to be as well (but it isn't).
19344
if (getEventCharCode(nativeEvent) === 0) {
19345
return null;
19346
}
19347
/* falls through */
19348
case topLevelTypes.topKeyDown:
19349
case topLevelTypes.topKeyUp:
19350
EventConstructor = SyntheticKeyboardEvent;
19351
break;
19352
case topLevelTypes.topBlur:
19353
case topLevelTypes.topFocus:
19354
EventConstructor = SyntheticFocusEvent;
19355
break;
19356
case topLevelTypes.topClick:
19357
// Firefox creates a click event on right mouse clicks. This removes the
19358
// unwanted click events.
19359
if (nativeEvent.button === 2) {
19360
return null;
19361
}
19362
/* falls through */
19363
case topLevelTypes.topContextMenu:
19364
case topLevelTypes.topDoubleClick:
19365
case topLevelTypes.topMouseDown:
19366
case topLevelTypes.topMouseMove:
19367
case topLevelTypes.topMouseOut:
19368
case topLevelTypes.topMouseOver:
19369
case topLevelTypes.topMouseUp:
19370
EventConstructor = SyntheticMouseEvent;
19371
break;
19372
case topLevelTypes.topDrag:
19373
case topLevelTypes.topDragEnd:
19374
case topLevelTypes.topDragEnter:
19375
case topLevelTypes.topDragExit:
19376
case topLevelTypes.topDragLeave:
19377
case topLevelTypes.topDragOver:
19378
case topLevelTypes.topDragStart:
19379
case topLevelTypes.topDrop:
19380
EventConstructor = SyntheticDragEvent;
19381
break;
19382
case topLevelTypes.topTouchCancel:
19383
case topLevelTypes.topTouchEnd:
19384
case topLevelTypes.topTouchMove:
19385
case topLevelTypes.topTouchStart:
19386
EventConstructor = SyntheticTouchEvent;
19387
break;
19388
case topLevelTypes.topScroll:
19389
EventConstructor = SyntheticUIEvent;
19390
break;
19391
case topLevelTypes.topWheel:
19392
EventConstructor = SyntheticWheelEvent;
19393
break;
19394
case topLevelTypes.topCopy:
19395
case topLevelTypes.topCut:
19396
case topLevelTypes.topPaste:
19397
EventConstructor = SyntheticClipboardEvent;
19398
break;
19399
}
19400
("production" !== process.env.NODE_ENV ? invariant(
19401
EventConstructor,
19402
'SimpleEventPlugin: Unhandled event type, `%s`.',
19403
topLevelType
19404
) : invariant(EventConstructor));
19405
var event = EventConstructor.getPooled(
19406
dispatchConfig,
19407
topLevelTargetID,
19408
nativeEvent
19409
);
19410
EventPropagators.accumulateTwoPhaseDispatches(event);
19411
return event;
19412
}
19413
19414
};
19415
19416
module.exports = SimpleEventPlugin;
19417
19418
}).call(this,require('_process'))
19419
},{"./EventConstants":29,"./EventPluginUtils":33,"./EventPropagators":34,"./SyntheticClipboardEvent":119,"./SyntheticDragEvent":121,"./SyntheticEvent":122,"./SyntheticFocusEvent":123,"./SyntheticKeyboardEvent":125,"./SyntheticMouseEvent":126,"./SyntheticTouchEvent":127,"./SyntheticUIEvent":128,"./SyntheticWheelEvent":129,"./getEventCharCode":151,"./invariant":164,"./keyOf":171,"./warning":185,"_process":1}],119:[function(require,module,exports){
19420
/**
19421
* Copyright 2013-2015, Facebook, Inc.
19422
* All rights reserved.
19423
*
19424
* This source code is licensed under the BSD-style license found in the
19425
* LICENSE file in the root directory of this source tree. An additional grant
19426
* of patent rights can be found in the PATENTS file in the same directory.
19427
*
19428
* @providesModule SyntheticClipboardEvent
19429
* @typechecks static-only
19430
*/
19431
19432
'use strict';
19433
19434
var SyntheticEvent = require("./SyntheticEvent");
19435
19436
/**
19437
* @interface Event
19438
* @see http://www.w3.org/TR/clipboard-apis/
19439
*/
19440
var ClipboardEventInterface = {
19441
clipboardData: function(event) {
19442
return (
19443
'clipboardData' in event ?
19444
event.clipboardData :
19445
window.clipboardData
19446
);
19447
}
19448
};
19449
19450
/**
19451
* @param {object} dispatchConfig Configuration used to dispatch this event.
19452
* @param {string} dispatchMarker Marker identifying the event target.
19453
* @param {object} nativeEvent Native browser event.
19454
* @extends {SyntheticUIEvent}
19455
*/
19456
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19457
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19458
}
19459
19460
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
19461
19462
module.exports = SyntheticClipboardEvent;
19463
19464
},{"./SyntheticEvent":122}],120:[function(require,module,exports){
19465
/**
19466
* Copyright 2013-2015, Facebook, Inc.
19467
* All rights reserved.
19468
*
19469
* This source code is licensed under the BSD-style license found in the
19470
* LICENSE file in the root directory of this source tree. An additional grant
19471
* of patent rights can be found in the PATENTS file in the same directory.
19472
*
19473
* @providesModule SyntheticCompositionEvent
19474
* @typechecks static-only
19475
*/
19476
19477
'use strict';
19478
19479
var SyntheticEvent = require("./SyntheticEvent");
19480
19481
/**
19482
* @interface Event
19483
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
19484
*/
19485
var CompositionEventInterface = {
19486
data: null
19487
};
19488
19489
/**
19490
* @param {object} dispatchConfig Configuration used to dispatch this event.
19491
* @param {string} dispatchMarker Marker identifying the event target.
19492
* @param {object} nativeEvent Native browser event.
19493
* @extends {SyntheticUIEvent}
19494
*/
19495
function SyntheticCompositionEvent(
19496
dispatchConfig,
19497
dispatchMarker,
19498
nativeEvent) {
19499
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19500
}
19501
19502
SyntheticEvent.augmentClass(
19503
SyntheticCompositionEvent,
19504
CompositionEventInterface
19505
);
19506
19507
module.exports = SyntheticCompositionEvent;
19508
19509
},{"./SyntheticEvent":122}],121:[function(require,module,exports){
19510
/**
19511
* Copyright 2013-2015, Facebook, Inc.
19512
* All rights reserved.
19513
*
19514
* This source code is licensed under the BSD-style license found in the
19515
* LICENSE file in the root directory of this source tree. An additional grant
19516
* of patent rights can be found in the PATENTS file in the same directory.
19517
*
19518
* @providesModule SyntheticDragEvent
19519
* @typechecks static-only
19520
*/
19521
19522
'use strict';
19523
19524
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
19525
19526
/**
19527
* @interface DragEvent
19528
* @see http://www.w3.org/TR/DOM-Level-3-Events/
19529
*/
19530
var DragEventInterface = {
19531
dataTransfer: null
19532
};
19533
19534
/**
19535
* @param {object} dispatchConfig Configuration used to dispatch this event.
19536
* @param {string} dispatchMarker Marker identifying the event target.
19537
* @param {object} nativeEvent Native browser event.
19538
* @extends {SyntheticUIEvent}
19539
*/
19540
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19541
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19542
}
19543
19544
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
19545
19546
module.exports = SyntheticDragEvent;
19547
19548
},{"./SyntheticMouseEvent":126}],122:[function(require,module,exports){
19549
/**
19550
* Copyright 2013-2015, Facebook, Inc.
19551
* All rights reserved.
19552
*
19553
* This source code is licensed under the BSD-style license found in the
19554
* LICENSE file in the root directory of this source tree. An additional grant
19555
* of patent rights can be found in the PATENTS file in the same directory.
19556
*
19557
* @providesModule SyntheticEvent
19558
* @typechecks static-only
19559
*/
19560
19561
'use strict';
19562
19563
var PooledClass = require("./PooledClass");
19564
19565
var assign = require("./Object.assign");
19566
var emptyFunction = require("./emptyFunction");
19567
var getEventTarget = require("./getEventTarget");
19568
19569
/**
19570
* @interface Event
19571
* @see http://www.w3.org/TR/DOM-Level-3-Events/
19572
*/
19573
var EventInterface = {
19574
type: null,
19575
target: getEventTarget,
19576
// currentTarget is set when dispatching; no use in copying it here
19577
currentTarget: emptyFunction.thatReturnsNull,
19578
eventPhase: null,
19579
bubbles: null,
19580
cancelable: null,
19581
timeStamp: function(event) {
19582
return event.timeStamp || Date.now();
19583
},
19584
defaultPrevented: null,
19585
isTrusted: null
19586
};
19587
19588
/**
19589
* Synthetic events are dispatched by event plugins, typically in response to a
19590
* top-level event delegation handler.
19591
*
19592
* These systems should generally use pooling to reduce the frequency of garbage
19593
* collection. The system should check `isPersistent` to determine whether the
19594
* event should be released into the pool after being dispatched. Users that
19595
* need a persisted event should invoke `persist`.
19596
*
19597
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by
19598
* normalizing browser quirks. Subclasses do not necessarily have to implement a
19599
* DOM interface; custom application-specific events can also subclass this.
19600
*
19601
* @param {object} dispatchConfig Configuration used to dispatch this event.
19602
* @param {string} dispatchMarker Marker identifying the event target.
19603
* @param {object} nativeEvent Native browser event.
19604
*/
19605
function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19606
this.dispatchConfig = dispatchConfig;
19607
this.dispatchMarker = dispatchMarker;
19608
this.nativeEvent = nativeEvent;
19609
19610
var Interface = this.constructor.Interface;
19611
for (var propName in Interface) {
19612
if (!Interface.hasOwnProperty(propName)) {
19613
continue;
19614
}
19615
var normalize = Interface[propName];
19616
if (normalize) {
19617
this[propName] = normalize(nativeEvent);
19618
} else {
19619
this[propName] = nativeEvent[propName];
19620
}
19621
}
19622
19623
var defaultPrevented = nativeEvent.defaultPrevented != null ?
19624
nativeEvent.defaultPrevented :
19625
nativeEvent.returnValue === false;
19626
if (defaultPrevented) {
19627
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
19628
} else {
19629
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
19630
}
19631
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
19632
}
19633
19634
assign(SyntheticEvent.prototype, {
19635
19636
preventDefault: function() {
19637
this.defaultPrevented = true;
19638
var event = this.nativeEvent;
19639
if (event.preventDefault) {
19640
event.preventDefault();
19641
} else {
19642
event.returnValue = false;
19643
}
19644
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
19645
},
19646
19647
stopPropagation: function() {
19648
var event = this.nativeEvent;
19649
if (event.stopPropagation) {
19650
event.stopPropagation();
19651
} else {
19652
event.cancelBubble = true;
19653
}
19654
this.isPropagationStopped = emptyFunction.thatReturnsTrue;
19655
},
19656
19657
/**
19658
* We release all dispatched `SyntheticEvent`s after each event loop, adding
19659
* them back into the pool. This allows a way to hold onto a reference that
19660
* won't be added back into the pool.
19661
*/
19662
persist: function() {
19663
this.isPersistent = emptyFunction.thatReturnsTrue;
19664
},
19665
19666
/**
19667
* Checks if this event should be released back into the pool.
19668
*
19669
* @return {boolean} True if this should not be released, false otherwise.
19670
*/
19671
isPersistent: emptyFunction.thatReturnsFalse,
19672
19673
/**
19674
* `PooledClass` looks for `destructor` on each instance it releases.
19675
*/
19676
destructor: function() {
19677
var Interface = this.constructor.Interface;
19678
for (var propName in Interface) {
19679
this[propName] = null;
19680
}
19681
this.dispatchConfig = null;
19682
this.dispatchMarker = null;
19683
this.nativeEvent = null;
19684
}
19685
19686
});
19687
19688
SyntheticEvent.Interface = EventInterface;
19689
19690
/**
19691
* Helper to reduce boilerplate when creating subclasses.
19692
*
19693
* @param {function} Class
19694
* @param {?object} Interface
19695
*/
19696
SyntheticEvent.augmentClass = function(Class, Interface) {
19697
var Super = this;
19698
19699
var prototype = Object.create(Super.prototype);
19700
assign(prototype, Class.prototype);
19701
Class.prototype = prototype;
19702
Class.prototype.constructor = Class;
19703
19704
Class.Interface = assign({}, Super.Interface, Interface);
19705
Class.augmentClass = Super.augmentClass;
19706
19707
PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
19708
};
19709
19710
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
19711
19712
module.exports = SyntheticEvent;
19713
19714
},{"./Object.assign":42,"./PooledClass":43,"./emptyFunction":143,"./getEventTarget":154}],123:[function(require,module,exports){
19715
/**
19716
* Copyright 2013-2015, Facebook, Inc.
19717
* All rights reserved.
19718
*
19719
* This source code is licensed under the BSD-style license found in the
19720
* LICENSE file in the root directory of this source tree. An additional grant
19721
* of patent rights can be found in the PATENTS file in the same directory.
19722
*
19723
* @providesModule SyntheticFocusEvent
19724
* @typechecks static-only
19725
*/
19726
19727
'use strict';
19728
19729
var SyntheticUIEvent = require("./SyntheticUIEvent");
19730
19731
/**
19732
* @interface FocusEvent
19733
* @see http://www.w3.org/TR/DOM-Level-3-Events/
19734
*/
19735
var FocusEventInterface = {
19736
relatedTarget: null
19737
};
19738
19739
/**
19740
* @param {object} dispatchConfig Configuration used to dispatch this event.
19741
* @param {string} dispatchMarker Marker identifying the event target.
19742
* @param {object} nativeEvent Native browser event.
19743
* @extends {SyntheticUIEvent}
19744
*/
19745
function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19746
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19747
}
19748
19749
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
19750
19751
module.exports = SyntheticFocusEvent;
19752
19753
},{"./SyntheticUIEvent":128}],124:[function(require,module,exports){
19754
/**
19755
* Copyright 2013-2015, Facebook, Inc.
19756
* All rights reserved.
19757
*
19758
* This source code is licensed under the BSD-style license found in the
19759
* LICENSE file in the root directory of this source tree. An additional grant
19760
* of patent rights can be found in the PATENTS file in the same directory.
19761
*
19762
* @providesModule SyntheticInputEvent
19763
* @typechecks static-only
19764
*/
19765
19766
'use strict';
19767
19768
var SyntheticEvent = require("./SyntheticEvent");
19769
19770
/**
19771
* @interface Event
19772
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
19773
* /#events-inputevents
19774
*/
19775
var InputEventInterface = {
19776
data: null
19777
};
19778
19779
/**
19780
* @param {object} dispatchConfig Configuration used to dispatch this event.
19781
* @param {string} dispatchMarker Marker identifying the event target.
19782
* @param {object} nativeEvent Native browser event.
19783
* @extends {SyntheticUIEvent}
19784
*/
19785
function SyntheticInputEvent(
19786
dispatchConfig,
19787
dispatchMarker,
19788
nativeEvent) {
19789
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19790
}
19791
19792
SyntheticEvent.augmentClass(
19793
SyntheticInputEvent,
19794
InputEventInterface
19795
);
19796
19797
module.exports = SyntheticInputEvent;
19798
19799
},{"./SyntheticEvent":122}],125:[function(require,module,exports){
19800
/**
19801
* Copyright 2013-2015, Facebook, Inc.
19802
* All rights reserved.
19803
*
19804
* This source code is licensed under the BSD-style license found in the
19805
* LICENSE file in the root directory of this source tree. An additional grant
19806
* of patent rights can be found in the PATENTS file in the same directory.
19807
*
19808
* @providesModule SyntheticKeyboardEvent
19809
* @typechecks static-only
19810
*/
19811
19812
'use strict';
19813
19814
var SyntheticUIEvent = require("./SyntheticUIEvent");
19815
19816
var getEventCharCode = require("./getEventCharCode");
19817
var getEventKey = require("./getEventKey");
19818
var getEventModifierState = require("./getEventModifierState");
19819
19820
/**
19821
* @interface KeyboardEvent
19822
* @see http://www.w3.org/TR/DOM-Level-3-Events/
19823
*/
19824
var KeyboardEventInterface = {
19825
key: getEventKey,
19826
location: null,
19827
ctrlKey: null,
19828
shiftKey: null,
19829
altKey: null,
19830
metaKey: null,
19831
repeat: null,
19832
locale: null,
19833
getModifierState: getEventModifierState,
19834
// Legacy Interface
19835
charCode: function(event) {
19836
// `charCode` is the result of a KeyPress event and represents the value of
19837
// the actual printable character.
19838
19839
// KeyPress is deprecated, but its replacement is not yet final and not
19840
// implemented in any major browser. Only KeyPress has charCode.
19841
if (event.type === 'keypress') {
19842
return getEventCharCode(event);
19843
}
19844
return 0;
19845
},
19846
keyCode: function(event) {
19847
// `keyCode` is the result of a KeyDown/Up event and represents the value of
19848
// physical keyboard key.
19849
19850
// The actual meaning of the value depends on the users' keyboard layout
19851
// which cannot be detected. Assuming that it is a US keyboard layout
19852
// provides a surprisingly accurate mapping for US and European users.
19853
// Due to this, it is left to the user to implement at this time.
19854
if (event.type === 'keydown' || event.type === 'keyup') {
19855
return event.keyCode;
19856
}
19857
return 0;
19858
},
19859
which: function(event) {
19860
// `which` is an alias for either `keyCode` or `charCode` depending on the
19861
// type of the event.
19862
if (event.type === 'keypress') {
19863
return getEventCharCode(event);
19864
}
19865
if (event.type === 'keydown' || event.type === 'keyup') {
19866
return event.keyCode;
19867
}
19868
return 0;
19869
}
19870
};
19871
19872
/**
19873
* @param {object} dispatchConfig Configuration used to dispatch this event.
19874
* @param {string} dispatchMarker Marker identifying the event target.
19875
* @param {object} nativeEvent Native browser event.
19876
* @extends {SyntheticUIEvent}
19877
*/
19878
function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19879
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19880
}
19881
19882
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
19883
19884
module.exports = SyntheticKeyboardEvent;
19885
19886
},{"./SyntheticUIEvent":128,"./getEventCharCode":151,"./getEventKey":152,"./getEventModifierState":153}],126:[function(require,module,exports){
19887
/**
19888
* Copyright 2013-2015, Facebook, Inc.
19889
* All rights reserved.
19890
*
19891
* This source code is licensed under the BSD-style license found in the
19892
* LICENSE file in the root directory of this source tree. An additional grant
19893
* of patent rights can be found in the PATENTS file in the same directory.
19894
*
19895
* @providesModule SyntheticMouseEvent
19896
* @typechecks static-only
19897
*/
19898
19899
'use strict';
19900
19901
var SyntheticUIEvent = require("./SyntheticUIEvent");
19902
var ViewportMetrics = require("./ViewportMetrics");
19903
19904
var getEventModifierState = require("./getEventModifierState");
19905
19906
/**
19907
* @interface MouseEvent
19908
* @see http://www.w3.org/TR/DOM-Level-3-Events/
19909
*/
19910
var MouseEventInterface = {
19911
screenX: null,
19912
screenY: null,
19913
clientX: null,
19914
clientY: null,
19915
ctrlKey: null,
19916
shiftKey: null,
19917
altKey: null,
19918
metaKey: null,
19919
getModifierState: getEventModifierState,
19920
button: function(event) {
19921
// Webkit, Firefox, IE9+
19922
// which: 1 2 3
19923
// button: 0 1 2 (standard)
19924
var button = event.button;
19925
if ('which' in event) {
19926
return button;
19927
}
19928
// IE<9
19929
// which: undefined
19930
// button: 0 0 0
19931
// button: 1 4 2 (onmouseup)
19932
return button === 2 ? 2 : button === 4 ? 1 : 0;
19933
},
19934
buttons: null,
19935
relatedTarget: function(event) {
19936
return event.relatedTarget || (
19937
((event.fromElement === event.srcElement ? event.toElement : event.fromElement))
19938
);
19939
},
19940
// "Proprietary" Interface.
19941
pageX: function(event) {
19942
return 'pageX' in event ?
19943
event.pageX :
19944
event.clientX + ViewportMetrics.currentScrollLeft;
19945
},
19946
pageY: function(event) {
19947
return 'pageY' in event ?
19948
event.pageY :
19949
event.clientY + ViewportMetrics.currentScrollTop;
19950
}
19951
};
19952
19953
/**
19954
* @param {object} dispatchConfig Configuration used to dispatch this event.
19955
* @param {string} dispatchMarker Marker identifying the event target.
19956
* @param {object} nativeEvent Native browser event.
19957
* @extends {SyntheticUIEvent}
19958
*/
19959
function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent) {
19960
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
19961
}
19962
19963
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
19964
19965
module.exports = SyntheticMouseEvent;
19966
19967
},{"./SyntheticUIEvent":128,"./ViewportMetrics":131,"./getEventModifierState":153}],127:[function(require,module,exports){
19968
/**
19969
* Copyright 2013-2015, Facebook, Inc.
19970
* All rights reserved.
19971
*
19972
* This source code is licensed under the BSD-style license found in the
19973
* LICENSE file in the root directory of this source tree. An additional grant
19974
* of patent rights can be found in the PATENTS file in the same directory.
19975
*
19976
* @providesModule SyntheticTouchEvent
19977
* @typechecks static-only
19978
*/
19979
19980
'use strict';
19981
19982
var SyntheticUIEvent = require("./SyntheticUIEvent");
19983
19984
var getEventModifierState = require("./getEventModifierState");
19985
19986
/**
19987
* @interface TouchEvent
19988
* @see http://www.w3.org/TR/touch-events/
19989
*/
19990
var TouchEventInterface = {
19991
touches: null,
19992
targetTouches: null,
19993
changedTouches: null,
19994
altKey: null,
19995
metaKey: null,
19996
ctrlKey: null,
19997
shiftKey: null,
19998
getModifierState: getEventModifierState
19999
};
20000
20001
/**
20002
* @param {object} dispatchConfig Configuration used to dispatch this event.
20003
* @param {string} dispatchMarker Marker identifying the event target.
20004
* @param {object} nativeEvent Native browser event.
20005
* @extends {SyntheticUIEvent}
20006
*/
20007
function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent) {
20008
SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
20009
}
20010
20011
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
20012
20013
module.exports = SyntheticTouchEvent;
20014
20015
},{"./SyntheticUIEvent":128,"./getEventModifierState":153}],128:[function(require,module,exports){
20016
/**
20017
* Copyright 2013-2015, Facebook, Inc.
20018
* All rights reserved.
20019
*
20020
* This source code is licensed under the BSD-style license found in the
20021
* LICENSE file in the root directory of this source tree. An additional grant
20022
* of patent rights can be found in the PATENTS file in the same directory.
20023
*
20024
* @providesModule SyntheticUIEvent
20025
* @typechecks static-only
20026
*/
20027
20028
'use strict';
20029
20030
var SyntheticEvent = require("./SyntheticEvent");
20031
20032
var getEventTarget = require("./getEventTarget");
20033
20034
/**
20035
* @interface UIEvent
20036
* @see http://www.w3.org/TR/DOM-Level-3-Events/
20037
*/
20038
var UIEventInterface = {
20039
view: function(event) {
20040
if (event.view) {
20041
return event.view;
20042
}
20043
20044
var target = getEventTarget(event);
20045
if (target != null && target.window === target) {
20046
// target is a window object
20047
return target;
20048
}
20049
20050
var doc = target.ownerDocument;
20051
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
20052
if (doc) {
20053
return doc.defaultView || doc.parentWindow;
20054
} else {
20055
return window;
20056
}
20057
},
20058
detail: function(event) {
20059
return event.detail || 0;
20060
}
20061
};
20062
20063
/**
20064
* @param {object} dispatchConfig Configuration used to dispatch this event.
20065
* @param {string} dispatchMarker Marker identifying the event target.
20066
* @param {object} nativeEvent Native browser event.
20067
* @extends {SyntheticEvent}
20068
*/
20069
function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent) {
20070
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
20071
}
20072
20073
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
20074
20075
module.exports = SyntheticUIEvent;
20076
20077
},{"./SyntheticEvent":122,"./getEventTarget":154}],129:[function(require,module,exports){
20078
/**
20079
* Copyright 2013-2015, Facebook, Inc.
20080
* All rights reserved.
20081
*
20082
* This source code is licensed under the BSD-style license found in the
20083
* LICENSE file in the root directory of this source tree. An additional grant
20084
* of patent rights can be found in the PATENTS file in the same directory.
20085
*
20086
* @providesModule SyntheticWheelEvent
20087
* @typechecks static-only
20088
*/
20089
20090
'use strict';
20091
20092
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
20093
20094
/**
20095
* @interface WheelEvent
20096
* @see http://www.w3.org/TR/DOM-Level-3-Events/
20097
*/
20098
var WheelEventInterface = {
20099
deltaX: function(event) {
20100
return (
20101
'deltaX' in event ? event.deltaX :
20102
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
20103
'wheelDeltaX' in event ? -event.wheelDeltaX : 0
20104
);
20105
},
20106
deltaY: function(event) {
20107
return (
20108
'deltaY' in event ? event.deltaY :
20109
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
20110
'wheelDeltaY' in event ? -event.wheelDeltaY :
20111
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
20112
'wheelDelta' in event ? -event.wheelDelta : 0
20113
);
20114
},
20115
deltaZ: null,
20116
20117
// Browsers without "deltaMode" is reporting in raw wheel delta where one
20118
// notch on the scroll is always +/- 120, roughly equivalent to pixels.
20119
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
20120
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
20121
deltaMode: null
20122
};
20123
20124
/**
20125
* @param {object} dispatchConfig Configuration used to dispatch this event.
20126
* @param {string} dispatchMarker Marker identifying the event target.
20127
* @param {object} nativeEvent Native browser event.
20128
* @extends {SyntheticMouseEvent}
20129
*/
20130
function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent) {
20131
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent);
20132
}
20133
20134
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
20135
20136
module.exports = SyntheticWheelEvent;
20137
20138
},{"./SyntheticMouseEvent":126}],130:[function(require,module,exports){
20139
(function (process){
20140
/**
20141
* Copyright 2013-2015, Facebook, Inc.
20142
* All rights reserved.
20143
*
20144
* This source code is licensed under the BSD-style license found in the
20145
* LICENSE file in the root directory of this source tree. An additional grant
20146
* of patent rights can be found in the PATENTS file in the same directory.
20147
*
20148
* @providesModule Transaction
20149
*/
20150
20151
'use strict';
20152
20153
var invariant = require("./invariant");
20154
20155
/**
20156
* `Transaction` creates a black box that is able to wrap any method such that
20157
* certain invariants are maintained before and after the method is invoked
20158
* (Even if an exception is thrown while invoking the wrapped method). Whoever
20159
* instantiates a transaction can provide enforcers of the invariants at
20160
* creation time. The `Transaction` class itself will supply one additional
20161
* automatic invariant for you - the invariant that any transaction instance
20162
* should not be run while it is already being run. You would typically create a
20163
* single instance of a `Transaction` for reuse multiple times, that potentially
20164
* is used to wrap several different methods. Wrappers are extremely simple -
20165
* they only require implementing two methods.
20166
*
20167
* <pre>
20168
* wrappers (injected at creation time)
20169
* + +
20170
* | |
20171
* +-----------------|--------|--------------+
20172
* | v | |
20173
* | +---------------+ | |
20174
* | +--| wrapper1 |---|----+ |
20175
* | | +---------------+ v | |
20176
* | | +-------------+ | |
20177
* | | +----| wrapper2 |--------+ |
20178
* | | | +-------------+ | | |
20179
* | | | | | |
20180
* | v v v v | wrapper
20181
* | +---+ +---+ +---------+ +---+ +---+ | invariants
20182
* perform(anyMethod) | | | | | | | | | | | | maintained
20183
* +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
20184
* | | | | | | | | | | | |
20185
* | | | | | | | | | | | |
20186
* | | | | | | | | | | | |
20187
* | +---+ +---+ +---------+ +---+ +---+ |
20188
* | initialize close |
20189
* +-----------------------------------------+
20190
* </pre>
20191
*
20192
* Use cases:
20193
* - Preserving the input selection ranges before/after reconciliation.
20194
* Restoring selection even in the event of an unexpected error.
20195
* - Deactivating events while rearranging the DOM, preventing blurs/focuses,
20196
* while guaranteeing that afterwards, the event system is reactivated.
20197
* - Flushing a queue of collected DOM mutations to the main UI thread after a
20198
* reconciliation takes place in a worker thread.
20199
* - Invoking any collected `componentDidUpdate` callbacks after rendering new
20200
* content.
20201
* - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
20202
* to preserve the `scrollTop` (an automatic scroll aware DOM).
20203
* - (Future use case): Layout calculations before and after DOM updates.
20204
*
20205
* Transactional plugin API:
20206
* - A module that has an `initialize` method that returns any precomputation.
20207
* - and a `close` method that accepts the precomputation. `close` is invoked
20208
* when the wrapped process is completed, or has failed.
20209
*
20210
* @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
20211
* that implement `initialize` and `close`.
20212
* @return {Transaction} Single transaction for reuse in thread.
20213
*
20214
* @class Transaction
20215
*/
20216
var Mixin = {
20217
/**
20218
* Sets up this instance so that it is prepared for collecting metrics. Does
20219
* so such that this setup method may be used on an instance that is already
20220
* initialized, in a way that does not consume additional memory upon reuse.
20221
* That can be useful if you decide to make your subclass of this mixin a
20222
* "PooledClass".
20223
*/
20224
reinitializeTransaction: function() {
20225
this.transactionWrappers = this.getTransactionWrappers();
20226
if (!this.wrapperInitData) {
20227
this.wrapperInitData = [];
20228
} else {
20229
this.wrapperInitData.length = 0;
20230
}
20231
this._isInTransaction = false;
20232
},
20233
20234
_isInTransaction: false,
20235
20236
/**
20237
* @abstract
20238
* @return {Array<TransactionWrapper>} Array of transaction wrappers.
20239
*/
20240
getTransactionWrappers: null,
20241
20242
isInTransaction: function() {
20243
return !!this._isInTransaction;
20244
},
20245
20246
/**
20247
* Executes the function within a safety window. Use this for the top level
20248
* methods that result in large amounts of computation/mutations that would
20249
* need to be safety checked.
20250
*
20251
* @param {function} method Member of scope to call.
20252
* @param {Object} scope Scope to invoke from.
20253
* @param {Object?=} args... Arguments to pass to the method (optional).
20254
* Helps prevent need to bind in many cases.
20255
* @return Return value from `method`.
20256
*/
20257
perform: function(method, scope, a, b, c, d, e, f) {
20258
("production" !== process.env.NODE_ENV ? invariant(
20259
!this.isInTransaction(),
20260
'Transaction.perform(...): Cannot initialize a transaction when there ' +
20261
'is already an outstanding transaction.'
20262
) : invariant(!this.isInTransaction()));
20263
var errorThrown;
20264
var ret;
20265
try {
20266
this._isInTransaction = true;
20267
// Catching errors makes debugging more difficult, so we start with
20268
// errorThrown set to true before setting it to false after calling
20269
// close -- if it's still set to true in the finally block, it means
20270
// one of these calls threw.
20271
errorThrown = true;
20272
this.initializeAll(0);
20273
ret = method.call(scope, a, b, c, d, e, f);
20274
errorThrown = false;
20275
} finally {
20276
try {
20277
if (errorThrown) {
20278
// If `method` throws, prefer to show that stack trace over any thrown
20279
// by invoking `closeAll`.
20280
try {
20281
this.closeAll(0);
20282
} catch (err) {
20283
}
20284
} else {
20285
// Since `method` didn't throw, we don't want to silence the exception
20286
// here.
20287
this.closeAll(0);
20288
}
20289
} finally {
20290
this._isInTransaction = false;
20291
}
20292
}
20293
return ret;
20294
},
20295
20296
initializeAll: function(startIndex) {
20297
var transactionWrappers = this.transactionWrappers;
20298
for (var i = startIndex; i < transactionWrappers.length; i++) {
20299
var wrapper = transactionWrappers[i];
20300
try {
20301
// Catching errors makes debugging more difficult, so we start with the
20302
// OBSERVED_ERROR state before overwriting it with the real return value
20303
// of initialize -- if it's still set to OBSERVED_ERROR in the finally
20304
// block, it means wrapper.initialize threw.
20305
this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
20306
this.wrapperInitData[i] = wrapper.initialize ?
20307
wrapper.initialize.call(this) :
20308
null;
20309
} finally {
20310
if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
20311
// The initializer for wrapper i threw an error; initialize the
20312
// remaining wrappers but silence any exceptions from them to ensure
20313
// that the first error is the one to bubble up.
20314
try {
20315
this.initializeAll(i + 1);
20316
} catch (err) {
20317
}
20318
}
20319
}
20320
}
20321
},
20322
20323
/**
20324
* Invokes each of `this.transactionWrappers.close[i]` functions, passing into
20325
* them the respective return values of `this.transactionWrappers.init[i]`
20326
* (`close`rs that correspond to initializers that failed will not be
20327
* invoked).
20328
*/
20329
closeAll: function(startIndex) {
20330
("production" !== process.env.NODE_ENV ? invariant(
20331
this.isInTransaction(),
20332
'Transaction.closeAll(): Cannot close transaction when none are open.'
20333
) : invariant(this.isInTransaction()));
20334
var transactionWrappers = this.transactionWrappers;
20335
for (var i = startIndex; i < transactionWrappers.length; i++) {
20336
var wrapper = transactionWrappers[i];
20337
var initData = this.wrapperInitData[i];
20338
var errorThrown;
20339
try {
20340
// Catching errors makes debugging more difficult, so we start with
20341
// errorThrown set to true before setting it to false after calling
20342
// close -- if it's still set to true in the finally block, it means
20343
// wrapper.close threw.
20344
errorThrown = true;
20345
if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) {
20346
wrapper.close.call(this, initData);
20347
}
20348
errorThrown = false;
20349
} finally {
20350
if (errorThrown) {
20351
// The closer for wrapper i threw an error; close the remaining
20352
// wrappers but silence any exceptions from them to ensure that the
20353
// first error is the one to bubble up.
20354
try {
20355
this.closeAll(i + 1);
20356
} catch (e) {
20357
}
20358
}
20359
}
20360
}
20361
this.wrapperInitData.length = 0;
20362
}
20363
};
20364
20365
var Transaction = {
20366
20367
Mixin: Mixin,
20368
20369
/**
20370
* Token to look for to determine if an error occured.
20371
*/
20372
OBSERVED_ERROR: {}
20373
20374
};
20375
20376
module.exports = Transaction;
20377
20378
}).call(this,require('_process'))
20379
},{"./invariant":164,"_process":1}],131:[function(require,module,exports){
20380
/**
20381
* Copyright 2013-2015, Facebook, Inc.
20382
* All rights reserved.
20383
*
20384
* This source code is licensed under the BSD-style license found in the
20385
* LICENSE file in the root directory of this source tree. An additional grant
20386
* of patent rights can be found in the PATENTS file in the same directory.
20387
*
20388
* @providesModule ViewportMetrics
20389
*/
20390
20391
'use strict';
20392
20393
var ViewportMetrics = {
20394
20395
currentScrollLeft: 0,
20396
20397
currentScrollTop: 0,
20398
20399
refreshScrollValues: function(scrollPosition) {
20400
ViewportMetrics.currentScrollLeft = scrollPosition.x;
20401
ViewportMetrics.currentScrollTop = scrollPosition.y;
20402
}
20403
20404
};
20405
20406
module.exports = ViewportMetrics;
20407
20408
},{}],132:[function(require,module,exports){
20409
(function (process){
20410
/**
20411
* Copyright 2014-2015, Facebook, Inc.
20412
* All rights reserved.
20413
*
20414
* This source code is licensed under the BSD-style license found in the
20415
* LICENSE file in the root directory of this source tree. An additional grant
20416
* of patent rights can be found in the PATENTS file in the same directory.
20417
*
20418
* @providesModule accumulateInto
20419
*/
20420
20421
'use strict';
20422
20423
var invariant = require("./invariant");
20424
20425
/**
20426
*
20427
* Accumulates items that must not be null or undefined into the first one. This
20428
* is used to conserve memory by avoiding array allocations, and thus sacrifices
20429
* API cleanness. Since `current` can be null before being passed in and not
20430
* null after this function, make sure to assign it back to `current`:
20431
*
20432
* `a = accumulateInto(a, b);`
20433
*
20434
* This API should be sparingly used. Try `accumulate` for something cleaner.
20435
*
20436
* @return {*|array<*>} An accumulation of items.
20437
*/
20438
20439
function accumulateInto(current, next) {
20440
("production" !== process.env.NODE_ENV ? invariant(
20441
next != null,
20442
'accumulateInto(...): Accumulated items must not be null or undefined.'
20443
) : invariant(next != null));
20444
if (current == null) {
20445
return next;
20446
}
20447
20448
// Both are not empty. Warning: Never call x.concat(y) when you are not
20449
// certain that x is an Array (x could be a string with concat method).
20450
var currentIsArray = Array.isArray(current);
20451
var nextIsArray = Array.isArray(next);
20452
20453
if (currentIsArray && nextIsArray) {
20454
current.push.apply(current, next);
20455
return current;
20456
}
20457
20458
if (currentIsArray) {
20459
current.push(next);
20460
return current;
20461
}
20462
20463
if (nextIsArray) {
20464
// A bit too dangerous to mutate `next`.
20465
return [current].concat(next);
20466
}
20467
20468
return [current, next];
20469
}
20470
20471
module.exports = accumulateInto;
20472
20473
}).call(this,require('_process'))
20474
},{"./invariant":164,"_process":1}],133:[function(require,module,exports){
20475
/**
20476
* Copyright 2013-2015, Facebook, Inc.
20477
* All rights reserved.
20478
*
20479
* This source code is licensed under the BSD-style license found in the
20480
* LICENSE file in the root directory of this source tree. An additional grant
20481
* of patent rights can be found in the PATENTS file in the same directory.
20482
*
20483
* @providesModule adler32
20484
*/
20485
20486
/* jslint bitwise:true */
20487
20488
'use strict';
20489
20490
var MOD = 65521;
20491
20492
// This is a clean-room implementation of adler32 designed for detecting
20493
// if markup is not what we expect it to be. It does not need to be
20494
// cryptographically strong, only reasonably good at detecting if markup
20495
// generated on the server is different than that on the client.
20496
function adler32(data) {
20497
var a = 1;
20498
var b = 0;
20499
for (var i = 0; i < data.length; i++) {
20500
a = (a + data.charCodeAt(i)) % MOD;
20501
b = (b + a) % MOD;
20502
}
20503
return a | (b << 16);
20504
}
20505
20506
module.exports = adler32;
20507
20508
},{}],134:[function(require,module,exports){
20509
/**
20510
* Copyright 2013-2015, Facebook, Inc.
20511
* All rights reserved.
20512
*
20513
* This source code is licensed under the BSD-style license found in the
20514
* LICENSE file in the root directory of this source tree. An additional grant
20515
* of patent rights can be found in the PATENTS file in the same directory.
20516
*
20517
* @providesModule camelize
20518
* @typechecks
20519
*/
20520
20521
var _hyphenPattern = /-(.)/g;
20522
20523
/**
20524
* Camelcases a hyphenated string, for example:
20525
*
20526
* > camelize('background-color')
20527
* < "backgroundColor"
20528
*
20529
* @param {string} string
20530
* @return {string}
20531
*/
20532
function camelize(string) {
20533
return string.replace(_hyphenPattern, function(_, character) {
20534
return character.toUpperCase();
20535
});
20536
}
20537
20538
module.exports = camelize;
20539
20540
},{}],135:[function(require,module,exports){
20541
/**
20542
* Copyright 2014-2015, Facebook, Inc.
20543
* All rights reserved.
20544
*
20545
* This source code is licensed under the BSD-style license found in the
20546
* LICENSE file in the root directory of this source tree. An additional grant
20547
* of patent rights can be found in the PATENTS file in the same directory.
20548
*
20549
* @providesModule camelizeStyleName
20550
* @typechecks
20551
*/
20552
20553
"use strict";
20554
20555
var camelize = require("./camelize");
20556
20557
var msPattern = /^-ms-/;
20558
20559
/**
20560
* Camelcases a hyphenated CSS property name, for example:
20561
*
20562
* > camelizeStyleName('background-color')
20563
* < "backgroundColor"
20564
* > camelizeStyleName('-moz-transition')
20565
* < "MozTransition"
20566
* > camelizeStyleName('-ms-transition')
20567
* < "msTransition"
20568
*
20569
* As Andi Smith suggests
20570
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
20571
* is converted to lowercase `ms`.
20572
*
20573
* @param {string} string
20574
* @return {string}
20575
*/
20576
function camelizeStyleName(string) {
20577
return camelize(string.replace(msPattern, 'ms-'));
20578
}
20579
20580
module.exports = camelizeStyleName;
20581
20582
},{"./camelize":134}],136:[function(require,module,exports){
20583
(function (process){
20584
/**
20585
* Copyright 2013-2015, Facebook, Inc.
20586
* All rights reserved.
20587
*
20588
* This source code is licensed under the BSD-style license found in the
20589
* LICENSE file in the root directory of this source tree. An additional grant
20590
* of patent rights can be found in the PATENTS file in the same directory.
20591
*
20592
* @typechecks static-only
20593
* @providesModule cloneWithProps
20594
*/
20595
20596
'use strict';
20597
20598
var ReactElement = require("./ReactElement");
20599
var ReactPropTransferer = require("./ReactPropTransferer");
20600
20601
var keyOf = require("./keyOf");
20602
var warning = require("./warning");
20603
20604
var CHILDREN_PROP = keyOf({children: null});
20605
20606
/**
20607
* Sometimes you want to change the props of a child passed to you. Usually
20608
* this is to add a CSS class.
20609
*
20610
* @param {ReactElement} child child element you'd like to clone
20611
* @param {object} props props you'd like to modify. className and style will be
20612
* merged automatically.
20613
* @return {ReactElement} a clone of child with props merged in.
20614
*/
20615
function cloneWithProps(child, props) {
20616
if ("production" !== process.env.NODE_ENV) {
20617
("production" !== process.env.NODE_ENV ? warning(
20618
!child.ref,
20619
'You are calling cloneWithProps() on a child with a ref. This is ' +
20620
'dangerous because you\'re creating a new child which will not be ' +
20621
'added as a ref to its parent.'
20622
) : null);
20623
}
20624
20625
var newProps = ReactPropTransferer.mergeProps(props, child.props);
20626
20627
// Use `child.props.children` if it is provided.
20628
if (!newProps.hasOwnProperty(CHILDREN_PROP) &&
20629
child.props.hasOwnProperty(CHILDREN_PROP)) {
20630
newProps.children = child.props.children;
20631
}
20632
20633
// The current API doesn't retain _owner and _context, which is why this
20634
// doesn't use ReactElement.cloneAndReplaceProps.
20635
return ReactElement.createElement(child.type, newProps);
20636
}
20637
20638
module.exports = cloneWithProps;
20639
20640
}).call(this,require('_process'))
20641
},{"./ReactElement":76,"./ReactPropTransferer":96,"./keyOf":171,"./warning":185,"_process":1}],137:[function(require,module,exports){
20642
/**
20643
* Copyright 2013-2015, Facebook, Inc.
20644
* All rights reserved.
20645
*
20646
* This source code is licensed under the BSD-style license found in the
20647
* LICENSE file in the root directory of this source tree. An additional grant
20648
* of patent rights can be found in the PATENTS file in the same directory.
20649
*
20650
* @providesModule containsNode
20651
* @typechecks
20652
*/
20653
20654
var isTextNode = require("./isTextNode");
20655
20656
/*jslint bitwise:true */
20657
20658
/**
20659
* Checks if a given DOM node contains or is another DOM node.
20660
*
20661
* @param {?DOMNode} outerNode Outer DOM node.
20662
* @param {?DOMNode} innerNode Inner DOM node.
20663
* @return {boolean} True if `outerNode` contains or is `innerNode`.
20664
*/
20665
function containsNode(outerNode, innerNode) {
20666
if (!outerNode || !innerNode) {
20667
return false;
20668
} else if (outerNode === innerNode) {
20669
return true;
20670
} else if (isTextNode(outerNode)) {
20671
return false;
20672
} else if (isTextNode(innerNode)) {
20673
return containsNode(outerNode, innerNode.parentNode);
20674
} else if (outerNode.contains) {
20675
return outerNode.contains(innerNode);
20676
} else if (outerNode.compareDocumentPosition) {
20677
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
20678
} else {
20679
return false;
20680
}
20681
}
20682
20683
module.exports = containsNode;
20684
20685
},{"./isTextNode":168}],138:[function(require,module,exports){
20686
/**
20687
* Copyright 2013-2015, Facebook, Inc.
20688
* All rights reserved.
20689
*
20690
* This source code is licensed under the BSD-style license found in the
20691
* LICENSE file in the root directory of this source tree. An additional grant
20692
* of patent rights can be found in the PATENTS file in the same directory.
20693
*
20694
* @providesModule createArrayFromMixed
20695
* @typechecks
20696
*/
20697
20698
var toArray = require("./toArray");
20699
20700
/**
20701
* Perform a heuristic test to determine if an object is "array-like".
20702
*
20703
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
20704
* Joshu replied: "Mu."
20705
*
20706
* This function determines if its argument has "array nature": it returns
20707
* true if the argument is an actual array, an `arguments' object, or an
20708
* HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
20709
*
20710
* It will return false for other array-like objects like Filelist.
20711
*
20712
* @param {*} obj
20713
* @return {boolean}
20714
*/
20715
function hasArrayNature(obj) {
20716
return (
20717
// not null/false
20718
!!obj &&
20719
// arrays are objects, NodeLists are functions in Safari
20720
(typeof obj == 'object' || typeof obj == 'function') &&
20721
// quacks like an array
20722
('length' in obj) &&
20723
// not window
20724
!('setInterval' in obj) &&
20725
// no DOM node should be considered an array-like
20726
// a 'select' element has 'length' and 'item' properties on IE8
20727
(typeof obj.nodeType != 'number') &&
20728
(
20729
// a real array
20730
(// HTMLCollection/NodeList
20731
(Array.isArray(obj) ||
20732
// arguments
20733
('callee' in obj) || 'item' in obj))
20734
)
20735
);
20736
}
20737
20738
/**
20739
* Ensure that the argument is an array by wrapping it in an array if it is not.
20740
* Creates a copy of the argument if it is already an array.
20741
*
20742
* This is mostly useful idiomatically:
20743
*
20744
* var createArrayFromMixed = require('createArrayFromMixed');
20745
*
20746
* function takesOneOrMoreThings(things) {
20747
* things = createArrayFromMixed(things);
20748
* ...
20749
* }
20750
*
20751
* This allows you to treat `things' as an array, but accept scalars in the API.
20752
*
20753
* If you need to convert an array-like object, like `arguments`, into an array
20754
* use toArray instead.
20755
*
20756
* @param {*} obj
20757
* @return {array}
20758
*/
20759
function createArrayFromMixed(obj) {
20760
if (!hasArrayNature(obj)) {
20761
return [obj];
20762
} else if (Array.isArray(obj)) {
20763
return obj.slice();
20764
} else {
20765
return toArray(obj);
20766
}
20767
}
20768
20769
module.exports = createArrayFromMixed;
20770
20771
},{"./toArray":182}],139:[function(require,module,exports){
20772
(function (process){
20773
/**
20774
* Copyright 2013-2015, Facebook, Inc.
20775
* All rights reserved.
20776
*
20777
* This source code is licensed under the BSD-style license found in the
20778
* LICENSE file in the root directory of this source tree. An additional grant
20779
* of patent rights can be found in the PATENTS file in the same directory.
20780
*
20781
* @providesModule createFullPageComponent
20782
* @typechecks
20783
*/
20784
20785
'use strict';
20786
20787
// Defeat circular references by requiring this directly.
20788
var ReactClass = require("./ReactClass");
20789
var ReactElement = require("./ReactElement");
20790
20791
var invariant = require("./invariant");
20792
20793
/**
20794
* Create a component that will throw an exception when unmounted.
20795
*
20796
* Components like <html> <head> and <body> can't be removed or added
20797
* easily in a cross-browser way, however it's valuable to be able to
20798
* take advantage of React's reconciliation for styling and <title>
20799
* management. So we just document it and throw in dangerous cases.
20800
*
20801
* @param {string} tag The tag to wrap
20802
* @return {function} convenience constructor of new component
20803
*/
20804
function createFullPageComponent(tag) {
20805
var elementFactory = ReactElement.createFactory(tag);
20806
20807
var FullPageComponent = ReactClass.createClass({
20808
tagName: tag.toUpperCase(),
20809
displayName: 'ReactFullPageComponent' + tag,
20810
20811
componentWillUnmount: function() {
20812
("production" !== process.env.NODE_ENV ? invariant(
20813
false,
20814
'%s tried to unmount. Because of cross-browser quirks it is ' +
20815
'impossible to unmount some top-level components (eg <html>, <head>, ' +
20816
'and <body>) reliably and efficiently. To fix this, have a single ' +
20817
'top-level component that never unmounts render these elements.',
20818
this.constructor.displayName
20819
) : invariant(false));
20820
},
20821
20822
render: function() {
20823
return elementFactory(this.props);
20824
}
20825
});
20826
20827
return FullPageComponent;
20828
}
20829
20830
module.exports = createFullPageComponent;
20831
20832
}).call(this,require('_process'))
20833
},{"./ReactClass":51,"./ReactElement":76,"./invariant":164,"_process":1}],140:[function(require,module,exports){
20834
(function (process){
20835
/**
20836
* Copyright 2013-2015, Facebook, Inc.
20837
* All rights reserved.
20838
*
20839
* This source code is licensed under the BSD-style license found in the
20840
* LICENSE file in the root directory of this source tree. An additional grant
20841
* of patent rights can be found in the PATENTS file in the same directory.
20842
*
20843
* @providesModule createNodesFromMarkup
20844
* @typechecks
20845
*/
20846
20847
/*jslint evil: true, sub: true */
20848
20849
var ExecutionEnvironment = require("./ExecutionEnvironment");
20850
20851
var createArrayFromMixed = require("./createArrayFromMixed");
20852
var getMarkupWrap = require("./getMarkupWrap");
20853
var invariant = require("./invariant");
20854
20855
/**
20856
* Dummy container used to render all markup.
20857
*/
20858
var dummyNode =
20859
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
20860
20861
/**
20862
* Pattern used by `getNodeName`.
20863
*/
20864
var nodeNamePattern = /^\s*<(\w+)/;
20865
20866
/**
20867
* Extracts the `nodeName` of the first element in a string of markup.
20868
*
20869
* @param {string} markup String of markup.
20870
* @return {?string} Node name of the supplied markup.
20871
*/
20872
function getNodeName(markup) {
20873
var nodeNameMatch = markup.match(nodeNamePattern);
20874
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
20875
}
20876
20877
/**
20878
* Creates an array containing the nodes rendered from the supplied markup. The
20879
* optionally supplied `handleScript` function will be invoked once for each
20880
* <script> element that is rendered. If no `handleScript` function is supplied,
20881
* an exception is thrown if any <script> elements are rendered.
20882
*
20883
* @param {string} markup A string of valid HTML markup.
20884
* @param {?function} handleScript Invoked once for each rendered <script>.
20885
* @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
20886
*/
20887
function createNodesFromMarkup(markup, handleScript) {
20888
var node = dummyNode;
20889
("production" !== process.env.NODE_ENV ? invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized') : invariant(!!dummyNode));
20890
var nodeName = getNodeName(markup);
20891
20892
var wrap = nodeName && getMarkupWrap(nodeName);
20893
if (wrap) {
20894
node.innerHTML = wrap[1] + markup + wrap[2];
20895
20896
var wrapDepth = wrap[0];
20897
while (wrapDepth--) {
20898
node = node.lastChild;
20899
}
20900
} else {
20901
node.innerHTML = markup;
20902
}
20903
20904
var scripts = node.getElementsByTagName('script');
20905
if (scripts.length) {
20906
("production" !== process.env.NODE_ENV ? invariant(
20907
handleScript,
20908
'createNodesFromMarkup(...): Unexpected <script> element rendered.'
20909
) : invariant(handleScript));
20910
createArrayFromMixed(scripts).forEach(handleScript);
20911
}
20912
20913
var nodes = createArrayFromMixed(node.childNodes);
20914
while (node.lastChild) {
20915
node.removeChild(node.lastChild);
20916
}
20917
return nodes;
20918
}
20919
20920
module.exports = createNodesFromMarkup;
20921
20922
}).call(this,require('_process'))
20923
},{"./ExecutionEnvironment":35,"./createArrayFromMixed":138,"./getMarkupWrap":156,"./invariant":164,"_process":1}],141:[function(require,module,exports){
20924
(function (process){
20925
/**
20926
* Copyright 2013-2015, Facebook, Inc.
20927
* All rights reserved.
20928
*
20929
* This source code is licensed under the BSD-style license found in the
20930
* LICENSE file in the root directory of this source tree. An additional grant
20931
* of patent rights can be found in the PATENTS file in the same directory.
20932
*
20933
* @providesModule cx
20934
*/
20935
20936
/**
20937
* This function is used to mark string literals representing CSS class names
20938
* so that they can be transformed statically. This allows for modularization
20939
* and minification of CSS class names.
20940
*
20941
* In static_upstream, this function is actually implemented, but it should
20942
* eventually be replaced with something more descriptive, and the transform
20943
* that is used in the main stack should be ported for use elsewhere.
20944
*
20945
* @param string|object className to modularize, or an object of key/values.
20946
* In the object case, the values are conditions that
20947
* determine if the className keys should be included.
20948
* @param [string ...] Variable list of classNames in the string case.
20949
* @return string Renderable space-separated CSS className.
20950
*/
20951
20952
'use strict';
20953
var warning = require("./warning");
20954
20955
var warned = false;
20956
20957
function cx(classNames) {
20958
if ("production" !== process.env.NODE_ENV) {
20959
("production" !== process.env.NODE_ENV ? warning(
20960
warned,
20961
'React.addons.classSet will be deprecated in a future version. See ' +
20962
'http://fb.me/react-addons-classset'
20963
) : null);
20964
warned = true;
20965
}
20966
20967
if (typeof classNames == 'object') {
20968
return Object.keys(classNames).filter(function(className) {
20969
return classNames[className];
20970
}).join(' ');
20971
} else {
20972
return Array.prototype.join.call(arguments, ' ');
20973
}
20974
}
20975
20976
module.exports = cx;
20977
20978
}).call(this,require('_process'))
20979
},{"./warning":185,"_process":1}],142:[function(require,module,exports){
20980
/**
20981
* Copyright 2013-2015, Facebook, Inc.
20982
* All rights reserved.
20983
*
20984
* This source code is licensed under the BSD-style license found in the
20985
* LICENSE file in the root directory of this source tree. An additional grant
20986
* of patent rights can be found in the PATENTS file in the same directory.
20987
*
20988
* @providesModule dangerousStyleValue
20989
* @typechecks static-only
20990
*/
20991
20992
'use strict';
20993
20994
var CSSProperty = require("./CSSProperty");
20995
20996
var isUnitlessNumber = CSSProperty.isUnitlessNumber;
20997
20998
/**
20999
* Convert a value into the proper css writable value. The style name `name`
21000
* should be logical (no hyphens), as specified
21001
* in `CSSProperty.isUnitlessNumber`.
21002
*
21003
* @param {string} name CSS property name such as `topMargin`.
21004
* @param {*} value CSS property value such as `10px`.
21005
* @return {string} Normalized style value with dimensions applied.
21006
*/
21007
function dangerousStyleValue(name, value) {
21008
// Note that we've removed escapeTextForBrowser() calls here since the
21009
// whole string will be escaped when the attribute is injected into
21010
// the markup. If you provide unsafe user data here they can inject
21011
// arbitrary CSS which may be problematic (I couldn't repro this):
21012
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
21013
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
21014
// This is not an XSS hole but instead a potential CSS injection issue
21015
// which has lead to a greater discussion about how we're going to
21016
// trust URLs moving forward. See #2115901
21017
21018
var isEmpty = value == null || typeof value === 'boolean' || value === '';
21019
if (isEmpty) {
21020
return '';
21021
}
21022
21023
var isNonNumeric = isNaN(value);
21024
if (isNonNumeric || value === 0 ||
21025
isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
21026
return '' + value; // cast to string
21027
}
21028
21029
if (typeof value === 'string') {
21030
value = value.trim();
21031
}
21032
return value + 'px';
21033
}
21034
21035
module.exports = dangerousStyleValue;
21036
21037
},{"./CSSProperty":18}],143:[function(require,module,exports){
21038
/**
21039
* Copyright 2013-2015, Facebook, Inc.
21040
* All rights reserved.
21041
*
21042
* This source code is licensed under the BSD-style license found in the
21043
* LICENSE file in the root directory of this source tree. An additional grant
21044
* of patent rights can be found in the PATENTS file in the same directory.
21045
*
21046
* @providesModule emptyFunction
21047
*/
21048
21049
function makeEmptyFunction(arg) {
21050
return function() {
21051
return arg;
21052
};
21053
}
21054
21055
/**
21056
* This function accepts and discards inputs; it has no side effects. This is
21057
* primarily useful idiomatically for overridable function endpoints which
21058
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
21059
*/
21060
function emptyFunction() {}
21061
21062
emptyFunction.thatReturns = makeEmptyFunction;
21063
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
21064
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
21065
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
21066
emptyFunction.thatReturnsThis = function() { return this; };
21067
emptyFunction.thatReturnsArgument = function(arg) { return arg; };
21068
21069
module.exports = emptyFunction;
21070
21071
},{}],144:[function(require,module,exports){
21072
(function (process){
21073
/**
21074
* Copyright 2013-2015, Facebook, Inc.
21075
* All rights reserved.
21076
*
21077
* This source code is licensed under the BSD-style license found in the
21078
* LICENSE file in the root directory of this source tree. An additional grant
21079
* of patent rights can be found in the PATENTS file in the same directory.
21080
*
21081
* @providesModule emptyObject
21082
*/
21083
21084
"use strict";
21085
21086
var emptyObject = {};
21087
21088
if ("production" !== process.env.NODE_ENV) {
21089
Object.freeze(emptyObject);
21090
}
21091
21092
module.exports = emptyObject;
21093
21094
}).call(this,require('_process'))
21095
},{"_process":1}],145:[function(require,module,exports){
21096
/**
21097
* Copyright 2013-2015, Facebook, Inc.
21098
* All rights reserved.
21099
*
21100
* This source code is licensed under the BSD-style license found in the
21101
* LICENSE file in the root directory of this source tree. An additional grant
21102
* of patent rights can be found in the PATENTS file in the same directory.
21103
*
21104
* @providesModule escapeTextContentForBrowser
21105
*/
21106
21107
'use strict';
21108
21109
var ESCAPE_LOOKUP = {
21110
'&': '&amp;',
21111
'>': '&gt;',
21112
'<': '&lt;',
21113
'"': '&quot;',
21114
'\'': '&#x27;'
21115
};
21116
21117
var ESCAPE_REGEX = /[&><"']/g;
21118
21119
function escaper(match) {
21120
return ESCAPE_LOOKUP[match];
21121
}
21122
21123
/**
21124
* Escapes text to prevent scripting attacks.
21125
*
21126
* @param {*} text Text value to escape.
21127
* @return {string} An escaped string.
21128
*/
21129
function escapeTextContentForBrowser(text) {
21130
return ('' + text).replace(ESCAPE_REGEX, escaper);
21131
}
21132
21133
module.exports = escapeTextContentForBrowser;
21134
21135
},{}],146:[function(require,module,exports){
21136
(function (process){
21137
/**
21138
* Copyright 2013-2015, Facebook, Inc.
21139
* All rights reserved.
21140
*
21141
* This source code is licensed under the BSD-style license found in the
21142
* LICENSE file in the root directory of this source tree. An additional grant
21143
* of patent rights can be found in the PATENTS file in the same directory.
21144
*
21145
* @providesModule findDOMNode
21146
* @typechecks static-only
21147
*/
21148
21149
'use strict';
21150
21151
var ReactCurrentOwner = require("./ReactCurrentOwner");
21152
var ReactInstanceMap = require("./ReactInstanceMap");
21153
var ReactMount = require("./ReactMount");
21154
21155
var invariant = require("./invariant");
21156
var isNode = require("./isNode");
21157
var warning = require("./warning");
21158
21159
/**
21160
* Returns the DOM node rendered by this element.
21161
*
21162
* @param {ReactComponent|DOMElement} componentOrElement
21163
* @return {DOMElement} The root node of this element.
21164
*/
21165
function findDOMNode(componentOrElement) {
21166
if ("production" !== process.env.NODE_ENV) {
21167
var owner = ReactCurrentOwner.current;
21168
if (owner !== null) {
21169
("production" !== process.env.NODE_ENV ? warning(
21170
owner._warnedAboutRefsInRender,
21171
'%s is accessing getDOMNode or findDOMNode inside its render(). ' +
21172
'render() should be a pure function of props and state. It should ' +
21173
'never access something that requires stale data from the previous ' +
21174
'render, such as refs. Move this logic to componentDidMount and ' +
21175
'componentDidUpdate instead.',
21176
owner.getName() || 'A component'
21177
) : null);
21178
owner._warnedAboutRefsInRender = true;
21179
}
21180
}
21181
if (componentOrElement == null) {
21182
return null;
21183
}
21184
if (isNode(componentOrElement)) {
21185
return componentOrElement;
21186
}
21187
if (ReactInstanceMap.has(componentOrElement)) {
21188
return ReactMount.getNodeFromInstance(componentOrElement);
21189
}
21190
("production" !== process.env.NODE_ENV ? invariant(
21191
componentOrElement.render == null ||
21192
typeof componentOrElement.render !== 'function',
21193
'Component (with keys: %s) contains `render` method ' +
21194
'but is not mounted in the DOM',
21195
Object.keys(componentOrElement)
21196
) : invariant(componentOrElement.render == null ||
21197
typeof componentOrElement.render !== 'function'));
21198
("production" !== process.env.NODE_ENV ? invariant(
21199
false,
21200
'Element appears to be neither ReactComponent nor DOMNode (keys: %s)',
21201
Object.keys(componentOrElement)
21202
) : invariant(false));
21203
}
21204
21205
module.exports = findDOMNode;
21206
21207
}).call(this,require('_process'))
21208
},{"./ReactCurrentOwner":58,"./ReactInstanceMap":86,"./ReactMount":90,"./invariant":164,"./isNode":166,"./warning":185,"_process":1}],147:[function(require,module,exports){
21209
(function (process){
21210
/**
21211
* Copyright 2013-2015, Facebook, Inc.
21212
* All rights reserved.
21213
*
21214
* This source code is licensed under the BSD-style license found in the
21215
* LICENSE file in the root directory of this source tree. An additional grant
21216
* of patent rights can be found in the PATENTS file in the same directory.
21217
*
21218
* @providesModule flattenChildren
21219
*/
21220
21221
'use strict';
21222
21223
var traverseAllChildren = require("./traverseAllChildren");
21224
var warning = require("./warning");
21225
21226
/**
21227
* @param {function} traverseContext Context passed through traversal.
21228
* @param {?ReactComponent} child React child component.
21229
* @param {!string} name String name of key path to child.
21230
*/
21231
function flattenSingleChildIntoContext(traverseContext, child, name) {
21232
// We found a component instance.
21233
var result = traverseContext;
21234
var keyUnique = !result.hasOwnProperty(name);
21235
if ("production" !== process.env.NODE_ENV) {
21236
("production" !== process.env.NODE_ENV ? warning(
21237
keyUnique,
21238
'flattenChildren(...): Encountered two children with the same key, ' +
21239
'`%s`. Child keys must be unique; when two children share a key, only ' +
21240
'the first child will be used.',
21241
name
21242
) : null);
21243
}
21244
if (keyUnique && child != null) {
21245
result[name] = child;
21246
}
21247
}
21248
21249
/**
21250
* Flattens children that are typically specified as `props.children`. Any null
21251
* children will not be included in the resulting object.
21252
* @return {!object} flattened children keyed by name.
21253
*/
21254
function flattenChildren(children) {
21255
if (children == null) {
21256
return children;
21257
}
21258
var result = {};
21259
traverseAllChildren(children, flattenSingleChildIntoContext, result);
21260
return result;
21261
}
21262
21263
module.exports = flattenChildren;
21264
21265
}).call(this,require('_process'))
21266
},{"./traverseAllChildren":183,"./warning":185,"_process":1}],148:[function(require,module,exports){
21267
/**
21268
* Copyright 2014-2015, Facebook, Inc.
21269
* All rights reserved.
21270
*
21271
* This source code is licensed under the BSD-style license found in the
21272
* LICENSE file in the root directory of this source tree. An additional grant
21273
* of patent rights can be found in the PATENTS file in the same directory.
21274
*
21275
* @providesModule focusNode
21276
*/
21277
21278
"use strict";
21279
21280
/**
21281
* @param {DOMElement} node input/textarea to focus
21282
*/
21283
function focusNode(node) {
21284
// IE8 can throw "Can't move focus to the control because it is invisible,
21285
// not enabled, or of a type that does not accept the focus." for all kinds of
21286
// reasons that are too expensive and fragile to test.
21287
try {
21288
node.focus();
21289
} catch(e) {
21290
}
21291
}
21292
21293
module.exports = focusNode;
21294
21295
},{}],149:[function(require,module,exports){
21296
/**
21297
* Copyright 2013-2015, Facebook, Inc.
21298
* All rights reserved.
21299
*
21300
* This source code is licensed under the BSD-style license found in the
21301
* LICENSE file in the root directory of this source tree. An additional grant
21302
* of patent rights can be found in the PATENTS file in the same directory.
21303
*
21304
* @providesModule forEachAccumulated
21305
*/
21306
21307
'use strict';
21308
21309
/**
21310
* @param {array} an "accumulation" of items which is either an Array or
21311
* a single item. Useful when paired with the `accumulate` module. This is a
21312
* simple utility that allows us to reason about a collection of items, but
21313
* handling the case when there is exactly one item (and we do not need to
21314
* allocate an array).
21315
*/
21316
var forEachAccumulated = function(arr, cb, scope) {
21317
if (Array.isArray(arr)) {
21318
arr.forEach(cb, scope);
21319
} else if (arr) {
21320
cb.call(scope, arr);
21321
}
21322
};
21323
21324
module.exports = forEachAccumulated;
21325
21326
},{}],150:[function(require,module,exports){
21327
/**
21328
* Copyright 2013-2015, Facebook, Inc.
21329
* All rights reserved.
21330
*
21331
* This source code is licensed under the BSD-style license found in the
21332
* LICENSE file in the root directory of this source tree. An additional grant
21333
* of patent rights can be found in the PATENTS file in the same directory.
21334
*
21335
* @providesModule getActiveElement
21336
* @typechecks
21337
*/
21338
21339
/**
21340
* Same as document.activeElement but wraps in a try-catch block. In IE it is
21341
* not safe to call document.activeElement if there is nothing focused.
21342
*
21343
* The activeElement will be null only if the document body is not yet defined.
21344
*/
21345
function getActiveElement() /*?DOMElement*/ {
21346
try {
21347
return document.activeElement || document.body;
21348
} catch (e) {
21349
return document.body;
21350
}
21351
}
21352
21353
module.exports = getActiveElement;
21354
21355
},{}],151:[function(require,module,exports){
21356
/**
21357
* Copyright 2013-2015, Facebook, Inc.
21358
* All rights reserved.
21359
*
21360
* This source code is licensed under the BSD-style license found in the
21361
* LICENSE file in the root directory of this source tree. An additional grant
21362
* of patent rights can be found in the PATENTS file in the same directory.
21363
*
21364
* @providesModule getEventCharCode
21365
* @typechecks static-only
21366
*/
21367
21368
'use strict';
21369
21370
/**
21371
* `charCode` represents the actual "character code" and is safe to use with
21372
* `String.fromCharCode`. As such, only keys that correspond to printable
21373
* characters produce a valid `charCode`, the only exception to this is Enter.
21374
* The Tab-key is considered non-printable and does not have a `charCode`,
21375
* presumably because it does not produce a tab-character in browsers.
21376
*
21377
* @param {object} nativeEvent Native browser event.
21378
* @return {string} Normalized `charCode` property.
21379
*/
21380
function getEventCharCode(nativeEvent) {
21381
var charCode;
21382
var keyCode = nativeEvent.keyCode;
21383
21384
if ('charCode' in nativeEvent) {
21385
charCode = nativeEvent.charCode;
21386
21387
// FF does not set `charCode` for the Enter-key, check against `keyCode`.
21388
if (charCode === 0 && keyCode === 13) {
21389
charCode = 13;
21390
}
21391
} else {
21392
// IE8 does not implement `charCode`, but `keyCode` has the correct value.
21393
charCode = keyCode;
21394
}
21395
21396
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
21397
// Must not discard the (non-)printable Enter-key.
21398
if (charCode >= 32 || charCode === 13) {
21399
return charCode;
21400
}
21401
21402
return 0;
21403
}
21404
21405
module.exports = getEventCharCode;
21406
21407
},{}],152:[function(require,module,exports){
21408
/**
21409
* Copyright 2013-2015, Facebook, Inc.
21410
* All rights reserved.
21411
*
21412
* This source code is licensed under the BSD-style license found in the
21413
* LICENSE file in the root directory of this source tree. An additional grant
21414
* of patent rights can be found in the PATENTS file in the same directory.
21415
*
21416
* @providesModule getEventKey
21417
* @typechecks static-only
21418
*/
21419
21420
'use strict';
21421
21422
var getEventCharCode = require("./getEventCharCode");
21423
21424
/**
21425
* Normalization of deprecated HTML5 `key` values
21426
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
21427
*/
21428
var normalizeKey = {
21429
'Esc': 'Escape',
21430
'Spacebar': ' ',
21431
'Left': 'ArrowLeft',
21432
'Up': 'ArrowUp',
21433
'Right': 'ArrowRight',
21434
'Down': 'ArrowDown',
21435
'Del': 'Delete',
21436
'Win': 'OS',
21437
'Menu': 'ContextMenu',
21438
'Apps': 'ContextMenu',
21439
'Scroll': 'ScrollLock',
21440
'MozPrintableKey': 'Unidentified'
21441
};
21442
21443
/**
21444
* Translation from legacy `keyCode` to HTML5 `key`
21445
* Only special keys supported, all others depend on keyboard layout or browser
21446
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
21447
*/
21448
var translateToKey = {
21449
8: 'Backspace',
21450
9: 'Tab',
21451
12: 'Clear',
21452
13: 'Enter',
21453
16: 'Shift',
21454
17: 'Control',
21455
18: 'Alt',
21456
19: 'Pause',
21457
20: 'CapsLock',
21458
27: 'Escape',
21459
32: ' ',
21460
33: 'PageUp',
21461
34: 'PageDown',
21462
35: 'End',
21463
36: 'Home',
21464
37: 'ArrowLeft',
21465
38: 'ArrowUp',
21466
39: 'ArrowRight',
21467
40: 'ArrowDown',
21468
45: 'Insert',
21469
46: 'Delete',
21470
112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
21471
118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
21472
144: 'NumLock',
21473
145: 'ScrollLock',
21474
224: 'Meta'
21475
};
21476
21477
/**
21478
* @param {object} nativeEvent Native browser event.
21479
* @return {string} Normalized `key` property.
21480
*/
21481
function getEventKey(nativeEvent) {
21482
if (nativeEvent.key) {
21483
// Normalize inconsistent values reported by browsers due to
21484
// implementations of a working draft specification.
21485
21486
// FireFox implements `key` but returns `MozPrintableKey` for all
21487
// printable characters (normalized to `Unidentified`), ignore it.
21488
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
21489
if (key !== 'Unidentified') {
21490
return key;
21491
}
21492
}
21493
21494
// Browser does not implement `key`, polyfill as much of it as we can.
21495
if (nativeEvent.type === 'keypress') {
21496
var charCode = getEventCharCode(nativeEvent);
21497
21498
// The enter-key is technically both printable and non-printable and can
21499
// thus be captured by `keypress`, no other non-printable key should.
21500
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
21501
}
21502
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
21503
// While user keyboard layout determines the actual meaning of each
21504
// `keyCode` value, almost all function keys have a universal value.
21505
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
21506
}
21507
return '';
21508
}
21509
21510
module.exports = getEventKey;
21511
21512
},{"./getEventCharCode":151}],153:[function(require,module,exports){
21513
/**
21514
* Copyright 2013-2015, Facebook, Inc.
21515
* All rights reserved.
21516
*
21517
* This source code is licensed under the BSD-style license found in the
21518
* LICENSE file in the root directory of this source tree. An additional grant
21519
* of patent rights can be found in the PATENTS file in the same directory.
21520
*
21521
* @providesModule getEventModifierState
21522
* @typechecks static-only
21523
*/
21524
21525
'use strict';
21526
21527
/**
21528
* Translation from modifier key to the associated property in the event.
21529
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
21530
*/
21531
21532
var modifierKeyToProp = {
21533
'Alt': 'altKey',
21534
'Control': 'ctrlKey',
21535
'Meta': 'metaKey',
21536
'Shift': 'shiftKey'
21537
};
21538
21539
// IE8 does not implement getModifierState so we simply map it to the only
21540
// modifier keys exposed by the event itself, does not support Lock-keys.
21541
// Currently, all major browsers except Chrome seems to support Lock-keys.
21542
function modifierStateGetter(keyArg) {
21543
/*jshint validthis:true */
21544
var syntheticEvent = this;
21545
var nativeEvent = syntheticEvent.nativeEvent;
21546
if (nativeEvent.getModifierState) {
21547
return nativeEvent.getModifierState(keyArg);
21548
}
21549
var keyProp = modifierKeyToProp[keyArg];
21550
return keyProp ? !!nativeEvent[keyProp] : false;
21551
}
21552
21553
function getEventModifierState(nativeEvent) {
21554
return modifierStateGetter;
21555
}
21556
21557
module.exports = getEventModifierState;
21558
21559
},{}],154:[function(require,module,exports){
21560
/**
21561
* Copyright 2013-2015, Facebook, Inc.
21562
* All rights reserved.
21563
*
21564
* This source code is licensed under the BSD-style license found in the
21565
* LICENSE file in the root directory of this source tree. An additional grant
21566
* of patent rights can be found in the PATENTS file in the same directory.
21567
*
21568
* @providesModule getEventTarget
21569
* @typechecks static-only
21570
*/
21571
21572
'use strict';
21573
21574
/**
21575
* Gets the target node from a native browser event by accounting for
21576
* inconsistencies in browser DOM APIs.
21577
*
21578
* @param {object} nativeEvent Native browser event.
21579
* @return {DOMEventTarget} Target node.
21580
*/
21581
function getEventTarget(nativeEvent) {
21582
var target = nativeEvent.target || nativeEvent.srcElement || window;
21583
// Safari may fire events on text nodes (Node.TEXT_NODE is 3).
21584
// @see http://www.quirksmode.org/js/events_properties.html
21585
return target.nodeType === 3 ? target.parentNode : target;
21586
}
21587
21588
module.exports = getEventTarget;
21589
21590
},{}],155:[function(require,module,exports){
21591
/**
21592
* Copyright 2013-2015, Facebook, Inc.
21593
* All rights reserved.
21594
*
21595
* This source code is licensed under the BSD-style license found in the
21596
* LICENSE file in the root directory of this source tree. An additional grant
21597
* of patent rights can be found in the PATENTS file in the same directory.
21598
*
21599
* @providesModule getIteratorFn
21600
* @typechecks static-only
21601
*/
21602
21603
'use strict';
21604
21605
/* global Symbol */
21606
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
21607
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
21608
21609
/**
21610
* Returns the iterator method function contained on the iterable object.
21611
*
21612
* Be sure to invoke the function with the iterable as context:
21613
*
21614
* var iteratorFn = getIteratorFn(myIterable);
21615
* if (iteratorFn) {
21616
* var iterator = iteratorFn.call(myIterable);
21617
* ...
21618
* }
21619
*
21620
* @param {?object} maybeIterable
21621
* @return {?function}
21622
*/
21623
function getIteratorFn(maybeIterable) {
21624
var iteratorFn = maybeIterable && (
21625
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL])
21626
);
21627
if (typeof iteratorFn === 'function') {
21628
return iteratorFn;
21629
}
21630
}
21631
21632
module.exports = getIteratorFn;
21633
21634
},{}],156:[function(require,module,exports){
21635
(function (process){
21636
/**
21637
* Copyright 2013-2015, Facebook, Inc.
21638
* All rights reserved.
21639
*
21640
* This source code is licensed under the BSD-style license found in the
21641
* LICENSE file in the root directory of this source tree. An additional grant
21642
* of patent rights can be found in the PATENTS file in the same directory.
21643
*
21644
* @providesModule getMarkupWrap
21645
*/
21646
21647
var ExecutionEnvironment = require("./ExecutionEnvironment");
21648
21649
var invariant = require("./invariant");
21650
21651
/**
21652
* Dummy container used to detect which wraps are necessary.
21653
*/
21654
var dummyNode =
21655
ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
21656
21657
/**
21658
* Some browsers cannot use `innerHTML` to render certain elements standalone,
21659
* so we wrap them, render the wrapped nodes, then extract the desired node.
21660
*
21661
* In IE8, certain elements cannot render alone, so wrap all elements ('*').
21662
*/
21663
var shouldWrap = {
21664
// Force wrapping for SVG elements because if they get created inside a <div>,
21665
// they will be initialized in the wrong namespace (and will not display).
21666
'circle': true,
21667
'clipPath': true,
21668
'defs': true,
21669
'ellipse': true,
21670
'g': true,
21671
'line': true,
21672
'linearGradient': true,
21673
'path': true,
21674
'polygon': true,
21675
'polyline': true,
21676
'radialGradient': true,
21677
'rect': true,
21678
'stop': true,
21679
'text': true
21680
};
21681
21682
var selectWrap = [1, '<select multiple="true">', '</select>'];
21683
var tableWrap = [1, '<table>', '</table>'];
21684
var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
21685
21686
var svgWrap = [1, '<svg>', '</svg>'];
21687
21688
var markupWrap = {
21689
'*': [1, '?<div>', '</div>'],
21690
21691
'area': [1, '<map>', '</map>'],
21692
'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
21693
'legend': [1, '<fieldset>', '</fieldset>'],
21694
'param': [1, '<object>', '</object>'],
21695
'tr': [2, '<table><tbody>', '</tbody></table>'],
21696
21697
'optgroup': selectWrap,
21698
'option': selectWrap,
21699
21700
'caption': tableWrap,
21701
'colgroup': tableWrap,
21702
'tbody': tableWrap,
21703
'tfoot': tableWrap,
21704
'thead': tableWrap,
21705
21706
'td': trWrap,
21707
'th': trWrap,
21708
21709
'circle': svgWrap,
21710
'clipPath': svgWrap,
21711
'defs': svgWrap,
21712
'ellipse': svgWrap,
21713
'g': svgWrap,
21714
'line': svgWrap,
21715
'linearGradient': svgWrap,
21716
'path': svgWrap,
21717
'polygon': svgWrap,
21718
'polyline': svgWrap,
21719
'radialGradient': svgWrap,
21720
'rect': svgWrap,
21721
'stop': svgWrap,
21722
'text': svgWrap
21723
};
21724
21725
/**
21726
* Gets the markup wrap configuration for the supplied `nodeName`.
21727
*
21728
* NOTE: This lazily detects which wraps are necessary for the current browser.
21729
*
21730
* @param {string} nodeName Lowercase `nodeName`.
21731
* @return {?array} Markup wrap configuration, if applicable.
21732
*/
21733
function getMarkupWrap(nodeName) {
21734
("production" !== process.env.NODE_ENV ? invariant(!!dummyNode, 'Markup wrapping node not initialized') : invariant(!!dummyNode));
21735
if (!markupWrap.hasOwnProperty(nodeName)) {
21736
nodeName = '*';
21737
}
21738
if (!shouldWrap.hasOwnProperty(nodeName)) {
21739
if (nodeName === '*') {
21740
dummyNode.innerHTML = '<link />';
21741
} else {
21742
dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
21743
}
21744
shouldWrap[nodeName] = !dummyNode.firstChild;
21745
}
21746
return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
21747
}
21748
21749
21750
module.exports = getMarkupWrap;
21751
21752
}).call(this,require('_process'))
21753
},{"./ExecutionEnvironment":35,"./invariant":164,"_process":1}],157:[function(require,module,exports){
21754
/**
21755
* Copyright 2013-2015, Facebook, Inc.
21756
* All rights reserved.
21757
*
21758
* This source code is licensed under the BSD-style license found in the
21759
* LICENSE file in the root directory of this source tree. An additional grant
21760
* of patent rights can be found in the PATENTS file in the same directory.
21761
*
21762
* @providesModule getNodeForCharacterOffset
21763
*/
21764
21765
'use strict';
21766
21767
/**
21768
* Given any node return the first leaf node without children.
21769
*
21770
* @param {DOMElement|DOMTextNode} node
21771
* @return {DOMElement|DOMTextNode}
21772
*/
21773
function getLeafNode(node) {
21774
while (node && node.firstChild) {
21775
node = node.firstChild;
21776
}
21777
return node;
21778
}
21779
21780
/**
21781
* Get the next sibling within a container. This will walk up the
21782
* DOM if a node's siblings have been exhausted.
21783
*
21784
* @param {DOMElement|DOMTextNode} node
21785
* @return {?DOMElement|DOMTextNode}
21786
*/
21787
function getSiblingNode(node) {
21788
while (node) {
21789
if (node.nextSibling) {
21790
return node.nextSibling;
21791
}
21792
node = node.parentNode;
21793
}
21794
}
21795
21796
/**
21797
* Get object describing the nodes which contain characters at offset.
21798
*
21799
* @param {DOMElement|DOMTextNode} root
21800
* @param {number} offset
21801
* @return {?object}
21802
*/
21803
function getNodeForCharacterOffset(root, offset) {
21804
var node = getLeafNode(root);
21805
var nodeStart = 0;
21806
var nodeEnd = 0;
21807
21808
while (node) {
21809
if (node.nodeType === 3) {
21810
nodeEnd = nodeStart + node.textContent.length;
21811
21812
if (nodeStart <= offset && nodeEnd >= offset) {
21813
return {
21814
node: node,
21815
offset: offset - nodeStart
21816
};
21817
}
21818
21819
nodeStart = nodeEnd;
21820
}
21821
21822
node = getLeafNode(getSiblingNode(node));
21823
}
21824
}
21825
21826
module.exports = getNodeForCharacterOffset;
21827
21828
},{}],158:[function(require,module,exports){
21829
/**
21830
* Copyright 2013-2015, Facebook, Inc.
21831
* All rights reserved.
21832
*
21833
* This source code is licensed under the BSD-style license found in the
21834
* LICENSE file in the root directory of this source tree. An additional grant
21835
* of patent rights can be found in the PATENTS file in the same directory.
21836
*
21837
* @providesModule getReactRootElementInContainer
21838
*/
21839
21840
'use strict';
21841
21842
var DOC_NODE_TYPE = 9;
21843
21844
/**
21845
* @param {DOMElement|DOMDocument} container DOM element that may contain
21846
* a React component
21847
* @return {?*} DOM element that may have the reactRoot ID, or null.
21848
*/
21849
function getReactRootElementInContainer(container) {
21850
if (!container) {
21851
return null;
21852
}
21853
21854
if (container.nodeType === DOC_NODE_TYPE) {
21855
return container.documentElement;
21856
} else {
21857
return container.firstChild;
21858
}
21859
}
21860
21861
module.exports = getReactRootElementInContainer;
21862
21863
},{}],159:[function(require,module,exports){
21864
/**
21865
* Copyright 2013-2015, Facebook, Inc.
21866
* All rights reserved.
21867
*
21868
* This source code is licensed under the BSD-style license found in the
21869
* LICENSE file in the root directory of this source tree. An additional grant
21870
* of patent rights can be found in the PATENTS file in the same directory.
21871
*
21872
* @providesModule getTextContentAccessor
21873
*/
21874
21875
'use strict';
21876
21877
var ExecutionEnvironment = require("./ExecutionEnvironment");
21878
21879
var contentKey = null;
21880
21881
/**
21882
* Gets the key used to access text content on a DOM node.
21883
*
21884
* @return {?string} Key used to access text content.
21885
* @internal
21886
*/
21887
function getTextContentAccessor() {
21888
if (!contentKey && ExecutionEnvironment.canUseDOM) {
21889
// Prefer textContent to innerText because many browsers support both but
21890
// SVG <text> elements don't support innerText even when <div> does.
21891
contentKey = 'textContent' in document.documentElement ?
21892
'textContent' :
21893
'innerText';
21894
}
21895
return contentKey;
21896
}
21897
21898
module.exports = getTextContentAccessor;
21899
21900
},{"./ExecutionEnvironment":35}],160:[function(require,module,exports){
21901
/**
21902
* Copyright 2013-2015, Facebook, Inc.
21903
* All rights reserved.
21904
*
21905
* This source code is licensed under the BSD-style license found in the
21906
* LICENSE file in the root directory of this source tree. An additional grant
21907
* of patent rights can be found in the PATENTS file in the same directory.
21908
*
21909
* @providesModule getUnboundedScrollPosition
21910
* @typechecks
21911
*/
21912
21913
"use strict";
21914
21915
/**
21916
* Gets the scroll position of the supplied element or window.
21917
*
21918
* The return values are unbounded, unlike `getScrollPosition`. This means they
21919
* may be negative or exceed the element boundaries (which is possible using
21920
* inertial scrolling).
21921
*
21922
* @param {DOMWindow|DOMElement} scrollable
21923
* @return {object} Map with `x` and `y` keys.
21924
*/
21925
function getUnboundedScrollPosition(scrollable) {
21926
if (scrollable === window) {
21927
return {
21928
x: window.pageXOffset || document.documentElement.scrollLeft,
21929
y: window.pageYOffset || document.documentElement.scrollTop
21930
};
21931
}
21932
return {
21933
x: scrollable.scrollLeft,
21934
y: scrollable.scrollTop
21935
};
21936
}
21937
21938
module.exports = getUnboundedScrollPosition;
21939
21940
},{}],161:[function(require,module,exports){
21941
/**
21942
* Copyright 2013-2015, Facebook, Inc.
21943
* All rights reserved.
21944
*
21945
* This source code is licensed under the BSD-style license found in the
21946
* LICENSE file in the root directory of this source tree. An additional grant
21947
* of patent rights can be found in the PATENTS file in the same directory.
21948
*
21949
* @providesModule hyphenate
21950
* @typechecks
21951
*/
21952
21953
var _uppercasePattern = /([A-Z])/g;
21954
21955
/**
21956
* Hyphenates a camelcased string, for example:
21957
*
21958
* > hyphenate('backgroundColor')
21959
* < "background-color"
21960
*
21961
* For CSS style names, use `hyphenateStyleName` instead which works properly
21962
* with all vendor prefixes, including `ms`.
21963
*
21964
* @param {string} string
21965
* @return {string}
21966
*/
21967
function hyphenate(string) {
21968
return string.replace(_uppercasePattern, '-$1').toLowerCase();
21969
}
21970
21971
module.exports = hyphenate;
21972
21973
},{}],162:[function(require,module,exports){
21974
/**
21975
* Copyright 2013-2015, Facebook, Inc.
21976
* All rights reserved.
21977
*
21978
* This source code is licensed under the BSD-style license found in the
21979
* LICENSE file in the root directory of this source tree. An additional grant
21980
* of patent rights can be found in the PATENTS file in the same directory.
21981
*
21982
* @providesModule hyphenateStyleName
21983
* @typechecks
21984
*/
21985
21986
"use strict";
21987
21988
var hyphenate = require("./hyphenate");
21989
21990
var msPattern = /^ms-/;
21991
21992
/**
21993
* Hyphenates a camelcased CSS property name, for example:
21994
*
21995
* > hyphenateStyleName('backgroundColor')
21996
* < "background-color"
21997
* > hyphenateStyleName('MozTransition')
21998
* < "-moz-transition"
21999
* > hyphenateStyleName('msTransition')
22000
* < "-ms-transition"
22001
*
22002
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
22003
* is converted to `-ms-`.
22004
*
22005
* @param {string} string
22006
* @return {string}
22007
*/
22008
function hyphenateStyleName(string) {
22009
return hyphenate(string).replace(msPattern, '-ms-');
22010
}
22011
22012
module.exports = hyphenateStyleName;
22013
22014
},{"./hyphenate":161}],163:[function(require,module,exports){
22015
(function (process){
22016
/**
22017
* Copyright 2013-2015, Facebook, Inc.
22018
* All rights reserved.
22019
*
22020
* This source code is licensed under the BSD-style license found in the
22021
* LICENSE file in the root directory of this source tree. An additional grant
22022
* of patent rights can be found in the PATENTS file in the same directory.
22023
*
22024
* @providesModule instantiateReactComponent
22025
* @typechecks static-only
22026
*/
22027
22028
'use strict';
22029
22030
var ReactCompositeComponent = require("./ReactCompositeComponent");
22031
var ReactEmptyComponent = require("./ReactEmptyComponent");
22032
var ReactNativeComponent = require("./ReactNativeComponent");
22033
22034
var assign = require("./Object.assign");
22035
var invariant = require("./invariant");
22036
var warning = require("./warning");
22037
22038
// To avoid a cyclic dependency, we create the final class in this module
22039
var ReactCompositeComponentWrapper = function() { };
22040
assign(
22041
ReactCompositeComponentWrapper.prototype,
22042
ReactCompositeComponent.Mixin,
22043
{
22044
_instantiateReactComponent: instantiateReactComponent
22045
}
22046
);
22047
22048
/**
22049
* Check if the type reference is a known internal type. I.e. not a user
22050
* provided composite type.
22051
*
22052
* @param {function} type
22053
* @return {boolean} Returns true if this is a valid internal type.
22054
*/
22055
function isInternalComponentType(type) {
22056
return (
22057
typeof type === 'function' &&
22058
typeof type.prototype !== 'undefined' &&
22059
typeof type.prototype.mountComponent === 'function' &&
22060
typeof type.prototype.receiveComponent === 'function'
22061
);
22062
}
22063
22064
/**
22065
* Given a ReactNode, create an instance that will actually be mounted.
22066
*
22067
* @param {ReactNode} node
22068
* @param {*} parentCompositeType The composite type that resolved this.
22069
* @return {object} A new instance of the element's constructor.
22070
* @protected
22071
*/
22072
function instantiateReactComponent(node, parentCompositeType) {
22073
var instance;
22074
22075
if (node === null || node === false) {
22076
node = ReactEmptyComponent.emptyElement;
22077
}
22078
22079
if (typeof node === 'object') {
22080
var element = node;
22081
if ("production" !== process.env.NODE_ENV) {
22082
("production" !== process.env.NODE_ENV ? warning(
22083
element && (typeof element.type === 'function' ||
22084
typeof element.type === 'string'),
22085
'Only functions or strings can be mounted as React components.'
22086
) : null);
22087
}
22088
22089
// Special case string values
22090
if (parentCompositeType === element.type &&
22091
typeof element.type === 'string') {
22092
// Avoid recursion if the wrapper renders itself.
22093
instance = ReactNativeComponent.createInternalComponent(element);
22094
// All native components are currently wrapped in a composite so we're
22095
// safe to assume that this is what we should instantiate.
22096
} else if (isInternalComponentType(element.type)) {
22097
// This is temporarily available for custom components that are not string
22098
// represenations. I.e. ART. Once those are updated to use the string
22099
// representation, we can drop this code path.
22100
instance = new element.type(element);
22101
} else {
22102
instance = new ReactCompositeComponentWrapper();
22103
}
22104
} else if (typeof node === 'string' || typeof node === 'number') {
22105
instance = ReactNativeComponent.createInstanceForText(node);
22106
} else {
22107
("production" !== process.env.NODE_ENV ? invariant(
22108
false,
22109
'Encountered invalid React node of type %s',
22110
typeof node
22111
) : invariant(false));
22112
}
22113
22114
if ("production" !== process.env.NODE_ENV) {
22115
("production" !== process.env.NODE_ENV ? warning(
22116
typeof instance.construct === 'function' &&
22117
typeof instance.mountComponent === 'function' &&
22118
typeof instance.receiveComponent === 'function' &&
22119
typeof instance.unmountComponent === 'function',
22120
'Only React Components can be mounted.'
22121
) : null);
22122
}
22123
22124
// Sets up the instance. This can probably just move into the constructor now.
22125
instance.construct(node);
22126
22127
// These two fields are used by the DOM and ART diffing algorithms
22128
// respectively. Instead of using expandos on components, we should be
22129
// storing the state needed by the diffing algorithms elsewhere.
22130
instance._mountIndex = 0;
22131
instance._mountImage = null;
22132
22133
if ("production" !== process.env.NODE_ENV) {
22134
instance._isOwnerNecessary = false;
22135
instance._warnedAboutRefsInRender = false;
22136
}
22137
22138
// Internal instances should fully constructed at this point, so they should
22139
// not get any new fields added to them at this point.
22140
if ("production" !== process.env.NODE_ENV) {
22141
if (Object.preventExtensions) {
22142
Object.preventExtensions(instance);
22143
}
22144
}
22145
22146
return instance;
22147
}
22148
22149
module.exports = instantiateReactComponent;
22150
22151
}).call(this,require('_process'))
22152
},{"./Object.assign":42,"./ReactCompositeComponent":56,"./ReactEmptyComponent":78,"./ReactNativeComponent":93,"./invariant":164,"./warning":185,"_process":1}],164:[function(require,module,exports){
22153
(function (process){
22154
/**
22155
* Copyright 2013-2015, Facebook, Inc.
22156
* All rights reserved.
22157
*
22158
* This source code is licensed under the BSD-style license found in the
22159
* LICENSE file in the root directory of this source tree. An additional grant
22160
* of patent rights can be found in the PATENTS file in the same directory.
22161
*
22162
* @providesModule invariant
22163
*/
22164
22165
"use strict";
22166
22167
/**
22168
* Use invariant() to assert state which your program assumes to be true.
22169
*
22170
* Provide sprintf-style format (only %s is supported) and arguments
22171
* to provide information about what broke and what you were
22172
* expecting.
22173
*
22174
* The invariant message will be stripped in production, but the invariant
22175
* will remain to ensure logic does not differ in production.
22176
*/
22177
22178
var invariant = function(condition, format, a, b, c, d, e, f) {
22179
if ("production" !== process.env.NODE_ENV) {
22180
if (format === undefined) {
22181
throw new Error('invariant requires an error message argument');
22182
}
22183
}
22184
22185
if (!condition) {
22186
var error;
22187
if (format === undefined) {
22188
error = new Error(
22189
'Minified exception occurred; use the non-minified dev environment ' +
22190
'for the full error message and additional helpful warnings.'
22191
);
22192
} else {
22193
var args = [a, b, c, d, e, f];
22194
var argIndex = 0;
22195
error = new Error(
22196
'Invariant Violation: ' +
22197
format.replace(/%s/g, function() { return args[argIndex++]; })
22198
);
22199
}
22200
22201
error.framesToPop = 1; // we don't care about invariant's own frame
22202
throw error;
22203
}
22204
};
22205
22206
module.exports = invariant;
22207
22208
}).call(this,require('_process'))
22209
},{"_process":1}],165:[function(require,module,exports){
22210
/**
22211
* Copyright 2013-2015, Facebook, Inc.
22212
* All rights reserved.
22213
*
22214
* This source code is licensed under the BSD-style license found in the
22215
* LICENSE file in the root directory of this source tree. An additional grant
22216
* of patent rights can be found in the PATENTS file in the same directory.
22217
*
22218
* @providesModule isEventSupported
22219
*/
22220
22221
'use strict';
22222
22223
var ExecutionEnvironment = require("./ExecutionEnvironment");
22224
22225
var useHasFeature;
22226
if (ExecutionEnvironment.canUseDOM) {
22227
useHasFeature =
22228
document.implementation &&
22229
document.implementation.hasFeature &&
22230
// always returns true in newer browsers as per the standard.
22231
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
22232
document.implementation.hasFeature('', '') !== true;
22233
}
22234
22235
/**
22236
* Checks if an event is supported in the current execution environment.
22237
*
22238
* NOTE: This will not work correctly for non-generic events such as `change`,
22239
* `reset`, `load`, `error`, and `select`.
22240
*
22241
* Borrows from Modernizr.
22242
*
22243
* @param {string} eventNameSuffix Event name, e.g. "click".
22244
* @param {?boolean} capture Check if the capture phase is supported.
22245
* @return {boolean} True if the event is supported.
22246
* @internal
22247
* @license Modernizr 3.0.0pre (Custom Build) | MIT
22248
*/
22249
function isEventSupported(eventNameSuffix, capture) {
22250
if (!ExecutionEnvironment.canUseDOM ||
22251
capture && !('addEventListener' in document)) {
22252
return false;
22253
}
22254
22255
var eventName = 'on' + eventNameSuffix;
22256
var isSupported = eventName in document;
22257
22258
if (!isSupported) {
22259
var element = document.createElement('div');
22260
element.setAttribute(eventName, 'return;');
22261
isSupported = typeof element[eventName] === 'function';
22262
}
22263
22264
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
22265
// This is the only way to test support for the `wheel` event in IE9+.
22266
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
22267
}
22268
22269
return isSupported;
22270
}
22271
22272
module.exports = isEventSupported;
22273
22274
},{"./ExecutionEnvironment":35}],166:[function(require,module,exports){
22275
/**
22276
* Copyright 2013-2015, Facebook, Inc.
22277
* All rights reserved.
22278
*
22279
* This source code is licensed under the BSD-style license found in the
22280
* LICENSE file in the root directory of this source tree. An additional grant
22281
* of patent rights can be found in the PATENTS file in the same directory.
22282
*
22283
* @providesModule isNode
22284
* @typechecks
22285
*/
22286
22287
/**
22288
* @param {*} object The object to check.
22289
* @return {boolean} Whether or not the object is a DOM node.
22290
*/
22291
function isNode(object) {
22292
return !!(object && (
22293
((typeof Node === 'function' ? object instanceof Node : typeof object === 'object' &&
22294
typeof object.nodeType === 'number' &&
22295
typeof object.nodeName === 'string'))
22296
));
22297
}
22298
22299
module.exports = isNode;
22300
22301
},{}],167:[function(require,module,exports){
22302
/**
22303
* Copyright 2013-2015, Facebook, Inc.
22304
* All rights reserved.
22305
*
22306
* This source code is licensed under the BSD-style license found in the
22307
* LICENSE file in the root directory of this source tree. An additional grant
22308
* of patent rights can be found in the PATENTS file in the same directory.
22309
*
22310
* @providesModule isTextInputElement
22311
*/
22312
22313
'use strict';
22314
22315
/**
22316
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
22317
*/
22318
var supportedInputTypes = {
22319
'color': true,
22320
'date': true,
22321
'datetime': true,
22322
'datetime-local': true,
22323
'email': true,
22324
'month': true,
22325
'number': true,
22326
'password': true,
22327
'range': true,
22328
'search': true,
22329
'tel': true,
22330
'text': true,
22331
'time': true,
22332
'url': true,
22333
'week': true
22334
};
22335
22336
function isTextInputElement(elem) {
22337
return elem && (
22338
(elem.nodeName === 'INPUT' && supportedInputTypes[elem.type] || elem.nodeName === 'TEXTAREA')
22339
);
22340
}
22341
22342
module.exports = isTextInputElement;
22343
22344
},{}],168:[function(require,module,exports){
22345
/**
22346
* Copyright 2013-2015, Facebook, Inc.
22347
* All rights reserved.
22348
*
22349
* This source code is licensed under the BSD-style license found in the
22350
* LICENSE file in the root directory of this source tree. An additional grant
22351
* of patent rights can be found in the PATENTS file in the same directory.
22352
*
22353
* @providesModule isTextNode
22354
* @typechecks
22355
*/
22356
22357
var isNode = require("./isNode");
22358
22359
/**
22360
* @param {*} object The object to check.
22361
* @return {boolean} Whether or not the object is a DOM text node.
22362
*/
22363
function isTextNode(object) {
22364
return isNode(object) && object.nodeType == 3;
22365
}
22366
22367
module.exports = isTextNode;
22368
22369
},{"./isNode":166}],169:[function(require,module,exports){
22370
/**
22371
* Copyright 2013-2015, Facebook, Inc.
22372
* All rights reserved.
22373
*
22374
* This source code is licensed under the BSD-style license found in the
22375
* LICENSE file in the root directory of this source tree. An additional grant
22376
* of patent rights can be found in the PATENTS file in the same directory.
22377
*
22378
* @providesModule joinClasses
22379
* @typechecks static-only
22380
*/
22381
22382
'use strict';
22383
22384
/**
22385
* Combines multiple className strings into one.
22386
* http://jsperf.com/joinclasses-args-vs-array
22387
*
22388
* @param {...?string} classes
22389
* @return {string}
22390
*/
22391
function joinClasses(className/*, ... */) {
22392
if (!className) {
22393
className = '';
22394
}
22395
var nextClass;
22396
var argLength = arguments.length;
22397
if (argLength > 1) {
22398
for (var ii = 1; ii < argLength; ii++) {
22399
nextClass = arguments[ii];
22400
if (nextClass) {
22401
className = (className ? className + ' ' : '') + nextClass;
22402
}
22403
}
22404
}
22405
return className;
22406
}
22407
22408
module.exports = joinClasses;
22409
22410
},{}],170:[function(require,module,exports){
22411
(function (process){
22412
/**
22413
* Copyright 2013-2015, Facebook, Inc.
22414
* All rights reserved.
22415
*
22416
* This source code is licensed under the BSD-style license found in the
22417
* LICENSE file in the root directory of this source tree. An additional grant
22418
* of patent rights can be found in the PATENTS file in the same directory.
22419
*
22420
* @providesModule keyMirror
22421
* @typechecks static-only
22422
*/
22423
22424
'use strict';
22425
22426
var invariant = require("./invariant");
22427
22428
/**
22429
* Constructs an enumeration with keys equal to their value.
22430
*
22431
* For example:
22432
*
22433
* var COLORS = keyMirror({blue: null, red: null});
22434
* var myColor = COLORS.blue;
22435
* var isColorValid = !!COLORS[myColor];
22436
*
22437
* The last line could not be performed if the values of the generated enum were
22438
* not equal to their keys.
22439
*
22440
* Input: {key1: val1, key2: val2}
22441
* Output: {key1: key1, key2: key2}
22442
*
22443
* @param {object} obj
22444
* @return {object}
22445
*/
22446
var keyMirror = function(obj) {
22447
var ret = {};
22448
var key;
22449
("production" !== process.env.NODE_ENV ? invariant(
22450
obj instanceof Object && !Array.isArray(obj),
22451
'keyMirror(...): Argument must be an object.'
22452
) : invariant(obj instanceof Object && !Array.isArray(obj)));
22453
for (key in obj) {
22454
if (!obj.hasOwnProperty(key)) {
22455
continue;
22456
}
22457
ret[key] = key;
22458
}
22459
return ret;
22460
};
22461
22462
module.exports = keyMirror;
22463
22464
}).call(this,require('_process'))
22465
},{"./invariant":164,"_process":1}],171:[function(require,module,exports){
22466
/**
22467
* Copyright 2013-2015, Facebook, Inc.
22468
* All rights reserved.
22469
*
22470
* This source code is licensed under the BSD-style license found in the
22471
* LICENSE file in the root directory of this source tree. An additional grant
22472
* of patent rights can be found in the PATENTS file in the same directory.
22473
*
22474
* @providesModule keyOf
22475
*/
22476
22477
/**
22478
* Allows extraction of a minified key. Let's the build system minify keys
22479
* without loosing the ability to dynamically use key strings as values
22480
* themselves. Pass in an object with a single key/val pair and it will return
22481
* you the string key of that single record. Suppose you want to grab the
22482
* value for a key 'className' inside of an object. Key/val minification may
22483
* have aliased that key to be 'xa12'. keyOf({className: null}) will return
22484
* 'xa12' in that case. Resolve keys you want to use once at startup time, then
22485
* reuse those resolutions.
22486
*/
22487
var keyOf = function(oneKeyObj) {
22488
var key;
22489
for (key in oneKeyObj) {
22490
if (!oneKeyObj.hasOwnProperty(key)) {
22491
continue;
22492
}
22493
return key;
22494
}
22495
return null;
22496
};
22497
22498
22499
module.exports = keyOf;
22500
22501
},{}],172:[function(require,module,exports){
22502
/**
22503
* Copyright 2013-2015, Facebook, Inc.
22504
* All rights reserved.
22505
*
22506
* This source code is licensed under the BSD-style license found in the
22507
* LICENSE file in the root directory of this source tree. An additional grant
22508
* of patent rights can be found in the PATENTS file in the same directory.
22509
*
22510
* @providesModule mapObject
22511
*/
22512
22513
'use strict';
22514
22515
var hasOwnProperty = Object.prototype.hasOwnProperty;
22516
22517
/**
22518
* Executes the provided `callback` once for each enumerable own property in the
22519
* object and constructs a new object from the results. The `callback` is
22520
* invoked with three arguments:
22521
*
22522
* - the property value
22523
* - the property name
22524
* - the object being traversed
22525
*
22526
* Properties that are added after the call to `mapObject` will not be visited
22527
* by `callback`. If the values of existing properties are changed, the value
22528
* passed to `callback` will be the value at the time `mapObject` visits them.
22529
* Properties that are deleted before being visited are not visited.
22530
*
22531
* @grep function objectMap()
22532
* @grep function objMap()
22533
*
22534
* @param {?object} object
22535
* @param {function} callback
22536
* @param {*} context
22537
* @return {?object}
22538
*/
22539
function mapObject(object, callback, context) {
22540
if (!object) {
22541
return null;
22542
}
22543
var result = {};
22544
for (var name in object) {
22545
if (hasOwnProperty.call(object, name)) {
22546
result[name] = callback.call(context, object[name], name, object);
22547
}
22548
}
22549
return result;
22550
}
22551
22552
module.exports = mapObject;
22553
22554
},{}],173:[function(require,module,exports){
22555
/**
22556
* Copyright 2013-2015, Facebook, Inc.
22557
* All rights reserved.
22558
*
22559
* This source code is licensed under the BSD-style license found in the
22560
* LICENSE file in the root directory of this source tree. An additional grant
22561
* of patent rights can be found in the PATENTS file in the same directory.
22562
*
22563
* @providesModule memoizeStringOnly
22564
* @typechecks static-only
22565
*/
22566
22567
'use strict';
22568
22569
/**
22570
* Memoizes the return value of a function that accepts one string argument.
22571
*
22572
* @param {function} callback
22573
* @return {function}
22574
*/
22575
function memoizeStringOnly(callback) {
22576
var cache = {};
22577
return function(string) {
22578
if (!cache.hasOwnProperty(string)) {
22579
cache[string] = callback.call(this, string);
22580
}
22581
return cache[string];
22582
};
22583
}
22584
22585
module.exports = memoizeStringOnly;
22586
22587
},{}],174:[function(require,module,exports){
22588
(function (process){
22589
/**
22590
* Copyright 2013-2015, Facebook, Inc.
22591
* All rights reserved.
22592
*
22593
* This source code is licensed under the BSD-style license found in the
22594
* LICENSE file in the root directory of this source tree. An additional grant
22595
* of patent rights can be found in the PATENTS file in the same directory.
22596
*
22597
* @providesModule onlyChild
22598
*/
22599
'use strict';
22600
22601
var ReactElement = require("./ReactElement");
22602
22603
var invariant = require("./invariant");
22604
22605
/**
22606
* Returns the first child in a collection of children and verifies that there
22607
* is only one child in the collection. The current implementation of this
22608
* function assumes that a single child gets passed without a wrapper, but the
22609
* purpose of this helper function is to abstract away the particular structure
22610
* of children.
22611
*
22612
* @param {?object} children Child collection structure.
22613
* @return {ReactComponent} The first and only `ReactComponent` contained in the
22614
* structure.
22615
*/
22616
function onlyChild(children) {
22617
("production" !== process.env.NODE_ENV ? invariant(
22618
ReactElement.isValidElement(children),
22619
'onlyChild must be passed a children with exactly one child.'
22620
) : invariant(ReactElement.isValidElement(children)));
22621
return children;
22622
}
22623
22624
module.exports = onlyChild;
22625
22626
}).call(this,require('_process'))
22627
},{"./ReactElement":76,"./invariant":164,"_process":1}],175:[function(require,module,exports){
22628
/**
22629
* Copyright 2013-2015, Facebook, Inc.
22630
* All rights reserved.
22631
*
22632
* This source code is licensed under the BSD-style license found in the
22633
* LICENSE file in the root directory of this source tree. An additional grant
22634
* of patent rights can be found in the PATENTS file in the same directory.
22635
*
22636
* @providesModule performance
22637
* @typechecks
22638
*/
22639
22640
"use strict";
22641
22642
var ExecutionEnvironment = require("./ExecutionEnvironment");
22643
22644
var performance;
22645
22646
if (ExecutionEnvironment.canUseDOM) {
22647
performance =
22648
window.performance ||
22649
window.msPerformance ||
22650
window.webkitPerformance;
22651
}
22652
22653
module.exports = performance || {};
22654
22655
},{"./ExecutionEnvironment":35}],176:[function(require,module,exports){
22656
/**
22657
* Copyright 2013-2015, Facebook, Inc.
22658
* All rights reserved.
22659
*
22660
* This source code is licensed under the BSD-style license found in the
22661
* LICENSE file in the root directory of this source tree. An additional grant
22662
* of patent rights can be found in the PATENTS file in the same directory.
22663
*
22664
* @providesModule performanceNow
22665
* @typechecks
22666
*/
22667
22668
var performance = require("./performance");
22669
22670
/**
22671
* Detect if we can use `window.performance.now()` and gracefully fallback to
22672
* `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
22673
* because of Facebook's testing infrastructure.
22674
*/
22675
if (!performance || !performance.now) {
22676
performance = Date;
22677
}
22678
22679
var performanceNow = performance.now.bind(performance);
22680
22681
module.exports = performanceNow;
22682
22683
},{"./performance":175}],177:[function(require,module,exports){
22684
/**
22685
* Copyright 2013-2015, Facebook, Inc.
22686
* All rights reserved.
22687
*
22688
* This source code is licensed under the BSD-style license found in the
22689
* LICENSE file in the root directory of this source tree. An additional grant
22690
* of patent rights can be found in the PATENTS file in the same directory.
22691
*
22692
* @providesModule quoteAttributeValueForBrowser
22693
*/
22694
22695
'use strict';
22696
22697
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
22698
22699
/**
22700
* Escapes attribute value to prevent scripting attacks.
22701
*
22702
* @param {*} value Value to escape.
22703
* @return {string} An escaped string.
22704
*/
22705
function quoteAttributeValueForBrowser(value) {
22706
return '"' + escapeTextContentForBrowser(value) + '"';
22707
}
22708
22709
module.exports = quoteAttributeValueForBrowser;
22710
22711
},{"./escapeTextContentForBrowser":145}],178:[function(require,module,exports){
22712
/**
22713
* Copyright 2013-2015, Facebook, Inc.
22714
* All rights reserved.
22715
*
22716
* This source code is licensed under the BSD-style license found in the
22717
* LICENSE file in the root directory of this source tree. An additional grant
22718
* of patent rights can be found in the PATENTS file in the same directory.
22719
*
22720
* @providesModule setInnerHTML
22721
*/
22722
22723
/* globals MSApp */
22724
22725
'use strict';
22726
22727
var ExecutionEnvironment = require("./ExecutionEnvironment");
22728
22729
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
22730
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
22731
22732
/**
22733
* Set the innerHTML property of a node, ensuring that whitespace is preserved
22734
* even in IE8.
22735
*
22736
* @param {DOMElement} node
22737
* @param {string} html
22738
* @internal
22739
*/
22740
var setInnerHTML = function(node, html) {
22741
node.innerHTML = html;
22742
};
22743
22744
// Win8 apps: Allow all html to be inserted
22745
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
22746
setInnerHTML = function(node, html) {
22747
MSApp.execUnsafeLocalFunction(function() {
22748
node.innerHTML = html;
22749
});
22750
};
22751
}
22752
22753
if (ExecutionEnvironment.canUseDOM) {
22754
// IE8: When updating a just created node with innerHTML only leading
22755
// whitespace is removed. When updating an existing node with innerHTML
22756
// whitespace in root TextNodes is also collapsed.
22757
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
22758
22759
// Feature detection; only IE8 is known to behave improperly like this.
22760
var testElement = document.createElement('div');
22761
testElement.innerHTML = ' ';
22762
if (testElement.innerHTML === '') {
22763
setInnerHTML = function(node, html) {
22764
// Magic theory: IE8 supposedly differentiates between added and updated
22765
// nodes when processing innerHTML, innerHTML on updated nodes suffers
22766
// from worse whitespace behavior. Re-adding a node like this triggers
22767
// the initial and more favorable whitespace behavior.
22768
// TODO: What to do on a detached node?
22769
if (node.parentNode) {
22770
node.parentNode.replaceChild(node, node);
22771
}
22772
22773
// We also implement a workaround for non-visible tags disappearing into
22774
// thin air on IE8, this only happens if there is no visible text
22775
// in-front of the non-visible tags. Piggyback on the whitespace fix
22776
// and simply check if any non-visible tags appear in the source.
22777
if (WHITESPACE_TEST.test(html) ||
22778
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
22779
// Recover leading whitespace by temporarily prepending any character.
22780
// \uFEFF has the potential advantage of being zero-width/invisible.
22781
node.innerHTML = '\uFEFF' + html;
22782
22783
// deleteData leaves an empty `TextNode` which offsets the index of all
22784
// children. Definitely want to avoid this.
22785
var textNode = node.firstChild;
22786
if (textNode.data.length === 1) {
22787
node.removeChild(textNode);
22788
} else {
22789
textNode.deleteData(0, 1);
22790
}
22791
} else {
22792
node.innerHTML = html;
22793
}
22794
};
22795
}
22796
}
22797
22798
module.exports = setInnerHTML;
22799
22800
},{"./ExecutionEnvironment":35}],179:[function(require,module,exports){
22801
/**
22802
* Copyright 2013-2015, Facebook, Inc.
22803
* All rights reserved.
22804
*
22805
* This source code is licensed under the BSD-style license found in the
22806
* LICENSE file in the root directory of this source tree. An additional grant
22807
* of patent rights can be found in the PATENTS file in the same directory.
22808
*
22809
* @providesModule setTextContent
22810
*/
22811
22812
'use strict';
22813
22814
var ExecutionEnvironment = require("./ExecutionEnvironment");
22815
var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
22816
var setInnerHTML = require("./setInnerHTML");
22817
22818
/**
22819
* Set the textContent property of a node, ensuring that whitespace is preserved
22820
* even in IE8. innerText is a poor substitute for textContent and, among many
22821
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves
22822
* as it should.
22823
*
22824
* @param {DOMElement} node
22825
* @param {string} text
22826
* @internal
22827
*/
22828
var setTextContent = function(node, text) {
22829
node.textContent = text;
22830
};
22831
22832
if (ExecutionEnvironment.canUseDOM) {
22833
if (!('textContent' in document.documentElement)) {
22834
setTextContent = function(node, text) {
22835
setInnerHTML(node, escapeTextContentForBrowser(text));
22836
};
22837
}
22838
}
22839
22840
module.exports = setTextContent;
22841
22842
},{"./ExecutionEnvironment":35,"./escapeTextContentForBrowser":145,"./setInnerHTML":178}],180:[function(require,module,exports){
22843
/**
22844
* Copyright 2013-2015, Facebook, Inc.
22845
* All rights reserved.
22846
*
22847
* This source code is licensed under the BSD-style license found in the
22848
* LICENSE file in the root directory of this source tree. An additional grant
22849
* of patent rights can be found in the PATENTS file in the same directory.
22850
*
22851
* @providesModule shallowEqual
22852
*/
22853
22854
'use strict';
22855
22856
/**
22857
* Performs equality by iterating through keys on an object and returning
22858
* false when any key has values which are not strictly equal between
22859
* objA and objB. Returns true when the values of all keys are strictly equal.
22860
*
22861
* @return {boolean}
22862
*/
22863
function shallowEqual(objA, objB) {
22864
if (objA === objB) {
22865
return true;
22866
}
22867
var key;
22868
// Test for A's keys different from B.
22869
for (key in objA) {
22870
if (objA.hasOwnProperty(key) &&
22871
(!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
22872
return false;
22873
}
22874
}
22875
// Test for B's keys missing from A.
22876
for (key in objB) {
22877
if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
22878
return false;
22879
}
22880
}
22881
return true;
22882
}
22883
22884
module.exports = shallowEqual;
22885
22886
},{}],181:[function(require,module,exports){
22887
(function (process){
22888
/**
22889
* Copyright 2013-2015, Facebook, Inc.
22890
* All rights reserved.
22891
*
22892
* This source code is licensed under the BSD-style license found in the
22893
* LICENSE file in the root directory of this source tree. An additional grant
22894
* of patent rights can be found in the PATENTS file in the same directory.
22895
*
22896
* @providesModule shouldUpdateReactComponent
22897
* @typechecks static-only
22898
*/
22899
22900
'use strict';
22901
22902
var warning = require("./warning");
22903
22904
/**
22905
* Given a `prevElement` and `nextElement`, determines if the existing
22906
* instance should be updated as opposed to being destroyed or replaced by a new
22907
* instance. Both arguments are elements. This ensures that this logic can
22908
* operate on stateless trees without any backing instance.
22909
*
22910
* @param {?object} prevElement
22911
* @param {?object} nextElement
22912
* @return {boolean} True if the existing instance should be updated.
22913
* @protected
22914
*/
22915
function shouldUpdateReactComponent(prevElement, nextElement) {
22916
if (prevElement != null && nextElement != null) {
22917
var prevType = typeof prevElement;
22918
var nextType = typeof nextElement;
22919
if (prevType === 'string' || prevType === 'number') {
22920
return (nextType === 'string' || nextType === 'number');
22921
} else {
22922
if (nextType === 'object' &&
22923
prevElement.type === nextElement.type &&
22924
prevElement.key === nextElement.key) {
22925
var ownersMatch = prevElement._owner === nextElement._owner;
22926
var prevName = null;
22927
var nextName = null;
22928
var nextDisplayName = null;
22929
if ("production" !== process.env.NODE_ENV) {
22930
if (!ownersMatch) {
22931
if (prevElement._owner != null &&
22932
prevElement._owner.getPublicInstance() != null &&
22933
prevElement._owner.getPublicInstance().constructor != null) {
22934
prevName =
22935
prevElement._owner.getPublicInstance().constructor.displayName;
22936
}
22937
if (nextElement._owner != null &&
22938
nextElement._owner.getPublicInstance() != null &&
22939
nextElement._owner.getPublicInstance().constructor != null) {
22940
nextName =
22941
nextElement._owner.getPublicInstance().constructor.displayName;
22942
}
22943
if (nextElement.type != null &&
22944
nextElement.type.displayName != null) {
22945
nextDisplayName = nextElement.type.displayName;
22946
}
22947
if (nextElement.type != null && typeof nextElement.type === 'string') {
22948
nextDisplayName = nextElement.type;
22949
}
22950
if (typeof nextElement.type !== 'string' ||
22951
nextElement.type === 'input' ||
22952
nextElement.type === 'textarea') {
22953
if ((prevElement._owner != null &&
22954
prevElement._owner._isOwnerNecessary === false) ||
22955
(nextElement._owner != null &&
22956
nextElement._owner._isOwnerNecessary === false)) {
22957
if (prevElement._owner != null) {
22958
prevElement._owner._isOwnerNecessary = true;
22959
}
22960
if (nextElement._owner != null) {
22961
nextElement._owner._isOwnerNecessary = true;
22962
}
22963
("production" !== process.env.NODE_ENV ? warning(
22964
false,
22965
'<%s /> is being rendered by both %s and %s using the same ' +
22966
'key (%s) in the same place. Currently, this means that ' +
22967
'they don\'t preserve state. This behavior should be very ' +
22968
'rare so we\'re considering deprecating it. Please contact ' +
22969
'the React team and explain your use case so that we can ' +
22970
'take that into consideration.',
22971
nextDisplayName || 'Unknown Component',
22972
prevName || '[Unknown]',
22973
nextName || '[Unknown]',
22974
prevElement.key
22975
) : null);
22976
}
22977
}
22978
}
22979
}
22980
return ownersMatch;
22981
}
22982
}
22983
}
22984
return false;
22985
}
22986
22987
module.exports = shouldUpdateReactComponent;
22988
22989
}).call(this,require('_process'))
22990
},{"./warning":185,"_process":1}],182:[function(require,module,exports){
22991
(function (process){
22992
/**
22993
* Copyright 2014-2015, Facebook, Inc.
22994
* All rights reserved.
22995
*
22996
* This source code is licensed under the BSD-style license found in the
22997
* LICENSE file in the root directory of this source tree. An additional grant
22998
* of patent rights can be found in the PATENTS file in the same directory.
22999
*
23000
* @providesModule toArray
23001
* @typechecks
23002
*/
23003
23004
var invariant = require("./invariant");
23005
23006
/**
23007
* Convert array-like objects to arrays.
23008
*
23009
* This API assumes the caller knows the contents of the data type. For less
23010
* well defined inputs use createArrayFromMixed.
23011
*
23012
* @param {object|function|filelist} obj
23013
* @return {array}
23014
*/
23015
function toArray(obj) {
23016
var length = obj.length;
23017
23018
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
23019
// old versions of Safari).
23020
("production" !== process.env.NODE_ENV ? invariant(
23021
!Array.isArray(obj) &&
23022
(typeof obj === 'object' || typeof obj === 'function'),
23023
'toArray: Array-like object expected'
23024
) : invariant(!Array.isArray(obj) &&
23025
(typeof obj === 'object' || typeof obj === 'function')));
23026
23027
("production" !== process.env.NODE_ENV ? invariant(
23028
typeof length === 'number',
23029
'toArray: Object needs a length property'
23030
) : invariant(typeof length === 'number'));
23031
23032
("production" !== process.env.NODE_ENV ? invariant(
23033
length === 0 ||
23034
(length - 1) in obj,
23035
'toArray: Object should have keys for indices'
23036
) : invariant(length === 0 ||
23037
(length - 1) in obj));
23038
23039
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
23040
// without method will throw during the slice call and skip straight to the
23041
// fallback.
23042
if (obj.hasOwnProperty) {
23043
try {
23044
return Array.prototype.slice.call(obj);
23045
} catch (e) {
23046
// IE < 9 does not support Array#slice on collections objects
23047
}
23048
}
23049
23050
// Fall back to copying key by key. This assumes all keys have a value,
23051
// so will not preserve sparsely populated inputs.
23052
var ret = Array(length);
23053
for (var ii = 0; ii < length; ii++) {
23054
ret[ii] = obj[ii];
23055
}
23056
return ret;
23057
}
23058
23059
module.exports = toArray;
23060
23061
}).call(this,require('_process'))
23062
},{"./invariant":164,"_process":1}],183:[function(require,module,exports){
23063
(function (process){
23064
/**
23065
* Copyright 2013-2015, Facebook, Inc.
23066
* All rights reserved.
23067
*
23068
* This source code is licensed under the BSD-style license found in the
23069
* LICENSE file in the root directory of this source tree. An additional grant
23070
* of patent rights can be found in the PATENTS file in the same directory.
23071
*
23072
* @providesModule traverseAllChildren
23073
*/
23074
23075
'use strict';
23076
23077
var ReactElement = require("./ReactElement");
23078
var ReactFragment = require("./ReactFragment");
23079
var ReactInstanceHandles = require("./ReactInstanceHandles");
23080
23081
var getIteratorFn = require("./getIteratorFn");
23082
var invariant = require("./invariant");
23083
var warning = require("./warning");
23084
23085
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
23086
var SUBSEPARATOR = ':';
23087
23088
/**
23089
* TODO: Test that a single child and an array with one item have the same key
23090
* pattern.
23091
*/
23092
23093
var userProvidedKeyEscaperLookup = {
23094
'=': '=0',
23095
'.': '=1',
23096
':': '=2'
23097
};
23098
23099
var userProvidedKeyEscapeRegex = /[=.:]/g;
23100
23101
var didWarnAboutMaps = false;
23102
23103
function userProvidedKeyEscaper(match) {
23104
return userProvidedKeyEscaperLookup[match];
23105
}
23106
23107
/**
23108
* Generate a key string that identifies a component within a set.
23109
*
23110
* @param {*} component A component that could contain a manual key.
23111
* @param {number} index Index that is used if a manual key is not provided.
23112
* @return {string}
23113
*/
23114
function getComponentKey(component, index) {
23115
if (component && component.key != null) {
23116
// Explicit key
23117
return wrapUserProvidedKey(component.key);
23118
}
23119
// Implicit key determined by the index in the set
23120
return index.toString(36);
23121
}
23122
23123
/**
23124
* Escape a component key so that it is safe to use in a reactid.
23125
*
23126
* @param {*} key Component key to be escaped.
23127
* @return {string} An escaped string.
23128
*/
23129
function escapeUserProvidedKey(text) {
23130
return ('' + text).replace(
23131
userProvidedKeyEscapeRegex,
23132
userProvidedKeyEscaper
23133
);
23134
}
23135
23136
/**
23137
* Wrap a `key` value explicitly provided by the user to distinguish it from
23138
* implicitly-generated keys generated by a component's index in its parent.
23139
*
23140
* @param {string} key Value of a user-provided `key` attribute
23141
* @return {string}
23142
*/
23143
function wrapUserProvidedKey(key) {
23144
return '$' + escapeUserProvidedKey(key);
23145
}
23146
23147
/**
23148
* @param {?*} children Children tree container.
23149
* @param {!string} nameSoFar Name of the key path so far.
23150
* @param {!number} indexSoFar Number of children encountered until this point.
23151
* @param {!function} callback Callback to invoke with each child found.
23152
* @param {?*} traverseContext Used to pass information throughout the traversal
23153
* process.
23154
* @return {!number} The number of children in this subtree.
23155
*/
23156
function traverseAllChildrenImpl(
23157
children,
23158
nameSoFar,
23159
indexSoFar,
23160
callback,
23161
traverseContext
23162
) {
23163
var type = typeof children;
23164
23165
if (type === 'undefined' || type === 'boolean') {
23166
// All of the above are perceived as null.
23167
children = null;
23168
}
23169
23170
if (children === null ||
23171
type === 'string' ||
23172
type === 'number' ||
23173
ReactElement.isValidElement(children)) {
23174
callback(
23175
traverseContext,
23176
children,
23177
// If it's the only child, treat the name as if it was wrapped in an array
23178
// so that it's consistent if the number of children grows.
23179
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar,
23180
indexSoFar
23181
);
23182
return 1;
23183
}
23184
23185
var child, nextName, nextIndex;
23186
var subtreeCount = 0; // Count of children found in the current subtree.
23187
23188
if (Array.isArray(children)) {
23189
for (var i = 0; i < children.length; i++) {
23190
child = children[i];
23191
nextName = (
23192
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
23193
getComponentKey(child, i)
23194
);
23195
nextIndex = indexSoFar + subtreeCount;
23196
subtreeCount += traverseAllChildrenImpl(
23197
child,
23198
nextName,
23199
nextIndex,
23200
callback,
23201
traverseContext
23202
);
23203
}
23204
} else {
23205
var iteratorFn = getIteratorFn(children);
23206
if (iteratorFn) {
23207
var iterator = iteratorFn.call(children);
23208
var step;
23209
if (iteratorFn !== children.entries) {
23210
var ii = 0;
23211
while (!(step = iterator.next()).done) {
23212
child = step.value;
23213
nextName = (
23214
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
23215
getComponentKey(child, ii++)
23216
);
23217
nextIndex = indexSoFar + subtreeCount;
23218
subtreeCount += traverseAllChildrenImpl(
23219
child,
23220
nextName,
23221
nextIndex,
23222
callback,
23223
traverseContext
23224
);
23225
}
23226
} else {
23227
if ("production" !== process.env.NODE_ENV) {
23228
("production" !== process.env.NODE_ENV ? warning(
23229
didWarnAboutMaps,
23230
'Using Maps as children is not yet fully supported. It is an ' +
23231
'experimental feature that might be removed. Convert it to a ' +
23232
'sequence / iterable of keyed ReactElements instead.'
23233
) : null);
23234
didWarnAboutMaps = true;
23235
}
23236
// Iterator will provide entry [k,v] tuples rather than values.
23237
while (!(step = iterator.next()).done) {
23238
var entry = step.value;
23239
if (entry) {
23240
child = entry[1];
23241
nextName = (
23242
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
23243
wrapUserProvidedKey(entry[0]) + SUBSEPARATOR +
23244
getComponentKey(child, 0)
23245
);
23246
nextIndex = indexSoFar + subtreeCount;
23247
subtreeCount += traverseAllChildrenImpl(
23248
child,
23249
nextName,
23250
nextIndex,
23251
callback,
23252
traverseContext
23253
);
23254
}
23255
}
23256
}
23257
} else if (type === 'object') {
23258
("production" !== process.env.NODE_ENV ? invariant(
23259
children.nodeType !== 1,
23260
'traverseAllChildren(...): Encountered an invalid child; DOM ' +
23261
'elements are not valid children of React components.'
23262
) : invariant(children.nodeType !== 1));
23263
var fragment = ReactFragment.extract(children);
23264
for (var key in fragment) {
23265
if (fragment.hasOwnProperty(key)) {
23266
child = fragment[key];
23267
nextName = (
23268
(nameSoFar !== '' ? nameSoFar + SUBSEPARATOR : SEPARATOR) +
23269
wrapUserProvidedKey(key) + SUBSEPARATOR +
23270
getComponentKey(child, 0)
23271
);
23272
nextIndex = indexSoFar + subtreeCount;
23273
subtreeCount += traverseAllChildrenImpl(
23274
child,
23275
nextName,
23276
nextIndex,
23277
callback,
23278
traverseContext
23279
);
23280
}
23281
}
23282
}
23283
}
23284
23285
return subtreeCount;
23286
}
23287
23288
/**
23289
* Traverses children that are typically specified as `props.children`, but
23290
* might also be specified through attributes:
23291
*
23292
* - `traverseAllChildren(this.props.children, ...)`
23293
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
23294
*
23295
* The `traverseContext` is an optional argument that is passed through the
23296
* entire traversal. It can be used to store accumulations or anything else that
23297
* the callback might find relevant.
23298
*
23299
* @param {?*} children Children tree object.
23300
* @param {!function} callback To invoke upon traversing each child.
23301
* @param {?*} traverseContext Context for traversal.
23302
* @return {!number} The number of children in this subtree.
23303
*/
23304
function traverseAllChildren(children, callback, traverseContext) {
23305
if (children == null) {
23306
return 0;
23307
}
23308
23309
return traverseAllChildrenImpl(children, '', 0, callback, traverseContext);
23310
}
23311
23312
module.exports = traverseAllChildren;
23313
23314
}).call(this,require('_process'))
23315
},{"./ReactElement":76,"./ReactFragment":82,"./ReactInstanceHandles":85,"./getIteratorFn":155,"./invariant":164,"./warning":185,"_process":1}],184:[function(require,module,exports){
23316
(function (process){
23317
/**
23318
* Copyright 2013-2015, Facebook, Inc.
23319
* All rights reserved.
23320
*
23321
* This source code is licensed under the BSD-style license found in the
23322
* LICENSE file in the root directory of this source tree. An additional grant
23323
* of patent rights can be found in the PATENTS file in the same directory.
23324
*
23325
* @providesModule update
23326
*/
23327
23328
/* global hasOwnProperty:true */
23329
23330
'use strict';
23331
23332
var assign = require("./Object.assign");
23333
var keyOf = require("./keyOf");
23334
var invariant = require("./invariant");
23335
var hasOwnProperty = {}.hasOwnProperty;
23336
23337
function shallowCopy(x) {
23338
if (Array.isArray(x)) {
23339
return x.concat();
23340
} else if (x && typeof x === 'object') {
23341
return assign(new x.constructor(), x);
23342
} else {
23343
return x;
23344
}
23345
}
23346
23347
var COMMAND_PUSH = keyOf({$push: null});
23348
var COMMAND_UNSHIFT = keyOf({$unshift: null});
23349
var COMMAND_SPLICE = keyOf({$splice: null});
23350
var COMMAND_SET = keyOf({$set: null});
23351
var COMMAND_MERGE = keyOf({$merge: null});
23352
var COMMAND_APPLY = keyOf({$apply: null});
23353
23354
var ALL_COMMANDS_LIST = [
23355
COMMAND_PUSH,
23356
COMMAND_UNSHIFT,
23357
COMMAND_SPLICE,
23358
COMMAND_SET,
23359
COMMAND_MERGE,
23360
COMMAND_APPLY
23361
];
23362
23363
var ALL_COMMANDS_SET = {};
23364
23365
ALL_COMMANDS_LIST.forEach(function(command) {
23366
ALL_COMMANDS_SET[command] = true;
23367
});
23368
23369
function invariantArrayCase(value, spec, command) {
23370
("production" !== process.env.NODE_ENV ? invariant(
23371
Array.isArray(value),
23372
'update(): expected target of %s to be an array; got %s.',
23373
command,
23374
value
23375
) : invariant(Array.isArray(value)));
23376
var specValue = spec[command];
23377
("production" !== process.env.NODE_ENV ? invariant(
23378
Array.isArray(specValue),
23379
'update(): expected spec of %s to be an array; got %s. ' +
23380
'Did you forget to wrap your parameter in an array?',
23381
command,
23382
specValue
23383
) : invariant(Array.isArray(specValue)));
23384
}
23385
23386
function update(value, spec) {
23387
("production" !== process.env.NODE_ENV ? invariant(
23388
typeof spec === 'object',
23389
'update(): You provided a key path to update() that did not contain one ' +
23390
'of %s. Did you forget to include {%s: ...}?',
23391
ALL_COMMANDS_LIST.join(', '),
23392
COMMAND_SET
23393
) : invariant(typeof spec === 'object'));
23394
23395
if (hasOwnProperty.call(spec, COMMAND_SET)) {
23396
("production" !== process.env.NODE_ENV ? invariant(
23397
Object.keys(spec).length === 1,
23398
'Cannot have more than one key in an object with %s',
23399
COMMAND_SET
23400
) : invariant(Object.keys(spec).length === 1));
23401
23402
return spec[COMMAND_SET];
23403
}
23404
23405
var nextValue = shallowCopy(value);
23406
23407
if (hasOwnProperty.call(spec, COMMAND_MERGE)) {
23408
var mergeObj = spec[COMMAND_MERGE];
23409
("production" !== process.env.NODE_ENV ? invariant(
23410
mergeObj && typeof mergeObj === 'object',
23411
'update(): %s expects a spec of type \'object\'; got %s',
23412
COMMAND_MERGE,
23413
mergeObj
23414
) : invariant(mergeObj && typeof mergeObj === 'object'));
23415
("production" !== process.env.NODE_ENV ? invariant(
23416
nextValue && typeof nextValue === 'object',
23417
'update(): %s expects a target of type \'object\'; got %s',
23418
COMMAND_MERGE,
23419
nextValue
23420
) : invariant(nextValue && typeof nextValue === 'object'));
23421
assign(nextValue, spec[COMMAND_MERGE]);
23422
}
23423
23424
if (hasOwnProperty.call(spec, COMMAND_PUSH)) {
23425
invariantArrayCase(value, spec, COMMAND_PUSH);
23426
spec[COMMAND_PUSH].forEach(function(item) {
23427
nextValue.push(item);
23428
});
23429
}
23430
23431
if (hasOwnProperty.call(spec, COMMAND_UNSHIFT)) {
23432
invariantArrayCase(value, spec, COMMAND_UNSHIFT);
23433
spec[COMMAND_UNSHIFT].forEach(function(item) {
23434
nextValue.unshift(item);
23435
});
23436
}
23437
23438
if (hasOwnProperty.call(spec, COMMAND_SPLICE)) {
23439
("production" !== process.env.NODE_ENV ? invariant(
23440
Array.isArray(value),
23441
'Expected %s target to be an array; got %s',
23442
COMMAND_SPLICE,
23443
value
23444
) : invariant(Array.isArray(value)));
23445
("production" !== process.env.NODE_ENV ? invariant(
23446
Array.isArray(spec[COMMAND_SPLICE]),
23447
'update(): expected spec of %s to be an array of arrays; got %s. ' +
23448
'Did you forget to wrap your parameters in an array?',
23449
COMMAND_SPLICE,
23450
spec[COMMAND_SPLICE]
23451
) : invariant(Array.isArray(spec[COMMAND_SPLICE])));
23452
spec[COMMAND_SPLICE].forEach(function(args) {
23453
("production" !== process.env.NODE_ENV ? invariant(
23454
Array.isArray(args),
23455
'update(): expected spec of %s to be an array of arrays; got %s. ' +
23456
'Did you forget to wrap your parameters in an array?',
23457
COMMAND_SPLICE,
23458
spec[COMMAND_SPLICE]
23459
) : invariant(Array.isArray(args)));
23460
nextValue.splice.apply(nextValue, args);
23461
});
23462
}
23463
23464
if (hasOwnProperty.call(spec, COMMAND_APPLY)) {
23465
("production" !== process.env.NODE_ENV ? invariant(
23466
typeof spec[COMMAND_APPLY] === 'function',
23467
'update(): expected spec of %s to be a function; got %s.',
23468
COMMAND_APPLY,
23469
spec[COMMAND_APPLY]
23470
) : invariant(typeof spec[COMMAND_APPLY] === 'function'));
23471
nextValue = spec[COMMAND_APPLY](nextValue);
23472
}
23473
23474
for (var k in spec) {
23475
if (!(ALL_COMMANDS_SET.hasOwnProperty(k) && ALL_COMMANDS_SET[k])) {
23476
nextValue[k] = update(value[k], spec[k]);
23477
}
23478
}
23479
23480
return nextValue;
23481
}
23482
23483
module.exports = update;
23484
23485
}).call(this,require('_process'))
23486
},{"./Object.assign":42,"./invariant":164,"./keyOf":171,"_process":1}],185:[function(require,module,exports){
23487
(function (process){
23488
/**
23489
* Copyright 2014-2015, Facebook, Inc.
23490
* All rights reserved.
23491
*
23492
* This source code is licensed under the BSD-style license found in the
23493
* LICENSE file in the root directory of this source tree. An additional grant
23494
* of patent rights can be found in the PATENTS file in the same directory.
23495
*
23496
* @providesModule warning
23497
*/
23498
23499
"use strict";
23500
23501
var emptyFunction = require("./emptyFunction");
23502
23503
/**
23504
* Similar to invariant but only logs a warning if the condition is not met.
23505
* This can be used to log issues in development environments in critical
23506
* paths. Removing the logging code for production environments will keep the
23507
* same logic and follow the same code paths.
23508
*/
23509
23510
var warning = emptyFunction;
23511
23512
if ("production" !== process.env.NODE_ENV) {
23513
warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
23514
if (format === undefined) {
23515
throw new Error(
23516
'`warning(condition, format, ...args)` requires a warning ' +
23517
'message argument'
23518
);
23519
}
23520
23521
if (format.length < 10 || /^[s\W]*$/.test(format)) {
23522
throw new Error(
23523
'The warning format should be able to uniquely identify this ' +
23524
'warning. Please, use a more descriptive format than: ' + format
23525
);
23526
}
23527
23528
if (format.indexOf('Failed Composite propType: ') === 0) {
23529
return; // Ignore CompositeComponent proptype check.
23530
}
23531
23532
if (!condition) {
23533
var argIndex = 0;
23534
var message = 'Warning: ' + format.replace(/%s/g, function() {return args[argIndex++];});
23535
console.warn(message);
23536
try {
23537
// --- Welcome to debugging React ---
23538
// This error was thrown as a convenience so that you can use this stack
23539
// to find the callsite that caused this warning to fire.
23540
throw new Error(message);
23541
} catch(x) {}
23542
}
23543
};
23544
}
23545
23546
module.exports = warning;
23547
23548
}).call(this,require('_process'))
23549
},{"./emptyFunction":143,"_process":1}],186:[function(require,module,exports){
23550
module.exports = require('./lib/React');
23551
23552
},{"./lib/React":44}],187:[function(require,module,exports){
23553
// Generated by CoffeeScript 1.9.2
23554
23555
/*
23556
23557
* Flummox using CoffeeScript --
23558
23559
* build:
23560
23561
cjsx -b -c flummox.cjsx && browserify --exports=require flummox.js -o flummox0.js
23562
*/
23563
var Actions, App, AppFlux, Flux, FluxComponent, MessageActions, MessageStore, React, Store, flux, log, page, ref, rtypes,
23564
slice = [].slice,
23565
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
23566
hasProp = {}.hasOwnProperty;
23567
23568
log = function() {
23569
var s;
23570
s = 1 <= arguments.length ? slice.call(arguments, 0) : [];
23571
return console.log.apply(console, s);
23572
};
23573
23574
log("flummox.cjsx");
23575
23576
ref = require('flummox'), Actions = ref.Actions, Store = ref.Store, Flux = ref.Flux;
23577
23578
MessageActions = (function(superClass) {
23579
extend(MessageActions, superClass);
23580
23581
function MessageActions() {
23582
return MessageActions.__super__.constructor.apply(this, arguments);
23583
}
23584
23585
MessageActions.prototype.createMessage = function(messageContent) {
23586
return {
23587
content: messageContent,
23588
date: Date.now()
23589
};
23590
};
23591
23592
MessageActions.prototype.clearMessages = function() {
23593
log("clearMessages");
23594
return {};
23595
};
23596
23597
return MessageActions;
23598
23599
})(Actions);
23600
23601
MessageStore = (function(superClass) {
23602
extend(MessageStore, superClass);
23603
23604
function MessageStore(flux) {
23605
var messageActionIds;
23606
MessageStore.__super__.constructor.call(this);
23607
messageActionIds = flux.getActionIds('messages');
23608
this.register(messageActionIds.createMessage, this.handleNewMessage);
23609
this.register(messageActionIds.clearMessages, this.clearMessages);
23610
this.state = {
23611
messages: []
23612
};
23613
}
23614
23615
MessageStore.prototype.handleNewMessage = function(message) {
23616
log("appending new message");
23617
this.setState({
23618
messages: this.state.messages.concat([message])
23619
});
23620
return log("now state=", this.state);
23621
};
23622
23623
MessageStore.prototype.clearMessages = function() {
23624
log("clearing messages");
23625
return this.setState({
23626
messages: []
23627
});
23628
};
23629
23630
return MessageStore;
23631
23632
})(Store);
23633
23634
AppFlux = (function(superClass) {
23635
extend(AppFlux, superClass);
23636
23637
function AppFlux() {
23638
log("AppFlux constructor");
23639
AppFlux.__super__.constructor.call(this);
23640
}
23641
23642
return AppFlux;
23643
23644
})(Flux);
23645
23646
flux = new AppFlux();
23647
23648
flux.createActions('messages', MessageActions);
23649
23650
flux.createStore('messages', MessageStore, flux);
23651
23652
flux.addListener('dispatch', function(payload) {
23653
return log('Dispatch: ', payload);
23654
});
23655
23656
window.flux = flux;
23657
23658
window.React = React = require('react');
23659
23660
rtypes = React.PropTypes;
23661
23662
App = (function(superClass) {
23663
extend(App, superClass);
23664
23665
function App() {
23666
return App.__super__.constructor.apply(this, arguments);
23667
}
23668
23669
App.prototype.propTypes = {
23670
title: rtypes.string
23671
};
23672
23673
App.prototype.message_list = function() {
23674
var i, j, len, m, ref1, results;
23675
if (this.props.messages != null) {
23676
ref1 = this.props.messages;
23677
results = [];
23678
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
23679
m = ref1[i];
23680
results.push(React.createElement("div", {
23681
"key": i
23682
}, m));
23683
}
23684
return results;
23685
}
23686
};
23687
23688
App.prototype.render = function() {
23689
return React.createElement("div", null, React.createElement("h1", null, this.props.title), React.createElement("form", {
23690
"onSubmit": this.submit_handler
23691
}, React.createElement("button", {
23692
"type": "submit"
23693
}, "Send a new message"), this.message_list()), React.createElement("form", {
23694
"onSubmit": this.clear_handler
23695
}, React.createElement("button", {
23696
"type": "submit"
23697
}, "Clear messages")));
23698
};
23699
23700
App.prototype.submit_handler = function(event) {
23701
event.preventDefault();
23702
log("new message button pushed");
23703
return flux.getActions('messages').createMessage("the button was pushed -- " + (Math.random()));
23704
};
23705
23706
App.prototype.clear_handler = function(event) {
23707
event.preventDefault();
23708
log("clear button pushed");
23709
return flux.getActions('messages').clearMessages();
23710
};
23711
23712
return App;
23713
23714
})(React.Component);
23715
23716
FluxComponent = require('flummox/component');
23717
23718
window.FluxComponent = FluxComponent;
23719
23720
log("FluxComponent=", FluxComponent);
23721
23722
page = function() {
23723
return React.createElement(FluxComponent, {
23724
"flux": flux,
23725
"connectToStores": ['messages']
23726
}, React.createElement(App, {
23727
"title": "Demo"
23728
}));
23729
};
23730
23731
log("render");
23732
23733
React.render(page(), document.getElementById('app'));
23734
23735
},{"flummox":4,"flummox/component":2,"react":186}]},{},[187]);
23736
23737