x-tag / core

The Heart of X-Tag
http://x-tag.github.io/
Other
1.25k stars 151 forks source link

v2 docs Pseudos versus Jasmine tests #190

Closed ghost closed 6 years ago

ghost commented 6 years ago

So, I'm a bit confused here because I can't get the action, onAdd, or onRemove functions to fire.

Do these fire when the element is added, removed, or have an event fired?

In the v2 beta docs it says the following --

xtag.pseudos.example = {
  onAdd: function(){
    /*
      This function is fired once when the base function is added to
      the target object. For instance:

      If you added an event with xtag.addEvent(someNode, 'tap:example', fn),
      the onAdd function of the 'example' pseudo would be fired once when
      the event is first attached to the element 'someNode'.
    */

  },
  onRemove: function(){
    /*
      This is basically the opposite of the onAdd function above.
      With onRemove, you can clean up whatever you may have done
      in your onAdd or action function invocations.
    */
  },
  action: function(pseudo, event) {
    /*
      This function is fired each time the pseudo chain is fired.
      Pseudo actions are fired in the order they are chained, meaning
      the in the pseudo 'toggle:log:example', the action function
      for the 'log' pseudo would fire first, then the 'example' action
      and finally the base function 'toggle' they are chained to.
    */
  }
};

but in the jasmine tests it's done like the folowing--

xtag.pseudos.foo = {
      onInvoke(){
        count++;
      }
    }