Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waterdataui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
Internet of Water
waterdataui
Commits
803bea12
Commit
803bea12
authored
7 years ago
by
Yan, Andrew N.
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:usgs/waterdataui into wdfn-62-masking-qualifiers
parents
17f6a6fa
3d21b3ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
assets/src/scripts/accessibility.js
+7
-3
7 additions, 3 deletions
assets/src/scripts/accessibility.js
assets/src/scripts/accessibility.spec.js
+30
-3
30 additions, 3 deletions
assets/src/scripts/accessibility.spec.js
with
37 additions
and
6 deletions
assets/src/scripts/accessibility.js
+
7
−
3
View file @
803bea12
...
@@ -7,9 +7,13 @@
...
@@ -7,9 +7,13 @@
* @param {Boolean} isInteractive
* @param {Boolean} isInteractive
*/
*/
function
addSVGAccessibility
(
svg
,
{
title
,
description
,
isInteractive
})
{
function
addSVGAccessibility
(
svg
,
{
title
,
description
,
isInteractive
})
{
svg
.
attr
(
'
title
'
,
title
)
svg
.
selectAll
(
'
title, desc
'
).
remove
();
.
attr
(
'
desc
'
,
description
)
.
attr
(
'
aria-labelledby
'
,
'
title desc
'
);
svg
.
insert
(
'
desc
'
,
'
:first-child
'
)
.
html
(
description
);
svg
.
insert
(
'
title
'
,
'
:first-child
'
)
.
html
(
title
);
svg
.
attr
(
'
aria-labelledby
'
,
'
title desc
'
);
if
(
isInteractive
)
{
if
(
isInteractive
)
{
svg
.
attr
(
'
tabindex
'
,
0
);
svg
.
attr
(
'
tabindex
'
,
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
assets/src/scripts/accessibility.spec.js
+
30
−
3
View file @
803bea12
...
@@ -13,20 +13,47 @@ describe('svgAccessibility tests', () => {
...
@@ -13,20 +13,47 @@ describe('svgAccessibility tests', () => {
svg
.
remove
();
svg
.
remove
();
});
});
it
(
'
Should add a title
,
desc
,
and aria attributes
'
,
()
=>
{
it
(
'
Should add a title
and
desc
tags
and aria attributes
'
,
()
=>
{
addSVGAccessibility
(
svg
,
{
addSVGAccessibility
(
svg
,
{
title
:
'
This is a title
'
,
title
:
'
This is a title
'
,
description
:
'
This is a description
'
,
description
:
'
This is a description
'
,
isInteractive
:
false
isInteractive
:
false
});
});
expect
(
svg
.
attr
(
'
title
'
)).
toBe
(
'
This is a title
'
);
const
title
=
svg
.
selectAll
(
'
title
'
);
expect
(
svg
.
attr
(
'
desc
'
)).
toBe
(
'
This is a description
'
);
const
desc
=
svg
.
selectAll
(
'
desc
'
);
expect
(
title
.
size
()).
toBe
(
1
);
expect
(
desc
.
size
()).
toBe
(
1
);
expect
(
title
.
html
()).
toEqual
(
'
This is a title
'
);
expect
(
desc
.
html
()).
toEqual
(
'
This is a description
'
);
const
labelledBy
=
svg
.
attr
(
'
aria-labelledby
'
);
const
labelledBy
=
svg
.
attr
(
'
aria-labelledby
'
);
expect
(
labelledBy
).
toContain
(
'
title
'
);
expect
(
labelledBy
).
toContain
(
'
title
'
);
expect
(
labelledBy
).
toContain
(
'
desc
'
);
expect
(
labelledBy
).
toContain
(
'
desc
'
);
});
});
it
(
'
Should remove the previous title and desc tags when called again
'
,
()
=>
{
addSVGAccessibility
(
svg
,
{
title
:
'
This is a title
'
,
description
:
'
This is a description
'
,
isInteractive
:
false
});
addSVGAccessibility
(
svg
,
{
title
:
'
That is a title
'
,
description
:
'
That is a description
'
,
isInteractive
:
false
});
const
title
=
svg
.
selectAll
(
'
title
'
);
const
desc
=
svg
.
selectAll
(
'
desc
'
);
expect
(
title
.
size
()).
toBe
(
1
);
expect
(
desc
.
size
()).
toBe
(
1
);
expect
(
title
.
html
()).
toEqual
(
'
That is a title
'
);
expect
(
desc
.
html
()).
toEqual
(
'
That is a description
'
);
});
it
(
'
Should not add a tabindex if isInteractive is false
'
,
()
=>
{
it
(
'
Should not add a tabindex if isInteractive is false
'
,
()
=>
{
addSVGAccessibility
(
svg
,
{
addSVGAccessibility
(
svg
,
{
title
:
'
This is a title
'
,
title
:
'
This is a title
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment