I've just updated an application I'm working on from angular 11 to 12. (also updated typscript from 4.0.5 to 4.3.5). We noticed a difference in the application, when before I had an empty value I now get the text "null" in my application.
I've narrowed down where the problem occurs and it boils down to this: (I've hardcoded the null value for demo purpose)
<div>
<span [innerHTML]="null | sanitizeHtml"></span>
</div>
The pipe code:
@Pipe({
name: 'sanitizeHtml'
})
export class SanitizeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {
}
transform(v:string):SafeHtml {
return this._sanitizer.bypassSecurityTrustHtml(v);
}
}
So the safeHtml object returned by the bypassSecurityTrustHtml
seems to have changed, or the method has changed in dealing with a null value.
Can anyone explain this behavior?
EDIT
A stackblitz for reproducing the issue: https://stackblitz.com/edit/angular-v12-ejwhmd?file=package.json
EDIT 2
Created a bug for angular https://github.com/angular/angular/issues/43794