From 0691295ce94746100bb1d3d17b10caf38f85979c Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Tue, 4 Feb 2025 09:22:27 -0800 Subject: [PATCH] fix(runtime): don't flag html tag with hydrate flag anymore (#6103) * fix(runtime): don't flag html tag with hydrate flag anymore * fix linter * remove unit test * fix unit test --- src/runtime/test/hydrated.spec.tsx | 52 ----------------------- src/runtime/test/lifecycle-async.spec.tsx | 2 - src/runtime/update-component.ts | 7 +-- 3 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 src/runtime/test/hydrated.spec.tsx diff --git a/src/runtime/test/hydrated.spec.tsx b/src/runtime/test/hydrated.spec.tsx deleted file mode 100644 index 0366f9c4054..00000000000 --- a/src/runtime/test/hydrated.spec.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Component } from '@stencil/core'; -import { newSpecPage } from '@stencil/core/testing'; - -describe('globals', () => { - @Component({ - tag: 'cmp-a', - }) - class CmpA {} - - it('should add hydrated to if no component is used', async () => { - const page = await newSpecPage({ - components: [CmpA], - html: `

No component used

`, - includeAnnotations: true, - }); - const html = page.doc.documentElement; - expect(html.classList.contains('hydrated')).toBe(false); - await new Promise((resolve) => { - setTimeout(() => { - expect(html.classList.contains('hydrated')).toBe(true); - resolve(); - }, 100); - }); - }); - - it('should add hydrated to if component is used', async () => { - const page = await newSpecPage({ - components: [CmpA], - html: ``, - includeAnnotations: true, - }); - const html = page.doc.documentElement; - expect(html.classList.contains('hydrated')).toBe(true); - }); - - it('should hide non hydrated components', async () => { - @Component({ - tag: 'cmp-b', - }) - class CmpB {} - - const { doc } = await newSpecPage({ - components: [CmpA, CmpB], - includeAnnotations: true, - }); - expect(doc.head.children[0]).toEqualHtml(` - - `); - }); -}); diff --git a/src/runtime/test/lifecycle-async.spec.tsx b/src/runtime/test/lifecycle-async.spec.tsx index d123520f665..1a88f835672 100644 --- a/src/runtime/test/lifecycle-async.spec.tsx +++ b/src/runtime/test/lifecycle-async.spec.tsx @@ -111,7 +111,6 @@ describe('lifecycle async', () => { @Component({ tag: 'cmp-a' }) class CmpA { componentWillLoad() { - expect(document.documentElement.classList.contains('hydrated')).toBe(false); window.addEventListener('appload', (ev: CustomEvent) => mockEvent(ev.detail)); } @@ -125,7 +124,6 @@ describe('lifecycle async', () => { includeAnnotations: true, }); - expect(document.documentElement.classList.contains('hydrated')).toBe(true); expect(mockEvent).toHaveBeenCalledTimes(1); expect(mockEvent).toHaveBeenCalledWith({ namespace: 'app', diff --git a/src/runtime/update-component.ts b/src/runtime/update-component.ts index d0600375520..643b90f03f1 100644 --- a/src/runtime/update-component.ts +++ b/src/runtime/update-component.ts @@ -1,5 +1,5 @@ import { BUILD, NAMESPACE } from '@app-data'; -import { Build, consoleError, doc, getHostRef, nextTick, plt, win, writeTask } from '@platform'; +import { Build, consoleError, getHostRef, nextTick, plt, win, writeTask } from '@platform'; import { CMP_FLAGS, HOST_FLAGS } from '@utils'; import type * as d from '../declarations'; @@ -415,11 +415,6 @@ export const forceUpdate = (ref: any) => { }; export const appDidLoad = (who: string) => { - // on appload - // we have finish the first big initial render - if (BUILD.cssAnnotations) { - addHydratedFlag(doc.documentElement); - } if (BUILD.asyncQueue) { plt.$flags$ |= PLATFORM_FLAGS.appLoaded; }