File tree 2 files changed +29
-0
lines changed
src/platforms/web/server/modules
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ export default function renderAttrs (node: VNodeWithData): string {
25
25
if ( isUndef ( opts ) || opts . Ctor . options . inheritAttrs !== false ) {
26
26
let parent = node . parent
27
27
while ( isDef ( parent ) ) {
28
+ // Stop fallthrough in case parent has inheritAttrs option set to false
29
+ if ( parent . componentOptions && parent . componentOptions . Ctor . options . inheritAttrs === false ) {
30
+ break ;
31
+ }
28
32
if ( isDef ( parent . data ) && isDef ( parent . data . attrs ) ) {
29
33
attrs = extend ( extend ( { } , attrs ) , parent . data . attrs )
30
34
}
Original file line number Diff line number Diff line change @@ -1613,6 +1613,31 @@ describe('SSR: renderToString', () => {
1613
1613
done ( )
1614
1614
} )
1615
1615
} )
1616
+
1617
+ it ( 'Options inheritAttrs in parent component' , done => {
1618
+ const childComponent = {
1619
+ template : `<div>{{ someProp }}</div>` ,
1620
+ props : {
1621
+ someProp : { }
1622
+ } ,
1623
+ }
1624
+ const parentComponent = {
1625
+ template : `<childComponent v-bind="$attrs" />` ,
1626
+ components : { childComponent } ,
1627
+ inheritAttrs : false
1628
+ }
1629
+ renderVmWithOptions ( {
1630
+ template : `
1631
+ <div>
1632
+ <parentComponent some-prop="some-val" />
1633
+ </div>
1634
+ ` ,
1635
+ components : { parentComponent }
1636
+ } , result => {
1637
+ expect ( result ) . toContain ( '<div data-server-rendered="true"><div>some-val</div></div>' )
1638
+ done ( )
1639
+ } )
1640
+ } )
1616
1641
} )
1617
1642
1618
1643
function renderVmWithOptions ( options , cb ) {
You can’t perform that action at this time.
0 commit comments