Closed SuricateCan closed 8 years ago
After struggling with the whole karma jasmine thing, I manage to get all code to run correctly (even corrected a bug because of the failed tests) and all tests to pass.
Hi, first thanks. Few points:
$$phase
is a good practice as this is internal to angularHi @ezraroi, let me explain:
Another way to trigger a digest for angular is wrapping the call with $timeout, but I don't think that its a good use in this scenario.
Another thing I feel like explaining is the use of $timeout
wrapping manageEvents
and wrapping onAdded
contents:
On manageEvents
, if the function is called immediately with the rest of the code, jstree triggers , specially those that trigger on document
, will be called after the user handling code. One bad example of it is if you try to bind to dnd_stop.vakata
. Without the $timeout
, your code on scope will execute before the element is actually moved, causing all node information to be "incorrect".
On onAdded
, I added the $timeout
so javascript wont hang. I don't know exactly why it would hang on while(blocked)
(I don't see any reason for this block to exist in the first place, but I wouldn't change the basics of your code).
It was design decision not trigger digest on every jstree event, it might have been wrong. In my projects, I just ran the event handler in $apply or $timeout when I needed.
About the while loop.. I don't really remember now as it was a long time ago, but it was needed on this I am pretty sure
Maybe the while loop was to prevent event handlers to call the onAdded function again? In any case, now that it is inside a $timeout, I don't think it is necessary, but again, it's your call.
BTW, I am glad I could contribute to your project.
Hi, I've talked about some of these fixes on #75.
Here is the list of accomplishments on this commit:
NOTE: These changes CAN break binding calls if they expect the li#node as this.
This change is