Skip to content

Commit

Permalink
fix: fixed metadata of resize-reflow-textoverflow custom rule (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaig-0911 authored Oct 18, 2024
1 parent c2f4e71 commit 2da71dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/preset-rules/src/custom-rules/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const checkData = [
{
id: 'Resize-reflow-textoverflow-check',
evaluate:
"function (node) {const style = window.getComputedStyle(node); const tabIndex = node.getAttribute('tabindex'); if (tabIndex === '-1' && node.actualNode && !isVisibleOnScreen(node) && !isVisibleToScreenReaders(node)) { return false; } if (node.innerText === '') { return false; } if (style.getPropertyValue('text-overflow') === 'ellipsis') { function isTextTruncated(element) {const isTruncated = (element.scrollWidth > element.clientWidth); return isTruncated; } return !isTextTruncated(node); } return true; }",
"function (node) {const style = window.getComputedStyle(node); const tabIndex = node.getAttribute('tabindex'); if (tabIndex === '-1' && node.actualNode && !isVisibleOnScreen(node) && !isVisibleToScreenReaders(node)) { return false; } if (!node.innerText ===\"\") { return false; } if (style.getPropertyValue('text-overflow') === 'ellipsis') { function isTextTruncated(element) {const isTruncated = (element.scrollWidth > element.clientWidth); return isTruncated; } return !isTextTruncated(node); } if (style.getPropertyValue('display') === '-webkit-box' && style.getPropertyValue('-webkit-line-clamp') != 0 && style.getPropertyValue('overflow') === 'hidden' && style.getPropertyValue('-webkit-box-orient') === 'vertical') { function isTextTruncated(element) { const isTruncated = (element.scrollWidth>element.clientWidth); return isTruncated; } return !isTextTruncated(node); } return true; }",
metadata: {
impact: 'moderate',
messages: {
Expand Down
10 changes: 8 additions & 2 deletions packages/preset-rules/src/custom-rules/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ const rulesData = [
},
{
id: 'Resize-reflow-textoverflow',
selector: '*', // Target all <img> elements
selector: '*',
enabled: true,
any: ['Resize-reflow-textoverflow-check'],
all: [],
tags: ['custom'],
metadata: {
description: 'Ensure Ellipses are not present as text is truncated.',
help: 'Text elements do not have ellipsis as text is truncated.',
helpUrl: 'https://example.com/custom-rule-help',
impact: 'moderate',
tags: ['wcag1410', 'custom'],
},
},
];

Expand Down

0 comments on commit 2da71dd

Please sign in to comment.