Explorar el Código

inject the proxy only in HTML documents

Gildas hace 7 años
padre
commit
d94578cb01
Se han modificado 1 ficheros con 8 adiciones y 6 borrados
  1. 8 6
      lib/single-file/font-face-proxy.js

+ 8 - 6
lib/single-file/font-face-proxy.js

@@ -1,13 +1,15 @@
 
-/* global window, addEventListener, dispatchEvent, CustomEvent, document */
+/* global window, addEventListener, dispatchEvent, CustomEvent, document, HTMLDocument */
 
 this.fontFaceProxy = this.fontFaceProxy || (() => {
 
-	const scriptElement = document.createElement("script");
-	scriptElement.textContent = `(${hook.toString()})()`;
-	document.documentElement.appendChild(scriptElement);
-	const fontFaces = [];
-	addEventListener("single-file-font-face", event => fontFaces.push(event.detail));
+	if (document instanceof HTMLDocument) {
+		const scriptElement = document.createElement("script");
+		scriptElement.textContent = `(${hook.toString()})()`;
+		document.documentElement.appendChild(scriptElement);
+		const fontFaces = [];
+		addEventListener("single-file-font-face", event => fontFaces.push(event.detail));
+	}
 
 	return {
 		getFontsData: () => fontFaces