Skip to content

Allow custom tag to extend existing tags #8903

Closed as not planned
Closed as not planned
@nosovk

Description

@nosovk

Describe the problem

I'm using custom elements to extend existing html templates. Common case is to add some new tags, like <my-video>, <my-menu> etc.
Unfortunately those tags does not play good with SEO.
In custom elements specification mentioned that extend of new tag registration we can extend existing one.

Describe the proposed solution

add additional property to customElement configuration. Like:

<svelte:options  customElement={{
    tag: 'my-video',
    extends: 'video',
    baseClass: HTMLVideoElement,
    props: {
      name: { reflect: true, type: 'String', attribute: 'src' }
    }
  }}>
<script>
export let src; // here we will get src tag from html
</script>
<video {src} /> // and render own video tag inside custom component.

Where in element we specify which tag we want to extend.
Then we can use the resulting component as <video as="my-video" src="https://video.mp4">

Alternatives considered

customElements.define("my-video", Video, { extends: "video" });

didn't work,
because with tags like video we must create Video as

class Video extends HTMLVideoElement

Which is currently not possible in svelte.

Importance

would make my life easier

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