Repository navigation
Add build-time analyzer for invalid Virtualize spacer elements - #66968
Conversation
|
Thanks for your PR, @Yuvan111. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
@Yuvan111 @kotlarmilos |
There was a problem hiding this comment.
Pull request overview
Adds a runtime warning in the Blazor Web.JS Virtualize interop to help developers avoid invalid HTML when Virtualize is rendered under parent elements that don’t allow <div> children (notably table sections and lists).
Changes:
- Add
warnIfSpacerElementIsInvalidto emit aconsole.warnwhen the spacer tag doesn’t match expected tags forTBODY/TABLE/THEAD/TFOOT(tr) orUL/OL(li). - Add Jest coverage to verify warnings fire for invalid spacer usage and do not fire for valid spacer configurations.
- Add test helpers to mock browser globals (CSS/IntersectionObserver/ResizeObserver) for deterministic unit tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Components/Web.JS/src/Virtualize.ts | Emits a warning when Virtualize is initialized with a spacer element that’s invalid for certain parent elements. |
| src/Components/Web.JS/test/Virtualize.test.ts | Adds unit tests validating the new warning behavior across table/list scenarios. |
|
@kotlarmilos , @skrustev |
|
@PureWeen, Thank you for the detailed review. I have addressed all the identified issues. |
|
Thanks for the update. At the current head ( Could you route direct This comment was written by GitHub Copilot with human direction and help. |
|
@PureWeen, Addressed by mapping direct OpenComponent<Virtualize> diagnostics to the Razor source and adding a regression test for the explicit TItem path. |
|
@Yuvan111, the explicit- Can you resolve the conflict against Prepared with GitHub Copilot and reviewed by a human. |
|
@PureWeen , Thanks for the review. I've resolved the conflicts with the latest main, updated the PR, and reran the checks on the refreshed head. Please let me know if you have any further feedback during the follow-up review. |
While tbody/thead/tfoot/tr/ul/ol do not accept
That is introducing a false positive. What's more, writing where each |
|
@ilonatommy, Thanks, I removed select and tr from the analyzer and updated the tests accordingly. |
Co-authored-by: Ilona Tomkowicz <[email protected]>
|
/ba-g Build analysis stuck, all the other checks green |
Add build-time analyzer for invalid Virtualize spacer elements
Description
Adds the BL0019 build-time analyzer to detect invalid SpacerElement values used by Blazor Virtualize components.
Virtualize renders div spacer elements by default. A div is invalid as a direct child of restricted HTML elements such as tbody and ul. The analyzer reports a warning and identifies the required spacer element.
Supported Elements
tbody, thead, tfoot require SpacerElement="tr".
ul, ol require SpacerElement="li".
Implementation
Testing
Added analyzer tests covering:
Fixes #43102