diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 53c298ab894..921257940f2 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -505,7 +505,7 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute, this, PR_TRUE, attrAtom, - kNameSpaceID_None); + kNameSpaceID_Unknown); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(*aReturn = list); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index e758235caec..e141125da8f 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1153,7 +1153,7 @@ nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute, nsnull, PR_TRUE, attrAtom, - kNameSpaceID_None); + kNameSpaceID_Unknown); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(*aReturn = list); @@ -2014,11 +2014,34 @@ nsXULDocument::MatchAttribute(nsIContent* aContent, const nsAString& aAttrValue) { NS_PRECONDITION(aContent, "Must have content node to work with!"); - - return aAttrValue.EqualsLiteral("*") ? - aContent->HasAttr(aNamespaceID, aAttrName) : - aContent->AttrValueIs(aNamespaceID, aAttrName, aAttrValue, - eCaseMatters); + + if (aNamespaceID != kNameSpaceID_Unknown) { + return aAttrValue.EqualsLiteral("*") ? + aContent->HasAttr(aNamespaceID, aAttrName) : + aContent->AttrValueIs(aNamespaceID, aAttrName, aAttrValue, + eCaseMatters); + } + + // Qualified name match. This takes more work. + + PRUint32 count = aContent->GetAttrCount(); + for (PRUint32 i = 0; i < count; ++i) { + const nsAttrName* name = aContent->GetAttrNameAt(i); + PRBool nameMatch; + if (name->IsAtom()) { + nameMatch = name->Atom() == aAttrName; + } else { + nameMatch = name->NodeInfo()->QualifiedNameEquals(aAttrName); + } + + if (nameMatch) { + return aAttrValue.EqualsLiteral("*") || + aContent->AttrValueIs(name->NamespaceID(), name->LocalName(), + aAttrValue, eCaseMatters); + } + } + + return PR_FALSE; } nsresult