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

fix: allow any role on a elem with no href #1026

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@

## Contextual Hyperlink: <a>

a.elem.phrasing =
element a { a.inner.phrasing & a.attrs }
a.elem.flow =
element a { a.inner.flow & a.attrs }
a.attrs =
( common.attrs.basic
& common.attrs.i18n
& common.attrs.present
& common.attrs.other
& a.attrs.name?
& shared-hyperlink.attrs.download?
& shared-hyperlink.attrs.href?
& shared-hyperlink.attrs.target?
& shared-hyperlink.attrs.rel?
& shared-hyperlink.attrs.hreflang?
& shared-hyperlink.attrs.type?
& shared-hyperlink.attrs.ping?
& referrerpolicy?
a.elem.phrasing = a.href.elem.phrasing | a.nohref.elem.phrasing
a.elem.flow = a.href.elem.flow | a.nohref.elem.flow
a.href.elem.phrasing =
element a { a.inner.phrasing & a.href.attrs }
a.href.elem.flow =
element a { a.inner.flow & a.href.attrs }
a.nohref.elem.phrasing =
element a { a.inner.phrasing & a.nohref.attrs }
a.nohref.elem.flow =
element a { a.inner.flow & a.nohref.attrs }
a.href.attrs =
( a.attrs
& shared-hyperlink.attrs.href
& ( common.attrs.aria.implicit.link
| common.attrs.aria.role.button
| common.attrs.aria.role.checkbox
Expand All @@ -41,6 +36,24 @@
| common.attrs.aria.role.doc-noteref
)?
)
a.nohref.attrs =
( a.attrs
& common.attrs.aria?
)
a.attrs =
( common.attrs.basic
& common.attrs.i18n
& common.attrs.present
& common.attrs.other
& a.attrs.name?
& shared-hyperlink.attrs.download?
& shared-hyperlink.attrs.target?
& shared-hyperlink.attrs.rel?
& shared-hyperlink.attrs.hreflang?
& shared-hyperlink.attrs.type?
& shared-hyperlink.attrs.ping?
& referrerpolicy?
)
a.attrs.name =
attribute name {
common.data.id # XXX not what the spec says
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/adobe/epubcheck/ops/OPSCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ public void setup()
expectedUsage.clear();
}

@Test
public void testARIARoleOnAElemWithNoHref()
{
// test that any role is allowed on `a` elem with no `href` attribute.
// the test case specifically tests the `doc-pagebreak` role.
testValidateDocument("xhtml/valid/aria-role-a-nohref.xhtml", "application/xhtml+xml",
EPUBVersion.VERSION_3);
}

@Test
public void testValidateXHTMLEdits001()
{
Expand Down
12 changes: 12 additions & 0 deletions src/test/resources/30/single/xhtml/valid/aria-role-a-nohref.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Test</title>
<meta charset="UTF-8"/>
</head>
<body>
<h1>Test</h1>
<!-- this is allowed by ARIA in HTML, but not a good practice -->
<a role="doc-pagebreak">1</a>
</body>
</html>