{"action":"created","issue":{"url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/16821","repository_url":"https://api.github.com/repos/LeaVerou/awesomplete","labels_url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/16821/labels{/name}","comments_url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/16821/comments","events_url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/16821/events","html_url":"https://github.com/LeaVerou/awesomplete/issues/16821","id":127921866,"number":16821,"title":"API consistency. Use item instead of text everywhere","user":{"login":"vlazar","id":7262,"avatar_url":"https://avatars.githubusercontent.com/u/7262?v=3","gravatar_id":"","url":"https://api.github.com/users/vlazar","html_url":"https://github.com/vlazar","followers_url":"https://api.github.com/users/vlazar/followers","following_url":"https://api.github.com/users/vlazar/following{/other_user}","gists_url":"https://api.github.com/users/vlazar/gists{/gist_id}","starred_url":"https://api.github.com/users/vlazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlazar/subscriptions","organizations_url":"https://api.github.com/users/vlazar/orgs","repos_url":"https://api.github.com/users/vlazar/repos","events_url":"https://api.github.com/users/vlazar/events{/privacy}","received_events_url":"https://api.github.com/users/vlazar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LeaVerou/awesomplete/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/LeaVerou/awesomplete/milestones/1","html_url":"https://github.com/LeaVerou/awesomplete/milestones/v1.1","labels_url":"https://api.github.com/repos/LeaVerou/awesomplete/milestones/1/labels","id":1553745,"number":1,"title":"v1.1","description":"Goals:\r\n- support list with items other than strings (key/value, arrays, etc.)\r\n- solidify tests\r\n- publish npm package","creator":{"login":"vlazar","id":7262,"avatar_url":"https://avatars.githubusercontent.com/u/7262?v=3","gravatar_id":"","url":"https://api.github.com/users/vlazar","html_url":"https://github.com/vlazar","followers_url":"https://api.github.com/users/vlazar/followers","following_url":"https://api.github.com/users/vlazar/following{/other_user}","gists_url":"https://api.github.com/users/vlazar/gists{/gist_id}","starred_url":"https://api.github.com/users/vlazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlazar/subscriptions","organizations_url":"https://api.github.com/users/vlazar/orgs","repos_url":"https://api.github.com/users/vlazar/repos","events_url":"https://api.github.com/users/vlazar/events{/privacy}","received_events_url":"https://api.github.com/users/vlazar/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":2,"state":"open","created_at":"2016-01-31T13:48:34Z","updated_at":"2016-02-07T11:52:21Z","due_on":null,"closed_at":null},"comments":62,"created_at":"2016-01-21T13:17:11Z","updated_at":"2016-02-19T07:24:41Z","closed_at":null,"body":"Continues #16818\r\n\r\nWith list of string items everything works out of the box right now.\r\n\r\nThere is also a frequently requested feature to have items as objects (key/value pairs). Making it work on top of current API is problematic.\r\n\r\nCurrently we pass list item (either a string or an object) to:\r\n```javascript\r\n// text is actually a list item, even if it's an object\r\nfilter: function (text, input)\r\nitem: function (text, input)\r\n// a and b both items (text if list is array of strings, object if it's array of objects)\r\nsort: function (a, b)\r\n```\r\n\r\nAnd here we have text (so items as object won't work):\r\n```javascript\r\n// text here always text as it's called as this.replace(selected.textContent);\r\nreplace: function (text)\r\n// and we also have text property in here\r\n$.fire(this.input, \"awesomplete-select\", {\r\n\ttext: selected.textContent,\r\n```\r\n\r\nI think this needs to be changed so that when we have list of objects both `replace` and `awesomplete-select` would also get the whole item data instead of text only. This change would make features like key/value support much easier to implement.\r\n\r\nIf we go with this, then the question is how we implement this API change.\r\n\r\nWe can make it as non breaking change in `1.x` (possibly showing deprecation warning in console too):\r\n```javascript\r\nreplace: function (text, item)\r\n$.fire(this.input, \"awesomplete-select\", {\r\n\ttext: selected.textContent,\r\n\titem: this._list[this.index]\r\n```\r\n\r\nAnd cleanup API in 2.0:\r\n```javascript\r\nreplace: function (item)\r\n$.fire(this.input, \"awesomplete-select\", {\r\n\titem: this._list[this.index]\r\n```\r\n\r\nHowever in this case `replace ` signature changes twice. So a better option would be to introduce new `item` instance property, which would be a selected item data (text or object) - essentially `this._list[this.index]`. We can even have `replace: function ()` without arguments in 2.0 since `this.item` would be accessible on any instance. So 2.0 API can be:\r\n\r\n```javascript\r\n// just use this.item the same way this.input is used currently\r\nreplace: function ()\r\n// still need to pass it to event handler\r\n$.fire(this.input, \"awesomplete-select\", {\r\n\titem: this.item\r\n```\r\n\r\nSee also related discussion #16819"},"comment":{"url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/comments/186102143","html_url":"https://github.com/LeaVerou/awesomplete/issues/16821#issuecomment-186102143","issue_url":"https://api.github.com/repos/LeaVerou/awesomplete/issues/16821","id":186102143,"user":{"login":"TxHawks","id":5658514,"avatar_url":"https://avatars.githubusercontent.com/u/5658514?v=3","gravatar_id":"","url":"https://api.github.com/users/TxHawks","html_url":"https://github.com/TxHawks","followers_url":"https://api.github.com/users/TxHawks/followers","following_url":"https://api.github.com/users/TxHawks/following{/other_user}","gists_url":"https://api.github.com/users/TxHawks/gists{/gist_id}","starred_url":"https://api.github.com/users/TxHawks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TxHawks/subscriptions","organizations_url":"https://api.github.com/users/TxHawks/orgs","repos_url":"https://api.github.com/users/TxHawks/repos","events_url":"https://api.github.com/users/TxHawks/events{/privacy}","received_events_url":"https://api.github.com/users/TxHawks/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T07:24:41Z","updated_at":"2016-02-19T07:24:41Z","body":"WeakMap can be polyfilled (and one is available through polyfill.io), but\nit seems like map cannot be.\n\nOn Fri, Feb 19, 2016, 08:59 Lea Verou <notifications@github.com> wrote:\n\n> IE10 usage is 0.81%. Same with IE9. IE8 is 1.02%\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/LeaVerou/awesomplete/issues/16821#issuecomment-186091284>\n> .\n>\n"}}