Skip to content

Commit

Permalink
#44 DCE attributes missing,observedAttributes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sashafirsov committed Apr 2, 2024
1 parent 4a27718 commit 15a9852
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
if( !fr )
return console.error("transformation error",{ xml:tc.outerHTML, xsl: xmlString( sanitizeXsl ) });
const params = [];
[...fr.querySelectorAll('dce-root>attribute')].forEach(p=>
{ p = cloneAs(p,'xsl:param');
[...fr.querySelectorAll('dce-root>attribute')].forEach( a=>
{
const p = cloneAs(a,'xsl:param');
payload.append(p);
let select = attr(p,'select')?.split('??')
if( !select)
Expand All @@ -226,8 +227,11 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
c.firstElementChild.setAttribute('test',select[0]);
emptyNode(c.firstElementChild).append( createText(c,'{'+select[0]+'}'));
emptyNode(c.lastElementChild ).append( createText(c,'{'+select[1]+'}'));
p.append(c)
}
p.append(c);
a.append(c.cloneNode(true));
}else
a.append(cloneAs(a,'xsl:value-of'));
a.removeAttribute('select');
params.push(p)
});

Expand Down Expand Up @@ -527,6 +531,12 @@ CustomElement extends HTMLElement
if( hasInitValue(el) )
changeCb(el)
}
});
// merge attributes from dce-root to `this`
[...this.firstElementChild.attributes].map(a=> {
if( a.value !== this.getAttribute(a.name))
this.setAttribute(a.name, a.value);
// this.firstElementChild.removeAttributeNode(a);
})
};
transform();
Expand Down

0 comments on commit 15a9852

Please sign in to comment.