2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

Merge remote-tracking branch 'antfu/feat/vue-ssr' into next

This commit is contained in:
Vjacheslav Trushkin 2024-04-19 08:56:23 +03:00
commit 24bee18f46
2 changed files with 16 additions and 8 deletions

View File

@ -243,6 +243,12 @@ export const Icon = defineComponent<IconProps>({
// Set initial data
data() {
return {
// Current icon name
_name: '',
// Loading
_loadingIcon: null,
// Mounted status
iconMounted: false,
@ -252,12 +258,6 @@ export const Icon = defineComponent<IconProps>({
},
mounted() {
// Current icon name
this._name = '';
// Loading
this._loadingIcon = null;
// Mark as mounted
this.iconMounted = true;
},
@ -354,7 +354,7 @@ export const Icon = defineComponent<IconProps>({
const props = this.$attrs;
// Get icon data
const icon: IconComponentData | null = this.iconMounted
const icon: IconComponentData | null = (this.iconMounted || props.ssr)
? this.getIcon(props.icon, props.onLoad)
: null;

View File

@ -67,4 +67,12 @@ interface IconifyElementProps {
/**
* Mix of icon properties and HTMLElement properties
*/
export type IconProps = IconifyElementProps & IconifyIconProps;
export interface IconProps extends IconifyElementProps, IconifyIconProps {
/**
* Try load icon on first render during SSR
*
* This is a low-level API for framework integrations, you don't usually need to use it directly.
* Note this might hydration mismatches if the icon data is not handled correctly, use with caution.
*/
ssr?: boolean
}