Bug 16309 - HTML5: The third execCommand argument for insert{un}orderedlist should be ignored
Summary: HTML5: The third execCommand argument for insert{un}orderedlist should be ign...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://tinymce.moxiecode.com/safari/l...
Keywords: HasReduction, InRadar
Depends on:
Blocks: 6627
  Show dependency treegraph
 
Reported: 2007-12-05 09:50 PST by Johan "Spocke" Sörlin
Modified: 2009-02-16 19:37 PST (History)
6 users (show)

See Also:


Attachments
patch (10.65 KB, patch)
2009-02-16 19:26 PST, Justin Garcia
mrowe: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johan "Spocke" Sörlin 2007-12-05 09:50:43 PST
When you create list elements in a contentEditable area the id of the new list will have the value false. The result is: <ol id="false">... when it should be a normal list like <ol>....

Steps to reproduce this bug:
1. Open the attached URL.
2. Press the test link.
3. Observe the incorrect result with a list element with a strange id attribute.
Comment 1 David Kilzer (:ddkilzer) 2007-12-06 06:58:38 PST
<rdar://problem/5632920>
Comment 2 Justin Garcia 2007-12-11 00:15:14 PST
The originator wrote: "When you create list elements in a contentEditable area the id of the new list will have the value false. The result is: <ol id="false">... when it should be a normal list like <ol>...."

The test case does:

document.execCommand('InsertUnorderedList', false, false);

The third argument for this command is "optional and specifies an id attribute for the unordered list.  [It] may be set to null or omitted" according to the MSDN documentation.  The boolean false as a string is "false" so it makes since to me that you would see a list with id="false".  If you want an id-less list you should omit the third argument or pass null for it.

I sent an email to Johan about this.  I'll leave this open until I hear back from him.
Comment 3 Johan "Spocke" Sörlin 2007-12-11 04:53:03 PST
The arguments can not be omitted in Firefox and using false as the last argument works fine in IE, FF and Opera so it's only Safari who has a problem with it but I guess we could simply start using null instead will go though the code to use that then.
Comment 4 Mark Rowe (bdash) 2007-12-11 12:29:58 PST
Justin, the MSDN documentation suggests that IE supports the third argument being used as the id, but my testing shows that it doesn't insert id="false" in this case.  Shouldn't we match that behaviour?
Comment 5 Justin Garcia 2007-12-11 14:02:47 PST
(In reply to comment #3)
> The arguments can not be omitted in Firefox and using false as the last
> argument works fine in IE, FF and Opera so it's only Safari who has a problem
> with it but I guess we could simply start using null instead will go though the
> code to use that then.

FireFox and Opera don't appear to support the ability to set an id with the third argument at all so I don't think they are a fair comparison.

IE6 doesn't either for that matter, unless I'm missing something.  Here's my testcase:

<body contenteditable="true">
<script>
document.body.focus();
document.execCommand("InsertUnorderedList", false, "hello");
alert(document.getElementsByTagName("ul")[0].id);
<script>
</body>


> 
Comment 6 Mark Rowe (bdash) 2007-12-11 14:04:50 PST
That's fair enough then :)
Comment 7 Ian 'Hixie' Hickson 2008-08-19 14:45:54 PDT
Shouldn't this bug be reopened then? If nobody else does anything with that third argument, regardless of what MSDN says, we shouldn't be adding an id.

HTML5 says to ignore the third argument for insertUnorderedList.
Comment 8 Justin Garcia 2008-08-19 15:36:55 PDT
(In reply to comment #7)
> Shouldn't this bug be reopened then? If nobody else does anything with that
> third argument, regardless of what MSDN says, we shouldn't be adding an id.
> 
> HTML5 says to ignore the third argument for insertUnorderedList.

Fair enough.  I noticed a typo at:

http://www.w3.org/TR/html5/editing.html

The second "insertOrderedList" should be "insertUnorderedList".
Comment 9 Justin Garcia 2009-02-16 17:02:42 PST
This bug blocks 6627 not the other way around.
Comment 10 Justin Garcia 2009-02-16 19:26:50 PST
Created attachment 27716 [details]
patch
Comment 11 Mark Rowe (bdash) 2009-02-16 19:28:46 PST
Comment on attachment 27716 [details]
patch

r=me
Comment 12 Justin Garcia 2009-02-16 19:37:09 PST
http://trac.webkit.org/changeset/41034