@@ -219,7 +219,7 @@ export default class Tab {
219219
220220 bindElement ( element ) {
221221 element . $TST = this ;
222- element . apiTab = this . tab ;
222+ element . apiRaw = this . raw ;
223223 this . element = element ;
224224 this . classList = element . classList ;
225225 // wait until initialization processes are completed
@@ -249,7 +249,7 @@ export default class Tab {
249249 this . element . removeAttribute ( name ) ;
250250 }
251251 this . element . $TST = null ;
252- this . element . apiTab = null ;
252+ this . element . apiRaw = null ;
253253 }
254254 this . element = null ;
255255 this . classList = null ;
@@ -299,7 +299,7 @@ export default class Tab {
299299 }
300300
301301 get type ( ) {
302- return 'color' in this . raw ? 'group' : 'tab' ;
302+ return Tab . isNativeTabGroup ( this . raw ) ? 'group' : 'tab' ;
303303 }
304304
305305 get renderingId ( ) {
@@ -939,7 +939,7 @@ export default class Tab {
939939 this . tab . groupId == - 1 ) {
940940 return null ;
941941 }
942- return TabsStore . windows . get ( this . tab . windowId ) . tabGroups . get ( this . tab . groupId ) ;
942+ return Tab . getNativeTabGroup ( this . tab ) ;
943943 }
944944
945945 set parent ( tab ) {
@@ -2026,7 +2026,7 @@ export default class Tab {
20262026 continue ;
20272027 }
20282028 const windowId = this . tab . windowId ;
2029- const group = TabsStore . windows . get ( this . tab . windowId ) . tabGroups . get ( groupId ) ;
2029+ const group = Tab . getNativeTabGroup ( { windowId : this . tab . windowId , groupId } ) ;
20302030 if ( ! group ) {
20312031 continue ;
20322032 }
@@ -2183,40 +2183,41 @@ export default class Tab {
21832183
21842184 let exportedTab = configs . cacheAPITreeItems && light ? this . $exportedForAPI : null ;
21852185 let favIconUrl ;
2186+ const tab = this . tab ;
21862187 if ( ! exportedTab ) {
21872188 const [ effectiveFavIconUrl , children ] = await Promise . all ( [
21882189 ( light ||
21892190 ( ! permissions ||
21902191 ( ! permissions . has ( kPERMISSION_TABS ) &&
21912192 ( ! permissions . has ( kPERMISSION_ACTIVE_TAB ) ||
2192- ! this . tab . active ) ) ) ) ?
2193+ ! tab ? .active ) ) ) ) ?
21932194 null :
2194- ( this . tab . id in cache . effectiveFavIconUrls ) ?
2195- cache . effectiveFavIconUrls [ this . tab . id ] :
2196- this . tab . favIconUrl ?. startsWith ( 'data:' ) ?
2197- this . tab . favIconUrl :
2198- TabFavIconHelper . getLastEffectiveFavIconURL ( this . tab ) . catch ( ApiTabs . handleMissingTabError ) ,
2195+ ( tab ? .id in cache . effectiveFavIconUrls ) ?
2196+ cache . effectiveFavIconUrls [ tab ? .id ] :
2197+ tab ? .favIconUrl ?. startsWith ( 'data:' ) ?
2198+ tab ? .favIconUrl :
2199+ TabFavIconHelper . getLastEffectiveFavIconURL ( tab ) . catch ( ApiTabs . handleMissingTabError ) ,
21992200 doProgressively (
2200- this . tab . $TST . children ,
2201+ this . raw . $TST . children ,
22012202 child => child . $TST . exportForAPI ( { addonId, light, isContextTab, interval, permissions, cache, cacheKey } ) ,
22022203 interval
22032204 ) ,
22042205 ] ) ;
22052206 favIconUrl = effectiveFavIconUrl ;
22062207
2207- if ( ! ( this . tab . id in cache . effectiveFavIconUrls ) )
2208- cache . effectiveFavIconUrls [ this . tab . id ] = effectiveFavIconUrl ;
2208+ if ( ! ( tab ? .id in cache . effectiveFavIconUrls ) )
2209+ cache . effectiveFavIconUrls [ tab ? .id ] = effectiveFavIconUrl ;
22092210
2210- const tabStates = this . tab . $TST . states ;
2211+ const tabStates = tab ? .$TST . states ;
22112212 exportedTab = {
2212- id : this . tab . id ,
2213- windowId : this . tab . windowId ,
2213+ id : this . raw . id ,
2214+ windowId : this . raw . windowId ,
22142215 type : this . type ,
2215- states : this . type == 'group' ? [ ] : Constants . kTAB_SAFE_STATES_ARRAY . filter ( state => tabStates . has ( state ) ) ,
2216- indent : parseInt ( this . tab . $TST . getAttribute ( Constants . kLEVEL ) || 0 ) ,
2216+ states : tabStates && Constants . kTAB_SAFE_STATES_ARRAY . filter ( state => tabStates . has ( state ) ) || [ ] ,
2217+ indent : parseInt ( this . raw . $TST . getAttribute ( Constants . kLEVEL ) || 0 ) ,
22172218 children,
2218- ancestorTabIds : this . tab . $TST . ancestorIds ,
2219- bundledTabId : this . tab . $TST . bundledTabId ,
2219+ ancestorTabIds : tab ? .$TST . ancestorIds || [ ] ,
2220+ bundledTabId : tab ? .$TST . bundledTabId ,
22202221 } ;
22212222 if ( this . stuck )
22222223 exportedTab . states . push ( Constants . kTAB_STATE_STUCK ) ;
@@ -2259,8 +2260,8 @@ export default class Tab {
22592260
22602261 if ( permissions . has ( kPERMISSION_TABS ) ||
22612262 ( permissions . has ( kPERMISSION_ACTIVE_TAB ) &&
2262- ( this . tab . active ||
2263- ( this . tab == this . tab && this . isContextTab ) ) ) ) {
2263+ ( tab ? .active ||
2264+ this . isContextTab ) ) ) {
22642265 // specially allowed with "tabs" or "activeTab" permission
22652266 allowedProperties . add ( 'favIconUrl' ) ;
22662267 allowedProperties . add ( 'title' ) ;
@@ -2269,12 +2270,12 @@ export default class Tab {
22692270 }
22702271 if ( permissions . has ( kPERMISSION_COOKIES ) ) {
22712272 allowedProperties . add ( 'cookieStoreId' ) ;
2272- fullExportedTab . cookieStoreName = this . tab . $TST . cookieStoreName ;
2273+ fullExportedTab . cookieStoreName = tab ? .$TST . cookieStoreName ;
22732274 }
22742275
22752276 for ( const property of allowedProperties ) {
2276- if ( property in this . tab )
2277- fullExportedTab [ property ] = this . tab [ property ] ;
2277+ if ( property in this . raw )
2278+ fullExportedTab [ property ] = this . raw [ property ] ;
22782279 }
22792280
22802281 if ( configs . cacheAPITreeItems )
@@ -2384,10 +2385,17 @@ Tab.isTracked = tabId => {
23842385 return TabsStore . tabs . has ( tabId ) ;
23852386} ;
23862387
2388+ Tab . isNativeTabGroup = tabOrGroup => typeof tabOrGroup ?. color !== 'undefined' ;
2389+
23872390Tab . get = tabId => {
2391+ if ( Tab . isNativeTabGroup ( tabId ) ) {
2392+ return Tab . getNativeTabGroup ( { windowId : tabId . windowId , groupId : tabId . id } ) ;
2393+ }
23882394 return TabsStore . tabs . get ( typeof tabId == 'number' ? tabId : tabId ?. id ) ;
23892395} ;
23902396
2397+ Tab . getNativeTabGroup = ( { windowId, groupId } ) => TabsStore . windows . get ( windowId ) . tabGroups . get ( groupId ) ;
2398+
23912399Tab . getByUniqueId = id => {
23922400 if ( ! id )
23932401 return null ;
0 commit comments