Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($compile): allow multiple directives on a single element even if one works with a multi-element range #4160

Closed
wants to merge 1 commit into from

Conversation

jankuca
Copy link
Contributor

@jankuca jankuca commented Sep 25, 2013

Closes #4002

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@jeffbcross
Copy link
Contributor

I added an inline comment to remove an iit, but could you also write a shorter first line of the commit message and a more descriptive commit message describing the behavior that was being observed before this fix?

@jeffbcross
Copy link
Contributor

… element

The problem was in keeping the values of `attrNameStart` and `attrNameEnd` between directive loop iterations which lead to the compiler looking for multi-element ranges for any directives that happened to be in the directive list after one that was applied on a range. For instance, having a ng-repeat-start and ng-class on a single element with ng-repeat being resolved first made the compiler look for an ng-repeat-end for both ng-repeat and ng-class because the `attrNameEnd` was not reset to a falsy value before the second iteration. As the result, an exception saying the block end element could not be found and the second directive was not actually applied.

Closes angular#4002
if ((index = ngAttrName.lastIndexOf('Start')) != -1 && index == ngAttrName.length - 5) {

var directiveNName = ngAttrName.replace(/(Start|End)$/, '');
if (ngAttrName === directiveNName + 'Start') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that attr{Start,End}Name should be set back to false, but why change this condition and involve a regex?
What's wrong with using lastIndexOf here?

If this way is the way to go, then remove the index variable (L626) since it's no longer used, and also cache the regex

@IgorMinar
Copy link
Contributor

landed as 6a8edc1

@IgorMinar IgorMinar closed this Sep 27, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ng-repeat-start with Ng-repeat causes ng-class, etc to not work
5 participants