diff --git a/lib/checks/color/color-contrast.js b/lib/checks/color/color-contrast.js index cd3814c6c6..101888379c 100644 --- a/lib/checks/color/color-contrast.js +++ b/lib/checks/color/color-contrast.js @@ -6,13 +6,15 @@ if (!dom.isVisible(node, false)) { const visibleText = text.visibleVirtual(virtualNode, false, true); const ignoreUnicode = !!(options || {}).ignoreUnicode; -const textContainsOnlyUnicode = !text.sanitize( - text.removeUnicode(visibleText, { - emoji: false, - nonBmp: true, - punctuations: false - }) -).length; +const textContainsOnlyUnicode = + text.hasUnicode(visibleText, { + nonBmp: true + }) && + text.sanitize( + text.removeUnicode(visibleText, { + nonBmp: true + }) + ) === ''; if (textContainsOnlyUnicode && ignoreUnicode) { this.data({ messageKey: 'nonBmp' }); diff --git a/lib/checks/color/color-contrast.json b/lib/checks/color/color-contrast.json index 2ee5d60ec8..39f32c90e6 100644 --- a/lib/checks/color/color-contrast.json +++ b/lib/checks/color/color-contrast.json @@ -1,13 +1,13 @@ { "id": "color-contrast", "evaluate": "color-contrast.js", + "options": { + "noScroll": false, + "ignoreUnicode": true, + "ignoreLength": false + }, "metadata": { "impact": "serious", - "options": { - "noScroll": false, - "ignoreUnicode": true, - "ignoreLength": false - }, "messages": { "pass": "Element has sufficient color contrast of ${data.contrastRatio}", "fail": "Element has insufficient color contrast of ${data.contrastRatio} (foreground color: ${data.fgColor}, background color: ${data.bgColor}, font size: ${data.fontSize}, font weight: ${data.fontWeight}). Expected contrast ratio of ${data.expectedContrastRatio}", diff --git a/lib/rules/color-contrast.json b/lib/rules/color-contrast.json index 6213e0abee..f9f0239820 100644 --- a/lib/rules/color-contrast.json +++ b/lib/rules/color-contrast.json @@ -2,11 +2,6 @@ "id": "color-contrast", "matches": "color-contrast-matches.js", "excludeHidden": false, - "options": { - "noScroll": false, - "ignoreUnicode": true, - "ignoreLength": false - }, "tags": ["cat.color", "wcag2aa", "wcag143"], "metadata": { "description": "Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds", diff --git a/test/integration/rules/color-contrast/color-contrast.html b/test/integration/rules/color-contrast/color-contrast.html index 7fdd144a7b..233052f382 100644 --- a/test/integration/rules/color-contrast/color-contrast.html +++ b/test/integration/rules/color-contrast/color-contrast.html @@ -219,3 +219,9 @@ Hi + +