Commit Graph

7286 Commits

Author SHA1 Message Date
Sebastian Markbage 442ab71fc7 Append deletions to the effect list
First clear any progressed deletions for any case where we start
over with the "current" set of children.

Once we've performed a new reconciliation we need to add the
deletions to the side-effect list (which we know is empty because
we just emptied it).

For other effects, instead of just adding a fiber to an effect
list we need to mark it with an update. Then after completion
we add it to the the effect list if it had any effects at all.

This means that we lose the opportunity to control if a fiber
gets added before or after its children but that was already
flawed since we want certain side-effects to happen before others
on a global level.

Instead, we'll do multiple passes through the effect list.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 901691eb92 Tag the fiber with the kind of side-effect that was applied to it
This allow us to track what kind of side-effect this was even
though we only have a single linked list for all side-effects.
2016-10-17 16:17:30 -04:00
Sebastian Markbage e9e645a9b1 Deletion tracking
When we reconcile children we need to track the deletions that
happen so that we can perf side-effects later as a result. The
data structure is a linked list where the next pointer uses the
nextEffect pointer.

However, we need to store this side-effect list for reuse if we
end up reusing the progressedChild set. That's why I add a
separate first/last pointer into this list so that we can keep it
for later.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 0dc840a2b9 Fast path for create child
When we don't have any previous fibers we can short cut this path
knowing that we will never have any previous child to compare to.

This also ensures that we don't create an empty Map in this case.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 3979bb9e24 Don't track side-effects unless needed
We don't need to track side-effects for a parent that has never
been mounted before. It will simply inject all its children when
it completes.
2016-10-17 16:17:30 -04:00
Sebastian Markbage cccc4ae2c6 Add index field to each fiber
We use this to track the index slot that this Fiber had at
reconciliation time. We will use this for two purposes:

1) We use it to quickly determine if a move is needed.

2) We also use it to model a sparce linked list, since we can have
null/false/undefined in our child set and these take up a slot for
the implicit key.
2016-10-17 16:17:30 -04:00
Sebastian Markbage edaf08fcfe Fiber child reconciliation
This implements the first step to proper child reconciliation.
It doesn't yet track side-effects like insert/move/delete but has
the main reconciliation algorithm in place.

The goal of this algorithm is to branch early and avoid rechecking those conditions. That leads to some duplications of code.

There are three major branches:

- Reconciling a single child per type.
- Reconciling all children that are in the same slot as before from the beginning.
- Adding remaining children to a temporary Map and reconciling them by scanning the map.

Even when we use the Map strategy we have to scan the linked list to line up "same slot" positions because React, unlike Inferno, can have implicit keys interleaved with explicit keys.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 13f01be64f Enable text updates in ReactNoop
We'll enable updating of text nodes. To be able to test that we
need the text nodes to be mutable. They're currently just strings
in the Noop renderer so this makes them an object instead.

That exposed a bug in ReactFiberCommitWork for text nodes.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 362e56a1c1 Add comment about bug in yields
This needs to be fixed somehow. The reconciler could know if you
are mounting this continuation into the same spot as before and
then clone it. However, if the continuation moves, this info is
lost. We'd try to unmount it in one place and mount the same fiber
in another place.
2016-10-17 16:17:30 -04:00
Sebastian Markbage c3310d3e32 Fix MultiChild tests so they work with Fiber
Dropped the unnecessary use of findDOMNode.
Dropped unnecessary arrow functions.
Math.random() -> id counter, since this used to be
non-deterministic which is not ideal for unit tests.

getOriginalKeys() used to rely on implementation details
to scan that the internal data structure maintained its
structure, however, since that is unobservable we don't
need to test the internal data structure itself. We're
already testing refs and dom structure which is the only
observable effect of the reorder.
2016-10-17 16:17:30 -04:00
Sebastian Markbage 8d3a58de62 Silence Fiber warning when the feature flag is on
When the feature flag is on, we should silence the warning since
we're explicitly testing it. This is needed when running unit
tests with the flag on.
2016-10-17 16:17:30 -04:00
Sebastian Markbage cafa7b284a Add Text node types
These nodes rendering into Text nodes in the DOM.

There is a special case when a string is a direct child of a host
node. In that case, we won't reconcile it as a child fiber. In
terms of fibers, it is terminal. However, the host config special
cases it.

It is kind of unfortunate that we have to special case this kind
of child in the HostConfig. It would be nice to unify this with
other types of child instances. Text nodes have some weird special
cases, but those special cases tend to *vary* by environment.
They're not the same special cases so not sure how valuable it is
to have a special protocol and special types for it.
2016-10-17 16:17:30 -04:00
Sebastian Markbage e0a305350b Add Fragment fiber type
We currently treat nested arrays as a unique namespace from top
level children. So that these won't share key namespaces. This
adds a new fiber type that will represent the position of a
fragment.

