From 4f0620876287b8f6bd04113e0a46b785aa8d3236 Mon Sep 17 00:00:00 2001 From: zepumph Date: Tue, 17 Mar 2020 18:03:15 -0800 Subject: [PATCH] aria-valuetext should appear right after element in a11y view, https://github.com/phetsims/chipper/issues/896 --- sun_a11y_view.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sun_a11y_view.html b/sun_a11y_view.html index 59704c46..78e71a05 100644 --- a/sun_a11y_view.html +++ b/sun_a11y_view.html @@ -389,7 +389,9 @@

PDOM & Descriptions for sun demo

valueTextElement.className = "pdom-style"; valueTextElement.style.opacity = 0.55; valueTextElement.textContent = element.getAttribute( 'aria-valuetext' ); - element.parentNode.appendChild( valueTextElement ); + + // insert directly after the element that has the valuetext. This handles the case if element is last, see https://stackoverflow.com/questions/4793604/how-to-insert-an-element-after-another-element-in-javascript-without-using-a-lib + element.parentNode.insertBefore( valueTextElement, element.nextSibling ); } } }