Skip to content

Commit

Permalink
observedAttributes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sashafirsov committed Apr 2, 2024
1 parent ebde5e5 commit 4a27718
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ npm i -P @epa-wg/custom-element
yarn add @epa-wg/custom-element
```

## [enable IDE support](ide/IDE.md)
## Enable IDE support
[IDE.md](ide/IDE.md)



Expand Down
15 changes: 7 additions & 8 deletions custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,15 @@ CustomElement extends HTMLElement

Object.defineProperty( this, "xsltString", { get: ()=>templateDocs.map( td => xmlString(td) ).join('\n') });

const dce = this;
const sliceNames = [...this.templateNode.querySelectorAll('[slice]')].map(e=>attr(e,'slice'));
const dce = this
, sliceNodes = [...this.templateNode.querySelectorAll('[slice]')]
, sliceNames = sliceNodes.map(e=>attr(e,'slice')).filter(n=>!n.includes('/'))
, declaredAttributes = templateDocs.reduce( (ret,t) => { if( t.params ) ret.push( ...t.params ); return ret; }, [] );

class DceElement extends HTMLElement
{
static get observedAttributes()
{ return templateDocs.reduce( (ret,t) =>
{ if( t.params ) ret.push( ...t.params.map(e=>attr(e,'name')) );
return ret;
}, [] );
}
static get observedAttributes(){ return declaredAttributes.map( a=>attr(a,'name')); }

connectedCallback()
{ if( this.firstElementChild?.tagName === 'TEMPLATE' )
{ const t = this.firstElementChild;
Expand Down

0 comments on commit 4a27718

Please sign in to comment.