Skip to content

Commit

Permalink
types: custom element interface should be internal
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Aug 6, 2024
1 parent 37ccb9b commit bcb9a70
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,12 @@ export function isClassComponent(value: unknown): value is ClassComponent {
}

export interface ComponentCustomElementInterface {
injectChildStyle(type: ConcreteComponent): void
removeChildStyle(type: ConcreteComponent): void
/**
* @internal
*/
_injectChildStyle(type: ConcreteComponent): void
/**
* @internal
*/
_removeChildStyle(type: ConcreteComponent): void
}
2 changes: 1 addition & 1 deletion packages/runtime-core/src/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function reload(id: string, newComp: HMRComponent) {

// update custom element child style
if (instance.root.ce && instance !== instance.root) {
instance.root.ce.removeChildStyle(oldComp)
instance.root.ce._removeChildStyle(oldComp)
}
}

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 @@ -1337,7 +1337,7 @@ function baseCreateRenderer(
} else {
// custom element style injection
if (root.ce) {
root.ce.injectChildStyle(type)
root.ce._injectChildStyle(type)
}

if (__DEV__) {
Expand Down
10 changes: 8 additions & 2 deletions packages/runtime-dom/src/apiCustomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,17 @@ export class VueElement
}
}

injectChildStyle(comp: ConcreteComponent & CustomElementOptions) {
/**
* @internal
*/
_injectChildStyle(comp: ConcreteComponent & CustomElementOptions) {
this._applyStyles(comp.styles, comp)
}

removeChildStyle(comp: ConcreteComponent): void {
/**
* @internal
*/
_removeChildStyle(comp: ConcreteComponent): void {
if (__DEV__) {
this._styleChildren.delete(comp)
if (this._childStyles && comp.__hmrId) {
Expand Down

0 comments on commit bcb9a70

Please sign in to comment.