From 3cbbba7940c7f40fe0fe5bad66f18dd4c6663416 Mon Sep 17 00:00:00 2001 From: Martin B Date: Thu, 20 Apr 2017 14:28:02 +0100 Subject: [PATCH 1/4] Only update mode if changed --- .../text-track-controls/text-track-menu-item.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/control-bar/text-track-controls/text-track-menu-item.js b/src/js/control-bar/text-track-controls/text-track-menu-item.js index 42a7dcc87d..9ac89606cc 100644 --- a/src/js/control-bar/text-track-controls/text-track-menu-item.js +++ b/src/js/control-bar/text-track-controls/text-track-menu-item.js @@ -101,9 +101,13 @@ class TextTrackMenuItem extends MenuItem { const track = tracks[i]; if (track === this.track && (kinds.indexOf(track.kind) > -1)) { - track.mode = 'showing'; + if (track.mode !== 'showing') { + track.mode = 'showing'; + } } else { - track.mode = 'disabled'; + if (track.mode !== 'disabled') { + track.mode = 'disabled'; + } } } } From b432e7d7846a0cf29e8710c9b86f6bf07389a53b Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Mon, 8 May 2017 16:48:51 -0400 Subject: [PATCH 2/4] Consolidate if statements and fix linter error. --- .../text-track-controls/text-track-menu-item.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/js/control-bar/text-track-controls/text-track-menu-item.js b/src/js/control-bar/text-track-controls/text-track-menu-item.js index 9ac89606cc..c42df7c451 100644 --- a/src/js/control-bar/text-track-controls/text-track-menu-item.js +++ b/src/js/control-bar/text-track-controls/text-track-menu-item.js @@ -100,14 +100,10 @@ class TextTrackMenuItem extends MenuItem { for (let i = 0; i < tracks.length; i++) { const track = tracks[i]; - if (track === this.track && (kinds.indexOf(track.kind) > -1)) { - if (track.mode !== 'showing') { - track.mode = 'showing'; - } - } else { - if (track.mode !== 'disabled') { - track.mode = 'disabled'; - } + if (track === this.track && (kinds.indexOf(track.kind) > -1) && track.mode !== 'showing') { + track.mode = 'showing'; + } else if (track.mode !== 'disabled') { + track.mode = 'disabled'; } } } From 54839def246c0fefc487524e95712ef323127ca5 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 9 May 2017 10:57:33 -0400 Subject: [PATCH 3/4] Revert one half of if-consolidation --- .../control-bar/text-track-controls/text-track-menu-item.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/control-bar/text-track-controls/text-track-menu-item.js b/src/js/control-bar/text-track-controls/text-track-menu-item.js index c42df7c451..5e71a55651 100644 --- a/src/js/control-bar/text-track-controls/text-track-menu-item.js +++ b/src/js/control-bar/text-track-controls/text-track-menu-item.js @@ -100,8 +100,10 @@ class TextTrackMenuItem extends MenuItem { for (let i = 0; i < tracks.length; i++) { const track = tracks[i]; - if (track === this.track && (kinds.indexOf(track.kind) > -1) && track.mode !== 'showing') { - track.mode = 'showing'; + if (track === this.track && (kinds.indexOf(track.kind) > -1)) { + if (track.mode !== 'showing) { + track.mode = 'showing'; + } } else if (track.mode !== 'disabled') { track.mode = 'disabled'; } From 070d75eda6e9bf6984d4d610d65d70e1d7669278 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 9 May 2017 10:57:55 -0400 Subject: [PATCH 4/4] and put back the quote --- src/js/control-bar/text-track-controls/text-track-menu-item.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/control-bar/text-track-controls/text-track-menu-item.js b/src/js/control-bar/text-track-controls/text-track-menu-item.js index 5e71a55651..448b8c8756 100644 --- a/src/js/control-bar/text-track-controls/text-track-menu-item.js +++ b/src/js/control-bar/text-track-controls/text-track-menu-item.js @@ -101,7 +101,7 @@ class TextTrackMenuItem extends MenuItem { const track = tracks[i]; if (track === this.track && (kinds.indexOf(track.kind) > -1)) { - if (track.mode !== 'showing) { + if (track.mode !== 'showing') { track.mode = 'showing'; } } else if (track.mode !== 'disabled') {