···11+MIT License
22+33+Copyright (c) 2026 Declan Chidlow
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
+12-12
fixcss.js
···181181 return before + fixed + brace;
182182 });
183183184184- // Phase 5: Fix property names and values inside declaration blocks
184184+ // Fix property names and values inside declaration blocks
185185 result = result.replace(/\{([^}]*)\}/g, function (match, declarations) {
186186 var fixed = declarations;
187187188188- // 5a: Fix property names
188188+ // Fix property names
189189 for (var prop in PROPERTY_FIXES) {
190190 var escapedProp = prop.replace(/([.*+?^${}()|[\]\\])/g, "\\$1");
191191 var propRegex = new RegExp("(^|[;\\s\\n])(" + escapedProp + ")\\s*:", "g");
···194194 });
195195 }
196196197197- // 5b: Fix display values (#37 — marked-block -> list-item, now that display-type -> display)
197197+ // Fix display values (#37 — marked-block -> list-item, now that display-type -> display)
198198 fixed = fixed.replace(/display\s*:\s*([^;!}]+)/g, function (m, val) {
199199 var trimmed = val.trim();
200200 if (DISPLAY_VALUES[trimmed]) {
···203203 return m;
204204 });
205205206206- // 5c: Fix property-specific and global values (data-driven from VALUE_FIXES)
206206+ // Fix property-specific and global values (data-driven from VALUE_FIXES)
207207 fixed = fixPropertyValues(fixed);
208208209209- // 5d: Fix 4-arg rgb/hsl -> rgba/hsla (#22)
209209+ // Fix 4-arg rgb/hsl -> rgba/hsla (#22)
210210 fixed = fixed.replace(/\brgb\s*\(\s*([^,)]+)\s*,\s*([^,)]+)\s*,\s*([^,)]+)\s*,\s*([^,)]+)\s*\)/g, "rgba($1, $2, $3, $4)");
211211 fixed = fixed.replace(/\bhsl\s*\(\s*([^,)]+)\s*,\s*([^,)]+)\s*,\s*([^,)]+)\s*,\s*([^,)]+)\s*\)/g, "hsla($1, $2, $3, $4)");
212212213213- // 5e: Fix span(N) -> span N in grid properties (#43)
213213+ // Fix span(N) -> span N in grid properties (#43)
214214 fixed = fixed.replace(/\bspan\s*\(\s*(\d+)\s*\)/g, "span $1");
215215216216- // 5f: Fix fr units in flex shorthand (#35)
216216+ // Fix fr units in flex shorthand (#35)
217217 fixed = fixed.replace(/flex\s*:\s*([^;!}]+)/g, function (m, flexVals) {
218218 return "flex: " + flexVals.replace(/(\d+(?:\.\d+)?)fr/g, "$1");
219219 });
220220221221- // 5g: Fix shorthand defaults (#8)
221221+ // Fix shorthand defaults (#8)
222222 if (opts.fixShorthandDefaults) {
223223 fixed = fixShorthandValues(fixed);
224224 }
225225226226- // 5h: Fix axis order for 2-value properties (#9)
226226+ // Fix axis order for 2-value properties (#9)
227227 if (opts.fixAxisOrder) {
228228 fixed = fixAxisOrder(fixed);
229229 }
230230231231- // 5i: Fix CCW -> CW for 4-value shorthands (#11, opt-in)
231231+ // Fix CCW -> CW for 4-value shorthands (#11, opt-in)
232232 fixed = fixShorthandDirection(fixed, opts);
233233234234 return "{" + fixed + "}";
235235 });
236236237237- // Phase 6: Restore comments
237237+ // Restore comments
238238 result = result.replace(/CMT(\d+)/g, function (match, index) {
239239 return comments[parseInt(index, 10)];
240240 });
241241242242- // Phase 7: Restore strings
242242+ // Restore strings
243243 result = result.replace(/STR(\d+)/g, function (match, index) {
244244 return strings[parseInt(index, 10)];
245245 });
+1-1
test/test.js
···6060test("#36 display-type -> display", function () {
6161 var result = fixCSS(".x { display-type: flex; }");
6262 assertContains(result, "display:");
6363- // Should not have "display-type"
6363+ // Should not have 'display-type'
6464 assertEqual(result.indexOf("display-type"), -1, "display-type should be removed");
6565});
6666