-
Notifications
You must be signed in to change notification settings - Fork 765
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
fix: Do not require media captions / descriptions #1075
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,27 @@ function hasUniqueId() { | |
}; | ||
} | ||
|
||
function hasTwoOutcomes(messages) { | ||
const keys = Object.keys(messages); | ||
if (keys.length < 2) { | ||
return false; | ||
} | ||
|
||
return keys.every(key => { | ||
switch (key) { | ||
case 'pass': | ||
case 'fail': | ||
return typeof messages[key] === 'string'; | ||
|
||
case 'incomplete': | ||
return ['string', 'object'].includes(typeof messages[key]); | ||
|
||
default: | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
function createSchemas() { | ||
var schemas = {}; | ||
|
||
|
@@ -84,16 +105,20 @@ function createSchemas() { | |
messages: { | ||
required: true, | ||
type: 'object', | ||
properties: { | ||
fail: { | ||
required: true, | ||
type: 'string' | ||
}, | ||
pass: { | ||
required: true, | ||
type: 'string' | ||
} | ||
conform: hasTwoOutcomes, | ||
messages: { | ||
conform: 'Must have at least two valid messages' | ||
} | ||
// propferties: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: 🤣 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, delete this comment |
||
// fail: { | ||
// required: true, | ||
// type: 'string' | ||
// }, | ||
// pass: { | ||
// required: true, | ||
// type: 'string' | ||
// } | ||
// } | ||
}, | ||
impact: { | ||
required: true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
var tracks = axe.utils.querySelectorAll(virtualNode, 'track'); | ||
const tracks = axe.utils.querySelectorAll(virtualNode, 'track'); | ||
const hasCaptions = tracks.some( | ||
({ actualNode }) => | ||
(actualNode.getAttribute('kind') || '').toLowerCase() === 'captions' | ||
); | ||
|
||
if (tracks.length) { | ||
// return false if any track has kind === 'caption' | ||
return !tracks.some( | ||
({ actualNode }) => | ||
(actualNode.getAttribute('kind') || '').toLowerCase() === 'captions' | ||
); | ||
} | ||
// Undefined if there are no tracks - media may be decorative | ||
return undefined; | ||
// Undefined if there are no tracks - media may use another caption method | ||
return hasCaptions ? false : undefined; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
"impact": "critical", | ||
"messages": { | ||
"pass": "The multimedia element has a captions track", | ||
"fail": "The multimedia element does not have a captions track", | ||
"incomplete": "A captions track for this element could not be found" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could make this message more explicit about what to do to check whether an alternative exists |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
var tracks = axe.utils.querySelectorAll(virtualNode, 'track'); | ||
const tracks = axe.utils.querySelectorAll(virtualNode, 'track'); | ||
const hasDescriptions = tracks.some( | ||
({ actualNode }) => | ||
(actualNode.getAttribute('kind') || '').toLowerCase() === 'descriptions' | ||
); | ||
|
||
if (tracks.length) { | ||
// return false if any track has kind === 'description' | ||
var out = !tracks.some( | ||
({ actualNode }) => | ||
(actualNode.getAttribute('kind') || '').toLowerCase() === 'descriptions' | ||
); | ||
return out; | ||
} | ||
// Undefined if there are no tracks - media may be decorative | ||
return undefined; | ||
// Undefined if there are no tracks - media may have another description method | ||
return hasDescriptions ? false : undefined; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<video id="incomplete1"></video> | ||
<video id="fail1"><track kind="descriptions"></video> | ||
<video id="incomplete2"><track kind="descriptions"></video> | ||
<video id="pass1"><track kind="captions"></video> | ||
<video id="pass2"><track kind="descriptions"><track kind="captions"></video> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"description": "video-caption test", | ||
"rule": "video-caption", | ||
"incomplete": [["#incomplete1"]], | ||
"violations": [["#fail1"]], | ||
"incomplete": [["#incomplete1"], ["#incomplete2"]], | ||
"passes": [["#pass1"], ["#pass2"]] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
<video id="incomplete1"></video> | ||
<video id="fail1"><track kind="captions"></video> | ||
<video id="incomplete2"><track kind="captions"></video> | ||
<video id="pass1"><track kind="descriptions"></video> | ||
<video id="pass2"><track kind="descriptions"><track kind="captions"></video> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"description": "video-description test", | ||
"rule": "video-description", | ||
"incomplete": [["#incomplete1"]], | ||
"violations": [["#fail1"]], | ||
"incomplete": [["#incomplete1"], ["#incomplete2"]], | ||
"passes": [["#pass1"], ["#pass2"]] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is normalising multiple outcomes, should change function name to something generic like
normaliseOutcomes
orhasMultipleOutcomes
rather than exactlyTwo
?