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

Function resolveSlots

static/vuejs/vue.runtime.common.js:1939–1970  ·  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

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

Callers 3

updateChildComponentFunction · 0.70
initRenderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected