2
0
mirror of https://github.com/esiur/iui.git synced 2025-12-16 19:40:24 +00:00
Files
iui/src/Data/Field.js
2021-02-22 11:39:50 +03:00

62 lines
1.5 KiB
JavaScript

import IUIElement from "../Core/IUIElement.js";
import { IUI } from "../Core/IUI.js";
export default IUI.module(class Field extends HTMLElement
{
constructor()
{
super();
}
static get moduleName(){
return this.name.toLowerCase();
}
create()
{
// if (this.formatter === undefined) {
// // load script
// for (var i = 0; i < this.children.length; i++)
// if (this.children[i] instanceof HTMLScriptElement) {
// //this.formatter = new Function this.children[i].
// }
// }
//this.style.display = "none";
}
get name() {
return this.getAttribute("name");
}
set name(value) {
this.setAttribute("name", value);
}
serialize(tag) {
let template = document.createElement("template");
let node = document.createElement(tag ?? "div");
let width = null, name = null, type = null;
// copy attributes
for (var i = 0; i < this.attributes.length; i++) {
let attr = this.attributes[i];
if (attr.name == "width")
width = attr.value;
else if (attr.name == "name")
name = attr.value;
else if (attr.name == "type")
type = attr.value;
else
node.setAttribute(attr.name, attr.value);
}
// copy html
node.innerHTML = this.innerHTML;
return { node, width, name, type };
}
});