react 15.1.0 → 15.2.1

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.
Files changed (124) hide show
  1. package/dist/react-with-addons.js +2685 -1842
  2. package/dist/react-with-addons.min.js +6 -6
  3. package/dist/react.js +2400 -1691
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +1 -1
  6. package/lib/CallbackQueue.js +3 -2
  7. package/lib/DOMChildrenOperations.js +9 -9
  8. package/lib/DOMLazyTree.js +3 -2
  9. package/lib/DOMProperty.js +5 -12
  10. package/lib/DOMPropertyOperations.js +21 -15
  11. package/lib/Danger.js +5 -101
  12. package/lib/DisabledInputUtils.js +5 -5
  13. package/lib/EventPluginHub.js +8 -2
  14. package/lib/EventPluginRegistry.js +13 -7
  15. package/lib/EventPluginUtils.js +3 -1
  16. package/lib/HTMLDOMPropertyConfig.js +1 -2
  17. package/lib/KeyEscapeUtils.js +2 -1
  18. package/lib/LinkedValueUtils.js +5 -3
  19. package/lib/NativeMethodsMixin.js +6 -4
  20. package/lib/PooledClass.js +4 -2
  21. package/lib/React.js +1 -1
  22. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  23. package/lib/ReactChildReconciler.js +17 -8
  24. package/lib/ReactClass.js +14 -13
  25. package/lib/ReactComponent.js +3 -6
  26. package/lib/ReactComponentEnvironment.js +3 -1
  27. package/lib/ReactComponentTreeDevtool.js +89 -16
  28. package/lib/ReactComponentTreeTestUtils.js +87 -0
  29. package/lib/ReactCompositeComponent.js +87 -117
  30. package/lib/ReactDOM.js +2 -2
  31. package/lib/ReactDOMButton.js +2 -2
  32. package/lib/ReactDOMComponent.js +130 -76
  33. package/lib/ReactDOMComponentTree.js +23 -21
  34. package/lib/ReactDOMDebugTool.js +17 -11
  35. package/lib/ReactDOMEmptyComponent.js +9 -9
  36. package/lib/ReactDOMFactories.js +1 -1
  37. package/lib/ReactDOMFiber.js +78 -0
  38. package/lib/ReactDOMInput.js +64 -26
  39. package/lib/ReactDOMInstrumentation.js +7 -2
  40. package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
  41. package/lib/ReactDOMOption.js +40 -26
  42. package/lib/ReactDOMSelect.js +3 -16
  43. package/lib/ReactDOMTextComponent.js +21 -20
  44. package/lib/ReactDOMTextarea.js +59 -46
  45. package/lib/ReactDOMTreeTraversal.js +18 -16
  46. package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
  47. package/lib/ReactDebugTool.js +148 -95
  48. package/lib/ReactDefaultInjection.js +2 -2
  49. package/lib/ReactElement.js +64 -25
  50. package/lib/ReactElementValidator.js +26 -81
  51. package/lib/ReactEventListener.js +2 -2
  52. package/lib/ReactFeatureFlags.js +1 -0
  53. package/lib/ReactFragment.js +3 -1
  54. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  55. package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
  56. package/lib/ReactInjection.js +2 -2
  57. package/lib/ReactInstanceHandles.js +8 -6
  58. package/lib/ReactInstrumentation.js +7 -2
  59. package/lib/ReactMount.js +38 -32
  60. package/lib/ReactMultiChild.js +38 -11
  61. package/lib/ReactNativeAttributePayload.js +5 -2
  62. package/lib/ReactNativeBaseComponent.js +7 -7
  63. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  64. package/lib/ReactNativeComponentTree.js +8 -6
  65. package/lib/ReactNativeDOMIDOperations.js +1 -2
  66. package/lib/ReactNativeDefaultInjection.js +9 -7
  67. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  68. package/lib/ReactNativeMount.js +3 -14
  69. package/lib/ReactNativeReconcileTransaction.js +16 -0
  70. package/lib/ReactNativeTagHandles.js +3 -1
  71. package/lib/ReactNativeTextComponent.js +10 -9
  72. package/lib/ReactNativeTreeTraversal.js +11 -11
  73. package/lib/ReactNodeTypes.js +6 -3
  74. package/lib/ReactNoop.js +173 -0
  75. package/lib/ReactNoopUpdateQueue.js +6 -5
  76. package/lib/ReactOwner.js +4 -2
  77. package/lib/ReactPerf.js +83 -7
  78. package/lib/ReactPropTypes.js +23 -0
  79. package/lib/ReactReconcileTransaction.js +17 -1
  80. package/lib/ReactReconciler.js +12 -7
  81. package/lib/ReactServerRendering.js +5 -7
  82. package/lib/ReactServerRenderingTransaction.js +17 -0
  83. package/lib/ReactServerUpdateQueue.js +141 -0
  84. package/lib/ReactSimpleEmptyComponent.js +4 -4
  85. package/lib/ReactTestMount.js +115 -0
  86. package/lib/ReactTestReconcileTransaction.js +108 -0
  87. package/lib/ReactTestRenderer.js +133 -0
  88. package/lib/ReactTestUtils.js +17 -10
  89. package/lib/ReactTransitionChildMapping.js +7 -1
  90. package/lib/ReactTransitionGroup.js +41 -6
  91. package/lib/ReactUpdateQueue.js +13 -3
  92. package/lib/ReactUpdates.js +10 -18
  93. package/lib/ReactVersion.js +1 -1
  94. package/lib/ResponderEventPlugin.js +9 -7
  95. package/lib/ResponderTouchHistoryStore.js +99 -95
  96. package/lib/SimpleEventPlugin.js +3 -1
  97. package/lib/SyntheticEvent.js +2 -3
  98. package/lib/SyntheticUIEvent.js +1 -1
  99. package/lib/Transaction.js +4 -2
  100. package/lib/accumulate.js +17 -15
  101. package/lib/accumulateInto.js +11 -12
  102. package/lib/adler32.js +1 -0
  103. package/lib/checkReactTypeSpec.js +73 -0
  104. package/lib/createReactNativeComponentClass.js +2 -2
  105. package/lib/dangerousStyleValue.js +3 -1
  106. package/lib/deprecated.js +7 -1
  107. package/lib/escapeTextContentForBrowser.js +96 -12
  108. package/lib/findDOMNode.js +6 -4
  109. package/lib/findNodeHandle.js +5 -3
  110. package/lib/flattenChildren.js +22 -10
  111. package/lib/forEachAccumulated.js +3 -2
  112. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  113. package/lib/getIteratorFn.js +1 -0
  114. package/lib/instantiateReactComponent.js +21 -19
  115. package/lib/isTextInputElement.js +11 -1
  116. package/lib/onlyChild.js +3 -1
  117. package/lib/reactComponentExpect.js +3 -3
  118. package/lib/reactProdInvariant.js +39 -0
  119. package/lib/setInnerHTML.js +17 -1
  120. package/lib/setTextContent.js +8 -0
  121. package/lib/traverseAllChildren.js +3 -1
  122. package/lib/update.js +12 -11
  123. package/package.json +2 -2
  124. package/lib/MetaMatchers.js +0 -118
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var EventConstants = require('./EventConstants');
15
17
  var EventListener = require('fbjs/lib/EventListener');
