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

custom-element: adding attributes without props #5326

Closed
gnuletik opened this issue Jan 25, 2022 · 1 comment
Closed

custom-element: adding attributes without props #5326

gnuletik opened this issue Jan 25, 2022 · 1 comment
Labels
🐞 bug Something isn't working scope: custom elements

Comments

@gnuletik
Copy link

gnuletik commented Jan 25, 2022

Version

3.2.29

Reproduction link

stackblitz.com

Steps to reproduce

<!-- index.html -->
<html>
  <body>
    <my-custom-element class="my-class"></my-custom-element>
    <script src="./main.ts"></script>
  </body>
</html>
// main.ts
import { defineCustomElement } from 'vue'
import MyCustomElement from './MyCustomElement.vue'

customElements.define('my-custom-element' defineCustomElement(MyCustomElement))
<!-- MyCustomElement.vue -->
<template>
  <p>hi !</p>
</template>

What is expected?

The component should mount.

The extra class attribute should not be used by the component as no props is declared.

What is actually happening?

Custom element doesn't load

Uncaught TypeError: Cannot read properties of undefined (reading 'class')
    at resolve2 (runtime-dom.esm-bundler.js:544:33)
    at VueCustomElement._resolveDef (runtime-dom.esm-bundler.js:579:13)
    at VueCustomElement.connectedCallback (runtime-dom.esm-bundler.js:506:18)
    at main.ts:4:16

Note: When adding a && props check here :

it works as expected.

gnuletik added a commit to gnuletik/vue-next that referenced this issue Jan 25, 2022
@LinusBorg LinusBorg added scope: custom elements 🐞 bug Something isn't working labels Jan 25, 2022
@ygj6
Copy link
Member

ygj6 commented Jan 26, 2022

I think it's a duplicate of #5280.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working scope: custom elements
Projects
None yet
Development

No branches or pull requests

3 participants