@@ -18,12 +18,6 @@ export type MaybeNodeDraft<
18
18
D extends NodeDraft = NodeDraft ,
19
19
> = N | D
20
20
21
- function unenumerable ( obj : any , key : string | symbol ) {
22
- Object . defineProperty ( obj , key , {
23
- enumerable : false ,
24
- } )
25
- }
26
-
27
21
type Constructor < T > = new ( ref : NodeRef ) => T
28
22
29
23
export class NodeRef <
@@ -50,6 +44,8 @@ export class NodeRef<
50
44
throw new Error ( 'HydrationNode has already been resolved' )
51
45
}
52
46
; ( Object . keys ( this . ref ) as Array < keyof NodeDraft > ) . forEach ( key => {
47
+ if ( DraftSkippedKeys . has ( key as string ) ) return
48
+
53
49
const newValue = this . draft ! [ key ]
54
50
const oldValue = theRef [ key ]
55
51
if ( newValue !== oldValue ) {
@@ -61,16 +57,18 @@ export class NodeRef<
61
57
}
62
58
}
63
59
60
+ const DraftSkippedKeys = new Set ( [
61
+ '__v_nodeRef' ,
62
+ '__v_parentNode' ,
63
+ '__v_childNodes' ,
64
+ ] )
65
+
64
66
export class NodeDraft {
65
67
constructor (
66
68
private __v_nodeRef : NodeRef ,
67
69
private __v_childNodes : NodeRef < false > [ ] = [ ] ,
68
70
private __v_parentNode : NodeRef < false , ParentNode > | null = null ,
69
- ) {
70
- unenumerable ( this , '__v_nodeRef' )
71
- unenumerable ( this , '__v_childNodes' )
72
- unenumerable ( this , '__v_parentNode' )
73
- }
71
+ ) { }
74
72
75
73
get parentNode ( ) : NodeRef < boolean , ParentNode > | null {
76
74
return this . __v_parentNode
@@ -184,7 +182,7 @@ export function nodeDraftPatch(
184
182
}
185
183
186
184
function _nodeDraftPatch (
187
- block : NodeRef [ ] ,
185
+ block : readonly NodeRef [ ] ,
188
186
parent : ParentNode ,
189
187
anchorIndex : number ,
190
188
) {
@@ -204,7 +202,9 @@ function _nodeDraftPatch(
204
202
const childNodes = nodeRef . ref . childNodes
205
203
if ( childNodes . length ) {
206
204
let $anchor = ( realNode as any ) . $anchor
207
- const theChildAnchorIndex = $anchor ? getNodeIndexOf ( parent , $anchor ) : 0
205
+ const theChildAnchorIndex = $anchor
206
+ ? getNodeIndexOf ( realNode as unknown as ParentNode , $anchor )
207
+ : 0
208
208
209
209
_nodeDraftPatch (
210
210
childNodes ,
0 commit comments