Skip to content

Commit 1f8a609

Browse files
committed
chore: Merge branch 'master' of github.com:vuejs/vue-next into akryum/on-server-prefetch
2 parents d9c1591 + 3efa2af commit 1f8a609

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+553
-288
lines changed

.github/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
66
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
77
- [Pull Request Guidelines](#pull-request-guidelines)
88
- [Development Setup](#development-setup)
9+
- [Scripts](#scripts)
910
- [Project Structure](#project-structure)
1011
- [Contributing Tests](#contributing-tests)
1112
- [Financial Contribution](#financial-contribution)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Please consult the [Migration Guide](https://v3.vuejs.org/guide/migration/introd
2828

2929
## Supporting Libraries
3030

31-
All of our official libraries and tools now support Vue 3, but most of them are still in beta status and distributed under the `next` dist tag on NPM. **We are planning to stabilize and switch all projects to use the `latest` dist tag by end of 2020.**
31+
All of our official libraries and tools now support Vue 3, but most of them are still in beta status and distributed under the `next` dist tag on NPM. **We are planning to stabilize and switch all projects to use the `latest` dist tag in early 2021.**
3232

3333
### Vue CLI
3434

packages/compiler-sfc/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018-present, Yuxi (Evan) You
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

packages/compiler-sfc/__tests__/__snapshots__/templateTransformSrcset.spec.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const _hoisted_8 = \\"/logo.png\\" + ', ' + _imports_0 + '2x'
1616
1717
export function render(_ctx, _cache) {
1818
return (_openBlock(), _createBlock(_Fragment, null, [
19+
_createVNode(\\"img\\", {
20+
src: \\"./logo.png\\",
21+
srcset: \\"\\"
22+
}),
1923
_createVNode(\\"img\\", {
2024
src: \\"./logo.png\\",
2125
srcset: _hoisted_1
@@ -69,6 +73,10 @@ exports[`compiler sfc: transform srcset transform srcset w/ base 1`] = `
6973
7074
export function render(_ctx, _cache) {
7175
return (_openBlock(), _createBlock(_Fragment, null, [
76+
_createVNode(\\"img\\", {
77+
src: \\"./logo.png\\",
78+
srcset: \\"\\"
79+
}),
7280
_createVNode(\\"img\\", {
7381
src: \\"./logo.png\\",
7482
srcset: \\"/foo/logo.png\\"
@@ -137,6 +145,10 @@ const _hoisted_11 = \\"data:image/png;base64,i\\" + '1x, ' + \\"data:image/png;b
137145
138146
export function render(_ctx, _cache) {
139147
return (_openBlock(), _createBlock(_Fragment, null, [
148+
_createVNode(\\"img\\", {
149+
src: \\"./logo.png\\",
150+
srcset: \\"\\"
151+
}),
140152
_createVNode(\\"img\\", {
141153
src: \\"./logo.png\\",
142154
srcset: _hoisted_1

packages/compiler-sfc/__tests__/parse.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ h1 { color: red }
139139
expect(descriptor.template!.content).toBe(content)
140140
})
141141

142+
test('treat empty lang attribute as the html', () => {
143+
const content = `<div><template v-if="ok">ok</template></div>`
144+
const { descriptor, errors } = parse(
145+
`<template lang="">${content}</template>`
146+
)
147+
expect(descriptor.template!.content).toBe(content)
148+
expect(errors.length).toBe(0)
149+
})
150+
142151
// #1120
143152
test('alternative template lang should be treated as plain text', () => {
144153
const content = `p(v-if="1 < 2") test`

packages/compiler-sfc/__tests__/templateTransformSrcset.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function compileWithSrcset(template: string, options?: AssetURLOptions) {
2525
}
2626

2727
const src = `
28+
<img src="./logo.png" srcset=""/>
2829
<img src="./logo.png" srcset="./logo.png"/>
2930
<img src="./logo.png" srcset="./logo.png 2x"/>
3031
<img src="./logo.png" srcset="./logo.png 2x"/>

packages/compiler-sfc/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"lru-cache": "^5.1.1",
4747
"magic-string": "^0.25.7",
4848
"merge-source-map": "^1.1.0",
49-
"postcss": "^7.0.32",
50-
"postcss-modules": "^3.2.2",
49+
"postcss": "^8.1.10",
50+
"postcss-modules": "^4.0.0",
5151
"postcss-selector-parser": "^6.0.4",
5252
"source-map": "^0.6.1"
5353
},

packages/compiler-sfc/src/compileStyle.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import postcss, {
22
ProcessOptions,
3-
LazyResult,
43
Result,
5-
ResultMap,
6-
ResultMessage
4+
SourceMap,
5+
Message,
6+
LazyResult
77
} from 'postcss'
88
import trimPlugin from './stylePluginTrim'
99
import scopedPlugin from './stylePluginScoped'
@@ -35,28 +35,33 @@ export interface SFCStyleCompileOptions {
3535
map?: RawSourceMap
3636
}
3737

38+
/**
39+
* Aligns with postcss-modules
40+
* https://github.com/css-modules/postcss-modules
41+
*/
42+
export interface CSSModulesOptions {
43+
scopeBehaviour?: 'global' | 'local'
44+
generateScopedName?:
45+
| string
46+
| ((name: string, filename: string, css: string) => string)
47+
hashPrefix?: string
48+
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'
49+
exportGlobals?: boolean
50+
globalModulePaths?: string[]
51+
}
52+
3853
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
3954
isAsync?: boolean
4055
// css modules support, note this requires async so that we can get the
4156
// resulting json
4257
modules?: boolean
43-
// maps to postcss-modules options
44-
// https://github.com/css-modules/postcss-modules
45-
modulesOptions?: {
46-
scopeBehaviour?: 'global' | 'local'
47-
globalModulePaths?: string[]
48-
generateScopedName?:
49-
| string
50-
| ((name: string, filename: string, css: string) => string)
51-
hashPrefix?: string
52-
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly'
53-
}
58+
modulesOptions?: CSSModulesOptions
5459
}
5560

5661
export interface SFCStyleCompileResults {
5762
code: string
5863
map: RawSourceMap | undefined
59-
rawResult: LazyResult | Result | undefined
64+
rawResult: Result | LazyResult | undefined
6065
errors: Error[]
6166
modules?: Record<string, string>
6267
dependencies: Set<string>
@@ -149,7 +154,7 @@ export function doCompileStyle(
149154

150155
let result: LazyResult | undefined
151156
let code: string | undefined
152-
let outMap: ResultMap | undefined
157+
let outMap: SourceMap | undefined
153158
// stylus output include plain css. so need remove the repeat item
154159
const dependencies = new Set(
155160
preProcessedSource ? preProcessedSource.dependencies : []
@@ -162,7 +167,7 @@ export function doCompileStyle(
162167
errors.push(...preProcessedSource.errors)
163168
}
164169

165-
const recordPlainCssDependencies = (messages: ResultMessage[]) => {
170+
const recordPlainCssDependencies = (messages: Message[]) => {
166171
messages.forEach(msg => {
167172
if (msg.type === 'dependency') {
168173
// postcss output path is absolute position path
@@ -226,7 +231,7 @@ function preprocess(
226231

227232
return preprocessor(
228233
options.source,
229-
options.map,
234+
options.inMap || options.map,
230235
{
231236
filename: options.filename,
232237
...options.preprocessOptions

packages/compiler-sfc/src/cssVars.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
BindingMetadata
99
} from '@vue/compiler-dom'
1010
import { SFCDescriptor } from './parse'
11-
import postcss, { Root } from 'postcss'
11+
import { PluginCreator } from 'postcss'
1212
import hash from 'hash-sum'
1313

1414
export const CSS_VARS_HELPER = `useCssVars`
@@ -49,20 +49,21 @@ export interface CssVarsPluginOptions {
4949
isProd: boolean
5050
}
5151

52-
export const cssVarsPlugin = postcss.plugin<CssVarsPluginOptions>(
53-
'vue-scoped',
54-
opts => (root: Root) => {
55-
const { id, isProd } = opts!
56-
root.walkDecls(decl => {
52+
export const cssVarsPlugin: PluginCreator<CssVarsPluginOptions> = opts => {
53+
const { id, isProd } = opts!
54+
return {
55+
postcssPlugin: 'vue-sfc-vars',
56+
Declaration(decl) {
5757
// rewrite CSS variables
5858
if (cssVarRE.test(decl.value)) {
5959
decl.value = decl.value.replace(cssVarRE, (_, $1, $2, $3) => {
6060
return `var(--${genVarName(id, $1 || $2 || $3, isProd)})`
6161
})
6262
}
63-
})
63+
}
6464
}
65-
)
65+
}
66+
cssVarsPlugin.postcss = true
6667

6768
export function genCssVarsCode(
6869
vars: string[],

packages/compiler-sfc/src/parse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function parse(
121121
p.type === NodeTypes.ATTRIBUTE &&
122122
p.name === 'lang' &&
123123
p.value &&
124+
p.value.content &&
124125
p.value.content !== 'html'
125126
))
126127
) {

0 commit comments

Comments
 (0)