@@ -32,6 +32,8 @@ import {
32
32
EventEmitter ,
33
33
} from '@angular/core' ;
34
34
import { isPlatformBrowser } from '@angular/common' ;
35
+ import { trustedResourceUrl } from 'safevalues' ;
36
+ import { setScriptSrc } from 'safevalues/dom' ;
35
37
import { Observable , of as observableOf , Subject , BehaviorSubject , fromEventPattern } from 'rxjs' ;
36
38
import { takeUntil , switchMap } from 'rxjs/operators' ;
37
39
import { PlaceholderImageQuality , YouTubePlayerPlaceholder } from './youtube-player-placeholder' ;
@@ -743,7 +745,7 @@ function loadApi(nonce: string | null): void {
743
745
}
744
746
745
747
// 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` ;
747
749
const script = document . createElement ( 'script' ) ;
748
750
const callback = ( event : Event ) => {
749
751
script . removeEventListener ( 'load' , callback ) ;
@@ -759,7 +761,7 @@ function loadApi(nonce: string | null): void {
759
761
} ;
760
762
script . addEventListener ( 'load' , callback ) ;
761
763
script . addEventListener ( 'error' , callback ) ;
762
- ( script as any ) . src = url ;
764
+ setScriptSrc ( script , url ) ;
763
765
script . async = true ;
764
766
765
767
if ( nonce ) {
0 commit comments