diff --git a/src/ecmascript/mujs/attributes.cpp b/src/ecmascript/mujs/attributes.cpp
index 06a584fc1..5be601de1 100644
--- a/src/ecmascript/mujs/attributes.cpp
+++ b/src/ecmascript/mujs/attributes.cpp
@@ -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);
 	}
 }
 
diff --git a/src/ecmascript/mujs/collection.cpp b/src/ecmascript/mujs/collection.cpp
index 353806906..94f83c5df 100644
--- a/src/ecmascript/mujs/collection.cpp
+++ b/src/ecmascript/mujs/collection.cpp
@@ -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++;
 	}
 }
diff --git a/src/ecmascript/mujs/form.cpp b/src/ecmascript/mujs/form.cpp
index 26f5a5957..7d245d5b7 100644
--- a/src/ecmascript/mujs/form.cpp
+++ b/src/ecmascript/mujs/form.cpp
@@ -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++;
 	}
 }
diff --git a/src/ecmascript/mujs/forms.cpp b/src/ecmascript/mujs/forms.cpp
index 7cc043000..534fa1a6d 100644
--- a/src/ecmascript/mujs/forms.cpp
+++ b/src/ecmascript/mujs/forms.cpp
@@ -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++;
 	}
 }