- From: Jon Barnett <jonbarnett@gmail.com>
- Date: Fri, 6 Jul 2007 16:12:44 -0500
On 7/6/07, Sander <html5 at zoid.nl> wrote: > > Hello, > > I'm not sure if this has been proposed yet (can hardly believe it hasn't). > But I couldn't find it in the specs so I just give it a go anyway. > > > I'd like to see a getElementsByAttr method. It would be quite similar as > the getElementsByClassName method but with an extra argument: > > getElementsByAttr(attribute_name, value) > > For attributes that can have more than one value (either seperated by > spaces or commas) the value argument may be a space(/comma) seperated string > or an array, similar to getElementsByClassName. If value is not defined of > perhaps a wildcard ("*") the method should return all nodes that have the > particular attribute, no matter what its value is. > > The method overlaps with both getElementsByClassName, getElementsByTagName > and getElementById, as these filter on attribute value as well, but it still > adds extra opportunities. > > cheers, > Sander > I personally prefer the DOM 3 XPath evaluate() method, which is implemented at least by Mozilla on the document object. Not sure about other UAs. However, AFAICR, XPath doesn't meet all use cases, such as space-separated token lists, like @class. http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator http://developer.mozilla.org/en/docs/DOM:document.evaluate Since these APIs are spread out over various specifications, it's hard to guess what common browsers are going to support in the future. It would be nice if HTML5 informatively notes these other APIs that may be supported (XMLHttpRequest also fits in this category) -- Jon Barnett -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20070706/8b349349/attachment.htm>
Received on Friday, 6 July 2007 14:12:44 UTC