mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 15:09:54 +01:00
wombat: ensure document.write override handles elements that go into
head as well as body
This commit is contained in:
parent
59630c08f6
commit
976decb3f1
@ -752,7 +752,6 @@ _WBWombat = (function() {
|
||||
targetOrigin = window.location.origin;
|
||||
}
|
||||
|
||||
|
||||
return orig.call(this, message, targetOrigin, transfer);
|
||||
}
|
||||
|
||||
@ -850,10 +849,25 @@ _WBWombat = (function() {
|
||||
//============================================
|
||||
function init_write_override()
|
||||
{
|
||||
var orig_doc_write = document.write;
|
||||
|
||||
document.write = function(string) {
|
||||
var doc = new DOMParser().parseFromString(string, "text/html");
|
||||
|
||||
if (doc) {
|
||||
|
||||
if (doc.head && document.head) {
|
||||
var children = doc.head.children;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
//document.head.appendChild(children[i]);
|
||||
// in head, must call original write to ensure same execution order..
|
||||
rewrite_elem(children[i]);
|
||||
orig_doc_write.call(this, children[i].outerHTML);
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.body && document.body) {
|
||||
var children = doc.body.children;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
@ -862,6 +876,7 @@ _WBWombat = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================
|
||||
function wombat_init(replay_prefix, capture_date, orig_scheme, orig_host, timestamp, mod) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user