props增加异常打印
parent
47090149f8
commit
bbe04eae83
|
@ -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",
|
||||
|
|
17
src/index.js
17
src/index.js
|
@ -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
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue