Adjust SuiWeb according to the standards
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
dedf7886e5
commit
8f488f48bd
|
@ -11,6 +11,9 @@ export class SuiWeb
|
|||
*
|
||||
* @param {HTMLElement} element
|
||||
* The element to add the rendered node to.
|
||||
*
|
||||
* @returns {Node}
|
||||
* The resulting element.
|
||||
*/
|
||||
static render(data, element)
|
||||
{
|
||||
|
@ -19,14 +22,33 @@ export class SuiWeb
|
|||
let descriptor = data[0];
|
||||
let args = data.slice(1);
|
||||
|
||||
if (typeof descriptor === "function" || typeof descriptor === "string")
|
||||
{
|
||||
/**
|
||||
* @type {HTMLElement}
|
||||
*/
|
||||
let result;
|
||||
|
||||
if (typeof descriptor === "function")
|
||||
{
|
||||
SuiWeb.render(descriptor(...args), element);
|
||||
}
|
||||
else if (typeof descriptor === "string")
|
||||
/**
|
||||
* @type {any[]}
|
||||
*/
|
||||
let arg = [];
|
||||
|
||||
if (typeof args[0] === "object" && !Array.isArray(args[0]))
|
||||
{
|
||||
let result = element.ownerDocument.createElement(descriptor);
|
||||
arg = [args[0]];
|
||||
args = args.slice(1);
|
||||
}
|
||||
|
||||
result = /** @type {HTMLElement} */ (SuiWeb.render(descriptor(...arg), element));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = element.ownerDocument.createElement(descriptor);
|
||||
element.appendChild(result);
|
||||
}
|
||||
|
||||
for (let arg of args)
|
||||
{
|
||||
|
@ -39,6 +61,8 @@ export class SuiWeb
|
|||
SuiWeb.render(arg, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -47,7 +71,7 @@ export class SuiWeb
|
|||
}
|
||||
else if (typeof data === "string")
|
||||
{
|
||||
element.appendChild(element.ownerDocument.createTextNode(data));
|
||||
return element.appendChild(element.ownerDocument.createTextNode(data));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue