How to use the lwc.createElement function in lwc

To help you get started, we’ve selected a few lwc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pmdartus / rcast / src / client / modules / rcast / app / app.js View on Github external
setPage(tagName, component, props = {}) {
        const el = createElement(tagName, {
            is: component,
            fallback: false,
        });

        Object.assign(el, props);

        // Remove previous components from the container if necessary
        const container = this.template.querySelector('.container');
        while (container.firstChild) {
            container.removeChild(container.firstChild);
        }

        container.appendChild(el);
    }
}
github salesforce / base-components-recipes / force-app / main / default / lwc / recordEditForm / __tests__ / recordEditForm.spec.js View on Github external
it('registers with dependecy manager', () => {
        const element = createElement('lightningtest-mock-record-edit-holder', {
            is: MockRecordHolder
        });

        element.objectApiName = 'Bad_Guy__c';
        element.showPicklist = true;
        window.PICKLIST_REPRESENTATION = picklistRepresentation;
        window.DEPENDENCY_INFO = null;
        document.body.appendChild(element);
        return new Promise((resolve, reject) => {
            element.addEventListener('load', () => {
                try {
                    expect(mockConstructor).toHaveBeenCalledWith(
                        expect.objectContaining({
                            dependentFields: undefined,
                            picklistValues: expect.any(Object)
                        })
github salesforce / base-components-recipes / force-app / main / default / lwc / formattedTime / __tests__ / formattedTime.spec.js View on Github external
const createFormattedTimeComponent = () => {
    const element = createElement('c-formatted-time', {
        is: Element
    });

    document.body.appendChild(element);
    return element;
};
github salesforce / base-components-recipes / force-app / main / default / lwc / accordionSection / __test__ / accordionSection.spec.js View on Github external
const createSectionWithMock = mock => {
            const element = createElement('c-accordion-section', {
                is: Element
            });

            const parentDiv = document.createElement('div');

            document.body.appendChild(parentDiv);
            parentDiv.addEventListener('privateaccordionsectionregister', mock);

            parentDiv.appendChild(element);

            return element;
        };
github salesforce / base-components-recipes / force-app / main / default / lwc / formattedNumber / __tests__ / formattedNumber.spec.js View on Github external
const createComponent = () => {
    const element = createElement('c-formatted-number', {
        is: Element
    });

    document.body.appendChild(element);
    return element;
};
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonMenu / __tests__ / buttonMenu.spec.js View on Github external
const createButtonMenu = () => {
    const element = createElement('c-button-menu', { is: Element });
    document.body.appendChild(element);
    return element;
};
github salesforce / base-components-recipes / force-app / main / default / lwc / tile / __tests__ / tile.spec.js View on Github external
const createComponent = (params = {}) => {
    const element = createElement('c-tile', {
        is: Element
    });

    element.label = TILE_TITLE;
    Object.assign(element, params);
    document.body.appendChild(element);
    return element;
};
github salesforce / base-components-recipes / force-app / main / default / lwc / icon / __tests__ / iconIe11.spec.js View on Github external
const createIcon = () => {
    const element = createElement('c-icon', { is: Element });
    document.body.appendChild(element);
    return element;
};
github salesforce / base-components-recipes / force-app / main / default / lwc / formattedText / __tests__ / formattedText.spec.js View on Github external
const createComponent = () => {
    const element = createElement('c-formatted-text', { is: Element });
    document.body.appendChild(element);
    return element;
};
const exampleText =
github salesforce / lwc / packages / perf-benchmarks / src / __benchmarks__ / benchmark-table-component / tablecmp-create-10k.benchmark.js View on Github external
before(() => {
        tableElement = createElement('benchmark-table-component', { is: Table });
        return insertTableComponent(tableElement);
    });