- From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- Date: Wed, 07 Sep 2005 10:51:07 +1000
Erik Arvidsson wrote: > You are really misusing new here. You never return an object of type > DOMTokenString. Since all your methods are linear and return a new > string you might as well implement them on the String prototype object. Well, yes, and in fact, when implementing the final version so that Element.className.add(), etc. can be used, I'll probably just have to extend the string prototype anyway. It would cetainly be more efficient than creating a new string and adding the methods each time, but I wasn't sure if all strings should implement the interface. > Lachlan Hunt wrote: >> s = s.add("baz quux") // returns "foo bar foo baz quux" > > Shouldn't this raise an exception? It could raise a DOMException SYNTAX_ERR [1], but what's wrong with just accepting it? [1] http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187 -- Lachlan Hunt http://lachy.id.au/
Received on Tuesday, 6 September 2005 17:51:07 UTC