Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-normalize-repeat-style

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-normalize-repeat-style - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

120

dist/index.js

@@ -37,54 +37,84 @@ 'use strict';

function transform(decl) {
const values = (0, _postcssValueParser2.default)(decl.value);
if (values.nodes.length === 1) {
return;
}
const args = (0, _cssnanoUtilGetArguments2.default)(values);
const relevant = [];
args.forEach(arg => {
relevant.push({
start: null,
end: null
});
arg.forEach((part, index) => {
const isRepeat = ~repeatKeywords.indexOf(part.value.toLowerCase());
const len = relevant.length - 1;
if (relevant[len].start === null && isRepeat) {
relevant[len].start = index;
relevant[len].end = index;
exports.default = _postcss2.default.plugin('postcss-normalize-repeat-style', () => {
return css => {
const cache = {};
css.walkDecls(/background(-repeat)?|(-webkit-)?mask-repeat/i, decl => {
const value = decl.value;
if (cache[value]) {
decl.value = cache[value];
return;
}
if (relevant[len].start !== null) {
if (part.type === 'space') {
const parsed = (0, _postcssValueParser2.default)(value);
if (parsed.nodes.length === 1) {
cache[value] = value;
return;
}
const args = (0, _cssnanoUtilGetArguments2.default)(parsed);
const relevant = [];
args.forEach(arg => {
relevant.push({
start: null,
end: null
});
arg.forEach((part, index) => {
const isRepeat = ~repeatKeywords.indexOf(part.value.toLowerCase());
const len = relevant.length - 1;
if (relevant[len].start === null && isRepeat) {
relevant[len].start = index;
relevant[len].end = index;
return;
}
if (relevant[len].start !== null) {
if (part.type === 'space') {
return;
} else if (isRepeat) {
relevant[len].end = index;
return;
}
return;
}
});
});
relevant.forEach((range, index) => {
if (range.start === null) {
return;
} else if (isRepeat) {
relevant[len].end = index;
}
const val = args[index].slice(range.start, range.end + 1);
if (val.length !== 3) {
return;
}
return;
}
const match = getMatch(val.filter(evenValues).map(n => n.value.toLowerCase()));
if (match) {
args[index][range.start].value = match;
args[index][range.start + 1].value = '';
args[index][range.end].value = '';
}
});
const result = parsed.toString();
decl.value = result;
cache[value] = result;
});
});
relevant.forEach((range, index) => {
if (range.start === null) {
return;
}
const val = args[index].slice(range.start, range.end + 1);
if (val.length !== 3) {
return;
}
const match = getMatch(val.filter(evenValues).map(n => n.value.toLowerCase()));
if (match) {
args[index][range.start].value = match;
args[index][range.start + 1].value = '';
args[index][range.end].value = '';
}
});
decl.value = values.toString();
}
exports.default = _postcss2.default.plugin('postcss-normalize-repeat-style', () => {
return css => css.walkDecls(/background(-repeat)?|(-webkit-)?mask-repeat/i, transform);
};
});
module.exports = exports['default'];
{
"name": "postcss-normalize-repeat-style",
"version": "4.0.1",
"version": "4.0.2",
"description": "Convert two value syntax for repeat-style into one value.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc