Ground up rewrite of bind/listenForBind#53
Merged
Conversation
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>
This was referenced Jul 20, 2020
Closed
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>
dgraham
approved these changes
Jul 20, 2020
koddsson
approved these changes
Jul 20, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@koddsson and I decided to rewrite the
bind/listenForBindimplementations 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.