-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[compiler-sfc] inconsistent behavior with vue2 when parsing empty blocks #2463
Comments
This was referenced Oct 22, 2020
meteorlxy
added a commit
to meteorlxy/vue-next
that referenced
this issue
Oct 23, 2020
Another edge case as brought up by @znck: no |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.2
Reproduction link
https://codesandbox.io/s/autumn-wildflower-cqpew?file=/src/index.ts
Steps to reproduce
What is expected?
Consistent with vue2, get the descriptor of empty block.
What is actually happening?
The descriptor of empty block is
null
.Related issues
Explanation
It seems to be intended as the tests show:
https://github.com/vuejs/vue-next/blob/f4621ff5ee4abe924d985177956af3ddc9bb378f/packages/compiler-sfc/__tests__/parse.spec.ts#L114-L119
However, it may cause some breakings in SFC:
<template>
block means it should render empty string, which is different from no<template>
block.@vue/compiler-sfc
returnnull
for empty<template>
, it's difficult forvue-loader
/rollup-plugin-vue
to determine if the SFC has<template>
block or not.In fact, the only difference is a runtime warning during development:
https://github.com/vuejs/vue-next/blob/288c764e5279ccef63e0ef304d4250f5ad935a46/packages/runtime-core/src/component.ts#L711
IMO:
<template>
block is intended by user, which should not be warned.<template>
block might be a fault, which should be warned.Questions / Discussion
As we do not have a full specification for vue SFC, some edge cases are not so specific, and the behavior of
vue-loader
/rollup-plugin-vue
/ other implementations can be inconsistent.Here are some edge cases that might need to be determined:
Case A: SFC has both
<template>
andscript.render
:Which is expected?
script.render
with<template>
script.render
Case B: SFC has empty
<template>
andscript.render
:Which is expected?
script.render
with empty<template>
script.render
Case C: SFC has empty
<template>
, but does not havescript.render
:Which is expected?
script.render
with empty<template>
script.render
with a NOOP as default renderundefined
(will print a runtime warning)Case D: SFC does not have
<template>
norscript.render
:Which is expected?
script.render
with a NOOP as default renderundefined
(will print a runtime warning)@yyx990803 @sodatea @znck
The text was updated successfully, but these errors were encountered: