Skip to content

v0.2.55..v0.2.56 changeset ElementJs.cpp

Garret Voltz edited this page Aug 14, 2020 · 3 revisions
diff --git a/hoot-js/src/main/cpp/hoot/js/elements/ElementJs.cpp b/hoot-js/src/main/cpp/hoot/js/elements/ElementJs.cpp
index d2bb02a..8714d8b 100644
--- a/hoot-js/src/main/cpp/hoot/js/elements/ElementJs.cpp
+++ b/hoot-js/src/main/cpp/hoot/js/elements/ElementJs.cpp
@@ -49,14 +49,6 @@ using namespace v8;
 namespace hoot
 {
 
-ElementJs::ElementJs()
-{
-}
-
-ElementJs::~ElementJs()
-{
-}
-
 void ElementJs::_addBaseFunctions(Local<FunctionTemplate> tpl)
 {
   Isolate* current = v8::Isolate::GetCurrent();
@@ -85,6 +77,8 @@ void ElementJs::_addBaseFunctions(Local<FunctionTemplate> tpl)
       FunctionTemplate::New(current, toString));
   tpl->PrototypeTemplate()->Set(String::NewFromUtf8(current, "toString"),
       FunctionTemplate::New(current, toString));
+  tpl->PrototypeTemplate()->Set(String::NewFromUtf8(current, "removeTag"),
+      FunctionTemplate::New(current, removeTag));
 }
 
 void ElementJs::getCircularError(const FunctionCallbackInfo<Value>& args)
@@ -276,6 +270,27 @@ void ElementJs::setTag(const FunctionCallbackInfo<Value>& args)
   }
 }
 
+void ElementJs::removeTag(const FunctionCallbackInfo<Value>& args)
+{
+  Isolate* current = args.GetIsolate();
+  HandleScope scope(current);
+
+  ElementPtr e = ObjectWrap::Unwrap<ElementJs>(args.This())->getElement();
+  if (!e)
+  {
+    args.GetReturnValue().Set(
+      current->ThrowException(
+        HootExceptionJs::create(
+          IllegalArgumentException("Unable to remove tag on a const Element."))));
+  }
+  else
+  {
+    const QString tagKey = toCpp<QString>(args[0]);
+    e->removeTag(tagKey);
+    args.GetReturnValue().SetUndefined();
+  }
+}
+
 void ElementJs::toString(const FunctionCallbackInfo<Value>& args)
 {
   Isolate* current = args.GetIsolate();
Clone this wiki locally