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 .visuallyhidden not being actually hidden #107

Merged
merged 2 commits into from
Jan 12, 2017
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
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