@brightspace-ui/core 3.234.0 → 3.234.1

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.
@@ -217,6 +217,10 @@ function formatCSSVariable([key, value]) {
217
217
  else return `${key}: ${value};`;
218
218
  }
219
219
 
220
+ function isCustomPropertyDefined(rule, name) {
221
+ return rule.style.getPropertyValue(name).trim() !== '';
222
+ }
223
+
220
224
  function resolvePrimitive(variableName, variables) {
221
225
  const value = variables.get(variableName);
222
226
  if (!value) return;
@@ -248,9 +252,7 @@ if (globalThis.document !== undefined && !globalThis.document.head.querySelector
248
252
  /* primary accent */
249
253
  --d2l-color-primary-accent-action: var(--d2l-color-celestine);
250
254
  --d2l-color-primary-accent-indicator: var(--d2l-color-carnelian);
251
- }
252
255
 
253
- html {
254
256
  ${lightCSS}
255
257
  }
256
258
  html[data-color-mode="dark"] {
@@ -270,17 +272,22 @@ if (globalThis.document !== undefined && !globalThis.document.head.querySelector
270
272
  globalThis.document.head.appendChild(style);
271
273
  }
272
274
 
275
+ const lightRule = style.sheet.cssRules[0];
276
+ const darkRule = style.sheet.cssRules[1];
277
+ const osRule = style.sheet.cssRules[2].cssRules[0];
278
+
273
279
  export function registerSemanticVariableForSvgImageUrl(name, value) {
274
280
  if (!name || typeof value !== 'string') {
275
281
  throw new TypeError('registerSemanticVariableForSvgImageUrl requires both a name and value');
276
282
  }
283
+ if (isCustomPropertyDefined(lightRule, name)) {
284
+ console.warn(`registerSemanticVariableForSvgImageUrl called for ${name} but a custom property is already defined with this name`);
285
+ }
277
286
 
278
287
  const replacedLightValue = svgToCSS(replaceSemanticVariables(value, lightVariables));
279
- style.sheet.insertRule(`html { ${ name }: ${ replacedLightValue } }`, 0);
288
+ lightRule.style.setProperty(name, replacedLightValue);
280
289
 
281
290
  const replacedDarkValue = svgToCSS(replaceSemanticVariables(value, darkVariables));
282
- style.sheet.insertRule(`html[data-color-mode="dark"] { ${ name }: ${ replacedDarkValue } }`, 1);
283
- style.sheet.insertRule(`@media (prefers-color-scheme: dark) {
284
- html[data-color-mode="os"] { ${ name }: ${ replacedDarkValue } }
285
- }`, 2);
291
+ darkRule.style.setProperty(name, replacedDarkValue);
292
+ osRule.style.setProperty(name, replacedDarkValue);
286
293
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.234.0",
3
+ "version": "3.234.1",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",