Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement inheritAttrs #153

Merged
merged 34 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bb26087
feat(vapor): implement inheritAttrs
Doctor-wu Mar 17, 2024
7e1f592
feat(runtime-vapor): apply inheritAttrs to instance
Doctor-wu Mar 17, 2024
9d8c1e5
feat(runtime-vapor): extract apiSetup & init setup ctx
Doctor-wu Mar 17, 2024
20aa749
feat(runtime-vapor): add setup ctx type
Doctor-wu Mar 17, 2024
e4bc5ab
Revert "feat(runtime-vapor): add setup ctx type"
Doctor-wu Mar 17, 2024
2f8b9af
Revert "feat(runtime-vapor): extract apiSetup & init setup ctx"
Doctor-wu Mar 17, 2024
757aa74
feat(runtime-vapor): impl fallthrough attrs
Doctor-wu Mar 17, 2024
2db5e19
test(runtime-vapor): tweak props test case
Doctor-wu Mar 17, 2024
8498ba6
feat(runtime-vapor): update attrs when props update
Doctor-wu Mar 17, 2024
1742efe
feat(runtime-vapor): remove unecessary property & use proper way to s…
Doctor-wu Mar 18, 2024
e082299
feat(runtime-vapor, compiler-vapor): add withAttr in singleRoot Compo…
Doctor-wu Mar 18, 2024
5cab771
feat(runtime-vapor, compiler-vapor): resolve nest component attrs
Doctor-wu Mar 18, 2024
1482a20
feat(compiler-vapor): remove unecessary clone props
Doctor-wu Mar 18, 2024
b3b6622
feat(runtime-vapor): clean code
Doctor-wu Mar 18, 2024
791f533
chore(runtime-vapor): make lint happy
Doctor-wu Mar 18, 2024
f7d4c13
feat(runtime-vapor, compiler-vapor): make inheritAttrs reactive
Doctor-wu Mar 18, 2024
bdc1ee4
chore(runtime-vapor): remove unecessary code
Doctor-wu Mar 18, 2024
35499bd
feat(runtime-vapor): should not withAttrs when component set inheritA…
Doctor-wu Mar 18, 2024
a474ac4
feat(runtim-vapor, compiler-vapor): simplify implement
Doctor-wu Mar 18, 2024
24488bc
Merge branch 'main' into feature-inherit-attrs
Doctor-wu Mar 18, 2024
6044bf7
test(compiler-vapor): add generator component test case & snapshot
Doctor-wu Mar 18, 2024
8afe97d
Merge branch 'main' into feature-inherit-attrs
Doctor-wu Mar 18, 2024
c30a618
feat(runtime-vapor): simplify implement
Doctor-wu Mar 18, 2024
c085cda
feat(runtime-vapor): simplify implement
Doctor-wu Mar 18, 2024
0ea395c
refactor: optimize bundle size
sxzz Mar 18, 2024
b5879d3
refactor: check if component
sxzz Mar 18, 2024
322f0ba
refactor: remove type casting
sxzz Mar 18, 2024
34c1937
feat(compiler-vapor): optimize single root implemention
Doctor-wu Mar 18, 2024
56ff7c4
fix: type error
sxzz Mar 18, 2024
47754b7
feat(compiler-vapor): perf bundle size
Doctor-wu Mar 18, 2024
5270734
chore(compiler-vapor, runtime-vapor): bundle size & make lint happy
Doctor-wu Mar 18, 2024
c068506
refactor: simplify
sxzz Mar 18, 2024
61b572c
chore(compiler-vapor): remove unecessary import
Doctor-wu Mar 18, 2024
47f8b9a
test: undo
sxzz Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "feat(runtime-vapor): add setup ctx type"
This reverts commit b385157.
Doctor-wu authored and sxzz committed Mar 17, 2024

Verified

This commit was signed with the committer’s verified signature.
sxzz Kevin Deng 三咲智子
commit e4bc5ab256fc6add9f246a0f77477c1be5da29ac
17 changes: 3 additions & 14 deletions packages/runtime-vapor/src/apiSetup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { proxyRefs } from '@vue/reactivity'
import { type Data, isArray, isFunction, isObject } from '@vue/shared'
import { isArray, isFunction, isObject } from '@vue/shared'
import { type ComponentInternalInstance, setCurrentInstance } from './component'
import { getAttrsProxy } from './componentAttrs'
// import { SetupContext } from 'vue'
import { type Block, fragmentKey } from './apiRender'
import type { EmitFn, EmitsOptions } from './componentEmits'

export type SetupContext<E = EmitsOptions> = E extends any
? {
attrs: Data
emit: EmitFn<E>
expose: (exposed?: Record<string, any>) => void
}
: never

export function setupComponent(instance: ComponentInternalInstance): void {
const reset = setCurrentInstance(instance)
@@ -50,9 +42,7 @@ export function setupComponent(instance: ComponentInternalInstance): void {
reset()
}

export function createSetupContext(
instance: ComponentInternalInstance,
): SetupContext {
export function createSetupContext(instance: ComponentInternalInstance): any {
if (__DEV__) {
// We use getters in dev in case libs like test-utils overwrite instance
// properties (overwrites should not be done in prod)
@@ -67,7 +57,6 @@ export function createSetupContext(
})
} else {
return {
expose: () => {},
get attrs() {
return getAttrsProxy(instance)
},