We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
const jsdom = require('jsdom'); const { JSDOM } = jsdom; const pattern = String.raw`^(?!-)[[A-Za-z0-9\-]]+([[\-\.]]{1}[[a-z0-9]]+)*\.[[A-Za-z]]{2,18}$`; const value = 'not-a-domain'; const dom = new JSDOM(`<input id="domain" pattern="${pattern}" required value="${value}">`); const input = dom.window.document.querySelector("#domain"); console.log('pattern:', input.pattern); console.log('value:', input.value); input.checkValidity(); console.log('validity.valid:', input.validity.valid); // returns true console.log('validity.patternMismatch:', input.validity.patternMismatch); // returns false
In the browser, input.validity.valid is false and input.validity.patternMismatch is true. You can test this by pasting this code:
input.validity.valid
false
input.validity.patternMismatch
true
<input id="domain" pattern="^(?!-)[[A-Za-z0-9\-]]+([[\-\.]]{1}[[a-z0-9]]+)*\.[[A-Za-z]]{2,18}$" required value="not-a-domain"> <input id="domain" pattern="^(?!-)[[A-Za-z0-9\-]]+([[\-\.]]{1}[[a-z0-9]]+)*\.[[A-Za-z]]{2,18}$" required value="example.com">
into MDN's pattern docs:
In jsdom's source code, I noticed the u flag being used for the RegExp:
u
https://github.com/kontomondo/jsdom/blob/c8f6f2504a71aa904f76b5bd4359505fc4820860/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L806
According to MDN:
Would it be okay to update the source accordingly?
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Basic info:
Minimal reproduction case
How does similar code behave in browsers?
In the browser,
input.validity.valid
isfalse
andinput.validity.patternMismatch
istrue
. You can test this by pasting this code:into MDN's pattern docs:
In jsdom's source code, I noticed the
u
flag being used for the RegExp:https://github.com/kontomondo/jsdom/blob/c8f6f2504a71aa904f76b5bd4359505fc4820860/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L806
According to MDN:
Would it be okay to update the source accordingly?
The text was updated successfully, but these errors were encountered: