Skip to content

Commit 8a52375

Browse files
committed
chore(transformer): add tests for property bindings and multiple executions
1 parent 87b3b71 commit 8a52375

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

modules/angular2/src/render/dom/compiler/compiler.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
1616
import {CompileStepFactory, DefaultStepFactory} from './compile_step_factory';
1717
import {Parser} from 'angular2/change_detection';
1818
import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
19-
import {
20-
PropertySetterFactory
21-
} from '../view/property_setter_factory'
19+
import {PropertySetterFactory} from '../view/property_setter_factory';
2220

23-
/**
24-
* The compiler loads and translates the html templates of components into
25-
* nested ProtoViews. To decompose its functionality it uses
26-
* the CompilePipeline and the CompileSteps.
27-
*/
28-
export class DomCompiler extends RenderCompiler {
21+
/**
22+
* The compiler loads and translates the html templates of components into
23+
* nested ProtoViews. To decompose its functionality it uses
24+
* the CompilePipeline and the CompileSteps.
25+
*/
26+
export class DomCompiler extends RenderCompiler {
2927
_templateLoader: TemplateLoader;
3028
_stepFactory: CompileStepFactory;
3129
_propertySetterFactory: PropertySetterFactory;

modules/angular2/src/render/dom/view/property_setter_factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export class PropertySetterFactory {
9393
var dashCasedClassName;
9494
if (isBlank(setterFn)) {
9595
dashCasedClassName = camelCaseToDashCase(className);
96-
setterFn = (element, value) => {
97-
if (value) {
96+
setterFn = (element, isAdd) => {
97+
if (isAdd) {
9898
DOM.addClass(element, dashCasedClassName);
9999
} else {
100100
DOM.removeClass(element, dashCasedClassName);

modules/angular2/test/transform/template_compiler/all_tests.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ void allTests() {
9292
output = await process(new AssetId('a', inputPath));
9393
_formatThenExpectEquals(output, expected);
9494
});
95+
96+
it('should create the same output for multiple calls.', () async {
97+
var inputPath =
98+
'template_compiler/inline_expression_files/hello.ng_deps.dart';
99+
var expected = readFile(
100+
'template_compiler/inline_expression_files/expected/hello.ng_deps.dart');
101+
var output = await process(new AssetId('a', inputPath));
102+
_formatThenExpectEquals(output, expected);
103+
output = await process(new AssetId('a', inputPath));
104+
_formatThenExpectEquals(output, expected);
105+
});
106+
95107
});
96108
}
97109

modules/angular2/test/transform/template_compiler/inline_expression_files/expected/hello.ng_deps.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ void initReflector(reflector) {
1414
'parameters': const [const []],
1515
'annotations': const [
1616
const Component(selector: 'hello-app'),
17-
const View(template: '{{greeting}}')
17+
const View(template: '<div [a]="b">{{greeting}}</div>')
1818
]
1919
})
20-
..registerGetters({'greeting': (o) => o.greeting})
21-
..registerSetters({'greeting': (o, v) => o.greeting = v});
20+
..registerGetters({'b': (o) => o.b, 'greeting': (o) => o.greeting})
21+
..registerSetters({
22+
'b': (o, v) => o.b = v,
23+
'greeting': (o, v) => o.greeting = v,
24+
'a': (o, v) => o.a = v
25+
});
2226
}

modules/angular2/test/transform/template_compiler/inline_expression_files/hello.ng_deps.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void initReflector(reflector) {
1414
'parameters': const [const []],
1515
'annotations': const [
1616
const Component(selector: 'hello-app'),
17-
const View(template: '{{greeting}}')
17+
const View(template: '<div [a]="b">{{greeting}}</div>')
1818
]
1919
});
2020
}

0 commit comments

Comments
 (0)