Skip to content

Commit

Permalink
fix(cta): double ssr (webkit)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Jan 8, 2025
1 parent 5396671 commit 52f9c93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion elements/rh-cta/rh-cta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ export class RhCta extends LitElement {
}

override firstUpdated() {
const { href, variant } = this;
// workaround for lit-ssr bugs
if (!isServer) {
this.removeAttribute('defer-hydration');
const [, ...duplicateContainers] = this.shadowRoot?.querySelectorAll('#container') ?? [];
for (const dupe of duplicateContainers) {
dupe.remove();
}
}
// TODO: remove in next major version, recommend static HTML audits instead
const { href, variant } = this;
const cta =
this.shadowRoot?.querySelector('a')
?? this.shadowRoot?.querySelector('slot')?.assignedElements().find(isSupportedContent)
Expand Down

0 comments on commit 52f9c93

Please sign in to comment.