Skip to content

Commit e9696a4

Browse files
authored
Merge pull request #107 from futpib/master
Fix `.visuallyhidden` not being actually hidden
2 parents a47d4b5 + 89dc484 commit e9696a4

8 files changed

+74
-19
lines changed

dist/bloodhound.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* typeahead.js 1.0.1
2+
* typeahead.js 1.1.0
33
* https://github.com/twitter/typeahead.js
44
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
55
*/
@@ -158,7 +158,7 @@
158158
noop: function() {}
159159
};
160160
}();
161-
var VERSION = "1.0.1";
161+
var VERSION = "1.1.0";
162162
var tokenizers = function() {
163163
"use strict";
164164
return {

dist/bloodhound.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typeahead.bundle.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* typeahead.js 1.0.1
2+
* typeahead.js 1.1.0
33
* https://github.com/twitter/typeahead.js
44
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
55
*/
@@ -158,7 +158,7 @@
158158
noop: function() {}
159159
};
160160
}();
161-
var VERSION = "1.0.1";
161+
var VERSION = "1.1.0";
162162
var tokenizers = function() {
163163
"use strict";
164164
return {
@@ -2003,8 +2003,21 @@
20032003
var Status = function() {
20042004
"use strict";
20052005
function Status(options) {
2006-
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
2007-
this.$el = $(this.el);
2006+
this.$el = $("<span></span>", {
2007+
role: "status",
2008+
"aria-live": "polite"
2009+
}).css({
2010+
position: "absolute",
2011+
padding: "0",
2012+
border: "0",
2013+
height: "1px",
2014+
width: "1px",
2015+
"margin-bottom": "-1px",
2016+
"margin-right": "-1px",
2017+
overflow: "hidden",
2018+
clip: "rect(0 0 0 0)",
2019+
"white-space": "nowrap"
2020+
});
20082021
options.$input.after(this.$el);
20092022
_.each(options.menu.datasets, _.bind(function(dataset) {
20102023
if (dataset.onSync) {

dist/typeahead.bundle.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typeahead.jquery.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* typeahead.js 1.0.1
2+
* typeahead.js 1.1.0
33
* https://github.com/twitter/typeahead.js
44
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
55
*/
@@ -1056,8 +1056,21 @@
10561056
var Status = function() {
10571057
"use strict";
10581058
function Status(options) {
1059-
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
1060-
this.$el = $(this.el);
1059+
this.$el = $("<span></span>", {
1060+
role: "status",
1061+
"aria-live": "polite"
1062+
}).css({
1063+
position: "absolute",
1064+
padding: "0",
1065+
border: "0",
1066+
height: "1px",
1067+
width: "1px",
1068+
"margin-bottom": "-1px",
1069+
"margin-right": "-1px",
1070+
overflow: "hidden",
1071+
clip: "rect(0 0 0 0)",
1072+
"white-space": "nowrap"
1073+
});
10611074
options.$input.after(this.$el);
10621075
_.each(options.menu.datasets, _.bind(function(dataset) {
10631076
if (dataset.onSync) {

dist/typeahead.jquery.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/typeahead/status.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@ var Status = (function () {
22
'use strict';
33

44
function Status(options) {
5-
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
6-
this.$el = $(this.el);
5+
this.$el = $('<span></span>', {
6+
'role': 'status',
7+
'aria-live': 'polite',
8+
}).css({
9+
// This `.visuallyhidden` style is inspired by HTML5 Boilerplate
10+
// https://github.com/h5bp/html5-boilerplate/blob/fea7f22/src/css/main.css#L128
11+
'position': 'absolute',
12+
'padding': '0',
13+
'border': '0',
14+
'height': '1px',
15+
'width': '1px',
16+
'margin-bottom': '-1px',
17+
'margin-right': '-1px',
18+
'overflow': 'hidden',
19+
'clip': 'rect(0 0 0 0)',
20+
'white-space': 'nowrap',
21+
});
722
options.$input.after(this.$el);
823
_.each(options.menu.datasets, _.bind(function (dataset) {
924
if (dataset.onSync) {

test/typeahead/status_spec.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,24 @@ describe('Status', function() {
2525
});
2626

2727
it('renders a status element after the input', function() {
28-
expect(status.el).toEqual('<span role="status" aria-live="polite" class="visuallyhidden"></span>');
28+
expect(status.$el.attr('role')).toEqual('status');
29+
expect(status.$el.attr('aria-live')).toEqual('polite');
2930
expect(status.$el.prev()).toEqual(this.$input);
3031
});
3132

33+
it('renders a status element that is visible to screen readers', function () {
34+
expect(status.$el.attr('aria-hidden')).not.toEqual('true');
35+
expect(status.$el.css('display')).not.toEqual('none');
36+
expect(status.$el.css('visibility')).not.toEqual('hidden');
37+
expect(status.$el.height()).not.toEqual(0);
38+
expect(status.$el.width()).not.toEqual(0);
39+
});
40+
41+
it('renders a status element that is hidden on displays', function () {
42+
expect(status.$el.outerHeight(true)).toEqual(0);
43+
expect(status.$el.outerWidth(true)).toEqual(0);
44+
});
45+
3246
describe('when rendered is triggered on the datasets', function() {
3347

3448
it('should update the status text based on number of suggestion', function() {

0 commit comments

Comments
 (0)