I added this conditional to make this autocomplete work with contenteditable=true which uses e.text(), not el.val(). Looks like everything uses .val() now.

Also kind of an awkward way to check for a textarea. Does .tagName == 'TEXTAREA' not work? If not, at least do a $(that.el).hasClass().

Maybe just check whether contenteditable="true" is set, then use .text(), otherwise .val().