From 18dd2548675fbe5a2ca8c1c1eb6ed11231a1698c Mon Sep 17 00:00:00 2001 From: Nikolai Shabalin Date: Tue, 28 May 2024 11:12:47 +0300 Subject: [PATCH 1/3] Enable svg for the req-webp-in-picture rule --- rules/req-webp-in-picture/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rules/req-webp-in-picture/index.js b/rules/req-webp-in-picture/index.js index 83dc693..5148d4d 100644 --- a/rules/req-webp-in-picture/index.js +++ b/rules/req-webp-in-picture/index.js @@ -7,6 +7,12 @@ module.exports = { lint(node, rule_config, { report }) { if (is_tag_node(node) && node.tagName === 'picture') { const sourceElements = node.children.filter((child) => child.tagName === 'source'); + const allSourcesAreSvg = sourceElements.every((source) => attribute_has_value(source, 'type', 'image/svg+xml')); + + if (allSourcesAreSvg) { + return; + } + const hasWebpSource = sourceElements.some((source) => attribute_has_value(source, 'type', 'image/webp')); if (!hasWebpSource) { From 9dd702af9611631ba8c8a5e47de4ebdd231da80c Mon Sep 17 00:00:00 2001 From: Nikolai Shabalin Date: Tue, 28 May 2024 11:14:08 +0300 Subject: [PATCH 2/3] Fix Readme.md --- rules/req-webp-in-picture/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rules/req-webp-in-picture/README.md b/rules/req-webp-in-picture/README.md index c603992..521bdeb 100644 --- a/rules/req-webp-in-picture/README.md +++ b/rules/req-webp-in-picture/README.md @@ -1,6 +1,6 @@ # htmlacademy/req-webp-in-picture -Правило проверяет наличие webp изображений в теге ``. +Правило проверяет наличие webp изображений в теге ``. Не проверяет `` если все `` имеют атрибут `type="image/svg+xml"`. ## true @@ -38,3 +38,11 @@ Example image ``` + +```html + + + + + +``` From 8ac345c1fd92861b2c580c326b5f92dbd9d09857 Mon Sep 17 00:00:00 2001 From: Nikolai Shabalin Date: Tue, 28 May 2024 11:15:05 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05d4d45..f06b16d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.21 +Fixes `req-webp-in-picture` to not check `` if all `` have attribute `type="image/svg+xml"`. + ## 1.0.20 - Adds a `req-tags-presence` rule that requires the specified tags on the page. - Adds a `req-preload-font` rule that requires the `preload` value for the font.