-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: fieldDropdown.getText works in node #9048
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
fix: fieldDropdown.getText works in node #9048
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
BenHenning
left a comment
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.
Thanks @maribethb! Approving to unblock, but had some thoughts (most of which likely don't need to happen now for v12).
|
|
||
| assert.deepEqual(jsonAfter, json); | ||
| }); | ||
| test('Dropdown getText works with no HTMLElement defined', function () { |
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.
Just to check: this test fails without the fix in place, right?
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.
Yes.
| "you're using HTMLElement dropdown options in node, ensure you're " + | ||
| 'using jsdom-global or similar.', | ||
| ); | ||
| return null; |
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.
Is it worth verifying the console warning & null case in tests?
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.
No, because in order to get here you'd have to pass something that is an HTMElement type but then don't have HTMLElement defined. It would be really annoying to set up in tests and is a scenario that is unlikely to happen at all. But I had to return null to satisfy the ts compiler and the warning helps figure out why that is, in the off chance it ever somehow does happen.

The basics
The details
Resolves
Fixes #9035
Proposed Changes
Checks that
HTMLElementis defined before trying to use itReason for Changes
Dropdown fields should work in node
Test Coverage
Added a node test to make sure this change fixes the CI problems we saw in samples
Documentation
I logged a warning for the case that would hit if:
FieldDropdownwithHTMLElementoptionsHTMLElement, and callgetText.Honestly the chances anyone does this and doesn't run into a number of other issues is relatively small, but hopefully the warning message helps them out if so.
If someone is using node with just regular text options, they don't need to supply an implementation of
HTMLElementand won't see the warning, so this doesn't affect the usual case (and before v12, the only case, as it wasn't possible to use element options).Additional Information