-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngRepeat: insert end comment only after last element, not after each iterated item #4786
Conversation
…iterated item This caused a subtle bug in angular-sortable directive: when moving elements between lists, previousNode was a comment, which doesn't have the .parentNode attribute so the $animate.enter function tried to call insertBefore of a null. Moreover, it looks bad that 'end ngRepeat' comment appears after every iterated node, it should be just at the end of the repeat block.
After going through Travis tests I managed to fix all of them except two: https://travis-ci.org/angular/angular.js/builds/13518556#L1838 These are quite tough, since it looks like there actually is some kind of dependency on comments for the ng-repeat directive. In the second case (with ng-if) it seems that it doesn't take into account the last line of the directive, only the ng-if comment. Unfortunately I haven't yet found the source of the problem. Anyone have an idea how to fix this? |
@CGenie - thanks for highlighting your problem. What would be really good is if you could provide a unit test that failed with the current state of the code for your situation. I am guessing that angular-sortable is trying to move nodes around but is confused because there are these comment nodes all over the place? If so, I wonder if it would be easier to fix angular-sortable to know about these comment nodes? Alternatively what if we changed the compiler so that if there was only one node to be repeated that comment nodes were not used? |
Also can you please have a good read through https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md and ensure that you have signed the CLA. |
@petebacondarwin Basically my most current code is this CGenie@b038c2b |
I think I'm having a similar problem. In my case, the commit 9efa46a is the one that introduced the code that is causing me trouble. If you look at the commit log and the related issue you'll see the rationale behind adding the |
I also ran into this problem, in a directive that very lightly wraps jquery.dragsort.js. In my case it was causing an |
I'm sorry, but I wasn't able to verify your CLA signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let me know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
1 similar comment
I'm sorry, but I wasn't able to verify your CLA signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let me know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
Any chance this is going to be released soon? I'm seeing this behavior too , it adds a lot of text in the page, especially if it's a long list <!--end ngRepeat: x in x | x | x, after each iteration. |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
the comment is needed after each iteration so that we can tell where an iteration starts and where it ends in case of multi-element repeaters, or repeaters in which elements get replaced by directives. I suggest that you let ng-repeat to sort the list rather than have an 3rd party javascript change the dom produced by ng-repeat |
This caused a subtle bug in angular-sortable directive: when moving elements
between lists, previousNode was a comment, which doesn't have the .parentNode
attribute so the $animate.enter function tried to call insertBefore of a null.
Moreover, it looks bad that 'end ngRepeat' comment appears after every iterated
node, it should be just at the end of the repeat block.