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

fix: STRF-8599 Passed down the target (current) element from the general subscribe event handlers #133

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

jairo-bc
Copy link
Contributor

@jairo-bc jairo-bc commented Sep 4, 2020

Some elements on the cornerstone couldn't rely on the currentTarget from the event, because .subscribe() method adds event handler on the document. So the idea is to pass down through the eventemitter not only the event, but also the currentTarget element.

@bigbot
Copy link

bigbot commented Sep 4, 2020

Autotagging @bigcommerce/storefront-team

@@ -5,7 +5,7 @@ export default class extends EventEmitter {
document.addEventListener(eventName, function (e) {
for (let target = e.target; target && target !== this; target = target.parentNode) {
if (target.matches(elementSelector)) {
handler.call(target, e);
handler.call(target, e, target);
Copy link
Contributor

Choose a reason for hiding this comment

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

so we pass target 2 times now ?

Copy link
Contributor

@junedkazi junedkazi Sep 4, 2020

Choose a reason for hiding this comment

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

should the first argument be elementSelector ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

first param is for binding this context

@jairo-bc jairo-bc requested a review from MaxGenash September 10, 2020 13:25
@junedkazi junedkazi merged commit f3d8d51 into bigcommerce:master Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants