PDA

View Full Version : [CLOSED] Ext.ComponentQuery.query returns components that does not exists on the DOM



rafaelreuber
15 Aug 2015, 5:44 PM
Steps de reproduce


1) Open the http://examples.sencha.com/extjs/6.0.0/examples/kitchensink/#form-register
2) I Open a Javascript console
3) Type the follow script:
Ext.ComponentQuery.query("button").map(function(e){
return e.id
})
The script will an array like ["button-1005", "button-1006", "button-1007", "button-1008", "splitbutton-1034", "splitbutton-1039", "splitbutton-1043", "button-1058", "tab-1062", "tab-1063", "tab-1064"]
4) If I execute the Script Ext.ComponentQuery.query("#button-1005") or document.getElementById("button-1005") it returns null

Greendrake
15 Aug 2015, 7:04 PM
That would only be a bug if it happened to Ext.dom.Query, not Ext.ComponentQuery. Ext JS components do not necessarily have to be represented in the DOM, they can be sitting in the memory waiting for the right moment to be rendered.

Try this:
Ext.create('Ext.Component', {
name: 'cool'
});
console.log(Ext.ComponentQuery.query('box[name="cool"]')[0].id);

evant
15 Aug 2015, 8:12 PM
The above is correct, components don't need to be rendered to be queryable.