-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(tooltip/popover): fix usage with $sce #3563
feat(tooltip/popover): fix usage with $sce #3563
Conversation
@chrisirhc Tests fail... |
Allows for trusted resource URLs through Strict Contextual Escaping ($sce). If the an interpolated expression is used instead, then the benefits of SCE is lost. Fixes angular-ui#3558
Allows for trusted resource URLs through Strict Contextual Escaping ($sce). If the an interpolated expression is used instead, then the benefits of SCE is lost. Fixes angular-ui#3558
445ceb0
to
8c37865
Compare
Thanks for checking @karianna , I marked it as "WIP" because of the failing tests. Just updated it. |
@@ -20,7 +20,7 @@ | |||
<a href="#" tooltip-animation="false" tooltip="I don't fade. :-(">fading</a> | |||
at elementum eu, facilisis sed odio morbi quis commodo odio. In cursus | |||
<a href="#" tooltip-popup-delay='1000' tooltip='appears with delay'>delayed</a> turpis massa tincidunt dui ut. | |||
<a href="#" tooltip-template="myTooltipTemplate.html">Custom template</a> | |||
<a href="#" tooltip-template="'myTooltipTemplate.html'">Custom template</a> |
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.
Can you explain this change? This seems a little awkward for use.
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.
This is because if a user needs to use a trusted resource url, the user can now do the following.
In controller:
$scope.templateUrl = $sce.trustAsResourceUrl('http://someurl.com/template.htm');
In template tooltip-template="templateUrl"
.
Before, the if the user did tooltip-template="{{templateUrl}}
, the URL gets converted into a plain string after interpolation and hence, loses its trusted context. Then there's no way for the user to specify a trusted URL. $sce
trust isn't needed for URLs on the current security origin but will fail when the user specifies URLs from another security origin (different domain/protocol/port).
This PR LGTM, just had a question about a change. |
Both those Plunkers aren't using the popover directive. Did you press "Save" to make sure that the Plunker updated? |
Please open another issue if this isn't related to this particular PR. We can talk about it there. |
Closes #3558