How to use the postcss/lib/list.comma function in postcss

To help you get started, we’ve selected a few postcss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postcss / postcss-selector-matches / src / replaceRuleSelector.js View on Github external
selectorPart.forEach(part => {
      const position = part.indexOf(pseudoClass)
      const pre = part.slice(0, position)
      const body = part.slice(position)
      const matches = balancedMatch("(", ")", body)

      const bodySelectors = matches && matches.body ?
        list
          .comma(matches.body)
          .reduce((acc, s) => [
            ...acc,
            ...explodeSelector(s, options),
          ], [])
        : [body]

      const postSelectors = matches && matches.post
        ? explodeSelector(matches.post, options)
        : []

      let newParts
      if (postSelectors.length === 0) {
        // the test below is a poor way to try we are facing a piece of a
        // selector...
        if (position === -1 || pre.indexOf(" ") > -1) {
github hail2u / node-csswring / lib / csswring.js View on Github external
if (preserveHacks && decl.raws.between) {
    decl.raws.between = decl.raws.between.replace(re.whiteSpaces, "");
  } else {
    decl.raws.between = ":";
  }

  if (decl.important) {
    decl.raws.important = "!important";
  }

  if (prop === "content") {
    return;
  }

  if (prop === "font-family") {
    decl.value = list.comma(value).map(unquoteFontFamily).join(",");

    return;
  }

  values = list.comma(value);
  value = values.map(wringValue.bind(null, prop)).join(",");

  if (re.propertyMultipleValues.test(prop)) {
    values = list.space(value);

    if (values.length === 4 && values[1] === values[3]) {
      values.splice(3, 1);
    }

    if (values.length === 3 && values[0] === values[2]) {
      values.splice(2, 1);
github hail2u / node-csswring / index.js View on Github external
}

  if (prop === "content") {
    return;
  }

  if (prop === "font-family") {
    decl.value = list
      .comma(value)
      .map(unquoteFontFamily)
      .join(",");

    return;
  }

  let values = list.comma(value);

  value = values.map(wringValue.bind(null, preserveHacks, prop)).join(",");

  if (re.propertyMultipleValues.test(prop)) {
    values = list.space(value);

    if (values.length === 4 && values[1] === values[3]) {
      values.splice(3, 1);
    }

    if (values.length === 3 && values[0] === values[2]) {
      values.splice(2, 1);
    }

    if (values.length === 2 && values[0] === values[1]) {
      values.splice(1, 1);
github hail2u / node-css-mqpacker / lib / css-mqpacker.js View on Github external
var parseQueryList = function (queryList) {
  var queries = [];
  list.comma(queryList).forEach(function (query) {
    var expressions = {};
    list.space(query).forEach(function (expression) {
      var feature;
      var value;
      expression = expression.toLowerCase();

      if (expression === "and") {
        return;
      }

      if (/^\w+$/.test(expression)) {
        expressions[expression] = true;

        return;
      }
github postcss / postcss-selector-matches / src / replaceRuleSelector.js View on Github external
function explodeSelector(selector, options) {
  if (selector && selector.indexOf(pseudoClass) > -1) {
    let newSelectors = []
    const preWhitespaceMatches = selector.match(/^\s+/)
    const preWhitespace = preWhitespaceMatches
      ? preWhitespaceMatches[0]
      : ""
    const selectorPart = list.comma(selector)
    selectorPart.forEach(part => {
      const position = part.indexOf(pseudoClass)
      const pre = part.slice(0, position)
      const body = part.slice(position)
      const matches = balancedMatch("(", ")", body)

      const bodySelectors = matches && matches.body ?
        list
          .comma(matches.body)
          .reduce((acc, s) => [
            ...acc,
            ...explodeSelector(s, options),
          ], [])
        : [body]

      const postSelectors = matches && matches.post
github postcss / postcss-selector-not / src / index.js View on Github external
function explodeSelector(pseudoClass, selector) {
  const position = locatePseudoClass(selector, pseudoClass)
  if (selector && position > -1) {
    const pre = selector.slice(0, position)
    const matches = balancedMatch("(", ")", selector.slice(position))
    const bodySelectors = matches.body
      ? list
        .comma(matches.body)
        .map(s => explodeSelector(pseudoClass, s))
        .join(`)${pseudoClass}(`)
      : ""
    const postSelectors = matches.post
      ? explodeSelector(pseudoClass, matches.post)
      : ""

    return `${pre}${pseudoClass}(${bodySelectors})${postSelectors}`
  }
  return selector
}
github anandthakker / doiuse / dist / data / features.js View on Github external
values: [function (value) {
      return list.comma(value).length > 1
    }]
  },
github cytle / wechat_web_devtools / package.nw / node_modules / autoprefixer / lib / transition.js View on Github external
decl.parent.each(function (i) {
            if (i.type !== 'decl') {
                return undefined;
            }
            if (i.prop.indexOf('transition-') !== 0) {
                return undefined;
            }
            if (i.prop === 'transition-property') {
                return undefined;
            }

            if (list.comma(i.value).length > 1) {
                decl.warn(result, 'Replace transition-property to transition, ' + 'because Autoprefixer could not support ' + 'any cases of transition-property ' + 'and other transition-*');
            }
            return false;
        });
    };
github Graphite-Docs / graphite / node_modules / autoprefixer / lib / transition.js View on Github external
decl.parent.each(function (i) {
            if (i.type !== 'decl') {
                return undefined;
            }
            if (i.prop.indexOf('transition-') !== 0) {
                return undefined;
            }
            if (i.prop === 'transition-property') {
                return undefined;
            }

            if (list.comma(i.value).length > 1) {
                decl.warn(result, 'Replace transition-property to transition, ' + 'because Autoprefixer could not support ' + 'any cases of transition-property ' + 'and other transition-*');
            }
            return false;
        });
    };