Skip to content

Commit

Permalink
fix(runtime-core): support extends template for runtime compiler (#6250)
Browse files Browse the repository at this point in the history
fix #6249
  • Loading branch information
edison1105 committed Aug 31, 2022
1 parent 6624ead commit 9875ecd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/runtime-core/__tests__/apiOptions.spec.ts
Expand Up @@ -12,6 +12,7 @@ import {
createApp,
computed
} from '@vue/runtime-test'
import { render as domRender } from 'vue'

describe('api: options', () => {
test('data', async () => {
Expand Down Expand Up @@ -1035,6 +1036,19 @@ describe('api: options', () => {
expect(renderToString(h(Comp))).toBe('base,base')
})

test('extends template', () => {
const Comp = {
extends: {
template: `<h1>Foo</h1>`
}
}

const root = document.createElement('div') as any
domRender(h(Comp), root)
expect(root.innerHTML).toBe(`<h1>Foo</h1>`)
})


test('options defined in component have higher priority', async () => {
const Mixin = {
msg1: 'base'
Expand Down
6 changes: 4 additions & 2 deletions packages/runtime-core/src/component.ts
Expand Up @@ -35,7 +35,8 @@ import {
applyOptions,
ComponentOptions,
ComputedOptions,
MethodOptions
MethodOptions,
resolveMergedOptions
} from './componentOptions'
import {
EmitsOptions,
Expand Down Expand Up @@ -792,7 +793,8 @@ export function finishComponentSetup(
(__COMPAT__ &&
instance.vnode.props &&
instance.vnode.props['inline-template']) ||
Component.template
Component.template ||
resolveMergedOptions(instance).template
if (template) {
if (__DEV__) {
startMeasure(instance, `compile`)
Expand Down

0 comments on commit 9875ecd

Please sign in to comment.