react 15.2.1 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,8 @@
11
11
  */
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactElement = require('./ReactElement');
15
17
  var ReactInstrumentation = require('./ReactInstrumentation');
16
18
  var ReactReconciler = require('./ReactReconciler');
@@ -19,6 +21,7 @@ var ReactUpdates = require('./ReactUpdates');
19
21
  var emptyObject = require('fbjs/lib/emptyObject');
20
22
  var getHostComponentFromComposite = require('./getHostComponentFromComposite');
21
23
  var instantiateReactComponent = require('./instantiateReactComponent');
24
+ var invariant = require('fbjs/lib/invariant');
22
25
 
23
26
  /**
24
27
  * Temporary (?) hack so that we can store all top-level pending updates on
@@ -69,6 +72,29 @@ var ReactTestInstance = function (component) {
69
72
  ReactTestInstance.prototype.getInstance = function () {
70
73
  return this._component._renderedComponent.getPublicInstance();
71
74
  };
75
+ ReactTestInstance.prototype.update = function (nextElement) {
76
+ !this._component ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactTestRenderer: .update() can\'t be called after unmount.') : _prodInvariant('139') : void 0;
77
+ var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
78
+ var component = this._component;
79
+ ReactUpdates.batchedUpdates(function () {
80
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true);
81
+ transaction.perform(function () {
82
+ ReactReconciler.receiveComponent(component, nextWrappedElement, transaction, emptyObject);
83
+ });
84
+ ReactUpdates.ReactReconcileTransaction.release(transaction);
85
+ });
86
+ };
87
+ ReactTestInstance.prototype.unmount = function (nextElement) {
88
+ var component = this._component;
89
+ ReactUpdates.batchedUpdates(function () {
90
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true);
91
+ transaction.perform(function () {
92
+ ReactReconciler.unmountComponent(component, false);
93
+ });
94
+ ReactUpdates.ReactReconcileTransaction.release(transaction);
95
+ });
96
+ this._component = null;
97
+ };
72
98
  ReactTestInstance.prototype.toJSON = function () {
73
99
  var inst = getHostComponentFromComposite(this._component);
74
100
  return inst.toJSON();
@@ -78,24 +104,11 @@ ReactTestInstance.prototype.toJSON = function () {
78
104
  * As soon as `ReactMount` is refactored to not rely on the DOM, we can share
79
105
  * code between the two. For now, we'll hard code the ID logic.
80
106
  */
