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

Commit 5927b23

Browse files
author
Di Peng
committed
fix(markup): Make special attrs such as ng:href work even without binding
- special attrs such as ng:href, ng:check did not work as intended when their values do not contain bindings. And this commit is to fix that Closes #534
1 parent 452607f commit 5927b23

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/markups.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ angularAttrMarkup('{{}}', function(value, name, element){
418418
value = decodeURI(value);
419419
var bindings = parseBindings(value),
420420
bindAttr;
421-
if (hasBindings(bindings)) {
421+
if (hasBindings(bindings) || SPECIAL_ATTRS[name]) {
422422
element.removeAttr(name);
423423
bindAttr = fromJson(element.attr(NG_BIND_ATTR) || "{}");
424424
bindAttr[SPECIAL_ATTRS[name] || name] = value;

test/markupSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ describe("markups", function(){
154154
expect(sortedHtml(element)).toEqual('<a ng:bind-attr="{"href":"{{url}}","rel":"{{rel}}"}"></a>');
155155
});
156156

157+
it('should bind Text with no Bindings', function() {
158+
forEach('src,href,checked,disabled,multiple,readonly,selected'.split(','), function(name) {
159+
compile('<div ng:' + name +'="some"></div>');
160+
expect(sortedHtml(element)).toEqual('<div ng:bind-attr="{"' + name +'":"some"}"></div>');
161+
dealoc(element);
162+
});
163+
})
164+
157165
it('should Parse Text With No Bindings', function(){
158166
var parts = parseBindings("a");
159167
assertEquals(parts.length, 1);

0 commit comments

Comments
 (0)