Skip to content

Prohibit CSS transform usage on SVG elements due to IE #1729

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

Merged
merged 1 commit into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"Uint8Array": true,
"Int16Array": true,
"Int32Array": true,
"ArrayBuffer": true
"ArrayBuffer": true,
"SVGElement": false
},
"rules": {
"no-trailing-spaces": [2],
Expand Down
11 changes: 8 additions & 3 deletions test/image/strict-d3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

if(sel.size()) {
if(typeof obj === 'string') {
checkVal(obj, arguments[1]);
checkVal(sel, obj, arguments[1]);
}
else {
Object.keys(obj).forEach(function(key) { checkVal(key, obj[key]); });
Object.keys(obj).forEach(function(key) { checkVal(sel, key, obj[key]); });
}
}

return originalSelStyle.apply(sel, arguments);
};

function checkVal(key, val) {
function checkVal(sel, key, val) {
if(typeof val === 'string') {
// in case of multipart styles (stroke-dasharray, margins, etc)
// test each part separately
Expand All @@ -37,6 +37,11 @@
throw new Error('d3 selection.style called with value: ' + val);
}
});

// Microsoft browsers incl. "Edge" don't support CSS transform on SVG elements
if(key === 'transform' && sel.node() instanceof SVGElement) {
throw new Error('d3 selection.style called on an SVG element with key: ' + key);
}
}

}
Expand Down