Skip to content

Commit

Permalink
Merge pull request #1222 from Patternslib/pat-inject-modernization
Browse files Browse the repository at this point in the history
pat-inject code optimizations
  • Loading branch information
thet authored Jan 12, 2025
2 parents a28a386 + 8a3af53 commit 13bf6dc
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 138 deletions.
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

0 comments on commit 13bf6dc

Please sign in to comment.