No need to have a mutable_ flag

Instead, educate users to call setStyle.
This commit is contained in:
Andreas Hocevar
2014-09-04 11:47:32 -06:00
parent 13d84e75ad
commit 0c36d7606b
8 changed files with 76 additions and 221 deletions

View File

@@ -16,12 +16,11 @@ describe('ol.FeatureOverlay', function() {
expect(featureOverlay.getFeatures().getLength()).to.be(1);
});
it('takes a style and makes it immutable', function() {
it('takes a style', function() {
var style = [new ol.style.Style()];
var featureOverlay = new ol.FeatureOverlay({
style: [new ol.style.Style()]
});
style[0].setMutable(false);
expect(featureOverlay.getStyle()).to.eql(style);
expect(featureOverlay.getStyleFunction()()).to.eql(style);
});

View File

@@ -2,50 +2,13 @@ goog.provide('ol.test.style.Style');
describe('ol.style.Style', function() {
describe('#setMutable', function() {
describe('#setZIndex', function() {
it('recursively sets the mutable flag', function() {
var style = new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.6)'
}),
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
fill: new ol.style.Fill({
color: '#000'
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
})
})
});
it('sets the zIndex', function() {
var style = new ol.style.Style();
expect(function() {
style.setZIndex(1);
}).to.not.throwException();
expect(style.mutable_).to.be(true);
expect(style.getFill().mutable_).to.be(true);
expect(style.getStroke().mutable_).to.be(true);
expect(style.getText().mutable_).to.be(true);
expect(style.getText().getStroke().mutable_).to.be(true);
style.setMutable(false);
expect(function() {
style.setZIndex();
}).to.throwException();
expect(style.mutable_).to.be(false);
expect(style.getFill().mutable_).to.be(false);
expect(style.getStroke().mutable_).to.be(false);
expect(style.getText().mutable_).to.be(false);
expect(style.getText().getStroke().mutable_).to.be(false);
style.setZIndex(0.7);
expect(style.getZIndex()).to.be(0.7);
});
});
});
@@ -77,41 +40,6 @@ describe('ol.style.createStyleFunction()', function() {
}).to.throwException();
});
it('makes styles immutable', function() {
var style = new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.6)'
}),
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
fill: new ol.style.Fill({
color: '#000'
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
})
})
});
expect(function() {
style.getFill().setColor('white');
}).to.not.throwException();
ol.style.createStyleFunction(style);
expect(function() {
style.getFill().setColor('black');
}).to.throwException();
});
});
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
goog.require('ol.style.Text');