-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #635 from equalizedigital/william/634/convert-text…
…_justified-rule-to-JS-check Convert text_justified rule to a JS rule
- Loading branch information
Showing
5 changed files
with
42 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Axe core check for elements that are aligned to justify. | ||
* | ||
* @param {Node} node The node to evaluate. | ||
* @return {boolean} True if the node is justified, false otherwise. | ||
*/ | ||
|
||
export default { | ||
id: 'text_is_justified', | ||
evaluate: ( node ) => { | ||
const style = window.getComputedStyle( node ); | ||
return style.textAlign.toLowerCase() === 'justify'; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Rule: Text Justified | ||
* | ||
* Text elements should not be justified because it interferes with readability. | ||
*/ | ||
|
||
const TEXT_JUSTIFIED_CHECK_THRESHOLD = 200; | ||
export default { | ||
id: 'text_justified', | ||
selector: 'p, span, small, strong, b, i, em, h1, h2, h3, h4, h5, h6, a, label, button, th, td, li, div, blockquote, address, cite, q, s, sub, sup, u, del, caption, dt, dd, figcaption, summary, data, time', | ||
matches: ( element ) => { | ||
return element.textContent.trim().length >= TEXT_JUSTIFIED_CHECK_THRESHOLD; | ||
}, | ||
tags: [ 'wcag2aaa', 'wcag148', 'cat.text', 'custom' ], | ||
metadata: { | ||
description: 'Text elements inside containers should not be justified.', | ||
}, | ||
all: [], | ||
any: [], | ||
none: [ 'text_is_justified' ], | ||
}; |