Skip to content

Overwrite of element attributes with default value #6864

Closed
@albrechtjohannes

Description

@albrechtjohannes

What problem does this feature solve?

For custom HTML elements Vue overwrites some attributes with default values. One example is the selected attribute which will always be set to selected=selected for truthy values. This absolutely makes sense for HTML elements that are defined in the HTML standard, but not for custom elements. Custom elements are not yet a web standard but there are already ways to build and use them. We experienced the issue when experimenting with a custom element for a tab bar which has the selected tab stored in a selected attribute.

Find a code example in:
https://jsfiddle.net/1pc2e9yj/2/
(The code example is currently limited to Chrome and Safari, because of missing polyfills for other browsers)

What does the proposed API look like?

Vue already has a config setting for ignoredElements. My proposal would be, that attributes are not set to their default values for elements in the ignoredElements array. If that approach is valid, then the example code in the jsfiddle would stay the same, but the output would change to "selected attribute value: tab1"

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