Open Bug 345845 Opened 18 years ago Updated 3 years ago

[midas] document.queryCommandEnabled return wrong value for 'insertlink' if no selection

Categories

(Core :: DOM: Editor, defect, P5)

x86
All
defect

Tracking

()

People

(Reporter: lists, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7) Gecko/20040616
Build Identifier: 

You can use 

document.queryCommandEnabled()

to find out if a command may be executed using document.execCommand().

The command: 'insertlink'

<manual>
command: insertlink
value: a URI
description:
This command will not do anything if no selection is made. If there is a selection, a link will be inserted around the selection with the url parameter as the href of the link.
</manual>

If you do a 

document.queryCommand('insertlink', "http://www.w3.org");

the function SHOULD return 'false' IF NO SELECTION is made. There is no other way - e.g. a command - to find out, if a user selected text for the insert link command.


Reproducible: Always

Steps to Reproduce:
1. Create a new html document.
2. Insert the following lines within <script>-tags of your document.
function reproduce()
{
   document.designMode="on";
   alert(document.queryCommandEnabled('createlink'));
}
3. call reproduce() within your document.

Actual Results:  
'true'

Expected Results:  
'false'

OT: The implementation of a command 'unselect' would be helpful, because that would allow to unselect selected text after the user e.g. changed the format. That would decrease the risk of deleting the selected text with the next keystroke.
Errata:

If you do a 

document.queryCommand('insertlink', "http://www.w3.org");


is to be changed to 

document.queryCommandEnabled('insertlink', "http://www.w3.org");
Component: General → Editor
QA Contact: general
QA Contact: editor
Confirmed. And that’s not solved by bug 676401.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Note to self: we could add an `isSelectionCollapsed' read-only boolean attribute to <nsIEditor> and use it in many of the `IsCommandEnabled' methods that have been patched in bug 676401. The current browserscope/richtext2 test suite should not be affected.
Depends on: 676401

Bulk-downgrade of unassigned, 4 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.