File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
src/platforms/web/server/modules Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,15 @@ export default function renderAttrs (node: VNodeWithData): string {
1717 let attrs = node . data . attrs
1818 let res = ''
1919
20- let parent = node . parent
21- while ( isDef ( parent ) ) {
22- if ( isDef ( parent . data ) && isDef ( parent . data . attrs ) ) {
23- attrs = Object . assign ( { } , attrs , parent . data . attrs )
20+ const opts = node . parent && node . parent . componentOptions
21+ if ( isUndef ( opts ) || opts . Ctor . options . inheritAttrs !== false ) {
22+ let parent = node . parent
23+ while ( isDef ( parent ) ) {
24+ if ( isDef ( parent . data ) && isDef ( parent . data . attrs ) ) {
25+ attrs = Object . assign ( { } , attrs , parent . data . attrs )
26+ }
27+ parent = parent . parent
2428 }
25- parent = parent . parent
2629 }
2730
2831 if ( isUndef ( attrs ) ) {
Original file line number Diff line number Diff line change @@ -880,6 +880,21 @@ describe('SSR: renderToString', () => {
880880 done ( )
881881 } )
882882 } )
883+
884+ it ( 'with inheritAttrs: false + $attrs' , done => {
885+ renderVmWithOptions ( {
886+ template : `<foo id="a"/>` ,
887+ components : {
888+ foo : {
889+ inheritAttrs : false ,
890+ template : `<div><div v-bind="$attrs"></div></div>`
891+ }
892+ }
893+ } , res => {
894+ expect ( res ) . toBe ( `<div data-server-rendered="true"><div id="a"></div></div>` )
895+ done ( )
896+ } )
897+ } )
883898} )
884899
885900function renderVmWithOptions ( options , cb ) {
You can’t perform that action at this time.
0 commit comments