Skip to content

Commit aa1c920

Browse files
authored
Adds isValidProperty util function (#38)
* Adds util module and first isValidProperty function
1 parent a7984f0 commit aa1c920

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

lib/util.js

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/**
2+
* @param {string} propertyName
3+
* @returns {boolean}
4+
*/
5+
export function isValidProperty(propertyName) {
6+
return cssProperties.includes(propertyName);
7+
}
8+
9+
const cssProperties = [
10+
"align-content",
11+
"align-items",
12+
"align-self",
13+
"animation",
14+
"animation-delay",
15+
"animation-direction",
16+
"animation-duration",
17+
"animation-fill-mode",
18+
"animation-iteration-count",
19+
"animation-name",
20+
"animation-play-state",
21+
"animation-timing-function",
22+
"background",
23+
"background-attachment",
24+
"background-color",
25+
"background-image",
26+
"background-position",
27+
"background-repeat",
28+
"background-size",
29+
"border",
30+
"border-collapse",
31+
"border-spacing",
32+
"box-shadow",
33+
"box-sizing",
34+
"caption-side",
35+
"clear",
36+
"clip",
37+
"color",
38+
"contain",
39+
"cursor",
40+
"display",
41+
"empty-cells",
42+
"filter",
43+
"flex",
44+
"flex-basis",
45+
"flex-direction",
46+
"flex-flow",
47+
"flex-grow",
48+
"flex-shrink",
49+
"flex-wrap",
50+
"float",
51+
"font-family",
52+
"font-size",
53+
"font-style",
54+
"font-weight",
55+
"grid",
56+
"grid-area",
57+
"grid-auto-columns",
58+
"grid-auto-flow",
59+
"grid-auto-rows",
60+
"grid-column",
61+
"grid-column-gap",
62+
"grid-gap",
63+
"grid-row",
64+
"grid-row-gap",
65+
"grid-template",
66+
"grid-template-areas",
67+
"grid-template-columns",
68+
"grid-template-rows",
69+
"height",
70+
"justify-content",
71+
"left",
72+
"letter-spacing",
73+
"line-height",
74+
"list-style",
75+
"list-style-image",
76+
"list-style-position",
77+
"list-style-type",
78+
"margin",
79+
"mask",
80+
"object-fit",
81+
"object-position",
82+
"opacity",
83+
"outline",
84+
"overflow",
85+
"padding",
86+
"pointer-events",
87+
"position",
88+
"resize",
89+
"right",
90+
"table-layout",
91+
"text-align",
92+
"text-decoration",
93+
"text-indent",
94+
"text-overflow",
95+
"text-shadow",
96+
"text-transform",
97+
"top",
98+
"transition",
99+
"transition-delay",
100+
"transition-duration",
101+
"transition-property",
102+
"transition-timing-function",
103+
"user-select",
104+
"vertical-align",
105+
"visibility",
106+
"white-space",
107+
"width",
108+
"will-change",
109+
"word-break",
110+
"word-spacing",
111+
"word-wrap",
112+
"z-index",
113+
];

lib/util.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { describe, it } from "node:test";
2+
import assert from "node:assert/strict";
3+
import { isValidProperty } from "./util.js";
4+
5+
describe("util module", () => {
6+
describe("isValidProperty function", () => {
7+
it("knows when properties are valid", () => {
8+
assert.equal(isValidProperty("color"), true);
9+
assert.equal(isValidProperty("animation-name"), true);
10+
});
11+
12+
it("knows when properties are invalid", () => {
13+
assert.equal(isValidProperty("horce"), false);
14+
assert.equal(isValidProperty("dIsPlaY"), false);
15+
});
16+
});
17+
});

0 commit comments

Comments
 (0)