summaryrefslogtreecommitdiff
path: root/platform/node
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-16 13:25:06 -0700
committerGitHub <noreply@github.com>2016-06-16 13:25:06 -0700
commit19158d9f01909bf566616524f23e0acb635562f7 (patch)
treea3adf8c8713dbe6d20fe9fae055836e677b4ca47 /platform/node
parent3f024ebaf02e82e9282e303a46127f366a84904d (diff)
downloadqtlocation-mapboxgl-19158d9f01909bf566616524f23e0acb635562f7.tar.gz
[core, node] Implement setPaintProperty for color properties (#5380)
Diffstat (limited to 'platform/node')
-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 };
}
};