Skip to content

Conversation

@rubennorte
Copy link
Contributor

Summary:

Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in 43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement MutationObserver and IntersectionObserver, but unfortunately EventEmitter/EventTarget only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with MutationObserver we intentionally want to have access to unmounted nodes when creating the list of addedNodes and removedNodes for the MutationRecord (depending on when exactly we generate this list, either addedNodes or removedNodes wouldn't be mounted).

Changes

This reverts my original change and adds a new field in ShadowNodeFamily to provide access to the InstanceHandle at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Differential Revision: D46149084

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels May 24, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request May 24, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Differential Revision: D46149084

fbshipit-source-id: 0871a15b16b3abb7ab6d695cce404d6d5598eea4
@analysis-bot
Copy link

analysis-bot commented May 24, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,747,161 +2,558
android hermes armeabi-v7a 8,059,769 +2,989
android hermes x86 9,238,769 +3,088
android hermes x86_64 9,088,583 +2,048
android jsc arm64-v8a 9,309,935 +2,558
android jsc armeabi-v7a 8,499,874 +2,981
android jsc x86 9,372,438 +3,101
android jsc x86_64 9,626,341 +2,055

Base commit: 108309e
Branch: main

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request May 25, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Differential Revision: D46149084

fbshipit-source-id: 703b2d6f9d3f9662cb83f2a7de5aea71fe7ca989
rubennorte added a commit to rubennorte/react-native that referenced this pull request May 25, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 62812beaff1160114bd3c401ca92833b3abfa8b0
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request May 26, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 3b00f4490ab26f557e99a314e704c3628095860a
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request May 26, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 12acb1b31c74174afe9506335307b2bfd59a918e
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request May 26, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: e0af3f829fbd545d000abf910c21c465bc16df2a
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 5, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 619d914485e6c99893091f9c6695606cf3a7a9e2
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 5, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 2f21e5e4327309a81ed3f7eae853d40187f13889
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 6, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: d39152061efa9d82bf63099f36cdeeb988f7d037
rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 6, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 91faf5dd5f5c1c349ead74e046a459f8ca8fd564
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 8, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: e1cfbfe69fba033cb3b11c08aa14164d2a53614a
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 8, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: aba3478b2c7751edf916b027014f0207daa934e7
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte added a commit to rubennorte/react-native that referenced this pull request Jun 8, 2023
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 97abed87fa87984c14a4d9683801b76e5fdd6c68
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

rubennorte and others added 3 commits June 8, 2023 10:16
…w node wrappers

Differential Revision: D46190383

fbshipit-source-id: 06e0354352d0f42559f4c899dbc8d8a27dfe108f
… new instances of ShadowNodeFamily

Differential Revision: D46190382

fbshipit-source-id: 485168423c3e60f94467e7b4b1c97182b4230e57
…vent emitters/targets (facebook#37553)

Summary:
Pull Request resolved: facebook#37553

## Context

I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in facebook@43864a1 (D44022477), so I could implement DOM traversal methods easily.

I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).

## Changes

This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).

This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D46149084

fbshipit-source-id: 7bb5be39a28188794d016befc9d27c178d67fd6c
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46149084

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 8, 2023
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 3250725.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants