1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[ecmascript] Random fixes

This commit is contained in:
Witold Filipczyk 2022-11-20 18:09:53 +01:00
parent 865f3fa0d0
commit df28d4345b
6 changed files with 32 additions and 22 deletions

View File

@ -296,6 +296,10 @@ walk_tree(std::map<int, xmlpp::Element *> *mapa, struct string *buf, void *nod,
{
xmlpp::Node *node = static_cast<xmlpp::Node *>(nod);
if (!node) {
return;
}
if (!start) {
const auto textNode = dynamic_cast<const xmlpp::TextNode*>(node);

View File

@ -395,7 +395,8 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
auto it2 = children2.begin();
auto end2 = children2.end();
for (; it2 != end2; ++it2) {
xmlAddPrevSibling(el->cobj(), (*it2)->cobj());
auto n = xmlAddPrevSibling(el->cobj(), (*it2)->cobj());
xmlpp::Node::create_wrapper(n);
}
xmlpp::Node::remove_node(el);
}

View File

@ -1646,7 +1646,8 @@ mjs_element_replaceWith(js_State *J)
js_pushundefined(J);
return;
}
xmlAddPrevSibling(el->cobj(), rep->cobj());
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
xmlpp::Node::create_wrapper(n);
xmlpp::Node::remove_node(el);
interpreter->changed = true;

View File

@ -1787,7 +1787,8 @@ js_element_replaceWith(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
}
JSValue replacement = argv[0];
xmlpp::Node *rep = static_cast<xmlpp::Node *>(js_getopaque(replacement, js_element_class_id));
xmlAddPrevSibling(el->cobj(), rep->cobj());
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
xmlpp::Node::create_wrapper(n);
xmlpp::Node::remove_node(el);
interpreter->changed = true;

View File

@ -3457,7 +3457,8 @@ element_replaceWith(JSContext *ctx, unsigned int argc, JS::Value *rval)
JS::RootedObject replacement(ctx, &args[0].toObject());
xmlpp::Node *rep = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(replacement, 0);
xmlAddPrevSibling(el->cobj(), rep->cobj());
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
xmlpp::Node::create_wrapper(n);
xmlpp::Node::remove_node(el);
interpreter->changed = true;
args.rval().setUndefined();

View File

@ -4,6 +4,26 @@
-| 16 colors |-
</title>
<script type="text/javascript">
function lpad_str(str) {
if (str.length<=9) { str=(str+" ").slice(-9); }
return str;
}
function lpad(number) {
if (number<=999) { number = ("00"+number).slice(-3); }
return number;
}
function printstr(item,index) {
if ((index)%4==0) { document.writeln("<tr>"); }
document.write('<td>');
document.write('<font color="'+item+'">'+lpad_str(item) +'</font> ');
document.write('<td>');
if ((index+1)%4==0) { document.writeln("</tr>"); }
}
function printstrln(item,index) {
document.writeln('<font color="'+item+'">'+lpad(index)+' This is '+item+'</font>');
}
function onl()
{
@ -33,24 +53,6 @@ document.writeln('<html><head><title>-| 16 colors |-</title></head><pre>');
document.writeln('<br>');
colors.forEach(printstrln);
function lpad_str(str) {
if (str.length<=9) { str=(str+" ").slice(-9); }
return str;
}
function lpad(number) {
if (number<=999) { number = ("00"+number).slice(-3); }
return number;
}
function printstr(item,index) {
if ((index)%4==0) { document.writeln("<tr>"); }
document.write('<td>');
document.write('<font color="'+item+'">'+lpad_str(item) +'</font> ');
document.write('<td>');
if ((index+1)%4==0) { document.writeln("</tr>"); }
}
function printstrln(item,index) {
document.writeln('<font color="'+item+'">'+lpad(index)+' This is '+item+'</font>');
}
document.writeln('');
document.writeln('<font color="yellow">This is true : '+true+'</font>');
document.writeln('<font color="red">and this is false: '+false+'</font>');