-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add isRequired and isNotRequired assertions #65
Conversation
lib/assertions/is-not-required.js
Outdated
if (!element) return; | ||
|
||
let result = element.required === false; | ||
let actual = element.required === true ? 'required' : 'not required'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just reuse the result
variable here instead of comparing the property again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also updated is-required.js
to do the same. FWIW, this is what is-checked
does, so we may want to update that too separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, agreed. I merged it and planned to do a small cleanup round later :)
lib/assertions/is-not-required.js
Outdated
let element = this.findTargetElement(); | ||
if (!element) return; | ||
|
||
let result = element.required === false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the element is not an <input>
element? would required
be undefined
then and fail this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I've added a conditional, which will throw if an element is passed that is not one of HTMLInputElement
, HTMLTextAreaElement
, or HTMLSelectElement
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And a test...
@Turbo87 anything else I need to do to push this in? |
remind me about it 😜 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thanks again! 👍
Implements #56
Fills in the API for
isRequired
isNotRequired
TODO:
isRequired
isNotRequired