<component :is=".."> should not set attributes to the root html tag of the component automatically
See original GitHub issueVersion
2.5.2
Reproduction link
https://codesandbox.io/s/2oz1p5qpo0
Steps to reproduce
Open the reproduction link:
- Open the devtools
- The element with the
id="foo"
will have thepropa
attribute
What is expected?
The element with the id="foo"
doesn’t have the propa
attribute
What is actually happening?
It has.
I know the problem is that the Foo component doesn’t declare the props
fields(I comment in the Foo component), if it has, the element with the id="foo"
will not have the propa
attribute, but the problem here is that the variable passed to is
to <component :is="...">
it not determined, probably it is a component which don’t need the propA
field.
So, we should not set any attribute to the root html tag of the component automatically.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Extraneous non-props attributes (...) were passed to ... - GitHub
I have met the same warning. The reason may be that you have more than one root node in the component template. Refer...
Read more >Vue 3 passing array warning: Extraneous non-props attributes ...
The Message is: [Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited ...
Read more >Element.setAttribute() - Web APIs | MDN
Sets the value of an attribute on the specified element. If the attribute already exists, the value is updated; otherwise a new attribute...
Read more >Build Advanced Components in Vue 3 using $attrs
A component property that holds all of the attribute, property, and custom events that are not currently defined within the component.
Read more >Web component HTML layout - 4Js
In order to get a stretchable HTML content in your web component, start by defining the WEBCOMPONENT form field with the following attributes:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually there are a lot of HTML global attributes which may need
inheritAttrs
to betrue
. For example, when you are making an accessible web app, thearia-*
global attributes are essential and needs to be handcrafted differently in each scenario. It’s impossible to encapsulate all A11Y annotation inside component libraries.You can pass a component’s options object into
is
and filter thev-bind
object by checking if it has specific prop declared for the rendered component. See this sandbox: https://codesandbox.io/s/42zoo8m4o7.Ok, fine, just trade off, though seems the codesandbox is more fussy than just use
inheritAttrs
IMO