ssrGetDirectiveProps.ts 608 B

1234567891011121314151617181920212223242526
  1. import { type ComponentPublicInstance, type Directive, ssrUtils } from 'vue'
  2. export function ssrGetDirectiveProps(
  3. instance: ComponentPublicInstance,
  4. dir: Directive,
  5. value?: any,
  6. arg?: string,
  7. modifiers: Record<string, boolean> = {},
  8. ): Record<string, any> {
  9. if (typeof dir !== 'function' && dir.getSSRProps) {
  10. return (
  11. dir.getSSRProps(
  12. {
  13. dir,
  14. instance: ssrUtils.getComponentPublicInstance(instance.$),
  15. value,
  16. oldValue: undefined,
  17. arg,
  18. modifiers,
  19. },
  20. null as any,
  21. ) || {}
  22. )
  23. }
  24. return {}
  25. }