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

Refactor embed.js.erb #5550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hlfan
Copy link
Contributor

@hlfan hlfan commented Jan 24, 2025

Refactors from #5519 and #5522 without adding dark mode (yet).

Copy link
Member

@tomhughes tomhughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good - just a couple of minor suggestions that I've made inline.

var parts = pairs[i].split("=");
args[parts[0]] = decodeURIComponent(parts[1] || "");
}
var args = Object.fromEntries(new URLSearchParams(window.location.search).entries());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually need .entries() here? I believe the URLSearchParams object itself should be iterable?

hot: ["HOT"],
mapnik: ["Mapnik", mapnikOptions]
};
baseLayers["cycle map"] = baseLayers.cyclemap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd just include this in the object definition after the cyclemap line. I realise it means duplicating the right hand side but I'm not sure that's any worse than this and I think it makes it a bit easier to see what's going on - also baseLayers could then be const I think?

Copy link
Contributor

@HolgerJeromin HolgerJeromin Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const defines only the variable. Ii does not prevent changing the properties of the object.
But yes, changing all var into let/const would be good because they work with much less surprise.
I would do this in a separate PR (and probably active lint rule later)

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

Successfully merging this pull request may close these issues.

3 participants