This is only used for nested arrays. Even if you return an array
from a composite component, we don't need this since they share
namespace with a single top level component.

This still doesn't implement the complete reconciliation
algorthim in child fiber. That's coming later.
2016-10-17 16:17:30 -04:00
Dan Abramov 7b7eddcc72 Add @preventMunge directives to classes (#7994) 2016-10-17 21:07:17 +01:00
Dan Abramov c2d5833e98 Ignore root docs folder in Flow config
Otherwise Flow finds obscure files in docs/vendor.
Seems like you'd only get them if you have a local checkout of docs Ruby dependencies.
This explains why Travis didn't fail.
2016-10-17 16:12:07 +01:00
Dan Abramov f33f03e357 Support passthrough updates for error boundaries (#7949)
* Initial pass at the easy case of updates (updates that start at the root).

* Don't expect an extra componentWillUnmount call

It was fixed in #6613.

* Remove duplicate expectations from the test

* Fix style issues

* Make naming consistent throughout the tests

* receiveComponent() does not accept safely argument

* Assert that lifecycle and refs fire for error message

* Add more tests for mounting

* Do not call componentWillMount twice on error boundary

* Document more of existing behavior in tests

* Do not call componentWillUnmount() when aborting mounting

Previously, we would call componentWillUnmount() safely on the tree whenever we abort mounting it. However this is likely risky because the tree was never mounted in the first place.

People shouldn't hold resources in componentWillMount() so it's safe to say that we can skip componentWillUnmount() if componentDidMount() was never called.

Here, we introduce a new flag. If we abort during mounting, we will not call componentWillUnmount(). However if we abort during an update, it is safe to call componentWillUnmount() because the previous tree has been mounted by now.

* Consistently display error messages in tests

* Add more logging to tests and remove redundant one

* Refactor tests

* Split complicated tests into smaller ones

* Assert clean unmounting

* Add assertions about update hooks

* Add more tests to document existing behavior and remove irrelevant details

* Verify we can recover from error state

* Fix lint

* Error in boundary’s componentWillMount should propagate up

This test is currently failing.

* Move calling componentWillMount() into mountComponent()

This removes the unnecessary non-recursive skipLifecycle check.
It fixes the previously failing test that verifies that if a boundary throws in its own componentWillMount(), the error will propagate.

* Remove extra whitespace
2016-10-15 18:13:56 +01:00
Héctor Ramos 1b7066ed6f Separate Ruby and Python instructions 2016-10-14 15:11:27 -07:00
Héctor Ramos 175fc4ae9b Add Windows-specific instructions 2016-10-14 15:10:16 -07:00
Sebastian Markbåge fda7a673c1 Fix whitespace in headers (#7980)
The script that strips providesModule is very sensitive.

Test plan:

Searched for providesModule in build. No more.

reactComponentExpect used to have problems too but doesn't seem
to anymore. Don't know why.
2016-10-14 17:46:34 -04:00
Dan Abramov 14ec2c0c46 Add 15.4.0 RC3 to Downloads 2016-10-14 20:21:05 +01:00
Héctor Ramos b59a8d94cc Add link to gulpjs 2016-10-13 15:48:16 -07:00
Dustan Kasten 91aa538221 build: strip @providesModule from output modules (#7968)
FB tools such as Flow and Jest are having issues finding duplicate modules
now that React internal modules are duplicated across packages.
2016-10-13 16:19:11 -04:00
CT Wu 836a054719 Fix a typo in the doc (#7969) 2016-10-13 16:58:57 +01:00
Nathan Hunzaker 0d20dcf910 Fix uncontrolled input decimal point "chopping" on number inputs, and validation warnings on email inputs (#7750)
* Only assign defaultValue if it has changed.

* Improve comment about reason for defaultValue conditional assignment
2016-10-13 08:20:14 -05:00
Giorgio Polvara 823dd3d65f Fix typo (#7953) 2016-10-12 21:29:37 -05:00
Sebastian Markbåge f38e0cb6ac Check in yarn.lock file (#7957)
Because we have to keep up with the latest hotness
https://yarnpkg.com/
2016-10-12 16:07:25 -04:00
Ujjwal Ojha 575727100a Fix typo (#7909) 2016-10-12 09:49:56 -05:00
Kevin Huang b728fa0c17 Add warning for shady-dom use with rendered react components in DEV (#7911)
* Add warning for shady-dom use with rendered react components in DEV

* Make shady dom warning emit only once regardless of number of components

* Use didWarnShadyDom as warning argument & add missing shadyRoot check to ReactDOMComponent

* Add check for shady dom test to run only when createElement flag is true

* Pass false to warning in shadyDom warning check

* Add consistent DOM phrasing for shady DOM warnings

* Reference component name in shady DOM warning if it exists

* Add check for if owner exists in shady dom warning

* Add test for named component using createClass for shady DOM warning

* Clean up named component test for shady DOM warning

* Fix trailing comma linting issue on named shady DOM warning test
2016-10-12 10:13:50 +01:00
Kevin Huang 3b708728b0 Declare type var higher up in mountComponent() in ReactDOMComponent for reuse (#7944) 2016-10-12 10:12:15 +01:00
Islam Sharabash b77a96e496 Inject the previous batching strategy when rendering to string (#7930)
Before this change calling renderToStringImpl would inject
ReactDefaultBatchingStrategy after completion, even if a custom batching
strategy was injected before. This makes renderToStringImpl keep a reference to
the batching strategy before it runs and reinject it afterwards.
2016-10-11 12:57:22 -05:00
Colin Wren 7aa621daee Fix typo in more-about-refs.md (#7933) 2016-10-11 11:56:34 +01:00
Alex Babkov deb4a5abee Typo fixes in codebase-overview.md (#7938) 2016-10-11 11:55:06 +01:00
Aesop Wolf f00fbbd1ce Update codebase-overview.md (#7934)
Fix typo
2016-10-11 01:14:05 +01:00
Dan Abramov d0cc73a957 Add Implementation Notes and amend Codebase Overview (#7830)
* Add more to Codebase Overview

* WIP

* Start a reconciler overview

* Add a few more sections

* todo

* WIP

* Finish it

* Whitespace

* Minor tweaks

* Minor tweaks
2016-10-10 17:29:48 +01:00
Toru Kobayashi 83381c1673 use npm-run-script in PULL_REQUEST_TEMPLATE (#7913) 2016-10-07 14:23:37 +01:00
Paul O’Shannessy 077d660a27 Fix npm package builds (#7888)
* Ensure lib/ is packaged for react-test-renderer

* Run npm pack from right working directory

We were running this on the original packages not the compiled ones, resulting in missing files
2016-10-05 15:32:38 -07:00
Sophia 2a2dd7689f removing parent/child references in props section of tutorial (#7887) 2016-10-05 22:29:55 +01:00
Tyler Buchea e5b197cd94 Update README.md to use jsx for syntax highlighting (#7884)
Github now supports jsx syntax highlighting in their markdown documents. So I have updated the main README.md to use jsx instead of js.
2016-10-05 14:13:11 -05:00
Michael O'Brien 48ea2d4743 Update comment to refer to correct method name (#7873) 2016-10-04 22:53:26 +01:00
Dan Abramov 7b10b2b88d Update the homepage with ES6 (#7868)
* Update the homepage with ES6

* Avoid array spread and stale state
2016-10-04 19:33:09 +01:00
Kateryna c9ec4bc445 Fix initial state example for Recat.createClass (#7867)
In the example there was a typo with setting initial state using `getInitialState` method
2016-10-04 18:43:49 +01:00
Toru Kobayashi 30067fa8ca Fix confusing variable names (#7863) 2016-10-04 12:53:29 +01:00
ankitml eddcee9884 Use ES6 in Language Tooling doc 2016-10-04 12:51:42 +01:00
Toru Kobayashi 85b0377bfd Refactor ShallowRenderer (#7739)
* Separate ReactShallowRenderer from TestUtils

* Use ES classes to ReactShallowRenderer
2016-10-04 12:28:06 +01:00
KeicaM f96237cdb8 Update 04-multiple-components.md (#7861)
added missing map bracket
2016-10-04 12:19:44 +01:00
Steve Mao 957f663513 simplify npm link script a little bit (#7862)
We don't need to remove the folders before linking the modules
2016-10-04 12:12:12 +01:00
Ben Alpert be63afcb64 Make sure .createElement({}) warns (#7857)
This is common when forgetting to export anything from a file.
2016-10-03 17:24:57 -07:00
Marcelo Alves 23cd77b683 Fix minor typo in closing H1 tag (#7855) 2016-10-03 19:07:56 -05:00
Paul O’Shannessy 92c84a6f37 Fix UMD bundles, making safe to use as required modules (#7840) 2016-10-03 15:49:10 -07:00
Ben Alpert f88c1d38be Update remarkable to 1.7.1 (#7851)
Fixes a subtle XSS hole.
2016-10-03 14:22:06 -07:00