Skip to content

[lexical-list] Bug Fix: DOMImportExtension list normalization uses ListNode.createListItemNode() - #9002

Closed
LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:list-import-createlistitemnode
Closed

LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:list-import-createlistitemnode

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Description

ListNode.createListItemNode() was added in #8427 ("Add the
createListItemNode method to the ListNode and use it for children
normalization") precisely so a ListNode subclass controls the item type its
normalization synthesizes. The legacy converter honours it —
$normalizeChildren does listNode.createListItemNode.bind(listNode) — and
so does ListNode.splice.

The DOMImportExtension port of that normalization,
$normalizeListChildren in ListImportExtension, does not: it calls the
module-level $createListItemNode() instead, so a subclassed list imported
through the new pipeline gets plain ListItemNode wrappers for both of its
synthesized-item cases (a nested list lifted into a sibling item, and a
non-item child wrapped into one). The two implementations of the same
normalization disagree.

This threads the ListNode being built into $normalizeListChildren and
uses listNode.createListItemNode(), matching $normalizeChildren. The
default ListNode.createListItemNode() returns $createListItemNode(), so
nothing changes for unsubclassed lists.

Test plan

npx vitest run packages/lexical-list/src/__tests__/unit/ListImportExtension.test.ts

Before

 FAIL  |unit| packages/lexical-list/src/__tests__/unit/ListImportExtension.test.ts > ListImportExtension > wrapper items come from ListNode.createListItemNode()
AssertionError: expected 'listitem' to be 'custom-listitem' // Object.is equality

Expected: "custom-listitem"
Received: "listitem"

 Test Files  1 failed (1)
      Tests  1 failed | 11 passed (12)

After

 Test Files  1 passed (1)
      Tests  12 passed (12)

npx vitest run packages/lexical-list is green (10 files, 126 tests).

…stNode.createListItemNode()

## Description

`ListNode.createListItemNode()` was added in meta#8427 ("Add the
`createListItemNode` method to the ListNode and use it for children
normalization") precisely so a `ListNode` subclass controls the item type its
normalization synthesizes. The legacy converter honours it —
`$normalizeChildren` does `listNode.createListItemNode.bind(listNode)` — and
so does `ListNode.splice`.

The `DOMImportExtension` port of that normalization,
`$normalizeListChildren` in `ListImportExtension`, does not: it calls the
module-level `$createListItemNode()` instead, so a subclassed list imported
through the new pipeline gets plain `ListItemNode` wrappers for both of its
synthesized-item cases (a nested list lifted into a sibling item, and a
non-item child wrapped into one). The two implementations of the same
normalization disagree.

This threads the `ListNode` being built into `$normalizeListChildren` and
uses `listNode.createListItemNode()`, matching `$normalizeChildren`. The
default `ListNode.createListItemNode()` returns `$createListItemNode()`, so
nothing changes for unsubclassed lists.

## Test plan

`npx vitest run packages/lexical-list/src/__tests__/unit/ListImportExtension.test.ts`

### Before

```
 FAIL  |unit| packages/lexical-list/src/__tests__/unit/ListImportExtension.test.ts > ListImportExtension > wrapper items come from ListNode.createListItemNode()
AssertionError: expected 'listitem' to be 'custom-listitem' // Object.is equality

Expected: "custom-listitem"
Received: "listitem"

 Test Files  1 failed (1)
      Tests  1 failed | 11 passed (12)
```

### After

```
 Test Files  1 passed (1)
      Tests  12 passed (12)
```

`npx vitest run packages/lexical-list` is green (10 files, 126 tests).
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 9, 2026
@LeSingh1

Copy link
Copy Markdown
Contributor Author

Consolidated into #9050 with the other PRs that share this defect, per @etrepum's note on #9027 and @mayrang's on #9035. Same fix and same tests, one review.

@LeSingh1 LeSingh1 closed this Aug 10, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant