Просмотр исходного кода

fixed "background-clip" value setting when using border-box

Gildas 7 лет назад
Родитель
Сommit
367e948c40
2 измененных файлов с 5 добавлено и 1 удалено
  1. 4 1
      lib/single-file/single-file-core.js
  2. 1 0
      lib/single-file/util/doc-helper.js

+ 4 - 1
lib/single-file/single-file-core.js

@@ -1107,7 +1107,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 		static setBackgroundImage(element, url, style) {
 			element.style.setProperty("background-blend-mode", "normal", "important");
-			element.style.setProperty("background-clip", "content-box", "important");
+			element.style.setProperty("background-clip", style && style["background-clip"] ? style["background-clip"] : "content-box", "important");
 			element.style.setProperty("background-position", style && style["background-position"] ? style["background-position"] : "center", "important");
 			element.style.setProperty("background-color", style && style["background-color"] ? style["background-color"] : "transparent", "important");
 			element.style.setProperty("background-image", url, "important");
@@ -1654,6 +1654,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 					if (imgData.backgroundColor) {
 						backgroundStyle["background-color"] = imgData.backgroundColor;
 					}
+					if (imgData.boxSizing) {
+						backgroundStyle["background-clip"] = imgData.boxSizing;
+					}
 					ProcessorHelper.setBackgroundImage(imgElement, "var(" + variableName + ")", backgroundStyle);
 					imgElement.removeAttribute(dataAttributeName);
 					return true;

+ 1 - 0
lib/single-file/util/doc-helper.js

@@ -293,6 +293,7 @@ this.docHelper = this.docHelper || (() => {
 						imageData.replaceable = true;
 						imageData.backgroundColor = computedStyle.getPropertyValue("background-color");
 						imageData.objectFit = computedStyle.getPropertyValue("object-fit");
+						imageData.boxSizing = computedStyle.getPropertyValue("box-sizing");
 						imageData.objectPosition = computedStyle.getPropertyValue("object-position");
 					}
 				}