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

Element.getAttributeNames() does not match browser behavior #1728

Open
titouanmathis opened this issue Feb 13, 2025 · 0 comments
Open

Element.getAttributeNames() does not match browser behavior #1728

titouanmathis opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@titouanmathis
Copy link
Contributor

titouanmathis commented Feb 13, 2025

Describe the bug

The Element.getAttributeNames() in happy-dom v16 and v17 does not return the same values as browsers. It is working as expected in happy-dom v15.

To Reproduce

Try the following snippet in a browser console (tested in Firefox 135, Chrome 133 and Safari 18 on macOS):

const element = document.createElement('div');
element.setAttribute('ns1:key', 'value1');
element.setAttribute('ns2:key', 'value1');
element.setAttribute('key1', 'value1');
element.setAttribute('key2', '');

console.log(element.getAttributeNames());
// browser: ['ns1:key', 'ns2:key', 'key1', 'key2']
// happy-dom@17: ['ns2:key', 'key1', 'key2']

I also added a failing test in a fork: titouanmathis@8fba4af.

Expected behavior

happy-dom should return the same attributes as the browser when using the Element.getAttributeNames() method.

Screenshots
Not relevant.

Device:

  • OS: macOS
  • Browser: firefox
  • Version: 135

Additional context

Bug encountered in a vitest environment.

@titouanmathis titouanmathis added the bug Something isn't working label Feb 13, 2025
titouanmathis added a commit to titouanmathis/happy-dom that referenced this issue Feb 13, 2025
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