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

test is not a function #125

Closed
AllaSydoriak-asd opened this issue May 18, 2023 · 5 comments
Closed

test is not a function #125

AllaSydoriak-asd opened this issue May 18, 2023 · 5 comments

Comments

@AllaSydoriak-asd
Copy link

AllaSydoriak-asd commented May 18, 2023

Hi!

Recently I have noticed that some input fields started not working with hyperform. I can't type anything in there. And I permenantly get this error Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).test is not a function which is raised on the 2nd line of hyperform.min.js.

Firsty I thought that this is connected to "pattern" property, but even if I remove it, the form still can't submit and all error messages that I see is described above.

Do you have any thoughts what the reason can be?

Thank you.

@Boldewyn
Copy link
Contributor

Hm, this is strange. Could you do me a favor and do two things:

  1. Try using hyperform.js without minification (i.e., not the one with .min in the file name). This will provide us with a more granular line number to look for the problem.
  2. Can you share the HTML snippet (basically just the <input>/<textarea> element) where the problem appears?

Thank you!

@AllaSydoriak-asd
Copy link
Author

AllaSydoriak-asd commented May 19, 2023

  1. It shows error in this line hyperform.js:1279
function test_pattern (element) {
    return !element.value || !element.hasAttribute('pattern') || (new RegExp('^(?:' + element.getAttribute('pattern') + ')$'), canUnicode ? 'u' : undefined).test(element.value);
  }
  1. here is one of examples:
<input 
      type="tel" 
      name="cvv" 
      data-name="cvv" 
      class="hf-validated hf-invalid user-error" 
      id="cvv" 
      pattern="[0-9]{3,4}" 
      placeholder="Security Code" 
      title="Please enter 3 digits for your CVV, or 4 digits for American Express" 
      value="" 
      required="" 
      aria-invalid="true"
 >

@Boldewyn
Copy link
Contributor

This was caused by a misplaced parenthesis. Thank you very much for the report! The fix is now in the repository.

As a side note: I suggest to use official releases. The error was introduced by problematic code last week, but there are also other issues currently worked at, and some parts of the code do not work yet as intended between releases. (In this concrete case: The stepUp and stepDown functions are currently worked at and do not yet work again.)

@AllaSydoriak-asd
Copy link
Author

AllaSydoriak-asd commented May 19, 2023

Thank you for a quick fix!

Just a question. Should this changes apply now and if yes, is this url <script src="https://cdn.rawgit.com/hyperform/hyperform/master/dist/hyperform.min.js"/> is correct? becuase issue is still reproducible.

@Boldewyn
Copy link
Contributor

Yes, the content behind that URL should update eventually. I assume it is cached for some time.

An alternative URL for a stable version would be, e.g., https://unpkg.com/hyperform@0.12.1/dist/hyperform.min.js . There the problem is not present, too.

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