Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datalist-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datalist-polyfill - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

bower.json
{
"name": "datalist-polyfill",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/mfranzke/datalist-polyfill",

@@ -6,0 +6,0 @@ "authors": [{

@@ -58,4 +58,3 @@ /*

// ... create an array out of the options list
var nodeArray = Array.prototype.slice.call( $dataListOptions ),
selected = false;
var nodeArray = Array.prototype.slice.call( $dataListOptions );

@@ -65,3 +64,3 @@ // ... sort all entries and

return a.value.localeCompare( b.value );
}).forEach( function( opt, index ) {
}).forEach( function( opt ) {
var optionValue = opt.value;

@@ -74,6 +73,2 @@

if ( optionValue === inputValue ) {
selected = index;
}
newSelectValues.appendChild( opt );

@@ -93,3 +88,3 @@

// preselect best fitting index
$dataListSelect.selectedIndex = selected || 0;
$dataListSelect.selectedIndex = 0;

@@ -96,0 +91,0 @@ // input the unused options as siblings next to the select

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

*/
!function(){"use strict";if(!("list"in document.createElement("input"))||(!document.createElement("datalist")||!window.HTMLDataListElement)){var e=function(e){var t=e.target;if(t.matches("input[list]")){var i=t.getAttribute("list"),r=document.getElementById(i);if(null!==r){var a=r.getElementsByTagName("select")[0];if(void 0!==a){if(27===e.keyCode)return a.classList.remove("visible"),void a.setAttribute("aria-hidden",!0);var n=r.querySelectorAll("option[value]"),l=t.value,o=document.createDocumentFragment(),s=document.createDocumentFragment(),u=!1;if(""!==l){var d=Array.prototype.slice.call(n),c=!1;d.sort(function(e,t){return e.value.localeCompare(t.value)}).forEach(function(e,t){var i=e.value;""!==i&&-1!==i.toLowerCase().indexOf(l.toLowerCase())&&!1===e.disabled?(e.innerText=i,i===l&&(c=t),o.appendChild(e),u=!0):s.appendChild(e)}),a.appendChild(o),a.selectedIndex=c||0,r.appendChild(s)}a.classList.toggle("visible",u),a.setAttribute("aria-hidden",!u),38!==e.keyCode&&40!==e.keyCode||a.focus()}}}},t=function(r){var a=r.target;if(a.matches("input[list]")){var n=r.type,l=a.getAttribute("list"),o=document.getElementById(l);if(null!==o){var s=o.getElementsByTagName("select")[0],u="focus"===n&&""!==r.target.value||r.relatedTarget&&r.relatedTarget===s,d=o.title;if(void 0===s){var c=a.getClientRects(),p=document.createElement("option");s=document.createElement("select"),s.setAttribute("aria-hidden",!0),s.setAttribute("aria-live","polite"),s.setAttribute("role","listbox"),s.style.marginLeft="-"+c[0].width+"px",s.style.marginTop=c[0].height+"px",s.style.minWidth=c[0].width+"px",p.innerText=d,p.disabled=!0,s.appendChild(p),o.appendChild(s),s.addEventListener("change",i),s.addEventListener("blur",i),s.addEventListener("keyup",i),a.setAttribute("autocomplete","off"),a.setAttribute("role","textbox"),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-owns",l)}switch(s.classList.toggle("visible",u),s.setAttribute("aria-hidden",!u),n){case"focus":a.addEventListener("keyup",e),a.addEventListener("blur",t,!0);break;case"blur":a.removeEventListener("keyup",e),a.removeEventListener("blur",t,!0);break}}}},i=function(e){var t=e.target,i=t.parentNode.title;if(t.matches("select")){var r=e.type,a="keyup"===r&&13!==e.keyCode&&27!==e.keyCode;if("change"===r||"keyup"===r&&13===e.keyCode){var n=t.parentNode.id,l=document.querySelector('input[list="'+n+'"]'),o=t.value;null!==l&&o.length>0&&o!==i&&(l.value=o)}t.classList.toggle("visible",a),t.setAttribute("aria-hidden",!a)}};document.addEventListener("focus",t,!0),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),i=t.length;--i>=0&&t.item(i)!==this;);return i>-1})}}();
!function(){"use strict";if(!("list"in document.createElement("input"))||(!document.createElement("datalist")||!window.HTMLDataListElement)){var e=function(e){var t=e.target;if(t.matches("input[list]")){var i=t.getAttribute("list"),r=document.getElementById(i);if(null!==r){var a=r.getElementsByTagName("select")[0];if(void 0!==a){if(27===e.keyCode)return a.classList.remove("visible"),void a.setAttribute("aria-hidden",!0);var n=r.querySelectorAll("option[value]"),l=t.value,o=document.createDocumentFragment(),s=document.createDocumentFragment(),u=!1;""!==l&&(Array.prototype.slice.call(n).sort(function(e,t){return e.value.localeCompare(t.value)}).forEach(function(e){var t=e.value;""!==t&&-1!==t.toLowerCase().indexOf(l.toLowerCase())&&!1===e.disabled?(e.innerText=t,o.appendChild(e),u=!0):s.appendChild(e)}),a.appendChild(o),a.selectedIndex=0,r.appendChild(s)),a.classList.toggle("visible",u),a.setAttribute("aria-hidden",!u),38!==e.keyCode&&40!==e.keyCode||a.focus()}}}},t=function(r){var a=r.target;if(a.matches("input[list]")){var n=r.type,l=a.getAttribute("list"),o=document.getElementById(l);if(null!==o){var s=o.getElementsByTagName("select")[0],u="focus"===n&&""!==r.target.value||r.relatedTarget&&r.relatedTarget===s,d=o.title;if(void 0===s){var c=a.getClientRects(),p=document.createElement("option");s=document.createElement("select"),s.setAttribute("aria-hidden",!0),s.setAttribute("aria-live","polite"),s.setAttribute("role","listbox"),s.style.marginLeft="-"+c[0].width+"px",s.style.marginTop=c[0].height+"px",s.style.minWidth=c[0].width+"px",p.innerText=d,p.disabled=!0,s.appendChild(p),o.appendChild(s),s.addEventListener("change",i),s.addEventListener("blur",i),s.addEventListener("keyup",i),a.setAttribute("autocomplete","off"),a.setAttribute("role","textbox"),a.setAttribute("aria-haspopup","true"),a.setAttribute("aria-autocomplete","list"),a.setAttribute("aria-owns",l)}switch(s.classList.toggle("visible",u),s.setAttribute("aria-hidden",!u),n){case"focus":a.addEventListener("keyup",e),a.addEventListener("blur",t,!0);break;case"blur":a.removeEventListener("keyup",e),a.removeEventListener("blur",t,!0);break}}}},i=function(e){var t=e.target,i=t.parentNode.title;if(t.matches("select")){var r=e.type,a="keyup"===r&&13!==e.keyCode&&27!==e.keyCode;if("change"===r||"keyup"===r&&13===e.keyCode){var n=t.parentNode.id,l=document.querySelector('input[list="'+n+'"]'),o=t.value;null!==l&&o.length>0&&o!==i&&(l.value=o)}t.classList.toggle("visible",a),t.setAttribute("aria-hidden",!a)}};document.addEventListener("focus",t,!0),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),i=t.length;--i>=0&&t.item(i)!==this;);return i>-1})}}();
{
"name": "datalist-polyfill",
"version": "1.1.0",
"version": "1.1.1",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",

@@ -5,0 +5,0 @@ "main": "datalist-polyfill.js",

@@ -8,3 +8,3 @@ # datalist-polyfill

## Features
* Lightweight: 3.07 kB of JavaScript - less than 1.3 kB gzipped
* Lightweight: 3.04 kB of JavaScript - less than 1.3 kB gzipped
* Fully flexible to change the data / `<option>`s

@@ -57,2 +57,5 @@ * Enables core keyboard controls like e.g. the up and down arrow keys, ESC and ENTER

### Version 1.1.1 - 2017/05/10
fixed another simple bug that lead to an incorrect index being selected - let's skip this, as it's not even the standard behaviour
### Version 1.1.0 - 2017/05/09

@@ -59,0 +62,0 @@ some small corrections

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc