diff --git a/src/ecmascript/spidermonkey/element.c b/src/ecmascript/spidermonkey/element.c index 54a14e5bd..7b045ab4e 100644 --- a/src/ecmascript/spidermonkey/element.c +++ b/src/ecmascript/spidermonkey/element.c @@ -2095,15 +2095,17 @@ htmlCollection_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId return htmlCollection_item2(ctx, hobj, index, hvp); } -#if 0 if (JSID_IS_STRING(id)) { JS::RootedValue r_idval(ctx, idval); JS_IdToValue(ctx, id, &r_idval); char *string = JS_EncodeString(ctx, r_idval.toString()); - return htmlCollection_namedItem2(ctx, hobj, string, hvp); + std::string test = string; + + if (test != "item" && test != "namedItem") { + return htmlCollection_namedItem2(ctx, hobj, string, hvp); + } } -#endif return JS_PropertyStub(ctx, hobj, hid, hvp); } diff --git a/test/ecmascript/namedItem.html b/test/ecmascript/namedItem.html new file mode 100644 index 000000000..68317718e --- /dev/null +++ b/test/ecmascript/namedItem.html @@ -0,0 +1,23 @@ + + + + +

HTMLCollection namedItem() Method

+ +

The namedItem() method returns the element with the specified ID or name.

+ +

This example uses a shorthand method for the namedItem() method

+ +

Click the button to return the content of the P element with ID "myElement":

+ + + + + + +