Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix(ngHref): allow strings without interpolation

This fixes the ngSrc as well.

Closes #850
  • Loading branch information...
commit 950f8632c3c665d0661bb730d18bd81e698beaa9 1 parent 1cebff5
@vojtajina authored
View
5 src/ng/directive/booleanAttrs.js
@@ -283,7 +283,7 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
var normalized = directiveNormalize('ng-' + attrName);
ngAttributeAliasDirectives[normalized] = function() {
return {
- priority: 100,
+ priority: 99,
compile: function(tpl, attr) {
return function(scope, element, attr) {
attr.$$observers[attrName] = [];
@@ -302,10 +302,11 @@ forEach(['src', 'href'], function(attrName) {
var normalized = directiveNormalize('ng-' + attrName);
ngAttributeAliasDirectives[normalized] = function() {
return {
- priority: 100,
+ priority: 99,
compile: function(tpl, attr) {
return function(scope, element, attr) {
attr.$$observers[attrName] = [];
+ attr.$set(attrName, attr[normalized]);
attr.$observe(normalized, function(value) {
attr.$set(attrName, value);
});
View
6 test/ng/directive/booleanAttrsSpec.js
@@ -110,4 +110,10 @@ describe('ng-href', function() {
expect(element.attr('href')).toEqual('http://server');
expect(element.attr('rel')).toEqual('REL');
}));
+
+
+ it('should set value to href if it is not interpolated', inject(function($rootScope, $compile) {
+ element = $compile('<a ng-href="some/value">link</a>')($rootScope);
+ expect(element.attr('href')).toBe('some/value');
+ }));
});

3 comments on commit 950f863

@mhevery

Hmm... looks like we both fixed the same thing, my is already in master. Sorry for not letting you know.

@mhevery

LGTM, otherwise

@IgorMinar

I like misko's fix better

Please sign in to comment.
Something went wrong with that request. Please try again.