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

d3.style('padding') or d3.style('margin') returned empty string only in firefox #290

Closed
ZaharovDm opened this issue Jul 27, 2021 · 2 comments

Comments

@ZaharovDm
Copy link

in Firefox
image

in Google

image

@ZaharovDm
Copy link
Author

    this.currentContainer = this.parentContainer.append("g")
        .attr("id", data.id)
        .attr("class", className)
        .attr("stroke-opacity", opacity)

this.currentContainer.style('margin')

@mbostock mbostock transferred this issue from d3/d3 Jul 27, 2021
@mbostock
Copy link
Member

You can see what selection.style returns here:

|| defaultView(node).getComputedStyle(node, null).getPropertyValue(name);

If Firefox returns an empty string, it’s because Firefox defines that as the computed value. D3 is not a compatibility layer, so it does not include workarounds to normalize different behaviors across browsers.

I suspect the problem here is that the G element is an SVG element, where the HTML styles of margin and padding do not make sense. These styles have no effect on layout within an SVG element; you must use the transform attribute to change how a G element is positioned. I suspect that Firefox does not compute HTML styles on SVG G elements, whereas other browsers may (even though they have no effect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants