File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131 body > main iframe {
3232 margin : 1rem ;
3333 }
34+ /* dynamically added images */
35+ .add-image ~ div {
36+ min-height : 100vh ;
37+ position : relative;
38+ }
39+ .add-image ~ div img {
40+ position : absolute;
41+ bottom : 0 ;
42+ }
3443
3544 /* Displaying the images on smaller viewports */
3645 img {
@@ -163,7 +172,13 @@ <h1>
163172 </ noscript >
164173
165174 < h2 > dynamic images</ h2 >
166- < button type ="button " class ="add-image "> Add image</ button >
175+ < p >
176+ Add < code > div</ code > element and image underneath (scroll down after
177+ pressing the following button)
178+ </ p >
179+ < button type ="button " class ="add-image ">
180+ Add dynamic image underneath
181+ </ button >
167182 </ main >
168183 <!-- Including other optional polyfills depending on expected browser support scope -->
169184 < script
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import loadingAttributePolyfill from '../dist/loading-attribute-polyfill.module.
22
33// Test for dynamically inserted images
44let addImage = ( event ) => {
5- let noscriptElement = document . createElement ( 'noscript' ) ,
5+ let divElement = document . createElement ( 'div' ) ,
6+ noscriptElement = document . createElement ( 'noscript' ) ,
67 imageElement = document . createElement ( 'img' ) ;
78
89 noscriptElement . classList . add ( 'loading-lazy' ) ;
@@ -15,10 +16,11 @@ let addImage = (event) => {
1516
1617 noscriptElement . appendChild ( imageElement ) ;
1718
18- document
19- . querySelector ( 'main' )
20- . insertAdjacentElement ( 'beforeend' , noscriptElement ) ;
19+ divElement . appendChild ( noscriptElement ) ;
2120
21+ document . querySelector ( 'main' ) . insertAdjacentElement ( 'beforeend' , divElement ) ;
22+
23+ // Call for preparing the sample image element included the latest
2224 loadingAttributePolyfill . prepareElement (
2325 document . querySelector ( 'main noscript.loading-lazy' )
2426 ) ;
You can’t perform that action at this time.
0 commit comments