Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
fix specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
biggieman committed Mar 1, 2019
1 parent c07ec13 commit d267276
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/mention.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ angular.module('ui.mention').controller('uiMention', ["$element", "$scope", "$at
return false;
}

var mentionExists = ~_this.mentions.map(function (mention) {
return mention.id;
}).indexOf(choice.id);
var mentionExists = _this.mentions.some(function (mention) {
return _this.encode(mention) === _this.encode(choice);
});

// Add the mention, unless its already been mentioned
if (!mentionExists) {
Expand Down
2 changes: 1 addition & 1 deletion dist/mention.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ angular.module('example', ['ui.mention']).run(["$rootScope", function ($rootScop
};
});

var choices = [{ first: 'bob', last: 'barker', id: 11123 }, { first: 'kenny', last: 'logins', id: '123ab-123' }, { first: 'kyle', last: 'corn', id: '123' }, { first: 'steve', last: 'rodriguez', id: 'hi' }, { first: 'steve', last: 'holt', id: '0-9' }, { first: 'megan', last: 'burgerpants', id: 'ab-' }];
var choices = [{ first: 'bob', last: 'barker', id: 11123 }, { first: 'kenny', last: 'logins', id: '123ab-123' }, { first: 'kyle', last: 'corn', id: '123' }, { first: 'steve', last: 'rodriguez', id: 'hi' }, { first: 'steve', last: 'holt', id: '0-9' }, { first: 'megan', last: 'burgerpants', id: 'ab-' }];
3 changes: 2 additions & 1 deletion src/mentionController.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ $element, $scope, $attrs, $q, $timeout, $document
return false;
}

const mentionExists = ~this.mentions.map(mention => mention.id).indexOf(choice.id);
const mentionExists = this.mentions
.some(mention => this.encode(mention) === this.encode(choice));

// Add the mention, unless its already been mentioned
if (!mentionExists) {
Expand Down

0 comments on commit d267276

Please sign in to comment.