@jsenv/dom 0.7.3 → 0.7.4

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +18 -0
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -518,6 +518,11 @@ const isKeyword = (value) => {
518
518
  return cssKeywordSet.has(value);
519
519
  };
520
520
 
521
+ // url(
522
+ // linear-gradient(
523
+ // radial-gradient(
524
+ // ...
525
+ const STARTS_WITH_CSS_IMAGE_FUNCTION_REGEX = /^[a-z-]+\(/;
521
526
  // Normalize a single style value
522
527
  const normalizeStyle = (value, propertyName, context = "js") => {
523
528
  if (propertyName === "transform") {
@@ -571,6 +576,19 @@ const normalizeStyle = (value, propertyName, context = "js") => {
571
576
  return undefined;
572
577
  }
573
578
 
579
+ if (propertyName === "backgroundImage") {
580
+ if (context === "css") {
581
+ if (
582
+ typeof value === "string" &&
583
+ !isKeyword(value) &&
584
+ !STARTS_WITH_CSS_IMAGE_FUNCTION_REGEX.test(value)
585
+ ) {
586
+ return `url(${value})`;
587
+ }
588
+ }
589
+ return value;
590
+ }
591
+
574
592
  if (pxProperties.includes(propertyName)) {
575
593
  return normalizeNumber(value, {
576
594
  propertyName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "DOM utilities for writing frontend code",
5
5
  "repository": {
6
6
  "type": "git",