chore: Merge branch 'main' into minor

This commit is contained in:
Evan You 2024-07-19 18:07:42 +08:00
commit 66579ea544
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
5 changed files with 30 additions and 22 deletions

View File

@ -1,3 +1,12 @@
## [3.4.33](https://github.com/vuejs/core/compare/v3.4.32...v3.4.33) (2024-07-19)
### Bug Fixes
* **runtime-dom:** handle undefined values in v-html ([#11403](https://github.com/vuejs/core/issues/11403)) ([5df67e3](https://github.com/vuejs/core/commit/5df67e36756639ea7b923d1b139d6cb14450123b))
## [3.4.32](https://github.com/vuejs/core/compare/v3.4.31...v3.4.32) (2024-07-17)

View File

@ -454,9 +454,6 @@ export interface ComponentInternalInstance {
refs: Data
emit: EmitFn
attrsProxy: Data | null
slotsProxy: Slots | null
/**
* used for keeping track of .once event handlers on components
* @internal
@ -659,9 +656,6 @@ export function createComponentInstance(
setupState: EMPTY_OBJ,
setupContext: null,
attrsProxy: null,
slotsProxy: null,
// suspense related
suspense,
suspenseId: suspense ? suspense.pendingId : 0,
@ -1104,15 +1098,12 @@ const attrsProxyHandlers = __DEV__
* Dev-only
*/
function getSlotsProxy(instance: ComponentInternalInstance): Slots {
return (
instance.slotsProxy ||
(instance.slotsProxy = new Proxy(instance.slots, {
get(target, key: string) {
track(instance, TrackOpTypes.GET, '$slots')
return target[key]
},
}))
)
return new Proxy(instance.slots, {
get(target, key: string) {
track(instance, TrackOpTypes.GET, '$slots')
return target[key]
},
})
}
export function createSetupContext(
@ -1146,6 +1137,7 @@ export function createSetupContext(
// We use getters in dev in case libs like test-utils overwrite instance
// properties (overwrites should not be done in prod)
let attrsProxy: Data
let slotsProxy: Slots
return Object.freeze({
get attrs() {
return (
@ -1154,7 +1146,7 @@ export function createSetupContext(
)
},
get slots() {
return getSlotsProxy(instance)
return slotsProxy || (slotsProxy = getSlotsProxy(instance))
},
get emit() {
return (event: string, ...args: any[]) => instance.emit(event, ...args)

View File

@ -152,6 +152,12 @@ describe('runtime-dom: props patching', () => {
expect(root.innerHTML).toBe(`<div><del>baz</del></div>`)
})
test('patch innerHTML porp w/ undefined value', async () => {
const root = document.createElement('div')
render(h('div', { innerHTML: undefined }), root)
expect(root.innerHTML).toBe(`<div></div>`)
})
test('textContent unmount prev children', () => {
const fn = vi.fn()
const comp = {

View File

@ -15,7 +15,7 @@ export function patchDOMProp(
if (key === 'innerHTML' || key === 'textContent') {
// null value case is handled in renderer patchElement before patching
// children
if (value === null) return
if (value == null) return
el[key] = value
return
}

View File

@ -60,13 +60,14 @@ export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
*/
export async function exec(command, args, options) {
return new Promise((resolve, reject) => {
const process = spawn(command, args, {
const _process = spawn(command, args, {
stdio: [
'ignore', // stdin
'pipe', // stdout
'pipe', // stderr
],
...options,
shell: process.platform === 'win32',
})
/**
@ -78,19 +79,19 @@ export async function exec(command, args, options) {
*/
const stdoutChunks = []
process.stderr?.on('data', chunk => {
_process.stderr?.on('data', chunk => {
stderrChunks.push(chunk)
})
process.stdout?.on('data', chunk => {
_process.stdout?.on('data', chunk => {
stdoutChunks.push(chunk)
})
process.on('error', error => {
_process.on('error', error => {
reject(error)
})
process.on('exit', code => {
_process.on('exit', code => {
const ok = code === 0
const stderr = Buffer.concat(stderrChunks).toString().trim()
const stdout = Buffer.concat(stdoutChunks).toString().trim()