Skip to content

Commit 1ff9de3

Browse files
committed
fix: [#1274] Fixes problem with query selectors not finding SVG elements after the v13.5.0 release
1 parent 0894067 commit 1ff9de3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/happy-dom/src/query-selector/SelectorItem.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class SelectorItem {
6565

6666
// Tag name match
6767
if (this.tagName) {
68-
if (this.tagName !== '*' && this.tagName !== element[PropertySymbol.tagName]) {
68+
if (this.tagName !== '*' && this.tagName !== element[PropertySymbol.tagName].toUpperCase()) {
6969
return null;
7070
}
7171
priorityWeight += 1;

packages/happy-dom/test/query-selector/QuerySelector.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,27 @@ describe('QuerySelector', () => {
11431143
expect(element2 === div.children[0]).toBe(true);
11441144
});
11451145

1146+
it('Returns SVG elements', () => {
1147+
document.body.innerHTML = `<svg width="3955.829" height="880" viewBox="0 0 3955.829 880" xmlns="http://www.w3.org/2000/svg" id="id_svg_model">
1148+
<g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt"
1149+
stroke="#000" stroke-width="0.25mm" fill="none" style="stroke:#000;stroke-width:0.25mm;fill:none"
1150+
>
1151+
<path d="M 0 0 L 0 880 L 1272.697 880 A 80 80 0 0 0 1350.647 817.996 L 1416.442 533.006 A 120 120 0 0 1 1533.367 440 L 1977.914 440 L 2422.462 440 A 120 120 0 0 1 2539.386 533.006
1152+
L 2605.182 817.996 A 80 80 0 0 0 2683.131 880 L 3955.829 880 L 3955.829 0"
1153+
vector-effect="non-scaling-stroke">
1154+
</path>
1155+
</g>
1156+
</svg>`;
1157+
1158+
const svg = document.querySelector('svg');
1159+
const path = document.querySelector('path');
1160+
1161+
expect(svg?.constructor.name).toBe('SVGSVGElement');
1162+
1163+
// TODO: Should be SVGPathElement, but it is not supported yet
1164+
expect(path?.constructor.name).toBe('SVGElement');
1165+
});
1166+
11461167
it('Throws an error when providing an invalid selector', () => {
11471168
const div = document.createElement('div');
11481169
expect(() => div.querySelector('1')).toThrowError(

0 commit comments

Comments
 (0)