File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,27 @@ class RHElement extends HTMLElement {
2525 window . customElements . define ( rhe . tag , rhe ) ;
2626 }
2727
28- constructor ( tag ) {
28+ static get RhTypes ( ) {
29+ return {
30+ Container : "container" ,
31+ Content : "content" ,
32+ Pattern : "pattern"
33+ } ;
34+ }
35+
36+ get rhType ( ) {
37+ return this . getAttribute ( "rh-type" ) ;
38+ }
39+
40+ set rhType ( value ) {
41+ this . setAttribute ( "rh-type" , value ) ;
42+ }
43+
44+ constructor ( tag , type ) {
2945 super ( ) ;
3046
3147 this . tag = tag ;
48+ this . _queue = [ ] ;
3249
3350 this . template = document . createElement ( "template" ) ;
3451 this . template . innerHTML = this . html ;
@@ -42,12 +59,42 @@ class RHElement extends HTMLElement {
4259 if ( this . html ) {
4360 this . shadowRoot . appendChild ( this . template . content . cloneNode ( true ) ) ;
4461 }
62+
63+ if ( type ) {
64+ this . _queueAction ( {
65+ type : "setProperty" ,
66+ data : {
67+ name : "rhType" ,
68+ value : type
69+ }
70+ } ) ;
71+ }
4572 }
4673
4774 connectedCallback ( ) {
4875 if ( window . ShadyCSS ) {
4976 ShadyCSS . styleElement ( this ) ;
5077 }
78+
79+ if ( this . _queue . length ) {
80+ this . _processQueue ( ) ;
81+ }
82+ }
83+
84+ _queueAction ( action ) {
85+ this . _queue . push ( action ) ;
86+ }
87+
88+ _processQueue ( ) {
89+ this . _queue . forEach ( action => {
90+ this [ `_${ action . type } ` ] ( action . data ) ;
91+ } ) ;
92+
93+ this . _queue = [ ] ;
94+ }
95+
96+ _setProperty ( { name, value } ) {
97+ this [ name ] = value ;
5198 }
5299}
53100
You can’t perform that action at this time.
0 commit comments