@ohhwells/bridge 0.1.36-next.52 → 0.1.36-next.54

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.
package/dist/index.cjs CHANGED
@@ -6544,6 +6544,11 @@ function fadeInImageElement(img, onReady) {
6544
6544
  img.style.opacity = "";
6545
6545
  });
6546
6546
  }
6547
+ function applyEditableImageSrc(img, url) {
6548
+ img.removeAttribute("srcset");
6549
+ img.removeAttribute("sizes");
6550
+ img.src = url;
6551
+ }
6547
6552
  function fadeInBgImage(el, url, onReady) {
6548
6553
  const prevPos = el.style.position;
6549
6554
  if (!prevPos || prevPos === "static") el.style.position = "relative";
@@ -7850,7 +7855,7 @@ function OhhwellsBridge() {
7850
7855
  if (el.dataset.ohwEditable === "image") {
7851
7856
  const img = el instanceof HTMLImageElement ? el : el.querySelector("img");
7852
7857
  if (img && img.src !== val) {
7853
- img.src = val;
7858
+ applyEditableImageSrc(img, val);
7854
7859
  imageLoads.push(new Promise((resolve) => {
7855
7860
  img.onload = () => resolve();
7856
7861
  img.onerror = () => resolve();
@@ -7921,7 +7926,7 @@ function OhhwellsBridge() {
7921
7926
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
7922
7927
  if (el.dataset.ohwEditable === "image") {
7923
7928
  const img = el instanceof HTMLImageElement ? el : el.querySelector("img");
7924
- if (img && img.src !== val) img.src = val;
7929
+ if (img && img.src !== val) applyEditableImageSrc(img, val);
7925
7930
  } else if (el.dataset.ohwEditable === "bg-image") {
7926
7931
  const next = `url('${val}')`;
7927
7932
  if (el.style.backgroundImage !== next) el.style.backgroundImage = next;
@@ -8768,7 +8773,7 @@ function OhhwellsBridge() {
8768
8773
  };
8769
8774
  img.onload = onReady;
8770
8775
  img.onerror = onReady;
8771
- img.src = url;
8776
+ applyEditableImageSrc(img, url);
8772
8777
  if (img.complete && img.naturalWidth > 0) {
8773
8778
  requestAnimationFrame(() => onReady());
8774
8779
  }
@@ -8856,7 +8861,7 @@ function OhhwellsBridge() {
8856
8861
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
8857
8862
  if (el.dataset.ohwEditable === "image") {
8858
8863
  const img = el instanceof HTMLImageElement ? el : el.querySelector("img");
8859
- if (img) img.src = val;
8864
+ if (img) applyEditableImageSrc(img, val);
8860
8865
  } else if (el.dataset.ohwEditable === "bg-image") {
8861
8866
  el.style.backgroundImage = `url('${val}')`;
8862
8867
  } else if (el.dataset.ohwEditable === "video") {