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

Commit

Permalink
fix(compiler): linking function should call $digest
Browse files Browse the repository at this point in the history
The linked scope should be $digest-ed but only if a $digest isn't
already running on it.
  • Loading branch information
IgorMinar committed Oct 13, 2011
1 parent 8f46a3c commit 8611ebe
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Compiler.prototype = {
scope.$element = element;
(cloneConnectFn||noop)(element, scope);
template.link(element, scope);
if (!scope.$$phase) scope.$digest();
return scope;
};
},
Expand Down
33 changes: 30 additions & 3 deletions test/CompilerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,42 @@ describe('compiler', function() {
};
};
scope = compile('before<span duplicate="expr">x</span>after');
expect(sortedHtml(scope.$element)).
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 1;
scope.$digest();
expect(sortedHtml(scope.$element)).toEqual('<div>before<#comment></#comment><span>x</span>after</div>');
expect(sortedHtml(scope.$element)).
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 2;
scope.$digest();
expect(sortedHtml(scope.$element)).toEqual('<div>before<#comment></#comment><span>x</span><span>x</span>after</div>');
expect(sortedHtml(scope.$element)).
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 3;
scope.$digest();
expect(sortedHtml(scope.$element)).toEqual('<div>before<#comment></#comment><span>x</span><span>x</span><span>x</span>after</div>');
expect(sortedHtml(scope.$element)).
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
});


Expand Down
13 changes: 11 additions & 2 deletions test/markupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,20 @@ describe("markups", function() {
});

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

compile('<div ng:src="some"></div>');
expect(sortedHtml(element)).toEqual('<div ng:bind-attr="{"src":"some"}" src="some"></div>');
dealoc(element);

compile('<div ng:href="some"></div>');
expect(sortedHtml(element)).toEqual('<div href="some" ng:bind-attr="{"href":"some"}"></div>');
dealoc(element);
});

it('should Parse Text With No Bindings', function() {
Expand Down

0 comments on commit 8611ebe

Please sign in to comment.