From 7669b3b713759a94ff89b53a61643a5cd19d39a0 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 21 Mar 2023 23:06:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=A0=E5=85=BC=E5=AE=B9vu?= =?UTF-8?q?e=E4=BA=8C=E6=AC=A1=E6=B8=B2=E6=9F=93=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/index.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d0471e9..93df4ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bd/core", - "version": "1.5.8", + "version": "1.5.9", "type": "module", "description": "百搭UI组件库的核心", "main": "dist/index.js", diff --git a/src/index.js b/src/index.js index 5569426..a310c04 100644 --- a/src/index.js +++ b/src/index.js @@ -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 })