Skip to content

Commit

Permalink
ListItemOrdinal should use explicit_value_ when the element's counter…
Browse files Browse the repository at this point in the history
…-set CSS property is set to empty

The patch[1] ensures that ListItemOrdinal does not use `explicit_value_`
when the `counter-set` is set. However, if the `counter-set` is assigned
an invalid value, ListItemOrdinal value will remain unchanged.
Consider this test case:
```
<!doctype html>
<ol>
  <li value="5" style="counter-set: list-item 1"></li>
</ol>
<script>
document.body.offsetLeft;
document.querySelector("li").style.counterSet = "";
</script>
```
The li element should show "5" as the `counter-set` is not set.
This patch ensures that ListItemOrdinal should use `explicit_value_`
when `counter-set` is not set.

[1]: https://chromium-review.googlesource.com/c/chromium/src/+/5974811

Bug: 40205385
Change-Id: I0c9eeda21ef6890e727a6f42c464af412b08eb50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5992536
Reviewed-by: Joey Arhar <[email protected]>
Commit-Queue: Peng Zhou <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1379108}
  • Loading branch information
zhoupeng authored and chromium-wpt-export-bot committed Nov 6, 2024
1 parent 67feadb commit e8e4fa7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions css/css-lists/li-value-counter-reset-002-ref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<title>CSS Test Reference</title>
<ol>
<li value="5">five
<li value="6">six
<li value="7">seven
</ol>
14 changes: 14 additions & 0 deletions css/css-lists/li-value-counter-reset-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<title>CSS Lists: LI will display the `value` attribute if `counter-set` is empty</title>
<link rel="help" href="https://drafts.csswg.org/css-lists/#propdef-counter-set">
<link rel="author" title="Peng Zhou" href="mailto:[email protected]">
<link rel="match" href="li-value-counter-reset-002-ref.html">
<ol>
<li value="5" style="counter-set: list-item 1" id="one">five</li>
<li value="6">six</li>
<li style="counter-set: list-item 7">seven</li>
</ol>
<script>
document.body.offsetLeft;
document.getElementById("one").style.counterSet = "";
</script>

0 comments on commit e8e4fa7

Please sign in to comment.