Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
erik168 committed Sep 11, 2014
1 parent a45d483 commit 80afecf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
22 changes: 11 additions & 11 deletions src/css.js
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);
}
} );
});
26 changes: 13 additions & 13 deletions src/js.js
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);
}
} );
});

0 comments on commit 80afecf

Please sign in to comment.