Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Apr 28, 2018
1 parent 9bb36ce commit e5007fe
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Value = require('./value');
const OLD_LINEAR = /(^|[^-])linear-gradient\(\s*(top|left|right|bottom)/i;
const OLD_RADIAL = /(^|[^-])radial-gradient\(\s*\d+(\w*|%)\s+\d+(\w*|%)\s*,/i;
const RADIAL_BLOCK = /\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/i;
const IGNORE_NEXT = /(!\s*)?autoprefixer:\s*ignore\s+next/i;

const SIZES = [
'width', 'height', 'min-width', 'max-width',
Expand Down Expand Up @@ -339,19 +340,16 @@ class Processor {
*/
disabled(node, result) {
if (!node) return false;

if (node._autoprefixerDisabled !== undefined) {
return node._autoprefixerDisabled;
}
if (node.parent) {
const previousNode = node.prev();
if (previousNode &&
previousNode.type === 'comment' &&
/(!\s*)?autoprefixer:\s*ignore\s+next/i
.test(previousNode.text)) {
node._autoprefixerDisabled = true;
node._autoprefixerOnlySelfDisabled = true;
return node._autoprefixerDisabled;
}

const prev = node.prev();
if (prev && prev.type === 'comment' && IGNORE_NEXT.test(prev.text)) {
node._autoprefixerDisabled = true;
node._autoprefixerOnlySelfDisabled = true;
return node._autoprefixerDisabled;
}

let value = null;
Expand Down

0 comments on commit e5007fe

Please sign in to comment.