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

Overwrite of element attributes with default value #6864

Comments

@albrechtjohannes
Copy link

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"

@albrechtjohannes albrechtjohannes changed the title Do not overwrite element attributes with default value Overwrite of element attributes with default value Oct 20, 2017
@imyzf
Copy link
Contributor

imyzf commented Nov 14, 2017

I have fixed this in #6885.

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