mirror of
https://github.com/AIsouler/GKD_subscription.git
synced 2025-12-19 16:25:09 +08:00
perf: check allowPropertyNames
This commit is contained in:
@@ -1,5 +1,40 @@
|
||||
import { CommonSelector } from '@gkd-kit/selector';
|
||||
|
||||
export const parseSelector = (source: string) => {
|
||||
return CommonSelector.Companion.parse(source);
|
||||
const selector = CommonSelector.Companion.parse(source);
|
||||
selector.propertyNames.forEach((name) => {
|
||||
if (!allowPropertyNames.has(name)) {
|
||||
throw new Error(`Property ${name} is not allowed in selector`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const allowPropertyNames = new Set([
|
||||
'id',
|
||||
'vid',
|
||||
|
||||
'name',
|
||||
'text',
|
||||
'text.length',
|
||||
'desc',
|
||||
'desc.length',
|
||||
|
||||
'clickable',
|
||||
'focusable',
|
||||
'checkable',
|
||||
'checked',
|
||||
'editable',
|
||||
'longClickable',
|
||||
'visibleToUser',
|
||||
|
||||
'left',
|
||||
'top',
|
||||
'right',
|
||||
'bottom',
|
||||
'width',
|
||||
'height',
|
||||
|
||||
'index',
|
||||
'depth',
|
||||
'childCount',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user