Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,12 @@
_ariaChecked: function () {
var dotElems = this.$.container.querySelectorAll('.slider__dot');
if (dotElems.length > 0) {
for (var i = 0; i < this.totalSlides; i++) {
for (var i = 0; i < dotElems.length; i++) {
dotElems[i].setAttribute("aria-checked", "false");
};

Check warning on line 377 in src/main/resources/META-INF/resources/frontend/paper-slider/l2t-paper-slider.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Expected a `for-of` loop instead of a `for` loop with this simple iteration.

See more on https://sonarcloud.io/project/issues?id=FlowingCode_CarouselAddon&issues=AZ3-LI4BkzfUE8jh3PVs&open=AZ3-LI4BkzfUE8jh3PVs&pullRequest=51
dotElems[this.position].setAttribute("aria-checked", "true");
if (this.position < dotElems.length) {
dotElems[this.position].setAttribute("aria-checked", "true");
}
}
},

Expand Down Expand Up @@ -478,13 +480,17 @@
_moveManual: function () {
var this$ = this;
var dotElems = this.$.container.querySelectorAll('.slider__dot'), i;
for (i = 0; i < this.totalSlides; ++i) {
for (i = 0; i < dotElems.length; ++i) {
dotElems[i].setAttribute("aria-label", "Slide " + parseInt(dotElems[i].getAttribute('aria-posinset')) + " selector");
dotElems[i].addEventListener('click', function (e) {
this$.movePos(e.target.getAttribute('aria-posinset') - 1);
});
};
if (this.totalSlides) {
if (!this._dotClickListener) {
this._dotClickListener = function (e) {
const dot = e.target.closest('.slider__dot');
if (dot) this$.movePos(Number.parseInt(dot.getAttribute('aria-posinset'), 10) - 1);
};
Comment thread
paodb marked this conversation as resolved.
this.$.container.addEventListener('click', this._dotClickListener);
}
if (dotElems.length) {
this._dotStyles = window.getComputedStyle(dotElems[0]);
}
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -540,14 +546,13 @@
*/
_spaceCatcher: function (e) {
e.preventDefault();
if (this.shadowRoot != null) {
var nextPos = this.shadowRoot.activeElement.getAttribute('aria-posinset');
const activeEl = this.shadowRoot && this.shadowRoot.activeElement;

Check warning on line 549 in src/main/resources/META-INF/resources/frontend/paper-slider/l2t-paper-slider.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=FlowingCode_CarouselAddon&issues=AZ3-LI4BkzfUE8jh3PVt&open=AZ3-LI4BkzfUE8jh3PVt&pullRequest=51
if (activeEl) {
const nextPos = activeEl.getAttribute('aria-posinset');
if (nextPos) this.movePos(Number.parseInt(nextPos, 10) - 1);
} else {
var nextPos = document.activeElement.getAttribute('aria-posinset');
this.movePos((this.position + 1) % this.totalSlides);
}
if (!nextPos)
return;
this.movePos(parseInt(nextPos) - 1);
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
Expand Down Expand Up @@ -657,6 +662,10 @@
detached: function() {
this.autoProgress = false;
removeListener(this.$.container, 'track', e => this._swipeHandler(e));
if (this._dotClickListener) {
this.$.container.removeEventListener('click', this._dotClickListener);
this._dotClickListener = null;
}
},

_increment: function(n) {
Expand Down
Loading