fix(queryhandler) only expose custom handlers (#6475)
This commit changes the custom query handler API to only operate on user-defined query handlers.
This commit is contained in:
parent
950ae334ca
commit
70ed875158
@ -101,11 +101,8 @@ const _defaultHandler = makeQueryHandler({
|
|||||||
element.querySelectorAll(selector),
|
element.querySelectorAll(selector),
|
||||||
});
|
});
|
||||||
|
|
||||||
const _builtInHandlers: Array<[string, InternalQueryHandler]> = [
|
const _builtInHandlers = new Map([['aria', ariaHandler]]);
|
||||||
['aria', ariaHandler],
|
const _queryHandlers = new Map(_builtInHandlers);
|
||||||
];
|
|
||||||
|
|
||||||
const _queryHandlers = new Map<string, InternalQueryHandler>(_builtInHandlers);
|
|
||||||
|
|
||||||
export function registerCustomQueryHandler(
|
export function registerCustomQueryHandler(
|
||||||
name: string,
|
name: string,
|
||||||
@ -127,17 +124,19 @@ export function registerCustomQueryHandler(
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
export function unregisterCustomQueryHandler(name: string): void {
|
export function unregisterCustomQueryHandler(name: string): void {
|
||||||
if (_queryHandlers.has(name)) {
|
if (_queryHandlers.has(name) && !_builtInHandlers.has(name)) {
|
||||||
_queryHandlers.delete(name);
|
_queryHandlers.delete(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function customQueryHandlerNames(): string[] {
|
export function customQueryHandlerNames(): string[] {
|
||||||
return [..._queryHandlers.keys()];
|
return [..._queryHandlers.keys()].filter(
|
||||||
|
(name) => !_builtInHandlers.has(name)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearCustomQueryHandlers(): void {
|
export function clearCustomQueryHandlers(): void {
|
||||||
_queryHandlers.clear();
|
customQueryHandlerNames().forEach(unregisterCustomQueryHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getQueryHandlerAndSelector(
|
export function getQueryHandlerAndSelector(
|
||||||
|
Loading…
Reference in New Issue
Block a user