}
},
render() {
- return [h(ChildA), h(ChildB), h(ChildC), h(ChildD), h(ChildE)]
+ return [
+ h(ChildA),
+ h(ChildB),
+ h(ChildC),
+ h(ChildD),
+ h(ChildE),
+ h(ChildF),
+ h(ChildG),
+ h(ChildH)
+ ]
}
})
from: 'a'
}
})
- const ChildD = defineChild({
+ const ChildD = defineChild(
+ {
+ a: {
+ default: () => 0
+ }
+ },
+ 'a'
+ )
+ const ChildE = defineChild({
b: {
from: 'c',
default: 2
}
})
- const ChildE = defineChild({
+ const ChildF = defineChild({
b: {
from: 'c',
default: () => 3
}
})
- expect(renderToString(h(Root))).toBe(`11123`)
+ const ChildG = defineChild({
+ b: {
+ default: 4
+ }
+ })
+ const ChildH = defineChild({
+ b: {
+ default: () => 5
+ }
+ })
+ expect(renderToString(h(Root))).toBe(`11112345`)
})
test('lifecycle', async () => {
| string[]
| Record<
string | symbol,
- string | symbol | { from: string | symbol; default?: unknown }
+ string | symbol | { from?: string | symbol; default?: unknown }
>
interface LegacyOptions<
const opt = injectOptions[key]
if (isObject(opt)) {
ctx[key] = inject(
- opt.from,
+ opt.from || key,
opt.default,
true /* treat default function as factory */
)