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

fix($parse): fix parsing error with leading space and one time bind #7641

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
2 changes: 2 additions & 0 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,8 @@ function $ParseProvider() {
switch (typeof exp) {
case 'string':

exp = trim(exp);

if (exp.charAt(0) === ':' && exp.charAt(1) === ':') {
oneTime = true;
exp = exp.substring(2);
Expand Down
16 changes: 16 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,22 @@ describe('$compile', function() {
})
);

it('should one-time bind if the expression starts with a space and two colons', inject(
function($rootScope, $compile) {
$rootScope.name = 'angular';
element = $compile('<div name="attr: {{::name}}">text: {{ ::name }}</div>')($rootScope);
expect($rootScope.$$watchers.length).toBe(2);
$rootScope.$digest();
expect(element.text()).toEqual('text: angular');
expect(element.attr('name')).toEqual('attr: angular');
expect($rootScope.$$watchers.length).toBe(0);
$rootScope.name = 'not-angular';
$rootScope.$digest();
expect(element.text()).toEqual('text: angular');
expect(element.attr('name')).toEqual('attr: angular');
})
);


it('should process attribute interpolation in pre-linking phase at priority 100', function() {
module(function() {
Expand Down