From 1d15dc377113558c1cdef797ff0576626616d989 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 15 Feb 2022 10:46:01 -0500 Subject: [PATCH] Use roots directly i guess --- packages/astro/src/runtime/client/idle.ts | 5 ++--- packages/astro/src/runtime/client/load.ts | 5 ++--- packages/astro/src/runtime/client/media.ts | 5 ++--- packages/astro/src/runtime/client/only.ts | 5 ++--- packages/astro/src/runtime/client/visible.ts | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/astro/src/runtime/client/idle.ts b/packages/astro/src/runtime/client/idle.ts index e7deba86ce76..23f377f8b105 100644 --- a/packages/astro/src/runtime/client/idle.ts +++ b/packages/astro/src/runtime/client/idle.ts @@ -11,13 +11,12 @@ export default async function onIdle(astroId: string, options: HydrateOptions, g throw new Error(`Unable to find the root for the component ${options.name}`); } - const root = roots[0]; let innerHTML: string | null = null; - let fragment = root.querySelector(`astro-fragment`); + let fragment = roots[0].querySelector(`astro-fragment`); if(fragment == null) { // If there is no child fragment, check to see if there is a template. // This happens if children were passed but the client component did not render any. - let template = root.querySelector(`template[data-astro-template]`); + let template = roots[0].querySelector(`template[data-astro-template]`); if(template) { innerHTML = template.innerHTML; template.remove(); diff --git a/packages/astro/src/runtime/client/load.ts b/packages/astro/src/runtime/client/load.ts index 9e788569822c..faba0dd69568 100644 --- a/packages/astro/src/runtime/client/load.ts +++ b/packages/astro/src/runtime/client/load.ts @@ -9,13 +9,12 @@ export default async function onLoad(astroId: string, options: HydrateOptions, g throw new Error(`Unable to find the root for the component ${options.name}`); } - const root = roots[0]; let innerHTML: string | null = null; - let fragment = root.querySelector(`astro-fragment`); + let fragment = roots[0].querySelector(`astro-fragment`); if(fragment == null) { // If there is no child fragment, check to see if there is a template. // This happens if children were passed but the client component did not render any. - let template = root.querySelector(`template[data-astro-template]`); + let template = roots[0].querySelector(`template[data-astro-template]`); if(template) { innerHTML = template.innerHTML; template.remove(); diff --git a/packages/astro/src/runtime/client/media.ts b/packages/astro/src/runtime/client/media.ts index 9aadf7d11597..92a29939ec5e 100644 --- a/packages/astro/src/runtime/client/media.ts +++ b/packages/astro/src/runtime/client/media.ts @@ -9,13 +9,12 @@ export default async function onMedia(astroId: string, options: HydrateOptions, throw new Error(`Unable to find the root for the component ${options.name}`); } - const root = roots[0]; let innerHTML: string | null = null; - let fragment = root.querySelector(`astro-fragment`); + let fragment = roots[0].querySelector(`astro-fragment`); if(fragment == null) { // If there is no child fragment, check to see if there is a template. // This happens if children were passed but the client component did not render any. - let template = root.querySelector(`template[data-astro-template]`); + let template = roots[0].querySelector(`template[data-astro-template]`); if(template) { innerHTML = template.innerHTML; template.remove(); diff --git a/packages/astro/src/runtime/client/only.ts b/packages/astro/src/runtime/client/only.ts index ca917014dbb5..a16443bb0d88 100644 --- a/packages/astro/src/runtime/client/only.ts +++ b/packages/astro/src/runtime/client/only.ts @@ -9,13 +9,12 @@ export default async function onLoad(astroId: string, options: HydrateOptions, g throw new Error(`Unable to find the root for the component ${options.name}`); } - const root = roots[0]; let innerHTML: string | null = null; - let fragment = root.querySelector(`astro-fragment`); + let fragment = roots[0].querySelector(`astro-fragment`); if(fragment == null) { // If there is no child fragment, check to see if there is a template. // This happens if children were passed but the client component did not render any. - let template = root.querySelector(`template[data-astro-template]`); + let template = roots[0].querySelector(`template[data-astro-template]`); if(template) { innerHTML = template.innerHTML; template.remove(); diff --git a/packages/astro/src/runtime/client/visible.ts b/packages/astro/src/runtime/client/visible.ts index 61e5afbd9f15..16e4e7cb29c9 100644 --- a/packages/astro/src/runtime/client/visible.ts +++ b/packages/astro/src/runtime/client/visible.ts @@ -11,13 +11,12 @@ export default async function onVisible(astroId: string, options: HydrateOptions throw new Error(`Unable to find the root for the component ${options.name}`); } - const root = roots[0]; let innerHTML: string | null = null; - let fragment = root.querySelector(`astro-fragment`); + const fragment = roots[0].querySelector(`astro-fragment`); if(fragment == null) { // If there is no child fragment, check to see if there is a template. // This happens if children were passed but the client component did not render any. - let template = root.querySelector(`template[data-astro-template]`); + const template = roots[0].querySelector(`template[data-astro-template]`); if(template) { innerHTML = template.innerHTML; template.remove();