New issue
Advanced search Search tips

Issue 682228 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jan 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

scripts inside svg switch-element children unexpectedly run

Reported by h.w...@klimapartner.de, Jan 18 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36

Steps to reproduce the problem:
1. create an svg with a switch element
2. add two child elements containing script elements
3. add a requiredFeatures attribute to the first child element with a feature string that evaluates to true in chrome.

What is the expected behavior?
only the first child element should be evaluated and rendered. the second script element should be bypassed and should not run.

What went wrong?
both script elements are evaluated and run.

Did this work before? No 

Does this work in other browsers? No

Chrome version: 52.0.2743.116  Channel: n/a
OS Version: 
Flash Version: Shockwave Flash 24.0 r0

From the SVG spec:

https://www.w3.org/TR/SVG/struct.html#SwitchElement

The ‘switch’ element evaluates the ‘requiredFeatures’, ‘requiredExtensions’ and ‘systemLanguage’ attributes on its direct child elements in order, and then processes and renders the first child for which these attributes evaluate to true. All others will be bypassed and therefore not rendered. If the child element is a container element such as a ‘g’, then the entire subtree is either processed/rendered or bypassed/not rendered.
 
switch.svg
363 bytes Download

Comment 1 Deleted

As you can see in the example (switch.svg) the renderable content is correctly bypassed, only the script elements are both processed and run...
Status: Available (was: Unconfirmed)
Nice catch. Firefox and Edge both do the same thing as us.
Labels: -OS-Linux OS-All

Comment 5 by f...@opera.com, Jan 18 2017

Status: WontFix (was: Available)
This has been "clarified" in SVG2:

 "conditional processing will have no effect on never-rendered elements; in particular, conditional processing does not affect the processing of a ‘style’ or ‘script’ element."

https://svgwg.org/svg2-draft/struct.html#ConditionalProcessing

FWIW, I don't think the intention in 1.1 was for <script>s to be "switchable" since they are not "rendered" / part of the rendering tree.
Seeing that there's interoperable behavior here and that behavior is specced, I will have to call this WontFix. Sorry.
Thanks for the clarification. It's ok with me anyways... there was just a real world problem on stack overflow that could have been solved by this...

http://stackoverflow.com/questions/41592123/svg-including-js-file-for-ie-only

thanks again

Sign in to add a comment