-
Notifications
You must be signed in to change notification settings - Fork 35
Allow URLSearchParams to be used as a base class to extend from within application javascript #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7884fde
to
006f585
Compare
1518d0f
to
4f0fd2b
Compare
006f585
to
d96d475
Compare
31736a1
to
a186188
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, I just had one question about testing self
in searchParams_get
.
bool append(JSContext *cx, unsigned argc, Value *vp); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering where the implementations for these prototypes were, and it's down on line 6935 on main -- the URLSearchParams
namespace is reopened three times throughout js-compute-builtins.cpp
. We should do some reorganization soon so that we don't need prototypes so far from the definitions :)
if (!self) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is necessary here -- line 6744 is using JS::GetReservedSlot
on self
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good spot, this was meant to be url_search_params_instance
95473a3
to
9a14faa
Compare
This pull-request is part of the solution for #113
This pull-request changes our URLSearchParams implementation to use JS_NewObjectForConstructor when the construction has come from the applications' JavaScript, which assigns the correct prototype to the instance being constructed (taking into account extends in JavaScript)
I've also added a test which confirms that the correct prototype has been assigned when extending from URLSearchParams, the test is written in a way that makes it simpler to add the same test for any other builtin classes