From bc7744706798346682b1e61eed8934c731d3fa35 Mon Sep 17 00:00:00 2001 From: Uriel Gomez Date: Wed, 21 Aug 2024 14:50:10 -0600 Subject: [PATCH] * Node.prototype.transform - Added logic to force transformToDocument method by using output standalone="yes" - xsl:output node is removed to avoid creating html structure * xover.fetch.xml - added br and hr to then nodes that won't be scoped automatically --- xo.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xo.js b/xo.js index dc572fa..594e6a3 100644 --- a/xo.js +++ b/xo.js @@ -7802,7 +7802,8 @@ xover.modernize = async function (targetWindow) { if (xover.session.debug || xsl.selectSingleNode('//xsl:param[@name="debug:timer" and text()="true"]')) { console.time(timer_id); } - if (xsl.documentElement.getAttribute("xmlns") && !(xsl.selectSingleNode('//xsl:output[@method="html"]')) /*xover.browser.isIOS()*/) {// && ((result || {}).documentElement || {}).namespaceURI == "http://www.w3.org/1999/xhtml" ) { + if (xsl.documentElement.getAttribute("xmlns") && !(xsl.selectSingleNode('//xsl:output[@method="html"][@standalone="yes"]')) /*xover.browser.isIOS()*/) {// && ((result || {}).documentElement || {}).namespaceURI == "http://www.w3.org/1999/xhtml" ) { + //use to avoid html rules (like embedding invalid items or duplicating
) //TODO: Analyze combinations let transformed = xsltProcessor.transformToFragment(xml, document); let newDoc; if (transformed && transformed.children.length > 1) { @@ -7814,6 +7815,7 @@ xover.modernize = async function (targetWindow) { result = newDoc; } if (result == null) { + xsl.select('//xsl:output[@method="html"]').remove() result = xsltProcessor.transformToDocument(xml); } result && [...result.children].map(el => el instanceof HTMLElement && el.select('//@*[starts-with(., "`") and substring(., string-length(.))="`"]').map(val => { try { val.value = eval(val.value.replace(/\$\{\}/g, '')) } catch (e) { console.log(e) } })); @@ -9405,7 +9407,7 @@ ${el.select(`ancestor::xsl:template[1]/@*`).map(attr => `${attr.name}="${new Tex el.prepend(xover.xml.createNode(``)); } - for (let el of return_value.select(`(//xsl:*[not(@match="/")]/html:*[not(self::html:script or self::html:style or self::html:link)]|//xsl:*/svg:*[not(ancestor::svg:*)])[not(@xo-source or @xo-stylesheet or ancestor-or-self::*[@xo-scope])]`)) { + for (let el of return_value.select(`(//xsl:*[not(@match="/")]/html:*[not(self::html:script or self::html:style or self::html:link or self::html:br or self::html:hr)]|//xsl:*/svg:*[not(ancestor::svg:*)])[not(@xo-source or @xo-stylesheet or ancestor-or-self::*[@xo-scope])]`)) { el.set("xo-scope", "{current()[not(self::*)]/../@xo:id|@xo:id}"); }