fix: hide an attribute with a null bound value from getAttributeNames - #25818
Open
totally-not-ai[bot] wants to merge 2 commits into
Open
totally-not-ai[bot] wants to merge 2 commits into
totally-not-ai[bot] wants to merge 2 commits into
Conversation
Binding a Signal<Boolean> to an attribute today requires mapping it to "" / null. The attribute is then correctly absent from getAttribute and hasAttribute, but getAttributeNames still lists it. The added assertions fail, documenting the gap behind #23887.
A signal binding keeps its key in ElementAttributeMap while the signal value is null so that the binding survives, and getAttribute and hasAttribute already treat that as "not set". getAttributeNames listed the key anyway, so an attribute toggled off through its binding still showed up among the attribute names.
|
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an attribute is bound to a signal and the signal value becomes
null, the attribute is no longer set — butgetAttributeNames()still listed it. It is now left out, so it matches whatgetAttribute()andhasAttribute()already report.What changed
Behavior change:
Element.getAttributeNames()no longer returns the name of an attribute whose bound signal value isnull. This only affects code using attribute bindings (bindAttribute); attributes set the normal way are not touched. Code that relied on the old (inconsistent) listing will see one fewer name.ElementAttributeMap.attributes()now filters the keys byhas(...). A binding keeps its key in the map while the value isnullso that the binding stays alive, and that key is now skipped when listing names.Fixes #23887.
Test summary
Signal<Boolean>mapped to""/null: while the value is"", the attribute is readable, reported as present, and listed among the attribute names.getAttribute,hasAttribute, and now also fromgetAttributeNames.