Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type:"html" #165

Closed
Nashorn opened this issue Oct 11, 2024 · 2 comments
Closed

type:"html" #165

Nashorn opened this issue Oct 11, 2024 · 2 comments

Comments

@Nashorn
Copy link

Nashorn commented Oct 11, 2024

Why not allow this?

@nicolo-ribaudo
Copy link
Member

This proposal only defines the syntax space, but then the various attributes (such as type: "json", or type: "css") are defined elsewhere. Given that HTML is not a JS concept, probably the best place to discuss it would be https://github.com/whatwg/html/, which is also where type: "css" is defined.

However, please write an actual motivation for what you want it to behave like, and why you need it. You will need to convince two browser vendors that it's worth to implement it :)

@nicolo-ribaudo nicolo-ribaudo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2024
@edbaafi
Copy link

edbaafi commented Feb 21, 2025

@Nashorn - I couldn't find if you raised the issue elsewhere. @nicolo-ribaudo - Thanks for the suggestion. It seems there is a related (and still open) question from 2017 here: WICG/webcomponents#645. I will raise this there.

re:

actual motivation for what you want it to behave like, and why you need it.

This would align nicely with the current use case for css module scripts. Instead of constructing a CSSStyleSheet from the .css file, this should construct an HTMLTemplateElement. The imported template could be used like this:

import styleSheet from './custom-element.css' with {type: 'css'};
import template from './custom-element.html' with {type: 'html'};

export class CustomElement extends HTMLElement {

    #shadowRoot;

    constructor() {
        super();
        this.#shadowRoot = this.attachShadow({ mode: 'closed' });
        this.#shadowRoot.adoptedStyleSheets = [styleSheet];
        this.#shadowRoot.appendChild(template.content.cloneNode(true));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants