Skip to content

Commit d6466e4

Browse files
committed
fix: correctly handle styles prop
1 parent c1db412 commit d6466e4

File tree

12 files changed

+19
-22
lines changed

12 files changed

+19
-22
lines changed

docs/componentsguide/interactions/modify/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import SnapModifyDemo from "@demos/SnapModifyDemo.vue"
3434
<ol-source-osm />
3535
</ol-tile-layer>
3636
37-
<ol-vector-layer :style="vectorStyle">
37+
<ol-vector-layer :styles="vectorStyle">
3838
<ol-source-vector :features="zones">
3939
<ol-interaction-modify
4040
v-if="modifyEnabled"

docs/componentsguide/interactions/snap/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import SnapModifyDemo from "@demos/SnapModifyDemo.vue"
3434
<ol-source-osm />
3535
</ol-tile-layer>
3636
37-
<ol-vector-layer :style="vectorStyle">
37+
<ol-vector-layer :styles="vectorStyle">
3838
<ol-source-vector :features="zones">
3939
<ol-interaction-modify
4040
v-if="modifyEnabled"

docs/componentsguide/layers/tilelayer/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Example below shows how to use ol-layer-tile component together with ol-source-w
3333
:matrixSet="matrixSet"
3434
:format="format"
3535
:layer="layerName"
36-
:style="styleName"
36+
:styles="styleName"
3737
></ol-source-wmts>
3838
</ol-tile-layer>
3939
</ol-map>

docs/componentsguide/layers/webglpointslayer/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import WebglPointsLayerDemo from "@demos/WebglPointsLayerDemo.vue"
2828
<ol-source-osm />
2929
</ol-tile-layer>
3030
31-
<ol-webglpoints-layer :style="webglPointsStyle">
31+
<ol-webglpoints-layer :styles="webglPointsStyle">
3232
<ol-source-webglpoints
3333
:format="geoJson"
3434
url="https://openlayers.org/en/latest/examples/data/geojson/world-cities.geojson"

docs/componentsguide/sources/wmts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Example below shows how to use ol-layer-tile component together with ol-source-w
3434
:matrixSet="matrixSet"
3535
:format="format"
3636
:layer="layerName"
37-
:style="styleName"
37+
:styles="styleName"
3838
></ol-source-wmts>
3939
</ol-tile-layer>
4040
</ol-map>

docs/demo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ import AppDemo from "@demos/AppDemo.vue"
269269
</ol-source-vector>
270270
</ol-vector-layer>
271271
272-
<ol-webglpoints-layer :style="webglPointsStyle">
272+
<ol-webglpoints-layer :styles="webglPointsStyle">
273273
<ol-source-webglpoints
274274
:format="geoJson"
275275
url="https://openlayers.org/en/latest/examples/data/geojson/world-cities.geojson"

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
</ol-animation-path>
276276
</ol-source-vector>
277277
</ol-vector-layer>
278-
<ol-webglpoints-layer :style="webglPointsStyle">
278+
<ol-webglpoints-layer :styles="webglPointsStyle">
279279
<ol-source-webglpoints
280280
:format="geoJson"
281281
url="https://openlayers.org/en/latest/examples/data/geojson/world-cities.geojson"

src/composables/usePropsAsObjectProperties.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,28 @@ import { toRefs, watch, reactive } from "vue";
44
* We can't use 'style' as a component prop since it's a reserved property
55
* This function will map the special `styles` prop to `style`
66
*/
7-
function getRevisedProps(props) {
8-
const revisedProps = { ...props };
9-
delete revisedProps.styles;
10-
if (props.styles) {
11-
props.style = props.styles;
7+
function checkAndUpdateStylePropDef(options, key) {
8+
if (key === "styles") {
9+
options.style = options[key].value;
1210
}
13-
return revisedProps;
1411
}
1512

1613
export default function usePropsAsObjectProperties(props, ignoredKeys = []) {
17-
const revisedProps = getRevisedProps(props);
18-
19-
let options = toRefs(revisedProps);
14+
let options = toRefs(props);
2015
Object.keys(options).forEach((key) => {
16+
checkAndUpdateStylePropDef(options, key);
2117
options[key] = options[key].value;
2218
});
2319

2420
const properties = reactive({
2521
...options,
2622
});
2723

28-
watch(props, (newVal) => {
29-
options = toRefs(getRevisedProps(newVal));
24+
watch(props, () => {
25+
options = toRefs(props);
3026
Object.keys(options).forEach((key) => {
3127
if (properties[key] != options[key].value && !ignoredKeys.includes(key)) {
28+
checkAndUpdateStylePropDef(options, key);
3229
properties[key] = options[key].value;
3330
}
3431
});

src/demos/AppDemo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246
</ol-source-vector>
247247
</ol-vector-layer>
248248

249-
<ol-webglpoints-layer :style="webglPointsStyle">
249+
<ol-webglpoints-layer :styles="webglPointsStyle">
250250
<ol-source-webglpoints
251251
:format="geoJson"
252252
url="https://openlayers.org/en/latest/examples/data/geojson/world-cities.geojson"

src/demos/SnapModifyDemo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<ol-source-osm />
2020
</ol-tile-layer>
2121

22-
<ol-vector-layer :style="vectorStyle">
22+
<ol-vector-layer :styles="vectorStyle">
2323
<ol-source-vector :features="zones">
2424
<ol-interaction-modify
2525
v-if="modifyEnabled"

0 commit comments

Comments
 (0)