You've already forked AstralRinth
forked from didirus/AstralRinth
* refactor: migrate to common eslint+prettier configs * fix: prettier frontend * feat: config changes * fix: lint issues * fix: lint * fix: type imports * fix: cyclical import issue * fix: lockfile * fix: missing dep * fix: switch to tabs * fix: continue switch to tabs * fix: rustfmt parity * fix: moderation lint issue * fix: lint issues * fix: ui intl * fix: lint issues * Revert "fix: rustfmt parity" This reverts commit cb99d2376c321d813d4b7fc7e2a213bb30a54711. * feat: revert last rs
26 lines
949 B
TypeScript
26 lines
949 B
TypeScript
import { createTextVNode, isVNode, toDisplayString, type VNode } from 'vue'
|
|
|
|
/**
|
|
* Checks whether a specific child is a VNode. If not, converts it to a display
|
|
* string and then creates text VNode for the result.
|
|
*
|
|
* @param child Child to normalize.
|
|
* @returns Either the original VNode or a text VNode containing child converted
|
|
* to a display string.
|
|
*/
|
|
function normalizeChild(child: any): VNode {
|
|
return isVNode(child) ? child : createTextVNode(toDisplayString(child))
|
|
}
|
|
|
|
/**
|
|
* Takes in an array of VNodes and other children. It then converts each child
|
|
* that is not already a VNode to a display string, and creates a text VNode for
|
|
* that string.
|
|
*
|
|
* @param children Children to normalize.
|
|
* @returns Children with all of non-VNodes converted to display strings.
|
|
*/
|
|
export function normalizeChildren(children: any | any[]): VNode[] {
|
|
return Array.isArray(children) ? children.map(normalizeChild) : [normalizeChild(children)]
|
|
}
|