summaryrefslogtreecommitdiff
path: root/javascript/jsapi/dom.bnd
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2012-11-09 10:52:32 +0000
committerVincent Sanders <vince@netsurf-browser.org>2012-11-09 10:52:55 +0000
commit9318e664490420bdbfbd7695d203225087b59c07 (patch)
tree8405776293ac9900fce01a8c31937dd1b603cc50 /javascript/jsapi/dom.bnd
parente25cb448142ba010cb97eaaaab0e00138dad97be (diff)
downloadnetsurf-9318e664490420bdbfbd7695d203225087b59c07.tar.gz
netsurf-9318e664490420bdbfbd7695d203225087b59c07.tar.bz2
add document.createElement
Diffstat (limited to 'javascript/jsapi/dom.bnd')
-rw-r--r--javascript/jsapi/dom.bnd34
1 files changed, 22 insertions, 12 deletions
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index 5611e8fa7..3a355256f 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -6,25 +6,25 @@ webidlfile "dom.idl";
getter textContent %{
- dom_exception exc;
- dom_string *content;
+ dom_exception exc;
+ dom_string *content;
- exc = dom_node_get_text_content(private->node, &content);
- if (exc != DOM_NO_ERR) {
+ exc = dom_node_get_text_content(private->node, &content);
+ if (exc != DOM_NO_ERR) {
return JS_FALSE;
}
if (content != NULL) {
- jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content));
+ jsret = JS_NewStringCopyN(cx, dom_string_data(content), dom_string_length(content));
dom_string_unref(content);
- }
+ }
%}
operation appendChild %{
struct dom_node *result = NULL;
- dom_exception exc;
+ dom_exception exc;
struct jsclass_private *node_private;
dom_node_type node_type;
@@ -34,12 +34,22 @@ operation appendChild %{
/* CAUTION this expects all Node objects private pointers to
* have private->node in the same place
*/
+ /* text */
node_private = JS_GetInstancePrivate(cx, node, &JSClass_Text, NULL);
- if (node_private != NULL) {
- exc = dom_node_append_child(private->node, node_private->node, &result);
- if (exc != DOM_NO_ERR) {
- return JS_FALSE;
- }
+ if (node_private == NULL) {
+ /* element */
+ node_private = JS_GetInstancePrivate(cx, node, &JSClass_HTMLElement, NULL);
+ }
+
+ if (node_private == NULL) {
+ /* type error? */
+ return JS_FALSE;
+ }
+
+ /* append the found element */
+ exc = dom_node_append_child(private->node, node_private->node, &result);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
}
if (result != NULL) {