File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
src/platforms/web/server/modules Expand file tree Collapse file tree 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 {
2525 if ( isUndef ( opts ) || opts . Ctor . options . inheritAttrs !== false ) {
2626 let parent = node . parent
2727 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+ }
2832 if ( isDef ( parent . data ) && isDef ( parent . data . attrs ) ) {
2933 attrs = extend ( extend ( { } , attrs ) , parent . data . attrs )
3034 }
Original file line number Diff line number Diff line change @@ -1613,6 +1613,31 @@ describe('SSR: renderToString', () => {
16131613 done ( )
16141614 } )
16151615 } )
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+ } )
16161641} )
16171642
16181643function renderVmWithOptions ( options , cb ) {
You can’t perform that action at this time.
0 commit comments