diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index bda06d508a5..714b5af26e5 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -62,6 +62,7 @@ #include "nsSVGSVGElement.h" #include "nsContentErrors.h" // For NS_PROPTABLE_PROP_OVERWRITTEN #include "nsContentUtils.h" +#include "nsStyleUtil.h" #include "nsEventDispatcher.h" #include "nsSMILTimeContainer.h" @@ -666,7 +667,17 @@ nsSVGSVGElement::CreateSVGTransformFromMatrix(nsIDOMSVGMatrix *matrix, NS_IMETHODIMP nsSVGSVGElement::GetElementById(const nsAString & elementId, nsIDOMElement **_retval) { - return NS_ERROR_NOT_IMPLEMENTED; + NS_ENSURE_ARG_POINTER(_retval); + *_retval = nsnull; + + nsresult rv = NS_OK; + nsAutoString selector(NS_LITERAL_STRING("#")); + nsStyleUtil::AppendEscapedCSSIdent(PromiseFlatString(elementId), selector); + nsIContent* element = nsGenericElement::doQuerySelector(this, selector, &rv); + if (NS_SUCCEEDED(rv) && element) { + return CallQueryInterface(element, _retval); + } + return rv; } //---------------------------------------------------------------------- diff --git a/content/svg/content/test/Makefile.in b/content/svg/content/test/Makefile.in index 09aec53550d..408c37eee6d 100644 --- a/content/svg/content/test/Makefile.in +++ b/content/svg/content/test/Makefile.in @@ -68,6 +68,7 @@ _TEST_FILES = \ dataTypes-helper.svg \ getCTM-helper.svg \ test_getCTM.html \ + test_getElementById.xhtml \ test_getSubStringLength.xhtml \ getSubStringLength-helper.svg \ test_isSupported.xhtml \ diff --git a/content/svg/content/test/test_getElementById.xhtml b/content/svg/content/test/test_getElementById.xhtml new file mode 100644 index 00000000000..863f520474e --- /dev/null +++ b/content/svg/content/test/test_getElementById.xhtml @@ -0,0 +1,67 @@ + +
++ ++ +