Skip to content

Commit

Permalink
Use roots directly i guess
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Feb 15, 2022
1 parent d575a17 commit 1d15dc3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
5 changes: 2 additions & 3 deletions packages/astro/src/runtime/client/idle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/src/runtime/client/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/src/runtime/client/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/src/runtime/client/only.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/src/runtime/client/visible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1d15dc3

Please sign in to comment.