From 3cf32048eddf3822f5ce724b11b1cae89881cb86 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 25 Jan 2016 07:07:43 +0300 Subject: [PATCH] Apply styles to application/xml autogenerated pages --- apply.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apply.js b/apply.js index cb0b48f1..c78356f6 100644 --- a/apply.js +++ b/apply.js @@ -134,6 +134,14 @@ function applyStyles(styleHash) { } if (Object.keys(g_styleElements).length) { + // when site response is application/xml Chrome displays our style elements + // under document.documentElement as plain text so we need to move them into HEAD + // (which already is autogenerated at this moment for the xml response) + if (document.head && document.head.firstChild && document.head.firstChild.id == "xml-viewer-style") { + for (var id in g_styleElements) { + document.head.appendChild(document.getElementById(id)); + } + } document.addEventListener("DOMContentLoaded", addDocumentStylesToAllIFrames); iframeObserver.start(); }