summaryrefslogtreecommitdiff
path: root/src/core/attr.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-26 17:47:37 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2012-03-26 17:47:37 +0000
commitac114128a79c598a82fc724f9746a27b64b18b6d (patch)
tree857c2616a98c4387977623e65fd21c59eb313839 /src/core/attr.c
parentfc5f899cffb00e861fd9e797069edd83b16feb37 (diff)
downloadlibdom-ac114128a79c598a82fc724f9746a27b64b18b6d.tar.gz
libdom-ac114128a79c598a82fc724f9746a27b64b18b6d.tar.bz2
When retrieving attribute values, if the attribute has a single child, said child is a text node, and has a value, then just ref that string and return it.
svn path=/trunk/libdom/; revision=13722
Diffstat (limited to 'src/core/attr.c')
-rw-r--r--src/core/attr.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/attr.c b/src/core/attr.c
index dc14a93..9db04b6 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -445,7 +445,16 @@ dom_exception _dom_attr_get_value(struct dom_attr *attr,
struct dom_node_internal *c;
dom_string *value, *temp;
dom_exception err;
-
+
+ /* Attempt to shortcut for a single text node child with value */
+ if ((a->first_child != NULL) &&
+ (a->first_child == a->last_child) &&
+ (a->first_child->type == DOM_TEXT_NODE) &&
+ (a->first_child->value != NULL)) {
+ *result = dom_string_ref(a->first_child->value);
+ return DOM_NO_ERR;
+ }
+
err = dom_string_create(NULL, 0, &value);
if (err != DOM_NO_ERR) {
return err;