From 713468e0109cdcaae65793f7ced7cf168d1ee9c5 Mon Sep 17 00:00:00 2001 From: Uriel Gomez Date: Sat, 20 Jul 2024 22:07:09 -0600 Subject: [PATCH] * XMLDocument.prototype.consolidate - refactored attribute import --- xo.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xo.js b/xo.js index 6e47086..7a88f16 100644 --- a/xo.js +++ b/xo.js @@ -5706,10 +5706,18 @@ xover.modernize = async function (targetWindow) { } for (let el of xsl.select(`//xsl:template//@xo:use-attribute-sets`)) { let attribute_sets = el.value.split(/\s+/g); - let attributes = attribute_sets.reduce((attrs, key) => attrs.concat([el.ownerDocument.createComment(`ack:attribute-set ${key}`)]).concat(el.select(`//xsl:attribute-set[@name="${key}"]/*`)), [xsl.createComment(`ack:importing-attribute-sets-begins`)]); + let attributes = attribute_sets.reduce((attrs, key) => { + let imported_attributes = el.select(`//xsl:attribute-set[@name="${key}"]/*`); + if (imported_attributes.length) { + attrs.push(el.ownerDocument.createComment(`ack:attribute-set ${key}`)); + attrs.push(...imported_attributes); + attrs.push(xsl.createComment(`ack:importing-attribute-sets-begins`)); + } + return attrs; + },[]); attributes = attributes.concat(xsl.createComment(`ack:importing-attribute-sets-end`)) el.parentNode.prepend(...attributes) - el.remove(); + //el.remove(); } return xsl; }