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

Commit c2031b1

Browse files
KELiONcaitp
authored andcommittedJan 20, 2015
fix(ngRepeat) do not allow $id and $root as aliases
Currently user can use `$id` or `$root` as alias in ng-repeat directive that leads to rewriting these scope-related variables. This commit fixes this behavior by throwing an error when user try to use these values. Closes #10778
1 parent d17fbc3 commit c2031b1

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed
 

‎docs/content/error/ngRepeat/badident.ngdoc

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Reserved names include:
1616
- `this`
1717
- `undefined`
1818
- `$parent`
19+
- `$id`
20+
- `$root`
1921
- `$even`
2022
- `$odd`
2123
- `$first`

‎src/ng/directive/ngRepeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
292292
var keyIdentifier = match[2];
293293

294294
if (aliasAs && (!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(aliasAs) ||
295-
/^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent)$/.test(aliasAs))) {
295+
/^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent|\$root|\$id)$/.test(aliasAs))) {
296296
throw ngRepeatMinErr('badident', "alias '{0}' is invalid --- must be a valid JS identifier which is not a reserved name.",
297297
aliasAs);
298298
}

‎test/ng/directive/ngRepeatSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ describe('ngRepeat', function() {
474474
'this',
475475
'undefined',
476476
'$parent',
477+
'$root',
478+
'$id',
477479
'$index',
478480
'$first',
479481
'$middle',

0 commit comments

Comments
 (0)
This repository has been archived.