Repository navigation
fix(partial): strip brackets from host binding keys - #682
Open
benjavicente wants to merge 1 commit into
Open
benjavicente wants to merge 1 commit into
benjavicente wants to merge 1 commit into
Conversation
The partial `host` kept the binding syntax of each `host:` key, emitting
`listeners: { "(click)": … }` and `properties: { "[attr.x]": … }`. ngtsc's
`parseHostBindings` keys them by the bare name (`click`, `attr.x`), and the
linker parses that name the way a full compilation parses a `host:` key
after removing its brackets. Angular's linker therefore bound a `(click)`
event and a `[attr.x]` property, and rejected `(window:resize)` with
"Unexpected global target '(window'".
Strip the brackets when writing the partial `listeners` / `properties` of
directives and components, as the full compilation already does.
Fixes voidzero-dev#680
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 #680
Summary: in partial mode,
host.listeners/host.propertieskept the(…)/[…]of theirhost:keys. Angular's linker then listened for an event named(click), set a property named[attr.x], and failed the build on(window:resize)(Unexpected global target '(window'). This PR writes bare names, as ngtsc'sparseHostBindingsdoes.Changes
partial/directive.rsandpartial/component.rsstrip the brackets with the existingstrip_host_keywhen writinglisteners/properties. The full compilation already did this.keydown.shift.tab,window:/document:targets,attr./class./style.height.px,@triggeranimations) stays for the linker to parse, as with ngtsc.Tests
partial_directive_test.rs: the host test now uses the bracketed keys the pipeline produces.partial-host-bindings.test.ts: links partial directives and components with Angular's linker and with Oxc's, and checks the generated host instructions. The Angular-linker cases fail without this fix.Reproduction: https://github.com/benjavicente/oxc-angular-repro-partial-host-keys