From 343686f7454c4ece95b520fa3ddbf3ecc0198100 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 27 Sep 2018 07:24:41 -0700 Subject: [PATCH] Don't leak a file into into the global DOM Fixes #662 This never should have been in the Webamp class. It's only used for testing/screenshots. --- js/index.js | 11 +++++++++++ js/webampLazy.js | 13 ------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/js/index.js b/js/index.js index fb14b639..9bdb6420 100644 --- a/js/index.js +++ b/js/index.js @@ -27,6 +27,7 @@ import { SET_EQ_AUTO, SET_DUMMY_VIZ_DATA } from "./actionTypes"; +import { loadFilesFromReferences } from "./actionCreators"; import { skinUrl as configSkinUrl, @@ -280,6 +281,16 @@ Raven.context(() => { enableMediaSession(webamp); + const fileInput = document.createElement("input"); + fileInput.id = "webamp-file-input"; + fileInput.style.display = "none"; + fileInput.type = "file"; + fileInput.value = null; + fileInput.addEventListener("change", e => { + webamp.store.dispatch(loadFilesFromReferences(e.target.files)); + }); + document.body.appendChild(fileInput); + webamp.renderWhenReady(document.getElementById("app")); // Expose webamp instance for debugging and integration tests. diff --git a/js/webampLazy.js b/js/webampLazy.js index 7f9ce92d..afa67286 100644 --- a/js/webampLazy.js +++ b/js/webampLazy.js @@ -11,7 +11,6 @@ import { setSkinFromUrl, loadMediaFiles, setWindowSize, - loadFilesFromReferences, play, pause, seekBackward, @@ -93,18 +92,6 @@ class Winamp { type: navigator.onLine ? NETWORK_CONNECTED : NETWORK_DISCONNECTED }); - if (true) { - const fileInput = document.createElement("input"); - fileInput.id = "webamp-file-input"; - fileInput.style.display = "none"; - fileInput.type = "file"; - fileInput.value = null; - fileInput.addEventListener("change", e => { - this.store.dispatch(loadFilesFromReferences(e.target.files)); - }); - document.body.appendChild(fileInput); - } - if (zIndex != null) { this.store.dispatch({ type: SET_Z_INDEX, zIndex }); }