Angular.js: 1.6.x: underscore prefix is not ignored in attribute directive's name

Created on 15 Oct 2017  路  9Comments  路  Source: angular/angular.js

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] other (Please do not submit support requests here (see above))

Current behavior:
Attribute directive registered as e.g. "t" and used on elements as "_t" is not working.

Expected / new behavior:
Attribute directive registered as e.g. "t" can be used as "_t" again.

Minimal reproduction of the problem with instructions:
comment/uncomment 1.6 vs 1.5 ng version to see the difference
https://plnkr.co/edit/earjy4mhjccYIexn7WYk?p=preview

AngularJS version: 1.x.y
1.5.x - works as described in 'expected' section, 1.6.x - does not work.

Browser:
not a browser-specific issue

Anything else:
My best guess, this bug was introduced in this commit:
https://github.com/angular/angular.js/commit/73050cdda04675bfa6705dc841ddbbb6919eb048#diff-a732922b631efed1b9f33a24082ae0dbR3600

regression bug

Most helpful comment

I can confirm that this is a bug. It appears that the regex replace is converting the _t to T rather than t, which stops it from being matched as a directive.

All 9 comments

I can confirm that this is a bug. It appears that the regex replace is converting the _t to T rather than t, which stops it from being matched as a directive.

Previously our camelCase utility didn't upper case the letter if the preceding "special" character was at the start of the name:

   replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
      return offset ? letter.toUpperCase() : letter;
    }).

But I wonder if this change was "on purpose" as part of 73050cdda04675bfa6705dc841ddbbb6919eb048... @mgol could say.

One option to fix this could be to update the PREFIX_REGEXP to capture and remove these special character prefixes before they get to the fnCamelCaseReplace if this is functioning as required for camel casing in general.

Is there any chance for this to be fixed in the nearest future?

@mgol confirmed that it is a regression. We now need a PR to fix it. Fancy having a go at that @curlydevil ?

@petebacondarwin I'll try)

@petebacondarwin I've created a PR but created it into master... should I (in case it passes CR and gets merged) create another one for v1.6.x branch?

No against master is fine. We will cherry-pick as necessary.

Was this page helpful?
0 / 5 - 0 ratings