mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[quickjs] attributes ref|unref
This commit is contained in:
parent
d631d32518
commit
51b735f695
@ -60,10 +60,11 @@ js_attributes_set_items(JSContext *ctx, JSValue this_val, void *node)
|
|||||||
if (!attrs) {
|
if (!attrs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_ref(attrs);
|
||||||
|
|
||||||
err = dom_namednodemap_get_length(attrs, &num_attrs);
|
err = dom_namednodemap_get_length(attrs, &num_attrs);
|
||||||
if (err != DOM_NO_ERR) {
|
if (err != DOM_NO_ERR) {
|
||||||
//dom_namednodemap_unref(attrs);
|
dom_namednodemap_unref(attrs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ next:
|
|||||||
dom_node_unref(attr);
|
dom_node_unref(attr);
|
||||||
JS_FreeValue(ctx, obj);
|
JS_FreeValue(ctx, obj);
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue
|
static JSValue
|
||||||
@ -125,11 +127,14 @@ js_attributes_get_property_length(JSContext *ctx, JSValueConst this_val)
|
|||||||
if (!attrs) {
|
if (!attrs) {
|
||||||
return JS_NewInt32(ctx, 0);
|
return JS_NewInt32(ctx, 0);
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_ref(attrs);
|
||||||
err = dom_namednodemap_get_length(attrs, &num_attrs);
|
err = dom_namednodemap_get_length(attrs, &num_attrs);
|
||||||
|
|
||||||
if (err != DOM_NO_ERR) {
|
if (err != DOM_NO_ERR) {
|
||||||
//dom_namednodemap_unref(attrs);
|
dom_namednodemap_unref(attrs);
|
||||||
return JS_NewInt32(ctx, 0);
|
return JS_NewInt32(ctx, 0);
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
|
|
||||||
return JS_NewInt32(ctx, num_attrs);
|
return JS_NewInt32(ctx, num_attrs);
|
||||||
}
|
}
|
||||||
@ -151,14 +156,16 @@ js_attributes_item2(JSContext *ctx, JSValueConst this_val, int idx)
|
|||||||
if (!attrs) {
|
if (!attrs) {
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_ref(attrs);
|
||||||
err = dom_namednodemap_item(attrs, idx, (void *)&attr);
|
err = dom_namednodemap_item(attrs, idx, (void *)&attr);
|
||||||
|
|
||||||
if (err != DOM_NO_ERR) {
|
if (err != DOM_NO_ERR) {
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
ret = getAttr(ctx, attr);
|
ret = getAttr(ctx, attr);
|
||||||
dom_node_unref(attr);
|
dom_node_unref(attr);
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -200,19 +207,23 @@ js_attributes_namedItem2(JSContext *ctx, JSValueConst this_val, const char *str)
|
|||||||
if (!attrs) {
|
if (!attrs) {
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
dom_namednodemap_ref(attrs);
|
||||||
err = dom_string_create((const uint8_t*)str, strlen(str), &name);
|
err = dom_string_create((const uint8_t*)str, strlen(str), &name);
|
||||||
|
|
||||||
if (err != DOM_NO_ERR) {
|
if (err != DOM_NO_ERR) {
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
err = dom_namednodemap_get_named_item(attrs, name, &attr);
|
err = dom_namednodemap_get_named_item(attrs, name, &attr);
|
||||||
dom_string_unref(name);
|
dom_string_unref(name);
|
||||||
|
|
||||||
if (err != DOM_NO_ERR || !attr) {
|
if (err != DOM_NO_ERR || !attr) {
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
obj = getAttr(ctx, attr);
|
obj = getAttr(ctx, attr);
|
||||||
dom_node_unref(attr);
|
dom_node_unref(attr);
|
||||||
|
dom_namednodemap_unref(attrs);
|
||||||
|
|
||||||
RETURN_JS(obj);
|
RETURN_JS(obj);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user