Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 3d87453

Browse files
authored
fix(tooltip): resolve expressions against correct scope (#10596)
1 parent 562b1c9 commit 3d87453

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/components/tooltip/tooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $interpolate,
106106
function addAriaLabel(labelText) {
107107
// Only interpolate the text from the HTML element because otherwise the custom text could
108108
// be interpolated twice and cause XSS violations.
109-
var interpolatedText = labelText || $interpolate(element.text().trim())(parent.scope);
109+
var interpolatedText = labelText || $interpolate(element.text().trim())(scope.$parent);
110110

111111
// Only add the `aria-label` to the parent if there isn't already one, if there isn't an
112112
// already present `aria-labelledby`, or if the previous `aria-label` was added by the

src/components/tooltip/tooltip.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ describe('MdTooltip Component', function() {
1414
// Test filter for ensuring tooltip expressions are evaluated against the correct scope.
1515
angular.module('fullNameFilter', []).filter('fullName', function() {
1616
return function(user) {
17-
return user ? user.name.first + ' ' + user.name.last : "";
17+
// Intentionally dereference user without checking whether it is defined. Do not change!
18+
return user.name.first + ' ' + user.name.last;
1819
}
1920
});
2021

0 commit comments

Comments
 (0)