@@ -5,21 +5,19 @@ const CompAttr = 'data-component'
55const PropsAttr = 'data-props'
66
77export type BosParserConfig = {
8- contexts : {
9- [ name : string ] : {
10- component ?: string
11- props ?: {
12- [ prop : string ] : string
13- }
14- insertionPoints ?: {
15- [ insPointName : string ] : {
16- component ?: string
17- bosLayoutManager ?: string
18- insertionType ?: InsertionType
19- }
8+ [ name : string ] : {
9+ component ?: string
10+ props ?: {
11+ [ prop : string ] : string
12+ }
13+ insertionPoints ?: {
14+ [ insPointName : string ] : {
15+ component ?: string
16+ bosLayoutManager ?: string
17+ insertionType ?: InsertionType
2018 }
21- children ?: string [ ]
2219 }
20+ children ?: string [ ]
2321 }
2422}
2523
@@ -30,18 +28,18 @@ export class BosParser implements IParser {
3028 // ToDo: validate config
3129 this . config = config
3230
33- if ( ! this . config . contexts [ 'root' ] ) {
34- this . config . contexts [ 'root' ] = {
31+ if ( ! this . config [ 'root' ] ) {
32+ this . config [ 'root' ] = {
3533 props : {
3634 id : 'root' ,
3735 } ,
38- children : Object . keys ( this . config . contexts ) , // ToDo:
36+ children : Object . keys ( this . config ) , // ToDo:
3937 }
4038 }
4139 }
4240
4341 parseContext ( element : HTMLElement , contextName : string ) {
44- const contextProperties = this . config . contexts [ contextName ] . props
42+ const contextProperties = this . config [ contextName ] . props
4543 if ( ! contextProperties ) return { }
4644
4745 const parsed : any = { }
@@ -56,14 +54,14 @@ export class BosParser implements IParser {
5654 }
5755
5856 findChildElements ( element : HTMLElement , contextName : string ) {
59- const contextConfig = this . config . contexts [ contextName ]
57+ const contextConfig = this . config [ contextName ]
6058 if ( ! contextConfig . children ?. length ) return [ ]
6159
6260 const result : { element : HTMLElement ; contextName : string } [ ] = [ ]
6361
6462 // ToDo: maybe querySelectorAll('.foo:not(.foo .foo)') is faster?
6563 for ( const childContextName of contextConfig . children ?? [ ] ) {
66- const childConfig = this . config . contexts [ childContextName ]
64+ const childConfig = this . config [ childContextName ]
6765 if ( ! childConfig . component ) continue
6866
6967 const childElements = Array . from (
@@ -83,7 +81,7 @@ export class BosParser implements IParser {
8381 contextName : string ,
8482 insertionPoint : string
8583 ) : HTMLElement | null {
86- const contextConfig = this . config . contexts [ contextName ]
84+ const contextConfig = this . config [ contextName ]
8785 const insPointConfig = contextConfig . insertionPoints ?. [ insertionPoint ]
8886
8987 if ( insPointConfig ?. component ) {
@@ -97,7 +95,7 @@ export class BosParser implements IParser {
9795 }
9896
9997 getInsertionPoints ( _ : HTMLElement , contextName : string ) : InsertionPoint [ ] {
100- const contextConfig = this . config . contexts [ contextName ]
98+ const contextConfig = this . config [ contextName ]
10199 if ( ! contextConfig . insertionPoints ) return [ ]
102100
103101 return Object . entries ( contextConfig . insertionPoints ) . map ( ( [ name , selectorOrObject ] ) => ( {
0 commit comments