File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ declare namespace preact {
2727 getDerivedStateFromError ?( error : any ) : Partial < S > | null ;
2828 }
2929
30- // eslint-disablex -next-line @typescript-eslint/no-unsafe-declaration-merging
30+ // eslint-disable -next-line @typescript-eslint/no-unsafe-declaration-merging
3131 export interface Component < P = { } , S = { } > {
3232 componentWillMount ?( ) : void ;
3333 componentDidMount ?( ) : void ;
Original file line number Diff line number Diff line change @@ -40,10 +40,12 @@ let renderStack = [];
4040 * ```
4141 *
4242 * Note: A `vnode` may be hoisted to the root scope due to compiler
43- * optimiztions. In these cases the `_owner` will be different.
43+ * optimiztions. In these cases the owner will be different.
4444 */
4545let ownerStack = [ ] ;
4646
47+ const ownerMap = new WeakMap ( ) ;
48+
4749/**
4850 * Get the currently rendered `vnode`
4951 * @returns {import('./internal').VNode | null }
@@ -76,9 +78,8 @@ function isPossibleOwner(vnode) {
7678export function getOwnerStack ( vnode ) {
7779 const stack = [ vnode ] ;
7880 let next = vnode ;
79- while ( next . _owner != null ) {
80- stack . push ( next . _owner ) ;
81- next = next . _owner ;
81+ while ( ( next = ownerMap . get ( next ) ) != null ) {
82+ stack . push ( next ) ;
8283 }
8384
8485 return stack . reduce ( ( acc , owner ) => {
@@ -131,8 +132,7 @@ export function setupComponentStack() {
131132 } ;
132133
133134 options . vnode = vnode => {
134- vnode . _owner =
135- ownerStack . length > 0 ? ownerStack [ ownerStack . length - 1 ] : null ;
135+ ownerMap . set ( vnode , ownerStack . length > 0 ? ownerStack [ ownerStack . length - 1 ] : null ) ;
136136 if ( oldVNode ) oldVNode ( vnode ) ;
137137 } ;
138138
You can’t perform that action at this time.
0 commit comments