Skip to content

Commit

Permalink
Fix implicit string-to-number conversions
Browse files Browse the repository at this point in the history
This was caught by a compiler upgrade.

Issue shaka-project#2528

Change-Id: Ica262703aa30dce2e59c139c88f3c1e74d5d9e2f
  • Loading branch information
joeyparrish committed Apr 28, 2020
1 parent fb0d819 commit 8867db6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/text/ttml_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions ui/range_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8867db6

Please sign in to comment.