Skip to content

mojave/manipulate/createElement: Can’t create all elements using HTML strings #62

@mangoischke

Description

@mangoischke

I tried to create a table with some data out of an array as I came across this bug.
If I try to create an element with the createElement function with an HTML string as a parameter, the return value is undefined:

const element = createElement(`<tr class="className"></tr>`);

After some debugging I found out, that this is because of the pareHtml function, which is called in the createElement function if an HTML string is given as a parameter.

So I ran through a list of HTML-tags to find out which elements can't be created as well and came up with a list of HTML elements/tags, which can't be created by the parseHtml function:

"<body></body>", 
"<caption></caption>", 
"<col>", 
"<colgroup></colgroup>", 
"<frame>", 
"<frameset></frameset>",
"<head></head>", 
"<html></html>", 
"<tbody></tbody>", 
"<td></td>", 
"<tfoot></tfoot>", 
"<th></th>", 
"<thead></thead>", 
"<tr></tr>",

This is probably because of the way the functions creates the element. The aforementioned tags shouldn't be placed directly in the body element, which is likely the reason why they don't appear in the children array.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions