KEMBAR78
Make img.naturalWidth/Height handle dimensionless images better · Issue #3510 · whatwg/html · GitHub
Skip to content

Make img.naturalWidth/Height handle dimensionless images better #3510

@tabatkins

Description

@tabatkins

Currently, the .naturalWidth and .naturalHeight attributes of HTMLImageElement take on the value 0 when the image doesn't have an intrinsic width/height. This is unfortunate, because images can actually have a zero intrinsic width/height, and you can't tell the difference between these two states. (It's also just generally a bad practice to use a sentinel value like this.)

For Typed OM level 2, when I expose the intrinsic sizes of images, I want to mostly match up with HTML, but am planning on making the attributes nullable instead, so that a number indicates the actual intrinsic size, and null means no size in that axis. CSS has a lot more stretchy images.

In w3c/css-houdini-drafts#714 (comment), @annevk wonders if we could make this change for HTML as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions