Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
3.3 KB
|
Line | |
---|
1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { PipeResolver } from '@angular/compiler';
|
---|
9 | export class MockPipeResolver extends PipeResolver {
|
---|
10 | constructor(refector) {
|
---|
11 | super(refector);
|
---|
12 | this._pipes = new Map();
|
---|
13 | }
|
---|
14 | /**
|
---|
15 | * Overrides the {@link Pipe} for a pipe.
|
---|
16 | */
|
---|
17 | setPipe(type, metadata) {
|
---|
18 | this._pipes.set(type, metadata);
|
---|
19 | }
|
---|
20 | /**
|
---|
21 | * Returns the {@link Pipe} for a pipe:
|
---|
22 | * - Set the {@link Pipe} to the overridden view when it exists or fallback to the
|
---|
23 | * default
|
---|
24 | * `PipeResolver`, see `setPipe`.
|
---|
25 | */
|
---|
26 | resolve(type, throwIfNotFound = true) {
|
---|
27 | let metadata = this._pipes.get(type);
|
---|
28 | if (!metadata) {
|
---|
29 | metadata = super.resolve(type, throwIfNotFound);
|
---|
30 | }
|
---|
31 | return metadata;
|
---|
32 | }
|
---|
33 | }
|
---|
34 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGlwZV9yZXNvbHZlcl9tb2NrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvdGVzdGluZy9zcmMvcGlwZV9yZXNvbHZlcl9tb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBeUIsWUFBWSxFQUFDLE1BQU0sbUJBQW1CLENBQUM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