Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a6029b0
Move some functions
asamuzaK Jul 27, 2025
5874693
Fix CSSStyleDeclaration.js and parsers.js
asamuzaK Jul 27, 2025
5bc7654
Remove isValid() from background
asamuzaK Jul 27, 2025
83238ce
Fix typo
asamuzaK Jul 27, 2025
b5a28cb
Fix _implicitSetter
asamuzaK Jul 27, 2025
cd9374f
Fix _subImplicitSetter
asamuzaK Jul 27, 2025
4f3f22e
Remove isValid()
asamuzaK Jul 30, 2025
3733d9a
Remove isValidColor()
asamuzaK Jul 30, 2025
1c08f53
Update properties
asamuzaK Jul 31, 2025
238f2b2
Export hasCalcFunc and add parseCalc
asamuzaK Aug 1, 2025
bc44907
Update backgrounds
asamuzaK Aug 1, 2025
c12fadc
Update borders
asamuzaK Aug 1, 2025
0416d4f
Update flex
asamuzaK Aug 1, 2025
0a4f0fb
Update numeric value parsers
asamuzaK Aug 1, 2025
c696fa8
Update fonts
asamuzaK Aug 1, 2025
73e0588
Update colors
asamuzaK Aug 2, 2025
9c87c5a
Update positions and boxes
asamuzaK Aug 2, 2025
a117362
Update floats and display
asamuzaK Aug 2, 2025
ae15a82
Fix colors and opacity
asamuzaK Aug 2, 2025
7b1acaf
Rename variable
asamuzaK Aug 2, 2025
79ae451
Update margins and paddings
asamuzaK Aug 2, 2025
bd512f6
Update parsers.js
asamuzaK Aug 2, 2025
1a3fabe
Add @webref/css
asamuzaK Aug 2, 2025
21bc17d
Update allProperties.js
asamuzaK Aug 2, 2025
96d527a
Update dev dependencies
asamuzaK Aug 2, 2025
66fa6c5
Update parseFunction
asamuzaK Aug 3, 2025
79f8800
Update parsers.js
asamuzaK Aug 3, 2025
c096b7d
Update backgroundColor.js
asamuzaK Aug 3, 2025
7829706
Add generic function to parse property value
asamuzaK Aug 3, 2025
fe2d356
Add edge case test
asamuzaK Aug 3, 2025
1762619
Update CSSStyleDeclaration.js
asamuzaK Aug 4, 2025
3cd3722
Update parsePropertyValue()
asamuzaK Aug 4, 2025
fe5bee5
Update parser functions
asamuzaK Aug 9, 2025
cd86606
Update fonts
asamuzaK Aug 10, 2025
a766882
Fix calc and shorthand handlers
asamuzaK Aug 10, 2025
29d3a59
Fix borders
asamuzaK Aug 11, 2025
b3e1bfe
Fix borders part2
asamuzaK Aug 18, 2025
a798d3b
Update parsers
asamuzaK Aug 20, 2025
80c1298
Update normalizeBorderProperties function
asamuzaK Aug 21, 2025
2510f3c
Update file path
asamuzaK Aug 22, 2025
d399c7a
Update normalize.js
asamuzaK Aug 24, 2025
01fee47
Fix normalize.js
asamuzaK Aug 29, 2025
27d5f13
Update parsers.js
asamuzaK Aug 29, 2025
304e555
Update border handling
asamuzaK Aug 30, 2025
0630908
Fix flexbox handling and some clean ups
asamuzaK Aug 30, 2025
5d1a2b0
Expose list of supported properties
asamuzaK Aug 30, 2025
46d83e4
Clean up
asamuzaK Aug 30, 2025
0c3f843
Export propertyList
asamuzaK Aug 31, 2025
b73f4db
Switch entry point and update dependencies
asamuzaK Sep 5, 2025
cdfdfd8
Change arguments
asamuzaK Sep 6, 2025
7ea4f04
Add CSSStyleProperties
asamuzaK Sep 6, 2025
82ae6fd
Remove cssFloat
asamuzaK Sep 6, 2025
1015f63
Remove properties from CSSStyleDeclaration
asamuzaK Sep 6, 2025
bf634ef
Export as single object and fix nits
asamuzaK Sep 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
640 changes: 315 additions & 325 deletions lib/CSSStyleDeclaration.js

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions lib/CSSStyleProperties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use strict";

const { CSSStyleDeclaration } = require("./CSSStyleDeclaration");
const allProperties = require("./generated/allProperties");
const implementedProperties = require("./generated/implementedProperties");
const generatedProperties = require("./generated/properties");
const allExtraProperties = require("./utils/allExtraProperties");
const { dashedToCamelCase } = require("./utils/camelize");
const { getPropertyDescriptor } = require("./utils/propertyDescriptors");

