feat: allow setValue to set values to contenteditable divs #2671
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.
Implements #2390
Support
setValue
forcontenteditable
ElementsSummary
This PR extends the
DOMWrapper.setValue
method to support elements with thecontenteditable
attribute (such as<div contenteditable="true">
). Previously,setValue
was only applicable to form inputs, textareas, and selects. With this change, users can now easily set the inner HTML of contenteditable elements in their tests, and trigger the expectedinput
andchange
events.Details
setValue
:When called on a
DIV
with thecontenteditable
attribute,setValue
updates the element’sinnerHTML
, triggers bothinput
andchange
events, and supports any value (object values will be stringified).If
setValue
is called on an unsupported element, an error is still thrown as before.Added a dedicated test case to verify that
setValue
properly updates a contenteditable element’s inner HTML and triggers the appropriate events.Motivation
Rich text editors and other contenteditable-based components are common in modern web apps. This enhancement allows for more robust and expressive testing of these components, improving DX and test reliability.
Example Usage