Skip to content

V4 without jquery: fix tests#23981

Merged
Johann-S merged 1 commit intotwbs:v4-without-jqueryfrom
alekitto:v4-without-jquery
Sep 18, 2017
Merged

V4 without jquery: fix tests#23981
Johann-S merged 1 commit intotwbs:v4-without-jqueryfrom
alekitto:v4-without-jquery

Conversation

@alekitto
Copy link
Copy Markdown
Contributor

Related to #23586 (comment)
There were a couple of buggy tests for IE 11:

  • trying to fire a click on an element not added to the DOM does not produce any effect
  • defaultPrevented does not work for code-generated events

Comment thread js/tests/unit/modal.js
var evt = new CustomEvent('click', {
bubbles: true,
cancelable: true
})
Copy link
Copy Markdown
Member

@Johann-S Johann-S Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why previously I asked you to use EventHandler in our unit test 😉 which correct the buggy preventDefault from IE, can you give it a try please ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to use EventHandler.trigger instead of creating a CustomEvent object, but preventDefault produces the same buggy result. Trying to replace the preventDefault in an HTMLEvents object works on IE, but breaks in phantom. This is the only working solution for all the browsers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's weird I didn't see that issue in our other plugins without jQuery

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only test for the defaultPrevented property for a non-jQuery event by now. In other tests trigger is used to emit the event (which works correctly), but the Event object is discarded and never checked. 

@Johann-S Johann-S merged commit c342396 into twbs:v4-without-jquery Sep 18, 2017
@alekitto
Copy link
Copy Markdown
Contributor Author

@Johann-S Now Edge is broken.. workin' on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants