-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(jqLite): allow triggerHandler()
to accept custom event
#8505
Conversation
This is one of those features that was left out of jqLite on purpose, but the implementation actually looks easier to read to me, so I think this is okay. @mzgol should review this though, imo |
}]; | ||
}; | ||
|
||
if ( eventName.type ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not use the jquery codestyle here though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry that is my dgeni coding style coming through :-)
Why was it left out? |
I wasn't here at the time it was left out, but my guess is that it was just simpler. Still, I think the code is a bit easier to read this way, so even if it's an extra feature it's still nice |
eventName = event.type; | ||
} | ||
|
||
var handlerArgs = [event].concat(eventData || []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't create memory garbage needlessly. use ternary operator plz
otherwise lgtm |
In some scenarios you want to be able to specify properties on the event that is passed to the event handler. JQuery does this by overloading the first parameter (`eventName`). If it is an object with a `type` property then we assume that it must be a custom event. In this case the custom event must provide the `type` property which is the name of the event to be triggered. `triggerHandler` will continue to provide dummy default functions for `preventDefault()`, `isDefaultPrevented()` and `stopPropagation()` but you may override these with your own versions in your custom object if you wish. Closes angular#8469
In some scenarios you want to be able to specify properties on the event that is passed to the event handler. JQuery does this by overloading the first parameter (`eventName`). If it is an object with a `type` property then we assume that it must be a custom event. In this case the custom event must provide the `type` property which is the name of the event to be triggered. `triggerHandler` will continue to provide dummy default functions for `preventDefault()`, `isDefaultPrevented()` and `stopPropagation()` but you may override these with your own versions in your custom object if you wish. Closes angular#8469
In some scenarios you want to be able to specify properties on the event that is passed to the event handler. JQuery does this by overloading the first parameter (`eventName`). If it is an object with a `type` property then we assume that it must be a custom event. In this case the custom event must provide the `type` property which is the name of the event to be triggered. `triggerHandler` will continue to provide dummy default functions for `preventDefault()`, `isDefaultPrevented()` and `stopPropagation()` but you may override these with your own versions in your custom object if you wish. Closes angular#8469
I have updated the algorithm to be exit earlier if there are no handlers ( I also changed the parameter name from
|
@IgorMinar says we can go ahead and merge this |
it might be a good idea to wait until they're done with the jquery stuff, but it's probably fine. |
anyways, lgtm |
Closed via 01d81cd |
In some scenarios you want to be able to specify properties on the event that is passed to the event handler. JQuery does this by overloading the first parameter (`eventName`). If it is an object with a `type` property then we assume that it must be a custom event. In this case the custom event must provide the `type` property which is the name of the event to be triggered. `triggerHandler` will continue to provide dummy default functions for `preventDefault()`, `isDefaultPrevented()` and `stopPropagation()` but you may override these with your own versions in your custom object if you wish. In addition the commit provides some performance and memory usage improvements by only creating objects and doing work that is necessary. This commit also renames the parameters inline with jQuery. Closes #8469 Closes #8505
In some scenarios you want to be able to specify properties on the event
that is passed to the event handler. JQuery does this by overloading the
first parameter (
eventName
). If it is an object with atype
propertythen we assume that it must be a custom event.
In this case the custom event must provide the
type
property which isthe name of the event to be triggered.
triggerHandler
will continue toprovide dummy default functions for
preventDefault()
,isDefaultPrevented()
and
stopPropagation()
but you may override these with your own versionsin your custom object if you wish.
Closes #8469