Skip to content

Modifying HTMLImageElement width and height properties triggers load event #46882

Closed

Description

@jdm
<script>
let e = document.createElement('img');
e.src = "https://joshmatthews.net/portrait.jpg";
e.onload = () => {
  console.log('onload');
  e.width *= 2;
};
</script>

In Firefox, this shows a single onload message. In Servo it shows an endless stream of them.

Activity

  1. added
    A-content/dom
    C-has-manual-testcase
    on Jul 30, 2026
  2. jdm commented on Jul 30, 2026

    @jdm
    MemberAuthor

    Womp womp:

    // Step 7.4.7.3. If maybe omit events is not set or previousURL is not
    // equal to urlString, then fire an event named load at the img element.
    // TODO: Add missing `maybe omit events` flag and previousURL.
    this.upcast::<EventTarget>().fire_event(cx, atom!("load"));

  3. added
    E-less-complex
    on Jul 30, 2026
  4. servo-highfive commented on Jul 30, 2026

    @servo-highfive

    Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in Zulip.

    If you intend to work on this issue, then add @servo-highfive: assign me to your comment, and I'll assign this to you. 😄

    Please read our policy on AI contributions before getting started.

  5. jdm commented on Jul 30, 2026

    @jdm
    MemberAuthor

    We're missing step 3 that sets the previousURL value and the check in this step that compares the newest URL.

  6. evlasics commented on Jul 31, 2026

    @evlasics

    @servo-highfive assign me

  7. added
    C-assigned
    on Jul 31, 2026
  8. servo-highfive commented on Jul 31, 2026

    @servo-highfive

    Hey @evlasics! Thanks for your interest in working on this issue. It's now assigned to you!

  9. evlasics commented on Aug 4, 2026

    @evlasics

    @jdm Unless I'm missing something, I don't think step 3 is the problem. As far as I can understand, maybe omit events is going to be false here, making any checks on previousURL moot. I'm currently working on figuring out what the cause of the discrepancy is.

  10. jdm commented on Aug 4, 2026

    @jdm
    MemberAuthor

    @evlasics Step 3 just sets previousURL, and step 7.4.7.3 says "If maybe omit events is not set" OR "previousURL is not equal to urlString", so I don't understand why "maybe omit events" matters here?

    Edit: sorry, misread your comment. Let me read the spec again.

  11. jdm commented on Aug 4, 2026

    @jdm
    MemberAuthor

    The maybe omit events flag was added in whatwg/html#8008 and that led me to whatwg/html#8492.

  12. mrobinson commented on Aug 20, 2026

    @mrobinson
    Member

    @evlasics Are you still working on this issue?

  13. evlasics commented on Aug 23, 2026

    @evlasics

    @mrobinson I don't really know to do on this issue until the whatwg spec is changed or clarified. Servo's current behavior matches the current whatwg spec in the above testcase, whereas the other browsers do not. The aforementioned issues by jdm don't seem to fully explain their behavior either. In any case, it's a bit above my pay grade, so feel free to unassign me.

  14. removed
    C-assigned
    E-less-complex
    on Aug 23, 2026
  15. jdm commented on Aug 23, 2026

    @jdm
    MemberAuthor

    I think our goal at this point should be to match the behaviour of other browsers, if we can find common behaviour.

  16. added a commit that references this issue on Oct 3, 2026
    2e584db
  17. added a commit that references this issue on Oct 6, 2026
    5347145
  18. added a commit that references this issue on Oct 12, 2026
    4f736fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domC-has-manual-testcase

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions