@@ -37,7 +37,7 @@ shaka.ui.PresentationTimeTracker = class extends shaka.ui.Element {
3737
3838 this . currentTime_ = shaka . util . Dom . createHTMLElement ( 'button' ) ;
3939 this . currentTime_ . classList . add ( 'shaka-current-time' ) ;
40- this . currentTime_ . textContent = '0:00' ;
40+ this . setValue_ ( '0:00' ) ;
4141 this . parent . appendChild ( this . currentTime_ ) ;
4242
4343 this . eventManager . listen ( this . currentTime_ , 'click' , ( ) => {
@@ -56,10 +56,18 @@ shaka.ui.PresentationTimeTracker = class extends shaka.ui.Element {
5656 } ) ;
5757 }
5858
59+ /** @private */
60+ setValue_ ( value ) {
61+ // To avoid constant updates to the DOM, which makes debugging more
62+ // difficult, only set the value if it has changed. If we don't do this
63+ // check, the DOM updates constantly, this element flashes in the debugger
64+ // in Chrome, and you can't make changes in the CSS panel.
65+ if ( value != this . currentTime_ . textContent ) {
66+ this . currentTime_ . textContent = value ;
67+ }
68+ }
5969
60- /**
61- * @private
62- */
70+ /** @private */
6371 updateTime_ ( ) {
6472 const isSeeking = this . controls . isSeeking ( ) ;
6573 let displayTime = this . controls . getDisplayTime ( ) ;
@@ -80,24 +88,21 @@ shaka.ui.PresentationTimeTracker = class extends shaka.ui.Element {
8088 // The button should only be clickable when it's live stream content, and
8189 // the current play time is behind live edge.
8290 if ( ( displayTime >= 1 ) || isSeeking ) {
83- this . currentTime_ . textContent =
84- '- ' + this . buildTimeString_ ( displayTime , showHour ) ;
91+ this . setValue_ ( '- ' + this . buildTimeString_ ( displayTime , showHour ) ) ;
8592 this . currentTime_ . disabled = false ;
8693 } else {
87- this . currentTime_ . textContent =
88- this . localization . resolve ( shaka . ui . Locales . Ids . LIVE ) ;
94+ this . setValue_ ( this . localization . resolve ( shaka . ui . Locales . Ids . LIVE ) ) ;
8995 this . currentTime_ . disabled = true ;
9096 }
9197 } else {
9298 const showHour = duration >= 3600 ;
9399
94- this . currentTime_ . textContent =
95- this . buildTimeString_ ( displayTime , showHour ) ;
96-
100+ let value = this . buildTimeString_ ( displayTime , showHour ) ;
97101 if ( duration ) {
98- this . currentTime_ . textContent += ' / ' +
102+ value += ' / ' +
99103 this . buildTimeString_ ( duration , showHour ) ;
100104 }
105+ this . setValue_ ( value ) ;
101106 this . currentTime_ . disabled = true ;
102107 }
103108 }
0 commit comments