Skip to content

Commit

Permalink
fix(slot): rename slots for render functions to kebab case
Browse files Browse the repository at this point in the history
  • Loading branch information
joseacabaneros committed Aug 5, 2024
1 parent f566c87 commit 78e0077
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { defineComponent, h, Comment } from 'vue';
import { defineComponent } from 'vue';
/**
* Component to be used as `default` for animation props together with dynamic components
Expand All @@ -8,8 +8,7 @@
export default defineComponent({
name: 'NoAnimation',
setup(_, { slots }) {
return () =>
slots.default?.()[0] ?? h(Comment, 'NoAnimation component - Without default slot');
return () => slots.default?.()[0] ?? '';
}
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
$x.emit('UserClickedCloseModal', props.modalId, { target: target as HTMLElement });
}
/* Hack to render through a render-function, the `closingElement` slot or, in its absence,
/* Hack to render through a render-function, the `closing-element` slot or, in its absence,
the component itself. It is the alternative for the NoElement antipattern. */
const innerProps = { closeModal };
return (
slots.closingElement ? () => slots.closingElement?.(innerProps)[0] : innerProps
slots['closing-element'] ? () => slots['closing-element']?.(innerProps)[0] : innerProps
) as typeof innerProps;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
$x.emit('UserClickedOpenModal', props.modalId, { target: target as HTMLElement });
}
/* Hack to render through a render-function, the `openingElement` slot or, in its absence,
/* Hack to render through a render-function, the `opening-element` slot or, in its absence,
the component itself. It is the alternative for the NoElement antipattern. */
const innerProps = { openModal };
return (
slots.openingElement ? () => slots.openingElement?.(innerProps)[0] : innerProps
slots['opening-element'] ? () => slots['opening-element']?.(innerProps)[0] : innerProps
) as typeof innerProps;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
const stateParams = useState('extraParams', ['params']).params;
/** It returns the value of the extra param from the store. */
const value = computed(() => stateParams.value[props.name]);
const extraParam = computed(() => stateParams.value[props.name]);
/**
* It sets the new value to the store.
Expand All @@ -37,7 +37,7 @@
xBus.emit('UserChangedExtraParams', { [props.name]: newValue });
}
return () => slots.default?.({ value: value.value, updateValue })[0] ?? '';
return () => slots.default?.({ value: extraParam.value, updateValue })[0] ?? '';
}
});
</script>
Expand Down

0 comments on commit 78e0077

Please sign in to comment.