File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,7 @@ describe('ScriptLoader', () => {
8080 it ( 'attaches script tag to document with data attributes' , async ( ) => {
8181 await loader . loadScript (
8282 'https://code.jquery.com/jquery-3.2.1.min.js' ,
83- undefined ,
84- { 'data-attribute1' : '1' , 'data-attribute2' : '2' } ) ;
83+ { async : true , attributes : { 'data-attribute1' : '1' , 'data-attribute2' : '2' } } ) ;
8584
8685 expect ( script . attributes . getNamedItem ( 'data-attribute1' ) ! . value )
8786 . toEqual ( '1' ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import BrowserSupport from './browser-support';
44
55export interface LoadScriptOptions {
66 async : boolean ;
7+ attributes : ScriptAttributes ;
78}
89
910export interface PreloadScriptOptions {
@@ -26,11 +27,12 @@ export default class ScriptLoader {
2627 private _requestSender : RequestSender
2728 ) { }
2829
29- loadScript ( src : string , options ?: LoadScriptOptions , scriptAttributes ?: ScriptAttributes ) : Promise < void > {
30+ loadScript ( src : string , options ?: LoadScriptOptions ) : Promise < void > {
3031 if ( ! this . _scripts [ src ] ) {
3132 this . _scripts [ src ] = new Promise ( ( resolve , reject ) => {
3233 const script = document . createElement ( 'script' ) as LegacyHTMLScriptElement ;
3334 const { async = false } = options || { } ;
35+ const scriptAttributes = options && options . attributes ;
3436
3537 for ( const key in scriptAttributes ) {
3638 if ( scriptAttributes . hasOwnProperty ( key ) ) {
You can’t perform that action at this time.
0 commit comments