[whatwg] Desired Features for Web Applications

On Wed, 20 Apr 2005, Brad Neuberg wrote:
>
> As someone who works with web application development, here's some of 
> the things that would make my life easier.  Also, including certain 
> methods as part of the standard that I usually have to roll on my own 
> would make things more standardized:

Thanks for your input!


> * Have a document.getByPath() method that takes an XPath expression to 
> traverse and find any nodes in the document; this would be _extremely_ 
> powerful and would erase a huge amount of boilerplate code needed for 
> walking over the DOM using the standard DOM traversal methods.  This 
> would have to be a fast implementation though or else it couldn't be 
> depended on.

http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator

I also hope to have a getElementsBySelector() method somewhere (either in 
DOM3 Style or in Web Apps, whichever I happen to edit first).


> * Have methods for traversing the DOM based on the 'class' attribute.  If you
> have XPath type traversal this is somewhat less needed, but I find myself
> rolling methods in most projects to work with my document by class name.
> Example methods I have rolled for myself along these lines:
>         * xGetElementsByClassName(rootElement, className, tagName) - Gets all
> the elements rooted at rootElement with the given className, optionally
> restricted by tagName

http://whatwg.org/specs/web-apps/current-work/#selecting

(Can't restrict by tag name, but that seems a bit arbitrary -- why not by 
attribute, or whatever? At that point you're back to getElementsBySelector 
or some such.)


>         * xGetSingleElementByClassName(rootElement, className, tagName) - Same
> as the above, but just returns one element

Just use getElementsByClass(...)[0]. (Since the returned NodeList is live, 
it can be lazily evaulated and thus would be no less efficient.)


>         * xGetParentElementByClassName(rootElement, className, tagName) -
> Navigates upwards until we hit a parent element with the given class name and
> optional tag name.

Interesting idea. Noted.


> * Formalization of innerHTML as being a standard part of creating web
> applications

http://whatwg.org/specs/web-apps/current-work/#serialization


> * Right now most people directly access an elements className property,
> without realizing that they might be clobbering multi-classed elements (i.e.
> something with class="class1 class2").  I usually have to create wrapper
> methods to ensure that this doesn't happen, such as xAddClass(target,
> className), xRemoveClass(target, className), and xHasClass(target, className),
> but it would be much nicer if the className property itself had better support
> for multi-classed elements.  Some example possibilities of what this might
> look like:
>         * someElement.className.add("someNewClass")
>         * someElement.className.remove("SomeOldClass")
>         * someElement.className.hasClass("someClass")

Agreed. Noted.


> * The lack of min-width and max-width in IE's CSS makes things difficult.

Not much we can do about this from a spec point of view.

Thanks,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 20 April 2005 16:16:55 UTC