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

Element Naming Conventions #86

Open
2 tasks
snuggs opened this issue Jul 5, 2017 · 9 comments
Open
2 tasks

Element Naming Conventions #86

snuggs opened this issue Jul 5, 2017 · 9 comments

Comments

@snuggs
Copy link
Member

snuggs commented Jul 5, 2017

Current API

Element `tag-name`

Tasks

  • - Naming conventions for element names.
  • - Naming conventions for id. (colon) Reference here

Naming Elements

TL;DR; use at least one hyphen - in tag name. (foo- is valid as well)
Below is the restriction set for custom elements naming conventions.
capture d ecran 2017-07-05 a 20 55 44
capture d ecran 2017-07-05 a 21 37 55
capture d ecran 2017-07-05 a 21 37 47

Suggestions

Custom elements with a single word name.

Similar to Custom HTTP Headers A convention when you don't have at least 2 words (i.e. <foo-bar>) would be to prefix custom element name with x-*. (i.e. <x-input>). That said #TodayILearned this has been deprecated in HTTP and has a bonafied spec for the deprecation So the following may be a better best practice. /cc @tmornini

Non-visual Components

Think a geo location component or a storage adapter. A Non-"Mixin" or... a "Mixin" that can be declared via HTML.

I kind of like the thought of the following:

<import- href=partial.html>

the <-*> styled elements say are for "non visual" components?

<geolocation- >

Would be a valid component name. Again we are just defining conventions around what's available to us within the spec.

Please note the intent is the name of the element not it's functionality.

Namespacing Elements (@snuggs + @robcole)

Had a conversation today with Rob and he discussed the need for namespacing.
I mentioned to him that in the W3C Specs and WHATWG specs they have gone out of
the way to preserve XML Namespacing due to the need to support XMLDocument parsing.
Perhaps we can borrow some conventions from there since they are already baked into the browser.

What is Namespacing

Namespacing TL;DR; example

Namespace Crash Course

"Namespaces are a means of identifying collections of reserved words of particular xml markup type so they can be combined with other markup without fear of conflict." - From this Youtube video.

It's not a "Location of something" but more a "grouping of ideas".

@tmornini especially curious of your input here on "namespacing" at a high level.

Resources and APIs

Discussion

@snuggs snuggs changed the title Namespacing! Element Naming Conventions Jul 6, 2017
@snuggs
Copy link
Member Author

snuggs commented Jul 6, 2017

@brandondees I think we should have the following in the "Conventions" docs. VERBATIM even:

@robcole looks like we have access to document.createElementNS therefore we have namespacing available to us. In the custom elements spec if you can define the element you can always create one the old fashion way document.createElement ('foo-bar') for backward compatibility scripts.

By the way... notice emoticons can be used as a valid name <this-is-valid-😍>

capture d ecran 2017-07-05 a 21 37 55

@brandondees
Copy link
Collaborator

is it best to namespace all snuggsi elements by default? or better to prescribe a default convention of app-namespacing all custom elements etc? i am going to go ahead and presume that for redistributable components namespacing should be an obvious best practice (import and and to use them side by side in an app, but the namespace way)

@brandondees
Copy link
Collaborator

should namespaces be human-meaningful / semantic? or is strictly programmatic better? (i'm looking at HTML id vs name attrs for comparison)

@snuggs
Copy link
Member Author

snuggs commented Jul 6, 2017

@robcole & @tmornini would probably have better input on this @brandondees. He sparked the idea so interested in opinion. I'm just an implementor. ;-) Probably best to review references:

In a way this makes sense of S3 buckets. @tmornini and i discussed once how the "URL paths" are merely namespaces where the delimiter just so happens to be /. /foo/bar.html is really just /bar.html within the /foo domain.Nothing really related to actual file path. That's merely an implementation detail.

@snuggs
Copy link
Member Author

snuggs commented Jul 9, 2017

@robcole @brandondees well there goes that theory of -element (Notice the hyphen prefix). HOwever <h1-> as a suffix is fine. Feeling a lil hackey now. Shoulda read the doc better. [a-z] means starts with a lettered character.

capture d ecran 2017-07-09 a 18 17 12

I think we can move on to "bonafied" namespacing.

capture d ecran 2017-07-09 a 17 58 01

@snuggs
Copy link
Member Author

snuggs commented Aug 2, 2017

@brandondees @robcole @kurtcagle seems to have been a discussion to try to get hyphen removed. I agree that's a bad idea. https://discourse.wicg.io/t/custom-elements-not-requiring-hyphens-in-names/1439

@brandondees
Copy link
Collaborator

i have no problem with the hyphen requirement, as it's only a very minor inconvenience, and having a clear rule to follow is helpful

@grepsedawk
Copy link
Collaborator

grepsedawk commented Aug 2, 2017 via email

@brandondees
Copy link
Collaborator

see that whole thread for the ins and outs of the rationale for the rule, and arguments against it as well. in short, that's the main justification for the rule.

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

6 participants