Fixed #1046 - CDN builds are broken
parent
ab4997ab55
commit
870693e7df
|
@ -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 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
import {EventBus} from 'primevue/utils';
|
||||
import EventBus from './EventBus.js';
|
||||
|
||||
export default EventBus();
|
Loading…
Reference in New Issue