Repository navigation
feat(core): keep stencil's hydrated class on every pine component through a dom morph - #877
Merged
Merged
Conversation
…after a dom morph
… stay visible after a morph
✅ Deploy Preview for pine-design-system ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
pixelflips
reviewed
Oct 16, 2026
pixelflips
left a comment
Member
There was a problem hiding this comment.
Observer logic looks solid. A few small notes on the docs and the new e2e.
pixelflips
approved these changes
Oct 16, 2026
12 tasks done
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.
Description
Stencil hides every Pine component until it has the
hydratedclass. A DOM morph (Turbo morphing, Idiomorph) that makes a host'sclassmatch the server's HTML removes it, and nothing puts it back, so the component goes invisible. #875 and #876 restore it for the 13 components with their own host restore. Every other component, such aspds-button,pds-input,pds-alertandpds-accordion, still vanishes after a morph.This adds
keepPineHydrated(): oneMutationObserveron the document that putshydrated, and a scoped component's ownsc-*classes, back on anypds-*element that loses them.sc-classes (styled-components ids).Where it runs
distbuilds: it runs as Pine's StencilglobalScript(newsrc/global/pine-global.ts, wired instencil.config.ts), so it starts as soon as the loader loads.@pine-ds/core/components,@pine-ds/react): that build doesn't run global scripts, sokeepPineHydratedis exported from@pine-ds/core. The getting-started guide tells those consumers to call it once.MutationObserver, the first call does nothing either.Size
isStencilClassandclassNamesOfmoved intoutils/keep-hydrated.ts. If the global script had importedattributes.ts, the loader would have fetched that whole module.Known limit: a page script that removes
hydratedevery time it comes back will loop against the observer. That's the same tug-of-war the planned restore cap (limitRestores) handles for the per-component observers. It can apply here once it lands.Fixes DSS-362
Type of change
How Has This Been Tested?
utils/test/keep-hydrated.spec.tscovers:MutationObserver;global/test/pine-global.e2e.tsstrips the classes ofpds-button,pds-input,pds-alert,pds-accordionand the scopedpds-radio-group, and checks that their Stencil classes come back and they stay visible. With the global script switched off, all five fail.pds-box,pds-row,pds-radio,pds-tabsandpds-select.pds-chip"subtle and solid sentiments" e2e tests, which fail onmaintoo.Checklist:
Note
Medium Risk
Adds a global MutationObserver on every page load that mutates host
classon all Pine components; low conflict risk but could fight scripts that intentionally striphydrated.Overview
Adds
keepPineHydrated(), a document-levelMutationObserverthat re-applies Stencil’shydratedand hostsc-*classes on anypds-*element when a DOM morph (e.g. Turbo) strips them—fixing invisible components that lack per-component host restore.CDN/
dist: wired via new StencilglobalScript(pine-global.ts). React / custom-elements: export from@pine-ds/coreand document a one-time startup call in getting-started.isStencilClass/classNamesOfmove tokeep-hydrated.tsand are reused by existing per-host restore inattributes.ts. Includes unit + e2e coverage; CDN chunk size limit raised 348 KB → 350 KB.Reviewed by Cursor Bugbot for commit c1e5b71. Bugbot is set up for automated code reviews on this repo. Configure here.