Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Form-association for <img> is inconsistent
https://bugs.webkit.org/show_bug.cgi?id=129742 Reviewed by Darin Adler. This patch updates the way HTMLImageElement associates itself with HTMLFormElement to be more consistent with FormAssociatedElement. New behavior matches that of Gecko and Blink. * LayoutTests/fast/forms/image/image-named-access-expected.txt: Added. * LayoutTests/fast/forms/image/image-named-access.html: Added. * Source/WebCore/html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::removedFromAncestor): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::~HTMLImageElement): (WebCore::HTMLImageElement::form const): Added. Returns m_form instead of returning the form ancestor. (WebCore::HTMLImageElement::setForm): Extracted from insertedIntoAncestor. Automatically calls removeImgElement and registerImgElement. (WebCore::HTMLImageElement::formOwnerRemovedFromTree): Added. Clear m_form when the associated form element is no longer in the same subtree as this element. (WebCore::HTMLImageElement::insertedIntoAncestor): Don't associate this element with a from element set by the parser if the form had been disconnected like FormAssociatedElement. (WebCore::HTMLImageElement::removedFromAncestor): Don't remove this element from the form element if the root node didn't change like FormAssociatedElement. * Source/WebCore/html/HTMLImageElement.h: Canonical link: https://commits.webkit.org/256629@main
- Loading branch information
Showing
5 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This tests removing an image element with a form element ancestor during parsing | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS form["img1"] is img1 | ||
PASS form["img2"] is img2 | ||
PASS form["img3"] is undefined. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<div id="willBeRemoved"> | ||
<div> | ||
<form id="form"> | ||
<img id="img1"> | ||
</div> | ||
<img id="img2"> | ||
</div> | ||
<img id="img3"> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script> | ||
description('This tests removing an image element with a form element ancestor during parsing'); | ||
const form = document.getElementById('form'); | ||
const img1 = document.getElementById('img1'); | ||
const img2 = document.getElementById('img2'); | ||
const img3 = document.getElementById('img3'); | ||
const willBeRemoved = document.getElementById('willBeRemoved'); | ||
willBeRemoved.remove(); | ||
shouldBe('form["img1"]', 'img1'); | ||
shouldBe('form["img2"]', 'img2'); | ||
shouldBeUndefined('form["img3"]'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters