Skip to content

feat: custom-event-name-casing custom casing #1260

Closed
@privatenumber

Description

@privatenumber

Extension of this bug report: #1250

Request

For the ability to customize what kind of casing should be enforced on event names.

Use case

Name spacing

In my codebase we namespace events using : with the component name for frictionless composability. That way, when composing components, there would be no collision in emitted events. (eg. input:update)

For example, a custom Input component would emit input:update, which triggers the new v-model value (not to takeover native event names with different values). There could be another component, for example Search, that uses this Input component and emit another "update" event with more data via search:update.

camelCase in Vue 3 docs

With Vue v3, v-model replaces .sync and their docs seem to contain a lot of examples using camelCase in event names.

(This is pretty confusing considering they still recommend event names be case insensitive (lower case) at the top.)

If this isn't a mistake, then surely, some people would want to use camelCase in their event names. (vuejs/docs#308)

Edit:
Changing to v-model.prop-name seems to be necessary in a non-compiled environment (haven't tested in a compiled one). Both update:propName and update:prop-name seem to work. Codepen

Proposed API

Just some ideas I had:

  • ignoreCharacters: [':']
  • allowCharacters: [':']
  • allowNamespace: true
  • allowDelimiters: ':'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions