From 8f5208cf1363a806f2984d442f1af54d28c7ac07 Mon Sep 17 00:00:00 2001 From: "stefan.r" Date: Thu, 23 Jan 2020 22:49:10 +0000 Subject: [PATCH] Deal with refNode being set to null in 2_5_3 --- .../WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js b/Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js index 5f99fa1a..152da2d6 100644 --- a/Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js +++ b/Standards/WCAG2AAA/Sniffs/Principle2/Guideline2_5/2_5_3.js @@ -55,13 +55,16 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_5_2_5_3 = { case "label": visibleLabel = HTMLCS.util.getTextContent(element); var labelFor = element.getAttribute("for"); + var refNode = undefined; if (labelFor) { if (top.ownerDocument) { - var refNode = top.ownerDocument.getElementById(labelFor); + refNode = top.ownerDocument.getElementById(labelFor); } else { - var refNode = top.getElementById(labelFor); + refNode = top.getElementById(labelFor); + } + if (!!refNode) { + accessibleName = HTMLCS.util.getAccessibleName(refNode); } - accessibleName = HTMLCS.util.getAccessibleName(refNode); } break; case "input":