Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 410ab8d

Browse files
committed
Remove offsetparent call
1 parent c58fe87 commit 410ab8d

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

src/plots/plots.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ plots.addLinks = function(gd) {
298298
// IE doesn't like getComputedTextLength if an element
299299
// isn't visible, which it (sometimes?) isn't
300300
// apparently offsetParent is null for invisibles.
301-
// http://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
302-
if (text && text.offsetParent &&
303-
text.getComputedTextLength() >= (fullLayout.width - 20)) {
301+
if (text && text.getComputedTextLength() >= (fullLayout.width - 20)) {
304302
// Align the text at the left
305303
attrs['text-anchor'] = 'start';
306304
attrs.x = 5;

test/jasmine/tests/config_test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var Plotly = require('@src/plotly');
2+
var createGraphDiv = require('../assets/create_graph_div');
3+
var destroyGraphDiv = require('../assets/destroy_graph_div');
4+
5+
fdescribe('config argument', function() {
6+
7+
var gd;
8+
9+
beforeEach(function(done) {
10+
gd = createGraphDiv();
11+
done();
12+
});
13+
14+
afterEach(destroyGraphDiv);
15+
16+
describe('showLink attribute', function() {
17+
18+
it('should not display the edit link by default', function() {
19+
Plotly.plot(gd, [], {});
20+
21+
var link = document.getElementsByClassName('js-plot-link-container')[0];
22+
23+
expect(link.textContent).toBe('');
24+
25+
var bBox = link.getBoundingClientRect();
26+
expect(bBox.width).toBe(0);
27+
expect(bBox.height).toBe(0);
28+
});
29+
30+
it('should display a link when true', function() {
31+
Plotly.plot(gd, [], {}, { showLink: true });
32+
33+
var link = document.getElementsByClassName('js-plot-link-container')[0];
34+
35+
console.log(link);
36+
expect(link.textContent).toBe('Edit chart »');
37+
38+
var bBox = link.getBoundingClientRect();
39+
expect(bBox.width).toBeGreaterThan(0);
40+
expect(bBox.height).toBeGreaterThan(0);
41+
});
42+
});
43+
});

0 commit comments

Comments
 (0)