/*

Siesta 5.1.0
Copyright(c) 2009-2018 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license

*/
Class('Ariadne.ExtJSComponentQueryFinder.Identifier.Id', {
    
    isa         : Ariadne.QueryFinder.Identifier,
    
    does        : [
        Ariadne.ExtJSComponentQueryFinder.Role.ExtJSComponentHelper,
        Ariadne.ExtJSDomQueryFinder.Role.ExtJSHelper
    ],
    
    
    methods : {
        
        identify : function (target, root, maze) {
            var id                  = target.id
            
            if (id && !this.ignoreComponentId(id, target, maze.finder.Ext)) {
                // the 1st encountered id will be assigned with weight -100000 in case of `enableMandatoryId`
                // it should be guaranteed that this id will belong to lowest parent with id (currently this holds)
                var weight          = maze.encounteredMandatoryId || !this.finder.enableMandatoryId ? 1000 : -100000
                
                maze.encounteredMandatoryId = true
                
                return {
                    query           : '#' + this.escapeCQSelector(id),
                    weight          : weight,
                    isId            : true
                }
            } else
                return null
        },
        
        
        ignoreComponentId : function (id, comp, Ext) {
            return this.componentHasAutoGeneratedId(comp, Ext)
        }
    }
});

// old ignore xtypes and classnames

//        // Table view is always in panel which seems more 'relevant'
//        // headerContainer is rarely useful (remember though, a grid column is also a headercontainer)
//        ignoreCQSelectors            : function () {
//            return [
//                'viewport',     // Adds no relevance, like matching BODY in a dom query
//                'tableview',    // Always sits in a grid panel
//                'treeview',     // Always sits in a tree panel
//                'gridview',     // Always sits in a grid panel
//                'surface',      // "belongs" to a chart but does not respond to CQ: https://www.sencha.com/forum/showthread.php?308911-Querying-chart-gt-surface-doesn-t-work&p=1128263#post1128263
//                '>>headercontainer[isColumn=undefined]'
//            ];
//        },
//
//        ignoreExtClassNamesRe : function () {
//            return [
//                'Ext\\.dd\\.StatusProxy'
//            ].join('|');
//        }