You can use /sandbox/ for writing and testing your own code. Nothing in /sandbox/ will get checked into the repo, except files that end in .example (so don't edit or add those files). To get started run `npm start` and open the index.html
+
npm start
+
open http://localhost:9999/sandbox/index.html
+
+
+
Tap on video to play/pause
+
+
+
+
+
+
+
diff --git a/src/css/components/_captions-settings.scss b/src/css/components/_captions-settings.scss
index 8fa89452d..8c36ed82b 100644
--- a/src/css/components/_captions-settings.scss
+++ b/src/css/components/_captions-settings.scss
@@ -53,6 +53,10 @@
}
// Form elements
+.vjs-text-track-settings select {
+ font-size: inherit;
+}
+
.vjs-track-setting > select {
margin-right: 1em;
margin-bottom: 0.5em;
@@ -65,7 +69,7 @@
.vjs-text-track-settings fieldset span {
display: inline-block;
- padding: 0 6px 8px;
+ padding: 0 .6em .8em;
}
// style the second select for text colors
@@ -76,17 +80,11 @@
.vjs-text-track-settings legend {
color: $primary-foreground-color;
font-weight: bold;
- font-size: 14px;
+ font-size: 1.2em;
}
.vjs-text-track-settings .vjs-label {
- clip: rect(1px 1px 1px 1px); // for Internet Explorer
- clip: rect(1px, 1px, 1px, 1px);
- margin: 0 5px 5px 0;
- border: 0;
- height: 1px;
- width: 1px;
- overflow: hidden;
+ margin: 0 .5em .5em 0;
}
.vjs-track-settings-controls button:focus,
diff --git a/src/css/components/_loading.scss b/src/css/components/_loading.scss
index 7dbee7da6..a88508431 100644
--- a/src/css/components/_loading.scss
+++ b/src/css/components/_loading.scss
@@ -3,20 +3,20 @@
position: absolute;
top: 50%;
left: 50%;
- margin: -25px 0 0 -25px;
+ transform: translate(-50%, -50%);
opacity: 0.85;
// Need to fix centered page layouts
text-align: left;
- border: 6px solid rgba($primary-background-color, $primary-background-transparency);
+ border: .6em solid rgba($primary-background-color, $primary-background-transparency);
// border: 6px solid rgba(43, 51, 63, 0.5);
box-sizing: border-box;
background-clip: padding-box;
- width: 50px;
- height: 50px;
- border-radius: 25px;
+ width: 5em;
+ height: 5em;
+ border-radius: 50%;
visibility: hidden;
}
@@ -31,7 +31,7 @@
.vjs-loading-spinner:after {
content: "";
position: absolute;
- margin: -6px;
+ margin: -0.6em;
box-sizing: inherit;
width: inherit;
height: inherit;
diff --git a/src/js/video.js b/src/js/video.js
index 2734cf08d..12a3d8235 100644
--- a/src/js/video.js
+++ b/src/js/video.js
@@ -149,7 +149,12 @@ function videojs(id, options, ready) {
// This will make sure that the element is indeed in the dom of that document.
// Additionally, check that the document in question has a default view.
// If the document is no longer attached to the dom, the defaultView of the document will be null.
- if (!el.ownerDocument.defaultView || !el.ownerDocument.body.contains(el)) {
+ // If element is inside Shadow DOM (e.g. is part of a Custom element), ownerDocument.body
+ // always returns false. Instead, use the Shadow DOM root.
+ const inShadowDom = el.getRootNode() instanceof window.ShadowRoot;
+ const rootNode = inShadowDom ? el.getRootNode() : el.ownerDocument.body;
+
+ if (!el.ownerDocument.defaultView || !rootNode.contains(el)) {
log.warn('The element supplied is not included in the DOM');
}
diff --git a/test/unit/utils/custom-element.test.js b/test/unit/utils/custom-element.test.js
new file mode 100644
index 000000000..a60f793da
--- /dev/null
+++ b/test/unit/utils/custom-element.test.js
@@ -0,0 +1,26 @@
+/* eslint-env browser */
+import videojs from '../../../src/js/video.js';
+
+export class TestCustomElement extends HTMLElement {
+
+ constructor() {
+ super();
+
+ const shadowRoot = this.attachShadow({ mode: 'closed' });
+
+ const containerElem = document.createElement('div');
+
+ containerElem.setAttribute('data-vjs-player', '');
+ shadowRoot.appendChild(containerElem);
+
+ const videoElem = document.createElement('video');
+
+ videoElem.setAttribute('width', 640);
+ videoElem.setAttribute('height', 260);
+ containerElem.appendChild(videoElem);
+
+ this.innerPlayer = videojs(videoElem);
+ }
+}
+
+window.customElements.define('test-custom-element', TestCustomElement);
diff --git a/test/unit/video.test.js b/test/unit/video.test.js
index 2b041b9ba..327437b0d 100644
--- a/test/unit/video.test.js
+++ b/test/unit/video.test.js
@@ -4,6 +4,8 @@ import * as Dom from '../../src/js/utils/dom.js';
import log from '../../src/js/utils/log.js';
import document from 'global/document';
import sinon from 'sinon';
+// import custom element for Shadow DOM test
+import './utils/custom-element.test';
QUnit.module('video.js', {
beforeEach() {
@@ -84,6 +86,29 @@ QUnit.test(
}
);
+QUnit.test(
+ 'should not log if the supplied element is included in the Shadow DOM',
+ function(assert) {
+ const origWarnLog = log.warn;
+ const fixture = document.getElementById('qunit-fixture');
+ const warnLogs = [];
+
+ log.warn = (args) => {
+ warnLogs.push(args);
+ };
+
+ const customElem = document.createElement('test-custom-element');
+
+ fixture.appendChild(customElem);
+ const innerPlayer = customElem.innerPlayer;
+
+ assert.ok(innerPlayer, 'created player within Shadow DOM');
+ assert.equal(warnLogs.length, 0, 'no warn logs');
+
+ log.warn = origWarnLog;
+ }
+);
+
QUnit.test(
'should log about already initialized players if options already passed',
function(assert) {
diff --git a/tsconfig.json b/tsconfig.json
index 46c83a27a..1311702d2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,7 +8,6 @@
"declarationMap": true,
"skipLibCheck": true,
"checkJs": false,
- "preserveWatchOutput": true,
- "resolveJsonModule": true
+ "preserveWatchOutput": true
}
}
\ No newline at end of file