txiki.js icon indicating copy to clipboard operation
txiki.js copied to clipboard

Event.target always return null

Open partic2 opened this issue 11 months ago • 4 comments

At https://github.com/saghul/txiki.js/blob/6e01bf4a0cbc1aba6dcdddf1d0aa67df287ce420/src/js/polyfills/event-target.js#L95-L103

txiki.js seem to always return null for Event.target

According to https://developer.mozilla.org/en-US/docs/Web/API/Event/target It should be the eventTarget on where dispatchEvent called.

Maybe we can simply fix it by below code?

get target() { 
     return this.currentTarget; 
 } 

partic2 avatar May 03 '25 14:05 partic2

What is your use case?

saghul avatar May 09 '25 11:05 saghul

What is your use case?

My code is simplicified like below

new Worker('xxx.js').addEventListener('message',function(ev){
  ev.target.postMessage('xxx')
})

This code work correctly on firefox and chrome, but throw on txiki.js

partic2 avatar May 09 '25 14:05 partic2

Got it. A PR would be welcome, if you're up for it!

saghul avatar May 09 '25 16:05 saghul

Got it. A PR would be welcome, if you're up for it!

Ok. I create a patch, after learning how to bundle modified js.

I'm not familiar with such js bundling.Maybe we should remove the generated bytecode from repository? Which may cause the code repository size to expand rapidly.

partic2 avatar May 09 '25 18:05 partic2