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

Commit acdc2d7

Browse files
committed
upgrade to new plugin format
1 parent 83a718e commit acdc2d7

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

css.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,34 @@ var webkitLoadCheck = function(link, callback) {
2323

2424
var noop = function() {}
2525

26-
var loadCSS = function(url, callback, errback) {
27-
var timeout = setTimeout(function() {
28-
errback('Unable to load CSS');
29-
}, waitSeconds * 1000);
30-
var _callback = function() {
31-
clearTimeout(timeout);
32-
link.onload = noop;
33-
setTimeout(callback, 7);
34-
}
35-
var link = document.createElement('link') ;
36-
link.type = 'text/css';
37-
link.rel = 'stylesheet';
38-
link.href = url;
39-
40-
if (!isWebkit)
41-
link.onload = _callback;
42-
else
43-
webkitLoadCheck(link, _callback);
44-
45-
head.appendChild(link);
26+
var loadCSS = function(url) {
27+
return new Promise(function(resolve, reject) {
28+
var timeout = setTimeout(function() {
29+
reject('Unable to load CSS');
30+
}, waitSeconds * 1000);
31+
var _callback = function() {
32+
clearTimeout(timeout);
33+
link.onload = noop;
34+
setTimeout(resolve, 7);
35+
}
36+
var link = document.createElement('link') ;
37+
link.type = 'text/css';
38+
link.rel = 'stylesheet';
39+
link.href = url;
40+
41+
if (!isWebkit)
42+
link.onload = _callback;
43+
else
44+
webkitLoadCheck(link, _callback);
45+
46+
head.appendChild(link);
47+
});
4648
}
4749

48-
49-
module.exports = function(name, address, fetch, callback, errback) {
50+
exports.fetch = function(load) {
5051
// dont reload styles loaded in the head
5152
for (var i = 0; i < linkHrefs.length; i++)
52-
if (address == linkHrefs[i])
53+
if (load.address == linkHrefs[i])
5354
return callback();
54-
loadCSS(address, callback, errback);
55+
return loadCSS(load.address);
5556
}

test.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: red;
3+
}

test.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script src="../es6-module-loader/dist/es6-module-loader.js"></script>
2+
<script src="../systemjs/dist/system.js"></script>
3+
<script>
4+
System.import('test.css!');
5+
</script>

0 commit comments

Comments
 (0)