Skip to content

Commit

Permalink
updated main logic to find next level shadow dom
Browse files Browse the repository at this point in the history
  • Loading branch information
sukgu committed Jun 8, 2020
1 parent c2884e5 commit bcd2840
Showing 1 changed file with 88 additions and 8 deletions.
96 changes: 88 additions & 8 deletions pyshadow/resources/querySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,53 @@ var getObject = function getObject(selector, root = document) {
if (multiLevelSelectors.length == 1) {
return querySelectorDeep(multiLevelSelectors[0], root);
} else if (multiLevelSelectors.length == 2) {
return querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root);
parent = querySelectorDeep(multiLevelSelectors[0]);
if (parent === undefined) {
parent = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
return querySelectorDeep(multiLevelSelectors[1], parent);
} else if (multiLevelSelectors.length == 3) {
return querySelectorDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
return querySelectorDeep(multiLevelSelectors[2], parent_2);
} else if (multiLevelSelectors.length == 4) {
return querySelectorDeep(multiLevelSelectors[3], querySelectorDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root)));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2);
if (parent_3 === undefined) {
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2).shadowRoot
}
return querySelectorDeep(multiLevelSelectors[3], parent_3);
} else if (multiLevelSelectors.length == 5) {
return querySelectorDeep(multiLevelSelectors[4], querySelectorDeep(multiLevelSelectors[3], querySelectorDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root))));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2);
if (parent_3 === undefined) {
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2).shadowRoot
}
parent_4 = querySelectorDeep(multiLevelSelectors[3], parent_3);
if (parent_4 === undefined) {
parent_4 = querySelectorDeep(multiLevelSelectors[3], parent_3).shadowRoot
}
return querySelectorDeep(multiLevelSelectors[4], parent_4);
}
};

Expand All @@ -170,13 +210,53 @@ var getAllObject = function getAllObject(selector, root = document) {
if (multiLevelSelectors.length == 1) {
return querySelectorAllDeep(multiLevelSelectors[0], root);
} else if (multiLevelSelectors.length == 2) {
return querySelectorAllDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root);
parent = querySelectorDeep(multiLevelSelectors[0]);
if (parent === undefined) {
parent = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
return querySelectorAllDeep(multiLevelSelectors[1], parent);
} else if (multiLevelSelectors.length == 3) {
return querySelectorAllDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
return querySelectorAllDeep(multiLevelSelectors[2], parent_2);
} else if (multiLevelSelectors.length == 4) {
return querySelectorAllDeep(multiLevelSelectors[3], querySelectorDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root)));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2);
if (parent_3 === undefined) {
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2).shadowRoot
}
return querySelectorAllDeep(multiLevelSelectors[3], parent_3);
} else if (multiLevelSelectors.length == 5) {
return querySelectorAllDeep(multiLevelSelectors[4], querySelectorDeep(multiLevelSelectors[3], querySelectorDeep(multiLevelSelectors[2], querySelectorDeep(multiLevelSelectors[1], querySelectorDeep(multiLevelSelectors[0]).root))));
parent_1 = querySelectorDeep(multiLevelSelectors[0]);
if (parent_1 === undefined) {
parent_1 = querySelectorDeep(multiLevelSelectors[0]).shadowRoot
}
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1);
if (parent_2 === undefined) {
parent_2 = querySelectorDeep(multiLevelSelectors[1], parent_1).shadowRoot
}
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2);
if (parent_3 === undefined) {
parent_3 = querySelectorDeep(multiLevelSelectors[2], parent_2).shadowRoot
}
parent_4 = querySelectorDeep(multiLevelSelectors[3], parent_3);
if (parent_4 === undefined) {
parent_4 = querySelectorDeep(multiLevelSelectors[3], parent_3).shadowRoot
}
return querySelectorAllDeep(multiLevelSelectors[4], parent_4);
}

};
Expand Down

0 comments on commit bcd2840

Please sign in to comment.