Volodymyr I
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
29 additions and
0 deletions
-
src/platforms/web/server/modules/attrs.js
-
test/ssr/ssr-string.spec.js
|
|
@ -25,6 +25,10 @@ export default function renderAttrs (node: VNodeWithData): string { |
|
|
|
if (isUndef(opts) || opts.Ctor.options.inheritAttrs !== false) { |
|
|
|
let parent = node.parent |
|
|
|
while (isDef(parent)) { |
|
|
|
// Stop fallthrough in case parent has inheritAttrs option set to false
|
|
|
|
if (parent.componentOptions && parent.componentOptions.Ctor.options.inheritAttrs === false) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (isDef(parent.data) && isDef(parent.data.attrs)) { |
|
|
|
attrs = extend(extend({}, attrs), parent.data.attrs) |
|
|
|
} |
|
|
|
|
|
@ -1613,6 +1613,31 @@ describe('SSR: renderToString', () => { |
|
|
|
done() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
it('Options inheritAttrs in parent component', done => { |
|
|
|
const childComponent = { |
|
|
|
template: `<div>{{ someProp }}</div>`, |
|
|
|
props: { |
|
|
|
someProp: {} |
|
|
|
}, |
|
|
|
} |
|
|
|
const parentComponent = { |
|
|
|
template: `<childComponent v-bind="$attrs" />`, |
|
|
|
components: { childComponent }, |
|
|
|
inheritAttrs: false |
|
|
|
} |
|
|
|
renderVmWithOptions({ |
|
|
|
template: ` |
|
|
|
<div> |
|
|
|
<parentComponent some-prop="some-val" /> |
|
|
|
</div> |
|
|
|
`,
|
|
|
|
components: { parentComponent } |
|
|
|
}, result => { |
|
|
|
expect(result).toContain('<div data-server-rendered="true"><div>some-val</div></div>') |
|
|
|
done() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
function renderVmWithOptions (options, cb) { |
|
|
|