Commit Graph

3269 Commits

Author SHA1 Message Date
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 e06b335588 Add some Flow types to inputValueTracking
Not perfect but better.
2016-11-18 17:59:37 +00:00
Sebastian Markbage 9b6738805a Exclude data-reactroot from tests when using Fiber 2016-11-18 17:59:36 +00:00
Sebastian Markbage 6e04bd758e Apply @spicyj's SelectEventPlugin fix
This fixes some tests with Fiber since we no longer rely on Stack
internals for this.
2016-11-18 17:59:36 +00:00
Sebastian Markbage 632ae806e8 Give wrappers the raw props object
Wrappers operate on the raw props object instead of the processed one.

We should probably clean this up a bit since it is very confusing and
unnecessary allocations to have two separate objects for props.
2016-11-18 17:59:36 +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 cd0f963fa3 Fix up Flow annotations to be a bit more explicit where the unsoundness is 2016-11-18 17:59:36 +00:00
Sebastian Markbage 7246659f4d Consistent method vs function 2016-11-18 12:20:25 +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
Sebastian Markbage 61a1a50955 Split mountComponent into create and set initial properties
This lets us insert children in between these two steps.
2016-11-18 00:26:26 +00:00
Sebastian Markbage 4b017507e2 Don't pass the Fiber around instead use the DOM node
To avoid exposing the implementation details of fibers we'll just pass the
DOM node around instead. We'll attach any additional wrapper state on it.
We don't have to do it that way. We can also just invert the relationship
and put the node in the wrapper state.

I'll probably just get rid of the wrapper object and just put them as
expandos on the DOM.
2016-11-18 00:26:26 +00:00
Sebastian Markbage e962e97f75 Satisfy Flow by assuming value is an array for multi-select 2016-11-18 00:26:26 +00:00
Sebastian Markbage 6dc04b73a7 Assert that this is a script tag
Also, use a fixed string for the HTML since this is always a script tag.
2016-11-18 00:26:26 +00:00
Sebastian Markbage e58b050773 Pass the tag explicitly instead of reading it from the internal instance 2016-11-18 00:26:26 +00:00
Sebastian Markbage 2defc83f34 Stop using host parent/container internal objects
Instead we extract the namespace from the root element.
2016-11-18 00:26:26 +00:00
Sebastian Markbage d2888a7dea Get rid of server side support for <option />
We read the wrapper state during initial mount for server rendering support
but Fiber doesn't use it and we don't need it. We also can't because we
haven't yet completed the parent that has the selected.

I will need to remember to always insert children before setting the
selected value on the parent <select />. That way the DOM will deal with
the `selected` property of option properly.
2016-11-18 00:26:26 +00:00
Sebastian Markbage 2ef2a8e6f5 Pass props explicitly instead of getting them off currentElement
We don't store currentElement and I'm trying to get rid of accessing the
Fiber directly inside the host config.
2016-11-18 00:26:25 +00:00
Sebastian Markbage e42842f2cd getCurrentOwnerName
Instead of passing around the owner and the internal fiber everywhere we
can set current owner during each commit. That way we have it available
globally where ever we need it.

That way we don't have to pass it as a DEV only argument nor expose the
internal representation to the host config.

This doesn't actually get the current owner yet. Will do that in a follow
up.
2016-11-18 00:26:25 +00:00
Sebastian Markbage 43f07779c4 We only need the root attribute for warnings and server-side rendering
We don't need this for Fiber yet. We can possibly add an expando to check
if this is rendered with React or not.
2016-11-18 00:26:25 +00:00
Sebastian Markbage a1645322a7 Lint issues
Most dead code
2016-11-18 00:26:25 +00:00
Sebastian Markbage 3a856091be Add some Flow and get rid of the typecheck annotations 2016-11-18 00:26:25 +00:00
Sebastian Markbage aea55609bf No need for unmounting DOM components
We'll stop tracking the input value tracking. We'll also stop uncaching the
node because we can just let the garbage collector take care of that. This
makes it easier to release components in trees that never mounted.

