ui: change <slot> check

This commit is contained in:
nick-delirium 2025-05-12 16:01:39 +02:00
parent 0c64003b09
commit 5304dbf8c1
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 7 additions and 5 deletions

View file

@ -122,8 +122,7 @@ export default class TabSessionManager {
this.state.update({ this.state.update({
vModeBadge: true, vModeBadge: true,
}) })
// easier to spot the warning appearing plus more time to go over all messages }, 0)
}, 1000)
} }
); );
this.lists = new Lists(initialLists); this.lists = new Lists(initialLists);

View file

@ -69,7 +69,8 @@ export default class DOMManager extends ListWalker<Message> {
all: () => Record<string, string>; all: () => Record<string, string>;
}; };
public readonly time: number; public readonly time: number;
private virtualMode: boolean = false; private virtualMode = false;
private hasSlots = false
private showVModeBadge?: () => void; private showVModeBadge?: () => void;
constructor(params: { constructor(params: {
@ -297,6 +298,9 @@ export default class DOMManager extends ListWalker<Message> {
this.insertNode(msg); this.insertNode(msg);
this.removeBodyScroll(msg.id, vElem); this.removeBodyScroll(msg.id, vElem);
this.removeAutocomplete(vElem); this.removeAutocomplete(vElem);
if (msg.tag === 'SLOT') {
this.hasSlots = true;
}
return; return;
} }
case MType.MoveNode: { case MType.MoveNode: {
@ -442,14 +446,13 @@ export default class DOMManager extends ListWalker<Message> {
// shadow DOM for a custom element + SALESFORCE (<slot>) // shadow DOM for a custom element + SALESFORCE (<slot>)
const isCustomElement = const isCustomElement =
vElem.tagName.includes('-') || vElem.tagName === 'SLOT'; vElem.tagName.includes('-') || vElem.tagName === 'SLOT';
const hasSlots = vElem.tagName === 'SLOT';
if (isCustomElement) { if (isCustomElement) {
if (this.virtualMode) { if (this.virtualMode) {
// Store the mapping but don't create the actual shadow root // Store the mapping but don't create the actual shadow root
this.shadowRootParentMap.set(msg.id, msg.frameID); this.shadowRootParentMap.set(msg.id, msg.frameID);
return; return;
} else if (hasSlots) { } else if (this.hasSlots) {
this.showVModeBadge?.(); this.showVModeBadge?.();
} }
} }