Skip to content

Commit 306e626

Browse files
committed
revert feat($compile): add support for ng-attr with camelCased attributes
This reverts commit a1e7eb6. This change broke the stable branch builds. /CC @petebacondarwin / @wesleycho
1 parent f31c749 commit 306e626

File tree

3 files changed

+3
-49
lines changed

3 files changed

+3
-49
lines changed

docs/content/guide/directive.ngdoc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ For example, we could fix the example above by instead writing:
172172
</svg>
173173
```
174174

175-
If one wants to modify a camelcased attribute (SVG elements have valid camelcased attributes), such as `viewBox` on the `svg` element, one can use underscores to denote that the attribute to bind to is naturally camelcased.
176-
177-
For example, to bind to `viewBox`, we can write:
178-
179-
```html
180-
<svg ng-attr-view_box="{{viewBox}}">
181-
</svg>
182-
```
183-
184175

185176
## Creating Directives
186177

src/ng/compile.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,10 +1051,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10511051
// support ngAttr attribute binding
10521052
ngAttrName = directiveNormalize(name);
10531053
if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {
1054-
name = name.replace(PREFIX_REGEXP, '')
1055-
.substr(8).replace(/_(.)/g, function(match, letter) {
1056-
return letter.toUpperCase();
1057-
});
1054+
name = snake_case(ngAttrName.substr(6), '-');
10581055
}
10591056

10601057
var directiveNName = ngAttrName.replace(/(Start|End)$/, '');

test/ng/compileSpec.js

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,21 +5040,16 @@ describe('$compile', function() {
50405040
expect(element.attr('href')).toBe('test/test');
50415041
}));
50425042

5043-
it('should work if they are prefixed with x- or data- and different prefixes', inject(function($compile, $rootScope) {
5043+
it('should work if they are prefixed with x- or data-', inject(function($compile, $rootScope) {
50445044
$rootScope.name = "Misko";
5045-
element = $compile('<span data-ng-attr-test2="{{name}}" x-ng-attr-test3="{{name}}" data-ng:attr-test4="{{name}}" ' +
5046-
'x_ng-attr-test5="{{name}}" data:ng-attr-test6="{{name}}"></span>')($rootScope);
5045+
element = $compile('<span data-ng-attr-test2="{{name}}" x-ng-attr-test3="{{name}}" data-ng:attr-test4="{{name}}"></span>')($rootScope);
50475046
expect(element.attr('test2')).toBeUndefined();
50485047
expect(element.attr('test3')).toBeUndefined();
50495048
expect(element.attr('test4')).toBeUndefined();
5050-
expect(element.attr('test5')).toBeUndefined();
5051-
expect(element.attr('test6')).toBeUndefined();
50525049
$rootScope.$digest();
50535050
expect(element.attr('test2')).toBe('Misko');
50545051
expect(element.attr('test3')).toBe('Misko');
50555052
expect(element.attr('test4')).toBe('Misko');
5056-
expect(element.attr('test5')).toBe('Misko');
5057-
expect(element.attr('test6')).toBe('Misko');
50585053
}));
50595054

50605055
describe('when an attribute has a dash-separated name', function () {
@@ -5088,35 +5083,6 @@ describe('$compile', function() {
50885083
});
50895084

50905085

5091-
describe('when an attribute has an underscore-separated name', function() {
5092-
5093-
it('should work with different prefixes', inject(function($compile, $rootScope) {
5094-
$rootScope.dimensions = "0 0 0 0";
5095-
element = $compile('<svg ng:attr:view_box="{{dimensions}}"></svg>')($rootScope);
5096-
expect(element.attr('viewBox')).toBeUndefined();
5097-
$rootScope.$digest();
5098-
expect(element.attr('viewBox')).toBe('0 0 0 0');
5099-
}));
5100-
5101-
it('should work if they are prefixed with x- or data-', inject(function($compile, $rootScope) {
5102-
$rootScope.dimensions = "0 0 0 0";
5103-
$rootScope.number = 0.42;
5104-
$rootScope.scale = 1;
5105-
element = $compile('<svg data-ng-attr-view_box="{{dimensions}}">' +
5106-
'<filter x-ng-attr-filter_units="{{number}}">' +
5107-
'<feDiffuseLighting data-ng:attr_surface_scale="{{scale}}">' +
5108-
'</feDiffuseLighting>' +
5109-
'<feSpecularLighting x-ng:attr_surface_scale="{{scale}}">' +
5110-
'</feSpecularLighting></filter></svg>')($rootScope);
5111-
expect(element.attr('viewBox')).toBeUndefined();
5112-
$rootScope.$digest();
5113-
expect(element.attr('viewBox')).toBe('0 0 0 0');
5114-
expect(element.find('filter').attr('filterUnits')).toBe('0.42');
5115-
expect(element.find('feDiffuseLighting').attr('surfaceScale')).toBe('1');
5116-
expect(element.find('feSpecularLighting').attr('surfaceScale')).toBe('1');
5117-
}));
5118-
});
5119-
51205086
describe('multi-element directive', function() {
51215087
it('should group on link function', inject(function($compile, $rootScope) {
51225088
$rootScope.show = false;

0 commit comments

Comments
 (0)