Bug 158115

Summary: queryCommandState('underline') returns a wrong value after toggling typing style via execCommand('underline')
Product: WebKit Reporter: Josh Hargreaves <jhargreaves4>
Component: BindingsAssignee: Ryosuke Niwa <rniwa>
Status: NEW ---    
Severity: Normal CC: achristensen, cdumez, enrica, rniwa, wenson_hsieh
Priority: P2    
Version: Safari 9   
Hardware: All   
OS: All   
Attachments:
Description Flags
bug_demo
none
Reduction
none
Fixes the bug none

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.