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

Function resolveSlots

static/vuejs/vue.js:1947–1978  ·  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

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

Callers 3

updateChildComponentFunction · 0.70
initRenderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected