fix: correct CSS error column numbers when <style> and content are on the same line#40490
Merged
fix: correct CSS error column numbers when <style> and content are on the same line#40490
<style> and content are on the same line#40490Conversation
… the same line Plumb text node position through CdataMatcher to the CSS tokenizer so that column numbers reflect the actual CSS content position, not the opening tag position. Includes test case for same-line style+CSS. Fixes #40424
Member
|
Good to see ya @Gregable :) . appreciate the contribution! |
Use the tag's line number (line_col_) but the content's column (content_line_col) in MatchCss. This preserves correct line numbering for multi-line stylesheets while fixing column offsets when CSS content is on the same line as the <style> tag. Also corrects the expected test output to match actual validator output.
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 #40424
When
<style amp-custom>and its CSS are on the same line (e.g.<style amp-custom>body{bad:css}</style>), CSS error column numbers point to the opening tag instead of the actual CSS content. This is becauseCdataMatcherpasses the tag's position to the CSS tokenizer, and when everything's on one line the column offset is wrong. When they're on separate lines it doesn't matter since the newline resets the column.The fix plumbs the text node's actual position (
node->FirstChild()->LineColInHtmlSrc()) through to the CSS tokenizer, with a fallback to the existing behavior if unavailable. Same approach that's already used for JSON content error positions a few lines above.Includes a test case with style tag and CSS on the same line.