Commit Graph

1138 Commits

Author SHA1 Message Date
Sebastian Markbåge
5890e0e692 Remove data-reactroot from server rendering and hydration heuristic (#20996)
This was used to implicitly hydrate if you call ReactDOM.render.

We've had a warning to explicitly use ReactDOM.hydrate(...) instead of
ReactDOM.render(...). We can now remove this from the generated markup.
(And avoid adding it to Fizz.)

This is a little strange to do now since we're trying hard to make the
root API work the same.

But if we kept it, we'd need to keep it in the generated output which adds
unnecessary bytes. It also risks people relying on it, in the Fizz world
where as this is an opportunity to create that clean state.

We could possibly only keep it in the old server rendering APIs but then
that creates an implicit dependency between which server API and which
client API that you use. Currently you can really mix and match either way.
2021-05-13 10:18:21 -07:00
Brian Vaughn
2bf4805e4b Update entry point exports (#21488)
The following APIs have been added to the `react` stable entry point:
* `SuspenseList`
* `startTransition`
* `unstable_createMutableSource`
* `unstable_useMutableSource`
* `useDeferredValue`
* `useTransition`

The following APIs have been added or removed from the `react-dom` stable entry point:
* `createRoot`
* `unstable_createPortal` (removed)

The following APIs have been added to the `react-is` stable entry point:
* `SuspenseList`
* `isSuspenseList`

The following feature flags have been changed from experimental to true:
* `enableLazyElements`
* `enableSelectiveHydration`
* `enableSuspenseServerRenderer`
2021-05-12 11:28:14 -04:00
Sebastian Markbåge
46ef1ab32a Convert emulated-Fizz PartialHydration tests to Fizz tests (#21437) 2021-05-05 21:22:27 -04:00
Sebastian Markbåge
212d2909d3 [Fizz] Make some tests more resilient to implementation details (#21438)
* Make some tests resilient against changing the specifics of the HTML

This ensures that for example flipping order of attributes doesn't matter.

* Use getVisibleChildren approach for more resilient tests
2021-05-05 16:13:45 -07:00
Sebastian Markbåge
8ea11306ad Allow complex objects as children of option only if value is provided (#21431) 2021-05-05 08:40:54 -07:00
Ricky
e9a4a44aae Add back root override for strict mode (#21428)
* Add back root override for strict mode

* Switch flag to boolean

* Fix flow
2021-05-04 15:42:48 -04:00
Sebastian Markbåge
442eb21e0e Allow dangerouslySetInnerHTML in <option> (#21373) 2021-05-04 07:45:54 -07:00
Brian Vaughn
15fb8c3045 createRoot API is no longer strict by default (#21417) 2021-05-03 16:57:03 -04:00
Andrew Clark
aea7c2aab1 Re-land "Support nesting of startTransition and flushSync (alt) (#21149)"
This re-lands commit faa1e127f1ba755da846bc6ce299cdefaf97721f.
2021-05-03 13:40:13 -05:00
Ricky
9e9dac6505 Add unstable_concurrentUpdatesByDefault (#21227) 2021-04-28 16:09:30 -04:00
Andrew Clark
207d4c3a53 Revert "Support nesting of startTransition and flushSync (alt) (#21149)"
This reverts commit faa1e127f1ba755da846bc6ce299cdefaf97721f.

* Support nesting of startTransition and flushSync

* Unset transition before entering any special execution contexts

Co-authored-by: Andrew Clark <git@andrewclark.io>
2021-04-28 11:56:54 -05:00
Sebastian Markbåge
2182563dc4 Let value override defaultValue if both are specified (#21369)
There's a DEV warning for this case but we still test for the production
behavior.
2021-04-27 13:18:42 -07:00
Sebastian Silbermann
29faeb2df3 Remove unnecessary type cast (#21363) 2021-04-27 12:37:14 -04:00
Sebastian Markbåge
4a8deb0836 Switch the isPrimaryRender flag based on the stream config (#21357) 2021-04-26 22:37:05 -04:00
Sebastian Markbåge
bd4f056a3e [Fizz] Implement lazy components and nodes (#21355)
* Implement lazy components

* Implement lazy elements / nodes

This is used by Flight to encode not yet resolved nodes of any kind.
2021-04-26 18:46:46 -07:00
Sebastian Markbåge
a2ae42db90 Escape style values (#21356) 2021-04-26 18:46:36 -07:00
Brian Vaughn
fc33f12bde Remove unstable scheduler/tracing API (#20037) 2021-04-26 19:16:18 -04:00
Sebastian Markbåge
9cd52b27fe Restore context after an error happens (#21341)
Typically we don't need to restore the context here because we assume that
we'll terminate the rest of the subtree so we don't need the correct
context since we're not rendering any siblings.

However, after a nested suspense boundary we need to restore the context.
The boundary could do this but since we're already doing this in the
suspense branch of renderNode, we might as well do it in the error case
which isn't very perf sensitive anyway.
2021-04-23 12:24:10 -07:00
Sebastian Markbåge
ad091759a9 Revert "Emit reactroot attribute on the first element we discover (#21154)" (#21340)
This reverts commit 266c26ad45.
2021-04-23 10:28:44 -07:00
Sebastian Markbåge
af5037a7a8 [Fizz] Wire up the Fixture (#21273)
* Wire up fizz to fixture

* Fixed typo conditional
2021-04-22 15:00:35 -07:00
Andrew Clark
e8cdce40d6 Don't flush sync at end of discreteUpdates (#21327)
All it should do is change the priority. The updates will be flushed
by the microtask.
2021-04-22 15:28:05 -05:00
Andrew Clark
a155860018 Fix: Don't flush discrete at end of batchedUpdates (#21229)
The outermost `batchedUpdates` call flushes pending sync updates at the
end. This was intended for legacy sync mode, but it also happens to
flush discrete updates in concurrent mode.

Instead, we should only flush sync updates at the end of
`batchedUpdates` for legacy roots. Discrete sync updates can wait to
flush in the microtask.

`discreteUpdates` has the same issue, which is how I originally noticed
this, but I'll change that one in a separate commit since it requires
updating a few (no longer relevant) internal tests.
2021-04-21 09:32:09 -07:00
Ricky
a632f7de3b Flip tuple order of useTransition (#20976) 2021-04-20 12:21:44 -04:00
Andrew Clark
78120032d4 Remove flushDiscreteUpdates from end of event (#21223)
We don't need this anymore because we flush in a microtask.

This should allow us to remove the logic in the event system that
tracks nested event dispatches.

I added a test to confirm that nested event dispatches don't triggger
a synchronous flush, like they would if we wrapped them `flushSync`. It
already passed; I added it to prevent a regression.
2021-04-20 08:25:31 -07:00
Sebastian Markbåge
9eddfbf5af [Fizz] Two More Fixes (#21288)
* Emit value of option tags

* Mask the legacy context passed to classes
2021-04-15 10:26:49 -07:00
Sebastian Markbåge
96d00b9bba [Fizz] Random Fixes (#21277) 2021-04-14 23:29:30 -04:00
Sebastian Markbåge
0e100ed00f Gate a test (#21275)
Rebase error
2021-04-14 16:37:44 -07:00
Sebastian Markbåge
81ef539535 Always insert a dummy node with an ID into fallbacks (#21272) 2021-04-14 15:39:51 -07:00
Sebastian Markbåge
266c26ad45 Emit reactroot attribute on the first element we discover (#21154)
This may not be the first root element if the root is a fragment and the
second one unsuspends first. But this tag doesn't work well for root
fragments anyway.
2021-04-14 15:09:22 -07:00
Sebastian Markbåge
f4d7a0f1ea Implement useOpaqueIdentifier (#21260)
The format of this ID is specific to the format.
2021-04-14 14:25:42 -07:00
Sebastian Markbåge
a597c2f5dc [Fizz] Fix reentrancy bug (#21270)
* Fix reentrancy bug

* Fix another reentrancy bug

There's also an issue if we try to schedule something to be client
rendered if its fallback hasn't rendered yet. So we don't do it
in that case.
2021-04-14 13:49:14 -07:00
Sebastian Markbåge
4f76a28c93 [Fizz] Implement New Context (#21255)
* Add NewContext module

This implements a reverse linked list tree containing the previous
contexts.

* Implement recursive algorithm

This algorithm pops the contexts back to a shared ancestor on the way down
the stack and then pushes new contexts in reverse order up the stack.

* Move isPrimaryRenderer to ServerFormatConfig

This is primarily intended to be used to support renderToString with a
separate build than the main one. This allows them to be nested.

* Wire up more element type matchers

* Wire up Context Provider type

* Wire up Context Consumer

* Test

* Implement reader in class

* Update error codez
2021-04-14 11:45:42 -07:00
Sebastian Markbåge
dbadfa2c36 [Fizz] Classes Follow Up (#21253)
* Port Classes from Fiber to Fizz

* Test
2021-04-13 13:57:36 -07:00
Sebastian Markbåge
343710c923 [Fizz] Fragments and Iterable support (#21228) 2021-04-10 15:50:42 -04:00
Ricky
933880b454 Make time-slicing opt-in (#21072)
* Add enableSyncDefaultUpdates feature flag

* Add enableSyncDefaultUpdates implementation

* Fix tests

* Switch feature flag to true by default

* Finish concurrent render whenever for non-sync lanes

* Also return DefaultLane with eventLane

* Gate interruption test

* Add continuout native event test

* Fix tests from rebasing main

* Hardcode lanes, remove added export

* Sync forks
2021-04-09 19:50:09 -04:00
Sebastian Markbåge
172e89b4bf Reland Remove redundant initial of isArray (#21188)
* Remove redundant initial of isArray (#21163)

* Reapply prettier

* Type the isArray function with refinement support

This ensures that an argument gets refined just like it does if isArray is
used directly.

I'm not sure how to express with just a direct reference so I added a
function wrapper and confirmed that this does get inlined properly by
closure compiler.

* A few more

* Rename unit test to internal

This is not testing a bundle.

Co-authored-by: Behnam Mohammadi <itten@live.com>
2021-04-07 07:57:43 -07:00
Sebastian Markbage
b4f119cdf1 Revert "Remove redundant initial of isArray (#21163)"
This reverts commit b130a0f5cd.
2021-04-01 15:19:00 -04:00
Behnam Mohammadi
b130a0f5cd Remove redundant initial of isArray (#21163) 2021-04-01 10:50:48 -07:00
Behnam Mohammadi
2c9fef32db Remove redundant initial of hasOwnProperty (#21134)
* remove redundant initial of hasOwnProperty

* remove redundant initial of hasOwnProperty part 2

* remove redundant initial of hasOwnProperty part 3
2021-04-01 09:05:10 -07:00
Sebastian Markbåge
a423a01223 Ignore function and symbol values on custom-elements on the server (#21157) 2021-03-31 18:17:42 -07:00
Sebastian Markbåge
588db2e1fc Don't warn for casing if it's a custom element (#21156)
This replicates what we do on the client.
2021-03-31 18:10:27 -07:00
Sebastian Markbåge
9ed0167945 Don't lower case HTML tags in comparison for built-ins (#21155) 2021-03-31 18:00:22 -07:00
Sebastian Markbåge
b9e4c10e99 [Fizz] Implement all the DOM attributes and special cases (#21153)
* Implement DOM format config structure

* Styles

* Input warnings

* Textarea special cases

* Select special cases

* Option special cases

We read the currently selected value from the FormatContext.

* Warning for non-lower case HTML

We don't change to lower case at runtime anymore but keep the warning.

* Pre tags innerHTML needs to be prefixed

This is because if you do the equivalent on the client using innerHTML,
this is the effect you'd get.

* Extract errors
2021-03-31 17:39:38 -07:00
Sebastian Markbåge
b48b38af68 Support nesting of startTransition and flushSync (alt) (#21149)
* Support nesting of startTransition and flushSync

* Unset transition before entering any special execution contexts

Co-authored-by: Andrew Clark <git@andrewclark.io>
2021-03-31 08:22:49 -07:00
Sebastian Markbåge
e40f0b2603 Remove checkReact (#21132)
I don't know what this is useful for but I suspect it was only useful at
FB and is not applicable to ES modules at FB nor elsewhere.
2021-03-29 19:35:58 -07:00
Sebastian Markbåge
cecfde51b6 Don't import star from ReactDOM (#21133) 2021-03-29 19:35:47 -07:00
Sebastian Markbåge
8e76371241 Move not shared to client (#21135) 2021-03-29 19:35:34 -07:00
Andrew Clark
dbe98a5aae Move sync task queue to its own module (#21109)
The sync task queue is React-specific and doesn't really have anything
to do with Scheduler. We'd keep using it even once `postTask` exists.

By separating that part out, `SchedulerWithReactIntegration` is now
just a module that re-exports the Scheduler API. So I unforked it.
When we switch to ES Modules, we can remove this re-exporting module.
2021-03-28 14:15:53 -07:00
Sebastian Markbåge
32d6f39edd [Fizz] Support special HTML/SVG/MathML tags to suspend (#21113)
* Encode tables as a special insertion mode

The table modes are special in that its children can't be created outside
a table context so we need the segment container to be wrapped in a table.

* Move formatContext from Task to Segment

It works the same otherwise. It's just that this context needs to outlive
the task so that I can use it when writing the segment.

* Use template tag for placeholders and inserted dummy nodes with IDs

These can be used in any parent. At least outside IE11. Not sure yet what
happens in IE11 to these.

Not sure if these are bad for perf since they're special nodes.

* Add special wrappers around inserted segments depending on their insertion mode

* Allow the root namespace to be configured

This allows us to insert the correct wrappers when streaming into an
existing non-HTML tree.

* Add comment
2021-03-27 10:50:38 -07:00
Andrew Clark
a77dd13ede Delete enableDiscreteEventFlushingChange (#21110)
This flag was meant to avoid flushing discrete updates unnecessarily,
if multiple discrete events were dispatched in response to the same
platform event.

But since we now flush all discrete events at the end of the task, in
a microtask, it no longer has any effect.
2021-03-25 22:05:59 -07:00