before_code
stringlengths
14
465k
reviewer_comment
stringlengths
16
64.5k
after_code
stringlengths
9
467k
diff_context
stringlengths
0
97k
file_path
stringlengths
5
226
comment_line
int32
0
26
language
stringclasses
37 values
quality_score
float32
0.07
1
comment_type
stringclasses
9 values
comment_length
int32
16
64.5k
before_lines
int32
1
17.2k
after_lines
int32
1
12.1k
is_negative
bool
2 classes
pr_title
stringlengths
1
308
pr_number
int32
1
299k
repo_name
stringclasses
533 values
repo_stars
int64
321
419k
repo_language
stringclasses
27 values
reviewer_username
stringlengths
0
39
author_username
stringlengths
2
39
test('merging props from global mixins and extends', () => { let renderProxy: any let extendedRenderProxy: any const render = () => h('div') const Comp = { mounted(this: ComponentPublicInstance) { renderProxy = this }, render, } const ExtendedComp = { extends: Comp, mounted(this:...
```suggestion return [h(CompA), h(CompB)] ``` Given we aren't checking the rendered output, I think it'd be clearer to omit the separator string.
// Note: emits and listener fallthrough is tested in // ./rendererAttrsFallthrough.spec.ts. import { type ComponentPublicInstance, createApp, defineComponent, h, nextTick, nodeOps, render, toHandlers, } from '@vue/runtime-test' import { isEmitListener } from '../src/componentEmits' describe('component...
@@ -599,3 +600,76 @@ describe('component: emit', () => { expect(renderFn).toHaveBeenCalledTimes(1) }) }) + +test('merging emits for a component that is also used as a mixin', () => { + const render = () => h('div') + const CompA = { + render, + } + + const mixin = { + emits: { + one: (arg: numbe...
packages/runtime-core/__tests__/componentEmits.spec.ts
26
TypeScript
0.714
suggestion
156
36
644
false
fix(runtime-core): use separate emits caches for components and mixins
11,661
vuejs/vue-next
25,296
TypeScript
skirtles-code
gcaaa31928
// Note: emits and listener fallthrough is tested in // ./rendererAttrsFallthrough.spec.ts. import { type ComponentPublicInstance, createApp, defineComponent, h, nextTick, nodeOps, render, toHandlers, } from '@vue/runtime-test' import { isEmitListener } from '../src/componentEmits' describe('component...
Perhaps rather than using the warning to check for correctness we could check which validator functions are called? If the validators use `vi.fn()` we could test for `toHaveBeenCalledTimes(1)` and `not.toHaveBeenCalled()`, as appropriate?
// Note: emits and listener fallthrough is tested in // ./rendererAttrsFallthrough.spec.ts. import { type ComponentPublicInstance, createApp, defineComponent, h, nextTick, nodeOps, render, toHandlers, } from '@vue/runtime-test' import { isEmitListener } from '../src/componentEmits' describe('component...
@@ -599,3 +600,76 @@ describe('component: emit', () => { expect(renderFn).toHaveBeenCalledTimes(1) }) }) + +test('merging emits for a component that is also used as a mixin', () => { + const render = () => h('div') + const CompA = { + render, + } + + const mixin = { + emits: { + one: (arg: numbe...
packages/runtime-core/__tests__/componentEmits.spec.ts
26
TypeScript
0.643
question
238
676
644
false
fix(runtime-core): use separate emits caches for components and mixins
11,661
vuejs/vue-next
25,296
TypeScript
skirtles-code
gcaaa31928
} class MutableReactiveHandler extends BaseReactiveHandler { constructor(isShallow = false) { super(false, isShallow) } set( target: Record<string | symbol, unknown>, key: string | symbol, value: unknown, receiver: object, ): boolean { let oldValue = target[key] if (!this._isShallo...
Would it maybe be better to use `target[key]` here instead of `oldValue`, so the logged value includes the readonly wrapper? - [Playground](https://deploy-preview-12141--vue-sfc-playground.netlify.app/#eNp9kT9PwzAQxb+K5aVBioL4M1UFCVAHGAABo5couQQXx7bscwiK8t05OzR0qLpY9u+9873TjfzO2qIPwNd84ysnLTIPGOyt0LKzxiEbmYOyQtlDTrc...
return res } } class MutableReactiveHandler extends BaseReactiveHandler { constructor(isShallow = false) { super(false, isShallow) } set( target: Record<string | symbol, unknown>, key: string | symbol, value: unknown, receiver: object, ): boolean { let oldValue = target[key] ...
@@ -151,7 +151,13 @@ class MutableReactiveHandler extends BaseReactiveHandler { } if (!isArray(target) && isRef(oldValue) && !isRef(value)) { if (isOldValueReadonly) { - return false + if (__DEV__) { + warn( + `Set operation on key "${String(key)}" failed...
packages/reactivity/src/baseHandlers.ts
26
TypeScript
0.643
question
590
51
51
false
fix(reactivity): warn on nested readonly ref update during unwrapping
12,141
vuejs/vue-next
25,296
TypeScript
skirtles-code
jh-leong
earlyRemove, delayedLeave, ) => { const leavingVNodesCache = getLeavingNodesForType( state, oldInnerChild!, ) leavingVNodesCache[String(oldInnerChild!.key)] = oldInnerChild! // early removal callback ...
```suggestion oldInnerChild = undefined ```
delayedLeave, ) => { const leavingVNodesCache = getLeavingNodesForType( state, oldInnerChild!, ) leavingVNodesCache[String(oldInnerChild!.key)] = oldInnerChild! // early removal callback el[leaveCbKey] = () => ...
@@ -238,18 +239,27 @@ const BaseTransitionImpl: ComponentOptions = { ) => { const leavingVNodesCache = getLeavingNodesForType( state, - oldInnerChild, + oldInnerChild!, ) - leavingVNodesCache[String(oldInnerChild.key)] = oldInnerCh...
packages/runtime-core/src/components/BaseTransition.ts
26
TypeScript
0.714
suggestion
51
51
51
false
fix(Transition): fix transition memory leak edge case
12,182
vuejs/vue-next
25,296
TypeScript
ferferga
edison1105
if (state.isLeaving) { return emptyPlaceholder(child) } // in the case of <transition><keep-alive/></transition>, we need to // compare the type of the kept-alive children. const innerChild = getInnerChild(child) if (!innerChild) { return emptyPlaceholder(child) ...
GitHub doesn't let me remove unmodified lines, but removing the previous ``oldChild`` and replacing it with this line: ```suggestion let oldInnerChild = instance.subTree && getInnerChild(instance.subTree) ``` Disposes the old node immediately.
if (state.isLeaving) { return emptyPlaceholder(child) } // in the case of <transition><keep-alive/></transition>, we need to // compare the type of the kept-alive children. const innerChild = getInnerChild(child) if (!innerChild) { return emptyPlaceholder(child) ...
@@ -199,7 +199,7 @@ const BaseTransitionImpl: ComponentOptions = { } const oldChild = instance.subTree - const oldInnerChild = oldChild && getInnerChild(oldChild) + let oldInnerChild = oldChild && getInnerChild(oldChild)
packages/runtime-core/src/components/BaseTransition.ts
26
TypeScript
0.857
suggestion
255
51
51
false
fix(Transition): fix transition memory leak edge case
12,182
vuejs/vue-next
25,296
TypeScript
ferferga
edison1105
*/ _?: SlotFlags } const isInternalKey = (key: string) => key[0] === '_' || key === '$stable' const normalizeSlotValue = (value: unknown): VNode[] => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value as VNodeChild)] const normalizeSlot = ( key: string, rawSlot: Function, rawSlot...
The condition will cause the following warning to never trigger. Removing the condition `|| (ctx && ctx.root === currentInstance.root)` will also prevent the warning from triggering in https://github.com/vuejs/core/blob/41e10dce085768a95f83cda175aef0c6cc42b2dd/packages/runtime-core/__tests__/componentSlots.spec.ts#L324...
* render function, and the optimization hint need to be on the slot object * itself to be preserved. * @internal */ _?: SlotFlags } const isInternalKey = (key: string) => key[0] === '_' || key === '$stable' const normalizeSlotValue = (value: unknown): VNode[] => isArray(value) ? value.map(normaliz...
@@ -87,17 +88,18 @@ const normalizeSlotValue = (value: unknown): VNode[] => const normalizeSlot = ( key: string, rawSlot: Function, - ctx: ComponentInternalInstance | null | undefined, + rawSlots: RawSlots, ): Slot => { if ((rawSlot as any)._n) { // already normalized - #5353 return rawSlot as Sl...
packages/runtime-core/src/componentSlots.ts
26
TypeScript
0.643
suggestion
395
51
51
false
fix(slots): properly warn if slot invoked in setup
12,195
vuejs/vue-next
25,296
TypeScript
edison1105
yangxiuxiu1115
instance.emit('hook:beforeMount') } toggleRecurse(instance, true) if (el && hydrateNode) { // vnode has adopted host node - perform hydration instead of mount. const hydrateSubTree = () => { if (__DEV__) { startMeasure(instance, `render`) ...
The `vnode.el` needs to be updated only if a mismatch occurs. So this is not the proper fix. The correct fix should be in the `handleMismatch` function. - update `vnode.el` as follows: https://github.com/vuejs/core/blob/ed01d9257104cf59d8330d96af77941b40494aa1/packages/runtime-core/src/components/Suspense.ts#L896-L89...
instance.emit('hook:beforeMount') } toggleRecurse(instance, true) if (el && hydrateNode) { // vnode has adopted host node - perform hydration instead of mount. const hydrateSubTree = () => { if (__DEV__) { startMeasure(instance, `render`) ...
@@ -1328,6 +1328,10 @@ function baseCreateRenderer( parentSuspense, null, ) + // when data-allow-mismatch is set, the component vnode's el may be incorrect, so it should be updated + if (initialVNode) {
packages/runtime-core/src/renderer.ts
26
TypeScript
0.786
suggestion
321
51
51
false
fix(hydration): the component vnode's el should be updated when a mismatch occurs.
12,255
vuejs/vue-next
25,296
TypeScript
edison1105
linzhe141
import { ElementTypes, type NodeTransform, NodeTypes, type ParentNode, type RootNode, type TemplateChildNode, createSimpleExpression, findDir, locStub, } from '@vue/compiler-dom' const filterChild = (node: ParentNode) => node.children.filter( n => n.type !== NodeTypes.COMMENT && n.type !== Node...
Doesn't this also need to check that the text node only contains whitespace? e.g. In this playground the attrs are incorrectly inherited in SSR mode because the text node is ignored: - [Playground](https://deploy-preview-12304--vue-sfc-playground.netlify.app/#__SSR__eNp9UctqwzAQ/JVFFHIJ9qE9BbfQhhxa6IOmR12MvXGUypK...
import { ElementTypes, type NodeTransform, NodeTypes, type ParentNode, type RootNode, type TemplateChildNode, createSimpleExpression, findDir, isCommentOrWhitespace, locStub, } from '@vue/compiler-dom' const filterChild = (node: ParentNode) => node.children.filter(n => !isCommentOrWhitespace(n)) ...
@@ -11,7 +11,9 @@ import { } from '@vue/compiler-dom' const filterChild = (node: ParentNode) => - node.children.filter(n => n.type !== NodeTypes.COMMENT) + node.children.filter( + n => n.type !== NodeTypes.COMMENT && n.type !== NodeTypes.TEXT,
packages/compiler-ssr/src/transforms/ssrInjectFallthroughAttrs.ts
15
TypeScript
0.5
bug
674
40
40
false
fix(compiler-ssr): handle ssr attr fallthrough when preserve whitespace
12,304
vuejs/vue-next
25,296
TypeScript
skirtles-code
edison1105
test('custom dir with normal attrs', () => { expect(getCompiledString(`<div class="foo" v-xxx />`)) .toMatchInlineSnapshot(` "\`<div\${ _ssrRenderAttrs(_temp0 = _mergeProps({ class: "foo" }, _ssrGetDirectiveProps(_ctx, _directive_xxx))) }>\${ ("textCon...
These test cases can pass without the following changes. The test cases should be written in `packages/server-renderer/__tests__/ssrDirectives.spec.ts` to verify the rendering result.
test('custom dir with normal attrs', () => { expect(getCompiledString(`<div class="foo" v-xxx />`)) .toMatchInlineSnapshot(` "\`<div\${ _ssrRenderAttrs(_temp0 = _mergeProps({ class: "foo" }, _ssrGetDirectiveProps(_ctx, _directive_xxx))) }>\${ ("textCon...
@@ -337,6 +337,39 @@ describe('ssr: element', () => { `) }) + test('custom dir with v-text', () => {
packages/compiler-ssr/__tests__/ssrElement.spec.ts
26
TypeScript
0.571
suggestion
185
51
51
false
fix(compiler-ssr): ensure v-text renders correctly with custom directives in SSR output
12,311
vuejs/vue-next
25,296
TypeScript
edison1105
mefcorvi
{ onClick: () => { this.counter++ }, }, 'Step', ), h('p', this.message), ] }, }) const root = nodeOps.createElement('div') render(h(Comp), root) expect(serializeInner(root)).toBe(`<button>St...
This could be simplified as: ```ts test('', () => { const spy = vi.fn() const c1 = computed(() => spy()) c1.value ref(0).value++ // update globalVersion c1.value expect(spy).toBeCalledTimes(1) }) ```
{ onClick: () => { this.counter++ }, }, 'Step', ), h('p', this.message), ] }, }) const root = nodeOps.createElement('div') render(h(Comp), root) expect(serializeInner(root)).toBe(`<button>St...
@@ -1012,6 +1012,42 @@ describe('reactivity/computed', () => { expect(cValue.value).toBe(1) }) + test('should not recompute when condition changes if computed does not track reactive data', async () => {
packages/reactivity/__tests__/computed.spec.ts
26
TypeScript
0.857
suggestion
245
51
51
false
fix(reactivity): should not recompute if computed does not track reactive data
12,341
vuejs/vue-next
25,296
TypeScript
jh-leong
edison1105
activeWatcher = currentEffect } } } } else { getter = NOOP __DEV__ && warnInvalidSource(source) } if (cb && deep) { const baseGetter = getter const depth = deep === true ? Infinity : deep getter = () => traverse(baseGetter(), depth) } const scope = getCurrentS...
Just a nit, could replace with `onScopeDispose(watchHandle)`
activeWatcher = currentEffect } } } } else { getter = NOOP __DEV__ && warnInvalidSource(source) } if (cb && deep) { const baseGetter = getter const depth = deep === true ? Infinity : deep getter = () => traverse(baseGetter(), depth) } const scope = getCurrentS...
@@ -215,8 +215,12 @@ export function watch( effect.stop() if (scope) { remove(scope.effects, effect) + remove(scope.cleanups, watchHandle) } } + if (scope) { + scope.cleanups.push(watchHandle) + }
packages/reactivity/src/watch.ts
26
TypeScript
0.571
suggestion
60
51
51
false
fix(reactivity): ensure watch cleanup on effect scope stop
12,373
vuejs/vue-next
25,296
TypeScript
jh-leong
edison1105
watch(clamped, spy) src.value = 2 expect(spy).toHaveBeenCalledTimes(1) src.value = 10 expect(spy).toHaveBeenCalledTimes(2) }) test('should ensure correct execution order in batch processing', () => { const dummy: number[] = [] const n1 = ref(0) const n2 = ref(0) const sum = com...
The test case might fit better in `packages/reactivity/__tests__/effectScope.spec.ts`
import { EffectScope, type Ref, WatchErrorCodes, type WatchOptions, type WatchScheduler, computed, onWatcherCleanup, ref, watch, } from '../src' const queue: (() => void)[] = [] // a simple scheduler for testing purposes let isFlushPending = false const resolvedPromise = /*@__PURE__*/ Promise.resolv...
@@ -277,4 +278,44 @@ describe('watch', () => { expect(dummy).toEqual([1, 2, 3]) }) + + test('removing a watcher while stopping its effectScope', async () => {
packages/reactivity/__tests__/watch.spec.ts
26
TypeScript
0.429
suggestion
85
51
281
false
fix(reactivity): ensure watch cleanup on effect scope stop
12,373
vuejs/vue-next
25,296
TypeScript
jh-leong
edison1105
: source(boundCleanup) } finally { activeWatcher = currentEffect } } } } else { getter = NOOP __DEV__ && warnInvalidSource(source) } if (cb && deep) { const baseGetter = getter const depth = deep === true ? Infinity : deep getter = () => travers...
I'm wondering whether there's an alternative to this. Registering the watch handle feels a bit heavy. Could we achieve the same result by just emptying the `effects` array inside `stop`? e.g. `this.effects.length = 0`? Maybe `cleanups` too?
: source(boundCleanup) } finally { activeWatcher = currentEffect } } } } else { getter = NOOP __DEV__ && warnInvalidSource(source) } if (cb && deep) { const baseGetter = getter const depth = deep === true ? Infinity : deep getter = () => travers...
@@ -215,8 +215,10 @@ export function watch( effect.stop() if (scope) { remove(scope.effects, effect) + remove(scope.cleanups, watchHandle) } } + onScopeDispose(watchHandle, true)
packages/reactivity/src/watch.ts
26
TypeScript
0.786
question
243
51
51
false
fix(reactivity): ensure watch cleanup on effect scope stop
12,373
vuejs/vue-next
25,296
TypeScript
skirtles-code
edison1105
} else if (__DEV__) { warn(`cannot run an inactive effect scope.`) } } /** * This should only be called on non-detached scopes * @internal */ on(): void { activeEffectScope = this } /** * This should only be called on non-detached scopes * @internal */ off(): void { ...
for what reason do you need to make this slice?
} else if (__DEV__) { warn(`cannot run an inactive effect scope.`) } } /** * This should only be called on non-detached scopes * @internal */ on(): void { activeEffectScope = this } /** * This should only be called on non-detached scopes * @internal */ off(): void { ...
@@ -119,17 +119,24 @@ export class EffectScope { if (this._active) { this._active = false let i, l - for (i = 0, l = this.effects.length; i < l; i++) { - this.effects[i].stop() + const effects = this.effects.slice()
packages/reactivity/src/effectScope.ts
26
TypeScript
0.071
question
47
51
51
false
fix(reactivity): ensure watch cleanup on effect scope stop
12,373
vuejs/vue-next
25,296
TypeScript
danyadev
edison1105
expect(container.innerHTML).toBe(`<div>1<div>1</div></div>`) list.push(2) await nextTick() expect(container.innerHTML).toBe(`<div>2<div>1</div></div>`) }) // #2413 it('EMPTY_ARR should not change', () => { const App = { template: `<div v-for="v of ['a']">{{ v }}</div>`, } const ...
This test can pass without the above changes.
expect(container.innerHTML).toBe(`<div>1<div>1</div></div>`) list.push(2) await nextTick() expect(container.innerHTML).toBe(`<div>2<div>1</div></div>`) }) // #2413 it('EMPTY_ARR should not change', () => { const App = { template: `<div v-for="v of ['a']">{{ v }}</div>`, } const ...
@@ -311,4 +311,34 @@ describe('compiler + runtime integration', () => { app.mount(root) expect(root.innerHTML).toBe('<div>60000000100000111</div>') }) + + test('should correctly update when reactive state and normal array are modified', async () => {
packages/vue/__tests__/index.spec.ts
26
TypeScript
0.143
suggestion
45
51
26
false
fix(runtime-core): handle patch stable fragment edge case
12,411
vuejs/vue-next
25,296
TypeScript
edison1105
linzhe141
expect(`Mixin has already been applied`).not.toHaveBeenWarned() app1.mount(document.createElement('div')) expect(mixin.created).toHaveBeenCalledTimes(1) }) // #5699 test('local app config should not affect other local apps in v3 mode', () => { Vue.configureCompat({ MODE: 3 }) const app1 = createApp({ r...
I'm wondering whether the tests for this should be in `misc.spec.ts` instead, as there are already tests for `ATTR_ENUMERATED_COERCION` in that file?
import Vue from '@vue/compat' import { effect, isReactive } from '@vue/reactivity' import { h, nextTick } from '@vue/runtime-core' import { DeprecationTypes, deprecationData, toggleDeprecationWarning, } from '../../runtime-core/src/compat/compatConfig' import { singletonApp } from '../../runtime-core/src/compat/g...
@@ -500,3 +500,11 @@ test('local app config should not affect other local apps in v3 mode', () => { const app2 = createApp({}) expect(app2.config.globalProperties.test).toBe(undefined) }) + +test('ATTR_ENUMERATED_COERCION: true', () => {
packages/vue-compat/__tests__/global.spec.ts
26
TypeScript
0.571
question
149
33
503
false
fix(compat): fix compat handler of draggable
12,445
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
} else { // attribute value is a string https://html.spec.whatwg.org/multipage/dom.html#attributes el.setAttribute( key, isBoolean ? '' : isSymbol(value) ? String(value) : value, ) } } } // 2.x compat const isEnumeratedAttr = __COMPAT__ ? /*@__PURE__*/ makeMap('contentedit...
I think the logic is correct, but it might be easier to understand if the `undefined` check were handled first?
} else { // attribute value is a string https://html.spec.whatwg.org/multipage/dom.html#attributes el.setAttribute( key, isBoolean ? '' : isSymbol(value) ? String(value) : value, ) } } } // 2.x compat const isEnumeratedAttr = __COMPAT__ ? /*@__PURE__*/ makeMap('contentedit...
@@ -59,9 +59,9 @@ export function compatCoerceAttr( ): boolean { if (isEnumeratedAttr(key)) { const v2CoercedValue = - value === null + value === null || value === false || value === 'false' ? 'false' - : typeof value !== 'boolean' && value !== undefined + : value !== undefined
packages/runtime-dom/src/modules/attrs.ts
26
TypeScript
0.643
question
111
51
51
false
fix(compat): fix compat handler of draggable
12,445
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
expect(vm.$el.getAttribute('draggable')).toBe('false') expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function )('draggable', null, 'false'),...
Is this needed? I think this is enabled in this file by default.
expect(vm.$el.getAttribute('draggable')).toBe('false') expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function )('draggable', null, 'false'),...
@@ -275,3 +275,17 @@ test('ATTR_ENUMERATED_COERCION', () => { )('contenteditable', 'foo', 'true'), ).toHaveBeenWarned() }) + +test('ATTR_ENUMERATED_COERCION: true', () => { + const vm = new Vue({ + compatConfig: { ATTR_ENUMERATED_COERCION: true },
packages/vue-compat/__tests__/misc.spec.ts
26
TypeScript
0.214
question
64
37
44
false
fix(compat): fix compat handler of draggable
12,445
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
expect(vm.$el).toBeInstanceOf(HTMLDivElement) expect(vm.$el.getAttribute('draggable')).toBe('false') expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .messa...
The test name should be more specific. Something like: ```suggestion test('ATTR_ENUMERATED_COERCION, coercing "false"', () => { ```
expect(vm.$el).toBeInstanceOf(HTMLDivElement) expect(vm.$el.getAttribute('draggable')).toBe('false') expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .messa...
@@ -275,3 +275,17 @@ test('ATTR_ENUMERATED_COERCION', () => { )('contenteditable', 'foo', 'true'), ).toHaveBeenWarned() }) + +test('ATTR_ENUMERATED_COERCION: true', () => {
packages/vue-compat/__tests__/misc.spec.ts
26
TypeScript
0.786
suggestion
134
39
46
false
fix(compat): fix compat handler of draggable
12,445
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function )('draggable', null, 'false'), ).toHaveBeenWarned() expect( ( deprecation...
I think we should also test boolean `false`. e.g.: ```suggestion template: `<div><div draggable="false" :spellcheck="false">hello</div></div>`, ``` Plus the relevant assertions.
expect(vm.$el.getAttribute('spellcheck')).toBe('true') expect(vm.$el.getAttribute('contenteditable')).toBe('true') expect( ( deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION] .message as Function )('draggable', null, 'false'), ).toHaveBeenWarned() expect( ( deprecation...
@@ -275,3 +275,17 @@ test('ATTR_ENUMERATED_COERCION', () => { )('contenteditable', 'foo', 'true'), ).toHaveBeenWarned() }) + +test('ATTR_ENUMERATED_COERCION: true', () => { + const vm = new Vue({ + compatConfig: { ATTR_ENUMERATED_COERCION: true }, + template: `<div><div draggable="false">hello</div></di...
packages/vue-compat/__tests__/misc.spec.ts
26
TypeScript
0.786
suggestion
185
36
43
false
fix(compat): fix compat handler of draggable
12,445
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
if (key === 'key' && this._app) { this._app._ceVNode!.key = val } } if (shouldUpdate && this._instance) { this._update() } // reflect if (shouldReflect) { const ob = this._ob ob && ob.disconnect() if (val === true) { this....
The reason for checking `this._app` here is that the test case will not pass. https://github.com/vuejs/core/blob/b7b093203775d292ede1ec5841452af9e2a7f3cc/packages/runtime-dom/__tests__/customElement.spec.ts#L137-L147 When re-inserting, `this._app` is `null` because we cleared it in `disconnectedCallback`. For custom ...
*/ _setProp( key: string, val: any, shouldReflect = true, shouldUpdate = false, ): void { if (val !== this._props[key]) { if (val === REMOVAL) { delete this._props[key] } else { this._props[key] = val // support set key on ceVNode if (key === 'key' ...
@@ -520,7 +520,9 @@ export class VueElement } private _update() { - render(this._createVNode(), this._root) + const vnode = this._createVNode() + if (this._app && !this._instance) vnode.appContext = this._app._context
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.786
bug
752
51
51
false
fix(custom-element): preserve appContext during update
12,455
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
if (key === 'key' && this._app) { this._app._ceVNode!.key = val } } if (shouldUpdate && this._instance) { this._update() } // reflect if (shouldReflect) { const ob = this._ob ob && ob.disconnect() if (val === true) { this....
@edison1105 I've found another issue related to this. When getting the current instance (with `getCurrentInstance`) and using it (with `withCtx`) after the root props have changed (where this `_update` function will be called) the context also gets lost. This would be fixed without the `!this._instance` check, but I ...
*/ _setProp( key: string, val: any, shouldReflect = true, shouldUpdate = false, ): void { if (val !== this._props[key]) { if (val === REMOVAL) { delete this._props[key] } else { this._props[key] = val // support set key on ceVNode if (key === 'key' ...
@@ -520,7 +520,9 @@ export class VueElement } private _update() { - render(this._createVNode(), this._root) + const vnode = this._createVNode() + if (this._app && !this._instance) vnode.appContext = this._app._context
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.643
suggestion
645
51
51
false
fix(custom-element): preserve appContext during update
12,455
vuejs/vue-next
25,296
TypeScript
danieldasilva-smake
edison1105
} else if (typeof val === 'string' || typeof val === 'number') { this.setAttribute(hyphenate(key), val + '') } else if (!val) { this.removeAttribute(hyphenate(key)) } ob && ob.observe(this, { attributes: true }) } } } private _update() { const vnode...
Whether it's an HMR update or not, the `appContext` needs to be preserved
if (key === 'key' && this._app) { this._app._ceVNode!.key = val } } if (shouldUpdate && this._instance) { this._update() } // reflect if (shouldReflect) { const ob = this._ob ob && ob.disconnect() if (val === true) { this....
@@ -520,7 +520,9 @@ export class VueElement } private _update() { - render(this._createVNode(), this._root) + const vnode = this._createVNode() + if (this._app) vnode.appContext = this._app._context
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.357
suggestion
73
51
51
false
fix(custom-element): preserve appContext during update
12,455
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
this._numberProps = numberProps if (isAsync) { // defining getter/setters on prototype // for sync defs, this already happened in the constructor this._resolveProps(def) } // apply CSS if (this.shadowRoot) { this._applyStyles(styles) } else if (__DEV...
What do you think about skipping the `if` check? ```suggestion def.configureApp = this._def.configureApp ``` It'd save a few bytes and I think it'd be a bit easier to read.
;(numberProps || (numberProps = Object.create(null)))[ camelize(key) ] = true } } } this._numberProps = numberProps this._resolveProps(def) // apply CSS if (this.shadowRoot) { this._applyStyles(styles) } else if (__DEV_...
@@ -403,9 +403,10 @@ export class VueElement const asyncDef = (this._def as ComponentOptions).__asyncLoader if (asyncDef) { - this._pendingResolve = asyncDef().then(def => - resolve((this._def = def), true), - ) + this._pendingResolve = asyncDef().then((def: InnerComponentDef) => { + ...
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.714
question
184
51
51
false
fix(custom-element): ensure configureApp is applied to async component
12,607
vuejs/vue-next
25,296
TypeScript
skirtles-code
edison1105
test('does not emit after unmount', async () => { const fn = vi.fn() const Foo = defineVaporComponent({ emits: ['closing'], setup(_, { emit }) { onBeforeUnmount(async () => { await nextTick() emit('closing', true) }) return [] }, }) cons...
there are no mixins in vapor mode
expect(isEmitListener(options, 'onClickOnce')).toBe(true) expect(isEmitListener(options, 'onclickOnce')).toBe(false) // kebab-case option expect(isEmitListener(options, 'onTestEvent')).toBe(true) // camelCase option expect(isEmitListener(options, 'onFooBar')).toBe(true) // PascalCase option ...
@@ -415,8 +424,4 @@ describe('component: emit', () => { await nextTick() expect(fn).not.toHaveBeenCalled() }) - - // NOTE: not supported mixins
packages/runtime-vapor/__tests__/componentEmits.spec.ts
26
TypeScript
0.071
suggestion
33
30
35
false
fix(runtime-vapor): properly normalize emits options if emits is an array
12,614
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
!isReadonly && track( rawTarget, TrackOpTypes.ITERATE, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY, ) // return a wrapped iterator which returns observed versions of the // values emitted from the real iterator return extend( // inheriting all iterator propert...
Can this part be removed? I think the inherited method will already return the appropriate `this` value.
!isReadonly && track( rawTarget, TrackOpTypes.ITERATE, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY, ) // return a wrapped iterator which returns observed versions of the // values emitted from the real iterator return extend( // inheriting all iterator propert...
@@ -55,22 +55,26 @@ function createIterableMethod( ) // return a wrapped iterator which returns observed versions of the // values emitted from the real iterator - return { - // iterator protocol - next() { - const { value, done } = innerIterator.next() - return done - ...
packages/reactivity/src/collectionHandlers.ts
26
TypeScript
0.571
suggestion
104
51
51
false
fix(reactivity): collection iteration should inherit iterator instance methods
12,644
vuejs/vue-next
25,296
TypeScript
skirtles-code
edison1105
ref('baz'), computed(() => 'hi'), ), ) }) // unref // #8747 declare const unref1: number | Ref<number> | ComputedRef<number> expectType<number>(unref(unref1)) // #11356 declare const unref2: | MaybeRef<string> | ShallowRef<string> | ComputedRef<string> | WritableComputedRef<string> expectTyp...
```diff - expectType<TemplateRef<unknown>>(tRef) + expectType<TemplateRef>(tRef) ```
ref('baz'), computed(() => 'hi'), ), ) }) // unref // #8747 declare const unref1: number | Ref<number> | ComputedRef<number> expectType<number>(unref(unref1)) // #11356 declare const unref2: | MaybeRef<string> | ShallowRef<string> | ComputedRef<string> | WritableComputedRef<string> expectTyp...
@@ -535,7 +536,7 @@ expectType<string>(toValue(unref2)) // useTemplateRef const tRef = useTemplateRef('foo') -expectType<Readonly<ShallowRef<unknown>>>(tRef) +expectType<TemplateRef<unknown>>(tRef)
packages-private/dts-test/ref.test-d.ts
26
TypeScript
0.714
suggestion
87
30
30
false
feat(types): add type TemplateRef
12,645
vuejs/vue-next
25,296
TypeScript
jh-leong
Shinigami92
) }) // unref // #8747 declare const unref1: number | Ref<number> | ComputedRef<number> expectType<number>(unref(unref1)) // #11356 declare const unref2: | MaybeRef<string> | ShallowRef<string> | ComputedRef<string> | WritableComputedRef<string> expectType<string>(unref(unref2)) // toValue expectType<numbe...
```diff - expectType<TemplateRef<HTMLElement | null>>(tRef2) + expectType<TemplateRef<HTMLElement>>(tRef2) ```
) }) // unref // #8747 declare const unref1: number | Ref<number> | ComputedRef<number> expectType<number>(unref(unref1)) // #11356 declare const unref2: | MaybeRef<string> | ShallowRef<string> | ComputedRef<string> | WritableComputedRef<string> expectType<string>(unref(unref2)) // toValue expectType<numbe...
@@ -535,7 +536,7 @@ expectType<string>(toValue(unref2)) // useTemplateRef const tRef = useTemplateRef('foo') -expectType<Readonly<ShallowRef<unknown>>>(tRef) +expectType<TemplateRef<unknown>>(tRef) const tRef2 = useTemplateRef<HTMLElement>('bar') -expectType<Readonly<ShallowRef<HTMLElement | null>>>(tRef2) +expe...
packages-private/dts-test/ref.test-d.ts
26
TypeScript
0.857
suggestion
113
27
27
false
feat(types): add type TemplateRef
12,645
vuejs/vue-next
25,296
TypeScript
jh-leong
Shinigami92
import { type ShallowRef, readonly, shallowRef } from '@vue/reactivity' import { getCurrentInstance } from '../component' import { warn } from '../warning' import { EMPTY_OBJ } from '@vue/shared' export const knownTemplateRefs: WeakSet<ShallowRef> = new WeakSet() export type TemplateRef<T = unknown> = Readonly<Shallo...
```diff - TemplateRef<T | null> + TemplateRef<T> ```
import { type ShallowRef, readonly, shallowRef } from '@vue/reactivity' import { getCurrentInstance } from '../component' import { warn } from '../warning' import { EMPTY_OBJ } from '@vue/shared' export const knownTemplateRefs: WeakSet<ShallowRef> = new WeakSet() export type TemplateRef<T = unknown> = Readonly<Shallo...
@@ -5,9 +5,11 @@ import { EMPTY_OBJ } from '@vue/shared' export const knownTemplateRefs: WeakSet<ShallowRef> = new WeakSet() +export type TemplateRef<T = unknown> = Readonly<ShallowRef<T | null>> + export function useTemplateRef<T = unknown, Keys extends string = string>( key: Keys, -): Readonly<ShallowRef<T |...
packages/runtime-core/src/helpers/useTemplateRef.ts
12
TypeScript
0.714
suggestion
55
37
37
false
feat(types): add type TemplateRef
12,645
vuejs/vue-next
25,296
TypeScript
jh-leong
Shinigami92
`the emits option nor as an "${toHandlerKey(camelize(event))}" prop.`, ) } } else { const validator = emitsOptions[event] if (isFunction(validator)) { const isValid = validator(...rawArgs) if (!isValid) { warn( `Invalid ...
The third argument here is not used when `__COMPAT__ && isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance)`, but adding a ternary for that here doesn't seem worth it.
) } } else { const validator = emitsOptions[event] if (isFunction(validator)) { const isValid = validator(...rawArgs) if (!isValid) { warn( `Invalid event arguments: event validation failed for event "${event}".`, ) ...
@@ -151,10 +152,14 @@ export function emit( } let args = rawArgs - const isModelListener = event.startsWith('update:') + const isModelListener = + __COMPAT__ && isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance) + ? compatModelEventPrefix + event in props + : event.startsWith('update:'...
packages/runtime-core/src/componentEmits.ts
26
TypeScript
0.714
suggestion
177
51
51
false
fix(compat): allow v-model built in modifiers on component
12,654
vuejs/vue-next
25,296
TypeScript
markrian
markrian
res[Symbol.iterator] = () => { let i = 0 return { next() { if (i < 2) { return { value: i++ ? modifiers || EMPTY_OBJ : res, done: false } } else { return { done: true } } }, } } return res } export const getModelModifiers = ( instance: Compon...
I was mostly guessing here, I don't know if this is "correct".
import { type Ref, customRef, ref } from '@vue/reactivity' import { EMPTY_OBJ, camelize, hasChanged, hyphenate } from '@vue/shared' import type { DefineModelOptions, ModelRef } from '../apiSetupHelpers' import { getCurrentInstance } from '../component' import { warn } from '../warning' import type { NormalizedProps } f...
@@ -118,9 +120,17 @@ export function useModel( } export const getModelModifiers = ( + instance: ComponentInternalInstance, props: Record<string, any>, modelName: string, ): Record<string, boolean> | undefined => { + if ( + __COMPAT__ && + isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance) ...
packages/runtime-core/src/helpers/useModel.ts
26
TypeScript
0.214
suggestion
62
35
130
false
fix(compat): allow v-model built in modifiers on component
12,654
vuejs/vue-next
25,296
TypeScript
markrian
markrian
// @ts-expect-error res[Symbol.iterator] = () => { let i = 0 return { next() { if (i < 2) { return { value: i++ ? modifiers || EMPTY_OBJ : res, done: false } } else { return { done: true } } }, } } return res } export const getModelModifiers...
This `__COMPAT__ && isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance)` check is repeated in a few places. It'd be nice if that were done only once, but I guess that might affect dead code elimination?
res[Symbol.iterator] = () => { let i = 0 return { next() { if (i < 2) { return { value: i++ ? modifiers || EMPTY_OBJ : res, done: false } } else { return { done: true } } }, } } return res } export const getModelModifiers = ( props: Record<st...
@@ -118,9 +120,17 @@ export function useModel( } export const getModelModifiers = ( + instance: ComponentInternalInstance, props: Record<string, any>, modelName: string, ): Record<string, boolean> | undefined => { + if ( + __COMPAT__ && + isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance)
packages/runtime-core/src/helpers/useModel.ts
26
TypeScript
0.714
question
212
37
27
false
fix(compat): allow v-model built in modifiers on component
12,654
vuejs/vue-next
25,296
TypeScript
markrian
markrian
} } else { const validator = emitsOptions[event] if (isFunction(validator)) { const isValid = validator(...rawArgs) if (!isValid) { warn( `Invalid event arguments: event validation failed for event "${event}".`, ) } ...
Not a big issue, but I was wondering about the extra bytes added to the non-compat build. It's only 6 bytes, but still. I experimented with a few ways to write this, and this version would keep the non-compat builds unchanged: ```suggestion const isCompatModelListener = __COMPAT__ && compatModelEventPrefi...
} } else { const validator = emitsOptions[event] if (isFunction(validator)) { const isValid = validator(...rawArgs) if (!isValid) { warn( `Invalid event arguments: event validation failed for event "${event}".`, ) } ...
@@ -151,10 +151,18 @@ export function emit( } let args = rawArgs - const isModelListener = event.startsWith('update:') + let isModelListener + let modifiers + if ( + __COMPAT__ && + (isModelListener = compatModelEventPrefix + event in props) + ) { + modifiers = props.modelModifiers + } else if ((...
packages/runtime-core/src/componentEmits.ts
26
TypeScript
0.857
suggestion
619
51
51
false
fix(compat): allow v-model built in modifiers on component
12,654
vuejs/vue-next
25,296
TypeScript
skirtles-code
markrian
set: val => (r.value = val), }) } } else if (__DEV__) { warn( `useTemplateRef() is called when there is no active component ` + `instance to be associated with.`, ) } const ret = __DEV__ ? readonly(r) : r if (__DEV__) { knownTemplateRefs.add(ret) } return ret } e...
```suggestion return (desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable ```
import { type ShallowRef, readonly, shallowRef } from '@vue/reactivity' import { type Data, getCurrentInstance } from '../component' import { warn } from '../warning' import { EMPTY_OBJ } from '@vue/shared' export const knownTemplateRefs: WeakSet<ShallowRef> = new WeakSet() export type TemplateRef<T = unknown> = Read...
@@ -38,3 +33,15 @@ export function useTemplateRef<T = unknown, Keys extends string = string>( } return ret } + +export function isUseTemplateRefKey(refs: Data, key: string): boolean { + let desc: PropertyDescriptor | undefined + if ( + (desc = Object.getOwnPropertyDescriptor(refs, key)) && + !desc.config...
packages/runtime-core/src/helpers/useTemplateRef.ts
26
TypeScript
0.714
suggestion
107
28
45
false
fix(useTemplateRef): don't update setup ref for useTemplateRef key
12,756
vuejs/vue-next
25,296
TypeScript
jacekkarczmarczyk
edison1105
reactive, reactiveMap, readonly, readonlyMap, shallowReactiveMap, shallowReadonlyMap, toRaw, } from './reactive' import { arrayInstrumentations } from './arrayInstrumentations' import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants' import { ITERATE_KEY, track, trigger } from './dep' imp...
This would break reactivity for a reactive property called `dep`: - [Playground](https://deploy-preview-12804--vue-sfc-playground.netlify.app/#eNp9kU1PwzAMhv+KlQugTa0mOE3dxId2gAMgPm65lMzrsrVJlDhjUpX/TpKysQPazX7fx9ZruWd3xhQ7j2zKKiesNAQOyZs5V7Iz2hL0YLEWJHcIAVZWd3AR+QuuuBJaOYLONTA7Qpc9LNFMYQLhiquqHJbGdbEh7ExbE8YOoFpP5n...
reactive, reactiveMap, readonly, readonlyMap, shallowReactiveMap, shallowReadonlyMap, toRaw, } from './reactive' import { arrayInstrumentations } from './arrayInstrumentations' import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants' import { ITERATE_KEY, track, trigger } from './dep' imp...
@@ -25,7 +25,9 @@ import { import { isRef } from './ref' import { warn } from './warning' -const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`) +const isNonTrackableKeys = /*@__PURE__*/ makeMap( + `__proto__,__v_isRef,__isVue,dep`, +)
packages/reactivity/src/baseHandlers.ts
26
TypeScript
0.571
suggestion
555
51
51
false
fix(reactivity): add `__v_skip` flag to `Dep` to prevent reactive conversion
12,804
vuejs/vue-next
25,296
TypeScript
skirtles-code
serkodev
expect(() => { obj.ror = true }).toThrow() expect(obj.ror).toBe(false) }) test('replacing a readonly ref nested in a reactive object with a new ref', () => { const r = ref(false) const ror = readonly(r) const obj = reactive({ ror }) obj.ror = ref(true) as unknown as boolean ex...
```suggestion test('should be able to trigger with triggerRef', () => { ```
expect(() => { obj.ror = true }).toThrow() expect(obj.ror).toBe(false) }) test('replacing a readonly ref nested in a reactive object with a new ref', () => { const r = ref(false) const ror = readonly(r) const obj = reactive({ ror }) obj.ror = ref(true) as unknown as boolean ex...
@@ -520,3 +522,16 @@ describe('reactivity/readonly', () => { expect(r.value).toBe(ro) }) }) + +test('should able to trigger on triggerRef', () => {
packages/reactivity/__tests__/readonly.spec.ts
26
TypeScript
0.643
suggestion
77
38
38
false
fix(reactivity): add `__v_skip` flag to `Dep` to prevent reactive conversion
12,804
vuejs/vue-next
25,296
TypeScript
skirtles-code
serkodev
optimized, internals, ) } else if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) { ;(type as typeof SuspenseImpl).process( n1, n2, container, anchor, parentComponent, parentSuspense, ...
```suggestion setRef(n1.ref, null, parentSuspense, n1, true) ``` - `oldRawRef` can be set to `null` during unset ref - `vnode` should be n1
slotScopeIds, optimized, internals, ) } else if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) { ;(type as typeof SuspenseImpl).process( n1, n2, container, anchor, parentComponent, ...
@@ -484,6 +484,8 @@ function baseCreateRenderer( // set ref if (ref != null && parentComponent) { setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2) + } else if (ref == null && n1 && n1.ref != null) { + setRef(n1.ref, n1.ref, parentSuspense, n2 || n1, true)
packages/runtime-core/src/renderer.ts
26
TypeScript
0.929
suggestion
149
51
51
false
fix(runtime-core): unset old ref during patching when new ref is absent
12,900
vuejs/vue-next
25,296
TypeScript
edison1105
inottn
refKey.value = 'bar' await nextTick() expect(refs.foo.value).toBe(null) expect(refs.bar.value).toBe(root.children[0]) }) it('render function ref unmount', async () => { const root = nodeOps.createElement('div') const el = ref(null) const toggle = ref(true) const Comp = { set...
```suggestion it('unset old ref when new ref is absent', async () => { ```
refKey.value = 'bar' await nextTick() expect(refs.foo.value).toBe(null) expect(refs.bar.value).toBe(root.children[0]) }) it('render function ref unmount', async () => { const root = nodeOps.createElement('div') const el = ref(null) const toggle = ref(true) const Comp = { set...
@@ -179,6 +179,37 @@ describe('api: template refs', () => { expect(el.value).toBe(null) }) + it('render function ref unmount with conditional update', async () => {
packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
26
TypeScript
0.571
suggestion
78
51
51
false
fix(runtime-core): unset old ref during patching when new ref is absent
12,900
vuejs/vue-next
25,296
TypeScript
edison1105
inottn
} if (n.type === 'universal') { const prev = selector.at(selector.index(n) - 1) const next = selector.at(selector.index(n) + 1) // * ... {} if (!prev) { // * .foo {} -> .foo[xxxxxxx] {} if (next) { if (next.type === 'combinator' && next.value === ' ') { ...
```suggestion // .foo * -> .foo[xxxxxxx] [xxxxxxx] ```
} if (n.type === 'universal') { const prev = selector.at(selector.index(n) - 1) const next = selector.at(selector.index(n) + 1) // * ... {} if (!prev) { // * .foo {} -> .foo[xxxxxxx] {} if (next) { if (next.type === 'combinator' && next.value === ' ') { ...
@@ -216,17 +217,21 @@ function rewriteSelector( return false } } - // .foo * -> .foo[xxxxxxx] * - if (node) return + // v- store this + // .foo * -> .foo[xxxxxxx] *[xxxxxxx]
packages/compiler-sfc/src/style/pluginScoped.ts
26
TypeScript
0.571
suggestion
62
51
51
false
fix(compiler-sfc): add scoping tag to trailing universal selector
12,918
vuejs/vue-next
25,296
TypeScript
edison1105
thecodewarrior
} } if (n.type === 'universal') { const prev = selector.at(selector.index(n) - 1) const next = selector.at(selector.index(n) + 1) // * ... {} if (!prev) { // * .foo {} -> .foo[xxxxxxx] {} if (next) { if (next.type === 'combinator' && next.value === ' ') {...
```suggestion // store the universal selector so it can be rewritten later ```
} } if (n.type === 'universal') { const prev = selector.at(selector.index(n) - 1) const next = selector.at(selector.index(n) + 1) // * ... {} if (!prev) { // * .foo {} -> .foo[xxxxxxx] {} if (next) { if (next.type === 'combinator' && next.value === ' ') {...
@@ -216,17 +217,21 @@ function rewriteSelector( return false } } - // .foo * -> .foo[xxxxxxx] * - if (node) return + // v- store this
packages/compiler-sfc/src/style/pluginScoped.ts
26
TypeScript
0.571
suggestion
86
51
51
false
fix(compiler-sfc): add scoping tag to trailing universal selector
12,918
vuejs/vue-next
25,296
TypeScript
edison1105
thecodewarrior
*/ private _childStyles?: Map<string, HTMLStyleElement[]> private _ob?: MutationObserver | null = null private _slots?: Record<string, Node[]> constructor( /** * Component def - note this may be an AsyncWrapper, and this._def will * be overwritten by the inner component when resolved. */ ...
Can you add unit tests for it?😎
*/ private _childStyles?: Map<string, HTMLStyleElement[]> private _ob?: MutationObserver | null = null private _slots?: Record<string, Node[]> constructor( /** * Component def - note this may be an AsyncWrapper, and this._def will * be overwritten by the inner component when resolved. */ ...
@@ -263,7 +264,7 @@ export class VueElement ) } if (_def.shadowRoot !== false) { - this.attachShadow({ mode: 'open' }) + this.attachShadow({ mode: 'open', ..._def.shadowRootOptions })
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.071
nitpick
31
51
51
false
feat(custom-element): allow specifying additional options for `shadowRoot` in custom elements
12,965
vuejs/vue-next
25,296
TypeScript
baiwusanyu-c
padcom
*/ private _childStyles?: Map<string, HTMLStyleElement[]> private _ob?: MutationObserver | null = null private _slots?: Record<string, Node[]> constructor( /** * Component def - note this may be an AsyncWrapper, and this._def will * be overwritten by the inner component when resolved. */ ...
```suggestion this.attachShadow(extend({}, _def.shadowRootOptions,{ mode: 'open' })) ``` to avoid `mode` being overwritten
*/ private _childStyles?: Map<string, HTMLStyleElement[]> private _ob?: MutationObserver | null = null private _slots?: Record<string, Node[]> constructor( /** * Component def - note this may be an AsyncWrapper, and this._def will * be overwritten by the inner component when resolved. */ ...
@@ -263,7 +264,7 @@ export class VueElement ) } if (_def.shadowRoot !== false) { - this.attachShadow({ mode: 'open' }) + this.attachShadow(extend({ mode: 'open' }, _def.shadowRootOptions))
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.786
suggestion
133
51
51
false
feat(custom-element): allow specifying additional options for `shadowRoot` in custom elements
12,965
vuejs/vue-next
25,296
TypeScript
edison1105
padcom
return start } export function queueJob(job: SchedulerJob): void { if (!(job.flags! & SchedulerJobFlags.QUEUED)) { const jobId = getId(job) const lastJob = queue[queue.length - 1] if ( !lastJob || // fast path when the job id is larger than the tail (!(job.flags! & SchedulerJobFlags.P...
I tested that revert this change and the change of line 50. tsc works fine.
return start } export function queueJob(job: SchedulerJob): void { if (!(job.flags! & SchedulerJobFlags.QUEUED)) { const jobId = getId(job) const lastJob = queue[queue.length - 1] if ( !lastJob || // fast path when the job id is larger than the tail (!(job.flags! & SchedulerJobFlags.P...
@@ -113,7 +118,9 @@ export function queueJob(job: SchedulerJob): void { function queueFlush() { if (!currentFlushPromise) { - currentFlushPromise = resolvedPromise.then(flushJobs) + currentFlushPromise = resolvedPromise.then(() => {
packages/runtime-core/src/scheduler.ts
26
TypeScript
0.286
suggestion
76
51
51
false
chore(types): compatible with TS 5.8
12,973
vuejs/vue-next
25,296
TypeScript
edison1105
yangmingshan
}, }).$mount() expect(vm.$el).toBeInstanceOf(HTMLButtonElement) expect(vm.$el.textContent).toBe(`0`) triggerEvent(vm.$el as Element, 'click') await nextTick() expect(vm.$el.textContent).toBe(`1`) expect(CompilerDeprecationTypes.COMPILER_V_BIND_SYNC).toHaveBeenWarned() }) test('COMPILER_V_BIND_OBJE...
```suggestion test('should not warn COMPILER_V_BIND_OBJECT_ORDER work with vFor', () => { ```
}, }).$mount() expect(vm.$el).toBeInstanceOf(HTMLButtonElement) expect(vm.$el.textContent).toBe(`0`) triggerEvent(vm.$el as Element, 'click') await nextTick() expect(vm.$el.textContent).toBe(`1`) expect(CompilerDeprecationTypes.COMPILER_V_BIND_SYNC).toHaveBeenWarned() }) test('COMPILER_V_BIND_OBJE...
@@ -93,6 +93,16 @@ test('COMPILER_V_BIND_OBJECT_ORDER', () => { ).toHaveBeenWarned() }) +test('COMPILER_V_BIND_OBJECT_ORDER', () => {
packages/vue-compat/__tests__/compiler.spec.ts
26
TypeScript
0.643
suggestion
95
51
51
false
fix(compat): should not warn COMPILER_V_BIND_OBJECT_ORDER when using v-bind together with v-for
12,993
vuejs/vue-next
25,296
TypeScript
edison1105
yangxiuxiu1115
// skip v-on in SSR compilation if (isVOn && ssr) { continue } if ( // #938: elements with dynamic keys should be forced into blocks (isVBind && isStaticArgOf(arg, 'key')) || // inline before-update hooks need to force block so that it is invoked // befor...
Given the new call to `pushMergeArg()` that's been added just before `mergeArgs.push(exp)`, I'm wondering whether this earlier call can now be moved inside the `if (__COMPAT__) {` check? For non-compat builds I think that'd be equivalent to what we have currently, with just a single call to `pushMergeArg()`, so we'd...
// skip v-on in SSR compilation if (isVOn && ssr) { continue } if ( // #938: elements with dynamic keys should be forced into blocks (isVBind && isStaticArgOf(arg, 'key')) || // inline before-update hooks need to force block so that it is invoked // befor...
@@ -594,8 +594,6 @@ export function buildProps( hasDynamicKeys = true if (exp) { if (isVBind) { - // #10696 in case a v-bind object contains ref - pushRefVForMarker() // have to merge early for compat build check pushMergeArg()
packages/compiler-core/src/transforms/transformElement.ts
26
TypeScript
0.643
suggestion
367
51
51
false
fix(compat): should not warn COMPILER_V_BIND_OBJECT_ORDER when using v-bind together with v-for
12,993
vuejs/vue-next
25,296
TypeScript
skirtles-code
yangxiuxiu1115
*/ emitsCache: WeakMap<ConcreteComponent, ObjectEmitsOptions | null> /** * HMR only * @internal */ reload?: () => void /** * v2 compat only * @internal */ filters?: Record<string, Function> } type PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...option...
What do you think about a note here to change options so in the next major the P can be removed? ```suggestion // TODO: in next major Options extends unknown[] and remove P Options = any[], ```
*/ emitsCache: WeakMap<ConcreteComponent, ObjectEmitsOptions | null> /** * HMR only * @internal */ reload?: () => void /** * v2 compat only * @internal */ filters?: Record<string, Function> } type PluginInstallFunction<Options = any[]> = Options extends unknown[] ? (app: App, ...option...
@@ -215,9 +215,10 @@ export type ObjectPlugin<Options = any[]> = { export type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> & Partial<ObjectPlugin<Options>> -export type Plugin<Options = any[]> = - | FunctionPlugin<Options> - | ObjectPlugin<Options> +export type Plugin< + Options = any[],
packages/runtime-core/src/apiCreateApp.ts
26
TypeScript
0.857
question
203
51
51
false
types: enhance plugin type inference for better IDE support
13,063
vuejs/vue-next
25,296
TypeScript
posva
jh-leong
const dotIndex = tag.indexOf('.') if (dotIndex > 0) { const ns = resolveSetupReference(tag.slice(0, dotIndex), context) if (ns) { tag = ns + tag.slice(dotIndex) asset = false } } if (asset) { context.component.add(tag) } } const hasVFor = node.props.some...
```suggestion root: singleRoot && !context.inVFor, ```
const dotIndex = tag.indexOf('.') if (dotIndex > 0) { const ns = resolveSetupReference(tag.slice(0, dotIndex), context) if (ns) { tag = ns + tag.slice(dotIndex) asset = false } } if (asset) { // self referencing component (inferred from filename) if (contex...
@@ -123,14 +123,18 @@ function transformComponentElement( } } + const hasVFor = node.props.some( + p => p.type === NodeTypes.DIRECTIVE && p.name === 'for', + ) + context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT context.dynamic.operation = { type: IRNodeTypes.CREATE_COMPON...
packages/compiler-vapor/src/transforms/transformElement.ts
26
TypeScript
0.571
suggestion
60
51
51
false
fix(compiler-vapor): prevent v-for components from being single root
13,149
vuejs/vue-next
25,296
TypeScript
edison1105
runyasak
`<my-el-parent-shadow-false data-v-app=""><!----></my-el-parent-shadow-false>`, ) isShown.value = true await nextTick() expect(container.innerHTML).toBe( `<my-el-parent-shadow-false data-v-app="" is-shown="">` + `<div>` + `<my-el-child-shadow-false data-v-app...
Hi @edison1105 , thanks for the fix, it works fine in our app as well! I'm not sure if it is related to the current issue or I need to create a separate one, but If in custom element slot we have a `v-if` clause, then it never renders even if the clause is true, but if it's `v-show` - it works fine.
return renderSlot(this.$slots, 'default') }, }, { shadowRoot: false }, ) customElements.define('my-el-teleport-parent', Parent) const App = { render() { return h('my-el-teleport-parent', null, { default: () => [ h('my-e...
@@ -1131,6 +1131,92 @@ describe('defineCustomElement', () => { expect(target.innerHTML).toBe(`<span>default</span>`) app.unmount() }) + + test('toggle nested custom element with shadowRoot: false', async () => {
packages/runtime-dom/__tests__/customElement.spec.ts
26
TypeScript
0.643
suggestion
303
51
51
false
fix(custom-element): ensure proper remount and prevent redundant slot parsing with shadowRoot false
13,201
vuejs/vue-next
25,296
TypeScript
wolandec
edison1105
ErrorCodes.APP_UNMOUNT_CLEANUP, ) render(null, app._container) if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { app._instance = null devtoolsUnmountApp(app) } delete app._container.__vue_app__ } else if (__DEV__) { warn(`...
Here I'm not sure if we should have a custom warning in cases where a value inherited from a parent element is overwritten, if we should simply ignore it or keep the same message.
) render(null, app._container) if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { app._instance = null devtoolsUnmountApp(app) } delete app._container.__vue_app__ } else if (__DEV__) { warn(`Cannot unmount an app that is not mounted.`)...
@@ -449,10 +449,18 @@ export function createAppAPI<HostElement>( provide(key, value) { if (__DEV__ && (key as string | symbol) in context.provides) { - warn( - `App already provides property with key "${String(key)}". ` + - `It will be overwritten with the new value.`,...
packages/runtime-core/src/apiCreateApp.ts
26
TypeScript
0.429
suggestion
179
51
51
false
fix(custom-element): allow injecting values ​​from app context in nested elements (fix #13212)
13,219
vuejs/vue-next
25,296
TypeScript
adrianbrs
adrianbrs
this._parent = parent break } } if (!this._instance) { if (this._resolved) { this._setParent() this._update() } else { if (parent && parent._pendingResolve) { this._pendingResolve = parent._pendingResolve.then(() => { this._pending...
This line is unnecessary because it's already inherit from `appContext.provides` https://github.com/vuejs/core/blob/4f792535e25af6941d1eb267fe16e4121623a006/packages/runtime-core/src/component.ts#L633
this._parent = parent break } } if (!this._instance) { if (this._resolved) { this._setParent() this._update() } else { if (parent && parent._pendingResolve) { this._pendingResolve = parent._pendingResolve.then(() => { this._pending...
@@ -316,7 +316,19 @@ export class VueElement private _setParent(parent = this._parent) { if (parent) { this._instance!.parent = parent._instance - this._instance!.provides = parent._instance!.provides + this._instance!.provides = this._instance!.appContext.provides
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.643
suggestion
201
51
51
false
fix(custom-element): allow injecting values ​​from app context in nested elements (fix #13212)
13,219
vuejs/vue-next
25,296
TypeScript
edison1105
adrianbrs
// otherwise, nothing needs to be done because the template ref // is forwarded to inner component return } const refValue = vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT ? getComponentPublicInstance(vnode.component!) : vnode.el const value = isUnmount ? null : refValue const { ...
There is no `setupState` on vapor component instance
// #4999 if an async component already resolved and cached by KeepAlive, // we need to set the ref to inner component if ( vnode.shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE && (vnode.type as ComponentOptions).__asyncResolved && vnode.component!.subTree.component ) { setRef(rawRef...
@@ -76,7 +76,7 @@ export function setRef( const setupState = owner.setupState const rawSetupState = toRaw(setupState) const canSetSetupRef = - setupState === EMPTY_OBJ + setupState === undefined || setupState === EMPTY_OBJ
packages/runtime-core/src/rendererTemplateRef.ts
26
TypeScript
0.357
suggestion
52
51
51
false
feat(vapor): templateRef vdom interop
13,323
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
// update vnode let parent = parentComponent while (parent) { if (parent.vnode.el === oldNode) { parent.vnode.el = parent.subTree.el = newNode } parent = parent.parent } } const isTemplateNode = (node: Node): node is HTMLTemplateElement => { return ( node.nodeTy...
```suggestion el: Element & { $cls?: string }, ```
} // update vnode let parent = parentComponent while (parent) { if (parent.vnode.el === oldNode) { parent.vnode.el = parent.subTree.el = newNode } parent = parent.parent } } const isTemplateNode = (node: Node): node is HTMLTemplateElement => { return ( node....
@@ -786,7 +787,7 @@ export function createHydrationFunctions( * Dev only */ function propHasMismatch( - el: Element, + el: Element & { $cls?: string | null },
packages/runtime-core/src/hydration.ts
26
TypeScript
0.571
suggestion
54
51
51
false
fix(hydration): handle transition appear hydration edge case
13,339
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
const isComponent = node.tagType === ElementTypes.COMPONENT const isDynamicComponent = isComponentTag(node.tag) const propsResult = buildProps( node, context as TransformContext<ElementNode>, isComponent, isDynamicComponent, getEffectIndex, ) let { parent } = context ...
```suggestion if (isComponent) { ```
const isComponent = node.tagType === ElementTypes.COMPONENT const isDynamicComponent = isComponentTag(node.tag) const propsResult = buildProps( node, context as TransformContext<ElementNode>, isComponent, isDynamicComponent, getEffectIndex, ) let { parent } = context ...
@@ -78,13 +81,23 @@ export const transformElement: NodeTransform = (node, context) => { parent.node.children.filter(child => child.type !== NodeTypes.COMMENT) .length === 1 - ;(isComponent ? transformComponentElement : transformNativeElement)( - node as any, - propsResult, - singleRo...
packages/compiler-vapor/src/transforms/transformElement.ts
26
TypeScript
0.429
suggestion
42
51
51
false
fix(compiler-vapor): correct execution order of operations
13,351
vuejs/vue-next
25,296
TypeScript
edison1105
zhiyuanzmj
X_MISSING_END_TAG, X_MISSING_INTERPOLATION_END, X_MISSING_DIRECTIVE_NAME, X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END, // transform errors X_V_IF_NO_EXPRESSION, X_V_IF_SAME_KEY, X_V_ELSE_NO_ADJACENT_IF, X_V_FOR_NO_EXPRESSION, X_V_FOR_MALFORMED_EXPRESSION, X_V_FOR_TEMPLATE_KEY_PLACEMENT, X_V_BIND_N...
```suggestion X_DEFINE_MODEL_NO_ASSIGNMENT, ``` I think this is more semantically clear.
X_MISSING_END_TAG, X_MISSING_INTERPOLATION_END, X_MISSING_DIRECTIVE_NAME, X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END, // transform errors X_V_IF_NO_EXPRESSION, X_V_IF_SAME_KEY, X_V_ELSE_NO_ADJACENT_IF, X_V_FOR_NO_EXPRESSION, X_V_FOR_MALFORMED_EXPRESSION, X_V_FOR_TEMPLATE_KEY_PLACEMENT, X_V_BIND_N...
@@ -90,7 +90,7 @@ export enum ErrorCodes { X_V_MODEL_ON_PROPS, X_INVALID_EXPRESSION, X_KEEP_ALIVE_INVALID_CHILDREN, - + X_DEFINE_MODEL_NO_VARIABLE,
packages/compiler-core/src/errors.ts
26
TypeScript
0.571
suggestion
95
51
51
false
fix(compiler-sfc): add error handling for defineModel() without variable assignment
13,352
vuejs/vue-next
25,296
TypeScript
KazariEX
runyasak
}) </script>`).content, ) }) test('should allow defineProps/Emit() referencing imported binding', () => { assertCode( compile(`<script setup> import { bar } from './bar' defineProps({ foo: { default: () => bar } }) ...
```suggestion const model = defineModel({ ```
}) </script>`).content, ) }) test('should allow defineProps/Emit() referencing imported binding', () => { assertCode( compile(`<script setup> import { bar } from './bar' defineProps({ foo: { default: () => bar } }) ...
@@ -980,7 +980,7 @@ describe('SFC compile <script setup>', () => { expect(() => compile(`<script setup> let bar = 1 - defineModel({ + const model =defineModel({
packages/compiler-sfc/__tests__/compileScript.spec.ts
26
TypeScript
0.571
suggestion
55
51
51
false
fix(compiler-sfc): add error handling for defineModel() without variable assignment
13,352
vuejs/vue-next
25,296
TypeScript
edison1105
runyasak
/** Defines the human readable text alternative of aria-valuenow for a range widget. */ 'aria-valuetext'?: string } // Vue's style normalization supports nested arrays export type StyleValue = | false | null | undefined | string | CSSProperties | Array<StyleValue> export interface HTMLAttributes exten...
It's unclear to me whether this should be `enterKeyHint` or `enterkeyhint`. The React types use camelCase, but they also use camelCase for other things too. It looks like we don't usually follow that convention here. From what I can tell, this file typically uses lowercase for attributes, and only uses capital le...
'aria-rowspan'?: Numberish | undefined /** * Indicates the current "selected" state of various widgets. * @see aria-checked @see aria-pressed. */ 'aria-selected'?: Booleanish | undefined /** * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in t...
@@ -264,6 +264,14 @@ export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> { contextmenu?: string dir?: string draggable?: Booleanish + enterKeyHint?:
packages/runtime-dom/src/jsx.ts
26
TypeScript
0.786
suggestion
764
51
51
false
types(jsx): add new HTML attributes for improved JSX support
13,370
vuejs/vue-next
25,296
TypeScript
skirtles-code
jeffwcx
} else { // move internals.m( oldVNode!, parentNode, anchor, MoveType.REORDER, parentComponent as any, ) } frag.remove = parentNode => { if (fallbackNodes) { remove(fallbackNodes, parentNode) } else if (oldVNode) { intern...
Pass a plain object instead of a Proxy one
const vaporSlotsProxyHandler: ProxyHandler<any> = { get(target, key) { const slot = target[key] if (isFunction(slot)) { slot.__vapor = true } return slot }, } let vdomHydrateNode: HydrationRenderer['hydrateNode'] | undefined /** * Mount vdom component in vapor */ function createVDOMCompone...
@@ -151,7 +151,7 @@ function createVDOMComponent( const frag = new VaporFragment([]) const vnode = createVNode( component, - rawProps && new Proxy(rawProps, rawPropsProxyHandlers), + rawProps && extend({}, new Proxy(rawProps, rawPropsProxyHandlers)),
packages/runtime-vapor/src/vdomInterop.ts
26
TypeScript
0.143
suggestion
42
37
51
false
fix(runtime-vapor): pass plain object props to createVNode during vdom interop
13,382
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
export function genBlockContent( block: BlockIRNode, context: CodegenContext, root?: boolean, customReturns?: (returns: CodeFragment[]) => CodeFragment[], ): CodeFragment[] { const [frag, push] = buildCodeFragment() const { dynamic, effect, operation, returns } = block const resetBlock = context.enterBloc...
I'm feeling confused. why coose to add an suffix in the fiename instead of directly extending the corresponding IR to include this state?
export function genBlockContent( block: BlockIRNode, context: CodegenContext, root?: boolean, customReturns?: (returns: CodeFragment[]) => CodeFragment[], ): CodeFragment[] { const [frag, push] = buildCodeFragment() const { dynamic, effect, operation, returns } = block const resetBlock = context.enterBloc...
@@ -44,7 +44,21 @@ export function genBlockContent( const resetBlock = context.enterBlock(block) if (root) { - genResolveAssets('component', 'resolveComponent') + for (let name of context.ir.component) { + const id = toValidAssetId(name, 'component') + const maybeSelfReference = name.endsWith('_...
packages/compiler-vapor/src/generators/block.ts
26
TypeScript
0.429
question
137
51
51
false
fix(compiler-vapor): resolve implicitly self-referencing component
13,400
vuejs/vue-next
25,296
TypeScript
LittleSound
edison1105
const { createApp, ref } = (window as any).Vue createApp({ template: ` <div id="container"> <transition name="test-reflow"> <div v-if="toggle" class="test-reflow">content</div> </transition> </div> <button id="toggleBtn" @click="cli...
Unrelated to the goal of this PR, but this test was flaky for me locally (even before the change); I see in most other places in this file `nextFrame` is called before `transitionFinish` so I added it here as well but please let me know if adding it here is incorrect
) test( 'separate enter and leave', async () => { await page().evaluate(duration => { const { createApp, ref } = (window as any).Vue createApp({ template: ` <div id="container"> <transition name="test" :duration="{ ...
@@ -3082,6 +3082,7 @@ describe('e2e: Transition', () => { // enter await classWhenTransitionStart() + await nextFrame()
packages/vue/__tests__/e2e/Transition.spec.ts
26
TypeScript
0.643
bug
267
51
51
false
fix(runtime-core): avoid setting direct ref of useTemplateRef in dev
13,449
vuejs/vue-next
25,296
TypeScript
alex-snezhko
alex-snezhko
} else if (isRef(oldRef)) { if (canSetRef(oldRef)) { oldRef.value = null } // this type assertion is valid since `oldRef` has already been asserted to be non-null const oldRawRefAtom = oldRawRef as VNodeNormalizedRefAtom if (oldRawRefAtom.k) refs[oldRawRefAtom.k] = null } ...
PR looks good. `canSetRef` will be treeshaking in the PROD build. The test cases don't seem to cover this change.
} } else if (isRef(oldRef)) { if (canSetRef(oldRef)) { oldRef.value = null } // this type assertion is valid since `oldRef` has already been asserted to be non-null const oldRawRefAtom = oldRawRef as VNodeNormalizedRefAtom if (oldRawRefAtom.k) refs[oldRawRefAtom.k] = nul...
@@ -119,7 +134,9 @@ export function setRef( ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] - : ref.value + : canSetRef(ref) || !rawRef.k
packages/runtime-core/src/rendererTemplateRef.ts
26
TypeScript
0.571
suggestion
114
51
51
false
fix(runtime-core): avoid setting direct ref of useTemplateRef in dev
13,449
vuejs/vue-next
25,296
TypeScript
edison1105
alex-snezhko
import { type ComponentInternalOptions, type ComponentPropsOptions, EffectScope, type EmitFn, type EmitsOptions, ErrorCodes, type GenericAppContext, type GenericComponentInstance, type LifecycleHook, type NormalizedPropsOptions, type ObjectEmitsOptions, type SuspenseBoundary, callWithErrorHand...
Are all of the other side effects of `renderEffect` safe/desired to avoid in the event of a `v-once` e.g. `setCurrentInstance`, `beforeUpdate`/`updated` lifecycle hooks, `startMeasure` in `RenderEffect.fn()`?
isSingleRoot, once, appContext, ) } const _insertionParent = insertionParent const _insertionAnchor = insertionAnchor const _isLastInsertion = isLastInsertion if (isHydrating) { locateHydrationNode() } else { resetInsertionState() } const el = isHydrating ? (adoptTemp...
@@ -504,9 +508,10 @@ export function createComponentWithFallback( ;(el as any).$root = isSingleRoot if (rawProps) { - renderEffect(() => { + const setFn = () => setDynamicProps(el, [resolveDynamicProps(rawProps as RawProps)]) - }) + if (once) setFn()
packages/runtime-vapor/src/component.ts
26
TypeScript
0.643
question
208
601
51
false
feat(runtime-vapor): add support for v-once
13,459
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
anchor: RendererNode | null, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, namespace: ElementNamespace, slotScopeIds: string[] | null, optimized: boolean, ) => { if (n2.type === 'svg') { namespace = 'svg' } else if (n2.type === 'math'...
Can be changed to `const isVueCE = !!(n1.el && (n1.el as any)._isVueCE)` `patchElement` may cause `n1` to be unmounted, but `n1.el` still has a value after `patchElement`
anchor: RendererNode | null, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, namespace: ElementNamespace, slotScopeIds: string[] | null, optimized: boolean, ) => { if (n2.type === 'svg') { namespace = 'svg' } else if (n2.type === 'math'...
@@ -621,15 +621,24 @@ function baseCreateRenderer( optimized, ) } else { - patchElement( - n1, - n2, - parentComponent, - parentSuspense, - namespace, - slotScopeIds, - optimized, - ) + if (n1.el && (n1.el as VueElement)._isVueCE) {
packages/runtime-core/src/renderer.ts
26
TypeScript
0.571
suggestion
170
51
51
false
fix(custom-element): batch custom element prop patching
13,478
vuejs/vue-next
25,296
TypeScript
edison1105
alex-snezhko
PREPEND_NODE, CREATE_COMPONENT_NODE, SLOT_OUTLET_NODE, DIRECTIVE, DECLARE_OLD_REF, // consider make it more general IF, FOR, GET_TEXT_CHILD, } export interface BaseIRNode { type: IRNodeTypes } export type CoreHelper = keyof typeof import('packages/runtime-dom/src') export type VaporHelper = keyo...
Performance nit: can use `Set<number>`
PREPEND_NODE, CREATE_COMPONENT_NODE, SLOT_OUTLET_NODE, DIRECTIVE, DECLARE_OLD_REF, // consider make it more general IF, FOR, GET_TEXT_CHILD, } export interface BaseIRNode { type: IRNodeTypes } export type CoreHelper = keyof typeof import('packages/runtime-dom/src') export type VaporHelper = keyo...
@@ -49,6 +49,7 @@ export interface BlockIRNode extends BaseIRNode { type: IRNodeTypes.BLOCK node: RootNode | TemplateChildNode dynamic: IRDynamicInfo + dynamicComponents: number[]
packages/compiler-vapor/src/ir/index.ts
26
TypeScript
0.429
performance
38
51
51
false
feat(runtime-vapor): v-html and v-text work with component
13,496
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
} if (value == null) { el.removeAttribute('value') } } /** * Only called on text nodes! * Compiler should also ensure value passed here is already converted by * `toDisplayString` */ export function setText(el: Text & { $txt?: string }, value: string): void { if (el.$txt !== value) { el.nodeValue =...
Would this type signature/treatment of `el` within this function still be accurate for the new usage with dynamic components? For example could `.nodes` on the dynamic component be one of the other `Block` variants besides `Node`?
const oldValue = el.tagName === 'OPTION' ? el.getAttribute('value') : el.value const newValue = value == null ? '' : value if (oldValue !== newValue) { el.value = newValue } if (value == null) { el.removeAttribute('value') } } /** * Only called on text nodes! * Compiler should also ensure value p...
@@ -185,13 +185,16 @@ export function setText(el: Text & { $txt?: string }, value: string): void { } /** - * Used by setDynamicProps only, so need to guard with `toDisplayString` + * Used by + * - setDynamicProps, need to guard with `toDisplayString` + * - v-text on dynamic component, value passed here is already c...
packages/runtime-vapor/src/dom/prop.ts
26
TypeScript
0.786
question
230
51
51
false
feat(runtime-vapor): v-html and v-text work with component
13,496
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
/** * Used by setDynamicProps only, so need to guard with `toDisplayString` */ export function setElementText( el: Node & { $txt?: string }, value: unknown, ): void { if (el.$txt !== (value = toDisplayString(value))) { el.textContent = el.$txt = value as string } } export function setBlockText( block: ...
Nit this function name seems a bit misleading as it's used besides just warning on arrays
/** * Used by setDynamicProps only, so need to guard with `toDisplayString` */ export function setElementText( el: Node & { $txt?: string }, value: unknown, ): void { if (el.$txt !== (value = toDisplayString(value))) { el.textContent = el.$txt = value as string } } export function setBlockText( block:...
@@ -196,13 +199,81 @@ export function setElementText( } } +export function setBlockText( + block: Block & { $txt?: string }, + value: unknown, +): void { + value = value == null ? '' : value + if (block.$txt !== value) { + setTextToBlock(block, (block.$txt = value as string)) + } +} + +/** + * dev only + ...
packages/runtime-vapor/src/dom/prop.ts
26
TypeScript
0.286
nitpick
89
51
51
false
feat(runtime-vapor): v-html and v-text work with component
13,496
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
} /** * dev only */ function warnOnArrayBlock(prop: string): void { warn( `Extraneous non-props attributes (` + `${prop}) ` + `were passed to component but could not be automatically inherited ` + `because component renders text or multiple root nodes.`, ) } function setTextToBlock(block: ...
Is there a scenario where this could be a single-element array i.e. in which `setTextToBlock(block[0], value)` could be used? Likewise with `setHtmlToBlock`
} } /** * dev only */ function warnCannotSetProp(prop: string): void { warn( `Extraneous non-props attributes (` + `${prop}) ` + `were passed to component but could not be automatically inherited ` + `because component renders text or multiple root nodes.`, ) } function setTextToBlock(bl...
@@ -196,13 +199,81 @@ export function setElementText( } } +export function setBlockText( + block: Block & { $txt?: string }, + value: unknown, +): void { + value = value == null ? '' : value + if (block.$txt !== value) { + setTextToBlock(block, (block.$txt = value as string)) + } +} + +/** + * dev only + ...
packages/runtime-vapor/src/dom/prop.ts
26
TypeScript
0.571
suggestion
156
51
51
false
feat(runtime-vapor): v-html and v-text work with component
13,496
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
import { EMPTY_OBJ, extend, isFunction } from '@vue/shared' import { type RawProps, rawPropsProxyHandlers } from './componentProps' import type { RawSlots, VaporSlot } from './componentSlots' import { renderEffect } from './renderEffect' import { createTextNode } from './dom/node' import { optimizePropertyLookup } from...
Add `__interop` flag to the `$` to mark props that are passed from vdom component
unmountComponent, } from './component' import { type Block, VaporFragment, insert, remove } from './block' import { EMPTY_OBJ, extend, isFunction } from '@vue/shared' import { type RawProps, rawPropsProxyHandlers } from './componentProps' import type { RawSlots, VaporSlot } from './componentSlots' import { renderEffe...
@@ -52,7 +52,7 @@ const vaporInteropImpl: Omit< const instance = (vnode.component = createComponent( vnode.type as any as VaporComponent, { - $: [() => propsRef.value], + $: extend([() => propsRef.value], { __interop: true }),
packages/runtime-vapor/src/vdomInterop.ts
26
TypeScript
0.357
suggestion
81
51
51
false
fix(runtime-vapor): component emits vdom interop
13,498
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
// resolve props and slots for setup context if (!(__COMPAT__ && compatMountInstance)) { if (__DEV__) { startMeasure(instance, `init`) } setupComponent(instance, false, optimized) if (__DEV__) { endMeasure(instance, `init`) } } // avoid hydration for hmr up...
This is incorrect, a component cannot have `el` before mounting. If it has an `el`, it would trigger hydration logic instead of mounting.
// resolve props and slots for setup context if (!(__COMPAT__ && compatMountInstance)) { if (__DEV__) { startMeasure(instance, `init`) } setupComponent(instance, false, optimized) if (__DEV__) { endMeasure(instance, `init`) } } // avoid hydration for hmr up...
@@ -1226,6 +1226,7 @@ function baseCreateRenderer( if (!initialVNode.el) { const placeholder = (instance.subTree = createVNode(Comment)) processCommentNode(null, placeholder, container!, anchor) + initialVNode.el = placeholder.el
packages/runtime-core/src/renderer.ts
26
TypeScript
0.571
bug
137
51
51
false
fix(runtime-core): ensure correct anchor el for unresolved async components
13,560
vuejs/vue-next
25,296
TypeScript
edison1105
linzhe141
import { defineComponent, h } from '@vue/runtime-dom' import { makeInteropRender } from './_utils' import { createComponent, defineVaporComponent } from '../src' const define = makeInteropRender() describe('vdomInterop', () => { describe('props', () => { test('prevent hasOwnProperty error when props is null', (...
```suggestion test('should work if props are not provided', () => { ```
import { defineComponent, h } from '@vue/runtime-dom' import { makeInteropRender } from './_utils' import { createComponent, defineVaporComponent } from '../src' const define = makeInteropRender() describe('vdomInterop', () => { describe('props', () => { test('should work if props are not provided', () => { ...
@@ -5,7 +5,26 @@ import { createComponent, defineVaporComponent } from '../src' const define = makeInteropRender() describe('vdomInterop', () => { - describe.todo('props', () => {}) + describe('props', () => { + test('prevent hasOwnProperty error when props is null', () => {
packages/runtime-vapor/__tests__/vdomInterop.spec.ts
9
TypeScript
0.643
suggestion
77
34
34
false
fix(runtime-vapor): prevent hasOwnProperty error when props is null
13,564
vuejs/vue-next
25,296
TypeScript
edison1105
zhiyuanzmj
export function getComponentPublicInstance( instance: ComponentInternalInstance, ): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null { if (instance.exposed) { return ( instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { get(...
As far as I'm aware, we don't currently have any lookbehind assertions in the code. I'm not sure exactly which old browsers we support, but lookbehind was added around the same time as other syntax features we don't use. From what I can tell, lookbehind was added in `es2018` and the build target version is `es201...
export function getComponentPublicInstance( instance: ComponentInternalInstance, ): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null { if (instance.exposed) { return ( instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { get(...
@@ -1203,7 +1203,7 @@ export function getComponentPublicInstance( } } -const classifyRE = /(?:^|[-_])(\w)/g +const classifyRE = /(?<=^|[-_])\w/g
packages/runtime-core/src/component.ts
26
TypeScript
0.786
performance
551
51
51
false
perf: improve regexp performance with non-capturing groups
13,567
vuejs/vue-next
25,296
TypeScript
skirtles-code
KazariEX
nonConstantExps.every(e => isStaticExpression(e, context.options.bindingMetadata), ) || context.inVOnce if (isStatic) { context.registerOperation({ type: IRNodeTypes.SET_TEXT, element: id, values, }) } else { context.registerEffect(values, { type: IRNodeTypes.S...
This logic is duplicated with the code above (line 103). Perhaps we can extract a function that also incorporates the logic of `createTextLikeExpression`. - logic reusability - only traverse the children once ```ts function processTextLikeChildren(children:TextLike[]){ const exps:SimpleExpressionNode[]=[] ...
if (isStatic) { context.registerOperation({ type: IRNodeTypes.SET_TEXT, element: id, values, }) } else { context.registerEffect(values, { type: IRNodeTypes.SET_TEXT, element: id, values, }) } } function processTextContainer( children: TextLike[], context: T...
@@ -129,8 +143,14 @@ function processTextContainer( children: TextLike[], context: TransformContext<ElementNode>, ) { - const values = children.map(child => createTextLikeExpression(child, context)) + const values = children + .map(child => createTextLikeExpression(child, context))
packages/compiler-vapor/src/transforms/transformText.ts
26
TypeScript
1
refactor
576
51
51
false
fix(compiler-vapor): handle empty interpolation
13,592
vuejs/vue-next
25,296
TypeScript
edison1105
LittleSound
] function genTag() { if (operation.dynamic) { if (operation.dynamic.isStatic) { return genCall( helper('resolveDynamicComponent'), genExpression(operation.dynamic, context), ) } else { return ['() => (', ...genExpression(operation.dynamic, context), ')']...
```vue <Foo @handle-update="() => {}"/> ``` It is also necessary to convert `-` to `_`
] function genTag() { if (operation.dynamic) { if (operation.dynamic.isStatic) { return genCall( helper('resolveDynamicComponent'), genExpression(operation.dynamic, context), ) } else { return ['() => (', ...genExpression(operation.dynamic, context), ')']...
@@ -102,6 +102,7 @@ export function genCreateComponent( function getUniqueHandlerName(context: CodegenContext, name: string): string { const { seenInlineHandlerNames } = context + name = name.replace(':', '_')
packages/compiler-vapor/src/generators/component.ts
26
TypeScript
0.714
suggestion
91
51
51
false
fix(compiler-vapor): handle special characters in cached variable names
13,626
vuejs/vue-next
25,296
TypeScript
edison1105
zhiyuanzmj
expressions, { type: IRNodeTypes.SET_DYNAMIC_PROPS, element: context.reference(), props: dynamicArgs, root: singleRoot, }, getEffectIndex, ) } else { let needsQuoting = false for (const prop of propsResult[1]) { const { key, values } = prop ...
This is a partial fix for `value='"foo"'` being turned into `value=""foo""`, I don't think this is the way to do it though, especially since this doesn't escape `&` as well. I've looked into how Vue compiler deals with entities and it seems that we only ever do decoding (which makes sense for the original compiler, ...
const ns = resolveSetupReference(tag.slice(0, dotIndex), context) if (ns) { tag = ns + tag.slice(dotIndex) asset = false } } if (asset) { // self referencing component (inferred from filename) if (context.selfName && capitalize(camelize(tag)) === context.selfName) ...
@@ -221,11 +221,30 @@ function transformNativeElement( getEffectIndex, ) } else { + let needsQuoting = false + for (const prop of propsResult[1]) { const { key, values } = prop if (key.isStatic && values.length === 1 && values[0].isStatic) { - template += ` ${key.content}` - ...
packages/compiler-vapor/src/transforms/transformElement.ts
26
TypeScript
0.571
security
455
51
51
false
refactor(compiler-vapor): skip unnecessary attribute quoting in templates
13,673
vuejs/vue-next
25,296
TypeScript
mary-ext
mary-ext
if (propsResult[0] /* dynamic props */) { const [, dynamicArgs, expressions] = propsResult context.registerEffect( expressions, { type: IRNodeTypes.SET_DYNAMIC_PROPS, element: context.reference(), props: dynamicArgs, root: singleRoot, }, getEffectIndex, ...
I've noticed that the browser diverges slightly from the specification here, the backticks and open angled bracket aren't something browser parsers cares about, and single/double quotes only matters if it's at the *start* of the value. This can be tested on the console: ```js template = document.createElement('tem...
const dotIndex = tag.indexOf('.') if (dotIndex > 0) { const ns = resolveSetupReference(tag.slice(0, dotIndex), context) if (ns) { tag = ns + tag.slice(dotIndex) asset = false } } if (asset) { // self referencing component (inferred from filename) if (conte...
@@ -221,11 +221,30 @@ function transformNativeElement( getEffectIndex, ) } else { + let needsQuoting = false + for (const prop of propsResult[1]) { const { key, values } = prop if (key.isStatic && values.length === 1 && values[0].isStatic) { - template += ` ${key.content}` - ...
packages/compiler-vapor/src/transforms/transformElement.ts
26
TypeScript
0.857
style
592
51
51
false
refactor(compiler-vapor): skip unnecessary attribute quoting in templates
13,673
vuejs/vue-next
25,296
TypeScript
mary-ext
mary-ext
identifiers[id].unshift(map[id] || id) } const ret = fn() ids.forEach(id => remove(identifiers[id], map[id] || id)) return ret } enterBlock(block: BlockIRNode) { const parent = this.block this.block = block return (): BlockIRNode => (this.block = parent) } scopeLevel: numbe...
A small optimization could be to analyze the `bindingMetadata` in the constructor ahead of time and create a mapping for what the next free name/number is; i.e. if `bindingMetadata` has `t0`, `t1`, `t2`, and `t4` then this mapping could be built like `{ 0 => 3, 1 => 3, 2 => 3, 4 => 5 }` and it can be looked up for cons...
identifiers: Record<string, (string | SimpleExpressionNode)[]> = Object.create(null) seenInlineHandlerNames: Record<string, number> = Object.create(null) block: BlockIRNode withId<T>( fn: () => T, map: Record<string, string | SimpleExpressionNode | null>, ): T { const { identifiers } = this...
@@ -68,6 +70,30 @@ export class CodegenContext { return [this.scopeLevel++, () => this.scopeLevel--] as const } + seenVarNames: Set<string> = new Set() + templateVars: Map<number, string> = new Map() + genVarName(prefix: string, baseNum: number): string { + let num = baseNum + let name = `${prefix}${...
packages/compiler-vapor/src/generate.ts
26
TypeScript
0.643
performance
415
51
51
false
refactor(compiler-vapor): generate unique variable to prevent collisions with user variables
13,822
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
enterScope(): [level: number, exit: () => number] { return [this.scopeLevel++, () => this.scopeLevel--] as const } private templateVars: Map<number, string> = new Map() private nextIdMap: Map<string, Map<number, number>> = new Map() private lastIdMap: Map<string, number> = new Map() private lastTIndex:...
Nit: I think `nums` would always have at least one value based on how `set` is always added to
enterScope(): [level: number, exit: () => number] { return [this.scopeLevel++, () => this.scopeLevel--] as const } private templateVars: Map<number, string> = new Map() private nextIdMap: Map<string, Map<number, number>> = new Map() private lastIdMap: Map<string, number> = new Map() private lastTIndex:...
@@ -68,6 +86,56 @@ export class CodegenContext { return [this.scopeLevel++, () => this.scopeLevel--] as const } + private templateVars: Map<number, string> = new Map() + private nextIdMap: Map<string, Map<number, number>> = new Map() + private lastIdMap: Map<string, number> = new Map() + private lastTInde...
packages/compiler-vapor/src/generate.ts
26
TypeScript
0.357
nitpick
94
51
51
false
refactor(compiler-vapor): generate unique variable to prevent collisions with user variables
13,822
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
} enterBlock(ir: BlockIRNode, isVFor: boolean = false): () => void { const { block, template, dynamic, childrenTemplate, slots } = this this.block = ir this.dynamic = ir.dynamic this.template = '' this.childrenTemplate = [] this.slots = [] isVFor && this.inVFor++ return () => { ...
Nit: can use `getNextId(this.nextIdMap, this.globalId)`
} enterBlock(ir: BlockIRNode, isVFor: boolean = false): () => void { const { block, template, dynamic, childrenTemplate, slots } = this this.block = ir this.dynamic = ir.dynamic this.template = '' this.childrenTemplate = [] this.slots = [] isVFor && this.inVFor++ return () => { ...
@@ -117,7 +121,34 @@ export class TransformContext<T extends AllNode = AllNode> { } } - increaseId = (): number => this.globalId++ + increaseId = (): number => { + // allocate an id that won't conflict with user-defined bindings when used + // as generated identifiers with n/x/r prefixes (e.g., n1, x1...
packages/compiler-vapor/src/transform.ts
26
TypeScript
0.429
nitpick
55
51
51
false
refactor(compiler-vapor): generate unique variable to prevent collisions with user variables
13,822
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
type, timeout, propCount, hasTransform, } } function getTimeout(delays: string[], durations: string[]): number { while (delays.length < durations.length) { delays = delays.concat(delays) } return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))) } // Old versions of Chromium ...
Consider adding a parameter to `forceReflow` to pass in the `el`. The places where it is called can easily access the `el`.
timeout, propCount, hasTransform, } } function getTimeout(delays: string[], durations: string[]): number { while (delays.length < durations.length) { delays = delays.concat(delays) } return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))) } // Old versions of Chromium (below 61....
@@ -477,5 +478,6 @@ function toMs(s: string): number { // synchronously force layout to put elements into a certain state export function forceReflow(): number {
packages/runtime-dom/src/components/Transition.ts
26
TypeScript
0.571
suggestion
123
30
29
false
fix(transition-group): run `forceReflow` on the correct document (fix #13849)
13,853
vuejs/vue-next
25,296
TypeScript
edison1105
zusorio
} else { ;(this._styles || (this._styles = [])).push(s) } } } } /** * Only called when shadowRoot is false */ private _parseSlots() { const slots: VueElement['_slots'] = (this._slots = {}) let n while ((n = this.firstChild)) { const slotName = (...
const outlets = getSlots([this._teleportTargets, this])
this._childStyles.set(owner.__hmrId, (entry = [])) } entry.push(s) } } else { ;(this._styles || (this._styles = [])).push(s) } } } } /** * Only called when shadowRoot is false */ private _parseSlots() { const slots: Vue...
@@ -635,7 +635,7 @@ export class VueElement * Only called when shadowRoot is false */ private _renderSlots() { - const outlets = (this._teleportTarget || this).querySelectorAll('slot') + const outlets = [...getSlots(this._teleportTargets), ...getSlots([this])]
packages/runtime-dom/src/apiCustomElement.ts
26
TypeScript
0.214
suggestion
55
51
51
false
fix(custom-element): properly mount multiple Teleports in custom element component w/ shadowRoot false
13,900
vuejs/vue-next
25,296
TypeScript
edison1105
linzhe141
dir: VaporDirectiveNode, context: TransformContext<ElementNode>, ) { if (!dir.exp) { context.options.onError( createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc), ) return } const parseResult = dir.forParseResult if (!parseResult) { context.options.onError( createCompi...
Should comment nodes be ignored here or would that cause problems?
node: ElementNode, dir: VaporDirectiveNode, context: TransformContext<ElementNode>, ): (() => void) | undefined { if (!dir.exp) { context.options.onError( createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc), ) return } const parseResult = dir.forParseResult if (!parseResult) {...
@@ -47,7 +47,13 @@ export function processFor( const keyProp = findProp(node, 'key') const keyProperty = keyProp && propToExpression(keyProp) - const isComponent = node.tagType === ElementTypes.COMPONENT + const isComponent = + node.tagType === ElementTypes.COMPONENT || + // template v-for with a single...
packages/compiler-vapor/src/transforms/vFor.ts
26
TypeScript
0.286
question
66
51
51
false
fix(compiler-vapor): treat template v-for with single component child as component
13,914
vuejs/vue-next
25,296
TypeScript
alex-snezhko
edison1105
import { type WatchOptions as BaseWatchOptions, type DebuggerOptions, type ReactiveMarker, type WatchCallback, type WatchEffect, type WatchHandle, type WatchSource, watch as baseWatch, } from '@vue/reactivity' import { type SchedulerJob, SchedulerJobFlags, queueJob } from './scheduler' import { EMPTY_OB...
Any reason why you are importing from the package level instead of using a relative import?
import { type WatchOptions as BaseWatchOptions, type DebuggerOptions, type ReactiveMarker, type WatchCallback, type WatchEffect, type WatchHandle, type WatchSource, watch as baseWatch, } from '@vue/reactivity' import { type SchedulerJob, SchedulerJobFlags, queueJob } from './scheduler' import { EMPTY_OB...
@@ -21,6 +21,7 @@ import { queuePostRenderEffect } from './renderer' import { warn } from './warning' import type { ObjectWatchOptionItem } from './componentOptions' import { useSSRContext } from './helpers/useSsrContext' +import type { ComponentPublicInstance } from '@vue/runtime-core'
packages/runtime-core/src/apiWatch.ts
24
TypeScript
0.286
question
91
49
49
false
chore(types): improve type safety in watch functions and instanceWatch
13,918
vuejs/vue-next
25,296
TypeScript
absidue
ArthurDarkstone
// eslint-disable-next-line no-restricted-syntax parent?.type === 'ObjectPattern' ) { // mark property in destructure pattern ;(node as any).inPattern = true } else if (isFunctionType(node)) { if (node.scopeIds) { node.scopeIds.forEach(id => markKnownIds(id,...
should be: ```js if (node.scopeIds) { node.scopeIds.forEach(id => markKnownIds(id, knownIds)) } else { walkSwitchStatment() } ```
// eslint-disable-next-line no-restricted-syntax parent?.type === 'ObjectPattern' ) { // mark property in destructure pattern ;(node as any).inPattern = true } else if (isFunctionType(node)) { if (node.scopeIds) { node.scopeIds.forEach(id => markKnownIds(id,...
@@ -80,6 +82,10 @@ export function walkIdentifiers( markScopeIdentifier(node, id, knownIds), ) } + } else if (node.type === 'SwitchStatement') { + walkSwitchStatement(node, false, id =>
packages/compiler-core/src/babelUtils.ts
26
TypeScript
0.786
suggestion
149
51
51
false
fix(compiler-core): identifiers in switch-case should not be inferred as references
13,923
vuejs/vue-next
25,296
TypeScript
edison1105
wngtk
// or native onclick with function values if (key in el && isNativeOn(key) && isFunction(value)) { return true } return false } // these are enumerated attrs, however their corresponding DOM properties // are actually booleans - this leads to setting it with a string "false" // value lead...
I think we should be checking `el.tagName` too. It isn't checked for `spellcheck`, `draggable`, `translate` and `autocorrect` because they are global and can apply to any element. For other special `key` values we do usually check the `tagName`. `form` is an outlier. It did originally check the `tagName`, but ...
// or native onclick with function values if (key in el && isNativeOn(key) && isFunction(value)) { return true } return false } // these are enumerated attrs, however their corresponding DOM properties // are actually booleans - this leads to setting it with a string "false" // value lead...
@@ -111,6 +111,13 @@ function shouldSetAsProp( return false } + // #13946 iframe.sandbox should always be set as attribute since setting + // the property to null results in 'null' string, and setting to empty string + // enables the most restrictive sandbox mode instead of no sandboxing. + if (key === 's...
packages/runtime-dom/src/patchProp.ts
26
TypeScript
0.786
suggestion
612
51
51
false
fix(runtime-dom): ensure iframe sandbox is handled as an attribute to prevent unintended behavior
13,950
vuejs/vue-next
25,296
TypeScript
skirtles-code
dejour
PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions, >(props: PP): Prettify<Readonly<ExtractPropTypes<PP>>> // overload 3: typed-based declaration export function defineProps<TypeProps>(): DefineProps< LooseRequired<TypeProps>, BooleanKey<TypeProps> > // implementation export function defineProps...
```suggestion type BooleanKey<T, K extends keyof T = keyof T> = K extends any ? T[K] extends boolean | undefined ? T[K] extends never | undefined ? never : K : never : never ``` `boolean extends T[K]` will cause that `true` or `false` is not inferred as boolean keys.
PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions, >(props: PP): Prettify<Readonly<ExtractPropTypes<PP>>> // overload 3: typed-based declaration export function defineProps<TypeProps>(): DefineProps< LooseRequired<TypeProps>, BooleanKey<TypeProps> > // implementation export function defineProps...
@@ -99,7 +99,9 @@ export type DefineProps<T, BKeys extends keyof T> = Readonly<T> & { type BooleanKey<T, K extends keyof T = keyof T> = K extends any ? [T[K]] extends [boolean | undefined] - ? K + ? boolean extends T[K] + ? K + : never : never : never
packages/runtime-core/src/apiSetupHelpers.ts
26
TypeScript
1
suggestion
302
51
51
false
types(defineProps): avoid never props becoming boolean flags
14,059
vuejs/vue-next
25,296
TypeScript
KazariEX
edison1105
}, } const root = nodeOps.createElement('div') render(h(Comp), root) await nextTick() await Promise.all(deps) expect(serializeInner(root)).toBe( `<div>111</div><div>222</div><div>333</div>`, ) items.value = [ { id: 4, name: '444' }, { id...
If you want an even smaller reproduction: ```js const items = ref([4, 5, 6]); const App = { setup() { const loader = async () => defineComponent({ props: {item: Number}, setup(props) { return () => h('div', props.item) } }); const LazyTest = defineAsyncComponent({ loader:...
}, } const root = nodeOps.createElement('div') render(h(Comp), root) await nextTick() await Promise.all(deps) expect(serializeInner(root)).toBe( `<div>111</div><div>222</div><div>333</div>`, ) items.value = [ { id: 4, name: '444' }, { id...
@@ -2360,6 +2360,101 @@ describe('Suspense', () => { ) }) + // #14173 + test('nested async components with v-for + only Suspense and async component wrappers', async () => {
packages/runtime-core/__tests__/components/Suspense.spec.ts
26
TypeScript
0.929
suggestion
1,162
51
51
false
fix(runtime-core): ensure correct anchor el for deeper unresolved async components
14,182
vuejs/vue-next
25,296
TypeScript
Tofandel
linzhe141
expect(input.value).toBe('bar') expect(span.textContent).toBe('bar') } test('with model modifiers', async () => { await runTestWithModifier({ name: 'CustomInput', props: ['value'], template: `<input :value="value" @input="$emit('input', $event.target.value)">`, }) }) test('wi...
```suggestion test('should handle v-model deprecation warning with missing appContext', async () => { ```
expect(input.value).toBe('bar') expect(span.textContent).toBe('bar') } test('with model modifiers', async () => { await runTestWithModifier({ name: 'CustomInput', props: ['value'], template: `<input :value="value" @input="$emit('input', $event.target.value)">`, }) }) test('wi...
@@ -140,4 +140,41 @@ describe('COMPONENT_V_MODEL', () => { template: `<input :value="foo" @input="$emit('bar', $event.target.value)">`, }) }) + + // #14202 + test('should handle v-model deprecation warning with missing appContext (#14202)', async () => {
packages/vue-compat/__tests__/componentVModel.spec.ts
26
TypeScript
0.929
suggestion
109
51
51
false
fix(compat): handle v-model deprecation warning with missing appContext
14,203
vuejs/vue-next
25,296
TypeScript
edison1105
edison1105
| 'cc-type' | 'country' | 'country-name' | 'current-password' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'name' | 'new-password' | 'one-time-code' | 'organization' | 'postal-code' | 'street-address' | 'transaction-amount' | 'transaction-currency' | 'user...
I don't think these types should be exported.
| 'cc-type' | 'country' | 'country-name' | 'current-password' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'name' | 'new-password' | 'one-time-code' | 'organization' | 'postal-code' | 'street-address' | 'transaction-amount' | 'transaction-currency' | 'user...
@@ -561,10 +561,72 @@ export type InputTypeHTMLAttribute = | 'week' | (string & {}) +export type AutoFillAddressKind = 'billing' | 'shipping' +export type AutoFillBase = '' | 'off' | 'on' +export type AutoFillContactField = + | 'email' + | 'tel' + | 'tel-area-code' + | 'tel-country-code' + | 'tel-extension...
packages/runtime-dom/src/jsx.ts
26
TypeScript
0.286
suggestion
45
51
51
false
types(jsx): improve autocomplete type
14,237
vuejs/vue-next
25,296
TypeScript
KazariEX
rzzf
) expect((container.firstChild!.firstChild as any)._value).toBe(true) }) // #7203 test('force hydrate custom element with dynamic props', () => { class MyElement extends HTMLElement { foo = '' constructor() { super() } } customElements.define('my-element-7203', MyEle...
```suggestion // #14274 test('should not render ref on custom element during hydration', () => { ```
) expect((container.firstChild!.firstChild as any)._value).toBe(true) }) // #7203 test('force hydrate custom element with dynamic props', () => { class MyElement extends HTMLElement { foo = '' constructor() { super() } } customElements.define('my-element-7203', MyEle...
@@ -1597,6 +1597,22 @@ describe('SSR hydration', () => { expect((container.firstChild as any).foo).toBe(msg.value) }) + test('should not render ref on custom element during hydration', () => {
packages/runtime-core/__tests__/hydration.spec.ts
26
TypeScript
0.786
suggestion
104
51
51
false
fix(runtime-core): skip patching reserved props for custom elements
14,275
vuejs/vue-next
25,296
TypeScript
danielroe
danielroe
if (!isHydrating) { this.initChildren() } } get parent(): ParentNode | null { return this.anchor ? this.anchor.parentNode : null } private initChildren(): void { renderEffect(() => { this.handleChildrenUpdate( this.rawSlots!.default && (this.rawSlots!.default as BlockFn)()...
should consider recursively processing child nodes see [repl with this PR](https://deploy-preview-14284--vue-sfc-playground.netlify.app/#eNp9U01PwzAM/Sshl4IE6wFOo5v4EAc4AAKOuXStNwJpEiVuGZr237HTbkyI7dLE773YL467ktfej7oW5FgWsQrao4iArRdd6V2YKqsbWlGsRIC5WIt5cI3I6EC2pW5d4wd8lHPA+YhWtnI2oqiccUFMOMFxFqDOTjZMfHdfA4GhBcKLvDdBhS...
if (!isHydrating) { this.initChildren() } } get parent(): ParentNode | null { return this.anchor ? this.anchor.parentNode : null } private initChildren(): void { renderEffect(() => { this.handleChildrenUpdate( this.rawSlots!.default && (this.rawSlots!.default as BlockFn)()...
@@ -116,6 +116,10 @@ export class TeleportFragment extends VaporFragment { ;(nodes.onUpdated || (nodes.onUpdated = [])).push(() => updateCssVars(this), ) + } else if (isVaporComponent(nodes) && isFragment(nodes.block)) {
packages/runtime-vapor/src/components/Teleport.ts
26
TypeScript
0.5
suggestion
703
51
51
false
fix(runtime-vapor): Loss of css var in Teleport
14,284
vuejs/vue-next
25,296
TypeScript
edison1105
jackma9604
return target[key] }, set() { warn(`setupContext.attrs is readonly.`) return false }, deleteProperty() { warn(`setupContext.attrs is readonly.`) return false }, } : { get(target: Data, key: string) { track(target, TrackOpTypes.GET...
Isn't this relevant to any build that runs in the browser? I'm not sure why only global builds would be affected. In-DOM templates aren't limited to global builds.
return target[key] }, set() { warn(`setupContext.attrs is readonly.`) return false }, deleteProperty() { warn(`setupContext.attrs is readonly.`) return false }, } : { get(target: Data, key: string) { track(target, TrackOpTypes.GET...
@@ -1110,17 +1111,20 @@ const attrsProxyHandlers = __DEV__ }, } -/** - * Dev-only - */ -function getSlotsProxy(instance: ComponentInternalInstance): Slots { - return new Proxy(instance.slots, { - get(target, key: string) { +const createSlotsProxyHandlers = ( + instance: ComponentInternalInstance, +):...
packages/runtime-core/src/component.ts
26
TypeScript
0.357
question
163
51
51
false
fix(runtime-core): resolve kebab-case slot names from in-DOM templates
14,302
vuejs/vue-next
25,296
TypeScript
skirtles-code
edison1105
owner: VaporComponentInstance | null, ): VaporComponentInstance | null { try { return currentSlotOwner } finally { currentSlotOwner = owner } } /** * Get the effective slot instance for accessing rawSlots and scopeId. * Prefers currentSlotOwner (if inside a slot), falls back to currentInstance. */ e...
The correct fix should be ```js const owner = getScopeOwner() ```
owner: VaporComponentInstance | null, ): VaporComponentInstance | null { try { return currentSlotOwner } finally { currentSlotOwner = owner } } /** * Get the effective slot instance for accessing rawSlots and scopeId. * Prefers currentSlotOwner (if inside a slot), falls back to currentInstance. */ e...
@@ -160,6 +160,8 @@ export function getScopeOwner(): VaporComponentInstance | null { */ export function withVaporCtx(fn: Function): BlockFn { const owner = currentInstance as VaporComponentInstance
packages/runtime-vapor/src/componentSlots.ts
26
TypeScript
0.643
suggestion
68
51
51
false
fix(runtime-vapor): take in account parent component scopeid on nested slot
14,326
vuejs/vue-next
25,296
TypeScript
edison1105
steel97
}).render() expect(host.innerHTML).toBe( '<div>content1<!--slot--></div>' + '<div>content2<!--slot--></div>' + '<div>content3<!--slot--></div>' + '<div>content4<!--slot--></div>' + '<div>content5<!--slot--></div>', ) // Update items items.v...
Move this test to `scopeId.spec.ts`
// NOTE: This test is implemented based on the case of `runtime-core/__test__/componentSlots.spec.ts`. import { child, createComponent, createFor, createForSlots, createIf, createSlot, createVaporApp, defineVaporComponent, insert, prepend, renderEffect, setInsertionState, template, txt, v...
@@ -2187,4 +2187,64 @@ describe('component: slots', () => { ) }) }) + + describe('scopeId', () => { + test('should set corret scopeId', async () => {
packages/runtime-vapor/__tests__/componentSlots.spec.ts
26
TypeScript
0.286
refactor
35
51
2,191
false
fix(runtime-vapor): take in account parent component scopeid on nested slot
14,326
vuejs/vue-next
25,296
TypeScript
edison1105
steel97
'aria-valuemin'?: Numberish | undefined /** * Defines the current value for a range widget. * @see aria-valuetext. */ 'aria-valuenow'?: Numberish | undefined /** Defines the human readable text alternative of aria-valuenow for a range widget. */ 'aria-valuetext'?: string | undefined } // Vue's style...
Shouldn't it be `Record<string, any>` to allow non-booleans `:class="{ red: errorMessage }"`
'aria-valuemin'?: Numberish | undefined /** * Defines the current value for a range widget. * @see aria-valuetext. */ 'aria-valuenow'?: Numberish | undefined /** Defines the human readable text alternative of aria-valuenow for a range widget. */ 'aria-valuetext'?: string | undefined } // Vue's style...
@@ -275,10 +275,19 @@ export type StyleValue = | CSSProperties | Array<StyleValue> +// Support for `class` attribute +export type ClassValue = + | false + | null + | undefined + | string + | Record<string, boolean>
packages/runtime-dom/src/jsx.ts
26
TypeScript
0.571
suggestion
92
51
51
false
types(jsx): flexible class attribute declarations
14,441
vuejs/vue-next
25,296
TypeScript
jacekkarczmarczyk
ZacharyBear
if (appear) { hook = onBeforeAppear || onBeforeEnter } else { return } } el[isLeavingKey] = false // for same element (v-show) if (el[leaveCbKey]) { el[leaveCbKey](true /* cancelled */) } // for toggled element with same key (v-if) ...
<img width="484" height="151" alt="Image" src="https://github.com/user-attachments/assets/aa468923-fedf-4cc3-9e05-d85bc82a57ea" /> It has an `isLeaving` state.
} else { return } } // for same element (v-show) if (el[leaveCbKey]) { el[leaveCbKey](true /* cancelled */) } // for toggled element with same key (v-if) const leavingVNode = leavingVNodesCache[key] if ( leavingVNode && isSameVN...
@@ -400,6 +403,7 @@ export function resolveTransitionHooks( }, enter(el) { + if (el[isLeavingKey]) return
packages/runtime-core/src/components/BaseTransition.ts
26
TypeScript
0.571
suggestion
160
51
51
false
fix(transition): prevent enter if leave is in progress
14,443
vuejs/vue-next
25,296
TypeScript
edison1105
Mini-ghost
if (isObjectType) { if (!compositeKeyCache.has(type)) compositeKeyCache.set(type, perType) } else if (!compositeKeyCachePrimitive.has(type)) { compositeKeyCachePrimitive.set(type, perType) } let composite = perType.get(branchKey) if (!composite) { composite = { type, branchKey } perType.set(b...
does vue prod code contains this test relevant code?
if (!compositeKeyCache.has(type)) compositeKeyCache.set(type, perType) } else if (!compositeKeyCachePrimitive.has(type)) { compositeKeyCachePrimitive.set(type, perType) } let composite = perType.get(branchKey) if (!composite) { composite = { type, branchKey } perType.set(branchKey, composite) ...
@@ -117,7 +118,16 @@ const VaporKeepAliveImpl = defineVaporComponent({ exclude: [String, RegExp, Array], max: [String, Number], }, - setup(props: KeepAliveProps, { slots }) { + setup(props: KeepAliveProps, { slots, expose }) { + let exposed!: Record<string, any> + // for e2e test + if (__BROWSER...
packages/runtime-vapor/src/components/KeepAlive.ts
26
TypeScript
0.214
question
52
51
51
false
fix(runtime-vapor): avoid exposing built-in components internals via template ref
14,448
vuejs/vue-next
25,296
TypeScript
Smrtnyk
edison1105
return oldRef } } /** * Function for handling a template ref */ function setRef( instance: VaporComponentInstance, el: RefEl, ref: NodeRef, oldRef?: NodeRef, refFor = false, refKey?: string, ): NodeRef | undefined { if (!instance || instance.isUnmounted) return // vdom interop const handleVd...
```suggestion if (handleVdomRef(el)) return ref ```
return oldRef } } /** * Function for handling a template ref */ function setRef( instance: VaporComponentInstance, el: RefEl, ref: NodeRef, oldRef?: NodeRef, refFor = false, refKey?: string, ): NodeRef | undefined { if (!instance || instance.isUnmounted) return // vdom interop const handleVd...
@@ -107,10 +107,14 @@ function setRef( if (!instance || instance.isUnmounted) return // vdom interop - if (isInteropEnabled && isFragment(el) && el.setRef) { - el.setRef(instance, ref, refFor, refKey) - return + const handleVdomRef = (target: any): boolean => { + if (isInteropEnabled && isFragment(ta...
packages/runtime-vapor/src/apiTemplateRef.ts
26
TypeScript
0.714
suggestion
53
51
51
false
fix(runtime-vapor): properly set ref on dynamic component + vdom component
14,496
vuejs/vue-next
25,296
TypeScript
edison1105
jackma9604
refFor = false, refKey?: string, ): NodeRef | undefined { if (!instance || instance.isUnmounted) return // vdom interop const handleVdomRef = (target: any): boolean => { if (isInteropEnabled && isFragment(target) && target.setRef) { target.setRef(instance, ref, refFor, refKey) return true ...
```suggestion if (handleVdomRef(refValue)) return ref ```
refFor = false, refKey?: string, ): NodeRef | undefined { if (!instance || instance.isUnmounted) return // vdom interop const handleVdomRef = (target: any): boolean => { if (isInteropEnabled && isFragment(target) && target.setRef) { target.setRef(instance, ref, refFor, refKey) return true ...
@@ -122,6 +126,8 @@ function setRef( const setupState: any = __DEV__ ? instance.setupState || {} : null const refValue = getRefValue(el) + if (handleVdomRef(refValue)) return
packages/runtime-vapor/src/apiTemplateRef.ts
26
TypeScript
0.714
suggestion
59
51
51
false
fix(runtime-vapor): properly set ref on dynamic component + vdom component
14,496
vuejs/vue-next
25,296
TypeScript
edison1105
jackma9604
import { ElementWithTransition } from '../components/Transition' // compiler should normalize class + :class bindings on the same element // into a single binding ['staticClass', dynamic] export function patchClass(el: Element, value: string | null, isSVG: boolean) { if (value == null) { value = '' } // dire...
No issues found.
import { ElementWithTransition } from '../components/Transition' // compiler should normalize class + :class bindings on the same element // into a single binding ['staticClass', dynamic] export function patchClass(el: Element, value: string | null, isSVG: boolean) { if (value == null) { value = '' } // dire...
@@ -2,7 +2,10 @@ import { ElementWithTransition } from '../components/Transition' // compiler should normalize class + :class bindings on the same element // into a single binding ['staticClass', dynamic] -export function patchClass(el: Element, value: string, isSVG: boolean) { +export function patchClass(el: Eleme...
packages/runtime-dom/src/modules/class.ts
0
TypeScript
1
none
16
22
22
true
test: add test for runtime-dom/modules/class
75
vuejs/vue-next
25,296
TypeScript
haoqunjiang
mounted() { calls.push('root onMounted') }, beforeUpdate() { calls.push('root onBeforeUpdate') }, updated() { calls.push('root onUpdated') }, beforeUnmount() { calls.push('root onBeforeUnmount') }, unmounted() { calls.push('ro...
No issues found.
mounted() { calls.push('root onMounted') }, beforeUpdate() { calls.push('root onBeforeUpdate') }, updated() { calls.push('root onUpdated') }, beforeUnmount() { calls.push('root onBeforeUnmount') }, unmounted() { calls.push('ro...
@@ -8,7 +8,8 @@ import { nextTick, renderToString, ref, - createComponent + createComponent, + mockWarn } from '@vue/runtime-test' describe('api: options', () => { @@ -505,4 +506,37 @@ describe('api: options', () => { await nextTick() expect(serializeInner(root)).toBe(`<div>1,1,3</div>`) })...
packages/runtime-core/__tests__/apiOptions.spec.ts
0
TypeScript
1
none
16
51
51
true
fix: add warnings
82
vuejs/vue-next
25,296
TypeScript
TimvdEijnden
`) expect(content).not.toMatch(`const { foo: bar } =`) expect(content).toMatch(`let x = foo`) // should not process expect(content).toMatch(`let y = __props.foo`) // should convert bar to __props.foo in template expressions expect(content).toMatch(`_toDisplayString(__props.foo + __props.foo)`) ...
No issues found.
`) expect(content).not.toMatch(`const { foo: bar } =`) expect(content).toMatch(`let x = foo`) // should not process expect(content).toMatch(`let y = __props.foo`) // should convert bar to __props.foo in template expressions expect(content).toMatch(`_toDisplayString(__props.foo + __props.foo)`) ...
@@ -294,7 +294,7 @@ describe('sfc props transform', () => { ).toThrow(`Cannot assign to destructured props`) }) - test('should error when watching destructured prop', () => { + test('should error when passing destructured prop into certain methods', () => { expect(() => compile( ...
packages/compiler-sfc/__tests__/compileScriptPropsDestructure.spec.ts
0
TypeScript
1
none
16
51
51
true
feat(reactivity): improve support of getter usage in reactivity APIs
7,997
vuejs/vue-next
25,296
TypeScript
yyx990803