Repository navigation
Conversation
…ted images
When the image is only known at runtime, its width and height are
`{x.img.w}` / `{x.img.h}` expressions, which `parseInt` turned into NaN.
Output an expression that scales them instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/ed86c665756b63876f126f8c46a18a1bac1f7afdOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: ed86c66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
closes #12727
When
enhanced:imggets an image imported in the script (src={example}), its size is only known at runtime, so the plugin passes{example.img.w}and{example.img.h}toserialize_img_attributes. If the user sets onlywidth(or onlyheight), the other one is computed withparseInton those strings, which givesheight=NaN(orwidth=NaN).In that case the plugin now outputs an expression that does the same calculation at runtime, for example
height={Math.round((example.img.h * 280) / example.img.w)}. Static images keep the number computed at build time.The snapshot test gets a width-only and a height-only case with an imported image, and now checks that the output contains no
NaN. It fails without this change.I used Claude Code to write this change.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkI ran the
@sveltejs/enhanced-imgunit tests and itscheck, plusoxfmt --checkand ESLint on the changed files, not the fullpnpm test.Changesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits