vrimar / construct-ui

A Mithril.js UI library
https://vrimar.github.io/construct-ui
MIT License
287 stars 24 forks source link

HTML tags in ListItem labels strip surrounding spaces #20

Closed angrytongan closed 4 years ago

angrytongan commented 4 years ago

Placing HTML tags in ListItem labels strips the surrounding spaces. Latest Chrome on Mac OS X on 1.0.0 branch.

const {
    List,
    ListItem

} = CUI;

const FormattingListItems = () => {
    const items = [
        '<strong>one</strong> two three <strong>four</strong> five',
        '<u>one</u> two three <u>four</u> five',
        '<i>one</i> two three <i>four</i> five',
    ];

    return {
        view: () => {
            return m(List, items.map((l) => m(ListItem, { label: m.trust(l) })));
        },
    };
};

document.addEventListener('DOMContentLoaded', () => {
    m.route(document.body, '/', {
        '/': FormattingListItems
    });
});

Screen Shot 2020-03-19 at 9 43 35 pm

vrimar commented 4 years ago

Looks like an issue with display: flex on the .cui-list-item div. You could wrap each label in a div to mitigate this.

m(List, items.map((l) => m(ListItem, { label: m('', m.trust(l)) })));