mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: correctly emplace optional values in the value converter (#21008)
* fix: correctly emplace optional values in the value converter * chore: replace optional with nullopt when the conversion failed
This commit is contained in:
@@ -41,10 +41,12 @@ struct Converter<base::Optional<T>> {
|
||||
v8::Local<v8::Value> val,
|
||||
base::Optional<T>* out) {
|
||||
if (val->IsNull() || val->IsUndefined()) {
|
||||
*out = base::nullopt;
|
||||
return true;
|
||||
}
|
||||
T converted;
|
||||
if (Converter<T>::FromV8(isolate, val, &converted)) {
|
||||
if (!Converter<T>::FromV8(isolate, val, &converted)) {
|
||||
*out = base::nullopt;
|
||||
return true;
|
||||
}
|
||||
out->emplace(converted);
|
||||
|
||||
Reference in New Issue
Block a user