"SVGSVGElement.viewBox.baseVal": when viewBox unset, it is null in FF but a 0-SVGRect in Chrome
#8907 aperta il 14 set 2021
Metriche repository
- Star
- (8900 star)
- Metriche merge PR
- (Merge medio 7g 3h) (147 PR mergiate in 30 g)
Descrizione
MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimatedRect/baseVal
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?
- There is the
viewBoxproperty which is anSVGAnimatedRect {baseVal: SVGRect|null, animVal: SVGRect|null} - changes to the
baseValproperty are reflected in theviewBoxattribute and vice-versa - If the attribute is not set (null),
- the property is
nullin Firefox - 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
- Folder:
en-us/web/api/svgsvgelement - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/SVGSVGElement
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/svgsvgelement/index.html
- Last commit: https://github.com/mdn/content/commit/db1552682a9731c704eb18103dbf909551fa6edb
- Document last modified: 2021-06-16T11:27:11.000Z