resolve-slots.ts — vue Source File
Architecture documentation for resolve-slots.ts, a typescript file in the vue codebase. 2 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR d1e549a1_8d2d_9fe4_1d06_3f7035b5e697["resolve-slots.ts"] 973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"] d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 --> 973389ac_8625_30a3_53ce_b1b48fae58c5 64c87498_c46a_6944_ab9d_8e45519852a8["component"] d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 --> 64c87498_c46a_6944_ab9d_8e45519852a8 d937f76e_061f_a631_9587_336503c9a15c["lifecycle.ts"] d937f76e_061f_a631_9587_336503c9a15c --> d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 2c65c43e_4691_415f_689a_805ec38ae46c["render.ts"] 2c65c43e_4691_415f_689a_805ec38ae46c --> d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 414b37af_5f63_dee7_31a2_9a7cad5979ec["create-functional-component.ts"] 414b37af_5f63_dee7_31a2_9a7cad5979ec --> d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 style d1e549a1_8d2d_9fe4_1d06_3f7035b5e697 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type VNode from 'core/vdom/vnode'
import type { Component } from 'types/component'
/**
* Runtime helper for resolving raw children VNodes into a slot object.
*/
export function resolveSlots(
children: Array<VNode> | null | undefined,
context: Component | null
): { [key: string]: Array<VNode> } {
if (!children || !children.length) {
return {}
}
const slots: Record<string, any> = {}
for (let i = 0, l = children.length; i < l; i++) {
const child = children[i]
const data = child.data
// remove slot attribute if the node is resolved as a Vue slot node
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot
}
// named slots should only be respected if the vnode was rendered in the
// same context.
if (
(child.context === context || child.fnContext === context) &&
data &&
data.slot != null
) {
const name = data.slot
const slot = slots[name] || (slots[name] = [])
if (child.tag === 'template') {
slot.push.apply(slot, child.children || [])
} else {
slot.push(child)
}
} else {
;(slots.default || (slots.default = [])).push(child)
}
}
// ignore slots that contains only whitespace
for (const name in slots) {
if (slots[name].every(isWhitespace)) {
delete slots[name]
}
}
return slots
}
function isWhitespace(node: VNode): boolean {
return (node.isComment && !node.asyncFactory) || node.text === ' '
}
Domain
Subdomains
Functions
Dependencies
- component
- vnode
Imported By
Source
Frequently Asked Questions
What does resolve-slots.ts do?
resolve-slots.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, Instance subdomain.
What functions are defined in resolve-slots.ts?
resolve-slots.ts defines 2 function(s): isWhitespace, resolveSlots.
What does resolve-slots.ts depend on?
resolve-slots.ts imports 2 module(s): component, vnode.
What files import resolve-slots.ts?
resolve-slots.ts is imported by 3 file(s): create-functional-component.ts, lifecycle.ts, render.ts.
Where is resolve-slots.ts in the architecture?
resolve-slots.ts is located at src/core/instance/render-helpers/resolve-slots.ts (domain: VueCore, subdomain: Instance, directory: src/core/instance/render-helpers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free