feat: validate selector format in element_getBoundingClientRect - #18
Open
Darley-Wey wants to merge 3 commits into
Open
Darley-Wey wants to merge 3 commits into
Darley-Wey wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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
selectorrequirements (especially for custom components). - Added runtime validation to restrict
selector/innerSelectorto 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 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 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 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
force-pushed
the
validate-bounding-client-rect-selector
branch
from
June 7, 2026 03:37
a10445e to
8350e84
Compare
Darley-Wey
force-pushed
the
validate-bounding-client-rect-selector
branch
from
June 7, 2026 03:48
8350e84 to
d6e6c57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.