-
Notifications
You must be signed in to change notification settings - Fork 184
Should not opened in window if the default behavior was prevented inside the event handler (for #5910 in TestCafe) #2582
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
Conversation
if (!settings.get().allowMultipleWindows) | ||
return; | ||
|
||
window.addEventListener('click', e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a native method for addEventListener
method here.
@LavrovArtem if it's possible add this method to eslint-plugin-hammerhead
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR is still in DRAFT. I discussed this approach with @LavrovArtem and we decided to modify it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready, please review
@@ -29,6 +29,7 @@ export function addListeningElement (el, events) { | |||
internalHandlers: [], | |||
outerHandlers: [], | |||
outerHandlersWrapper: null, | |||
postHandlers: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this name because it can be understood in several ways.
It's internal hammerhead handlers, which are called last.
I guess, the internalHandlers
are handlers which are called before users' scripts.
So, I propose to clean up the code and perform some renames:
internalHandlers -> internalBeforeHanlders
postHandlers -> internlaAfterHanlders
@LavrovArtem What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this suggestion
Tests in TestCafe failed since TestCafe requires update as well: |
New mechanism of
postHandlers
which will be called after all user handlers are called.This mechanism allows us to prevent opening of new window in multiple window mode, if the event was prevented inside on the user listeners