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

216
Visualizações
Why Vue3 is clearing event:Event in a setTimeout while compiling into a Web Custom Element

I have a Vue3.2 (3.2.33) component which is perfectly working while deployed as a SPA. I tried to wrap it as a web Custom Element with a very sample wrapping:

import { defineCustomElement } from 'vue';
import TrackJoiner from '@/views/TrackJoinerView.vue'

const TrackJoinerElement = defineCustomElement({...TrackJoiner})

customElements.define('trackjoiner-element', TrackJoinerElement)

The custom element is perfectly inserted in my html page with

<trackjoiner-element/>

The problem comes with a call to my API in a setTimeout. In fact the event becomes null in the setTimeout callback, this is the Vue3 method:

  methods: {
    clickFile(event: Event, trackType: trackTypes) {
      (this.state as ReactiveData).isLoading = true;
      setTimeout(() => {
        openFileAsPromise(event, trackType).then(() => {
          this.updateRows();
        });
      });
    },

While debugging I saw that event is correct before calling setTimeout(), but becomes null while calling openFileAsPromise(event, trackType) but trackType remains correct.

While running as a Vue3 SPA this code works perfectly and the event is forwarded to openFileAsPromise()

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