Skip to content

Conversation

@mikemaccana
Copy link
Contributor

Fixes #20

@developit developit self-requested a review April 10, 2017 13:44
@thomasdegry
Copy link

@developit any reason why we can't merge this yet? Would be awesome to have this functionality working!

@developit
Copy link
Owner

Array.prototype.includes() is not supported in IE9, which this library targets.

// Add multiple tags if the user pastes in data with SEPERATOR already in it
if (~text.indexOf(SEPERATOR)) text = text.split(SEPERATOR);
if (Array.isArray(text)) return text.forEach(addTag);
if ( text.includes(SEPERATOR) ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems a shame to give up IE compat here

@mikemaccana
Copy link
Contributor Author

We could just add a polyfill for legacy browsers. This keeps the code clean and can be deleted quickly when you finally drop IE. :^)

@developit
Copy link
Owner

I'm too obsessed with file size to go that route 😜

@mikemaccana
Copy link
Contributor Author

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants