[whatwg] Proposed updates for the command API's

Dav Glass dav.glass at yahoo.com
Wed Aug 13 07:46:26 PDT 2008


----- Original Message ----

From: Ian Hickson <ian at hixie.ch>
> 
> > * ModifiedNodes - I think this would be better as a separate API, maybe 
> >    "queryCommandAffected()" or something, that returns the collection. 
> >    Also, maybe it should return a range rather than a collection. What is 
> >    the use case? (How and why would you actually use this?)
> 
> The use case is outlined here:
> http://blog.davglass.com/files/yui/html5/#examples

> That's not a use case, it's an example of how it would work. By "use 
> case", I mean, _why_ would you ever use this? What problem is it solving?


> The main issue with a range, is overlapping elements, that's why I would 
> opt for a collection :)

> I don't understand, could you elaborate? Presumably which is more useful
> would depend primarily on the reason behind the feature, so maybe I need 
> to have a clearer picture of the use case before I can really figure out 
> whether a collection or a range is a better thing to return.


This would allow the developer the ability to easily add new functionality.

For example:

If I wanted to make a button that took the selection, and opened a more info window for extra data (just a simple example).

Using
this method, I could add a class to the selection. Then open a more
info window, which would force the selection to be removed (that I
could cache).

But I have access to all the items that it
modified, not just the range that it changed. Since I have access to
all of the nodes that changed, I can manipulate them after the
selection has been removed and focus has been lost.

Then when I am finished, I can use my cached data from the selection to create the selection again.

AFAIK,
a selection object gives you the data about some of the elements, but
not all of the containing elements (especially in the situation I have
as an example on the site).

There is also the use case of
someone selecting part of a node (like in between tags) and executing a
command, some commands will auto select the node others won't.

The modifiedNodes command would allow us to get that data.

Does all that make sense?

Dav



More information about the whatwg mailing list