Skip to content

Commit

Permalink
Improve xml-prune scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 25, 2023
1 parent ceb7e0c commit 334a744
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2397,18 +2397,18 @@ function xmlPrune(
thisArg.addEventListener('readystatechange', function() {
if ( thisArg.readyState !== 4 ) { return; }
const type = thisArg.responseType;
if ( type === 'text' ) {
if ( type === 'document' || thisArg.responseXML instanceof XMLDocument ) {
pruneFromDoc(thisArg.responseXML);
return;
}
if ( type === 'text' || typeof thisArg.responseText === 'string' ) {
const textin = thisArg.responseText;
const textout = pruneFromText(textin);
if ( textout === textin ) { return; }
Object.defineProperty(thisArg, 'response', { value: textout });
Object.defineProperty(thisArg, 'responseText', { value: textout });
return;
}
if ( type === 'document' ) {
pruneFromDoc(thisArg.response);
return;
}
});
return Reflect.apply(target, thisArg, args);
}
Expand Down

0 comments on commit 334a744

Please sign in to comment.