Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting all input might cause TypeError: Cannot call method 'replace' of undefined #53

Closed
metamatt opened this issue Mar 25, 2014 · 2 comments
Labels
bug DEPRECATED jquery-textcomplete Issues associated to jquery-textcomplete (was DEPRECATED)

Comments

@metamatt
Copy link
Contributor

If I configure jquery-textcomplete with a completion strategy based on @, and type @xyz and backspace over it a few times (and keep pressing backspace after I've erased all input), sometimes I get it to throw this exception:

Uncaught client exception: TypeError: Cannot call method 'replace' of undefined
    at Function.jQuery.extend.camelCase (http://test:1080/static/lib/jquery/jquery.js:620:17)
    at Function.jQuery.extend.css (http://test:1080/static/lib/jquery/jquery.js:7048:22)
    at null.<anonymous> (http://test:1080/static/lib/jquery/jquery.js:6920:12)
    at Function.jQuery.extend.access (http://test:1080/static/lib/jquery/jquery.js:885:8)
    at jQuery.fn.extend.css (http://test:1080/static/lib/jquery/jquery.js:6902:17)
    at ListView.$.extend.setPosition (http://test:1080/static/lib/jquery-textcomplete/jquery.textcomplete.js:462:18)
    at Completer.$.extend.renderList (http://test:1080/static/lib/jquery-textcomplete/jquery.textcomplete.js:179:18)
    at http://test:1080/static/lib/jquery-textcomplete/jquery.textcomplete.js:196:16
    at http://test:1080/static/lib/jquery-textcomplete/jquery.textcomplete.js:76:20

I think this happens when the server is slow to respond (I was introducing intentional delays to reproduce another bug) and the callback arrives late.

This is easy to fix (don't call $el.css(null)); would you like a PR?

@yuku
Copy link
Owner

yuku commented Mar 26, 2014

Hi @metamatt
Thank you for reporting the issue! This is a bug 👾

setPosition is called with the result of getCaretPosition (here) and getCaretPosition returns undefined when a caret is located at the head of textarea (here).
Don't call $el.css(null) is 🆗 , but I think removing this line is better :)

@yuku
Copy link
Owner

yuku commented Mar 26, 2014

By the way, all PR is welcome.

metamatt added a commit to metamatt/jquery-textcomplete that referenced this issue Mar 26, 2014
Avoid returning undefined from getCaretPosition, so that we don't
pass undefined to jQuery.css.

Fixes yuku#53.
metamatt added a commit to metamatt/jquery-textcomplete that referenced this issue Mar 26, 2014
Avoid returning undefined from getCaretPosition, so that we don't
pass undefined to jQuery.css.

Fixes yuku#53.
@yuku yuku closed this as completed in #55 Mar 28, 2014
@yuku yuku added the DEPRECATED jquery-textcomplete Issues associated to jquery-textcomplete (was DEPRECATED) label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug DEPRECATED jquery-textcomplete Issues associated to jquery-textcomplete (was DEPRECATED)
Projects
None yet
Development

No branches or pull requests

2 participants