Skip to content

Commit

Permalink
Merge pull request #107 from futpib/master
Browse files Browse the repository at this point in the history
Fix `.visuallyhidden` not being actually hidden
  • Loading branch information
jlbooker authored Jan 12, 2017
2 parents a47d4b5 + 89dc484 commit e9696a4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/bloodhound.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.0.1
* typeahead.js 1.1.0
* https://github.com/twitter/typeahead.js
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -158,7 +158,7 @@
noop: function() {}
};
}();
var VERSION = "1.0.1";
var VERSION = "1.1.0";
var tokenizers = function() {
"use strict";
return {
Expand Down
4 changes: 2 additions & 2 deletions dist/bloodhound.min.js

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions dist/typeahead.bundle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.0.1
* typeahead.js 1.1.0
* https://github.com/twitter/typeahead.js
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -158,7 +158,7 @@
noop: function() {}
};
}();
var VERSION = "1.0.1";
var VERSION = "1.1.0";
var tokenizers = function() {
"use strict";
return {
Expand Down Expand Up @@ -2003,8 +2003,21 @@
var Status = function() {
"use strict";
function Status(options) {
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
this.$el = $(this.el);
this.$el = $("<span></span>", {
role: "status",
"aria-live": "polite"
}).css({
position: "absolute",
padding: "0",
border: "0",
height: "1px",
width: "1px",
"margin-bottom": "-1px",
"margin-right": "-1px",
overflow: "hidden",
clip: "rect(0 0 0 0)",
"white-space": "nowrap"
});
options.$input.after(this.$el);
_.each(options.menu.datasets, _.bind(function(dataset) {
if (dataset.onSync) {
Expand Down
6 changes: 3 additions & 3 deletions dist/typeahead.bundle.min.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions dist/typeahead.jquery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* typeahead.js 1.0.1
* typeahead.js 1.1.0
* https://github.com/twitter/typeahead.js
* Copyright 2013-2016 Twitter, Inc. and other contributors; Licensed MIT
*/
Expand Down Expand Up @@ -1056,8 +1056,21 @@
var Status = function() {
"use strict";
function Status(options) {
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
this.$el = $(this.el);
this.$el = $("<span></span>", {
role: "status",
"aria-live": "polite"
}).css({
position: "absolute",
padding: "0",
border: "0",
height: "1px",
width: "1px",
"margin-bottom": "-1px",
"margin-right": "-1px",
overflow: "hidden",
clip: "rect(0 0 0 0)",
"white-space": "nowrap"
});
options.$input.after(this.$el);
_.each(options.menu.datasets, _.bind(function(dataset) {
if (dataset.onSync) {
Expand Down
4 changes: 2 additions & 2 deletions dist/typeahead.jquery.min.js

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions src/typeahead/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ var Status = (function () {
'use strict';

function Status(options) {
this.el = '<span role="status" aria-live="polite" class="visuallyhidden"></span>';
this.$el = $(this.el);
this.$el = $('<span></span>', {
'role': 'status',
'aria-live': 'polite',
}).css({
// This `.visuallyhidden` style is inspired by HTML5 Boilerplate
// https://github.com/h5bp/html5-boilerplate/blob/fea7f22/src/css/main.css#L128
'position': 'absolute',
'padding': '0',
'border': '0',
'height': '1px',
'width': '1px',
'margin-bottom': '-1px',
'margin-right': '-1px',
'overflow': 'hidden',
'clip': 'rect(0 0 0 0)',
'white-space': 'nowrap',
});
options.$input.after(this.$el);
_.each(options.menu.datasets, _.bind(function (dataset) {
if (dataset.onSync) {
Expand Down
16 changes: 15 additions & 1 deletion test/typeahead/status_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,24 @@ describe('Status', function() {
});

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

it('renders a status element that is visible to screen readers', function () {
expect(status.$el.attr('aria-hidden')).not.toEqual('true');
expect(status.$el.css('display')).not.toEqual('none');
expect(status.$el.css('visibility')).not.toEqual('hidden');
expect(status.$el.height()).not.toEqual(0);
expect(status.$el.width()).not.toEqual(0);
});

it('renders a status element that is hidden on displays', function () {
expect(status.$el.outerHeight(true)).toEqual(0);
expect(status.$el.outerWidth(true)).toEqual(0);
});

describe('when rendered is triggered on the datasets', function() {

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

0 comments on commit e9696a4

Please sign in to comment.