Skip to content

Commit

Permalink
Merge pull request #649 from itutto/#648-option-element-value-patch
Browse files Browse the repository at this point in the history
#648@patch: OptionElement.value returns `textContent` as fallback.
  • Loading branch information
capricorn86 committed Nov 8, 2022
2 parents 62e2920 + f543b06 commit 1a21ed7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -109,7 +109,7 @@ export default class HTMLOptionElement extends HTMLElement implements IHTMLOptio
* @returns Value.
*/
public get value(): string {
return this.getAttributeNS(null, 'value') || '';
return this.getAttributeNS(null, 'value') || this.textContent;
}

/**
Expand Down
Expand Up @@ -25,6 +25,12 @@ describe('HTMLOptionElement', () => {
element.setAttribute('value', 'VALUE');
expect(element.value).toBe('VALUE');
});

it('Returns the text IDL value if no attribute is present.', () => {
element.removeAttribute('value');
element.textContent = 'TEXT VALUE';
expect(element.value).toBe('TEXT VALUE');
});
});

describe('set value()', () => {
Expand Down

0 comments on commit 1a21ed7

Please sign in to comment.