Skip to content

Commit

Permalink
* xover.Source - added finally block to clear progress items
Browse files Browse the repository at this point in the history
* xover.Store.render - added check for statustext to 401 errors
* Node.prototype.normalizeNamespaces - fixes for document node
* Node.prototype.transform
  - removed cloning to allow document to be modified within listener handler
  - reallocated listener matchers
  - handles empty nodes
  • Loading branch information
uriel-online committed Jan 17, 2024
1 parent 403670c commit 42c96fc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions xo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,9 @@ xover.Source = function (tag) {
} else {
return reject(e)
}
} finally {
progress = await this.settings.progress || [];
progress.forEach(item => item.remove());
}
resolve(response);
}));
Expand Down Expand Up @@ -6336,7 +6339,7 @@ xover.Store = function (xml, ...args) {
let tag = self.tag;
e = e || {}
if (e instanceof Response || e instanceof Error || typeof (e) === 'string') {
if ([401].includes(e.status)) {
if ([401].includes(e.status) && e.statusText) {
console.error(e.statusText)
} else {
return Promise.reject(e);
Expand Down Expand Up @@ -9511,7 +9514,8 @@ xover.modernize = async function (targetWindow) {

Node.prototype.normalizeNamespaces = function () {
let normalized = xover.xml.normalizeNamespaces(this)
this.replaceWith(normalized)
let target = this instanceof Document ? this.documentElement : this;
target.replaceWith(normalized instanceof Document ? normalized.documentElement : normalized)
return this;
}

Expand Down Expand Up @@ -10850,7 +10854,7 @@ xover.modernize = async function (targetWindow) {
return (xml_document || xover.xml.createDocument(`<xo:empty xo:id="empty" xmlns:xo="http://panax.io/xover"/>`).seed()).transform(this);
}
let xsl = xml_document;
let xml = this.cloneNode(true);
let xml = this;
let xmlDoc;
let result = undefined;
if (!xsl/* && ((arguments || {}).callee || {}).caller != Node.prototype.transform*/) {
Expand All @@ -10862,15 +10866,19 @@ xover.modernize = async function (targetWindow) {
}
return xml;
}
let before_listeners = xover.listener.matches(xml, 'beforeTransform')
let after_listeners = xover.listener.matches(xml, 'transform')
xml.disconnect();
//if (!(xml && xsl)) {
// return xml;//false;
//}
let original_doc = xml;
if (!(typeof (xsl.selectSingleNode) != 'undefined' && xsl.selectSingleNode('xsl:*'))) {
throw (new Error("XSL document is empty or invalid"));
}
let empty_node
if (!xml.selectSingleNode("self::*|*|comment()") && xml.createComment) {
xml.appendChild(xml.createComment("empty"))
empty_node = xml.appendChild(xml.createComment("empty"))
}

if (document.implementation && document.implementation.createDocument) {
Expand Down Expand Up @@ -10980,9 +10988,6 @@ xover.modernize = async function (targetWindow) {
////}
let tag = xml.tag || `#${xsl.href || ""}`;
xml.tag = tag;
let before_listeners = xover.listener.matches(xml, 'beforeTransform')
let after_listeners = xover.listener.matches(xml, 'transform')
xml.disconnect();
window.top.dispatchEvent(new xover.listener.Event('beforeTransform', { listeners: before_listeners, document: this instanceof Document && this || this.ownerDocument, node: this, store: xml.store, stylesheet: xsl }, xml));
let timer_id = `${xsl.href || "Transform"}-${Date.now()}`;
performance.mark(`${timer_id} - Transform start`);
Expand Down Expand Up @@ -11011,6 +11016,7 @@ xover.modernize = async function (targetWindow) {
if ((xover.session.debug || {})["transform"] || xsl.selectSingleNode('//xsl:param[@name="debug:timer" and text()="true"]')) {
console.timeEnd(timer_id);
}
empty_node && empty_node.remove()
performance.mark(`${timer_id} - Transform end`);
} catch (e) {
return Promise.reject(e)
Expand Down

0 comments on commit 42c96fc

Please sign in to comment.