LibWeb/SVG: Implement default_tab_index_value for a element

Another FIXME bites the dust :^)
This commit is contained in:
Jamie Mansfield 2024-08-14 18:45:18 +01:00 committed by Tim Ledbetter
commit 9c4e80a3ec
Notes: github-actions[bot] 2024-08-14 19:40:26 +00:00
5 changed files with 61 additions and 1 deletions

View file

@ -0,0 +1,12 @@
p.tabIndex initial value: -1
h1.tabIndex initial value: -1
a.tabIndex initial value: 0
area.tabIndex initial value: 0
button.tabIndex initial value: 0
frame.tabIndex initial value: 0
iframe.tabIndex initial value: 0
input.tabIndex initial value: 0
object.tabIndex initial value: 0
select.tabIndex initial value: 0
textarea.tabIndex initial value: 0
svg.a.tabIndex initial value: 0

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
function tabIndexTest(tagName, element) {
println(`${tagName}.tabIndex initial value: ${element.tabIndex}`);
}
test(() => {
const controlTagNamesToTest = [
"p",
"h1",
];
const tagNamesToTest = [
"a",
"area",
"button",
"frame",
"iframe",
"input",
"object",
"select",
"textarea",
];
const svgTagNamesToTest = [
"a",
];
for (const tagName of controlTagNamesToTest) {
const element = document.createElement(tagName);
tabIndexTest(tagName, element);
}
for (const tagName of tagNamesToTest) {
const element = document.createElement(tagName);
tabIndexTest(tagName, element);
}
for (const tagName of svgTagNamesToTest) {
const element = document.createElementNS("http://www.w3.org/2000/svg", tagName);
tabIndexTest(`svg.${tagName}`, element);
}
});
</script>

View file

@ -1184,7 +1184,6 @@ i32 Element::default_tab_index_value() const
// The default value is 0 if the element is an a, area, button, frame, iframe, input, object, select, textarea, or SVG a element, or is a summary element that is a summary for its parent details.
// The default value is 1 otherwise.
// Note: The varying default value based on element type is a historical artifact.
// FIXME: We currently do not have the SVG a element.
return -1;
}

View file

@ -43,6 +43,13 @@ void SVGAElement::attribute_changed(FlyString const& name, Optional<String> cons
}
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
i32 SVGAElement::default_tab_index_value() const
{
// See the base function for the spec comments.
return 0;
}
// https://svgwg.org/svg2-draft/linking.html#__svg__SVGAElement__relList
JS::NonnullGCPtr<DOM::DOMTokenList> SVGAElement::rel_list()
{

View file

@ -33,6 +33,7 @@ private:
// ^DOM::Element
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override;
virtual i32 default_tab_index_value() const override;
JS::GCPtr<DOM::DOMTokenList> m_rel_list;
};