From 1904fe6b3c885dd6241844899242d31987dcdc9a Mon Sep 17 00:00:00 2001 From: Illya Klymov Date: Sun, 9 Oct 2022 21:09:25 +0300 Subject: [PATCH] chore: remove occasionally added file --- src/directives.ts | 73 ----------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/directives.ts diff --git a/src/directives.ts b/src/directives.ts deleted file mode 100644 index 7e202e6b7..000000000 --- a/src/directives.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { - transformVNodeArgs, - Directive, - ComponentInternalInstance, - VNodeTypes -} from 'vue' -import { isObject } from './utils' - -interface CreateDirectivesTransformerConfig { - directives?: Record -} -type VNodeArgsTransformer = NonNullable< - Parameters[0] -> - -export function createDirectivesTransformer({ - directives = {} -}: CreateDirectivesTransformerConfig): VNodeArgsTransformer { - const directivesTransformerCache: WeakMap< - VNodeTypes & object, - VNodeTypes & object - > = new WeakMap() - - if (Object.keys(directives).length === 0) { - return (args) => args - } - - return function directivesTransformer( - args, - instance: ComponentInternalInstance | null - ) { - // We care about - // * object components - // * functional components - // * legacy components - // * legacy functional components - // * class components (sigh) - - const [nodeType, props, children, patchFlag, dynamicProps] = args - - if (!isObject(nodeType)) { - return args - } - - if ((nodeType as any).__PATCHED) { - console.log('wtf') - } - - const cachedTransformation = directivesTransformerCache.get(nodeType) - if (cachedTransformation) { - return [cachedTransformation, props, children, patchFlag, dynamicProps] - } - - const nodeTypeWithDirectives = { - __PATCHED: true, - ...nodeType, - directives: { - ...((nodeType as any)?.directives ?? {}), - ...directives - } - } - - directivesTransformerCache.set(nodeType, nodeTypeWithDirectives as any) - - return [ - nodeTypeWithDirectives as any, - props, - children, - patchFlag, - dynamicProps - ] - } -}