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

Uncaught TypeError - invalid input #146

Closed
ghost opened this issue Apr 28, 2014 · 6 comments
Closed

Uncaught TypeError - invalid input #146

ghost opened this issue Apr 28, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Apr 28, 2014

Hi,

I'm getting the following messages when including uri.js:
image

I've tried various combinations (with/without jquery, ipv6, punycode; minified, only whitespace). Same error in Chrome and IE10, maybe this issue is related to SharePoint 2013 wrapping the script files? Including jQuery or other scripts in my SharePoint page does work fine.

Regards

@rodneyrehm
Copy link
Member

Is that live somewhere? What's the input that causes this? use the debugger to break where the error is thrown to see what the passed value is. (apparently it's not a string, DOM node, URI instance, or object representing window.location)

@ghost
Copy link
Author

ghost commented Apr 28, 2014

This is not publicly live, sorry.

Should have mentioned: the error occurs even if not using any URI(), it's just included (besides jquery itself) without calling any method.

@rodneyrehm
Copy link
Member

is the jQuery plugin loaded as well? Can you please try the debugger anyway?

@rodneyrehm
Copy link
Member

closing because OP did not provide a test-case for reproduction.

@mdoelker
Copy link

I encountered this error myself today. It occurs when setting href/src using a String object rather than a string. I noticed it when setting an image src through jQuery using a String object which works fine when using jQuery but will fail when URI.js with jQuery plugin is loaded. Easy fix is wrapping the value with String(), thus converting it to a primitive string.

So why would you use String objects over primitives? Apparently jQuery calls .each() with this being a String object whereas the value passed to the callback is of type string like you would expect. See this example:

$.fn.logType = function () {
    this.each(function (i, value) {
        console.log(value, typeof this, typeof value);
    });
};

$(["one", "two", "three"]).logType();

/*
logs:

one object string
two object string
three object string
*/

So it's easily possible to run into this problem without even knowing what you did wrong.

See this fiddle that produces the error: http://jsfiddle.net/n3y27v2f/

@rodneyrehm
Copy link
Member

Thank you @mdoelker! I just committed a fix, please check if that solves your problem

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

No branches or pull requests

2 participants