<commit_before>module plat.controls {
    /**
     * @name SimpleEventControl
     * @memberof plat.controls
     * @kind class
     * 
     * @extends {plat.AttributeControl}
     * @implements {plat.controls.ISimpleEventControl}
     * 
     * @description
     * An {@link plat.AttributeControl|AttributeControl} that binds to a specified DOM event handler.
     */
    export class SimpleEventControl extends AttributeControl implements ISimpleEventControl {
        /**
         * @name $Parser
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {plat.expressions.IParser}
         * 
         * @description
         * Reference to the {@link plat.expressions.IParser|IParser} injectable.
         */
        $Parser: expressions.IParser = acquire(__Parser);

        /**
         * @name $Regex
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {plat.expressions.IRegex}
         * 
         * @description
         * Reference to the {@link plat.expressions.IRegex|IRegex} injectable.
         */
        $Regex: expressions.IRegex = acquire(__Regex);

        /**
         * @name event
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {string}
         * 
         * @description
         * The event name.
         */
        event: string;

        /**
         * @name attribute
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {string}
         * 
         * @description
         * The camel-cased name of the control as it appears as an attribute.
         */
        attribute: string;

        /**
         * @name _expression
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access protected
         * 
         * @type {Array<string>}
         * 
         * @description
         * A parsed form of the expression found in the attribute's value.
         */
        protected _expression: Array<string> = [];

        /**
         * @name _fn
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access protected
         * 
         * @type {plat.IControlProperty}
         * 
         * @description
         * The found function up the control's parent chain denoted by the attribute value.
         */
        protected _fn: IControlProperty;

        /**
         * @name _aliases
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access protected
         * 
         * @type {Array<string>}
         * 
         * @description
         * An array of the aliases used in the expression.
         */
        protected _aliases: Array<string> = [];

        /**
         * @name loaded
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access public
         * 
         * @description
         * Kicks off finding and setting the listener.
         * 
         * @returns {void}
         */
        loaded(): void {
            if (isNull(this.element)) {
                return;
            }

            this.attribute = camelCase(this.type);
            this._setListener();
        }

        /**
         * @name _setListener
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Parses function args and sets the event listener.
         * 
         * @returns {void}
         */
        protected _setListener(): void {
            var fn = this.attributes[this.attribute];

            if (isEmpty(this.event) || isEmpty(fn)) {
                return;
            }

            this._parseArgs(fn);
            this._addEventListeners();
        }

        /**
         * @name _addEventListeners
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Adds any and all necessary event listeners.
         * 
         * @returns {void}
         */
        protected _addEventListeners(): void {
            this.addEventListener(this.element, this.event, this._onEvent, false);
        }

        /**
         * @name _buildExpression
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Constructs the function to evaluate with 
         * the evaluated arguments taking resources 
         * into account.
         * 
         * @returns {{ fn: () => void; control: ui.ITemplateControl; args: Array<expressions.IParsedExpression>; }} 
         * The function to call and the associated arguments, as well as the control context with which to call the function.
         */
        protected _buildExpression(): { fn: () => void; control: ui.ITemplateControl; args: Array<expressions.IParsedExpression>; } {
            var expression = this._expression.slice(0),
                parent = this.parent,
                hasParent = !isNull(parent),
                listenerStr = expression.shift(),
                listener: { control: ui.ITemplateControl; value: any; },
                control: ui.ITemplateControl,
                fn: () => void,
                aliases: IObject<any>,
                argContext: any;

            if (!isNull(parent)) {
                aliases = parent.getResources(this._aliases);
                argContext = parent.context;
            }

            if (listenerStr[0] !== '@') {
                listener = this._fn || (this._fn = this.findProperty(listenerStr));

                if (isNull(listener)) {
                    return {
                        fn: noop,
                        control: <ui.ITemplateControl>{},
                        args: []
                    };
                }

                fn = listener.value;
                control = listener.control;
            } else {
                fn = isNull(aliases) ? noop : (aliases[listenerStr] || noop);
                control = undefined;
            }
<commit_msg>removed function caching for simple event<commit_after>module plat.controls {
    /**
     * @name SimpleEventControl
     * @memberof plat.controls
     * @kind class
     * 
     * @extends {plat.AttributeControl}
     * @implements {plat.controls.ISimpleEventControl}
     * 
     * @description
     * An {@link plat.AttributeControl|AttributeControl} that binds to a specified DOM event handler.
     */
    export class SimpleEventControl extends AttributeControl implements ISimpleEventControl {
        /**
         * @name $Parser
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {plat.expressions.IParser}
         * 
         * @description
         * Reference to the {@link plat.expressions.IParser|IParser} injectable.
         */
        $Parser: expressions.IParser = acquire(__Parser);

        /**
         * @name $Regex
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {plat.expressions.IRegex}
         * 
         * @description
         * Reference to the {@link plat.expressions.IRegex|IRegex} injectable.
         */
        $Regex: expressions.IRegex = acquire(__Regex);

        /**
         * @name event
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {string}
         * 
         * @description
         * The event name.
         */
        event: string;

        /**
         * @name attribute
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access public
         * 
         * @type {string}
         * 
         * @description
         * The camel-cased name of the control as it appears as an attribute.
         */
        attribute: string;

        /**
         * @name _expression
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access protected
         * 
         * @type {Array<string>}
         * 
         * @description
         * A parsed form of the expression found in the attribute's value.
         */
        protected _expression: Array<string> = [];

        /**
         * @name _aliases
         * @memberof plat.controls.SimpleEventControl
         * @kind property
         * @access protected
         * 
         * @type {Array<string>}
         * 
         * @description
         * An array of the aliases used in the expression.
         */
        protected _aliases: Array<string> = [];

        /**
         * @name loaded
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access public
         * 
         * @description
         * Kicks off finding and setting the listener.
         * 
         * @returns {void}
         */
        loaded(): void {
            if (isNull(this.element)) {
                return;
            }

            this.attribute = camelCase(this.type);
            this._setListener();
        }

        /**
         * @name _setListener
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Parses function args and sets the event listener.
         * 
         * @returns {void}
         */
        protected _setListener(): void {
            var fn = this.attributes[this.attribute];

            if (isEmpty(this.event) || isEmpty(fn)) {
                return;
            }

            this._parseArgs(fn);
            this._addEventListeners();
        }

        /**
         * @name _addEventListeners
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Adds any and all necessary event listeners.
         * 
         * @returns {void}
         */
        protected _addEventListeners(): void {
            this.addEventListener(this.element, this.event, this._onEvent, false);
        }

        /**
         * @name _buildExpression
         * @memberof plat.controls.SimpleEventControl
         * @kind function
         * @access protected
         * 
         * @description
         * Constructs the function to evaluate with 
         * the evaluated arguments taking resources 
         * into account.
         * 
         * @returns {{ fn: () => void; control: ui.ITemplateControl; args: Array<expressions.IParsedExpression>; }} 
         * The function to call and the associated arguments, as well as the control context with which to call the function.
         */
        protected _buildExpression(): { fn: () => void; control: ui.ITemplateControl; args: Array<expressions.IParsedExpression>; } {
            var expression = this._expression.slice(0),
                parent = this.parent,
                hasParent = !isNull(parent),
                listenerStr = expression.shift(),
                listener: { control: ui.ITemplateControl; value: any; },
                control: ui.ITemplateControl,
                fn: () => void,
                aliases: IObject<any>,
                argContext: any;

            if (!isNull(parent)) {
                aliases = parent.getResources(this._aliases);
                argContext = parent.context;
            }

            if (listenerStr[0] !== '@') {
                listener = this.findProperty(listenerStr);

                if (isNull(listener)) {
                    return {
                        fn: noop,
                        control: <ui.ITemplateControl>{},
                        args: []
                    };
                }

                fn = listener.value;
                control = listener.control;
            } else {
                fn = isNull(aliases) ? noop : (aliases[listenerStr] || noop);
                control = undefined;
            }

{'fraction_non_alphanumeric': 0.09648551903677188, 'fraction_numerical': 0.0003254149040026033, 'mean_word_length': 1.4222660098522169, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '4039916', 'n_tokens_mistral': 3120, 'n_tokens_neox': 2981, 'n_words': 736}