Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tcuongtran/1eea8890726bdd9070479103a0395d2b to your computer and use it in GitHub Desktop.
Save tcuongtran/1eea8890726bdd9070479103a0395d2b to your computer and use it in GitHub Desktop.
IE9: D3 throw exception on setProperty
(function () {
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
var d3_style_prototype = this.CSSStyleDeclaration.prototype,
d3_style_setProperty = d3_style_prototype.setProperty;
d3_style_prototype.setProperty = function (name, value, priority) {
try {
d3_style_setProperty.call(this, name, value + '', priority);
} catch (exception) {
// console.warn('d3_style_prototype.setProperty - name: ', name, ', value: ', value, ', priority: ', priority, ', exception: ', exception);
switch (name) {
case 'left':
name = 'start';
break;
case 'right':
name = 'end';
break;
default:
name = 'middle';
break;
}
d3_style_setProperty.call(this, name, value + '', priority);
}
};
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment