summaryrefslogtreecommitdiff
path: root/platform/node/src/node_style.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/node/src/node_style.hpp')
-rw-r--r--platform/node/src/node_style.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/platform/node/src/node_style.hpp b/platform/node/src/node_style.hpp
index a987c0d262..0b6b05e13b 100644
--- a/platform/node/src/node_style.hpp
+++ b/platform/node/src/node_style.hpp
@@ -65,8 +65,18 @@ struct ValueConverter<T, std::enable_if_t<std::is_enum<T>::value>> {
template <>
struct ValueConverter<mbgl::Color> {
mbgl::optional<mbgl::style::PropertyValue<mbgl::Color>> operator()(const v8::Local<v8::Value>& value) const {
- (void)value;
- return {};
+ if (!value->IsString()) {
+ Nan::ThrowTypeError("string required");
+ return {};
+ }
+
+ mbgl::optional<mbgl::Color> result = mbgl::Color::parse(*Nan::Utf8String(value));
+ if (!result) {
+ Nan::ThrowTypeError("invalid color");
+ return {};
+ }
+
+ return { *result };
}
};