Draggable: [Bug] Empty catch block throws warnings

Created on 18 Oct 2017  路  3Comments  路  Source: Shopify/draggable

Trying to get a basic drag and drop setup working with custom elements. My setup looks like this:

//Draggable is expecting a node list, but I have a direct reference to the element, so I wrap it in an array to simulate being _like_ a node list (could be an issue, but this would be a feature request to enable)
this._draggable = new Draggable([this._element.parentElement], {
            draggable: 'element-type' //My custom element I'm creating a drag event for is a <element-type> 
        });

When I click and try to drag the element, I get these warnings thrown in the console (and no drag and drop behavior):

Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
    (No stack trace)

Looking at where it's throwing, it seems based on this empty catch block (https://github.com/Shopify/draggable/blob/23a7f3ae15ff68c5695d482da20f367ca52984f8/src/Draggable/Plugins/Mirror/Mirror.js#L51). I do not believe an empty catch block is allowed as per the spec (http://www.ecma-international.org/ecma-262/6.0/#sec-promise.prototype.catch).
I am using BlueBird as a promise library, so that's probably where the warnings are being thrown from, but nevertheless, an empty catch block should be invalid.

Quick console demo.

var testfn = function(){console.log('test')};
Promise.resolve({}).then(testfn).catch();
//Warning: .then() only accepts functions but was passed: [object Undefined], [object Undefined]
//    at <anonymous>:2:39
bug

All 3 comments

@AStoker thanks for your feedback! The empty catch in the mirror implementation will be addressed soon, the plan is to clean up the mirror (remove from DOM) if an error occurs. I will add it to the v1.0.0-beta.3 release 馃憤

I will keep this issue open until we release the next beta

@AStoker The fix made it into v1.0.0-beta.3 via https://github.com/Shopify/draggable/commit/0286a2da731ab4772aac4720a48d1258bb822596

Let's wait for the beta.3 release before closing this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kauffecup picture kauffecup  路  5Comments

noloop picture noloop  路  5Comments

mbarakaja picture mbarakaja  路  3Comments

decademoon picture decademoon  路  4Comments

890f2151c2be69c51db72017546d00fd picture 890f2151c2be69c51db72017546d00fd  路  4Comments