Created
July 21, 2017 16:43
-
-
Save garystorey/7bf9f6410ad547a4370a3d877628173e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var testInputType = (function(GOOD, BAD) { | |
| 'button checkbox color date datetime datetime-local email month number password radio range reset search submit tel text time url week'.replace(/\S+/g, function(typeName) { | |
| var input = document.createElement('input'); | |
| input.setAttribute('type', typeName); | |
| (input.type.toLowerCase() == typeName ? GOOD : BAD).push(typeName); | |
| }); | |
| return function(value) { | |
| return 'boolean' == typeof value ? (value ? GOOD : BAD).slice() : GOOD.includes(value.toLowerCase()); | |
| }; | |
| })([], []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment