feat(DqElement source): improved truncation of element for source of …
feat(DqElement): Fixed truncation logic for large outerHTML for the the element itself
Changed truncation logic to also truncate the element of DqElement's source, while preserving the earlier truncation logic.
Closes: Issue #45444
Walkthrough
The truncation logic for serializing DOM elements was refactored. The old simple string truncation was replaced with new functions that intelligently truncate an element's outerHTML, prioritizing attribute shortening and removal. The getSource function now uses this improved truncation. Corresponding tests were added for these new behaviors.
Changes
| File(s) | Change Summary |
|---|---|
| lib/core/utils/dq-element.js | Removed truncate; added getOuterHtml, truncateAttributes, and truncateElement; updated getSource to use new truncation logic. |
| test/core/utils/dq-element.js | Added tests for truncation of elements with very long attribute names, many attributes, and long tag names in the source property of DqElement. |
Sequence Diagram(s)
sequenceDiagram
participant Caller
participant DqElement
participant Utils
Caller->>DqElement: get source property
DqElement->>Utils: truncateElement(element, maxLength, maxAttributeLength)
Utils->>Utils: getOuterHtml(element)
Utils->>Utils: Truncate attributes if needed
Utils->>Utils: Truncate tag if needed
Utils-->>DqElement: truncated outerHTML string
DqElement-->>Caller: truncated source string
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
npm warn skipping integrity check for git dependency ssh://[email protected]/w3c/aria-practices.git npm error Exit handler never called! npm error This is an error with npm itself. Please report this error at: npm error https://github.com/npm/cli/issues npm error A complete log of this run can be found in: /.npm/_logs/2025-06-20T16_10_08_824Z-debug-0.log
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📥 Commits
Reviewing files that changed from the base of the PR and between 9629adbe807f217de5626301e385342d353eb680 and c94fb4a5f9019840ad925a53a3e3b4b32eea64b8.
📒 Files selected for processing (2)
lib/core/utils/dq-element.js(1 hunks)test/core/utils/dq-element.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- test/core/utils/dq-element.js
- lib/core/utils/dq-element.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Security Review
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need 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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Thanks for the changes. I'm unable to look at this this week but will try to look at it next week.
Thanks for the changes. Unfortunately something in those changes broke a bunch of the tests. Double unfortunately since you forced pushed I'm unable to see the newest changes compared to prior changes, so I don't know exactly what you changed that caused the problem, nor can I revert to the point where the code was passing.
I tried running the tests from the develop branch locally, and they were failing over there too (the same areas). Can there be an issue in that ? I will check and submit again.
Develop is passing on my end. The way our tests are set up you have to build first before you test, otherwise the changes won't be tested.
My mistake, I was looking at the wrong place 😅. I have debugged the issue now.
This all looks good, thanks for the updates. I'm trying to finalize feedback from other teams about changing the html property, but once I get the all clear I should be able to merge.