MCPcopy Create free account
hub / github.com/TruthHun/BookStack / resolveSlots

Function resolveSlots

static/vuejs/vue.runtime.js:1943–1974  ·  view source on GitHub ↗

* Runtime helper for resolving raw children VNodes into a slot object.

(
  children,
  context
)

Source from the content-addressed store, hash-verified

1941 * Runtime helper for resolving raw children VNodes into a slot object.
1942 */
1943function resolveSlots (
1944 children,
1945 context
1946) {
1947 var slots = {};
1948 if (!children) {
1949 return slots
1950 }
1951 var defaultSlot = [];
1952 var name, child;
1953 for (var i = 0, l = children.length; i < l; i++) {
1954 child = children[i];
1955 // named slots should only be respected if the vnode was rendered in the
1956 // same context.
1957 if ((child.context === context || child.functionalContext === context) &&
1958 child.data && (name = child.data.slot)) {
1959 var slot = (slots[name] || (slots[name] = []));
1960 if (child.tag === 'template') {
1961 slot.push.apply(slot, child.children);
1962 } else {
1963 slot.push(child);
1964 }
1965 } else {
1966 defaultSlot.push(child);
1967 }
1968 }
1969 // ignore whitespace
1970 if (!defaultSlot.every(isWhitespace)) {
1971 slots.default = defaultSlot;
1972 }
1973 return slots
1974}
1975
1976function isWhitespace (node) {
1977 return node.isComment || node.text === ' '

Callers 3

updateChildComponentFunction · 0.70
initRenderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected