master
yutent 2024-04-03 12:18:35 +08:00
parent 9bea35996b
commit b0ad04f1f9
2 changed files with 38 additions and 9 deletions

View File

@ -9,6 +9,16 @@ import { $, uuid, h, preload, hyphen } from './utils.js'
import { Base } from './base-elem.js' import { Base } from './base-elem.js'
import { Orphan } from './orphan.js' import { Orphan } from './orphan.js'
class Defs extends Base {
constructor(el) {
super(el)
}
}
function createDefs(el) {
return new Defs(el, this)
}
export class Component extends Base { export class Component extends Base {
// #node // #node
// type // type
@ -41,6 +51,9 @@ export class Component extends Base {
#create(name, attr, child) { #create(name, attr, child) {
let node = h(name, attr, child) let node = h(name, attr, child)
this.node.appendChild(node) this.node.appendChild(node)
if (ORPHAN_TAGS[name]) {
return new Orphan(node)
}
return new Component(node) return new Component(node)
} }

View File

@ -10,23 +10,39 @@ import { uuid, h, preload } from './utils.js'
export class Orphan extends Base { export class Orphan extends Base {
id = null id = null
#animate
#animateMotion
#animateTransform
constructor(el) { constructor(el) {
super(el) super(el)
this.id = uuid(this.type) this.id = uuid(this.type)
} }
animate() { #create(name, attr) {
// let node = h(name, attr)
return this this.node.appendChild(node)
return new base(node)
} }
animateMotion() { animate(props = null) {
// if (!this.#animate) {
return this this.#animate = this.#create('animate', props)
}
return this.#animate
} }
animateTransform() { animateMotion(props = null) {
// if (!this.#animateMotion) {
return this this.#animateMotion = this.#create('animateMotion', props)
}
return this.#animateMotion
}
animateTransform(props = null) {
if (!this.#animateTransform) {
this.#animateTransform = this.#create('animateTransform', props)
}
return this.#animateTransform
} }
} }