Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init side-effects #3

Open
dy opened this issue Jun 12, 2019 · 2 comments
Open

Init side-effects #3

dy opened this issue Jun 12, 2019 · 2 comments

Comments

@dy
Copy link
Contributor

dy commented Jun 12, 2019

  1. It won't trigger initial onload for elements that are in DOM already:
import onload from "fast-on-load";
onload(document.body, () => console.log('on'), () => console.log('off'))
// silence in console
  1. It triggers unload-only for elements present in both added/removed nodes:
let a = document.createElement(a)
onload(a, function () {
  console.log('on')
}, function () {
  console.log('off')
})

document.body.appendChild(a)
document.body.removeChild(a)

// logs only 'off' 

Just to make sure if that's planned behavior.

@mafintosh
Copy link
Member

  1. is working as designed.
  2. good question what the intend is here. @bcomnes @emilbayes wdyt?

@bcomnes
Copy link
Contributor

bcomnes commented Jun 12, 2019

  1. could go either way. If you want to support ssr then you probably need to make this an option. If you want to keep this as an editorialized constraint, keeping it as is buys some simplicity.

  2. sounds like a bug in the general conceptual sense. It should fire both. Are we auto wrapping callbacks in micro tasks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants