Commit Graph

150 Commits

Author SHA1 Message Date
Paul O’Shannessy 95206fe5dc Make cloneWithProps typechecks static-only 2015-02-22 14:40:39 -08:00
Toru Kobayashi 60e96edce2 Fix a doc. cloneWithProps clones a ReactElement. 2015-02-20 10:08:46 +09:00
Jim bad85fafa1 Fixed mistake in jsdocs types for cloneWithProps 2015-02-19 16:38:25 -08:00
Henry Zhu eba5d1365c lint: remove spaces from array brackets 2015-02-19 00:13:36 -05:00
Henry Zhu 07cfd66028 lint: remove spaces from object braces 2015-02-19 00:10:31 -05:00
Sebastian Markbåge cf4bef8bd7 Merge pull request #3171 from sebmarkbage/moarwarnings
Moar Warnings
2015-02-17 15:09:33 -08:00
Sebastian Markbage 91194126d8 Warn if using Maps as children
We're not sure if this is the way we want to support this API. It creates
two ways of doing things.

It is convenient to avoid needing to explicitly redefine the key of Maps.
However, this use case isn't as common as having an iterable where the
key is on the value, not the key.
2015-02-17 11:23:12 -08:00
Paul O’Shannessy 68a8e4491f Merge pull request #3147 from hzoo/lint-fixes
lint whitespace , trailing comma
2015-02-17 10:58:42 -08:00
Dustan Kasten dc21dca50e s/upate/update 2015-02-14 22:09:31 -05:00
Henry Zhu 74726f0af5 remove space before round brace in function expressions 2015-02-13 23:41:53 -05:00
Henry Zhu e2a57920da lint whitespace , trailing comma 2015-02-13 23:13:47 -05:00
Sebastian Markbåge 0fdd2a74e2 Merge pull request #3030 from sebmarkbage/fragments
Make keyed object fragments an opaque type
2015-02-09 14:50:46 -08:00
Paul O’Shannessy dae1dc6292 Upgrade to newer eslint, use esprima-fb
Eslint now allows us to use a different parser, which allows us to use
esprima-fb explicitly. This means we don't have to wait for espree to add
things like rest-param parsing. Though we do need eslint to upgrade its rules
to handle that AST.

I had hoped to enable parsing of our tests but we can't do that until we
change esprima-fb's XJS nodes to JSX.

While I was here, I also enabled the no-unused-vars rule since eslint
understands template strings. I also made the single quote enforcement
actually fail instead of just warn.
2015-02-09 14:27:28 -08:00
Sebastian Markbage 56f51156ba Make keyed object fragments an opaque type
This triggers a warning if you try to pass a keyed object as a child.

You now have to wrap it in React.addons.createFragment(object) which
creates a proxy (in dev) which warns if it is accessed. The purpose of
this is to make these into opaque objects so that nobody relies on its
data structure.

After that we can turn it into a different data structure such as a
ReactFragment node or an iterable of flattened ReactElements.
2015-02-09 14:24:56 -08:00
Paul O’Shannessy 7853260788 Merge pull request #3080 from zpao/upgrade-internal-modules
Upgrade internal modules
2015-02-06 17:17:00 -08:00
Paul O’Shannessy 705353fbaf Move keyMirror to vendor to match internal move 2015-02-06 12:09:36 -08:00
Andreas Svensson 8ca058ac4e Split escapeTextForBrowser into escapeTextContentForBrowser and quoteAttributeValueForBrowser 2015-02-04 13:44:38 +01:00
Rick Beerendonk 3e0750a4ad Update copyright headers for 2015 2015-01-31 20:18:25 +01:00
Paul O’Shannessy 9801f2d8ab Merge pull request #2940 from kevinold/2749-consistent-use-of-spys-or-mocks
update to use spyOn for console.warn #2749
2015-01-27 13:38:56 -08:00
Kevin Old f0ea2b5979 update to use spyOn for console.warn #2749 2015-01-26 21:51:42 -06:00
Kevin Old e8ef06783a Update warning calls to use %s #2870 2015-01-26 21:39:43 -06:00
Paul O’Shannessy 45c0747a17 Merge pull request #2851 from jsfb/unique-key-in-dev-only
The unique key warning should only happen in dev.
2015-01-15 15:08:43 -08:00
Paul O’Shannessy e27da99731 [lint] Fix majority of issues eslint found 2015-01-13 15:26:33 -08:00
Paul O’Shannessy df2ddc5dfa [lint] convert to single quotes 2015-01-13 15:26:33 -08:00
Paul O’Shannessy df64a67b7f codemod "use strict" to 'use strict' for better linting 2015-01-13 15:26:32 -08:00
Jim 6b5b1b3f17 The unique key warning should only happen in dev. 2015-01-13 14:03:00 -08:00
Paul O’Shannessy 7863175cd9 Remove LegacyImmutableObject
We don't use it and it's not part of the build so nobody else is using
it. You should probably use immutable instead anyway.
2015-01-07 11:37:52 -08:00
Sebastian Markbåge 7354a699ff Revert "Monitoring code use of cloneWithProps" 2014-12-18 12:13:09 -08:00
Jim d42b285b0c Monitoring code use of cloneWithProps 2014-11-26 16:29:09 -08:00
Ben Alpert c96ea9abf2 Remove transferPropsTo
I'd like to outlaw prop mutation altogether, and now seems like a fine time to remove transferPropsTo.

