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