$destroy causes exception while digesting !? (Cannot read property '$$nextSibling' of null)

610 views
Skip to first unread message

Bernd Wessels

unread,
May 1, 2013, 4:58:06 PM5/1/13
to ang...@googlegroups.com
Hi

In my directive I use something like this:

var newScope = $scope.$new();
var newElement = $compile(...)(newScope);

later in an JQuery mousemove event I do something like:

if(!$rootScope.$$phase) {
    scope.$apply(function () {
        newScope.$destroy();
    });
}

Unfortunately that causes and exception:

TypeError: Cannot read property '$$nextSibling' of null

in:

// Insanity Warning: scope depth-first traversal
// yes, this code is a bit crazy, but it works and we have tests to prove it!
// this piece should be kept in sync with the traversal in $broadcast
if (!(next = (current.$$childHead || (current !== target && current.$$nextSibling)))) {
while(current !== target && !(next = current.$$nextSibling)) {
current = current.$parent;
}

Is there a bug?

Best regards
Bernd
Reply all
Reply to author
Forward
0 new messages