Repository navigation
Conversation
✅ Deploy Preview for vue-test-utils-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
9287d8e to
fc329eb
Compare
|
Thanks for the review, @cexbrayat — good catches, both addressed. On So instead of the property, I rewrote it to mirror On test coverage, added:
35/35 tests pass, and I verified the two new inheritance-specific tests actually catch the original bug (they fail against the pre-rewrite code, since the old attribute-only check didn't look at ancestors at all). |
wrapper.setValue() threw on any element that wasn't INPUT, TEXTAREA, SELECT, or OPTION, so it had no way to drive a `<div contenteditable>` rich-text editor, a common pattern for building such editors on the web. An element is now editable (and setValue sets innerHTML and triggers input/change) when its nearest contenteditable ancestor-or-self has a value other than "false" -- mirroring Element.isContentEditable's inheritance rules (any tag, and a child with no attribute of its own inherits from an editable parent) without relying on the property itself, which jsdom does not implement and would therefore never read as editable for the vast majority of this library's consumers. Fixes vuejs#2390
cexbrayat
left a comment
There was a problem hiding this comment.
I think happy-dom does implement isContentEditable (see https://github.com/capricorn86/happy-dom/blob/master/packages/happy-dom/src/nodes/html-element/HTMLElement.ts#L564-L581), and people may run their tests in a browser directly, using Vitest Browser Mode.
So I think we should use native isContentEditable when it returns a boolean.
|
Hi @Revan0809 if you're still interesting in landing this PR, would you mind take a look at my last comment ? Thanks! |
|
@Revan0809 are you still planning to finish this one (the |
|
Opened #3033 that builds on this and addresses the review here. |
|
Superseded by #3033 |
Summary
wrapper.setValue()threwwrapper.setValue() cannot be called on ${tagName}for any element that wasn'tINPUT,TEXTAREA,SELECT, orOPTION— so there was no way to drive a<div contenteditable>element, which is a common pattern for building rich-text editors on the web.contenteditableattribute whose value isn't"false"(i.e.contenteditable,contenteditable="",contenteditable="true", orcontenteditable="plaintext-only"),setValue()now setsinnerHTMLand triggersinput/change, mirroring the existingINPUT/TEXTAREAbranch.contenteditable="false"still throws, since that value explicitly marks it non-editable — matching the issue's proposed fix, extended slightly for correctness on that one edge case.Closes #2390
Test plan
contenteditable="true", barecontenteditable, input/change event firing, and thecontenteditable="false"case still throwingdomWrapper.tswhile keeping the tests reproduces the exactwrapper.setValue() cannot be called on DIVerror from the issuenpx vitest run tests/setValue.spec.ts— 29/29 passnpx vue-tsc --noEmit -p tsconfig.volar.json— 0 errorsnpx oxlint src/domWrapper.ts tests/setValue.spec.ts— 0 new issues (pre-existingvitest(require-mock-type-parameters)warnings onvi.fn()calls are present throughout this file already, confirmed unrelated to this change)🤖 Generated with Claude Code