diff --git a/src/index.ts b/src/index.ts index 08bb59d..5f057e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,9 @@ function getRootBlock( rootChild && tag !== 'formkit' && tag !== 'form-kit' && - rootChild.isSelfClosing === false + tag !== 'formkitschema' && + tag !== 'form-kit-schema' && + !rootChild.isSelfClosing ) { // In this case the component has a root node that is not formkit and is // not self-closing, like, perhaps, a div. We need to move the provider @@ -114,7 +116,6 @@ function injectProviderComponent( const content = code.substring(startInsertAt, template.loc.end.offset - 11) const after = code.substring(template.loc.end.offset - 11) code = `${before}\n${open}\n${content}\n${close}\n${after}` - return { code, map: null } } diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 00221cc..5c1f82d 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -32,6 +32,30 @@ exports[`index > injects inside root node if there is one 1`] = ` " `; +exports[`index > injects inside root node with full sfc 1`] = ` +" + + +" +`; + exports[`index > injects setup block when using options api 1`] = ` " + + +`, + 'test.vue', + ) + ).code, + ).toMatchSnapshot() + }) + it('injects import into script setup block', async () => { expect( (await plugin.transform(aboutSFCFile, 'about.vue')).code,