Repository navigation
fix(linker): accept template literals in styles and host bindings - #527
Merged
Brooooooklyn merged 2 commits intoOct 2, 2026
Merged
Brooooooklyn merged 2 commits into
Brooooooklyn merged 2 commits into
Conversation
Partial declarations whose strings were rewritten as template literals (for example by esbuild, which prefers backticks for strings containing quotes or newlines) linked with their styles and host bindings missing. Emptied styles also downgraded encapsulation from Emulated to None. Treat a template literal with no substitutions as its cooked string value for `styles` entries and host `properties`/`listeners`, sharing the existing handling used by `get_string_property`.
ashley-hunter
force-pushed
the
fix/linker-template-literal-strings
branch
from
October 2, 2026 11:39
2f17f8a to
7168b52
Compare
…terals
The same bundler rewrite (strings → no-substitution template literals)
still leaked through other linker paths:
- `inputs: { x: [`pub`, `prop`] }` failed the first-is-string check, so
the `[InputFlags, ...]` definition-format element was never inserted.
The runtime reads element 0 as InputFlags, so a truthy publicName was
treated as SignalBased and the alias was lost.
- `deps: `invalid`` was not recognised, producing a plain `new Type()`
factory instead of `ɵɵinvalidFactory()`.
- `host.attributes` values emitted the raw source (`` `x` `` rather
than `"x"`), diverging from the quoted form; attr keys and input
public/class names are now emitted through escape_string.
- The styles loop used `to_expression()`, which panics on array
elisions; `as_expression()` skips them instead.
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.
Summary
Partial declarations can reach the linker with their strings written as template literals. esbuild, for example, rewrites strings containing quotes or newlines to backticks, which most CSS does:
Previously the linker only read
StringLiteralvalues in these places, so:stylesentries were dropped, and with no styles left the component's encapsulation was downgraded from Emulated toNone.propertiesandlistenerswere dropped, so their bindings were never emitted.The build succeeded with no warning, and the problem only showed up as missing styling or behaviour at runtime.
Changes
as_static_stringfromget_string_property: it accepts a string literal, or a template literal with no substitutions (using its cooked value).stylesentries and for hostproperties/listenersvalues.x: [pub,prop]are now recognised as declaration format, so the[InputFlags, ...]element is inserted; previously the array was passed through verbatim and the runtime read the public name asInputFlags.deps:invalid`` now selects theɵɵinvalidFactory()path like the quoted form.host.attributesstatic-string values are emitted cooked and quoted, and attribute keys / inputpublicName/classPropertyNamego throughescape_string.stylesloop usesas_expression()so an array elision can't panic it.${...}substitutions are still skipped.Tests
test_link_styles_template_literal_matches_string_literal: backtick and quotedstyleslink to byte-identical output, including a case with escape sequences.test_link_host_bindings_template_literal_matches_string_literal: same for host properties and listeners.test_link_host_attributes_template_literal_matches_string_literal: cooked template-literal attribute values produce byte-identicalhostAttrs.test_link_inputs_template_literal_matches_string_literal: simple, aliased-array, and object input forms all survive the rewrite.test_link_factory_invalid_deps_template_literal:deps:invalid`` emitsɵɵinvalidFactory.@angular/compiler-cli21.2.6's linker output.cargo test, conformance (1264/1264, snapshot unchanged),pnpm test(374/374),pnpm check, compare fixtures (979/979) and Playwright e2e (37/37).