Bläddra i källkod

fixed issue with <base> tags containing no href attribute

Gildas 7 år sedan
förälder
incheckning
7eab30ea77
1 ändrade filer med 4 tillägg och 1 borttagningar
  1. 4 1
      lib/single-file/single-file-browser.js

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

@@ -84,7 +84,10 @@ this.SingleFile = this.SingleFile || (() => {
 		static create(pageContent, baseURI) {
 			const doc = (new DOMParser()).parseFromString(pageContent, "text/html");
 			let baseElement = doc.querySelector("base");
-			if (!baseElement) {
+			if (!baseElement || !baseElement.getAttribute("href")) {
+				if (baseElement) {
+					baseElement.remove();
+				}
 				baseElement = doc.createElement("base");
 				baseElement.setAttribute("href", baseURI);
 				doc.head.insertBefore(baseElement, doc.head.firstChild);