<commit_before>var requirejs = (typeof requirejs === "undefined" ? require("requirejs") : requirejs);

requirejs(["rAppid"], function (rAppid) {
    rAppid.defineClass("js.html.DomElement",
        ["js.core.Component", "js.core.Binding", "underscore"], function (Component, Binding, _) {

            var rspace = /\s+/;

            var DomElementFunctions = {
                defaults: {
                    selected: false,
                    selectable: false
                },
                ctor: function (attributes, descriptor, applicationDomain, parentScope, rootScope) {
                    this.callBase();
                    this.$renderMap = {};

                    if (descriptor) {
                        if (!this.$tagName) {
                            this.$tagName = descriptor.localName;
                        }
                        if (!this.$namespace) {
                            this.$namespace = descriptor.namespaceURI;
                        }
                    }
                },
                _initializeAttributes: function (attributes) {
                    this.callBase();

                    if (attributes.tagName) {
                        this.$tagName = attributes.tagName;
                    }
                },
                addChild: function (child) {
                    this.callBase();
                    if (this.isRendered()) {
                        this._renderChild(child);
                    }
                },
                getPlaceholder: function (name) {
                    for (var i = 0; i < this.$children.length; i++) {
                        if (this.$children[i].$.name === name) {
                            return this.$children[i];
                        }
                    }
                    var placeholder;
                    for (i = 0; i < this.$children.length; i++) {
                        if (this.$children[i].getPlaceholder) {
                            placeholder = this.$children[i].getPlaceholder(name);
                            if (placeholder) {
                                return placeholder;
                            }
                        }

                    }
                    return null;
                },
                render: function () {
                    if (!this.$initialized) {
                        this._initialize(this.$creationPolicy);
                    }
                    // check if it is already rendered
                    if (this.isRendered()) {
                        return this.$el;
                    }

                    this.$el = document.createElement(this.$tagName);

                    // TODO: read layout and create renderMAP
                    /**
                     * <js:Template name="layout"><placeholder cid="icon"/><placeholder cid="label"/></js:Template>
                     */



                        // TODO: bind the events


                    this._renderChildren(this.$children);
                    this._renderAttributes(this.$);
                    this._bindDomEvents(this.$el);

                    return this.$el;
                },
                _bindDomEvents: function (el) {
                    var self = this;
                    this.$el.addEventListener('click', function (e) {
                        self.trigger('onclick', e, self);
                    });
                    if (this.$el.tagName == "INPUT") {
                        if (this.$el.type == "text" || this.$el.type == "password") {
                            this.$el.addEventListener('change', function (e) {
                                self.set('value', e.target.value);
                            });
                        } else if (this.$el.type == "checkbox") {
                            this.$el.addEventListener('change', function (e) {
                                self.set('checked', e.target.checked);
                            });
                        }


                    }

                },
                _renderChildren: function (children) {
                    // for all children
                    var child;
                    for (var i = 0; i < children.length; i++) {
                        child = children[i];
                        this._renderChild(child);
                    }
                },
                _renderChild: function (child) {
                    if (_.isFunction(child.render)) {
                        var el = child.render();
                        if (el) {
                            this.$el.appendChild(el);
                        }
                    }
                },
                _getIndexOfPlaceHolder: function (placeHolder) {
                    if (this.$layoutTpl) {
                        var child;
                        for (var i = 0; i < this.$layoutTpl.$children.length; i++) {
                            child = this.$layoutTpl.$children[i];
                            if (placeHolderId == child.$cid) {
                                return i;
                            }
                        }
                    }
                    return -1;
                },
                isRendered: function () {
                    return typeof (this.$el) !== "undefined";
                },
                _renderAttributes: function (attributes) {
                    var attr;
                    for (var key in attributes) {
                        if (key.indexOf("$") !== 0 && attributes.hasOwnProperty(key)) {
                            attr = attributes[key];
                            this._renderAttribute(key, attr);
                        }
                    }
                },
                _renderAttribute: function (key, attr) {
                    var method = this.$renderMap[key];
                    var prev = this.$previousAttributes[key];

                    if (_.isUndefined(method)) {
                        // generic call of render functions
                        var k = key[0].toUpperCase() + key.substr(1);
                        var methodName = "_render" + k;
                        method = this[methodName];

                        if (!_.isFunction(method)) {
                            method = false;
                        }

                        this.$renderMap[key] = method;
                    }
                    if (method !== false) {
                        method.call(this, attr, prev);
                    } else if (this.className && this.className.indexOf("js.html.") > -1) {
                        if (!_.isUndefined(this.$el[key])) {
                            this.$el[key] = attr;
                        } else {
                            this.$el.setAttribute(key, attr);
                        }
                    }
                },

                _renderVisible: function (visible) {
                    if (visible === true) {
                        this.removeClass('hidden');
                    } else if (visible === false) {
                        this.addClass('hidden');
                    }
                },
                _renderSelected: function (selected) {
                    if (selected === true) {
                        this.addClass('active');
                    } else if (selected === false) {
                        this.removeClass('active');
                    }
                },
                _renderSelectable: function (selectable) {
                    if (selectable === true) {
                        var self = this;
                        this.$el.addEventListener('click', function (e) {
                            self.set({selected: !self.$.selected});
                        });
                    } else {
                        this.set({selected: false});
                    }
                },
                _renderWidth: function (width) {
                    // TODO: implement
                },
                _renderHeight: function (height) {
                    // TODO: implement
                },
                _commitChangedAttributes: function (attributes) {
                    if (this.isRendered()) {
                        this._renderAttributes(attributes);
                    }<commit_msg>cleaned up DomElement and prevent data* attributes rendering<commit_after>var requirejs = (typeof requirejs === "undefined" ? require("requirejs") : requirejs);

requirejs(["rAppid"], function (rAppid) {
    rAppid.defineClass("js.html.DomElement",
        ["js.core.Component", "js.core.Binding", "underscore"], function (Component, Binding, _) {

            var rspace = /\s+/;

            var DomElementFunctions = {
                defaults: {
                    selected: false,
                    selectable: false
                },
                ctor: function (attributes, descriptor, applicationDomain, parentScope, rootScope) {
                    this.callBase();
                    this.$renderMap = {};

                    if (descriptor) {
                        if (!this.$tagName) {
                            this.$tagName = descriptor.localName;
                        }
                        if (!this.$namespace) {
                            this.$namespace = descriptor.namespaceURI;
                        }
                    }
                },
                _initializeAttributes: function (attributes) {
                    this.callBase();

                    if (attributes.tagName) {
                        this.$tagName = attributes.tagName;
                    }
                },
                addChild: function (child) {
                    this.callBase();
                    if (this.isRendered()) {
                        this._renderChild(child);
                    }
                },
                getPlaceholder: function (name) {
                    for (var i = 0; i < this.$children.length; i++) {
                        if (this.$children[i].$.name === name) {
                            return this.$children[i];
                        }
                    }
                    var placeholder;
                    for (i = 0; i < this.$children.length; i++) {
                        if (this.$children[i].getPlaceholder) {
                            placeholder = this.$children[i].getPlaceholder(name);
                            if (placeholder) {
                                return placeholder;
                            }
                        }

                    }
                    return null;
                },
                render: function () {
                    if (!this.$initialized) {
                        this._initialize(this.$creationPolicy);
                    }
                    // check if it is already rendered
                    if (this.isRendered()) {
                        return this.$el;
                    }

                    this.$el = document.createElement(this.$tagName);

                    // TODO: read layout and create renderMAP
                    /**
                     * <js:Template name="layout"><placeholder cid="icon"/><placeholder cid="label"/></js:Template>
                     */

                    this._renderChildren(this.$children);
                    this._renderAttributes(this.$);
                    this._bindDomEvents(this.$el);

                    return this.$el;
                },
                _bindDomEvents: function (el) {
                    var self = this;

                    if (this.$el.tagName == "INPUT") {
                        if (this.$el.type == "text" || this.$el.type == "password") {
                            this.$el.addEventListener('change', function (e) {
                                self.set('value', e.target.value);
                            });
                        } else if (this.$el.type == "checkbox") {
                            this.$el.addEventListener('change', function (e) {
                                self.set('checked', e.target.checked);
                            });
                        }


                    }

                },
                _renderChildren: function (children) {
                    // for all children
                    var child;
                    for (var i = 0; i < children.length; i++) {
                        child = children[i];
                        this._renderChild(child);
                    }
                },
                _renderChild: function (child) {
                    if (_.isFunction(child.render)) {
                        var el = child.render();
                        if (el) {
                            this.$el.appendChild(el);
                        }
                    }
                },
                _getIndexOfPlaceHolder: function (placeHolder) {
                    if (this.$layoutTpl) {
                        var child;
                        for (var i = 0; i < this.$layoutTpl.$children.length; i++) {
                            child = this.$layoutTpl.$children[i];
                            if (placeHolderId == child.$cid) {
                                return i;
                            }
                        }
                    }
                    return -1;
                },
                isRendered: function () {
                    return typeof (this.$el) !== "undefined";
                },
                _renderAttributes: function (attributes) {
                    var attr;
                    for (var key in attributes) {
                        if (attributes.hasOwnProperty(key) && key.indexOf("$") !== 0 && key.indexOf("data") !== 0){
                            attr = attributes[key];
                            this._renderAttribute(key, attr);
                        }
                    }
                },
                _renderAttribute: function (key, attr) {
                    var method = this.$renderMap[key];
                    var prev = this.$previousAttributes[key];

                    if (_.isUndefined(method)) {
                        // generic call of render functions
                        var k = key[0].toUpperCase() + key.substr(1);
                        var methodName = "_render" + k;
                        method = this[methodName];

                        if (!_.isFunction(method)) {
                            method = false;
                        }

                        this.$renderMap[key] = method;
                    }
                    if (method !== false) {
                        method.call(this, attr, prev);
                    } else if (this.className && this.className.indexOf("js.html.") > -1) {
                        if (!_.isUndefined(this.$el[key])) {
                            this.$el[key] = attr;
                        } else {
                            this.$el.setAttribute(key, attr);
                        }
                    }
                },

                _renderVisible: function (visible) {
                    if (visible === true) {
                        this.removeClass('hidden');
                    } else if (visible === false) {
                        this.addClass('hidden');
                    }
                },
                _renderHidden: function(hidden){
                    if(typeof(hidden) !== "undefined"){
                        this.set({visible:!hidden});
                    }
                },
                _renderSelected: function (selected) {
                    if (selected === true) {
                        this.addClass('active');
                    } else if (selected === false) {
                        this.removeClass('active');
                    }
                },
                _renderSelectable: function (selectable) {
                    if (selectable === true) {
                        var self = this;
                        this.$el.addEventListener('click', function (e) {
                            // e.preventDefault();
                            self.set({selected: !self.$.selected});
                        });
                    } else {
                        this.set({selected: false});
                    }
                },
                _renderWidth: function (width) {
                    // TODO: implement
                },
                _renderHeight: function (height) {
                    // TODO: implement
                },
                _commitChangedAttributes: function (attributes) {
                    if (this.isRendered()) {
                        this._renderAttributes(attributes);
                    }
{'fraction_non_alphanumeric': 0.1048729446935725, 'fraction_numerical': 0.0011360239162929745, 'mean_word_length': 0.8321831525906452, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, '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': '5598435', 'n_tokens_mistral': 3722, 'n_tokens_neox': 3355, 'n_words': 701}