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() { export default function() {
let eventTarget = document.body.appendChild(document.createComment('')); let eventTarget, eventListener, eventKey;
let eventListener, eventKey;
return { return {
on(type, listener, key) { on(type, listener, key) {
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
eventKey = key; eventKey = key;
eventListener = function(e) { listener(e.detail); }; eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener); eventTarget.addEventListener(type, eventListener);
}, },
once(type, listener, key) { once(type, listener, key) {
eventTarget = eventTarget || document.body.appendChild(document.createComment(''));
eventKey = key; eventKey = key;
eventListener = function(e) { listener(e.detail); }; eventListener = function(e) { listener(e.detail); };
eventTarget.addEventListener(type, eventListener, { once: true }); eventTarget.addEventListener(type, eventListener, { once: true });
}, },
off(type, key) { off(type, key) {
if (eventListener && eventKey === key) { if (eventTarget && eventListener && eventKey === key) {
eventTarget.removeEventListener(type, eventListener); eventTarget.removeEventListener(type, eventListener);
} }
}, },
emit(type, detail) { 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(); export default EventBus();