From 4459445b8ccc44de714a8bc1c2269cc92cd79878 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Sun, 10 Sep 2017 22:38:01 -0700 Subject: [PATCH] Fix accessibility sim regression when setting pin ARIA text. Fixes pxt#2894 (#533) --- libs/core/_locales/core-jsdoc-strings.json | 1 + sim/visuals/microbit.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/core/_locales/core-jsdoc-strings.json b/libs/core/_locales/core-jsdoc-strings.json index 220a5e37..c1adf164 100644 --- a/libs/core/_locales/core-jsdoc-strings.json +++ b/libs/core/_locales/core-jsdoc-strings.json @@ -45,6 +45,7 @@ "Math.pow|param|y": "The exponent value of the expression.", "Math.random": "Return a pseudorandom number between 0 and `limit`.", "Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.", + "Math.random|param|limit": "the upper bound of the number generated, eg: 4.", "Math.sign": "Returns the sign of the x, indicating whether x is positive, negative or zero.", "Math.sign|param|x": "The numeric expression to test", "Math.sqrt": "Return the square root of a number.", diff --git a/sim/visuals/microbit.ts b/sim/visuals/microbit.ts index 8dd66fe0..3cd4c9b5 100644 --- a/sim/visuals/microbit.ts +++ b/sim/visuals/microbit.ts @@ -477,10 +477,10 @@ namespace pxsim.visuals { accessibility.makeFocusable(this.pins[index]); accessibility.setAria(this.pins[index], "slider", this.pins[index].firstChild.textContent); this.pins[index].setAttribute("aria-valuemin", "0"); - this.pins[index].setAttribute("aria-valuemax", "1023"); + this.pins[index].setAttribute("aria-valuemax", pin.mode & PinFlags.Analog ? "1023" : "100"); this.pins[index].setAttribute("aria-orientation", "vertical"); - this.pins[index].setAttribute("aria-valuenow", text.textContent); - accessibility.setLiveContent(text.textContent); + this.pins[index].setAttribute("aria-valuenow", text ? text.textContent : v); + accessibility.setLiveContent(text ? text.textContent : v); } }