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:
trop[bot]
2019-11-06 13:32:38 -08:00
committed by Shelley Vohr
parent d63150502b
commit 2e8349c520

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