()
| 554 | } |
| 555 | |
| 556 | private _createVNode(): VNode<any, any> { |
| 557 | const baseProps: VNodeProps = {} |
| 558 | if (!this.shadowRoot) { |
| 559 | baseProps.onVnodeMounted = baseProps.onVnodeUpdated = |
| 560 | this._renderSlots.bind(this) |
| 561 | } |
| 562 | const vnode = createVNode(this._def, extend(baseProps, this._props)) |
| 563 | if (!this._instance) { |
| 564 | vnode.ce = instance => { |
| 565 | this._instance = instance |
| 566 | instance.ce = this |
| 567 | instance.isCE = true // for vue-i18n backwards compat |
| 568 | // HMR |
| 569 | if (__DEV__) { |
| 570 | instance.ceReload = newStyles => { |
| 571 | // always reset styles |
| 572 | if (this._styles) { |
| 573 | this._styles.forEach(s => this._root.removeChild(s)) |
| 574 | this._styles.length = 0 |
| 575 | } |
| 576 | this._styleAnchors.delete(this._def) |
| 577 | this._applyStyles(newStyles) |
| 578 | this._instance = null |
| 579 | this._update() |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | const dispatch = (event: string, args: any[]) => { |
| 584 | this.dispatchEvent( |
| 585 | new CustomEvent( |
| 586 | event, |
| 587 | isPlainObject(args[0]) |
| 588 | ? extend({ detail: args }, args[0]) |
| 589 | : { detail: args }, |
| 590 | ), |
| 591 | ) |
| 592 | } |
| 593 | |
| 594 | // intercept emit |
| 595 | instance.emit = (event: string, ...args: any[]) => { |
| 596 | // dispatch both the raw and hyphenated versions of an event |
| 597 | // to match Vue behavior |
| 598 | dispatch(event, args) |
| 599 | if (hyphenate(event) !== event) { |
| 600 | dispatch(hyphenate(event), args) |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | this._setParent() |
| 605 | } |
| 606 | } |
| 607 | return vnode |
| 608 | } |
| 609 | |
| 610 | private _applyStyles( |
| 611 | styles: string[] | undefined, |
no test coverage detected