openlayers/ol3 — pull request #798 by twpayne (2013-06-19 14:54:17+00:00)
Title: Don't attempt to constrain values in setters

A number of setters in `ol.layer.Layer` attempted to constrain the values that could be set which breaks property binding. This PR fixes that by deferring the application of the constraints until the creation of the layer state.

Here are two examples of how the old code could break. Consider brightness (which eventually needs to be in the range -1..1) and opacity (range 0..1).

Case one:
```javascript
// Bind brightness to opacity, strange but legal
layer.bindTo('brightness', layer, 'opacity');

// What should happen here? -1 is not a valid opacity
layer.setBrightness(-1);

// What should the following output?
console.log(layer.getBrightness());
console.log(layer.getOpacity());

// Is it possible for opacity and brightness to be bound, and
// for brightness to be equal to the set value (-1)?
```

Case two:
```javascript
// Set up the binding chain:
// layer1.brightness -> layer2.brightness -> layer2.opacity -> layer3.brightness
layer1.bindTo('brightness', layer2);
layer2.bindTo('opacity', layer2, 'brightness');
layer3.bindTo('brightness', layer2, 'opacity');

layer3.setBrightness(-1); // A valid brightness value, but not a valid opacity value

// What should the following output?
console.log(layer1.getBrightness());

// How did the opacity constraint of 0..1 affect the the brightness value?
```

In general, due to binding, it is not possible to apply constraints in setters. Consider the case where two properties with incompatible constraints are bound to each other (e.g. constraint in the first object is `x > 0` and constraint in the second object is `x < 0`; what values can `x` take?).

The PR fixes these problems by removing the constraints from the properties, and instead sanitising the values when they are used.