Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with "SVGSVGElement": In FF an unset viewBox property means viewBox.baseVal = null. For Chrome it is an SVGRect initialized to 0. #8907

Open
htho opened this issue Sep 14, 2021 · 0 comments
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help! needs BCD update

Comments

@htho
Copy link

htho commented Sep 14, 2021

MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/SVGSVGElement

What information was incorrect, unhelpful, or incomplete?

There are differences between the browsers implementation of the initial values of the viewBox (baseVal) property.

const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
const baseVal = svg.viewBox.baseVal;

In Firefox baseVal is null. In Chrome it is an SVGRect {x: 0, y: 0, width: 0, height: 0}.
In my opinion it is nice to just write the values on the pre-initialized SVGRect and to let the browser synchronize the attribute.

Since the bug on this topic (https://bugzilla.mozilla.org/show_bug.cgi?id=888307) is closed and no one seems to care, at least developers should be informed of this difference.

I am not sure if this should be a "note" in the compability table, or if it should be described in the property section.
I am aware that this property is inherited from SVGFitToViewBox, but there is no page for this Interface. Since this is my first contribution I don't feel ready to create a new Page.

Specific section or headline?

new Property section named "viewBox" OR a note in the compability table
(see above)

What did you expect to see?

  1. There is the viewBox property which is an SVGAnimatedRect {baseVal: SVGRect|null, animVal: SVGRect|null}
  2. changes to the baseVal property are reflected in the viewBox attribute and vice-versa
  3. If the attribute is not set (null),
  4. the property is null in Firefox
  5. the property is SVGRect {x: 0, y: 0, width: 0, height: 0} in Chrome

Did you test this? If so, how?

to test this the code from above can be executed in the browsers console

MDN Content page report details
@sideshowbarker sideshowbarker added the Content:SVG SVG docs label Sep 15, 2021
@Rumyra Rumyra added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 25, 2021
@sideshowbarker sideshowbarker added help wanted If you know something about this topic, we would love your help! and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jul 6, 2022
@Josh-Cena Josh-Cena added Content:WebAPI Web API docs and removed Content:SVG SVG docs labels Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help! needs BCD update
Projects
Status: No status
Development

No branches or pull requests

4 participants