Commit Graph

22 Commits

Author SHA1 Message Date
Ben Alpert
75ff12e984 Run fiber tests just once on Travis (#8221)
Consolidate facts tracking with the other script.
2016-11-07 11:43:29 -08:00
Ben Alpert
c4b9330f2a Hide detailed failure output in scripts/fiber/record-tests (#8214)
![image](https://cloud.githubusercontent.com/assets/6820/20033841/a55fefa4-a367-11e6-99c0-44dfe38e1db7.png)
2016-11-07 11:43:02 -08:00
Ben Alpert
84c57ddc6d Fix errors in ReactNativeMount (#8223) 2016-11-07 11:42:39 -08:00
Robin Ricard
33325ad009 [Fiber] Attempt to fix ReactDOMTextComponent test in Fiber (#8146)
* Attempt to fix ReactDOMTextComponent test in Fiber

Obviously, some tests pass but the reconciliation is still incomplete on this in Fiber.

Those changes just ignore reconciliation Comments while asserting (this fixes 2 tests already) but now shows that Fiber lacks some reconciliation features.

* Transmit a parentInstance to commitTextUpdate

This is done in case a Node#normalize() was performed on the parent instance and that the TextInstance got desolidarized from the parent. We provide the parent known by the parent Fiber to reattach the DOM node in this case.

* Added a more complex case around split nodes

This test does not assume one split node substitution alone but also some non-split nodes.

* Fiber supports split text nodes

This is done by suppressing nodes appearing during the split. this is based by comparing against the old value known by the Fiber.

* Simplify siblings cleaning in commitTextUpdate

No need to assert instanceof Text since the length comparator will work correctly.

* Ensure non-text nodes won't be removed

* Fix flow for Fiber Text reconciliation additions

Mostly define types as optionals. Respects the strict DOM API around Node & Element.

* Append at any stack stage only if necessary

The direct parent of the TextNode fiber may not contain the host node. We have to go through the hierarchy. However, since this work may be expensive, we only do it if absolutely necessary!

* Use tag & ReactTypeOfWork to find an HostComponent

* Addfailing scenario when running Node.normalize()

It happens when non-text-elements are added in the mix. @sebmarkbage seems to have an idea on how to fix it. This is just a repro of the bug!

* Register failing/passing fiber tests
2016-11-07 11:39:52 -08:00
Sebastian Markbåge
95334fada0 Track if SelectEventPlugin is attached on a per document basis (#8190)
This gets rid of the global flag on if something has listened to onSelect
and instead reads the isListening map if all the events are covered.
This is required if we want to attach events locally at roots.

Could be slower perf wise to handle events. An alternative solution would
be to attach a special flag on the listener map for the document so we
don't have to check the full dependency list.

However, my favorite solution would be to just eagerly attach all event
listeners (except maybe wheel). Then we don't have to do any of this stuff
on a per element basis.
2016-11-07 11:30:34 -08:00
Ben Alpert
f705adb599 Re-record tests 2016-11-05 14:59:22 -07:00
Ben Alpert
5f49b63bde Move setState callback to right after didUpdate (#8204)
It's much easier to do it this way in Fiber and there shouldn't be much observable difference.
2016-11-05 14:37:43 -07:00
Robin Ricard
ba6b53afba [Fiber] Complete ES6 Class related errors support (#8156)
* Print a warning in fiber for lacking render method

* Reject initial non-object state in Fiber

Rejects Arrays, Strings & Numbers. Allows nulls.

* Centralize fiber checks on ES6 Classes

* Add classic & instance property checks on fiber

- check the absence of getInitialState & getDefaultProps as methods
- check the absence of propTypes & contextTypes at instance-level

* Convert to normalized React `warning` calls

* Support lifecycle typo detection in fiber

* Get the complete warnings from the existing code

* Only check classInstance once

Avoid rechecking while resuming

* Can warn component while resuming but only once

This is achieved by tracking the warning state in the Fiber structure.

* Remove warning deduplication

* Factor name retrieval in a getName helper

* Use invariant instead of throw

* Read inst.state only once for the invariant

* Fix condition on the instance state

* Register failing/passing fiber tests
2016-11-05 11:19:48 -07:00
Dan Abramov
c80f390823 Make error handling more resilient
* Ensure that errors in one root don't prevent work on another root
* Fix an issue where boundary state change would get ignored in incremental mode
2016-11-04 23:35:50 +00:00
Andrew Clark
4266f08e48 [Fiber] "Task" priority for error boundaries and batched updates (#8193)
* Refactor scheduling functions and introduce Task priority

There was lots of duplication across all the scheduling functions. I
think we're far enough along that we can start trying to clean some
stuff up.

Also introduces a new priority level provisionally called Task priority.
This is for work that completes at the end of the current tick, after
the current batch of work has been committed. It's different from
Synchronous priority, which needs to complete immediately.

A full implementation of Task priority will follow. It will replace
the current batching solution.

* Implement Task priority

Task priority is similar to Synchronous priority. Both are flushed in
the current tick. Synchronous priority is flushed immediately (e.g. sync
work triggered by setState will flush before setState exits), where as
Task is flushed after the current batch of work is committed.

Currently used for batchedUpdates and nested sync updates. Task should
also be used for componentDidUpdate/Mount and error boundary work. I'll
add this in a later commit.

* Make error boundaries use Task Priority

I have all but one error fixed. Not sure how tricky the last one is,
but I'm cautiously optimistic. Pushing to show my current progress.

* Remove recursion from handleErrors

Changed the algorithm of handleErrors a bit to ensure that boundaries
are not revisited once they are acknowledged.

* Add incremental error boundary test

Discovered an edge case: a noop error boundary will break in incremental
mode unless you explicitly schedule an update.

* Refactor error boundaries in Fiber

* Simplify trapError() calls

The existing logic was written before we had a proper error handling system.

* Remove unnecessary flags

* Prevent performTaskWork recursion

* Be stricter about preventing recursion
2016-11-04 19:40:50 +00:00
Ben Alpert
f4a42b872b Fiber: Fix reconciling after null (#8202)
Before, this code was bailing out after encoutering a null child because it thought it was out of old children. Seen when reconciling [null, <span />, <Image />] with [null, <span />, <Image />] in XUISelector.
2016-11-03 23:56:29 -07:00
Dan Abramov
857672f7e7 Update passing tests 2016-11-03 14:41:39 +00:00
Andrew Clark
29dbbc31c9 UpdateQueue fixes
- Incorrect comparison when computing hasUpdate
- isReplace should be a property of the node, not the queue
2016-11-02 23:00:00 -07:00
Dan Abramov
c894679b75 [Fiber] Schedule animation regardless of deferred work (#8187)
* Remove comments about implementation details

* Schedule animation regardless of deferred work
2016-11-02 20:46:20 +00:00
Dan Abramov
eb674e47c8 [Fiber] Add tests for scheduling inside callbacks (#8186)
* Add tests for scheduling inside callbacks

* Don't test implementation details
2016-11-02 20:11:27 +00:00
Dan Abramov
95084bedbb Fix lint by removing unneeded type import 2016-11-02 12:45:15 -07:00
Andrew Clark
c3ab541e0f New effect type: Callback
This solves the problem I had with enqueueSetState and enqueueCallback
being separate.
2016-11-02 12:40:21 -07:00
Dan Abramov
2b26ea614d Fix the build (these tests were renamed) 2016-11-02 19:28:26 +00:00
Dan Abramov
99be3781ef [Fiber] Add more tests for scheduling (#8183)
* Add more tests for scheduling

* Remove ambiguous terms
2016-11-02 17:49:22 +00:00
Sebastian Markbåge
576542d0cf Handle the radio button case completely in the asap case (#8170)
Instead of scheduling individual callbacks to asap, we schedule one and
then do all the work in that one.

I'm doing this for architectural refactoring reasons.

Nevertheless, I'm adding a contrived unit test that this fixes. :)
2016-11-01 18:54:11 -07:00
Dan Abramov
1a49b5f563 [Fiber] Fix infinite loop in scheduler and add more tests (#8172)
* Make test more complete

* Add a failing test for scheduling in reverse order

It hangs forever because we don't clear next pointer when unscheduling a root. Therefore, when it's scheduled again, it brings all its previous chain with it, potentially creating a cycle.

* Clear the next pointer when unscheduling a root

Fixes a potential infinite cycle when we reschedule a root.

* Add new tests to Fiber test tracker
2016-11-01 17:44:57 +00:00
Ben Alpert
08b4cc53b8 Track passing/failing tests in fiber (#8169)
* Work around jest toEqual bug in ReactTreeTraversal

![image](https://cloud.githubusercontent.com/assets/6820/19879640/1cd7595a-9fb2-11e6-94ac-8c38bdfc90d3.png)

* Track passing/failing tests in fiber

Run scripts/fiber/record-tests to re-record, then check git diff to see what you changed.
2016-10-31 23:26:38 -07:00