<commit_before>(function() {
    
    Batman.DOM = {
        view: function(view) {
            var node = view.node(),
                contexts = [Batman.View.helpers, Batman.mixins, view, {view: view}];
            
            if (view.context)
                contexts.push(view.context);
            
            Batman.DOM.node(node, contexts);
        },
        
        node: function(node, contexts) {
            if (typeof node === 'string')
                node = document.getElementById(node);
            
            if (!node)
                return;
            
            contexts = contexts || [];
            
            var result;
            if (typeof node.getAttribute === 'function') {
                contexts.push({node: node}, node);
                
                var attributes = Array.toArray(node.attributes);
                for (var i = -1, count = attributes.length; ++i < count;) {
                    var attribute = attributes[i],
                        attributeName = attribute.nodeName,
                        attributeValue = attribute.nodeValue;
                    
                    if (attributeName.substr(0,5) !== 'data-')
                        continue;
                    
                    var binding = attributeName.substr(5);
                    if (binding.substr(0,5) === 'bind-')
                        result = Batman.DOM.bindAttribute(binding.substr(5), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,5) === 'each-')
                        result = Batman.DOM.bindEach(binding.substr(5), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,6) === 'mixin-')
                        result = Batman.DOM.bindMixin(binding.substr(6), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,8) === 'formfor-')
                        result = Batman.DOM.bindForm(binding.substr(8), attributeValue, node, contexts);
                    
                    else if (Batman.DOM.bindings[binding])
                        result = Batman.DOM.bindings[binding](attributeValue, node, contexts);
                    
                    else
                        continue;
                    
                    node.removeAttribute(attributeName);
                    
                    if (result === false)
                        break;
                }
                
                contexts.splice(contexts.indexOf(node) - 1);
            }
            
            if (result !== false) {
                var children = node.childNodes;
                for (var i = -1, count = children.length; ++i < count;)
                    Batman.DOM.node(children[i], contexts);
                
                if (node.onBatmanLoad) {
                    var i = node.onBatmanLoad.length;
                    while (i--)
                        node.onBatmanLoad[i].call(node, node);
                }
            }
        },
        
        forgetNode: function(node) {
            
        },
        
        bindings: {
            bind: function(string, node, contexts) {
                var binding = node._valueBinding = Batman.bindingFromString(string, contexts);
                binding.observe(function(value) { Batman.DOM.valueForNode(node, value); }, true);
                Batman.DOM.onchange(node, function(value) { binding(value); });
            },
            
            visible: function(string, node, contexts) {
                var originalDisplay = node.style.display,
                    binding = Batman.bindingFromString(string, contexts);
                
                binding.observe(function(value) {
                    var visible = !!value;
                    if (typeof node.show === 'function' && typeof node.hide === 'function')
                        visible ? node.show() : node.hide();
                    else
                        node.style.display = visible ? originalDisplay : 'none';
                }, true);
            },
            
            classes: function(string, node, contexts) {
                var classes = Batman.hashFromString(string, contexts);
                for (var key in classes) {
                    var binding = classes[key];
                    binding.observe(function(value) {
                        var current = node.className;
                        if (!!value) {
                            if (current.indexOf(key) === -1)
                                node.className = current + ' ' + key;
                        } else {
                            if (current.indexOf(key) !== -1)
                                node.className = current.replace(key, '');
                        }
                    }, true);
                }
            },
            
            events: function(string, node, contexts) {
                var events = Batman.hashFromString(string, contexts);
                for (var key in events)
                    Batman.DOM.events[key](node, events[key]);
            },
            
            route: function(string, node, contexts) {
                var route = Batman.functionFromString(string, contexts)(),
                    nodeName = node.nodeName.toUpperCase();
                
                var url;
                if (route.isRecord)
                    url = '#/' + route.model.identifier + '/' + route.id();
                
                if (nodeName === 'A') {
                    node.href = url || '#';
                    if (!url)
                        Batman.DOM.onclick(node, route);<commit_msg>Fix closure loop in data-classes.<commit_after>(function() {
    
    Batman.DOM = {
        view: function(view) {
            var node = view.node(),
                contexts = [Batman.View.helpers, Batman.mixins, view, {view: view}];
            
            if (view.context)
                contexts.push(view.context);
            
            Batman.DOM.node(node, contexts);
        },
        
        node: function(node, contexts) {
            if (typeof node === 'string')
                node = document.getElementById(node);
            
            if (!node)
                return;
            
            contexts = contexts || [];
            
            var result;
            if (typeof node.getAttribute === 'function') {
                contexts.push({node: node}, node);
                
                var attributes = Array.toArray(node.attributes);
                for (var i = -1, count = attributes.length; ++i < count;) {
                    var attribute = attributes[i],
                        attributeName = attribute.nodeName,
                        attributeValue = attribute.nodeValue;
                    
                    if (attributeName.substr(0,5) !== 'data-')
                        continue;
                    
                    var binding = attributeName.substr(5);
                    if (binding.substr(0,5) === 'bind-')
                        result = Batman.DOM.bindAttribute(binding.substr(5), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,5) === 'each-')
                        result = Batman.DOM.bindEach(binding.substr(5), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,6) === 'mixin-')
                        result = Batman.DOM.bindMixin(binding.substr(6), attributeValue, node, contexts);
                    
                    else if (binding.substr(0,8) === 'formfor-')
                        result = Batman.DOM.bindForm(binding.substr(8), attributeValue, node, contexts);
                    
                    else if (Batman.DOM.bindings[binding])
                        result = Batman.DOM.bindings[binding](attributeValue, node, contexts);
                    
                    else
                        continue;
                    
                    node.removeAttribute(attributeName);
                    
                    if (result === false)
                        break;
                }
                
                contexts.splice(contexts.indexOf(node) - 1);
            }
            
            if (result !== false) {
                var children = node.childNodes;
                for (var i = -1, count = children.length; ++i < count;)
                    Batman.DOM.node(children[i], contexts);
                
                if (node.onBatmanLoad) {
                    var i = node.onBatmanLoad.length;
                    while (i--)
                        node.onBatmanLoad[i].call(node, node);
                }
            }
        },
        
        forgetNode: function(node) {
            
        },
        
        bindings: {
            bind: function(string, node, contexts) {
                var binding = node._valueBinding = Batman.bindingFromString(string, contexts);
                binding.observe(function(value) { Batman.DOM.valueForNode(node, value); }, true);
                Batman.DOM.onchange(node, function(value) { binding(value); });
            },
            
            visible: function(string, node, contexts) {
                var originalDisplay = node.style.display,
                    binding = Batman.bindingFromString(string, contexts);
                
                binding.observe(function(value) {
                    var visible = !!value;
                    if (typeof node.show === 'function' && typeof node.hide === 'function')
                        visible ? node.show() : node.hide();
                    else
                        node.style.display = visible ? originalDisplay : 'none';
                }, true);
            },
            
            classes: function(string, node, contexts) {
                var observer = function(key) {
                    return function(value) {
                        var current = node.className;
                        if (!!value) {
                            if (current.indexOf(key) === -1)
                                node.className = current + ' ' + key;
                        } else {
                            if (current.indexOf(key) !== -1)
                                node.className = current.replace(key, '');
                        }
                    };
                };
                
                var classes = Batman.hashFromString(string, contexts);
                for (var key in classes) {
                    var binding = classes[key];
                    binding.observe(observer(key), true);
                }
            },
            
            events: function(string, node, contexts) {
                var events = Batman.hashFromString(string, contexts);
                for (var key in events)
                    Batman.DOM.events[key](node, events[key]);
            },
            
            route: function(string, node, contexts) {
                var route = Batman.functionFromString(string, contexts)(),
                    nodeName = node.nodeName.toUpperCase();
                
                var url;
                if (route.isRecord)
                    url = '#/' + route.model.identifier + '/' + route.id();
                
                if (nodeName === 'A') {
                    node.href = url || '#';
                    if (!url)
                        Batman.DOM.onclick(node, route);
{'fraction_non_alphanumeric': 0.10705278719888686, 'fraction_numerical': 0.0034785633533350726, 'mean_word_length': 1.0448079658605975, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1729386', 'n_tokens_mistral': 2799, 'n_tokens_neox': 2552, 'n_words': 542}