16
18
  var EventPropagators = require('./EventPropagators');
@@ -594,7 +596,7 @@ var SimpleEventPlugin = {
594
596
  EventConstructor = SyntheticClipboardEvent;
595
597
  break;
596
598
  }
597
- !EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) : void 0;
599
+ !EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : _prodInvariant('86', topLevelType) : void 0;
598
600
  var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
599
601
  EventPropagators.accumulateTwoPhaseDispatches(event);
600
602
  return event;
@@ -165,10 +165,9 @@ _assign(SyntheticEvent.prototype, {
165
165
  this[shouldBeReleasedProperties[i]] = null;
166
166
  }
167
167
  if (process.env.NODE_ENV !== 'production') {
168
- var noop = require('fbjs/lib/emptyFunction');
169
168
  Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
170
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', noop));
171
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', noop));
169
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction));
170
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction));
172
171
  }
173
172
  }
174
173
 
@@ -26,7 +26,7 @@ var UIEventInterface = {
26
26
  }
27
27
 
28
28
  var target = getEventTarget(event);
29
- if (target != null && target.window === target) {
29
+ if (target.window === target) {
30
30
  // target is a window object
31
31
  return target;
32
32
  }
@@ -11,6 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var invariant = require('fbjs/lib/invariant');
15
17
 
16
18
  /**
@@ -122,7 +124,7 @@ var Mixin = {
122
124
  * @return {*} Return value from `method`.
123
125
  */
124
126
  perform: function (method, scope, a, b, c, d, e, f) {
125
- !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : void 0;
127
+ !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there is already an outstanding transaction.') : _prodInvariant('27') : void 0;
126
128
  var errorThrown;
127
129
  var ret;
128
130
  try {
@@ -186,7 +188,7 @@ var Mixin = {
186
188
  * invoked).
187
189
  */
188
190
  closeAll: function (startIndex) {
189
- !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : void 0;
191
+ !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : _prodInvariant('28') : void 0;
190
192
  var transactionWrappers = this.transactionWrappers;
191
193
  for (var i = startIndex; i < transactionWrappers.length; i++) {
192
194
  var wrapper = transactionWrappers[i];
package/lib/accumulate.js CHANGED
@@ -7,10 +7,13 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule accumulate
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
13
14
 
15
+ var _prodInvariant = require('./reactProdInvariant');
16
+
14
17
  var invariant = require('fbjs/lib/invariant');
15
18
 
16
19
  /**
@@ -21,24 +24,23 @@ var invariant = require('fbjs/lib/invariant');
21
24
  * @return {*|array<*>} An accumulation of items.
22
25
  */
23
26
  function accumulate(current, next) {
24
- !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : invariant(false) : void 0;
27
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : _prodInvariant('29') : void 0;
28
+
25
29
  if (current == null) {
26
30
  return next;
27
- } else {
28
- // Both are not empty. Warning: Never call x.concat(y) when you are not
29
- // certain that x is an Array (x could be a string with concat method).
30
- var currentIsArray = Array.isArray(current);
31
- var nextIsArray = Array.isArray(next);
32
- if (currentIsArray) {
33
- return current.concat(next);
34
- } else {
35
- if (nextIsArray) {
36
- return [current].concat(next);
37
- } else {
38
- return [current, next];
39
- }
40
- }
41
31
  }
32
+
33
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
34
+ // certain that x is an Array (x could be a string with concat method).
35
+ if (Array.isArray(current)) {
36
+ return current.concat(next);
37
+ }
38
+
39
+ if (Array.isArray(next)) {
40
+ return [current].concat(next);
41
+ }
42
+
43
+ return [current, next];
42
44
  }
43
45
 
44
46
  module.exports = accumulate;
@@ -7,14 +7,16 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule accumulateInto
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
13
14
 
15
+ var _prodInvariant = require('./reactProdInvariant');
16
+
14
17
  var invariant = require('fbjs/lib/invariant');
15
18
 
16
19
  /**
17
- *
18
20
  * Accumulates items that must not be null or undefined into the first one. This
19
21
  * is used to conserve memory by avoiding array allocations, and thus sacrifices
20
22
  * API cleanness. Since `current` can be null before being passed in and not
@@ -28,27 +30,24 @@ var invariant = require('fbjs/lib/invariant');
28
30
  */
29
31
 
30
32
  function accumulateInto(current, next) {
31
- !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : void 0;
33
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : _prodInvariant('30') : void 0;
34
+
32
35
  if (current == null) {
33
36
  return next;
34
37
  }
35
38
 
36
39
  // Both are not empty. Warning: Never call x.concat(y) when you are not
37
40
  // certain that x is an Array (x could be a string with concat method).
38
- var currentIsArray = Array.isArray(current);
39
- var nextIsArray = Array.isArray(next);
40
-
41
- if (currentIsArray && nextIsArray) {
42
- current.push.apply(current, next);
43
- return current;
44
- }
45
-
46
- if (currentIsArray) {
41
+ if (Array.isArray(current)) {
42
+ if (Array.isArray(next)) {
43
+ current.push.apply(current, next);
44
+ return current;
45
+ }
47
46
  current.push(next);
48
47
  return current;
49
48
  }
50
49
 
51
- if (nextIsArray) {
50
+ if (Array.isArray(next)) {
52
51
  // A bit too dangerous to mutate `next`.
53
52
  return [current].concat(next);
54
53
  }
package/lib/adler32.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule adler32
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule checkReactTypeSpec
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
17
+
18
+ var invariant = require('fbjs/lib/invariant');
19
+ var warning = require('fbjs/lib/warning');
20
+
21
+ var loggedTypeFailures = {};
22
+
23
+ /**
24
+ * Assert that the values match with the type specs.
25
+ * Error messages are memorized and will only be shown once.
26
+ *
27
+ * @param {object} typeSpecs Map of name to a ReactPropType
28
+ * @param {object} values Runtime values that need to be type-checked
29
+ * @param {string} location e.g. "prop", "context", "child context"
30
+ * @param {string} componentName Name of the component for error messages.
31
+ * @param {?object} element The React element that is being type-checked
32
+ * @param {?number} debugID The React component instance that is being type-checked
33
+ * @private
34
+ */
35
+ function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
36
+ for (var typeSpecName in typeSpecs) {
37
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
38
+ var error;
39
+ // Prop type validation may throw. In case they do, we don't want to
40
+ // fail the render phase where it didn't fail before. So we log it.
41
+ // After these have been cleaned up, we'll let them throw.
42
+ try {
43
+ // This is intentionally an invariant that gets caught. It's the same
44
+ // behavior as without this statement except with a better message.
45
+ !(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);
47
+ } catch (ex) {
48
+ error = ex;
49
+ }
50
+ process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
51
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
52
+ // Only monitor this failure once because there tends to be a lot of the
53
+ // same error.
54
+ loggedTypeFailures[error.message] = true;
55
+
56
+ var componentStackInfo = '';
57
+
58
+ if (process.env.NODE_ENV !== 'production') {
59
+ var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
60
+ if (debugID !== null) {
61
+ componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID);
62
+ } else if (element !== null) {
63
+ componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element);
64
+ }
65
+ }
66
+
67
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ module.exports = checkReactTypeSpec;
@@ -25,8 +25,8 @@ var createReactNativeComponentClass = function (viewConfig) {
25
25
  var Constructor = function (element) {
26
26
  this._currentElement = element;
27
27
  this._topLevelWrapper = null;
28
- this._nativeParent = null;
29
- this._nativeContainerInfo = null;
28
+ this._hostParent = null;
29
+ this._hostContainerInfo = null;
30
30
  this._rootNodeID = null;
31
31
  this._renderedChildren = null;
32
32
  };
@@ -50,7 +50,9 @@ function dangerousStyleValue(name, value, component) {
50
50
 
51
51
  if (typeof value === 'string') {
52
52
  if (process.env.NODE_ENV !== 'production') {
53
- if (component) {
53
+ // Allow '0' to pass through without warning. 0 is already special and
54
+ // doesn't require units, so we don't need to warn about it.
55
+ if (component && value !== '0') {
54
56
  var owner = component._currentElement._owner;
55
57
  var ownerName = owner ? owner.getName() : null;
56
58
  if (ownerName && !styleWarnings[ownerName]) {
package/lib/deprecated.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule deprecated
10
+ *
10
11
  */
11
12
 
12
13
  'use strict';
@@ -42,7 +43,12 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
42
43
  };
43
44
  // We need to make sure all properties of the original fn are copied over.
44
45
  // In particular, this is needed to support PropTypes
45
- return _assign(newFn, fn);
46
+ _assign(newFn, fn);
47
+
48
+ // Flow is not smart enough to figure out that newFn is of the same type as
49
+ // fn. Since we don't want to lose out the type of the function, casting
50
+ // to any and force flow to use T.
51
+ return newFn;
46
52
  }
47
53
 
48
54
  return fn;
@@ -1,29 +1,107 @@
1
1
  /**
2
- * Copyright 2013-present, Facebook, Inc.
2
+ * Copyright 2016-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
+ * Based on the escape-html library, which is used under the MIT License below:
10
+ *
11
+ * Copyright (c) 2012-2013 TJ Holowaychuk
12
+ * Copyright (c) 2015 Andreas Lubbe
13
+ * Copyright (c) 2015 Tiancheng "Timothy" Gu
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining
16
+ * a copy of this software and associated documentation files (the
17
+ * 'Software'), to deal in the Software without restriction, including
18
+ * without limitation the rights to use, copy, modify, merge, publish,
19
+ * distribute, sublicense, and/or sell copies of the Software, and to
20
+ * permit persons to whom the Software is furnished to do so, subject to
21
+ * the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be
24
+ * included in all copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
27
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
30
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
+ *
9
34
  * @providesModule escapeTextContentForBrowser
10
35
  */
11
36
 
12
37
  'use strict';
13
38
 
14
- var ESCAPE_LOOKUP = {
15
- '&': '&amp;',
16
- '>': '&gt;',
17
- '<': '&lt;',
18
- '"': '&quot;',
19
- '\'': '&#x27;'
20
- };
39
+ // code copied and modified from escape-html
40
+ /**
41
+ * Module variables.
42
+ * @private
43
+ */
44
+
45
+ var matchHtmlRegExp = /["'&<>]/;
46
+
47
+ /**
48
+ * Escape special characters in the given string of html.
49
+ *
50
+ * @param {string} string The string to escape for inserting into HTML
51
+ * @return {string}
52
+ * @public
53
+ */
54
+
55
+ function escapeHtml(string) {
56
+ var str = '' + string;
57
+ var match = matchHtmlRegExp.exec(str);
58
+
59
+ if (!match) {
60
+ return str;
61
+ }
62
+
63
+ var escape;
64
+ var html = '';
65
+ var index = 0;
66
+ var lastIndex = 0;
67
+
68
+ for (index = match.index; index < str.length; index++) {
69
+ switch (str.charCodeAt(index)) {
70
+ case 34:
71
+ // "
72
+ escape = '&quot;';
73
+ break;
74
+ case 38:
75
+ // &
76
+ escape = '&amp;';
77
+ break;
78
+ case 39:
79
+ // '
80
+ escape = '&#x27;'; // modified from escape-html; used to be '&#39'
81
+ break;
82
+ case 60:
83
+ // <
84
+ escape = '&lt;';
85
+ break;
86
+ case 62:
87
+ // >
88
+ escape = '&gt;';
89
+ break;
90
+ default:
91
+ continue;
92
+ }
93
+
94
+ if (lastIndex !== index) {
95
+ html += str.substring(lastIndex, index);
96
+ }
21
97
 
22
- var ESCAPE_REGEX = /[&><"']/g;
98
+ lastIndex = index + 1;
99
+ html += escape;
100
+ }
23
101
 
24
- function escaper(match) {
25
- return ESCAPE_LOOKUP[match];
102
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
26
103
  }
104
+ // end code copied and modified from escape-html
27
105
 
28
106
  /**
29
107
  * Escapes text to prevent scripting attacks.
@@ -32,7 +110,13 @@ function escaper(match) {
32
110
  * @return {string} An escaped string.
33
111
  */
34
112
  function escapeTextContentForBrowser(text) {
35
- return ('' + text).replace(ESCAPE_REGEX, escaper);
113
+ if (typeof text === 'boolean' || typeof text === 'number') {
114
+ // this shortcircuit helps perf for types that we know will never have
115
+ // special characters, especially given that this function is used often
116
+ // for numeric dom ids.
117
+ return '' + text;
118
+ }
119
+ return escapeHtml(text);
36
120
  }
37
121
 
38
122
  module.exports = escapeTextContentForBrowser;
@@ -11,11 +11,13 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
14
16
  var ReactCurrentOwner = require('./ReactCurrentOwner');
15
17
  var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
18
  var ReactInstanceMap = require('./ReactInstanceMap');
17
19
 
18
- var getNativeComponentFromComposite = require('./getNativeComponentFromComposite');
20
+ var getHostComponentFromComposite = require('./getHostComponentFromComposite');
19
21
  var invariant = require('fbjs/lib/invariant');
20
22
  var warning = require('fbjs/lib/warning');
21
23
 
@@ -44,14 +46,14 @@ function findDOMNode(componentOrElement) {
44
46
 
45
47
  var inst = ReactInstanceMap.get(componentOrElement);
46
48
  if (inst) {
47
- inst = getNativeComponentFromComposite(inst);
49
+ inst = getHostComponentFromComposite(inst);
48
50
  return inst ? ReactDOMComponentTree.getNodeFromInstance(inst) : null;
49
51
  }
50
52
 
51
53
  if (typeof componentOrElement.render === 'function') {
52
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : void 0;
54
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : _prodInvariant('44') : void 0;
53
55
  } else {
54
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : void 0;
56
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : _prodInvariant('45', Object.keys(componentOrElement)) : void 0;
55
57
  }
56
58
  }
57
59