react 0.14.0-alpha1 → 0.14.0-alpha2

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 ReactDOMServer
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactDefaultInjection = require("./ReactDefaultInjection");
15
+ var ReactServerRendering = require("./ReactServerRendering");
16
+
17
+ ReactDefaultInjection.inject();
18
+
19
+ var ReactDOMServer = {
20
+ renderToString: ReactServerRendering.renderToString,
21
+ renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup
22
+ };
23
+
24
+ module.exports = ReactDOMServer;
@@ -64,8 +64,8 @@ assign(ReactDOMTextComponent.prototype, {
64
64
  */
65
65
  mountComponent: function (rootID, transaction, context) {
66
66
  if ('production' !== process.env.NODE_ENV) {
67
- if (context[validateDOMNesting.tagStackContextKey]) {
68
- validateDOMNesting(context[validateDOMNesting.tagStackContextKey], 'span', null);
67
+ if (context[validateDOMNesting.ancestorInfoContextKey]) {
68
+ validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
69
69
  }
70
70
  }
71
71
 
@@ -62,7 +62,17 @@ function autoGenerateWrapperClass(type) {
62
62
  });
63
63
  }
64
64
 
65
+ var alreadyInjected = false;
66
+
65
67
  function inject() {
68
+ if (alreadyInjected) {
69
+ // TODO: This is currently true because these injections are shared between
70
+ // the client and the server package. They should be built independently
71
+ // and not share any injection state. Then this problem will be solved.
72
+ return;
73
+ }
74
+ alreadyInjected = true;
75
+
66
76
  ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);
67
77
 
68
78
  /**
@@ -99,6 +99,19 @@ var ReactElement = function (type, key, ref, owner, context, props) {
99
99
  // commonly used development environments.
100
100
  this._store = { props: props, originalProps: assign({}, props) };
101
101
 
102
+ // To make comparing ReactElements easier for testing purposes, we make
103
+ // the validation flag non-enumerable (where possible, which should
104
+ // include every environment we run tests in), so the test framework
105
+ // ignores it.
106
+ try {
107
+ Object.defineProperty(this._store, 'validated', {
108
+ configurable: false,
109
+ enumerable: false,
110
+ writable: true
111
+ });
112
+ } catch (x) {}
113
+ this._store.validated = false;
114
+
102
115
  // We're not allowed to set props directly on the object so we early
103
116
  // return and rely on the prototype membrane to forward to the backing
104
117
  // store.
@@ -148,20 +161,6 @@ ReactElement.createElement = function (type, config, children) {
148
161
  props.children = children;
149
162
  } else if (childrenLength > 1) {
150
163
  var childArray = Array(childrenLength);
151
-
152
- // To make comparing ReactElements easier for testing purposes, we make
153
- // the validation flag non-enumerable (where possible, which should
154
- // include every environment we run tests in), so the test framework
155
- // ignores it.
156
- try {
157
- Object.defineProperty(childArray, '_reactChildKeysValidated', {
158
- configurable: false,
159
- enumerable: false,
160
- writable: true
161
- });
162
- } catch (x) {}
163
- childArray._reactChildKeysValidated = true;
164
-
165
164
  for (var i = 0; i < childrenLength; i++) {
166
165
  childArray[i] = arguments[i + 2];
167
166
  }
@@ -194,6 +193,11 @@ ReactElement.createFactory = function (type) {
194
193
 
195
194
  ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
196
195
  var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps);
196
+
197
+ if ('production' !== process.env.NODE_ENV) {
198
+ // If the key on the original is valid, then the clone is valid
199
+ newElement._store.validated = oldElement._store.validated;
200
+ }
197
201
  return newElement;
198
202
  };
199
203
 
@@ -90,9 +90,11 @@ function getCurrentOwnerDisplayName() {
90
90
  * @param {*} parentType element's parent's type.
91
91
  */
92
92
  function validateExplicitKey(element, parentType) {
93
- if (element.key != null) {
93
+ if (element._store.validated || element.key != null) {
94
94
  return;
95
95
  }
96
+ element._store.validated = true;
97
+
96
98
  warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);
97
99
  }
98
100
 
@@ -158,22 +160,15 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
158
160
  */
159
161
  function validateChildKeys(node, parentType) {
160
162
  if (Array.isArray(node)) {
161
- if (node._reactChildKeysValidated) {
162
- // All child elements were passed in a valid location.
163
- return;
164
- }
165
163
  for (var i = 0; i < node.length; i++) {
166
164
  var child = node[i];
167
165
  if (ReactElement.isValidElement(child)) {
168
166
  validateExplicitKey(child, parentType);
169
- } else {
170
- // TODO: Warn on unkeyed arrays and suggest using createFragment
171
- validateChildKeys(child, parentType);
172
167
  }
173
168
  }
174
- } else if (typeof node === 'string' || typeof node === 'number' || ReactElement.isValidElement(node)) {
169
+ } else if (ReactElement.isValidElement(node)) {
175
170
  // This element was passed in a valid location.
176
- return;
171
+ node._store.validated = true;
177
172
  } else if (node) {
178
173
  var iteratorFn = getIteratorFn(node);
179
174
  // Entry iterators provide implicit keys.
@@ -184,8 +179,6 @@ function validateChildKeys(node, parentType) {
184
179
  while (!(step = iterator.next()).done) {
185
180
  if (ReactElement.isValidElement(step.value)) {
186
181
  validateExplicitKey(step.value, parentType);
187
- } else {
188
- validateChildKeys(step.value, parentType);
189
182
  }
190
183
  }
191
184
  }
@@ -194,7 +187,6 @@ function validateChildKeys(node, parentType) {
194
187
  for (var key in fragment) {
195
188
  if (fragment.hasOwnProperty(key)) {
196
189
  validatePropertyKey(key, fragment[key], parentType);
197
- validateChildKeys(fragment[key], parentType);
198
190
  }
199
191
  }
200
192
  }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 ReactIsomorphic
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactChildren = require("./ReactChildren");
15
+ var ReactComponent = require("./ReactComponent");
16
+ var ReactClass = require("./ReactClass");
17
+ var ReactDOM = require("./ReactDOM");
18
+ var ReactElement = require("./ReactElement");
19
+ var ReactElementValidator = require("./ReactElementValidator");
20
+ var ReactPropTypes = require("./ReactPropTypes");
21
+
22
+ var assign = require("./Object.assign");
23
+ var onlyChild = require("./onlyChild");
24
+
25
+ var createElement = ReactElement.createElement;
26
+ var createFactory = ReactElement.createFactory;
27
+ var cloneElement = ReactElement.cloneElement;
28
+
29
+ if ('production' !== process.env.NODE_ENV) {
30
+ createElement = ReactElementValidator.createElement;
31
+ createFactory = ReactElementValidator.createFactory;
32
+ cloneElement = ReactElementValidator.cloneElement;
33
+ }
34
+
35
+ var React = {
36
+
37
+ // Modern
38
+
39
+ Children: {
40
+ map: ReactChildren.map,
41
+ forEach: ReactChildren.forEach,
42
+ count: ReactChildren.count,
43
+ only: onlyChild
44
+ },
45
+
46
+ Component: ReactComponent,
47
+
48
+ createElement: createElement,
49
+ cloneElement: cloneElement,
50
+ isValidElement: ReactElement.isValidElement,
51
+
52
+ // Classic
53
+
54
+ PropTypes: ReactPropTypes,
55
+ createClass: ReactClass.createClass,
56
+ createFactory: createFactory,
57
+ createMixin: function (mixin) {
58
+ // Currently a noop. Will be used to validate and trace mixins.
59
+ return mixin;
60
+ },
61
+
62
+ // This looks DOM specific but these are actually isomorphic helpers
63
+ // since they are just generating DOM strings.
64
+ DOM: ReactDOM,
65
+
66
+ // Hook for JSX spread, don't use this for anything else.
67
+ __spread: assign
68
+ };
69
+
70
+ module.exports = React;
package/lib/ReactMount.js CHANGED
@@ -251,7 +251,8 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
251
251
  if (context === emptyObject) {
252
252
  context = {};
253
253
  }
254
- context[validateDOMNesting.tagStackContextKey] = [container.nodeName.toLowerCase()];
254
+ var tag = container.nodeName.toLowerCase();
255
+ context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
255
256
  }
256
257
  var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
257
258
  componentInstance._isTopLevel = true;
@@ -86,16 +86,17 @@ var ReactPropTypes = {
86
86
  };
87
87
 
88
88
  function createChainableTypeChecker(validate) {
89
- function checkType(isRequired, props, propName, componentName, location) {
89
+ function checkType(isRequired, props, propName, componentName, location, propFullName) {
90
90
  componentName = componentName || ANONYMOUS;
91
+ propFullName = propFullName || propName;
91
92
  if (props[propName] == null) {
92
93
  var locationName = ReactPropTypeLocationNames[location];
93
94
  if (isRequired) {
94
- return new Error('Required ' + locationName + ' `' + propName + '` was not specified in ' + ('`' + componentName + '`.'));
95
+ return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
95
96
  }
96
97
  return null;
97
98
  } else {
98
- return validate(props, propName, componentName, location);
99
+ return validate(props, propName, componentName, location, propFullName);
99
100
  }
100
101
  }
101
102
 
@@ -106,7 +107,7 @@ function createChainableTypeChecker(validate) {
106
107
  }
107
108
 
108
109
  function createPrimitiveTypeChecker(expectedType) {
109
- function validate(props, propName, componentName, location) {
110
+ function validate(props, propName, componentName, location, propFullName) {
110
111
  var propValue = props[propName];
111
112
  var propType = getPropType(propValue);
112
113
  if (propType !== expectedType) {
@@ -116,7 +117,7 @@ function createPrimitiveTypeChecker(expectedType) {
116
117
  // 'of type `object`'.
117
118
  var preciseType = getPreciseType(propValue);
118
119
 
119
- return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + preciseType + '` ' + ('supplied to `' + componentName + '`, expected `' + expectedType + '`.'));
120
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
120
121
  }
121
122
  return null;
122
123
  }
@@ -128,15 +129,15 @@ function createAnyTypeChecker() {
128
129
  }
129
130
 
130
131
  function createArrayOfTypeChecker(typeChecker) {
131
- function validate(props, propName, componentName, location) {
132
+ function validate(props, propName, componentName, location, propFullName) {
132
133
  var propValue = props[propName];
133
134
  if (!Array.isArray(propValue)) {
134
135
  var locationName = ReactPropTypeLocationNames[location];
135
136
  var propType = getPropType(propValue);
136
- return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
137
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
137
138
  }
138
139
  for (var i = 0; i < propValue.length; i++) {
139
- var error = typeChecker(propValue, i, componentName, location);
140
+ var error = typeChecker(propValue, i, componentName, location, '' + propFullName + '[' + i + ']');
140
141
  if (error instanceof Error) {
141
142
  return error;
142
143
  }
@@ -147,10 +148,10 @@ function createArrayOfTypeChecker(typeChecker) {
147
148
  }
148
149
 
149
150
  function createElementTypeChecker() {
150
- function validate(props, propName, componentName, location) {
151
+ function validate(props, propName, componentName, location, propFullName) {
151
152
  if (!ReactElement.isValidElement(props[propName])) {
152
153
  var locationName = ReactPropTypeLocationNames[location];
153
- return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactElement.'));
154
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
154
155
  }
155
156
  return null;
156
157
  }
@@ -158,11 +159,11 @@ function createElementTypeChecker() {
158
159
  }
159
160
 
160
161
  function createInstanceTypeChecker(expectedClass) {
161
- function validate(props, propName, componentName, location) {
162
+ function validate(props, propName, componentName, location, propFullName) {
162
163
  if (!(props[propName] instanceof expectedClass)) {
163
164
  var locationName = ReactPropTypeLocationNames[location];
164
165
  var expectedClassName = expectedClass.name || ANONYMOUS;
165
- return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
166
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
166
167
  }
167
168
  return null;
168
169
  }
@@ -170,7 +171,7 @@ function createInstanceTypeChecker(expectedClass) {
170
171
  }
171
172
 
172
173
  function createEnumTypeChecker(expectedValues) {
173
- function validate(props, propName, componentName, location) {
174
+ function validate(props, propName, componentName, location, propFullName) {
174
175
  var propValue = props[propName];
175
176
  for (var i = 0; i < expectedValues.length; i++) {
176
177
  if (propValue === expectedValues[i]) {
@@ -180,22 +181,22 @@ function createEnumTypeChecker(expectedValues) {
180
181
 
181
182
  var locationName = ReactPropTypeLocationNames[location];
182
183
  var valuesString = JSON.stringify(expectedValues);
183
- return new Error('Invalid ' + locationName + ' `' + propName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
184
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
184
185
  }
185
186
  return createChainableTypeChecker(validate);
186
187
  }
187
188
 
188
189
  function createObjectOfTypeChecker(typeChecker) {
189
- function validate(props, propName, componentName, location) {
190
+ function validate(props, propName, componentName, location, propFullName) {
190
191
  var propValue = props[propName];
191
192
  var propType = getPropType(propValue);
192
193
  if (propType !== 'object') {
193
194
  var locationName = ReactPropTypeLocationNames[location];
194
- return new Error('Invalid ' + locationName + ' `' + propName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
195
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
195
196
  }
196
197
  for (var key in propValue) {
197
198
  if (propValue.hasOwnProperty(key)) {
198
- var error = typeChecker(propValue, key, componentName, location);
199
+ var error = typeChecker(propValue, key, componentName, location, '' + propFullName + '.' + key);
199
200
  if (error instanceof Error) {
200
201
  return error;
201
202
  }
@@ -207,25 +208,25 @@ function createObjectOfTypeChecker(typeChecker) {
207
208
  }
208
209
 
209
210
  function createUnionTypeChecker(arrayOfTypeCheckers) {
210
- function validate(props, propName, componentName, location) {
211
+ function validate(props, propName, componentName, location, propFullName) {
211
212
  for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
212
213
  var checker = arrayOfTypeCheckers[i];
213
- if (checker(props, propName, componentName, location) == null) {
214
+ if (checker(props, propName, componentName, location, propFullName) == null) {
214
215
  return null;
215
216
  }
216
217
  }
217
218
 
218
219
  var locationName = ReactPropTypeLocationNames[location];
219
- return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`.'));
220
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
220
221
  }
221
222
  return createChainableTypeChecker(validate);
222
223
  }
223
224
 
224
225
  function createNodeChecker() {
225
- function validate(props, propName, componentName, location) {
226
+ function validate(props, propName, componentName, location, propFullName) {
226
227
  if (!isNode(props[propName])) {
227
228
  var locationName = ReactPropTypeLocationNames[location];
228
- return new Error('Invalid ' + locationName + ' `' + propName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
229
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
229
230
  }
230
231
  return null;
231
232
  }
@@ -233,19 +234,19 @@ function createNodeChecker() {
233
234
  }
234
235
 
235
236
  function createShapeTypeChecker(shapeTypes) {
236
- function validate(props, propName, componentName, location) {
237
+ function validate(props, propName, componentName, location, propFullName) {
237
238
  var propValue = props[propName];
238
239
  var propType = getPropType(propValue);
239
240
  if (propType !== 'object') {
240
241
  var locationName = ReactPropTypeLocationNames[location];
241
- return new Error('Invalid ' + locationName + ' `' + propName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
242
+ return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
242
243
  }
243
244
  for (var key in shapeTypes) {
244
245
  var checker = shapeTypes[key];
245
246
  if (!checker) {
246
247
  continue;
247
248
  }
248
- var error = checker(propValue, key, componentName, location);
249
+ var error = checker(propValue, key, componentName, location, '' + propFullName + '.' + key);
249
250
  if (error) {
250
251
  return error;
251
252
  }
@@ -9,8 +9,6 @@
9
9
  * @providesModule SVGDOMPropertyConfig
10
10
  */
11
11
 
12
- /*jslint bitwise: true*/
13
-
14
12
  'use strict';
15
13
 
16
14
  var DOMProperty = require("./DOMProperty");
package/lib/adler32.js CHANGED
@@ -9,8 +9,6 @@
9
9
  * @providesModule adler32
10
10
  */
11
11
 
12
- /* jslint bitwise:true */
13
-
14
12
  'use strict';
15
13
 
16
14
  var MOD = 65521;
@@ -27,9 +27,9 @@ function containsNode(_x, _x2) {
27
27
  var _again = true;
28
28
 
29
29
  _function: while (_again) {
30
- _again = false;
31
30
  var outerNode = _x,
32
31
  innerNode = _x2;
32
+ _again = false;
33
33
 
34
34
  if (!outerNode || !innerNode) {
35
35
  return false;