Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pat-inject code optimizations #1222

Merged
merged 9 commits into from
Jan 12, 2025
2 changes: 1 addition & 1 deletion src/core/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const toNodeArray = (nodes) => {
* @returns {Array} - The DOM nodes found.
*/
const querySelectorAllAndMe = (el, selector) => {
if (!el) {
if (!el || !el.querySelectorAll) {
return [];
}

Expand Down
9 changes: 9 additions & 0 deletions src/core/dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ describe("core.dom tests", () => {

done();
});

it("return empty list, if the element is not a real element.", (done) => {
const res = dom.querySelectorAllAndMe("text", ".selector");
expect(Array.isArray(res)).toBe(true);
expect(res.length).toBe(0);

done();
});

});

describe("wrap tests", () => {
Expand Down
Loading
Loading