-
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.
Create rule S6854: iFrames must have a title (#3446)
- Loading branch information
1 parent
03512e6
commit 0303498
Showing
3 changed files
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"title": "iFrames must have a title", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "5min" | ||
}, | ||
"tags": [ | ||
"accessibility", | ||
"react" | ||
], | ||
"defaultSeverity": "Minor", | ||
"ruleSpecification": "RSPEC-6854", | ||
"sqKey": "S6854", | ||
"scope": "All", | ||
"defaultQualityProfiles": ["Sonar way"], | ||
"quickfix": "infeasible", | ||
"code": { | ||
"impacts": { | ||
"RELIABILITY": "LOW" | ||
}, | ||
"attribute": "CONVENTIONAL" | ||
} | ||
} |
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,42 @@ | ||
== Why is this an issue? | ||
|
||
An iframe, or inline frame, is an HTML document embedded inside another HTML document on a website. The iframe HTML element is often used to insert content from another source, such as an advertisement, into a web page. | ||
|
||
In the context of web accessibility, ``++<iframe>++``'s should have a ``++title++`` attribute. This is because screen readers for the visually impaired use this title to help users understand the content of the iframe. | ||
Without a title, it can be difficult for these users to understand the context or purpose of the iframe's content. | ||
== How to fix it | ||
To fix missing iframe titles, you simply need to add a ``++title++`` attribute to your ``++<iframe>++`` element. The value of this attribute should be a brief description of the iframe's content. | ||
=== Code examples | ||
==== Noncompliant code example | ||
[source,javascript,diff-id=1,diff-type=noncompliant] | ||
---- | ||
function iframe() { | ||
return ( | ||
<iframe src="https://openweathermap.org"></iframe> // Noncompliant | ||
); | ||
} | ||
---- | ||
==== Compliant solution | ||
[source,javascript,diff-id=1,diff-type=compliant] | ||
---- | ||
function iframe() { | ||
return ( | ||
<iframe src="https://openweathermap.org" title="Weather forecasts, nowcasts and history"></iframe> | ||
); | ||
} | ||
---- | ||
== Resources | ||
=== Documentation | ||
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe[iframe element] | ||
* WCAG - https://www.w3.org/WAI/WCAG21/Understanding/bypass-blocks[Bypass Blocks] | ||
* WCAG - https://www.w3.org/WAI/WCAG21/Understanding/name-role-value[Name, Role, Value] |
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,2 @@ | ||
{ | ||
} |