Fix a few more misc issues (TS errors, dupe files)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useId } from "$lib/hooks/use-id";
|
||||
import { Keys } from "$lib/utils/keyboard";
|
||||
import { Focus } from "$lib/utils/calculate-active-index";
|
||||
import { treeWalker } from "$lib/utils/tree-walker";
|
||||
import { treeWalker } from "$lib/hooks/use-tree-walker";
|
||||
import { State } from "$lib/internal/open-closed";
|
||||
import { getContext, tick } from "svelte";
|
||||
import type { Writable } from "svelte/store";
|
||||
|
||||
@@ -23,11 +23,11 @@ export function treeWalker({
|
||||
let acceptNode = Object.assign((node: HTMLElement) => accept(node), {
|
||||
acceptNode: accept,
|
||||
});
|
||||
// @ts-ignore-error Typescript bug thinks this can only have 3 args
|
||||
let walker = document.createTreeWalker(
|
||||
root,
|
||||
NodeFilter.SHOW_ELEMENT,
|
||||
acceptNode,
|
||||
// @ts-ignore-error Typescript bug thinks this can only have 3 args
|
||||
false
|
||||
);
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
type AcceptNode = (
|
||||
node: HTMLElement
|
||||
) =>
|
||||
| typeof NodeFilter.FILTER_ACCEPT
|
||||
| typeof NodeFilter.FILTER_SKIP
|
||||
| typeof NodeFilter.FILTER_REJECT;
|
||||
|
||||
export function treeWalker({
|
||||
container,
|
||||
accept,
|
||||
walk,
|
||||
enabled,
|
||||
}: {
|
||||
container: HTMLElement | null;
|
||||
accept: AcceptNode;
|
||||
walk(node: HTMLElement): void;
|
||||
enabled?: boolean;
|
||||
}) {
|
||||
let root = container;
|
||||
if (!root) return;
|
||||
if (enabled !== undefined && !enabled) return;
|
||||
|
||||
let acceptNode = Object.assign((node: HTMLElement) => accept(node), {
|
||||
acceptNode: accept,
|
||||
});
|
||||
// @ts-ignore-error Typescript bug thinks this can only have 3 args
|
||||
let walker = document.createTreeWalker(
|
||||
root,
|
||||
NodeFilter.SHOW_ELEMENT,
|
||||
acceptNode,
|
||||
false
|
||||
);
|
||||
|
||||
while (walker.nextNode()) walk(walker.currentNode as HTMLElement);
|
||||
}
|
||||
Reference in New Issue
Block a user