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

Adjacent sibling selector does not work in querySelector, when <select> element is involved. #1532

Open
ushi-as opened this issue Sep 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ushi-as
Copy link

ushi-as commented Sep 5, 2024

Describe the bug

Since version 15 of happy-dom i see strange behavior when using the adjacent sibling selector (+), when a select element is involved. When selecting 'E1 + E2', happy-dom does not find E2 if E1 is a <select> Element.

To Reproduce

Execute the following script:

import { Window } from 'happy-dom';

const window = new Window({ url: 'https://localhost:8080' });
const document = window.document;

document.body.innerHTML = `
<div class="a"></div>
<div class="b"></div>
`

console.log(document.body.innerHTML);
console.log(document.body.querySelector('.a + .b') !== null);
console.log(document.body.querySelector('div + div') !== null);

document.body.innerHTML = `
<select class="a"></select>
<div class="b"></div>
`

console.log(document.body.innerHTML);
console.log(document.body.querySelector('.a + .b') !== null);
console.log(document.body.querySelector('select + div') !== null);

document.body.innerHTML = `
<div class="a"></div>
<select class="b"></select>
`

console.log(document.body.innerHTML);
console.log(document.body.querySelector('.a + .b') !== null);
console.log(document.body.querySelector('div + select') !== null);

It outputs:

<div class="a"></div>
<div class="b"></div>

true
true

<select class="a"></select>
<div class="b"></div>

false
false

<div class="a"></div>
<select class="b"></select>

true
true

Expected behavior

The expected output is:

<div class="a"></div>
<div class="b"></div>

true
true

<select class="a"></select>
<div class="b"></div>

true
true

<div class="a"></div>
<select class="b"></select>

true
true

Device:

  • Node version: 20
  • happy-dom version: 15.7
@ushi-as ushi-as added the bug Something isn't working label Sep 5, 2024
@ushi-as ushi-as changed the title Adjacent sibling selector in combination with select element does not work in querySelector. Adjacent sibling selector in combination with <select> element does not work in querySelector. Sep 5, 2024
@ushi-as ushi-as changed the title Adjacent sibling selector in combination with <select> element does not work in querySelector. Adjacent sibling selector does not work in querySelector, when <select> element is involved. Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant