Permalink
Comparing changes
Open a pull request
- 1 commit
- 3 files changed
- 0 commit comments
- 1 contributor
Commits on Dec 14, 2014
…utes This reverts commit a1e7eb6. This change broke the stable branch builds. /CC @petebacondarwin / @wesleycho
Unified
Split
Showing
with
3 additions
and 49 deletions.
- +0 −9 docs/content/guide/directive.ngdoc
- +1 −4 src/ng/compile.js
- +2 −36 test/ng/compileSpec.js
| @@ -172,15 +172,6 @@ For example, we could fix the example above by instead writing: | ||
| </svg> | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
| For example, to bind to `viewBox`, we can write: | ||
|
|
||
| ```html | ||
| <svg ng-attr-view_box="{{viewBox}}"> | ||
| </svg> | ||
| ``` | ||
|
|
||
|
|
||
| ## Creating Directives | ||
|
|
||
| @@ -1051,10 +1051,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | ||
| // support ngAttr attribute binding | ||
| ngAttrName = directiveNormalize(name); | ||
| if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { | ||
| name = name.replace(PREFIX_REGEXP, '') | ||
| .substr(8).replace(/_(.)/g, function(match, letter) { | ||
| return letter.toUpperCase(); | ||
| }); | ||
| name = snake_case(ngAttrName.substr(6), '-'); | ||
| } | ||
|
|
||
| var directiveNName = ngAttrName.replace(/(Start|End)$/, ''); | ||
| @@ -5040,21 +5040,16 @@ describe('$compile', function() { | ||
| expect(element.attr('href')).toBe('test/test'); | ||
| })); | ||
|
|
||
| it('should work if they are prefixed with x- or data- and different prefixes', inject(function($compile, $rootScope) { | ||
| it('should work if they are prefixed with x- or data-', inject(function($compile, $rootScope) { | ||
| $rootScope.name = "Misko"; | ||
| element = $compile('<span data-ng-attr-test2="{{name}}" x-ng-attr-test3="{{name}}" data-ng:attr-test4="{{name}}" ' + | ||
| 'x_ng-attr-test5="{{name}}" data:ng-attr-test6="{{name}}"></span>')($rootScope); | ||
| element = $compile('<span data-ng-attr-test2="{{name}}" x-ng-attr-test3="{{name}}" data-ng:attr-test4="{{name}}"></span>')($rootScope); | ||
| expect(element.attr('test2')).toBeUndefined(); | ||
| expect(element.attr('test3')).toBeUndefined(); | ||
| expect(element.attr('test4')).toBeUndefined(); | ||
| expect(element.attr('test5')).toBeUndefined(); | ||
| expect(element.attr('test6')).toBeUndefined(); | ||
| $rootScope.$digest(); | ||
| expect(element.attr('test2')).toBe('Misko'); | ||
| expect(element.attr('test3')).toBe('Misko'); | ||
| expect(element.attr('test4')).toBe('Misko'); | ||
| expect(element.attr('test5')).toBe('Misko'); | ||
| expect(element.attr('test6')).toBe('Misko'); | ||
| })); | ||
|
|
||
| describe('when an attribute has a dash-separated name', function () { | ||
| @@ -5088,35 +5083,6 @@ describe('$compile', function() { | ||
| }); | ||
|
|
||
|
|
||
| describe('when an attribute has an underscore-separated name', function() { | ||
|
|
||
| it('should work with different prefixes', inject(function($compile, $rootScope) { | ||
| $rootScope.dimensions = "0 0 0 0"; | ||
| element = $compile('<svg ng:attr:view_box="{{dimensions}}"></svg>')($rootScope); | ||
| expect(element.attr('viewBox')).toBeUndefined(); | ||
| $rootScope.$digest(); | ||
| expect(element.attr('viewBox')).toBe('0 0 0 0'); | ||
| })); | ||
|
|
||
| it('should work if they are prefixed with x- or data-', inject(function($compile, $rootScope) { | ||
| $rootScope.dimensions = "0 0 0 0"; | ||
| $rootScope.number = 0.42; | ||
| $rootScope.scale = 1; | ||
| element = $compile('<svg data-ng-attr-view_box="{{dimensions}}">' + | ||
| '<filter x-ng-attr-filter_units="{{number}}">' + | ||
| '<feDiffuseLighting data-ng:attr_surface_scale="{{scale}}">' + | ||
| '</feDiffuseLighting>' + | ||
| '<feSpecularLighting x-ng:attr_surface_scale="{{scale}}">' + | ||
| '</feSpecularLighting></filter></svg>')($rootScope); | ||
| expect(element.attr('viewBox')).toBeUndefined(); | ||
| $rootScope.$digest(); | ||
| expect(element.attr('viewBox')).toBe('0 0 0 0'); | ||
| expect(element.find('filter').attr('filterUnits')).toBe('0.42'); | ||
| expect(element.find('feDiffuseLighting').attr('surfaceScale')).toBe('1'); | ||
| expect(element.find('feSpecularLighting').attr('surfaceScale')).toBe('1'); | ||
| })); | ||
| }); | ||
|
|
||
| describe('multi-element directive', function() { | ||
| it('should group on link function', inject(function($compile, $rootScope) { | ||
| $rootScope.show = false; | ||