obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

dv.el("hr") should not have children

Open ShahriarKh opened this issue 3 years ago • 3 comments
trafficstars

What happened?

dv.el("hr") ouputs:

<hr>
    <span>-</span>
</hr>

This can be fixed by dv.el("hr", ""). However, void elements like hr shouldn't have child elements. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr

DQL

No response

JS

No response

Dataview Version

0.5.47

Obsidian Version

1.0.3

OS

Windows

ShahriarKh avatar Nov 04 '22 14:11 ShahriarKh

dv.el is not a very good abstraction generally; I am currently considering replacing it with react-hyperscript, which offers shorthand for making virtual react doms for rendering.

blacksmithgu avatar Nov 05 '22 00:11 blacksmithgu

Creating with dv.el is going to add a span which should not exist image image

Beipy avatar Sep 15 '23 05:09 Beipy

It would be nice to pass "null" as second argument to omit the . E.g.

const table = dv.el("table");
const thead = dv.el("thead", null, {container: table})
const trh = dv.el("tr", null, {container:thead})
dv.el("th", "test1", {container:trh})
dv.el("th", "test2", {container:trh})
dv.el("th", "test3", {container:trh})
const tbody = dv.el("tbody", null, {container:table})
const trb = dv.el("tr", null, {container: tbody})
dv.el("td", "1", {container:trb})
dv.el("td", "1", {container:trb})
dv.el("td", "1", {container:trb})

CodeAndWeb avatar Apr 21 '25 20:04 CodeAndWeb