Skip to content

Commit 8fd0a71

Browse files
author
Nicolò Maria Mezzopera
committed
feat: wrap ready event in $nextTick
1 parent c487599 commit 8fd0a71

21 files changed

+63
-21
lines changed

src/components/LCircle.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default {
3131
this.ready = true;
3232
this.parentContainer = findRealParent(this.$parent);
3333
this.parentContainer.addLayer(this, !this.visible);
34-
this.$emit('ready', this.mapObject);
34+
this.$nextTick(() => {
35+
this.$emit('ready', this.mapObject);
36+
});
3537
},
3638
methods: {}
3739
};

src/components/LCircleMarker.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export default {
3535
this.ready = true;
3636
this.parentContainer = findRealParent(this.$parent);
3737
this.parentContainer.addLayer(this, !this.visible);
38-
this.$emit('ready', this.mapObject);
38+
this.$nextTick(() => {
39+
this.$emit('ready', this.mapObject);
40+
});
3941
}
4042
};
4143
</script>

src/components/LControl.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export default {
2929
this.parentContainer = findRealParent(this.$parent);
3030
this.mapObject.setElement(this.$el);
3131
this.mapObject.addTo(this.parentContainer.mapObject);
32-
this.$emit('ready', this.mapObject);
32+
this.$nextTick(() => {
33+
this.$emit('ready', this.mapObject);
34+
});
3335
}
3436
};
3537
</script>

