-
Notifications
You must be signed in to change notification settings - Fork 3
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
When the element is can-defined, not able to dispatch DOM events #15
Comments
This adds a test for DOM events that currently doesn't work. Skipping it for now so that we can get it into master. For #15
There's a test in master that is being skipped for this bug, DOM events work when can-defined |
So to summarize, we need to support both defined property events and arbitrary DOM events. @justinbmeyer One way to fix this would be to wrap canEvent.addEventListener and fallback to the Pseudo-code: var canEvent = require("can-event");
var aEL = canEvent.addEventListener;
canEvent.addEventListener = function(eventName, fn){
if((this instanceof HTMLElement) && !this._define.definitions[eventName]) {
return Node.prototype.addEventListener.apply(this, arguments);
}
return aEL.apply(this, arguments);
}; |
Implemented the above in #19 |
This fixes #15. Wraps canEvents.addEventListener to fallback to DOM events if the event isn't for a defined property.
We probably need can-define to not setup its own event stuff if it exists already
…Sent from my iPhone
On Jan 22, 2017, at 4:15 PM, Matthew Phillips ***@***.***> wrote:
Implemented the above in #19
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'm not understanding how that could work. If someone listens to a defined property event it has to go through the can-event system, doesn't it? Otherwise that property isn't bound and won't fire events. |
It doesn't have to go through I'm betting it can keep native DOM events and avoid using |
Regarding batches, you can probably add the event dispatching in the event queue, so it would be fired at the right time. You'll have to make sure it add the batchNum, but everything should be possible. |
I don't think I'm following your suggestion here. can-define does all of this stuff: https://github.com/canjs/can-define/blob/master/can-define.js#L649 You are saying to remove this, correct? If we remove that, how will it know that a property is being observed? |
" property is being observed" happens when a property is being read and isn't related to the code you shared. However, that code is important. Could we provide our own |
Filed canjs/can-define#145 |
this should dispatch the event on the element, but since can-define sets up its own addEventListener, the DOM event doesn't work.
The text was updated successfully, but these errors were encountered: