Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-unused-expressions": [0],
"no-underscore-dangle": [0],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
npm-debug.log
coverage/
.nyc_output/
23 changes: 0 additions & 23 deletions gulpfile.js

This file was deleted.

23 changes: 10 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function parseGradient(input) {
// `top right` and `right top` are the same,
// so we should put this situation into consideration
var rSideCorner = new RegExp(
'(' + // 1
'(' + // 1
'(?:to\\s+)?' +
'(?:' +
'(?:left|right|top|bottom)' +
Expand Down Expand Up @@ -46,7 +46,7 @@ function parseGradient(input) {
'(?:(' + rGradientLine.source + ')\\s*,\\s*)?' + // match gradient line
'(' + rColorStops.source + '(?:\\s*,\\s*' + rColorStops.source + ')+)' + // match color stops
'\\s*\\)',
'i');
'i');

var gradientMatch = rGradient.exec(input);

Expand Down Expand Up @@ -247,8 +247,7 @@ function getGradientFromRule(rule) {
return gradient;
}

module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
opts = opts || {};
module.exports = (opts = {}) => {
opts.angleFallback = opts.angleFallback !== false;
opts.skipMultiColor = opts.skipMultiColor === true;
opts.skipWarnings = opts.skipWarnings === true;
Expand All @@ -258,12 +257,10 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
target.warn(result, message);
}

return function (root, result) {
root.walkRules(function (rule) {
var gradient;
var filter;

gradient = getGradientFromRule(rule);
return {
postcssPlugin: 'postcss-filter-gradient',
Rule(rule, { result }) {
const gradient = getGradientFromRule(rule);

// if linear-gradient and `filter` both exist, warn users
if (gradient.value && hasFilter(rule)) {
Expand All @@ -284,7 +281,7 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
return;
}

filter = gradientToFilter(gradient.value);
const filter = gradientToFilter(gradient.value);

// warn users when the gradient value is not valid.
if (!filter.success) {
Expand All @@ -309,6 +306,6 @@ module.exports = postcss.plugin('postcss-filter-gradient', function (opts) {
gradient.decl.cloneAfter({
prop: 'filter', value: filter.string
});
});
}
};
});
};
Loading