修复因兼容vue二次渲染引起的bug

pull/1/head 1.5.9
yutent 2023-03-21 23:06:40 +08:00
parent 81f8fd45eb
commit 7669b3b713
2 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@bd/core",
"version": "1.5.8",
"version": "1.5.9",
"type": "module",
"description": "百搭UI组件库的核心",
"main": "dist/index.js",

View File

@ -106,6 +106,7 @@ export class Component extends HTMLElement {
this[__in_tree__] = false
// 这里提前定义一次, 是为了在connectedCallback之前, 就已有赋值时报错的bug
this[__changed_props__] = new Map() // 记录一次渲染周期内变化的属性
// this[__init__]()
this.root = this.shadowRoot || this.attachShadow({ mode: 'open' })
Object.defineProperty(this, '$refs', {
@ -121,9 +122,7 @@ export class Component extends HTMLElement {
this[__changed_props__] = new Map()
// 初始化 props
this.constructor[__props__].forEach((options, prop) => {
// console.log(this, prop, this[prop], options.default)
this[prop] = this[prop] === void 0 ? options.default : this[prop]
// console.log('赋值后:', prop, this[prop])
})
// 若无定义props时, 手动执行一次渲染
@ -250,9 +249,9 @@ export class Component extends HTMLElement {
// 渲染视图
[__render__]() {
let htmlText = this.render()
let ast = this.render()
this[__children__] = render(htmlText, this.root, {
this[__children__] = render(ast, this.root, {
host: this,
isConnected: !this[__mounted__] && this.isConnected
})