This also removes an invariant error which is covered by unit tests.
This is necessary to separate regardless because we don't want this to
fire for a component that was started but was thrown away because it never
mounted. We can come back to that later.
2016-11-18 00:26:25 +00:00
Sebastian Markbage 77de47e378 Stop tracking event listeners on DOM nodes
Basically, we don't need to remove the event listeners because we can just
check if something is still mounted when they fire instead. We'll rely on
garbage collection to clean them up.
2016-11-18 00:26:25 +00:00
Sebastian Markbage e1ed610740 Remove the notion of transactions
We don't need to wait for the commit phase to start listening to events
since we have the node.

Next we'll stop unlistening to events too and instead just check isMounted.
2016-11-18 00:26:24 +00:00
Sebastian Markbage 7cd26b9c71 Manage children inside DOM properties
Fiber manages children separately so we don't need to do it here.
However, we special case the text content children and
dangerouslySetInnerHTML.

This reveals a bug that we currently don't handle the case where we switch
from dangerouslySetInnerHTML or text children to element children, because
child insertions are handled before the parent updates. We could possibly
handle this case by removing all nodes before the first host child but
that is a bit unfortunate.
2016-11-18 00:26:24 +00:00
Sebastian Markbage 7c5ec42350 Remove _domID
Not used by Fiber
2016-11-18 00:26:24 +00:00
Sebastian Markbage 4073dc79d7 Remove instrumentation and nesting warning
The nesting warning isn't as important now that we use createElement and
I don't want to deal with this just yet.
2016-11-18 00:26:24 +00:00
Sebastian Markbage 447e0a12b5 Get rid of the previousStyleCopy
We have warned about not mutating styles already. At this point we can just
freeze the style object in DEV.

That way we can read it from the previous props object without storing
another copy of it.

Also delete the associated warning.
2016-11-18 00:26:24 +00:00
Sebastian Markbage 151094ce03 Rely on lazy listeners 2016-11-18 00:26:24 +00:00
Sebastian Markbage 82e1d7dac3 Remove child nodes flag
We're always eager in Fiber.
2016-11-18 00:26:24 +00:00
Sebastian Markbage c8d877a4c4 Remove rootNodeID
We only use this to determine if something is mounted or not but I don't
think we really need to.
2016-11-18 00:26:24 +00:00
Sebastian Markbage e34e8974db Remove markup related paths 2016-11-18 00:26:24 +00:00
Sebastian Markbage ec178acf15 Turn ReactDOMFiberComponent into a singleton
And turn on Flow.
2016-11-18 00:26:23 +00:00
Sebastian Markbage 9c3e9fbb05 Fork ReactDOMComponent and the wrappers to Fiber
From now on any change to these have to be replicated to these files.

I will next start changing the implementation to work with Fiber.
2016-11-18 00:26:23 +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
Tom Occhino 9589c726da Fix a line-length warning (#8298)
Test Plan: npm run lint / yarn run lint
2016-11-16 10:33:16 +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 4029ccd650 Merge pull request #8272 from gaearon/fiber-context
[Fiber] Initial implementation of context
2016-11-15 17:14:12 +00: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 1e42c1833c Add explicit tests for intermediate components 2016-11-15 16:08:15 +00:00
Dan Abramov a6ee5b876a Memoize merged child context when possible
We can avoid recreating the merged context object if the context provider work was reused. This is essential to avoid allocations for deep setState() calls.
2016-11-15 14:41:59 +00:00
Dan Abramov 299009c41f Add test cases for context below and above setState 2016-11-15 13:23:29 +00:00
Andrew Clark 4528cddf51 Removes UpdateQueueNode.callbackWasCalled (#8290)
Tracking this isn't necessary.
2016-11-15 09:52:05 +00:00
Dan Abramov 137029be31 Catch first error from setState callbacks (#8287)
* Catch first error from setState updaters

* Minor style tweaks
2016-11-14 18:27:38 +00:00