Skip to content

Commit

Permalink
Merge pull request #76 from simonminter/master
Browse files Browse the repository at this point in the history
Use custom attribute on showmore container element, intead of aria-expanded
  • Loading branch information
tomickigrzegorz authored May 21, 2024
2 parents e2587b0 + a4661ca commit 99342e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class ShowMore {
_initial = () => {
const { element, after, ellipsis, nobutton, limit, type } = this._object;
// set default aria-expande to false
setAttributes(element, { "aria-expanded": "false" });
setAttributes(element, { "showmore-expanded": "false" });

const limitCounts = limit + after;
const ellips = ellipsis === false ? "" : "...";
Expand Down Expand Up @@ -186,8 +186,8 @@ export default class ShowMore {

if (!checkContainsClass) return;

const ariaExpanded = element.getAttribute("aria-expanded");
this._checkExp = ariaExpanded === "false";
const showMoreExpanded = element.getAttribute("showmore-expanded");
this._checkExp = showMoreExpanded === "false";

// --------------------------------------------------
// text
Expand Down Expand Up @@ -267,7 +267,7 @@ export default class ShowMore {
const ariaText = type === "table" ? type : `the ${type}`;
const lastChild = element.lastElementChild;

setAttributes(element, { "aria-expanded": this._checkExp });
setAttributes(element, { "showmore-expanded": this._checkExp });
setAttributes(target, {
"aria-expanded": this._checkExp,
"aria-label": `${aria} ${ariaText}`,
Expand Down

0 comments on commit 99342e2

Please sign in to comment.