-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conformant with https://github.com/ecomfe/spec/blob/master/javascript…
- Loading branch information
Showing
2 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
/** | ||
* ESL (Enterprise Standard Loader) | ||
* Copyright 2013 Baidu Inc. All rights reserved. | ||
* | ||
* | ||
* @file CSS Loader-Plugin | ||
* @author errorrik([email protected]) | ||
*/ | ||
|
||
// 构建环境暂不支持分析,为了能合并该plugin到loader里, | ||
// 只能暂时使用具名id | ||
define( 'css', { | ||
load: function ( resourceId, req, load, config ) { | ||
var link = document.createElement( 'link' ); | ||
link.setAttribute( 'rel', 'stylesheet' ); | ||
link.setAttribute( 'type', 'text/css' ); | ||
link.setAttribute( 'href', req.toUrl( resourceId ) ); | ||
define('css', { | ||
load: function (resourceId, req, load) { | ||
var link = document.createElement('link'); | ||
link.setAttribute('rel', 'stylesheet'); | ||
link.setAttribute('type', 'text/css'); | ||
link.setAttribute('href', req.toUrl(resourceId)); | ||
|
||
var parent = document.getElementsByTagName( 'head' )[ 0 ] | ||
var parent = document.getElementsByTagName('head')[0] | ||
|| document.body; | ||
parent.appendChild( link ); | ||
parent.appendChild(link); | ||
|
||
parent = null; | ||
link = null; | ||
|
||
load( true ); | ||
load(true); | ||
} | ||
} ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
/** | ||
* ESL (Enterprise Standard Loader) | ||
* Copyright 2013 Baidu Inc. All rights reserved. | ||
* | ||
* | ||
* @file JS Loader-Plugin | ||
* @author errorrik([email protected]) | ||
*/ | ||
|
||
// 构建环境暂不支持分析,为了能合并该plugin到loader里, | ||
// 只能暂时使用具名id | ||
define( 'js', { | ||
load: function ( resourceId, req, load, config ) { | ||
define('js', { | ||
load: function (resourceId, req, load) { | ||
function onload() { | ||
var readyState = script.readyState; | ||
if ( | ||
typeof readyState == 'undefined' | ||
|| /^(loaded|complete)$/.test( readyState ) | ||
if ( | ||
typeof readyState === 'undefined' | ||
|| /^(loaded|complete)$/.test(readyState) | ||
) { | ||
script.onload = script.onreadystatechange = null; | ||
script = null; | ||
load( true ); | ||
load(true); | ||
} | ||
} | ||
|
||
var script = document.createElement( 'script' ); | ||
script.src = req.toUrl( resourceId ); | ||
var script = document.createElement('script'); | ||
script.src = req.toUrl(resourceId); | ||
script.async = true; | ||
if ( script.readyState ) { | ||
if (script.readyState) { | ||
script.onreadystatechange = onload; | ||
} | ||
else { | ||
script.onload = onload; | ||
} | ||
|
||
var parent = document.getElementsByTagName( 'head' )[ 0 ] | ||
var parent = document.getElementsByTagName('head')[0] | ||
|| document.body; | ||
parent.appendChild( script ) && ( parent = null ); | ||
parent.appendChild(script) && (parent = null); | ||
} | ||
} ); | ||
}); |