tags-input
tags-input copied to clipboard
Ensure tags must fit pattern before adding them
Fixes #20
@developit any reason why we can't merge this yet? Would be awesome to have this functionality working!
Array.prototype.includes() is not supported in IE9, which this library targets.
We could just add a polyfill for legacy browsers. This keeps the code clean and can be deleted quickly when you finally drop IE. :^)
I'm too obsessed with file size to go that route 😜
Developit: it's literally only a few characters
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes . It's also way more readable than ye olde "if index is greater than or equal to zero".