-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(ngRepeat): use block separator comments #4157
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
Tests passed on CI: http://ci.angularjs.org/job/angular.js-jeff/58/console |
Can you change the commit message to close the issues that this resolves? https://help.github.com/articles/closing-issues-via-commit-messages Unfortunately, I tried applying the fix to issue #4002 but it didn't completely fix it. I think it may require a separate PR though. If you want to see the failing example, see this plnkr: http://plnkr.co/edit/Hjqpqbuy0nhrTOmCjk36?p=preview and swap out the angular.js src with http://ci.angularjs.org/job/angular.js-jeff/58/artifact/build/angular.js |
There is a problem with multi-element directives: if they contain an element with a directive having <div ng-if-start="expr"></div>
<div ng-repeat="item in list">{{ item }}</div>
<div ng-if-end></div> Anything that This PR solves the problem for ngRepeat, which is where multi-element directives are used the most. But a more generic solution implemented in |
var children = element.find('div'); | ||
expect(children.length).toBe(3); | ||
|
||
// Note: COMMENT_NODE === 8 |
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.
better to create a DSL, toBeComment()
I added some changes in https://github.com/vojtajina/angular.js/tree/pr-4157:
@IgorMinar can you review that ? |
While this does solve #3104, #3104 unveils an underlying problem that the changes in this PR don't address (and I tried to explain the problem in that issue a while ago) This only works for ngRepeat, it's simply not generic! It's like the whole multi-element implementation scenario again: The first PRs submitted on the subject worked just for ngRepeat (#1646, #2531), but then we had a PR (#2783) that made $compile support multi-element directives natively with I'm not saying that this PR is bad: if we're looking for a solution to include in the 1.2.0rc3 release, then this is great. But in the long run, it would be better to solve the problem in a way that will work for all directives, not just one. We will surely get new issues when people start using |
@rodyhaddad you are right - $compile should take care of this in order to make it more general. That would be however a much bigger change, so for 1.2 I'm merging this fix. The future version of Angular will more likely have a re-designed "compiler" (similar to what angular.dart has now), that takes care of this stuff. |
Landed as 9efa46a. |
This change allows the use of ngRepeat in combination with directives that use transclusion and directives that replace its original elements or add more elements to ngRepeat blocks.