Skip to content

Commit 5601f90

Browse files
authored
Merge pull request #1729 from plotly/prohibit-css-transform
Prohibit CSS transform usage on SVG elements due to IE
2 parents 200a677 + 1bb5c92 commit 5601f90

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"Uint8Array": true,
1717
"Int16Array": true,
1818
"Int32Array": true,
19-
"ArrayBuffer": true
19+
"ArrayBuffer": true,
20+
"SVGElement": false
2021
},
2122
"rules": {
2223
"no-trailing-spaces": [2],

test/image/strict-d3.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
if(sel.size()) {
1919
if(typeof obj === 'string') {
20-
checkVal(obj, arguments[1]);
20+
checkVal(sel, obj, arguments[1]);
2121
}
2222
else {
23-
Object.keys(obj).forEach(function(key) { checkVal(key, obj[key]); });
23+
Object.keys(obj).forEach(function(key) { checkVal(sel, key, obj[key]); });
2424
}
2525
}
2626

2727
return originalSelStyle.apply(sel, arguments);
2828
};
2929

30-
function checkVal(key, val) {
30+
function checkVal(sel, key, val) {
3131
if(typeof val === 'string') {
3232
// in case of multipart styles (stroke-dasharray, margins, etc)
3333
// test each part separately
@@ -37,6 +37,11 @@
3737
throw new Error('d3 selection.style called with value: ' + val);
3838
}
3939
});
40+
41+
// Microsoft browsers incl. "Edge" don't support CSS transform on SVG elements
42+
if(key === 'transform' && sel.node() instanceof SVGElement) {
43+
throw new Error('d3 selection.style called on an SVG element with key: ' + key);
44+
}
4045
}
4146

4247
}

0 commit comments

Comments
 (0)