Subscribe on changes!

Props not inferred properly when using defineCustomElement

avatar
Sep 15th 2021

Version

3.2.6

Reproduction link

codesandbox.io

Steps to reproduce

  1. Define props in a file called App.ce.vue
const props = defineProps({
  shouldbestring: {
    required: true,
    type: String,
  }
});
  1. Create a component in DOM like this:
<custom-element shouldbestring="7e8dfe0e-eb4c-4615-a8da-2f150faaef8e"></custom-element>

The output of props.shouldbestring is number 70000.

What is expected?

The prop value should be "7e8dfe0e-eb4c-4615-a8da-2f150faaef8e"

What is actually happening?

The prop value is 70000.

avatar
Sep 15th 2021

It's an edge case.

parseFloat('7e8') === 7e8 (i.e. 7 × 10⁸).

avatar
Sep 16th 2021

It's an edge case.

parseFloat('7e8') === 7e8 (i.e. 7 × 10⁸).

Wow, thanks for noticing!

avatar
Sep 17th 2021

Anyway, since 0cfa2112ce2210300cf2edf272c8c8d11b9355e4 commit, Vue won't try to convert String props to number.