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

feat(tooltip): change back to jqLite listeners #5157

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/tooltip/test/tooltip-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ describe('tooltip template', function() {
});

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down
24 changes: 7 additions & 17 deletions src/tooltip/test/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe('tooltip', function() {
});

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down Expand Up @@ -750,9 +748,7 @@ describe('tooltipWithDifferentSymbols', function() {
}));

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down Expand Up @@ -798,9 +794,7 @@ describe('tooltip positioning', function() {
}));

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down Expand Up @@ -856,9 +850,7 @@ describe('tooltipHtml', function() {
}));

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down Expand Up @@ -897,9 +889,7 @@ describe('$uibTooltipProvider', function() {
tooltipScope;

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down Expand Up @@ -1030,7 +1020,7 @@ describe('$uibTooltipProvider', function() {
});

describe('triggers', function() {
describe('triggers with a mapped value', function() {
describe('with a mapped value', function() {
beforeEach(module('ui.bootstrap.tooltip', function($uibTooltipProvider) {
$uibTooltipProvider.options({trigger: 'focus'});
}));
Expand Down Expand Up @@ -1077,7 +1067,7 @@ describe('$uibTooltipProvider', function() {
}));
});

describe('triggers with a custom mapped value', function() {
describe('with a custom mapped value', function() {
beforeEach(module('ui.bootstrap.tooltip', function($uibTooltipProvider) {
$uibTooltipProvider.setTriggers({ customOpenTrigger: 'foo bar' });
$uibTooltipProvider.options({trigger: 'customOpenTrigger'});
Expand Down
4 changes: 1 addition & 3 deletions src/tooltip/test/tooltip2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ describe('tooltip directive', function() {
}

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

element[0].dispatchEvent(evt);
element.trigger(evt);
element.scope().$$childTail.$digest();
}

Expand Down
31 changes: 13 additions & 18 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,20 +481,18 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
var unregisterTriggers = function() {
triggers.show.forEach(function(trigger) {
if (trigger === 'outsideClick') {
element[0].removeEventListener('click', toggleTooltipBind);
element.off('click', toggleTooltipBind);
} else {
element[0].removeEventListener(trigger, showTooltipBind);
element[0].removeEventListener(trigger, toggleTooltipBind);
element.off(trigger, showTooltipBind);
element.off(trigger, toggleTooltipBind);
}
});
triggers.hide.forEach(function(trigger) {
trigger.split(' ').forEach(function(hideTrigger) {
if (trigger === 'outsideClick') {
$document[0].removeEventListener('click', bodyHideTooltipBind);
} else {
element[0].removeEventListener(hideTrigger, hideTooltipBind);
}
});
if (trigger === 'outsideClick') {
$document.off('click', bodyHideTooltipBind);
} else {
element.off(trigger, hideTooltipBind);
}
});
};

Expand All @@ -506,17 +504,14 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s

if (triggers.show !== 'none') {
triggers.show.forEach(function(trigger, idx) {
// Using raw addEventListener due to jqLite/jQuery bug - #4060
if (trigger === 'outsideClick') {
element[0].addEventListener('click', toggleTooltipBind);
$document[0].addEventListener('click', bodyHideTooltipBind);
element.on('click', toggleTooltipBind);
$document.on('click', bodyHideTooltipBind);
} else if (trigger === triggers.hide[idx]) {
element[0].addEventListener(trigger, toggleTooltipBind);
element.on(trigger, toggleTooltipBind);
} else if (trigger) {
element[0].addEventListener(trigger, showTooltipBind);
triggers.hide[idx].split(' ').forEach(function(trigger) {
element[0].addEventListener(trigger, hideTooltipBind);
});
element.on(trigger, showTooltipBind);
element.on(triggers.hide[idx], hideTooltipBind);
}

element.on('keypress', function(e) {
Expand Down