-
Notifications
You must be signed in to change notification settings - Fork 371
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
Reserve hyphenated or $
-including properties for customization
#700
Comments
There's no conflict here. Custom element properties and methods shadow those from prototypes, so we don't have any compatibility concerns. You can use whatever names you want. For attributes, we've already reserved the data- prefix. Closing, as the JavaScript language already had us covered here. Happy to continue discussing in the closed thread. |
$
-including properties/attributes for customization$
-including properties for customization
Sure, but for libraries which enhance an element, providing a kind of public API, there is the risk/concern that the wrapped element API will block future use of a new built-in API without modifications being required of the library and modification of prior consumer code. This is a very practical concern. And sorry, I didn't mean to add "attributes" in the title. But speaking of which, to be clear, since And while setting element properties (as opposed to attributes) with |
How? Can you give a concrete example? |
Let's say I released a buffed up If the spec later added such a feature using the same name, but implemented in a different manner, users of the widget could not progressively take advantage of the new API while avoiding the need to upgrading all of their prior code. Even for the case where the user had never used the old API, they'd still need to delete it from the old library before using the new API. With namespacing, however, they could lazily update their old code, leveraging the standard API (e.g., Beyond such general purpose libraries, there could also be special purpose libraries which added behaviors beyond the element, e.g., an enhanced |
OK. In that case yes, I personally guarantee you we will never add methods starting with any of the following prefixes:
You can use any of those in your libraries, if you are concerned about such cases. I don't think we should encode such practice in the spec though, as not everyone is concerned about such cases. |
Ok, good to know. Of course I'd still like to ask though what makes |
And even when one is convinced they are doing something perfectly acceptable, without the spec granting "permission" so to speak, one has to spend time dealing with the disapproval of others, and perfectly legitimate libraries end up with less traction because of it... |
The main distinction I think is that with conflicting properties the developer-added property overrides the browser implementation, but with conflicting attributes the browser implementation overrides the developer-added attribute. So we created the |
For the sake of enhancing individual element instances (or their prototypes), having the peace of mind to add a method (or other property) via JS without fear of conflict would be helpful, even if it doesn't meet all use cases of customized built-in elements. It would also avoid the ugliness of adding symbols (or worse, maps) during attachment and method invocation (though admittedly hyphens are still somewhat awkward for JS given the need for calling methods like
elem['my-method']()
). An alternative would be reserving$
soelem.$myMethod()
would not only work without the need for brackets, but would also clearly signal a non-standard method/property.While this might not deal with custom elements per se, since the spec is reserving the hyphen for elements, and since the suggestion relates to one of the use cases for customized built-in elements (being able to enhance them as is, including intuitively using
this
scoped to the element along with convenient access through thatthis
to other such custom methods), I thought it might be appropriate to add the suggestion here.The text was updated successfully, but these errors were encountered: