"You can create a native DOM element by using the ",
el("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement",title:"MDN documentation for document.createElement()"}).append(
el("code","document.createElement()")
),". ",
"It is also possible to provide asome attribute(s) declaratively using ",el("code","Object.assign()"),". ",
"The ",el("code","assign")," function provides improved behaviour of ",el("code","Object.assign()"),". ",
"You can declaratively sets any IDL and attribute of the given element. ",
"Function prefers IDL and fallback to the ",el("code","element.setAttribute")," if there is no writable property in the element prototype."
),
el("p").append(
"You can study all JavaScript elements interfaces to the corresponding HTML elements. ",
"All HTML elements inherits from ",el("a",{textContent:"HTMLElement",href:"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement"}),". ",
"To see all available IDLs for example for paragraphs, see ",el("a",{textContent:"HTMLParagraphElement",href:"https://developer.mozilla.org/en-US/docs/Web/API/HTMLParagraphElement"}),". ",
"Moreover, the ",el("code","assign")," provides away to sets declaratively some convenient properties:"
),
el("ul").append(
el("li").append(
"It is possible to sets ",el("code","data-*"),"/",el("code","aria-*")," attributes using object notation."
),
el("li").append(
"In opposite, it is also possible to sets ",el("code","data-*"),"/",el("code","aria-*")," attribute using camelCase notation."
),
el("li").append(
"You can use string or object as avalue for ",el("code","style")," property."
),
el("li").append(
el("code","className")," (IDL – preffered)/",el("code","class")," are ways to add CSS class to the element. ",
"You can use string (similarly to ",el("code","class=\"…\"")," syntax in HTML) or array of strings. ",
"This is handy to concat conditional classes."
),
el("li").append(
"Use ",el("code","classList")," to toggle specific classes. This will be handy later when the reactivity via signals is beeing introduced.",
),
el("li").append(
"The ",el("code","assign")," also accepts the ",el("code","undefined")," as avalue for any property to remove it from the element declaratively. ",
"Also for some IDL the corresponding attribute is removed as it can be confusing. ",
el("em").append(
"For example, natievly the element’s ",el("code","id")," is removed by setting the IDL to an empty string."
)
)
),
el("p").append(
"For processing, the ",el("code","assign")," internally uses ",el("code","assignAttribute")," and ",el("code","classListDeclarative"),"."
"As you can see, in case of state-less/basic components there is no difference",
" between calling component function directly or using ",el("code","el")," function.",
),
el("p",{className:"notice"}).append(
"It is nice to use similar naming convention as native DOM API. ",
"This allows us to use ",el("a",{textContent:"the destructuring assignment syntax",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment",title:"Destructuring assignment | MDN"}),
" and keep track of the native API (things are best remembered through regular use).",
"Similarly to the native DOM API (",el("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS",title:"MDN"}).append(el("code","document.createElementNS")),") for non-HTML elements",
" we need to tell JavaScript which kind of the element to create.",