Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
data- attributes don't work when lazy loading components in svelte

I was lazy loading some components on my svelte applications (followed this guide - https://www.youtube.com/watch?v=eXM0i6qgJyY) but data- attributes don't work on lazy-loaded components.

In my case, I am using Flowbite for popovers but the popovers don't work and upon inspecting the page, I found out that the data- attribute wasn't present in the HTML.

Lazy loading is handled by the following reusable component -

<script>
let loadComponent;
export { loadComponent as this };

const componentPromise = loadComponent();
</script>

{#await componentPromise}
  <slot name="loading">Loading...</slot>
{:then { default: Component }}
  <slot name="component" {Component} />
{/await}

For components being lazy loaded, this is how I have coded it -

<Lazy this={() => import("../components/blog-posts.svelte")}>
  <div slot="loading">Loading</div>
  <svelte:fragment slot="component" let:Component>
    <Component blogPosts={blogData.posts} blogBaseUrl={data.blogBaseUrl} />
  </svelte:fragment>
</Lazy>

The source code for the website - https://github.com/AnishDe12020/portfolio

Would be helpful if someone could let me know if I am going wrong anywhere (maybe there is a better way to lazy load that preserves the data- attributes?)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda