Fixed #1046 - CDN builds are broken

pull/1047/head
Cagatay Civici 2021-03-03 12:56:04 +03:00
parent ab4997ab55
commit 870693e7df
2 changed files with 9 additions and 6 deletions

View File

@ -1,25 +1,28 @@
export default function handler() {
let eventTarget = document.body.appendChild(document.createComment(''));
let eventListener, eventKey;
export default function() {
let eventTarget, eventListener, eventKey;
return {
on(type, listener, key) {
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener);
},
once(type, listener, key) {
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
eventKey = key;
eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener, { once: true });
},
off(type, key) {
if (eventListener && eventKey === key) {
if (eventTarget && eventListener && eventKey === key) {
eventTarget.removeEventListener(type, eventListener);
}
},
emit(type, detail) {
eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
if (eventTarget) {
eventTarget.dispatchEvent(new CustomEvent(type, { detail }));
}
}
}
}

View File

@ -1,3 +1,3 @@
import {EventBus} from 'primevue/utils';
import EventBus from './EventBus.js';
export default EventBus();