-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(tooltip): tooltip now accepts and sanitizes HTML content #154
Conversation
Sorry for the second commit. I always have to change the browser section of the Testacular config so I've gotten used to just ignoring it in On a different note, I would like to push a few more tooltip and popover changes this week, but I'll wait until this is approved by y'all so as to avoid any merge-related funk. |
LGTM, just would like to clarify one thing based on my comment. Great stuff, you've figured out all the places to change! I guess we will update README as well with more explicit instructions as I'm sure that people will keep forgetting to include ngSanitize :-( |
I did actually choose Doh! I did forget to change the README. It's always something... |
I dunno about the requirement of I think it would be better to just not sanitize it. Even though that's slightly dangerous, isn't it the user of the library's role to check the values he puts into the title? |
@ajoslin - That's a valid point and there will be many angry posts. But I would look at it from the perspective of least work. We can call |
What do you mean by "the user can do some manipulation with Can't you just use ng-bind-html-unsafe skipping the current $sanitize step? |
Yeah, that was pretty vague. :-) My assumption was that most of the time, any content populated from the server that would end up in a tooltip was probably part of some data set; if it's complex, then the user would have to do something like this in the controller: var $scope.itemsCopy = []; // so as not to overwrite the server data
angular.forEach( 'items', function ( item, idx ) {
item.prop.subprop = $sanitize( item.prop.subprop );
$scope.itemsCopy.push( item );
}); So I meant that we could include But at the end of the hangout earlier, we just decided not to include So actually, I'm just going to close this PR. :-) |
The tooltip uses the
$sanitize
service on the content passed to thetooltip
attribute and then binds that content in the template usingng-bind-html-unsafe
. The reason I used the service instead of theng-bind-html
attribute was to be able to design the tests to run exclusively off the scope, rather than requiring DOM knowledge, which would simply break with any template customization by the user.The ngSanitize module is now included during testing and a note was added to the requirements section of the docs to specify that module is required, but we may need to make it more clear.
Closes #142.