Skip to content

Commit

Permalink
Remove component.base
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Nov 10, 2024
1 parent abf813b commit be7f9cd
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 751 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- https://github.com/preactjs/preact/pull/4460
- https://github.com/preactjs/preact/pull/4453
- Backing VNodes
- Remove deprecated lifecycle methods
- Try to get rid of DOM pointers
- Separate mount/update paths
- Rethink TypeScript types
Expand Down
3 changes: 2 additions & 1 deletion compat/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ function unmountComponentAtNode(container) {
function findDOMNode(component) {
return (
(component &&
(component.base || (component.nodeType === 1 && component))) ||
((component._vnode && component._vnode._dom) ||
(component.nodeType === 1 && component))) ||
null
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ function renderComponent(component) {
*/
function updateParentDomPointers(vnode) {
if ((vnode = vnode._parent) != null && vnode._component != null) {
vnode._dom = vnode._component.base = null;
vnode._dom = null;
for (let i = 0; i < vnode._children.length; i++) {
let child = vnode._children[i];
if (child != null && child._dom != null) {
vnode._dom = vnode._component.base = child._dom;
vnode._dom = child._dom;
break;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ export function diff(
refQueue
);

c.base = newVNode._dom;

// We successfully rendered this VNode, unset any stored hydration/bailout state:
newVNode._flags &= RESET_MODE;

Expand Down Expand Up @@ -607,7 +605,7 @@ export function unmount(vnode, parentVNode, skipRemove) {
}
}

r.base = r._parentDom = null;
r._parentDom = null;
}

if ((r = vnode._children)) {
Expand Down
1 change: 0 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export abstract class Component<P, S> {
state: Readonly<S>;
props: RenderableProps<P>;
context: any;
base?: Element | Text;

// From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e836acc75a78cf0655b5dfdbe81d69fdd4d8a252/types/react/index.d.ts#L402
// // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
Expand Down
1 change: 0 additions & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ declare global {
// When component is functional component, this is reset to functional component
constructor: ComponentType<P>;
state: S; // Override Component["state"] to not be readonly for internal use, specifically Hooks
base?: PreactElement;

_dirty: boolean;
_force?: boolean;
Expand Down
Loading

0 comments on commit be7f9cd

Please sign in to comment.