Skip to content

Commit

Permalink
Fixed #1046 - CDN builds are broken
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Mar 3, 2021
1 parent ab4997a commit 870693e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/components/utils/EventBus.js
Original file line number Diff line number Diff line change
@@ -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 }));
}
}
}
}
2 changes: 1 addition & 1 deletion src/components/utils/OverlayEventBus.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {EventBus} from 'primevue/utils';
import EventBus from './EventBus.js';

export default EventBus();

0 comments on commit 870693e

Please sign in to comment.