Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autoprefixer

Package Overview
Dependencies
Maintainers
1
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autoprefixer - npm Package Compare versions

Comparing version 0.3.20130502 to 0.4.20130507

2

component.json
{
"name": "autoprefixer",
"version": "0.3.20130502",
"version": "0.4.20130507",
"description": "Parse CSS and add prefixed properties and values by actual Can I Use database",

@@ -5,0 +5,0 @@ "keywords": ["css", "prefix", "rework"],

@@ -228,3 +228,22 @@ // Don't edit this files, because it's autogenerated.

"ios 5.1"
]
],
replace: function (string, prefix) {
var regexp;
if (prefix !== '-webkit-') {
return;
}
regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
if (deg) {
deg = parseInt(deg);
deg += 90;
if (deg > 360) {
deg -= 360;
}
return prefix + gradient + deg + 'deg';
} else {
return prefix + gradient;
}
});
}
},

@@ -288,3 +307,22 @@ "radial-gradient": {

"ios 5.1"
]
],
replace: function (string, prefix) {
var regexp;
if (prefix !== '-webkit-') {
return;
}
regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
if (deg) {
deg = parseInt(deg);
deg += 90;
if (deg > 360) {
deg -= 360;
}
return prefix + gradient + deg + 'deg';
} else {
return prefix + gradient;
}
});
}
},

@@ -348,3 +386,22 @@ "repeating-linear-gradient": {

"ios 5.1"
]
],
replace: function (string, prefix) {
var regexp;
if (prefix !== '-webkit-') {
return;
}
regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
if (deg) {
deg = parseInt(deg);
deg += 90;
if (deg > 360) {
deg -= 360;
}
return prefix + gradient + deg + 'deg';
} else {
return prefix + gradient;
}
});
}
},

@@ -408,4 +465,23 @@ "repeating-radial-gradient": {

"ios 5.1"
]
],
replace: function (string, prefix) {
var regexp;
if (prefix !== '-webkit-') {
return;
}
regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
if (deg) {
deg = parseInt(deg);
deg += 90;
if (deg > 360) {
deg -= 360;
}
return prefix + gradient + deg + 'deg';
} else {
return prefix + gradient;
}
});
}
}
};

@@ -18,2 +18,3 @@ /*

*/
(function () {
'use strict';

@@ -36,3 +37,3 @@

var splitPrefix = function (prop) {
if ( prop[0] == '-' ) {
if ( prop[0] === '-' ) {
var sep = prop.indexOf('-', 1) + 1;

@@ -48,3 +49,3 @@ return { prefix: prop.slice(0, sep), name: prop.slice(sep) };

return new RegExp('(^|\\s|,|\\()' +
word.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1") +
word.replace(/([.?*+\^\$\[\]\\(){}|\-])/g, "\\$1") +
'($|\\s|\\()', 'ig');

@@ -107,16 +108,19 @@ };

var browsers = this.parse(requirements);
var props = this.prefixes(browsers);
var browsers = this.parse(requirements);
var values = this.filter(this.data.values, browsers);
var props = this.filter(this.data.props, browsers);
var prefixes = this.prefixes(props, values);
var unprefixes = this.unprefixes(props, values);
return function (style, css) {
autoprefixer.prefixer(props, style, css);
return function (style) {
autoprefixer.unprefixer(unprefixes, style);
autoprefixer.prefixer(prefixes, style);
};
},
// Change `style` declarations in parsed `css`, to add prefixes for `props`.
prefixer: function (props, style, css) {
// Change `style` declarations in parsed CSS, to add prefixes for `props`.
prefixer: function (props, style) {
if ( props['@keyframes'] ) {
// Keyframes
style.rules.forEach(function(rule) {
style.rules.forEach(function(rule) {
if ( !rule.keyframes ) {

@@ -128,4 +132,4 @@ return;

var contain = style.rules.some(function (other) {
return other.keyframes && rule.name == other.name &&
other.vendor == prefix;
return other.keyframes && rule.name === other.name &&
other.vendor === prefix;
});

@@ -172,3 +176,3 @@ if ( contain ) {

return rules.some(function (rule) {
return rule.property == prop && rule.value == value;
return rule.property === prop && rule.value === value;
});

@@ -184,7 +188,8 @@ };

};
var num, rule, prop;
// Properties
for ( var num = 0; num < rules.length; num += 1 ) {
var rule = rules[num];
var prop = props[rule.property];
for ( num = 0; num < rules.length; num += 1 ) {
rule = rules[num];
prop = props[rule.property];

@@ -199,10 +204,10 @@ if ( !prop || !prop.prefixes ) {

prop.prefixes.forEach(function (prefix) {
if ( vendor && vendor != prefix ) {
if ( vendor && vendor !== prefix ) {
return;
}
var wrong = prefixes.some(function (other) {
if ( other == prefix ) {
if ( other === prefix ) {
return false;
}
return rule.value.indexOf(other) != -1;
return rule.value.indexOf(other) !== -1;
});

@@ -215,11 +220,11 @@ if ( wrong ) {

});
};
}
// Values
for ( var num = 0; num < rules.length; num += 1 ) {
var rule = rules[num];
for ( num = 0; num < rules.length; num += 1 ) {
rule = rules[num];
var split = splitPrefix(rule.property);
var prop = props[split.name];
var split = splitPrefix(rule.property);
var propVendor = split.prefix || vendor;
prop = props[split.name];

@@ -236,3 +241,3 @@ var valuePrefixer = function (values) {

value.prefixes.forEach(function (prefix) {
if ( propVendor && propVendor != prefix ) {
if ( propVendor && propVendor !== prefix ) {
return;

@@ -243,2 +248,12 @@ }

}
if ( value.replace ) {
if ( prefixed[prefix].match(value.regexp) ) {
var replaced = value.replace(
prefixed[prefix], prefix);
if ( replaced ) {
prefixed[prefix] = replaced;
return;
}
}
}
prefixed[prefix] = prefixed[prefix].replace(

@@ -251,3 +266,3 @@ value.regexp, '$1' + prefix + name + '$2');

for ( var prefix in prefixed ) {
if ( prefixed[prefix] != rule.value ) {
if ( prefixed[prefix] !== rule.value ) {
if ( propVendor ) {

@@ -282,5 +297,43 @@ var exists = contain(rules, rule.property,

// Change `style` declarations in parsed CSS, to remove `remove`.
unprefixer: function (remove, style) {
var all = remove.values['*'];
// Keyframes
style.rules = style.rules.filter(function (rule) {
return !(rule.keyframes && remove.keyframes[rule.vendor]);
});
rework.visit.declarations(style, function (rules) {
for ( var num = 0; num < rules.length; num += 1 ) {
var rule = rules[num];
// Properties
if ( remove.props[rule.property] ) {
rules.splice(num, 1);
continue;
}
// Values
var prop = splitPrefix(rule.property).name;
var values = all;
if ( remove.values[prop] ) {
values = values.concat(remove.values[prop]);
}
if ( prop === 'transition' || prop === 'transition-property' ) {
values = values.concat(remove.transition);
}
values.forEach(function (value) {
if ( rule.value.match(value) ) {
rules.splice(num, 1);
return false;
}
});
}
});
},
// Return array of browsers for requirements in free form.
parse: function (requirements) {
if ( requirements.length == 0 ) {
if ( requirements.length === 0 ) {
requirements = ['last 2 versions'];

@@ -368,7 +421,7 @@ }

var prefixes = browsers.filter(function (browser) {
return need.indexOf(browser) != -1;
return need.indexOf(browser) !== -1;
}).map(function (browser) {
var key = browser.split(' ')[0];
return autoprefixer.data.browsers[key].prefix;
}).sort(function (a, b) { return b.length - a.length });
}).sort(function (a, b) { return b.length - a.length; });

@@ -378,5 +431,5 @@ if ( prefixes.length ) {

var obj = { prefixes: prefixes }
var obj = { prefixes: prefixes };
for ( var key in data[name] ) {
if ( key == 'browsers' ) {
if ( key === 'browsers' ) {
continue;

@@ -398,6 +451,3 @@ }

// Return properties, which them prefixed values inside.
prefixes: function (browsers) {
var values = this.filter(this.data.values, browsers);
var props = this.filter(this.data.props, browsers);
prefixes: function (props, values) {
for ( var name in values ) {

@@ -416,2 +466,60 @@ values[name].props.forEach(function (prop) {

return props;
},
// Return old properties and values to remove.
unprefixes: function (props, values) {
var remove = { props: {}, values: {}, transition: [], keyframes: {} };
var name, prefixes, prop, value, names;
for ( name in this.data.props ) {
prop = this.data.props[name];
prefixes = prop.browsers.map(function (b) {
var key = b.split(' ')[0];
return autoprefixer.data.browsers[key].prefix;
});
uniq(prefixes).filter(function (prefix) {
if ( !props[name] ) {
return true;
}
return props[name].prefixes.indexOf(prefix) === -1;
}).forEach(function (prefix) {
if ( prop.transition ) {
remove.transition.push(containRegexp(prefix + name));
}
if ( name === '@keyframes' ) {
remove.keyframes[prefix] = true;
} else {
if ( prop.prefixed && prop.prefixed[prefix] ) {
remove.props[prop.prefixed[prefix]] = true;
} else {
remove.props[prefix + name] = true;
}
}
});
}
for ( name in this.data.values ) {
value = this.data.values[name];
prefixes = value.browsers.map(function (b) {
var key = b.split(' ')[0];
return autoprefixer.data.browsers[key].prefix;
});
names = uniq(prefixes).filter(function (prefix) {
if ( !values[name] ) {
return true;
}
return values[name].prefixes.indexOf(prefix) === -1;
}).map(function (prefix) {
return containRegexp(prefix + name);
});
value.props.forEach(function (prop) {
if ( !remove.values[prop] ) {
remove.values[prop] = [];
}
remove.values[prop] = remove.values[prop].concat(names);
});
}
return remove;
}

@@ -421,1 +529,2 @@ };

module.exports = autoprefixer;
})();
{
"name": "autoprefixer",
"version": "0.3.20130502",
"version": "0.4.20130507",
"description": "Parse CSS and add prefixed properties and values by actual Can I Use database",

@@ -18,5 +18,6 @@ "keywords": ["css", "prefix", "rework"],

"mocha": "1.9.0",
"sinon": "1.6.0",
"sinon": "1.7.0",
"should": "1.2.2",
"component": "0.15.1"
"component": "0.15.1",
"js-beautify": "1.3.2"
},

@@ -23,0 +24,0 @@ "bin": {

@@ -45,2 +45,3 @@ # Autoprefixer

(scripts don’t have holidays and work).
* Remove outdated prefixes to clean libraries and legacy code.
* It also adds prefixes to the values. For example, to `calc(1em + 5px)` or

@@ -47,0 +48,0 @@ to properties names in `transition`.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc