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.
This commit is contained in:
Jordan Eldredge 2018-09-27 07:24:41 -07:00
parent 9cef2e606a
commit 343686f745
2 changed files with 11 additions and 13 deletions

View file

@ -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.

View file

@ -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 });
}