1ada25d73108a83a01d13fd60946d54174f3e113
diff --git a/doc/rsvg-sections.txt b/doc/rsvg-sections.txt
index 7552a83..6cdd07d 100644
--- a/doc/rsvg-sections.txt
+++ b/doc/rsvg-sections.txt
@@ -26,6 +26,7 @@ rsvg_handle_get_desc
 rsvg_handle_get_dimensions
 rsvg_handle_get_dimensions_sub
 rsvg_handle_get_position_sub
+rsvg_handle_has_sub
 </SECTION>
 
 <SECTION>
diff --git a/librsvg.def b/librsvg.def
index dc9cbb9..2ba9834 100644
--- a/librsvg.def
+++ b/librsvg.def
@@ -20,6 +20,7 @@ rsvg_handle_get_position_sub
 rsvg_handle_get_title
 rsvg_handle_get_desc
 rsvg_handle_get_metadata
+rsvg_handle_has_sub
 rsvg_handle_new_from_data
 rsvg_handle_new_from_file
 rsvg_handle_set_size_callback
diff --git a/rsvg-base.c b/rsvg-base.c
index 06eccc4..2283b32 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1473,6 +1473,30 @@ bail:
 	return ret;
 }
 
+/** 
+ * rsvg_handle_has_sub:
+ * @handle: a #RsvgHandle
+ * @id: an element's id within the SVG
+ *
+ * Checks whether the element @id exists in the SVG document.
+ *
+ * Returns: %TRUE if @id exists in the SVG document
+ *
+ * Since: 2.22
+ */
+gboolean
+rsvg_handle_has_sub (RsvgHandle * handle,
+                     const char *id)
+{
+    RsvgNode *sself;
+
+    g_return_val_if_fail (handle, FALSE);
+
+    if (G_UNLIKELY (!id || !id[0]))
+      return FALSE;
+
+    return rsvg_defs_lookup (handle->priv->defs, id) != NULL;
+}
 
 /** 
  * rsvg_set_default_dpi
diff --git a/rsvg.h b/rsvg.h
index 1acd1ae..b1fa906 100644
--- a/rsvg.h
+++ b/rsvg.h
@@ -130,6 +130,8 @@ void rsvg_handle_get_dimensions (RsvgHandle * handle, RsvgDimensionData * dimens
 gboolean rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimension_data, const char *id);
 gboolean rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_data, const char *id);
 
+gboolean rsvg_handle_has_sub (RsvgHandle * handle, const char *id);
+
 /* Accessibility API */
 
 G_CONST_RETURN char *rsvg_handle_get_title	(RsvgHandle * handle);
