Problem:
The ability to open a HTMLSelectElement's option list from javascript doesn't exist. Some of the solutions used currently with Chrome won't work in the future due to planned trusted event processing.An example of a current solution that works in Chrome is:
showDropdown = function (element) {
var event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
};
showDropdown(document.getElementById('dropdown'));
This solution relies on the fact that Chrome currently allows untrusted events to execute the default action. The default action for the HTMLSelectElement for mousedown is to open the option list.
According to the UI Event specification untrusted actions should not execute the default action. Chromium’s bug number is 334015.
Solution:
Since this is not consistent across all browsers I would like to propose that we add a open() method to the HTMLSelectElement that will open the option list when called.interface HTMLSelectElement : HTMLElement {
void open();
void close();
};
This method would run the focusing-steps open the select option list. If the element is inert it would do nothing.