From 2f3548d18a29d9237605aa9fa225a0029e5d0782 Mon Sep 17 00:00:00 2001 From: "rginda%netscape.com" Date: Thu, 14 Feb 2002 00:40:55 +0000 Subject: [PATCH] bug 123118, getElementsByTagName("script") doesn't work for XUL windows sr=hyatt, r=jst insert a nsXULPrototypeElement before the nsXULPrototypeScript in the proto-docu ment, so that we can get to it in the final content model. --- content/xul/document/src/nsXULContentSink.cpp | 21 ++++++++++--------- content/xul/document/src/nsXULDocument.cpp | 8 ++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index a6e7534e739d..f7a8083bc80c 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -1386,12 +1386,6 @@ XULContentSinkImpl::OpenTag(const PRUnichar** aAttributes, { nsresult rv; - if (aNodeInfo->Equals(kScriptAtom, kNameSpaceID_HTML) || - aNodeInfo->Equals(kScriptAtom, kNameSpaceID_XUL)) { - // Oops, it's a script! - return OpenScript(aAttributes, aLineNumber); - } - // Create the element nsXULPrototypeElement* element; rv = CreateElement(aNodeInfo, &element); @@ -1417,17 +1411,24 @@ XULContentSinkImpl::OpenTag(const PRUnichar** aAttributes, return rv; } + // Add the attributes + rv = AddAttributes(aAttributes, aAttrLen, element); + if (NS_FAILED(rv)) return rv; + children->AppendElement(element); + if (aNodeInfo->Equals(kScriptAtom, kNameSpaceID_HTML) || + aNodeInfo->Equals(kScriptAtom, kNameSpaceID_XUL)) { + // Do scripty things now. OpenScript will push the + // nsPrototypeScriptElement onto the stack, so we're done after this. + return OpenScript(aAttributes, aLineNumber); + } + // Push the element onto the context stack, so that child // containers will hook up to us as their parent. rv = mContextStack.Push(element, mState); if (NS_FAILED(rv)) return rv; - // Add the attributes - rv = AddAttributes(aAttributes, aAttrLen, element); - if (NS_FAILED(rv)) return rv; - mState = eInDocumentElement; return NS_OK; } diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 1769f6fec021..4baeecc9d95a 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -90,6 +90,7 @@ #include "nsIDocumentObserver.h" #include "nsIFormControl.h" #include "nsIHTMLContent.h" +#include "nsHTMLAtoms.h" #include "nsIElementFactory.h" #include "nsIEventStateManager.h" #include "nsIInputStream.h" @@ -6303,6 +6304,12 @@ nsXULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype, nsIConten rv = nsXULElement::Create(aPrototype, this, PR_FALSE, getter_AddRefs(element)); if (NS_FAILED(rv)) return rv; + if (aPrototype->mNodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_XUL) || + aPrototype->mNodeInfo->Equals(nsHTMLAtoms::script, kNameSpaceID_HTML)) { + //