Skip to content

Uncaught TypeError: $(...).getValue is not a function #342

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

Closed
tbtalbottjr opened this issue Jul 31, 2018 · 5 comments
Closed

Uncaught TypeError: $(...).getValue is not a function #342

tbtalbottjr opened this issue Jul 31, 2018 · 5 comments

Comments

@tbtalbottjr
Copy link

We recently moved an old codebase from Prototype 1.7 to 1.7.1 because we are about to embark on an iterative rewrite using vue.js. Moving to 1.7.1 fixed some incompatibility issues that I don't recall off the top of my head. But we noticed that since moving to 1.7.1 we are getting the following error when used in mobile Safari or mobile Chrome:

application.js:2001 Uncaught TypeError: $(...).getValue is not a function
    at Object.set_criteria (application.js:2001)

where application.js has:

  set_criteria: function(num) {
    console.log('search_select_' + num)
    console.log($('search_select_' + num))
    var uid     = $('search_select_' + num).readAttribute("_uid");
    var val     = $('search_select_' + num).getValue();
    ...

This error also occurs using 1.7.2 and 1.7.3. The error does not occur in either desktop browser.

We are reverting to 1.7 for now until we can figure out this problem and will try to create a simplified repro case when I get a chance, but was wondering if this is a known issue. I can't find anything on it, so I wonder if there is a different incompatibility with another JS library we are using.

@jwestbrook
Copy link
Collaborator

I see the console.log calls what do they show in the console?

Typically if an element with the id does not exist then $() will return null and $().getValue() will not be a function.

Also I think if the element you are attempting to run .getValue() on is not a normal form element, or not a descendent of a <form> element the .getValue() method will not exist on the element.

@tbtalbottjr
Copy link
Author

tbtalbottjr commented Jul 31, 2018

Thanks for the reply

The log shows the <select> element that we are expecting. I thought the same thing.

Right now we are going down the path of suspecting some other JS library conflict since an isolated test case seems to be working. I will close if we are able to determine why it is happening and why only on mobile and if it isn't a problem with 1.7.1+.

@tbtalbottjr
Copy link
Author

We found that the problem was being caused by our own JS that was defining:

   var Node = {
      ...
   }

This apparently conflicts with code in 1.7.1+, but only in mobile browsers. :/

Renaming this (or namespacing it) solves the problem. I can close this unless you feel it is worth investigating whether it makes sense for Node to be left vulnerable in this case.

Thanks.

@jwestbrook
Copy link
Collaborator

I'm guessing that your Node is in the global space - so with the DOM rewrite in 1.7.1 Prototype uses a variable Node in the global space as well as a general definition of a DOM node.

I'll open a specific issue that references this issue so you can close it.

@tbtalbottjr
Copy link
Author

Yes, that is correct.

Closing.

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