Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add advice over empty valued <option> in required <select> #406

Merged
merged 4 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/a11y-ar.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ar_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ar_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ar_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en_advices-only.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en_errors-only.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-en_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-es.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-es_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-es_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-es_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-fr.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-fr_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-fr_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-fr_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-gr.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-gr_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-gr_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-gr_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-pt-br.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-pt-br_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-pt-br_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-pt-br_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ru.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ru_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ru_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-ru_warning.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-zh.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-zh_error.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-zh_obsolete.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/a11y-zh_warning.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/Hologram/test-assets/_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<option value="ru" lang="ru">русский</option>
<option value="zh" lang="zh">中文</option>
<option value="gr" lang="gr">ελληνικά</option>
<option value="es" lang="es">Español</option>
</select>
</p>
</fieldset>
Expand Down
1 change: 1 addition & 0 deletions locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "مصصم كجدول",
"advice:no-href": "رابط من غير هدف",
"advice:no-https": "لا يوجد HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "توزيع شريط البحث",
"error:empty-href": "المصدر غير موجود[href]",
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Layout table",
"advice:no-href": "Link without target",
"advice:no-https": "No HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "Disrupting tab order",
"error:empty-href": "Empty [href]",
Expand Down
1 change: 1 addition & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Diseño con tablas",
"advice:no-href": "Enlace sin destino",
"advice:no-https": "No HTTPS",
"advice:select-option-not-empty": "<select required> debe empezar con <option value=\"\">",

"error:tab-order": "Orden de pestaña disruptivo",
"error:empty-href": "[href] vacío",
Expand Down
1 change: 1 addition & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Tableau de mise en forme",
"advice:no-href": "Lien sans cible",
"advice:no-https": "Pas de HTTPS",
"advice:select-option-not-empty": "Un <select required> devrait débuter par <option value=\"\"",

"error:tab-order": "Ordre de tabulation perturbé",
"error:empty-href": "[href] vide",
Expand Down
1 change: 1 addition & 0 deletions locales/gr.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Δεδομένα σε πίνακα διάταξης.",
"advice:no-href": "Σύνδεσμος χωρίς διεύθυνση.",
"advice:no-https": "Ο σύνδεσμος δεν είναι HTTPS.",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "[tabindex] > 0",
"error:empty-href": "Κενή ιδιότητα [href].",
Expand Down
1 change: 1 addition & 0 deletions locales/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Layout table",
"advice:no-href": "Link sem destino",
"advice:no-https": "Sem HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "Interrupção da ordem da aba",
"error:empty-href": "Vazio [href]",
Expand Down
1 change: 1 addition & 0 deletions locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "Таблица используемая для разметки страницы",
"advice:no-href": "Пропущен [href] у ссылки",
"advice:no-https": "Нет HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "Некорректное значение tabindex",
"error:empty-href": "Пустой атрибут [href]",
Expand Down
1 change: 1 addition & 0 deletions locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"advice:table-presentation": "确认这个 [table] 元素是用于布局而非展示数据",
"advice:no-href": "缺少 [href]",
"advice:no-https": "缺少 HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",

"error:tab-order": "标签页位置不正确",
"error:empty-href": "[href] 为空",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_ar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "مصصم كجدول",
"advice:no-href": "رابط من غير هدف",
"advice:no-https": "لا يوجد HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "توزيع شريط البحث",
"error:empty-href": "المصدر غير موجود[href]",
"error:empty-link": " الرابط غير موجود...",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_en.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Layout table",
"advice:no-href": "Link without target",
"advice:no-https": "No HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "Disrupting tab order",
"error:empty-href": "Empty [href]",
"error:empty-link": "Empty link…",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_es.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Diseño con tablas",
"advice:no-href": "Enlace sin destino",
"advice:no-https": "No HTTPS",
"advice:select-option-not-empty": "<select required> debe empezar con <option value=\"\">",
"error:tab-order": "Orden de pestaña disruptivo",
"error:empty-href": "[href] vacío",
"error:empty-link": "Enlace vacío…",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_fr.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Tableau de mise en forme",
"advice:no-href": "Lien sans cible",
"advice:no-https": "Pas de HTTPS",
"advice:select-option-not-empty": "Un <select required> devrait débuter par <option value=\"\"",
"error:tab-order": "Ordre de tabulation perturbé",
"error:empty-href": "[href] vide",
"error:empty-link": "Lien vide",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_gr.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Δεδομένα σε πίνακα διάταξης.",
"advice:no-href": "Σύνδεσμος χωρίς διεύθυνση.",
"advice:no-https": "Ο σύνδεσμος δεν είναι HTTPS.",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "[tabindex] > 0",
"error:empty-href": "Κενή ιδιότητα [href].",
"error:empty-link": "Κενός σύνδεσμος.",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_pt-br.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Layout table",
"advice:no-href": "Link sem destino",
"advice:no-https": "Sem HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "Interrupção da ordem da aba",
"error:empty-href": "Vazio [href]",
"error:empty-link": "Vazio link…",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_ru.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "Таблица используемая для разметки страницы",
"advice:no-href": "Пропущен [href] у ссылки",
"advice:no-https": "Нет HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "Некорректное значение tabindex",
"error:empty-href": "Пустой атрибут [href]",
"error:empty-link": "Пустая ссылка…",
Expand Down
1 change: 1 addition & 0 deletions sass/locales/_zh.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $messages: (
"advice:table-presentation": "确认这个 [table] 元素是用于布局而非展示数据",
"advice:no-href": "缺少 [href]",
"advice:no-https": "缺少 HTTPS",
"advice:select-option-not-empty": "<select required> should start with <option value=\"\">",
"error:tab-order": "标签页位置不正确",
"error:empty-href": "[href] 为空",
"error:empty-link": "空链接",
Expand Down
35 changes: 35 additions & 0 deletions sass/themes/_advice.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
@charset 'UTF-8';


/*doc
---
title: "<select required> should start with an empty <option>'s [value]"
name: empty-option-on-select
category: Advices
---

## Description
A `<select required>` element, which isn't neither `[multiple]` nor `[size]` greater than `1`, should start with an empty `<option>`. That being said, you may use a placeholder content for this option but must ensure to use an empty `[value]` attribute; or set a `[size]` attributes to the `<select>`, which value should equal to the number of `<option>`s.
ffoodd marked this conversation as resolved.
Show resolved Hide resolved

## References
* <https://twitter.com/WebPlatformNews/status/1346492730223058946>
* <https://html.spec.whatwg.org/multipage/form-elements.html#placeholder-label-option>
* <https://validator.w3.org/nu/?showsource=yes&doc=https%3A%2F%2Fjsbin.com%2Ftozopid%2Fquiet>

## Selector
```css_example
select[required]:not([multiple])[size="1"],
select[required]:not([multiple]):not([size])
```

## Test
```html_example
<select name="slices" required>
<option value="1">Cheese</option>
<option value="2">Salami</option>
</select><span>†</span>
ffoodd marked this conversation as resolved.
Show resolved Hide resolved
```
*/
select[required]:not([multiple])[size="1"],
select[required]:not([multiple]):not([size]) {
@include advice('select-option-not-empty', $self-closing: true);
}


/*doc
---
title: "Empty [class] attribute"
Expand Down