@@ -148,23 +148,23 @@ export function tabWidget (options: TabWidgetOptions) {
148
148
div . setAttribute ( 'style' , selectedStyle )
149
149
if ( ! ele . bodyTR ) return
150
150
ele . bodyTR . setAttribute ( 'style' , shownStyle )
151
- let bodyMain = ele . bodyTR . children [ 0 ] as ContainerElement
152
- if ( ! bodyMain ) {
151
+ const bodyMain = getOrCreateContainerElement ( ele )
152
+ if ( options . renderTabSettings && e . altKey && ele . subject && bodyMain . asSettings !== true ) {
153
153
bodyMain = ele . bodyTR . appendChild ( dom . createElement ( 'main' ) )
154
154
bodyMain . setAttribute ( 'style' , bodyMainStyle )
155
155
}
156
156
if ( options . renderTabSettings && e . altKey && ele . subject ) {
157
157
if ( bodyMain . asSettings !== true ) {
158
- bodyMain . innerHTML = 'loading settings ...' + item
159
- options . renderTabSettings ( bodyMain , ele . subject )
160
- bodyMain . asSettings = true
161
- }
158
+ bodyMain . innerHTML = 'loading settings ...' + item
159
+ options . renderTabSettings ( bodyMain , ele . subject )
160
+ bodyMain . asSettings = true
161
+ } else if ( options . renderMain && ele . subject && bodyMain . asSettings !== false ) {
162
162
} else if ( options . renderMain && ele . subject ) {
163
163
if ( bodyMain . asSettings !== false ) {
164
- bodyMain . innerHTML = 'loading item ...' + item
165
- options . renderMain ( bodyMain , ele . subject )
166
- bodyMain . asSettings = false
167
- }
164
+ bodyMain . innerHTML = 'loading item ...' + item
165
+ options . renderMain ( bodyMain , ele . subject )
166
+ bodyMain . asSettings = false
167
+ }
168
168
}
169
169
} )
170
170
@@ -174,6 +174,14 @@ export function tabWidget (options: TabWidgetOptions) {
174
174
div . textContent = label ( item )
175
175
}
176
176
return ele
177
+
178
+ function getOrCreateContainerElement ( ele : TabElement ) : ContainerElement {
179
+ const bodyMain = ele . bodyTR ?. children [ 0 ] as ContainerElement
180
+ if ( bodyMain ) return bodyMain
181
+ const newBodyMain = ele . bodyTR ! . appendChild ( dom . createElement ( 'main' ) )
182
+ newBodyMain . setAttribute ( 'style' , bodyMainStyle )
183
+ return newBodyMain
184
+ }
177
185
}
178
186
179
187
// @@ Use common one from utils?
0 commit comments