diff --git a/src/lib/index.js b/src/lib/index.js index e0b6576d8ca..0778748e09b 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -713,7 +713,7 @@ lib.addRelatedStyleRule = function(uid, selector, styleString) { lib.deleteRelatedStyleRule = function(uid) { var id = 'plotly.js-style-' + uid, style = document.getElementById(id); - if(style) style.remove(); + if(style) lib.removeElement(style); }; lib.isIE = function() { diff --git a/test/jasmine/assets/unpolyfill.js b/test/jasmine/assets/unpolyfill.js new file mode 100644 index 00000000000..821a732ce5a --- /dev/null +++ b/test/jasmine/assets/unpolyfill.js @@ -0,0 +1,22 @@ +/* + * Un-polyfills - to be included in karma.conf.js to catch + * browser-dependent errors. + */ + +'use strict'; + +(function(arr) { + arr.forEach(function(item) { + Object.defineProperty(item, 'remove', { + configurable: true, + enumerable: true, + writable: true, + value: function remove() { + throw Error([ + 'test/jasmine/assets/unpolyfill.js error: calling ChildNode.remove()', + 'which is not available in IE.' + ].join(' ')); + } + }); + }); +})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); diff --git a/test/jasmine/karma.conf.js b/test/jasmine/karma.conf.js index 4050c8ccc5e..0d8f789b90d 100644 --- a/test/jasmine/karma.conf.js +++ b/test/jasmine/karma.conf.js @@ -106,6 +106,7 @@ var pathToStrictD3 = path.join(__dirname, '..', '..', 'tasks', 'util', 'strict_d var pathToJQuery = path.join(__dirname, 'assets', 'jquery-1.8.3.min.js'); var pathToIE9mock = path.join(__dirname, 'assets', 'ie9_mock.js'); var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js'); +var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js'); var reporters = (isFullSuite && !argv.tags) ? ['dots', 'spec'] : ['progress']; if(argv.failFast) reporters.push('fail-fast'); @@ -142,7 +143,7 @@ func.defaultConfig = { // list of files / patterns to load in the browser // // N.B. the rest of this field is filled below - files: [pathToCustomMatchers], + files: [pathToCustomMatchers, pathToUnpolyfill], // list of files / pattern to exclude exclude: [],