From d2cd4acab13928347181b9e5d7c19103283b5165 Mon Sep 17 00:00:00 2001 From: Aaron Barnes Date: Wed, 23 Oct 2013 00:12:18 +1300 Subject: [PATCH] MDL-42476 report_progress: don't browser sniff for SVG support Use feature detection, its more robust and better practice. --- report/completion/textrotate.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/report/completion/textrotate.js b/report/completion/textrotate.js index 241fb853584..e647d102ddd 100644 --- a/report/completion/textrotate.js +++ b/report/completion/textrotate.js @@ -26,10 +26,6 @@ function textrotate_make_svg(el) text.setAttribute('text-anchor','end'); text.setAttribute('transform','rotate(90)'); - if (el.className.indexOf('completion-rplheader') != -1) { - text.setAttribute('fill','#238E23'); - } - text.appendChild(document.createTextNode(string)); // Is there an icon near the text? @@ -52,7 +48,16 @@ function textrotate_make_svg(el) el.parentNode.removeChild(el); } +function browser_supports_svg() { + return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"); +} + function textrotate_init() { + if (!browser_supports_svg()) { + // Feature detect, else bail. + return; + } + YUI().use('yui2-dom', function(Y) { var elements= Y.YUI2.util.Dom.getElementsByClassName('completion-criterianame', 'span'); for(var i=0;i