-
Notifications
You must be signed in to change notification settings - Fork 932
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
base: master
Are you sure you want to change the base?
Refactor embed.js.erb #5550
Conversation
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
Refactors from #5519 and #5522 without adding dark mode (yet).