Socket
Socket
Sign inDemoInstall

postcss-font-variant

Package Overview
Dependencies
4
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 5.0.0

5

CHANGELOG.md

@@ -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": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc