react-component-instance 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-component-instance",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Get a React class component instance from its DOM Element",
5
5
  "keywords": [
6
6
  "react",
@@ -137,41 +137,41 @@ export function getContainerFiberFrom (element) {
137
137
  }
138
138
 
139
139
  /**
140
- * @param {FiberNode} fiber
141
- * @returns {FiberNode | null | undefined}
140
+ * @param {FiberNode} fiber
141
+ * @returns {FiberNode | null | undefined}
142
142
  */
143
143
  export function getParentFiber ({ return: parentFiber }) {
144
144
  return parentFiber
145
145
  }
146
146
 
147
147
  /**
148
- * @param {FiberNode} fiber
149
- * @returns {FiberNode | null | undefined}
148
+ * @param {FiberNode} fiber
149
+ * @returns {FiberNode | null | undefined}
150
150
  */
151
151
  export function getChildFiber ({ child: childFiber }) {
152
152
  return childFiber
153
153
  }
154
154
 
155
155
  /**
156
- * @param {FiberNode} fiber
157
- * @returns {React.Component<any, any, any> | HTMLElement | Text | null}
156
+ * @param {FiberNode} fiber
157
+ * @returns {React.Component<any, any, any> | HTMLElement | Text | null}
158
158
  */
159
159
  export function getComponentInstance ({ stateNode: instance }) {
160
160
  return instance
161
161
  }
162
162
 
163
163
  /**
164
- * @param {(() => React.JSX.Element) | typeof React.Component} Component
165
- * @param {FiberNode} fiber
166
- * @returns {boolean}
164
+ * @param {(() => React.JSX.Element) | typeof React.Component} Component
165
+ * @param {FiberNode} fiber
166
+ * @returns {boolean}
167
167
  */
168
168
  export function isComponentType (Component, { type }) {
169
169
  return Component === type
170
170
  }
171
171
 
172
172
  /**
173
- * @param {(() => React.JSX.Element) | typeof React.Component} Component
174
- * @returns {(fiber: FiberNode) => boolean}
173
+ * @param {(() => React.JSX.Element) | typeof React.Component} Component
174
+ * @returns {(fiber: FiberNode) => boolean}
175
175
  */
176
176
  export function getIsComponentType (Component) {
177
177
  return function isComponentType ({ type }) {
@@ -20,6 +20,16 @@ export function getContainerFiberNodeFrom (container) {
20
20
  throw new Error('Container is not an Element')
21
21
  }
22
22
 
23
+ /**
24
+ * @param {{ container: Element }} component
25
+ * @returns {Element}
26
+ */
27
+ export function getComponentElement ({
28
+ container
29
+ }) {
30
+ return container
31
+ }
32
+
23
33
  /**
24
34
  * @param {Element | null | undefined} container
25
35
  * @returns {React.Component<any, any, any> | HTMLElement | Text | null}
package/src/index.mjs CHANGED
@@ -86,6 +86,18 @@ export function getChildFiberNodeFrom (element) {
86
86
  throw new Error('Element is not an Element')
87
87
  }
88
88
 
89
+ /**
90
+ * @param {{ container: { firstElementChild: Element | null } }} component
91
+ * @returns {Element | null}
92
+ */
93
+ export function getComponentElement ({
94
+ container: {
95
+ firstElementChild: element
96
+ }
97
+ }) {
98
+ return element
99
+ }
100
+
89
101
  /**
90
102
  * @param {Element | null | undefined} element
91
103
  * @returns {React.Component<any, any, any> | HTMLElement | Text | null}