Decide if element is bold by getComputedStyle (#2453) (#2579)

* Decide if element is bold by getComputedStyle (#2453)

* Use getComputedStyle() for italics too (dae)
This commit is contained in:
mmjang 2024-10-02 17:37:40 +08:00 committed by GitHub
parent 2ac27585b2
commit 9ced6be03e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -17,8 +17,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
return match.remove();
}
const fontWeight = element.style.fontWeight;
if (fontWeight === "bold" || Number(fontWeight) >= 700) {
const fontWeight = getComputedStyle(element).fontWeight;
const threshold = 700;
if (fontWeight && Number(fontWeight) >= threshold) {
return match.clear((): void => {
if (
removeStyleProperties(element, "font-weight") &&

View file

@ -17,7 +17,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
return match.remove();
}
if (["italic", "oblique"].includes(element.style.fontStyle)) {
const fontStyle = getComputedStyle(element).fontStyle;
if (["italic", "oblique"].includes(fontStyle)) {
return match.clear((): void => {
if (
removeStyleProperties(element, "font-style") &&