Unable to add nested elements #1

Closed
opened 2021-02-08 17:13:14 +01:00 by etherbob · 4 comments
etherbob commented 2021-02-08 17:13:14 +01:00 (Migrated from github.com)

My apologies if I've misread the docs, but I would expect crel('p', {}, ['strong', {}, 'hello']) to return <p><strong>hello</strong></p> similar to prosemirror's toDOM spec. Instead I get RangeError: Unsupported child node: [object Object].

My apologies if I've misread the docs, but I would expect `crel('p', {}, ['strong', {}, 'hello'])` to return `<p><strong>hello</strong></p>` similar to prosemirror's toDOM spec. Instead I get `RangeError: Unsupported child node: [object Object]`.
marijnh commented 2021-02-08 17:18:07 +01:00 (Migrated from github.com)

That's not how the library works. You want [crel("strong", "hello")], not the arguments as an array.

That's not how the library works. You want `[crel("strong", "hello")]`, not the arguments as an array.
etherbob commented 2021-02-08 17:37:42 +01:00 (Migrated from github.com)

I figured that part out, but the docs and my prior use of Prosemirror seemed to imply the above could work as well. Thank you for clarifying. Would you be open to a Read Me PR if I can think of a decent one?

I figured that part out, but the docs and my prior use of Prosemirror seemed to imply the above could work as well. Thank you for clarifying. Would you be open to a Read Me PR if I can think of a decent one?
marijnh commented 2021-02-08 17:40:24 +01:00 (Migrated from github.com)

The readme states that for array arguments, each element is added separately. I don't think that implies that you can do what you're doing above.

The readme states that for array arguments, each element is added separately. I don't think that implies that you can do what you're doing above.
etherbob commented 2021-02-08 17:44:14 +01:00 (Migrated from github.com)

That was actually the part that made me think that crel would operate on arrays like nested arguments, but I appreciate that it was my misunderstanding. I very much enjoy this sublimely lightweight, useful tool.

That was actually the part that made me think that crel would operate on arrays like nested arguments, but I appreciate that it was my misunderstanding. I very much enjoy this sublimely lightweight, useful tool.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marijn/crelt#1
No description provided.