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', () => {
80
80
it ( 'attaches script tag to document with data attributes' , async ( ) => {
81
81
await loader . loadScript (
82
82
'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' } } ) ;
85
84
86
85
expect ( script . attributes . getNamedItem ( 'data-attribute1' ) ! . value )
87
86
. toEqual ( '1' ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import BrowserSupport from './browser-support';
4
4
5
5
export interface LoadScriptOptions {
6
6
async : boolean ;
7
+ attributes : ScriptAttributes ;
7
8
}
8
9
9
10
export interface PreloadScriptOptions {
@@ -26,11 +27,12 @@ export default class ScriptLoader {
26
27
private _requestSender : RequestSender
27
28
) { }
28
29
29
- loadScript ( src : string , options ?: LoadScriptOptions , scriptAttributes ?: ScriptAttributes ) : Promise < void > {
30
+ loadScript ( src : string , options ?: LoadScriptOptions ) : Promise < void > {
30
31
if ( ! this . _scripts [ src ] ) {
31
32
this . _scripts [ src ] = new Promise ( ( resolve , reject ) => {
32
33
const script = document . createElement ( 'script' ) as LegacyHTMLScriptElement ;
33
34
const { async = false } = options || { } ;
35
+ const scriptAttributes = options && options . attributes ;
34
36
35
37
for ( const key in scriptAttributes ) {
36
38
if ( scriptAttributes . hasOwnProperty ( key ) ) {
You can’t perform that action at this time.
0 commit comments