Skip to content

Remove offsetparent call #224

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 2 commits into from
Jan 28, 2016
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
4 changes: 1 addition & 3 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
43 changes: 43 additions & 0 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var Plotly = require('@src/plotly');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');

describe('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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great test 🎉

});
});
});