1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-23 07:20:10 -04:00

SEE & SMJS: document.write(ln): use all arguments

Additionally add a test to test/ecmascript/document_write.html.

Thanks to Kirk Reiser for observing that ELinks only printed the first.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-02-12 04:33:42 +00:00 committed by Miciah Dashiel Butler Masters
parent 7b092af628
commit a464157d4d
3 changed files with 19 additions and 7 deletions

View File

@ -212,11 +212,17 @@ js_document_write_do(struct SEE_interpreter *interp, struct SEE_object *self,
struct string *ret = g->ret;
if (argc >= 1 && ret) {
unsigned char *code = SEE_value_to_unsigned_char(interp, argv[0]);
int i = 0;
if (code) {
add_to_string(ret, code);
mem_free(code);
for (; i < argc; ++i) {
unsigned char *code;
code = SEE_value_to_unsigned_char(interp, argv[i]);
if (code) {
add_to_string(ret, code);
mem_free(code);
}
}
if (newline)

View File

@ -212,9 +212,14 @@ document_write_do(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
struct string *ret = interpreter->ret;
if (argc >= 1 && ret) {
unsigned char *code = jsval_to_string(ctx, &argv[0]);
int i = 0;
for (; i < argc; ++i) {
unsigned char *code = jsval_to_string(ctx, &argv[i]);
add_to_string(ret, code);
}
add_to_string(ret, code);
if (newline)
add_char_to_string(ret, '\n');
}

View File

@ -3,7 +3,8 @@
<a href="history.html">history.html</a><br/>
<script type="text/javascript">
document.writeln('<a href="ontest.html">Test</a><br/>');
document.write('<a href="infinite2.html">infinite2.html</a><br/>');
document.writeln('<a href="infinite2.html">infinite2.html</a><br/>');
document.write(1,2,'3', '<br/>');
</script>
<a href="onload.html">onload.html</a><br/>
</body>