postcss-normalize-positions
Advanced tools
Comparing version
@@ -8,10 +8,4 @@ "use strict"; | ||
var _postcss = require("postcss"); | ||
var _postcssValueParser = _interopRequireWildcard(require("postcss-value-parser")); | ||
var _has = _interopRequireDefault(require("has")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
@@ -156,3 +150,3 @@ | ||
if ((0, _has.default)(map, firstNode)) { | ||
if (Object.prototype.hasOwnProperty.call(map, firstNode)) { | ||
nodes[0].value = map[firstNode]; | ||
@@ -167,3 +161,3 @@ } | ||
if ((0, _has.default)(horizontal, secondNode)) { | ||
if (Object.prototype.hasOwnProperty.call(horizontal, secondNode)) { | ||
nodes[2].value = horizontal[secondNode]; | ||
@@ -175,7 +169,7 @@ } | ||
if ((0, _has.default)(horizontal, firstNode) && (0, _has.default)(verticalValue, secondNode)) { | ||
if (Object.prototype.hasOwnProperty.call(horizontal, firstNode) && Object.prototype.hasOwnProperty.call(verticalValue, secondNode)) { | ||
nodes[0].value = horizontal[firstNode]; | ||
nodes[2].value = verticalValue[secondNode]; | ||
return; | ||
} else if ((0, _has.default)(verticalValue, firstNode) && (0, _has.default)(horizontal, secondNode)) { | ||
} else if (Object.prototype.hasOwnProperty.call(verticalValue, firstNode) && Object.prototype.hasOwnProperty.call(horizontal, secondNode)) { | ||
nodes[0].value = horizontal[secondNode]; | ||
@@ -189,25 +183,32 @@ nodes[2].value = verticalValue[firstNode]; | ||
var _default = (0, _postcss.plugin)('postcss-normalize-positions', () => { | ||
return css => { | ||
const cache = {}; | ||
css.walkDecls(/^(background(-position)?|(-\w+-)?perspective-origin)$/i, decl => { | ||
const value = decl.value; | ||
function pluginCreator() { | ||
return { | ||
postcssPlugin: 'postcss-normalize-positions', | ||
if (!value) { | ||
return; | ||
} | ||
OnceExit(css) { | ||
const cache = {}; | ||
css.walkDecls(/^(background(-position)?|(-\w+-)?perspective-origin)$/i, decl => { | ||
const value = decl.value; | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
return; | ||
} | ||
if (!value) { | ||
return; | ||
} | ||
const result = transform(value); | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
if (cache[value]) { | ||
decl.value = cache[value]; | ||
return; | ||
} | ||
const result = transform(value); | ||
decl.value = result; | ||
cache[value] = result; | ||
}); | ||
} | ||
}; | ||
}); | ||
} | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "postcss-normalize-positions", | ||
"version": "4.0.0-nightly.2020.1.9", | ||
"version": "4.0.0-nightly.2020.1.11", | ||
"description": "Normalize keyword values for position into length values.", | ||
@@ -29,5 +29,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"has": "^1.0.3", | ||
"postcss": "^7.0.16", | ||
"postcss-value-parser": "^3.3.1" | ||
"postcss-value-parser": "^4.1.0" | ||
}, | ||
@@ -39,3 +37,9 @@ "bugs": { | ||
"node": ">=10.13.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
} | ||
} |
8559
1.15%2
-33.33%165
1.23%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated