-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add javascript to rule S5264 * Add rule S5264 to JS --------- Co-authored-by: vdiez <vdiez@users.noreply.github.com> Co-authored-by: Victor <victor.diez@sonarsource.com>
- Loading branch information
1 parent
491634b
commit 2e71406
Showing
9 changed files
with
92 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Provide alternative content to ``++<object>++`` elements. | ||
|
||
[source,html,diff-id=1,diff-type=compliant] | ||
---- | ||
<object>This application shows the simulation of two particles colliding</object> | ||
<object> | ||
<img src="flower.png" alt="Flower growing in a pot" /> | ||
</object> | ||
<object> | ||
<object> | ||
This application shows the simulation of two particles colliding | ||
</object> | ||
</object> | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,2 @@ | ||
{ | ||
"title": "\"<object>\" tags should provide an alternative content", | ||
"type": "CODE_SMELL", | ||
"code": { | ||
"impacts": { | ||
"MAINTAINABILITY": "LOW" | ||
}, | ||
"attribute": "COMPLETE" | ||
}, | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "2min" | ||
}, | ||
"tags": [ | ||
"accessibility", | ||
"wcag2-a" | ||
], | ||
"extra": { | ||
"replacementRules": [ | ||
|
||
], | ||
"legacyKeys": [ | ||
|
||
] | ||
}, | ||
"defaultSeverity": "Minor", | ||
"ruleSpecification": "RSPEC-5264", | ||
"sqKey": "S5264", | ||
"scope": "All", | ||
"defaultQualityProfiles": [ | ||
"Sonar way" | ||
], | ||
"quickfix": "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,5 @@ | ||
== Why is this an issue? | ||
include::../why.adoc[] | ||
|
||
Assistive technologies, such as screen readers, will not be able to render ``++<object>++`` elements, in such cases it is the content of the ``++<object>++`` which is provided to the user. This alternative content needs to be accessible or the screen readers won't be able to use it. For example, if an ``++<img>++`` is used it must contain an ``++alt++`` attribute (see corresponding rule Web:ImgWithoutAltCheck). | ||
include::../fix.adoc[] | ||
|
||
|
||
This rule raises an issue when an ``++<object>++`` tag does not have any alternative content. | ||
|
||
|
||
=== Noncompliant code example | ||
|
||
[source,html] | ||
---- | ||
<object></object> <!-- Noncompliant --> | ||
<object> | ||
<object></object> <!-- Noncompliant --> | ||
</object> | ||
---- | ||
|
||
|
||
=== Compliant solution | ||
|
||
[source,html] | ||
---- | ||
<object>This application shows the simulation of two particles colliding</object> | ||
<object> | ||
<img src="flower.png" alt="Flower growing in a pot" /> | ||
</object> | ||
<object> | ||
<object> | ||
This application shows the simulation of two particles colliding | ||
</object> | ||
</object> | ||
---- | ||
|
||
|
||
== Resources | ||
|
||
* https://www.w3.org/TR/WCAG20-TECHS/H53.html[WCAG2, H53] - Using the body of the object element | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-text-equiv-all[WCAG2, 1.1.1] - Non-text Content | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-media-equiv-audio-desc[WCAG2, 1.2.3] - Audio Description or Media Alternative (Prerecorded) | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-media-equiv-text-doc[WCAG2, 1.2.8] - Media Alternative (Prerecorded) | ||
|
||
ifdef::env-github,rspecator-view[] | ||
|
||
''' | ||
== Implementation Specification | ||
(visible only on this page) | ||
|
||
=== Message | ||
|
||
Add an accessible content to this "<object>" tag. | ||
|
||
|
||
=== Highlighting | ||
|
||
The opening <object> tag without its content | ||
|
||
|
||
endif::env-github,rspecator-view[] | ||
include::../resources.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tags": [ | ||
"accessibility", | ||
"wcag2-a", | ||
"react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include::../why.adoc[] | ||
|
||
include::../fix.adoc[] | ||
|
||
include::../resources.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,35 @@ | ||
{ | ||
"title": "\"<object>\" tags should provide an alternative content", | ||
"type": "CODE_SMELL", | ||
"code": { | ||
"impacts": { | ||
"MAINTAINABILITY": "LOW" | ||
}, | ||
"attribute": "COMPLETE" | ||
}, | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "2min" | ||
}, | ||
"tags": [ | ||
"accessibility", | ||
"wcag2-a" | ||
], | ||
"extra": { | ||
"replacementRules": [ | ||
|
||
], | ||
"legacyKeys": [ | ||
|
||
] | ||
}, | ||
"defaultSeverity": "Minor", | ||
"ruleSpecification": "RSPEC-5264", | ||
"sqKey": "S5264", | ||
"scope": "All", | ||
"defaultQualityProfiles": [ | ||
"Sonar way" | ||
], | ||
"quickfix": "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
== Resources | ||
|
||
* https://www.w3.org/TR/WCAG20-TECHS/H53.html[WCAG2, H53] - Using the body of the object element | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-text-equiv-all[WCAG2, 1.1.1] - Non-text Content | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-media-equiv-audio-desc[WCAG2, 1.2.3] - Audio Description or Media Alternative (Prerecorded) | ||
* https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-media-equiv-text-doc[WCAG2, 1.2.8] - Media Alternative (Prerecorded) | ||
=== Related rules | ||
|
||
* Web:ImgWithoutAltCheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
== Why is this an issue? | ||
|
||
The ``++<object>++`` HTML element represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin. The element's children are the fallback content. This allows multiple object elements to be nested inside each other, targeting multiple user agents with different capabilities, with the user agent picking the first one it supports. | ||
|
||
Assistive technologies, such as screen readers, will not be able to render ``++<object>++`` elements, in such cases it is the content of the ``++<object>++`` which is provided to the user. This alternative content needs to be accessible or the screen readers won't be able to use it. For example, if an ``++<img>++`` is used it must contain an ``++alt++`` attribute. | ||
|
||
This rule raises an issue when an ``++<object>++`` tag does not have any alternative content. | ||
|
||
[source,html,diff-id=1,diff-type=noncompliant] | ||
---- | ||
<object></object> <!-- Noncompliant --> | ||
<object> | ||
<object></object> <!-- Noncompliant --> | ||
</object> | ||
---- |