forked from mystiq/hydrogen-web
Remove unneded attribute objects
This commit is contained in:
parent
900ebfe289
commit
996d0cfea8
1 changed files with 13 additions and 13 deletions
|
@ -40,12 +40,12 @@ export class TextMessageView extends BaseMessageView {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderList(listBlock) {
|
function renderList(listBlock) {
|
||||||
const items = listBlock.items.map(item => tag.li({}, renderParts(item)));
|
const items = listBlock.items.map(item => tag.li(renderParts(item)));
|
||||||
const start = listBlock.startOffset;
|
const start = listBlock.startOffset;
|
||||||
if (start) {
|
if (start) {
|
||||||
return tag.ol({ start }, items);
|
return tag.ol({ start }, items);
|
||||||
} else {
|
} else {
|
||||||
return tag.ul({}, items);
|
return tag.ul(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ function renderImage(imagePart) {
|
||||||
imagePart.alt && { alt: imagePart.alt },
|
imagePart.alt && { alt: imagePart.alt },
|
||||||
imagePart.title && { title: imagePart.title }
|
imagePart.title && { title: imagePart.title }
|
||||||
);
|
);
|
||||||
return tag.img(attributes, []);
|
return tag.img(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderPill(pillPart) {
|
function renderPill(pillPart) {
|
||||||
|
@ -75,30 +75,30 @@ function renderTable(tablePart) {
|
||||||
const children = [];
|
const children = [];
|
||||||
if (tablePart.head) {
|
if (tablePart.head) {
|
||||||
const headers = tablePart.head
|
const headers = tablePart.head
|
||||||
.map(cell => tag.th({}, renderParts(cell)));
|
.map(cell => tag.th(renderParts(cell)));
|
||||||
children.push(tag.thead({}, tag.tr({}, headers)))
|
children.push(tag.thead(tag.tr(headers)))
|
||||||
}
|
}
|
||||||
const rows = [];
|
const rows = [];
|
||||||
for (const row of tablePart.body) {
|
for (const row of tablePart.body) {
|
||||||
const data = row.map(cell => tag.td({}, renderParts(cell)));
|
const data = row.map(cell => tag.td(renderParts(cell)));
|
||||||
rows.push(tag.tr({}, data));
|
rows.push(tag.tr(data));
|
||||||
}
|
}
|
||||||
children.push(tag.tbody({}, rows));
|
children.push(tag.tbody(rows));
|
||||||
return tag.table({}, children);
|
return tag.table(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map from part to function that outputs DOM for the part
|
* Map from part to function that outputs DOM for the part
|
||||||
*/
|
*/
|
||||||
const formatFunction = {
|
const formatFunction = {
|
||||||
header: headerBlock => tag["h" + Math.min(6,headerBlock.level)]({}, renderParts(headerBlock.inlines)),
|
header: headerBlock => tag["h" + Math.min(6,headerBlock.level)](renderParts(headerBlock.inlines)),
|
||||||
codeblock: codeBlock => tag.pre({}, tag.code({}, text(codeBlock.text))),
|
codeblock: codeBlock => tag.pre(tag.code(text(codeBlock.text))),
|
||||||
table: tableBlock => renderTable(tableBlock),
|
table: tableBlock => renderTable(tableBlock),
|
||||||
code: codePart => tag.code({}, text(codePart.text)),
|
code: codePart => tag.code(text(codePart.text)),
|
||||||
text: textPart => text(textPart.text),
|
text: textPart => text(textPart.text),
|
||||||
link: linkPart => tag.a({href: linkPart.url, className: "link", target: "_blank", rel: "noopener" }, renderParts(linkPart.inlines)),
|
link: linkPart => tag.a({href: linkPart.url, className: "link", target: "_blank", rel: "noopener" }, renderParts(linkPart.inlines)),
|
||||||
pill: renderPill,
|
pill: renderPill,
|
||||||
format: formatPart => tag[formatPart.format]({}, renderParts(formatPart.children)),
|
format: formatPart => tag[formatPart.format](renderParts(formatPart.children)),
|
||||||
list: renderList,
|
list: renderList,
|
||||||
image: renderImage,
|
image: renderImage,
|
||||||
newline: () => tag.br()
|
newline: () => tag.br()
|
||||||
|
|
Loading…
Reference in a new issue