capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.24k stars 194 forks source link

Order of calls of connectedCallback and attributeChangedCallback is different in happy-dom and browser #1314

Open Mighty683 opened 5 months ago

Mighty683 commented 5 months ago

Describe the bug When I run the same component in browser first is called attributeChangedCallback and then connectedCallback. Inside happy-dom it's otherwise

To Reproduce Steps to reproduce the behavior:

  1. Create custom element
  2. Add observedAttributes, attributeChangedCallback, connectedCallback
  3. Create element

Minimal repro: https://github.com/Mighty683/happy-dom-repro Run dev and test check console of both

Expected behavior Order of calls is the same for browser and test environment

Screenshots obraz

obraz

Device:

Additional context I have checked Chrome and Firefox, it seems connected callback is called after. Maybe it's not a bug but connected to setting body by innerHTML?