Skip to content

Commit

Permalink
feat(runtime-core): restrict setting container for CE
Browse files Browse the repository at this point in the history
Co-authored-by: 白雾三语 <[email protected]>
  • Loading branch information
eagleoflqj and baiwusanyu-c committed Sep 23, 2023
1 parent 9bab0a5 commit bf0795a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ export interface ComponentInternalInstance {
root: ComponentInternalInstance
appContext: AppContext
/**
* The DOM element that app is mounted to, or shadowRoot of custom element.
* ShadowRoot of custom element if it is
*/
container: any
container: ShadowRoot | null
/**
* Vnode representing this component in its parent's vdom tree
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ function baseCreateRenderer(
parentComponent,
parentSuspense
))
instance.container = container
instance.isCE && (instance.container = container as ShadowRoot)

if (__DEV__ && instance.type.__hmrId) {
registerHMR(instance)
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/__tests__/customElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ describe('defineCustomElement', () => {
const ins = getCurrentInstance()!
const style = document.createElement('style')
style.innerHTML = `div { color: red; }`
ins.container.appendChild(style)
ins.container!.appendChild(style)
return () => h('div', 'hello')
}
})
Expand Down

0 comments on commit bf0795a

Please sign in to comment.