src/options/vendor-prefix-align.js
function(ast) {
      let detected = [];

      ast.traverseByType('block', function(node) {
        var result = {
          true: 0,
          false: 0
        };

        var maybePrefix = false;
        var prevPrefixLength = false;
        var prevProp;
        var prevSum;
        var partialResult = null;

        var getResult = function(options) {
          let {node, sum, info, i} = options;
          var prop = info.baseName;

          // If this is the last item in a row and we have a result,
          // then catch it
          if (prop !== prevProp && partialResult !== null) {
            if (partialResult) {
              result.true++;
            } else {
              result.false++;
            }
            partialResult = null;
          }

          if (prop === prevProp &&
              info.prefixLength !== prevPrefixLength) {
            maybePrefix = true;
          } else {
            maybePrefix = false;
          }

          if (maybePrefix && partialResult !== false) {
            // If there is prefixed prop, check if the prefixes are
            // aligned, but only if we hadn't already catched
            // that it is false
            if (sum === prevSum) {
              partialResult = true;
            } else {
              partialResult = false;
            }
          }

          if (node.length === i + 3 && partialResult !== null) {
            // If we're at the last property and have a result,
            // catch it
            if (partialResult) {
              result.true++;
            } else {
              result.false++;
            }
          }

          prevPrefixLength = info.prefixLength;
          prevProp = prop;
          prevSum = sum;
        };

        // Gathering Info
        walk({
          node: node,
          selector: getPropertyName,
          getExtraSymbols: extraIndentProperty,
          payload: function(info, i) {
            if (node.get(i - 1) && node.get(i - 1).content) {
              let nodeLength = node.get(i - 1).content
                  .replace(/^[ \t]*\n+/, '').length;
              var sum = nodeLength + info.prefixLength;
              getResult({node: node, sum: sum, info: info, i: i});
            }
          }
        });

        walk({
          node: node,
          selector: getValName,
          getExtraSymbols: extraIndentVal,
          payload: function(info, i) {
            for (var x = node.get(i).length; x--;) {
              if (node.get(i).get(x).is('value')) break;
            }

            if (node.get(i).get(x - 1)) {
              let nodeLength = node.get(i).get(x - 1).content
                  .replace(/^[ \t]*\n+/, '').length;
              var sum = nodeLength + info.prefixLength;
              getResult({node: node, sum: sum, info: info, i: i});
            }
          }
        });

        if (result.true > 0 || result.false > 0) {
          if (result.true >= result.false) {
            detected.push(true);
          } else {
            detected.push(false);
          }
        }
      });

      return detected;
    }
function(ast) {
      let detected = [];

      ast.traverseByType('block', function(node) {
        var result = {
          true: 0,
          false: 0
        };

        var maybePrefix = false;
        var prevPrefixLength = false;
        var prevProp;
        var prevSum;
        var partialResult = null;

        var getResult = function(options) {
          let {node, sum, info, i} = options;
          var prop = info.baseName;

          // If this is the last item in a row and we have a result,
          // then catch it
          if (prop !== prevProp && partialResult !== null) {
            if (partialResult) {
              result.true++;
            } else {
              result.false++;
            }
            partialResult = null;
          }

          if (prop === prevProp &&
              info.prefixLength !== prevPrefixLength) {
            maybePrefix = true;
          } else {
            maybePrefix = false;
          }

          if (maybePrefix && partialResult !== false) {
            // If there is prefixed prop, check if the prefixes are
            // aligned, but only if we hadn't already catched
            // that it is false
            if (sum === prevSum) {
              partialResult = true;
            } else {
              partialResult = false;
            }
          }

          if (node.length === i + 3 && partialResult !== null) {
            // If we're at the last property and have a result,
            // catch it
            if (partialResult) {
              result.true++;
            } else {
              result.false++;
            }
          }

          prevPrefixLength = info.prefixLength;
          prevProp = prop;
          prevSum = sum;
        };

        // Gathering Info
        walk({
          node: node,
          selector: getPropertyName,
          getExtraSymbols: extraIndentProperty,
          payload: function(info, i) {
            if (node.get(i - 1) && node.get(i - 1).content) {
              let nodeLength = node.get(i - 1).content
                  .replace(/^[ \t]*\n+/, '').length;
              var sum = nodeLength + info.prefixLength;
              getResult({node: node, sum: sum, info: info, i: i});
            }
          }
        });

        walk({
          node: node,
          selector: getValName,
          getExtraSymbols: extraIndentVal,
          payload: function(info, i) {
            for (var x = node.get(i).length; x--;) {
              if (node.get(i).get(x).is('value')) break;
            }

            if (node.get(i).get(x - 1)) {
              let nodeLength = node.get(i).get(x - 1).content
                  .replace(/^[ \t]*\n+/, '').length;
              var sum = nodeLength + info.prefixLength;
              getResult({node: node, sum: sum, info: info, i: i});
            }
          }
        });

        if (result.true > 0 || result.false > 0) {
          if (result.true >= result.false) {
            detected.push(true);
          } else {
            detected.push(false);
          }
        }
      });

      return detected;
    }
function ( ast ) { let detected = [ ] ; ast . traverseByType ( 'block' , function ( node ) { var result = { true : 0 , false : 0 } ; var maybePrefix = false ; var prevPrefixLength = false ; var prevProp ; var prevSum ; var partialResult = null ; var getResult = function ( options ) { let { node , sum , info , i } = options ; var prop = info . baseName ; // If this is the last item in a row and we have a result, // then catch it if ( prop !== prevProp && partialResult !== null ) { if ( partialResult ) { result . true ++ ; } else { result . false ++ ; } partialResult = null ; } if ( prop === prevProp && info . prefixLength !== prevPrefixLength ) { maybePrefix = true ; } else { maybePrefix = false ; } if ( maybePrefix && partialResult !== false ) { // If there is prefixed prop, check if the prefixes are // aligned, but only if we hadn't already catched // that it is false if ( sum === prevSum ) { partialResult = true ; } else { partialResult = false ; } } if ( node . length === i + 3 && partialResult !== null ) { // If we're at the last property and have a result, // catch it if ( partialResult ) { result . true ++ ; } else { result . false ++ ; } } prevPrefixLength = info . prefixLength ; prevProp = prop ; prevSum = sum ; } ; // Gathering Info walk ( { node : node , selector : getPropertyName , getExtraSymbols : extraIndentProperty , payload : function ( info , i ) { if ( node . get ( i - 1 ) && node . get ( i - 1 ) . content ) { let nodeLength = node . get ( i - 1 ) . content . replace ( / ^[ \t]*\n+ / , '' ) . length ; var sum = nodeLength + info . prefixLength ; getResult ( { node : node , sum : sum , info : info , i : i } ) ; } } } ) ; walk ( { node : node , selector : getValName , getExtraSymbols : extraIndentVal , payload : function ( info , i ) { for ( var x = node . get ( i ) . length ; x -- ; ) { if ( node . get ( i ) . get ( x ) . is ( 'value' ) ) break ; } if ( node . get ( i ) . get ( x - 1 ) ) { let nodeLength = node . get ( i ) . get ( x - 1 ) . content . replace ( / ^[ \t]*\n+ / , '' ) . length ; var sum = nodeLength + info . prefixLength ; getResult ( { node : node , sum : sum , info : info , i : i } ) ; } } } ) ; if ( result . true > 0 || result . false > 0 ) { if ( result . true >= result . false ) { detected . push ( true ) ; } else { detected . push ( false ) ; } } } ) ; return detected ; }
Detects the value of an option at the tree node.

@param {node} ast
Detects the value of an option at the tree node .