fix: content editable retarget (#29792)

If `contenteditable` is wrapped into a button or `[role=button]`,
`element.fill` will incorrectly retarget the closest button element.

fix https://github.com/microsoft/playwright/issues/29813
This commit is contained in:
Peng Xiao 2024-04-02 04:03:09 +08:00 committed by GitHub
parent 1602548c10
commit cc881fdb1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -459,7 +459,7 @@ export class InjectedScript {
return null;
if (behavior === 'none')
return element;
if (!element.matches('input, textarea, select')) {
if (!element.matches('input, textarea, select') && !(element as any).isContentEditable) {
if (behavior === 'button-link')
element = element.closest('button, [role=button], a, [role=link]') || element;
else

View File

@ -250,7 +250,7 @@ it('input value retargeting', async ({ page, browserName }) => {
}
});
it.fixme('selection retargeting', async ({ page, browserName }) => {
it('selection retargeting', async ({ page, browserName }) => {
const cases = [
{ dom: domStandalone(`<div contenteditable id=target>content</div>`), locator: 'div' },
{ dom: domInButton(`<div contenteditable id=target>content</div>`), locator: 'div' },