File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 31
31
body > main iframe {
32
32
margin : 1rem ;
33
33
}
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
+ }
34
43
35
44
/* Displaying the images on smaller viewports */
36
45
img {
@@ -163,7 +172,13 @@ <h1>
163
172
</ noscript >
164
173
165
174
< 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 >
167
182
</ main >
168
183
<!-- Including other optional polyfills depending on expected browser support scope -->
169
184
< script
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import loadingAttributePolyfill from '../dist/loading-attribute-polyfill.module.
2
2
3
3
// Test for dynamically inserted images
4
4
let addImage = ( event ) => {
5
- let noscriptElement = document . createElement ( 'noscript' ) ,
5
+ let divElement = document . createElement ( 'div' ) ,
6
+ noscriptElement = document . createElement ( 'noscript' ) ,
6
7
imageElement = document . createElement ( 'img' ) ;
7
8
8
9
noscriptElement . classList . add ( 'loading-lazy' ) ;
@@ -15,10 +16,11 @@ let addImage = (event) => {
15
16
16
17
noscriptElement . appendChild ( imageElement ) ;
17
18
18
- document
19
- . querySelector ( 'main' )
20
- . insertAdjacentElement ( 'beforeend' , noscriptElement ) ;
19
+ divElement . appendChild ( noscriptElement ) ;
21
20
21
+ document . querySelector ( 'main' ) . insertAdjacentElement ( 'beforeend' , divElement ) ;
22
+
23
+ // Call for preparing the sample image element included the latest
22
24
loadingAttributePolyfill . prepareElement (
23
25
document . querySelector ( 'main noscript.loading-lazy' )
24
26
) ;
You can’t perform that action at this time.
0 commit comments