-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(compiler-core): add openTagLoc and closeTagLoc to element ast node
#12928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
WalkthroughThe changes introduce new options and properties to enable and handle precise source location tracking for opening and closing tags in the parser's AST nodes. Updates include AST type extensions, parser logic to populate these locations when enabled, parser options to control the feature, and corresponding test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant SourceCode
participant Parser
participant ASTNode
SourceCode->>Parser: Provide HTML/XML source
Parser->>Parser: Check if tagLocations option is enabled
alt tagLocations enabled
Parser->>ASTNode: Attach openTagLoc during open tag parse
Parser->>ASTNode: Attach closeTagLoc during close tag parse
end
Parser->>ASTNode: Build AST with tag location info (if enabled)
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
tagLoc and closeTagLoc to element ast nodeopenTagLoc and closeTagLoc to element ast node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
packages/compiler-core/src/options.ts (1)
100-104: Minor doc tweakThe comment says “open tag and close tag of each node” – consider clarifying that it records the tag-name locations, not the whole tag range, to avoid ambiguity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/compiler-core/src/ast.ts(1 hunks)packages/compiler-core/src/options.ts(1 hunks)packages/compiler-core/src/parser.ts(3 hunks)packages/compiler-dom/__tests__/parse.spec.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test / unit-test-windows
🔇 Additional comments (1)
packages/compiler-core/src/parser.ts (1)
81-82: Performance toggle added – ensure downstream opts in
tagLocationsdefaults tofalse, yet the DOM-parser tests rely on it beingtrue.
IfparserOptionsinpackages/compiler-dom/src/parserOptions.tsis not explicitly enabling this flag, the new fields will never be set and tests will still fail even after the naming fix.
Please verify & enable where needed.
Nowadays, language tools rely on string search to determine the offset of tags, which is not reliable and may cause some issues, like:
Summary by CodeRabbit
New Features
Tests