refactor(pipes): removed pipes from properties
BREAKING CHANGE: This PR remove an ability to use pipes in the properties config. Instead, inject the pipe registry.
This commit is contained in:
@ -6,7 +6,7 @@ import {Parser} from 'angular2/src/change_detection/parser/parser';
|
||||
import {Unparser} from './unparser';
|
||||
import {Lexer} from 'angular2/src/change_detection/parser/lexer';
|
||||
import {Locals} from 'angular2/src/change_detection/parser/locals';
|
||||
import {Pipe, LiteralPrimitive} from 'angular2/src/change_detection/parser/ast';
|
||||
import {BindingPipe, LiteralPrimitive} from 'angular2/src/change_detection/parser/ast';
|
||||
|
||||
class TestData {
|
||||
constructor(public a?: any, public b?: any, public fnReturnValue?: any) {}
|
||||
@ -39,8 +39,6 @@ export function main() {
|
||||
return createParser().parseInterpolation(text, location);
|
||||
}
|
||||
|
||||
function addPipes(ast, pipes): any { return createParser().addPipes(ast, pipes); }
|
||||
|
||||
function emptyLocals() { return new Locals(null, new Map()); }
|
||||
|
||||
function evalAction(text, passedInContext = null, passedInLocals = null) {
|
||||
@ -412,7 +410,7 @@ export function main() {
|
||||
it("should parse pipes", () => {
|
||||
var originalExp = '"Foo" | uppercase';
|
||||
var ast = parseBinding(originalExp).ast;
|
||||
expect(ast).toBeAnInstanceOf(Pipe);
|
||||
expect(ast).toBeAnInstanceOf(BindingPipe);
|
||||
expect(new Unparser().unparse(ast)).toEqual(`(${originalExp})`);
|
||||
});
|
||||
|
||||
@ -600,7 +598,7 @@ export function main() {
|
||||
it('should parse pipes', () => {
|
||||
var bindings = parseTemplateBindings('key value|pipe');
|
||||
var ast = bindings[0].expression.ast;
|
||||
expect(ast).toBeAnInstanceOf(Pipe);
|
||||
expect(ast).toBeAnInstanceOf(BindingPipe);
|
||||
});
|
||||
});
|
||||
|
||||
@ -622,29 +620,6 @@ export function main() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('addPipes', () => {
|
||||
it('should return the given ast whe the list of pipes is empty', () => {
|
||||
var ast = parseBinding("1 + 1", "Location");
|
||||
var transformedAst = addPipes(ast, []);
|
||||
expect(transformedAst).toBe(ast);
|
||||
});
|
||||
|
||||
it('should append pipe ast nodes', () => {
|
||||
var ast = parseBinding("1 + 1", "Location");
|
||||
var transformedAst = addPipes(ast, ['one', 'two']);
|
||||
expect(transformedAst.ast.name).toEqual("two");
|
||||
expect(transformedAst.ast.exp.name).toEqual("one");
|
||||
expect(transformedAst.ast.exp.exp.operation).toEqual("+");
|
||||
});
|
||||
|
||||
it('should preserve location and source', () => {
|
||||
var ast = parseBinding("1 + 1", "Location");
|
||||
var transformedAst = addPipes(ast, ['one', 'two']);
|
||||
expect(transformedAst.source).toEqual("1 + 1");
|
||||
expect(transformedAst.location).toEqual("Location");
|
||||
});
|
||||
});
|
||||
|
||||
describe('wrapLiteralPrimitive', () => {
|
||||
it('should wrap a literal primitive', () => {
|
||||
expect(createParser().wrapLiteralPrimitive("foo", null).eval(null, emptyLocals()))
|
||||
|
Reference in New Issue
Block a user