axe-core icon indicating copy to clipboard operation
axe-core copied to clipboard

feat(DqElement source): improved truncation of element for source of …

Open GeneratorX16 opened this issue 6 months ago • 2 comments

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

GeneratorX16 avatar Jun 10 '25 18:06 GeneratorX16

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 10 '25 18:06 CLAassistant

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.

❤️ Share
🪧 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Jun 10 '25 18:06 coderabbitai[bot]

Thanks for the changes. I'm unable to look at this this week but will try to look at it next week.

straker avatar Jul 02 '25 17:07 straker

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.

straker avatar Jul 10 '25 16:07 straker

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.

GeneratorX16 avatar Jul 10 '25 17:07 GeneratorX16

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.

straker avatar Jul 10 '25 18:07 straker

My mistake, I was looking at the wrong place 😅. I have debugged the issue now.

GeneratorX16 avatar Jul 10 '25 18:07 GeneratorX16

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.

straker avatar Jul 22 '25 15:07 straker