Bug 158115 - queryCommandState('underline') returns a wrong value after toggling typing style via execCommand('underline')
Summary: queryCommandState('underline') returns a wrong value after toggling typing st...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: Safari 9
Hardware: All All
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-26 04:27 PDT by Josh Hargreaves
Modified: 2021-11-01 12:15 PDT (History)
5 users (show)

See Also:


Attachments
bug_demo (618 bytes, text/html)
2016-05-26 04:27 PDT, Josh Hargreaves
no flags Details
Reduction (621 bytes, text/html)
2016-05-29 03:24 PDT, Ryosuke Niwa
no flags Details
Fixes the bug (13.91 KB, patch)
2018-05-22 00:07 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Hargreaves 2016-05-26 04:27:26 PDT
Created attachment 279878 [details]
bug_demo

When using the attribute 'contenteditable=true' on an element, if said element in underlined and no selection is made,
a call to execCommand('underline') will not result in the value returned by 'queryCommandState('underline')' to be 'toggled' from true to false and vice versa;
this behavior is inconsistent with the behavior of 'execCommand('bold')', 'execCommand('italic')' for example, where the relevant command states 
are in fact toggled.

The attached demo will behave differently in chrome when compared to safari. (clicking toggle underline does toggled the state in chrome). 

I believe this bug to be the inverse of this bug: https://bugs.webkit.org/show_bug.cgi?id=17594

As far as I'm aware this is a bug, but please forgive me if it's desired behavior?

Bug is at least present on IOS 9.2 and Safari 9 on Mac. I have not had time to test other platforms.
Comment 1 Ryosuke Niwa 2016-05-29 03:24:28 PDT
Created attachment 280058 [details]
Reduction

Adding a reduction. The behaviors of queryCommandState('underline') and queryCommandState('bold') are inconsistent.
Comment 2 Ryosuke Niwa 2018-05-22 00:07:00 PDT
Created attachment 340958 [details]
Fixes the bug
Comment 3 Alex Christensen 2021-11-01 12:15:53 PDT
Comment on attachment 340958 [details]
Fixes the bug

This has been requesting review for more than one year.  If this is still needed, please rebase and re-request review.