@@ -32,6 +32,8 @@ import {
3232 EventEmitter ,
3333} from '@angular/core' ;
3434import { isPlatformBrowser } from '@angular/common' ;
35+ import { trustedResourceUrl } from 'safevalues' ;
36+ import { setScriptSrc } from 'safevalues/dom' ;
3537import { Observable , of as observableOf , Subject , BehaviorSubject , fromEventPattern } from 'rxjs' ;
3638import { takeUntil , switchMap } from 'rxjs/operators' ;
3739import { PlaceholderImageQuality , YouTubePlayerPlaceholder } from './youtube-player-placeholder' ;
@@ -743,7 +745,7 @@ function loadApi(nonce: string | null): void {
743745 }
744746
745747 // We can use `document` directly here, because this logic doesn't run outside the browser.
746- const url = ' https://www.youtube.com/iframe_api' ;
748+ const url = trustedResourceUrl ` https://www.youtube.com/iframe_api` ;
747749 const script = document . createElement ( 'script' ) ;
748750 const callback = ( event : Event ) => {
749751 script . removeEventListener ( 'load' , callback ) ;
@@ -759,7 +761,7 @@ function loadApi(nonce: string | null): void {
759761 } ;
760762 script . addEventListener ( 'load' , callback ) ;
761763 script . addEventListener ( 'error' , callback ) ;
762- ( script as any ) . src = url ;
764+ setScriptSrc ( script , url ) ;
763765 script . async = true ;
764766
765767 if ( nonce ) {
0 commit comments