WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.66k stars 80 forks source link

Select `<option>` `value` field is `undefined` #170

Closed MadLittleMods closed 1 year ago

MadLittleMods commented 1 year ago

Similar to https://github.com/WebReflection/linkedom/issues/166

The value field is undefined for <option> elements.

parseHTML(`<select><option id="foo" value="foo">foo</option></select>`).document.querySelector('option').id;
// 'foo'

parseHTML(`<select><option id="foo" value="foo">foo</option></select>`).document.querySelector('option').value;
// undefined

parseHTML(`<select><option id="foo" value="foo">foo</option></select>`).document.querySelector('option').getAttribute('value');
'foo'

It would be nice if you could get the value from a <select> element as well but I understand this may be a bit less straight-forward.

parseHTML(`<select id="form-select"><option value="foo" selected="selected">foo</option></select>`).document.querySelector('select').id;
// 'form-select'

parseHTML(`<select id="form-select"><option value="foo" selected="selected">foo</option></select>`).document.querySelector('select').value;
// undefined
WebReflection commented 1 year ago

It's up ... select.value and options.selected or options.value are up

MadLittleMods commented 1 year ago

Thanks for the quick update @WebReflection! Spotted a tiny issue with the new change: https://github.com/WebReflection/linkedom/issues/171

WebReflection commented 1 year ago

that's not an issue to me, explained in comments 👋