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 { core } from '@angular/compiler';
|
---|
9 | export class MockSchemaRegistry {
|
---|
10 | constructor(existingProperties, attrPropMapping, existingElements, invalidProperties, invalidAttributes) {
|
---|
11 | this.existingProperties = existingProperties;
|
---|
12 | this.attrPropMapping = attrPropMapping;
|
---|
13 | this.existingElements = existingElements;
|
---|
14 | this.invalidProperties = invalidProperties;
|
---|
15 | this.invalidAttributes = invalidAttributes;
|
---|
16 | }
|
---|
17 | hasProperty(tagName, property, schemas) {
|
---|
18 | const value = this.existingProperties[property];
|
---|
19 | return value === void 0 ? true : value;
|
---|
20 | }
|
---|
21 | hasElement(tagName, schemaMetas) {
|
---|
22 | const value = this.existingElements[tagName.toLowerCase()];
|
---|
23 | return value === void 0 ? true : value;
|
---|
24 | }
|
---|
25 | allKnownElementNames() {
|
---|
26 | return Object.keys(this.existingElements);
|
---|
27 | }
|
---|
28 | securityContext(selector, property, isAttribute) {
|
---|
29 | return core.SecurityContext.NONE;
|
---|
30 | }
|
---|
31 | getMappedPropName(attrName) {
|
---|
32 | return this.attrPropMapping[attrName] || attrName;
|
---|
33 | }
|
---|
34 | getDefaultComponentElementName() {
|
---|
35 | return 'ng-component';
|
---|
36 | }
|
---|
37 | validateProperty(name) {
|
---|
38 | if (this.invalidProperties.indexOf(name) > -1) {
|
---|
39 | return { error: true, msg: `Binding to property '${name}' is disallowed for security reasons` };
|
---|
40 | }
|
---|
41 | else {
|
---|
42 | return { error: false };
|
---|
43 | }
|
---|
44 | }
|
---|
45 | validateAttribute(name) {
|
---|
46 | if (this.invalidAttributes.indexOf(name) > -1) {
|
---|
47 | return {
|
---|
48 | error: true,
|
---|
49 | msg: `Binding to attribute '${name}' is disallowed for security reasons`
|
---|
50 | };
|
---|
51 | }
|
---|
52 | else {
|
---|
53 | return { error: false };
|
---|
54 | }
|
---|
55 | }
|
---|
56 | normalizeAnimationStyleProperty(propName) {
|
---|
57 | return propName;
|
---|
58 | }
|
---|
59 | normalizeAnimationStyleValue(camelCaseProp, userProvidedProp, val) {
|
---|
60 | return { error: null, value: val.toString() };
|
---|
61 | }
|
---|
62 | }
|
---|
63 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hX3JlZ2lzdHJ5X21vY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci90ZXN0aW5nL3NyYy9zY2hlbWFfcmVnaXN0cnlfbW9jay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsSUFBSSxFQUF3QixNQUFNLG1CQUFtQixDQUFDO0FBRTlELE1BQU0sT0FBTyxrQkFBa0I7SUFDN0IsWUFDVyxrQkFBNEMsRUFDNUMsZUFBd0MsRUFDeEMsZ0JBQTBDLEVBQVMsaUJBQWdDLEVBQ25GLGlCQUFnQztRQUhoQyx1QkFBa0IsR0FBbEIsa0JBQWtCLENBQTBCO1FBQzVDLG9CQUFlLEdBQWYsZUFBZSxDQUF5QjtRQUN4QyxxQkFBZ0IsR0FBaEIsZ0JBQWdCLENBQTBCO1FBQVMsc0JBQWlCLEdBQWpCLGlCQUFpQixDQUFlO1FBQ25GLHNCQUFpQixHQUFqQixpQkFBaUIsQ0FBZTtJQUFHLENBQUM7SUFFL0MsV0FBVyxDQUFDLE9BQWUsRUFBRSxRQUFnQixFQUFFLE9BQThCO1FBQzNFLE1BQU0sS0FBSyxHQUFHLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUNoRCxPQUFPLEtBQUssS0FBSyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQ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