Fix Tag
This commit is contained in:
26
sigpro2.js
26
sigpro2.js
@@ -210,18 +210,24 @@ const Tag = (tag, props = {}, children = []) => {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
effect()
|
effect()
|
||||||
ctx._mounts = effect._mounts || []
|
|
||||||
ctx._cleanups = effect._cleanups || new Set()
|
|
||||||
const result = effect._result
|
const result = effect._result
|
||||||
const attachLifecycle = node => node && typeof node === 'object' && !node._isRuntime && (
|
|
||||||
node._mounts = ctx._mounts,
|
|
||||||
node._cleanups = ctx._cleanups,
|
|
||||||
node._ownerEffect = effect
|
|
||||||
)
|
|
||||||
isArr(result) ? result.forEach(attachLifecycle) : attachLifecycle(result)
|
|
||||||
if (result == null) return null
|
if (result == null) return null
|
||||||
if (result instanceof Node || (isArr(result) && result.every(n => n instanceof Node))) return result
|
|
||||||
return doc.createTextNode(String(result))
|
const node = (result instanceof Node || (isArr(result) && result.every(n => n instanceof Node)))
|
||||||
|
? result
|
||||||
|
: doc.createTextNode(String(result))
|
||||||
|
|
||||||
|
const attach = n => {
|
||||||
|
if (isObj(n) && !n._isRuntime) {
|
||||||
|
n._mounts = effect._mounts || []
|
||||||
|
n._cleanups = effect._cleanups || new Set()
|
||||||
|
n._ownerEffect = effect
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isArr(node) ? node.forEach(attach) : attach(node)
|
||||||
|
return node
|
||||||
}
|
}
|
||||||
const isSVG = /^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(tag)
|
const isSVG = /^(svg|path|circle|rect|line|polyline|polygon|g|defs|text|tspan|use)$/.test(tag)
|
||||||
const el = isSVG ? doc.createElementNS("http://www.w3.org/2000/svg", tag) : doc.createElement(tag)
|
const el = isSVG ? doc.createElementNS("http://www.w3.org/2000/svg", tag) : doc.createElement(tag)
|
||||||
|
|||||||
Reference in New Issue
Block a user