cssstyle 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generated/implementedProperties.js +1 -1
- package/lib/generated/properties.js +137 -50
- package/lib/properties/backgroundAttachment.js +1 -1
- package/lib/properties/backgroundColor.js +1 -1
- package/lib/properties/backgroundImage.js +1 -1
- package/lib/properties/backgroundPosition.js +1 -1
- package/lib/properties/backgroundRepeat.js +1 -1
- package/lib/properties/font.js +94 -29
- package/lib/properties/fontFamily.js +23 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// autogenerated - 2025-06-
|
|
2
|
+
// autogenerated - 2025-06-20
|
|
3
3
|
// https://www.w3.org/Style/CSS/all-properties.en.html
|
|
4
4
|
|
|
5
5
|
var external_dependency_parsers_0 = require("../parsers.js");
|
|
@@ -18,7 +18,7 @@ backgroundImage_export_definition = {
|
|
|
18
18
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
19
19
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
20
20
|
this._setProperty("background", "");
|
|
21
|
-
this._setProperty("
|
|
21
|
+
this._setProperty("background-image", v);
|
|
22
22
|
} else {
|
|
23
23
|
this._setProperty("background-image", backgroundImage_export_parse(v));
|
|
24
24
|
}
|
|
@@ -65,7 +65,7 @@ backgroundPosition_export_definition = {
|
|
|
65
65
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
66
66
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
67
67
|
this._setProperty("background", "");
|
|
68
|
-
this._setProperty("
|
|
68
|
+
this._setProperty("background-position", v);
|
|
69
69
|
} else {
|
|
70
70
|
this._setProperty("background-position", backgroundPosition_export_parse(v));
|
|
71
71
|
}
|
|
@@ -92,7 +92,7 @@ backgroundRepeat_export_definition = {
|
|
|
92
92
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
93
93
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
94
94
|
this._setProperty("background", "");
|
|
95
|
-
this._setProperty("
|
|
95
|
+
this._setProperty("background-repeat", v);
|
|
96
96
|
} else {
|
|
97
97
|
this._setProperty("background-repeat", backgroundRepeat_export_parse(v));
|
|
98
98
|
}
|
|
@@ -119,7 +119,7 @@ backgroundAttachment_export_definition = {
|
|
|
119
119
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
120
120
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
121
121
|
this._setProperty("background", "");
|
|
122
|
-
this._setProperty("
|
|
122
|
+
this._setProperty("background-attachment", v);
|
|
123
123
|
} else {
|
|
124
124
|
this._setProperty("background-attachment", backgroundAttachment_export_parse(v));
|
|
125
125
|
}
|
|
@@ -149,7 +149,7 @@ backgroundColor_export_definition = {
|
|
|
149
149
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
150
150
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
151
151
|
this._setProperty("background", "");
|
|
152
|
-
this._setProperty("
|
|
152
|
+
this._setProperty("background-color", v);
|
|
153
153
|
} else {
|
|
154
154
|
this._setProperty("background-color", backgroundColor_export_parse(v));
|
|
155
155
|
}
|
|
@@ -1427,7 +1427,7 @@ fontFamily_export_parse = function parse(v) {
|
|
|
1427
1427
|
if (v === "") {
|
|
1428
1428
|
return v;
|
|
1429
1429
|
}
|
|
1430
|
-
const keywords = ["serif", "sans-serif", "system-ui", "
|
|
1430
|
+
const keywords = ["serif", "sans-serif", "cursive", "fantasy", "monospace", "system-ui", "math", "ui-serif", "ui-sans-serif", "ui-monospace", "ui-rounded"];
|
|
1431
1431
|
const val = external_dependency_parsers_0.splitValue(v, {
|
|
1432
1432
|
delimiter: ","
|
|
1433
1433
|
});
|
|
@@ -1446,16 +1446,15 @@ fontFamily_export_parse = function parse(v) {
|
|
|
1446
1446
|
valid = true;
|
|
1447
1447
|
continue;
|
|
1448
1448
|
}
|
|
1449
|
-
// This implementation does not strictly follow the specification.
|
|
1450
|
-
// does not require the first letter of the font-family to be
|
|
1451
|
-
//
|
|
1449
|
+
// This implementation does not strictly follow the specification.
|
|
1450
|
+
// The spec does not require the first letter of the font-family to be
|
|
1451
|
+
// capitalized, and unquoted font-family names are not restricted to ASCII.
|
|
1452
1452
|
// However, in the real world, the first letter of the ASCII font-family
|
|
1453
|
-
// names are
|
|
1454
|
-
//
|
|
1455
|
-
//
|
|
1456
|
-
// Therefore, it is unlikely that this implementation will cause problems.
|
|
1453
|
+
// names are capitalized, and unquoted font-family names do not contain
|
|
1454
|
+
// spaces, e.g. `Times`. And non-ASCII font-family names are quoted even
|
|
1455
|
+
// without spaces, e.g. `"メイリオ"`.
|
|
1457
1456
|
// @see https://drafts.csswg.org/css-fonts/#font-family-prop
|
|
1458
|
-
if (
|
|
1457
|
+
if (i !== "undefined" && /^(?:[A-Z][A-Za-z\d-]+(?:\s+[A-Z][A-Za-z\d-]+)*|-?[a-z][a-z-]+)$/.test(i)) {
|
|
1459
1458
|
font.push(i.trim());
|
|
1460
1459
|
valid = true;
|
|
1461
1460
|
continue;
|
|
@@ -1523,50 +1522,138 @@ font_export_parse = function parse(v) {
|
|
|
1523
1522
|
const [fontBlock, ...families] = external_dependency_parsers_0.splitValue(v, {
|
|
1524
1523
|
delimiter: ","
|
|
1525
1524
|
});
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
}
|
|
1534
|
-
const obj = external_dependency_parsers_0.parseShorthand(blockA, font_local_var_shorthandFor, true);
|
|
1535
|
-
if (!obj) {
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
const font = {};
|
|
1525
|
+
const [fontBlockA, fontBlockB] = external_dependency_parsers_0.splitValue(fontBlock, {
|
|
1526
|
+
delimiter: "/"
|
|
1527
|
+
});
|
|
1528
|
+
const font = {
|
|
1529
|
+
"font-style": "normal",
|
|
1530
|
+
"font-variant": "normal",
|
|
1531
|
+
"font-weight": "normal"
|
|
1532
|
+
};
|
|
1539
1533
|
const fontFamilies = new Set();
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1534
|
+
if (fontBlockB) {
|
|
1535
|
+
const [lineB, ...familiesB] = fontBlockB.trim().split(" ");
|
|
1536
|
+
if (!lineB || !{
|
|
1537
|
+
parse: lineHeight_export_parse,
|
|
1538
|
+
isValid: lineHeight_export_isValid,
|
|
1539
|
+
definition: lineHeight_export_definition
|
|
1540
|
+
}.isValid(lineB) || !familiesB.length) {
|
|
1541
|
+
return;
|
|
1547
1542
|
}
|
|
1548
|
-
|
|
1549
|
-
// blockB, if matched, includes line-height and first font-family
|
|
1550
|
-
if (blockB) {
|
|
1551
|
-
const [lineheight, family] = external_dependency_parsers_0.splitValue(blockB);
|
|
1552
|
-
if ({
|
|
1543
|
+
const lineHeightB = {
|
|
1553
1544
|
parse: lineHeight_export_parse,
|
|
1554
1545
|
isValid: lineHeight_export_isValid,
|
|
1555
1546
|
definition: lineHeight_export_definition
|
|
1556
|
-
}.
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1547
|
+
}.parse(lineB);
|
|
1548
|
+
const familyB = familiesB.join(" ");
|
|
1549
|
+
if ({
|
|
1550
|
+
parse: fontFamily_export_parse,
|
|
1551
|
+
isValid: fontFamily_export_isValid,
|
|
1552
|
+
definition: fontFamily_export_definition
|
|
1553
|
+
}.isValid(familyB)) {
|
|
1554
|
+
fontFamilies.add({
|
|
1555
|
+
parse: fontFamily_export_parse,
|
|
1556
|
+
isValid: fontFamily_export_isValid,
|
|
1557
|
+
definition: fontFamily_export_definition
|
|
1558
|
+
}.parse(familyB));
|
|
1562
1559
|
} else {
|
|
1563
1560
|
return;
|
|
1564
1561
|
}
|
|
1565
|
-
|
|
1562
|
+
const parts = external_dependency_parsers_0.splitValue(fontBlockA.trim());
|
|
1563
|
+
const properties = ["font-style", "font-variant", "font-weight", "font-size"];
|
|
1564
|
+
for (const part of parts) {
|
|
1565
|
+
if (part === "normal") {
|
|
1566
|
+
continue;
|
|
1567
|
+
} else {
|
|
1568
|
+
for (const property of properties) {
|
|
1569
|
+
switch (property) {
|
|
1570
|
+
case "font-style":
|
|
1571
|
+
case "font-variant":
|
|
1572
|
+
case "font-weight":
|
|
1573
|
+
{
|
|
1574
|
+
const value = font_local_var_shorthandFor.get(property);
|
|
1575
|
+
if (value.isValid(part)) {
|
|
1576
|
+
font[property] = value.parse(part);
|
|
1577
|
+
}
|
|
1578
|
+
break;
|
|
1579
|
+
}
|
|
1580
|
+
case "font-size":
|
|
1581
|
+
{
|
|
1582
|
+
const value = font_local_var_shorthandFor.get(property);
|
|
1583
|
+
if (value.isValid(part)) {
|
|
1584
|
+
font[property] = value.parse(part);
|
|
1585
|
+
}
|
|
1586
|
+
break;
|
|
1587
|
+
}
|
|
1588
|
+
default:
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
if (Object.hasOwn(font, "font-size")) {
|
|
1594
|
+
font["line-height"] = lineHeightB;
|
|
1595
|
+
} else {
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
} else {
|
|
1599
|
+
// FIXME: Switch to toReversed() when we can drop Node.js 18 support.
|
|
1600
|
+
const revParts = [...external_dependency_parsers_0.splitValue(fontBlockA.trim())].reverse();
|
|
1601
|
+
const revFontFamily = [];
|
|
1602
|
+
const properties = ["font-style", "font-variant", "font-weight", "line-height"];
|
|
1603
|
+
font["font-style"] = "normal";
|
|
1604
|
+
font["font-variant"] = "normal";
|
|
1605
|
+
font["font-weight"] = "normal";
|
|
1606
|
+
font["line-height"] = "normal";
|
|
1607
|
+
let fontSizeA;
|
|
1608
|
+
for (const part of revParts) {
|
|
1609
|
+
if (fontSizeA) {
|
|
1610
|
+
if (part === "normal") {
|
|
1611
|
+
continue;
|
|
1612
|
+
} else {
|
|
1613
|
+
for (const property of properties) {
|
|
1614
|
+
switch (property) {
|
|
1615
|
+
case "font-style":
|
|
1616
|
+
case "font-variant":
|
|
1617
|
+
case "font-weight":
|
|
1618
|
+
case "line-height":
|
|
1619
|
+
{
|
|
1620
|
+
const value = font_local_var_shorthandFor.get(property);
|
|
1621
|
+
if (value.isValid(part)) {
|
|
1622
|
+
font[property] = value.parse(part);
|
|
1623
|
+
}
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
default:
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
} else if ({
|
|
1631
|
+
parse: fontSize_export_parse,
|
|
1632
|
+
isValid: fontSize_export_isValid,
|
|
1633
|
+
definition: fontSize_export_definition
|
|
1634
|
+
}.isValid(part)) {
|
|
1635
|
+
fontSizeA = {
|
|
1636
|
+
parse: fontSize_export_parse,
|
|
1637
|
+
isValid: fontSize_export_isValid,
|
|
1638
|
+
definition: fontSize_export_definition
|
|
1639
|
+
}.parse(part);
|
|
1640
|
+
} else if ({
|
|
1641
|
+
parse: fontFamily_export_parse,
|
|
1642
|
+
isValid: fontFamily_export_isValid,
|
|
1643
|
+
definition: fontFamily_export_definition
|
|
1644
|
+
}.isValid(part)) {
|
|
1645
|
+
revFontFamily.push(part);
|
|
1646
|
+
} else {
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
const family = revFontFamily.reverse().join(" ");
|
|
1651
|
+
if (fontSizeA && {
|
|
1566
1652
|
parse: fontFamily_export_parse,
|
|
1567
1653
|
isValid: fontFamily_export_isValid,
|
|
1568
1654
|
definition: fontFamily_export_definition
|
|
1569
1655
|
}.isValid(family)) {
|
|
1656
|
+
font["font-size"] = fontSizeA;
|
|
1570
1657
|
fontFamilies.add({
|
|
1571
1658
|
parse: fontFamily_export_parse,
|
|
1572
1659
|
isValid: fontFamily_export_isValid,
|
|
@@ -1597,7 +1684,7 @@ font_export_parse = function parse(v) {
|
|
|
1597
1684
|
font_export_definition = {
|
|
1598
1685
|
set(v) {
|
|
1599
1686
|
v = external_dependency_parsers_0.prepareValue(v, this._global);
|
|
1600
|
-
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
1687
|
+
if (v === "" || external_dependency_parsers_0.hasVarFunc(v)) {
|
|
1601
1688
|
for (const [key] of font_local_var_shorthandFor) {
|
|
1602
1689
|
this._setProperty(key, "");
|
|
1603
1690
|
}
|
|
@@ -1612,7 +1699,7 @@ font_export_definition = {
|
|
|
1612
1699
|
const val = obj[key];
|
|
1613
1700
|
if (typeof val === "string") {
|
|
1614
1701
|
this._setProperty(key, val);
|
|
1615
|
-
if (val && !str.has(val)) {
|
|
1702
|
+
if (val && val !== "normal" && !str.has(val)) {
|
|
1616
1703
|
if (key === "line-height") {
|
|
1617
1704
|
str.add(`/ ${val}`);
|
|
1618
1705
|
} else {
|
|
@@ -1635,7 +1722,7 @@ font_export_definition = {
|
|
|
1635
1722
|
if (external_dependency_parsers_0.hasVarFunc(v)) {
|
|
1636
1723
|
return "";
|
|
1637
1724
|
}
|
|
1638
|
-
if (v && !str.has(v)) {
|
|
1725
|
+
if (v && v !== "normal" && !str.has(v)) {
|
|
1639
1726
|
if (key === "line-height") {
|
|
1640
1727
|
str.add(`/ ${v}`);
|
|
1641
1728
|
} else {
|
|
@@ -19,7 +19,7 @@ module.exports.definition = {
|
|
|
19
19
|
v = parsers.prepareValue(v, this._global);
|
|
20
20
|
if (parsers.hasVarFunc(v)) {
|
|
21
21
|
this._setProperty("background", "");
|
|
22
|
-
this._setProperty("
|
|
22
|
+
this._setProperty("background-attachment", v);
|
|
23
23
|
} else {
|
|
24
24
|
this._setProperty("background-attachment", module.exports.parse(v));
|
|
25
25
|
}
|
|
@@ -22,7 +22,7 @@ module.exports.definition = {
|
|
|
22
22
|
v = parsers.prepareValue(v, this._global);
|
|
23
23
|
if (parsers.hasVarFunc(v)) {
|
|
24
24
|
this._setProperty("background", "");
|
|
25
|
-
this._setProperty("
|
|
25
|
+
this._setProperty("background-color", v);
|
|
26
26
|
} else {
|
|
27
27
|
this._setProperty("background-color", module.exports.parse(v));
|
|
28
28
|
}
|
|
@@ -18,7 +18,7 @@ module.exports.definition = {
|
|
|
18
18
|
v = parsers.prepareValue(v, this._global);
|
|
19
19
|
if (parsers.hasVarFunc(v)) {
|
|
20
20
|
this._setProperty("background", "");
|
|
21
|
-
this._setProperty("
|
|
21
|
+
this._setProperty("background-image", v);
|
|
22
22
|
} else {
|
|
23
23
|
this._setProperty("background-image", module.exports.parse(v));
|
|
24
24
|
}
|
|
@@ -39,7 +39,7 @@ module.exports.definition = {
|
|
|
39
39
|
v = parsers.prepareValue(v, this._global);
|
|
40
40
|
if (parsers.hasVarFunc(v)) {
|
|
41
41
|
this._setProperty("background", "");
|
|
42
|
-
this._setProperty("
|
|
42
|
+
this._setProperty("background-position", v);
|
|
43
43
|
} else {
|
|
44
44
|
this._setProperty("background-position", module.exports.parse(v));
|
|
45
45
|
}
|
|
@@ -19,7 +19,7 @@ module.exports.definition = {
|
|
|
19
19
|
v = parsers.prepareValue(v, this._global);
|
|
20
20
|
if (parsers.hasVarFunc(v)) {
|
|
21
21
|
this._setProperty("background", "");
|
|
22
|
-
this._setProperty("
|
|
22
|
+
this._setProperty("background-repeat", v);
|
|
23
23
|
} else {
|
|
24
24
|
this._setProperty("background-repeat", module.exports.parse(v));
|
|
25
25
|
}
|
package/lib/properties/font.js
CHANGED
|
@@ -26,38 +26,103 @@ module.exports.parse = function parse(v) {
|
|
|
26
26
|
const [fontBlock, ...families] = parsers.splitValue(v, {
|
|
27
27
|
delimiter: ","
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const obj = parsers.parseShorthand(blockA, shorthandFor, true);
|
|
38
|
-
if (!obj) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const font = {};
|
|
29
|
+
const [fontBlockA, fontBlockB] = parsers.splitValue(fontBlock, {
|
|
30
|
+
delimiter: "/"
|
|
31
|
+
});
|
|
32
|
+
const font = {
|
|
33
|
+
"font-style": "normal",
|
|
34
|
+
"font-variant": "normal",
|
|
35
|
+
"font-weight": "normal"
|
|
36
|
+
};
|
|
42
37
|
const fontFamilies = new Set();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
if (fontBlockB) {
|
|
39
|
+
const [lineB, ...familiesB] = fontBlockB.trim().split(" ");
|
|
40
|
+
if (!lineB || !lineHeight.isValid(lineB) || !familiesB.length) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const lineHeightB = lineHeight.parse(lineB);
|
|
44
|
+
const familyB = familiesB.join(" ");
|
|
45
|
+
if (fontFamily.isValid(familyB)) {
|
|
46
|
+
fontFamilies.add(fontFamily.parse(familyB));
|
|
48
47
|
} else {
|
|
49
|
-
|
|
48
|
+
return;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
const parts = parsers.splitValue(fontBlockA.trim());
|
|
51
|
+
const properties = ["font-style", "font-variant", "font-weight", "font-size"];
|
|
52
|
+
for (const part of parts) {
|
|
53
|
+
if (part === "normal") {
|
|
54
|
+
continue;
|
|
55
|
+
} else {
|
|
56
|
+
for (const property of properties) {
|
|
57
|
+
switch (property) {
|
|
58
|
+
case "font-style":
|
|
59
|
+
case "font-variant":
|
|
60
|
+
case "font-weight": {
|
|
61
|
+
const value = shorthandFor.get(property);
|
|
62
|
+
if (value.isValid(part)) {
|
|
63
|
+
font[property] = value.parse(part);
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case "font-size": {
|
|
68
|
+
const value = shorthandFor.get(property);
|
|
69
|
+
if (value.isValid(part)) {
|
|
70
|
+
font[property] = value.parse(part);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (Object.hasOwn(font, "font-size")) {
|
|
80
|
+
font["line-height"] = lineHeightB;
|
|
57
81
|
} else {
|
|
58
82
|
return;
|
|
59
83
|
}
|
|
60
|
-
|
|
84
|
+
} else {
|
|
85
|
+
// FIXME: Switch to toReversed() when we can drop Node.js 18 support.
|
|
86
|
+
const revParts = [...parsers.splitValue(fontBlockA.trim())].reverse();
|
|
87
|
+
const revFontFamily = [];
|
|
88
|
+
const properties = ["font-style", "font-variant", "font-weight", "line-height"];
|
|
89
|
+
font["font-style"] = "normal";
|
|
90
|
+
font["font-variant"] = "normal";
|
|
91
|
+
font["font-weight"] = "normal";
|
|
92
|
+
font["line-height"] = "normal";
|
|
93
|
+
let fontSizeA;
|
|
94
|
+
for (const part of revParts) {
|
|
95
|
+
if (fontSizeA) {
|
|
96
|
+
if (part === "normal") {
|
|
97
|
+
continue;
|
|
98
|
+
} else {
|
|
99
|
+
for (const property of properties) {
|
|
100
|
+
switch (property) {
|
|
101
|
+
case "font-style":
|
|
102
|
+
case "font-variant":
|
|
103
|
+
case "font-weight":
|
|
104
|
+
case "line-height": {
|
|
105
|
+
const value = shorthandFor.get(property);
|
|
106
|
+
if (value.isValid(part)) {
|
|
107
|
+
font[property] = value.parse(part);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
default:
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} else if (fontSize.isValid(part)) {
|
|
116
|
+
fontSizeA = fontSize.parse(part);
|
|
117
|
+
} else if (fontFamily.isValid(part)) {
|
|
118
|
+
revFontFamily.push(part);
|
|
119
|
+
} else {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const family = revFontFamily.reverse().join(" ");
|
|
124
|
+
if (fontSizeA && fontFamily.isValid(family)) {
|
|
125
|
+
font["font-size"] = fontSizeA;
|
|
61
126
|
fontFamilies.add(fontFamily.parse(family));
|
|
62
127
|
} else {
|
|
63
128
|
return;
|
|
@@ -77,7 +142,7 @@ module.exports.parse = function parse(v) {
|
|
|
77
142
|
module.exports.definition = {
|
|
78
143
|
set(v) {
|
|
79
144
|
v = parsers.prepareValue(v, this._global);
|
|
80
|
-
if (parsers.hasVarFunc(v)) {
|
|
145
|
+
if (v === "" || parsers.hasVarFunc(v)) {
|
|
81
146
|
for (const [key] of shorthandFor) {
|
|
82
147
|
this._setProperty(key, "");
|
|
83
148
|
}
|
|
@@ -92,7 +157,7 @@ module.exports.definition = {
|
|
|
92
157
|
const val = obj[key];
|
|
93
158
|
if (typeof val === "string") {
|
|
94
159
|
this._setProperty(key, val);
|
|
95
|
-
if (val && !str.has(val)) {
|
|
160
|
+
if (val && val !== "normal" && !str.has(val)) {
|
|
96
161
|
if (key === "line-height") {
|
|
97
162
|
str.add(`/ ${val}`);
|
|
98
163
|
} else {
|
|
@@ -115,7 +180,7 @@ module.exports.definition = {
|
|
|
115
180
|
if (parsers.hasVarFunc(v)) {
|
|
116
181
|
return "";
|
|
117
182
|
}
|
|
118
|
-
if (v && !str.has(v)) {
|
|
183
|
+
if (v && v !== "normal" && !str.has(v)) {
|
|
119
184
|
if (key === "line-height") {
|
|
120
185
|
str.add(`/ ${v}`);
|
|
121
186
|
} else {
|
|
@@ -6,7 +6,19 @@ module.exports.parse = function parse(v) {
|
|
|
6
6
|
if (v === "") {
|
|
7
7
|
return v;
|
|
8
8
|
}
|
|
9
|
-
const keywords = [
|
|
9
|
+
const keywords = [
|
|
10
|
+
"serif",
|
|
11
|
+
"sans-serif",
|
|
12
|
+
"cursive",
|
|
13
|
+
"fantasy",
|
|
14
|
+
"monospace",
|
|
15
|
+
"system-ui",
|
|
16
|
+
"math",
|
|
17
|
+
"ui-serif",
|
|
18
|
+
"ui-sans-serif",
|
|
19
|
+
"ui-monospace",
|
|
20
|
+
"ui-rounded"
|
|
21
|
+
];
|
|
10
22
|
const val = parsers.splitValue(v, {
|
|
11
23
|
delimiter: ","
|
|
12
24
|
});
|
|
@@ -25,16 +37,18 @@ module.exports.parse = function parse(v) {
|
|
|
25
37
|
valid = true;
|
|
26
38
|
continue;
|
|
27
39
|
}
|
|
28
|
-
// This implementation does not strictly follow the specification.
|
|
29
|
-
// does not require the first letter of the font-family to be
|
|
30
|
-
//
|
|
40
|
+
// This implementation does not strictly follow the specification.
|
|
41
|
+
// The spec does not require the first letter of the font-family to be
|
|
42
|
+
// capitalized, and unquoted font-family names are not restricted to ASCII.
|
|
31
43
|
// However, in the real world, the first letter of the ASCII font-family
|
|
32
|
-
// names are
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// Therefore, it is unlikely that this implementation will cause problems.
|
|
44
|
+
// names are capitalized, and unquoted font-family names do not contain
|
|
45
|
+
// spaces, e.g. `Times`. And non-ASCII font-family names are quoted even
|
|
46
|
+
// without spaces, e.g. `"メイリオ"`.
|
|
36
47
|
// @see https://drafts.csswg.org/css-fonts/#font-family-prop
|
|
37
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
i !== "undefined" &&
|
|
50
|
+
/^(?:[A-Z][A-Za-z\d-]+(?:\s+[A-Z][A-Za-z\d-]+)*|-?[a-z][a-z-]+)$/.test(i)
|
|
51
|
+
) {
|
|
38
52
|
font.push(i.trim());
|
|
39
53
|
valid = true;
|
|
40
54
|
continue;
|