Commit Graph

2096 Commits

Author SHA1 Message Date
Mike Nordick 8da4efa899 Adding support for CSS3 Grid layout module.
grid-row and grid-column must be unitless numbers.
2015-09-10 15:56:11 -05:00
Ben Alpert 4a4174b9e8 0.14.0-rc1 2015-09-10 08:47:40 -07:00
Sebastian Markbage 031fc24dae Use a Symbol to tag every ReactElement
Fixes #3473

I tag each React element with `$$typeof: Symbol.for('react.element')`. We need
this to be able to safely distinguish these from plain objects that might have
come from user provided JSON.

The idiomatic JavaScript way of tagging an object is for it to inherent some
prototype and then use `instanceof` to test for it.

However, this has limitations since it doesn't work with value types which
require `typeof` checks. They also don't work across realms. Which is why there
are alternative tag checks like `Array.isArray` or the `toStringTag`. Another
problem is that different instances of React that might have been created not knowing about eachother. npm tends to make this kind of problem occur a lot.

Additionally, it is our hope that ReactElement will one day be specified in
terms of a "Value Type" style record instead of a plain Object.

This Value Types proposal by @nikomatsakis is currently on hold but does satisfy all these requirements:

https://github.com/nikomatsakis/typed-objects-explainer/blob/master/valuetypes.md#the-typeof-operator

Additionally, there is already a system for coordinating tags across module
systems and even realms in ES6. Namely using `Symbol.for`.

Currently these objects are not able to transfer between Workers but there is
nothing preventing that from being possible in the future. You could imagine
even `Symbol.for` working across Worker boundaries. You could also build a
system that coordinates Symbols and Value Types from server to client or through
serialized forms. That's beyond the scope of React itself, and if it was built
it seems like it would belong with the `Symbol` system. A system could override
the `Symbol.for('react.element')` to return a plain yet
cryptographically random or unique number. That would allow ReactElements to
pass through JSON without risking the XSS issue.

The fallback solution is a plain well-known number. This makes it unsafe with
regard to the XSS issue described in #3473. We could have used a much more
convoluted solution to protect against JSON specifically but that would require
some kind of significant coordination, or change the check to do a
`typeof element.$$typeof === 'function'` check which would not make it unique to
React. It seems cleaner to just use a fixed number since the protection is just
a secondary layer anyway. I'm not sure if this is the right tradeoff.

In short, if you want the XSS protection, use a proper Symbol polyfill.

Finally, the reason for calling it `$$typeof` is to avoid confusion with `.type`
and the use case is to add a tag that the `typeof` operator would refer to.
I would use `@@typeof` but that seems to deopt in JSC. I also don't use
`__typeof` because this is more than a framework private. It should really be
part of the polyfilling layer.
2015-09-09 23:19:00 -07:00
Ben Alpert a05691f0ad Merge pull request #4747 from spicyj/gh-1939
Don't crash in event handling when mixing React copies
2015-09-09 22:10:19 -07:00
Ben Alpert dc2570e1ce Merge pull request #4825 from spicyj/gh-2770
Preserve DOM node when updating empty component
2015-09-09 22:09:34 -07:00
Ben Alpert 14ede77123 Merge pull request #4827 from spicyj/occured
occured -> occurred
2015-09-09 16:29:43 -07:00
Ben Alpert 0b857a473a occured -> occurred 2015-09-09 16:19:40 -07:00
Ben Alpert db589a7175 Preserve DOM node when updating empty component
Fixes #2770.
2015-09-09 14:00:59 -07:00
Ben Alpert 999b0f9b3e Refactor empty component handling
Now doesn't use ReactCompositeComponent and `._currentElement` is actually null/false.
2015-09-09 14:00:58 -07:00
Ben Alpert b004bc5f22 Don't try to iterate over non-objects
Fixes #4776.
2015-09-09 09:03:05 -07:00
Ben Alpert a87c8555fa Merge pull request #4719 from djrodgerspryor/fix_css_transition_group_child_props
Fix transitionName prop-type on CSS transition group child

Closes #4719.
2015-09-09 08:35:44 -07:00
Ben Alpert 324bec17e3 Fix up style in #4719 2015-09-09 08:35:04 -07:00
Ben Alpert 0cce198c28 Merge pull request #4796 from spicyj/lazy-node
Fetch DOM node lazily for updates
2015-09-09 08:29:56 -07:00
Daniel Rodgers-Pryor 91555f6f9e Fix name prop-type on CSS transition group child
And share it with the parent. There's now a test for varying class names by transition-type.
2015-09-09 23:21:15 +10:00
PatrickJS ab0c84f53f Fix typo combatibility => compatibility 2015-09-09 00:47:01 -07:00
Paul O’Shannessy b2ca3349c2 Actually build react-dom file with the build 2015-09-08 22:18:44 -07:00
Ben Alpert e7ce46ff28 Don't crash in event handling when mixing React copies
Should fix #1939.

