How to use css-selector-tokenizer - 10 common examples

To help you get started, we’ve selected a few css-selector-tokenizer 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 elastic / timelion / node_modules / postcss-modules-local-by-default / index.js View on Github external
css.eachRule(function(rule) {
      if(rule.parent.type === "atrule" && /keyframes$/.test(rule.parent.name)) {
        // ignore keyframe rules
        return;
      }
      var selector = Tokenizer.parse(rule.selector);
      var context = {
        options: options,
        global: globalMode,
        hasPureGlobals: false
      };
      var newSelector;
      try {
        newSelector = localizeNode(selector, context);
      } catch(e) {
        throw rule.error(e.message);
      }
      if(pureMode && context.hasPureGlobals) {
        throw rule.error("Selector '" + Tokenizer.stringify(selector) + "' is not pure " +
          "(pure selectors must contain at least one local class or id)");
      }
      rule.nodes.forEach(function(decl) {
github decentraland / editor-legacy / node_modules / postcss-modules-local-by-default / index.js View on Github external
css.walkRules(function(rule) {
      if(rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name)) {
        // ignore keyframe rules
        return;
      }
      var selector = Tokenizer.parse(rule.selector);
      var context = {
        options: options,
        global: globalMode,
        hasPureGlobals: false
      };
      var newSelector;
      try {
        newSelector = localizeNode(selector, context);
      } catch(e) {
        throw rule.error(e.message);
      }
      if(pureMode && context.hasPureGlobals) {
        throw rule.error('Selector "' + Tokenizer.stringify(selector) + '" is not pure ' +
          '(pure selectors must contain at least one local class or id)');
      }
      // Less-syntax mixins parse as rules with no nodes
github css-modules / postcss-icss-selectors / index.js View on Github external
function localizeDecl(decl, context) {
  var valuesNode = Tokenizer.parseValues(decl.value);
  var localizeName = /animation(-name)?$/.test(decl.prop);
  var newValuesNode = Object.create(valuesNode);
  newValuesNode.nodes = valuesNode.nodes.map(function(valueNode) {
    var subContext = {
      options: context.options,
      global: context.global,
      localizeNextItem: localizeName && !context.global
    };
    return localizeDeclValue(valueNode, subContext);
  });
  decl.value = Tokenizer.stringifyValues(newValuesNode);
}
github elastic / timelion / node_modules / css-loader / lib / processCss.js View on Github external
case "url":
						if(!/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
							item.stringType = "";
							delete item.innerSpacingBefore;
							delete item.innerSpacingAfter;
							var url = item.url;
							item.url = "___CSS_LOADER_URL___" + urlItems.length + "___";
							urlItems.push({
								url: url
							});
						}
						break;
					}
				});
			});
			decl.value = Tokenizer.stringifyValues(values);
		});
		css.eachAtRule(function(atrule) {
github sx1989827 / DOClever / node_modules / css-loader / lib / processCss.js View on Github external
css.walkAtRules(/^import$/i, function(rule) {
				var values = Tokenizer.parseValues(rule.params);
				var url = values.nodes[0].nodes[0];
				if(url && url.type === "url") {
					url = url.url;
				} else if(url && url.type === "string") {
					url = url.value;
				} else throw rule.error("Unexpected format " + rule.params);
				if (!url.replace(/\s/g, '').length) {
					return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);

				if(loaderUtils.isUrlRequest(url, options.root)) {
					url = loaderUtils.urlToRequest(url, options.root);
				}
github willurmston / Tone.Editor / node_modules / css-loader / lib / processCss.js View on Github external
css.walkDecls(function(decl) {
			var values = Tokenizer.parseValues(decl.value);
			values.nodes.forEach(function(value) {
				value.nodes.forEach(processNode);
			});
			decl.value = Tokenizer.stringifyValues(values);
		});
		css.walkAtRules(function(atrule) {
github zubairghori / Ultimate_todo_list / node_modules / css-loader / lib / processCss.js View on Github external
css.walkAtRules(/^import$/i, function(rule) {
				var values = Tokenizer.parseValues(rule.params);
				var url = values.nodes[0].nodes[0];
				if(url && url.type === "url") {
					url = url.url;
				} else if(url && url.type === "string") {
					url = url.value;
				} else throw rule.error("Unexpected format " + rule.params);
				if (!url.replace(/\s/g, '').length) {
					return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,
github sx1989827 / DOClever / Desktop / node_modules / css-loader / lib / processCss.js View on Github external
css.walkAtRules(/^import$/i, function(rule) {
				var values = Tokenizer.parseValues(rule.params);
				var url = values.nodes[0].nodes[0];
				if(url && url.type === "url") {
					url = url.url;
				} else if(url && url.type === "string") {
					url = url.value;
				} else throw rule.error("Unexpected format " + rule.params);
				if (!url.replace(/\s/g, '').length) {
					return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,
github markfinger / unfort / compiler / postcss_ast_dependencies.js View on Github external
function getDependencyIdentifiersFromDeclarationValue(value) {
    const node = css_selector_tokenizer_1.parseValues(value);
    const accum = [];
    findUrlsInNode(node, accum);
    return accum;
}
exports.getDependencyIdentifiersFromDeclarationValue = getDependencyIdentifiersFromDeclarationValue;
github fossasia / susper.com / node_modules / css-loader / lib / processCss.js View on Github external
css.walkAtRules(/^import$/i, function(rule) {
				var values = Tokenizer.parseValues(rule.params);
				var url = values.nodes[0].nodes[0];
				if(url && url.type === "url") {
					url = url.url;
				} else if(url && url.type === "string") {
					url = url.value;
				} else throw rule.error("Unexpected format " + rule.params);
				if (!url.replace(/\s/g, '').length) {
					return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,

css-selector-tokenizer

Parses and stringifies CSS selectors

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis