1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[mujs] More js_try

This commit is contained in:
Witold Filipczyk 2022-08-20 14:26:00 +02:00
parent f9d5ec099b
commit abbfdc3db1
4 changed files with 33 additions and 10 deletions

View File

@ -86,11 +86,13 @@ mjs_attributes_set_items(js_State *J, void *node)
js_setindex(J, -2, i);
xmlpp::ustring name = attr->get_name();
if (name != "" && name != "item" && name != "namedItem") {
mjs_push_attr(J, attr);
js_setproperty(J, -2, name.c_str());
if (js_try(J)) {
js_pop(J, 1);
continue;
}
mjs_push_attr(J, attr);
js_setproperty(J, -2, name.c_str());
js_endtry(J);
}
}

View File

@ -190,10 +190,14 @@ mjs_htmlCollection_set_items(js_State *J, void *node)
if (name == "") {
name = element->get_attribute_value("name");
}
if (name != "" && name != "item" && name != "namedItem") {
mjs_push_element(J, element);
js_setproperty(J, -2, name.c_str());
if (js_try(J)) {
js_pop(J, 1);
goto next;
}
mjs_push_element(J, element);
js_setproperty(J, -2, name.c_str());
js_endtry(J);
next:
counter++;
}
}

View File

@ -128,13 +128,24 @@ mjs_form_set_items(js_State *J, void *node)
mjs_push_form_control_object(J, fc->type, fs);
js_setindex(J, -2, counter);
if (fc->id && strcmp(fc->id, "item") && strcmp(fc->id, "namedItem")) {
if (fc->id) {
if (js_try(J)) {
js_pop(J, 1);
goto next;
}
mjs_push_form_control_object(J, fc->type, fs);
js_setproperty(J, -2, fc->id);
} else if (fc->name && strcmp(fc->name, "item") && strcmp(fc->name, "namedItem")) {
js_endtry(J);
} else if (fc->name) {
if (js_try(J)) {
js_pop(J, 1);
goto next;
}
mjs_push_form_control_object(J, fc->type, fs);
js_setproperty(J, -2, fc->name);
js_endtry(J);
}
next:
counter++;
}
}

View File

@ -101,10 +101,16 @@ mjs_forms_set_items(js_State *J)
mjs_push_form_object(J, form);
js_setindex(J, -2, counter);
if (form->name && strcmp(form->name, "item") && strcmp(form->name, "namedItem")) {
if (form->name) {
if (js_try(J)) {
js_pop(J, 1);
goto next;
}
mjs_push_form_object(J, form);
js_setproperty(J, -2, form->name);
js_endtry(J);
}
next:
counter++;
}
}