Kaynağa Gözat

don't insert the base tag is one is already present

Gildas 7 yıl önce
ebeveyn
işleme
a3b811ce83
1 değiştirilmiş dosya ile 6 ekleme ve 3 silme
  1. 6 3
      lib/single-file/single-file-browser.js

+ 6 - 3
lib/single-file/single-file-browser.js

@@ -72,9 +72,12 @@ this.SingleFile = (() => {
 	class DOM {
 		static create(pageContent, baseURI) {
 			const doc = (new DOMParser()).parseFromString(pageContent, "text/html");
-			const baseElement = doc.createElement("base");
-			baseElement.href = baseURI;
-			doc.head.insertBefore(baseElement, doc.head.firstChild);
+			let baseElement = doc.querySelector("base");
+			if (!baseElement) {
+				baseElement = doc.createElement("base");
+				baseElement.href = baseURI;
+				doc.head.insertBefore(baseElement, doc.head.firstChild);
+			}
 			return {
 				DOMParser,
 				getComputedStyle,