WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.66k stars 80 forks source link

Missing `window.Location` (the constructor) #159

Closed fregante closed 1 year ago

fregante commented 2 years ago

Due to some TypeScript code that uses instanceof Location to tell an argument apart from other types of URLs, I'd need this global class. I was unable to locate where exactly the location property is generated in this codebase.

WebReflection commented 2 years ago

there's no location here ... it's SSR: you define the location? add a global class would be my answer but that might not solve, right?

fregante commented 2 years ago

This is not a location?

const {window} = parseHTML('')
window.location

I'm just asking window.location to be an instance of window.Location, which currently doesn't exist in the first place.

I already know what a workaround would be, I'm suggesting to add a class so that I don't need to work around this.

If it doesn't belong to linkedom because you want to keep it light, that's fair.

WebReflection commented 2 years ago

If location is exposed (can’t remember, sorry) then it’s ok to expose Location class.

mind filing a PR?

WebReflection commented 2 years ago

actually ... tests show that location is something you pass along, so you can add Location globally, or should I check if location is available (passed) and return its proto constructor?

WebReflection commented 1 year ago

Closing as no interest shown whatsoever for more than a month.