fix(ios): respect atIndex in getAttributes#4912
Open
vazidmansuri005 wants to merge 1 commit intowix:masterfrom
Open
fix(ios): respect atIndex in getAttributes#4912vazidmansuri005 wants to merge 1 commit intowix:masterfrom
vazidmansuri005 wants to merge 1 commit intowix:masterfrom
Conversation
2 tasks
569f3fb to
9750b05
Compare
The `attributes` property on `Element` was ignoring `self.index`, causing `element(...).atIndex(N).getAttributes()` to return all matching elements instead of the one at the specified index. This aligns the `attributes` property with the existing `view` property, which already correctly handles `self.index`. Fixes wix#4633
9750b05 to
607ec33
Compare
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.
Description
element(...).atIndex(N).getAttributes()on iOS was ignoring theatIndex()modifier and returning attributes for all matching elements instead of just the one at the specified index.Root cause
The
attributescomputed property inElement.swiftnever checkedself.index. When multiple elements matched the predicate, it unconditionally mapped over all views and returned them in anelementsarray — regardless of whetheratIndex()was specified.Fix
Added index-aware logic to the
attributesproperty, matching the pattern already used by theviewproperty (which correctly handlesself.index).atIndex(N).getAttributes()with multiple matches{ elements: [...] }(ignores index)getAttributes()with single matchgetAttributes()withoutatIndex, multiple matches{ elements: [...] }Tests
33.attributes.test.jsforatIndex+getAttributeson iOS (both legacy and new arch)atIndexis used, the result is a single element object (noelementsarray wrapper)