src/components/LControlAttribution.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default {
2121
this.mapObject = control.attribution(options);
2222
propsBinder(this, this.mapObject, this.$options.props);
2323
this.mapObject.addTo(this.$parent.mapObject);
24-
this.$emit('ready', this.mapObject);
24+
this.$nextTick(() => {
25+
this.$emit('ready', this.mapObject);
26+
});
2527
},
2628
render () {
2729
return null;

src/components/LControlLayers.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export default {
4141
this.mapObject = control.layers(null, null, options);
4242
propsBinder(this, this.mapObject, this.$options.props);
4343
this.$parent.registerLayerControl(this);
44-
this.$emit('ready', this.mapObject);
44+
this.$nextTick(() => {
45+
this.$emit('ready', this.mapObject);
46+
});
4547
},
4648
methods: {
4749
addLayer (layer) {

src/components/LControlScale.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export default {
3636
this.mapObject = control.scale(options);
3737
propsBinder(this, this.mapObject, this.$options.props);
3838
this.mapObject.addTo(this.$parent.mapObject);
39-
this.$emit('ready', this.mapObject);
39+
this.$nextTick(() => {
40+
this.$emit('ready', this.mapObject);
41+
});
4042
},
4143
render () {
4244
return null;

src/components/LControlZoom.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export default {
3636
this.mapObject = control.zoom(options);
3737
propsBinder(this, this.mapObject, this.$options.props);
3838
this.mapObject.addTo(this.$parent.mapObject);
39-
this.$emit('ready', this.mapObject);
39+
this.$nextTick(() => {
40+
this.$emit('ready', this.mapObject);
41+
});
4042
},
4143
render () {
4244
return null;

src/components/LFeatureGroup.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default {
2626
if (this.visible) {
2727
this.parentContainer.addLayer(this);
2828
}
29-
this.$emit('ready', this.mapObject);
29+
this.$nextTick(() => {
30+
this.$emit('ready', this.mapObject);
31+
});
3032
}
3133
};
3234
</script>

src/components/LGeoJson.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export default {
3737
propsBinder(this, this.mapObject, this.$options.props);
3838
this.parentContainer = findRealParent(this.$parent, true);
3939
this.parentContainer.addLayer(this, !this.visible);
40-
this.$emit('ready', this.mapObject);
40+
this.$nextTick(() => {
41+
this.$emit('ready', this.mapObject);
42+
});
4143
},
4244
beforeDestroy () {
4345
this.parentContainer.mapObject.removeLayer(this.mapObject);

src/components/LGridLayer.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export default {
4343
this.mapObject.createTile = this.createTile;
4444
this.parentContainer = findRealParent(this.$parent);
4545
this.parentContainer.addLayer(this, !this.visible);
46-
this.$emit('ready', this.mapObject);
46+
this.$nextTick(() => {
47+
this.$emit('ready', this.mapObject);
48+
});
4749
},
4850
beforeDestroy () {
4951
this.parentContainer.removeLayer(this.mapObject);

src/components/LImageOverlay.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default {
1313
propsBinder(this, this.mapObject, this.$options.props);
1414
this.parentContainer = findRealParent(this.$parent);
1515
this.parentContainer.addLayer(this, !this.visible);
16-
this.$emit('ready', this.mapObject);
16+
this.$nextTick(() => {
17+
this.$emit('ready', this.mapObject);
18+
});
1719
},
1820
render () {
1921
return null;

src/components/LLayerGroup.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default {
2626
if (this.visible) {
2727
this.parentContainer.addLayer(this);
2828
}
29-
this.$emit('ready', this.mapObject);
29+
this.$nextTick(() => {
30+
this.$emit('ready', this.mapObject);
31+
});
3032
}
3133
};
3234
</script>

src/components/LMap.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ export default {
158158
this.ready = true;
159159
// DEPRECATED leaflet:load
160160
this.$emit('leaflet:load');
161-
this.$emit('ready', this.mapObject);
161+
this.$nextTick(() => {
162+
this.$emit('ready', this.mapObject);
163+
});
162164
},
163165
methods: {
164166
registerLayerControl (lControlLayers) {

src/components/LMarker.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export default {
5252
this.parentContainer = findRealParent(this.$parent);
5353
this.parentContainer.addLayer(this, !this.visible);
5454
this.ready = true;
55-
this.$emit('ready', this.mapObject);
55+
this.$nextTick(() => {
56+
this.$emit('ready', this.mapObject);
57+
});
5658
},
5759
methods: {
5860
setDraggable (newVal, oldVal) {

src/components/LPolygon.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default {
3131
this.ready = true;
3232
this.parentContainer = findRealParent(this.$parent);
3333
this.parentContainer.addLayer(this, !this.visible);
34-
this.$emit('ready', this.mapObject);
34+
this.$nextTick(() => {
35+
this.$emit('ready', this.mapObject);
36+
});
3537
}
3638
};
3739
</script>

src/components/LPolyline.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default {
3131
this.ready = true;
3232
this.parentContainer = findRealParent(this.$parent);
3333
this.parentContainer.addLayer(this, !this.visible);
34-
this.$emit('ready', this.mapObject);
34+
this.$nextTick(() => {
35+
this.$emit('ready', this.mapObject);
36+
});
3537
}
3638
};
3739
</script>

src/components/LPopup.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export default {
2424
this.mapObject.setContent(this.content || this.$el);
2525
this.parentContainer = findRealParent(this.$parent);
2626
this.parentContainer.mapObject.bindPopup(this.mapObject);
27-
this.$emit('ready', this.mapObject);
27+
this.$nextTick(() => {
28+
this.$emit('ready', this.mapObject);
29+
});
2830
},
2931
beforeDestroy () {
3032
if (this.parentContainer) {

src/components/LRectangle.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default {
3131
this.ready = true;
3232
this.parentContainer = findRealParent(this.$parent);
3333
this.parentContainer.addLayer(this, !this.visible);
34-
this.$emit('ready', this.mapObject);
34+
this.$nextTick(() => {
35+
this.$emit('ready', this.mapObject);
36+
});
3537
}
3638
};
3739
</script>

src/components/LTileLayer.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export default {
2828
propsBinder(this, this.mapObject, this.$options.props);
2929
this.parentContainer = findRealParent(this.$parent);
3030
this.parentContainer.addLayer(this, !this.visible);
31-
this.$emit('ready', this.mapObject);
31+
this.$nextTick(() => {
32+
this.$emit('ready', this.mapObject);
33+
});
3234
}
3335
};
3436
</script>

src/components/LTooltip.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export default {
1515
this.mapObject.setContent(this.content || this.$el);
1616
this.parentContainer = findRealParent(this.$parent);
1717
this.parentContainer.mapObject.bindTooltip(this.mapObject);
18-
this.$emit('ready', this.mapObject);
18+
this.$nextTick(() => {
19+
this.$emit('ready', this.mapObject);
20+
});
1921
},
2022
beforeDestroy () {
2123
if (this.parentContainer) {

src/components/LWMSTileLayer.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export default {
2020
propsBinder(this, this.mapObject, this.$options.props);
2121
this.parentContainer = findRealParent(this.$parent);
2222
this.parentContainer.addLayer(this, !this.visible);
23-
this.$emit('ready', this.mapObject);
23+
this.$nextTick(() => {
24+
this.$emit('ready', this.mapObject);
25+
});
2426
}
2527
};
2628
</script>

0 commit comments

Comments
 (0)