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

209
Visualizações
Browser events default action - Is there a spec for it?

Some events has default action. For example - clicking on a checkbox will check/uncheck it. This can be prevented by the event.preventDefault() method.

While looking for the errorEvent default action, I could not find any documentation or specs about events default action - not only for errorEvent, but for ANY event. According to the DOM spec - Constructing events scetion

As of the time of this writing Web IDL does not yet define any default behavior; see whatwg/webidl#135.

Beyond that, I couldn't find any clear or update-to-date information regarding any progress on such spec. Is it possible such spec still doesn't finalize, so the default actions can be different for different browsers? or am I missing something?

UPDATE:

My question wasn't clear enough - clearly, an event can have different default actions for different context (e.g. a click event for a checkbox-input will have a different default action than a click event on a text-input)

Thanks to @kaiido's elaborated answer I've found the spec I was looking for (which is specifically for DOM UI events) - UI Events section 4.1 List of Event Types

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is no real "default action" per Event type, so no, you wont find a default action for "click" Events, nor for "error" Events.
What happens is that in various places, it is defined that after an event (note the lower-case "e"), some things should occur, among which, an Event may be dispatched, and then possibly something else, based on the canceled flag of the Event that got dispatched.

If you like to look at specs, then the DOM specifications define that when an event is being dispatched, the User Agent must check the canceled flag of the dispatched Event, and if it's still unset, then it must run the activation behavior of the target (step 11.1).
This activation behavior is what other specs will define and which thus correspond to the "default behavior" you are looking for.
Note that UI Events also goes into details with different terms to describe this same behavior.

Also, many specs may have their own ways of defining this behavior, for instance WebGL's contextlost event defines directly what should happen in the case the event has been canceled without defining an activation behavior, which wouldn't mean much on a WebGL context.

Thus, there isn't a single place where all such "preventable" actions are defined. Every specification may define many of these.
Browser's interoperability is preserved because they follow every specs that do define these.

Might be interesting to note though that your checkbox example is actually quite an outsider, since, for weird historical reasons, the default action of switching the .checked property is done before dispatching the Event, and after the Event has been dispatched it is being restored to the initial state if the event has been canceled.

about 4 years ago · Juan Pablo Isaza Relatório
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