From 15dfe80590926b510b883c90c662a4aa72994c14 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 11 Jul 2007 01:14:55 +0000 Subject: [PATCH] Notify before firing mutation events. Bug 387460, r+sr=sicking --- content/base/src/nsGenericElement.cpp | 8 ++++---- content/xul/content/src/nsXULElement.cpp | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 8da75c88cb1..ba9069a3113 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3626,6 +3626,10 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, } } + if (aNotify) { + nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, modType); + } + if (aFireMutation) { nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED); @@ -3651,10 +3655,6 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID, nsEventDispatcher::Dispatch(this, nsnull, &mutation); } - if (aNotify) { - nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, modType); - } - if (aNamespaceID == kNameSpaceID_XMLEvents && aName == nsGkAtoms::event && mNodeInfo->GetDocument()) { mNodeInfo->GetDocument()->AddXMLEventsContent(this); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 4d12f3946c9..a664d4a05f5 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1297,6 +1297,18 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) } } + if (doc) { + nsXBLBinding *binding = doc->BindingManager()->GetBinding(this); + if (binding) + binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); + + } + + if (aNotify) { + nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName, + nsIDOMMutationEvent::REMOVAL); + } + if (hasMutationListeners) { nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED); @@ -1312,18 +1324,6 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify) nsnull, &mutation); } - if (doc) { - nsXBLBinding *binding = doc->BindingManager()->GetBinding(this); - if (binding) - binding->AttributeChanged(aName, aNameSpaceID, PR_TRUE, aNotify); - - } - - if (aNotify) { - nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName, - nsIDOMMutationEvent::REMOVAL); - } - return NS_OK; }