File tree 2 files changed +23
-5
lines changed
src/platforms/web/server/modules
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 {
17
17
let attrs = node . data . attrs
18
18
let res = ''
19
19
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
24
28
}
25
- parent = parent . parent
26
29
}
27
30
28
31
if ( isUndef ( attrs ) ) {
Original file line number Diff line number Diff line change @@ -880,6 +880,21 @@ describe('SSR: renderToString', () => {
880
880
done ( )
881
881
} )
882
882
} )
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
+ } )
883
898
} )
884
899
885
900
function renderVmWithOptions ( options , cb ) {
You can’t perform that action at this time.
0 commit comments