<commit_before>/**
 * @preserve Neuron core:dom v2.0(jQuerified)
 */
;(function(K){

/**
 nodeType: 
 ref: https://developer.mozilla.org/en/nodeType
 
    Node.ELEMENT_NODE == 1
        - document.documentElement
        - document.body
        - <head>
        
    Node.ATTRIBUTE_NODE == 2
    Node.TEXT_NODE == 3
    Node.CDATA_SECTION_NODE == 4
    Node.ENTITY_REFERENCE_NODE == 5
    Node.ENTITY_NODE == 6
    Node.PROCESSING_INSTRUCTION_NODE == 7
    Node.COMMENT_NODE == 8
    Node.DOCUMENT_NODE == 9
        - document
        
    Node.DOCUMENT_TYPE_NODE == 10
    Node.DOCUMENT_FRAGMENT_NODE == 11
    Node.NOTATION_NODE == 12
 */
 
 
/**
 *
 */
function isDOMSubject(el){
    var type;
    return K.isWindow(el) || el && (type = el.nodeType) && (type === 1 || type === 9);
};


/**
 * filter an array or Array-like object. this method will change the origin subject
 * @param {Array|Object} array
 * @param {function(mixed, number)} filter
 */
function filterArrayObject(array, filter){
    var i = 0;
    
    // array.length is changing
    for(; i < array.length; i ++){
        if(!filter.call(array, array[i], i)){
        
            // the member at the iterator has been removed, so we should move the iterator one step to the left
            array.splice(i --, 1);
        }
    }
    
    return array;
};


// function getContext(el){
    // window         -> window
    // body         -> body
    // [null]        -> [null]
    // $(window)    -> window
//    return !el || isDOMSubject(el) ? el : el._ === atom && el.context;
// };


/**

Select:
$(selector)             =
$(DOMElement)           =
$(NodeList)             =
$(NR.DOM)               =
$(selector, context)    +
$(Array.<DOMElement>)   +

Create:
$(fragment)             +       X
$(fragment, attrs)      +?      X

$.create(tagName, attrs);

*/

/**
 * @private
 * @param {string|DOMElement} selector
 * @param {(DOM|NodeList|DOMElement)=} context
 * @param {boolean=} first only get the first matched element
 */
function DOMInit(selector, context, first){

    // use ECMAScript strict
    var self = this,
        element;
    
    
    if(!selector){
        return self;
    }
    
    if(
        // if `selector` is a DOMElement, ignore `context`
        isDOMSubject(element = selector)
        
        // optimize finding document.body
        || selector === 'body' && !context && (element = DOC.body)
    ){
        self[0] = element;
        self.length = 1;
        return self;
    }
    
    if(K.isString(selector)){
    
        // give id special treatment, 
        if(REGEX_IS_ID.test(selector)){
            var id = selector.slice(1),
                el = DOC.getElementById(id);
            
            // from jQuery:
            // > Check parentNode to catch when Blackberry 4.6 returns
            // > nodes that are no longer in the document [#6963](http://bugs.jquery.com/ticket/6963)
            if(el && el.parentNode){
            
                // > In IE7 Standards mode and previous modes, 
                // > this method performs a case-insensitive match on both the ID and NAME attributes, 
                // > which might produce unexpected results
                // via: [msdn](http://msdn.microsoft.com/en-us/library/ie/ms536437(v=vs.85).aspx)
                if(el.id !== id){
                    return ROOT.findOne(selector);
                }
                
                self[0] = el;
                self.length = 1;
            }
            
            return self;
        }
        
        // normal selectors
        return DOM(context || ROOT)[first ? 'one' : 'find'](selector);
    }

    makeArray(selector, self);
    filterArrayObject(self, isDOMSubject);

    if(first){
        // in IE6-8, the second argument of Array.prototype.splice is *required*, which is different from standard
        // [ref: msdn](http://msdn.microsoft.com/en-us/library/wctc5k7s(v=vs.94).aspx)
        self.splice(1, self.length - 1);
    }

    return self;
};


function DOM(element, context){<commit_msg>dom/core: fix findOne<commit_after>/**
 * @preserve Neuron core:dom v2.0(jQuerified)
 */
;(function(K){

/**
 nodeType: 
 ref: https://developer.mozilla.org/en/nodeType
 
    Node.ELEMENT_NODE == 1
        - document.documentElement
        - document.body
        - <head>
        
    Node.ATTRIBUTE_NODE == 2
    Node.TEXT_NODE == 3
    Node.CDATA_SECTION_NODE == 4
    Node.ENTITY_REFERENCE_NODE == 5
    Node.ENTITY_NODE == 6
    Node.PROCESSING_INSTRUCTION_NODE == 7
    Node.COMMENT_NODE == 8
    Node.DOCUMENT_NODE == 9
        - document
        
    Node.DOCUMENT_TYPE_NODE == 10
    Node.DOCUMENT_FRAGMENT_NODE == 11
    Node.NOTATION_NODE == 12
 */
 
 
/**
 *
 */
function isDOMSubject(el){
    var type;
    return K.isWindow(el) || el && (type = el.nodeType) && (type === 1 || type === 9);
};


/**
 * filter an array or Array-like object. this method will change the origin subject
 * @param {Array|Object} array
 * @param {function(mixed, number)} filter
 */
function filterArrayObject(array, filter){
    var i = 0;
    
    // array.length is changing
    for(; i < array.length; i ++){
        if(!filter.call(array, array[i], i)){
        
            // the member at the iterator has been removed, so we should move the iterator one step to the left
            array.splice(i --, 1);
        }
    }
    
    return array;
};


// function getContext(el){
    // window         -> window
    // body         -> body
    // [null]        -> [null]
    // $(window)    -> window
//    return !el || isDOMSubject(el) ? el : el._ === atom && el.context;
// };


/**

Select:
$(selector)             =
$(DOMElement)           =
$(NodeList)             =
$(NR.DOM)               =
$(selector, context)    +
$(Array.<DOMElement>)   +

Create:
$(fragment)             +       X
$(fragment, attrs)      +?      X

$.create(tagName, attrs);

*/

/**
 * @private
 * @param {string|DOMElement} selector
 * @param {(DOM|NodeList|DOMElement)=} context
 * @param {boolean=} first only get the first matched element
 */
function DOMInit(selector, context, first){

    // use ECMAScript strict
    var self = this,
        element;
    
    
    if(!selector){
        return self;
    }
    
    if(
        // if `selector` is a DOMElement, ignore `context`
        isDOMSubject(element = selector)
        
        // optimize finding document.body
        || selector === 'body' && !context && (element = DOC.body)
    ){
        self[0] = element;
        self.length = 1;
        return self;
    }
    
    if(K.isString(selector)){
    
        // give id special treatment, 
        if(REGEX_IS_ID.test(selector)){
            var id = selector.slice(1),
                el = DOC.getElementById(id);
            
            // from jQuery:
            // > Check parentNode to catch when Blackberry 4.6 returns
            // > nodes that are no longer in the document [#6963](http://bugs.jquery.com/ticket/6963)
            if(el && el.parentNode){
            
                // > In IE7 Standards mode and previous modes, 
                // > this method performs a case-insensitive match on both the ID and NAME attributes, 
                // > which might produce unexpected results
                // via: [msdn](http://msdn.microsoft.com/en-us/library/ie/ms536437(v=vs.85).aspx)
                if(el.id !== id){
                    return ROOT.findOne(selector);
                }
                
                self[0] = el;
                self.length = 1;
            }
            
            return self;
        }
        
        // normal selectors
        return DOM(context || ROOT)[first ? 'findOne' : 'find'](selector);
    }

    makeArray(selector, self);
    filterArrayObject(self, isDOMSubject);

    if(first){
        // in IE6-8, the second argument of Array.prototype.splice is *required*, which is different from standard
        // [ref: msdn](http://msdn.microsoft.com/en-us/library/wctc5k7s(v=vs.94).aspx)
        self.splice(1, self.length - 1);
    }

    return self;
};


function DOM(element, context){
{'fraction_non_alphanumeric': 0.13433571604633965, 'fraction_numerical': 0.013063840276066059, 'mean_word_length': 1.7620830496936692, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2061294', 'n_tokens_mistral': 2600, 'n_tokens_neox': 2419, 'n_words': 603}