fix: locale bug; didn't reverse on remove
This commit is contained in:
parent
32458c7fd4
commit
4dd1cf209b
3 changed files with 10 additions and 6 deletions
|
@ -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 => {
|
||||
|
|
|
@ -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];
|
||||
})
|
||||
})
|
||||
})()
|
Loading…
Add table
Add a link
Reference in a new issue