Skip to content

Commit fe2d356

Browse files
committed
Add edge case test
1 parent 7829706 commit fe2d356

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/properties/fontFamily.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ module.exports.parse = function parse(v) {
6767
valid = true;
6868
continue;
6969
}
70+
if (
71+
i !== "undefined" &&
72+
/^(?:[A-Z][A-Za-z\d\\-]+(?:\s+[A-Z][A-Za-z\d\\-]+)*|-?[a-z][a-z-]+)$/.test(i)
73+
) {
74+
const j = i.replaceAll("\\", "").replaceAll('"', '\\"').trim();
75+
font.push(`"${j}"`);
76+
valid = true;
77+
continue;
78+
}
7079
if (!valid) {
7180
return;
7281
}

test/properties.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,14 @@ describe("font", () => {
17461746
);
17471747
});
17481748

1749+
it("font-family should set / get family values", () => {
1750+
testPropertyValue("font-family", "Times\\ New Roman, serif", '"Times New Roman", serif');
1751+
});
1752+
1753+
it("font-family should set / get family values", () => {
1754+
testPropertyValue("font-family", '"Times\\ New Roman", serif', '"Times New Roman", serif');
1755+
});
1756+
17491757
it("font-family should set / get family values", () => {
17501758
testPropertyValue(
17511759
"font-family",

0 commit comments

Comments
 (0)