summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/UnimplementedJavascript.txt1
-rw-r--r--javascript/duktape/Element.bnd25
2 files changed, 25 insertions, 1 deletions
diff --git a/Docs/UnimplementedJavascript.txt b/Docs/UnimplementedJavascript.txt
index 82b0b1628..ccc924726 100644
--- a/Docs/UnimplementedJavascript.txt
+++ b/Docs/UnimplementedJavascript.txt
@@ -484,7 +484,6 @@ method Element::removeAttribute();\n
method Element::removeAttributeNode();\n
method Element::removeAttributeNS();\n
method Element::replaceWith();\n
-method Element::setAttribute();\n
method Element::setAttributeNode();\n
method Element::setAttributeNodeNS();\n
method Element::setAttributeNS();\n
diff --git a/javascript/duktape/Element.bnd b/javascript/duktape/Element.bnd
index 9cd8a4c9f..58604cdb1 100644
--- a/javascript/duktape/Element.bnd
+++ b/javascript/duktape/Element.bnd
@@ -248,6 +248,31 @@ setter Element::id ()
return 0;
%}
+method Element::setAttribute()
+%{
+ dom_exception exc;
+ dom_string *attr_str, *value_str;
+ duk_size_t attr_len, value_len;
+ const char *attr = duk_safe_to_lstring(ctx, 0, &attr_len);
+ const char *value = duk_safe_to_lstring(ctx, 1, &value_len);
+
+ exc = dom_string_create((const uint8_t *)attr, attr_len, &attr_str);
+ if (exc != DOM_NO_ERR) return 0;
+
+ exc = dom_string_create((const uint8_t *)value, value_len, &value_str);
+ if (exc != DOM_NO_ERR) {
+ dom_string_unref(attr_str);
+ return 0;
+ }
+
+ exc = dom_element_set_attribute(priv->parent.node,
+ attr_str, value_str);
+ dom_string_unref(attr_str);
+ dom_string_unref(value_str);
+ if (exc != DOM_NO_ERR) return 0;
+ return 0;
+%}
+
getter Element::className ()
%{
dom_string *classstr = NULL;