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

TypeError: evt.target.closest is not a function #234

Open
UweOhse opened this issue Oct 17, 2020 · 1 comment
Open

TypeError: evt.target.closest is not a function #234

UweOhse opened this issue Oct 17, 2020 · 1 comment
Labels
Milestone

Comments

@UweOhse
Copy link

UweOhse commented Oct 17, 2020

Bliss.delegate(document.body, "dragstart", "[draggable=true]", function(e) { /* nothing */ });
leads to the exception in the title if one drags a text, because a dragstart event runs, and is handled here:

delegate: overload(function (type, selector, callback) {
		$.bind(this, type, function(evt) {
			if (evt.target.closest(selector)) {
				callback.call(this, evt);
			}
		});
	}, 0, 2),

evt.target unfortunately is a text in this case, and has no closest() method.

A fix is simple:
if (evt.target.closest && evt.target.closest(selector)) {
(tested, works)

btw: bliss is great. thank you very much.

@LeaVerou LeaVerou added the bug label Oct 21, 2020
@LeaVerou LeaVerou added this to the Bliss 2.0 milestone Oct 21, 2020
@LeaVerou
Copy link
Owner

Thanks for reporting! I've added it to my radar.

Actually, a better fix would be to use evt.parentNode.closest() in this case which is essentially what you need.

UweOhse added a commit to UweOhse/bliss that referenced this issue Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants