Repository navigation
Engine: Honor # herb:debug disable on an output tag - #2860
Open
jonasporto wants to merge 1 commit into
Open
jonasporto wants to merge 1 commit into
jonasporto wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Touches marcoroth/reactionview#103.
# herb:debug disableis only read on a block's opening tag (include_debug_disable_comment?runs against@erb_block_stackinin_excluded_context?), so a single output tag has no way to opt out of the debug span. Where that span lands in a place the HTML parser does not allow a<span>, the element it wraps is dropped or moved:<%= tag.td "Ada", id: "cell_1" %>arrives as<template><span style="display: contents;"><td id="cell_1">Ada</td></span></template>; inside<template>the parser switches to "in body" at the<span>and ignores the<td>start tag, so only the text is left and the next stream that targetscell_1finds nothing.<tr>and the other table-structure tags behave the same (reproduction in the issue).<head>content comes from a partial. The partial's own AST has no<head>ancestor, so<%= stylesheet_link_tag … %>is wrapped and the browser closes<head>at the<span>(the issue's report).With this change the comment is honoured on an output tag too, with the same whitespace rules as on a block:
compiles to
_buf << (tag.td "Ada", id: "cell_1").to_s;with no span, and the other output tags in the same template keep theirs. The engine already drops a trailing comment from the compiled Ruby, so nothing changes at runtime.This is an opt-out, not a detection: at compile time the visitor cannot know that a partial will be sent inside a
<template>or rendered into<head>, and the span is only wrong there. If you would rather skip the span automatically for the helpers whose output is a table-structure element (tag.td,tag.tr,content_tag(:td, …), the list in the HTML table model), that fits besidecomplex_rails_helper?and I can add it. The head case has no finite helper list (the report's template usesvite_stylesheet_tag), so the comment seems the right tool there.Tests: three in
test/engine/debug_mode_test.rbwith snapshots, placed after the last top-level test so the existing snapshot numbers do not move. Againstmainthey fail with the span around the helper's output. Checked against v0.11.1 andmainat 5d75561 (debug_visitor.rbis identical in both).bin/integrationlocally (macOS, Ruby 4.0.7): 5256 Ruby tests (0 failures, 0 errors, 59 skips), 135 C checks, 0 leaks,bin/lint,bin/tidy, RuboCop with no offenses.