autoprefixer-core
Advanced tools
Comparing version 5.1.11 to 5.2.0
(function() { | ||
var add, crispedges, feature, flexbox, gradients, logicalProps, prefix, resolution, result, sort, textDecoration, | ||
var add, crispedges, feature, flexbox, gradients, logicalProps, prefix, resolution, result, sort, | ||
slice = [].slice; | ||
@@ -264,3 +264,3 @@ | ||
}); | ||
return prefix(':placeholder-shown', '::placeholder', { | ||
return prefix('::placeholder', { | ||
selector: true, | ||
@@ -321,6 +321,4 @@ browsers: browsers | ||
textDecoration = require('caniuse-db/features-json/text-decoration'); | ||
feature(textDecoration, function(browsers) { | ||
return prefix('text-decoration-style', { | ||
feature(require('caniuse-db/features-json/text-decoration'), function(browsers) { | ||
return prefix('text-decoration-style', 'text-decoration-line', 'text-decoration-color', { | ||
browsers: browsers | ||
@@ -330,10 +328,2 @@ }); | ||
feature(textDecoration, { | ||
match: /y\sx($|\s)/ | ||
}, function(browsers) { | ||
return prefix('text-decoration-line', 'text-decoration-color', { | ||
browsers: browsers | ||
}); | ||
}); | ||
feature(require('caniuse-db/features-json/text-size-adjust'), function(browsers) { | ||
@@ -412,3 +402,3 @@ return prefix('text-size-adjust', { | ||
}, function(browsers) { | ||
return prefix('crisp-edges', { | ||
return prefix('pixelated', { | ||
props: ['image-rendering'], | ||
@@ -445,2 +435,8 @@ browsers: browsers | ||
feature(require('caniuse-db/features-json/css-appearance'), function(browsers) { | ||
return prefix('appearance', { | ||
browsers: browsers | ||
}); | ||
}); | ||
}).call(this); |
(function() { | ||
var Autoprefixer, Browsers, Prefixes, autoprefixer, browserslist, infoCache, isPlainObject, postcss, | ||
slice = [].slice, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
var Browsers, Prefixes, browserslist, cache, isPlainObject, postcss, | ||
slice = [].slice; | ||
@@ -14,4 +13,2 @@ browserslist = require('browserslist'); | ||
infoCache = null; | ||
isPlainObject = function(obj) { | ||
@@ -21,4 +18,6 @@ return Object.prototype.toString.apply(obj) === '[object Object]'; | ||
autoprefixer = function() { | ||
var options, reqs; | ||
cache = {}; | ||
module.exports = postcss.plugin('autoprefixer', function() { | ||
var loadPrefixes, options, plugin, reqs; | ||
reqs = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
@@ -36,77 +35,57 @@ if (reqs.length === 1 && isPlainObject(reqs[0])) { | ||
} | ||
if ((options != null ? options.browsers : void 0) != null) { | ||
options || (options = {}); | ||
if (options.browsers != null) { | ||
reqs = options.browsers; | ||
} | ||
return new Autoprefixer(autoprefixer.data, reqs, options); | ||
}; | ||
autoprefixer.data = { | ||
browsers: require('caniuse-db/data').agents, | ||
prefixes: require('../data/prefixes') | ||
}; | ||
Autoprefixer = (function() { | ||
function Autoprefixer(data, reqs1, options1) { | ||
this.data = data; | ||
this.reqs = reqs1; | ||
this.options = options1 != null ? options1 : {}; | ||
this.postcss = bind(this.postcss, this); | ||
} | ||
Autoprefixer.prototype.process = function(str, options) { | ||
if (options == null) { | ||
options = {}; | ||
} | ||
return postcss(this.postcss).process(str, options); | ||
loadPrefixes = function(opts) { | ||
var browsers, key; | ||
browsers = new Browsers(module.exports.data.browsers, reqs, opts); | ||
key = browsers.selected.join(', ') + options.cascade; | ||
return cache[key] || (cache[key] = new Prefixes(module.exports.data.prefixes, browsers, options)); | ||
}; | ||
Autoprefixer.prototype.postcss = function(css) { | ||
plugin = function(css, result) { | ||
var prefixes; | ||
prefixes = this.prefixes({ | ||
prefixes = loadPrefixes({ | ||
from: css.source.input.file | ||
}); | ||
if (this.options.remove !== false) { | ||
if (options.remove !== false) { | ||
prefixes.processor.remove(css); | ||
} | ||
return prefixes.processor.add(css); | ||
if (options.add !== false) { | ||
return prefixes.processor.add(css, result); | ||
} | ||
}; | ||
Autoprefixer.prototype.prefixes = function(opts) { | ||
var browsers; | ||
browsers = new Browsers(autoprefixer.data.browsers, this.reqs, opts); | ||
return new Prefixes(autoprefixer.data.prefixes, browsers, this.options); | ||
plugin.options = options; | ||
plugin.process = function(str, options) { | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (typeof console !== "undefined" && console !== null) { | ||
if (typeof console.warn === "function") { | ||
console.warn('Autoprefixer\'s process() method is deprecated ' + 'and will removed in next major release. ' + 'Use postcss([autoprefixer]).process() instead'); | ||
} | ||
} | ||
return postcss(plugin).process(str, options); | ||
}; | ||
Autoprefixer.prototype.info = function(opts) { | ||
infoCache || (infoCache = require('./info')); | ||
return infoCache(this.prefixes(opts)); | ||
plugin.info = function(opts) { | ||
return require('./info')(loadPrefixes(opts)); | ||
}; | ||
return plugin; | ||
}); | ||
return Autoprefixer; | ||
})(); | ||
autoprefixer.defaults = browserslist.defaults; | ||
autoprefixer.loadDefault = function() { | ||
return this.defaultCache || (this.defaultCache = autoprefixer()); | ||
module.exports.data = { | ||
browsers: require('caniuse-db/data').agents, | ||
prefixes: require('../data/prefixes') | ||
}; | ||
autoprefixer.process = function(str, options) { | ||
if (options == null) { | ||
options = {}; | ||
} | ||
return this.loadDefault().process(str, options); | ||
}; | ||
module.exports.defaults = browserslist.defaults; | ||
autoprefixer.postcss = function(css) { | ||
return autoprefixer.loadDefault().postcss(css); | ||
module.exports.process = function(css, options) { | ||
return module.exports().process(css, options); | ||
}; | ||
autoprefixer.info = function() { | ||
return this.loadDefault().info(); | ||
module.exports.info = function() { | ||
return module.exports().info(); | ||
}; | ||
module.exports = autoprefixer; | ||
}).call(this); |
@@ -228,2 +228,15 @@ (function() { | ||
Gradient.prototype.process = function(node, result) { | ||
var added; | ||
added = Gradient.__super__.process.apply(this, arguments); | ||
if (added && this.name === 'linear-gradient') { | ||
if (/\(\s*(top|left|right|bottom)/.test(node.value)) { | ||
result.warn('Gradient has outdated direction syntax. ' + 'New syntax is like "to left" instead of "right".', { | ||
node: node | ||
}); | ||
} | ||
} | ||
return added; | ||
}; | ||
return Gradient; | ||
@@ -230,0 +243,0 @@ |
@@ -18,3 +18,3 @@ (function() { | ||
ImageRendering.prototype.check = function(decl) { | ||
return decl.value === 'crisp-edges'; | ||
return decl.value === 'pixelated'; | ||
}; | ||
@@ -44,2 +44,11 @@ | ||
ImageRendering.prototype.process = function(node, result) { | ||
if (this.name === 'image-rendering' && node.value === 'crisp-edges') { | ||
result.warn('There is no browsers with crisp-edges rendering support.' + 'Maybe you mean pixelated?', { | ||
node: node | ||
}); | ||
} | ||
return ImageRendering.__super__.process.apply(this, arguments); | ||
}; | ||
return ImageRendering; | ||
@@ -46,0 +55,0 @@ |
@@ -13,5 +13,2 @@ (function() { | ||
var cloned, i, value; | ||
if (typeof obj !== 'object') { | ||
return obj; | ||
} | ||
cloned = new obj.constructor(); | ||
@@ -32,3 +29,6 @@ for (i in obj) { | ||
} else if (i !== '_autoprefixerPrefix' && i !== '_autoprefixerValues') { | ||
cloned[i] = clone(value, cloned); | ||
if (typeof value === 'object') { | ||
value = clone(value, cloned); | ||
} | ||
cloned[i] = value; | ||
} | ||
@@ -35,0 +35,0 @@ } |
@@ -40,2 +40,4 @@ (function() { | ||
Declaration.hack(require('./hacks/appearance')); | ||
Declaration.hack(require('./hacks/align-self')); | ||
@@ -73,3 +75,3 @@ | ||
Value.hack(require('./hacks/crisp-edges')); | ||
Value.hack(require('./hacks/pixelated')); | ||
@@ -76,0 +78,0 @@ Value.hack(require('./hacks/flex-values')); |
@@ -15,3 +15,3 @@ (function() { | ||
Processor.prototype.add = function(css) { | ||
Processor.prototype.add = function(css, result) { | ||
var keyframes, resolution, supports, viewport; | ||
@@ -53,3 +53,3 @@ resolution = this.prefixes.add['@resolution']; | ||
selector = ref[j]; | ||
results.push(selector.process(rule)); | ||
results.push(selector.process(rule, result)); | ||
} | ||
@@ -62,6 +62,12 @@ return results; | ||
var prefix; | ||
if (decl.prop === 'display' && decl.value === 'box') { | ||
result.warn('You should write display: flex by final spec ' + 'instead of display: box', { | ||
node: decl | ||
}); | ||
return; | ||
} | ||
prefix = _this.prefixes.add[decl.prop]; | ||
if (prefix && prefix.prefixes) { | ||
if (!_this.disabled(decl)) { | ||
return prefix.process(decl); | ||
return prefix.process(decl, result); | ||
} | ||
@@ -81,3 +87,3 @@ } | ||
value = ref[j]; | ||
value.process(decl); | ||
value.process(decl, result); | ||
} | ||
@@ -84,0 +90,0 @@ return Value.save(_this.prefixes, decl); |
{ | ||
"name": "autoprefixer-core", | ||
"version": "5.1.11", | ||
"version": "5.2.0", | ||
"description": "CLI-less core of Autoprefixer to use in plugins", | ||
@@ -9,4 +9,4 @@ "keywords": [ | ||
"prefix", | ||
"postprocessor", | ||
"postcss" | ||
"postcss", | ||
"postcss-plugin" | ||
], | ||
@@ -20,6 +20,6 @@ "author": "Andrey Sitnik <andrey@sitnik.ru>", | ||
"dependencies": { | ||
"browserslist": "~0.2.0", | ||
"num2fraction": "~1.1.0", | ||
"caniuse-db": "^1.0.30000132", | ||
"postcss": "~4.0.6" | ||
"browserslist": "~0.4.0", | ||
"num2fraction": "^1.1.0", | ||
"caniuse-db": "^1.0.30000181", | ||
"postcss": "~4.1.11" | ||
}, | ||
@@ -29,11 +29,10 @@ "devDependencies": { | ||
"gulp-json-editor": "2.2.1", | ||
"jshint-stylish": "1.0.1", | ||
"gulp-replace": "0.5.3", | ||
"gulp-jshint": "1.10.0", | ||
"gulp-eslint": "0.12.0", | ||
"gulp-coffee": "2.3.1", | ||
"gulp-mocha": "2.0.1", | ||
"browserify": "9.0.8", | ||
"fs-extra": "0.18.2", | ||
"should": "6.0.1", | ||
"mocha": "2.2.4", | ||
"gulp-mocha": "2.1.0", | ||
"browserify": "10.2.1", | ||
"fs-extra": "0.18.4", | ||
"should": "6.0.3", | ||
"mocha": "2.2.5", | ||
"gulp": "3.8.11", | ||
@@ -40,0 +39,0 @@ "coffee-script": "1.9.2" |
@@ -1,4 +0,6 @@ | ||
# Autoprefixer Core [![Build Status](https://travis-ci.org/postcss/autoprefixer-core.svg)](https://travis-ci.org/postcss/autoprefixer-core) | ||
# Autoprefixer Core [![Build Status][ci-img]][ci] | ||
<img align="right" width="94" height="71" src="http://postcss.github.io/autoprefixer/logo.svg" title="Autoprefixer logo by Anton Lovchikov"> | ||
<img align="right" width="94" height="71" | ||
src="http://postcss.github.io/autoprefixer/logo.svg" | ||
title="Autoprefixer logo by Anton Lovchikov"> | ||
@@ -20,2 +22,4 @@ [PostCSS] plugin to parse CSS and add vendor prefixes using values | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[ci-img]: https://travis-ci.org/postcss/autoprefixer-core.svg | ||
[ci]: https://travis-ci.org/postcss/autoprefixer-core | ||
@@ -37,3 +41,10 @@ ## Quick Example | ||
var autoprefixer = require('autoprefixer-core'); | ||
var prefixed = autoprefixer.process(css).css; | ||
var postcss = require('postcss'); | ||
postcss([ autoprefixer ]).process(css).then(function (result) { | ||
result.warnings().forEach(function (warn) { | ||
console.warn(warn.toString()); | ||
}); | ||
console.log(result.css); | ||
}); | ||
``` | ||
@@ -67,14 +78,15 @@ | ||
To process your CSS you need to make 2 steps: | ||
To process your CSS you need to make 3 steps: | ||
1. Build processor for your options and browsers supported in your project. | ||
1. Build plugin for your options and browsers supported in your project. | ||
2. Add this plugin to PostCSS processor. | ||
2. Process CSS through this processor. | ||
Function `autoprefixer(options)` returns new processor object: | ||
Function `autoprefixer(options)` returns new PostCSS plugin: | ||
```js | ||
var processor = autoprefixer({ browsers: ['> 1%', 'IE 7'], cascade: false }); | ||
var plugin = autoprefixer({ browsers: ['> 1%', 'IE 7'], cascade: false }); | ||
``` | ||
There are 2 options: | ||
There are 4 options: | ||
@@ -86,22 +98,21 @@ * `browsers` (array): list of browsers, which are supported in your project. | ||
* `cascade` (boolean): should Autoprefixer uses [Visual Cascade], | ||
if CSS will be uncompressed. | ||
if CSS is uncompressed. Default: `true` | ||
* `add` (boolean): should Autoprefixer add prefixes. Default is `true`. | ||
* `remove` (boolean): should Autoprefixer [remove outdated] prefixes. | ||
Default is `true`. | ||
Processor object had: | ||
Plugin object has `info()` method for [debug purpose]. | ||
* `.process(css, opts)` method, which will add prefixes to `css`. | ||
* `.info()` method, which returns debug information: which browsers are selected | ||
and which properties will be prefixed | ||
* `.postcss` property returns [PostCSS] processor to use in chain | ||
with other [PostCSS processors]. | ||
You can use processor object to process several CSS files | ||
You can use PostCSS processor to process several CSS files | ||
to increase perfomance. | ||
There are `autoprefixer.process()`, `autoprefixer.info()` | ||
and `autoprefixer.postcss` shortcuts, which use default browsers and options. | ||
See [PostCSS API] for plugin usage documentation. | ||
See all [PostCSS Runner Guidelines] for best practices. | ||
[PostCSS processors]: https://github.com/postcss/postcss#built-with-postcss | ||
[Browserslist docs]: https://github.com/ai/browserslist | ||
[Visual Cascade]: https://github.com/postcss/autoprefixer#visual-cascade | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[PostCSS Runner Guidelines]: https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md | ||
[Browserslist docs]: https://github.com/ai/browserslist | ||
[remove outdated]: https://github.com/postcss/autoprefixer/#outdated-prefixes | ||
[Visual Cascade]: https://github.com/postcss/autoprefixer#visual-cascade | ||
[debug purpose]: #debug | ||
[PostCSS API]: https://github.com/postcss/postcss/blob/master/docs/api.md | ||
@@ -132,3 +143,3 @@ ## CSS Processing | ||
[PostCSS documentation]: https://github.com/postcss/postcss#source-map-1 | ||
[PostCSS documentation]: https://github.com/postcss/postcss#source-map | ||
[Safe Mode]: https://github.com/postcss/postcss#safe-mode | ||
@@ -177,17 +188,2 @@ | ||
## Cleaning | ||
By default, Autoprefixer not only add new prefixes, but also remove outdated. | ||
You can remove this behaviour by `remove: false` option: | ||
```js | ||
autoprefixer() | ||
.process('a { -webkit-border-radius: 2px; border-radius: 2px }'); | ||
// remove outdated -webkit-border-radius | ||
autoprefixer({ remove: false }) | ||
.process('a { -webkit-border-radius: 2px; border-radius: 2px }'); | ||
// keeps -webkit-border-radius | ||
``` | ||
## Debug | ||
@@ -194,0 +190,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142961
12
52
3207
191
+ Addedbrowserslist@0.4.0(transitive)
+ Addedes6-promise@2.3.0(transitive)
+ Addednum2fraction@1.2.2(transitive)
+ Addedpostcss@4.1.16(transitive)
+ Addedsource-map@0.4.4(transitive)
- Removedbrowserslist@0.2.0(transitive)
- Removednum2fraction@1.1.0(transitive)
- Removedpostcss@4.0.6(transitive)
- Removedsource-map@0.2.0(transitive)
Updatedbrowserslist@~0.4.0
Updatedcaniuse-db@^1.0.30000181
Updatednum2fraction@^1.1.0
Updatedpostcss@~4.1.11