Skip to content

Commit c66bf40

Browse files
authored
fix: make compatible with chrome 53 (#8354)
1 parent 8dd98f6 commit c66bf40

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

src/js/player.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,7 @@ class Player extends Component {
31003100
Dom.copyStyleSheetsToWindow(pipWindow);
31013101
this.el_.parentNode.insertBefore(pipContainer, this.el_);
31023102

3103-
pipWindow.document.body.append(this.el_);
3103+
pipWindow.document.body.appendChild(this.el_);
31043104
pipWindow.document.body.classList.add('vjs-pip-window');
31053105

31063106
this.player_.isInPictureInPicture(true);
@@ -3110,7 +3110,7 @@ class Player extends Component {
31103110
pipWindow.addEventListener('pagehide', (event) => {
31113111
const pipVideo = event.target.querySelector('.video-js');
31123112

3113-
pipContainer.replaceWith(pipVideo);
3113+
pipContainer.parentNode.replaceChild(pipVideo, pipContainer);
31143114
this.player_.isInPictureInPicture(false);
31153115
this.player_.trigger('leavepictureinpicture');
31163116
});

src/js/tracks/text-track-display.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ class TextTrackDisplay extends Component {
324324
* a {@link Player#texttrackchange} or a {@link Player#fullscreenchange} is fired.
325325
*/
326326
updateDisplayOverlay() {
327-
if (!this.player_.videoHeight()) {
327+
// inset-inline and inset-block are not supprted on old chrome, but these are
328+
// only likely to be used on TV devices
329+
if (!this.player_.videoHeight() || !window.CSS.supports('inset-inline: 10px')) {
328330
return;
329331
}
330332

src/js/video.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function videojs(id, options, ready) {
151151
// If the document is no longer attached to the dom, the defaultView of the document will be null.
152152
// If element is inside Shadow DOM (e.g. is part of a Custom element), ownerDocument.body
153153
// always returns false. Instead, use the Shadow DOM root.
154-
const inShadowDom = el.getRootNode() instanceof window.ShadowRoot;
154+
const inShadowDom = 'getRootNode' in el ? el.getRootNode() instanceof window.ShadowRoot : false;
155155
const rootNode = inShadowDom ? el.getRootNode() : el.ownerDocument.body;
156156

157157
if (!el.ownerDocument.defaultView || !rootNode.contains(el)) {

test/unit/player.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,7 +2848,7 @@ QUnit.test('document pictureinpicture is opt-in', function(assert) {
28482848

28492849
player.requestPictureInPicture().catch(e => {
28502850
assert.equal(e, 'No PiP mode is available', 'docPiP not used when not enabled');
2851-
}).finally(_ => {
2851+
}).then(_ => {
28522852
if (window.documentPictureInPicture === testPiPObj) {
28532853
delete window.documentPictureInPicture;
28542854
}
@@ -2888,7 +2888,7 @@ QUnit.test('docPiP is used in preference to winPiP', function(assert) {
28882888
assert.ok(true, 'docPiP was called');
28892889
}).catch(_ => {
28902890
assert.ok(true, 'docPiP was called');
2891-
}).finally(_ => {
2891+
}).then(_ => {
28922892
assert.equal(0, count, 'requestPictureInPicture not passed to tech');
28932893
if (window.documentPictureInPicture === testPiPObj) {
28942894
delete window.documentPictureInPicture;

test/unit/tracks/text-track-display.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ if (!Html5.supportsNativeTextTracks()) {
450450
);
451451
});
452452

453-
QUnit.test('text track display should overlay a video', function(assert) {
453+
const skipOnOldChrome = window.CSS.supports('inset-inline: 10px') ? 'test' : 'skip';
454+
455+
QUnit[skipOnOldChrome]('text track display should overlay a video', function(assert) {
454456
const tag = document.createElement('video');
455457

456458
tag.width = 320;

test/unit/utils/custom-element.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export class TestCustomElement extends HTMLElement {
2323
}
2424
}
2525

26-
window.customElements.define('test-custom-element', TestCustomElement);
26+
// Not supported on Chrome < 54
27+
if ('customElements' in window) {
28+
window.customElements.define('test-custom-element', TestCustomElement);
29+
}

test/unit/video.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import videojs from '../../src/js/video.js';
33
import * as Dom from '../../src/js/utils/dom.js';
44
import log from '../../src/js/utils/log.js';
55
import document from 'global/document';
6+
import window from 'global/window';
67
import sinon from 'sinon';
78
// import custom element for Shadow DOM test
89
import './utils/custom-element.test';
@@ -86,7 +87,9 @@ QUnit.test(
8687
}
8788
);
8889

89-
QUnit.test(
90+
const skipWithoutCustomElements = 'customElements' in window ? 'test' : 'skip';
91+
92+
QUnit[skipWithoutCustomElements](
9093
'should not log if the supplied element is included in the Shadow DOM',
9194
function(assert) {
9295
const origWarnLog = log.warn;

0 commit comments

Comments
 (0)