Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
upgrade to new plugin format
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 15, 2014
1 parent 83a718e commit acdc2d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
49 changes: 25 additions & 24 deletions css.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,34 @@ var webkitLoadCheck = function(link, callback) {

var noop = function() {}

var loadCSS = function(url, callback, errback) {
var timeout = setTimeout(function() {
errback('Unable to load CSS');
}, waitSeconds * 1000);
var _callback = function() {
clearTimeout(timeout);
link.onload = noop;
setTimeout(callback, 7);
}
var link = document.createElement('link') ;
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;

if (!isWebkit)
link.onload = _callback;
else
webkitLoadCheck(link, _callback);

head.appendChild(link);
var loadCSS = function(url) {
return new Promise(function(resolve, reject) {
var timeout = setTimeout(function() {
reject('Unable to load CSS');
}, waitSeconds * 1000);
var _callback = function() {
clearTimeout(timeout);
link.onload = noop;
setTimeout(resolve, 7);
}
var link = document.createElement('link') ;
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;

if (!isWebkit)
link.onload = _callback;
else
webkitLoadCheck(link, _callback);

head.appendChild(link);
});
}


module.exports = function(name, address, fetch, callback, errback) {
exports.fetch = function(load) {
// dont reload styles loaded in the head
for (var i = 0; i < linkHrefs.length; i++)
if (address == linkHrefs[i])
if (load.address == linkHrefs[i])
return callback();
loadCSS(address, callback, errback);
return loadCSS(load.address);
}
3 changes: 3 additions & 0 deletions test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
background-color: red;
}
5 changes: 5 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script src="../es6-module-loader/dist/es6-module-loader.js"></script>
<script src="../systemjs/dist/system.js"></script>
<script>
System.import('test.css!');
</script>

0 comments on commit acdc2d7

Please sign in to comment.