Skip to content

feat: validate selector format in element_getBoundingClientRect - #18

Open
Darley-Wey wants to merge 3 commits into
yfmeii:mainfrom
Darley-Wey:validate-bounding-client-rect-selector
Open

Darley-Wey wants to merge 3 commits into
yfmeii:mainfrom
Darley-Wey:validate-bounding-client-rect-selector

Conversation

@Darley-Wey

Copy link
Copy Markdown
Contributor

Validate that selector and innerSelector start with '#' or '.' in element_getBoundingClientRect. Additionally, add a reminder to assign an id to custom components if they need to be selected.

Copilot AI review requested due to automatic review settings June 7, 2026 02:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the element_getBoundingClientRect tool to validate selector inputs upfront and clarify selector constraints in the tool description.

Changes:

  • Clarified the description to emphasize selector requirements (especially for custom components).
  • Added runtime validation to restrict selector / innerSelector to ID or class selector formats.
  • Improved user-facing errors when unsupported selectors are provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools/element.ts Outdated
Comment on lines +606 to +611
if (!selector.startsWith("#") && !selector.startsWith(".")) {
throw new UserError("selector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)。若需选择页面内自定义组件,请保证代码对组件赋值了 ID 并使用 ID 选择器。");
}
if (innerSelector && !innerSelector.startsWith("#") && !innerSelector.startsWith(".")) {
throw new UserError("innerSelector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)");
}
Comment thread src/tools/element.ts Outdated
Comment on lines +606 to +611
if (!selector.startsWith("#") && !selector.startsWith(".")) {
throw new UserError("selector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)。若需选择页面内自定义组件,请保证代码对组件赋值了 ID 并使用 ID 选择器。");
}
if (innerSelector && !innerSelector.startsWith("#") && !innerSelector.startsWith(".")) {
throw new UserError("innerSelector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)");
}
Comment thread src/tools/element.ts Outdated
Comment on lines +607 to +610
throw new UserError("selector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)。若需选择页面内自定义组件,请保证代码对组件赋值了 ID 并使用 ID 选择器。");
}
if (innerSelector && !innerSelector.startsWith("#") && !innerSelector.startsWith(".")) {
throw new UserError("innerSelector 仅支持 ID 选择器 (以 '#' 开头) 或类选择器 (以 '.' 开头)");
@Darley-Wey
Darley-Wey force-pushed the validate-bounding-client-rect-selector branch from a10445e to 8350e84 Compare June 7, 2026 03:37
@Darley-Wey
Darley-Wey force-pushed the validate-bounding-client-rect-selector branch from 8350e84 to d6e6c57 Compare June 7, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants