Results 1 to 5 of 5

Thread: TreeStore.unregisterNode assumes childNodes is non-null

    You found a bug! We've classified it as EXTJS-13897 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default TreeStore.unregisterNode assumes childNodes is non-null

    Code:
        unregisterNode : function(node, includeChildren) {
            var me = this,
                children, length, i;
    
    
            delete me.byIdMap[node.id];
            delete me.byInternalIdMap[node.internalId];
            if (includeChildren === true) {
                children = node.childNodes;
                length = children.length;
                for (i = 0; i < length; i++) {
                    me.unregisterNode(children[i], true);
                }
            }
        },
    But NodeInteface.erase sets childNodes to null.

    Therefore I suggest something like:
    Code:
        unregisterNode : function(node, includeChildren) {
            var me = this,
                children, length, i;
    
    
            delete me.byIdMap[node.id];
            delete me.byInternalIdMap[node.internalId];
            if (includeChildren === true) {
                children = node.childNodes;
                if (children) {
                   length = children.length;
                    for (i = 0; i < length; i++) {
                        me.unregisterNode(children[i], true);
                    }
                }
            }
        },
    Cheers,
    Westy
    Product Architect
    Altus Ltd.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Jan 2015
    Location
    Vancouver
    Posts
    15

    Default

    Any updates on this one? or a work-around?

    We defined our TreePanel with "root" property.
    Then, we adds childs through "appendChild" to a certain child (child1).

    Later, when we call removeAll from a node (child1), we run into this issue.


    I created a fiddle.
    https://fiddle.sencha.com/#fiddle/10l9

    Steps to reproduce:
    1. click on "click to add item" multiple times to add items
    2. click on "click to removeAll"

    Expected:
    - All items are removed without any error. Then you can add items again.

    Actual:
    - All items are removed. But there's an exception thrown. Nothing works after.


    EXTJS version tested:
    5.1 ~ 6.0.1: has this issue
    5.0: has this issue. But it behaves slightly different.
    4.2: no issue

  4. #4
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Well, I added an override, as hinted at above.

    Code:
        Ext.define('Altus.overrides.data.TreeStore', {
            override: 'Ext.data.TreeStore',
    
    
            /**
             * Reported here: http://www.sencha.com/forum/showthread.php?287336-TreeStore.unregisterNode-assumes-childNodes-is-non-null
             */
            unregisterNode : function(node, includeChildren) {
                var me = this,
                    children, length, i;
    
    
                delete me.byIdMap[node.id];
                delete me.byInternalIdMap[node.internalId];
                if (includeChildren === true) {
                    children = node.childNodes;
                    // Westy fix - added if
                    if (children) {
                        length = children.length;
                        for (i = 0; i < length; i++) {
                            me.unregisterNode(children[i], true);
                        }
                    }
                }
            }
        });
    Hope that helps,
    Westy
    Product Architect
    Altus Ltd.

  5. #5
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,038

    Default

    Well, just upgrading from Ext 5.1.0 to 6.7.0 and going through our override suite. Amazingly this still looks like a problem! :P

    NodeInterface's prototype implementation of cascade doesn't guard against undefined/null childNodes either.
    Product Architect
    Altus Ltd.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •