Skip to content

Ground up rewrite of bind/listenForBind#53

Merged
keithamus merged 17 commits intomasterfrom
fix-listenforbind-handle-children
Jul 21, 2020
Merged

Ground up rewrite of bind/listenForBind#53
keithamus merged 17 commits intomasterfrom
fix-listenforbind-handle-children

Conversation

@keithamus
Copy link
Copy Markdown
Contributor

@koddsson and I decided to rewrite the bind/listenForBind implementations in light of #50 and #51.

#50 attempts to fix bugs in deep traversal but introduces new ones, as discovered by @muan in #50 (comment)

#51 was an attempt to move #50 in a different direction by having a centralised EventHandler which dispatches events. It fixes the bug in #50 but it added complexity.

This PR is an attempt to take the broad learning from #51 and #50 but ignore the implementation details and write it from scratch. The result is, I believe, much simpler refactoring of these methods which does the minimal amount of work when it needs to.

keithamus and others added 9 commits July 20, 2020 11:52
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
This is a rewrite from first-principles of `bind` and `listenForBind` to
balance readability and performance, in light of the current
requirements (as encoded by tests).

Co-authored-by: Kristján Oddsson <koddsson@gmail.com>
dgraham and others added 8 commits July 20, 2020 10:24
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
The addEventListener function binds only once based on the listener
function's identity. We're passing `handleEvent` rather than a function
closure so we can invoke addEventListener multiple times.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
The handleEvent function is bound only to Element targets.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@muan muan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@keithamus keithamus merged commit 9c8fb8d into master Jul 21, 2020
@keithamus keithamus deleted the fix-listenforbind-handle-children branch July 21, 2020 06:56
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

Successfully merging this pull request may close these issues.

4 participants