New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.12.0 to 1.12.1

.editorconfig

54

bower.json
{
"name": "datalist-polyfill",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",
"version": "1.12.0",
"homepage": "https://github.com/mfranzke/datalist-polyfill",
"authors": [{
"name": "Maximilian Franzke",
"url": "https://www.mfranzke.net/",
"email": "contact_mfr@nzke.net"
}],
"keywords": [
"datalist",
"autosuggest",
"autosuggester",
"suggest",
"suggester",
"select"
],
"licenses": [{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
}],
"ignore": [
"bower.json",
"demo.html",
"readme.md"
]
}
"name": "datalist-polyfill",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",
"version": "1.12.1",
"homepage": "https://github.com/mfranzke/datalist-polyfill",
"authors": [{
"name": "Maximilian Franzke",
"url": "https://www.mfranzke.net/",
"email": "contact_mfr@nzke.net"
}],
"keywords": [
"datalist",
"autosuggest",
"autosuggester",
"suggest",
"suggester",
"select"
],
"licenses": [{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
}],
"ignore": [
"bower.json",
"demo.html",
"readme.md"
]
}

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

lastSeperator,
multipleEmails = (inputList.type === 'email' && inputList.multiple);
multipleEmails = (inputList.type === 'email' && inputList.multiple),
evt;

@@ -377,14 +378,14 @@ // in case of type=email and multiple attribute, we need to set up the resulting inputs value differently

}
// create and dispatch the input event; divided for IE9 usage
if (typeof(Event) === 'function') {
var evt = new Event('input', {
evt = new Event('input', {
bubbles:true
});
} else {
var evt = document.createEvent('Event');
evt = document.createEvent('Event');
evt.initEvent('input', true, false);
}
inputList.dispatchEvent(evt);
// set the visibility to false afterwards, as we're done here

@@ -391,0 +392,0 @@ visible = false;

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

*/
!function(){"use strict";if("list"in document.createElement("input")&&!(!document.createElement("datalist")||!window.HTMLDataListElement))return!1;!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.getElementsByClassName("polyfilling")[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]):not(.message)"),s=i.value,u=document.createDocumentFragment(),d=document.createDocumentFragment(),c=!1,p="email"===i.type&&i.multiple,m=38===t.keyCode||40===t.keyCode;if(p){var b=s.split(","),v=b.length-1;s=b[v].trim()}if(""!==s||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(s.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 d.appendChild(e)}),o.appendChild(u);var g=o.options.length,f=0,y=g-1;if(o.size=g>10?10:g,o.multiple=!e&&g<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.getElementsByClassName("ie9_fix")[0]||a).appendChild(d)}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,u=window.getComputedStyle(i);if(r&&"input"===r&&i.getAttribute("list")&&a.indexOf(n)>-1){var d=t.type,c=i.getAttribute("list"),p=document.getElementById(c);if(null!==p){var m=p.getElementsByClassName("polyfilling")[0],b="focus"===d&&""!==t.target.value||t.relatedTarget&&t.relatedTarget===m,v=p.title;if(void 0===m){var g=i.getClientRects(),f=parseFloat(u.getPropertyValue("margin-right")),y=parseFloat(u.getPropertyValue("margin-left"));if(m=document.createElement("select"),m.setAttribute("class","polyfilling"),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"),"block"===u.getPropertyValue("display")?m.style.marginTop="-"+u.getPropertyValue("margin-bottom"):("rtl"===u.getPropertyValue("direction")?m.style.marginRight="-"+(g[0].width+y)+"px":m.style.marginLeft="-"+(g[0].width+f)+"px",m.style.marginTop=g[0].height+"px"),m.style.borderRadius=u.getPropertyValue("border-radius"),m.style.minWidth=g[0].width+"px",e){var h=document.createElement("option");h.innerText=v,h.disabled=!0,h.setAttribute("class","message"),m.appendChild(h)}p.appendChild(m),e?m.addEventListener("change",s):m.addEventListener("click",s),m.addEventListener("blur",s),m.addEventListener("keyup",s),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()),d){case"focus":i.addEventListener("keyup",o),i.addEventListener("focusOut",l,!0);break;case"blur":i.removeEventListener("keyup",o),i.removeEventListener("focusOut",l,!0);break}}}},s=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||"click"===o||"keyup"===o&&13===e.keyCode){var s=n.id,u=document.querySelector('input[list="'+s+'"]'),d=r.value;if(null!==u&&void 0!==d&&d.length>0&&d!==a){var c=u.value,p;if("email"===u.type&&u.multiple&&(p=c.lastIndexOf(","))>-1?u.value=c.slice(0,p)+","+d:u.value=d,"function"==typeof Event)var m=new Event("input",{bubbles:!0});else{var m=document.createEvent("Event");m.initEvent("input",!0,!1)}u.dispatchEvent(m),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))return!1;!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.getElementsByClassName("polyfilling")[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]):not(.message)"),s=i.value,u=document.createDocumentFragment(),d=document.createDocumentFragment(),c=!1,p="email"===i.type&&i.multiple,m=38===t.keyCode||40===t.keyCode;if(p){var b=s.split(","),g=b.length-1;s=b[g].trim()}if(""!==s||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(s.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 d.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.getElementsByClassName("ie9_fix")[0]||a).appendChild(d)}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,u=window.getComputedStyle(i);if(r&&"input"===r&&i.getAttribute("list")&&a.indexOf(n)>-1){var d=t.type,c=i.getAttribute("list"),p=document.getElementById(c);if(null!==p){var m=p.getElementsByClassName("polyfilling")[0],b="focus"===d&&""!==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.setAttribute("class","polyfilling"),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"),"block"===u.getPropertyValue("display")?m.style.marginTop="-"+u.getPropertyValue("margin-bottom"):("rtl"===u.getPropertyValue("direction")?m.style.marginRight="-"+(v[0].width+y)+"px":m.style.marginLeft="-"+(v[0].width+f)+"px",m.style.marginTop=v[0].height+"px"),m.style.borderRadius=u.getPropertyValue("border-radius"),m.style.minWidth=v[0].width+"px",e){var h=document.createElement("option");h.innerText=g,h.disabled=!0,h.setAttribute("class","message"),m.appendChild(h)}p.appendChild(m),e?m.addEventListener("change",s):m.addEventListener("click",s),m.addEventListener("blur",s),m.addEventListener("keyup",s),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()),d){case"focus":i.addEventListener("keyup",o),i.addEventListener("focusOut",l,!0);break;case"blur":i.removeEventListener("keyup",o),i.removeEventListener("focusOut",l,!0);break}}}},s=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||"click"===o||"keyup"===o&&13===e.keyCode){var s=n.id,u=document.querySelector('input[list="'+s+'"]'),d=r.value;if(null!==u&&void 0!==d&&d.length>0&&d!==a){var c=u.value,p,m="email"===u.type&&u.multiple,b;m&&(p=c.lastIndexOf(","))>-1?u.value=c.slice(0,p)+","+d:u.value=d,"function"==typeof Event?b=new Event("input",{bubbles:!0}):(b=document.createEvent("Event"),b.initEvent("input",!0,!1)),u.dispatchEvent(b),l=!1}}l?r.removeAttribute("hidden"):r.setAttributeNode(document.createAttribute("hidden")),r.setAttribute("aria-hidden",(!l).toString())}};document.addEventListener("focus",l,!0)}();
{
"name": "datalist-polyfill",
"version": "1.12.0",
"version": "1.12.1",
"description": "An extremely lightweight and library-dependency-free vanilla JavaScript datalist polyfill.",

@@ -28,2 +28,2 @@ "main": "datalist-polyfill.js",

"homepage": "https://github.com/mfranzke/datalist-polyfill"
}
}

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

## Features
* Lightweight: 5.3 kB of JavaScript, around 2.2 kB gzipped
* Lightweight: 5.25 kB of JavaScript, around 2.33 kB gzipped
* Fully flexible to change the datalist entries / `<option>`s

@@ -14,3 +14,3 @@ * Supporting:

* ... while leaving the others like color or date related, as those would most likely need another polyfill to work correctly or have a meaningful UI
* `input[type=email]` element's `multiple` attribute
* `input[type=email]` elements `multiple` attribute
* properties `.options` for `datalist` elements and `.list` for `input` elements

@@ -21,3 +21,3 @@ * right to left text-direction

* both Safari and Internet Explorer (IE9+) browsers
* emits "input" event when item in the `datalist` is selected
* Emits "input" event when item in the `datalist` is selected
* Enables core keyboard controls such as the up and down arrow keys, `ESC`, and `ENTER`

@@ -101,2 +101,5 @@ * Implements the [WAI-ARIA design pattern](https://www.w3.org/TR/wai-aria-practices/)

### Version 1.12.1 - 2018/04/07
simple (code) style changes (plus added editorconfig to keep it that way) and typo
### Version 1.12.0 - 2018/03/18

@@ -103,0 +106,0 @@ @ottoville thankfully contributed by mentioning and implementing the feature of emitting an event when item in datalist is selected

Sorry, the diff of this file is not supported yet

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