Open Bug 345845 Opened 15 years ago Updated 9 months ago

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


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





(Reporter: lists, Unassigned)



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

You can use 


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

The command: 'insertlink'

command: insertlink
value: a URI
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.

If you do a 

document.queryCommand('insertlink', "");

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()
3. call reproduce() within your document.

Actual Results:  

Expected Results:  

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.

If you do a 

document.queryCommand('insertlink', "");

is to be changed to 

document.queryCommandEnabled('insertlink', "");
Component: General → Editor
QA Contact: general
QA Contact: editor
Confirmed. And that’s not solved by bug 676401.
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.