Skip to content

Commit

Permalink
Apply decaffeinate suggestions to Click
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Sep 12, 2023
1 parent 7f81236 commit 623ed04
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/assets/javascripts/turbograft/click.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
// The Click class handles clicked links, verifying if Turbolinks should
// take control by inspecting both the event and the link. If it should,
// the page change process is initiated. If not, control is passed back
Expand All @@ -12,7 +6,7 @@ window.Click = class Click {
static installHandlerLast(event) {
if (!event.defaultPrevented) {
document.removeEventListener('click', Click.handle, false);
return document.addEventListener('click', Click.handle, false);
document.addEventListener('click', Click.handle, false);
}
}

Expand All @@ -33,11 +27,11 @@ window.Click = class Click {
_extractLink() {
let link = this.event.target;
while (!!link.parentNode && (link.nodeName !== 'A')) { link = link.parentNode; }
if ((link.nodeName === 'A') && (link.href.length !== 0)) { return this.link = new Link(link); }
if ((link.nodeName === 'A') && (link.href.length !== 0)) { this.link = new Link(link); }
}

_validForTurbolinks() {
return (this.link != null) && !(this.link.shouldIgnore() || this._nonStandardClick());
return (this.link != null) && !this.link.shouldIgnore() && !this._nonStandardClick();
}

_nonStandardClick() {
Expand Down

0 comments on commit 623ed04

Please sign in to comment.