vuejs / rfcs

RFCs for substantial changes / feature additions to Vue core
4.87k stars 546 forks source link

Custom Elements Interop Improvements #149

Closed yyx990803 closed 4 years ago

yyx990803 commented 4 years ago

Full Rendered Proposal

backbone87 commented 4 years ago

just some thoughts:

(the ! meta char is up to debate)

pros:

con:

yyx990803 commented 4 years ago

@backbone87 we are not considering any drastic template syntax change at this point.

jods4 commented 4 years ago

The idea of <[comp]> as an additional syntax meant to replace <component :is=comp> feels very natural, though, considering the existing dynamic syntaxes. Could be an idea for 3.1! 💭

yyx990803 commented 4 years ago

<[comp]> is not valid HTML (it would be interpreted as plain text by native parsers) so that would not work for in-DOM templates. I'm afraid it's not an option.

jods4 commented 4 years ago

so are self-closing tags? They are really handy, I love them.

yyx990803 commented 4 years ago

@jods4 yeah, that's an exception for string-only templates (so are CamelCase components). We already have these special cases and it would be wise to avoid adding more, especially when you are not adding new capabilities.

backbone87 commented 4 years ago

I provided an expanded form, which the browser should be able to parse

leopiccionia commented 4 years ago

Would the following pattern be removed (guide)?

<table>
  <!-- CustomRow resolves to a function or object, not a string -->
  <tr :is="CustomRow">
    <td>1</td>
  </tr>
</table>

As of today, my evergreen browser still parses:

<table>
  <custom-row>
    <td>1</td>
  </custom-row>
</table>

Like the following:

<custom-row></custom-row>
<table>
  <tr>
    <td>1</td>
  </tr>
</table>
yyx990803 commented 4 years ago

@leopiccionia that's a good point. We should still support this case when is binding value is not a string. <- I think different behavior based on binding value can be confusing, especially when this means you have to expose the component directly to the render context instead of normally registering it.

Maybe we need to introduce a separate v-is directive for the in-DOM use cases:

<table>
  <tr v-is="CustomRow">
    <td>1</td>
  </tr>
</table>

And if the user registered CustomRow via the components option:

<table>
  <tr v-is="'CustomRow'">
    <td>1</td>
  </tr>
</table>
yyx990803 commented 4 years ago

This RFC is now in final comments stage. An RFC in final comments stage means that:

The core team has reviewed the feedback and reached consensus about the general direction of the RFC and believe that this RFC is a worthwhile addition to the framework. Final comments stage does not mean the RFC's design details are final - we may still tweak the details as we implement it and discover new technical insights or constraints. It may even be further adjusted based on user feedback after it lands in an alpha/beta release. If no major objections with solid supporting arguments have been presented after a week, the RFC will be merged and become an active RFC.