From f9269b517eea449a6bfca91169befcc84b413139 Mon Sep 17 00:00:00 2001 From: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> Date: Thu, 7 Jul 2022 17:17:00 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20issue=20with=20`container`=20undefined?= =?UTF-8?q?=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> --- src/map/VMap.vue | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/map/VMap.vue b/src/map/VMap.vue index 11dddd2f..a2367f54 100644 --- a/src/map/VMap.vue +++ b/src/map/VMap.vue @@ -1,5 +1,5 @@ @@ -26,9 +26,10 @@ let events: Ref> = 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); @@ -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, + }; }, });