This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linky): throw error if input is not a string
BREAKING CHANGE: Before this change, the filter assumed that the input (if not undefined/null) was of type 'string' and that certain methods (such as `.match()`) would be available on it. Passing a non-string value would most likely result in a not-very-useful error being thrown (trying to call a method that does not exist) or in unexpected behavior (if the input happened to have the assumed methods). After this change, a proper (informative) error will be thrown. If you want to pass non-string values through `linky`, you need to explicitly convert them to strings first. Since input values could be initialized asynchronously, `undefined` or `null` will still be returned unchanged (without throwing an error). Closes #13547 Closes #13693
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@ngdoc error | ||
@name linky:notstring | ||
@fullName Not a string | ||
@description | ||
|
||
This error occurs when {@link ngSanitize.linky linky} is used with a non-empty, non-string value: | ||
```html | ||
<div ng-bind-html="42 | linky"></div> | ||
``` | ||
|
||
`linky` is supposed to be used with string values only, and therefore assumes that several methods | ||
(such as `.match()`) are available on the passed in value. | ||
The value can be initialized asynchronously and therefore null or undefined won't throw this error. | ||
|
||
If you want to pass non-string values to `linky` (e.g. Objects whose `.toString()` should be | ||
utilized), you need to manually convert them to strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters