@@ -37,6 +37,8 @@ import {
3737 initRouterMode ,
3838} from './sandbox/router'
3939
40+ const SECONDARY_CONTAINER_ATTRIBUTE = 'secondary-container'
41+
4042/**
4143 * define element
4244 * @param tagName element name
@@ -47,6 +49,10 @@ export function defineElement (tagName: string): void {
4749 return [ 'name' , 'url' ]
4850 }
4951
52+ static get SECONDARY_CONTAINER_ATTRIBUTE ( ) : string {
53+ return SECONDARY_CONTAINER_ATTRIBUTE
54+ }
55+
5056 private isWaiting = false
5157 private cacheData : Record < PropertyKey , unknown > | null = null
5258 private connectedCount = 0
@@ -68,6 +74,8 @@ export function defineElement (tagName: string): void {
6874 // keep-alive: open keep-alive mode
6975
7076 public connectedCallback ( ) : void {
77+ if ( this . hasAttribute ( SECONDARY_CONTAINER_ATTRIBUTE ) ) return
78+
7179 /**
7280 * In FireFox, iframe Node.prototype will point to native Node.prototype after insert to document
7381 * If <micro-app>.prototype is not MicroAppElement.prototype, we should reset it
@@ -100,6 +108,8 @@ export function defineElement (tagName: string): void {
100108 }
101109
102110 public disconnectedCallback ( ) : void {
111+ if ( this . hasAttribute ( SECONDARY_CONTAINER_ATTRIBUTE ) ) return
112+
103113 this . connectStateMap . set ( this . connectedCount , false )
104114 this . handleDisconnected ( )
105115 }
@@ -140,6 +150,9 @@ export function defineElement (tagName: string): void {
140150 }
141151
142152 public attributeChangedCallback ( attr : ObservedAttrName , _oldVal : string , newVal : string ) : void {
153+ if ( ( attr as string ) === SECONDARY_CONTAINER_ATTRIBUTE ) return
154+ if ( this . hasAttribute ( SECONDARY_CONTAINER_ATTRIBUTE ) ) return
155+
143156 if (
144157 this . legalAttribute ( attr , newVal ) &&
145158 this [ attr === ObservedAttrName . NAME ? 'appName' : 'appUrl' ] !== newVal
@@ -194,6 +207,8 @@ export function defineElement (tagName: string): void {
194207 * first mount of this app
195208 */
196209 private handleConnected ( ) : void {
210+ if ( this . hasAttribute ( SECONDARY_CONTAINER_ATTRIBUTE ) ) return
211+
197212 if ( ! this . appName || ! this . appUrl ) return
198213
199214 if ( this . getDisposeResult ( 'shadowDOM' ) && ! this . shadowRoot && isFunction ( this . attachShadow ) ) {
0 commit comments