Dispatch change on feature id change
This commit is contained in:
@@ -185,6 +185,7 @@ ol.Feature.prototype.setStyle = function(style) {
|
|||||||
*/
|
*/
|
||||||
ol.Feature.prototype.setId = function(id) {
|
ol.Feature.prototype.setId = function(id) {
|
||||||
this.id_ = id;
|
this.id_ = id;
|
||||||
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,34 @@ describe('ol.Feature', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#setId()', function() {
|
||||||
|
|
||||||
|
it('sets the feature identifier', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
expect(feature.getId()).to.be(undefined);
|
||||||
|
feature.setId('foo');
|
||||||
|
expect(feature.getId()).to.be('foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('accepts a string or number', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.setId('foo');
|
||||||
|
expect(feature.getId()).to.be('foo');
|
||||||
|
feature.setId(2);
|
||||||
|
expect(feature.getId()).to.be(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dispatches the "change" event', function(done) {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.on('change', function() {
|
||||||
|
expect(feature.getId()).to.be('foo');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
feature.setId('foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('#getStyleFunction()', function() {
|
describe('#getStyleFunction()', function() {
|
||||||
|
|
||||||
var styleFunction = function(resolution) {
|
var styleFunction = function(resolution) {
|
||||||
|
|||||||
Reference in New Issue
Block a user