Skip to content

WebImage.prototype.setSize(width, height) doesn't work properly after WebImage loads #155

@dgrilawidbanana

Description

@dgrilawidbanana

Describe the bug
Calling WebImage.prototype.setSize(width, height) on a WebImage with the dimensions originalWidth x originalHeight (with width < originalWidth and height < originalHeight) after it loads (such as when using WebImage.prototype.loaded(callback) or setting its size after a second using setTimeout(callback, 1000)) results in the image having the dimensions (width ** 2 / originalWidth) x (height ** 2 / originalHeight) despite the WebImage having the correct dimensions when seen in debug mode. In other words, the image is scaled down twice when it should only be scaled down once.

To Reproduce
Steps to reproduce the behavior:

  1. Click here: https://codehs.com/sandbox/dashboard/webimageprototypesetsizewidth-height-bug-exhibit

Expected behavior
The WebImage should have the correct size even if its size is set after the image loads.

Desktop:

  • OS: Windows 10 Version 22H2 (Build 19045.5487)
  • Browser: Google Chrome | 132.0.6834.197 (Official Build) (64-bit) (cohort: Control)
  • JavaScript: V8 13.2.152.36

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions