arsd.dom appenChild method gives assertion message
Erdem via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Dec 11 09:52:29 PST 2016
I would like to add first documents content inside a div element
like this.
import arsd.dom;
import std.stdio;
void main()
{
auto document = new Document();
document.parseGarbage(`<html>
<head>
<title>Test Document1</title>
</head>
<body>
<p>This is the first paragraph of our <a
href="test.html">test document</a>.
<p>This second paragraph also has a <a
href="test2.html">link</a>.
<p id="custom-paragraph">Old text</p>
</body>
</html>`);
auto document2 = new Document();
document2.parseGarbage(`<html>
<head>
<title>Test Document</title>
</head>
<body>
<div id="foo"></div>
<a href="www.example.com"></a>
<div id="content">
</div>
<p id="custom-paragraph">Old text</p>
</body>
</html>`);
Element content =
document2.getElementsBySelector(`div[id="content"]`)[0];
writeln(content);
Element[] firstElements =
document.getElementsBySelector("body");
writeln (firstElements);
content.appendChild(firstElements[0]);
}
The program compiles fine. But when I try to execute it gives an
assertion error like this.
??:? _d_assert_msg [0x80cc048]
??:?
_D4arsd3dom7Element11appendChildMFC4arsd3dom7ElementZ9__requireMFZv [0x80a6f62]
??:? arsd.dom.Element
arsd.dom.Element.appendChild(arsd.dom.Element) [0x80a6df1]
??:? _Dmain [0x809f73c]
??:?
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
[0x80cd792]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x80cd6dc]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll() [0x80cd74e]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x80cd6dc]
??:? _d_run_main [0x80cd66e]
??:? main [0x809fc93]
??:? __libc_start_main [0x129532]
How should one use appendChild or similiar methods of arsd.dom
library?
More information about the Digitalmars-d-learn
mailing list