Skip to content

Commit

Permalink
fix: [#1526] Handles scenario where a symbol property doesn't exist o…
Browse files Browse the repository at this point in the history
…n HTMLSelectElement (#1527)
  • Loading branch information
Cherry authored Sep 1, 2024
1 parent 20b520a commit afc3692
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export default class HTMLSelectElement extends HTMLElement {
return true;
}

if (typeof property === 'symbol') {
return false;
}

const index = Number(property);

if (!isNaN(index)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ describe('HTMLSelectElement', () => {
});
});

describe('get symbol()', () => {
it('returns existing symbol properties', () => {
const symbol = Symbol('test');
element[symbol] = 'test';
expect(element[symbol]).toBe('test');
});

it('ignores missing symbol properties', () => {
const symbol = Symbol('other-test');

expect(element[symbol]).toBe(undefined);

// https://github.com/capricorn86/happy-dom/issues/1526
expect(symbol in element).toBe(false);
});
});

describe(`set selectedIndex()`, () => {
it('Allows -1', () => {
element.selectedIndex = -1;
Expand Down

0 comments on commit afc3692

Please sign in to comment.