Skip to content

Commit

Permalink
Merge branch 'main' into fix-7276
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhonghe committed Jul 16, 2023
2 parents 31929a2 + 37a14a5 commit 953e1bb
Show file tree
Hide file tree
Showing 202 changed files with 6,995 additions and 5,131 deletions.
4 changes: 2 additions & 2 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ import { h } from '@vue/runtime-core'
This is made possible via several configurations:

- For TypeScript, `compilerOptions.paths` in `tsconfig.json`
- Vitest and Rollup share the sae set of aliases from `scripts/aliases.js`
- Vitest and Rollup share the same set of aliases from `scripts/aliases.js`
- For plain Node.js, they are linked using [PNPM Workspaces](https://pnpm.io/workspaces).

### Package Dependencies
Expand Down Expand Up @@ -330,4 +330,4 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu

Thank you to all the people who have already contributed to Vue.js!

<a href="https://github.com/vuejs/vue/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
<a href="https://github.com/vuejs/core/graphs/contributors"><img src="https://opencollective.com/vuejs/contributors.svg?width=890" /></a>
2 changes: 1 addition & 1 deletion BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Vue.js is an MIT-licensed open source project with its ongoing development made

<p align="center">
<a target="_blank" href="https://sponsors.vuejs.org/backers.svg">
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg">
<img alt="sponsors" src="https://sponsors.vuejs.org/backers.svg?v1">
</a>
</p>
3,161 changes: 159 additions & 3,002 deletions CHANGELOG.md

Large diffs are not rendered by default.

1,617 changes: 1,617 additions & 0 deletions changelogs/CHANGELOG-3.0.md

Large diffs are not rendered by default.

320 changes: 320 additions & 0 deletions changelogs/CHANGELOG-3.1.md

Large diffs are not rendered by default.

1,067 changes: 1,067 additions & 0 deletions changelogs/CHANGELOG-3.2.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.3.0-beta.1",
"packageManager": "pnpm@7.26.0",
"version": "3.3.4",
"packageManager": "pnpm@8.6.2",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"build-runtime-esm": "node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime",
"build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
"build-sfc-playground-self": "cd packages/sfc-playground && npm run build",
"preinstall": "node ./scripts/preinstall.js",
"preinstall": "npx only-allow pnpm",
"postinstall": "simple-git-hooks"
},
"simple-git-hooks": {
Expand All @@ -57,7 +57,6 @@
"devDependencies": {
"@babel/parser": "^7.21.3",
"@babel/types": "^7.21.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@rollup/plugin-alias": "^4.0.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
Expand All @@ -73,6 +72,7 @@
"conventional-changelog-cli": "^2.0.31",
"enquirer": "^2.3.2",
"esbuild": "^0.17.4",
"esbuild-plugin-polyfill-node": "^0.2.0",
"eslint": "^8.33.0",
"eslint-plugin-jest": "^27.2.1",
"estree-walker": "^2.0.2",
Expand All @@ -87,7 +87,7 @@
"prettier": "^2.7.1",
"pug": "^3.0.1",
"puppeteer": "~19.6.0",
"rollup": "^3.20.2",
"rollup": "^3.26.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-polyfill-node": "^0.12.0",
Expand All @@ -97,7 +97,7 @@
"terser": "^5.15.1",
"todomvc-app-css": "^2.3.0",
"tslib": "^2.5.0",
"typescript": "^5.0.0",
"typescript": "^5.1.6",
"vite": "^4.3.0",
"vitest": "^0.30.1"
}
Expand Down
32 changes: 30 additions & 2 deletions packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { ParserOptions } from '../src/options'
import { baseParse, TextModes } from '../src/parse'
import { ErrorCodes } from '../src/errors'
Expand All @@ -11,7 +10,8 @@ import {
Position,
TextNode,
InterpolationNode,
ConstantTypes
ConstantTypes,
DirectiveNode
} from '../src/ast'

describe('compiler: parse', () => {
Expand Down Expand Up @@ -1164,6 +1164,34 @@ describe('compiler: parse', () => {
})
})

// #3494
test('directive argument edge case', () => {
const ast = baseParse('<div v-slot:slot />')
const directive = (ast.children[0] as ElementNode)
.props[0] as DirectiveNode
expect(directive.arg).toMatchObject({
loc: {
start: { offset: 12, line: 1, column: 13 },
end: { offset: 16, line: 1, column: 17 },
source: 'slot'
}
})
})

// https://github.com/vuejs/language-tools/issues/2710
test('directive argument edge case (2)', () => {
const ast = baseParse('<div #item.item />')
const directive = (ast.children[0] as ElementNode)
.props[0] as DirectiveNode
expect(directive.arg).toMatchObject({
loc: {
start: { offset: 6, line: 1, column: 7 },
end: { offset: 15, line: 1, column: 16 },
source: 'item.item'
}
})
})

test('directive with dynamic argument', () => {
const ast = baseParse('<div v-on:[event]/>')
const directive = (ast.children[0] as ElementNode).props[0]
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transform.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse } from '../src/parse'
import { transform, NodeTransform } from '../src/transform'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down Expand Up @@ -431,6 +430,16 @@ describe('compiler: expression transform', () => {
})
})

