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.10.1 to 1.10.2

2

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

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

@@ -79,3 +79,3 @@ /*

// check for whether the events target was an input datalist
if ( eventTargetTagName && eventTargetTagName === 'input' && $eventTarget.getAttribute('list') ) {
if ( eventTargetTagName && eventTargetTagName === 'input' && $eventTarget.getAttribute( 'list' ) ) {

@@ -133,8 +133,2 @@ var list = $eventTarget.getAttribute( 'list' ),

console.log(optionValue);
console.log(inputValue);
console.log(optionValue.toLowerCase().indexOf( inputValue.toLowerCase() ));
var label = opt.label,

@@ -203,3 +197,3 @@ labelValueSeperator = ' / ',

}
$dataListSelect.setAttribute( 'aria-hidden', (!visible).toString() );
$dataListSelect.setAttribute( 'aria-hidden', ( !visible ).toString() );

@@ -225,3 +219,3 @@ // on arrow up or down keys, focus the select

// check for whether the events target was an input datalist and whether it's of one of the supported input types defined above
if ( eventTargetTagName && eventTargetTagName === 'input' && $eventTarget.getAttribute('list') && supportedTypes.indexOf( inputType ) > -1 ) {
if ( eventTargetTagName && eventTargetTagName === 'input' && $eventTarget.getAttribute( 'list' ) && supportedTypes.indexOf( inputType ) > -1 ) {

@@ -275,3 +269,3 @@ var eventType = event.type,

if ( touched ) {
var $message = document.createElement('option');
var $message = document.createElement( 'option' );

@@ -357,3 +351,3 @@ // ... and it's first entry should contain the localized message to select an entry

var list = $datalist.id,
$inputList = document.querySelector('input[list="' + list + '"]'),
$inputList = document.querySelector( 'input[list="' + list + '"]' ),
selectValue = $select.value;

@@ -368,3 +362,3 @@

// in case of type=email and multiple attribute, we need to set up the resulting inputs value differently
if ( multipleEmails && ( lastSeperator = inputListValue.lastIndexOf(',') ) > -1 ) {
if ( multipleEmails && ( lastSeperator = inputListValue.lastIndexOf( ',' ) ) > -1 ) {
$inputList.value = inputListValue.slice( 0, lastSeperator ) + ',' + selectValue;

@@ -371,0 +365,0 @@ } else {

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

*/
!function(){"use strict";if(!("list"in document.createElement("input"))||(!document.createElement("datalist")||!window.HTMLDataListElement)){!function(e){e&&e.prototype&&void 0===e.prototype.list&&Object.defineProperty(e.prototype,"list",{get:function(){if("object"==typeof this&&this instanceof e){var t=this.getAttribute("list");return document.getElementById(t)}return null}})}(window.HTMLInputElement),function(e){e&&e.prototype&&void 0===e.prototype.options&&Object.defineProperty(e.prototype,"options",{get:function(){if("object"==typeof this&&this instanceof e)return this.getElementsByTagName("option")}})}(window.HTMLElement);var e=!1,t=13,i=27,r=38,n=40,a=["text","email","number","search","tel","url"];window.addEventListener("touchstart",function t(){e=!0,window.removeEventListener("touchstart",t)});var o=function(t){var i=t.target,r=i.tagName.toLowerCase();if(r&&"input"===r&&i.getAttribute("list")){var n=i.getAttribute("list"),a=document.getElementById(n);if(null!==a){var o=a.getElementsByTagName("select")[0];if(void 0!==o){if(27===t.keyCode)return o.setAttributeNode(document.createAttribute("hidden")),void o.setAttribute("aria-hidden","true");var l=a.querySelectorAll("option:not([disabled].message)"),d=i.value,s=document.createDocumentFragment(),u=document.createDocumentFragment(),c=!1,p="email"===i.type&&i.multiple,m=38===t.keyCode||40===t.keyCode;if(p){var b=d.split(","),g=b.length-1;d=b[g].trim()}if(""!==d||m){Array.prototype.slice.call(l).sort(function(e,t){return e.value.localeCompare(t.value)}).forEach(function(e){var t=e.value;if(""!==t&&-1!==t.toLowerCase().indexOf(d.toLowerCase())&&!1===e.disabled){console.log(t),console.log(d),console.log(t.toLowerCase().indexOf(d.toLowerCase()));var i=e.label,r=" / ",n=i.substr(0,t.length+" / ".length),a=t+" / ";i&&i!==t&&n!==a?(e.innerText=t+" / "+i,e.setAttribute("data-label",e.getAttribute("label")),e.removeAttribute("label")):e.innerText.trim()||(e.innerText=t),s.appendChild(e),c=!0}else u.appendChild(e)}),o.appendChild(s);var v=o.options.length,f=0,y=v-1;if(o.size=v>10?10:v,o.multiple=!e&&v<2,e)o.selectedIndex=0;else if(-1===o.selectedIndex)switch(t.keyCode){case 38:o.selectedIndex=y;break;case 40:o.selectedIndex=0;break}a.appendChild(u)}c?o.removeAttribute("hidden"):o.setAttributeNode(document.createAttribute("hidden")),o.setAttribute("aria-hidden",(!c).toString()),m&&o.focus()}}}},l=function(t){var i=t.target,r=i.tagName.toLowerCase(),n=i.type,s=window.getComputedStyle(i);if(r&&"input"===r&&i.getAttribute("list")&&a.indexOf(n)>-1){var u=t.type,c=i.getAttribute("list"),p=document.getElementById(c);if(null!==p){var m=p.getElementsByTagName("select")[0],b="focus"===u&&""!==t.target.value||t.relatedTarget&&t.relatedTarget===m,g=p.title;if(void 0===m){var v=i.getClientRects(),f=parseFloat(s.getPropertyValue("margin-right")),y=parseFloat(s.getPropertyValue("margin-left"));if(m=document.createElement("select"),m.setAttributeNode(document.createAttribute("hidden")),m.style.position="absolute",m.setAttribute("aria-hidden","true"),m.setAttribute("aria-live","polite"),m.setAttribute("role","listbox"),e||m.setAttribute("aria-multiselectable","false"),"rtl"===s.getPropertyValue("direction")?m.style.marginRight="-"+(v[0].width+y)+"px":m.style.marginLeft="-"+(v[0].width+f)+"px",m.style.borderRadius=s.getPropertyValue("border-radius"),m.style.marginTop=v[0].height+"px",m.style.minWidth=v[0].width+"px",e){var h=document.createElement("option");h.innerText=g,h.disabled=!0,h.classList.add("message"),m.appendChild(h)}p.appendChild(m),e?m.addEventListener("change",d):m.addEventListener("mouseup",d),m.addEventListener("blur",d),m.addEventListener("keyup",d),i.setAttribute("autocomplete","off"),i.setAttribute("role","textbox"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-owns",c)}switch(b?m.removeAttribute("hidden"):m.setAttributeNode(document.createAttribute("hidden")),m.setAttribute("aria-hidden",(!b).toString()),u){case"focus":i.addEventListener("keyup",o),i.addEventListener("blur",l,!0);break;case"blur":i.removeEventListener("keyup",o),i.removeEventListener("blur",l,!0);break}}}},d=function(e){var t=e.target,i=t.tagName.toLowerCase();if(i&&("select"===i||"option"===i)){var r="select"===i?t:t.parentNode,n=r.parentNode,a=n.title,o=e.type,l="keyup"===o&&13!==e.keyCode&&27!==e.keyCode;if("change"===o||"mouseup"===o||"keyup"===o&&13===e.keyCode){var d=n.id,s=document.querySelector('input[list="'+d+'"]'),u=r.value;if(null!==s&&u.length>0&&u!==a){var c=s.value,p;"email"===s.type&&s.multiple&&(p=c.lastIndexOf(","))>-1?s.value=c.slice(0,p)+","+u:s.value=u,l=!1}}l?r.removeAttribute("hidden"):r.setAttributeNode(document.createAttribute("hidden")),r.setAttribute("aria-hidden",(!l).toString())}};document.addEventListener("focus",l,!0)}}();
!function(){"use strict";if(!("list"in document.createElement("input"))||(!document.createElement("datalist")||!window.HTMLDataListElement)){!function(e){e&&e.prototype&&void 0===e.prototype.list&&Object.defineProperty(e.prototype,"list",{get:function(){if("object"==typeof this&&this instanceof e){var t=this.getAttribute("list");return document.getElementById(t)}return null}})}(window.HTMLInputElement),function(e){e&&e.prototype&&void 0===e.prototype.options&&Object.defineProperty(e.prototype,"options",{get:function(){if("object"==typeof this&&this instanceof e)return this.getElementsByTagName("option")}})}(window.HTMLElement);var e=!1,t=13,i=27,r=38,n=40,a=["text","email","number","search","tel","url"];window.addEventListener("touchstart",function t(){e=!0,window.removeEventListener("touchstart",t)});var o=function(t){var i=t.target,r=i.tagName.toLowerCase();if(r&&"input"===r&&i.getAttribute("list")){var n=i.getAttribute("list"),a=document.getElementById(n);if(null!==a){var o=a.getElementsByTagName("select")[0];if(void 0!==o){if(27===t.keyCode)return o.setAttributeNode(document.createAttribute("hidden")),void o.setAttribute("aria-hidden","true");var d=a.querySelectorAll("option:not([disabled].message)"),l=i.value,u=document.createDocumentFragment(),s=document.createDocumentFragment(),c=!1,p="email"===i.type&&i.multiple,m=38===t.keyCode||40===t.keyCode;if(p){var b=l.split(","),g=b.length-1;l=b[g].trim()}if(""!==l||m){Array.prototype.slice.call(d).sort(function(e,t){return e.value.localeCompare(t.value)}).forEach(function(e){var t=e.value;if(""!==t&&-1!==t.toLowerCase().indexOf(l.toLowerCase())&&!1===e.disabled){var i=e.label,r=" / ",n=i.substr(0,t.length+" / ".length),a=t+" / ";i&&i!==t&&n!==a?(e.innerText=t+" / "+i,e.setAttribute("data-label",e.getAttribute("label")),e.removeAttribute("label")):e.innerText.trim()||(e.innerText=t),u.appendChild(e),c=!0}else s.appendChild(e)}),o.appendChild(u);var v=o.options.length,f=0,y=v-1;if(o.size=v>10?10:v,o.multiple=!e&&v<2,e)o.selectedIndex=0;else if(-1===o.selectedIndex)switch(t.keyCode){case 38:o.selectedIndex=y;break;case 40:o.selectedIndex=0;break}a.appendChild(s)}c?o.removeAttribute("hidden"):o.setAttributeNode(document.createAttribute("hidden")),o.setAttribute("aria-hidden",(!c).toString()),m&&o.focus()}}}},d=function(t){var i=t.target,r=i.tagName.toLowerCase(),n=i.type,u=window.getComputedStyle(i);if(r&&"input"===r&&i.getAttribute("list")&&a.indexOf(n)>-1){var s=t.type,c=i.getAttribute("list"),p=document.getElementById(c);if(null!==p){var m=p.getElementsByTagName("select")[0],b="focus"===s&&""!==t.target.value||t.relatedTarget&&t.relatedTarget===m,g=p.title;if(void 0===m){var v=i.getClientRects(),f=parseFloat(u.getPropertyValue("margin-right")),y=parseFloat(u.getPropertyValue("margin-left"));if(m=document.createElement("select"),m.setAttributeNode(document.createAttribute("hidden")),m.style.position="absolute",m.setAttribute("aria-hidden","true"),m.setAttribute("aria-live","polite"),m.setAttribute("role","listbox"),e||m.setAttribute("aria-multiselectable","false"),"rtl"===u.getPropertyValue("direction")?m.style.marginRight="-"+(v[0].width+y)+"px":m.style.marginLeft="-"+(v[0].width+f)+"px",m.style.borderRadius=u.getPropertyValue("border-radius"),m.style.marginTop=v[0].height+"px",m.style.minWidth=v[0].width+"px",e){var h=document.createElement("option");h.innerText=g,h.disabled=!0,h.classList.add("message"),m.appendChild(h)}p.appendChild(m),e?m.addEventListener("change",l):m.addEventListener("mouseup",l),m.addEventListener("blur",l),m.addEventListener("keyup",l),i.setAttribute("autocomplete","off"),i.setAttribute("role","textbox"),i.setAttribute("aria-haspopup","true"),i.setAttribute("aria-autocomplete","list"),i.setAttribute("aria-owns",c)}switch(b?m.removeAttribute("hidden"):m.setAttributeNode(document.createAttribute("hidden")),m.setAttribute("aria-hidden",(!b).toString()),s){case"focus":i.addEventListener("keyup",o),i.addEventListener("blur",d,!0);break;case"blur":i.removeEventListener("keyup",o),i.removeEventListener("blur",d,!0);break}}}},l=function(e){var t=e.target,i=t.tagName.toLowerCase();if(i&&("select"===i||"option"===i)){var r="select"===i?t:t.parentNode,n=r.parentNode,a=n.title,o=e.type,d="keyup"===o&&13!==e.keyCode&&27!==e.keyCode;if("change"===o||"mouseup"===o||"keyup"===o&&13===e.keyCode){var l=n.id,u=document.querySelector('input[list="'+l+'"]'),s=r.value;if(null!==u&&s.length>0&&s!==a){var c=u.value,p;"email"===u.type&&u.multiple&&(p=c.lastIndexOf(","))>-1?u.value=c.slice(0,p)+","+s:u.value=s,d=!1}}d?r.removeAttribute("hidden"):r.setAttributeNode(document.createAttribute("hidden")),r.setAttribute("aria-hidden",(!d).toString())}};document.addEventListener("focus",d,!0)}}();
{
"name": "datalist-polyfill",
"version": "1.10.1",
"version": "1.10.2",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",

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

@@ -67,2 +67,5 @@ # datalist-polyfill

### Version 1.10.2- 2017/09/26
Simple corrections.
### Version 1.10.1- 2017/09/25

@@ -69,0 +72,0 @@ Simple bugfix, that came up through the latest implementation on the up and down arrow keys.

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