Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event.target should match event.currentTarget at time of dispatch #18

Closed
leeoniya opened this issue Dec 14, 2017 · 4 comments
Closed

event.target should match event.currentTarget at time of dispatch #18

leeoniya opened this issue Dec 14, 2017 · 4 comments

Comments

@leeoniya
Copy link

https://github.com/developit/undom/blob/master/src/undom.js#L140

should be

let t = event.currentTarget = event.target = this,
@leeoniya
Copy link
Author

leeoniya commented Dec 14, 2017

err, no i think this is wrong too.

currentTarget (and this) should always point to the element that the listener is attached to while target is always the source of the event. the actual impl that passes my browser-tested tests is this one:

Element.prototype.dispatchEvent = function(event) {
	let t = event.target = this,
		c = event.cancelable,
		l, i;
	do {
		l = t.__handlers && t.__handlers[(event.type).toLowerCase()];
		if (l && (event.currentTarget = t)) for (i=l.length; i--; ) {
			if ((l[i].call(t, event)===false || event._end) && c) break;
		}
	} while (event.bubbles && !(c && event._stop) && (t=t.parentNode));
	return !event.defaultPrevented;
};

i think this is correct, but plz doublecheck.

https://stackoverflow.com/a/10086501/973988

@developit
Copy link
Owner

That is correct, yes.

@leeoniya
Copy link
Author

leeoniya commented Jan 22, 2018

FWIW, i had to make some other additions/tweaks to undom to get all my tests fully working (that already passed in browsers), though i cannot guarantee my impls are anything close to DOM spec compliant :D

feel free to cherry pick anything you find useful. value, textContent and createComment are fairly low weight and non-contrived for domvm's test cases.

https://github.com/leeoniya/domvm/blob/3.x-dev/test/init-spec.js

@developit
Copy link
Owner

Whoops, had those properties reversed!

developit added a commit that referenced this issue Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants