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

Implement handleEvent #102

Closed
wants to merge 2 commits into from
Closed

Implement handleEvent #102

wants to merge 2 commits into from

Conversation

AutoSponge
Copy link

@AutoSponge AutoSponge commented Nov 20, 2017

Needs discussion and possibly further tests. Designed to build components. Any copy features built based on bel will likely want to copy el.events from element to element rather than their current implementation so this is likely a breaking change.

There's an alternate implementation that looks like this:

        el.events = el.events || {}
        el.handleEvent = dispatch
        el.events[type] = val
        el.addEventListener(type, el)

In this case, the listener points to the el and dispatch looks for the events object property. This may be a better pattern since it's easier for the implementer to overwrite handleEvent at the element level. When copying events, you can iterate over Object.keys(events).

It may be worse because when copying events between elements, you need to copy the events expando property and also add handleEvent instead of it all coming in the same package. You just have to remember skip handleEvent when iterating the events object.

@AutoSponge AutoSponge changed the title [WIP] Implement handleEvent Implement handleEvent Dec 3, 2017
@AutoSponge AutoSponge closed this May 13, 2019
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.

None yet

1 participant