File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ define ( [ 'module' ] , function ( module ) {
2+ 'use strict' ;
3+
4+ function _load ( tag ) {
5+ return function ( url ) {
6+ // This promise will be used by Promise.all to determine success or failure
7+ return new Promise ( function ( resolve , reject ) {
8+ var element = document . createElement ( tag ) ;
9+ var parent = 'body' ;
10+ var attr = 'src' ;
11+
12+ // Important success and error for the promise
13+ element . onload = function ( ) {
14+ return resolve ( url ) ;
15+ } ;
16+ element . onerror = function ( ) {
17+ return reject ( url ) ;
18+ } ;
19+
20+ // Need to set different attributes depending on tag type
21+ switch ( tag ) {
22+ case 'script' :
23+ element . async = true ;
24+ break ;
25+ case 'link' :
26+ element . type = 'text/css' ;
27+ element . rel = 'stylesheet' ;
28+ attr = 'href' ;
29+ parent = 'head' ;
30+ }
31+
32+ // Inject into document to kick off loading
33+ element [ attr ] = url ;
34+ document [ parent ] . appendChild ( element ) ;
35+ } ) ;
36+ } ;
37+ }
38+
39+ module . exports = {
40+ css : _load ( 'link' ) ,
41+ js : _load ( 'script' ) ,
42+ img : _load ( 'img' )
43+ } ;
44+ } ) ;
Original file line number Diff line number Diff line change 1515 < div id ="css-target "> </ div >
1616
1717 < script type ="text/javascript ">
18- curl . config ( { baseUrl : "../lib " } ) ;
18+ curl . config ( { baseUrl : "./ " } ) ;
1919 curl ( [ 'basic-loader-amd' ] , function ( load ) {
2020
2121 mocha . ui ( 'bdd' ) ;
Original file line number Diff line number Diff line change 99 "test:watch" : " npm t -- --watch --reporter min" ,
1010 "e2e" : " mocha-phantomjs ./e2e/test.html --ignore-ssl-errors=true --ssl-protocol=any" ,
1111 "build" : " shx rm -rf lib && babel src --ignore spec.js -d lib && babel -o lib/basic-loader-amd.js --plugins transform-es2015-modules-amd src/basic-loader.js" ,
12- "publish-test" : " shx rm -rf docs && mkdir docs && shx cp -r e2e/* docs/ && shx mv docs/test.html docs/index.html" ,
12+ "publish-test" : " shx rm -rf docs && mkdir docs && shx cp -r e2e/* docs/ && shx mv docs/test.html docs/index.html && shx cp lib/basic-loader-amd.js docs/basic-loader-amd.js && shx sed -i s/.. \\ /lib/. \\ //g docs/index.html " ,
1313 "precommit" : " npm run lint" ,
1414 "prepush" : " npm test && npm run e2e" ,
1515 "release" : " npm run build && git status --porcelain && git checkout master && git pull origin master && standard-version && git push --follow-tags origin master && npm publish --access=public"
You can’t perform that action at this time.
0 commit comments