fix: locale bug; didn't reverse on remove

This commit is contained in:
Strix 2023-12-24 03:17:39 +01:00
parent 32458c7fd4
commit 4dd1cf209b
No known key found for this signature in database
GPG key ID: 5F35B3B8537287A7
3 changed files with 10 additions and 6 deletions

View file

@ -1,6 +1,8 @@
// [x-copy-query="<query selector>"]
// [x-inner-text] - will use innerText
(() => {
// TODO: make copy work with checksums because not uuid will not always cut it.
function updateCopy() {
document.querySelectorAll("[x-copy-query]:not([x1-copy-uuid])")
.forEach(e => {

View file

@ -11,9 +11,9 @@
function updateLocale() {
document.querySelectorAll("[x-locale-key]:not([x1-locale-uuid])")
.forEach(e => {
let uuid = new Date().getTime().toString(36);
let uuid = (Math.random() + new Date().getTime()).toString(36);
e.setAttribute("x1-locale-uuid", uuid);
backupElements[uuid] = e.cloneNode();
backupElements[uuid] = e.outerHTML;
e.innerHTML = getValueFromPath(locale, e.getAttribute("x-locale-key"));
})
}
@ -28,7 +28,7 @@
window.x0?.registerModuleRemoveHook("locale", (s) => {
Object.keys(s)
.forEach(uuid => {
document.querySelector(`[x1-locale-uuid="${uuid}"]`).outerHTML = s[uuid].outerHTML;
document.querySelector(`[x1-locale-uuid="${uuid}"]`).outerHTML = s[uuid];
})
})
})()