Skip to content

Commit

Permalink
fix: issue with container undefined 🐛
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
  • Loading branch information
vinayakkulkarni committed Jul 7, 2022
1 parent 2cc57b1 commit f9269b5
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/map/VMap.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :id="`${options.container}` || 'map'" class="v-map-container">
<div :id="getContainer()" class="v-map-container">
<slot />
</div>
</template>
Expand All @@ -26,9 +26,10 @@
let events: Ref<Array<keyof MapEventType>> = ref(mapEvents);
onMounted(() => {
const options = props.options.container
? props.options
: { ...props.options, container: 'map' };
const options =
'container' in props.options
? props.options
: { ...props.options, container: 'map' };
map.value = new Map(options);
loaded.value = true;
provide(MapKey, map);
Expand All @@ -55,6 +56,22 @@
});
});
}
/**
* Gets the container element
*
* @returns {string} - The container element id
*/
const getContainer = (): string => {
if (Object.keys(props.options).includes('container')) {
return `${props.options.container}`;
}
return 'map';
};
return {
getContainer,
};
},
});
</script>
Expand Down

0 comments on commit f9269b5

Please sign in to comment.