move controller check into initialization

This commit is contained in:
Ilya Grigorik
2017-07-03 09:17:51 +02:00
parent 212616da72
commit 18455d521f

View File

@@ -50,6 +50,10 @@ chrome.extension.sendMessage({}, function(response) {
function defineVideoController() {
tc.videoController = function(target, parent) {
if (target.dataset['vscid']) {
return;
}
this.video = target;
this.parent = target.parentElement || parent;
this.document = target.ownerDocument;
@@ -244,9 +248,7 @@ chrome.extension.sendMessage({}, function(response) {
function checkForVideo(node, parent, added) {
if (node.nodeName === 'VIDEO') {
if (added) {
if (!node.dataset['vscid']) {
new tc.videoController(node, parent);
}
} else {
if (node.classList.contains('vsc-initialized')) {
let id = node.dataset['vscid'];