-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Description
I noticed 'replace' has been deprecated. Definitely agree that components should have only one root element, however we have other reasons for using replace.
Behavior questions:
-
What is the behavior moving forward? Currently the default value is true. Will this assumption be baked in?
-
How will this interact with the restricted elements in the dom? eg, those outlined in template parsing. Specifically, given this component template:
<!-- my-component --> <div class="foo"><slot></slot></div>
And this parent template:
<table> <tr><th class="bar" is="my-component">stuff</th></tr> </table>
What happens to the
th
element? Wouldn't replacing it with thediv
lead to invalid html? We use replace false to get around this, resulting in:<table> <tr><th class="bar" is="my-component"><div class="foo">stuff</div></th></tr> </table>
Our usage:
-
From a preference standpoint, I'd like to point you to this comment here 😉. It's definitely a stylistic preference and could live without. I also find it easier to grep the dom for
my-component
vs somediv
. -
More important to us, replace is necessary for our data table mixin. We can easily insert sorting behavior to any column by just adding
is="sort-controls"
and a sortkey
.<!-- sort-controls component --> <div class="sort-controls no-wrap" v-on:click="pushSort(sortKey)"> <slot></slot> <!-- Other details --> ... </div> <!-- example usage --> <table class="table table-bordered table-striped table-hover"> <tr> <th class="col-xs-2">Link</th> <th class="col-xs-5" is="sort-controls" key="name">Company</th> <th class="col-xs-5" is="sort-controls" key="employeeCount">Employees</th> </tr> <tr v-for="company in companies"> ... </tr> </table>
It's a terse solution that breaks when
replace: true
, as the parentth
is lost.
Regardless of our specific usage, how do you extend restricted elements when replace: true
?