{"size": 1233, "ext": "js", "max_stars_repo_path": "packages/ag-grid-polymer/src/PolymerFrameworkComponentWrapper.js", "max_stars_repo_name": "pmccloghrylaing/ag-grid", "max_stars_repo_stars_event_min_datetime": "2019-05-14T09:16:10.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-17T05:16:51.000Z", "max_issues_repo_path": "packages/ag-grid-polymer/src/PolymerFrameworkComponentWrapper.js", "max_issues_repo_name": "pmccloghrylaing/ag-grid", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/ag-grid-polymer/src/PolymerFrameworkComponentWrapper.js", "max_forks_repo_name": "pmccloghrylaing/ag-grid", "max_forks_repo_forks_event_min_datetime": "2021-03-30T17:15:55.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-30T17:15:55.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 35.2285714286, "max_line_length": 109, "alphanum_fraction": 0.5660989457}
import BaseGuiComponent from './BaseFrameworkComponent'

export default class PolymerFrameworkComponentWrapper {
    wrap(element, mandatoryMethodList, optionalMethodList) {
        function addMethod(wrapper, methodName, mandatory) {
            let methodProxy = function () {
                if (wrapper.getFrameworkComponentInstance()[methodName]) {
                    var componentRef = this.getFrameworkComponentInstance();
                    return wrapper.getFrameworkComponentInstance()[methodName].apply(componentRef, arguments)
                } else {
                    if (mandatory) {
                        console.warn('ag-Grid: Polymer Element is missing the method ' + methodName + '()');
                    }
                    return null;
                }
            };

            wrapper[methodName] = methodProxy
        }

        let wrapper = new BaseGuiComponent(element);
        mandatoryMethodList.forEach((methodName => {
            addMethod(wrapper, methodName, true);
        }));

        if (optionalMethodList) {
            optionalMethodList.forEach((methodName => {
                addMethod(wrapper, methodName, false);
            }));
        }

        return wrapper;
    }
}
