Bug 16066 - Undocumented property for execCommand()
Summary: Undocumented property for execCommand()
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 523.x (Safari 3)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-20 03:13 PST by Anders Jenbo
Modified: 2007-11-21 14:54 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Jenbo 2007-11-20 03:13:54 PST
execCommand() has an undocumented optional parameater for 'insertorderedlist' and 'insertunorderedlist', the third parameater will be set as the lists id, this can result in id="undefined" if this is not taken in to account by the javascript.
This is also true for InsertHorizontalRule but this matches mozila behaviour.
Comment 1 Mark Rowe (bdash) 2007-11-20 06:51:51 PST
Can you please provide a small test case demonstrating this behaviour?
Comment 2 Anders Jenbo 2007-11-20 10:30:41 PST
I can provide you with a not so small test :/
Go to
http://rtef.info/demo.htm
select some text and fire the folowing command from the adressbar (locationbar).
javascript:rteCommand('rte1', 'insertorderedlist', 'test');
(this fires an execcommand(parm2, false, parm3) the frame with id parm1)

if a button was to fire rteCommand('rte1','insertorderedlist'), parm3 would equal "undefined" so that would end up as the id of every orderedlist and unorderedlist.
This might be considered a feature, but I can't find any place where it is documented that it is different from all othere browsers implementation.
Comment 3 Mark Rowe (bdash) 2007-11-20 10:56:45 PST
I cannot reproduce what you describe in a simple test case, which suggests the bug is in your JavaScript.

I wrote up a test case that does what you describe.  It is at <http://bdash.net.nz/files/arguments-combinations.html>.  One of the test cases fails, but those that cover the arguments you describe (the last 4 cases) all give the expected result.  This test case is a simple modification of an existing regression test we have that focusses on the behaviour of InsertHorizontalRule.

What version of WebKit and Safari are you testing?  Can you also please provide a test case that rules out your own JavaScript as the source of the problem?
Comment 4 Mark Rowe (bdash) 2007-11-20 10:59:47 PST
I cannot reproduce the behaviour by following the steps you describe either.  Closing as WORKSFORME.
Comment 5 Anders Jenbo 2007-11-20 12:05:12 PST
You must be miss understanding the issue here.
In your test it sayes
<ol id="foo"><li><br></li></ol>
I see no where that the id should become foo if 'foo' is the third parameater, if it's not documented it might cause confusion for any one trying to use it, this is the issue, the only referance to it i can find on webkit.org just points to MSDN where it sayes that it has no third parameater.

Also you have one that procude 
<ol id="0"><li><br></li></ol>, but id can't start with a nummeral so it should fail. Test 5 fails on my system (vista 64bit, Safari 3.0.4).
Comment 6 Mark Rowe (bdash) 2007-11-20 12:25:06 PST
The MSDN documentation states that the "value" parameter for execCommand is optional, but if specified it will specify the "id" attribute for the ordered list.  See <http://msdn2.microsoft.com/en-us/library/ms537396.aspx> for details on the InsertOrderedListCommand that states this, and <http://msdn2.microsoft.com/en-us/library/ms536419.aspx> for the documentation which clearly shows execCommand as taking three arguments.

As for whether we should reject 0 as the id in this instance I'm not so sure.  There are many other means of setting an element's id to a numeric value, and from what I can see the HTML 5 specification states only that the id must contain at least one character and must not contain space characters.

The test that fails does look like a legitimate problem so I will write up a bug report on that issue.
Comment 7 Mark Rowe (bdash) 2007-11-20 12:27:00 PST
I just took a second look at the test case and the failing one is actually giving the correct result.  The expected result is wrong as the empty id attribute is not valid as I noted in my previous comment.
Comment 8 Mark Rowe (bdash) 2007-11-20 12:45:02 PST
Filed bug 16074 on the empty id being inserted for InsertHorizontalRule in the original test case on which my example was based.
Comment 9 Anders Jenbo 2007-11-21 14:54:00 PST
I don't know how safe is is to base your software on a working draft, but in html 4.01, xhtml 1.0 and 1.1 all in strict and trans having 0 as the starting charector in a id is invalid.