fix(compiler): use parentheses around expressions and escape quotes
This commit is contained in:
@ -13,15 +13,32 @@ export function main() {
|
||||
it('should find text interpolation in normal elements', () => {
|
||||
var results = createPipeline().process(createElement('<div>{{expr1}}<span></span>{{expr2}}</div>'));
|
||||
var bindings = results[0].textNodeBindings;
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("''+expr1+''");
|
||||
expect(MapWrapper.get(bindings, 2)).toEqual("''+expr2+''");
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("(expr1)");
|
||||
expect(MapWrapper.get(bindings, 2)).toEqual("(expr2)");
|
||||
});
|
||||
|
||||
it('should find text interpolation in template elements', () => {
|
||||
var results = createPipeline().process(createElement('<template>{{expr1}}<span></span>{{expr2}}</template>'));
|
||||
var bindings = results[0].textNodeBindings;
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("''+expr1+''");
|
||||
expect(MapWrapper.get(bindings, 2)).toEqual("''+expr2+''");
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("(expr1)");
|
||||
expect(MapWrapper.get(bindings, 2)).toEqual("(expr2)");
|
||||
});
|
||||
|
||||
it('should allow multiple expressions', () => {
|
||||
var results = createPipeline().process(createElement('<div>{{expr1}}{{expr2}}</div>'));
|
||||
var bindings = results[0].textNodeBindings;
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("(expr1)+(expr2)");
|
||||
});
|
||||
|
||||
it('should allow fixed text before, in between and after expressions', () => {
|
||||
var results = createPipeline().process(createElement('<div>a{{expr1}}b{{expr2}}c</div>'));
|
||||
var bindings = results[0].textNodeBindings;
|
||||
expect(MapWrapper.get(bindings, 0)).toEqual("'a'+(expr1)+'b'+(expr2)+'c'");
|
||||
});
|
||||
|
||||
it('should escape quotes in fixed parts', () => {
|
||||
var results = createPipeline().process(createElement("<div>'\"a{{expr1}}</div>"));
|
||||
expect(MapWrapper.get(results[0].textNodeBindings, 0)).toEqual("'\\'\"a'+(expr1)");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user