pipe_resolver_mock.js
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import { PipeResolver } from '@angular/compiler';
import { Compiler, Injectable, Injector } from '@angular/core';
export var MockPipeResolver = (function (_super) {
__extends(MockPipeResolver, _super);
function MockPipeResolver(_injector) {
_super.call(this);
this._injector = _injector;
this._pipes = new Map();
}
Object.defineProperty(MockPipeResolver.prototype, "_compiler", {
get: function () { return this._injector.get(Compiler); },
enumerable: true,
configurable: true
});
MockPipeResolver.prototype._clearCacheFor = function (pipe) { this._compiler.clearCacheFor(pipe); };
/**
* Overrides the {@link Pipe} for a pipe.
*/
MockPipeResolver.prototype.setPipe = function (type, metadata) {
this._pipes.set(type, metadata);
this._clearCacheFor(type);
};
/**
* Returns the {@link Pipe} for a pipe:
* - Set the {@link Pipe} to the overridden view when it exists or fallback to the
* default
* `PipeResolver`, see `setPipe`.
*/
MockPipeResolver.prototype.resolve = function (type, throwIfNotFound) {
if (throwIfNotFound === void 0) { throwIfNotFound = true; }
var metadata = this._pipes.get(type);
if (!metadata) {
metadata = _super.prototype.resolve.call(this, type, throwIfNotFound);
}
return metadata;
};
MockPipeResolver.decorators = [
{ type: Injectable },
];
/** @nocollapse */
MockPipeResolver.ctorParameters = function () { return [
{ type: Injector, },
]; };
return MockPipeResolver;
}(PipeResolver));
//# sourceMappingURL=pipe_resolver_mock.js.map