Skip to content

Commit 6cd187e

Browse files
zombieJclaude
andcommitted
refactor: simplify isIgnoredElement logic
Simplify the isIgnoredElement function for better readability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a8fd11c commit 6cd187e

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/Dom/focus.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,25 @@ function getLastElement() {
113113
}
114114

115115
function isIgnoredElement(element: Element | null): boolean {
116-
if (!element) return false;
117116
const lastElement = getLastElement();
118-
if (!lastElement) return false;
119-
120-
// Find the ID that maps to the last element
121-
let lockId: string | undefined;
122-
for (const [id, ele] of idToElementMap.entries()) {
123-
if (ele === lastElement) {
124-
lockId = id;
125-
break;
117+
118+
if (element && lastElement) {
119+
// Find the ID that maps to the last element
120+
let lockId: string | undefined;
121+
for (const [id, ele] of idToElementMap.entries()) {
122+
if (ele === lastElement) {
123+
lockId = id;
124+
break;
125+
}
126126
}
127-
}
128127

129-
if (!lockId) return false;
128+
const ignoredEle = ignoredElementMap.get(lockId);
129+
return (
130+
!!ignoredEle && (ignoredEle === element || ignoredEle.contains(element))
131+
);
132+
}
130133

131-
const ignoredEle = ignoredElementMap.get(lockId);
132-
return (
133-
!!ignoredEle && (ignoredEle === element || ignoredEle.contains(element))
134-
);
134+
return false;
135135
}
136136

137137
function hasFocus(element: HTMLElement) {

0 commit comments

Comments
 (0)