Przeglądaj źródła

set src attribute when image cannot be replaced

Gildas 7 lat temu
rodzic
commit
5a3aca00cc
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3 1
      lib/single-file/single-file-core.js

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

@@ -1127,13 +1127,15 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 						if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
 							const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
 							if (removeElementIfMissing && content == EMPTY_DATA_URI) {
-								resourceElement.remove();
+								resourceElement.setAttribute(attributeName, content);
 							} else {
 								if (content.startsWith(prefixDataURI) || content.startsWith(PREFIX_DATA_URI_NO_MIMETYPE) || content.match(PREFIX_DATA_URI_OCTET_STREAM)) {
 									const isSVG = content.startsWith(PREFIX_DATA_URI_IMAGE_SVG);
 									if (processDuplicates && duplicate && options.groupDuplicateImages && !isSVG) {
 										if (DomUtil.replaceImageSource(resourceElement, SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource, options)) {
 											DomUtil.insertVariable(doc, indexResource, content, options);
+										} else {
+											resourceElement.setAttribute(attributeName, content);
 										}
 									} else {
 										resourceElement.setAttribute(attributeName, content);