Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(jqLite): fire $destroy event via triggerHandler
Browse files Browse the repository at this point in the history
in jQuery 1.8.x the data() data structure is changed and events are
not accessible via data().events. Since all we need is to trigger
all event handlers, we can do so via triggerHandler() api instead of
mocking with the internal jQuery data structures.

This fix was originally proposed by PeteAppleton via PR #1512.

Closes #1512
  • Loading branch information
IgorMinar committed Nov 26, 2012
1 parent 650fd93 commit b9a9f91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ function JQLitePatchJQueryRemove(name, dispatchThis) {
for(setIndex = 0, setLength = set.length; setIndex < setLength; setIndex++) {
element = jqLite(set[setIndex]);
if (fireEvent) {
events = element.data('events');
if ( (fns = events && events.$destroy) ) {
forEach(fns, function(fn){
fn.handler();
});
}
element.triggerHandler('$destroy');
} else {
fireEvent = !fireEvent;
}
Expand Down
5 changes: 1 addition & 4 deletions test/ngScenario/ApplicationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ describe('angular.scenario.Application', function() {
var app, frames;

function callLoadHandlers(app) {
var handlers = app.getFrame_().data('events').load;
expect(handlers).toBeDefined();
expect(handlers.length).toEqual(1);
handlers[0].handler();
var handler = app.getFrame_().triggerHandler('load')
}

beforeEach(function() {
Expand Down

0 comments on commit b9a9f91

Please sign in to comment.