Skip to content

Refactor MapML elements as custom elements #511

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

Closed
prushforth opened this issue Sep 12, 2021 · 7 comments
Closed

Refactor MapML elements as custom elements #511

prushforth opened this issue Sep 12, 2021 · 7 comments

Comments

@prushforth
Copy link
Member

prushforth commented Sep 12, 2021

Per #174, it seems like a best practice of Web platform speculative polyfills is to generate proposed new APIs in a separate namespace, so that the name of the polyfills doesn't collide with the eventual standard name.

For elements, that implies today that we should use custom elements, and if I understand correctly, probably also data- prefixed attributes. Customised built-in elements would be ideal for implementing proposed extensions of existing elements, while autonomous custom elements would better serve the use case of new elements. There is apparently a viable polyfill for customized built-in (is=), but unsure how it works. It may not be worth the trouble of using the polyfill, opting instead for a apec explanation of the intended name of the eventual element.

This issue is for discussion of how to approach this refactoring.

We'll also need to decide how to do this in the draft spec, so that it's clear whether a proposed.element is 'new', or an extension of an existing element.

Also see Maps4HTML/MapML-Specification#215 (comment)

@Malvoz
Copy link
Member

Malvoz commented Sep 13, 2021

probably also data- prefixed attributes

Just noting that IMO the situation regarding "custom" attributes vs data- prefixed attributes (related: #191) is much less important than converting the MapML elements to custom elements containing a hyphen. Especially so if the attributes are used only on custom elements, since that wont "pollute" standard HTML elements. So perhaps this issue can focus solely on the elements aspect?

@prushforth
Copy link
Member Author

Yes, for now we'll focus on elements. What's your opinion on the <mapml> element?

@Malvoz
Copy link
Member

Malvoz commented Sep 13, 2021

All MapML elements must contain a hyphen, so it'd be <mapml->. In the spec and the explainer the elements should be referred to without hyphens.

Edit: well, assuming nobody serves .mapml files with content-type text/html (whether that'd work or not) it should be fine to use <mapml> I suppose, since that element can't be inline in HTML. But for consistency we may as well use <mapml->?

@prushforth
Copy link
Member Author

Ok, I went with <mapml->, but everything else (except mapml-viewer and layer-) I put into the map- "namespace". ok?

We'll need to explain this somehow, perhaps in the MapML spec?

@Malvoz
Copy link
Member

Malvoz commented Sep 14, 2021

I don't think there's a need to use a map- prefix. The MapML spec should name elements as they're intended to be standardized. But the polyfill must follow the HTML custom components rules, so they're required to include a hyphen.

The intention is then that when the spec is mature and browsers are ready to implement it and the polyfill follows the spec exactly (the tipping point) we're safe to remove the hyphens because now the polyfill is guaranteed to match the behaviors of the standard.

@Malvoz
Copy link
Member

Malvoz commented Sep 23, 2021

Fixed in c67198b.

Thanks to everyone involved!

@Malvoz Malvoz closed this as completed Sep 23, 2021
@prushforth
Copy link
Member Author

Thanks to everyone involved!

Thanks to you, too, for motivating some change for the better. Hopefully any bugs are minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants