2019-05-30 21:24:40 +08:00
|
|
|
// Patch flags are optimization hints generated by the compiler.
|
|
|
|
// when a block with dynamicChildren is encountered during diff, the algorithm
|
|
|
|
// enters "optimized mode". In this mode, we know that the vdom is produced by
|
|
|
|
// a render function generated by the compiler, so the algorithm only needs to
|
|
|
|
// handle updates explicitly marked by these patch flags.
|
|
|
|
|
|
|
|
// Patch flags can be combined using the | bitwise operator and can be checked
|
|
|
|
// using the & operator, e.g.
|
|
|
|
//
|
|
|
|
// const flag = TEXT | CLASS
|
|
|
|
// if (flag & TEXT) { ... }
|
2019-05-30 21:27:14 +08:00
|
|
|
//
|
|
|
|
// Check the `patchElement` function in './createRednerer.ts' to see how the
|
|
|
|
// flags are handled during diff.
|
2019-05-30 21:24:40 +08:00
|
|
|
|
|
|
|
// Indicates an element with dynamic textContent (children fast path)
|
2019-05-25 23:51:20 +08:00
|
|
|
export const TEXT = 1
|
2019-05-30 21:24:40 +08:00
|
|
|
|
2019-06-01 17:47:19 +08:00
|
|
|
// 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 : '')
|
2019-05-25 23:51:20 +08:00
|
|
|
export const CLASS = 1 << 1
|
2019-05-30 21:24:40 +08:00
|
|
|
|
|
|
|
// Indicates an element with dynamic style
|
2019-06-03 13:57:19 +08:00
|
|
|
// The compiler pre-compiles static string styles into static objects
|
|
|
|
// + detects and hoists inline static objects
|
|
|
|
// e.g. style="color: red" and :style="{ color: 'red' }" both get hoisted as
|
|
|
|
// const style = { color: 'red' }
|
|
|
|
// render() { return e('div', { style }) }
|
2019-05-25 23:51:20 +08:00
|
|
|
export const STYLE = 1 << 2
|
2019-05-30 21:24:40 +08:00
|
|
|
|
|
|
|
// Indicates an element that has non-class/style dynamic props.
|
|
|
|
// Can also be on a component that has any dynamic props (includes class/style).
|
|
|
|
// when this flag is present, the vnode also has a dynamicProps array that
|
|
|
|
// contains the keys of the props that may change so the runtime can diff
|
|
|
|
// them faster (without having to worry about removed props)
|
2019-05-25 23:51:20 +08:00
|
|
|
export const PROPS = 1 << 3
|
2019-05-30 21:24:40 +08:00
|
|
|
|
2019-05-31 12:25:11 +08:00
|
|
|
// Indicates an element with props with dynamic keys. When keys change, a full
|
|
|
|
// diff is always needed to remove the old key. This flag is mutually exclusive
|
|
|
|
// with CLASS, STYLE and PROPS.
|
|
|
|
export const FULL_PROPS = 1 << 4
|
|
|
|
|
2019-05-30 21:24:40 +08:00
|
|
|
// Indicates a fragment or element with keyed or partially-keyed v-for children
|
2019-05-31 12:25:11 +08:00
|
|
|
export const KEYED = 1 << 5
|
2019-05-30 21:24:40 +08:00
|
|
|
|
|
|
|
// Indicates a fragment or element that contains unkeyed v-for children
|
2019-05-31 12:25:11 +08:00
|
|
|
export const UNKEYED = 1 << 6
|
2019-05-30 21:24:40 +08:00
|
|
|
|
2019-05-31 12:25:11 +08:00
|
|
|
// Indicates a component with dynamic slots (e.g. slot that references a v-for
|
|
|
|
// iterated value, or dynamic slot names).
|
|
|
|
// Components with this flag are always force updated.
|
|
|
|
export const DYNAMIC_SLOTS = 1 << 7
|
2019-06-03 13:44:45 +08:00
|
|
|
|
|
|
|
// Indicates an element with ref. This includes static string refs because the
|
|
|
|
// refs object is refreshed on each update and all refs need to set again.
|
|
|
|
export const REF = 1 << 8
|