Add named exports for createStyleFunction function
This commit is contained in:
@@ -237,8 +237,7 @@ Feature.prototype.setGeometry = function(geometry) {
|
||||
*/
|
||||
Feature.prototype.setStyle = function(style) {
|
||||
this.style_ = style;
|
||||
this.styleFunction_ = !style ?
|
||||
undefined : Feature.createStyleFunction(style);
|
||||
this.styleFunction_ = !style ? undefined : createStyleFunction(style);
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -285,7 +284,7 @@ Feature.prototype.setGeometryName = function(name) {
|
||||
* A feature style function, a single style, or an array of styles.
|
||||
* @return {ol.StyleFunction} A style function.
|
||||
*/
|
||||
Feature.createStyleFunction = function(obj) {
|
||||
export function createStyleFunction(obj) {
|
||||
if (typeof obj === 'function') {
|
||||
return obj;
|
||||
} else {
|
||||
@@ -304,5 +303,5 @@ Feature.createStyleFunction = function(obj) {
|
||||
return styles;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
export default Feature;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Feature from '../../../src/ol/Feature.js';
|
||||
import Feature, {createStyleFunction} from '../../../src/ol/Feature.js';
|
||||
import Point from '../../../src/ol/geom/Point.js';
|
||||
import {isEmpty} from '../../../src/ol/obj.js';
|
||||
import Style from '../../../src/ol/style/Style.js';
|
||||
@@ -441,12 +441,12 @@ describe('ol.Feature.createStyleFunction()', function() {
|
||||
const style = new Style();
|
||||
|
||||
it('creates a feature style function from a single style', function() {
|
||||
const styleFunction = Feature.createStyleFunction(style);
|
||||
const styleFunction = createStyleFunction(style);
|
||||
expect(styleFunction()).to.eql([style]);
|
||||
});
|
||||
|
||||
it('creates a feature style function from an array of styles', function() {
|
||||
const styleFunction = Feature.createStyleFunction([style]);
|
||||
const styleFunction = createStyleFunction([style]);
|
||||
expect(styleFunction()).to.eql([style]);
|
||||
});
|
||||
|
||||
@@ -454,13 +454,13 @@ describe('ol.Feature.createStyleFunction()', function() {
|
||||
const original = function(feature, resolution) {
|
||||
return [style];
|
||||
};
|
||||
const styleFunction = Feature.createStyleFunction(original);
|
||||
const styleFunction = createStyleFunction(original);
|
||||
expect(styleFunction).to.be(original);
|
||||
});
|
||||
|
||||
it('throws on (some) unexpected input', function() {
|
||||
expect(function() {
|
||||
Feature.createStyleFunction({bogus: 'input'});
|
||||
createStyleFunction({bogus: 'input'});
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user