ember-native-dom-helpers icon indicating copy to clipboard operation
ember-native-dom-helpers copied to clipboard

Options object not included in the event object for the change event for file selector.

Open simpleclicks opened this issue 7 years ago • 1 comments
trafficstars

When I send in the options through the trigger event for the 'change' event on the file input selector, buildFileEvent gets called and the function does not include the options with the event object returned.

function buildFileEvent(type, element, files = []) {
  let event = buildBasicEvent(type);

  if (files.length > 0) {
    Object.defineProperty(files, 'item', {
      value(index) {
        return typeof index === 'number' ? this[index] : null;
      }
    });
    Object.defineProperty(element, 'files', {
      value: files
    });
  }

  Object.defineProperty(event, 'target', {
    value: element
  });

  return event;
}

simpleclicks avatar Apr 09 '18 20:04 simpleclicks

If you are able to, I'd recommend stop using the triggerEvent from this addon and instead use the one in @ember/test-helpers (note: It required ember-cli-qunit 4.3 or greater). The helpers in this addon have been copied there and perfected, so this one will soon be deprecated.

cibernox avatar Apr 09 '18 20:04 cibernox