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

Why aren't ValidityState[tooLong|tooShort] supported? #2493

Closed
brophdawg11 opened this issue Jan 18, 2019 · 4 comments
Closed

Why aren't ValidityState[tooLong|tooShort] supported? #2493

brophdawg11 opened this issue Jan 18, 2019 · 4 comments

Comments

@brophdawg11
Copy link

Basic info:

  • Node.js version: 8.11.3
  • jsdom version: 13.1.0

Minimal reproduction case

n/a

I don't have a specific example, rather a question about the source code. Can someone elaborate on this code comment and why tooLong and tooShort can't be implemented?

https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L777

It doesn't appear that other string-input validations require user-interactions (i.e., patternMismatch). It is quite frustrating to only be able to test portions of the ValidityState API using jsdom.

How does similar code behave in browsers?

ValidityState is fully functional

@domenic
Copy link
Member

domenic commented Jan 18, 2019

The comment pretty clearly explains why, I think.

Please provide a code example that works in the browser but not jsdom and we can consider this further. Until then, closing.

@domenic domenic closed this as completed Jan 18, 2019
@brophdawg11
Copy link
Author

I opened the issue because I don't understand the comment...

@domenic
Copy link
Member

domenic commented Jan 18, 2019

I'm very sorry; I skimmed and missed that you had already read the comment. I didn't mean to be dismissive.

The comment means that tooLong and tooShort cannot be caused by JavaScript, only user interaction (i.e., an actual user clicking and typing things on the screen). Since jsdom is a JavaScript library with a JavaScript API, and not a true web browser that you can click on and type things in to, tooLong and tooShort cannot be triggered in jsdom.

It's possible the comment is incorrect; I haven't read or investigated these parts of the spec in detail. But if the comment were incorrect, then you'd be able to provide a piece of JavaScript that works in the browser but not in jsdom. Thus my request.

@brophdawg11
Copy link
Author

No worries - I'll admit I didn't dig too deep beyond the comment either. The second link in the code contains a link to the dirty value attribute, which made it clearer to me.

For kicks, I pout together a codepen to confirm the comment is still accurate: https://codepen.io/brophdawg11/pen/aPgqVE

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