File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11function _load ( tag ) {
22 // attributes example: { 'data-test': 'new-attribute-here' }
3- return function ( url , attributes = { } ) {
3+ return function ( url , attributes = { } ) {
44 // This promise will be used by Promise.all to determine success or failure
55 return new Promise ( ( resolve , reject ) => {
66 let element = document . createElement ( tag ) ;
7- let parent = " body" ;
8- let attr = " src" ;
7+ let parent = ' body' ;
8+ let attr = ' src' ;
99
1010 // Important success and error for the promise
1111 element . onload = ( ) => resolve ( url ) ;
1212 element . onerror = ( ) => reject ( url ) ; // maybe we should remove the broken node, who knows
1313
1414 // Need to set different attributes depending on tag type
1515 switch ( tag ) {
16- case " script" :
16+ case ' script' :
1717 element . async = true ;
1818 break ;
19- case " link" :
20- element . type = " text/css" ;
21- element . rel = " stylesheet" ;
22- attr = " href" ;
23- parent = " head" ;
19+ case ' link' :
20+ element . type = ' text/css' ;
21+ element . rel = ' stylesheet' ;
22+ attr = ' href' ;
23+ parent = ' head' ;
2424 }
2525
2626 // Inject into document to kick off loading
@@ -35,7 +35,7 @@ function _load(tag) {
3535
3636// exporting a "default" would render the amd package to work differently
3737module . exports = {
38- css : _load ( " link" ) ,
39- js : _load ( " script" ) ,
40- img : _load ( " img" )
38+ css : _load ( ' link' ) ,
39+ js : _load ( ' script' ) ,
40+ img : _load ( ' img' )
4141} ;
You can’t perform that action at this time.
0 commit comments