@unsetsoft/ryunixjs 1.2.4-canary.10 → 1.2.4-canary.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -556,6 +556,16 @@ const clearContainer = (container) => {
556
556
  */
557
557
  const commitRoot = () => {
558
558
  const state = getState();
559
+
560
+ if (state.wipRoot && state.wipRoot.dom && state.wipRoot.dom.hasChildNodes() && !state.currentRoot) {
561
+ // This is the hydration commit. We synchronously clear existing SSR content to prevent FOUC.
562
+ // Ensure we only clear once by verifying !state.currentRoot.
563
+ // We clear BEFORE appending new children in commitWork.
564
+ while (state.wipRoot.dom.firstChild) {
565
+ state.wipRoot.dom.removeChild(state.wipRoot.dom.firstChild);
566
+ }
567
+ }
568
+
559
569
  state.deletions.forEach(commitWork);
560
570
  commitWork(state.wipRoot.child);
561
571
  state.currentRoot = state.wipRoot;
@@ -1839,15 +1849,7 @@ const render = (element, container) => {
1839
1849
  return state.wipRoot
1840
1850
  };
1841
1851
 
1842
- /**
1843
- * The `hydrate` function attaches Ryunix elements to an existing HTML DOM.
1844
- * Note: We clear the SSR content and do a clean CSR render.
1845
- * The SSR HTML serves its purpose for first-paint and SEO; once JS loads
1846
- * it takes over with a full CSR render to ensure correctness and interactivity.
1847
- */
1848
1852
  const hydrate = (element, container) => {
1849
- // Clear SSR content — prevents duplicate DOM nodes when hooks trigger re-renders
1850
- clearContainer(container);
1851
1853
  return render(element, container)
1852
1854
  };
1853
1855