bigskysoftware/intercooler-js

Modifiers for ic-action-target are not respected

vborovikov opened this issue · 3 comments

Looking at the code I see I can use ic-*-action-target attribute along with the ic-*-action. But its value isn't actually used to get the target for an action. Instead, Intercooler tries to use the regular ic-action-target or ic-target even if the more specific attribute, i.e. ic-beforeSend-action-target, is present.

I believe it is a bug in the function invokeLocalAction.

I rewrote the beginning of the function and it seems to work as expected:

  function invokeLocalAction(elt, actions, modifier) {
    var actionTargetAttr = 'ic' + modifier + '-action-target';
    var actionTargetVal = closestAttrValue(elt, actionTargetAttr);
    if (actionTargetVal === null && modifier !== "") {
      actionTargetAttr = 'ic-action-target';
      actionTargetVal = closestAttrValue(elt, actionTargetAttr);
    }

    var target = null;
    if(actionTargetVal) {
      target = getTargetImpl(elt, actionTargetAttr);
    } else {
      target = getTarget(elt);
    }
  // ...skipped
1cg commented

thank you for catching this. can you create a pull request with this fix (and, ideally, tests?)

1cg commented

Hello, can I ask again for a pull request on this?

I'm on it.