File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
rules/req-webp-in-picture Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 1.0.21
4
+ Fixes ` req-webp-in-picture ` to not check ` <picture> ` if all ` <source> ` have attribute ` type="image/svg+xml" ` .
5
+
3
6
## 1.0.20
4
7
- Adds a ` req-tags-presence ` rule that requires the specified tags on the page.
5
8
- Adds a ` req-preload-font ` rule that requires the ` preload ` value for the font.
Original file line number Diff line number Diff line change 1
1
# htmlacademy/req-webp-in-picture
2
2
3
- Правило проверяет наличие webp изображений в теге ` <picture> ` .
3
+ Правило проверяет наличие webp изображений в теге ` <picture> ` . Не проверяет ` <picture> ` если все ` <source> ` имеют атрибут ` type="image/svg+xml" ` .
4
4
5
5
## true
6
6
38
38
<img width =" 400" height =" 200" src =" image.png" alt =" Example image" >
39
39
</picture >
40
40
```
41
+
42
+ ``` html
43
+ <picture >
44
+ <source type =" image/svg+xml" media =" (width >= 1280px)" srcset =" images/logo-1280.svg" width =" 33" height =" 38" >
45
+ <source type =" image/svg+xml" media =" (width >= 768px)" srcset =" images/logo-768.svg" width =" 33" height =" 38" >
46
+ <img src =" images/logo.svg" srcset =" images/logo.svg" width =" 33" height =" 38" alt =" " >
47
+ </picture >
48
+ ```
Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ module.exports = {
7
7
lint ( node , rule_config , { report } ) {
8
8
if ( is_tag_node ( node ) && node . tagName === 'picture' ) {
9
9
const sourceElements = node . children . filter ( ( child ) => child . tagName === 'source' ) ;
10
+ const allSourcesAreSvg = sourceElements . every ( ( source ) => attribute_has_value ( source , 'type' , 'image/svg+xml' ) ) ;
11
+
12
+ if ( allSourcesAreSvg ) {
13
+ return ;
14
+ }
15
+
10
16
const hasWebpSource = sourceElements . some ( ( source ) => attribute_has_value ( source , 'type' , 'image/webp' ) ) ;
11
17
12
18
if ( ! hasWebpSource ) {
You can’t perform that action at this time.
0 commit comments