fix: correctly emplace optional values in the value converter (#20985)

* fix: correctly emplace optional values in the value converter

* chore: replace optional with nullopt when the conversion failed
This commit is contained in:
Samuel Attard
2019-11-06 10:34:29 -08:00
committed by GitHub
parent 517a5915d7
commit a46b50fc7b

View File

@@ -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);