angular-bind-html-compile
angular-bind-html-compile copied to clipboard
Odd comment doesn't match code logic
If this is a case that only happens some of the time, then why does the code always call the - toString - method? And if - value - is "falsey" (e.g. an empty string, 0, null, etc.) then it will be passed to the - html - method (which sets the innerHTML property of the element)?
The intent of the code is just not clear. For example, what is allowed for the - value - argument? For another, what is supposed to happen if it is a disallowed value (e.g. assume that setting the innerHTML property to "null" is not intended). The comment isn't helping either; if anything, it makes the intent less clear.
// In case value is a TrustedValueHolderType, sometimes it // needs to be explicitly called into a string in order to // get the HTML string.
element.html(value && value.toString());