allow target to be specified as a string for controls, update the documentation to make more clear what element and target are for
This commit is contained in:
@@ -24,6 +24,30 @@ describe('ol.control.Control', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.control.Control\'s target', function() {
|
||||
describe('target as string or element', function() {
|
||||
it('transforms target from string to element', function() {
|
||||
var target = goog.dom.createDom('div', {'id': 'mycontrol'});
|
||||
document.body.appendChild(target);
|
||||
var ctrl = new ol.control.Control({target: 'mycontrol'});
|
||||
expect(ctrl.target_.id).to.equal('mycontrol');
|
||||
goog.dispose(ctrl);
|
||||
});
|
||||
it('accepts element for target', function() {
|
||||
var target = goog.dom.createDom('div', {'id': 'mycontrol'});
|
||||
document.body.appendChild(target);
|
||||
var ctrl = new ol.control.Control({target: target});
|
||||
expect(ctrl.target_.id).to.equal('mycontrol');
|
||||
goog.dispose(ctrl);
|
||||
});
|
||||
it('ignores non-existing target id', function() {
|
||||
var ctrl = new ol.control.Control({target: 'doesnotexist'});
|
||||
expect(ctrl.target_).to.equal(undefined);
|
||||
goog.dispose(ctrl);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagName');
|
||||
|
||||
Reference in New Issue
Block a user