parent
f397c57c37
commit
9b76cfa141
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@bd/core",
|
"name": "@bd/core",
|
||||||
"version": "1.5.11",
|
"version": "1.5.12",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "百搭UI组件库的核心",
|
"description": "百搭UI组件库的核心",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
|
@ -51,7 +51,6 @@ export const __attr2prop__ = Symbol('attr2prop')
|
||||||
export const __clear_update__ = Symbol('clearupdate')
|
export const __clear_update__ = Symbol('clearupdate')
|
||||||
export const __children__ = Symbol('children')
|
export const __children__ = Symbol('children')
|
||||||
export const __updated__ = Symbol('updated')
|
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;}`
|
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__,
|
__attr2prop__,
|
||||||
__clear_update__,
|
__clear_update__,
|
||||||
__children__,
|
__children__,
|
||||||
__updated__,
|
__updated__
|
||||||
__in_tree__
|
|
||||||
} from './constants.js'
|
} from './constants.js'
|
||||||
import { css, adoptStyles } from './css.js'
|
import { css, adoptStyles } from './css.js'
|
||||||
import { render, html, svg } from './html.js'
|
import { render, html, svg } from './html.js'
|
||||||
|
@ -103,10 +102,8 @@ export class Component extends HTMLElement {
|
||||||
super()
|
super()
|
||||||
this[__pending__] = false
|
this[__pending__] = false
|
||||||
this[__mounted__] = false
|
this[__mounted__] = false
|
||||||
this[__in_tree__] = false
|
|
||||||
// 这里提前定义一次, 是为了在connectedCallback之前, 就已有赋值时报错的bug
|
// 这里提前定义一次, 是为了在connectedCallback之前, 就已有赋值时报错的bug
|
||||||
this[__changed_props__] = new Map() // 记录一次渲染周期内变化的属性
|
this[__changed_props__] = new Map() // 记录一次渲染周期内变化的属性
|
||||||
// this[__init__]()
|
|
||||||
this.root = this.shadowRoot || this.attachShadow({ mode: 'open' })
|
this.root = this.shadowRoot || this.attachShadow({ mode: 'open' })
|
||||||
|
|
||||||
Object.defineProperty(this, '$refs', {
|
Object.defineProperty(this, '$refs', {
|
||||||
|
@ -228,17 +225,12 @@ export class Component extends HTMLElement {
|
||||||
|
|
||||||
// 更新回调反馈
|
// 更新回调反馈
|
||||||
[__feedback__](props) {
|
[__feedback__](props) {
|
||||||
if (this[__in_tree__] === false) {
|
// 初始化时不触发updated回调
|
||||||
this[__in_tree__] = document.body.contains(this)
|
if (this[__mounted__] === false) {
|
||||||
}
|
this[__mounted__] = true
|
||||||
if (this[__in_tree__]) {
|
this.mounted()
|
||||||
// 初始化时不触发updated回调
|
} else {
|
||||||
if (this[__mounted__] === false) {
|
this.updated(props)
|
||||||
this[__mounted__] = true
|
|
||||||
this.mounted()
|
|
||||||
} else {
|
|
||||||
this.updated(props)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue