New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

systemjs-plugin-css

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

systemjs-plugin-css - npm Package Compare versions

Comparing version

to
0.1.22

clean-css.js

7

css-builder.js
// it's bad to do this in general, as code is now heavily environment specific
var fs = System._nodeRequire('fs');
var CleanCSS = require('./clean-css.js');

@@ -45,3 +46,2 @@ function escape(source) {

return loader['import']('clean-css').then(function(CleanCSS) {
// SystemJS Builder 0.14 will write the stubs for use, we detect by the 3 argument over 2 argument bundle call

@@ -94,7 +94,2 @@ var writeStubs = typeof outputOpts == 'undefined';

return [stubDefines, cssInject, '("' + escape(cssOutput) + '");'].join('\n');
}, function(err) {
if (err.toString().indexOf('ENOENT') != -1)
throw new Error('Install Clean CSS via `jspm install npm:clean-css --dev` for CSS build support. Set System.buildCSS = false to skip CSS builds.');
throw err;
});
};

@@ -6,9 +6,2 @@ if (typeof window !== 'undefined') {

// get all link tags in the page
var links = document.getElementsByTagName('link');
var linkHrefs = [];
for (var i = 0; i < links.length; i++) {
linkHrefs.push(links[i].href);
}
var isWebkit = !!window.navigator.userAgent.match(/AppleWebKit\/([^ ;]*)/);

@@ -26,5 +19,24 @@ var webkitLoadCheck = function(link, callback) {

var cssIsReloadable = function cssIsReloadable(links){
// Css loaded on the page initially should be skipped by the first
// systemjs load, and marked for reload
var reloadable = true;
forEach(links, function(link){
if(!link.hasAttribute('data-systemjs-css')){
reloadable = false;
link.setAttribute('data-systemjs-css', '');
}
});
return reloadable;
}
var findExistingCSS = function findExistingCSS(url){
// Search for existing link to reload
var links = head.getElementsByTagName('link')
return filter(links, function(link){ return link.href === url; });
}
var noop = function() {};
var loadCSS = function(url) {
var loadCSS = function(url, existingLinks) {
return new Promise(function(resolve, reject) {

@@ -48,2 +60,3 @@ var timeout = setTimeout(function() {

link.href = url;
link.setAttribute('data-systemjs-css', '');
if (!isWebkit) {

@@ -59,4 +72,12 @@ link.onload = function() {

};
head.appendChild(link);
});
head.insertBefore(link, existingLinks[0]);
})
// Remove the old link regardless of loading outcome
.then(function(result){
forEach(existingLinks, function(link){link.parentElement.removeChild(link);})
return result;
}, function(err){
forEach(existingLinks, function(link){link.parentElement.removeChild(link);})
throw err;
})
};

@@ -66,6 +87,6 @@

// dont reload styles loaded in the head
for (var i = 0; i < linkHrefs.length; i++)
if (load.address == linkHrefs[i])
var links = findExistingCSS(load.address)
if(!cssIsReloadable(links))
return '';
return loadCSS(load.address);
return loadCSS(load.address, links);
};

@@ -86,3 +107,3 @@ }

// don't load the CSS at all until build time
return '';
return Promise.resolve('');
};

@@ -105,1 +126,18 @@ exports.instantiate = function() {};

}
// Because IE8?
function filter(arrayLike, func){
var arr = []
forEach(arrayLike, function(item){
if(func(item))
arr.push(item);
});
return arr;
}
// Because IE8?
function forEach(arrayLike, func){
for (var i = 0; i < arrayLike.length; i++) {
func(arrayLike[i])
}
}
{
"name": "systemjs-plugin-css",
"version": "0.1.20",
"version": "0.1.22",
"main": "css",
"registry": "jspm"
"registry": "jspm",
"scripts": {
"test": "mocha --harmony test/test.js"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"mocha": "^2.4.5",
"mocha-phantomjs": "^4.0.2",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"systemjs": "^0.19.28",
"systemjs-builder": "^0.15.17"
}
}

@@ -6,2 +6,10 @@ css

Installation
---
For installing with JSPM run:
```
jspm install css
```
Basic Use

@@ -8,0 +16,0 @@ ---

Sorry, the diff of this file is not supported yet