331 Commits
Author SHA1 Message Date
Dan Abramov d0e6cbc3b0 Run ReactBrowserEventEmitter test on bundles 2020-07-01 15:52:06 +01:00
Vetrivel ChinnasamyandGitHub b621dab5d4 make link https (#19147) 2020-06-30 12:43:52 +01:00
Dominic GannawayandGitHub 3c1a7ac87c Move TOP_BEFORE_BLUR to bubble phase (#19197) 2020-06-26 20:35:21 +01:00
RickyandGitHub 30b47103d4 Fix spelling errors and typos (#19138) 2020-06-15 19:59:44 -04:00
Rick Hanlonandshengxinjing 655affa302 Clarifications
Co-authored-by: shengxinjing <316783812@qq.com>
2020-06-12 21:09:29 -04:00
Andrew ClarkandGitHub 8f05f2bd6d Land Lanes implementation in old fork (#19108)
* Add autofix to cross-fork lint rule

* replace-fork: Replaces old fork contents with new

For each file in the new fork, copies the contents into the
corresponding file of the old fork, replacing what was already there.

In contrast to merge-fork, which performs a three-way merge.

* Replace old fork contents with new fork

First I ran  `yarn replace-fork`.

Then I ran `yarn lint` with autofix enabled. There's currently no way to
do that from the command line (we should fix that), so I had to edit the
lint script file.

* Manual fix-ups

Removes dead branches, removes prefixes from internal fields.  Stuff
like that.

* Fix DevTools tests

DevTools tests only run against the old fork, which is why I didn't
catch these earlier.

There is one test that is still failing. I'm fairly certain it's related
to the layout of the Suspense fiber: we no longer conditionally wrap the
primary children. They are always wrapped in an extra fiber.

Since this has been running in www for weeks without major issues, I'll
defer fixing the remaining test to a follow up.
2020-06-11 20:05:15 -07:00
Andrew ClarkandGitHub 4c7036e807 Bugfix: Infinite loop in beforeblur event (#19053)
* Failing test: Infinite loop in beforeblur event

If the focused node is hidden by a Suspense boundary, we fire the
beforeblur event. Our check for whether a tree is being hidden isn't
specific enough. It should only fire when the tree is initially hidden,
but it's being fired for updates, too.

* Only fire beforeblur on visible -> hidden

Should only beforeblur fire if the node was previously visible. Not
during updates to an already hidden tree.

To optimize this, we should use a dedicated effect tag and mark it in
the render phase. I've left this for a follow-up, though. Maybe can
revisit after the planned refactor of the commit phase.

* Move logic to commit phase

isFiberSuspenseAndTimedOut is used elsewhere, so I inlined the commit
logic into the commit phase itself.
2020-06-01 09:01:21 -07:00
Sebastian MarkbågeandGitHub 8f511754db Prettier wants me to change this (#19039) 2020-05-28 20:13:56 -07:00
Dominic GannawayandGitHub 4a3f779d67 Remove event pooling in the modern system (#18969) 2020-05-21 13:54:05 +01:00
Dominic GannawayandGitHub 61f2a560e0 Add experimental ReactDOM.createEventHandle (#18756) 2020-05-12 20:24:25 +01:00
Dominic GannawayandGitHub 80c4dea0d1 Modern Event System: Add scaffolding for createEventHandle (#18898) 2020-05-12 19:01:12 +01:00
Dominic GannawayandGitHub e16703e6c7 Modern Event System: revise ancestor logic (#18886) 2020-05-11 22:09:52 +01:00
Dominic GannawayandGitHub 6778c53c16 Modern Event System: fix bug in EnterLeave (#18849) 2020-05-07 00:13:13 +01:00
Dominic GannawayandGitHub 823dc581fe Modern Event System: fix EnterLeave plugin logic (#18830) 2020-05-05 22:10:07 +01:00
Dominic GannawayandGitHub e028ce2ab7 Modern Event System: ensure target ancestors are only host nodes (#18827) 2020-05-05 13:10:05 +01:00
Andrew ClarkandGitHub fe7163e73d Add unstable prefix to experimental APIs (#18825)
We've been shipping unprefixed experimental APIs (like `createRoot` and
`useTransition`) to the Experimental release channel, with the rationale
that because these APIs do not appear in any stable release, we're free
to change or remove them later without breaking any downstream projects.

What we didn't consider is that downstream projects might be tempted to
use feature detection:

```js
const useTransition = React.useTransition || fallbackUseTransition;
```

This pattern assumes that the version of `useTransition` that exists in
the Experimental channel today has the same API contract as the final
`useTransition` API that we'll eventually ship to stable.

To discourage feature detection, I've added an `unstable_` prefix to
all of our unstable APIs.

The Facebook builds still have the unprefixed APIs, though. We will
continue to support those; if we make any breaking changes, we'll
migrate the internal callers like we usually do. To make testing easier,
I added the `unstable_`-prefixed APIs to the www builds, too. That way
our tests can always use the prefixed ones without gating on the
release channel.
2020-05-04 22:25:41 -07:00
Dominic GannawayandGitHub 9751935abf Modern Event System: improve dispatching queue (#18799) 2020-05-04 16:55:45 +01:00
Dominic GannawayandGitHub aa88589d0b Refine experimental Scopes API (#18778)
* Refine experimental Scopes API
2020-05-01 19:01:43 +01:00
Dominic GannawayandGitHub 88d0be6da5 Refactor ElementListenerMap (#18766) 2020-04-28 21:53:51 +01:00
Andrew ClarkandGitHub db6513914f Make ExpirationTime an opaque type (#18732)
* Add LanePriority type

React's internal scheduler has more priority levels than the external
Scheduler package. Let's use React as the source of truth for tracking
the priority of updates so we have more control. We'll still fall back
to Scheduler in the default case. In the future, we should consider
removing `runWithPriority` from Scheduler and replacing the valid use
cases with React-specific APIs.

This commit adds a new type, called a LanePriority to disambiguate from
the Scheduler one.

("Lane" refers to another type that I'm planning. It roughly translates
to "thread." Each lane will have a priority associated with it.)

I'm not actually using the lane anywhere, yet. Only setting stuff up.

* Remove expiration times train model

In the old reconciler, expiration times are computed by applying an
offset to the current system time. This has the effect of increasing
the priority of updates as time progresses. Because we also use
expiration times as a kind of "thread" identifier, it turns out this
is quite limiting because we can only flush work sequentially along
the timeline.

The new model will use a bitmask to represent parallel threads that
can be worked on in any combination and in any order.

In this commit, expiration times and the linear timeline are still in
place, but they are no longer based on a timestamp. Effectively, they
are constants based on their priority level.

* Stop using ExpirationTime to represent timestamps

Follow up to the previous commit. This converts the remaining places
where we were using the ExpirationTime type to represent a timestamp,
like Suspense timeouts.

* Fork Dependencies and PendingInteractionMap types

These contain expiration times

* Make ExpirationTime an opaque type

ExpirationTime is currently just an alias for the `number` type, for a
few reasons. One is that it predates Flow's opaque type feature. Another
is that making it opaque means we have to move all our comparisons and
number math to the ExpirationTime module, and use utility functions
everywhere else.

However, this is actually what we want in the new system, because the
Lanes type that will replace ExpirationTime is a bitmask with a
particular layout, and performing operations on it will involve more
than just number comparisions and artihmetic. I don't want this logic to
spread ad hoc around the whole codebase.

The utility functions get inlined by Closure so it doesn't matter
performance-wise.

I automated most of the changes with JSCodeshift, with only a few manual
tweaks to stuff like imports. My goal was to port the logic exactly to
prevent subtle mistakes, without trying to simplify anything in the
process. I'll likely need to audit many of these sites again when I
replace them with the new type, though, especially the ones
in ReactFiberRoot.

I added the codemods I used to the `scripts` directory. I won't merge
these to master. I'll remove them in a subsequent commit. I'm only
committing them here so they show up in the PR for future reference.

I had a lot of trouble getting Flow to pass. Somehow it was not
inferring the correct type of the constants exported from the
ExpirationTime module, despite being annotated correctly.

I tried converting them them to constructor functions — `NoWork`
becomes `NoWork()` — and that made it work. I used that to unblock me,
and fixed all the other type errors. Once there were no more type
errors, I tried converting the constructors back to constants. Started
getting errors again.

Then I added a type constraint everywhere a constant was referenced.
That fixed it. I also figured out that you only have to add a constraint
when the constant is passed to another function, even if the function is
annotated. So this indicates to me that it's probably a Flow bug. I'll
file an issue with Flow.

* Delete temporary codemods used in previous commit

I only added these to the previous commit so that I can easily run it
again when rebasing. When the stack is squashed, it will be as if they
never existed.
2020-04-24 23:26:04 -07:00
Dominic GannawayandGitHub 30cee2f4c7 Modern Event System: register onMouseEnter for portals (#18720) 2020-04-23 20:57:52 +01:00
Dominic GannawayandGitHub 4e3545fd6f ReactDOMEventListener: clean up module (#18713) 2020-04-23 20:19:28 +01:00
Dominic GannawayandGitHub ff431b7fc4 Remove ReactDOM.useEvent and associated types+tests (#18689) 2020-04-21 16:40:44 +01:00
Dominic GannawayandGitHub 4f59a149b8 Modern event system: fix selectionchange bug (#18680) 2020-04-20 19:54:12 +01:00
Dominic GannawayandGitHub 32bb44c80a Clean up modern plugins to remove dead code (#18639) 2020-04-16 20:10:23 +01:00
Dominic GannawayandGitHub b1a083183c Revert legacy plugin modules (#18638) 2020-04-16 18:46:24 +01:00
Dominic GannawayandGitHub 31977d1bb3 Create copy of Legacy event plugins for Modern system (#18637) 2020-04-16 16:09:05 +01:00
Andrew ClarkandGitHub bec7599067 Migrate conditional tests to gate pragma (#18585)
* Migrate conditional tests to gate pragma

I searched through the codebase for this pattern:

```js
describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})
```

and converted them to the `@gate` pragma instead.

The reason this pattern isn't preferred is because you end up disabling
more tests than you need to.

* Add flag for www release channels

Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
2020-04-13 14:45:52 -07:00
Andrew ClarkandGitHub 65237a237e Codemod it.experimental to gate pragma (#18582)
* Codemod it.experimental to gate pragma

Find-and-replace followed by Prettier

* Delete it.experimental

Removes the API from our test setup script
2020-04-13 10:28:59 -07:00
Dominic GannawayandGitHub 8cbce05be1 Move plugins into their own directory (#18553) 2020-04-09 14:18:33 +01:00
Andrew Clark 376d5c1b5a Split cross-package types from implementation
Some of our internal reconciler types have leaked into other packages.
Usually, these types are treated as opaque; we don't read and write
to its fields. This is good.

However, the type is often passed back to a reconciler method. For
example, React DOM creates a FiberRoot with `createContainer`, then
passes that root to `updateContainer`. It doesn't do anything with the
root except pass it through, but because `updateContainer` expects a
full FiberRoot, React DOM is still coupled to all its fields.

I don't know if there's an idiomatic way to handle this in Flow. Opaque
types are simlar, but those only work within a single file. AFAIK,
there's no way to use a package as the boundary for opaqueness.

The immediate problem this presents is that the reconciler refactor will
involve changes to our internal data structures. I don't want to have to
fork every single package that happens to pass through a Fiber or
FiberRoot, or access any one of its fields. So my current plan is to
share the same Flow type across both forks. The shared type will be a
superset of each implementation's type, e.g. Fiber will have both an
`expirationTime` field and a `lanes` field. The implementations will
diverge, but not the types.

To do this, I lifted the type definitions into a separate module.
2020-04-08 23:49:23 -07:00
Andrew Clark d686f3f16a Add .old prefix to reconciler modules 2020-04-08 23:49:19 -07:00
Sebastian MarkbågeandGitHub 147bdef11b Port more tests to the Scheduler.unstable_yieldValue pattern and drop internal.js (#18549)
* Drop the .internal.js suffix on some files that don't need it anymore

* Port some ops patterns to scheduler yield

* Fix triangle test to avoid side-effects in constructor

* Move replaying of setState updaters until after the effect

Otherwise any warnings get silenced if they're deduped.

* Drop .internal.js in more files

* Don't check propTypes on a simple memo component unless it's lazy

Comparing the elementType doesn't work for this because it will never be
the same for a simple element.

This caused us to double validate these. This was covered up because in
internal tests this was deduped since they shared the prop types cache
but since we now inline it, it doesn't get deduped.
2020-04-08 20:54:54 -07:00
Sebastian MarkbågeandGitHub 5474a83e25 Disable console.logs in the second render pass of DEV mode double render (#18547)
* Disable console log during the second rerender

* Use the disabled log to avoid double yielding values in scheduler mock

* Reenable debugRenderPhaseSideEffectsForStrictMode in tests that can
2020-04-08 16:43:51 -07:00
Dominic GannawayandGitHub a3875663f6 React Event System: cleanup plugins + break out update batching logic (#18503) 2020-04-06 22:01:20 +01:00
Nick ReileyandGitHub f625fce857 Add KeyboardEvent.code to synthetic event (#18287)
* Add KeyboardEvent.code to synthetic event

* remove null to 0 transformation

* make onKeyPress work
2020-04-04 14:24:46 +01:00
Dan AbramovandGitHub a8f2165e83 Update to Jest 25 (#18480)
* Revert "Revert "Upgrade to jest 25 (#17896)" (#18376)"

This reverts commit fc7835c657.

* Other fixes

* Fix a broken test
2020-04-03 16:37:36 +01:00
Dominic GannawayandGitHub 91c9d69f9a Modern Event System: Remove TestUtils.SimulateNative support (#18471) 2020-04-03 00:12:47 +01:00
Dominic GannawayandGitHub 8815e4cc72 Cleanup getListener and EventSystemFlags (#18469) 2020-04-02 23:17:10 +01:00
Dominic GannawayandGitHub 5e464546af ReactDOM.useEvent: fix scope propagation issue (#18464) 2020-04-02 18:26:56 +01:00
Dominic GannawayandGitHub d5e4b3ae1d Modern Event System: refine flags and handling of enableLegacyFBSupport (#18466) 2020-04-02 18:26:34 +01:00
Dominic GannawayandGitHub 663c13d71d Refactor Enter/Leave listener accumulation (#18405)
* Refactor Enter/Leave listener accumulation
2020-04-02 11:07:20 +01:00
Dan AbramovandGitHub c80cd8ee27 Revert "Fix email cursor jump (#18379)" (#18459)
* Revert "Fix email cursor jump (#18379)"

This reverts commit 9b88b78b3d.

* Leave fixtures be
2020-04-01 22:44:59 +01:00
Sebastian MarkbågeandGitHub 3e94bce765 Enable prefer-const lint rules (#18451)
* Enable prefer-const rule

Stylistically I don't like this but Closure Compiler takes advantage of
this information.

* Auto-fix lints

* Manually fix the remaining callsites
2020-04-01 12:35:52 -07:00
9b88b78b3d Fix email cursor jump (#18379)
* add email input fixture to show cursor jump

* fix cursor jump in email input

Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru>

* add regression tests to ensure attributes are working

Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru>
2020-04-01 19:30:26 +01:00
Dominic GannawayandGitHub d6d5f5aabe Move accumulateEventTargetListeners to its own module/function (#18407) 2020-04-01 14:19:21 +01:00
Dominic GannawayandGitHub dc3c6c9565 ReactDOM.useEvent: revert and add guard for null stateNode (#18441) 2020-04-01 12:45:26 +01:00
Andrew ClarkandGitHub 90e90ac8e0 Revert useEvent PRs (#18438)
* Revert "ReactDOM.useEvent: enable on internal www and add inspection test (#18395)"

This reverts commit e0ab1a429d.

* Revert "ReactDOM.useEvent: Add support for experimental scopes API (#18375)"

This reverts commit a16b349745.

* ReactDOM.useEvent: Add support for experimental scopes API
2020-03-30 19:16:28 -07:00
Sebastian SilbermannandGitHub ba31ad40a9 feat(StrictMode): Double-invoke render for every component (#18430)
* feat(StrictMode): Double-invoke render for every component

* fix: Mark ReactTestRendererAsync as internal
2020-03-29 23:13:46 +01:00
Dominic GannawayandGitHub e0ab1a429d ReactDOM.useEvent: enable on internal www and add inspection test (#18395) 2020-03-26 17:13:05 +00:00