🌐 AI搜索 & 代理 主页
Skip to content

Commit 77c43a7

Browse files
Fix aria warnings in Chrome lighthouse, make aria spec compliant (#197)
* remove initial empty aria-activedescendant, remove aria-readonly, fix aria-owns * remove unneeded bind from previous commit * add aria-expanded attr to input to fix lighthouse issue * remove console logs * add yarn.lock * update package.json name * fix lighthouse tt-hint accessibility issue * 1.2.3 * fix tests * rebuild dist * rebuild dist, fix wrong boolean * remove yarn.lock * change travis version, bump package version, rebuild dist * Update package.json Co-Authored-By: Juliano Marques Nunes <julianomarquesnunes@gmail.com> Co-authored-by: Juliano Marques Nunes <julianomarquesnunes@gmail.com>
1 parent 662ee46 commit 77c43a7

File tree

11 files changed

+116
-82
lines changed

11 files changed

+116
-82
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
- secure: VY4J2ERfrMEin++f4+UDDtTMWLuE3jaYAVchRxfO2c6PQUYgR+SW4SMekz855U/BuptMtiVMR2UUoNGMgOSKIFkIXpPfHhx47G5a541v0WNjXfQ2qzivXAWaXNK3l3C58z4dKxgPWsFY9JtMVCddJd2vQieAILto8D8G09p7bpo=
1818
- secure: kehbNCoYUG2gLnhmCH/oKhlJG6LoxgcOPMCtY7KOI4ropG8qlypb+O2b/19+BWeO3aIuMB0JajNh3p2NL0UKgLmUK7EYBA9fQz+vesFReRk0V/KqMTSxHJuseM4aLOWA2Wr9US843VGltfODVvDN5sNrfY7RcoRx2cTK/k1CXa8=
1919
node_js:
20-
- "4.1"
20+
- "10.18.0"
2121
cache:
2222
directories:
2323
- node_modules

dist/bloodhound.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* typeahead.js 1.3.0
2+
* typeahead.js 1.3.1
33
* https://github.com/corejavascript/typeahead.js
4-
* Copyright 2013-2019 Twitter, Inc. and other contributors; Licensed MIT
4+
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
55
*/
66

77

@@ -159,7 +159,7 @@
159159
noop: function() {}
160160
};
161161
}();
162-
var VERSION = "1.3.0";
162+
var VERSION = "1.3.1";
163163
var tokenizers = function() {
164164
"use strict";
165165
return {

dist/bloodhound.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typeahead.bundle.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* typeahead.js 1.3.0
2+
* typeahead.js 1.3.1
33
* https://github.com/corejavascript/typeahead.js
4-
* Copyright 2013-2019 Twitter, Inc. and other contributors; Licensed MIT
4+
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
55
*/
66

77

@@ -159,7 +159,7 @@
159159
noop: function() {}
160160
};
161161
}();
162-
var VERSION = "1.3.0";
162+
var VERSION = "1.3.1";
163163
var tokenizers = function() {
164164
"use strict";
165165
return {
@@ -1430,21 +1430,26 @@
14301430
40: "down"
14311431
};
14321432
function Input(o, www) {
1433+
var id;
14331434
o = o || {};
14341435
if (!o.input) {
14351436
$.error("input is missing");
14361437
}
14371438
www.mixin(this);
14381439
this.$hint = $(o.hint);
14391440
this.$input = $(o.input);
1441+
this.$menu = $(o.menu);
1442+
id = this.$input.attr("id") || _.guid();
1443+
this.$menu.attr("id", id + "_listbox");
1444+
this.$hint.attr({
1445+
"aria-hidden": true
1446+
});
14401447
this.$input.attr({
1441-
"aria-activedescendant": "",
1442-
"aria-owns": this.$input.attr("id") + "_listbox",
1448+
"aria-owns": id + "_listbox",
14431449
role: "combobox",
1444-
"aria-readonly": "true",
1445-
"aria-autocomplete": "list"
1450+
"aria-autocomplete": "list",
1451+
"aria-expanded": false
14461452
});
1447-
$(www.menu).attr("id", this.$input.attr("id") + "_listbox");
14481453
this.query = this.$input.val();
14491454
this.queryWhenFocused = this.hasFocus() ? this.query : null;
14501455
this.$overflowHelper = buildOverflowHelper(this.$input);
@@ -1617,6 +1622,9 @@
16171622
this.$input.off(".tt");
16181623
this.$overflowHelper.remove();
16191624
this.$hint = this.$input = this.$overflowHelper = $("<div>");
1625+
},
1626+
setAriaExpanded: function setAriaExpanded(value) {
1627+
this.$input.attr("aria-expanded", value);
16201628
}
16211629
});
16221630
return Input;
@@ -2307,6 +2315,7 @@
23072315
},
23082316
open: function open() {
23092317
if (!this.isOpen() && !this.eventBus.before("open")) {
2318+
this.input.setAriaExpanded(true);
23102319
this.menu.open();
23112320
this._updateHint();
23122321
this.eventBus.trigger("open");
@@ -2315,6 +2324,7 @@
23152324
},
23162325
close: function close() {
23172326
if (this.isOpen() && !this.eventBus.before("close")) {
2327+
this.input.setAriaExpanded(false);
23182328
this.menu.close();
23192329
this.input.clearHint();
23202330
this.input.resetInputValue();
@@ -2433,7 +2443,8 @@
24332443
});
24342444
input = new Input({
24352445
hint: $hint,
2436-
input: $input
2446+
input: $input,
2447+
menu: $menu
24372448
}, www);
24382449
menu = new MenuConstructor({
24392450
node: $menu,

dist/typeahead.bundle.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typeahead.jquery.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* typeahead.js 1.3.0
2+
* typeahead.js 1.3.1
33
* https://github.com/corejavascript/typeahead.js
4-
* Copyright 2013-2019 Twitter, Inc. and other contributors; Licensed MIT
4+
* Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
55
*/
66

77

@@ -483,21 +483,26 @@
483483
40: "down"
484484
};
485485
function Input(o, www) {
486+
var id;
486487
o = o || {};
487488
if (!o.input) {
488489
$.error("input is missing");
489490
}
490491
www.mixin(this);
491492
this.$hint = $(o.hint);
492493
this.$input = $(o.input);
494+
this.$menu = $(o.menu);
495+
id = this.$input.attr("id") || _.guid();
496+
this.$menu.attr("id", id + "_listbox");
497+
this.$hint.attr({
498+
"aria-hidden": true
499+
});
493500
this.$input.attr({
494-
"aria-activedescendant": "",
495-
"aria-owns": this.$input.attr("id") + "_listbox",
501+
"aria-owns": id + "_listbox",
496502
role: "combobox",
497-
"aria-readonly": "true",
498-
"aria-autocomplete": "list"
503+
"aria-autocomplete": "list",
504+
"aria-expanded": false
499505
});
500-
$(www.menu).attr("id", this.$input.attr("id") + "_listbox");
501506
this.query = this.$input.val();
502507
this.queryWhenFocused = this.hasFocus() ? this.query : null;
503508
this.$overflowHelper = buildOverflowHelper(this.$input);
@@ -670,6 +675,9 @@
670675
this.$input.off(".tt");
671676
this.$overflowHelper.remove();
672677
this.$hint = this.$input = this.$overflowHelper = $("<div>");
678+
},
679+
setAriaExpanded: function setAriaExpanded(value) {
680+
this.$input.attr("aria-expanded", value);
673681
}
674682
});
675683
return Input;
@@ -1360,6 +1368,7 @@
13601368
},
13611369
open: function open() {
13621370
if (!this.isOpen() && !this.eventBus.before("open")) {
1371+
this.input.setAriaExpanded(true);
13631372
this.menu.open();
13641373
this._updateHint();
13651374
this.eventBus.trigger("open");
@@ -1368,6 +1377,7 @@
13681377
},
13691378
close: function close() {
13701379
if (this.isOpen() && !this.eventBus.before("close")) {
1380+
this.input.setAriaExpanded(false);
13711381
this.menu.close();
13721382
this.input.clearHint();
13731383
this.input.resetInputValue();
@@ -1486,7 +1496,8 @@
14861496
});
14871497
input = new Input({
14881498
hint: $hint,
1489-
input: $input
1499+
input: $input,
1500+
menu: $menu
14901501
}, www);
14911502
menu = new MenuConstructor({
14921503
node: $menu,

dist/typeahead.jquery.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@
7171
"scripts": {
7272
"test": "bower install && node ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
7373
},
74-
"version": "1.3.0",
74+
"version": "1.3.1",
7575
"main": "dist/typeahead.bundle.js"
7676
}

0 commit comments

Comments
 (0)