bliss icon indicating copy to clipboard operation
bliss copied to clipboard

TypeError: evt.target.closest is not a function

Open UweOhse opened this issue 5 years ago • 1 comments

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.

UweOhse avatar Oct 17 '20 12:10 UweOhse

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.

LeaVerou avatar Oct 21 '20 17:10 LeaVerou