Merge pull request #13444 from themoffster/fullscreen-classname

Ensure FullScreen button has classname set on render.
This commit is contained in:
Andreas Hocevar
2022-03-04 13:24:39 +01:00
committed by GitHub
2 changed files with 20 additions and 0 deletions

View File

@@ -165,6 +165,7 @@ class FullScreen extends Control {
const tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
this.button_.setAttribute('type', 'button');
this.setClassName_(this.button_, this.isInFullscreen_);
this.button_.title = tipLabel;
this.button_.appendChild(this.labelNode_);

View File

@@ -7,4 +7,23 @@ describe('ol.control.FullScreen', function () {
expect(instance).to.be.an(FullScreen);
});
});
describe('the fullscreen button', function () {
describe('when inactiveClassName is not set', function () {
it('is created with the default inactive classname set on the button', function () {
const instance = new FullScreen();
const button = instance.button_;
expect(button.className).to.equal('ol-full-screen-false');
});
});
describe('when inactiveClassName is set', function () {
it('is created with the desired inactive classnames set on the button', function () {
const instance = new FullScreen({
inactiveClassName: 'foo bar',
});
const button = instance.button_;
expect(button.className).to.equal('foo bar');
});
});
});
});