Repository navigation
fix(core): do not treat outputs named class or style as styling inputs - #71661
Merged
Merged
Conversation
When a directive had an output whose public name is `class` or `style`, the node was flagged as having a directive input with that name. The template's `[class]` or `[style]` binding was then sent to directive inputs instead of the element, found none, and its value was silently dropped. Interpolated `class`/`style` attributes and host directives that expose such an output were affected as well. The regression came from angular#60036, which moved the flag into helpers shared by inputs and outputs. The flag is now set only while inputs are collected, keeping the structure introduced by that refactor.
Contributor
Author
|
This regression first shipped in 19.2.0 (#60036), so the fix may also be a candidate for the patch branch. Could a maintainer consider adding the |
JeanMeche
reviewed
Oct 27, 2026
JeanMeche
approved these changes
Oct 27, 2026
…g inputs Add a test that a `(class)` listener still receives events from an output named `class` while `[class]` is bound on the same element.
JeanMeche
approved these changes
Oct 27, 2026
Member
Member
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #71660 | Regressed in #60036
Why the change
When a directive has an output named
classorstyle, Angular sends the template's[class]or[style]value to directive inputs that don't exist, so the value is silently dropped. With this fix, only real inputs with those names take over the binding.Special things to note
tNode.inputs, would also fix it. This fix keeps the helpers that Input/output refactors #60036 introduced and only sets the flag on the input path.classorstylestill take over the binding as before. A test covers a directive that has both an input and an output namedclass.Change outline
setShadowStylingInputFlagsnow runs only while inputs are being collected:initializeInputAndOutputAliases(tNode) for each directive on the node setupSelectorMatchedInputsOrOutputs(Inputs) setShadowStylingInputFlags // input 'class' → hasClassInput setupSelectorMatchedInputsOrOutputs(Outputs) - setShadowStylingInputFlags // output 'class' → hasClassInput too setupHostDirectiveInputsOrOutputs(Inputs) setShadowStylingInputFlags setupHostDirectiveInputsOrOutputs(Outputs) - setShadowStylingInputFlagsFor a template binding, the flag decides where
[class]="cls()"goes:The tests in
packages/core/test/acceptance/styling_spec.ts:PR Checklist
PR Type
What is the current behavior?
An output named
classorstylemakes a template[class]or[style]binding on the same element do nothing. Interpolatedclassandstyleattributes are affected too, and so are host directives that expose such an output.Issue Number: #71660
What is the new behavior?
These bindings are applied to the element. Only directive inputs named
classorstyletake them over.Does this PR introduce a breaking change?
Other information
This is a candidate for the patch branch, because the regression dates back to 19.2.0.