fix: 🐛 support register html render object
This commit is contained in:
@ -722,9 +722,13 @@ export class Hook extends Base implements Hook.IHook {
|
||||
|
||||
@Decorator.hook()
|
||||
shouldUpdateHTMLComponent(node: HTML): boolean {
|
||||
const html = node.getHTML()
|
||||
let html = node.getHTML()
|
||||
|
||||
if (html && typeof html === 'object') {
|
||||
if (typeof html === 'string') {
|
||||
html = HTML.componentRegistry.get(html) || html
|
||||
}
|
||||
|
||||
if (ObjectExt.isPlainObject(html)) {
|
||||
const shouldUpdate = (html as HTML.UpdatableComponent)
|
||||
.shouldComponentUpdate
|
||||
|
||||
|
@ -150,7 +150,9 @@ export namespace HTML {
|
||||
shouldComponentUpdate: boolean | ((this: Graph, node: HTML) => boolean)
|
||||
}
|
||||
|
||||
export const componentRegistry = Registry.create<Component>({
|
||||
export const componentRegistry = Registry.create<
|
||||
Component | UpdatableComponent
|
||||
>({
|
||||
type: 'html componnet',
|
||||
})
|
||||
}
|
||||
|
@ -34,12 +34,18 @@ const isNativeClass =
|
||||
* Extends class with specified class name.
|
||||
*/
|
||||
export function createClass<T>(className: string, base: Function): T {
|
||||
// tslint:disable-next-line
|
||||
let cls
|
||||
if (isNativeClass) {
|
||||
cls = new Function('base',`return class ${className} extends base { }`)(base)
|
||||
// tslint:disable-next-line
|
||||
cls = new Function('base', `return class ${className} extends base { }`)(
|
||||
base,
|
||||
)
|
||||
} else {
|
||||
cls = new Function('base',`return function ${className}() { return base.apply(this, arguments) }`)(base)
|
||||
// tslint:disable-next-line
|
||||
cls = new Function(
|
||||
'base',
|
||||
`return function ${className}() { return base.apply(this, arguments) }`,
|
||||
)(base)
|
||||
inherit(cls, base)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user