docs icon indicating copy to clipboard operation
docs copied to clipboard

Vue does not perform 100% anymore at Web Components test

Open cimchd opened this issue 3 years ago • 4 comments
trafficstars

On this page: https://vuejs.org/guide/extras/web-components.html#using-custom-elements-in-vue it is said that vue performs 100% at Custom Elements Everywhere test. It seems that the test has changed now. 3 tests failed. Until vue comes back to 100% this line should probably be updated or removed.

cimchd avatar May 10 '22 05:05 cimchd

I think that, if we switch the tests from

<custom-ce v-on:CusTomCaSes="handler"/>

to

<custom-ce v-on="{ CusTomCaSes: handler }"/>

it may work.

I'll try it tomorrow.

If it works, I'll open a PR to the testing suite (so Vue can keep the 100% score). Either way, it's good to add the caveat somewhere in the Custom Elements section of the docs.

leopiccionia avatar May 10 '22 20:05 leopiccionia

Related: #1553

skirtles-code avatar May 11 '22 06:05 skirtles-code

I couldn't still make the tests run on my machine, by, looking at the code, it seems that the event names are indeed converted to camel-case (toHandlers call toHandlerKey), what may break some edge-cases.

A Vue RFC discussed escape hatches to solve this issue, but it seems to not have been implemented.

So I'm favorable, for now, to change the docs.

leopiccionia avatar May 12 '22 12:05 leopiccionia

@skirtles-code I think I'd be in favor of reflecting this current state of affairs in the docs, given that the workaround that I proposed to them is still in concideration but seems to be stuck.

We could reflect the actual current score in the docs and add a small section explaining the workarounds:

  1. adding the listeners for camelCase, PascalCase and CASPScase events imperatively with a template ref
  2. adding the listeners for camelCase, PascalCase and CASPScase events decaratively with a small custom directive:
app.directive('event', {
  beforeMount((el, { arg, value }) => {
    el.addEventListener(arg, value)
  }),
  unmounted((el, { arg, value }) => {
    el.removeEventListener(arg, value)
  })
}
<my-custom-el v-event:PascalCase="handleEvent">

That would of course also only work in build-time compilation as string compilation at runtime would lowercase the arg before the compiler processes it.

Thoughts?

LinusBorg avatar Jun 26 '22 10:06 LinusBorg