mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[ecmascript] Treat document.write in <head> as new document.
This commit is contained in:
parent
3c8e625956
commit
af190c57cc
@ -50,6 +50,7 @@
|
|||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
#include <libxml++/libxml++.h>
|
#include <libxml++/libxml++.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
std::map<struct timer *, bool> map_timer;
|
std::map<struct timer *, bool> map_timer;
|
||||||
@ -359,6 +360,15 @@ delayed_reload(void *data)
|
|||||||
mem_free(rel);
|
mem_free(rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
iequals(const std::string& a, const std::string& b)
|
||||||
|
{
|
||||||
|
return std::equal(a.begin(), a.end(),
|
||||||
|
b.begin(), b.end(), [](char a, char b) {
|
||||||
|
return toupper(a) == toupper(b);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
||||||
{
|
{
|
||||||
@ -381,6 +391,11 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
|||||||
|
|
||||||
if (element != (*mapa).end()) {
|
if (element != (*mapa).end()) {
|
||||||
xmlpp::Element *el = element->second;
|
xmlpp::Element *el = element->second;
|
||||||
|
|
||||||
|
const xmlpp::Element *parent = el->get_parent();
|
||||||
|
|
||||||
|
if (!parent || iequals(parent->get_name(), "HEAD")) goto fromstart;
|
||||||
|
|
||||||
xmlpp::ustring text = "<root>";
|
xmlpp::ustring text = "<root>";
|
||||||
text += interpreter->writecode.source;
|
text += interpreter->writecode.source;
|
||||||
text += "</root>";
|
text += "</root>";
|
||||||
@ -404,6 +419,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (interpreter->writecode.length) {
|
if (interpreter->writecode.length) {
|
||||||
|
fromstart:
|
||||||
add_fragment(cached, 0, interpreter->writecode.source, interpreter->writecode.length);
|
add_fragment(cached, 0, interpreter->writecode.source, interpreter->writecode.length);
|
||||||
document->ecmascript_counter++;
|
document->ecmascript_counter++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user