document.all('foo') doesn't work (bug 626050, r=brendan).

This commit is contained in:
Andreas Gal 2011-01-16 23:30:38 -08:00
parent f00ce6228a
commit cc7aab8dd2

View File

@ -8928,21 +8928,16 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE; return JS_FALSE;
} }
// If we are called via document.all(id) instead of document.all.item(i) or
// another method, use the document.all callee object as self.
JSObject *self; JSObject *self;
if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) &&
if (::JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION) { ::JS_GetClass(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) {
// If the callee is a function, we're called through self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
// document.all.item() or something similar. In such a case, self } else {
// is passed as obj.
self = JS_THIS_OBJECT(cx, vp); self = JS_THIS_OBJECT(cx, vp);
if (!self) if (!self)
return JS_FALSE; return JS_FALSE;
} else {
// In other cases (i.e. document.all("foo")), self is passed as
// the callee
self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
} }
size_t length; size_t length;