postcss-font-variant
Advanced tools
Comparing version 4.0.1 to 5.0.0
@@ -0,1 +1,6 @@ | ||
# 5.0.0 - 2021-01-12 | ||
- Changed: use PostCSS 7 API | ||
- Updated: Node support to 10.0.0 (major) | ||
# 4.0.1 - 2020-10-28 | ||
@@ -2,0 +7,0 @@ |
85
index.js
@@ -1,3 +0,1 @@ | ||
var postcss = require("postcss"); | ||
/** | ||
@@ -8,3 +6,3 @@ * font variant convertion map | ||
*/ | ||
var fontVariantProperties = { | ||
const fontVariantProperties = { | ||
"font-variant-ligatures": { | ||
@@ -59,5 +57,5 @@ "common-ligatures": "\"liga\", \"clig\"", | ||
// The `font-variant` property is a shorthand for all the others. | ||
for (var prop in fontVariantProperties) { | ||
var keys = fontVariantProperties[prop] | ||
for (var key in keys) { | ||
for (const prop in fontVariantProperties) { | ||
const keys = fontVariantProperties[prop] | ||
for (const key in keys) { | ||
if (!(key in fontVariantProperties["font-variant"])) { | ||
@@ -72,4 +70,4 @@ fontVariantProperties["font-variant"][key] = keys[key] | ||
function getFontFeatureSettingsPrevTo(decl) { | ||
var fontFeatureSettings = null; | ||
decl.parent.walkDecls(function(decl) { | ||
let fontFeatureSettings = null; | ||
decl.parent.walkDecls((decl) => { | ||
if (decl.prop === "font-feature-settings") { | ||
@@ -89,37 +87,44 @@ fontFeatureSettings = decl; | ||
function walkRule(rule) { | ||
let fontFeatureSettings = null | ||
// read custom media queries | ||
rule.walkDecls((decl) => { | ||
if (!fontVariantProperties[decl.prop]) { | ||
return null | ||
} | ||
let newValue = decl.value | ||
if (decl.prop === "font-variant") { | ||
newValue = decl.value.split(/\s+/g).map((val) => { | ||
return fontVariantProperties["font-variant"][val] | ||
}).join(", ") | ||
} | ||
else if (fontVariantProperties[decl.prop][decl.value]) { | ||
newValue = fontVariantProperties[decl.prop][decl.value] | ||
} | ||
if (fontFeatureSettings === null) { | ||
fontFeatureSettings = getFontFeatureSettingsPrevTo(decl); | ||
} | ||
if (fontFeatureSettings.value && fontFeatureSettings.value !== newValue) { | ||
fontFeatureSettings.value += ", " + newValue; | ||
} | ||
else { | ||
fontFeatureSettings.value = newValue; | ||
} | ||
}) | ||
} | ||
/** | ||
* Expose the font-variant plugin. | ||
*/ | ||
module.exports = postcss.plugin("postcss-font-variant", function() { | ||
return function(styles) { | ||
styles.walkRules(function(rule) { | ||
var fontFeatureSettings = null | ||
// read custom media queries | ||
rule.walkDecls(function(decl) { | ||
if (!fontVariantProperties[decl.prop]) { | ||
return null | ||
} | ||
module.exports = () => { | ||
return { | ||
postcssPlugin: "postcss-font-variant", | ||
Once(root) { | ||
root.walkRules(walkRule) | ||
} | ||
} | ||
} | ||
var newValue = decl.value | ||
if (decl.prop === "font-variant") { | ||
newValue = decl.value.split(/\s+/g).map(function(val) { | ||
return fontVariantProperties["font-variant"][val] | ||
}).join(", ") | ||
} | ||
else if (fontVariantProperties[decl.prop][decl.value]) { | ||
newValue = fontVariantProperties[decl.prop][decl.value] | ||
} | ||
if (fontFeatureSettings === null) { | ||
fontFeatureSettings = getFontFeatureSettingsPrevTo(decl); | ||
} | ||
if (fontFeatureSettings.value && fontFeatureSettings.value !== newValue) { | ||
fontFeatureSettings.value += ", " + newValue; | ||
} | ||
else { | ||
fontFeatureSettings.value = newValue; | ||
} | ||
}) | ||
}) | ||
} | ||
}) | ||
module.exports.postcss = true |
{ | ||
"name": "postcss-font-variant", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "PostCSS plugin to transform W3C font-variant properties to more compatible CSS (font-feature-settings)", | ||
@@ -19,4 +19,4 @@ "keywords": [ | ||
], | ||
"dependencies": { | ||
"postcss": "^7.0.2" | ||
"peerDependencies": { | ||
"postcss": "^8.1.0" | ||
}, | ||
@@ -27,3 +27,4 @@ "devDependencies": { | ||
"npmpub": "^4.1.0", | ||
"tape": "^4.9.1" | ||
"postcss": "^8.1.0", | ||
"tape": "^5.0.0" | ||
}, | ||
@@ -30,0 +31,0 @@ "scripts": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8181
113
0
5
+ Addednanoid@3.3.7(transitive)
+ Addedpicocolors@1.0.0(transitive)
+ Addedpostcss@8.4.38(transitive)
+ Addedsource-map-js@1.2.0(transitive)
- Removedpostcss@^7.0.2
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)