New issue
Advanced search Search tips

Issue 782241 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

SVG elements disappear if placed inside <view> tag

Reported by nikuli...@gmail.com, Nov 7 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Example URL:
https://jsfiddle.net/qwy7dzj1/

Steps to reproduce the problem:
Test case:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="450" height="450">
	<g id="test-body-content">
		<g transform="translate(-155,110)">
			<rect x="300" y="55" width="125" height="85" fill="#aaa"/>
			<a xlink:href="#rect-view">
				<text x="320" y="70" fill="red">Go to Rectangle</text>
			</a>
			<a xlink:href="#ellipse-view">
				<text x="320" y="90" fill="blue">Go to Ellipse</text>
			</a>
			<text x="315" y="150" font-size="12">Click element's line</text>
			<text x="315" y="162" font-size="12">to link to its view</text>
		</g>
		<!-- View with no attributes.  Picture should not change. -->
    <view id="rect-view">
      <rect id="rect-object" fill="red" x="280" y="45" width="135" height="85"/>
    </view>
    </g>

		<text id="rect-label" x="325" y="145">Rectangle</text>
		<rect x="277" y="37" width="141" height="113" fill="none" stroke="black"/>
		<text x="287" y="160" font-size="10">No view attributes except id.</text>
		<!-- Test viewBox.  Should blow-up the ellipse in the frame. -->
		<view id="ellipse-view" viewBox="279 276 152 104"/>
		<ellipse id="ellipse-object" fill="blue" cx="355" cy="320" rx="72" ry="40"/>
		<text id="ellipse-label" x="340" y="375">Ellipse</text>
		<rect x="280" y="277" width="150" height="102" fill="none" stroke="black"/>
		<text x="300" y="275" font-size="10">viewBox, should fill frame.</text>

	</g>

</svg>

What is the expected behavior?
Elements are being shown

What went wrong?
No elements inside the <view> tag are being rendered

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 61.0.3163.100  Channel: stable
OS Version: 10.0
Flash Version: 

I have suspicion that this can be a regression from v56 and onwards, when the viewTarget property support was dropped
 

Comment 1 by e...@chromium.org, Nov 7 2017

Components: -Blink Blink>SVG
Labels: Needs-Feedback
NextAction: 2017-11-20
Chrome's behavior in Version 62.0.3202.62 (Official Build) beta (64-bit) linux matches FireFox. What do you expect to happen? Can you show a screenshot of another browser?

Comment 3 by f...@opera.com, Nov 7 2017

<view> is used to define overriding 'view':

"If the SVG fragment identifier addresses a ‘view’ element within an SVG document (e.g., MyDrawing.svg#MyView) then the root ‘svg’ element is displayed in the SVG viewport. Any view specification attributes included on the given ‘view’ element override the corresponding view specification attributes on the root ‘svg’ element."

(https://svgwg.org/svg2-draft/linking.html#LinksIntoSVG)

So you can use it to override 'viewBox' and 'preserveAspectRatio' (and 'zoomAndPan') on the root.

Anything nested within it will not participate in the rendering tree.
>Chrome's behavior in Version 62.0.3202.62 (Official Build) beta (64-bit) linux matches FireFox. What do you expect to happen? Can you show a screenshot of another browser?

If I remember correctly it worked once in Chrome back in v40~50. It does not seem to be working in any browser now.

https://css-tricks.com/svg-fragment-identifiers-work/ cites:

>The <view> elements can be stand-alone like this, or they can actually wrap other elements, in which case that viewBox takes hold when the ID matches, so

====

>Anything nested within it will not participate in the rendering tree.

Is this what the spec says?

I haven't found anything like that in the view spec.

Since there is no chance to get other browsermakers to be consistent on this matter now, it is likely not worth trying

Why this was important:

When you define a view with ID, you loose the ability to select the target element since viewTarget attribute is now obsoleted. This makes it impossible to mask other elements with css like this:

* {display:none}
:target {display:inline}
Project Member

Comment 5 by sheriffbot@chromium.org, Nov 8 2017

Cc: schenney@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "schenney@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by f...@opera.com, Nov 8 2017

Status: WontFix (was: Unconfirmed)
I don't think this has ever worked in any browser (modulo bugs, but I'm not aware of Blink having any such bug at least.)

>The <view> elements can be stand-alone like this, or they can actually wrap other elements, in which case that viewBox takes hold when the ID matches, so

This is, as mentioned earlier, not correct. (The example it references - the same that you appear to have based the test here upon - does not do anything like that.)

The "content model" definition for <view> at https://svgwg.org/svg2-draft/linking.html#ViewElement says that <rect> is not a "valid child". It could be seen as an example of a "never-rendered" element [1], but is not actually called out as such (it probably should be.) It's not even defined to be a container element ("never-rendered" or not.)

The way the processing model for a fragment referencing a <view> is defined, a <view> without any relevant properties ('viewBox' et.c) on it wouldn't have any effect anyway, even if it was defined a transparent container

'viewTarget' wasn't particularly well-defined AFAICR, but since it allowed for multiple elements to be "targeted" it would likely not have worked for the effect you are describing either.

I don't exactly what you want to use the :target selector for, but it should still be set - only it will point to the <view>. So some forms of selectors still ought to work, like for example:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <style>
    g.sprite { display: none; }
    :target + g.sprite { display: inline; }
  </style>
  <view id="a"/>
  <g class="sprite">
    <rect width="100" height="100" fill="blue"/>
  </g>
  <view id="b"/>
  <g class="sprite">
    <circle cx="50" cy="50" r="50" fill="red"/>
  </g>
</svg>

[1] https://svgwg.org/svg2-draft/render.html#RenderingTree
>So some forms of selectors still ought to work, like for example:

View allows you to select viewport coordinates, but doesn't let you select the element to target.

If you target an element, you can use CSS to mask other elements, but you can't set the viewport coordinates.

This way, it is impossible to simultaneously hide other elements with CSS and set viewport coordinates at the same time.

It might be a good idea to forward up thoughts on making this possible to SVGWG.

Comment 8 by f...@opera.com, Nov 9 2017

I believe I just showed one way - albeit somewhat limited (but no specific use case has been mentioned) - in which you can do both. So: "impossible", no; "limited", yes.

Feel free to raise an issue at https://github.com/w3c/svgwg (preferably with an actual use case.)
The NextAction date has arrived: 2017-11-20
NextAction: ----

Sign in to add a comment