Test Plan:
With two copies of React, render a div using React1 and use that as a container to render a div with React2. Add onMouseEnter/onMouseLeave to both divs that log. Mouse around and see correct logs (as if each React was isolated), no errors.
2015-09-08 17:40:20 -07:00
Ben Alpert 27996377e0 Fetch DOM node lazily for updates
Previously, we fetched the node once for every changed attribute. In my createElement diff, I changed it to fetch the node (once) regardless of if there were changes -- fetching it once only if there are changes is even better.
2015-09-08 14:53:41 -07:00
Paul O’Shannessy 58d62989bd Move version to standalone module in preparation for reuse 2015-09-08 10:18:41 -07:00
Ben Alpert b01af40ae6 Merge pull request #4663 from spicyj/isreactclass
Require instantiable components to extend React.Component
2015-09-08 10:01:15 -07:00
Ben Alpert f3b7749c37 Require instantiable components to extend React.Component 2015-09-08 10:01:13 -07:00
Paul O’Shannessy 2fa59aa2d2 Merge pull request #4787 from Simek/patch-5
simplify valid attribute regex in DOMPropertyOperations
2015-09-04 17:42:32 -07:00
Jon Tewksbury f445dd91b0 Update docs to match standard HTML attribute support 2015-09-03 22:59:29 -07:00
Bartosz Kaszubowski f99c83ba06 simplify valid attribute regex in DOMPropertyOperations 2015-09-04 07:41:19 +02:00
Ben Alpert 9d93693b2e Update wording and style for #2065 2015-09-03 17:00:16 -07:00
Charles Marsh 270a805369 Warn when passing invalid containers to render and unmountComponentAtNode 2015-09-03 17:00:11 -07:00
Ben Alpert 4139b2e223 Merge pull request #3942 from spicyj/el-plain-obj
Make ReactElement really a plain object and freeze it
2015-09-03 15:02:56 -07:00
Ben Alpert 750338ef47 Make ReactElement really a plain object
This should guarantee that the hidden class is the same after inlining.
2015-09-03 14:58:52 -07:00
Jon Tewksbury a4bd998edc Update console messages regarding devtools 2015-09-03 14:16:26 -07:00
Ben Alpert 697c09a26e Merge pull request #4759 from spicyj/devprod
Fix diverging behavior of ReactFragment in `__DEV__`
2015-09-01 17:35:14 -07:00
Ben Alpert c04d02e5e8 Add warnings to React module 2015-09-01 14:36:41 -07:00
Ben Alpert b1e16b9d7e React -> ReactDOM in test files 2015-09-01 14:34:37 -07:00
Ben Alpert 31cb102650 Merge pull request #4762 from spicyj/ts
Make TypeScript test work with ReactDOM
2015-09-01 14:30:56 -07:00
Ben Alpert 589c8364b0 Make TypeScript test work with ReactDOM 2015-09-01 14:28:12 -07:00
Ben Alpert 7e5ce19a94 Fix diverging behavior of ReactFragment in __DEV__
We could also remove the return statements but this is not a hot path and this seems safer.
2015-09-01 13:27:17 -07:00
Paul O’Shannessy 7645c07720 Use eslintrc from fbjs 2015-08-31 23:05:04 -07:00
Michelle Todd 719fe15b9e Update warning messages to use ReactDOM and ReactDOMServer as appropriate
Fixes #4710.

- `React.findDOMNode` => `ReactDOM.findDOMNode`
- `React.render` => `ReactDOM.render` or "top-level render" (depends on whether we're in DOM-specific usage or generic cases)
- `React.renderToString` => `ReactDOMServer.renderToString`
- `React.renderToStaticMarkup` => `ReactDOMServer.renderToStaticMarkup`
2015-08-31 22:55:27 -07:00
Ben Alpert 487cc586f7 Merge pull request #4731 from spicyj/map-one-pass
Make React.Children.map do one pass only
2015-08-31 18:52:51 -07:00
Ben Alpert 6013105a9c Make React.Children.map do one pass only
Changed: createFragment no longer includes nulls in its output (since toArray doesn't and they share code).

Changed: React.Children.map no longer warns for clashing keys; traverseAllChildren will later when rendering.

Also change the generated key format around to accomodate. My keys are probably not bulletproof but should definitely be safe against accidental collisions.
2015-08-31 18:47:09 -07:00
Ben Alpert dc4f011f57 Merge pull request #4735 from spicyj/shallow-error
Better error for invalid element when shallow rendering
2015-08-31 13:30:56 -07:00
Ben Alpert 42602a8922 Fix code style/grammar on synthetic event warning 2015-08-31 11:32:12 -07:00
Jim 0ff65cc892 Merge pull request #4635 from edvinerikson/event-pooling-warning
Added warning when calling methods on a released event.
2015-08-31 10:49:01 -07:00
Olivier Tassinari 0304051591 [adler32] fix wrong name 2015-08-29 19:07:36 +01:00
Ben Alpert f4d7feb8be Better error for invalid element when shallow rendering
Fixes #4721, fixes #4730.
2015-08-28 18:21:30 -07:00
Ben Alpert a7230de902 Merge pull request #4727 from spicyj/gh-4233
Make findDOMNode error clearer
2015-08-28 12:52:18 -07:00
Paul O’Shannessy 2e5b047f04 Reverse condition of a ternary for readability 2015-08-28 11:34:50 -07:00
Ben Alpert 024f71535c Merge pull request #4720 from spicyj/destructor
Add destructors to pooled classes in ReactChildren
2015-08-27 19:06:11 -07:00
Ben Alpert 16d8f20576 Add destructors to pooled classes in ReactChildren
And make destructors mandatory so we're less likely to forget again.
2015-08-27 19:05:56 -07:00
Niole Nelson 70c07c67b7 resolves issue #4168, style prop error now names React class that erroring element is a child of. 2015-08-27 18:10:51 -07:00
Ben Alpert 72d5b8f116 Merge pull request #4700 from spicyj/frag-array
Make createFragment return an array, disallow objects as children
2015-08-26 11:12:06 -07:00