whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.17k stars 2.69k forks source link

Proposal: add searchParams on Location #3884

Open regseb opened 6 years ago

regseb commented 6 years ago

Add the attribute searchParams on Location interface which returns a URLSearchParams class. Like the URL class.

annevk commented 6 years ago

We had this and had to remove it due to the security story being rather involved. You can use new URLSearchParams(location.search) and then set it after manipulation.

domenic commented 6 years ago

@annevk, could you say more, for posterity? I don't recall the security aspects, just that it was hard to hook it the mutable object up to the navigation stuff.

annevk commented 6 years ago

@domenic https://blog.whatwg.org/windowproxy-window-and-location has some detail on why Location is special. Any kind of tearoff object it holds would need similar protections or be kept safe through equivalent manners (perhaps by replacing it a lot, but that might make it less useful for the use case and inconsistent with URL).

domenic commented 6 years ago

Yeah, I think we'd need to basically create a parallel LocationSearchParams object. Which is a lot of work for medium gain. So that's basically the answer...