[whatwg] HTML 5 - comments on 5.6 Command APIs

Dnia 11-03-2008, Wt o godzinie 19:31 +0000, Tom Gilder pisze:
> On Tue, Mar 11, 2008 at 6:15 PM, Krzysztof ?elechowski
> <giecrilj at stegny.2a.pl> wrote:
> > > I see no point in returning true when there are no links to remove. IE
> > > and Opera currently only return true when the selection contains a
> > > link. WebKit follows the current HTML 5 wording.
> >
> > "Unlink" means "Remove all links".
> > There is no point removing all links when there are none
> > but there is no harm either.
> > Me thinks "Unlink" should be enabled in this case.
> 
> queryCommandEnabled is primarily, I would argue, used to update UIs
> (especially enabling/disabling toolbar buttons) to show whether the
> command will currently have any affect on the document.
> 
> There is indeed never any harm in calling execCommand('Unlink'), you
> can call it as much as you like at any point without raising an
> exception, but execCommandEnabled is surely about whether the call
> will actually achieve anything.
> 
> Following your logic, queryCommandEnabled('Undo') could always return
> true, because there's no harm in trying to undo even when there's
> nothing to undo.

I have mixed feelings about this.  
I admit there is no practical harm; however,
"Undo" means "undo the latest action" 
and it is an error to say "take your hat off" 
to somebody who does not wear one.
I resembles popping from an empty stack; 
this action usually throws.
On the other hand, 
it is not an error to say "Give me all your money" 
to somebody who does not have any.

> 
> execCommandEnabled is pointless unless it actually returns a useful
> value as to if it's going to do something.

I would read it more literally: it is enabled when it can be executed.  
Your version should be called execCommandEffective.

Chris

Received on Wednesday, 12 March 2008 10:49:22 UTC