Commit Graph

2138 Commits

Author SHA1 Message Date
Ben Alpert 2a51d1bf93 Merge pull request #5016 from spicyj/tu-stateless
Make scry* look through stateless components
2015-10-01 14:13:32 -07:00
Sebastian Markbage 83644185f4 isReactClass -> .prototype.isReactComponent
Put the flag on the prototype instead to help certain limited forms
of class extensions that doesn't properly transfer static properties.

Fixes #4836
2015-09-30 18:28:49 -07:00
Ben Alpert 29fbbe7263 Merge pull request #5017 from spicyj/gh-5005
Fix dev/prod mismatch in context === bailout
2015-09-30 17:05:25 -07:00
Ben Alpert 2b63601472 Don't throw for onClick={false} in initial render
I accidentally regressed this in #3246. Now this matches what we already checked for updates.
2015-09-30 16:53:47 -07:00
Ben Alpert cf86cd8ebf Fix dev/prod mismatch in context === bailout
Fixes #5005.
2015-09-30 16:47:40 -07:00
Ben Alpert 7bd51659d6 Make scry* look through stateless components
Fixes #4882.
2015-09-30 16:00:21 -07:00
Ben Alpert 5a4b92d8c5 Merge pull request #5003 from spicyj/gh-4996
Improve warning for old element objects
2015-09-29 22:52:08 -07:00
Ben Alpert 35f731b012 Merge pull request #5002 from spicyj/check-no-warn-jest
Fail jest tests on any un-spied warnings
2015-09-29 22:51:47 -07:00
Ben Alpert d561949711 Improve warning for old element objects
Fixes #4996.
2015-09-29 18:02:47 -07:00
Ben Alpert b8c7b13042 Fail jest tests on any un-spied warnings
Originally #4223 -- we lost this when we switched to jest.
2015-09-29 17:35:39 -07:00
Greg Perkins c9320142ec Rename TYPE_SYMBOL to REACT_ELEMENT_TYPE
See D2454031 for context.
2015-09-28 14:11:40 -07:00
Ben Alpert c512603a8c Merge pull request #4987 from spicyj/perf
Add unit test to ensure DOM mutations are instrumented
2015-09-28 11:48:18 -07:00
Paul O’Shannessy e9c571acc6 Make ReactTestUtils.scryRenderedComponentWithClass find multiple classes 2015-09-28 10:06:54 -07:00
Ben Alpert 7938650ca9 Make new perf unit test pass 2015-09-27 14:26:26 -07:00
Ben Alpert 47de0a8ce6 Add unit test to ensure DOM mutations are instrumented 2015-09-27 14:26:01 -07:00
Ben Alpert 6e62a010dd Actually don't store <input> until mount-ready
So #4976 was a lie. Fixes #4870 for real (thanks @STRML).
2015-09-25 13:39:05 -07:00
Ben Alpert b82f3ab55d Merge pull request #4976 from spicyj/gh-4870
Don't store <input> instance until mount-ready
2015-09-25 13:30:01 -07:00
Ben Alpert c04d10f033 Don't store <input> instance until mount-ready
Fixes #4870.

This more or less matches what we were doing with the old wrapper components (not storing until componentDidMount).
2015-09-25 13:20:40 -07:00
Ben Alpert e352475ddc Don't blow up on missing _store in element validation
Seems better to fail gracefully, especially now that we support inlining. If people do this by accident we can figure out how to add a helpful warning instead.

Fixes #3285.
2015-09-25 13:09:03 -07:00
Paul O’Shannessy 7037ef9d8b [lint] Update and fix 2015-09-25 12:32:51 -07:00
Sebastian Markbåge 8854a31e31 Merge pull request #4942 from darobin/rdfa-attributes
Add RDFa attributes not already covered (fixes #3459)
2015-09-25 09:32:40 -07:00
Paul O’Shannessy 8857e12c9e Use main document for getTestDocument
This should be fine in a jest environment, which is all we really care about now.
2015-09-23 13:46:41 -07:00
Ben Alpert ab03f34965 Merge pull request #4951 from spicyj/gh-4840
Improve traverseAllChildren object error message
2015-09-23 12:17:35 -07:00
Ben Alpert 1922db1711 Improve traverseAllChildren object error message
Fixes #4840.
2015-09-23 12:17:20 -07:00
Paul O’Shannessy 33e44f041b Merge pull request #4944 from zpao/rm-event-path
Remove SyntheticEvent.path
2015-09-23 10:03:19 -07:00
Ben Alpert 7398606ccf Merge pull request #4683 from JaeHunRo/master
temporarily fixes printWasted abnormality
2015-09-23 00:34:51 -07:00
Paul O’Shannessy 96b3ef54bf Merge pull request #4935 from saifelse/fix-firefox-dom-sel
Fix ReactDOMSelection to avoid erroring on Firefox's anonymous divs
2015-09-22 17:57:24 -07:00
JaeHunRo 6244a985c4 updates printWasted 2015-09-23 01:46:31 +01:00
Ben Alpert b06be9bc2d Merge pull request #4946 from spicyj/nan
Improve error for style mutation
2015-09-22 16:34:05 -07:00
Ben Alpert 9faf1f3969 Improve error for style mutation
Fixes #4877. I opted not to change shallowEqual for this since it seems relatively one-off.
2015-09-22 16:29:40 -07:00
Ben Alpert 57c516cb0e Don't use magic browser event dispatching for simulated events
When calling ReactTestUtils.Simulate, sometimes you want to test that an exception is thrown by the event handler. This lets you do that without relying on the fact that old jsdom doesn't implement `Event`.
2015-09-22 15:31:08 -07:00
Saif Hakim 0267cfbb8f Fix ReactDOMSelection to avoid erroring on Firefox's anonymous divs 2015-09-22 15:28:33 -07:00
Paul O’Shannessy 8a837cbd3f Remove SyntheticEvent.path 2015-09-22 15:12:19 -07:00
Robin Berjon fd682b5cac add RDFa attributes not already covered 2015-09-22 16:58:48 -04:00
Ben Alpert c561324e7e Merge pull request #4903 from spicyj/event-unmounted
Just ignore events on unmounted components
2015-09-22 09:54:04 -07:00
Ben Alpert 45f85a6cc5 Just ignore events on unmounted components
Fixes #4865 and also seems to fixes #3790.
2015-09-17 17:42:01 -07:00
Ignacio Carbajo e11631eea7 Fix documentation errata 2015-09-16 22:25:46 +02:00
Paul O’Shannessy f9bbc06960 Merge pull request #4858 from zpao/eslint-1.4
Upgrade eslint to 1.4.1
2015-09-16 12:35:12 -07:00
Paul O’Shannessy 20f0b0f464 Upgrade eslint to 1.4.1 2015-09-16 12:16:46 -07:00
Paul O’Shannessy 0fb49fc4dc Merge pull request #4859 from zpao/stateless-arrow-functions
Support native arrow functions as stateless components
2015-09-16 12:02:38 -07:00
Paul O’Shannessy e5c3fb14fa Support arrow functions as stateless components 2015-09-16 11:39:41 -07:00
Ben Alpert 65370ff752 Check input and textarea propTypes only in DEV 2015-09-15 21:46:37 -07:00
Paul O’Shannessy d54fa9e563 Better simulate Symbol-less environment
This ensures that our tests expecting Symbol not to exist pass.
2015-09-13 13:15:26 -07: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