// #8295
test('should treat floating point number literals as constant', () => {
const node = parseWithExpressionTransform(
`{{ [1, 2.1] }}`
) as InterpolationNode
expect(node.content).toMatchObject({
constType: ConstantTypes.CAN_STRINGIFY
})
})

describe('ES Proposals support', () => {
test('bigInt', () => {
const node = parseWithExpressionTransform(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vBind.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vFor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse as parse } from '../../src/parse'
import { transform } from '../../src/transform'
import { transformIf } from '../../src/transforms/vIf'
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vIf.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { baseParse as parse } from '../../src/parse'
import { transform } from '../../src/transform'
import { transformIf } from '../../src/transforms/vIf'
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vModel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vOn.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
CompilerOptions,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-core/__tests__/transforms/vSlot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
CompilerOptions,
baseParse as parse,
Expand Down
4 changes: 2 additions & 2 deletions 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.3.0-beta.1",
"version": "3.3.4",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
"dependencies": {
"@babel/parser": "^7.21.3",
"@vue/shared": "3.3.0-beta.1",
"@vue/shared": "3.3.4",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/babelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function walkIdentifiers(
root.body[0].type === 'ExpressionStatement' &&
root.body[0].expression

;(walk as any)(root, {
walk(root, {
enter(node: Node & { scopeIds?: Set<string> }, parent: Node | undefined) {
parent && parentStack.push(parent)
if (
Expand Down
5 changes: 4 additions & 1 deletion packages/compiler-core/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,10 @@ function parseAttribute(

if (match[2]) {
const isSlot = dirName === 'slot'
const startOffset = name.lastIndexOf(match[2])
const startOffset = name.lastIndexOf(
match[2],
name.length - (match[3]?.length || 0)
)
const loc = getSelection(
context,
getNewPosition(context, start, startOffset),
Expand Down
12 changes: 8 additions & 4 deletions packages/compiler-core/src/transforms/transformExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '../babelUtils'
import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
import {
isGloballyWhitelisted,
isGloballyAllowed,
makeMap,
hasOwn,
isString,
Expand All @@ -45,6 +45,10 @@ import { BindingTypes } from '../options'

const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this')

// a heuristic safeguard to bail constant expressions on presence of
// likely function invocation and member access
const constantBailRE = /\w\s*\(|\.[^\d]/

export const transformExpression: NodeTransform = (node, context) => {
if (node.type === NodeTypes.INTERPOLATION) {
node.content = processExpression(
Expand Down Expand Up @@ -217,11 +221,11 @@ export function processExpression(
// fast path if expression is a simple identifier.
const rawExp = node.content
// bail constant on parens (function invocation) and dot (member access)
const bailConstant = rawExp.indexOf(`(`) > -1 || rawExp.indexOf('.') > 0
const bailConstant = constantBailRE.test(rawExp)

if (isSimpleIdentifier(rawExp)) {
const isScopeVarReference = context.identifiers[rawExp]
const isAllowedGlobal = isGloballyWhitelisted(rawExp)
const isAllowedGlobal = isGloballyAllowed(rawExp)
const isLiteral = isLiteralWhitelisted(rawExp)
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
// const bindings exposed from setup can be skipped for patching but
Expand Down Expand Up @@ -354,7 +358,7 @@ export function processExpression(

function canPrefix(id: Identifier) {
// skip whitelisted globals
if (isGloballyWhitelisted(id.name)) {
if (isGloballyAllowed(id.name)) {
return false
}
// special case for webpack compilation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import { compile } from '../../src'

describe('Transition multi children warnings', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vHtml.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vModel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vShow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
1 change: 0 additions & 1 deletion packages/compiler-dom/__tests__/transforms/vText.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { vi } from 'vitest'
import {
baseParse as parse,
transform,
Expand Down
6 changes: 3 additions & 3 deletions 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.3.0-beta.1",
"version": "3.3.4",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
"dependencies": {
"@vue/shared": "3.3.0-beta.1",
"@vue/compiler-core": "3.3.0-beta.1"
"@vue/shared": "3.3.4",
"@vue/compiler-core": "3.3.4"
}
}
4 changes: 2 additions & 2 deletions packages/compiler-dom/src/decodeHtmlBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function decodeHtmlBrowser(raw: string, asAttr = false): string {
}
if (asAttr) {
decoder.innerHTML = `<div foo="${raw.replace(/"/g, '&quot;')}">`
return decoder.children[0].getAttribute('foo') as string
return decoder.children[0].getAttribute('foo')!
} else {
decoder.innerHTML = raw
return decoder.textContent as string
return decoder.textContent!
}
}
10 changes: 7 additions & 3 deletions packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export const ignoreSideEffectTags: NodeTransform = (node, context) => {
node.tagType === ElementTypes.ELEMENT &&
(node.tag === 'script' || node.tag === 'style')
) {
context.onError(
createDOMCompilerError(DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG, node.loc)
)
__DEV__ &&
context.onError(
createDOMCompilerError(
DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG,
node.loc
)
)
context.removeNode()
}
}
Loading

0 comments on commit 953e1bb

Please sign in to comment.