Skip to content

Commit ab3176a

Browse files
committed
fix(PreviewSignature): remove @load handler to prevent double emit
The @load='onImageLoad' on <img> caused a third 'loaded' emission when the native DOM load event fired after imageData.value was set, in addition to the explicit onImageLoad(true) call inside loadImage(). Remove the @load handler and call onImageLoad(true) explicitly in the data: URL path too, so emission is always triggered once per loadImage call regardless of jsdom behavior. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent dad6bde commit ab3176a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/components/PreviewSignature/PreviewSignature.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
:style="{
1313
width,
1414
height,
15-
}"
16-
@load="onImageLoad">
15+
}">
1716
</div>
1817
</div>
1918
</template>
@@ -56,7 +55,7 @@ const props = withDefaults(defineProps<{
5655
})
5756
5857
const emit = defineEmits<{
59-
(e: 'loaded', status: boolean | Event): void
58+
(e: 'loaded', status: boolean): void
6059
}>()
6160
6261
const loading = ref(true)
@@ -82,6 +81,7 @@ function arrayBufferToBase64(data: ArrayBuffer) {
8281
async function loadImage() {
8382
if (props.src.startsWith('data:')) {
8483
imageData.value = props.src
84+
onImageLoad(true)
8585
return
8686
}
8787
@@ -105,7 +105,7 @@ async function loadImage() {
105105
}
106106
}
107107
108-
function onImageLoad(status: boolean | Event) {
108+
function onImageLoad(status: boolean) {
109109
loading.value = false
110110
isLoaded.value = true
111111
emit('loaded', status)

0 commit comments

Comments
 (0)