fix(ivy): ensure NgClass does not overwrite other dir data (#31788)

We currently have a handwritten version of the Ivy directive def for NgClass so
we can switch between Ivy and View Engine behavior. This generated code needs to
be kept up-to-date with what the Ivy compiler generates.

PR 30742 recently changed `classMap` such that it now requires allocation of
host binding slots. This means that the `allocHostVars()` function must be
called in the NgClass directive def to match compiler output, but the
handwritten directive def was not updated. This caused a bug where NgClass
was inappropriately overwriting data for other directives because space was
not allocated for its values.

PR Close #31788
This commit is contained in:
Kara Erickson
2019-07-22 14:44:23 -07:00
committed by Miško Hevery
parent 5a8eb924ba
commit 215ef3c5f4
3 changed files with 55 additions and 2 deletions

View File

@ -1278,6 +1278,8 @@ describe('compiler compliance: styling', () => {
}
};
// NOTE: IF YOU ARE CHANGING THIS COMPILER SPEC, YOU MAY NEED TO CHANGE THE DIRECTIVE
// DEF THAT'S HARD-CODED IN `ng_class.ts`.
const template = `
function ClassDirective_HostBindings(rf, ctx, elIndex) {
if (rf & 1) {