NEW 76514
execCommand insertorderedlist changes markup
https://bugs.webkit.org/show_bug.cgi?id=76514
Summary execCommand insertorderedlist changes markup
Patrick Quinn-Graham
Reported 2012-01-17 20:40:54 PST
Given markup similar to: <p><span class="foo" data-foo="bar">Magic</span></p> and having the entire contents of the <p> tag selected, document.execCommand('insertorderedlist') results in: <p><ul><li><span class="Apple-style-span" style="font-family: Some, fonts, defined, by, foo, class;">Magic</li></ul></p> Losing both the class and data-foo attributes.
Attachments
reduction (402 bytes, text/html)
2012-05-01 22:54 PDT, Ryosuke Niwa
no flags
Ryosuke Niwa
Comment 1 2012-05-01 22:54:24 PDT
Created attachment 139750 [details] reduction
Yi Shen
Comment 2 2012-05-02 06:42:42 PDT
Niwa, are you working on this bug? (In reply to comment #1) > Created an attachment (id=139750) [details] > reduction
Ryosuke Niwa
Comment 3 2012-05-02 23:07:49 PDT
(In reply to comment #2) > Niwa, are you working on this bug? No.
Yi Shen
Comment 4 2012-05-03 06:38:57 PDT
i believe the root cause of this issue is because webkit uses VisibleSelection to represent the selected content/dom nodes, which may lose some information after canonicalization. For example, in Patrick's test, only the Text node ("Magic") can be actually selected since webkit uses VisibleSelection, and that's why we lose the <span> tag after execution the insert list command. Generally, I don't think we can fix this issue in a small patch since we use VisibleSelection in text selection and html editing everywhere. Niwa & Enrica, what do you think? (In reply to comment #3) > (In reply to comment #2) > > Niwa, are you working on this bug? > > No.
Ryosuke Niwa
Comment 5 2012-05-03 11:45:10 PDT
I don't think we should be deleting span in this case though. In addition, InsertListCommand has some logic to extend the visible selection to include all elements around the selection so I'm not sure why that logic isn't kicking in.
Yi Shen
Comment 6 2012-05-03 12:36:26 PDT
hmm, how does the InsertListCommand know whether it should extend the visible selection? Considering following two cases, 1) user selected the text "Magic" only. 2) user selected the text "Magic" with the surrounding span tag. The InsertListCommand should only extend the visible selection for case 2, right? (In reply to comment #5) > I don't think we should be deleting span in this case though. In addition, InsertListCommand has some logic to extend the visible selection to include all elements around the selection so I'm not sure why that logic isn't kicking in.
Ryosuke Niwa
Comment 7 2012-05-05 12:56:54 PDT
(In reply to comment #6) > hmm, how does the InsertListCommand know whether it should extend the visible selection? Considering following two cases, 1) user selected the text "Magic" only. 2) user selected the text "Magic" with the surrounding span tag. The InsertListCommand should only extend the visible selection for case 2, right? No. We should always extend the selection to include the span. There is no way to just indent the text inside the span since the span shouldn't have non-phrasing elements (e.g. ul, li) as its children.
Ahmad Saleem
Comment 8 2022-08-30 04:52:05 PDT
*** Safari Technology Preview 152 *** <p><ol><li>Magic<br></li></ol></p> *** Chrome Canary 107 *** <p><ol><li><span class="foo" data-foo="bar">Magic</span></li></ol></p> *** Firefox Nightly 106 *** <ol><li><span class="foo" data-foo="bar">Magic</span></li></ol> ________ All browsers differ in the above test case. Appreciate if someone can add this to RADAR. Thanks!
Radar WebKit Bug Importer
Comment 9 2022-08-30 09:50:19 PDT
Note You need to log in before you can comment on or make changes to this bug.