From a7716632d2c7ba8e62fb4ec495197c56288a7db5 Mon Sep 17 00:00:00 2001 From: Sandra Lokshina Date: Thu, 1 Aug 2019 14:45:25 -0700 Subject: [PATCH] Don't create a UI if the app already has one. If an app uses the shaka.ui.Overlay constructor to create a UI before our auto-detection code runs, they end up with two UIs one on top of the other. I personally think anyone should be grateful to get an extra UI or two, but people complain for some reason. Closes #2073. Change-Id: I793b5a7d8b5092a9b65426f5994019fde75bf957 --- ui/ui.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/ui.js b/ui/ui.js index 739abdb67..9daa0ba52 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -236,6 +236,11 @@ shaka.ui.Overlay = class { } else if (videos.length && !containers.length) { // Just the video elements were provided. for (const video of videos) { + // If the app has already manually created a UI for this element, + // don't create another one. + if (video['ui']) { + continue; + } goog.asserts.assert(video.tagName.toLowerCase() == 'video', 'Should be a video element!'); @@ -264,6 +269,11 @@ shaka.ui.Overlay = class { } } else { for (const container of containers) { + // If the app has already manually created a UI for this element, + // don't create another one. + if (container['ui']) { + continue; + } goog.asserts.assert(container.tagName.toLowerCase() == 'div', 'Container should be a div!');