From 8867db677396e1064f446cf46c93f344656a6656 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 27 Apr 2020 15:19:28 -0700 Subject: [PATCH] Fix implicit string-to-number conversions This was caught by a compiler upgrade. Issue #2528 Change-Id: Ica262703aa30dce2e59c139c88f3c1e74d5d9e2f --- lib/text/ttml_text_parser.js | 2 +- ui/range_element.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/text/ttml_text_parser.js b/lib/text/ttml_text_parser.js index b2aa7cbd04..48be4d8877 100644 --- a/lib/text/ttml_text_parser.js +++ b/lib/text/ttml_text_parser.js @@ -613,7 +613,7 @@ shaka.text.TtmlTextParser = class { const opacity = TtmlTextParser.getStyleAttribute_( cueElement, region, styles, 'opacity'); if (opacity) { - cue.opacity = opacity; + cue.opacity = parseFloat(opacity); } // Text decoration is an array of values which can come both from the diff --git a/ui/range_element.js b/ui/range_element.js index b525c61b04..15f62e804f 100644 --- a/ui/range_element.js +++ b/ui/range_element.js @@ -147,16 +147,17 @@ shaka.ui.RangeElement = class extends shaka.ui.Element { const changedTouch = /** @type {TouchEvent} */ (event).changedTouches[0]; const rect = this.bar.getBoundingClientRect(); + const min = parseFloat(this.bar.min); + const max = parseFloat(this.bar.max); // Calculate the range value based on the touch position. - let value = (this.bar.max / rect.width) * - (changedTouch.clientX - rect.left); + let value = (max / rect.width) * (changedTouch.clientX - rect.left); // Keep value within bounds. - if (value < this.bar.min) { - value = this.bar.min; - } else if (value > this.bar.max) { - value = this.bar.max; + if (value < min) { + value = min; + } else if (value > max) { + value = max; } this.bar.value = value;