Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

null is not an object on ios/cordova #11213

Open
gdjennings opened this issue Mar 1, 2015 · 4 comments
Open

null is not an object on ios/cordova #11213

gdjennings opened this issue Mar 1, 2015 · 4 comments

Comments

@gdjennings
Copy link

From rootscope.js...

      // 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 $digest
      // (though it differs due to having the extra check for $$listenerCount)
      if (!(next = ((current.$$listenerCount[name] && current.$$childHead) ||
          (current !== target && current.$$nextSibling)))) {
      while (current !== target && !(next = current.$$nextSibling)) {     //<<<----- current null?
          current = current.$parent;
        }
      }
    }

Under certain circumstances (that I don't yet understand), current is null. Checking for null in the loop gets rid of the error. It may be related to load. I suspect something else bad is happening that is causing this. Apologies for the lack of detail/reproducibility.
I am using Ionic but 1.3.13 of angular.

@pkozlowski-opensource
Copy link
Member

@gdjennings thnx for the report. It will be rather hard to take meaningful actions on this one without more info, so anything you can do to pinpoint the problem will help tremendously....

@pkozlowski-opensource pkozlowski-opensource added this to the Purgatory milestone Mar 1, 2015
@gdjennings
Copy link
Author

@pkozlowski-opensource Completely understand. I wanted to get it out there in case something stood out to someone. I haven't had a chance to look further into the context of this block and under what circumstances it is even possible that current is null and why it isn't checked for in the loop. I am sometimes seeing errors in other unchecked lines (within Ionic) so perhaps a scope is being trashed in an antisocial way by myself, Ionic or Apple.
A couple of additional notes

  1. Because of (iOS 8 GM iPhone5C) TypeError: Attempted to assign to readonly property #9128 I commented out 'use strict'
  2. I am using cordova + WKWebView and IndexedDB. I need to check if I can reproduce this in plain old safari.

@pkozlowski-opensource pkozlowski-opensource changed the title Achieving null is not an object on ios/cordova null is not an object on ios/cordova Mar 4, 2015
@wesleycho
Copy link
Contributor

FWIW, I never came across this problem in Cordova (my company also uses Ionic). More details would probably be helpful.

@ArthurThornton
Copy link

This issue seems to be related to #1627.

A project I'm working on is running into a similar issue. It seems the easiest way to reproduce it is to destroy the parent scope from within the child scope by way of $broadcast/$emit. Here's a simple jsFiddle that shows the behavior:

http://jsfiddle.net/n7sr080e/

Note that the error message is different in Chrome vs Firefox. In Firefox, the error message is "TypeError: current is null" whereas in Chrome it's "TypeError: Cannot read property '$$nextSibling' of null". This is the same error and occurs in the same location:

if (!(next = ((current.$$listenerCount[name] && current.$$childHead) ||

There are other areas where it is assumed that the current object will exist even if it does not (in this case, that's because we've destroyed the parent of the element from which we're calling $broadcast).

I should also note that this is not, in fact, limited to just iOS/Cordova/etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants