fix $ for detached nodes

This commit is contained in:
tophf 2022-01-19 22:19:50 +03:00
parent 98da86f816
commit f041f2265a
3 changed files with 5 additions and 5 deletions

View File

@ -13,7 +13,7 @@ async function StyleSettings() {
await t.fetchTemplate('/edit/settings.html', SS_ID);
const {style} = editor;
const ui = t.template[SS_ID].cloneNode(true);
const elAuto = $('[id="config.autosave"]', ui);
const elAuto = $('#config\\.autosave', ui);
const elSave = $('#ss-save', ui);
const pendingSetters = new Map();
const updaters = [

View File

@ -67,7 +67,7 @@ setTimeout(() => !cm && showSpinner($('#header')), 200);
({tabId, initialUrl} = preinit);
liveReload = initLiveReload();
preinit.tpl.then(el => $('#ss-scheme').append(...$('[id=ss-scheme]', el).children));
preinit.tpl.then(el => $('#ss-scheme').append(...$('#ss-scheme', el).children));
const [
{dup, style, error, sourceCode},

View File

@ -64,11 +64,11 @@ window.messageBoxProxy = new Proxy({}, {
},
});
function $(selector, base = document) {
function $(selector, base) {
// we have ids with . like #manage.onlyEnabled which looks like #id.class
// so since getElementById is superfast we'll try it anyway
const byId = selector.startsWith('#') && document.getElementById(selector.slice(1));
return byId || base.querySelector(selector);
const byId = !base && selector.startsWith('#') && document.getElementById(selector.slice(1));
return byId || (base || document).querySelector(selector);
}
function $$(selector, base = document) {