aboutsummaryrefslogtreecommitdiff
path: root/src/app/browser.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-03-22 19:49:01 +0100
committer0neGal <mail@0negal.com>2022-03-22 19:59:45 +0100
commit0879494e67a278e122fbb5d153fe9bdc156cab88 (patch)
treec83f4cc60471b0d81bafbba90ff986bcf986c301 /src/app/browser.js
parent5932eb6799f13bc16bf93e170611f0f4f8c4c793 (diff)
downloadViper-0879494e67a278e122fbb5d153fe9bdc156cab88.tar.gz
Viper-0879494e67a278e122fbb5d153fe9bdc156cab88.zip
fixed potential edge case
If a mod has the name of an already existing element some issues may arise... So now we have all mod elements prefixed with "mod-" and we also only search for elements inside #browserEntries, that should avoid all issues...
Diffstat (limited to 'src/app/browser.js')
-rw-r--r--src/app/browser.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index 275e16e..8a8c6e4 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -70,15 +70,15 @@ var Browser = {
},
setbutton: (mod, string) => {
mod = normalize(mod);
- if (document.getElementById(mod)) {
- let elems = document.querySelectorAll(`#${mod}`);
+ if (browserEntries.querySelector(`#mod-${mod}`)) {
+ let elems = browserEntries.querySelectorAll(`.el#mod-${mod}`);
for (let i = 0; i < elems.length; i++) {
elems[i].querySelector(".text button").innerHTML = string;
}
} else {
let make = (str) => {
- if (document.getElementById(str)) {
+ if (browserEntries.querySelector(`#mod-${str}`)) {
return Browser.setbutton(str, string);
} else {
return false;
@@ -170,7 +170,7 @@ function BrowserEl(properties) {
}
browserEntries.innerHTML += `
- <div class="el" id="${normalize(properties.title)}">
+ <div class="el" id="mod-${normalize(properties.title)}">
<div class="image">
<img src="${properties.image}">
</div>