fix(codegen): ignore previously hovered detached nodes (#23057)

Fixes #23043.
This commit is contained in:
Dmitry Gozman 2023-05-16 11:13:19 -07:00 committed by GitHub
parent 2fc6341841
commit 62146b946c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -249,8 +249,9 @@ export class Recorder {
}
private _updateModelForHoveredElement() {
if (!this._hoveredElement) {
if (!this._hoveredElement || !this._hoveredElement.isConnected) {
this._hoveredModel = null;
this._hoveredElement = null;
this._updateHighlight();
return;
}

View File

@ -439,6 +439,17 @@ test.describe('cli codegen', () => {
expect(models.hovered).toBe('#checkbox');
});
test('should reset hover model on action when element detaches', async ({ page, openRecorder }) => {
const recorder = await openRecorder();
await recorder.setContentAndWait(`<input id="checkbox" onclick="document.getElementById('checkbox').remove()">`);
const [models] = await Promise.all([
recorder.waitForActionPerformed(),
page.click('input')
]);
expect(models.hovered).toBe(null);
});
test('should update active model on action', async ({ page, openRecorder, browserName, headless }) => {
test.fixme(browserName === 'webkit');