-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fixes #9263 #9266
Fixes #9263 #9266
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,10 +86,10 @@ String URLSearchParams::get(const String& name) const | |
return String(); | ||
} | ||
|
||
bool URLSearchParams::has(const String& name) const | ||
bool URLSearchParams::has(const String& name, const String& value) const | ||
{ | ||
for (const auto& pair : m_pairs) { | ||
if (pair.key == name) | ||
if (pair.key == name && (value.isNull() || pair.value == value)) | ||
return true; | ||
} | ||
return false; | ||
|
@@ -101,6 +101,7 @@ void URLSearchParams::sort() | |
return WTF::codePointCompareLessThan(a.key, b.key); | ||
}); | ||
updateURL(); | ||
needsSorting = false; | ||
} | ||
|
||
void URLSearchParams::set(const String& name, const String& value) | ||
|
@@ -147,13 +148,11 @@ Vector<String> URLSearchParams::getAll(const String& name) const | |
return values; | ||
} | ||
|
||
void URLSearchParams::remove(const String& name) | ||
void URLSearchParams::remove(const String& name, const String& value) | ||
{ | ||
if (!m_pairs.removeAllMatching([&](const auto& pair) { | ||
return pair.key == name; | ||
}) | ||
&& m_pairs.size() > 0) | ||
return; | ||
m_pairs.removeAllMatching([&](const auto& pair) { | ||
return pair.key == name && (value.isNull() || pair.value == value); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relavent WebKit change: WebKit/WebKit@93a5678 |
||
updateURL(); | ||
needsSorting = true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
#include <wtf/Vector.h> | ||
#include <variant> | ||
#include "GCDefferalContext.h" | ||
#include "wtf/StdLibExtras.h" | ||
|
||
namespace WebCore { | ||
using namespace JSC; | ||
|
@@ -278,7 +279,15 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_deleteBody( | |
EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); | ||
auto name = convert<IDLUSVString>(*lexicalGlobalObject, argument0.value()); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.remove(WTFMove(name)); }))); | ||
|
||
String value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should do an argsCount() check here before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. argument() does the check internally There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah that's right, I was looking at the wrong implementation. I thought I remembered something about |
||
EnsureStillAliveScope argument1 = callFrame->argument(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (!argument1.value().isUndefined()) { | ||
value = convert<IDLUSVString>(*lexicalGlobalObject, argument1.value()); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
} | ||
|
||
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.remove(WTFMove(name), WTFMove(value)); }))); | ||
} | ||
|
||
JSC_DEFINE_HOST_FUNCTION(jsURLSearchParamsPrototypeFunction_delete, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) | ||
|
@@ -338,7 +347,15 @@ static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunction_hasBody(JSC | |
EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0); | ||
auto name = convert<IDLUSVString>(*lexicalGlobalObject, argument0.value()); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLBoolean>(*lexicalGlobalObject, throwScope, impl.has(WTFMove(name))))); | ||
|
||
String value; | ||
EnsureStillAliveScope argument1 = callFrame->argument(1); | ||
if (!argument1.value().isUndefined()) { | ||
value = convert<IDLUSVString>(*lexicalGlobalObject, argument1.value()); | ||
RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); | ||
} | ||
|
||
RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLBoolean>(*lexicalGlobalObject, throwScope, impl.has(WTFMove(name), WTFMove(value))))); | ||
} | ||
|
||
JSC_DEFINE_HOST_FUNCTION(jsURLSearchParamsPrototypeFunction_has, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) | ||
|
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.
why does
needsSorting
exist? it doesn't seem to be used