mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Add support for Element::setAttribute method.
This fixes test/js/dom-html-div-element.html test case.
This commit is contained in:
parent
6098646e72
commit
d795f1ca2d
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user