> 2) I've added two flavors of appendParameter. The first flavor takes > a DOMString for a value and appends a single parameter. The second > flavor takes an array of DOMStrings and appends one parameter for each > array. This seemed better than using a variable number of arguments.
-1 I really want the setParameter method - appendParameter now requires the developer to know what someone might have done in the past with the URL object. this can be a cause of trouble as the web application might do something that the developer doesn't expect , so I specifically want the developer to opt-in to using appendParameters. I know clearParameter is a method - but this is not the clear separation between the '2 APIs' that we talked about earlier in the thread. I remember reading about how some web application frameworks combine ?q=a&q=b to q=ab at the server side, whereas some will only consider q=a and some will only consider q=b. This is such a mess - the developer should have to specifically opt-in to this. cheers devdatta > 3) I've added a clearParameter method. > > Defining these methods required some low-level URL manipulation that's > not actually defined anywhere (AFAIK), so I've added a reference to my > work-in-progress draft about parsing and canonicalizing URLs. > > Adam > > > On Tue, Sep 21, 2010 at 3:40 PM, Ojan Vafai <[email protected]> wrote: >> appendParameter/clearParameter seems fine to me. >> On Wed, Sep 22, 2010 at 2:53 AM, Tab Atkins Jr. <[email protected]> >> wrote: >>> >>> On Mon, Sep 20, 2010 at 11:56 PM, Adam Barth <[email protected]> wrote: >>> > Ok. I'm sold on having an API for constructing query parameters. >>> > Thoughts on what it should look like? Here's what jQuery does: >>> > >>> > http://api.jquery.com/jQuery.get/ >>> > >>> > Essentially, you supply a JSON object containing the parameters. They >>> > also have some magical syntax for specifying multiple instances of the >>> > same parameter name. I like the easy of supplying a JSON object, but >>> > I'm not in love with the magical syntax. An alternative is to use two >>> > APIs, like we current have for reading the parameter values. >>> >>> jQuery's syntax isn't magical - the example they give using the query >>> param name of 'choices[]' is doing that because PHP requires a [] at >>> the end of the query param name to signal it that you want multiple >>> values. It's opaque, though - you could just as easily have left off >>> the '[]' and it would have worked the same. >>> >>> The switch is just whether you pass an array or a string (maybe they >>> support numbers too?). >>> >>> I recommend the method be called append*, so you can use it both for >>> first sets and later additions (this is particularly useful if you're >>> just looping through some data). This obviously would then need a >>> clear functionality as well. >>> >>> ~TJ >>> >> >> >
