1
0
Эх сурвалжийг харах

add base tag to the doc to set the base URI

Gildas 7 жил өмнө
parent
commit
7f68e228cc

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

@@ -70,8 +70,11 @@ this.SingleFile = (() => {
 	// DOM
 	// ---
 	class DOM {
-		static create(pageContent/*, url*/) {
+		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);
 			return {
 				DOMParser,
 				getComputedStyle,