From bfe3e6abbc547a542122fa34545df697ca36d684 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 1 Nov 2015 09:28:15 +0000 Subject: Implement Element::hasAttribute(). --- javascript/duktape/Element.bnd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'javascript/duktape') diff --git a/javascript/duktape/Element.bnd b/javascript/duktape/Element.bnd index a5ac8b94f..d34e8c1eb 100644 --- a/javascript/duktape/Element.bnd +++ b/javascript/duktape/Element.bnd @@ -318,6 +318,28 @@ method Element::setAttribute() return 0; %} +method Element::hasAttribute() +%{ + dom_string *attr_name = NULL; + dom_exception exc; + duk_size_t slen; + bool res; + + 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_has_attribute(priv->parent.node, + attr_name, &res); + dom_string_unref(attr_name); + if (exc != DOM_NO_ERR) { + return 0; + } + + duk_push_boolean(ctx, res); + return 1; +%} + getter Element::className () %{ dom_string *classstr = NULL; -- cgit v1.2.3