mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 22:03:37 +02:00
Use getBoundingClientRect for dimensions instead of offsetHeight/offsetWidth
`offsetHeight`/`offsetWidth` does not work for SVG Elements except in Chrome and this support is being removed from Chrome soon: >'SVGElement.offsetWidth' is deprecated and will be removed in M50, around April 2016. See https://www.chromestatus.com/features/5724912467574784 for more details.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
d3.selection.prototype.dimensions = function (dimensions) {
|
||||
if (!arguments.length) {
|
||||
var node = this.node();
|
||||
return [node.offsetWidth,
|
||||
node.offsetHeight];
|
||||
if (!node) return;
|
||||
|
||||
var cr = node.getBoundingClientRect();
|
||||
return [cr.width, cr.height];
|
||||
}
|
||||
return this.attr({width: dimensions[0], height: dimensions[1]});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user