Commit Graph

2084 Commits

Author SHA1 Message Date
Sebastian Markbåge 7d2be2c9a7 Merge pull request #8400 from sebmarkbage/fibercontainerchildren
[Fiber] Update root children using appendChild/insertBefore/removeChild
2016-11-23 18:09:50 -08:00
Ben Alpert 8791325db0 Finish ReactGenericBatching (#8405) 2016-11-23 17:40:20 -08:00
Sebastian Markbage 78add2dc63 Update root children using the appendChild/insertBefore/removeChild methods
This removes updateContainer and instead uses the regular child mutation
methods to insert into the root container and portals.

Since we're no longer clearing out the container DOM in updateContainer
we have to do that manually during initial mount. This now works on a
document and one of the tests end up unmounting the body when you render
into the document so I had to work around that bit since we don't yet
properly support rendering into the document root.
2016-11-23 17:38:35 -08:00
Ben Alpert af659a2544 Re-record 2016-11-23 15:22:35 -08:00
Ben Alpert 0c885af183 Restore DOM selection and suppress events (#8353)
This makes Draft mostly work.
2016-11-23 13:43:00 -08:00
Ben Alpert 7ac2044bce Fix queueing updates in cWM/cWRP when batching (#8398)
I tried to add a temporary check for the correct state in https://gist.github.com/spicyj/338147e989215b6eeaf48a6ce2d68d93 and run our test suites over it, but none of our existing test cases would have triggered that invariant. The new one I added does.
2016-11-23 13:00:49 -08:00
Sebastian Markbåge 7ef856aa36 Change the behavior to always fail childContextTypes if there is a method (#8391)
Even if that method returns falsy values.
2016-11-23 10:59:49 -08:00
Sebastian Markbage d71bd59a4e Passing disabled events 2016-11-22 16:16:47 -08:00
Sebastian Markbage 475a6492c7 Utilize the backtracking during events to figure out if a Fiber was unmounted
We're walking backwards up to the root to find the parent so that we can
propagate events further up to nested React parents. If we don't find a
root, that means that the tree was unmounted and we shouldn't send any
events to it.
2016-11-22 16:16:47 -08:00
Sebastian Markbage a481016883 Preserve the original object when using replaceState
When we use only replace state we don't need to clone the object.
2016-11-22 16:16:46 -08:00
Sebastian Markbage a489e3f057 Disable one irrelevant test for Fiber
We don't use transaction objects.
2016-11-22 16:16:46 -08:00
Sebastian Markbage 826e90f5a0 Don't test for comments in empty components for Fiber
Fiber doesn't use comments in empty components.
2016-11-22 16:16:46 -08:00
Sebastian Markbage 7dd8fc549e Implement the same search strategy in ReactTestUtils as findDOMNode
This was supposed to fix an issue in refs-test but instead it revealed that
this strategy is broken.

The problem is that Placement effect is not sufficient when the insertion
is completed since the effect flag is reset then and the previous tree
has no effects in it to indicate that this is the wrong tree.
2016-11-22 16:16:46 -08:00
Sebastian Markbage be2ec3d5b8 Fix findDOMNode for empty children
If there is no child there is nothing to tell us that this was the
workInProgress branch. Therefore, we need to look at the other branch
if there are children in it to see if *that* was the workInProgress branch.
2016-11-22 16:16:46 -08:00
Sebastian Markbage 977357765b Drop "previous style" copy from Stack to bring it inline with Fiber
We've already been warning for mutating styles so now we'll freeze them
in DEV instead. This isn't as good because we don't have more specific
warnings than the generic error that doesn't even fire in sloppy mode.

This lets Fiber pass the same tests.
2016-11-22 16:16:46 -08:00
Sebastian Markbage 9ceed8d69b Track inputs after setting its properties
This used to be done at the end of the transaction but I made it synchronous.

For this to work it needs to be applied after we have already set the .type
property since it is read by inputValueTracker.
2016-11-22 16:16:45 -08:00
Sebastian Markbage 075f3043a7 Update the internal Fiber on the DOM node to always be the current
We need this to safely extract the current event listeners from the props.
Unfortunately, we are still not safe to use the return pointer since it
may not point to the current tree when the Fiber is reused. So this is not
fully done yet.
2016-11-22 16:16:45 -08:00
Sebastian Markbage 7149a26eba Allow EventListener to traverse up the tree until it hits the root
We use this to find the root node so that we can look for outer React
subtrees if this is nested.
2016-11-22 16:16:45 -08:00
Sebastian Markbåge f38c355cba [Fiber] Make server rendering tests pass (#8372)
* Use the public ReactDOMServer in tests

We need this because it runs the injection.

* Let Fiber skip react data attributes and comments in SSR tests

This markup is testing implementation details rather than behavior.
2016-11-22 16:03:50 -08:00
Ben Alpert c7129ce1f0 Stopgap fix for element disabling (#8387)
Fix for #8308. This is a bad hack -- EventPluginHub.getListener isn't even DOM-specific -- but this works for now and lets us release 15.4.1.
2016-11-22 14:39:30 -08:00
Dan Abramov 6434c37649 [Fiber] Add ReactDOMFiber.unstable_createPortal() (#8386)
* [Fiber] Add ReactDOMFiber.unstable_createPortal()

While #8368 added a version of `ReactDOM.unstable_renderSubtreeIntoContainer()` to Fiber, it is a bit hacky and, more importantly, incompatible with Fiber goals. Since it encourages performing portal work in lifecycles, it stretches the commit phase and prevents slicing that work, potentially negating Fiber benefits.

This PR adds a first version of a declarative API meant to replace `ReactDOM.unstable_renderSubtreeIntoContainer()`. The API is a declarative way to render subtrees into DOM node containers.

* Remove hacks related to output field
2016-11-22 22:08:13 +00:00
Ben Alpert cb6da8e922 Fiber: renderSubtreeIntoContainer (#8368) 2016-11-22 09:57:13 -08:00
Ben Alpert 3438d503db Make findDOMNode generic (#8348) 2016-11-21 17:13:26 +00:00
Evan Scott 77c890dfa2 Update all Jest packages to 17.x (#8327)
* Update all Jest packages to 17.x, cache babel-jest transforms

* Remove the caching

Looking at the other builds it doesn't seem to actually be that necessary.  The bottleneck is executors, not build time.

* Remove unnecessary package, fix fiber test runner

* Regenerate yarn lockfile
2016-11-20 16:10:08 +00:00
Tom Occhino dfdff2b61a Move all dev *Hook tests and ComponentTreeTestUtils to expectDev (#8350) 2016-11-18 18:53:48 +00:00
Sebastian Markbåge 0deb71223d Fix ReactDOMFiberSelect to set the initial values (#8349)
I forgot that the normal properties route doesn't do this. We also have
to make sure that the order is 1) insert children (options), 2) set
multiple 3) update the options.
2016-11-18 18:52:15 +00:00
Sebastian Markbage c1daa6f2c1 Record tests and fix BrowserEventEmitter test to not crash jest 2016-11-18 18:08:40 +00:00
Sebastian Markbage a2ca759dfd Handle controlled components in Fiber
We need to adjust inputValueTracking a bit to handle the fact that
Fiber attaches wrapper state on nodes.
2016-11-18 17:59:36 +00:00
Sebastian Markbage 836331ba5f Wire up ReactDOMFiberComponent in ReactDOMFiber
We'll need to do the DOM injection now.
2016-11-18 12:01:22 +00:00
Tom Occhino 32f5b034ed Upgrade ESLint and dependencies, fix new lint errors, switch Travis to Yarn (#8309)
* Update ESLint to 3.10.2

Also pull in fbjs for extending properly, per @zpao. This also disables consistent-return, which has about 80 failing cases in React currently. If we'd like to turn this back on, we should do it separately and fix all the call sites properly (rather than just adding 'return undefined;' everywhere, which adds no value.

Fixes to all existing lint errors plus an update for yarn.lock to follow.

* Update yarn.lock after the eslint update.

* Fix all new eslint failures

Unfortunately I had to add three eslint-disable-next-line instances. All have explanations inline.

* Switch Travis to use yarn instead of npm
2016-11-17 22:16:44 +00:00
Ben Alpert 8ecb248e6d Make numerical refs work in Fiber (#8334) 2016-11-17 18:56:33 +00:00
Sebastian Markbage 4e2688db4a Extract event listener from memoizedProps on Fiber instances
This makes some basic events work with Fiber.

This is however not a complete solution since we may be reading the wrong
Fiber.
2016-11-16 15:56:13 +00:00
Sebastian Markbage b3af02a3cd Add Fibers to ReactTreeTraversal
This traverses parent based on the type of internal instance it is passed.
If it is a Fiber it may have to traverse multiple steps until it finds a
HostComponent.

This will allow us to use the event system with Fiber.
2016-11-16 15:43:55 +00:00
Sebastian Markbage 57cc182f26 Add Fibers to ReactDOMComponentTree
This adds precaching to ReactDOMFiber. I.e. adding a handle from the DOM
node to the internal Fiber. This means that we need to expose an internal
handle to the reconciler.

We use duck typing to figure out if it is a Fiber or Stack instance.

The new failing tests are failing because this is now able to actually
fire events onto Fibers and then the result of those events are
incorrect where as they were ignored before.
2016-11-16 15:42:39 +00:00
Sebastian Markbåge dde670fd36 Reapply Check for event listener in props instead of bank (#8292)
* Reapply Check for event listener in props instead of bank (#8192)

This reverts the previous revert.

* Don't throw on falsy event listeners

Some code relies on passing null. This restores the earlier behavior.
2016-11-15 18:16:27 +01:00
Dan Abramov 2397f1fce6 Use empty object if context does not exist
This matches Stack behavior.
Had to rewrite a test that used Simulate because Fiber doesn't support events yet.
Also changed tests for componentDidUpdate() since Fiber intentionally doesn't pass prevContext argument.
2016-11-15 16:35:00 +00:00
Dan Abramov fd8c8038f0 Update passing tests 2016-11-15 14:49:54 +00:00
Dan Abramov eedca6f641 Disable memoized props bailout when context might have changed 2016-11-14 18:24:32 +00:00
Dan Abramov f9e1bc9c97 Move context management into scheduler
It is error-prone to push and pop context in begin or complete phases because of all the bailouts. Scheduler has enough knowledge to see if pushing is necessary because it knows when we go inside or outside the tree.
2016-11-14 13:32:09 +00:00
Dan Abramov b8cca3711e Update passing tests 2016-11-14 13:32:09 +00:00
Dan Abramov 9a42f8a0c5 Update passing tests 2016-11-14 13:22:47 +00:00
Ben Alpert 64cba04bf9 Build infra for tracking dev-specific failures (#8228)
I'll plan to change all of our console.error and component-tree expects to expectDev. It's a little annoying that we need to make sure tests don't throw (see my change to normalizeCodeLocInfo) but any alternative would seem to require two separate test runs or a much more cumbersome syntax.
2016-11-13 14:00:07 -08:00
Ankeet Maini 077822e9d0 Handles risky callbacks on setState. Fixes #8238 (#8242)
* Handles risky callbacks on setState. Fixes #8238

* Updates try-catch to cover `callback` when context is not present.

* Updates code to trapErrors instead of swallowing them.

* Fixes flow errors

* Incorporates review comments

* Traps only the first error.

Removes `callbackWasCalled` and updates fiber tests.
2016-11-12 12:51:36 -08:00
Sebastian Markbåge 4804518c26 Handle nested controlled events (#8251)
I came up with a contrived case of where nested controlled events could
fire within the same batch - but on different targets.

I think we came to the conclusion that controlled values typically cannot
use preventDefault so it is ok that they don't flush until after the event
has finished. So therefore we accumulate a queue of all the nested targets
within a batch and then restore state on all of them.

I'm still skeptical that this is the correct way to do controlled values.
The reason we have to do them in a single event loop is because when you
type, the sequence of values that get accepted or not can matter. I wonder
if there is a scenario we can come up with where you can fire multiple
inner events in an event loop and end up with batching causing problems.

This effectively just reimplements asap again but with no allocations for
a single target and no closure allocations.
2016-11-11 16:49:59 +00:00
Brandon Dail e43aaab254 Use _hostContainerInfo to track test renderer options (#8261)
* Use _hostContainerInfo to track test renderer options

The transaction is not available when unmounting or updating the
instance, so we track it using _hostContainerInfo

* Throw if hostContainerInfo is not populated in getPublicInstance

* Linting fixes

* Remove transaction from ref lifecycle code path

We don't need to pass the transaction around anymore since we store the
test options on _hostContainerInfo instead

* Remove unused argument
2016-11-11 14:35:18 +00:00
Dan Abramov da021ca4ae Use ReactDOM.unstable_batchedUpdates in Fiber tests (#8263) 2016-11-10 21:28:49 +00:00
Dan Abramov a9fa135fd8 [Fiber] Fix reactComponentExpect (#8258) (#8257)
* Add more reactComponentExpect tests

* Implement reactComponentExpect in Fiber
2016-11-10 21:27:07 +00:00
Dan Abramov 3e2680411e [Fiber] Fix reactComponentExpect (#8258)
* Add more reactComponentExpect tests

* Implement reactComponentExpect in Fiber
2016-11-10 21:19:57 +00:00
Toru Kobayashi d0a8d8b951 [Fiber]Warn when shoulcComponentUpdate returns undefined (#8243)
* [Fiber]Warn when shoulcComponentUpdate returns undefined

* Remove unnecessary fallback
2016-11-09 16:30:41 +00:00
Sebastian Markbåge 84b8bbdfc9 Fixed batching reentrant controlled events (#8240)
If a controlled target fires within another controlled event, we should not
restore it until we've fully completed the event. Otherwise, if someone
reads from it afterwards, they'll get the restored value.

Not super happy with this particular solution.
2016-11-08 17:42:53 -08:00