How to use the jsdom/lib/jsdom/living/generated/utils.implForWrapper function in jsdom

To help you get started, we’ve selected a few jsdom 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 webhintio / hint / packages / connector-jsdom / src / before-parse.ts View on Github external
return (window: DOMWindow) => {
        const mutationObserverPolyfill = readFile(require.resolve('mutationobserver-shim'));
        const customElementsPolyfill = readFile(path.join(__dirname, 'polyfills', 'custom-elements.min.js'));

        const mutationScript: vm.Script = new vm.Script(mutationObserverPolyfill);
        const customElementsScript: vm.Script = new vm.Script(customElementsPolyfill);

        mutationScript.runInContext(jsdomutils.implForWrapper(window.document)._global);
        customElementsScript.runInContext(jsdomutils.implForWrapper(window.document)._global);

        window.document.domain = new URL(finalHref).host;

        /* istanbul ignore next */
        window.matchMedia = () => {
            return { addListener() { } } as any;
        };

        Object.defineProperty(window.HTMLHtmlElement.prototype, 'clientWidth', { value: 1024 });
        Object.defineProperty(window.HTMLHtmlElement.prototype, 'clientHeight', { value: 768 });
    };
};
github paperjs / paper.js / src / node / canvas.js View on Github external
set: function(type) {
            // Allow replacement of internal node-canvas, so we can switch to a
            // PDF canvas.
            var impl = idlUtils.implForWrapper(this),
                size = impl._canvas || impl;
            impl._canvas = new Canvas(size.width, size.height, type);
            impl._context = null;
        }
    });
github paperjs / paper.js / dist / node / canvas.js View on Github external
set: function(type) {
            // Allow replacement of internal node-canvas, so we can switch to a
            // PDF canvas.
            var impl = idlUtils.implForWrapper(this),
                size = impl._canvas || impl;
            impl._canvas = new Canvas(size.width, size.height, type);
            impl._context = null;
        }
    });
github paperjs / paper.js / dist / node / canvas.js View on Github external
HTMLCanvasElement.prototype[key] = function() {
            var canvas = idlUtils.implForWrapper(this)._canvas;
            return canvas[key].apply(canvas, arguments);
        };
    });
github webhintio / hint / packages / connector-jsdom / src / evaluate-runner.ts View on Github external
return setTimeout(async () => {
            try {
                const script: vm.Script = new vm.Script(source);
                const evaluteResult = await script.runInContext(jsdomutils.implForWrapper(jsdom.window.document)._global);

                result.evaluate = evaluteResult;
            } catch (err) {
                result.error = err;
            }

            process.send!(result);
        }, waitFor);
    };
github paperjs / paper.js / src / node / canvas.js View on Github external
HTMLCanvasElement.prototype[key] = function() {
            var canvas = idlUtils.implForWrapper(this)._canvas;
            return canvas[key].apply(canvas, arguments);
        };
    });