Skip to content

Conversation

@adrian-niculescu
Copy link
Contributor

Fixes URLSearchParams.forEach() to match the spec.

Equivalent fix for Android: NativeScript/android#1895

Problem

Calling url.searchParams.forEach() in NativeScript iOS crashed with EXC_BAD_ACCESS (code=1, address=0x0) because an empty v8::Local<v8::Value>() was passed as the thisArg to callback->Call().

Fixes

  1. Crash: Use v8::Undefined(isolate) instead of empty v8::Local<v8::Value>()
  2. Argument order: Changed from (key, value) to (value, key, searchParams)
  3. Duplicate keys: Use get_entries() iterator instead of get_keys() + get()
  4. thisArg: Support the optional second parameter

Changes

  • NativeScript/runtime/URLSearchParamsImpl.cpp
  • TestRunner/app/tests/URLSearchParams.js

Known Limitations (pre-existing)

The entries() and values() methods still use get_keys() + get() which doesn't handle duplicate keys correctly.

- Use v8::Undefined(isolate) instead of empty v8::Local<v8::Value>()
- Changed argument order from (key, value) to (value, key, searchParams)
- Use get_entries() iterator instead of get_keys() + get() for duplicate keys
- Support the optional thisArg second parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant