fix(ivy): support schemas at runtime (#28637)

Accounts for schemas in when validating properties in Ivy.

This PR resolves FW-819.

A couple of notes:
* I had to rework the test slightly, in order to have it fail when we expect it to. The one in master is passing since Ivy's validation runs during the update phase, rather than creation.
* I had to deviate from the design in FW-819 and not add an `enableSchema` instruction, because the schema is part of the `NgModule` scope, however the scope is only assigned to a component once all of the module's declarations have been resolved and some of them can be async. Instead, I opted to have the `schemas` on the component definition.

PR Close #28637
This commit is contained in:
Kristiyan Kostadinov
2019-02-12 00:03:04 +01:00
committed by Miško Hevery
parent 7cbc36fdac
commit 80a5934af6
18 changed files with 162 additions and 76 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ViewEncapsulation} from '../../core';
import {SchemaMetadata, ViewEncapsulation} from '../../core';
import {Type} from '../../interface/type';
import {CssSelectorList} from './projection';
@ -264,7 +264,6 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
readonly onPush: boolean;
/**
* Registry of directives and components that may be found in this view.
*
* The property is either an array of `DirectiveDef`s or a function which returns the array of
@ -280,6 +279,11 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
*/
pipeDefs: PipeDefListOrFactory|null;
/**
* The set of schemas that declare elements to be allowed in the component's template.
*/
schemas: SchemaMetadata[]|null;
/**
* Used to store the result of `noSideEffects` function so that it is not removed by closure
* compiler. The property should never be read.

View File

@ -10,6 +10,7 @@ import {InjectionToken} from '../../di/injection_token';
import {Injector} from '../../di/injector';
import {Type} from '../../interface/type';
import {QueryList} from '../../linker';
import {SchemaMetadata} from '../../metadata';
import {Sanitizer} from '../../sanitization/security';
import {LContainer} from './container';
@ -535,6 +536,11 @@ export interface TView {
* A list of indices for child directives that have content queries.
*/
contentQueries: number[]|null;
/**
* Set of schemas that declare elements to be allowed inside the view.
*/
schemas: SchemaMetadata[]|null;
}
export const enum RootContextFlags {Empty = 0b00, DetectChanges = 0b01, FlushPlayers = 0b10}