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

fix(compiler): revert 8611ebe6 - calling after linking #614

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ explicitly.
<script src="http://code.angularjs.org/angular.js"></script>
<script>
angular.element(document).ready(function() {
angular.compile(document)();
angular.compile(document)().$apply();
});
</script>
</head>
Expand Down
10 changes: 9 additions & 1 deletion src/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ Template.prototype = {
* the same scope as the one passed into the template function, or if none were provided it's the
* newly create scope.
*
* It is important to understand that the returned scope is "linked" to the view DOM, but no linking
* (instance) functions registered by {@link angular.directive directives} or
* {@link angular.widget widgets} found in the template have been executed yet. This means that the
* view is likely empty and doesn't contain any values that result from evaluation on the scope. To
* bring the view to life, the scope needs to run through a $digest phase which typically is done by
* Angular automatically, except for the case when an application is being
* {@link guide/dev_guide.bootstrap.manual_bootstrap} manually bootstrapped, in which case the
* $digest phase must be invoked by calling {@link angular.scope.$apply}.
*
* If you need access to the bound view, there are two ways to do it:
*
* - If you are not asking the linking function to clone the template, create the DOM element(s)
Expand Down Expand Up @@ -209,7 +218,6 @@ Compiler.prototype = {
scope.$element = element;
(cloneConnectFn||noop)(element, scope);
template.link(element, scope);
if (!scope.$$phase) scope.$digest();
return scope;
};
},
Expand Down
4 changes: 0 additions & 4 deletions test/CompilerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ describe('compiler', function() {
expect(sortedHtml(scope.$element)).
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 1;
Expand All @@ -119,7 +118,6 @@ describe('compiler', function() {
toEqual('<div>' +
'before<#comment></#comment>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 2;
Expand All @@ -129,7 +127,6 @@ describe('compiler', function() {
'before<#comment></#comment>' +
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
scope.value = 3;
Expand All @@ -140,7 +137,6 @@ describe('compiler', function() {
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'<span>x</span>' +
'after' +
'</div>');
});
Expand Down
14 changes: 3 additions & 11 deletions test/markupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,12 @@ describe("markups", function() {
});

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