Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hooks/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventEmitter from 'eventemitter3';

export default class extends EventEmitter {
on(eventName, elementSelector, handler) {
subscribe(eventName, elementSelector, handler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we making this change ? Is there some kind of name collusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's why some tests were failing on cornerstone. EventEmitter has method with name on

document.addEventListener(eventName, function (e) {
for (let target = e.target; target && target !== this; target = target.parentNode) {
if (target.matches(elementSelector)) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends BaseHooks {
}

itemAdd() {
this.on('submit', '[data-cart-item-add]', (event) => {
this.subscribe('submit', '[data-cart-item-add]', (event) => {
this.emit('cart-item-add', event, event.target);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/currency-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends BaseHooks {
}

currencySelector() {
this.on('input', '[data-currency-selector-toggle]', (event) => {
this.subscribe('input', '[data-currency-selector-toggle]', (event) => {
this.emit('currencySelector-toggle', event);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/faceted-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export default class extends BaseHooks {
}

searchEvents() {
this.on('click', '[data-faceted-search-facet]', (event) => {
this.subscribe('click', '[data-faceted-search-facet]', (event) => {
this.emit('facetedSearch-facet-clicked', event);
});

this.on('submit', '[data-faceted-search-range]', (event) => {
this.subscribe('submit', '[data-faceted-search-range]', (event) => {
this.emit('facetedSearch-range-submitted', event);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends BaseHooks {
}

optionsChange() {
this.on('change', '[data-product-option-change]', (event) => {
this.subscribe('change', '[data-product-option-change]', (event) => {
this.emit('product-option-change', event, event.target);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends BaseHooks {
}

quickSearch() {
this.on('input', '[data-search-quick]', (event) => {
this.subscribe('input', '[data-search-quick]', (event) => {
this.emit('search-quick', event);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/sort-by.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default class extends BaseHooks {
}

sortByEvents() {
this.on('submit', '[data-sort-by]', (event) => {
this.subscribe('submit', '[data-sort-by]', (event) => {
this.emit('sortBy-submitted', event);
});

this.on('change', '[data-sort-by] select', (event) => {
this.subscribe('change', '[data-sort-by] select', (event) => {
this.emit('sortBy-select-changed', event);

if (!event.isDefaultPrevented()) {
Expand Down