DebugElement.queryAll can return results in different order than DOM. #13066
Labels
area: testing
Issues related to Angular testing features, such as TestBed
freq3: high
hotlist: google
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
type: bug/fix
Milestone
I'm submitting a ... (check one with "x")
Current behavior
DebugElements are returned from
DebugElement.queryAll()
in the same order they were first created in theViewContainer
regardless if they were moved by a structural directive likeNgFor
. If they were moved, then the order is out of sync with with the DOM.Expected behavior
DebugElements should be returned from a query in the order they appear within the DOM. Order should be updated when underlying
ViewRef
s are moved around in aViewContainer
Minimal reproduction of the problem with instructions
Plunker Reproducing the Issue
Running plunker will run tests that are almost identical to the unit tests for
NgFor
. Tests illustrate how adding and removingViewRef
s from aViewContainer
work as expected. Two tests illustrate how movingViewRef
s and using DebugElement to query for the moved items fails. Two tests illustrate how the DOM is in the correct order by using the nativequerySelectorAll()
method.What is the motivation / use case for changing the behavior?
DebugElements should be returned in the order they appear in the DOM when queried for.
Please tell us about your environment:
Windows 10 x64
Angular version: 2.2.1 with angular-cli 1.0.0-beta.20-4 (plunker not at this version)
Browser: all
Language: Typescript
Node (for AoT issues):
node --version
= 7.1.0The text was updated successfully, but these errors were encountered: