-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(link-in-text-block): Update rule to match current guidance, revis…
…e tests (#3575) * fix: Update link-in-text-block + unit tests * Remove unintended change * Reword message Co-authored-by: Madalyn <[email protected]> * Reword message Co-authored-by: Madalyn <[email protected]> * Update templates after updating messages * Update templates (npm run build) * Split link-in-text-block into 2 checks * Use a check option for the required contrast ratio * Prefer foreground changes over background changes * Reduce noise in _templates.json * Update integration tests * Add an incomplete test * fix typo * Apply 2 suggestions from code review Co-authored-by: Wilco Fiers <[email protected]> * Fix whitespace * Exit loop early if parentBlock comes back as undefined Co-authored-by: Madalyn <[email protected]> Co-authored-by: Wilco Fiers <[email protected]>
- Loading branch information
1 parent
8a4f00d
commit edb88ed
Showing
10 changed files
with
526 additions
and
157 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 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,36 @@ | ||
import { getComposedParent } from '../../commons/dom'; | ||
import { elementIsDistinct } from '../../commons/color'; | ||
|
||
const blockLike = [ | ||
'block', | ||
'list-item', | ||
'table', | ||
'flex', | ||
'grid', | ||
'inline-block' | ||
]; | ||
function isBlock(elm) { | ||
var display = window.getComputedStyle(elm).getPropertyValue('display'); | ||
return blockLike.indexOf(display) !== -1 || display.substr(0, 6) === 'table-'; | ||
} | ||
|
||
function linkInTextBlockStyleEvaluate(node) { | ||
if (isBlock(node)) { | ||
return false; | ||
} | ||
|
||
var parentBlock = getComposedParent(node); | ||
while (parentBlock && parentBlock.nodeType === 1 && !isBlock(parentBlock)) { | ||
parentBlock = getComposedParent(parentBlock); | ||
} | ||
|
||
if (!parentBlock) { | ||
return undefined; | ||
} | ||
|
||
this.relatedNodes([parentBlock]); | ||
|
||
return elementIsDistinct(node, parentBlock); | ||
} | ||
|
||
export default linkInTextBlockStyleEvaluate; |
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,11 @@ | ||
{ | ||
"id": "link-in-text-block-style", | ||
"evaluate": "link-in-text-block-style-evaluate", | ||
"metadata": { | ||
"impact": "serious", | ||
"messages": { | ||
"pass": "Links can be distinguished from surrounding text by visual styling", | ||
"fail": "The link has no styling (such as underline) to distinguish it from the surrounding text" | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.