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

Commit

Permalink
fix(markup): Make special attrs such as ng:href work even without bin…
Browse files Browse the repository at this point in the history
…ding

- 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
  • Loading branch information
Di Peng committed Aug 25, 2011
1 parent 452607f commit 5927b23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/markups.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ angularAttrMarkup('{{}}', function(value, name, element){
value = decodeURI(value);
var bindings = parseBindings(value),
bindAttr;
if (hasBindings(bindings)) {
if (hasBindings(bindings) || SPECIAL_ATTRS[name]) {
element.removeAttr(name);
bindAttr = fromJson(element.attr(NG_BIND_ATTR) || "{}");
bindAttr[SPECIAL_ATTRS[name] || name] = value;
Expand Down
8 changes: 8 additions & 0 deletions test/markupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ describe("markups", function(){
expect(sortedHtml(element)).toEqual('<a ng:bind-attr="{"href":"{{url}}","rel":"{{rel}}"}"></a>');
});

it('should bind Text with no Bindings', function() {
forEach('src,href,checked,disabled,multiple,readonly,selected'.split(','), function(name) {
compile('<div ng:' + name +'="some"></div>');
expect(sortedHtml(element)).toEqual('<div ng:bind-attr="{"' + name +'":"some"}"></div>');
dealoc(element);
});
})

it('should Parse Text With No Bindings', function(){
var parts = parseBindings("a");
assertEquals(parts.length, 1);
Expand Down

0 comments on commit 5927b23

Please sign in to comment.