Performance improvements and type checking of additional properties of DOM nodes make the new Vue worth updating. The Vue team has really done a lot of work. In fact, they released two sub-versions on the same day. Vue 3.3.5
and 3.3.6
are both released on October 20, 2023.
WeakMaps
One of the improvements was the move from Maps
and Sets
to WeakMaps
and WeakSets
where possible.
What is that and why is it important?
If you store things in Maps
or Sets
, you will make a reference to those things. This means that as long as Map
or Set
is used, this thing will not be released from memory by the garbage collector.
Usually this makes sense. But sometimes not. Especially when you’re writing some code that’s just deep into the normal workflow of the data. For example, by adding diagnostic data to the data flowing through the system.
You want the data to be released when you need it, you don’t want to retain the right to retain the data.
This is where WeakMaps
and WeakSets
come into play, Vue now uses these more internally to prevent memory leaks and improve overall performance.
Support for contenteditable=”plaintext-only”
I think contenteditable
can be true
or false
. But apparently, there is a third value "plaintext-only"
.
Normally, when you set the parameter to true
, you can also edit the format and paste rich text. Using the plaintext-only
value does not work.
The change now is that Vue will not throw Typescript errors for legal values defined in the HTML specification.
Lazy loading of images
Again, this is just type support for HTML features. It was added in 3.3.5
and enables you to set the img’s load parameter to lazy
.
This way, the image doesn’t load immediately, but when your browser decides you’ll be able to see it soon.
This is a standard HTML feature that has been around for a while, but this fix is a good reminder to use it to improve application performance.
There are other bug fixes and performance improvements in this release.
New features in Vue 3.2.40
The latest version of Vue, the popular web framework, was released on September 28, 2022, providing developers with bug fixes in preparation for version 3.3.
Button incorrectly disabled
The code above illustrates that the button should not be disabled because “false” in the attribute is actually a string, not a boolean. In the latest versions of Vue, it’s fixed by checking the type of the property.
V-on does not throw errors
The code above and similar ones were recently throwing errors when they should have been working fine, and it’s been fixed.
Events are triggered correctly
The above code does not cause onBlur
to be called, but it should be called. The merging of dynamic and static v-on
caused this bug to disappear.
Fixed a memory leak
In the above case, the memory is not cleaned properly in the dev scene. It is caused by promoted vnodes
improperly retaining DOM nodes. It’s fixed now too.
These are the most interesting fixes, a number of other SSR-related issues have also been fixed and the team is working hard on it.
The 3 most interesting bug fixes for Vue 3.2.41-45
The Vue team didn’t take a break last month. Vue 3.2.40 was just introduced, and now there are five new minor versions. Below we’ll walk you through the most important bug fixes.
Vue throws error on strange single file component (SFC)
The code passed to the single-file component parser does not have nor does it have
. This is valid HTML code, but it's quite possible that passing code like this means that the wrong variable is being passed. Now, if a component does not contain a
or
tag, the parser will throw an error.
import { parse } from '@vue/compiler-sfc';
const result = parse(` import a from 'vue' `); console.log(result.errors); // []
Stripping HTML comments does not cause whitespace to be removed
In general, HTML is tolerant of whitespace. Unless it's not, and the layout breaks. Unfortunately, this happens where one of the HTML comments (shown below) is stripped without being replaced with whitespace. This happens around string interpolation. This has now been fixed.
<template> <div class="foo"> <h1>Message:</h1> <!-- A comment explaining the interpolation below --> {<!-- -->{ msg }} </div> </template>
You can use inline comments in CSS
Previously, adding comments to inline CSS would cause the CSS rules below to stop working. Now you can use annotations without problems.
<div style=" /* something */ width: 300px; height: 300px; background-color: pink; " ></div>
Vue.js 3.3: Great DX and 10x faster builds
Vue made headlines with the launch of 3.3
. We all know that Vue is actually a very fast and efficient way to build web applications. Can it get better?
It seems OK. The new version relaxes the rules for props
and emis
types, making Typescript developers happy. Defining emis
is now also easier and requires no boilerplate. Providing default values for props
is now also easy.
The new defineModel
makes it easier to define two-way bindings.
Using defineSlots
we can define types for slots
which is a useful tool that documents the code well and is easy to use.
Using defineSlots
, we can define types for slots
, which is a useful tool that documents the code well and is easy to use.
We can also enjoy common components.
Vue once again shows that it cares about DX and is able to build applications quickly and directly without a lot of wiring.
It also cares about performance. Now decoupling type checking from rollup
builds, ESBuild rolloup dependencies are combined to achieve 10x faster build times according to the release notes.
Jest was replaced by Vitest
, meaning writing and executing tests will now be easier and faster.
Changing the type generator can also help improve performance more granularly.
Overall, this is a good release that touches on the two main concerns that everyone should be concerned about: simplifying use and improving performance.
The Vue team shows with every release that it is a valuable framework for production projects. It bridges the gap between being lightweight and fast, yet powerful and strong type library.
With a powerful ecosystem of tools like true automatic import and quick setup, it's an excellent choice for modern web applications.
Welcome to long press the picture to add dishwasher as a friend and share Vue React Ts regularly.
at last:
vue2 and vue3 skills collection
VueUse source code interpretation
The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Vue entry skill treeHomepage Overview 39519 people are learning the system