From 410ab8dbb8ca536c736981e5cf242a6804238202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Thu, 28 Jan 2016 12:36:33 -0500 Subject: [PATCH 1/2] Remove offsetparent call --- src/plots/plots.js | 4 +-- test/jasmine/tests/config_test.js | 43 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/jasmine/tests/config_test.js diff --git a/src/plots/plots.js b/src/plots/plots.js index 616e1e35e69..595296de3d7 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -298,9 +298,7 @@ plots.addLinks = function(gd) { // IE doesn't like getComputedTextLength if an element // isn't visible, which it (sometimes?) isn't // apparently offsetParent is null for invisibles. - // http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom - if (text && text.offsetParent && - text.getComputedTextLength() >= (fullLayout.width - 20)) { + if (text && text.getComputedTextLength() >= (fullLayout.width - 20)) { // Align the text at the left attrs['text-anchor'] = 'start'; attrs.x = 5; diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js new file mode 100644 index 00000000000..db26430e287 --- /dev/null +++ b/test/jasmine/tests/config_test.js @@ -0,0 +1,43 @@ +var Plotly = require('@src/plotly'); +var createGraphDiv = require('../assets/create_graph_div'); +var destroyGraphDiv = require('../assets/destroy_graph_div'); + +fdescribe('config argument', function() { + + var gd; + + beforeEach(function(done) { + gd = createGraphDiv(); + done(); + }); + + afterEach(destroyGraphDiv); + + describe('showLink attribute', function() { + + it('should not display the edit link by default', function() { + Plotly.plot(gd, [], {}); + + var link = document.getElementsByClassName('js-plot-link-container')[0]; + + expect(link.textContent).toBe(''); + + var bBox = link.getBoundingClientRect(); + expect(bBox.width).toBe(0); + expect(bBox.height).toBe(0); + }); + + it('should display a link when true', function() { + Plotly.plot(gd, [], {}, { showLink: true }); + + var link = document.getElementsByClassName('js-plot-link-container')[0]; + + console.log(link); + expect(link.textContent).toBe('Edit chart ยป'); + + var bBox = link.getBoundingClientRect(); + expect(bBox.width).toBeGreaterThan(0); + expect(bBox.height).toBeGreaterThan(0); + }); + }); +}); From c4872ae13a4118ccfeb64965d98143493b7ae12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Tusz?= Date: Thu, 28 Jan 2016 12:50:38 -0500 Subject: [PATCH 2/2] Remove fdescribe --- test/jasmine/tests/config_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index db26430e287..a8abcd1545c 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -2,7 +2,7 @@ var Plotly = require('@src/plotly'); var createGraphDiv = require('../assets/create_graph_div'); var destroyGraphDiv = require('../assets/destroy_graph_div'); -fdescribe('config argument', function() { +describe('config argument', function() { var gd;