static createElement()

in resources/perf.webkit.org/public/shared/common-component-base.js [99:123]


    static createElement(name, attributes, content)
    {
        const element = CommonComponentBase._context.createElement(name);
        if (!content && (Array.isArray(attributes) || CommonComponentBase._isNode(attributes)
            || attributes instanceof CommonComponentBase._baseClass || typeof(attributes) != 'object')) {
            content = attributes;
            attributes = {};
        }

        if (attributes) {
            for (const name in attributes) {
                if (name.startsWith('on'))
                    element.addEventListener(name.substring(2), attributes[name]);
                else if (attributes[name] === true)
                    element.setAttribute(name, '');
                else if (attributes[name] !== false)
                    element.setAttribute(name, attributes[name]);
            }
        }
        
        if (content)
            CommonComponentBase._addContentToElement(element, content);

        return element;
    }