-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(android): coerce string width/height in ImageAssetOptions #10862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NathanWalker
merged 7 commits into
NativeScript:main
from
VeinDevTtv:fix/android-imageassetoptions-parse-dimensions
Oct 30, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f9e0e0
fix(android): coerce string width/height for ImageAssetOptions; norma…
VeinDevTtv 533ec67
Merge branch 'main' into fix/android-imageassetoptions-parse-dimensions
VeinDevTtv 25c2ba9
Merge branch 'main' into fix/android-imageassetoptions-parse-dimensions
NathanWalker be89dea
revert(package.json): restore package.json from main (remove unrelate…
NathanWalker 031a1da
chore: cleanup tests
NathanWalker a973136
Merge branch 'main' into fix/android-imageassetoptions-parse-dimensions
NathanWalker a9c4097
chore: updated widgets build
NathanWalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { getRequestedImageSize } from './image-asset-common'; | ||
|
|
||
| describe('ImageAssetOptions normalization', () => { | ||
| it('coerces string width/height to numbers', () => { | ||
| const src = { width: 2000, height: 1500 }; | ||
| const result = getRequestedImageSize(src as any, { width: '300' as any, height: '200' as any, keepAspectRatio: false, autoScaleFactor: true } as any); | ||
| expect(result.width).toBe(300); | ||
| expect(result.height).toBe(200); | ||
| }); | ||
|
|
||
| it('falls back to defaults when invalid strings provided', () => { | ||
| const src = { width: 800, height: 600 }; | ||
| const result = getRequestedImageSize(src as any, { width: 'abc' as any, height: '' as any, keepAspectRatio: false } as any); | ||
| // should fall back to screen pixel defaults via getRequestedImageSize, but since | ||
| // we cannot easily control Screen.mainScreen here, we at least assert they are > 0 | ||
| expect(result.width).toBeGreaterThan(0); | ||
| expect(result.height).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| it('respects keepAspectRatio by adjusting to safe dimensions', () => { | ||
| const src = { width: 2000, height: 1000 }; | ||
| const result = getRequestedImageSize(src as any, { width: '500' as any, height: '500' as any, keepAspectRatio: true } as any); | ||
| // current implementation scales using the smaller coefficient (min), so expect 1000x500 | ||
| expect(result.width).toBe(1000); | ||
| expect(result.height).toBe(500); | ||
| }); | ||
| }); |
Binary file not shown.
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.