-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngSwitch): use the correct transclusion scope #8244
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
'<pre ng-switch-when="item1" ng-repeat="bar in bars">' + | ||
'foo = {{foo}}' + | ||
'bar = {{bar}}' + | ||
'$index = {{$index}}' + |
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.
I don't know if we really need to reproduce their entire reproduction here --- it's probably safer to just use <span ng-switch-when="item1" ng-repeat="bar in bars">{{$index}}</span>
instead --- smaller, and possibly fewer text nodes
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.
I agree but I think it is useful to have the {{foo}}
bit in there too.
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.
keep {{foo}}
- simplify the rest.
otherwise lgtm |
Actually ngSwitch is totally fubarred if we have multiple cases that each contain multi-element transclusions. See #8235 (comment) |
@lgalfaso - what do you think of these fixes? |
LGTM |
Thanks to @lgalfaso for help with this! |
If an ngSwitchWhen or ngSwitchDefault directive is on an element that also contains a transclusion directive (such as ngRepeat) the new scope should be the one provided by the bound transclusion function. Previously we were incorrectly creating a simple child of the main ngSwitch scope. BREAKING CHANGE: ** Directive Priority Changed ** - this commit changes the priority of `ngSwitchWhen` and `ngSwitchDefault` from 800 to 1200. This makes their priority higher than `ngRepeat`, which allows items to be repeated on the switch case element reliably. In general your directives should have a lower priority than these directives if you want them to exist inside the case elements. If you relied on the priority of these directives then you should check that your code still operates correctly. Closes angular#8235
If an ngSwitchWhen or ngSwitchDefault directive is on an element that also
contains a transclusion directive (such as ngRepeat) the new scope should
be the one provided by the bound transclusion function.
Previously we were incorrectly creating a simple child of the main ngSwitch
scope.
Closes #8235