Bläddra i källkod

chore: comments

Evan You 7 år sedan
förälder
incheckning
b77709286f
2 ändrade filer med 7 tillägg och 2 borttagningar
  1. 6 1
      packages/runtime-core/src/patchFlags.ts
  2. 1 1
      packages/runtime-core/src/vnode.ts

+ 6 - 1
packages/runtime-core/src/patchFlags.ts

@@ -16,7 +16,12 @@
 // Indicates an element with dynamic textContent (children fast path)
 export const TEXT = 1
 
-// Indicates an element with dynamic class
+// Indicates an element with dynamic class.
+// The compiler also pre-normalizes the :class binding:
+// - b -> normalize(b)
+// - ['foo', b] -> 'foo' + normalize(b)
+// - { a, b: c } -> (a ? a : '') + (b ? c : '')
+// - ['a', b, { c }] -> 'a' + normalize(b) + (c ? c : '')
 export const CLASS = 1 << 1
 
 // Indicates an element with dynamic style

+ 1 - 1
packages/runtime-core/src/vnode.ts

@@ -192,7 +192,7 @@ function normalizeStyle(
   }
 }
 
-function normalizeClass(value: unknown): string {
+export function normalizeClass(value: unknown): string {
   let res = ''
   if (isString(value)) {
     res = value