Opened 8 years ago

Closed 8 years ago

#145 closed defect (fixed)

LegendPanel: protect getComponent call

Reported by: bartvde Owned by: bartvde
Priority: minor Milestone: 0.6
Component: GeoExt.LegendPanel Version: trunk
Keywords: Cc:
State: Commit

Description

We have a custom layerloader which on store add sets the hideInLegend property of the layer record. This will cause a javascript exception since the legend panel will check for getComponent while its items are undefined. I was surprised to see ExtJS is not protected for this:

    /**
     * Examines this container's <code>{@link #items}</code> <b>property</b>
     * and gets a direct child component of this container.
     * @param {String/Number} comp This parameter may be any of the following:
     * <div><ul class="mdetail-params">
     * <li>a <b><tt>String</tt></b> : representing the <code>{@link Ext.Component#itemId itemId}</code>
     * or <code>{@link Ext.Component#id id}</code> of the child component </li>
     * <li>a <b><tt>Number</tt></b> : representing the position of the child component
     * within the <code>{@link #items}</code> <b>property</b></li>
     * </ul></div>
     * <p>For additional information see {@link Ext.util.MixedCollection#get}.
     * @return Ext.Component The component (if found).
     */
    getComponent : function(comp){
        if(Ext.isObject(comp)){
            return comp;
        }
        return this.items.get(comp);
    }, 

So we need to protect ourselves, patch to come.

Attachments (1)

ticket145.patch (653 bytes) - added by bartvde 8 years ago.
patch protecting ourselves against this.items is undefined error in ExtJS

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by bartvde

patch protecting ourselves against this.items is undefined error in ExtJS

comment:1 Changed 8 years ago by bartvde

  • State changed from None to Review

comment:2 Changed 8 years ago by tschaub

  • Owner set to bartvde
  • State changed from Review to Commit

Looks good. Please commit.

comment:3 Changed 8 years ago by bartvde

  • Resolution set to fixed
  • Status changed from new to closed

(In [1332]) protect ourselves against this.items is undefined error in LegendPanel, r=tschaub (closes #145)

Note: See TracTickets for help on using tickets.