react 0.13.0-beta.2 → 0.13.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.
@@ -39,13 +39,13 @@ if ("production" !== process.env.NODE_ENV) {
39
39
  Object.defineProperty(
40
40
  {},
41
41
  fragmentKey,
42
- { enumerable: false, value: true }
42
+ {enumerable: false, value: true}
43
43
  );
44
44
 
45
45
  Object.defineProperty(
46
46
  {},
47
47
  'key',
48
- { enumerable: true, get: dummy }
48
+ {enumerable: true, get: dummy}
49
49
  );
50
50
 
51
51
  canWarnForReactFragment = true;
@@ -96,14 +96,22 @@ var ReactFragment = {
96
96
  // of its properties.
97
97
  create: function(object) {
98
98
  if ("production" !== process.env.NODE_ENV) {
99
- if (typeof object !== 'object' || !object) {
99
+ if (typeof object !== 'object' || !object || Array.isArray(object)) {
100
100
  ("production" !== process.env.NODE_ENV ? warning(
101
101
  false,
102
- 'React.addons.createFragment only accepts a single object. Not %s',
102
+ 'React.addons.createFragment only accepts a single object.',
103
103
  object
104
104
  ) : null);
105
105
  return object;
106
106
  }
107
+ if (ReactElement.isValidElement(object)) {
108
+ ("production" !== process.env.NODE_ENV ? warning(
109
+ false,
110
+ 'React.addons.createFragment does not accept a ReactElement ' +
111
+ 'without a wrapper object.'
112
+ ) : null);
113
+ return object;
114
+ }
107
115
  if (canWarnForReactFragment) {
108
116
  var proxy = {};
109
117
  Object.defineProperty(proxy, fragmentKey, {
@@ -133,7 +141,8 @@ var ReactFragment = {
133
141
  ("production" !== process.env.NODE_ENV ? warning(
134
142
  didWarnForFragment(fragment),
135
143
  'Any use of a keyed object should be wrapped in ' +
136
- 'React.addons.createFragment(object) before passed as a child.'
144
+ 'React.addons.createFragment(object) before being passed as a ' +
145
+ 'child.'
137
146
  ) : null);
138
147
  return fragment;
139
148
  }
package/lib/ReactMount.js CHANGED
@@ -279,7 +279,7 @@ function batchedMountComponentIntoNode(
279
279
  }
280
280
 
281
281
  /**
282
- * Mounting is the process of initializing a React component by creatings its
282
+ * Mounting is the process of initializing a React component by creating its
283
283
  * representative DOM elements and inserting them into a supplied `container`.
284
284
  * Any prior content inside `container` is destroyed in the process.
285
285
  *
@@ -370,13 +370,13 @@ var ReactMount = {
370
370
 
371
371
  /**
372
372
  * Render a new component into the DOM.
373
- * @param {ReactComponent} nextComponent component instance to render
373
+ * @param {ReactElement} nextElement element to render
374
374
  * @param {DOMElement} container container to render into
375
375
  * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
376
376
  * @return {ReactComponent} nextComponent
377
377
  */
378
378
  _renderNewRootComponent: function(
379
- nextComponent,
379
+ nextElement,
380
380
  container,
381
381
  shouldReuseMarkup
382
382
  ) {
@@ -391,7 +391,7 @@ var ReactMount = {
391
391
  'componentDidUpdate.'
392
392
  ) : null);
393
393
 
394
- var componentInstance = instantiateReactComponent(nextComponent, null);
394
+ var componentInstance = instantiateReactComponent(nextElement, null);
395
395
  var reactRootID = ReactMount._registerComponent(
396
396
  componentInstance,
397
397
  container
@@ -12,6 +12,7 @@
12
12
  'use strict';
13
13
 
14
14
  var ReactElement = require("./ReactElement");
15
+ var ReactFragment = require("./ReactFragment");
15
16
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
16
17
 
17
18
  var emptyFunction = require("./emptyFunction");
@@ -291,6 +292,7 @@ function isNode(propValue) {
291
292
  switch (typeof propValue) {
292
293
  case 'number':
293
294
  case 'string':
295
+ case 'undefined':
294
296
  return true;
295
297
  case 'boolean':
296
298
  return !propValue;
@@ -298,9 +300,10 @@ function isNode(propValue) {
298
300
  if (Array.isArray(propValue)) {
299
301
  return propValue.every(isNode);
300
302
  }
301
- if (ReactElement.isValidElement(propValue)) {
303
+ if (propValue === null || ReactElement.isValidElement(propValue)) {
302
304
  return true;
303
305
  }
306
+ propValue = ReactFragment.extractIfFragment(propValue);
304
307
  for (var k in propValue) {
305
308
  if (!isNode(propValue[k])) {
306
309
  return false;
@@ -86,7 +86,6 @@ var ReactReconciler = {
86
86
  }
87
87
 
88
88
  var refsChanged = ReactRef.shouldUpdateRefs(
89
- this,
90
89
  prevElement,
91
90
  nextElement
92
91
  );
package/lib/ReactRef.js CHANGED
@@ -40,7 +40,7 @@ ReactRef.attachRefs = function(instance, element) {
40
40
  }
41
41
  };
42
42
 
43
- ReactRef.shouldUpdateRefs = function(instance, prevElement, nextElement) {
43
+ ReactRef.shouldUpdateRefs = function(prevElement, nextElement) {
44
44
  // If either the owner or a `ref` has changed, make sure the newest owner
45
45
  // has stored a reference to `this`, and the previous owner (if different)
46
46
  // has forgotten the reference to `this`. We use the element instead
@@ -16,6 +16,7 @@ var EventPluginHub = require("./EventPluginHub");
16
16
  var EventPropagators = require("./EventPropagators");
17
17
  var React = require("./React");
18
18
  var ReactElement = require("./ReactElement");
19
+ var ReactEmptyComponent = require("./ReactEmptyComponent");
19
20
  var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
20
21
  var ReactCompositeComponent = require("./ReactCompositeComponent");
21
22
  var ReactInstanceHandles = require("./ReactInstanceHandles");
@@ -64,7 +65,7 @@ var ReactTestUtils = {
64
65
  isDOMComponent: function(inst) {
65
66
  // TODO: Fix this heuristic. It's just here because composites can currently
66
67
  // pretend to be DOM components.
67
- return !!(inst && inst.getDOMNode && inst.tagName);
68
+ return !!(inst && inst.tagName && inst.getDOMNode);
68
69
  },
69
70
 
70
71
  isDOMComponentElement: function(inst) {
@@ -169,7 +170,7 @@ var ReactTestUtils = {
169
170
  var all =
170
171
  ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
171
172
  if (all.length !== 1) {
172
- throw new Error('Did not find exactly one match '+
173
+ throw new Error('Did not find exactly one match ' +
173
174
  '(found: ' + all.length + ') for class:' + className
174
175
  );
175
176
  }
@@ -322,14 +323,17 @@ var ReactShallowRenderer = function() {
322
323
  ReactShallowRenderer.prototype.getRenderOutput = function() {
323
324
  return (
324
325
  (this._instance && this._instance._renderedComponent &&
325
- this._instance._renderedComponent._currentElement)
326
+ this._instance._renderedComponent._renderedOutput)
326
327
  || null
327
328
  );
328
329
  };
329
330
 
330
331
  var NoopInternalComponent = function(element) {
331
- this._currentElement = element;
332
- }
332
+ this._renderedOutput = element;
333
+ this._currentElement = element === null || element === false ?
334
+ ReactEmptyComponent.emptyElement :
335
+ element;
336
+ };
333
337
 
334
338
  NoopInternalComponent.prototype = {
335
339
 
@@ -337,11 +341,13 @@ NoopInternalComponent.prototype = {
337
341
  },
338
342
 
339
343
  receiveComponent: function(element) {
340
- this._currentElement = element;
344
+ this._renderedOutput = element;
345
+ this._currentElement = element === null || element === false ?
346
+ ReactEmptyComponent.emptyElement :
347
+ element;
341
348
  },
342
349
 
343
350
  unmountComponent: function() {
344
-
345
351
  }
346
352
 
347
353
  };
@@ -366,6 +372,12 @@ ReactShallowRenderer.prototype.render = function(element, context) {
366
372
  ReactUpdates.ReactReconcileTransaction.release(transaction);
367
373
  };
368
374
 
375
+ ReactShallowRenderer.prototype.unmount = function() {
376
+ if (this._instance) {
377
+ this._instance.unmountComponent();
378
+ }
379
+ };
380
+
369
381
  ReactShallowRenderer.prototype._render = function(element, transaction, context) {
370
382
  if (!this._instance) {
371
383
  var rootID = ReactInstanceHandles.createReactRootID();
@@ -61,7 +61,7 @@ var invariant = require("./invariant");
61
61
  * content.
62
62
  * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
63
63
  * to preserve the `scrollTop` (an automatic scroll aware DOM).
64
- * - (Future use case): Layout calculations before and after DOM upates.
64
+ * - (Future use case): Layout calculations before and after DOM updates.
65
65
  *
66
66
  * Transactional plugin API:
67
67
  * - A module that has an `initialize` method that returns any precomputation.
@@ -6,7 +6,7 @@
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
- * @typechecks
9
+ * @typechecks static-only
10
10
  * @providesModule cloneWithProps
11
11
  */
12
12
 
@@ -24,10 +24,10 @@ var CHILDREN_PROP = keyOf({children: null});
24
24
  * Sometimes you want to change the props of a child passed to you. Usually
25
25
  * this is to add a CSS class.
26
26
  *
27
- * @param {object} child child component you'd like to clone
27
+ * @param {ReactElement} child child element you'd like to clone
28
28
  * @param {object} props props you'd like to modify. className and style will be
29
29
  * merged automatically.
30
- * @return {object} a clone of child with props merged in.
30
+ * @return {ReactElement} a clone of child with props merged in.
31
31
  */
32
32
  function cloneWithProps(child, props) {
33
33
  if ("production" !== process.env.NODE_ENV) {
@@ -33,6 +33,7 @@ function createFullPageComponent(tag) {
33
33
  var elementFactory = ReactElement.createFactory(tag);
34
34
 
35
35
  var FullPageComponent = ReactClass.createClass({
36
+ tagName: tag.toUpperCase(),
36
37
  displayName: 'ReactFullPageComponent' + tag,
37
38
 
38
39
  componentWillUnmount: function() {
package/lib/cx.js CHANGED
@@ -24,7 +24,22 @@
24
24
  * @param [string ...] Variable list of classNames in the string case.
25
25
  * @return string Renderable space-separated CSS className.
26
26
  */
27
+
28
+ 'use strict';
29
+ var warning = require("./warning");
30
+
31
+ var warned = false;
32
+
27
33
  function cx(classNames) {
34
+ if ("production" !== process.env.NODE_ENV) {
35
+ ("production" !== process.env.NODE_ENV ? warning(
36
+ warned,
37
+ 'React.addons.classSet will be deprecated in a future version. See ' +
38
+ 'http://fb.me/react-addons-classset'
39
+ ) : null);
40
+ warned = true;
41
+ }
42
+
28
43
  if (typeof classNames == 'object') {
29
44
  return Object.keys(classNames).filter(function(className) {
30
45
  return classNames[className];
@@ -11,11 +11,14 @@
11
11
  */
12
12
 
13
13
  'use strict';
14
+
15
+ var ReactCurrentOwner = require("./ReactCurrentOwner");
14
16
  var ReactInstanceMap = require("./ReactInstanceMap");
15
17
  var ReactMount = require("./ReactMount");
16
18
 
17
19
  var invariant = require("./invariant");
18
20
  var isNode = require("./isNode");
21
+ var warning = require("./warning");
19
22
 
20
23
  /**
21
24
  * Returns the DOM node rendered by this element.
@@ -24,6 +27,21 @@ var isNode = require("./isNode");
24
27
  * @return {DOMElement} The root node of this element.
25
28
  */
26
29
  function findDOMNode(componentOrElement) {
30
+ if ("production" !== process.env.NODE_ENV) {
31
+ var owner = ReactCurrentOwner.current;
32
+ if (owner !== null) {
33
+ ("production" !== process.env.NODE_ENV ? warning(
34
+ owner._warnedAboutRefsInRender,
35
+ '%s is accessing getDOMNode or findDOMNode inside its render(). ' +
36
+ 'render() should be a pure function of props and state. It should ' +
37
+ 'never access something that requires stale data from the previous ' +
38
+ 'render, such as refs. Move this logic to componentDidMount and ' +
39
+ 'componentDidUpdate instead.',
40
+ owner.getName() || 'A component'
41
+ ) : null);
42
+ owner._warnedAboutRefsInRender = true;
43
+ }
44
+ }
27
45
  if (componentOrElement == null) {
28
46
  return null;
29
47
  }
@@ -116,6 +116,7 @@ function instantiateReactComponent(node, parentCompositeType) {
116
116
 
117
117
  if ("production" !== process.env.NODE_ENV) {
118
118
  instance._isOwnerNecessary = false;
119
+ instance._warnedAboutRefsInRender = false;
119
120
  }
120
121
 
121
122
  // Internal instances should fully constructed at this point, so they should
@@ -17,6 +17,7 @@ var ReactInstanceHandles = require("./ReactInstanceHandles");
17
17
 
18
18
  var getIteratorFn = require("./getIteratorFn");
19
19
  var invariant = require("./invariant");
20
+ var warning = require("./warning");
20
21
 
21
22
  var SEPARATOR = ReactInstanceHandles.SEPARATOR;
22
23
  var SUBSEPARATOR = ':';
@@ -34,6 +35,8 @@ var userProvidedKeyEscaperLookup = {
34
35
 
35
36
  var userProvidedKeyEscapeRegex = /[=.:]/g;
36
37
 
38
+ var didWarnAboutMaps = false;
39
+
37
40
  function userProvidedKeyEscaper(match) {
38
41
  return userProvidedKeyEscaperLookup[match];
39
42
  }
@@ -158,6 +161,15 @@ function traverseAllChildrenImpl(
158
161
  );
159
162
  }
160
163
  } else {
164
+ if ("production" !== process.env.NODE_ENV) {
165
+ ("production" !== process.env.NODE_ENV ? warning(
166
+ didWarnAboutMaps,
167
+ 'Using Maps as children is not yet fully supported. It is an ' +
168
+ 'experimental feature that might be removed. Convert it to a ' +
169
+ 'sequence / iterable of keyed ReactElements instead.'
170
+ ) : null);
171
+ didWarnAboutMaps = true;
172
+ }
161
173
  // Iterator will provide entry [k,v] tuples rather than values.
162
174
  while (!(step = iterator.next()).done) {
163
175
  var entry = step.value;
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": "0.13.0-beta.2",
4
+ "version": "0.13.1",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],