chore(transformer): add tests for property bindings and multiple executions
This commit is contained in:
parent
87b3b718e3
commit
8a52375fb8
|
@ -16,9 +16,7 @@ import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||||
import {CompileStepFactory, DefaultStepFactory} from './compile_step_factory';
|
import {CompileStepFactory, DefaultStepFactory} from './compile_step_factory';
|
||||||
import {Parser} from 'angular2/change_detection';
|
import {Parser} from 'angular2/change_detection';
|
||||||
import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
|
import {ShadowDomStrategy} from '../shadow_dom/shadow_dom_strategy';
|
||||||
import {
|
import {PropertySetterFactory} from '../view/property_setter_factory';
|
||||||
PropertySetterFactory
|
|
||||||
} from '../view/property_setter_factory'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The compiler loads and translates the html templates of components into
|
* The compiler loads and translates the html templates of components into
|
||||||
|
|
|
@ -93,8 +93,8 @@ export class PropertySetterFactory {
|
||||||
var dashCasedClassName;
|
var dashCasedClassName;
|
||||||
if (isBlank(setterFn)) {
|
if (isBlank(setterFn)) {
|
||||||
dashCasedClassName = camelCaseToDashCase(className);
|
dashCasedClassName = camelCaseToDashCase(className);
|
||||||
setterFn = (element, value) => {
|
setterFn = (element, isAdd) => {
|
||||||
if (value) {
|
if (isAdd) {
|
||||||
DOM.addClass(element, dashCasedClassName);
|
DOM.addClass(element, dashCasedClassName);
|
||||||
} else {
|
} else {
|
||||||
DOM.removeClass(element, dashCasedClassName);
|
DOM.removeClass(element, dashCasedClassName);
|
||||||
|
|
|
@ -92,6 +92,18 @@ void allTests() {
|
||||||
output = await process(new AssetId('a', inputPath));
|
output = await process(new AssetId('a', inputPath));
|
||||||
_formatThenExpectEquals(output, expected);
|
_formatThenExpectEquals(output, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create the same output for multiple calls.', () async {
|
||||||
|
var inputPath =
|
||||||
|
'template_compiler/inline_expression_files/hello.ng_deps.dart';
|
||||||
|
var expected = readFile(
|
||||||
|
'template_compiler/inline_expression_files/expected/hello.ng_deps.dart');
|
||||||
|
var output = await process(new AssetId('a', inputPath));
|
||||||
|
_formatThenExpectEquals(output, expected);
|
||||||
|
output = await process(new AssetId('a', inputPath));
|
||||||
|
_formatThenExpectEquals(output, expected);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,13 @@ void initReflector(reflector) {
|
||||||
'parameters': const [const []],
|
'parameters': const [const []],
|
||||||
'annotations': const [
|
'annotations': const [
|
||||||
const Component(selector: 'hello-app'),
|
const Component(selector: 'hello-app'),
|
||||||
const View(template: '{{greeting}}')
|
const View(template: '<div [a]="b">{{greeting}}</div>')
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
..registerGetters({'greeting': (o) => o.greeting})
|
..registerGetters({'b': (o) => o.b, 'greeting': (o) => o.greeting})
|
||||||
..registerSetters({'greeting': (o, v) => o.greeting = v});
|
..registerSetters({
|
||||||
|
'b': (o, v) => o.b = v,
|
||||||
|
'greeting': (o, v) => o.greeting = v,
|
||||||
|
'a': (o, v) => o.a = v
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ void initReflector(reflector) {
|
||||||
'parameters': const [const []],
|
'parameters': const [const []],
|
||||||
'annotations': const [
|
'annotations': const [
|
||||||
const Component(selector: 'hello-app'),
|
const Component(selector: 'hello-app'),
|
||||||
const View(template: '{{greeting}}')
|
const View(template: '<div [a]="b">{{greeting}}</div>')
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue