Skip to content

Commit

Permalink
fix: allow list of values for 'accessModeSufficient'
Browse files Browse the repository at this point in the history
Fixes #238
  • Loading branch information
rdeltour committed Jul 8, 2019
1 parent 0f9e656 commit 6cb5402
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/ace-core/src/checker/checker-epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ function checkMetadata(assertions, epub) {
if (!Array.isArray(values)) {
values = [values]
}
// Parse list values
values = values.map(value => value.trim().replace(',', ' ').replace(/\s{2,}/g, ' ').split(' '))
values = [].concat(...values);
// Check metadata values are allowed
// see https://www.w3.org/wiki/WebSchemas/Accessibility
if (meta.allowedValues) {
Expand Down
7 changes: 7 additions & 0 deletions tests/__tests__/epub-rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ describe('accessibility metadata', () => {
}),
}),
]));
expect(assertions).not.toEqual(expect.arrayContaining([
expect.objectContaining({
'earl:test': expect.objectContaining({
'dct:title': 'metadata-accessmodesufficient-invalid',
}),
}),
]));
});
test('`printPageNumbers` is declared as a feature but the Nav Doc has no page list', async () => {
const report = await ace('../data/epubrules-metadata-printPageNumbers-nopagelist');
Expand Down
2 changes: 1 addition & 1 deletion tests/data/epubrules-metadata/EPUB/package.opf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
<!-- Fail #2: bad metadata value -->
<meta property="schema:accessMode">text</meta>
<meta property="schema:accessModeSufficient">textual</meta>
<meta property="schema:accessModeSufficient">visual,textual</meta>
</metadata>
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
Expand Down

0 comments on commit 6cb5402

Please sign in to comment.