From 2fa9201c745a7eeddb966cd606f4081e8ffa1f82 Mon Sep 17 00:00:00 2001 From: audrasjb <[audrasjb@gmail.com]> Date: Tue, 9 Jan 2018 01:30:09 +0100 Subject: [PATCH 1/6] update/missing_alt_attributes --- blocks/library/image/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index 9f3802080d404..2392238655e25 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -35,6 +35,7 @@ registerBlockType( 'core/image', { source: 'attribute', selector: 'img', attribute: 'alt', + default: '', }, caption: { type: 'array', From 064fd8f3b24ab959c70a52f9fe303830a4e56644 Mon Sep 17 00:00:00 2001 From: audrasjb <[audrasjb@gmail.com]> Date: Tue, 9 Jan 2018 01:40:56 +0100 Subject: [PATCH 2/6] add missing default alt text to gallery block images --- blocks/library/gallery/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/blocks/library/gallery/index.js b/blocks/library/gallery/index.js index 2fc8fbdf6344c..5d20879114423 100644 --- a/blocks/library/gallery/index.js +++ b/blocks/library/gallery/index.js @@ -42,6 +42,7 @@ registerBlockType( 'core/gallery', { alt: { source: 'attribute', attribute: 'alt', + default: '', }, id: { source: 'attribute', From 50e4cc437e95246a3f986fb1cf2da5e98b422161 Mon Sep 17 00:00:00 2001 From: audrasjb <[audrasjb@gmail.com]> Date: Wed, 10 Jan 2018 10:26:17 +0100 Subject: [PATCH 3/6] add docs for default attribute argument --- docs/attributes.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/attributes.md b/docs/attributes.md index 059250a34d3f0..a222c246a9987 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -12,7 +12,9 @@ Under the hood, attribute sources are a superset of functionality provided by [h Use `attribute` to extract the value of an attribute from markup. -_Example_: Extract the `src` attribute from an image found in the block's markup. +_Example_: Extract the `src` attribute from an image found in the block's markup. +`default` parameter can be used to set a default value. +Images alt attribute default value should be set to `default: ''` (empty value) to follow WCAG criterias. ```js { @@ -20,6 +22,7 @@ _Example_: Extract the `src` attribute from an image found in the block's markup source: 'attribute', selector: 'img', attribute: 'src', + default: 'https://example.com/image.png', } } // { "url": "https://lorempixel.com/1200/800/" } From f386c7ce058ee267e3e21f63f28b3ee6ccb1d262 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 11 Jan 2018 14:52:40 +0100 Subject: [PATCH 4/6] Fix tests --- .../api/raw-handling/test/integration/google-docs-out.html | 2 +- .../raw-handling/test/integration/ms-word-online-out.html | 2 +- blocks/api/raw-handling/test/integration/ms-word-out.html | 2 +- blocks/test/fixtures/core__image.html | 2 +- blocks/test/fixtures/core__image.json | 5 +++-- blocks/test/fixtures/core__image.parsed.json | 2 +- blocks/test/fixtures/core__image.serialized.html | 2 +- blocks/test/fixtures/core__image__center-caption.html | 2 +- blocks/test/fixtures/core__image__center-caption.json | 5 +++-- blocks/test/fixtures/core__image__center-caption.parsed.json | 2 +- .../fixtures/core__image__center-caption.serialized.html | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/blocks/api/raw-handling/test/integration/google-docs-out.html b/blocks/api/raw-handling/test/integration/google-docs-out.html index 8cb94dc1bbcb8..d8242c4779198 100644 --- a/blocks/api/raw-handling/test/integration/google-docs-out.html +++ b/blocks/api/raw-handling/test/integration/google-docs-out.html @@ -60,6 +60,6 @@

This is a heading

-
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-online-out.html b/blocks/api/raw-handling/test/integration/ms-word-online-out.html index 997359fa84037..d7d6370dfc3ba 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-online-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-online-out.html @@ -50,5 +50,5 @@ -
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-out.html b/blocks/api/raw-handling/test/integration/ms-word-out.html index 3f4687910c6ce..b5d2e6ba1ca54 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-out.html @@ -85,5 +85,5 @@

This is a heading level 2

-
+
diff --git a/blocks/test/fixtures/core__image.html b/blocks/test/fixtures/core__image.html index 2a414855b0344..eda663561a38b 100644 --- a/blocks/test/fixtures/core__image.html +++ b/blocks/test/fixtures/core__image.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/test/fixtures/core__image.json b/blocks/test/fixtures/core__image.json index 89bdd5ba93cbc..0aaa9b4804a96 100644 --- a/blocks/test/fixtures/core__image.json +++ b/blocks/test/fixtures/core__image.json @@ -5,8 +5,9 @@ "isValid": true, "attributes": { "url": "https://cldup.com/uuUqE_dXzy.jpg", - "caption": [] + "caption": [], + "alt": "" }, - "originalContent": "
" + "originalContent": "
\"\"
" } ] diff --git a/blocks/test/fixtures/core__image.parsed.json b/blocks/test/fixtures/core__image.parsed.json index 4e50ecd68576d..eba958b3ec9a3 100644 --- a/blocks/test/fixtures/core__image.parsed.json +++ b/blocks/test/fixtures/core__image.parsed.json @@ -3,7 +3,7 @@ "blockName": "core/image", "attrs": null, "innerBlocks": [], - "innerHTML": "\n
\n" + "innerHTML": "\n
\"\"
\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__image.serialized.html b/blocks/test/fixtures/core__image.serialized.html index fb41212fe367e..bbe320d2bc140 100644 --- a/blocks/test/fixtures/core__image.serialized.html +++ b/blocks/test/fixtures/core__image.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/test/fixtures/core__image__center-caption.html b/blocks/test/fixtures/core__image__center-caption.html index 1973035e7c6e6..4fbce9c6fafd7 100644 --- a/blocks/test/fixtures/core__image__center-caption.html +++ b/blocks/test/fixtures/core__image__center-caption.html @@ -1,3 +1,3 @@ -
Give it a try. Press the "really wide" button on the image toolbar.
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/blocks/test/fixtures/core__image__center-caption.json b/blocks/test/fixtures/core__image__center-caption.json index c5465d7896235..dfd4d57389ac5 100644 --- a/blocks/test/fixtures/core__image__center-caption.json +++ b/blocks/test/fixtures/core__image__center-caption.json @@ -8,8 +8,9 @@ "caption": [ "Give it a try. Press the \"really wide\" button on the image toolbar." ], - "align": "center" + "align": "center", + "alt": "" }, - "originalContent": "
Give it a try. Press the "really wide" button on the image toolbar.
" + "originalContent": "
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
" } ] diff --git a/blocks/test/fixtures/core__image__center-caption.parsed.json b/blocks/test/fixtures/core__image__center-caption.parsed.json index b32c1f8fd1a0f..abd5611da1948 100644 --- a/blocks/test/fixtures/core__image__center-caption.parsed.json +++ b/blocks/test/fixtures/core__image__center-caption.parsed.json @@ -5,7 +5,7 @@ "align": "center" }, "innerBlocks": [], - "innerHTML": "\n
Give it a try. Press the "really wide" button on the image toolbar.
\n" + "innerHTML": "\n
\"\"
Give it a try. Press the "really wide" button on the image toolbar.
\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__image__center-caption.serialized.html b/blocks/test/fixtures/core__image__center-caption.serialized.html index 3dffbf76bc841..7b7acfcd4d09d 100644 --- a/blocks/test/fixtures/core__image__center-caption.serialized.html +++ b/blocks/test/fixtures/core__image__center-caption.serialized.html @@ -1,5 +1,5 @@ -
+
Give it a try. Press the "really wide" button on the image toolbar.
From 8295b4a56c730228b30b031bcea2f022fdbed4f0 Mon Sep 17 00:00:00 2001 From: audrasjb <[audrasjb@gmail.com]> Date: Tue, 16 Jan 2018 13:29:01 +0100 Subject: [PATCH 5/6] remove docs about default attribute in wrong section --- docs/attributes.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/attributes.md b/docs/attributes.md index a222c246a9987..d81c60470cb69 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -13,8 +13,6 @@ Under the hood, attribute sources are a superset of functionality provided by [h Use `attribute` to extract the value of an attribute from markup. _Example_: Extract the `src` attribute from an image found in the block's markup. -`default` parameter can be used to set a default value. -Images alt attribute default value should be set to `default: ''` (empty value) to follow WCAG criterias. ```js { @@ -22,7 +20,6 @@ Images alt attribute default value should be set to `default: ''` (empty value) source: 'attribute', selector: 'img', attribute: 'src', - default: 'https://example.com/image.png', } } // { "url": "https://lorempixel.com/1200/800/" } From 8e0674aad4f750b2568194b57df8862aee1216f4 Mon Sep 17 00:00:00 2001 From: audrasjb <[audrasjb@gmail.com]> Date: Tue, 16 Jan 2018 13:52:01 +0100 Subject: [PATCH 6/6] remove trailing space :s ' --- docs/attributes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/attributes.md b/docs/attributes.md index d81c60470cb69..059250a34d3f0 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -12,7 +12,7 @@ Under the hood, attribute sources are a superset of functionality provided by [h Use `attribute` to extract the value of an attribute from markup. -_Example_: Extract the `src` attribute from an image found in the block's markup. +_Example_: Extract the `src` attribute from an image found in the block's markup. ```js {