parent
0f33586ff4
commit
ff51e09e39
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wkit",
|
"name": "wkit",
|
||||||
"version": "1.10.10",
|
"version": "1.10.11",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "A library for building fast, lightweight web components.",
|
"description": "A library for building fast, lightweight web components.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
30
src/index.js
30
src/index.js
|
@ -86,8 +86,7 @@ export class Component extends HTMLElement {
|
||||||
if (this[__mounted__]) {
|
if (this[__mounted__]) {
|
||||||
return animate.call(this, duration, fromto, out)
|
return animate.call(this, duration, fromto, out)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
enumerable: false
|
|
||||||
})
|
})
|
||||||
this.prototype.$animate.immediate = immediate
|
this.prototype.$animate.immediate = immediate
|
||||||
delete this.animation
|
delete this.animation
|
||||||
|
@ -136,6 +135,8 @@ export class Component extends HTMLElement {
|
||||||
|
|
||||||
keepAlive = false
|
keepAlive = false
|
||||||
|
|
||||||
|
removed = false
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
this[__pending__] = false
|
this[__pending__] = false
|
||||||
|
@ -147,20 +148,14 @@ export class Component extends HTMLElement {
|
||||||
this.root.ownHost = this
|
this.root.ownHost = this
|
||||||
|
|
||||||
Object.defineProperty(this, '$refs', {
|
Object.defineProperty(this, '$refs', {
|
||||||
value: Object.create(null),
|
value: Object.create(null)
|
||||||
enumerable: false
|
|
||||||
})
|
})
|
||||||
Object.defineProperty(this, '$events', {
|
Object.defineProperty(this, '$events', {
|
||||||
value: Object.create(null),
|
value: Object.create(null)
|
||||||
enumerable: false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (window.wkitd && this.$store) {
|
|
||||||
window.wkitd.assign(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let [prop, options] of this.constructor[__props__]) {
|
for (let [prop, options] of this.constructor[__props__]) {
|
||||||
this.createProperty(prop, options)
|
this.#createProperty(prop, options)
|
||||||
// 按W3C规范, 在构造函数内不可设置节点的属性
|
// 按W3C规范, 在构造函数内不可设置节点的属性
|
||||||
// 所以这里只记录需要初始化的属性, 在#init()回调中才去修改
|
// 所以这里只记录需要初始化的属性, 在#init()回调中才去修改
|
||||||
this[__changed_props__].set(prop, this[prop])
|
this[__changed_props__].set(prop, this[prop])
|
||||||
|
@ -169,7 +164,7 @@ export class Component extends HTMLElement {
|
||||||
nextTick(_ => this.created())
|
nextTick(_ => this.created())
|
||||||
}
|
}
|
||||||
|
|
||||||
createProperty(name, options) {
|
#createProperty(name, options) {
|
||||||
let key = Symbol(name)
|
let key = Symbol(name)
|
||||||
let descriptor
|
let descriptor
|
||||||
|
|
||||||
|
@ -186,8 +181,7 @@ export class Component extends HTMLElement {
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
this.$requestUpdate(name)
|
this.$requestUpdate(name)
|
||||||
},
|
}
|
||||||
enumerable: false
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
descriptor = {
|
descriptor = {
|
||||||
|
@ -205,8 +199,7 @@ export class Component extends HTMLElement {
|
||||||
if (options.observer) {
|
if (options.observer) {
|
||||||
options.observer.call(this, value, oldValue)
|
options.observer.call(this, value, oldValue)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
enumerable: false
|
|
||||||
}
|
}
|
||||||
this[key] = options.default
|
this[key] = options.default
|
||||||
}
|
}
|
||||||
|
@ -258,6 +251,7 @@ export class Component extends HTMLElement {
|
||||||
if (this.$animate) {
|
if (this.$animate) {
|
||||||
this.style.display = 'none'
|
this.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
this.removed = false
|
||||||
this.#init()
|
this.#init()
|
||||||
adoptStyles(this.root, this.constructor.styles)
|
adoptStyles(this.root, this.constructor.styles)
|
||||||
}
|
}
|
||||||
|
@ -275,9 +269,7 @@ export class Component extends HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (window.wkitd && this.$store) {
|
this.removed = true
|
||||||
window.wkitd.deassign(this)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nextTick(_ => this.unmounted())
|
nextTick(_ => this.unmounted())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue