remove unused code, small refactor
This commit is contained in:
parent
45f6973593
commit
5ab32e9cf8
1 changed files with 9 additions and 29 deletions
|
@ -189,20 +189,12 @@ function findComponentUpward (context, componentName, componentNames) {
|
||||||
export {findComponentUpward};
|
export {findComponentUpward};
|
||||||
|
|
||||||
// Find component downward
|
// Find component downward
|
||||||
function findComponentDownward (context, componentName) {
|
export function findComponentDownward (context, componentName) {
|
||||||
const childrens = context.$children;
|
const childrens = context.$children;
|
||||||
let children = null;
|
let children = null;
|
||||||
|
|
||||||
if (childrens.length) {
|
if (childrens.length) {
|
||||||
childrens.forEach(child => {
|
for (const child of childrens) {
|
||||||
const name = child.$options.name;
|
|
||||||
if (name === componentName) {
|
|
||||||
children = child;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < childrens.length; i++) {
|
|
||||||
const child = childrens[i];
|
|
||||||
const name = child.$options.name;
|
const name = child.$options.name;
|
||||||
if (name === componentName) {
|
if (name === componentName) {
|
||||||
children = child;
|
children = child;
|
||||||
|
@ -215,27 +207,15 @@ function findComponentDownward (context, componentName) {
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
export {findComponentDownward};
|
|
||||||
|
|
||||||
// Find components downward
|
// Find components downward
|
||||||
function findComponentsDownward (context, componentName, components = []) {
|
export function findComponentsDownward (context, componentName) {
|
||||||
const childrens = context.$children;
|
return context.$children.reduce((components, child) => {
|
||||||
|
if (child.$options.name === componentName) components.push(child);
|
||||||
if (childrens.length) {
|
const foundChilds = findComponentsDownward(child, componentName);
|
||||||
childrens.forEach(child => {
|
return components.concat(foundChilds);
|
||||||
const name = child.$options.name;
|
}, []);
|
||||||
const childs = child.$children;
|
|
||||||
|
|
||||||
if (name === componentName) components.push(child);
|
|
||||||
if (childs.length) {
|
|
||||||
const findChilds = findComponentsDownward(child, componentName, components);
|
|
||||||
if (findChilds) components.concat(findChilds);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return components;
|
|
||||||
}
|
}
|
||||||
export {findComponentsDownward};
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
const trim = function(string) {
|
const trim = function(string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue