Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core.mjs does not work inside node #5515

Open
frank-dspeed opened this issue May 11, 2021 · 0 comments
Open

Core.mjs does not work inside node #5515

frank-dspeed opened this issue May 11, 2021 · 0 comments

Comments

@frank-dspeed
Copy link
Contributor

frank-dspeed commented May 11, 2021

I would love to submit a patch for that i would replace the code with
something that allows injection of HTMLElement into a function that then Returns DriveElement

what do you think?

core.mjs:27464
function DeriveElement(BaseElement = HTMLElement) {
                                     ^

ReferenceError: HTMLElement is not defined
    at DeriveElement (file:///home/frank/Projekte/streamline/src/server/core.mjs:27464:38)
    at file:///home/frank/Projekte/streamline/src/server/core.mjs:27523:72
    at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)

my current workaround

globalThis.HTMLElement = class {};
globalThis.XMLHttpRequest = class {};
globalThis.location = { href:  '' };

export default await  import('./core.src.mjs').catch(console.error)

Other changes
move

var originUrl = canParseUri_1_2_2_canParseUri(global_1().location.href);

into the function ajax(o) { function that uses it so that it does not get read on inital load

  1. give the XHR Modifcation for the MOCK a init function so that it does not get inited on load
// This overwrites the default XHR with a mock XHR object.
// The mock XHR object's `.send` method is able to
// call the fixture callbacks or create a real XHR request
// and then respond normally.





// Save the real XHR object as XHR
var XHR = XMLHttpRequest,
// Get a global reference.
	GLOBAL = typeof commonjsGlobal !== "undefined"? commonjsGlobal : window;

// Figure out props and events on XHR object
// but start with some defaults
var props$2 = [
	"type", "url", "async", "response", "responseText", "responseType",
	"responseXML", "responseURL", "status", "statusText", "readyState"
];
var events = ["abort", "error", "load", "loadend", "loadstart",  "progress", "readystatechange"];
(function(){
	var x = new XHR();
	for(var prop in x) {
		if(prop.indexOf("on") === 0) {
			if (events.indexOf(prop.substr(2)) === -1) {
				events.push(prop.substr(2));
			}
		} else if (props$2.indexOf(prop) === -1 && typeof x[prop] !== 'function') {
			props$2.push(prop);
		}
	}
})();
// DEFINE HELPERS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant