Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List Recursor Continues to Execute on Empty Nested item.items Array #53

Open
Luzefiru opened this issue Mar 21, 2024 · 0 comments · May be fixed by #54
Open

List Recursor Continues to Execute on Empty Nested item.items Array #53

Luzefiru opened this issue Mar 21, 2024 · 0 comments · May be fixed by #54

Comments

@Luzefiru
Copy link

The Problem

Looking at the clean data of a list using the @editorjs/nested-list plugin, it seems that each item[*] child has an item[*].items automatically added to it, but with no items [].

The current transformers.ts code found here checks if (item.items) before calling the recursor() function. An empty array [] in JavaScript is evaluated to true, making the recursor basically parse nothing and return `<${listStyle}>${list.join("")}</${listStyle}>.

Possible Fix

Ensure that the item.items array is not empty before calling the recursor. Like so:

if (item.items.length) list = recursor(item.items, listStyle);

Current Output

Currently, when you make a single @editorjs/nested-list with text content, it creates a duplicate empty <${listStyle}></${listStyle}> pair before the closing </${listStyle}> tag.

This leads to outputted markup looking like this <${listStyle}> ${content} <${listStyle}></${listStyle}></${listStyle}>.

See this demo:
image

Expected Output

Using the same input should only output <${listStyle}> ${content} </${listStyle}>. After applying the possible fix mentioned previously, this is the new output.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant