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
matzerj opened this Issue Apr 28, 2014 · 6 comments

Comments

Projects
None yet
3 participants
@matzerj

matzerj 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

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Apr 28, 2014

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)

Member

rodneyrehm commented Apr 28, 2014

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)

@matzerj

This comment has been minimized.

Show comment
Hide comment
@matzerj

matzerj 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.

matzerj 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

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Apr 28, 2014

Member

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

Member

rodneyrehm commented Apr 28, 2014

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

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Aug 20, 2014

Member

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

Member

rodneyrehm commented Aug 20, 2014

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

@rodneyrehm rodneyrehm closed this Aug 20, 2014

@mdoelker

This comment has been minimized.

Show comment
Hide comment
@mdoelker

mdoelker Sep 10, 2014

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/

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

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Sep 10, 2014

Member

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

Member

rodneyrehm commented Sep 10, 2014

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