Skip to content

Commit

Permalink
fix(CarbonAds): avoid duplicate emits
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Nov 11, 2024
1 parent c6831d7 commit c93bd22
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/runtime/components/ScriptCarbonAds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ function loadCarbon() {
}))
script.setAttribute('id', attrId)
script.onerror = (err) => {
status.value = 'error'
emit('error', err)
if (status.value !== 'error') {
status.value = 'error'
emit('error', err)
}
}
script.onload = () => {
status.value = 'loaded'
emit('ready', script)
if (status.value !== 'loaded') {
status.value = 'loaded'
emit('ready', script)
}
}
carbonadsEl.value.appendChild(script)
}
Expand Down

0 comments on commit c93bd22

Please sign in to comment.