Skip to content

Conversation

@skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Dec 16, 2022

This PR is closely related to my other PR, #7359. There is significant overlap between them and merging one will cause conflicts for the other.

Vue 3 unintentionally introduced the ability to use the shorthands :, @, # and . without an argument. For example, :="obj" is equivalent to v-bind="obj". This isn't documented and I believe support for this was intentionally avoided in Vue 2, e.g. when the # shorthand was introduced. It is just a little bit too magical having the attribute name as pure punctuation.

I've seen this used on Vue Land, so it definitely does happen in real applications.

The compiler currently doesn't use warnings, only errors. However, I felt an error would be too severe for the initial introduction of this check as it would prevent some applications from building. As it isn't documented it wouldn't technically be a breaking change, but an error would break real applications in practice. In future, once people have had chance to fix the warnings, we could maybe increase the severity to make it an error.

The warnings should be visible in the console for anyone using the SFC Playground or a browser-based compiler. For a standard Vite setup, the warning won't be shown in the browser, it'll only appear in the terminal running Vite.

SFC Playground example

Screenshot of Vite:

image

# Conflicts:
#	packages/compiler-dom/src/errors.ts
#	packages/compiler-ssr/src/errors.ts
@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.5 kB 34 kB 30.7 kB
vue.global.prod.js 146 kB 53.3 kB 47.6 kB (-17 B)

Usages

Name Size Gzip Brotli
createApp 49.8 kB 19.5 kB 17.8 kB
createSSRApp 53.2 kB 20.8 kB 19 kB
defineCustomElement 52.1 kB 20.3 kB 18.5 kB
overall 63.3 kB 24.4 kB 22.2 kB

# Conflicts:
#	packages/compiler-core/src/parse.ts
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 13, 2023

CodSpeed Performance Report

Merging #7360 will not alter performance

Comparing skirtles-code:warn-shorthand-no-argument (7d48125) with main (a6503e3)

Summary

✅ 53 untouched benchmarks

# Conflicts:
#	packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap
#	packages/compiler-core/__tests__/parse.spec.ts
#	packages/compiler-core/src/errors.ts
#	packages/compiler-core/src/parse.ts
#	packages/compiler-dom/src/errors.ts
#	packages/compiler-ssr/src/errors.ts
@edison1105 edison1105 added scope: compiler 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready for review This PR requires more reviews scope: compiler

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants