فهرست منبع

types(jsx): flexible class attribute declarations (#14441)

close: vuejs/rfcs#820
Zachary Bear 2 ماه پیش
والد
کامیت
521157d0c3
1فایلهای تغییر یافته به همراه11 افزوده شده و 2 حذف شده
  1. 11 2
      packages/runtime-dom/src/jsx.ts

+ 11 - 2
packages/runtime-dom/src/jsx.ts

@@ -275,10 +275,19 @@ export type StyleValue =
   | CSSProperties
   | Array<StyleValue>
 
+// Support for `class` attribute
+export type ClassValue =
+  | false
+  | null
+  | undefined
+  | string
+  | Record<string, any>
+  | Array<ClassValue>
+
 export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
   innerHTML?: string | undefined
 
-  class?: any
+  class?: ClassValue | undefined
   style?: StyleValue | undefined
 
   // Standard HTML Attributes
@@ -916,7 +925,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers<Events> {
    * SVG Styling Attributes
    * @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling
    */
-  class?: any
+  class?: ClassValue | undefined
   style?: StyleValue | undefined
 
   color?: string | undefined