Skip to content

Commit

Permalink
Merge branch 'vuejs:main' into bwsy/fix/renderRef
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Oct 3, 2022
2 parents 199bd20 + 35a113e commit 052eb8f
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 31 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Expand Up @@ -69,6 +69,14 @@ module.exports = {
'no-restricted-globals': ['error', ...NodeGlobals],
'no-restricted-syntax': 'off'
}
},
// Node scripts
{
files: ['scripts/**', './*.js', 'packages/**/index.js', 'packages/size-check/**'],
rules: {
'no-restricted-globals': 'off',
'no-restricted-syntax': 'off'
}
}
]
}
4 changes: 2 additions & 2 deletions packages/compiler-core/src/transforms/vOn.ts
Expand Up @@ -54,9 +54,9 @@ export const transformOn: DirectiveTransform = (
? // for component and vnode lifecycle event listeners, auto convert
// it to camelCase. See issue #2249
toHandlerKey(camelize(rawName))
// preserve case for plain element listeners that have uppercase
: // preserve case for plain element listeners that have uppercase
// letters, as these may be custom elements' custom events
: `on:${rawName}`
`on:${rawName}`
eventName = createSimpleExpression(eventString, true, arg.loc)
} else {
// #2388
Expand Down
8 changes: 6 additions & 2 deletions packages/compiler-sfc/__tests__/rewriteDefault.spec.ts
Expand Up @@ -206,7 +206,10 @@ describe('compiler sfc: rewriteDefault', () => {

test('@Component\nexport default class w/ comments', async () => {
expect(
rewriteDefault(`// export default\n@Component\nexport default class Foo {}`, 'script')
rewriteDefault(
`// export default\n@Component\nexport default class Foo {}`,
'script'
)
).toMatchInlineSnapshot(`
"// export default
@Component
Expand All @@ -231,7 +234,8 @@ describe('compiler sfc: rewriteDefault', () => {
test('@Component\nexport default class w/ comments 3', async () => {
expect(
rewriteDefault(
`/*\n@Component\nexport default class Foo {}*/\n` + `export default class Bar {}`,
`/*\n@Component\nexport default class Foo {}*/\n` +
`export default class Bar {}`,
'script'
)
).toMatchInlineSnapshot(`
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler-ssr/src/ssrCodegenTransform.ts
Expand Up @@ -49,8 +49,7 @@ export function ssrCodegenTransform(ast: RootNode, options: CompilerOptions) {
createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
)
Array.from(cssContext.helpers.keys()).forEach(helper => {
if (!ast.helpers.includes(helper))
ast.helpers.push(helper)
if (!ast.helpers.includes(helper)) ast.helpers.push(helper)
})
}

Expand Down
Expand Up @@ -33,8 +33,8 @@ export function ssrTransformTransitionGroup(
node,
context,
otherProps,
true, /* isComponent */
false, /* isDynamicComponent */
true /* isComponent */,
false /* isDynamicComponent */,
true /* ssr (skip event listeners) */
)
let propsExp = null
Expand Down
1 change: 0 additions & 1 deletion packages/runtime-core/__tests__/apiOptions.spec.ts
Expand Up @@ -1048,7 +1048,6 @@ describe('api: options', () => {
expect(root.innerHTML).toBe(`<h1>Foo</h1>`)
})


test('options defined in component have higher priority', async () => {
const Mixin = {
msg1: 'base'
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/BaseTransition.ts
Expand Up @@ -274,7 +274,7 @@ if (__COMPAT__) {

// export the public type for h/tsx inference
// also to avoid inline import() in generated d.ts files
export const BaseTransition = BaseTransitionImpl as any as {
export const BaseTransition = BaseTransitionImpl as unknown as {
new (): {
$props: BaseTransitionProps<any>
}
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-core/src/components/Suspense.ts
Expand Up @@ -89,7 +89,9 @@ export const SuspenseImpl = {
}

// Force-casted public typing for h and TSX props inference
export const Suspense = (__FEATURE_SUSPENSE__ ? SuspenseImpl : null) as any as {
export const Suspense = (__FEATURE_SUSPENSE__
? SuspenseImpl
: null) as unknown as {
__isSuspense: true
new (): { $props: VNodeProps & SuspenseProps }
}
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-core/src/components/Teleport.ts
Expand Up @@ -52,13 +52,13 @@ const resolveTarget = <T = RendererElement>(
`ideally should be outside of the entire Vue component tree.`
)
}
return target as any
return target as T
}
} else {
if (__DEV__ && !targetSelector && !isTeleportDisabled(props)) {
warn(`Invalid Teleport target: ${targetSelector}`)
}
return targetSelector as any
return targetSelector as T
}
}

Expand Down Expand Up @@ -388,7 +388,7 @@ function hydrateTeleport(
}

// Force-casted public typing for h and TSX props inference
export const Teleport = TeleportImpl as any as {
export const Teleport = TeleportImpl as unknown as {
__isTeleport: true
new (): { $props: VNodeProps & TeleportProps }
}
24 changes: 12 additions & 12 deletions packages/runtime-core/src/devtools.ts
Expand Up @@ -28,7 +28,11 @@ interface DevtoolsHook {
once: (event: string, handler: Function) => void
off: (event: string, handler: Function) => void
appRecords: AppRecord[]
_buffer: any[][]
/**
* Added at https://github.com/vuejs/devtools/commit/f2ad51eea789006ab66942e5a27c0f0986a257f9
* Returns wether the arg was buffered or not
*/
cleanupBuffer?: (matchArg: unknown) => boolean
}

export let devtools: DevtoolsHook
Expand Down Expand Up @@ -109,18 +113,14 @@ const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
export const devtoolsComponentRemoved = (
component: ComponentInternalInstance
) => {
if (devtools && devtools._buffer.length) {
let wasBuffered = false
devtools._buffer = devtools._buffer.filter(item => {
if (item.some(arg => arg === component)) {
wasBuffered = true
return false
}
return true
})
if (wasBuffered) return
if (
devtools &&
typeof devtools.cleanupBuffer === 'function' &&
// remove the component if it wasn't buffered
!devtools.cleanupBuffer(component)
) {
_devtoolsComponentRemoved(component)
}
_devtoolsComponentRemoved(component)
}

function createDevtoolsComponentHook(hook: DevtoolsHooks) {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/h.ts
Expand Up @@ -108,7 +108,7 @@ export function h(
export function h(
type: typeof Teleport,
props: RawProps & TeleportProps,
children: RawChildren
children: RawChildren | RawSlots
): VNode

// suspense
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/helpers/withMemo.ts
Expand Up @@ -23,7 +23,7 @@ export function isMemoSame(cached: VNode, memo: any[]) {
if (prev.length != memo.length) {
return false
}

for (let i = 0; i < prev.length; i++) {
if (hasChanged(prev[i], memo[i])) {
return false
Expand Down
5 changes: 3 additions & 2 deletions packages/shared/src/index.ts
Expand Up @@ -52,7 +52,8 @@ export const isMap = (val: unknown): val is Map<any, any> =>
export const isSet = (val: unknown): val is Set<any> =>
toTypeString(val) === '[object Set]'

export const isDate = (val: unknown): val is Date => toTypeString(val) === '[object Date]'
export const isDate = (val: unknown): val is Date =>
toTypeString(val) === '[object Date]'
export const isFunction = (val: unknown): val is Function =>
typeof val === 'function'
export const isString = (val: unknown): val is string => typeof val === 'string'
Expand Down Expand Up @@ -99,7 +100,7 @@ const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
return ((str: string) => {
const hit = cache[str]
return hit || (cache[str] = fn(str))
}) as any
}) as T
}

const camelizeRE = /-(\w)/g
Expand Down
2 changes: 1 addition & 1 deletion packages/template-explorer/src/index.ts
Expand Up @@ -275,5 +275,5 @@ function debounce<T extends (...args: any[]) => any>(
fn(...args)
prevTimer = null
}, delay)
}) as any
}) as T
}
1 change: 1 addition & 0 deletions test-dts/h.test-d.ts
Expand Up @@ -47,6 +47,7 @@ describe('h inference w/ Fragment', () => {

describe('h inference w/ Teleport', () => {
h(Teleport, { to: '#foo' }, 'hello')
h(Teleport, { to: '#foo' }, { default() {} })
// @ts-expect-error
expectError(h(Teleport))
// @ts-expect-error
Expand Down

0 comments on commit 052eb8f

Please sign in to comment.