Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: Ext.get() throws errors if the element has the same id as a recently removed element

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-13702 in 5.0.1.
  1. #11
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    Looks like we have a bug in our Element garbage detection method (it doesn't account for the fact that the element in question might be replacing a recently removed element with the same ID)

  2. #12
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    In response to Mats:

    1. Is this considered 'wrongful' use of your Grid / Element API?
    2. Can we somehow opt out of the caching, or it's checks?
    3. This was fine in Ext 4.x, is there an override to get back the old way?
    1) Yes, I believe so. Because the elements you're referring to are transient, you can never really hold a reference to them so each time you need an access you have to call get(), then you should really be using fly().
    2) Use fly() to not cache, but otherwise there's no way to opt-out of caching
    3) Phil's got an override

    So in short, it's a bug, I'd say it's not good practice to be doing it in they way you've got it now.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #13
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    @mankz @Zdeno Will be fixed in next release - here's a workaround for now:

    Code:
    Ext.require('Ext.dom.Element', function() {
        Ext.isGarbage = function(dom) {
            // determines if the dom element is in the document or in the detached body element
            // use by collectGarbage and Ext.get()
            return dom &&
                // Must be an element. window, document and documentElement can never be garbage.
                dom.nodeType === 1 &&
                // if the element does not have a parent node, it is definitely not in the
                // DOM - we can exit immediately
                (!dom.parentNode ||
                // If the element has an offset parent we can bail right away, it is
                // definitely in the DOM.
                (!dom.offsetParent &&
                    // if the element does not have an offsetParent it can mean the element is
                    // either not in the dom or it is hidden.  The next step is to check to see
                    // if it can be found by id using either document.all or getElementById(),
                    // whichever is faster for the current browser.  Normally we would not
                    // include IE-specific checks in the sencha-core package, however,  in this
                    // case the function will be inlined and therefore cannot be overridden in
                    // the ext package.
                    ((Ext.isIE8 ? document.all[dom.id] : document.getElementById(dom.id)) !== dom) &&
                    // finally if the element was not found in the dom by id, we need to check
                    // the detachedBody element
                    !(Ext.detachedBodyEl && Ext.detachedBodyEl.isAncestor(dom))));
        };
    });
    Still probably best to avoid using Ext.get() for this type of thing anyway. Use Ext.fly() for quick and easy access to the Ext.Element api (unless you need to attach listeners). Ext.fly() will bypass the caching mechanism
    Phil Guerrant
    Ext JS - Development Team

  4. #14

  5. #15
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,153

    Default

    Patch seems to work, a few more tests green as a result

  6. #16
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    769

    Default

    Thanks Everything works like a charm now.

  7. #17
    Ext JS Premium Member
    Join Date
    Feb 2008
    Posts
    318

    Default

    Phil Guerrant

    I have placed your code into Application.js (I'm not sure if this is the right place).

    But error is still there (tested on IE11):
    "
    DOM element with id ext-gen2 in Element cache is not the same as element in the DOM. Make sure to clean up Element instances using destroy()
    "

    I have included my example as attachment - index.html. You just have to replace library path.

    br, Simon
    Attachment 50890
    Attached Files Attached Files

  8. #18
    Sencha User Phil Guerrant's Avatar
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352

    Default

    You can know for sure if the override is working by putting a breakpoint inside the isGarbage function in the override.

    If the override is being called, I'd need more detail to know for sure what's happening, (call stacks etc)
    Phil Guerrant
    Ext JS - Development Team

  9. #19
    Sencha Premium Member
    Join Date
    Nov 2014
    Posts
    1

    Default Still happening in 5.1

    I saw this issue today in ext 5.1 in IE8. I have a card layout that includes a box. I am updating the box html based on events in the app. I am using a callback on the update() method (and resize listener) to get elements on the html to size them like so.

    var node = this.el.getById('myId');
    node.setHeight(value);

    I got around this using Ext.fly() instead, but it appears there is still a garbage collection issue since the node with myId is replaced by the call to update().

  10. #20
    Sencha Premium Member
    Join Date
    Apr 2014
    Posts
    39

    Default

    We also have this problem. We included the calendar example in our project and started customizing it. Sometimes, mostly when trying to drag and drop an event in the week view this error will appear and disappear at random. I'm reluctant on using Ext.fly since i'm not 100% familiar with the calendar's code yet and I'm not sure it can replace Ext.get(). I'll try to find an exact scenario where this error appears and post again.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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