Repository navigation
[internal] Upgrade to core-js v3 - #418
Merged
Merged
Conversation
Netlify deploy preview |
michaldudak
approved these changes
May 28, 2024
michaldudak
added a commit
to michaldudak/base-ui
that referenced
this pull request
Jun 10, 2026
Extract the nonce + isHydrating + <script> element into a shared PrehydrationScript component, removing the duplicated logic from TabsIndicator and SliderThumb. Callers gate it structurally (renderBeforeHydration, plus inset/last for the slider); the component only owns the hydration mechanics. The script string is still imported per-component through the #prehydration/* subpath import (stubbed in client bundles). The component keeps rendering the <script> element with empty content on the client during the hydration pass, rather than returning null: the server emits the element, so dropping it on the client triggers a recoverable hydration error (React mui#418, verified in a production build). suppressHydrationWarning bridges the content difference and the element unmounts once isHydrating flips to false. Only the script body is excluded from client bundles, not the component. Co-Authored-By: Claude Fable 5 <[email protected]>
arindampradhan
added a commit
to noevaresearch/base-ui
that referenced
this pull request
Sep 10, 2026
…te — the inline-script emitter that positions server-rendered content ahead of hydration (PrehydrationScript.tsx:32-49, consumed by Tabs.Indicator at TabsIndicator.tsx:170 and Slider.Thumb at SliderThumb.tsx:469): use_is_hydrating.rs ports packages/react/src/utils/useIsHydrating.ts (the useSyncExternalStore no-subscribe hook whose getServerSnapshot=true/getSnapshot=false pair yields exactly one true pass during server render + hydration and false for fresh client mounts, useIsHydrating.ts:4-14) as a module-level ArcRwSignal<bool> global the future SSR/hydration runtime drives through set_is_hydrating — the runtime seam standing in for React resolving the snapshot pair, default false (the fresh-client-mount world the crate runs in), the flip a real signal write so reactive consumers re-run (upstream's forced post-hydration re-render that unmounts the element, PrehydrationScript.tsx:20-21); prehydration_script.rs ports the component: useCSPContext for the nonce (:34) riding the lazy-attribute convention (the composite_view roving-tabIndex precedent — the memo re-read at attribute-read time, None yields no attribute), the hydration gate returning None (the :37-39 null branch), and the script-element description (tag 'script', the body as the new RenderElementProps::inner_html member — the dangerouslySetInnerHTML analog at :45) built directly rather than through useRenderElement because upstream returns a bare <script>, not a merge call site; RenderElementProps gains inner_html (merge_into folds it as a plain prop key — later bag wins only when carried, per mergeProps' for-in-over-own-keys — is_empty counts it, create_element applies it via set_inner_html) with a host merge test; N/A adaptations documented in the module docs: the #prehydration/* browser-condition stub (packages/react/package.json:112-118, prehydrationScript.stub.ts:6 — no JS bundler; the body is inert data until a script element carrying it connects, and a plain client mount emits nothing because the flag defaults false), suppressHydrationWarning (no reconciler comparing content), the React mui#418 client-bundle constraint (the gate itself expresses the hydration-tree-matches-server rule), and 'use client'; the ArcRwSignal backing is deliberate and documented — a plain RwSignal lazily created inside a test/app owner registers its wasm ArenaItem storage with that owner and is disposed with it, panicking every later reader (observed as a wasm-only latent failure this iteration — the host's Arc storage has no owner-registered arena item, so only the browser suite caught it; ArcRwSignal is pure Arc/RwLock state with no owner registration, the app-long-lived contract); the unit has no upstream tests (implementation.md untested-source item 5), so 6 host tests pin the written mechanics (the flag default, the runtime pass flip, the read-only tracked surface, the gate short-circuit, the description shape, the nonce lazy-attribute flow incl. the provider case) and 6 wasm tests pin the browser behavior (materialized <script> carrying the body, the provider nonce attribute, the end-to-end feature — the detached element has not executed until it connects and the browser runs the body on insertion exactly as server HTML parses, and the gate/unmount matrix); 260 host + 352 wasm crate-wide, wasm suite run in-browser (Chrome 152 + chromedriver 152.0.7977.82 re-fetched per the .cargo/config.toml recipe — the prior session's driver copy lost its execute bit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
core-js2 has been deprecated for a while and has started to cause bugs with new Promise APIs in the docs.