-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prototype auto sizes for lazy-loaded img
Spec PR: whatwg/html#8008 WPT tests PR: #34427 R=pdr Bug: 1359051 Change-Id: I8e9bc836e9582a9209db53d55e0edc96f90499f2
- Loading branch information
1 parent
2b825bf
commit f70f511
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
.../semantics/embedded-content/the-img-element/sizes/reference/sizes-auto-rendering-ref.html
This file contains 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,8 @@ | ||
<!doctype html> | ||
<title>Auto sizes rendering</title> | ||
<link rel="help" href="specLinkTBDhttps://drafts.csswg.org/css-images-4/#image-set-notation"> | ||
<meta name="assert" content="auto sizes rendering"> | ||
<img | ||
src="/images/green.png" | ||
width="100px" | ||
> |
42 changes: 42 additions & 0 deletions
42
html/semantics/embedded-content/the-img-element/sizes/sizes-auto-rendering-dynamic.html
This file contains 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,42 @@ | ||
<!doctype html> | ||
<html class="reftest-wait"> | ||
<title>Auto sizes rendering</title> | ||
<link rel="help" href="specLinkTBDhttps://drafts.csswg.org/css-images-4/#image-set-notation"> | ||
<link rel="match" href="reference/sizes-auto-rendering-ref.html"> | ||
<meta name="assert" content="auto sizes rendering"> | ||
<img | ||
id="testImg" | ||
loading="lazy" | ||
srcset=" | ||
/images/green.png 100w, | ||
/images/red.png 50w | ||
" | ||
sizes="auto" | ||
width="50px" | ||
> | ||
<script> | ||
function runTest() { | ||
testImg.addEventListener( | ||
'load', | ||
() => { | ||
requestAnimationFrame(() => { | ||
testImg.style.width = '100px'; | ||
requestAnimationFrame(() => { | ||
testImg.addEventListener('load', () => { | ||
requestAnimationFrame(() => { | ||
requestAnimationFrame(() => { | ||
document.documentElement.classList.remove("reftest-wait"); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', runTest); | ||
</script> |
33 changes: 33 additions & 0 deletions
33
html/semantics/embedded-content/the-img-element/sizes/sizes-auto-rendering.html
This file contains 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,33 @@ | ||
<!doctype html> | ||
<html class="reftest-wait"> | ||
<title>Auto sizes rendering</title> | ||
<link rel="help" href="specLinkTBDhttps://drafts.csswg.org/css-images-4/#image-set-notation"> | ||
<link rel="match" href="reference/sizes-auto-rendering-ref.html"> | ||
<meta name="assert" content="auto sizes rendering"> | ||
<img | ||
id="testImg" | ||
loading="lazy" | ||
srcset=" | ||
/images/green.png 100w, | ||
/images/red.png 200w | ||
" | ||
sizes="auto" | ||
width="100px" | ||
> | ||
<script> | ||
function runTest() { | ||
testImg.addEventListener( | ||
'load', | ||
() => { | ||
requestAnimationFrame(() => { | ||
document.documentElement.classList.remove("reftest-wait"); | ||
}); | ||
}, | ||
{ | ||
once: true, | ||
} | ||
); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', runTest); | ||
</script> |