Hasty Treat - Things You Should Know About Javascript Events

May 4, 2020, 1 p.m. (4 years, 6 months ago)
0 Comments

In this Hasty Treat, Scott and Wes talk about javascript events, and how to avoid some common pitfalls!

Prismic - Sponsor

Prismic is a Headless CMS that makes it easy to build website pages as a set of components. Break pages into sections of components using React, Vue, or whatever you like. Make corresponding Slices in Prismic. Start building pages dynamically in minutes. Get started at prismic.io/syntax.

Show Notes

02:23 - Event bubbling

  • Some events bubble, some don’t
  • Clicks bubble
  • Mouseevents bubble
  • Focus doesn’t bubble

04:10 - Event capturing

  • Capture: down, bubble up
  • Canceling: prevent default
  • target` vs currentTarget
  • currentTarget is what got clicked
  • target is what you listened for the click on
  • event.isTrusted
  • addEventListener once: true

Links

Tweet us your tasty treats!

Login to Add New Comment
No comments have been posted yet, be the first one to comment.