81
- var ReactHostMount = {
107
+ var ReactTestMount = {
82
108
 
83
109
  render: function (nextElement) {
84
110
  var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
85
111
 
86
- // var prevComponent = ReactHostMount._instancesByContainerID[containerTag];
87
- // if (prevComponent) {
88
- // var prevWrappedElement = prevComponent._currentElement;
89
- // var prevElement = prevWrappedElement.props;
90
- // if (shouldUpdateReactComponent(prevElement, nextElement)) {
91
- // ReactUpdateQueue.enqueueElementInternal(prevComponent, nextWrappedElement);
92
- // if (callback) {
93
- // ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
94
- // }
95
- // return prevComponent;
96
- // }
97
- // }
98
-
99
112
  var instance = instantiateReactComponent(nextWrappedElement, false);
100
113
 
101
114
  // The initial render is synchronous but any updates that happen during
@@ -112,4 +125,4 @@ var ReactHostMount = {
112
125
 
113
126
  };
114
127
 
115
- module.exports = ReactHostMount;
128
+ module.exports = ReactTestMount;
@@ -15,6 +15,7 @@ var _assign = require('object-assign');
15
15
 
16
16
  function _objectWithoutProperties(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; }
17
17
 
18
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
18
19
  var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
19
20
  var ReactEmptyComponent = require('./ReactEmptyComponent');
20
21
  var ReactMultiChild = require('./ReactMultiChild');
@@ -56,6 +57,11 @@ ReactTestComponent.prototype.receiveComponent = function (nextElement, transacti
56
57
  this.updateChildren(nextElement.props.children, transaction, context);
57
58
  };
58
59
  ReactTestComponent.prototype.getHostNode = function () {};
60
+ ReactTestComponent.prototype.getPublicInstance = function () {
61
+ // I can't say this makes a ton of sense but it seems better than throwing.
62
+ // Maybe we'll revise later if someone has a good use case.
63
+ return null;
64
+ };
59
65
  ReactTestComponent.prototype.unmountComponent = function () {};
60
66
  ReactTestComponent.prototype.toJSON = function () {
61
67
  var _currentElement$props = this._currentElement.props;
@@ -121,6 +127,11 @@ ReactEmptyComponent.injection.injectEmptyComponentFactory(function () {
121
127
  return new ReactTestEmptyComponent();
122
128
  });
123
129
 
130
+ ReactComponentEnvironment.injection.injectEnvironment({
131
+ processChildrenUpdates: function () {},
132
+ replaceNodeWithMarkup: function () {}
133
+ });
134
+
124
135
  var ReactTestRenderer = {
125
136
  create: ReactTestMount.render,
126
137
 
@@ -344,9 +344,11 @@ NoopInternalComponent.prototype = {
344
344
 
345
345
  var ShallowComponentWrapper = function (element) {
346
346
  // TODO: Consolidate with instantiateReactComponent
347
- this._debugID = nextDebugID++;
348
- var displayName = element.type.displayName || element.type.name || 'Unknown';
349
- ReactInstrumentation.debugTool.onSetDisplayName(this._debugID, displayName);
347
+ if (process.env.NODE_ENV !== 'production') {
348
+ this._debugID = nextDebugID++;
349
+ var displayName = element.type.displayName || element.type.name || 'Unknown';
350
+ ReactInstrumentation.debugTool.onSetDisplayName(this._debugID, displayName);
351
+ }
350
352
 
351
353
  this.construct(element);
352
354
  };
@@ -424,6 +426,8 @@ function makeSimulator(eventType) {
424
426
 
425
427
  var fakeNativeEvent = new Event();
426
428
  fakeNativeEvent.target = node;
429
+ fakeNativeEvent.type = eventType.toLowerCase();
430
+
427
431
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
428
432
  // properly destroying any properties assigned from `eventData` upon release
429
433
  var event = new SyntheticEvent(dispatchConfig, ReactDOMComponentTree.getInstanceFromNode(node), fakeNativeEvent, node);
@@ -42,10 +42,11 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
42
42
  var internalInstance = ReactInstanceMap.get(publicInstance);
43
43
  if (!internalInstance) {
44
44
  if (process.env.NODE_ENV !== 'production') {
45
+ var ctor = publicInstance.constructor;
45
46
  // Only warn when we have a callerName. Otherwise we should be silent.
46
47
  // We're probably calling from enqueueCallback. We don't want to warn
47
48
  // there because we already warned for the corresponding lifecycle method.
48
- process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : void 0;
49
+ process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, ctor && (ctor.displayName || ctor.name) || 'ReactClass') : void 0;
49
50
  }
50
51
  return null;
51
52
  }
@@ -11,4 +11,4 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- module.exports = '15.2.1';
14
+ module.exports = '15.3.0';
@@ -263,6 +263,8 @@ var ATTRS = {
263
263
  xlinkTitle: 'xlink:title',
264
264
  xlinkType: 'xlink:type',
265
265
  xmlBase: 'xml:base',
266
+ xmlns: 0,
267
+ xmlnsXlink: 'xmlns:xlink',
266
268
  xmlLang: 'xml:lang',
267
269
  xmlSpace: 'xml:space',
268
270
  y: 0,
@@ -485,6 +485,10 @@ for (var type in topLevelEventsToDispatchConfig) {
485
485
  var ON_CLICK_KEY = keyOf({ onClick: null });
486
486
  var onClickListeners = {};
487
487
 
488
+ function getDictionaryKey(inst) {
489
+ return '.' + inst._rootNodeID;
490
+ }
491
+
488
492
  var SimpleEventPlugin = {
489
493
 
490
494
  eventTypes: eventTypes,
@@ -608,19 +612,19 @@ var SimpleEventPlugin = {
608
612
  // fire. The workaround for this bug involves attaching an empty click
609
613
  // listener on the target node.
610
614
  if (registrationName === ON_CLICK_KEY) {
611
- var id = inst._rootNodeID;
615
+ var key = getDictionaryKey(inst);
612
616
  var node = ReactDOMComponentTree.getNodeFromInstance(inst);
613
- if (!onClickListeners[id]) {
614
- onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
617
+ if (!onClickListeners[key]) {
618
+ onClickListeners[key] = EventListener.listen(node, 'click', emptyFunction);
615
619
  }
616
620
  }
617
621
  },
618
622
 
619
623
  willDeleteListener: function (inst, registrationName) {
620
624
  if (registrationName === ON_CLICK_KEY) {
621
- var id = inst._rootNodeID;
622
- onClickListeners[id].remove();
623
- delete onClickListeners[id];
625
+ var key = getDictionaryKey(inst);
626
+ onClickListeners[key].remove();
627
+ delete onClickListeners[key];
624
628
  }
625
629
  }
626
630
 
@@ -14,10 +14,22 @@
14
14
  var _prodInvariant = require('./reactProdInvariant');
15
15
 
16
16
  var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
17
+ var ReactPropTypesSecret = require('./ReactPropTypesSecret');
17
18
 
18
19
  var invariant = require('fbjs/lib/invariant');
19
20
  var warning = require('fbjs/lib/warning');
20
21
 
22
+ var ReactComponentTreeDevtool;
23
+
24
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
25
+ // Temporary hack.
26
+ // Inline requires don't work well with Jest:
27
+ // https://github.com/facebook/react/issues/7240
28
+ // Remove the inline requires when we don't need them anymore:
29
+ // https://github.com/facebook/react/pull/7178
30
+ ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
31
+ }
32
+
21
33
  var loggedTypeFailures = {};
22
34
 
23
35
  /**
@@ -43,7 +55,7 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
43
55
  // This is intentionally an invariant that gets caught. It's the same
44
56
  // behavior as without this statement except with a better message.
45
57
  !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
46
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location);
58
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
47
59
  } catch (ex) {
48
60
  error = ex;
49
61
  }
@@ -56,7 +68,9 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
56
68
  var componentStackInfo = '';
57
69
 
58
70
  if (process.env.NODE_ENV !== 'production') {
59
- var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
71
+ if (!ReactComponentTreeDevtool) {
72
+ ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
73
+ }
60
74
  if (debugID !== null) {
61
75
  componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID);
62
76
  } else if (element !== null) {
@@ -16,6 +16,17 @@ var KeyEscapeUtils = require('./KeyEscapeUtils');
16
16
  var traverseAllChildren = require('./traverseAllChildren');
17
17
  var warning = require('fbjs/lib/warning');
18
18
 
19
+ var ReactComponentTreeDevtool;
20
+
21
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
22
+ // Temporary hack.
23
+ // Inline requires don't work well with Jest:
24
+ // https://github.com/facebook/react/issues/7240
25
+ // Remove the inline requires when we don't need them anymore:
26
+ // https://github.com/facebook/react/pull/7178
27
+ ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
28
+ }
29
+
19
30
  /**
20
31
  * @param {function} traverseContext Context passed through traversal.
21
32
  * @param {?ReactComponent} child React child component.
@@ -28,7 +39,9 @@ function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID
28
39
  var result = traverseContext;
29
40
  var keyUnique = result[name] === undefined;
30
41
  if (process.env.NODE_ENV !== 'production') {
31
- var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
42
+ if (!ReactComponentTreeDevtool) {
43
+ ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
44
+ }
32
45
  process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
33
46
  }
34
47
  if (keyUnique && child != null) {
@@ -98,7 +98,14 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
98
98
  }
99
99
  } else {
100
100
  if (process.env.NODE_ENV !== 'production') {
101
- process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : void 0;
101
+ var mapsAsChildrenAddendum = '';
102
+ if (ReactCurrentOwner.current) {
103
+ var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
104
+ if (mapsAsChildrenOwnerName) {
105
+ mapsAsChildrenAddendum = ' Check the render method of `' + mapsAsChildrenOwnerName + '`.';
106
+ }
107
+ }
108
+ process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
102
109
  didWarnAboutMaps = true;
103
110
  }
104
111
  // Iterator will provide entry [k,v] tuples rather than values.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react",
3
3
  "description": "React is a JavaScript library for building user interfaces.",
4
- "version": "15.2.1",
4
+ "version": "15.3.0",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],