Skip to content

Differences in rendering .mjs files vs .html files #123

@sjorsrijsdam

Description

@sjorsrijsdam

Rendering a page from an .html files results in a different HTML output than rendering a page from an .mjs template file with that doesn't use the store.

Problem

The problem is that this makes for an inconsistent author experience and complicates page level styling as there is an extra layer that is sometimes there that they then may or may not have to deal with.

Current situation

Rendering from .mjs

// api/test.mjs
export function get () {
    return {
        'json': {},
    };
}
// pages/test.mjs
export default function test () {
    return html`
        <h1>This is a title</h1>
    `;
}

Results in:

<body>
    <page-test>
        <h1>This is a title</h1>
    </page-test>
</body>

Rendering from .html

<!-- pages/test.html -->
<h1>This is a title</h1>

Results in:

<body>
    <h1>This is a title</h1>
</body>

Desired situation

At the very least, both situations should result in the same output so authors have a predictable output where they can apply styling to.
The most desired situation is that .mjs files are rendered like the .html files without the wrapper element so the framework is as little in the way as possible and authors can decide if they want a wrapper element, and if so what its signature is.
If a wrapper element is needed, changing the signature from <page-test> to something like <enhance-page route="test"> is preferable. That way there is a predictable element name that can be targeted with CSS and is easier queryable for folks that want JS access for some reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions