fix(node): always compute offset in positionBy() like rangeBy()#2099
Merged
Conversation
positionBy()'s default branch returned this.source.start verbatim, so for custom syntaxes whose source.start lacks an offset (e.g. postcss-html) it returned a position without offset, violating the Position type which declares offset as required. rangeBy()/positionInside() were normalized to always compute offset via sourceOffset() (#2033, issue #2029) but positionBy() was left behind. Mirror the rangeBy() pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Member
|
Thanks |
Member
|
Released in 8.5.16. |
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.
Mirrors #2033 to the one sibling it left out.
#2033 (issue #2029) normalized
rangeBy()andpositionInside()to always computeoffsetviasourceOffset(), so they return a completePosition.positionBy()'s default branch was left returningthis.source.startas-is:lib/node.js(default branch ofpositionBy)For custom syntaxes whose
source.startcarries nooffset(e.g. postcss-html), this returns a position missingoffset, which violates thePositiontype that declaresoffset: numberas required.rangeBy()two lines away already handles exactly this viasourceOffset();positionBy()is the unmirrored twin.Fix mirrors
rangeBy()precisely (computeoffsetthroughsourceOffset()on the default branch).Verification: added a regression test that fails on baseline (1/90 fail) and passes with the fix (90/90); the full existing suite is 89/89 on both baseline and patched, so zero regression;
tsc --noEmitis clean. Branch is based on the currentmaintip.