Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggering event with custom data is not propagated correctly #1064

Closed
bankyadam opened this issue Dec 11, 2018 · 4 comments
Closed

Triggering event with custom data is not propagated correctly #1064

bankyadam opened this issue Dec 11, 2018 · 4 comments
Labels

Comments

@bankyadam
Copy link

Version

1.0.0-beta.26

Reproduction link

https://gist.github.com/bankyadam/e10442e3fabac607882ced63ab8c4a05

Steps to reproduce

Run example test with beta.26 or newer.

What is expected?

Test passes

What is actually happening?

Test fails


I found out that Wrapper.prototype.trigger() does not apply the given options object on the eventObject since the logic was extracted into createDOMEvent() and we're not running in IE (8771b8f).

@bankyadam
Copy link
Author

bankyadam commented Dec 11, 2018

Additional information about the running environment:
NodeJS: 10.13.0
vue: 2.5.20
mocha: 5.2.0

Failing:

  !

  0 passing (85ms)
  1 failing

  1) issue
       fails:
     AssertionError: expected { isTrusted: [Getter],
  composedPath: [Function: composedPath],
  stopPropagation: [Function: stopPropagation],
  stopImmediatePropagation: [Function: stopImmediatePropagation],
  preventDefault: [Function: preventDefault],
  initEvent: [Function: initEvent],
  type: 'update',
  target: <button>Label</button>,
  srcElement: <button>Label</button>,
  currentTarget: null,
  eventPhase: 0,
  cancelBubble: false,
  bubbles: true,
  cancelable: true,
  returnValue: true,
  defaultPrevented: false,
  composed: false,
  timeStamp: 1544520161202,
  NONE: 0,
  CAPTURING_PHASE: 1,
  AT_TARGET: 2,
  BUBBLING_PHASE: 3 } to have property 'detail'
      at Context.<anonymous> (dist/webpack:/src/issue.spec.js:8:1)

@eddyerburgh
Copy link
Member

@blake-newman Are you able to add support for this?

@bankyadam
Copy link
Author

I don't know if we expect window.Event to add our custom properties on the constructed event object or not.

  • If we DO, than this fix should belong to jsdom instead of @vue/test-utils.
  • If we DO NOT, than we should iterate over the constructed event object and add the extra option properties like we do for IE now.

@hmsk
Copy link

hmsk commented Dec 19, 2018

Also, some native events don't work as like before.
For example,

wrapper.find('.something').trigger('drop', { dataTransfer: 'data' });

doesn't give option values for the emit logs, since new DragEvent('drop', { dataTransfer: 'data' }) doesn't work to give dataTransfer.

This is a bit different from the problem for update custom event on this issue. But hope will be addressed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants