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