Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should change the element that events are proxied from', function() {
var origin = document.createElement('div');
document.body.appendChild(origin);
var target = new EventEmitter();
var proxy = new DomEventEmitterProxy(origin, target);
var listener = sinon.stub();
target.on('click', listener);
var origin2 = document.createElement('div');
document.body.appendChild(origin2);
proxy.setOriginEmitter(origin2);
dom.triggerEvent(origin, 'click');
assert.strictEqual(0, listener.callCount);
dom.triggerEvent(origin2, 'click');
assert.strictEqual(1, listener.callCount);
assert.ok(listener.args[0][0]);
it('should not to clear screen cache the being used in a pending navigation', (done) => {
const event = new EventEmitter();
class StubScreen extends Screen {
constructor() {
super();
this.cacheable = true;
}
flip(surfaces) {
super.flip(surfaces);
event.emit('flip');
}
}
const callback = () => {
this.app.clearScreensCache();
assert.strictEqual(1, Object.keys(this.app.screens).length);
it('should not proxy event emitter events after disposed', function() {
var origin = new EventEmitter();
var target = new EventEmitter();
var proxy = new DomEventEmitterProxy(origin, target);
var listener = sinon.stub();
target.on('event1', listener);
proxy.dispose();
origin.emit('event1', 1, 2);
assert.strictEqual(0, listener.callCount);
});
'use strict';
import EventEmitter from 'metal-events';
const emitter = new EventEmitter();
emitter.on('myEvent', (...args) => console.log(args));
debugger;
emitter.emit('myEvent', 1, 2, 3);
attachListener(eventType, fnNamesString) {
var selector = '[data-on' + eventType + '="' + fnNamesString + '"]';
this.hasListener_[selector] = true;
if (!this.eventHandles_[selector]) {
this.eventHandles_[selector] = new EventHandler();
var fnNames = fnNamesString.split(',');
for (var i = 0; i < fnNames.length; i++) {
var fn = this.component_.getListenerFn(fnNames[i]);
if (fn) {
this.eventHandles_[selector].add(this.component_.delegate(eventType, selector, this.onEvent_.bind(this, fn)));
}
}
}
}
'use strict';
import EventEmitter from 'metal-events';
const emitter = new EventEmitter();
debugger;
emitter.many('myEvent', 3, () => {});
emitter.emit('myEvent');
emitter.emit('myEvent');
emitter.emit('myEvent');
'use strict';
import EventEmitter from 'metal-events';
const emitter = new EventEmitter();
const listener = () => {};
emitter.on('myEvent', listener);
debugger;
emitter.off('myEvent', listener);
emitter.emit('myEvent', 1, 2, 3);
created() {
this.eventHandler_ = new EventHandler();
this.on('select', this.select);
}
addListenersFromObj_(obj) {
if (!this.eventsStateKeyHandler_) {
this.eventsStateKeyHandler_ = new EventHandler();
}
const handles = addListenersFromObj(this, obj);
this.eventsStateKeyHandler_.add(...handles);
}
created() {
this.eventHandler_ = new EventHandler();
}