Skip to content

bypass non-string ids when matching axes #4858

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 1 commit into from
May 22, 2020
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
2 changes: 1 addition & 1 deletion src/plots/cartesian/axis_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports.name2id = function name2id(name) {
};

exports.cleanId = function cleanId(id, axLetter) {
if(!id.match(constants.AX_ID_PATTERN)) return;
if(typeof id !== 'string' || !id.match(constants.AX_ID_PATTERN)) return;
if(axLetter && id.charAt(0) !== axLetter) return;

var axNum = id.substr(1).replace(/^0+/, '');
Expand Down
38 changes: 38 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5576,3 +5576,41 @@ describe('more react tests', function() {
.then(done);
});
});

describe('more matching axes tests', function() {
var gd;

beforeEach(function() {
gd = createGraphDiv();
});

afterEach(destroyGraphDiv);

it('should bypass non-string id when matching ids', function(done) {
Plotly.newPlot(gd, {
data: [{
x: [0, 1],
y: [0, 1]
}, {
x: [0, 1],
y: [1, 2],
yaxis: 'y2'
}],
layout: {
xaxis: {
anchor: 'y'
},
yaxis: {
anchor: 'x'
},
yaxis2: {
anchor: [], // bad input
position: 0.1,
overlaying: 'y'
}
}
})
.catch(failTest)
.then(done);
});
});