diff --git a/src/index.ts b/src/index.ts index 265cd6a..5d3da4c 100755 --- a/src/index.ts +++ b/src/index.ts @@ -325,6 +325,14 @@ export class HTMLElement extends Node { matcher = selector; matcher.reset(); } else { + if (selector.includes(',')) { + const selectors = selector.split(',') as string[]; + let result = [] as HTMLElement[]; + selectors.forEach((s) => { + result = result.concat(this.querySelectorAll(s.trim())); + }) + return result; + } matcher = new Matcher(selector); } const res = [] as HTMLElement[]; diff --git a/test/html.js b/test/html.js index adef4fc..741bd0d 100644 --- a/test/html.js +++ b/test/html.js @@ -310,6 +310,7 @@ describe('HTML Parser', function () { root.querySelectorAll('span.a.b').should.eql([root.firstChild.firstChild.firstChild]); root.querySelectorAll('#id .b').should.eql([root.firstChild.firstChild.firstChild]); root.querySelectorAll('#id span').should.eql(root.firstChild.firstChild.childNodes); + root.querySelectorAll('#id, #id .b').should.eql([root.firstChild, root.firstChild.firstChild.firstChild]); }); });