props增加异常打印

master
yutent 2023-11-23 17:42:00 +08:00
parent 47090149f8
commit bbe04eae83
2 changed files with 11 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{
"name": "wkit",
"version": "1.11.0",
"version": "1.11.1",
"type": "module",
"description": "A library for building fast, lightweight web components.",
"main": "dist/index.js",

View File

@ -31,6 +31,14 @@ export {
} from './utils.js'
export { html, raw, css, svg, bind, unbind, nextTick, fire, hyphen, camelize }
function safely(callback, ...args) {
try {
callback && callback.apply(this, args)
} catch (err) {
console.error(err)
}
}
// 简单的类名解析
export function classMap(data = {}) {
let output = ''
@ -196,9 +204,7 @@ export class Component extends HTMLElement {
}
this[key] = value
this.$requestUpdate(name)
if (options.observer) {
options.observer.call(this, value, oldValue)
}
safely.call(this, options.observer, value, oldValue)
}
}
this[key] = options.default
@ -225,10 +231,7 @@ export class Component extends HTMLElement {
Reflect.set(target, prop, value, receiver)
this.$requestUpdate(key)
if (options.observer) {
options.observer.call(this, value, oldValue)
}
safely.call(this, options.observer, value, oldValue)
return true
}
})