Commit Graph

45 Commits

Author SHA1 Message Date
Paul O’Shannessy 94a3b0f8a3 Merge pull request #3552 from James-Dunn/fix-for-loops
Remove caching from for loops
2015-03-31 10:30:44 -07:00
James 90dcc1ffb7 Remove caching from for loops
Removed caching from for loops as it does not seem to increase
performance and makes the code harder to read.
2015-03-31 10:22:52 +04:00
Ben Alpert 07b7e8424d Remove stray console.log comment 2015-03-25 17:06:42 -07:00
Ben Alpert 76bb96ef21 Validate only against problematic tag nesting
Turns out lots of people write invalid HTML all the time and no one, including your browser or React, cares. Most invalid HTML combinations don't cause magic reparented nodes; only some do. The HTML5 parsing spec (https://html.spec.whatwg.org/multipage/syntax.html) specifies which tag combinations cause strange parsing behavior. I did my best to encode the logic here. It's more lenient than before in some cases, but more strict in others (before we didn't look at the whole stack of tags; now we warn with deeply nested `p` or `form` or `a` tags).
2015-03-25 16:43:41 -07:00
Ben Alpert e791fccf58 Use console.error to show stack trace in console
Better version of #3277.

Test Plan: jest, grunt test
2015-03-17 13:39:04 -07:00
cpojer ae7da3aadd foo.getDOMNode => React.findDOMNode(foo) 2015-03-10 17:17:21 -07: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 2490289c4a Warn if getDOMNode or isMounted is accessed in render
This is an anti-pattern that can be easily avoided by putting the logic
in componentDidMount and componentDidUpdate instead.

It creates a dependency on stale data inside render without enforcing
a two-pass render.
2015-02-17 11:49:20 -08:00
Henry Zhu e2a57920da lint whitespace , trailing comma 2015-02-13 23:13:47 -05:00
Matias Singers b9310a8fa5 Consistently use calls.length instead of callCount for Jasmine spies 2015-02-10 10:11:22 +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
Rick Beerendonk 3e0750a4ad Update copyright headers for 2015 2015-01-31 20:18:25 +01:00
Paul O’Shannessy e27da99731 [lint] Fix majority of issues eslint found 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
Paul O’Shannessy 4772967e29 Remove period from findDOMNode test filename 2015-01-07 15:16:31 -08:00
Jim f507ba3c2b Minor updates to findDOMNode, as per additional post-commit CR feedback. 2015-01-05 13:26:35 -08:00
Jim e0725341cf Merge pull request #2646 from jsfb/getDOMNode-becomes-findDOMNode
Added findDOMNode, as we move toward deprecating getDOMNode
2014-12-22 13:05:49 -08:00
Sebastian Markbage cea2c38733 Separate createElement and JSX tests
This essentially copies all classic element creation tests to the modern
JSX tests. The classic tests doesn't use JSX and modern tests do.

The idea is that the JSX tests can start dropping dynamic checks once
we have Flow support for those features. JSX won't be necessary for
dropping dynamic checks. Plain object will also work. Flow will also not
be necessary for JSX. However, the tests should test for the suggested
combination (JSX + Flow).

This also moves some misplaced tests to ReactDOM and Validator.

Note that the modern tests uses ES6 classes. I will add separate tests for
those. However, these are not guaranteed to have .displayName so all our
error messages should check .name if available instead. This should be
better abstracted but I just adhoc fix this for now.
2014-12-18 16:13:29 -08:00
Jim b46a6ce4bb Added findDOMNode, as we move toward deprecating getDOMNode 2014-12-18 13:55:44 -08:00
Paul O’Shannessy bd6b10887a Remove unused require from ReactDOM-test
This happened internally in a codemod
2014-12-02 14:39:19 -08:00
Sebastian Markbage 9c3e2d833d Wrap every DOM node in a Composite Component
...unless they already have a wrapper. Also, add tagName to every wrapper.

This ensures that refs are consistent. They always look like composite
components. This effectively hides the internal implementation details of
real DOM components since you can no longer get a ref to one.

In the future we might want to drop this wrapper and have refs refer
directly to the DOM node.

I currently use a hacky way of auto-wrapping inside of ReactNativeComponent
so that any given string can be wrapped. Better suggestions are welcome.
2014-11-16 10:32:46 -08:00
Sebastian Markbage 199a7d6903 Drop Legacy Factories Around Classes
Classes are now pure classes without a legacy factory around them.

Since classes will become just any function that returns a valid instance,
let's drop isValidClass.

There's some hacks in here for auto-mocking frameworks (jest) that mock the
prototype of these classes. These hacks allow these classes to be mounted.
2014-10-28 15:08:52 -07:00
Sebastian Markbage ef971014bc Deprecate isValidClass
Fixes #2374
2014-10-19 23:55:57 -07:00
Paul O’Shannessy dcf415c2b9 BSD + PATENTS 2014-10-10 13:34:07 -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 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
Sebastian Markbage 7f9b1d18d1 Start warning when React.DOM.x is passed into JSX
React.DOM is becoming helper factories to generate ReactElements. They're not
classes. It will be ok to call them directly as functions, but not to use them
where a class is expected.
2014-10-07 10:49:18 -07:00
Cheng Lou 74ff6fb6b8 Merge pull request #2039 from crm416/return-false
Deprecate 'return false' in event handlers
2014-08-27 13:33:40 -07:00
Charles Marsh eb36b57079 Use warning module 2014-08-23 09:46:32 +08:00
Sebastian Markbage 989e6b618e Drop usage of plain functions to create descriptors
Replace plain function calls to legacy factories with createFactory or
createElement. For ReactDOMComponents the type should be replaced with
strings.

Because we don't have easy access to ReactLegacyDescriptor from within
React, we need to use the .type property to extract the real class.
This will go away later and is covered by unit tests.
2014-08-20 00:14:59 -07:00
Charles Marsh 429650a750 Test for both true and false 2014-08-15 19:47:36 -04:00
Charles Marsh c5be746fda Fixed style and comment nits 2014-08-15 11:52:22 -04:00
Charles Marsh a195d3ea1f Re-add with warning and monitorCodeUse 2014-08-14 10:43:00 -04:00
Charles Marsh 45f8b52135 Deprecate 'return false' in event handlers 2014-08-13 22:37:41 -04:00
Pete Hunt e1c2d02fdd Create ReactEventListener
Per our discussion friday, this creates ReactEventListener and renames variables to use the "handle"
nomenclature.
2014-06-14 20:38:45 -07:00
Paul O'Shannessy 7a9b81ef55 remove spurios module ref
long long ago in a galaxy far away this was probably a dependency
2014-05-23 15:35:22 -07:00
Pete Hunt 5ede7fb619 ReactDOMComponent optimization
Slight optimization to not do unneeded reconciles of DOM components
2014-03-10 15:32:20 -07:00
Pete Hunt a8fc3b940d Move UI-thread-only browser modules to browser/ui/
This also deletes an unused module.
2014-03-03 15:07:11 -08:00
Ben Alpert 36e97bac21 Simulate synthetic events using ReactTestUtils
Most of the time this is what you want to do, so I've renamed what was Simulate to be SimulateNative.

Now Simulate.change does what you expect, so this fixes #517 and fixes #519.
2014-02-19 00:04:16 -08:00
Paul O’Shannessy 8a47813baa Update copyrights for 2014.
grep -rl 'Copyright 2013 Facebook' static_upstream | xargs perl -pi -w -e s/Copyright 2013 Facebook/Copyright 2013-2014 Facebook/g;'

Not going to check in a script to do this since it will just change every year.
Closes #1006
2014-02-18 17:06:43 -08:00
Ben Alpert 2f0bb69708 Prevent error thrown when removing event target
Fixes #1105.
2014-02-17 10:33:34 -08:00
Ben Newman 47ae865428 Make ReactWebWorker-test.js less flaky.
Two improvements: make sure we set `done = true` when an error message is
received, so that the test output contains the error message instead of
eventually timing out and displaying nothing useful; and increase the
timeout for this particular test from 5000ms (the default) to 20000ms.
2014-02-16 12:57:14 -05:00
Pete Hunt 73b4f954f2 DOMIDOperations -> BackendIDOperations 2014-02-05 19:47:54 -08:00
Pete Hunt 1a39c3143c The great reorg of February 2014 2014-02-04 19:49:58 -08:00