Skip to content

Add mindensity and maxdensity attributes to img and source - #13192

Open
noamr wants to merge 6 commits into
mainfrom
noamr/min-max-density
Open

noamr wants to merge 6 commits into
mainfrom
noamr/min-max-density

Conversation

@noamr

@noamr noamr commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Add mindensity and maxdensity content attributes (reflected as minDensity and maxDensity on HTMLImageElement and HTMLSourceElement) to clamp the target pixel density (devicePixelRatio) used when selecting an image source from a source set.

Stacked on #13183:

  • Content and IDL attributes: Adds mindensity and maxdensity to <img> and <source> (when inside <picture>), reflected as minDensity and maxDensity (DOMString). Values are parsed using the rules for parsing floating-point number values; non-positive values and parse errors are ignored.
  • Per-attribute fallback in <picture>: When a <source> element is selected in <picture>, each of mindensity and maxdensity falls back independently to the corresponding attribute on the <img> element if not present on <source>.
  • Target density clamping: In select an image source from a source set, targetDensity starts at devicePixelRatio, is clamped to maximum density (min(targetDensity, maxDensity)), and then to minimum density (max(targetDensity, minDensity)), so mindensity takes precedence if mindensity > maxdensity (matching CSS min/max clamping).
  • Relevant mutations: Setting, changing, or removing mindensity or maxdensity on <img> or a preceding sibling <source> in <picture> triggers update the image data.

Fixes #4421.
Fixes #13069.



💥 Error: Wattsi server error 💥

PR Preview failed to build. (Last tried on Nov 25, 2026, 11:24 AM UTC).

More

PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.

🔗 Related URL

Error output:

      <!DOCTYPE html>
      <html>
      <head>
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <meta name="robots" content="noindex">
          <style>body,html{height:100%;margin:0}body{display:flex;align-items:center;justify-content:center;flex-direction:column;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}p{text-align:center;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;color:#000;font-size:14px;margin-top:-50px}p.code{font-size:24px;font-weight:500;border-bottom:1px solid #e0e1e2;padding:0 20px 15px}p.text{margin:0}a,a:visited{color:#aaa}</style>
      </head>
      <body>
      <p class="code">
        Error code: 503      </p>
      <p class="text">
        Well, This is unexpected. An Error has occurred, and we are working to fix the problem! We will be up and running shortly. Try refreshing the page or try again in a few minutes.
      </p>
        <div style="display:none;">
          <h1>
    upstream_reset_before_response_started{connection_termination} (503 UC)      </h1>
          <p data-translate="connection_timed_out">App Platform failed to forward this request to the application.</p>
      </div>
      </body>
      </html>
    

This seems to be an issue with the Wattsi Server service. PR Preview doesn't manage this service and so has no control over it. If you've identified an issue with it, you can report the issue to the maintainers of Wattsi Server directly. Please be courteous. Thank you!

If you don't have enough information above to solve the error by yourself or if the issue doesn't seem related to Wattsi Server, you can file an issue with PR Preview.

noamr added 5 commits November 3, 2026 16:07
Replace the implementation-defined choice in select an image source from
a source set with deterministic selection matching implementations:
deduplicate equal pixel densities keeping the earliest entry, sort
ascending by pixel density, and pick the first candidate whose pixel
density is greater than or equal to the document's device pixel ratio
(or the last candidate if none qualify), with a "may" allowance for
preferring an already-available higher-density candidate.

Also pass the document from preload links and return early if no source
is selected.

Fixes #13077.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant