Socket
Socket
Sign inDemoInstall

awesomplete

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

test/events/clickSpec.js

99

awesomplete.js

@@ -13,2 +13,6 @@ /**

// Keep track of number of instances for unique IDs
_.count = (_.count || 0) + 1;
this.count = _.count;
// Setup

@@ -19,6 +23,9 @@

this.input = $(input);
this.input.setAttribute("autocomplete", "off");
this.input.setAttribute("aria-autocomplete", "list");
this.input.setAttribute("autocomplete", "awesomplete");
this.input.setAttribute("aria-owns", "awesomplete_list_" + this.count);
this.input.setAttribute("role", "combobox");
o = o || {};
// store constructor options in case we need to distinguish
// between default and customized behavior later on
this.options = o = o || {};

@@ -32,4 +39,6 @@ configure(this, {

sort: o.sort === false ? false : _.SORT_BYLENGTH,
container: _.CONTAINER,
item: _.ITEM,
replace: _.REPLACE
replace: _.REPLACE,
tabSelect: false
}, o);

@@ -41,9 +50,8 @@

this.container = $.create("div", {
className: "awesomplete",
around: input
});
this.container = this.container(input);
this.ul = $.create("ul", {
hidden: "hidden",
role: "listbox",
id: "awesomplete_list_" + this.count,
inside: this.container

@@ -56,4 +64,5 @@ });

"aria-live": "assertive",
"aria-relevant": "additions",
inside: this.container
"aria-atomic": true,
inside: this.container,
textContent: this.minChars != 0 ? ("Type " + this.minChars + " or more characters for results.") : "Begin typing for results."
});

@@ -77,2 +86,5 @@

}
else if (c === 9 && me.selected && me.tabSelect) {
me.select();
}
else if (c === 27) { // Esc

@@ -92,3 +104,10 @@ me.close({ reason: "esc" });

ul: {
// Prevent the default mousedowm, which ensures the input is not blurred.
// The actual selection will happen on click. This also ensures dragging the
// cursor away from the list item will cancel the selection
"mousedown": function(evt) {
evt.preventDefault();
},
// The click event is fired even if the corresponding mousedown event has called preventDefault
"click": function(evt) {
var li = evt.target;

@@ -175,2 +194,4 @@

this.status.setAttribute("hidden", "");
$.fire(this.input, "awesomplete-close", o || {});

@@ -183,2 +204,4 @@ },

this.status.removeAttribute("hidden");
if (this.autoFirst && this.index === -1) {

@@ -196,7 +219,10 @@ this.goto(0);

//move the input out of the awesomplete container and remove the container and its children
var parentNode = this.container.parentNode;
// cleanup container if it was created by Awesomplete but leave it alone otherwise
if (!this.options.container) {
//move the input out of the awesomplete container and remove the container and its children
var parentNode = this.container.parentNode;
parentNode.insertBefore(this.input, this.container);
parentNode.removeChild(this.container);
parentNode.insertBefore(this.input, this.container);
parentNode.removeChild(this.container);
}

@@ -239,4 +265,7 @@ //remove autocomplete and aria-autocomplete attributes

lis[i].setAttribute("aria-selected", "true");
this.status.textContent = lis[i].textContent;
this.status.textContent = lis[i].textContent + ", list item " + (i + 1) + " of " + lis.length;
this.input.setAttribute("aria-activedescendant", this.ul.id + "_item_" + this.index);
// scroll to highlighted element in case parent's height is fixed

@@ -280,3 +309,3 @@ this.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight;

if (value.length >= this.minChars && this._list.length > 0) {
if (value.length >= this.minChars && this._list && this._list.length > 0) {
this.index = -1;

@@ -300,10 +329,16 @@ // Populate list with options that match

this.suggestions.forEach(function(text) {
me.ul.appendChild(me.item(text, value));
this.suggestions.forEach(function(text, index) {
me.ul.appendChild(me.item(text, value, index));
});
if (this.ul.children.length === 0) {
this.status.textContent = "No results found";
this.close({ reason: "nomatches" });
} else {
this.open();
this.status.textContent = this.ul.children.length + " results found";
}

@@ -313,2 +348,4 @@ }

this.close({ reason: "nomatches" });
this.status.textContent = "No results found";
}

@@ -338,7 +375,15 @@ }

_.ITEM = function (text, input) {
_.CONTAINER = function (input) {
return $.create("div", {
className: "awesomplete",
around: input
});
}
_.ITEM = function (text, input, item_id) {
var html = input.trim() === "" ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
return $.create("li", {
innerHTML: html,
"aria-selected": "false"
"aria-selected": "false",
"id": "awesomplete_list_" + this.count + "_item_" + item_id
});

@@ -419,2 +464,6 @@ };

element.appendChild(ref);
if (ref.getAttribute("autofocus") != null) {
ref.focus();
}
}

@@ -486,2 +535,7 @@ else if (i in element) {

// Make sure to export Awesomplete on self when in a browser
if (typeof self !== "undefined") {
self.Awesomplete = _;
}
// Are we in a browser? Check for Document constructor

@@ -502,7 +556,2 @@ if (typeof Document !== "undefined") {

// Make sure to export Awesomplete on self when in a browser
if (typeof self !== "undefined") {
self.Awesomplete = _;
}
// Expose Awesomplete as a CJS module

@@ -509,0 +558,0 @@ if (typeof module === "object" && module.exports) {

// Awesomplete - Lea Verou - MIT license
!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):!1===s?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;this.isOpened=!1,this.input=i(t),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-autocomplete","list"),n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:!1!==n.sort&&r.SORT_BYLENGTH,item:r.ITEM,replace:r.REPLACE},n),this.index=-1,this.container=i.create("div",{className:"awesomplete",around:t}),this.ul=i.create("ul",{hidden:"hidden",inside:this.container}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-relevant":"additions",inside:this.container}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select()):27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target))}}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.ul.removeAttribute("hidden"),this.isOpened=!0,this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form);var t=this.container.parentNode;t.insertBefore(this.input,this.container),t.removeChild(this.container),this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=r.all.indexOf(this);-1!==e&&r.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index<t-1?this.index+1:t?0:-1)},previous:function(){var t=this.ul.children.length,e=this.index-1;this.goto(this.selected&&-1!==e?e:t-1)},goto:function(t){var e=this.ul.children;this.selected&&e[this.index].setAttribute("aria-selected","false"),this.index=t,t>-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent,this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var n=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:n,origin:e||t})&&(this.replace(n),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.maxItems),this.suggestions.forEach(function(t){e.ul.appendChild(e.item(t,i))}),0===this.ul.children.length?this.close({reason:"nomatches"}):this.open()):this.close({reason:"nomatches"})}},r.all=[],r.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},r.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},r.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t<e?-1:1},r.ITEM=function(t,e){return i.create("li",{innerHTML:""===e.trim()?t:t.replace(RegExp(i.regExpEscape(e.trim()),"gi"),"<mark>$&</mark>"),"aria-selected":"false"})},r.REPLACE=function(t){this.input.value=t.value},r.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var o=Array.prototype.slice;i.create=function(t,e){var n=document.createElement(t);for(var s in e){var r=e[s];if("inside"===s)i(r).appendChild(n);else if("around"===s){var o=i(r);o.parentNode.insertBefore(n,o),n.appendChild(o)}else s in n?n[s]=r:n.setAttribute(s,r)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.unbind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),r.$=i,r.$$=n,"undefined"!=typeof self&&(self.Awesomplete=r),"object"==typeof module&&module.exports&&(module.exports=r)}();
!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):!1===s?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;Awesomplete.count=(Awesomplete.count||0)+1,this.count=Awesomplete.count,this.isOpened=!1,this.input=i(t),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-owns","awesomplete_list_"+this.count),this.input.setAttribute("role","combobox"),n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:!1!==n.sort&&r.SORT_BYLENGTH,item:r.ITEM,replace:r.REPLACE},n),this.index=-1,this.container=i.create("div",{className:"awesomplete",around:t}),this.ul=i.create("ul",{hidden:"hidden",role:"listbox",id:"awesomplete_list_"+this.count,inside:this.container}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:0!=this.minChars?"Type "+this.minChars+" or more characters for results.":"Begin typing for results."}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select()):27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){t.preventDefault()},click:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target))}}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.ul.removeAttribute("hidden"),this.isOpened=!0,this.status.removeAttribute("hidden"),this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form);var t=this.container.parentNode;t.insertBefore(this.input,this.container),t.removeChild(this.container),this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=r.all.indexOf(this);-1!==e&&r.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index<t-1?this.index+1:t?0:-1)},previous:function(){var t=this.ul.children.length,e=this.index-1;this.goto(this.selected&&-1!==e?e:t-1)},goto:function(t){var e=this.ul.children;this.selected&&e[this.index].setAttribute("aria-selected","false"),this.index=t,t>-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent+", list item "+(t+1)+" of "+e.length,this.input.setAttribute("aria-activedescendant",this.ul.id+"_item_"+this.index),this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var n=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:n,origin:e||t})&&(this.replace(n),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.maxItems),this.suggestions.forEach(function(t,n){e.ul.appendChild(e.item(t,i,n))}),0===this.ul.children.length?(this.status.textContent="No results found",this.close({reason:"nomatches"})):(this.open(),this.status.textContent=this.ul.children.length+" results found")):(this.close({reason:"nomatches"}),this.status.textContent="No results found")}},r.all=[],r.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},r.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},r.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t<e?-1:1},r.ITEM=function(t,e,n){return i.create("li",{innerHTML:""===e.trim()?t:t.replace(RegExp(i.regExpEscape(e.trim()),"gi"),"<mark>$&</mark>"),"aria-selected":"false",id:"awesomplete_list_"+this.count+"_item_"+n})},r.REPLACE=function(t){this.input.value=t.value},r.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var o=Array.prototype.slice;i.create=function(t,e){var n=document.createElement(t);for(var s in e){var r=e[s];if("inside"===s)i(r).appendChild(n);else if("around"===s){var o=i(r);o.parentNode.insertBefore(n,o),n.appendChild(o)}else s in n?n[s]=r:n.setAttribute(s,r)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.unbind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),r.$=i,r.$$=n,"undefined"!=typeof self&&(self.Awesomplete=r),"object"==typeof module&&module.exports&&(module.exports=r)}();
//# sourceMappingURL=awesomplete.min.js.map
{
"name": "awesomplete",
"version": "1.1.2",
"version": "1.1.3",
"description": "http://leaverou.github.io/awesomplete/",

@@ -5,0 +5,0 @@ "main": "awesomplete.js",

@@ -11,3 +11,23 @@ # Awesomplete

## Installation
There are a few ways to obtain the needed files.
Here are 2 of them:
1. CDN server
```sh
https://cdnjs.com/libraries/awesomplete
```
2. Another way to get up and running is by using `yarn` or `npm`:
```sh
yarn add awesomplete
```
```sh
npm install awesomplete --save
```
More information about the npm package can be found [here](https://www.npmjs.com/package/awesomplete).
## Basic Usage

@@ -14,0 +34,0 @@

@@ -53,3 +53,3 @@ describe("awesomplete.goto", function () {

it("updates status", function () {
expect(this.subject.status.textContent).toBe("item1");
expect(this.subject.status.textContent).toBe("item1, list item 1 of 3");
});

@@ -65,5 +65,5 @@ });

it("does not update status", function () {
expect(this.subject.status.textContent).toBe("item1");
expect(this.subject.status.textContent).toBe("item1, list item 1 of 3");
});
});
});

@@ -67,2 +67,31 @@ describe("keydown event", function () {

});
it("does not select on tab", function () {
this.subject.next();
spyOn(this.subject, "select");
$.keydown(this.subject.input, $.k.TAB);
expect(this.subject.select).not.toHaveBeenCalled();
});
});
describe("tabSelect option true ", function () {
$.fixture("plain");
subject(function () {
return new Awesomplete("#plain", { list: ["item1", "item2", "item3"], tabSelect: true });
});
beforeEach(function () {
$.type(this.subject.input, "ite");
});
it("selects on tab", function () {
this.subject.next();
spyOn(this.subject, "select");
$.keydown(this.subject.input, $.k.TAB);
expect(this.subject.select).toHaveBeenCalled();
});
})

@@ -19,5 +19,6 @@ describe("mousedown event", function () {

it("does not select item", function () {
it("does not select item and keeps the input focussed", function () {
$.fire(this.target, "mousedown", { button: 0 });
expect(this.subject.select).not.toHaveBeenCalled();
expect(this.subject.input).toBe(document.activeElement);
});

@@ -30,6 +31,7 @@ });

describe("on left click", function () {
it("selects item", function () {
it("does not select item and keeps the input focussed", function () {
var event = $.fire(this.target, "mousedown", { button: 0 });
expect(this.subject.select).toHaveBeenCalledWith(this.li, this.target);
expect(this.subject.select).not.toHaveBeenCalled();
expect(event.defaultPrevented).toBe(true);
expect(this.subject.input).toBe(document.activeElement);
});

@@ -39,5 +41,7 @@ });

describe("on right click", function () {
it("does not select item", function () {
$.fire(this.target, "mousedown", { button: 2 });
it("does not select item and keeps the input focussed", function () {
var event = $.fire(this.target, "mousedown", { button: 2 });
expect(this.subject.select).not.toHaveBeenCalled();
expect(event.defaultPrevented).toBe(true);
expect(this.subject.input).toBe(document.activeElement);
});

@@ -51,6 +55,7 @@ });

describe("on left click", function () {
it("selects item", function () {
it("does not select item and keeps the input focussed", function () {
var event = $.fire(this.target, "mousedown", { button: 0 });
expect(this.subject.select).toHaveBeenCalledWith(this.li, this.target);
expect(this.subject.select).not.toHaveBeenCalled();
expect(event.defaultPrevented).toBe(true);
expect(this.subject.input).toBe(document.activeElement);
});

@@ -60,5 +65,7 @@ });

describe("on right click", function () {
it("does not select item", function () {
$.fire(this.target, "mousedown", { button: 2 });
it("does not select item and keeps the input focussed", function () {
var event = $.fire(this.target, "mousedown", { button: 2 });
expect(this.subject.select).not.toHaveBeenCalled();
expect(event.defaultPrevented).toBe(true);
expect(this.subject.input).toBe(document.activeElement);
});

@@ -65,0 +72,0 @@ });

@@ -13,3 +13,3 @@ describe("Html modifications", function () {

it("turns native autocompleter off", function () {
expect(this.subject.input.getAttribute("autocomplete")).toBe("off");
expect(this.subject.input.getAttribute("autocomplete")).toBe("awesomplete");
});

@@ -43,3 +43,4 @@

it("makes input accessible", function () {
expect(this.subject.input.getAttribute("aria-autocomplete")).toBe("list");
expect(this.subject.input.getAttribute("role")).toBe("combobox");
expect(this.subject.input.getAttribute("aria-owns")).toMatch(/awesomplete_list_[0-9]+/);
});

@@ -51,3 +52,2 @@

expect(this.subject.status.getAttribute("aria-live")).toBe("assertive");
expect(this.subject.status.getAttribute("aria-relevant")).toBe("additions");
});

@@ -54,0 +54,0 @@

@@ -58,2 +58,3 @@ fixture.setBase("test/fixtures");

$.k = {
TAB: 9,
ENTER: 13,

@@ -60,0 +61,0 @@ ESC: 27,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc