blob: dcb02aa80e5663ca533b3547232f39f8c97bf983 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* Node binding for browser using duktape and libdom
*
* Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* Released under the terms of the MIT License,
* http://www.opensource.org/licenses/mit-license
*/
class Node {
private "dom_node *" node;
}
init Node("struct dom_node *" node)
%{
priv->node = node;
dom_node_ref(node);
%}
fini Node()
%{
dom_node_unref(priv->node);
%}
method Node::appendChild()
%{
if (!dukky_instanceof(ctx, PROTO_NAME(NODE))) return 0;
DUKKY_SAFE_GET_ANOTHER(other,node,0);
dom_exception err;
dom_node *spare;
err = dom_node_append_child(priv->node, other->node, &spare);
if (err != DOM_NO_ERR) return 0;
dom_node_unref(spare);
%}
getter Node::textContent()
%{
dom_exception exc;
dom_string *content;
exc = dom_node_get_text_content(priv->node, &content);
if (exc != DOM_NO_ERR) {
return 0;
}
if (content != NULL) {
duk_push_lstring(ctx, dom_string_data(content), dom_string_length(content));
dom_string_unref(content);
return 1;
}
%}
|