Skip to content

Commit a450d93

Browse files
authored
Merge pull request #4858 from plotly/fix4844-handle-bad-axis-anchor
bypass non-string ids when matching axes
2 parents bee2455 + 45841a8 commit a450d93

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/plots/cartesian/axis_ids.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exports.name2id = function name2id(name) {
3131
};
3232

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

3737
var axNum = id.substr(1).replace(/^0+/, '');

test/jasmine/tests/axes_test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5576,3 +5576,41 @@ describe('more react tests', function() {
55765576
.then(done);
55775577
});
55785578
});
5579+
5580+
describe('more matching axes tests', function() {
5581+
var gd;
5582+
5583+
beforeEach(function() {
5584+
gd = createGraphDiv();
5585+
});
5586+
5587+
afterEach(destroyGraphDiv);
5588+
5589+
it('should bypass non-string id when matching ids', function(done) {
5590+
Plotly.newPlot(gd, {
5591+
data: [{
5592+
x: [0, 1],
5593+
y: [0, 1]
5594+
}, {
5595+
x: [0, 1],
5596+
y: [1, 2],
5597+
yaxis: 'y2'
5598+
}],
5599+
layout: {
5600+
xaxis: {
5601+
anchor: 'y'
5602+
},
5603+
yaxis: {
5604+
anchor: 'x'
5605+
},
5606+
yaxis2: {
5607+
anchor: [], // bad input
5608+
position: 0.1,
5609+
overlaying: 'y'
5610+
}
5611+
}
5612+
})
5613+
.catch(failTest)
5614+
.then(done);
5615+
});
5616+
});

0 commit comments

Comments
 (0)