[whatwg] Re: getElementsByClassName

Ian Hickson wrote:
> On Tue, 6 Sep 2005, Lachlan Hunt wrote:
>>>    http://whatwg.org/specs/web-apps/current-work/#domtokenstring
>> 
>> Cool, I'll see what I can do about implementing that.  I think I may be 
>> able to extend the String() object quite easily for that, though I'll 
>> have to think about it a little more.
> 
> Let me know how that goes. That interface hasn't really been looked at 
> much yet.

I've thought about it some more, and it may be difficult to do with the 
way the add() and remove() are currently defined with no return value. 
I assume that means you're intending for these functions to modify the 
string itself.  However, in JavaScript a String() is immutable and all 
other methods that do modifications actually return a new string, not 
modify itself.

Then, there's also the question of assuming the token delimiter will 
always be a space.  Will there need to be a way to specify what the 
delimiter is, or is that intended to be dependant upon the language? 
For example, in HTML .className would return a DOMTokenString delimited 
by spaces, but in FooBarML it may be semi-colons, commas, or anything else.

>>In which case, would it be worth adding a note to the spec stating that 
>>implementations should not assume that all languages will use white 
>>space delimiters between class names?
> 
> Well, it's highly theoretical. It seems such a note might be more 
> confusing than helpful. What do you think?

I think fixing the grammar of this paragraph and adding one more 
sentence won't be too confusing

Current text:

| The space character (U+0020) is not special in the method's arguments.
| In HTML, XHTML, SVG and MathML it is impossible for an element to
| belong to a class whose name contains a space character, however, and
| so typically the method would return no nodes if one of its arguments
| contained a space.

Suggested text:

   The space character (U+0020) is not special in the method's arguments.
   In HTML, XHTML, SVG and MathML it is impossible for an element to
   belong to a class whose name contains a space character and thus, for
   these languages, the method would return no nodes if one of its
   arguments contained a space.  This does not, however, prevent other
   languages from allowing spaces in class names.

-- 
Lachlan Hunt
http://lachy.id.au/

Received on Monday, 5 September 2005 20:07:33 UTC