2

On Safari 11.0, if I copy and paste the following code into the js console, I get the result shown in the image A, where the filter hasn't been applied to all elements.

However if I do the same thing on Chrome, I get the result shown in image B, the filter has been applied to all elements as expected.

Im simply adding an SVG filter that I want to apply to the whole HTML doc.

Any suggestions on why this is working on Chrome and not Safari?

var matrixValue = '0.299 0.587 0.114 0 0  0.299 0.587 0.114 0 0      0.299 0.587 0.114 0 0      0 0 0 1 0'; 

var div = document.createElement('div');  
div.innerHTML = "<svg xmlns='http://www.w3.org/2000/svg' version='1.1'><defs><filter id='ulSvgFilterDoc2'><feColorMatrix type='matrix' values='" + matrixValue + "'></feColorMatrix></filter></defs></svg>"; 

div.setAttribute('class', 'ulSvgFilterDoc'); 
div.setAttribute('id', 'ulSvgFilterDoc'); 
div.setAttribute('style', 'display: none;'); 
document.getElementsByTagName('body')[0].append(div); 
document.getElementsByTagName('html')[0].setAttribute('style', 'filter: url("#ulSvgFilterDoc2")'); 

Image A: Safari SVG Color Filter - Safari

Image B: Chrome SVG Color Filter = Chrome

5
  • Interesting... I first thought it was because of <g-XXX> custom elements, but when trying to reproduce, it works...
    – Kaiido
    Commented Oct 5, 2017 at 3:28
  • Is all the content coming from the same domain as the filter? There are cross-site restrictions in filters. Commented Oct 6, 2017 at 19:31
  • @MichaelMullany wouldn't these restrictions concern only the filter itself? Like you can't load cross-site filters, but you can apply it on any content. (And actually, since I am able to repro, I can tell for sure that targeting directly g-XXX elements with the same rule does work.)
    – Kaiido
    Commented Oct 8, 2017 at 8:23
  • I was a little rusty on this - you're right - you're not using any of the taintable primitives or inputs Commented Oct 8, 2017 at 19:59
  • Thanks, looks like this is a WebKit bug. Commented Oct 9, 2017 at 21:10

0

Browse other questions tagged or ask your own question.