From 6489de08611fee640f81b1b3e2ee290abc14caa1 Mon Sep 17 00:00:00 2001 From: Jason Barnabe Date: Tue, 19 Nov 2013 13:37:09 -0600 Subject: [PATCH] issue 5 Stylish does not affect all SVG --- apply.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apply.js b/apply.js index 3924028d..6f788a09 100644 --- a/apply.js +++ b/apply.js @@ -33,7 +33,14 @@ function applyStyle(s) { } function applySections(style, sections) { - var styleElement = document.createElement("style"); + var styleElement; + if (document.documentElement instanceof SVGSVGElement) { + // SVG document, make an SVG style element. + styleElement = document.createElementNS("http://www.w3.org/2000/svg", "style"); + } else { + // This will make an HTML style element. If there's SVG embedded in an HTML document, this works on the SVG too. + styleElement = document.createElement("style"); + } styleElement.setAttribute("id", "stylish-" + style.id); styleElement.setAttribute("class", "stylish"); styleElement.setAttribute("type", "text/css");