Commit Graph

98 Commits

Author SHA1 Message Date
Leland Richardson f938299765 [fix] key/ref warnings incorrectly throw on DOM Elements 2016-03-08 18:51:06 -08:00
Max 32b0c62214 Copy and paste no-jsx note from top of file to places where it's used
Closes #6157
2016-03-01 20:06:20 +01:00
chico 03925f4f06 Using Object.is implementation when compare values inside React.PropTypes.oneOf 2016-02-29 18:46:19 +03:00
Ben Alpert 74070e5838 Merge pull request #6082 from spicyj/nq-set-props
Remove unused enqueueSetProps methods
2016-02-26 00:39:48 -08:00
Ben Alpert cf4255445e Remove unused enqueueSetProps methods 2016-02-21 14:30:23 -08:00
Jim 70b5eda83e Merge pull request #5997 from truongduy134/clone-element
Fix #5929. Resolve to default props when config key is set to undefined in cloneElement
2016-02-19 14:53:38 -08:00
Jim 3bee2d962a Merge pull request #5744 from prometheansacrifice/warn-if-user-accesses-key-ref-props
Warns on access of `props.key` and `props.ref`
2016-02-16 10:11:28 -08:00
Manas c3980a6d08 Warns on access of `props.key` and `props.ref` 2016-02-16 22:04:32 +05:30
Nguyen Truong Duy 48ded230fc Resolve default prop values in cloneElement
In cloneElement, when key in input config is set to undefined, the associated
prop value should be resolved to default prop values
2016-02-09 09:02:07 +07:00
karczk ef2b1f26ef Unnecessary type comparisons have been changed to value comparison 2016-02-02 19:35:58 +01:00
krystian.karczewski 8c7d743361 Fix for #5957: Bug on resolving default props (HTMLAllCollection) 2016-02-02 11:51:31 +01:00
jim e8af100849 Removed getDOMNode from react classes. 2016-01-11 23:32:22 -08:00
Rick Beerendonk bef45b0b1a Year-agnostic copyright message, like React Native uses, to prevent the need for yearly changes. 2015-12-29 20:20:32 +01:00
James Wen 6ff96441da Clarify React class constructor comments
- The constructor is not always overridden by mocks. Makes viewing this constructor during debugging less confusing.
2015-12-23 12:58:18 -05:00
Oliver Zeigermann 20e5a95fe3 fixed docs on ReactElement that were out of sync with code 2015-12-16 11:26:32 +01:00
jpersson 13080f99ba Rephrase comment to better describe use of `warning()` 2015-12-14 23:27:37 -05:00
Ben Alpert 3997164418 Merge pull request #5550 from spicyj/cc-speed
Make createClass 10-15% faster on complex specs
2015-12-14 14:45:44 -08:00
Justas Brazauskas 0886273438 Fix few typos in React docs and comments 2015-12-13 16:39:07 +02:00
Ben Alpert 46f5251c66 Remove @typechecks
These don't really do anything.

```
codemod.py -d src --extensions js -m '\s* \* @typechecks.*?\n' '\n'
```

with "yes to all".
2015-12-10 11:26:45 -08:00
jim fbf81a8435 Remove setProps and replaceProps. 2015-11-30 11:46:07 -08:00
Ben Alpert 50c81d5fe6 Make createClass 10-15% faster on complex specs 2015-11-25 18:24:46 -08:00
Paul O’Shannessy 8104262043 Merge pull request #5390 from chicoxyzzy/arrayof-objectof-tests
Add validation for arrayOf and objectOf in ReactPropTypes
2015-11-11 16:48:33 -08:00
chico a86d25d584 update error messages 2015-11-05 06:12:27 +03:00
chico 8987522a2a remove eslint-disable when possible and update eslint version 2015-11-05 05:11:39 +03:00
chico 7ae67916cc Adding validation for arrayOf and objectOf in ReactPropTypes 2015-11-05 00:20:33 +03:00
cpojer ac17bdaaba Remove `generateFromMetadata` and `getMetadata` usage. 2015-10-29 15:45:30 -07:00
cpojer 2ecfc4f8fb Codemod old APIs away. 2015-10-29 12:40:52 -07:00
Timothy Yung cdaea311a3 Remove "Invariant Violation: " from Invariant Error Messages 2015-10-16 16:09:28 -07:00
Vipul A M b4a6bc89c2 - Added tests to compare testing of components using different types of element creation
Fixes [#2576]

- Fixed Lint warnings and errors
2015-10-12 16:44:00 -04:00
Matias Singers f8f2be05ce Consistently use `calls[n].args[n]` instead of `argsForCall[n][n]` for Jasmine spies 2015-10-12 22:39:19 +08:00
Ben Alpert 2253405dcc Merge pull request #5085 from spicyj/cdp
Extract defineProperty feature testing to one file
2015-10-08 11:33:07 -07:00
Ben Alpert 3fb2d3f5d4 Extract defineProperty feature testing to one file
This makes it slightly more bearable to debug in IE8 with an exception breakpoint. Also the old way was just silly and could mask other bugs.
2015-10-07 18:33:13 -07:00
Ben Alpert a7189c57fc Merge pull request #5057 from camsong/patch-1
Text fix in ReactClass.js
2015-10-07 17:19:19 -07:00
Cam Song 9af15d3ecd Text fix in ReactClass.js
Rename 'component class' to 'function' as it should be.
2015-10-08 08:13:27 +08:00
Jim d0970ee8b8 Merge pull request #5063 from facebook/revert-5062-revert-4959-no-shams
Remove dependence on ES5 shams per #4189
2015-10-07 14:23:35 -07:00
Cam Song a69f05c881 Always use ANONYMOUS const in ReactPropTypes.js 2015-10-07 11:28:38 +08:00
Jim fc043bb3a5 Revert "Revert "Remove dependence on ES5 shams per #4189"" 2015-10-06 14:31:20 -07:00
Jim 571edd85c2 Revert "Remove dependence on ES5 shams per #4189" 2015-10-06 14:30:03 -07:00
David Greenspan f95747b929 Remove dependence on ES5 shams per #4189
Docs not updated
2015-10-06 13:49:47 -07:00
Ben Alpert 94ccda8543 Merge pull request #5041 from spicyj/val-key-err
Don't blow up in key warning for undefined type
2015-10-05 13:57:25 -07:00
Ben Alpert 1959aaa1f9 Don't blow up in key warning for undefined type 2015-10-02 11:31:28 -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
Greg Perkins c9320142ec Rename TYPE_SYMBOL to REACT_ELEMENT_TYPE
See D2454031 for context.
2015-09-28 14:11: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
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
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 b004bc5f22 Don't try to iterate over non-objects
Fixes #4776.
2015-09-09 09:03:05 -07:00
Ben Alpert f3b7749c37 Require instantiable components to extend React.Component 2015-09-08 10:01:13 -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