parent
f397c57c37
commit
9b76cfa141
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@bd/core",
|
||||
"version": "1.5.11",
|
||||
"version": "1.5.12",
|
||||
"type": "module",
|
||||
"description": "百搭UI组件库的核心",
|
||||
"main": "dist/index.js",
|
||||
|
|
|
@ -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;}`
|
||||
|
||||
|
|
22
src/index.js
22
src/index.js
|
@ -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,17 +225,12 @@ 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
|
||||
this.mounted()
|
||||
} else {
|
||||
this.updated(props)
|
||||
}
|
||||
// 初始化时不触发updated回调
|
||||
if (this[__mounted__] === false) {
|
||||
this[__mounted__] = true
|
||||
this.mounted()
|
||||
} else {
|
||||
this.updated(props)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue