mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-21 03:32:35 +03:00
Add Element::getAttribute() implementation.
This commit is contained in:
parent
0247bed13f
commit
f65ea4b096
@ -461,7 +461,6 @@ method Element::before();\n
|
||||
getter Element::children(user);\n
|
||||
getter Element::classList(user);\n
|
||||
method Element::closest();\n
|
||||
method Element::getAttribute();\n
|
||||
method Element::getAttributeNode();\n
|
||||
method Element::getAttributeNodeNS();\n
|
||||
method Element::getAttributeNS();\n
|
||||
|
@ -265,6 +265,31 @@ method Element::removeAttribute()
|
||||
return 0;
|
||||
%}
|
||||
|
||||
method Element::getAttribute()
|
||||
%{
|
||||
dom_string *attr_name = NULL;
|
||||
dom_string *attr_value = NULL;
|
||||
dom_exception exc;
|
||||
duk_size_t slen;
|
||||
|
||||
const char *s = duk_safe_to_lstring(ctx, 0, &slen);
|
||||
exc = dom_string_create((const uint8_t *)s, slen, &attr_name);
|
||||
duk_pop(ctx);
|
||||
|
||||
exc = dom_element_get_attribute(priv->parent.node,
|
||||
attr_name, &attr_value);
|
||||
dom_string_unref(attr_name);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
if (attr_value == NULL) {
|
||||
duk_push_lstring(ctx, "", 0);
|
||||
} else {
|
||||
duk_push_lstring(ctx, dom_string_data(attr_value),
|
||||
dom_string_length(attr_value));
|
||||
dom_string_unref(attr_value);
|
||||
}
|
||||
return 1;
|
||||
%}
|
||||
|
||||
method Element::setAttribute()
|
||||
%{
|
||||
dom_exception exc;
|
||||
|
Loading…
Reference in New Issue
Block a user