-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix data-permanent to preserve element attributes, not just descendants #64622
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
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
|
@copilot Have you followed the steps in src/Components/AGENTS.MD? |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Yes, I've now followed the steps in AGENTS.MD. In commit
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Pull request overview
This PR fixes a bug where the data-permanent attribute only prevented child content synchronization during enhanced navigation, but still synchronized attributes on the element itself. The fix moves the isDataPermanentElement check to occur before attribute synchronization, ensuring both attributes and content are preserved for elements marked with data-permanent.
Key Changes:
- Modified TypeScript logic to skip all synchronization (attributes and content) for
data-permanentelements - Added unit tests verifying attribute preservation on
data-permanentelements - Added E2E test confirming dynamically added CSS classes survive enhanced navigation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Components/Web.JS/src/Rendering/DomMerging/DomSync.ts |
Moved isDataPermanentElement check before attribute synchronization to preserve both attributes and content for permanent elements |
src/Components/Web.JS/test/DomSync.test.ts |
Added two unit tests verifying attributes are preserved: one for existing attributes and one for dynamically added attributes |
src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs |
Added E2E test verifying dynamically added CSS class is preserved across multiple enhanced navigation events |
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/EnhancedNav/PageThatPreservesContent.razor |
Extended test page to include element for attribute preservation testing with dynamically added CSS class |
Fix data-permanent to preserve element attributes, not just descendants
Description
The
data-permanentattribute was only preventing child content synchronization during enhanced navigation, but still synchronized attributes on the element itself. This caused JS-modified attributes (like dynamically added classes) to be lost.Changes:
isDataPermanentElementcheck intreatAsMatch()to occur before attribute synchronization, skipping both attribute and content sync for permanent elementsdata-permanentelements, including dynamically added attributesElementsWithDataPermanentAttribute_HavePreservedAttributes) to verify dynamically added CSS classes are preserved after enhanced navigationPageThatPreservesContent.razortest component to include attribute preservation scenarioFixes #51021
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.