Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(tooltip): switch to use raw DOM event bindings
Browse files Browse the repository at this point in the history
- Switch to use `addEventListener` and `removeEventListener` to prevent
  jqLite/jQuery bug where the events are swallowed on disabled elements

Closes #4322
Fixes #4060
  • Loading branch information
wesleycho committed Sep 1, 2015
1 parent d891c8d commit 7556bed
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 103 deletions.
14 changes: 10 additions & 4 deletions src/tooltip/test/tooltip-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ describe('tooltip template', function() {
tooltipScope = elmScope.$$childTail;
}));

function trigger(element, evt) {
evt = new Event(evt);

element[0].dispatchEvent(evt);
}

it('should open on mouseenter', inject(function() {
elm.trigger('mouseenter');
trigger(elm, 'mouseenter');
expect( tooltipScope.isOpen ).toBe( true );

expect( elmBody.children().length ).toBe( 2 );
Expand All @@ -41,7 +47,7 @@ describe('tooltip template', function() {
scope.templateUrl = null;
scope.$digest();

elm.trigger('mouseenter');
trigger(elm, 'mouseenter');
expect(tooltipScope.isOpen).toBe(false);

expect(elmBody.children().length).toBe(1);
Expand All @@ -51,7 +57,7 @@ describe('tooltip template', function() {
scope.myTemplateText = 'some text';
scope.$digest();

elm.trigger('mouseenter');
trigger(elm, 'mouseenter');
expect(tooltipScope.isOpen).toBe(true);

expect(elmBody.children().eq(1).text().trim()).toBe('some text');
Expand All @@ -63,7 +69,7 @@ describe('tooltip template', function() {
}));

it('should hide tooltip when template becomes empty', inject(function($timeout) {
elm.trigger('mouseenter');
trigger(elm, 'mouseenter');
expect(tooltipScope.isOpen).toBe(true);

scope.templateUrl = '';
Expand Down
Loading

0 comments on commit 7556bed

Please sign in to comment.