/**
* @see https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
*/
class CSSStyleProperties extends CSSStyleDeclaration {
get cssFloat() {
return this.getPropertyValue("float");
}

set cssFloat(value) {
this.setProperty("float", value);
}
}

// Properties
Object.defineProperties(CSSStyleProperties.prototype, generatedProperties);

// Additional properties
const unifiedProperties =
typeof allProperties.union === "function"
? allProperties.union(allExtraProperties)
: new Set([...allProperties, ...allExtraProperties]);

unifiedProperties.forEach((property) => {
if (!implementedProperties.has(property)) {
const declaration = getPropertyDescriptor(property);
Object.defineProperty(CSSStyleProperties.prototype, property, declaration);
const camel = dashedToCamelCase(property);
if (camel !== property) {
Object.defineProperty(CSSStyleProperties.prototype, camel, declaration);
if (/^webkit[A-Z]/.test(camel)) {
const pascal = camel.replace(/^webkit/, "Webkit");
Object.defineProperty(CSSStyleProperties.prototype, pascal, declaration);
}
}
}
});

module.exports = {
CSSStyleProperties
};
49 changes: 0 additions & 49 deletions lib/allExtraProperties.js

This file was deleted.

40 changes: 39 additions & 1 deletion lib/generated/allProperties.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
// autogenerated - 2025-05-14
// autogenerated - 2025-08-02
// https://www.w3.org/Style/CSS/all-properties.en.html

module.exports = new Set([
Expand Down Expand Up @@ -57,21 +57,29 @@ module.exports = new Set([
"border-block-color",
"border-block-end",
"border-block-end-color",
"border-block-end-radius",
"border-block-end-style",
"border-block-end-width",
"border-block-start",
"border-block-start-color",
"border-block-start-radius",
"border-block-start-style",
"border-block-start-width",
"border-block-style",
"border-block-width",
"border-bottom",
"border-bottom-color",
"border-bottom-left-radius",
"border-bottom-radius",
"border-bottom-right-radius",
"border-bottom-style",
"border-bottom-width",
"border-boundary",
"border-clip",
"border-clip-bottom",
"border-clip-left",
"border-clip-right",
"border-clip-top",
"border-collapse",
"border-color",
"border-end-end-radius",
Expand All @@ -86,37 +94,49 @@ module.exports = new Set([
"border-inline-color",
"border-inline-end",
"border-inline-end-color",
"border-inline-end-radius",
"border-inline-end-style",
"border-inline-end-width",
"border-inline-start",
"border-inline-start-color",
"border-inline-start-radius",
"border-inline-start-style",
"border-inline-start-width",
"border-inline-style",
"border-inline-width",
"border-left",
"border-left-color",
"border-left-radius",
"border-left-style",
"border-left-width",
"border-limit",
"border-radius",
"border-right",
"border-right-color",
"border-right-radius",
"border-right-style",
"border-right-width",
"border-shape",
"border-spacing",
"border-start-end-radius",
"border-start-start-radius",
"border-style",
"border-top",
"border-top-color",
"border-top-left-radius",
"border-top-radius",
"border-top-right-radius",
"border-top-style",
"border-top-width",
"border-width",
"bottom",
"box-decoration-break",
"box-shadow",
"box-shadow-blur",
"box-shadow-color",
"box-shadow-offset",
"box-shadow-position",
"box-shadow-spread",
"box-sizing",
"box-snap",
"break-after",
Expand Down Expand Up @@ -158,6 +178,23 @@ module.exports = new Set([
"content",
"content-visibility",
"continue",
"corner-block-end-shape",
"corner-block-start-shape",
"corner-bottom-left-shape",
"corner-bottom-right-shape",
"corner-bottom-shape",
"corner-end-end-shape",
"corner-end-start-shape",
"corner-inline-end-shape",
"corner-inline-start-shape",
"corner-left-shape",
"corner-right-shape",
"corner-shape",
"corner-start-end-shape",
"corner-start-start-shape",
"corner-top-left-shape",
"corner-top-right-shape",
"corner-top-shape",
"counter-increment",
"counter-reset",
"counter-set",
Expand Down Expand Up @@ -382,6 +419,7 @@ module.exports = new Set([
"overflow-wrap",
"overflow-x",
"overflow-y",
"overlay",
"overscroll-behavior",
"overscroll-behavior-block",
"overscroll-behavior-inline",
Expand Down
11 changes: 11 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";

const { CSSStyleDeclaration } = require("./CSSStyleDeclaration");
const { CSSStyleProperties } = require("./CSSStyleProperties");
const implementedProperties = require("./generated/implementedProperties");

module.exports = {
CSSStyleDeclaration,
CSSStyleProperties,
propertyList: Object.fromEntries(implementedProperties)
};
Loading