lightpanda-io / browser

The open-source browser made for headless usage
https://lightpanda.io
GNU Affero General Public License v3.0
152 stars 0 forks source link

events: bubble DOM tree events to window #161

Open krichprollsch opened 10 months ago

krichprollsch commented 10 months ago

According with the MDN documentation, the DOM tree events must bubble untli the window object.

In addition to the events listed below, many events can bubble from the Document contained in the window object. https://developer.mozilla.org/en-US/docs/Web/API/Window#events

Examples using FF:

var nb = 0;
window.addEventListener('foo', function(event) {nb ++;}, true);
document.getElementById('content').dispatchEvent(new Event('foo'));
nb; // returns 1
var nb = 0;
window.addEventListener('foo', function(event) {nb ++;});
document.getElementById('content').dispatchEvent(new Event('foo', {'bubbles':true}));
nb; // returns 1

But our usage of libdom node dispatch will not take account the pure zig window object.

krichprollsch commented 9 months ago

We could register listeners to document with a * type to receive document's events. Then we will able to dispatch these events to widow's listeners.

Maybe we will have to implement the * type into libdom to do so.