vguillou / swipe-action

A Polymer element providing a declarative way to swipe DOM elements with configurable underlays and trigger some action when the swiping is done. Integrates seamlessly with the <iron-list> element.
https://vguillou.github.io/webcomponents/swipe-action
MIT License
15 stars 5 forks source link

Bug: Setting activated-action-id on the element in a template breaks #5

Open OvermindDL1 opened 7 years ago

OvermindDL1 commented 7 years ago

Specifically it is causing an access of undefined because on this line in swipe-action.html:

// Line 388 as of the latest release, inside the function activateAction
        var actionToActivate = this._actionsMap[actionId];

The this._actionsMap is undefined, the activateAction function is called from _onActivatedActionIdChange when this._activatedActionIdAlreadyChanged is undefined as well. _onActivatedActionIdChange appears to have a dependency on the element being isReady'd first, but that is not shown, thus it is being called before it is ready, and thus crashing.

What should probably happen from a quick look through the code is there should be an isReady check in _onActivatedActionIdChange and if not isReady then it should return early. Then in the function _refreshActions should probably call activateAction or so after it sets this._actionsMap.