Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.4.26
Choose a base ref
...
head repository: vuejs/core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.4.27
Choose a head ref
  • 13 commits
  • 34 files changed
  • 8 contributors

Commits on Apr 29, 2024

  1. test: fix test case name

    yyx990803 committed Apr 29, 2024
    Copy the full SHA
    96e8e99 View commit details
  2. chore(workflow): link to minor branch changelog for pre-releases [ci …

    …skip]
    yyx990803 committed Apr 29, 2024
    Copy the full SHA
    f750c41 View commit details
  3. fix(compiler-core): add support for arrow aysnc function with unbrack…

    …eted (#5789)
    
    close #5788
    hchlq authored Apr 29, 2024
    Copy the full SHA
    ca7d421 View commit details
  4. refactor(perf): assign value in if block (#10836)

    Plumbiu authored Apr 29, 2024
    Copy the full SHA
    c9c9dff View commit details

Commits on May 1, 2024

  1. fix(compiler-dom): restrict createStaticVNode usage with option eleme…

    …nts (#10846)
    
    close #6568
    close #7434
    skirtles-code authored May 1, 2024
    Copy the full SHA
    0e3d617 View commit details

Commits on May 3, 2024

  1. test(watch): watching a reactive array (#10848)

    skirtles-code authored May 3, 2024
    Copy the full SHA
    c0c9432 View commit details

Commits on May 6, 2024

  1. chore(deps): update all non-major dependencies (#10866)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored May 6, 2024
    Copy the full SHA
    bead21a View commit details
  2. chore(deps): update build (#10867)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored May 6, 2024
    Copy the full SHA
    8373350 View commit details
  3. refactor(types): use explicit modifiers type (#10856)

    btea authored May 6, 2024
    Copy the full SHA
    481b1b6 View commit details
  4. fix(hydration): handle edge case of style mismatch without style attr…

    …ibute
    
    ref #10786
    yyx990803 committed May 6, 2024
    Copy the full SHA
    f2c1412 View commit details
  5. fix(compat): include legacy scoped slots (#10868)

    close #8869
    CyberAP authored May 6, 2024
    Copy the full SHA
    8366126 View commit details
  6. fix(compiler-sfc): handle keyof operator (#10874)

    close #10871
    jh-leong authored May 6, 2024
    Copy the full SHA
    10d34a5 View commit details
  7. release: v3.4.27

    yyx990803 committed May 6, 2024
    Copy the full SHA
    4619461 View commit details
Showing with 483 additions and 602 deletions.
  1. +2 −1 .github/workflows/release-tag.yml
  2. +13 −0 CHANGELOG.md
  3. +7 −7 package.json
  4. +1 −1 packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts
  5. +50 −0 packages/compiler-core/__tests__/transforms/vOn.spec.ts
  6. +1 −1 packages/compiler-core/package.json
  7. +1 −1 packages/compiler-core/src/transforms/vOn.ts
  8. +32 −0 packages/compiler-dom/__tests__/transforms/__snapshots__/stringifyStatic.spec.ts.snap
  9. +47 −0 packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts
  10. +1 −1 packages/compiler-dom/package.json
  11. +12 −0 packages/compiler-dom/src/transforms/stringifyStatic.ts
  12. +36 −0 packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
  13. +2 −2 packages/compiler-sfc/package.json
  14. +34 −4 packages/compiler-sfc/src/script/resolveType.ts
  15. +1 −1 packages/compiler-ssr/package.json
  16. +1 −1 packages/dts-test/defineComponent.test-d.tsx
  17. +1 −1 packages/reactivity/package.json
  18. +42 −0 packages/runtime-core/__tests__/apiWatch.spec.ts
  19. +7 −0 packages/runtime-core/__tests__/hydration.spec.ts
  20. +1 −1 packages/runtime-core/package.json
  21. +2 −10 packages/runtime-core/src/compat/instance.ts
  22. +3 −3 packages/runtime-core/src/hydration.ts
  23. +1 −1 packages/runtime-dom/__tests__/directives/vOn.spec.ts
  24. +1 −1 packages/runtime-dom/package.json
  25. +14 −2 packages/runtime-dom/src/directives/vOn.ts
  26. +1 −1 packages/server-renderer/package.json
  27. +1 −1 packages/sfc-playground/package.json
  28. +1 −1 packages/sfc-playground/src/download/template/package.json
  29. +1 −1 packages/shared/package.json
  30. +1 −1 packages/shared/src/normalizeProp.ts
  31. +2 −2 packages/vue-compat/__tests__/instance.spec.ts
  32. +1 −1 packages/vue-compat/package.json
  33. +1 −1 packages/vue/package.json
  34. +161 −554 pnpm-lock.yaml
3 changes: 2 additions & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -24,4 +24,5 @@ jobs:
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](https://github.com/vuejs/core/blob/main/CHANGELOG.md) for details.
For stable releases, please refer to [CHANGELOG.md](https://github.com/vuejs/core/blob/main/CHANGELOG.md) for details.
For pre-releases, please refer to [CHANGELOG.md](https://github.com/vuejs/core/blob/minor/CHANGELOG.md) of the `minor` branch.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [3.4.27](https://github.com/vuejs/core/compare/v3.4.26...v3.4.27) (2024-05-06)


### Bug Fixes

* **compat:** include legacy scoped slots ([#10868](https://github.com/vuejs/core/issues/10868)) ([8366126](https://github.com/vuejs/core/commit/83661264a4ced3cb2ff6800904a86dd9e82bbfe2)), closes [#8869](https://github.com/vuejs/core/issues/8869)
* **compiler-core:** add support for arrow aysnc function with unbracketed ([#5789](https://github.com/vuejs/core/issues/5789)) ([ca7d421](https://github.com/vuejs/core/commit/ca7d421e8775f6813f8943d32ab485e0c542f98b)), closes [#5788](https://github.com/vuejs/core/issues/5788)
* **compiler-dom:** restrict createStaticVNode usage with option elements ([#10846](https://github.com/vuejs/core/issues/10846)) ([0e3d617](https://github.com/vuejs/core/commit/0e3d6178b02d0386d779720ae2cc4eac1d1ec990)), closes [#6568](https://github.com/vuejs/core/issues/6568) [#7434](https://github.com/vuejs/core/issues/7434)
* **compiler-sfc:** handle keyof operator ([#10874](https://github.com/vuejs/core/issues/10874)) ([10d34a5](https://github.com/vuejs/core/commit/10d34a5624775f20437ccad074a97270ef74c3fb)), closes [#10871](https://github.com/vuejs/core/issues/10871)
* **hydration:** handle edge case of style mismatch without style attribute ([f2c1412](https://github.com/vuejs/core/commit/f2c1412e46a8fad3e13403bfa78335c4f704f21c)), closes [#10786](https://github.com/vuejs/core/issues/10786)



## [3.4.26](https://github.com/vuejs/core/compare/v3.4.25...v3.4.26) (2024-04-29)


14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.4.26",
"packageManager": "pnpm@9.0.6",
"version": "3.4.27",
"packageManager": "pnpm@9.1.0",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
@@ -70,7 +70,7 @@
"@rollup/plugin-terser": "^0.4.4",
"@types/hash-sum": "^1.0.2",
"@types/minimist": "^1.2.5",
"@types/node": "^20.12.7",
"@types/node": "^20.12.10",
"@types/semver": "^7.5.8",
"@vitest/coverage-istanbul": "^1.5.2",
"@vue/consolidate": "1.0.0",
@@ -97,20 +97,20 @@
"pug": "^3.0.2",
"puppeteer": "~22.7.1",
"rimraf": "^5.0.5",
"rollup": "^4.17.1",
"rollup": "^4.17.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"semver": "^7.6.0",
"serve": "^14.2.3",
"simple-git-hooks": "^2.11.1",
"terser": "^5.30.4",
"terser": "^5.31.0",
"todomvc-app-css": "^2.4.3",
"tslib": "^2.6.2",
"tsx": "^4.7.3",
"tsx": "^4.9.3",
"typescript": "~5.4.5",
"typescript-eslint": "^7.7.1",
"vite": "^5.2.10",
"vite": "^5.2.11",
"vitest": "^1.5.2"
},
"pnpm": {
Original file line number Diff line number Diff line change
@@ -431,7 +431,7 @@ describe('compiler: expression transform', () => {
})
})

test('should not bail constant on strings w/ ()', () => {
test('should bail constant for global identifiers w/ new or call expressions', () => {
const node = parseWithExpressionTransform(
`{{ new Date().getFullYear() }}`,
) as InterpolationNode
50 changes: 50 additions & 0 deletions packages/compiler-core/__tests__/transforms/vOn.spec.ts
Original file line number Diff line number Diff line change
@@ -286,6 +286,23 @@ describe('compiler: transform v-on', () => {
})
})

test('should NOT wrap as function if expression is already function expression (async)', () => {
const { node } = parseWithVOn(
`<div @click="async $event => await foo($event)"/>`,
)
expect((node.codegenNode as VNodeCall).props).toMatchObject({
properties: [
{
key: { content: `onClick` },
value: {
type: NodeTypes.SIMPLE_EXPRESSION,
content: `async $event => await foo($event)`,
},
},
],
})
})

test('should NOT wrap as function if expression is already function expression (with newlines)', () => {
const { node } = parseWithVOn(
`<div @click="
@@ -630,6 +647,39 @@ describe('compiler: transform v-on', () => {
})
})

test('inline async arrow function with no bracket expression handler', () => {
const { root, node } = parseWithVOn(
`<div v-on:click="async e => await foo(e)" />`,
{
prefixIdentifiers: true,
cacheHandlers: true,
},
)

expect(root.cached).toBe(1)
const vnodeCall = node.codegenNode as VNodeCall
// should not treat cached handler as dynamicProp, so no flags
expect(vnodeCall.patchFlag).toBeUndefined()
expect(
(vnodeCall.props as ObjectExpression).properties[0].value,
).toMatchObject({
type: NodeTypes.JS_CACHE_EXPRESSION,
index: 0,
value: {
type: NodeTypes.COMPOUND_EXPRESSION,
children: [
`async `,
{ content: `e` },
` => await `,
{ content: `_ctx.foo` },
`(`,
{ content: `e` },
`)`,
],
},
})
})

test('inline async function expression handler', () => {
const { root, node } = parseWithVOn(
`<div v-on:click="async function () { await foo() } " />`,
2 changes: 1 addition & 1 deletion packages/compiler-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
2 changes: 1 addition & 1 deletion packages/compiler-core/src/transforms/vOn.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import { hasScopeRef, isMemberExpression } from '../utils'
import { TO_HANDLER_KEY } from '../runtimeHelpers'

const fnExpRE =
/^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/
/^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/

export interface VOnDirectiveNode extends DirectiveNode {
// v-on without arg is handled directly in ./transformElements.ts due to it affecting
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`stringify static html > should bail for <option> elements with number values 1`] = `
"const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
const _hoisted_1 = /*#__PURE__*/_createElementVNode("select", null, [
/*#__PURE__*/_createElementVNode("option", { value: 1 }),
/*#__PURE__*/_createElementVNode("option", { value: 1 }),
/*#__PURE__*/_createElementVNode("option", { value: 1 }),
/*#__PURE__*/_createElementVNode("option", { value: 1 }),
/*#__PURE__*/_createElementVNode("option", { value: 1 })
], -1 /* HOISTED */)
const _hoisted_2 = [
_hoisted_1
]
return function render(_ctx, _cache) {
return (_openBlock(), _createElementBlock("div", null, _hoisted_2))
}"
`;
exports[`stringify static html > should bail on bindings that are hoisted but not stringifiable 1`] = `
"const { createElementVNode: _createElementVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
@@ -20,6 +39,19 @@ return function render(_ctx, _cache) {
}"
`;
exports[`stringify static html > should work for <option> elements with string values 1`] = `
"const { createElementVNode: _createElementVNode, createStaticVNode: _createStaticVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
const _hoisted_1 = /*#__PURE__*/_createStaticVNode("<select><option value=\\"1\\"></option><option value=\\"1\\"></option><option value=\\"1\\"></option><option value=\\"1\\"></option><option value=\\"1\\"></option></select>", 1)
const _hoisted_2 = [
_hoisted_1
]
return function render(_ctx, _cache) {
return (_openBlock(), _createElementBlock("div", null, _hoisted_2))
}"
`;
exports[`stringify static html > should work with bindings that are non-static but stringifiable 1`] = `
"const { createElementVNode: _createElementVNode, createStaticVNode: _createStaticVNode, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
47 changes: 47 additions & 0 deletions packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts
Original file line number Diff line number Diff line change
@@ -485,4 +485,51 @@ describe('stringify static html', () => {
expect(code).toMatch(`<code>text1</code>`)
expect(code).toMatchSnapshot()
})

test('should work for <option> elements with string values', () => {
const { ast, code } = compileWithStringify(
`<div><select>${repeat(
`<option value="1" />`,
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
)}</select></div>`,
)
// should be optimized now
expect(ast.hoists).toMatchObject([
{
type: NodeTypes.JS_CALL_EXPRESSION,
callee: CREATE_STATIC,
arguments: [
JSON.stringify(
`<select>${repeat(
`<option value="1"></option>`,
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
)}</select>`,
),
'1',
],
},
{
type: NodeTypes.JS_ARRAY_EXPRESSION,
},
])
expect(code).toMatchSnapshot()
})

test('should bail for <option> elements with number values', () => {
const { ast, code } = compileWithStringify(
`<div><select>${repeat(
`<option :value="1" />`,
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
)}</select></div>`,
)
expect(ast.hoists).toMatchObject([
{
type: NodeTypes.VNODE_CALL,
},
{
type: NodeTypes.JS_ARRAY_EXPRESSION,
},
])
expect(code).toMatchSnapshot()
})
})
2 changes: 1 addition & 1 deletion packages/compiler-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
12 changes: 12 additions & 0 deletions packages/compiler-dom/src/transforms/stringifyStatic.ts
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import {
type TextCallNode,
type TransformContext,
createCallExpression,
isStaticArgOf,
} from '@vue/compiler-core'
import {
escapeHtml,
@@ -200,6 +201,7 @@ function analyzeNode(node: StringifiableNode): [number, number] | false {
// probably only need to check for most common case
// i.e. non-phrasing-content tags inside `<p>`
function walk(node: ElementNode): boolean {
const isOptionTag = node.tag === 'option' && node.ns === Namespaces.HTML
for (let i = 0; i < node.props.length; i++) {
const p = node.props[i]
// bail on non-attr bindings
@@ -225,6 +227,16 @@ function analyzeNode(node: StringifiableNode): [number, number] | false {
) {
return bail()
}
// <option :value="1"> cannot be safely stringified
if (
isOptionTag &&
isStaticArgOf(p.arg, 'value') &&
p.exp &&
p.exp.ast &&
p.exp.ast.type !== 'StringLiteral'
) {
return bail()
}
}
}
for (let i = 0; i < node.children.length; i++) {
36 changes: 36 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Original file line number Diff line number Diff line change
@@ -447,6 +447,42 @@ describe('resolveType', () => {
})
})

test('keyof', () => {
const files = {
'/foo.ts': `export type IMP = { ${1}: 1 };`,
}

const { props } = resolve(
`
import { IMP } from './foo'
interface Foo { foo: 1, ${1}: 1 }
type Bar = { bar: 1 }
declare const obj: Bar
declare const set: Set<any>
declare const arr: Array<any>
defineProps<{
imp: keyof IMP,
foo: keyof Foo,
bar: keyof Bar,
obj: keyof typeof obj,
set: keyof typeof set,
arr: keyof typeof arr
}>()
`,
files,
)

expect(props).toStrictEqual({
imp: ['Number'],
foo: ['String', 'Number'],
bar: ['String'],
obj: ['String'],
set: ['String'],
arr: ['String', 'Number'],
})
})

test('ExtractPropTypes (element-plus)', () => {
const { props, raw } = resolve(
`
4 changes: 2 additions & 2 deletions packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-sfc",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
@@ -62,6 +62,6 @@
"postcss-modules": "^6.0.0",
"postcss-selector-parser": "^6.0.16",
"pug": "^3.0.2",
"sass": "^1.75.0"
"sass": "^1.76.0"
}
}
Loading