summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javascript/jsapi/binding.h14
-rw-r--r--javascript/jsapi/dom.bnd4
-rw-r--r--javascript/jsapi/htmldocument.bnd22
-rw-r--r--javascript/jsapi/text.bnd2
4 files changed, 38 insertions, 4 deletions
diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h
index c1006589e..446fb0c51 100644
--- a/javascript/jsapi/binding.h
+++ b/javascript/jsapi/binding.h
@@ -124,4 +124,18 @@ JSObject *jsapi_new_NodeList(JSContext *cx,
dom_nodelist *nodelist,
struct html_content *htmlc);
+
+JSObject *jsapi_InitClass_Text(JSContext *cx, JSObject *parent);
+/** Create a new javascript text object
+ *
+ * @param cx The javascript context.
+ * @param parent The parent object, usually a global window object
+ * @param node The dom node to use in the object
+ * @return new javascript object or NULL on error
+ */
+JSObject *jsapi_new_Text(JSContext *cx,
+ JSObject *prototype,
+ JSObject *parent,
+ dom_text *node);
+
#endif
diff --git a/javascript/jsapi/dom.bnd b/javascript/jsapi/dom.bnd
index c2f9e787e..bf3b44ea3 100644
--- a/javascript/jsapi/dom.bnd
+++ b/javascript/jsapi/dom.bnd
@@ -24,7 +24,5 @@ getter textContent %{
operation appendChild %{
-%}
-
-operation createTextNode %{
+/* void * JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); */
%}
diff --git a/javascript/jsapi/htmldocument.bnd b/javascript/jsapi/htmldocument.bnd
index 1432ce5da..b642cabe6 100644
--- a/javascript/jsapi/htmldocument.bnd
+++ b/javascript/jsapi/htmldocument.bnd
@@ -169,3 +169,25 @@ operation write %{
dom_hubbub_parser_insert_chunk(private->htmlc->parser, (uint8_t *)text, text_len);
}
%}
+
+/* in dom Document */
+operation createTextNode %{
+ dom_string *data_dom;
+ dom_element *element;
+ dom_exception exc;
+ dom_text *text;
+
+ exc = dom_string_create((unsigned char*)data, data_len, &data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ exc = dom_document_create_text_node(private->node, data_dom, &text);
+ dom_string_unref(data_dom);
+ if (exc != DOM_NO_ERR) {
+ return JS_FALSE;
+ }
+
+ jsret = jsapi_new_Text(cx, NULL, NULL, text);
+
+%}
diff --git a/javascript/jsapi/text.bnd b/javascript/jsapi/text.bnd
index d440e4a9e..53e93803d 100644
--- a/javascript/jsapi/text.bnd
+++ b/javascript/jsapi/text.bnd
@@ -34,7 +34,7 @@ binding text {
interface Text; /* Web IDL interface to generate */
- private "dom_node *" node;
+ private "dom_text *" node;
}
api finalise %{