fix(core): prevent unknown property check for AOT-compiled components (#36072)

Prior to this commit, the unknown property check was unnecessarily invoked for AOT-compiled components (for these components, the check happens at compile time). This commit updates the code to avoid unknown property verification for AOT-compiled components by checking whether schemas information is present (as a way to detect whether this is JIT or AOT compiled component).

Resolves #35945.

PR Close #36072
This commit is contained in:
Andrew Kushnir
2020-03-15 09:08:57 -07:00
committed by atscott
parent 08b8b51486
commit fe1d9bacc3
2 changed files with 120 additions and 65 deletions

View File

@ -1038,6 +1038,12 @@ export function setNgReflectProperties(
function validateProperty(
tView: TView, lView: LView, element: RElement|RComment, propName: string,
tNode: TNode): boolean {
// If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
// mode where this check happens at compile time. In JIT mode, `schemas` is always present and
// defined as an array (as an empty array in case `schemas` field is not defined) and we should
// execute the check below.
if (tView.schemas === null) return true;
// The property is considered valid if the element matches the schema, it exists on the element
// or it is synthetic, and we are in a browser context (web worker nodes should be skipped).
if (matchingSchemas(tView, lView, tNode.tagName) || propName in element ||