2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-29 05:29:09 +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 // Set initial data
data() { data() {
return { return {
// Current icon name
_name: '',
// Loading
_loadingIcon: null,
// Mounted status // Mounted status
iconMounted: false, iconMounted: false,
@ -252,12 +258,6 @@ export const Icon = defineComponent<IconProps>({
}, },
mounted() { mounted() {
// Current icon name
this._name = '';
// Loading
this._loadingIcon = null;
// Mark as mounted // Mark as mounted
this.iconMounted = true; this.iconMounted = true;
}, },
@ -354,7 +354,7 @@ export const Icon = defineComponent<IconProps>({
const props = this.$attrs; const props = this.$attrs;
// Get icon data // Get icon data
const icon: IconComponentData | null = this.iconMounted const icon: IconComponentData | null = (this.iconMounted || props.ssr)
? this.getIcon(props.icon, props.onLoad) ? this.getIcon(props.icon, props.onLoad)
: null; : null;

View File

@ -67,4 +67,12 @@ interface IconifyElementProps {
/** /**
* Mix of icon properties and HTMLElement properties * 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
}