})
const toggle = ref(true)
- const ES = defineCustomElement({
- shadowRoot: false,
- render() {
- return [
- renderSlot(this.$slots, 'default'),
- toggle.value ? renderSlot(this.$slots, 'named') : null,
- renderSlot(this.$slots, 'omitted', {}, () => [h('div', 'fallback')]),
- ]
+ const ES = defineCustomElement(
+ {
+ render() {
+ return [
+ renderSlot(this.$slots, 'default'),
+ toggle.value ? renderSlot(this.$slots, 'named') : null,
+ renderSlot(this.$slots, 'omitted', {}, () => [
+ h('div', 'fallback'),
+ ]),
+ ]
+ },
},
- })
+ { shadowRoot: false },
+ )
customElements.define('my-el-shadowroot-false-slots', ES)
test('should render slots', async () => {
Exposed
>
>,
+ extraOptions?: CustomElementOptions,
): VueElementConstructor<ResolvedProps>
// overload 3: defining a custom element from the returned value of
T extends DefineComponent<any, any, any, any>,
>(
options: T,
+ extraOptions?: CustomElementOptions,
): VueElementConstructor<
T extends DefineComponent<infer P, any, any, any>
? ExtractPropTypes<P>
hydrate?: RootHydrateFunction,
): VueElementConstructor {
const Comp = defineComponent(options, extraOptions) as any
+ if (isPlainObject(Comp)) extend(Comp, extraOptions)
class VueCustomElement extends VueElement {
static def = Comp
constructor(initialProps?: Record<string, any>) {
useShadowRoot,
VueElement,
type VueElementConstructor,
+ type CustomElementOptions,
} from './apiCustomElement'
// SFC CSS utilities