修复组件内组件的mounted不触发的bug

pull/1/head 1.5.12
yutent 2023-03-23 11:17:55 +08:00
parent f397c57c37
commit 9b76cfa141
3 changed files with 8 additions and 17 deletions

View File

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

View File

@ -51,7 +51,6 @@ export const __attr2prop__ = Symbol('attr2prop')
export const __clear_update__ = Symbol('clearupdate')
export const __children__ = Symbol('children')
export const __updated__ = Symbol('updated')
export const __in_tree__ = Symbol('intree')
export const RESET_CSS_STYLE = `* {box-sizing: border-box;margin: 0;padding: 0;}::before,::after {box-sizing: border-box;}`

View File

@ -19,8 +19,7 @@ import {
__attr2prop__,
__clear_update__,
__children__,
__updated__,
__in_tree__
__updated__
} from './constants.js'
import { css, adoptStyles } from './css.js'
import { render, html, svg } from './html.js'
@ -103,10 +102,8 @@ export class Component extends HTMLElement {
super()
this[__pending__] = false
this[__mounted__] = false
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', {
@ -228,10 +225,6 @@ export class Component extends HTMLElement {
// 更新回调反馈
[__feedback__](props) {
if (this[__in_tree__] === false) {
this[__in_tree__] = document.body.contains(this)
}
if (this[__in_tree__]) {
// 初始化时不触发updated回调
if (this[__mounted__] === false) {
this[__mounted__] = true
@ -240,7 +233,6 @@ export class Component extends HTMLElement {
this.updated(props)
}
}
}
[__clear_update__]() {
this[__changed_props__] = new Map()