Test Plan: jest
2014-11-16 17:41:07 -08:00
Ben Alpert 230115da92 Make ReactTextComponent properly injectable
ReactTextComponent's implementation is DOM-specific; instead of flattenChildren creating the ReactTextComponent instances, ReactNativeComponent now takes care of having ReactTextComponent injected and creating the component instance. I also renamed ReactTextComponent to ReactDOMTextComponent and moved it to browser/ui/ where it belongs. ReactDOMTextComponent no longer inherits directly from ReactComponent and instead implements construct and {mount,receive,unmount}Component directly.

This diff removes `ReactTestUtils.isTextComponent` which should have previously never returned true when using public APIs.

Test Plan: jest, use ballmer-peak example.
2014-11-15 12:30:42 -08:00
Martin Jul 042c6c794c Fix some minor typos in doc comments / code comments. 2014-11-07 18:07:07 +01:00
Paul O’Shannessy dca7ffbe21 Merge pull request #2446 from enaqx/master
Add 'use strict' to statisfy linter rules
2014-11-05 16:25:38 -08:00
Lee Byron a3608d27ab [traverseAllChildren] fix out-of-scope var use.
Dear ES6 gods, bring us `let` soon.

This fixes an issue where non-keyed iterables are used as children and the value of `i` would be undefined because its used out of scope. This adds a separately scoped iteration index value and appropriately increments it as iteration continues. Doi.

While I'm in there, make the usage of falsey `nameSoFar` more obvious and more consistent with the existing usage on L115

Test plan: first wrote a test covering this previously untested path. Saw an identical issue as was experienced in development environment. Then ensured test passed after this diff.
2014-11-03 21:19:28 -05:00
Nick Raienko bea9fbbf62 Add 'use strict' to statisfy linter rules 2014-11-01 07:05:46 +02:00
Lee Byron c07ea0ba34 Allow iterables in traverseAllChildren
This lets you use any kind of iterable as a container of react child elements. It also preserves keys when possible if the iterable is keyed.

 * Use an ES6 Map or Set to hold children.
 * Use an Immutable-js collection to hold children.
 * Use a function* which yields children.

Concretely, this removes the necessary conversion to JS objects if you're mapping over Immutable-js collections to get children, i.e.:

```
<div>
  {myImmutable.map(val => <span>{val}</span>).toJS()
</div>
```

Now we can remove the `toJS()` and the intermediate allocation along with it.

This also cleans up the traverseAllChildrenImpl method.
2014-10-21 15:18:53 -07:00
Sebastian Markbage 8210beeef4 Hide Object.assign polyfill behind a module
Because the JS community's polyfilling infrastructure sucks and we'll
have to fix it for them before we require this.

JSX spread uses React.__spread
(which might get special behavior for key/ref, not sure yet)

This never uses the native implementation and throws for prototype chains.
Once the native implementations are faster, we'll start using them.
2014-10-16 09:21:10 -07:00
Paul O’Shannessy 770b579aa2 Update PropTypes for ReactElement & ReactNode 2014-10-14 21:35:48 -07:00
Paul O’Shannessy dcf415c2b9 BSD + PATENTS 2014-10-10 13:34:07 -07:00
Paul O’Shannessy 9b1fa914fa React.renderComponent -> React.render
Also rename all the associated render methods and adds deprecation
notices.
2014-10-09 16:41:03 -07:00
Sebastian Markbage 348af57842 Drop the @jsx docblock from unit tests
This is no longer necessary in our transforms.
2014-10-08 12:46:45 -07:00
Sebastian Markbage 096360db03 Use Object.assign instead of merge, mergeInto, mixInto and copyProperties
This makes it easier to contribute without having to learn a bunch of
slightly different helpers and remember their slightly different
signatures and semantics.

We'll probably start using ES7 spread properties instead of merge in the
future when at least one more transpiler supports it.
2014-10-08 11:32:40 -07:00
Sebastian Markbage 8f1657bba6 Renamed Descriptor -> Element
We've decided on a new naming convention for ReactDescriptor. It's now
called ReactElement, which is a subset of the ReactNode union type.
2014-10-07 13:41:51 -07:00
Greg Hurrell 94eac0b8fa Fix a comment typo 2014-09-18 09:47:23 -07:00
Paul O’Shannessy 5d88ebbecb Merge pull request #2144 from zertosh/master
Comment typo
2014-09-08 19:37:00 -07:00
Paul O’Shannessy f3c64704ad Merge pull request #1988 from syranide/tacfix
Don't wrap values with ReactTextComponent in traverseAllChildren (cloneWithProps)
2014-09-08 15:36:26 -07:00
Andreas Svensson 45f8837e35 Don't wrap values with ReactTextComponent in traverseAllChildren 2014-09-08 22:35:25 +02:00
Andres Suarez 4c2f124aa8 Comment typo 2014-09-04 12:00:43 -04:00
Miorel Palii 335e91df71 Fix console warning in LegacyImmutableObject
It does check `hasOwnProperty`, but *after* accessing the field and therefore triggering enumerable getters in modified prototypes.
2014-08-29 14:32:50 -07:00
Cheng Lou b8ab95aaa7 Merge pull request #2054 from chenglou/accum
[RFC] Use `accumulateInto` to save even more allocation
2014-08-20 13:36:45 -07:00