From 57aeaf92d697c1f7d15f3b64e93bc8028c05ed2b Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sun, 16 Jan 2011 23:30:38 -0800 Subject: [PATCH] document.all('foo') doesn't work (bug 626050, r=brendan). --- dom/base/nsDOMClassInfo.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 9d759cc2cb29..c2ec42681272 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -8928,21 +8928,16 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, uintN argc, jsval *vp) 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; - - if (::JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION) { - // If the callee is a function, we're called through - // document.all.item() or something similar. In such a case, self - // is passed as obj. - + if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) && + ::JS_GetClass(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) { + self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)); + } else { self = JS_THIS_OBJECT(cx, vp); if (!self) 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;