<commit_before># FocusImplOld
class Focus:

    def blur(self, elem):
        JS("""
        // Attempts to blur elements from within an event callback will
        // generally be unsuccessful, so we invoke blur() from outside of
        // the callback.
        $wnd.setTimeout(function() {
                                       elem.firstChild.blur();
                        },
                        0);
        """)
    
    def createFocusable(self):
        JS("""
        var div = $doc.createElement('div');
        var input = $doc.createElement('input');
        input.type = 'text';
        input.style.width = input.style.height = 0;
        input.style.zIndex = -1;
        input.style.position = 'absolute';

        input.addEventListener(
            'blur',
            function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); },
            false);

        input.addEventListener(
            'focus',
            function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); },
            false);

        div.addEventListener(
            'mousedown',
            function(evt) { this.firstChild.focus(); },
            false);
        
        div.appendChild(input);
        return div;
        """)

    def focus(self, elem):
        JS("""
        // Attempts to focus elements from within an event callback will
        // generally be unsuccessful, so we invoke focus() from outside of
        // the callback.
        $wnd.setTimeout(function() {
                                       elem.firstChild.focus();
                        },
                        0);
        """)
    
    def getTabIndex(self, elem):
        JS("""
        return elem.firstChild.tabIndex;<commit_msg>#74 - really _does_ have to be elem.focus not elem.firstChild.focus<commit_after># FocusImplOld
class Focus:

    def blur(self, elem):
        JS("""
        // Attempts to blur elements from within an event callback will
        // generally be unsuccessful, so we invoke blur() from outside of
        // the callback.
        $wnd.setTimeout(function() {
                                       elem.blur();
                        },
                        0);
        """)
    
    def createFocusable(self):
        JS("""
        var div = $doc.createElement('div');
        var input = $doc.createElement('input');
        input.type = 'text';
        input.style.width = input.style.height = 0;
        input.style.zIndex = -1;
        input.style.position = 'absolute';

        input.addEventListener(
            'blur',
            function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); },
            false);

        input.addEventListener(
            'focus',
            function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); },
            false);

        div.addEventListener(
            'mousedown',
            function(evt) { this.firstChild.focus(); },
            false);
        
        div.appendChild(input);
        return div;
        """)

    def focus(self, elem):
        JS("""
        // Attempts to focus elements from within an event callback will
        // generally be unsuccessful, so we invoke focus() from outside of
        // the callback.
        $wnd.setTimeout(function() {
                                       elem.focus();
                        },
                        0);
        """)
    
    def getTabIndex(self, elem):
        JS("""
        return elem.firstChild.tabIndex;
{'fraction_non_alphanumeric': 0.11656267725467952, 'fraction_numerical': 0.0028360748723766306, 'mean_word_length': 1.4324137931034482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5081780', 'n_tokens_mistral': 915, 'n_tokens_neox': 888, 'n_words': 223}