Skip to content

Commit 3ac09d2

Browse files
committed
Fix null transform attribute warning in Firefox.
Strictly speaking, the transform attribute should never be set to null; it should be set to "translate(0)" for the identity transform, or it should be removed using removeAttribute("transform"). Setting this attribute to null causes a warning to appear in Firefox: "Unexpected value null parsing transform attribute." This occurs when using d3.transform(null), e.g. to interpolate to or from a non-existent transform attribute (null). This fix checks whether the value is null, and if so, returns an identity transform.
1 parent 0c7d186 commit 3ac09d2

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

d3.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4633,8 +4633,10 @@ d3 = function() {
46334633
d3.transform = function(string) {
46344634
var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
46354635
return (d3.transform = function(string) {
4636-
g.setAttribute("transform", string);
4637-
var t = g.transform.baseVal.consolidate();
4636+
if (string != null) {
4637+
g.setAttribute("transform", string);
4638+
var t = g.transform.baseVal.consolidate();
4639+
}
46384640
return new d3_transform(t ? t.matrix : d3_transformIdentity);
46394641
})(string);
46404642
};

0 commit comments

Comments
 (0)