Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-plants-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/react": patch
---

Refactor: Improved naming for list operation related types. Renamed `UpdateAction` interface to `ListOperations`.
28 changes: 18 additions & 10 deletions packages/react/runtime/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ export interface ListUpdateInfo {
onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
}

interface InsertAction {
position: number;
type: string;
}

interface UpdateAction {
insertAction: {
position: number;
type: string;
}[];
from: number;
to: number;
type: string;
flush: boolean;
}

interface ListOperations {
insertAction: InsertAction[];
removeAction: number[];
// TODO: type `updateAction`
updateAction: any[];
updateAction: UpdateAction[];
}

// class ListUpdateInfoDiffing implements ListUpdateInfo {
Expand Down Expand Up @@ -115,12 +123,12 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
this.platformInfoUpdate.set(child, attr);
}

private __toAttribute(): UpdateAction {
private __toAttribute(): ListOperations {
const { removeChild, insertBefore, appendChild, platformInfoUpdate } = this;

const removals: number[] = [];
const insertions: { position: number; type: string }[] = [];
const updates: any[] = [];
const insertions: InsertAction[] = [];
const updates: UpdateAction[] = [];

let j = 0;
for (let i = 0; i < this.oldChildNodes.length; i++, j++) {
Expand Down Expand Up @@ -199,7 +207,7 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
};
}

toJSON(): [UpdateAction] {
toJSON(): [ListOperations] {
// if (this.__pendingAttributes) {
// return [...this.__pendingAttributes, this.__toAttribute()];
// } else {
Expand Down
Loading