fix: extra protection around tagName accessor #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alert: https://cypressio.slack.com/archives/C0614M4DZV5/p1746718971129419
We have a test case in the cypress-services repo that specifically overrides a form element's
tagName
property using a nested<input id="tagName">
element. When the form is processed with unique-selector, unique-selector will throw as a result of this overridden property that references an element (rather than the expected string). This is causing a few alerts to come through (and knocking our Cypress reports into a "Processed with errors" state).So, added a little check to ignore tagName when it's not the expected type.
I looked at the other accessors in use here, and most everything else goes through a
getAttribute
call. I [don't think we can really be exhaustive here without going overboard, buttagName
overrides are something the App has run into as well, so we might as well work around it (and keep our own tests happy). If we notice other goofy things happening to elements, we can evaluate further protections.