summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2012-07-04 17:44:59 +0100
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2012-07-04 17:44:59 +0100
commitd28b99de7f0a4cc1ea090447194607ef426f3431 (patch)
tree059ac049f1ad70905e53ef30843709ceedfc5ee1
parentb641ce20ca434e4e9e1b15bd9976947f03166abb (diff)
downloadlibdom-d28b99de7f0a4cc1ea090447194607ef426f3431.tar.gz
libdom-d28b99de7f0a4cc1ea090447194607ef426f3431.tar.bz2
HTMLElement.set_id: Use memoised 'id' string from HTMLDocument
-rw-r--r--src/html/html_element.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/html/html_element.c b/src/html/html_element.c
index 4d43205..555e4fb 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -124,19 +124,19 @@ dom_exception _dom_html_element_get_id(dom_html_element *element,
dom_exception _dom_html_element_set_id(dom_html_element *element,
dom_string *id)
{
- dom_exception ret;
- dom_string *idstr;
-
- ret = dom_string_create_interned((const uint8_t *) "id", SLEN("id"),
- &idstr);
- if (ret != DOM_NO_ERR)
- return ret;
-
- ret = dom_element_set_attribute(element, idstr, id);
-
- dom_string_unref(idstr);
+ dom_exception ret;
+ dom_string *_memo_id;
+
+ /* Because we're an HTML element, our document is always
+ * an HTML document, so we can get its memoised id string
+ */
+ _memo_id =
+ ((struct dom_html_document *)
+ ((struct dom_node_internal *)element)->owner)->_memo_id;
+
+ ret = dom_element_set_attribute(element, _memo_id, id);
- return ret;
+ return ret;
}
dom_exception _dom_html_element_get_title(dom_html_element *element,