Example #1
0
function dispatchEvent(eventTarget, type, params) {
  if (type === 'timeout') {
    eventTarget.requestError = true;
  }

  var assign = require('lodash-compat/object/assign');
  var includes = require('lodash-compat/collection/includes');
  var event;

  if (includes(support.xdr.eventObjects, type)) {
    params = params || {};

    event = new Event(type, {
      bubbles: params.bubbles,
      cancelable: params.cancelable
    });

    // target and currentTarget are always `null` on IE8/9 on XDomainRequest
    // if you find a case where it's not, show me
    event.target = null;
    event.currentTarget = null;

    assign(event, params);

    event.eventPhase = Event.AT_TARGET;
  } else {
    event = type;
  }

  eventTarget.dispatchEvent(event);
}
Example #2
0
var eventPhases = {
  NONE: 0,
  CAPTURING_PHASE: 1,
  AT_TARGET: 2,
  BUBBLING_PHASE: 3
};

// https://dom.spec.whatwg.org/#event
function Event(type, eventInitDict) {
  this.type = type;
  this.bubbles = eventInitDict.bubbles;
  this.cancelable = eventInitDict.cancelable;

  this.target = null;
  this.currentTarget = null;
  this.eventPhase = eventPhases.NONE;

  this.timestamp = now();
}

Event.prototype.stopPropagation = function() {

};

Event.prototype.preventDefault = function() {
  this.defaultPrevented = true;
};

assign(Event, eventPhases);
assign(Event.prototype, eventPhases);
  return request.post('/consoles.json', { console: requestBody, bite: requestBody }).then(function(response) {
    self.attributes = assign(self.attributes, utils.camelizeAttributes(response.body));
    self.set('embedURL', response.body.url);

    return self;
  });
function Console(attributes) {
  this.attributes = assign({}, utils.camelizeAttributes(attributes));
}