-
Notifications
You must be signed in to change notification settings - Fork 7
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
Should work with objects that have their own event system #145
Comments
I'll create a test with an object that has its own mini event emitter system so we can better look at the solution. |
Added a test here: c93641f |
@justinbmeyer I did a quick and dirty implementation that uses the element's native addEventListener here: 4fbb7eb The result of that change is that the DOM events now fire but the property events do not (without that change the opposite happens). |
This makes it possible to use can-define with HTML elements so that both property events and DOM events can be listened to and fire correctly. The method for doing this is to call to the existing `addEventListener` if one exists, otherwise to do the default action of calling to eventLifecycle.addAndSetup. Closes #145
This makes it possible to use can-define with HTML elements so that both property events and DOM events can be listened to and fire correctly. This is done by using the can-event/lifecycle/lifecycle mixin, and passing it our existing addEventListener (where it exists), rather than using canEvent.addEventListener as lifecycle did before. Closes #145
Last I left off with this there was a problem with can-observation expecting 3 argument events. I patched my local can-observation to fix this: onDependencyChange: function(ev, newVal, oldVal){
if(arguments.length === 1 && Array.isArray(ev.args)) {
newVal = ev.args[0];
newVal = ev.args[1];
}
this.dependencyChange(ev, newVal, oldVal);
}, However, it still fails because there is no batchNum associated with this event: The problem is that I changed can-define to use canEvent.trigger, which triggers real DOM events if it's a DOM element. However this fails because there is no batch stuff happening now. So I'm not sure how to fix this now. I suppose maybe canEvent.trigger might need to do some batching. |
@matthewp I've been thinking about this probably and how it relates to |
@matthewp |
Just noting that this never was fully fixed, should revisit. |
can-define should work with objects that already have an
addEventListener
, such as dom elements.The text was updated successfully, but these errors were encountered: