Ver código fonte

empty attributes instead of removing them to avoid breaking styles

Gildas 7 anos atrás
pai
commit
0a637945ce
1 arquivos alterados com 5 adições e 5 exclusões
  1. 5 5
      lib/single-file/single-file-core.js

+ 5 - 5
lib/single-file/single-file-core.js

@@ -392,7 +392,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				this.onEventAttributeNames.forEach(attributeName => this.doc.querySelectorAll("[" + attributeName + "]").forEach(element => element.removeAttribute(attributeName)));
 				this.doc.querySelectorAll("[href]").forEach(element => {
 					if (element.href && element.href.match && element.href.match(/^\s*javascript:/)) {
-						element.removeAttribute("href");
+						element.setAttribute("href", "");
 					}
 				});
 				this.doc.querySelectorAll("[src]").forEach(element => {
@@ -521,16 +521,16 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				if (responsiveImageData) {
 					if (tagName == "img") {
 						if (responsiveImageData.source.src && responsiveImageData.source.naturalWidth > 1 && responsiveImageData.source.naturalHeight > 1) {
-							element.removeAttribute("srcset");
-							element.removeAttribute("sizes");
+							element.setAttribute("srcset", "");
+							element.setAttribute("sizes", "");
 							element.src = responsiveImageData.source.src;
 						}
 					}
 					if (tagName == "picture") {
 						const imageElement = element.querySelector("img");
 						if (responsiveImageData.source && responsiveImageData.source.src && responsiveImageData.source.naturalWidth > 1 && responsiveImageData.source.naturalHeight > 1) {
-							imageElement.removeAttribute("srcset");
-							imageElement.removeAttribute("sizes");
+							imageElement.setAttribute("srcset", "");
+							imageElement.setAttribute("sizes", "");
 							imageElement.src = responsiveImageData.source.src;
 							element.querySelectorAll("source").forEach(sourceElement => sourceElement.remove());
 						} else {