cssstyle 4.5.0 → 5.0.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.
@@ -5,12 +5,14 @@
5
5
  "use strict";
6
6
  const CSSOM = require("rrweb-cssom");
7
7
  const allExtraProperties = require("./allExtraProperties");
8
+ const { shorthandProperties } = require("./shorthandProperties");
8
9
  const allProperties = require("./generated/allProperties");
9
10
  const implementedProperties = require("./generated/implementedProperties");
10
11
  const generatedProperties = require("./generated/properties");
11
12
  const { hasVarFunc, parseKeyword, parseShorthand, prepareValue, splitValue } = require("./parsers");
12
13
  const { dashedToCamelCase } = require("./utils/camelize");
13
14
  const { getPropertyDescriptor } = require("./utils/propertyDescriptors");
15
+ const { asciiLowercase } = require("./utils/strings");
14
16
 
15
17
  /**
16
18
  * @see https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface
@@ -120,18 +122,26 @@ class CSSStyleDeclaration {
120
122
  if (this._computed) {
121
123
  return "";
122
124
  }
123
- const properties = [];
125
+ const properties = new Map();
124
126
  for (let i = 0; i < this._length; i++) {
125
127
  const property = this[i];
126
128
  const value = this.getPropertyValue(property);
127
129
  const priority = this.getPropertyPriority(property);
128
130
  if (priority === "important") {
129
- properties.push(`${property}: ${value} !${priority};`);
131
+ properties.set(property, `${property}: ${value} !${priority};`);
130
132
  } else {
131
- properties.push(`${property}: ${value};`);
133
+ if (shorthandProperties.has(property)) {
134
+ const longhandProperties = shorthandProperties.get(property);
135
+ for (const [longhandProperty] of longhandProperties) {
136
+ if (properties.has(longhandProperty) && !this.getPropertyPriority(longhandProperty)) {
137
+ properties.delete(longhandProperty);
138
+ }
139
+ }
140
+ }
141
+ properties.set(property, `${property}: ${value};`);
132
142
  }
133
143
  }
134
- return properties.join(" ");
144
+ return [...properties.values()].join(" ");
135
145
  }
136
146
 
137
147
  set cssText(value) {
@@ -272,10 +282,10 @@ class CSSStyleDeclaration {
272
282
  }
273
283
  const isCustomProperty = property.startsWith("--");
274
284
  if (isCustomProperty) {
275
- this._setProperty(property, value);
285
+ this._setProperty(property, value, priority);
276
286
  return;
277
287
  }
278
- property = property.toLowerCase();
288
+ property = asciiLowercase(property);
279
289
  if (!allProperties.has(property) && !allExtraProperties.has(property)) {
280
290
  return;
281
291
  }
@@ -1,14 +1,26 @@
1
1
  "use strict";
2
- // autogenerated - 2025-06-20
2
+ // autogenerated - 2025-07-14
3
3
  // https://www.w3.org/Style/CSS/all-properties.en.html
4
4
 
5
5
  module.exports = new Set([
6
+ "-webkit-border-after-color",
7
+ "-webkit-border-before-color",
8
+ "-webkit-border-end-color",
9
+ "-webkit-border-start-color",
10
+ "-webkit-column-rule-color",
11
+ "-webkit-tap-highlight-color",
12
+ "-webkit-text-emphasis-color",
13
+ "-webkit-text-fill-color",
14
+ "-webkit-text-stroke-color",
6
15
  "background",
7
16
  "background-attachment",
17
+ "background-clip",
8
18
  "background-color",
9
19
  "background-image",
20
+ "background-origin",
10
21
  "background-position",
11
22
  "background-repeat",
23
+ "background-size",
12
24
  "border",
13
25
  "border-bottom",
14
26
  "border-bottom-color",
@@ -66,14 +78,5 @@ module.exports = new Set([
66
78
  "right",
67
79
  "stop-color",
68
80
  "top",
69
- "-webkit-border-after-color",
70
- "-webkit-border-before-color",
71
- "-webkit-border-end-color",
72
- "-webkit-border-start-color",
73
- "-webkit-column-rule-color",
74
- "-webkit-tap-highlight-color",
75
- "-webkit-text-emphasis-color",
76
- "-webkit-text-fill-color",
77
- "-webkit-text-stroke-color",
78
81
  "width"
79
82
  ]);