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.
Created attachment 139750 [details] reduction
Niwa, are you working on this bug? (In reply to comment #1) > Created an attachment (id=139750) [details] > reduction
(In reply to comment #2) > Niwa, are you working on this bug? No.
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.
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.
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.
(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.
*** 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!
<rdar://problem/99335825>