Skip to content

Parser: Properly handle asset tag helper options and duplicate sources - #2155

Draft
marcoroth wants to merge 1 commit into
mainfrom
stylesheet_link_tag
Draft

Parser: Properly handle asset tag helper options and duplicate sources#2155
marcoroth wants to merge 1 commit into
mainfrom
stylesheet_link_tag

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

Rails removes several options from the tag attributes before rendering, which neither javascript_include_tag nor stylesheet_link_tag accounted for.

Rails removes several options from the tag attributes before rendering,
which neither `javascript_include_tag` nor `stylesheet_link_tag`
accounted for.

`nopush` and `preload_links_header` are deleted from the options hash
and only feed the Early Hints link header, so they are now stripped
instead of being rendered as attributes. `crossorigin` is also deleted,
normalized so that `true` becomes `"anonymous"`, and reinserted second
in the base hash for both helpers. `integrity` is read without being
deleted, so it stays where the caller wrote it.

Rails calls `sources.uniq` before mapping, so duplicate sources now
collapse into a single element. Sources compare as string literals by
their unescaped value and as expressions by their source text.

Placing `crossorigin` correctly for `javascript_include_tag` required
fixing its single source attribute ordering, which appended `src` last
while the multi source path already emitted it first. Both paths now
emit `src` first, matching Rails. The `data attributes` engine test
matches Rails exactly as a result and was promoted from
`assert_optimized_mismatch_snapshot` to `assert_optimized_snapshot`.
@github-actions github-actions Bot added typescript TypeScript source across the javascript/ packages c C source for the core parser, lexer, and AST engine Herb engine and Rails template compilation rewriter @herb-tools/rewriter AST and string transformation system action-view-helpers Action View helper support and metadata labels Aug 10, 2026
@github-actions

Copy link
Copy Markdown

馃尶 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


馃尡 Grown from commit aae0dc2

@pkg-pr-new

pkg-pr-new Bot commented Aug 10, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@2155
npx https://pkg.pr.new/@herb-tools/language-server@2155
npx https://pkg.pr.new/@herb-tools/linter@2155

commit: aae0dc2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-view-helpers Action View helper support and metadata c C source for the core parser, lexer, and AST engine Herb engine and Rails template compilation rewriter @herb-tools/rewriter AST and string transformation system typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant