mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Update the select element's text when setting the selected index
We were updating the IDL values, but the rendered text would remain on the previously selected value.
This commit is contained in:
parent
9b6ae962d0
commit
206ec6694c
Notes:
github-actions[bot]
2025-03-22 16:29:20 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/206ec6694c5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4036
3 changed files with 37 additions and 0 deletions
|
@ -284,6 +284,8 @@ void HTMLSelectElement::set_selected_index(WebIDL::Long index)
|
|||
for (auto& option : m_cached_list_of_options)
|
||||
option->set_selected_internal(false);
|
||||
|
||||
ScopeGuard guard { [&]() { update_inner_text_element(); } };
|
||||
|
||||
if (index < 0 || static_cast<size_t>(index) >= m_cached_list_of_options.size())
|
||||
return;
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x37 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x21 children: inline
|
||||
frag 0 from BlockContainer start: 0, length: 0, rect: [13,10 78.390625x17] baseline: 18.5
|
||||
BlockContainer <select#select> at (13,10) content-size 78.390625x17 inline-block [BFC] children: not-inline
|
||||
Box <div> at (13,10) content-size 78.390625x17 flex-container(row) [FFC] children: not-inline
|
||||
BlockContainer <div> at (13,10) content-size 58.390625x17 flex-item [BFC] children: inline
|
||||
frag 0 from TextNode start: 0, length: 7, rect: [13,10 58.390625x17] baseline: 13.296875
|
||||
"Value 1"
|
||||
TextNode <#text>
|
||||
BlockContainer <div> at (75.390625,10.5) content-size 16x16 flex-item [BFC] children: inline
|
||||
frag 0 from SVGSVGBox start: 0, length: 0, rect: [75.390625,10.5 16x16] baseline: 16
|
||||
SVGSVGBox <svg> at (75.390625,10.5) content-size 16x16 [SVG] children: not-inline
|
||||
SVGGeometryBox <path> at (79.390625,16.21875) content-size 8x4.953125 children: not-inline
|
||||
TextNode <#text>
|
||||
TextNode <#text>
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x37]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x21]
|
||||
PaintableWithLines (BlockContainer<SELECT>#select) [8,8 88.390625x21]
|
||||
PaintableBox (Box<DIV>) [13,10 78.390625x17]
|
||||
PaintableWithLines (BlockContainer<DIV>) [13,10 58.390625x17]
|
||||
TextPaintable (TextNode<#text>)
|
||||
PaintableWithLines (BlockContainer<DIV>) [75.390625,10.5 16x16]
|
||||
SVGSVGPaintable (SVGSVGBox<svg>) [75.390625,10.5 16x16]
|
||||
SVGPathPaintable (SVGGeometryBox<path>) [79.390625,16.21875 8x4.953125]
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<select id="select">
|
||||
<option>Value 0</option>
|
||||
<option>Value 1</option>
|
||||
</select>
|
||||
<script>
|
||||
select.selectedIndex = 1;
|
||||
</script>
|
Loading…
Add table
Reference in a new issue