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:
parent
865f3fa0d0
commit
df28d4345b
src
document/xml
ecmascript
test/ecmascript
@ -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);
|
xmlpp::Node *node = static_cast<xmlpp::Node *>(nod);
|
||||||
|
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!start) {
|
if (!start) {
|
||||||
const auto textNode = dynamic_cast<const xmlpp::TextNode*>(node);
|
const auto textNode = dynamic_cast<const xmlpp::TextNode*>(node);
|
||||||
|
|
||||||
|
@ -395,7 +395,8 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
|||||||
auto it2 = children2.begin();
|
auto it2 = children2.begin();
|
||||||
auto end2 = children2.end();
|
auto end2 = children2.end();
|
||||||
for (; it2 != end2; ++it2) {
|
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);
|
xmlpp::Node::remove_node(el);
|
||||||
}
|
}
|
||||||
|
@ -1646,7 +1646,8 @@ mjs_element_replaceWith(js_State *J)
|
|||||||
js_pushundefined(J);
|
js_pushundefined(J);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlAddPrevSibling(el->cobj(), rep->cobj());
|
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
|
||||||
|
xmlpp::Node::create_wrapper(n);
|
||||||
xmlpp::Node::remove_node(el);
|
xmlpp::Node::remove_node(el);
|
||||||
interpreter->changed = true;
|
interpreter->changed = true;
|
||||||
|
|
||||||
|
@ -1787,7 +1787,8 @@ js_element_replaceWith(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
|
|||||||
}
|
}
|
||||||
JSValue replacement = argv[0];
|
JSValue replacement = argv[0];
|
||||||
xmlpp::Node *rep = static_cast<xmlpp::Node *>(js_getopaque(replacement, js_element_class_id));
|
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);
|
xmlpp::Node::remove_node(el);
|
||||||
interpreter->changed = true;
|
interpreter->changed = true;
|
||||||
|
|
||||||
|
@ -3457,7 +3457,8 @@ element_replaceWith(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
|
|
||||||
JS::RootedObject replacement(ctx, &args[0].toObject());
|
JS::RootedObject replacement(ctx, &args[0].toObject());
|
||||||
xmlpp::Node *rep = JS::GetMaybePtrFromReservedSlot<xmlpp::Node>(replacement, 0);
|
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);
|
xmlpp::Node::remove_node(el);
|
||||||
interpreter->changed = true;
|
interpreter->changed = true;
|
||||||
args.rval().setUndefined();
|
args.rval().setUndefined();
|
||||||
|
@ -4,6 +4,26 @@
|
|||||||
-| 16 colors |-
|
-| 16 colors |-
|
||||||
</title>
|
</title>
|
||||||
<script type="text/javascript">
|
<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()
|
function onl()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -33,24 +53,6 @@ document.writeln('<html><head><title>-| 16 colors |-</title></head><pre>');
|
|||||||
document.writeln('<br>');
|
document.writeln('<br>');
|
||||||
colors.forEach(printstrln);
|
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('');
|
||||||
document.writeln('<font color="yellow">This is true : '+true+'</font>');
|
document.writeln('<font color="yellow">This is true : '+true+'</font>');
|
||||||
document.writeln('<font color="red">and this is false: '+false+'</font>');
|
document.writeln('<font color="red">and this is false: '+false+'</font>');
|
||||||
|
Loading…
Reference in New Issue
Block a user